GT PFC::multi_miller(int n,G1** QQ,G1** PP) { GT z; ZZn *Px,*Py; int i,j,*k,nb; ECn *Q,*A; ECn P; ZZn2 res; Big iters=*ord-1; Px=new ZZn[n]; Py=new ZZn[n]; Q=new ECn[n]; A=new ECn[n]; k=new int[n]; nb=bits(iters); res=1; for (j=0;j<n;j++) { k[j]=0; P=PP[j]->g; normalise(P); Q[j]=QQ[j]->g; normalise(Q[j]); extract(P,Px[j],Py[j]); } for (j=0;j<n;j++) A[j]=Q[j]; for (i=nb-2;i>=0;i--) { res*=res; for (j=0;j<n;j++) { if (QQ[j]->ptable==NULL) res*=g(A[j],A[j],Px[j],Py[j]); else res*=gp(QQ[j]->ptable,k[j],Px[j],Py[j]); } if (bit(iters,i)==1) for (j=0;j<n;j++) { if (QQ[j]->ptable==NULL) res*=g(A[j],Q[j],Px[j],Py[j]); else res*=gp(QQ[j]->ptable,k[j],Px[j],Py[j]); } if (res.iszero()) return 0; } delete [] k; delete [] A; delete [] Q; delete [] Py; delete [] Px; z.g=res; return z; }
void gp(int l, int r, int n, string str, vector<string>& res){ if (l>n) return; // IMPORTANT! if ( r==n ) res.push_back(str); // IMPORTANT! else{ gp(l+1,r,n,str+'(',res); if(l>r){ // IMPORTANT! gp(l,r+1,n,str+')',res); } } }
int EuclidDistHeuristic::GetFromToHeuristic(int from_id, int to_id) { if (m_pose_ext) { if (from_id == planningSpace()->getGoalStateID()) { auto& gp = planningSpace()->goal().pose; Affine3 p; if (!m_pose_ext->projectToPose(to_id, p)) { return 0; } return (int)(FIXED_POINT_RATIO * computeDistance(gp, p)); } else if (to_id == planningSpace()->getGoalStateID()) { auto& gp = planningSpace()->goal().pose; Affine3 p; if (!m_pose_ext->projectToPose(from_id, p)) { return 0; } return (int)(FIXED_POINT_RATIO * computeDistance(p, gp)); } else { Affine3 a, b; if (!m_pose_ext->projectToPose(from_id, a) || !m_pose_ext->projectToPose(to_id, b)) { return 0; } return (int)(FIXED_POINT_RATIO * computeDistance(a, b)); } } else if (m_point_ext) { if (from_id == planningSpace()->getGoalStateID()) { Vector3 gp(planningSpace()->goal().pose.translation()); Vector3 p; if (!m_pose_ext->projectToPoint(to_id, p)) { return 0; } return (int)(FIXED_POINT_RATIO * computeDistance(gp, p)); } else if (to_id == planningSpace()->getGoalStateID()) { Vector3 gp(planningSpace()->goal().pose.translation()); Vector3 p; if (!m_pose_ext->projectToPoint(from_id, p)) { return 0; } return (int)(FIXED_POINT_RATIO * computeDistance(p, gp)); } else { Vector3 a, b; if (!m_pose_ext->projectToPoint(from_id, a) || !m_pose_ext->projectToPoint(to_id, b)) { return 0; } return (int)(FIXED_POINT_RATIO * computeDistance(a, b)); } } else { return 0; } }
GT PFC::miller_loop(const G2& QQ,const G1& PP) { GT z; Big n; int i,j,nb,nbw,nzs; ECn2 A,KA,Q; ECn P; ZZn Px,Py; BOOL precomp; ZZn12 r; Big X=*x; Q=QQ.g; P=PP.g; precomp=FALSE; if (QQ.ptable!=NULL) precomp=TRUE; else Q.norm(); normalise(P); extract(P,Px,Py); if (X<0) n=-(6*X+2); else n=6*X+2; A=Q; nb=bits(n); r=1; // Short Miller loop r.mark_as_miller(); j=0; for (i=nb-2;i>=0;i--) { r*=r; if (precomp) r*=gp(QQ.ptable,j,Px,Py); else r*=g(A,A,Px,Py); if (bit(n,i)) { if (precomp) r*=gp(QQ.ptable,j,Px,Py); else r*=g(A,Q,Px,Py); } } // Combining ideas due to Longa, Aranha et al. and Naehrig KA=Q; q_power_frobenius(KA,*frob); if (X<0) {A=-A; r.conj();} if (precomp) r*=gp(QQ.ptable,j,Px,Py); else r*=g(A,KA,Px,Py); q_power_frobenius(KA,*frob); KA=-KA; if (precomp) r*=gp(QQ.ptable,j,Px,Py); else r*=g(A,KA,Px,Py); z.g=r; return z; }
int main(int argc, char **argv){ int nodeAmts[3] = {inputs,hiddens,outputs}; int L1[inputs][hiddens]; // Weights int L2[hiddens][outputs]; //Weights int i,j; for(j=0;j<hiddens;j++){ for(i=0;i<inputs;i++){ L1[i][j] = rand(); } for(k=0;k<outputs;k++){ L2[j][k] = rand(); } } for(e=0;e<length(examples);e++){ for(i=0;i<length(x);i++){ node[0][i]->activation = x[i]; } for(l=1;l<3;l++){ for(j=0;j<nodeAmts[l];j++){ node[l][j]->in = 0; for(i=0;i<nodeAmts[l-1];i++){ node[l][j]->in += L[i][j]*node[l-1][i]->activation; } node[l][j]->activation = g(in); } } for(j=0;j<nodeAmts[2];j++){ node[2][j]->delta = gp(node[2][j]->in)*y[j]-node[2][j]->activation; } for(l=1;l>0;l--){ for(i=0;i<nodeAmts[l];i++){ delta = 0; for(j=0;j<nodeAmts[l+1];j++){ delta += L[i][j] * node[l+1][j]->delta; } node[l][i]->delta = gp(node[2][j]->in)*delta; } } for(j=0;j<hiddens;j++){ for(i=0;i<inputs;i++){ L1[i][j] += alpha * node[0][i]->activation * node[1][i]->delta; } for(k=0;k<outputs;k++){ L2[j][k] += alpha * node[1][j]->activation * node[2][k]->delta; } } } }
static const kul::SCM* GET_SCM(const kul::Dir& d, const std::string& r){ std::vector<std::string> repos; if(IS_SOLID(r)) repos.push_back(r); else for(const std::string& s : Settings::INSTANCE().remoteRepos()) repos.push_back(s + r); for(const auto& repo : repos){ try{ kul::Process g("git"); kul::ProcessCapture gp(g); std::string r1(repo); if(repo.find("http") != std::string::npos && repo.find("@") == std::string::npos) r1 = repo.substr(0, repo.find("//") + 2) + "u:p@" + repo.substr(repo.find("//") + 2); g.arg("ls-remote").arg(r1).start(); if(!gp.errs().size()) { INSTANCE().valids.insert(d.path(), repo); return &kul::scm::Manager::INSTANCE().get("git"); } }catch(const kul::proc::ExitException& e){} try{ kul::Process s("svn"); kul::ProcessCapture sp(s); s.arg("ls").arg(repo).start(); if(!sp.errs().size()) { INSTANCE().valids.insert(d.path(), repo); return &kul::scm::Manager::INSTANCE().get("svn"); } }catch(const kul::proc::ExitException& e){} } std::stringstream ss; for(const auto& s : repos) ss << s << "\n"; KEXCEPT(Exception, "SCM not found or not supported type(git/svn) for repo(s)\n"+ss.str()+"project:"+d.path()); }
inline bool app_init_config() { #ifdef _WIN32 std::string global_config_file = "gsmartcontrol.conf"; // installation dir s_home_config_file = hz::get_home_dir() + hz::DIR_SEPARATOR_S + "gsmartcontrol.conf"; // $HOME/program_name.conf #else std::string global_config_file = std::string(PACKAGE_SYSCONF_DIR) + hz::DIR_SEPARATOR_S + "gsmartcontrol.conf"; s_home_config_file = hz::get_home_dir() + hz::DIR_SEPARATOR_S + ".gsmartcontrolrc"; #endif hz::FsPath gp(global_config_file); // Default system-wide settings. This file is empty by default. hz::FsPath hp(s_home_config_file); // Per-user settings. if (gp.exists() && gp.is_readable()) rconfig::load_from_file(gp.str()); if (hp.exists() && hp.is_readable()) rconfig::load_from_file(hp.str()); rconfig::dump_tree(); init_default_settings(); // initialize /default #ifdef ENABLE_GLIB rconfig::autosave_set_config_file(s_home_config_file); uint32_t autosave_timeout = rconfig::get_data<uint32_t>("system/config_autosave_timeout"); if (autosave_timeout) rconfig::autosave_start(autosave_timeout); #endif return true; }
vector<string> generateParenthesis(int n) { vector<string> res; if(n==0) return res; gp(0,0,n,"",res); }
int main(int argc, char** argv) { if (argc > 1 && strncmp(argv[1], "-l", 2) == 0) loopcount = atoi(argv[1] + 2); HeapPool sp(pageSize, pageBits); sp.setInitPages(7); sp.setMaxPages(7); if (! sp.allocMemory()) assert(false); GroupPool gp(sp); Uint16 s = (Uint16)getpid(); srandom(s); ndbout << "rand " << s << endl; int count; count = 0; while (++count <= 0) { // change to 1 to find new bug sp_test<T1>(gp); sp_test<T2>(gp); sp_test<T3>(gp); sp_test<T4>(gp); sp_test<T5>(gp); } count = 0; while (++count <= 1) { lp_test<T3>(gp); } return 0; }
CRhinoCommand::result CCommandSampleMoveCPlane::RunCommand( const CRhinoCommandContext& context ) { CRhinoView* view = ::RhinoApp().ActiveView(); if( !view ) return CRhinoCommand::failure; ON_3dmConstructionPlane cplane = view->Viewport().ConstructionPlane(); ON_3dPoint origin = cplane.m_plane.origin; CSampleMoveCPlanePoint gp( cplane ); gp.SetCommandPrompt( L"CPlane origin" ); gp.SetBasePoint( origin ); gp.DrawLineFromPoint( origin, TRUE ); gp.GetPoint(); if( gp.CommandResult() != CRhinoCommand::success ) return gp.CommandResult(); ON_3dPoint pt = gp.Point(); ON_3dVector v = origin - pt; if( v.IsTiny() ) return CRhinoCommand::nothing; cplane.m_plane.CreateFromFrame( pt, cplane.m_plane.xaxis, cplane.m_plane.yaxis ); view->Viewport().SetConstructionPlane( cplane ); view->Redraw(); return CRhinoCommand::success; }
void gen_PROGRAM ( node_t *root, int scopedepth) { /* Output the data segment */ if( outputStage == 12 ) strings_output ( stderr ); instruction_add ( STRING, STRDUP( ".text" ), NULL, 0, 0 ); tracePrint("Starting PROGRAM\n"); gen_default(root, scopedepth);//RECUR(); TEXT_DEBUG_FUNC_ARM(); TEXT_HEAD_ARM(); gp(root,scopedepth); tracePrint("End PROGRAM\n"); TEXT_TAIL_ARM(); if( outputStage == 12 ) instructions_print ( stderr ); instructions_finalize (); }
dynent *newdynent() // create a new blank player or monster { dynent *d = (dynent *)gp()->alloc(sizeof(dynent)); d->o.x = 0; d->o.y = 0; d->o.z = 0; d->yaw = 270; d->pitch = 0; d->roll = 0; d->maxspeed = 22; d->outsidemap = false; d->inwater = false; d->radius = 1.1f; d->eyeheight = 3.2f; d->aboveeye = 0.7f; d->frags = 0; d->plag = 0; d->ping = 0; d->lastupdate = lastmillis; d->enemy = NULL; d->monsterstate = 0; d->name[0] = d->team[0] = 0; d->blocked = false; d->lifesequence = 0; d->state = CS_ALIVE; spawnstate(d); return d; };
bool wxGenericPen::IsSameAs(const wxPen &pen) const { wxCHECK_MSG(Ok() && pen.Ok(), false, wxT("Invalid generic pen")); wxGenericPen gp(pen); gp.GetGenericColour().SetAlpha(M_GPENDATA->m_colour.GetAlpha()); return IsSameAs(gp); }
int main() { testSequence2(); return 0; testSequenceCMAES(); return 0; testSequence(); return 0; testLogs(); return 0; //Plot real target function Leph::Plot plot; for (double x=0.0;x<=1.0;x+=0.03) { for (double y=0.0;y<=1.0;y+=0.03) { plot.add(Leph::VectorLabel( "x", x, "y", y, "real", function(x, y))); } } //Initialize Gaussian Process libgp::GaussianProcess gp(2, "CovSum ( CovSEiso, CovNoise)"); //Adding noised data point to model for (size_t k=0;k<100;k++) { double x = 0.5*uniform(generator) + 0.5; double y = 0.5*uniform(generator) + 0.5; double f = function(x, y) + noise(1.0); plot.add(Leph::VectorLabel( "x", x, "y", y, "target", f)); double input[] = {x, y}; gp.add_pattern(input, f); } //Optimize hyper parameter libgp::RProp rprop; rprop.init(); rprop.maximize(&gp, 50, true); //Predict fitted model for (double x=0.0;x<=1.0;x+=0.04) { for (double y=0.0;y<=1.0;y+=0.04) { double input[] = {x, y}; plot.add(Leph::VectorLabel( "x", x, "y", y, "fitted", gp.f(input))); } } //Display plot plot.plot("x", "y", "all").render(); return 0; }
int main(int argc, char** argv){ int opt; int r; AST_Class modelica_class; while((opt = getopt(argc, argv, "d:")) != -1){ switch(opt){ case 'd': if(optarg != NULL && isDebugParam(optarg)){ debugInit(optarg); }else{ ERROR("Command line option d requires an argument\n"); } break; } } if(optind < argc){ modelica_class = parseClass(argv[optind],&r); }else{ /* si no se especifico un archivo leo de stdin*/ modelica_class = parseClass("", &r); } if(r!=0){ return -1; } /* creamos la clase MicroModelica */ TypeSymbolTable ty = newTypeSymbolTable(); MMO_Class mmo_class = newMMO_Class(modelica_class, ty); ReducedGraphBuilder *gb = new ReducedGraphBuilder(mmo_class); CausalizationGraph g = gb->makeGraph(); //para debuggeo: crea archivo grafo.dot if(debugIsEnabled('g')){ GraphPrinter gp(g); gp.printGraph(); } CausalizationStrategy2 *cs = new CausalizationStrategy2(g); if(cs->causalize()){ if(debugIsEnabled('c')){ cout << "Result of causalization (variable, [range,] equationID):" << endl; cs->print(); } }else{ //si no anduvo, probamos con la estrategia clasica DEBUG('c', "Executing the classic strategy\n"); CausalizationStrategy *cs_clasica = new CausalizationStrategy(mmo_class); AST_ClassList cl = newAST_ClassList(); cs_clasica->causalize(mmo_class->name(), cl); DEBUG('c', "Causalized Equations:\n"); MMO_EquationList causalEqs = mmo_class->getEquations(); MMO_EquationListIterator causalEqsIter; foreach(causalEqsIter, causalEqs) { DEBUG('c', "%s", current_element(causalEqsIter)->print().c_str()); } }
void plotResults(deque<long>*dateS, deque<double>*returnS){ // -persist option makes the window not disappear when program exits Gnuplot gp("gnuplot -persist"); gp << "plot '-' with lines title 'returns'\n"; gp.send(dateS->begin(), dateS->end(), returnS->begin(), returnS->end()); }
GT PFC::miller_loop(const G2& QQ,const G1& PP) { GT z; int i,j,n,nb,nbw,nzs; ECn3 A,Q; ECn P; ZZn Px,Py; BOOL precomp; ZZn6 res; Big X=*x; P=PP.g; Q=QQ.g; #ifdef MR_ECN3_PROJECTIVE Q.norm(); #endif precomp=FALSE; if (QQ.ptable!=NULL) precomp=TRUE; normalise(P); extract(P,Px,Py); Px+=Px; // because x^6+2 is irreducible.. simplifies line function calculation Py+=Py; res=1; A=Q; // reset A nb=bits(X); res.mark_as_miller(); j=0; for (i=nb-2;i>=0;i--) { res*=res; if (precomp) res*=gp(QQ.ptable,j,Px,Py); else res*=g(A,A,Px,Py); if (bit(X,i)==1) { if (precomp) res*=gp(QQ.ptable,j,Px,Py); else res*=g(A,Q,Px,Py); } } z.g=res; return z; }
EvtComplex wignerD( int j, int m1, int m2, double phi, double theta, double gamma ) { EvtComplex gp(0.0, -phi*m1); EvtComplex gm(0.0, -gamma*m2); return exp( gp ) * EvtdFunction::d(j, m1, m2, theta) * exp( gm ); }
bool MDFNI_SaveState(const char *fname, const char *suffix, const MDFN_Surface *surface, const MDFN_Rect *DisplayRect, const int32 *LineWidths) noexcept { bool ret = true; try { if(!MDFNGameInfo->StateAction) { throw MDFN_Error(0, _("Module \"%s\" doesn't support save states."), MDFNGameInfo->shortname); } if(MDFNnetplay && (MDFNGameInfo->SaveStateAltersState == true)) { throw MDFN_Error(0, _("Module %s is not compatible with manual state saving during netplay."), MDFNGameInfo->shortname); } // // { MemoryStream st(65536); MDFNSS_SaveSM(&st, false, surface, DisplayRect, LineWidths); // // // GZFileStream gp(fname ? std::string(fname) : MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix), GZFileStream::MODE::WRITE, MDFN_GetSettingI("filesys.state_comp_level")); gp.write(st.map(), st.size()); gp.close(); } MDFND_SetStateStatus(NULL); if(!fname && !suffix) { SaveStateStatus[CurrentState] = true; RecentlySavedState = CurrentState; MDFN_DispMessage(_("State %d saved."), CurrentState); } } catch(std::exception &e) { if(!fname && !suffix) MDFN_DispMessage(_("State %d save error: %s"), CurrentState, e.what()); else MDFN_PrintError("%s", e.what()); if(MDFNnetplay) MDFND_NetplayText(e.what(), false); ret = false; } return(ret); }
inline object_info_ptr create_rocket_flare(kernel::system* csys, create_msg const& msg) { decart_position dpos(msg.pos,msg.orien); geo_position gp(dpos, get_base()); rocket_flare::settings_t vs; return rocket_flare::create(dynamic_cast<objects_factory*>(csys),vs,gp); }
int main() { //Gnuplot gp; // Create a script which can be manually fed into gnuplot later: // Gnuplot gp(">script.gp"); // Create script and also feed to gnuplot: Gnuplot gp("tee plot.gp | gnuplot -persist"); gp << "set terminal png\n"; // Or choose any of those options at runtime by setting the GNUPLOT_IOSTREAM_CMD // environment variable. // Gnuplot vectors (i.e. arrows) require four columns: (x,y,dx,dy) std::vector<boost::tuple<double, double, double, double> > pts_A; // You can also use a separate container for each column, like so: std::vector<double> pts_B_x; std::vector<double> pts_B_y; std::vector<double> pts_B_dx; std::vector<double> pts_B_dy; // You could also use: // std::vector<std::vector<double> > // boost::tuple of four std::vector's // std::vector of std::tuple (if you have C++11) // arma::mat (with the Armadillo library) // blitz::Array<blitz::TinyVector<double, 4>, 1> (with the Blitz++ library) // ... or anything of that sort for(double alpha=0; alpha<1; alpha+=1.0/24.0) { double theta = alpha*2.0*3.14159; pts_A.push_back(boost::make_tuple( cos(theta), sin(theta), -cos(theta)*0.1, -sin(theta)*0.1 )); pts_B_x .push_back( cos(theta)*0.8); pts_B_y .push_back( sin(theta)*0.8); pts_B_dx.push_back( sin(theta)*0.1); pts_B_dy.push_back(-cos(theta)*0.1); } gp << "set output 'plot_1.png'\n"; // Don't forget to put "\n" at the end of each line! gp << "set xrange [-2:2]\nset yrange [-2:2]\n"; // '-' means read from stdin. The send1d() function sends data to gnuplot's stdin. gp << "plot '-' with vectors title 'pts_A', '-' with vectors title 'pts_B'\n"; gp.send1d(pts_A); gp.send1d(boost::make_tuple(pts_B_x, pts_B_y, pts_B_dx, pts_B_dy)); #ifdef _WIN32 // For Windows, prompt for a keystroke before the Gnuplot object goes out of scope so that // the gnuplot window doesn't get closed. std::cout << "Press enter to exit." << std::endl; std::cin.get(); #endif }
void plotLogResults(deque<double>*returnS){ // -persist option makes the window not disappear when program exits Gnuplot gp("gnuplot -persist"); gp << "set logscale y\n"; gp << "plot '-' with lines title 'log returns'\n"; gp.send(returnS->begin(), returnS->end()); }
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); // Local matrix is ignored if we don't have local coords. If we have localcoords we only // batch with identical view matrices SkMatrix localMatrix; if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) { SkDebugf("Cannot invert\n"); return; } SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage, localMatrix, this->usesLocalCoords(), this->coverageIgnored())); batchTarget->initDraw(gp, pipeline); size_t vertexStride = gp->getVertexStride(); SkASSERT(canTweakAlphaForCoverage ? vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) : vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr)); int innerVertexNum = 4; int outerVertexNum = this->miterStroke() ? 4 : 8; int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2; int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexCnt; int instanceCount = fGeoData.count(); const SkAutoTUnref<const GrIndexBuffer> indexBuffer( GetIndexBuffer(batchTarget->resourceProvider(), this->miterStroke())); InstancedHelper helper; void* vertices = helper.init(batchTarget, kTriangles_GrPrimitiveType, vertexStride, indexBuffer, verticesPerInstance, indicesPerInstance, instanceCount); if (!vertices || !indexBuffer) { SkDebugf("Could not allocate vertices\n"); return; } for (int i = 0; i < instanceCount; i++) { const Geometry& args = fGeoData[i]; this->generateAAStrokeRectGeometry(vertices, i * verticesPerInstance * vertexStride, vertexStride, outerVertexNum, innerVertexNum, args.fColor, args.fDevOutside, args.fDevOutsideAssist, args.fDevInside, args.fMiterStroke, canTweakAlphaForCoverage); } helper.issueDraw(batchTarget); }
Stokhos::TensorProductQuadrature<ordinal_type, value_type>:: TensorProductQuadrature(const Teuchos::RCP<const ProductBasis<ordinal_type,value_type> >& product_basis,const ordinal_type& quad_order) { #ifdef STOKHOS_TEUCHOS_TIME_MONITOR TEUCHOS_FUNC_TIME_MONITOR("Stokhos::TensorProductQuadrature -- Quad Grid Generation"); #endif ordinal_type d = product_basis->dimension(); ordinal_type sz = product_basis->size(); Teuchos::Array< Teuchos::RCP<const OneDOrthogPolyBasis<ordinal_type,value_type> > > coordinate_bases = product_basis->getCoordinateBases(); // Compute quad points, weights, values Teuchos::Array< Teuchos::Array<value_type> > gp(d); Teuchos::Array< Teuchos::Array<value_type> > gw(d); Teuchos::Array< Teuchos::Array< Teuchos::Array<value_type> > > gv(d); Teuchos::Array<ordinal_type> n(d); ordinal_type ntot = 1; for (ordinal_type i=0; i<d; i++) { coordinate_bases[i]->getQuadPoints(quad_order, gp[i], gw[i], gv[i]); n[i] = gp[i].size(); ntot *= n[i]; } quad_points.resize(ntot); quad_weights.resize(ntot); quad_values.resize(ntot); Teuchos::Array<ordinal_type> index(d); for (ordinal_type i=0; i<d; i++) index[i] = 0; ordinal_type cnt = 0; while (cnt < ntot) { quad_points[cnt].resize(d); quad_weights[cnt] = value_type(1.0); quad_values[cnt].resize(sz); for (ordinal_type j=0; j<d; j++) { quad_points[cnt][j] = gp[j][index[j]]; quad_weights[cnt] *= gw[j][index[j]]; } for (ordinal_type k=0; k<sz; k++) { quad_values[cnt][k] = value_type(1.0); MultiIndex<ordinal_type> term = product_basis->term(k); for (ordinal_type j=0; j<d; j++) quad_values[cnt][k] *= gv[j][index[j]][term[j]]; } ++index[0]; ordinal_type i = 0; while (i < d-1 && index[i] == n[i]) { index[i] = 0; ++i; ++index[i]; } ++cnt; } //std::cout << "Number of quadrature points = " << ntot << std::endl; }
void gp(int i,int j){ int dir[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}}; int k; if(img[i][j]==1){ img[i][j]=count; for(k=0;k<8;k++) if((i+dir[k][0])>=0&&(j+dir[k][1])>=0&&(i+dir[k][0])<n&&(j+dir[k][1])<n) gp(i+dir[k][0],j+dir[k][1]); } }
GT PFC::miller_loop(const G1& QQ,const G1& PP) { GT z; int i,j,n,nb,nbw,nzs; ECn A,Q; ECn P; ZZn Px,Py; BOOL precomp; ZZn2 res; Big iters=*ord-1; // can omit last addition P=PP.g; Q=QQ.g; precomp=FALSE; if (QQ.ptable!=NULL) precomp=TRUE; normalise(P); normalise(Q); extract(P,Px,Py); //Px=-Px; res=1; A=Q; // reset A nb=bits(iters); j=0; for (i=nb-2; i>=0; i--) { res*=res; if (precomp) res*=gp(QQ.ptable,j,Px,Py); else res*=g(A,A,Px,Py); if (bit(iters,i)==1) { if (precomp) res*=gp(QQ.ptable,j,Px,Py); else res*=g(A,Q,Px,Py); } } z.g=res; return z; }
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { SkAutoTUnref<const GrGeometryProcessor> gp( GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, this->color(), this->usesLocalCoords(), this->coverageIgnored(), this->viewMatrix(), SkMatrix::I())); batchTarget->initDraw(gp, pipeline); size_t vertexStride = gp->getVertexStride(); SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr)); Geometry& args = fGeoData[0]; int vertexCount = kVertsPerHairlineRect; if (args.fStrokeWidth > 0) { vertexCount = kVertsPerStrokeRect; } const GrVertexBuffer* vertexBuffer; int firstVertex; void* verts = batchTarget->makeVertSpace(vertexStride, vertexCount, &vertexBuffer, &firstVertex); if (!verts) { SkDebugf("Could not allocate vertices\n"); return; } SkPoint* vertex = reinterpret_cast<SkPoint*>(verts); GrPrimitiveType primType; if (args.fStrokeWidth > 0) {; primType = kTriangleStrip_GrPrimitiveType; args.fRect.sort(); this->setStrokeRectStrip(vertex, args.fRect, args.fStrokeWidth); } else { // hairline primType = kLineStrip_GrPrimitiveType; vertex[0].set(args.fRect.fLeft, args.fRect.fTop); vertex[1].set(args.fRect.fRight, args.fRect.fTop); vertex[2].set(args.fRect.fRight, args.fRect.fBottom); vertex[3].set(args.fRect.fLeft, args.fRect.fBottom); vertex[4].set(args.fRect.fLeft, args.fRect.fTop); } GrVertices vertices; vertices.init(primType, vertexBuffer, firstVertex, vertexCount); batchTarget->draw(vertices); }
bool LoggerContestLog::exportGJV( HANDLE fd ) { // straight copy to disk int mind = 1; int maxd = maxSerial; if ( !enquireDialog( /*Owner*/0, "Please give first serial to be dumped", mind ) ) return false; if ( !enquireDialog( /*Owner*/0, "Please give last serial to be dumped", maxd ) ) return false; int mindump = std::min( mind, maxd ); int maxdump = std::max( mind, maxd ); // ???? if ( MessageBox( 0, "Do you wish to edit the file?", "Contest", MB_OKCANCEL ) != ID_CANCEL ) // if (cmOK != messageBox(mfOKCancel|mfConfirmation, "Dumping all contacts between serials %d and %d inclusive", mindump, maxdump)) std::string temp = ( boost::format( "Dumping all contacts between serials %d and %d inclusive" ) % mindump % maxdump ).str(); if ( !MinosParameters::getMinosParameters() ->yesNoMessage( 0, temp.c_str() ) ) return false; GJVParams gp( fd ); GJVsave( gp ); bool inDump = false; for ( LogIterator i = ctList.begin(); i != ctList.end(); i++ ) { ContestContact *lct = dynamic_cast<ContestContact *>( *i ); // we need to test for "in dump" int serials = atoi( lct->serials.getValue().c_str() ); // dump the contact, until serial seen if ( ( serials == mindump ) || ( mindump == 0 ) ) inDump = true; if ( inDump && ( serials <= maxdump ) ) { if ( !lct->GJVsave( gp ) ) break; gp.count++; } if ( serials >= maxdump ) { break; // as all dumped } } GJVsave( gp ); return true; }
void ItemSerializer::toJson(std::ostream& out, sserialize::Static::spatial::DenseGeoPointVector::const_iterator it, sserialize::Static::spatial::DenseGeoPointVector::const_iterator end) const { sserialize::Static::spatial::GeoPoint gp(*it); out << "[" << gp.lat() << "," << gp.lon() << "]"; for(++it; it != end; ++it) { gp = *it; out << ",[" << gp.lat() << "," << gp.lon() << "]"; } }
void executeGasPricerTest(string const& name, double _etherPrice, double _blockFee, string const& bcTestPath, TransactionPriority _txPrio, u256 _expectedAsk, u256 _expectedBid, eth::Network _sealEngineNetwork = eth::Network::Test) { BasicGasPricer gp(u256(double(ether / 1000) / _etherPrice), u256(_blockFee * 1000)); Json::Value vJson = test::loadJsonFromFile(test::getTestPath() + bcTestPath); test::BlockChainLoader bcLoader(vJson[name], _sealEngineNetwork); BlockChain const& bc = bcLoader.bc(); gp.update(bc); BOOST_CHECK(abs(gp.ask(Block(Block::Null)) - _expectedAsk ) < 100000000); BOOST_CHECK(abs(gp.bid(_txPrio) - _expectedBid ) < 100000000); }