evidence_t reasoner::operator() ( const qdb &kb, const qlist& query ) { evidence_t evidence; cases_t cases; for ( const pair<string, jsonld::pqlist>& x : kb ) { for ( jsonld::pquad quad : *x.second ) { const string &s = quad->subj->value, &p = quad->pred->value, &o = quad->object->value, &c = quad->graph->value; trace("processing quad " << quad->tostring() << endl); cases[dict[p]].push_back ( mkrule ( triple ( s, p, o ) ) ); if ( p != implication || kb.find ( o ) == kb.end() ) continue; for ( jsonld::pquad y : *kb.at ( o ) ) { rule& rul = *mkrule(); rul.head = triple ( *y ); if ( kb.find ( s ) != kb.end() ) for ( jsonld::pquad z : *kb.at ( s ) ) rul.body.push_back ( triple ( *z ) ); cases[rul.head->pred].push_back ( &rul ); trace("added rule " << rul << endl); } } } rule& goal = *mkrule(); for ( auto q : query ) goal.body.push_back ( triple ( *q ) ); printkb(); return ( *this ) ( &goal, -1, cases ); }
static int garmin_img_coord_get(void *priv_data, struct coord *c, int count) { struct map_rect_priv *mr=priv_data; struct subdivision *sub=(struct subdivision *)(mr->subdiv+mr->subdiv_pos); int ret=0; int debug=0; if (debug) printf("garmin_img_coord_get %d\n",count); if (debug) dump_subdivision(sub); while (count--) { if (mr->rgn_type < 2) { c->x=triple(&sub->center.lng)+(mr->pnt->lng_delta << shift); c->y=triple(&sub->center.lat)+(mr->pnt->lat_delta << shift); } else { if (! mr->ply_bitpos) { if (mr->ply->info & 0x80) { mr->ply_bitcount=mr->ply->u.p2.bitstream_len*8; mr->ply_lngbits=mr->ply->u.p2.bitstream_info & 0xf; mr->ply_latbits=mr->ply->u.p2.bitstream_info >> 4; } else { mr->ply_bitcount=mr->ply->u.p1.bitstream_len*8; mr->ply_lngbits=mr->ply->u.p1.bitstream_info & 0xf; mr->ply_latbits=mr->ply->u.p1.bitstream_info >> 4; } if (mr->ply_lngbits <= 9) mr->ply_lngbits+=2; if (mr->ply_latbits <= 9) mr->ply_latbits+=2; if (! get_bits(mr,1)) { mr->ply_lngbits+=1; mr->ply_lngsign=0; } else if (get_bits(mr, 1)) mr->ply_lngsign=-1; else mr->ply_lngsign=1; if (! get_bits(mr,1)) { mr->ply_latbits+=1; mr->ply_latsign=0; } else if (get_bits(mr, 1)) mr->ply_latsign=-1; else mr->ply_latsign=1; mr->ply_lnglimit=1 << (mr->ply_lngbits-1); mr->ply_latlimit=1 << (mr->ply_latbits-1); mr->ply_lng=mr->ply->lng_delta; mr->ply_lat=mr->ply->lat_delta; if (debug) printf("lngbits %d latbits %d bitcount %d\n", mr->ply_lngbits, mr->ply_latbits, mr->ply_bitcount); c->x=0; c->y=0; } else { if (mr->ply_bitpos + mr->ply_lngbits + mr->ply_latbits > mr->ply_bitcount) {
// Performs symmetric rank-k update of the submatrix. // Input to this step is the given submatrix and the output of the previous step. int S3_compute::execute(const triple & t, cholesky_context & c ) const { tile_const_ptr_type A_block; tile_const_ptr_type L1_block; tile_const_ptr_type L2_block; double temp; int b = c.b; const int k = t[0]; const int j = t[1]; const int i = t[2]; assert( j != k && i != k ); c.Lkji.get(triple(k, j, i), A_block); // Get the input tile. if(i==j) { // Diagonal tile. c.Lkji.get(triple(k+1,j,k), L2_block); // In case of a diagonal tile, i=j, hence both the tiles are the same. } else { // Non-diagonal tile. c.Lkji.get(triple(k+1,i,k), L2_block); // Get the first tile. c.Lkji.get(triple(k+1,j,k), L1_block); // Get the second tile. } #ifdef USE_MKL const double alpha = -1; const double beta = 1; if(i==j) { // Diagonal tile. cblas_dsyrk( CblasColMajor, CblasLower, CblasNoTrans, b, b, alpha, L2_block->get_array(), b, beta, const_cast< double* >( A_block->get_array() ), b ); } else { cblas_dgemm( CblasColMajor, CblasNoTrans, CblasTrans, b, b, b, alpha, L1_block->get_array(), b, L2_block->get_array(), b, beta, const_cast< double* >( A_block->get_array() ), b ); } #else for(int j_b = 0; j_b < b; j_b++) { for(int k_b = 0; k_b < b; k_b++) { temp = -1 * (*L2_block)( j_b, k_b ); if(i!=j) { for(int i_b = 0; i_b < b; i_b++) { const_cast< tile_type & >(*A_block)( i_b, j_b ) = (*A_block)( i_b, j_b ) + (temp * (*L1_block)( i_b, k_b )); } } else { for(int i_b = j_b; i_b < b; i_b++) { const_cast< tile_type & >(*A_block)( i_b, j_b ) = (*A_block)( i_b, j_b ) + (temp * (*L2_block)( i_b, k_b )); } } } } #endif c.Lkji.put(triple(k+1,j,i),A_block); // Write the output at the next time step. return CnC::CNC_Success; }
void dScriptCompiler::CreateLLVMTargetMachine (llvm::Module* const module) { std::string error; const std::string archName (D_VIRTUAL_MACHINE_NAME); const llvm::Target* const target = llvm::TargetRegistry::lookupTarget(archName, error); dAssert (target); llvm::StringRef mcpu(""); llvm::StringRef triple(""); llvm::StringRef feature(""); llvm::TargetOptions options; // InitTargetOptionsFromCodeGenFlags(); // options.DisableIntegratedAS = NoIntegratedAssembler; // options.MCOptions.ShowMCEncoding = ShowMCEncoding; // options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory; // options.MCOptions.AsmVerbose = AsmVerbose; std::unique_ptr<llvm::TargetMachine> targetMachinePtr(target->createTargetMachine(triple, mcpu, feature, options)); dAssert (targetMachinePtr.get()); llvm::TargetMachine &targetMachine = *targetMachinePtr.get(); llvm::legacy::PassManager passManager; // Newton Virtual machine does no have subtarget const llvm::DataLayout* const dataLayout = targetMachine.getSubtargetImpl()->getDataLayout(); dAssert (dataLayout); m_module->setDataLayout(dataLayout); passManager.add(new llvm::DataLayoutPass(module)); llvm::formatted_raw_ostream outputStream; targetMachine.addPassesToEmitFile (passManager, outputStream, llvm::TargetMachine::CGFT_AssemblyFile, false, NULL, NULL); passManager.run(*module); }
void TripleMultiNetwork::removeTriplesFromLinkEnd(const link_id_t l, const bool fromSource) { std::vector<triple_id_t> temp; const node_id_t s = fromSource ? link(l).source() : link(l).target(); // remove all triples containing l where s is the center node NeighborTripleIteratorRange iters = neighborTriples(l); for (NeighborTripleIterator& it = iters.first; it != iters.second; ++it) { NeighborLinkIteratorRange niters = neighborLinks(s); for (NeighborLinkIterator& nit = niters.first; nit != niters.second; ++nit) { if ((*nit != l) && triple(*it).containsLink(*nit)) { link(*nit).removeTriple(*it); temp.push_back(*nit); } } } for (std::vector<triple_id_t>::const_iterator tit = temp.begin(); tit != temp.end(); ++tit) { link(l).removeTriple(*tit); tripleStore_->remove(*tit); } }
// Color map classification triple ParticleColorClassifier::operator() (triple pos, quad axis, triple d_pos, triple d_angle, Particle * p) { if (p->colorMap.size() > ParticleSet::currentframe) return p->colorMap[ParticleSet::currentframe]; else return triple(1, 1, 1); }
bool Compiler::generateObjectFile(GeneratedCode *genCode, const std::string &output) const { llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. llvm::InitializeAllTargetMCs(); llvm::InitializeAllAsmPrinters(); llvm::InitializeAllAsmParsers(); std::string error; llvm::tool_output_file out(output.c_str(), error, llvm::sys::fs::F_Binary); if (!error.empty()) { return false; } llvm::formatted_raw_ostream fos(out.os()); llvm::PassManager pm; llvm::InitializeAllTargetInfos(); llvm::Triple triple(llvm::sys::getDefaultTargetTriple()); const llvm::Target *targetLookup = llvm::TargetRegistry::lookupTarget("", triple, error); if (!targetLookup) { llvm::outs() << error; return false; } llvm::TargetOptions options; std::auto_ptr<llvm::TargetMachine> target(targetLookup->createTargetMachine(triple.getTriple(), "", "", options, llvm::Reloc::Default, llvm::CodeModel::Default, llvm::CodeGenOpt::Default)); if ((*target).addPassesToEmitFile(pm, fos, llvm::TargetMachine::CGFT_ObjectFile, false, 0, 0)) { llvm::outs() << "target does not support generation of this file type!\n"; return false; } pm.run(*genCode->getModule()); out.keep(); return true; }
/** * @return the SBML object corresponding to next XMLToken in the * XMLInputStream or NULL if the token was not recognized. */ SBase* ListOfLineSegments::createObject (XMLInputStream& stream) { const std::string& name = stream.peek().getName(); SBase* object = 0; if (name == "curveSegment") { std::string type = "LineSegment"; XMLTriple triple("type","http://www.w3.org/2001/XMLSchema-instance","xsi"); if (!stream.peek().getAttributes().readInto(triple, type)) { //std::cout << "[DEBUG] ListOfLineSegments::createObject () : Failed to read xsi:type" << std::endl; return object; } //std::cout << "[DEBUG] ListOfLineSegments::createObject () : type " << type << std::endl; LAYOUT_CREATE_NS(layoutns,this->getSBMLNamespaces()); if(type=="LineSegment") { object = new LineSegment(layoutns); } else if(type=="CubicBezier") { object = new CubicBezier(layoutns); } } if(object) appendAndOwn(object); return object; }
int check_error(char *s) { if (s[0] != '&') if (triple(s) == -1 || s[0] == '|') return (FAILURE); return (SUCCESS); }
llvm::TargetMachine * getTargetMachine(llvm::Module *last_module) { llvm::Triple triple(last_module->getTargetTriple()); if (triple.getTriple().empty()) { triple.setTriple(getTriple()); } std::string Err; const llvm::Target *target = llvm::TargetRegistry::lookupTarget(triple.getTriple(), Err); assert(target && "cannot auto-select target for module"); #if D_LLVM_VERSION_MINOR >= 2 llvm::TargetOptions target_options; #endif std::string Features; target_sp = #if D_LLVM_VERSION_MINOR <= 4 std::auto_ptr<llvm::TargetMachine> #else std::shared_ptr<llvm::TargetMachine> #endif (target->createTargetMachine( triple.getTriple(), llvm::sys::getHostCPUName(), Features #if D_LLVM_VERSION_MINOR >= 2 , target_options #endif )); return target_sp.get(); }
int main(void) { freopen("daffodil.in","r",stdin); freopen("daffodil.out","w",stdout); int n; int a,b,c; for(n=100;n<1000;++n) { a = n/100; b = (n/10)%10; c = n%10; if(triple(a)+triple(b)+triple(c) == n) printf("%d \n",n); } return 0; }
// Perform unblocked Cholesky factorization on the input block (item indexed by tag values). // Output is a lower triangular matrix. int S1_compute::execute(const int & t, cholesky_context & c ) const { tile_const_ptr_type A_block; int b = c.b; const int k = t; c.Lkji.get(triple(k,k,k), A_block); // Get the input tile. #ifdef USE_MKL char uplo = 'l'; int info; dpotf2(&uplo, &b, const_cast< double * >( A_block->get_array() ), &b, &info); tile_const_ptr_type L_block = A_block; #else // Allocate memory for the output tile. tile_ptr_type L_block = std::make_shared< tile_type >( b ); // FIXME this need to be a triangular tile only // for(int i = 0; i < b; i++) { // L_block[i] = (double *) malloc((i+1) * sizeof(double)); // if(L_block[i] == NULL) { // fprintf(stderr, "Malloc failed -> %d\n", i); // exit(0); // } // } for(int k_b = 0; k_b < b; k_b++) { if((*A_block)( k_b, k_b ) <= 0) { fprintf(stderr, "Not a symmetric positive definite (SPD) matrix\n"); exit(0); } (*L_block)( k_b, k_b ) = sqrt((*A_block)( k_b, k_b )); for(int j_b = k_b+1; j_b < b; j_b++) { (*L_block)( j_b, k_b ) = (*A_block)( j_b, k_b )/(*L_block)( k_b, k_b ); } for(int j_bb = k_b+1; j_bb < b; j_bb++) { for(int i_b = j_bb; i_b < b; i_b++) { const_cast< tile_type & >(*A_block)( i_b, j_bb ) = (*A_block)( i_b, j_bb ) - ((*L_block)( i_b, k_b ) * (*L_block)( j_bb, k_b )); } } } #endif c.Lkji.put(triple(k+1, k, k), L_block); // Write the output tile at the next time step. return CnC::CNC_Success; }
SEXP R_TargetRegistry_lookupTarget(SEXP r_triple, SEXP r_arch) { std::string err; const llvm::Target *ans; if(Rf_length(r_arch)) { std::string arch(CHAR(STRING_ELT(r_arch, 0))); llvm::Triple triple(makeTwine(r_triple)); ans = llvm::TargetRegistry::lookupTarget(arch, triple, err); } else { std::string triple(CHAR(STRING_ELT(r_triple, 0))); ans = llvm::TargetRegistry::lookupTarget(triple, err); } return(R_createRef(ans, "Target")); }
void LZ::findMatch() { int offset = 0; string s = ""; triple temp = triple(); //expand through the lookahead, looking for matching substrings of size //2 or larger in the window for (int len = 2; len < lookahead.size(); ++len) { // grab temporary substring s s = lookahead.substr(0, len); int index = window.find(s); //if we find a match of len 2 or more if (index != string::npos) { temp.s = s; temp.offset = window.length() - index; temp.length = s.length(); } else //either there is no match of 2 or more or we have iterated past the //bounds of the match, in either case, we are done expanding { /* //here index == string::npos, which is equivalent to -1 because // it is the largest possible unsigned (int, in this case) if (temp.s.length()-1==window.length()) { int next = 0; while (len + next <= F && temp.s+lookahead[next]==s) { temp.s += lookahead[next]; s = temp.s + lookahead[len + next]; ++next; } }*/ break; } } //now that we have finished expanding //if we did not find a match, just output the character at the beginning of //our lookahead if (temp.s =="") { temp.s = lookahead[0]; temp.length = 0; temp.offset = 1; } if (temp.s.length() < F) { lookahead = lookahead.substr(temp.s.length(), lookahead.length()); } else//temp.s.length==F->empty lookahead { lookahead = ""; } //now append the best match(temp.s) to window(we will resize it when //we go through the loop again) window += temp.s; //append temp to tokens tokens.push_back(temp); }
int main(int argc, char const *argv[]) { int resultat = 0, op = 0; printf("saisir un nombre à tripler\n"); scanf("%d", &op); resultat = triple(op); printf("resultat de l'opération : %d\n", resultat); return 0; }
void sf_csmooth (sf_ctriangle tr /* smoothing object */, int o, int d /* trace sampling */, bool der /* if derivative */, bool box /* if box filter */, sf_complex *x /* data (smoothed in place) */) /*< apply adjoint triangle smoothing >*/ { triple (o,d,tr->nx,tr->nb,x,tr->tmp,box); doubint (tr->np,tr->tmp,(bool) (box || der)); fold (o,d,tr->nx,tr->nb,tr->np,x,tr->tmp); }
void physics::simreset() { std::vector<triple>::iterator itor; size_t i; for(itor=velocities.begin();itor!=velocities.end();++itor) (*itor)=triple(0,0,0); for(itor=accelerations.begin();itor!=accelerations.end();++itor) (*itor)=triple(0,0,0); // Flat front face impact for(i=0;i<16;++i) velocities[i] = triple(1,0,0); // Corner impact /* velocities[0]= triple(1,1,1); */ // Shaped front face impact /* for(i=0;i<16;++i) velocities[i]= triple(1,0,0); velocities[6]= triple(2,0,0); velocities[7]= triple(2,0,0); velocities[10]=triple(2,0,0); velocities[11]=triple(2,0,0); */ // Internal explosion /* velocities[37]=triple(-1,-1,-1); velocities[38]=triple(1,-1,-1); velocities[41]=triple(-1,1,-1); velocities[42]=triple(1,1,-1) ; velocities[53]=triple(-1,-1,1); velocities[54]=triple(1,-1,1); velocities[57]=triple(-1,1,1); velocities[58]=triple(1,1,1); */ }
void nsmooth (ntriangle tr /* smoothing object */, int o, int d /* sampling */, bool der /* derivative flag */, const float *t /* triangle lengths */, const int *s /* triangle shifts */, float *x /* data (smoothed in place) */) /*< smooth >*/ { fold (o,d,tr->nx,tr->nb,tr->np,x,tr->tmp); doubint (tr->np,tr->tmp,der); triple (o,d,tr->nx,tr->nb,t,s,x,tr->tmp); }
RdfTriple RdfStorePrivate::StatementToRdfTriple(librdf_statement* statement) const { librdf_node *subject = librdf_statement_get_subject(statement); librdf_node *predicate = librdf_statement_get_predicate(statement); librdf_node *object = librdf_statement_get_object(statement); RdfTriple triple(LibRdfNodeToRdfNode(subject), LibRdfNodeToRdfNode(predicate), LibRdfNodeToRdfNode(object)); return triple; }
std::string generatePtx(llvm::Module *module, int devMajor, int devMinor) { std::string mcpu; if ((devMajor == 3 && devMinor >= 5) || devMajor > 3) { mcpu = "sm_35"; } else if (devMajor >= 3 && devMinor >= 0) { mcpu = "sm_30"; } else { mcpu = "sm_20"; } // Select target given the module's triple llvm::Triple triple(module->getTargetTriple()); std::string errStr; const llvm::Target* target = nullptr; target = llvm::TargetRegistry::lookupTarget(triple.str(), errStr); iassert(target) << errStr; llvm::TargetOptions targetOptions; std::string features = "+ptx40"; std::unique_ptr<llvm::TargetMachine> targetMachine( target->createTargetMachine(triple.str(), mcpu, features, targetOptions, // llvm::Reloc::PIC_, llvm::Reloc::Default, llvm::CodeModel::Default, llvm::CodeGenOpt::Default)); // Make a passmanager and add emission to string llvm::legacy::PassManager pm; pm.add(new llvm::TargetLibraryInfoWrapperPass(triple)); // Set up constant NVVM reflect mapping llvm::StringMap<int> reflectMapping; reflectMapping["__CUDA_FTZ"] = 1; // Flush denormals to zero pm.add(llvm::createNVVMReflectPass(reflectMapping)); pm.add(llvm::createAlwaysInlinerPass()); targetMachine->Options.MCOptions.AsmVerbose = true; llvm::SmallString<8> ptxStr; llvm::raw_svector_ostream outStream(ptxStr); outStream.SetUnbuffered(); bool failed = targetMachine->addPassesToEmitFile( pm, outStream, targetMachine->CGFT_AssemblyFile, false); iassert(!failed); pm.run(*module); outStream.flush(); return ptxStr.str(); }
DataServer::DataServer(QObject *parent) : QObject(parent) { Dataquay::BasicStore store; store.setBaseUri(Dataquay::Uri("http://www.w3.org/ns/hydra/core#")); // Simple test. FIXME: remove QUrl testUrl("https://raw.githubusercontent.com/semiotproject/semiot-platform/master/api-gateway/src/main/resources/ru/semiot/platform/apigateway/ApiDocumentation.ttl"); FileDownloader fd(testUrl); QString path = fd.download(); store.import(path,Dataquay::BasicStore::ImportPermitDuplicates); Dataquay::Triple triple(Dataquay::Node(Dataquay::Uri(QUrl("http://semiot.ru/doc#EntryPoint-Sensors"))),Dataquay::Node(Dataquay::Uri(QUrl("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))),Dataquay::Node(Dataquay::Uri(QUrl("http://www.w3.org/ns/hydra/core#Link")))); store.save(QString("superstore.ttl")); qDebug()<<store.contains(triple); }
int main() { int t; scanf("%d", &t); while (t--) { scanf("%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y); scanf("%lf%lf%lf%lf", &C.x, &C.y, &D.x, &D.y); scanf("%lf%Lf%lf", &P, &Q, &R); triple(); } return 0; }
SEXP R_Target_createTargetMachine(SEXP r_target, SEXP r_triple, SEXP r_cpu, SEXP r_features, SEXP r_opts) { const llvm::Target *tgt = GET_REF(r_target, Target); // llvm::Module *mod = GET_REF(r_module, Module); std::string triple(CHAR(STRING_ELT(r_triple, 0))); llvm::TargetOptions *opts = NULL, defaultOpts; llvm::TargetMachine *ans; if(Rf_length(r_opts)) opts = GET_REF(r_opts, TargetOptions); else { /* taken from Halide's CodeGen.cpp */ defaultOpts.LessPreciseFPMADOption = true; //defaultOpts.NoFramePointerElim = false; #ifdef LLVM_HAS_NOFRAMEPOINTERELIMNONLEAF defaultOpts.NoFramePointerElimNonLeaf = false; #endif defaultOpts.AllowFPOpFusion = llvm::FPOpFusion::Fast; defaultOpts.UnsafeFPMath = true; defaultOpts.NoInfsFPMath = true; defaultOpts.NoNaNsFPMath = true; defaultOpts.HonorSignDependentRoundingFPMathOption = false; //defaultOpts.UseSoftFloat = false; defaultOpts.FloatABIType = llvm::FloatABI::Soft; defaultOpts.NoZerosInBSS = false; defaultOpts.GuaranteedTailCallOpt = false; //defaultOpts.DisableTailCalls = false; defaultOpts.StackAlignmentOverride = 32; #ifdef LLVM_HAS_REALIGNSTACK defaultOpts.RealignStack = true; #endif //defaultOpts.TrapFuncName = ""; defaultOpts.PositionIndependentExecutable = true; #if LLVM_VERSION == 3 && LLVM_MINOR_VERSION < 5 defaultOpts.EnableSegmentedStacks = false; #endif defaultOpts.UseInitArray = false; #ifdef LLVM_HAS_SSPBUFFERSIZE defaultOpts.SSPBufferSize = 0; #endif opts = &defaultOpts; } ans = tgt->createTargetMachine(triple, std::string(CHAR(STRING_ELT(r_cpu, 0))), std::string(CHAR(STRING_ELT(r_features, 0))), *opts); return(R_createRef(ans, "TargetMachine")); }
triple transform(triple x, int a){ if(a==1) { int r1[3]={1,-2,2}; int r2[3]={2,-1,2}; int r3[3]={2,-2,3}; return triple(x.dot(r1), x.dot(r2), x.dot(r3)); } else if(a==2) { int r1[3]={1,2,2}; int r2[3]={2,1,2}; int r3[3]={2,2,3}; return triple(x.dot(r1), x.dot(r2), x.dot(r3)); } else { int r1[3]={-1,2,2}; int r2[3]={-2,1,2}; int r3[3]={-2,2,3}; return triple(x.dot(r1), x.dot(r2), x.dot(r3)); } }
bool MeanFiller::iterate(double thres) { stack<triple> historyEntity = stack<triple>(); cube sample; int cols, rows, slices; image->getSize(cols, rows, slices); bool flag = false; for (int i = minx; i <= maxx; i++) { for (int j = miny; j <= maxy; j++) { for (int k = minz; k <= maxz; k++) { if (image->getVoxel(i, j, k) > 0 && res_image->getVoxel(i, j, k) == 0) { sample = wBright * Utils::convert_d(image->getRegion(i - 2, j - 2, i + 2, j + 2, k - 2, k + 2)) + wCurv * Utils::convert_d(res_image->getRegion(i - 2, j - 2, i + 2, j + 2, k - 2, k + 2)); double der = derivate(sample); if (der > thres) { res_image->setVoxel(i, j, k, 255); if (i <= minx && i >= 4 && minx > i - 1) minx = i - 1; if (i >= maxx && i <= cols - 4 && maxx < i + 1) maxx = i + 1; if (j <= miny && j >= 4 && miny > j - 1) miny = j - 1; if (j >= maxy && j <= rows - 4 && maxy < j + 1) maxy = j + 1; if (k <= minz && k >= 4 && minz > k - 1) minz = k - 1; if (k >= maxz && k <= slices - 4 && maxz < k + 1) maxz = k + 1; historyEntity.push(triple(i, j, k)); flag = true; } } } } } if (flag) { if (history.size() >= h_size) { history.pop_back(); } history.push_front(historyEntity); } return flag; }
void displayCathedral(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glColor3f(1.0, 1.0, 1.0); /* clear the screen to black */ glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); float A = (-.2 + .2/512.f)/2.f; ray r = ray(triple(0.f, -10.f, 0.f), spaceVector(.1, A, A), 0.f, FLT_MAX); spaceVector deltaZ = spaceVector(0.f, 0.f, .2/512.0); spaceVector deltaY = spaceVector(0.f, .2/512.0, 0.f); ray temp; ray normRay; seenPair pair; float * color = new float[3]; for (int j = 0; j < 512; j++) { temp = r; gJ = j; for (int i = 0; i < 512; i++) { gI = i; normRay = temp.normalized(); tShootRay(normRay, color); gammaCorrect(color, .454545); glColor3fv((GLfloat *) color); glVertex2i(i, j); temp = temp.changeDirection(deltaZ); } r = r.changeDirection(deltaY); } delete[] color; glEnd(); glFlush(); return; }
// Perform triangular system solve on the input tile. // Input to this step are the input tile and the output tile of the previous step. int S2_compute::execute(const pair & t, cholesky_context & c ) const { tile_const_ptr_type A_block; tile_const_ptr_type Li_block; int b = c.b; const int k = t.first; const int j = t.second; assert( j != k ); c.Lkji.get(triple(k,j,k), A_block); // Get the input tile. c.Lkji.get(triple(k+1, k, k), Li_block); // Get the 2nd input tile (Output of previous step). #ifdef USE_MKL char uplo='l', side='r', transa='t', diag='n'; double alpha = 1; dtrsm (&side,&uplo,&transa,&diag,&b,&b,&alpha,Li_block->get_array(),&b,const_cast< double * >( A_block->get_array() ),&b); tile_const_ptr_type Lo_block = A_block; #else // Allocate memory for the output tile. tile_ptr_type Lo_block = std::make_shared< tile_type >( b ); for(int k_b = 0; k_b < b; k_b++) { for(int i_b = 0; i_b < b; i_b++) { (*Lo_block)( i_b, k_b ) = (*A_block)( i_b, k_b )/(*Li_block)( k_b, k_b ); } for( int j_b = k_b+1; j_b < b; j_b++) { for( int i_b = 0; i_b < b; i_b++) { const_cast< tile_type & >(*A_block)( i_b, j_b ) = (*A_block)( i_b, j_b ) - ((*Li_block)( j_b, k_b ) * (*Lo_block)( i_b, k_b )); } } } #endif c.Lkji.put(triple(k+1, j, k),Lo_block); // Write the output tile at the next time step. return CnC::CNC_Success; }
void MeanFiller::addNeighbors(int x, int y, int z) { for (int i = x - 1; i <= x + 1; i++) { for (int j = y - 1; j <= y + 1; j++) { for (int k = z - 1; k <= z + 1; k++) { if (image->inNarrowBounds(i, j, k) && image->getVoxel(i, j, k) > 0 && res_image->getVoxel(i, j, k) == 0) { candidates.insert(triple(i, j, k)); } } } } }
/** @cond doxygenLibsbmlInternal */ SBase* ListOfLineSegments::createObject (XMLInputStream& stream) { const std::string& name = stream.peek().getName(); SBase* object = 0; if (name == "curveSegment") { std::string type = "LineSegment"; XMLTriple triple("type","http://www.w3.org/2001/XMLSchema-instance","xsi"); if (!stream.peek().getAttributes().readInto(triple, type)) { //std::cout << "[DEBUG] ListOfLineSegments::createObject () : // Failed to read xsi:type" << std::endl; getErrorLog()->logPackageError("layout", LayoutXsiTypeAllowedLocations, getPackageVersion(), getLevel(), getVersion(), "", getLine(), getColumn()); return object; } //std::cout << "[DEBUG] ListOfLineSegments::createObject () : type " // << type << std::endl; LAYOUT_CREATE_NS(layoutns,this->getSBMLNamespaces()); if(type=="LineSegment") { object = new LineSegment(layoutns); } else if(type=="CubicBezier") { object = new CubicBezier(layoutns); } else { getErrorLog()->logPackageError("layout", LayoutXsiTypeSyntax, getPackageVersion(), getLevel(), getVersion(), "", getLine(), getColumn()); } delete layoutns; } if(object) appendAndOwn(object); return object; }
/** @cond doxygenLibsbmlInternal */ void RenderPoint::writeAttributes (XMLOutputStream& stream) const { SBase::writeAttributes(stream); XMLTriple triple("type","","xsi"); stream.writeAttribute(triple,std::string("RenderPoint")); std::ostringstream os; os << mXOffset; stream.writeAttribute("x", getPrefix(), os.str()); os.str(""); os << mYOffset; stream.writeAttribute("y", getPrefix(), os.str()); if(this->mZOffset!=RelAbsVector(0.0,0.0)) { os.str(""); os << mZOffset; stream.writeAttribute("z", getPrefix(), os.str()); } }