int MBSObjectFactory::AddGeomElement(int objectTypeId) { // the order of this list MUST coincide with the order in MBSObjectFactory() switch(objectTypeId) //element type { case 1: //GeomMesh3D { GeomMesh3D ge(GetMBS(), 0, defaultbodycol); return GetMBS()->Add(ge); } case 2: //GeomCyl3D { GeomZyl3D ge(GetMBS(), Vector3D(0.,0.,0.), Vector3D(0.,0.,0.), 0, defaultgeomtile, defaultbodycol); return GetMBS()->Add(ge); } case 3: //GeomSphere3D { GeomSphere3D ge(GetMBS(), 0, Vector3D(0.,0.,0.), 0, defaultgeomtile, defaultbodycol); ge.SetDrawParam(Vector3D(0.001,16,0.)); return GetMBS()->Add(ge); } case 4: //GeomCube3D { GeomCube3D ge(GetMBS(), Vector3D(0.,0.,0.), Vector3D(1.,1.,1.), defaultbodycol); return GetMBS()->Add(ge); } case 5: //GeomOrthoCube3D { GeomOrthoCube3D ge(GetMBS(), Vector3D(0.,0.,0.), Vector3D(1.,1.,1.), Matrix3D(1.), defaultbodycol); return GetMBS()->Add(ge); } } assert(0); return -1; }
EWaving::EWaving( lua_State *L, int idx ) { InitFastCos(); u_wind = 0; time = 0; #ifdef USE_SS_GRID //sea_mesh = ge()->LoadMeshFromFile("sea.esx|sea_ss"); sea_mesh = ge()->CreatePlane( 2, 2, 40, 80 ); EShadingGroup sg; sg.start = 0; sg.num = sea_mesh->GetTriangleNum(); sg.shader = "textures/water.tga"; sea_mesh->ComputeTangents(); sea_mesh->SetSGNum(1); sea_mesh->SetSG(0, sg); #else sea_mesh = ge()->LoadMeshFromFile("sea.esx|sea"); #endif sky_mesh = ge()->LoadMeshFromFile("sky.esx|sky"); r_ent = sci_vis->GetFRScene()->AddEntity(); r_ent->SetMesh( sea_mesh ); r_sky = sci_vis->GetFRScene()->AddEntity(); r_sky->SetMesh( sky_mesh ); //r_sky->SetFlag( RSE_HIDDEN ); InitWaving(true); }
/** * A bunch of cases in which a geo expression is equivalent() to both itself or to another * expression. */ TEST(ExpressionGeoTest, GeoEquivalent) { { BSONObj query = fromjson("{$within: {$box: [{x: 4, y: 4}, [6, 6]]}}"); std::unique_ptr<GeoMatchExpression> ge(makeGeoMatchExpression(query)); ASSERT(ge->equivalent(ge.get())); } { BSONObj query = fromjson( "{$within: {$geometry: {type: 'Polygon'," "coordinates: [[[0, 0], [3, 6], [6, 1], [0, 0]]]}}}"); std::unique_ptr<GeoMatchExpression> ge(makeGeoMatchExpression(query)); ASSERT(ge->equivalent(ge.get())); } { BSONObj query1 = fromjson( "{$within: {$geometry: {type: 'Polygon'," "coordinates: [[[0, 0], [3, 6], [6, 1], [0, 0]]]}}}"), query2 = fromjson( "{$within: {$geometry: {type: 'Polygon'," "coordinates: [[[0, 0], [3, 6], [6, 1], [0, 0]]]}}}"); std::unique_ptr<GeoMatchExpression> ge1(makeGeoMatchExpression(query1)), ge2(makeGeoMatchExpression(query2)); ASSERT(ge1->equivalent(ge2.get())); } }
TEST( hokuyo_packed, scip_ge_response ) { hok::request_gd ge( true ); ge.header.start_step = 0; ge.header.end_step = 10; ge.message_id.seq_num = 1111; // const char* request = "GE0000001000;GE00001111"; const char* reply = "GE0000001000;GE00001111\n" "00P\n" "`mK3;\n" "0NC0<O0Mg0<Y0Je0<d0I[0<I0I90;00H]0:P0HD0:30H109l0H50;F0H40;X0Gj0^\n" ":cM\n\n"; EXPECT_TRUE( hok::verify_checksum( std::string( "`mK3;" ) ) ); EXPECT_TRUE( hok::verify_checksum( std::string( "0NC0<O0Mg0<Y0Je0<d0I[0<I0I90;00H]0:P0HD0:30H109l0H50;F0H40;X0Gj0^" ) ) ); EXPECT_TRUE( hok::verify_checksum( std::string( ":cM" ) ) ); boost::asio::streambuf buf; std::ostream oss( &buf ); oss << reply; std::istream iss( &buf ); hok::reply_ge< 11 > ge_reply; EXPECT_TRUE( hok::read( ge_reply, iss ) == 0 ); // const hok::reply_ge< 11 >* ge_reply = reinterpret_cast< const hok::reply_ge< 11 >* >( reply ); EXPECT_EQ( "00P", std::string( ge_reply.header.status.data(), hok::status_t::size ) ); EXPECT_EQ( 0, ge_reply.header.status() ); typedef hok::di_data< 11 > data_t; data_t::rays rays; ge_reply.encoded.get_values( rays ); }
static inline A0_n kernel_atan(const A0_n a0_n) { typedef typename meta::scalar_of<A0>::type sA0; const A0 tan3pio8 = double_constant<A0, 0x4003504f333f9de6ll>(); const A0 tanpio8 = double_constant<A0, 0x3fda827999fcef31ll>(); const A0 a0 = {a0_n}; const A0 x = nt2::abs(a0); const bA0 flag1 = lt(x, tan3pio8); const bA0 flag2 = logical_and(ge(x, tanpio8), flag1); A0 yy = if_zero_else(flag1, Pio_2<A0>()); yy = select(flag2, Pio_4<A0>(), yy); A0 xx = select(flag1, x, -rec(x)); xx = select(flag2, minusone(x)/oneplus(x),xx); A0 z = sqr(xx); z = z*horner< NT2_HORNER_COEFF_T(sA0, 5, (0xbfec007fa1f72594ll, 0xc03028545b6b807all, 0xc052c08c36880273ll, 0xc05eb8bf2d05ba25ll, 0xc0503669fd28ec8ell) )>(z)/ horner< NT2_HORNER_COEFF_T(sA0, 6, (0x3ff0000000000000ll, 0x4038dbc45b14603cll, 0x4064a0dd43b8fa25ll, 0x407b0e18d2e2be3bll, 0x407e563f13b049eall, 0x4068519efbbd62ecll) )>(z); z = fma(xx, z, xx); const A0 morebits = double_constant<A0, 0x3c91a62633145c07ll>(); z = seladd(flag2, z, mul(Half<A0>(), morebits)); z = z+if_zero_else(flag1, morebits); return yy + z; }
static void checkTypeSyntax(Val form, int iMin, int iMax, char* szSyntax) { Val n = safe_list_length(form); if (nil == n) error("Malformed type specifier: ~S", form); if (ge(n, iMin) && le(n, iMax)) return; error("Expect ~S: ~S", make_string(szSyntax), form); } // checkTypeSyntax
template<class T0,class T1, class T2> BOOST_FORCEINLINE result_type eval_at(const T0& a0,const T1& a1,const T2& a2) const { return l_and( ge( a0, splat<base_t>(a2)) , lt( a0, splat<base_t>(a2+a1)) ); }
static void modmult(Bignum r1, Bignum r2, Bignum modulus, Bignum result) { Bignum temp = newbn(modulus[0]+1); Bignum tmp2 = newbn(modulus[0]+1); int i; int bit, bits, digit, smallbit; enter((">modmult\n")); debug(r1); debug(r2); debug(modulus); for (i=1; i<=result[0]; i++) result[i] = 0; /* result := 0 */ for (i=1; i<=temp[0]; i++) temp[i] = (i > r2[0] ? 0 : r2[i]); /* temp := r2 */ bits = 1+msb(r1); for (bit = 0; bit < bits; bit++) { digit = 1 + bit / 16; smallbit = bit % 16; debug(temp); if (digit <= r1[0] && (r1[digit] & (1<<smallbit))) { dmsg(("bit %d\n", bit)); add(temp, result, tmp2); if (ge(tmp2, modulus)) sub(tmp2, modulus, result); else add(tmp2, Zero, result); debug(result); } add(temp, temp, tmp2); if (ge(tmp2, modulus)) sub(tmp2, modulus, temp); else add(tmp2, Zero, temp); } freebn(temp); freebn(tmp2); debug(result); leave(("<modmult\n")); }
/** * Check if val1 < val2 * * @param val1 SensorReading * @param val2 SensorReading * * @return false also in error case **/ bool NewSimulatorSensor::lt(const SaHpiSensorReadingT &val1, const SaHpiSensorReadingT &val2) { if (val1.Type != val2.Type) { err("Different sensor reading types in comparision."); return false; } return ( ! ge( val1, val2 ) ) ; }
void main() { //* Set initial guess and parameters int iStep, nStep = 10; // Number of iterations before stopping int nVars = 3, nParams = 3; // Number of variables and parameters Matrix x(nVars), xp(nVars,nStep+1); cout << "Enter the initial guess: " << endl; int i,j; for( i=1; i<=nVars; i++ ) { cout << " x(" << i << ") = "; cin >> x(i); xp(i,1) = x(i); // Record initial guess for plotting } Matrix a(nParams); cout << "Enter the parameters: " << endl; for( i=1; i<=nParams; i++ ) { cout << "a(" << i << ") = "; cin >> a(i); } //* Loop over desired number of steps Matrix f(nVars), D(nVars,nVars), dx(nVars); for( iStep=1; iStep<=nStep; iStep++ ) { //* Evaluate function f and its Jacobian matrix D fnewt(x,a,f,D); // fnewt returns value of f and D for( i=1; i<=nVars; i++ ) for( j=i+1; j<=nVars; j++ ) { double temp = D(i,j); D(i,j) = D(j,i); // Transpose of matrix D D(j,i) = temp; } //* Find dx by Gaussian elimination ge(D,f,dx); //* Update the estimate for the root for( i=1; i<=nVars; i++ ) { x(i) -= dx(i); // Newton iteration for new x xp(i,iStep+1) = x(i); // Save current estimate for plotting } } //* Print the final estimate for the root cout << "After " << nStep << " iterations the root is:" << endl; for( i=1; i<=nVars; i++ ) cout << "x(" << i << ") = " << x(i) << endl; //* Print out the plotting variable: xp ofstream xpOut("xp.txt"); for( i=1; i<=nVars; i++ ) { for( int j=1; j<=nStep; j++ ) xpOut << xp(i,j) << ", "; xpOut << xp(i,nStep+1) << endl; } }
TEST( hokuyo_packed, requests ) { hok::header header; hok::sequence_string msg_id; hok::request_gd gd; hok::request_gd ge( true ); hok::request_md md; hok::request_md me( true ); hok::reply_gd< 1080 > gd_data; hok::reply_ge< 1080 > ge_data; hok::reply_md md_response; hok::reply_md_data< 1080 > md_data; hok::reply_me_data< 1080 > me_data; gd.header.start_step = 0; gd.header.end_step = 100; gd.message_id.seq_num = 999; const std::string gd_request( "GD0000010000;GD00000999\n" ); std::string result( gd.data(), hok::request_gd::size ); EXPECT_EQ( gd_request, result ); const std::string ge_request( "GE0000108000;GE00001111\n" ); ge.header.start_step = 0; ge.header.end_step = 1080; ge.message_id.seq_num = 1111; result = std::string( ge.data(), hok::request_gd::size ); EXPECT_EQ( ge_request, result ); md.header.start_step = 5; md.header.end_step = 10; md.num_of_scans = 2; // two scans only md.message_id.seq_num = 222; result = std::string( md.data(), hok::request_md::size ); EXPECT_EQ( "MD0005001000002;MD00000222\n", result ); me.header.start_step = 5; me.header.end_step = 10; me.num_of_scans = 2; // two scans only me.message_id.seq_num = 222; result = std::string( me.data(), hok::request_md::size ); EXPECT_EQ( "ME0005001000002;ME00000222\n", result ); md_response.request = md; md_response.status.sum = 'P'; result = std::string( md_response.data(), hok::reply_md::size ); EXPECT_EQ( "MD0005001000002;MD00000222\n00P\n\n", result ); }
transform_list_ptr parse_transform(std::string const& str, std::string const& encoding) { transform_list_ptr tl = boost::make_shared<transform_list>(); transcoder tc(encoding); expression_grammar<std::string::const_iterator> ge(tc); transform_expression_grammar__string gte(ge); if (!parse_transform(*tl, str, gte)) { tl.reset(); } return tl; }
void TDynamicTextGadget::CommandEnable() { PRECONDITION(GetGadgetWindow()); // Must send, not post here, since a ptr to a temp is passed // // This might be called during idle processing before the // HWND has created. Therefore, confirm handle exists. // if (GetGadgetWindow()->GetHandle()){ TDynamicTextGadgetEnabler ge(*GetGadgetWindow(), this); GetGadgetWindow()->HandleMessage(WM_COMMAND_ENABLE,0,TParam2(&ge)); } }
TEST(ExpressionGeoTest, Geo1) { BSONObj query = fromjson("{loc:{$within:{$box:[{x: 4, y:4},[6,6]]}}}"); std::unique_ptr<GeoExpression> gq(new GeoExpression); ASSERT_OK(gq->parseFrom(query["loc"].Obj())); GeoMatchExpression ge("a", gq.release(), query); ASSERT(!ge.matchesBSON(fromjson("{a: [3,4]}"))); ASSERT(ge.matchesBSON(fromjson("{a: [4,4]}"))); ASSERT(ge.matchesBSON(fromjson("{a: [5,5]}"))); ASSERT(ge.matchesBSON(fromjson("{a: [5,5.1]}"))); ASSERT(ge.matchesBSON(fromjson("{a: {x: 5, y:5.1}}"))); }
int main() { Map map(20,10); GraphicEngine ge(map); if (!ge.initialize()) { std::cout << "Error : Can\'t initialize GraphicEngine." << std::endl; return (-1); } while (ge.update()) ge.draw(); return (0); }
int main (void) { gt (360.0); gt (-360.0); ge (360.0); ge (-360.0); lt (-360.0); lt (360.0); le (-360.0); le (360.0); eq (0.0); eq (360.0); ne (360.0); ne (0.0); return 0; }
/* reduction modulo 2^255-19 */ void fe25519_freeze(fe25519 *r) { int i; crypto_uint32 m = equal(r->v[31],127); for(i=30;i>0;i--) m &= equal(r->v[i],255); m &= ge(r->v[0],237); m = -m; r->v[31] -= m&127; for(i=30;i>0;i--) r->v[i] -= m&255; r->v[0] -= m&237; }
/// override close() to write EOF line virtual void close(void) throw(Exception) { try { // if writing, add the final line if(writingMode && !wroteEOF) { (*this) << "EOF\n"; wroteEOF = true; } FFTextStream::close(); } catch(std::exception& e) { Exception ge(e.what()); GPSTK_THROW(ge); } }
int main(int argc,char* argv[]) { try { GridEditor ge(argc,argv); ge.run(); } catch(std::runtime_error err) { std::cerr<<"Caught exception "<<err.what()<<std::endl; return 1; } return 0; }
static void test_maximize(opt::model_based_opt& mbo, ast_manager& m, unsigned num_vars, expr_ref_vector const& fmls, app* t) { qe::arith_project_plugin plugin(m); model mdl(m); arith_util a(m); for (unsigned i = 0; i < num_vars; ++i) { app_ref var(m); mk_var(i, var); rational val = mbo.get_value(i); mdl.register_decl(var->get_decl(), a.mk_numeral(val, false)); } expr_ref ge(m), gt(m); opt::inf_eps value1 = plugin.maximize(fmls, mdl, t, ge, gt); opt::inf_eps value2 = mbo.maximize(); std::cout << "optimal: " << value1 << " " << value2 << "\n"; mbo.display(std::cout); }
// 'a' void MyRandomUnitKeyHandler(unsigned long , tKeyboardModifier , char) { GraphMapInconsistentHeuristic diffHeuristic(mp, grp); diffHeuristic.SetPlacement(kAvoidPlacement); for (int x = 0; x < 1; x++) diffHeuristic.AddHeuristic(); diffHeuristic.SetNumUsedHeuristics(1); double sum = 0; uint64_t s1 = 0, s2 = 0, s3 = 0, s4 = 0; for (int x = 0; x < 100; x++) { graphState n1 = grp->GetRandomNode()->GetNum(); graphState n2 = grp->GetRandomNode()->GetNum(); double a, b; // diffHeuristic.SetMode(kIgnore); // printf("Max: %f\t", a = diffHeuristic.HCost(n1, n2)); // diffHeuristic.SetMode(kCompressed); // printf("Compressed: %f\t", b = diffHeuristic.HCost(n1, n2)); // printf("Error: %f\n", a-b); // assert(a >= b); // sum += a-b; // printf("Average error: %f\n", sum/(x+1)); GraphEnvironment ge(mp, grp, &diffHeuristic); ge.SetDirected(true); diffHeuristic.SetMode(kIgnore); vis1.GetPath(&ge, n1, n2, gPath); printf("%lld\t%1.1f\t", vis1.GetNodesExpanded(), ge.GetPathLength(gPath)); s1+=vis1.GetNodesExpanded(); diffHeuristic.SetMode(kCompressed); vis1.SetUseBPMX(1); vis1.GetPath(&ge, n1, n2, gPath); printf("%lld\t%1.1f\t", vis1.GetNodesExpanded(), ge.GetPathLength(gPath)); s2+=vis1.GetNodesExpanded(); vis1.SetUseBPMX(2); vis1.GetPath(&ge, n1, n2, gPath); printf("%lld\t%1.1f\t", vis1.GetNodesExpanded(), ge.GetPathLength(gPath)); s3+=vis1.GetNodesExpanded(); vis1.SetUseBPMX(3); vis1.GetPath(&ge, n1, n2, gPath); printf("%lld\t%1.1f\n", vis1.GetNodesExpanded(), ge.GetPathLength(gPath)); s4+=vis1.GetNodesExpanded(); } printf("%10lld %10lld %10lld %10lld\n", s1, s2, s3, s4); }
static inline AA0 other(const bAA0& test, const AA0& xx) { typedef typename meta::scalar_of<AA0>::type sA0; static boost::array<sA0, 7> P = {{ sA0(1.60119522476751861407E-4), sA0(1.19135147006586384913E-3), sA0(1.04213797561761569935E-2), sA0(4.76367800457137231464E-2), sA0(2.07448227648435975150E-1), sA0(4.94214826801497100753E-1), sA0(9.99999999999999996796E-1) }}; static boost::array<sA0, 8> Q = {{ sA0(-2.31581873324120129819E-5), sA0(5.39605580493303397842E-4), sA0(-4.45641913851797240494E-3), sA0(1.18139785222060435552E-2), sA0(3.58236398605498653373E-2), sA0(-2.34591795718243348568E-1), sA0(7.14304917030273074085E-2), sA0(1.00000000000000000320E0) }}; AA0 x = nt2::if_else(test, nt2::Five<A0>()/nt2::Two<A0>(), xx); AA0 z = nt2::One<A0>(); bAA0 test1; while( nt2::any(test1 = ge(x,Three<A0>())) ) { x = nt2::seladd(test1, x, nt2::Mone<A0>()); z = nt2::if_else( test1, z*x, z); } bAA0 test2; while( nt2::any(test2 = nt2::is_ltz(x)) ) { z = nt2::if_else( test2, z/x, z); x = nt2::seladd(test2, x, nt2::One<A0>()); } while( nt2::any(test1 =lt(x,nt2::Two<A0>())) ) { z = nt2::if_else( test1, z/x, z); x = nt2::seladd(test1, x, nt2::One<A0>()); } x -= nt2::Two<A0>(); AA0 p = nt2::polevl(x,P); AA0 q = nt2::polevl(x,Q); return z*p/q; }
int DataLoader::loadMarkerAsCovariate(const std::string& inVcf, const std::string& marker) { this->FLAG_inVcf = inVcf; this->FLAG_condition = marker; Matrix geno; VCFGenotypeExtractor ge(FLAG_inVcf); ge.excludeAllPeople(); ge.includePeople(phenotype.getRowName()); ge.setRangeList(marker); if (ge.extractMultipleGenotype(&geno) != GenotypeExtractor::SUCCEED) { logger->error("Load conditional markers [ %s ] from [ %s ] failed", FLAG_condition.c_str(), FLAG_inVcf.c_str()); exit(1); } std::vector<double> d(geno.rows); for (int i = 0; i < geno.cols; ++i) { for (int j = 0; j < geno.rows; ++j) { d[j] = geno[j][i]; } covariate.appendCol(d, geno.GetColumnLabel(i)); } // // load conditional markers // if (!FLAG_condition.empty()) { // Matrix geno; // std::vector<std::string> rowLabel; // if (loadMarkerFromVCF(FLAG_inVcf, FLAG_condition, &rowLabel, &geno) < 0) // { // logger->error("Load conditional markers [ %s ] from [ %s ] failed.", // FLAG_condition.c_str(), FLAG_inVcf.c_str()); // exit(1); // } // if (appendGenotype(&covariate, phenotypeNameInOrder, geno, rowLabel) < 0) // { // logger->error( // "Failed to combine conditional markers [ %s ] from [ %s ] failed.", // FLAG_condition.c_str(), FLAG_inVcf.c_str()); // exit(1); // } // } return 0; }
static inline A0_n kernel_atan(const A0_n a0_n) { const A0 a0 = {a0_n}; const A0 x = nt2::abs(a0); //here x is positive const bA0 flag1 = lt(x, single_constant<A0, 0x401a827a>()); //tan3pio8); const bA0 flag2 = logical_and(ge(x, single_constant<A0, 0x3ed413cd>()), flag1); A0 yy = if_zero_else(flag1, Pio_2<A0>()); yy = select(flag2, Pio_4<A0>(), yy); A0 xx = select(flag1, x, -rec(x)); xx = select(flag2, (minusone(x)/oneplus(x)),xx); const A0 z = sqr(xx); A0 z1 = madd(z, single_constant<A0, 0x3da4f0d1>(),single_constant<A0, 0xbe0e1b85>()); const A0 z2 = madd(z, single_constant<A0, 0x3e4c925f>(),single_constant<A0, 0xbeaaaa2a>()); z1 = madd(z1, sqr(z), z2); return add(yy, madd(xx, mul( z1, z), xx)); }
Z void dbg_callcb(C *s,I n,A arg1,A arg2,A arg3) { if(dbg_hold)R; dbg_hold=1; { A event=ge(MS(si(s))); callafunc(dbg_cbfunc,dbg_cbdata,event,n,arg1,arg2,arg3); dc(event); } /* if(1<=n)dc(arg1);if(2<=n)dc(arg2);if(3<=n)dc(arg3); */ if(n==1) dc(arg1); else if(n==2) dc(arg1),dc(arg2); else if(n==3) dc(arg1),dc(arg2),dc(arg3); dbg_hold=0; }
static inline A0 atan(const A0& a0) { A0 x, sign; x = nt2::abs(a0); sign = bitofsign(a0); // bf::tie(sign, x) = sign_and_abs(a0); const A0 flag1 = lt(x, single_constant<A0, 0x401a827a>()); //tan3pio8); const A0 flag2 = b_and(ge(x, single_constant<A0, 0x3ed413cd>()), flag1); A0 yy = b_notand(flag1, Pio_2<A0>()); yy = select(flag2, Pio_4<A0>(), yy); A0 xx = select(flag1, x, -rec(x)); xx = select(flag2, (minusone(x)/oneplus(x)),xx); const A0 z = sqr(xx); A0 z1 = madd(z, single_constant<A0, 0x3da4f0d1>(),single_constant<A0, 0xbe0e1b85>()); A0 z2 = madd(z, single_constant<A0, 0x3e4c925f>(),single_constant<A0, 0xbeaaaa2a>()); z1 = madd(z1, sqr(z), z2); yy = add(yy, madd(xx, mul( z1, z), xx)); return b_xor(yy, sign); }
double FindFarDist(Graph *g, node *n, graphState &from, graphState &to) { std::vector<graphState> endPath; GraphEnvironment ge(g); ge.SetDirected(true); // 2. search to depth d (all g-costs >= d) TemplateAStar<graphState, graphMove, GraphEnvironment> theSearch; theSearch.SetStopAfterGoal(false); theSearch.InitializeSearch(&ge, n->GetNum(), n->GetNum(), endPath); double gCost; graphState s; while (1) { if (theSearch.GetNumOpenItems() == 0) break; s = theSearch.CheckNextNode(); if (theSearch.DoSingleSearchStep(endPath)) break; theSearch.GetClosedListGCost(s, gCost); } theSearch.InitializeSearch(&ge, s, s, endPath); from = s; while (1) { if (theSearch.GetNumOpenItems() == 0) break; s = theSearch.CheckNextNode(); if (theSearch.DoSingleSearchStep(endPath)) break; to = s; double tmpCost; theSearch.GetClosedListGCost(s, tmpCost); if (tmpCost > gCost) gCost = tmpCost; } return gCost; }
void EstimateDimension(Map *m) { // Graph *g = GraphSearchConstants::GetGraph(m); // GraphEnvironment ge(g); // std::vector<graphState> endPath; // node *n = g->GetRandomNode(); Graph *g = GraphSearchConstants::GetGraph(m); GraphEnvironment ge(g); std::vector<graphState> endPath; // 1. choose a random point node *n = g->GetRandomNode(); // 2. search to depth d (all g-costs >= d) double limit = 0; TemplateAStar<graphState, graphMove, GraphEnvironment> theSearch; theSearch.SetStopAfterGoal(false); theSearch.InitializeSearch(&ge, n->GetNum(), n->GetNum(), endPath); while (1) { double gCost; graphState s = theSearch.CheckNextNode(); theSearch.GetClosedListGCost(s, gCost); //printf("Expanding g-cost %f next\n", gCost); if (gCost >= limit) { printf("%d\t%d\n", (int)limit, theSearch.GetNodesExpanded()); limit++; } if (theSearch.DoSingleSearchStep(endPath)) break; } graphState start = n->GetNum(); BFS<graphState, graphMove> b; b.GetPath(&ge, start, start, endPath); }
int main( int /*argc*/, char** /*args[]*/ ) { #if _DEBUG && !GCC _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); //_CrtSetBreakAlloc(2988); #endif he::HappyEngine::init(he::SubEngine_All); CONTENT->setContentDir(he::Path("../../data")); he::ge::Game* ge(NEW(ht::MainGame)()); HAPPYENGINE->start(ge); HEDelete(ge); he::HappyEngine::dispose(); he_checkmem(); std::cout << "\npress enter to quit\n"; std::cin.get(); return 0; }
static inline A0 atan(const A0& a0) { typedef typename meta::scalar_of<A0>::type sA0; static const A0 tan3pio8 = double_constant<A0, 0x4003504f333f9de6ll>(); static const A0 Twothird = double_constant<A0, 0x3fe51eb851eb851fll>(); static const A0 tanpio8 = double_constant<A0, 0x3fda827999fcef31ll>(); A0 x = abs(a0); const A0 flag1 = lt(x, double_constant<A0, 0x4003504f333f9de6ll>()); //tan3pio8 const A0 flag2 = b_and(ge(x, double_constant<A0, 0x3fda827999fcef31ll>()), flag1); //tanpio8 A0 yy = b_notand(flag1, Pio_2<A0>()); yy = select(flag2, Pio_4<A0>(), yy); A0 xx = select(flag1, x, -rec(x)); xx = select(flag2, minusone(x)/oneplus(x),xx); A0 z = sqr(xx); z = z*horner< NT2_HORNER_COEFF_T(sA0, 5, (0xbfec007fa1f72594ll, 0xc03028545b6b807all, 0xc052c08c36880273ll, 0xc05eb8bf2d05ba25ll, 0xc0503669fd28ec8ell) )>(z)/ horner< NT2_HORNER_COEFF_T(sA0, 6, (0x3ff0000000000000ll, 0x4038dbc45b14603cll, 0x4064a0dd43b8fa25ll, 0x407b0e18d2e2be3bll, 0x407e563f13b049eall, 0x4068519efbbd62ecll) )>(z); z = fma(xx, z, xx); // static const A0 morebits = double_constant<A0, 0x3c91a62633145c07ll>(); z = seladd(flag2, z, mul(Half<A0>(), double_constant<A0, 0x3c91a62633145c07ll>())); z = z+b_notand(flag1, double_constant<A0, 0x3c91a62633145c07ll>()); yy = yy + z; return b_xor(yy, bitofsign(a0)); }