int main(){ Simple_window win(Point(100, 100), 600, 400, "test"); Circle c(Point(300, 200), 100); Graph_lib::Ellipse el(Point(300, 200), 100, 200); Open_polyline poly1, poly2; poly1.add(n(c)); poly1.add(s(c)); poly1.add(e(c)); poly1.add(w(c)); poly1.add(center(c)); poly1.add(ne(c)); poly1.add(se(c)); poly1.add(sw(c)); poly1.add(nw(c)); poly2.add(n(el)); poly2.add(s(el)); poly2.add(e(el)); poly2.add(w(el)); poly2.add(center(el)); poly2.add(ne(el)); poly2.add(se(el)); poly2.add(sw(el)); poly2.add(nw(el)); win.attach(c); win.attach(el); win.attach(poly1); win.attach(poly2); win.wait_for_button(); }
/** Adds newElem to node n's element adjacency list */ void FEM_Mesh::n2e_add(int n, int newElem) { if (n == -1) return; if(FEM_Is_ghost_index(n)){ FEM_VarIndexAttribute *eAdj = (FEM_VarIndexAttribute *)node.getGhost()->lookup(FEM_NODE_ELEM_ADJACENCY,"n2e_add"); CkVec<CkVec<ElemID> > &eVec = eAdj->get(); CkVec<ElemID> &nsVec = eVec[FEM_To_ghost_index(n)]; ElemID ne(0, newElem); nsVec.push_back(ne); int *testn2e, testn2ec; n2e_getAll(n,testn2e,testn2ec); for(int i=0; i<testn2ec; i++) { if(FEM_Is_ghost_index(testn2e[i])) CkAssert(elem[0].ghost->is_valid(FEM_From_ghost_index(testn2e[i]))); else CkAssert(elem[0].is_valid(testn2e[i])); } if(testn2ec!=0) delete[] testn2e; } else { FEM_VarIndexAttribute *eAdj = (FEM_VarIndexAttribute *)node.lookup(FEM_NODE_ELEM_ADJACENCY,"n2e_add"); CkVec<CkVec<ElemID> > &eVec = eAdj->get(); CkVec<ElemID> &nsVec = eVec[n]; ElemID ne(0, newElem); nsVec.push_back(ne); } }
//-------------------------------------------------------------------------- void BoundingBoxTests::testEquality() { CPPUNIT_ASSERT_EQUAL(false, eq(a1, a2)); CPPUNIT_ASSERT_EQUAL(true, ne(a1, a2)); CPPUNIT_ASSERT_EQUAL(true, ne(a1, a2)); CPPUNIT_ASSERT_EQUAL(true, ne(a1, a6)); }
/** * \brief Charge un espace de travail * \details Charge un espace de travail. Si le dossier spécifié n'était pas un espace de travail, ce dernier est transformé en espace de travail * \param path chemin vers le dosier de l'espace de travail */ void Workspace::load(const QString& path){ clear(); wspath = path; QFile xml_doc(path + "\\.workspace"); if(xml_doc.exists()){ if(!xml_doc.open(QIODevice::ReadOnly)){ xml_doc.close(); NoteException ne("Le fichier .workspace n'a pas pu être ouvert."); throw ne; } if (!dom->setContent(&xml_doc)){ xml_doc.close(); NoteException ne("Le fichier .workspace est corrompu."); throw ne; } loadMaps(); check(); xml_doc.close(); } else { // create the .workspace file xml_doc.open(QIODevice::ReadWrite); QTextStream out(&xml_doc); out.setCodec("UTF-8"); out << "<?xml version='1.0' encoding='UTF-8'?>\n<workspace>\n <notes></notes>\n <trash_notes></trash_notes>\n <tags></tags>\n</workspace>"; xml_doc.close(); dom->setContent(&xml_doc); } }
TEST_F(CoordinateGridBasicTest, FourPosInitializationCornersOk) { vposition sw( 0.00,0.00); vposition nw( 0.30,0.10); vposition ne( 0.30,0.35); vposition se(-0.01,0.30); /* std::cout << format::dd; std::cout << sw << std::endl; std::cout << nw << std::endl; std::cout << ne << std::endl; std::cout << se << std::endl; */ CoordinateGrid cg(sw,nw,ne,se); // Expect the "middle" point to be within boundries. ASSERT_GT(cg.getCenter().coords.a[0],cg.getSW().coords.a[0]); ASSERT_GT(cg.getCenter().coords.a[1],cg.getSW().coords.a[1]); ASSERT_LT(cg.getCenter().coords.a[0],cg.getNE().coords.a[0]); ASSERT_LT(cg.getCenter().coords.a[1],cg.getNE().coords.a[1]); ASSERT_LT(cg.getCenter().coords.a[0],cg.getNW().coords.a[0]); ASSERT_GT(cg.getCenter().coords.a[1],cg.getNW().coords.a[1]); ASSERT_GT(cg.getCenter().coords.a[0],cg.getSE().coords.a[0]); ASSERT_LT(cg.getCenter().coords.a[1],cg.getSE().coords.a[1]); }
int TopologicalGraph::ExpandEdges() { int nadded=0; int morig=ne(); tedge e; int i; if (!Set(tedge()).exist(PROP_MULTIPLICITY)) return 0; Prop<int> multiplicity(Set(tedge()),PROP_MULTIPLICITY); for (e=1; e<=morig; e++) {for (i=2; i<=multiplicity[e]; ++i) NewEdge(e.firsttbrin(), e.secondtbrin()); nadded+=multiplicity[e]-1; } Set(tedge()).erase(PROP_MULTIPLICITY); // add loops if (!Set(tvertex()).exist(PROP_NLOOPS)) return nadded; tvertex v; Prop<int> nloops(Set(tvertex()),PROP_NLOOPS); for (v=1; v<=nv(); ++v) for (i=1; i<=nloops[v]; ++i) {++nadded; NewEdge(v,v); } Set(tvertex()).erase(PROP_NLOOPS); return nadded; }
void MainWindow::on_saveButton_clicked() { int size = nc*3/4; char potentialFilename[]="out/potential-%1.txt"; char concFilename[]="out/ni_ne-%1.txt"; //Save potential QVector<double> r(size), potential(size); for (int i=0; i<size; ++i) { r[i] = r_array[i]; potential[i] = phi[i]; } saveToFile(r,potential,QString(potentialFilename).arg((t/dt))); //Save concentration of the electrons and ions QVector<double> /*r(size),*/ ne(size),ni(size); for (int i=0; i<size; ++i) { r[i] = r_array[i]; ne[i] = srho[0][i]; ni[i] = srho[1][i]; } saveToFile2(r,ne,ni, QString(concFilename).arg((t/dt))); }
void Worker::doWork() { QTime* t = new QTime(); t->start(); Script* s=parse(inputFile,reporter); if(print) { TreePrinter p(output); s->accept(p); output.flush(); } TreeEvaluator e(output); s->accept(e); delete s; output.flush(); Node* n = e.getRootNode(); if(print) { NodePrinter p(output); n->accept(p); output.flush(); } NodeEvaluator ne(output); try { n->accept(ne); delete n; #if USE_CGAL } catch(CGAL::Assertion_exception e) { output << "What: " << QString::fromStdString(e.what()) << "\n"; } #else } catch(...) {
point crosspointLL(const line& l, const line& m) { double A = cross(l.b - l.a, m.b - m.a); double B = cross(l.b - l.a, m.a - l.a); if (eq(A, 0.0) and eq(B, 0.0)) return m.a; // overlap assert(ne(A, 0.0)); // not parallel return m.a - B / A * (m.b - m.a); }
int main(){ size_t tnum = 200, nnum = 202; std::vector<double> te(tnum), ne(nnum); std::vector<std::vector<double>> rate_ii(tnum, std::vector<double>(nnum)); std::vector<std::vector<double>> rate_ie(tnum, std::vector<double>(nnum)); std::vector<std::vector<double>> rate_ei(tnum, std::vector<double>(nnum)); std::vector<std::vector<double>> rate_ee(tnum, std::vector<double>(nnum)); plasmaFormulary::IonProperty proton(myconst::pmass, 1); for (size_t i = 0; i < tnum; ++i){ te[i] = 0.1 * exp(log(1.0e4 / 0.1) / (tnum - 1) * i); for (size_t j = 0; j < nnum; ++j){ ne[j] = 1.0e17 * exp(log(1.0e22 / 1.0e17) / (nnum - 1) * j); rate_ii[i][j] = plasmaFormulary::nu_ii_slow(ne[j], te[i], ne[j], te[i], proton, ne[j], te[i], proton)/ne[j]; rate_ie[i][j] = plasmaFormulary::nu_ie_slow(ne[j], te[i], ne[j], te[i], proton) / ne[j]; rate_ei[i][j] = plasmaFormulary::nu_ei_slow(ne[j], te[i], ne[j], te[i], proton) / ne[j]; rate_ee[i][j] = plasmaFormulary::nu_ee_slow(ne[j], te[i]) / ne[j]; } } IGORdata::write_itx(rate_ii, "rate_coef_ii.itx", "rate_coef_ii"); IGORdata::write_itx(rate_ie, "rate_coef_ie.itx", "rate_coef_ie"); IGORdata::write_itx(rate_ei, "rate_coef_ei.itx", "rate_coef_ei"); IGORdata::write_itx(rate_ee, "rate_coef_ee.itx", "rate_coef_ee"); IGORdata::write_edgeVector(te, "te.itx", "te"); IGORdata::write_edgeVector(ne, "ne.itx", "ne"); }
// <MetadataSet // DEF="" ID // USE="" IDREF // name="" SFString [inputOutput] // reference="" SFString [inputOutput] // /> void X3DImporter::ParseNode_MetadataSet() { std::string def, use; std::string name, reference; CX3DImporter_NodeElement* ne( nullptr ); MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue); MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue); MACRO_ATTRREAD_LOOPEND; // if "USE" defined then find already defined element. if(!use.empty()) { MACRO_USE_CHECKANDAPPLY(def, use, ENET_MetaSet, ne); } else { ne = new CX3DImporter_NodeElement_MetaSet(NodeElement_Cur); if(!def.empty()) ne->ID = def; ((CX3DImporter_NodeElement_MetaSet*)ne)->Reference = reference; // also metadata node can contain childs if(!mReader->isEmptyElement()) ParseNode_Metadata(ne, "MetadataSet"); else NodeElement_Cur->Child.push_back(ne);// made object as child to current element NodeElement_List.push_back(ne);// add new element to elements list. }// if(!use.empty()) else }
void Worker::primary() { Script* s=parse(inputFile,reporter,true); if(print) { TreePrinter p(output); s->accept(p); output << endl; } TreeEvaluator e(reporter); s->accept(e); delete s; output.flush(); Node* n = e.getRootNode(); if(print) { NodePrinter p(output); n->accept(p); output << endl; } NodeEvaluator ne(reporter); n->accept(ne); delete n; primitive=ne.getResult(); if(!primitive) reporter->reportWarning(tr("no top level object.")); else if(!outputFile.isEmpty()) { exportResult(outputFile); } }
Rect32 TransformTools::newRect(const Rect32 &oldRect, const TransformStruct &transform, Point32 *newHotspot) { Point32 nw(oldRect.left, oldRect.top); Point32 ne(oldRect.right, oldRect.top); Point32 sw(oldRect.left, oldRect.bottom); Point32 se(oldRect.right, oldRect.bottom); FloatPoint nw1, ne1, sw1, se1; nw1 = transformPoint(nw - transform._hotspot, transform._angle, transform._zoom); ne1 = transformPoint(ne - transform._hotspot, transform._angle, transform._zoom); sw1 = transformPoint(sw - transform._hotspot, transform._angle, transform._zoom); se1 = transformPoint(se - transform._hotspot, transform._angle, transform._zoom); float top = MIN(nw1.y, MIN(ne1.y, MIN(sw1.y, se1.y))); float bottom = MAX(nw1.y, MAX(ne1.y, MAX(sw1.y, se1.y))); float left = MIN(nw1.x, MIN(ne1.x, MIN(sw1.x, se1.x))); float right = MAX(nw1.x, MAX(ne1.x, MAX(sw1.x, se1.x))); if (newHotspot) { newHotspot->y = (uint32)(-floor(top)); newHotspot->x = (uint32)(-floor(left)); } Rect32 res; res.top = (int32)(floor(top)) + transform._hotspot.y; res.bottom = (int32)(ceil(bottom)) + transform._hotspot.y; res.left = (int32)(floor(left)) + transform._hotspot.x; res.right = (int32)(ceil(right)) + transform._hotspot.x; return res; }
void Server::run() { this->start(); Wrapper::NetworkEnvironnement ne(this); while (run_) { boost::lock_guard<boost::mutex> lk_in_package(in_packages_mut_); while (!incomming_packages_.empty()) { Package_ptr & pack = incomming_packages_.back(); // Interpretation des commandes a distance. incomming_packages_.pop_back(); } boost::lock_guard<boost::mutex> lk_out_package(out_packages_mut_); while (!sending_packages_.empty()) { socket_container::iterator it = sockets_.begin(); socket_container::iterator ite = sockets_.end(); for (; it != ite; ++it) { if ((it->second)->is_open()) { if (!send_message((it->second), sending_packages_.back())) break; } } sending_packages_.pop_back(); } this->cleaning_sockets(); } this->stop(); }
int main(int argc,char* argv[]) { int opt = 0; PsimagLite::String file(""); while ((opt = getopt(argc, argv, "f:")) != -1) { switch (opt) { case 'f': file=optarg; break; default: /* '?' */ throw std::runtime_error("Wrong usage\n"); } } if (file=="") { throw std::runtime_error("Wrong usage\n"); } FreeFermions::InputCheck inputCheck; InputNgType::Writeable ioWriteable(file,inputCheck); InputNgType::Readable io(ioWriteable); GeometryParamsType geometryParams(io); SizeType electronsUp = GeometryParamsType::readElectrons(io, geometryParams.sites); SizeType dof = 1; // spinless GeometryLibraryType geometry(geometryParams); std::cerr<<geometry; SizeType npthreads = 1; try { io.readline(npthreads,"Threads="); } catch (std::exception&) {} PsimagLite::Concurrency concurrency(&argc,&argv,npthreads); EngineType engine(geometry.matrix(), geometryParams.outputFile, dof, EngineType::VERBOSE_YES); PsimagLite::Vector<SizeType>::Type ne(dof,electronsUp); HilbertStateType gs(engine,ne,0,false); RealType sum = 0; for (SizeType i=0;i<ne[0];i++) sum += engine.eigenvalue(i); std::cerr<<"Energy="<<dof*sum<<"\n"; SizeType halfSites = static_cast<SizeType>(0.5*engine.size()); ReducedDensityMatrixType reducedDensityMatrix(engine,halfSites,electronsUp); PsimagLite::Vector<double>::Type e(reducedDensityMatrix.rank()); reducedDensityMatrix.diagonalize(e); if (concurrency.root()) { std::cout<<"DensityMatrixEigenvalues:\n"; std::cout<<e; } }
function chkperiod(in isperiod) { //check if allowed to post into other periods if (isperiod ne (fin.currperiod ^ "/" ^ fin.curryear)) { if (not(authorised("JOURNAL POST OUTSIDE CURRENT PERIOD", msg, ""))) { return invalid2(msg); } } //check minimum period var minperiod = gen.company.a(16); if (minperiod) { //T=MIN.PERIOD[-2,2]:('00':FIELD(MIN.PERIOD,'/',1))[-2,2] var tt = addcent(minperiod.substr(-2, 2)) ^ ("00" ^ minperiod.field("/", 1)).substr(-2, 2); //IF ADDCENT(T) GE ADDCENT(IS.PERIOD[-2,2]:('00':FIELD(IS.PERIOD,'/',1))[-2,2]) THEN var t2 = addcent(isperiod.field("/", 2)) ^ ("00" ^ isperiod.field("/", 1)).substr(-2, 2); //call msg(t:' ':t2:' ':is.period) if (tt >= t2) { msg = "Sorry, the ledgers are closed up to " ^ addcent(minperiod) ^ "|for company " ^ (DQ ^ (gen.company.a(1) ^ DQ)) ^ " (" ^ fin.currcompany ^ ")"; return invalid2(msg); } } //check maximum month var tt = isperiod.field("/", 1); if (tt < 1 or tt > fin.maxperiod or not tt.match("0N")) { badperiod: msg = "Please enter a period, or period/year|eg. " ^ (DQ ^ (fin.currperiod ^ DQ)) ^ " or " ^ (DQ ^ (fin.currperiod ^ "/" ^ fin.curryear ^ DQ)); return invalid2(msg); } //check year tt = (isperiod.field("/", 2)).substr(-2, 2); //IF t matches '1N' or T MATCHES '2N' ELSE GOTO BADPERIOD if (not tt.match("2N")) { goto badperiod; } //check maximum year if (addcent(tt) > addcent((gen.company.a(2)).substr(-2, 2))) { msg = "The year " ^ (DQ ^ (addcent(tt) ^ DQ)) ^ " must be opened for|" ^ gen.company.a(1) ^ "|before you can post to it"; return invalid2(msg); } //note if not current year if (interactive and tt ne fin.curryear) { tt = addcent(fin.curryear) - addcent(tt); if (tt > 5) { msg = "WARNING: THAT IS " ^ tt ^ " YEARS BEFORE THE CURRENT YEAR !!!"; gosub note3(msg); } //not needed by reval.subs //MSG='NOTE. THE CURRENT YEAR IS ':CURRYEAR //GOSUB NOTE3 } return 1; }
void node_common(detail::NodeBase* node, std::string name) { typedef typename ft::result_type<FPTR>::type result_type; typedef typename ft::parameter_types<FPTR>::type parameter_types; util::TypeInfoVector types; mpl::for_each<parameter_types> (util::TypeInfoInserter(types)); detail::NodeEntry ne(node, typeid(result_type), types, name); detail::nodesbysequence.push_back(ne); }
void ErrorReporter::reportException(Reason reason, const Address & addr, const char* prefix) { NubException ne(reason, addr); this->reportException(ne, prefix); }
bool TopologicalGraph::CheckSimple() {if(debug())DebugPrintf(" CheckSimple"); if(Set().exist(PROP_SIMPLE))return true; if(ne() <= 1){Prop1<int> simple(Set(),PROP_SIMPLE);return true;} if(debug())DebugPrintf("Executing CheckSimple"); if(!CheckNoLoops())return false; svector<tedge>link(1,ne()); link.clear(); link.SetName("CheckSimple:link"); svector<tedge>top1(1,nv()); top1.clear(); top1.SetName("CheckSimple:link"); svector<tedge>top2(1,nv()); top2.clear(); top2.SetName("CheckSimple:link"); tvertex u,v,w; tedge e,next; //First sort with respect to biggest label for(e = ne();e >= 1;e--) {v = (vin[e] < vin[-e]) ? vin[-e] : vin[e]; link[e] = top1[v];top1[v] = e; } // Then sort with respect to smallest label for(u = nv();u > 1;u--) {e = top1[u]; while(e!=0) {next = link[e]; //as link is modified v = (vin[e] < vin[-e]) ? vin[e] : vin[-e]; link[e] = top2[v]; top2[v] = e; e = next; } } // Check Multiple edges for(v = nv()-1;v >= 1;v--) {e = top2[v]; while(e!=0) {next = link[e]; u = vin[e]; if(u == v)u = vin[-e]; w = vin[next]; if(w == v)w = vin[-next]; if(u == w) return false; else link[e] = 0; e = next; } } Prop1<int> simple(Set(),PROP_SIMPLE); return true; }
int main(int, char**) { int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned s = sizeof(ia)/sizeof(ia[0]); input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), ne(3)); assert(*r == 3); r = std::find_if_not(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), ne(10)); assert(r == input_iterator<const int*>(ia+s)); #if TEST_STD_VER > 17 static_assert(test_constexpr()); #endif return 0; }
int main(void) { int rows, cols; printf("Enter rows and columns apart: "); scanf("%d %d", &rows, &cols); printf("Rows and columns apart: %d %d\n", rows, cols); printf("Number of NE-paths = %d\n", ne(rows, cols)); return 0; }
//'@rdname neighbours //'@export // [[Rcpp::export]] DataFrame gh_neighbours(CharacterVector hashes){ unsigned int input_size = hashes.size(); CharacterVector north(input_size); CharacterVector ne(input_size); CharacterVector east(input_size); CharacterVector se(input_size); CharacterVector south(input_size); CharacterVector sw(input_size); CharacterVector west(input_size); CharacterVector nw(input_size); std::vector < std::string > holding(8); for(unsigned int i = 0; i < input_size; i++){ if((i % 10000) == 0){ Rcpp::checkUserInterrupt(); } if(CharacterVector::is_na(hashes[i])){ north[i] = NA_REAL; ne[i] = NA_REAL; east[i] = NA_REAL; se[i] = NA_REAL; south[i] = NA_REAL; sw[i] = NA_REAL; west[i] = NA_REAL; nw[i] = NA_REAL; } else { holding = cgeohash::all_neighbours(Rcpp::as<std::string>(hashes[i])); north[i] = holding[0]; ne[i] = holding[1]; east[i] = holding[2]; se[i] = holding[3]; south[i] = holding[4]; sw[i] = holding[5]; west[i] = holding[6]; nw[i] = holding[7]; } } return DataFrame::create(_["north"] = north, _["northeast"] = ne, _["east"] = east, _["southeast"] = se, _["south"] = south, _["southwest"] = sw, _["west"] = west, _["northwest"] = nw, _["stringsAsFactors"] = false); }
/* called by the C++ code to render */ extern "C" void device_render (int* pixels, const int width, const int height, const float time, const Vec3fa& vx, const Vec3fa& vy, const Vec3fa& vz, const Vec3fa& p) { /* create scene */ if (g_scene == NULL) g_scene = convertScene(g_ispc_scene); /* create accumulator */ if (g_accu_width != width || g_accu_height != height) { //g_accu = new Vec3fa[width*height]; g_accu = (Vec3fa*)alignedMalloc(width*height*sizeof(Vec3fa)); g_accu_width = width; g_accu_height = height; memset(g_accu,0,width*height*sizeof(Vec3fa)); } /* reset accumulator */ bool camera_changed = g_changed; g_changed = false; camera_changed |= ne(g_accu_vx,vx); g_accu_vx = vx; // FIXME: use != operator camera_changed |= ne(g_accu_vy,vy); g_accu_vy = vy; // FIXME: use != operator camera_changed |= ne(g_accu_vz,vz); g_accu_vz = vz; // FIXME: use != operator camera_changed |= ne(g_accu_p, p); g_accu_p = p; // FIXME: use != operator g_accu_count++; if (camera_changed) { g_accu_count=0; memset(g_accu,0,width*height*sizeof(Vec3fa)); } /* render frame */ const int numTilesX = (width +TILE_SIZE_X-1)/TILE_SIZE_X; const int numTilesY = (height+TILE_SIZE_Y-1)/TILE_SIZE_Y; enableFilterDispatch = renderPixel == renderPixelStandard; launch_renderTile(numTilesX*numTilesY,pixels,width,height,time,vx,vy,vz,p,numTilesX,numTilesY); enableFilterDispatch = false; rtcDebug(); }
/* occlusion filter function */ void occlusionFilter(void* ptr, RTCRay2& ray) { /* make all surfaces opaque */ if (ray.geomID >= g_ispc_scene->numHairSets) { ray.transparency = Vec3fa(0.0f); return; } Vec3fa T = hair_Kt; T = T * ray.transparency; // FIXME: use *= operator ray.transparency = T; if (ne(T,Vec3fa(0.0f))) ray.geomID = RTC_INVALID_GEOMETRY_ID; // FIXME: use != operator }
TEST( NorOp, MatchesSingleClause ) { BSONObj baseOperand = BSON( "$ne" << 5 ); auto_ptr<ComparisonMatchExpression> ne( new ComparisonMatchExpression() ); ASSERT( ne->init( "a", ComparisonMatchExpression::NE, baseOperand[ "$ne" ] ).isOK() ); NorMatchExpression norOp; norOp.add( ne.release() ); ASSERT( !norOp.matches( BSON( "a" << 4 ), NULL ) ); ASSERT( !norOp.matches( BSON( "a" << BSON_ARRAY( 4 << 6 ) ), NULL ) ); ASSERT( norOp.matches( BSON( "a" << 5 ), NULL ) ); ASSERT( norOp.matches( BSON( "a" << BSON_ARRAY( 4 << 5 ) ), NULL ) ); }
/* occlusion filter function */ void occlusionFilter(void* ptr, RTCRay2& ray) { /* make all surfaces opaque */ ISPCGeometry* geometry = g_ispc_scene->geometries[ray.geomID]; if (geometry->type == TRIANGLE_MESH) { ray.transparency = Vec3fa(0.0f); return; } Vec3fa T = hair_Kt; T = T * ray.transparency; ray.transparency = T; if (ne(T,Vec3fa(0.0f))) ray.geomID = RTC_INVALID_GEOMETRY_ID; }
bool TopologicalGraph::CheckBiconnected() {if(debug())DebugPrintf(" CheckBionnected"); if(Set().exist(PROP_BICONNECTED))return true; if(nv() < 3 || ne() < 3)return false; if(debug())DebugPrintf("Executing CheckBionnected"); int m = ne(); int n = nv(); if (m==0) return true; svector<tvertex> nvin(-m,m); nvin.SetName("TG:Bicon:nvin"); svector<tvertex> low(0,n); low.SetName("TG:Bicon:low"); if(!DFS(nvin)) // not connected ... return false; _Bicon Bicon(n); int ret = bicon(n,m,nvin,Bicon,low); if(ret) {Prop1<int> isbicon(Set(),PROP_BICONNECTED); Prop1<int> is_con(Set(),PROP_CONNECTED); return true; } return false; }
static FuncInfo * get_suspect (List *stack) { List *p; FuncInfo *occurs = stack->data; for (p = stack; p; p = p->next) { FuncInfo *f = p->data; if (ne(f->lib, occurs->lib) && !list_find(trusted_libs, f->lib, libcmp)) return f; } /* Without a suspect, default to where the error occured */ return occurs; }
void multiCompare() const { // Test for found Token one(0); one.str("one"); ASSERT_EQUALS(1, Token::multiCompare(&one, "one|two", 0)); Token two(0); two.str("two"); ASSERT_EQUALS(1, Token::multiCompare(&two, "one|two", 0)); ASSERT_EQUALS(1, Token::multiCompare(&two, "verybig|two|", 0)); // Test for empty string found Token notfound(0); notfound.str("notfound"); ASSERT_EQUALS(0, Token::multiCompare(¬found, "|one|two", 0)); ASSERT_EQUALS(0, Token::multiCompare(¬found, "one||two", 0)); ASSERT_EQUALS(0, Token::multiCompare(¬found, "one|two|", 0)); // Test for not found ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(¬found, "one|two", 0))); Token s(0); s.str("s"); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&s, "verybig|two", 0))); Token ne(0); ne.str("ne"); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&ne, "one|two", 0))); Token a(0); a.str("a"); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&a, "abc|def", 0))); Token abcd(0); abcd.str("abcd"); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&abcd, "abc|def", 0))); Token def(0); def.str("default"); ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&def, "abc|def", 0))); // %op% Token plus(0); plus.str("+"); ASSERT_EQUALS(1, Token::multiCompare(&plus, "one|%op%", 0)); ASSERT_EQUALS(1, Token::multiCompare(&plus, "%op%|two", 0)); Token x(0); x.str("x"); ASSERT_EQUALS(-1, Token::multiCompare(&x, "one|%op%", 0)); ASSERT_EQUALS(-1, Token::multiCompare(&x, "%op%|two", 0)); }
void resetMySql(const std::string& mysqlurl, const std::string& dbname, int num = 10) { MySqlConnection mysql; if (mysql.connectByURL(mysqlurl)) { if (true) { mysqlpp::NoExceptions ne(mysql); mysqlpp::Query query = mysql.query(); if (!mysql.select_db(dbname.c_str())) { if (!mysql.create_db(dbname.c_str()) || !mysql.select_db(dbname.c_str())) { LOG4CXX_ERROR(logger, "reset mysql failed .."); return; } } } LOG4CXX_INFO(logger, "creating tables ..."); try { mysqlpp::Query query = mysql.query(); for (int i = 0; i < num; i++) { query.reset(); query << "DROP TABLE IF EXISTS KVS_" << i; query.execute(); query.reset(); query << "CREATE TABLE KVS_" << i << " (" << " `key` VARCHAR(255) NOT NULL, " << " value BLOB NOT NULL," << " flag INT(10) UNSIGNED NOT NULL, " << " touchtime INT(10) UNSIGNED NOT NULL, "<< "PRIMARY KEY (`key`))" << "ENGINE = InnoDB " << "CHARACTER SET utf8 COLLATE utf8_general_ci"; query.execute(); LOG4CXX_INFO(logger, "KVS_" << i); } } catch (std::exception& err) { LOG4CXX_ERROR(logger, "reset mysql failed:" << err.what()); } } }