// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // WlanElementLocator::TWlanLocateStatus WlanElementLocator::InformationElement( TUint8 aIeId, const TIeOui& aIeOui, TUint8 aIeOuiType, TUint8 aIeOuiSubtype, TUint8& aIeLength, const TUint8** aIeData ) { // Element format is: // ID = Element ID (1 byte) // Len = Length (1 byte) // OUI = OUI (3 bytes) // OUItyp = OUI Type (1 byte) // OUIsub = OUI Subtype (1 byte) // ... TUint8 ie( aIeId ); TUint8 len( 0 ); const TUint8* data( NULL ); // Find the first element with matching IE id if ( InformationElement( aIeId, len, &data, EFalse ) != EWlanLocateOk ) { // there isn't one aIeLength = 0; *aIeData = NULL; return EWlanLocateElementNotFound; } // The ID is correct but also the OUI, OUI Type and OUI Subtype need to // match TWlanLocateStatus ret( EWlanLocateOk ); const TUint KMinAcceptableIeDataLen = KIeOuiLength + sizeof( KWmmElemOuiType ) + sizeof( KWmmInfoElemOuiSubType ); // offset of the Subtype field from the beginning of element Information const TUint KOuiSubtypeOffset = 4; while ( ret == EWlanLocateOk && ( len < KMinAcceptableIeDataLen || ie != aIeId || !( data[0] == aIeOui[0] && data[1] == aIeOui[1] && data[2] == aIeOui[2] ) || *( data + KOuiTypeOffset ) != aIeOuiType || *( data + KOuiSubtypeOffset ) != aIeOuiSubtype ) ) { ret = NextIE( ie, len, &data ); } if ( ret == EWlanLocateElementNotFound ) { aIeLength = 0; *aIeData = NULL; return EWlanLocateElementNotFound; } else { aIeLength = len; *aIeData = data; return ValidIE( aIeId, aIeLength, data, aIeOuiType, aIeOuiSubtype ); } }
void DocumentExporter::exportCurrentScene(Scene *sce) { PointerRNA sceneptr, unit_settings; PropertyRNA *system; /* unused , *scale; */ clear_global_id_map(); COLLADABU::NativeString native_filename = COLLADABU::NativeString(std::string(this->export_settings->filepath), COLLADABU::NativeString::ENCODING_UTF8); COLLADASW::StreamWriter sw(native_filename); fprintf(stdout, "Collada export: %s\n", this->export_settings->filepath); // open <collada> sw.startDocument(); // <asset> COLLADASW::Asset asset(&sw); RNA_id_pointer_create(&(sce->id), &sceneptr); unit_settings = RNA_pointer_get(&sceneptr, "unit_settings"); system = RNA_struct_find_property(&unit_settings, "system"); //scale = RNA_struct_find_property(&unit_settings, "scale_length"); std::string unitname = "meter"; float linearmeasure = RNA_float_get(&unit_settings, "scale_length"); switch (RNA_property_enum_get(&unit_settings, system)) { case USER_UNIT_NONE: case USER_UNIT_METRIC: if (linearmeasure == 0.001f) { unitname = "millimeter"; } else if (linearmeasure == 0.01f) { unitname = "centimeter"; } else if (linearmeasure == 0.1f) { unitname = "decimeter"; } else if (linearmeasure == 1.0f) { unitname = "meter"; } else if (linearmeasure == 1000.0f) { unitname = "kilometer"; } break; case USER_UNIT_IMPERIAL: if (linearmeasure == 0.0254f) { unitname = "inch"; } else if (linearmeasure == 0.3048f) { unitname = "foot"; } else if (linearmeasure == 0.9144f) { unitname = "yard"; } break; default: break; } asset.setUnit(unitname, linearmeasure); asset.setUpAxisType(COLLADASW::Asset::Z_UP); if (U.author[0] != '\0') { asset.getContributor().mAuthor = U.author; } else { asset.getContributor().mAuthor = "Blender User"; } char version_buf[128]; #ifdef WITH_BUILDINFO sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, build_rev); #else sprintf(version_buf, "Blender %d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); #endif asset.getContributor().mAuthoringTool = version_buf; asset.add(); LinkNode *export_set = this->export_settings->export_set; // <library_cameras> if (bc_has_object_type(export_set, OB_CAMERA)) { CamerasExporter ce(&sw, this->export_settings); ce.exportCameras(sce); } // <library_lights> if (bc_has_object_type(export_set, OB_LAMP)) { LightsExporter le(&sw, this->export_settings); le.exportLights(sce); } // <library_images> ImagesExporter ie(&sw, this->export_settings); ie.exportImages(sce); // <library_effects> EffectsExporter ee(&sw, this->export_settings); ee.exportEffects(sce); // <library_materials> MaterialsExporter me(&sw, this->export_settings); me.exportMaterials(sce); // <library_geometries> if (bc_has_object_type(export_set, OB_MESH)) { GeometryExporter ge(&sw, this->export_settings); ge.exportGeom(sce); } // <library_animations> AnimationExporter ae(&sw, this->export_settings); ae.exportAnimations(sce); // <library_controllers> ArmatureExporter arm_exporter(&sw, this->export_settings); if (bc_has_object_type(export_set, OB_ARMATURE)) { arm_exporter.export_controllers(sce); } // <library_visual_scenes> SceneExporter se(&sw, &arm_exporter, this->export_settings); se.exportScene(sce); // <scene> std::string scene_name(translate_id(id_name(sce))); COLLADASW::Scene scene(&sw, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, scene_name)); scene.add(); // close <Collada> sw.endDocument(); }
void Permute::execute(int num, //input Buffer<float4>& pos_u, Buffer<float4>& pos_s, Buffer<float4>& vel_u, Buffer<float4>& vel_s, Buffer<float4>& veleval_u, Buffer<float4>& veleval_s, Buffer<float4>& color_u, Buffer<float4>& color_s, Buffer<float>& mass_u, Buffer<float>& mass_s, Buffer<unsigned int>& objectIndex_u, Buffer<unsigned int>& objectIndex_s, /*Buffer<float>& spring_coef_u, Buffer<float>& spring_coef_s, Buffer<float>& dampening_coef_u, Buffer<float>& dampening_coef_s,*/ Buffer<unsigned int>& indices, //params //Buffer<SPHParams>& sphp, Buffer<GridParams>& gp, //debug params Buffer<float4>& clf_debug, Buffer<int4>& cli_debug) { int iarg = 0; k_permute.setArg(iarg++, num); k_permute.setArg(iarg++, pos_u.getDevicePtr()); k_permute.setArg(iarg++, pos_s.getDevicePtr()); k_permute.setArg(iarg++, vel_u.getDevicePtr()); k_permute.setArg(iarg++, vel_s.getDevicePtr()); k_permute.setArg(iarg++, veleval_u.getDevicePtr()); k_permute.setArg(iarg++, veleval_s.getDevicePtr()); k_permute.setArg(iarg++, color_u.getDevicePtr()); k_permute.setArg(iarg++, color_s.getDevicePtr()); k_permute.setArg(iarg++, mass_u.getDevicePtr()); k_permute.setArg(iarg++, mass_s.getDevicePtr()); k_permute.setArg(iarg++, objectIndex_u.getDevicePtr()); k_permute.setArg(iarg++, objectIndex_s.getDevicePtr()); /*k_permute.setArg(iarg++, spring_coef_u.getDevicePtr()); k_permute.setArg(iarg++, spring_coef_u_s.getDevicePtr()); k_permute.setArg(iarg++, dampening_coef_u.getDevicePtr()); k_permute.setArg(iarg++, dampening_coef_s.getDevicePtr());*/ k_permute.setArg(iarg++, indices.getDevicePtr()); int workSize = 64; //printf("about to data structures\n"); try { //printf("k_permute (non-cloud): num= %d\n", num); float gputime = k_permute.execute(num, workSize); if(gputime > 0) timer->set(gputime); } catch (cl::Error er) { printf("ERROR(data structures): %s(%s)\n", er.what(), CL::oclErrorString(er.err())); } #if 0 //printPermuteDiagnostics(); printf("**************** Permute Diagnostics ****************\n"); int nbc = nb_cells + 1; printf("nb_cells: %d\n", nbc); printf("num particles: %d\n", num); std::vector<unsigned int> is(nbc); std::vector<unsigned int> ie(nbc); ci_end.copyToHost(ie); ci_start.copyToHost(is); //std::vector<unsigned int> hpos_u(nbc); //std::vector<unsigned int> hpos_s(nbc); //pos_s.copyToHost(hpos_s); //pos_u.copyToHost(hpos_u); for(int i = 0; i < nbc; i++) { if (is[i] != -1)// && ie[i] != 0) { //nb = ie[i] - is[i]; //nb_particles += nb; printf("cell: %d indices start: %d indices stop: %d\n", i, is[i], ie[i]); } } #endif #if 0 //print out elements from the sorted arrays #define DENS 0 #define POS 1 #define VEL 2 printf("gordon\n"); int nbc = num+5; std::vector<float4> hpos_u(nbc); std::vector<float4> hpos_s(nbc); std::vector<unsigned int> hindices(nbc); //svars.copyToHost(dens, DENS*sphp.max_num); //svars.copyToHost(poss, POS*sphp.max_num); pos_u.copyToHost(hpos_u); pos_s.copyToHost(hpos_s); indices.copyToHost(hindices); printf("**** INSIDE PERMUTE ****\n"); printf("**** UNSORTED POSITIONS *****\n"); for (int i=0; i < num; i++) { //printf("clf_debug: %f, %f, %f, %f\n", clf[i].x, clf[i].y, clf[i].z, clf[i].w); printf("pos unsorted: %f, %f, %f, %f\n", hpos_u[i].x, hpos_u[i].y, hpos_u[i].z, hpos_u[i].w); } printf("**** SORTED POSITIONS *****\n"); for (int i=0; i < num; i++) { printf("pos sorted: %f, %f, %f, %f\n", hpos_s[i].x, hpos_s[i].y, hpos_s[i].z, hpos_s[i].w); } printf("**** SORTED INDICES *****\n"); for (int i=0; i < num; i++) { printf("indices: %d\n", hindices[i]); } #endif //return nc; }
RcppExport SEXP DPPhaseSim(SEXP Rsequence, SEXP RflowCycle, SEXP Rcf, SEXP Rie, SEXP Rdr, SEXP Rmaxflows, SEXP RgetStates, SEXP RnucContamination) { SEXP ret = R_NilValue; char *exceptionMesg = NULL; try { Rcpp::StringVector sequences(Rsequence); string flowCycle = Rcpp::as<string>(RflowCycle); Rcpp::NumericMatrix cf_mat(Rcf); Rcpp::NumericMatrix ie_mat(Rie); Rcpp::NumericMatrix dr_mat(Rdr); Rcpp::NumericMatrix nuc_contamination(RnucContamination); unsigned int max_flows = Rcpp::as<int>(Rmaxflows); unsigned int get_states = Rcpp::as<int>(RgetStates); ion::FlowOrder flow_order(flowCycle, flowCycle.length()); unsigned int nFlow = flow_order.num_flows(); unsigned int nRead = sequences.size(); max_flows = min(max_flows, nFlow); vector<vector<double> > nuc_availbality; nuc_availbality.resize(nuc_contamination.nrow()); for (unsigned int iFlowNuc=0; iFlowNuc < nuc_availbality.size(); iFlowNuc++){ nuc_availbality.at(iFlowNuc).resize(nuc_contamination.ncol()); for (unsigned int iNuc=0; iNuc < nuc_availbality.at(iFlowNuc).size(); iNuc++){ nuc_availbality.at(iFlowNuc).at(iNuc) = nuc_contamination(iFlowNuc, iNuc); } } // Prepare objects for holding and passing back results Rcpp::NumericMatrix predicted_out(nRead,nFlow); Rcpp::StringVector seq_out(nRead); // Set Phasing Model DPPhaseSimulator PhaseSimulator(flow_order); PhaseSimulator.UpdateNucAvailability(nuc_availbality); bool per_read_phasing = true; if (cf_mat.nrow() == 1 and cf_mat.ncol() == 1) { per_read_phasing = false; cout << "DPPhaseSim: Single Phase Parameter set detected." << endl; // XXX PhaseSimulator.SetPhasingParameters_Basic((double)cf_mat(0,0), (double)ie_mat(0,0), (double)dr_mat(0,0)); } else if (cf_mat.nrow() == (int)nFlow and cf_mat.ncol() == (int)nFlow) { cout << "DPPhaseSim: Full Phase Parameter set detected." << endl; // XXX per_read_phasing = false; vector<vector<double> > cf(nFlow); vector<vector<double> > ie(nFlow); vector<vector<double> > dr(nFlow); for (unsigned int iFlowNuc=0; iFlowNuc < nFlow; iFlowNuc++){ cf.at(iFlowNuc).resize(nFlow); ie.at(iFlowNuc).resize(nFlow); dr.at(iFlowNuc).resize(nFlow); for (unsigned int iFlow=0; iFlow < nFlow; iFlow++){ cf.at(iFlowNuc).at(iFlow) = cf_mat(iFlowNuc, iFlow); ie.at(iFlowNuc).at(iFlow) = ie_mat(iFlowNuc, iFlow); dr.at(iFlowNuc).at(iFlow) = dr_mat(iFlowNuc, iFlow); } } PhaseSimulator.SetPhasingParameters_Full(cf, ie, dr); } else cout << "DPPhaseSim: Per Read Phase Parameter set detected." << endl; //XXX // --- Iterate over all sequences string my_sequence, sim_sequence; vector<float> my_prediction; for(unsigned int iRead=0; iRead<nRead; iRead++) { if (per_read_phasing) PhaseSimulator.SetPhasingParameters_Basic((double)cf_mat(0,iRead), (double)ie_mat(0,iRead), (double)dr_mat(0,iRead)); my_sequence = Rcpp::as<std::string>(sequences(iRead)); PhaseSimulator.Simulate(my_sequence, my_prediction, max_flows); PhaseSimulator.GetSimSequence(sim_sequence); // Simulated sequence might be shorter than input sequence. seq_out(iRead) = sim_sequence; for(unsigned int iFlow=0; iFlow<nFlow and iFlow<max_flows; ++iFlow) { predicted_out(iRead,iFlow) = (double) my_prediction.at(iFlow); } //cout << "--- DPPhaseSim: Done simulating read "<< iRead << " of " << nRead << endl; // XXX } // --- Store results if (nRead == 1 and get_states > 0) { vector<vector<float> > query_states; vector<int> hp_lengths; PhaseSimulator.GetStates(query_states, hp_lengths); Rcpp::NumericMatrix states(hp_lengths.size(), nFlow); Rcpp::NumericVector HPlengths(hp_lengths.size()); for (unsigned int iHP=0; iHP<hp_lengths.size(); iHP++){ HPlengths(iHP) = (double)hp_lengths[iHP]; for (unsigned int iFlow=0; iFlow<nFlow; iFlow++) states(iHP, iFlow) = (double)query_states.at(iHP).at(iFlow); } ret = Rcpp::List::create(Rcpp::Named("sig") = predicted_out, Rcpp::Named("seq") = seq_out, Rcpp::Named("states") = states, Rcpp::Named("HPlengths") = HPlengths); } else { ret = Rcpp::List::create(Rcpp::Named("sig") = predicted_out, Rcpp::Named("seq") = seq_out); } } catch(std::exception& ex) { forward_exception_to_r(ex); } catch(...) { ::Rf_error("c++ exception (unknown reason)"); } if(exceptionMesg != NULL) Rf_error(exceptionMesg); return ret; }
Partitioner::RegionStats * Partitioner::region_statistics(const ExtentMap &addresses) { RegionStats *stats = new_region_stats(); assert(stats!=NULL); size_t nbytes = addresses.size(); if (0==nbytes) return stats; stats->add_sample(RegionStats::RA_NBYTES, nbytes); ExtentMap not_addresses = addresses.invert<ExtentMap>(); Disassembler::AddressSet worklist; // addresses waiting to be disassembled recursively InstructionMap insns_found; // all the instructions we found herein ExtentMap insns_extent; // memory used by the instructions we've found ExtentMap pending = addresses; // addresses we haven't looked at yet /* Undirected local control flow graph used to count connected components */ typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> CFG; typedef boost::graph_traits<CFG>::vertex_descriptor CFGVertex; typedef std::map<rose_addr_t, CFGVertex> Addr2Vertex; CFG cfg; Addr2Vertex va2id; /* Statistics */ size_t nstarts=0; // number of times the recursive disassembler was started size_t nfails=0; // number of disassembler failures size_t noverlaps=0; // instructions overlapping with a previously found instruction size_t nincomplete=0; // number of instructions with unknown successors size_t nfallthrough=0; // number of branches to fall-through address within our "addresses" size_t ncalls=0; // number of function calls outside our "addresses" size_t nnoncalls=0; // number of branches to non-functions outside our "addresses" size_t ninternal=0; // number of non-fallthrough internal branches while (!pending.empty()) { rose_addr_t start_va = pending.min(); worklist.insert(start_va); ++nstarts; while (!worklist.empty()) { rose_addr_t va = *worklist.begin(); worklist.erase(worklist.begin()); /* Obtain (disassemble) the instruction and make sure it falls entirely within the "addresses" */ Instruction *insn = find_instruction(va); if (!insn) { ++nfails; pending.erase(Extent(va)); continue; } Extent ie(va, insn->get_size()); if (not_addresses.overlaps(ie)) { ++nfails; pending.erase(Extent(va)); continue; } /* The disassembler can also return an "unknown" instruction when failing, depending on how it is invoked. */ if (insn->node->is_unknown()) { ++nfails; pending.erase(Extent(va, insn->get_size())); continue; } insns_found.insert(std::make_pair(va, insn)); rose_addr_t fall_through_va = va + insn->get_size(); /* Does this instruction overlap with any we've already found? */ if (insns_extent.overlaps(ie)) ++noverlaps; pending.erase(Extent(va, insn->get_size())); insns_extent.insert(ie); /* Find instruction successors by looking only at the instruction itself. This is simpler, but less rigorous * method than finding successors a basic block at a time. For instance, we'll find both sides of a branch * instruction even if the more rigorous method determined that one side or the other is always taken. But this is * probably what we want here anyway for determining whether something looks like code. */ bool complete; Disassembler::AddressSet succs = insn->get_successors(&complete); if (!complete) ++nincomplete; /* Add instruction as vertex to CFG */ std::pair<Addr2Vertex::iterator, bool> inserted = va2id.insert(std::make_pair(va, va2id.size())); if (inserted.second) { CFGVertex vertex __attribute__((unused)) = add_vertex(cfg); assert(vertex==inserted.first->second); } /* Classify the various successors. */ for (Disassembler::AddressSet::const_iterator si=succs.begin(); si!=succs.end(); ++si) { rose_addr_t succ_va = *si; if (succ_va==fall_through_va) { ++nfallthrough; if (pending.find(succ_va)!=pending.end()) worklist.insert(succ_va); /* Add edge to CFG graph */ va2id.insert(std::make_pair(succ_va, va2id.size())); add_edge(va2id[va], va2id[succ_va], cfg); } else if (addresses.find(succ_va)==addresses.end()) { /* A non-fallthrough branch to something outside this memory region */ if (functions.find(succ_va)!=functions.end()) { /* A branch to a function entry point we've previously discovered. */ ++ncalls; } else { ++nnoncalls; } } else { /* A non-fallthrough branch to something in our address range. */ ++ninternal; if (pending.find(succ_va)!=pending.end()) worklist.insert(succ_va); /* Add edge to CFG graph */ va2id.insert(std::make_pair(succ_va, va2id.size())); add_edge(va2id[va], va2id[succ_va], cfg); } } } } /* Statistics */ stats->add_sample(RegionStats::RA_NFAILS, nfails); stats->add_sample(RegionStats::RA_NINSNS, insns_found.size()); stats->add_sample(RegionStats::RA_NOVERLAPS, noverlaps); stats->add_sample(RegionStats::RA_NSTARTS, nstarts); stats->add_sample(RegionStats::RA_NCOVERAGE, insns_extent.size()); stats->add_sample(RegionStats::RA_NINCOMPLETE, nincomplete); stats->add_sample(RegionStats::RA_NBRANCHES, ncalls+nnoncalls+ninternal); stats->add_sample(RegionStats::RA_NCALLS, ncalls); stats->add_sample(RegionStats::RA_NNONCALLS, nnoncalls); stats->add_sample(RegionStats::RA_NINTERNAL, ninternal); stats->add_sample(RegionStats::RA_NICFGEDGES, ninternal + nfallthrough); stats->add_sample(RegionStats::RA_NIUNIQUE, count_kinds(insns_found)); stats->add_sample(RegionStats::RA_NPRIV, count_privileged(insns_found)); stats->add_sample(RegionStats::RA_NFLOAT, count_floating_point(insns_found)); double regsz, regvar; stats->add_sample(RegionStats::RA_NREGREFS, count_registers(insns_found, ®sz, ®var)); stats->add_sample(RegionStats::RA_REGSZ, regsz); stats->add_sample(RegionStats::RA_REGVAR, regvar); /* Count the number of connected components in the undirected CFG */ if (!va2id.empty()) { std::vector<int> component(num_vertices(cfg)); stats->add_sample(RegionStats::RA_NCOMPS, connected_components(cfg, &component[0])); } stats->compute_ratios(); return stats; }
RcppExport SEXP phaseSolve(SEXP Rsignal, SEXP RflowCycle, SEXP RnucConc, SEXP Rcf, SEXP Rie, SEXP Rdr, SEXP RhpScale, SEXP RdroopType, SEXP RmaxAdv, SEXP RnIterations, SEXP RresidualScale, SEXP RresidualScaleMinFlow, SEXP RresidualScaleMaxFlow, SEXP RextraTaps, SEXP RdebugBaseCall) { SEXP ret = R_NilValue; char *exceptionMesg = NULL; try { Rcpp::NumericMatrix signal(Rsignal); string flowCycle = Rcpp::as<string>(RflowCycle); Rcpp::NumericMatrix cc(RnucConc); Rcpp::NumericVector cf(Rcf); Rcpp::NumericVector ie(Rie); Rcpp::NumericVector dr(Rdr); Rcpp::NumericVector hpScale(RhpScale); string drType = Rcpp::as<string>(RdroopType); unsigned int maxAdv = (unsigned int) Rcpp::as<int>(RmaxAdv); unsigned int nIterations = (unsigned int) Rcpp::as<int>(RnIterations); unsigned int extraTaps = (unsigned int) Rcpp::as<int>(RextraTaps); bool residualScale = Rcpp::as<bool>(RresidualScale); int residualScaleMinFlow = Rcpp::as<int>(RresidualScaleMinFlow); int residualScaleMaxFlow = Rcpp::as<int>(RresidualScaleMaxFlow); bool debugBaseCall = Rcpp::as<bool>(RdebugBaseCall); unsigned int nFlow = signal.cols(); unsigned int nRead = signal.rows(); DroopType droopType; bool badDroopType = false; if(drType == "ONLY_WHEN_INCORPORATING") { droopType = ONLY_WHEN_INCORPORATING; } else if(drType == "EVERY_FLOW") { droopType = EVERY_FLOW; } else { badDroopType = true; } if(badDroopType) { std::string exception = "bad droop type supplied\n"; exceptionMesg = strdup(exception.c_str()); } else if(cc.rows() != (int) N_NUCLEOTIDES) { std::string exception = "concentration matrix should have 4 rows\n"; exceptionMesg = strdup(exception.c_str()); } else if(cc.cols() != (int) N_NUCLEOTIDES) { std::string exception = "concentration matrix should have 4 columns\n"; exceptionMesg = strdup(exception.c_str()); } else { // recast cf, ie, dr, hpScale weight_vec_t cfMod(cf.size()); for(int i=0; i<cf.size(); i++) cfMod[i] = cf(i); weight_vec_t ieMod(ie.size()); for(int i=0; i<ie.size(); i++) ieMod[i] = ie(i); weight_vec_t drMod(dr.size()); for(int i=0; i<dr.size(); i++) drMod[i] = dr(i); weight_vec_t hpScaleMod(hpScale.size()); for(int i=0; i<hpScale.size(); i++) hpScaleMod[i] = hpScale(i); // recast nuc concentration vector<weight_vec_t> ccMod(cc.rows()); for(int iRow=0; iRow < cc.rows(); iRow++) { ccMod[iRow].resize(cc.cols()); for(unsigned int iCol=0; iCol < N_NUCLEOTIDES; iCol++) ccMod[iRow][iCol] = cc(iRow,iCol); } // Other recasts hpLen_t maxAdvMod = (hpLen_t) maxAdv; // Prepare objects for holding and passing back results Rcpp::NumericMatrix predicted_out(nRead,nFlow); Rcpp::NumericMatrix residual_out(nRead,nFlow); Rcpp::IntegerMatrix hpFlow_out(nRead,nFlow); std::vector< std::string> seq_out(nRead); Rcpp::NumericMatrix multiplier_out(nRead,1+nIterations); // Iterate over all reads weight_vec_t sigMod(nFlow); string result; for(unsigned int iRead=0; iRead < nRead; iRead++) { for(unsigned int iFlow=0; iFlow < nFlow; iFlow++) sigMod[iFlow] = (weight_t) signal(iRead,iFlow); PhaseSolve p; p.SetResidualScale(residualScale); if(residualScaleMinFlow >= 0) p.SetResidualScaleMinFlow((unsigned int) residualScaleMinFlow); if(residualScaleMaxFlow >= 0) p.SetResidualScaleMaxFlow((unsigned int) residualScaleMaxFlow); p.setExtraTaps(extraTaps); p.setHpScale(hpScaleMod); p.setPhaseParam(flowCycle,maxAdvMod,ccMod,cfMod,ieMod,drMod,droopType); p.GreedyBaseCall(sigMod, nIterations, debugBaseCall); p.getSeq(result); seq_out[iRead] = result; weight_vec_t & predicted = p.GetPredictedSignal(); weight_vec_t & residual = p.GetResidualSignal(); hpLen_vec_t & hpFlow = p.GetPredictedHpFlow(); for(unsigned int iFlow=0; iFlow < nFlow; iFlow++) { predicted_out(iRead,iFlow) = (double) predicted[iFlow]; residual_out(iRead,iFlow) = (double) residual[iFlow]; hpFlow_out(iRead,iFlow) = (int) hpFlow[iFlow]; } if(residualScale) { weight_vec_t & multiplier = p.GetMultiplier(); // We re-order these so the last multiplier comes first. This is for convenience // as it allows us grab the first col of the matrix as the last multiplier applied // even if each read ended up taking different numbers of iterations. unsigned int i1,i2; for(i1=0,i2=multiplier.size()-1; i1 < multiplier.size(); i1++,i2--) { multiplier_out(iRead,i1) = (double) multiplier[i2]; } // If the read took fewer than all available iterations, pad with zero for(; i1 <= nIterations; i1++) { multiplier_out(iRead,i1) = 0; } } } // Store results std::map<std::string,SEXP> map; map["seq"] = Rcpp::wrap( seq_out ); map["predicted"] = Rcpp::wrap( predicted_out ); map["residual"] = Rcpp::wrap( residual_out ); map["hpFlow"] = Rcpp::wrap( hpFlow_out ); if(residualScale) map["multiplier"] = Rcpp::wrap( multiplier_out ); ret = Rcpp::wrap( map ); } } catch(std::exception& ex) { forward_exception_to_r(ex); } catch(...) { ::Rf_error("c++ exception (unknown reason)"); } if(exceptionMesg != NULL) Rf_error(exceptionMesg); return ret; }
bool TTabDelimExampleGenerator::readExample(TFileExampleIteratorData &fei, TExample &exam) { vector<string> atoms; // read lines until eof or a non-empty line while(!feof(fei.file) && ((readTabAtom(fei, atoms, true, csv)>0) || atomsEmpty(atoms))) { vector<string>::iterator ii(atoms.begin()), ie(atoms.end()); while ((ii!=ie) && !(*ii).length()) ii++; if (ii==ie) atoms.clear(); else break; } if (!atoms.size()) return false; // Add an appropriate number of empty atoms, if needed while (atoms.size()<attributeTypes->size()) atoms.push_back(string("")); _ASSERT(exam.domain==domain); exam.removeMetas(); TExample::iterator ei(exam.begin()); TVarList::iterator vi(domain->attributes->begin()); vector<string>::iterator ai(atoms.begin()); TIntList::iterator si(attributeTypes->begin()), se(attributeTypes->end()); TIntList::iterator cb, cp, ce; if (classPoses) { cb = cp = classPoses->begin(); ce = classPoses->end(); } int pos=0; for (; (si!=se); pos++, si++, ai++) { if (*si) { // if attribute is not to be skipped and is not a basket string valstr; // Check for don't care valstr = *ai; if (!valstr.length() || (valstr == "NA") || (valstr == ".") || (DC && (valstr == DC))) valstr = "?"; else if ((valstr == "*") || (DK && (valstr == DK))) valstr = "~"; try { if (*si==-1) if (pos==classPos) { // if this is class value TValue cval; domain->classVar->filestr2val(valstr, cval, exam); exam.setClass(cval); } else if (classPoses && (cp != ce) && (pos == *cp)) { const int ind = cp - cb; domain->classVars->at(ind)->filestr2val(valstr, exam.values_end[ind], exam); cp++; } else { // if this is a normal value (*vi++)->filestr2val(valstr, *ei++, exam); } else { // if this is a meta value TMetaDescriptor *md = domain->metas[*si]; _ASSERT(md!=NULL); TValue mval; md->variable->filestr2val(valstr, mval, exam); exam.setMeta(*si, mval); } } catch (mlexception &err) { raiseError("file '%s', line '%i': %s", fei.filename.c_str(), fei.line, err.what()); } } // the attribute is marked to be skipped, but may also be a basket else { if (pos == basketPos) { TSplits splits; split(*ai, splits); ITERATE(TSplits, si, splits) basketFeeder->addItem(exam, string(si->first, si->second), fei.line); } } } if (pos==classPos) // if class is the last value in the line, it is set here domain->classVar->filestr2val(ai==atoms.end() ? "?" : *(ai++), exam[domain->variables->size()-1], exam); /* I'm not sure that this is needed; this code is a mess but I don't wish to waste time studying it since we are moving to 3.0 */ else if (classPoses && (cp != ce) && (pos == *cp)) { const int ind = cp - cb; domain->classVars->at(ind)->filestr2val(ai==atoms.end() ? "?" : *(ai++), exam.values_end[ind], exam); } while ((ai!=atoms.end()) && !(*ai).length()) ai++; // line must be empty from now on if (ai!=atoms.end()) { vector<string>::iterator ii=atoms.begin(); string s=*ii; while(++ii!=atoms.end()) s+=" "+*ii; raiseError("example of invalid length (%s)", s.c_str()); } return true; }
// for convenience image_element_type operator()( const domain_element_type& de ) const { image_element_type ie( M_dualImageSpace ); apply( de, ie ); return ie; }
void HKUserInterface::OnInputEvent(HKInputManager &manager, const HKInputManager::EventInfo &ev) { HKWidget *pFocusWidget = pFocusList[ev.pSource->sourceID]; if(ev.pSource->device == IDD_Mouse || ev.pSource->device == IDD_TouchPanel) { // positional events will be sent to the hierarchy MFVector pos = { ev.hover.x, ev.hover.y, 0.f, 1.f }; MFVector dir = { 0.f, 0.f, 1.f, 1.f }; MFVector localPos; HKWidget *pWidget = NULL; if(pFocusWidget) { pWidget = pFocusWidget->IntersectWidget(pos, dir, &localPos); if(!pWidget) pWidget = pFocusWidget; } else { pWidget = pRoot->IntersectWidget(pos, dir, &localPos); } // update the down widget if(ev.ev == HKInputManager::IE_Down) pDownOver[ev.pSource->sourceID] = pWidget; else if(ev.ev == HKInputManager::IE_Tap) { // if we receive a tap event, check that it was on the same widget we recorded the down event for if(pDownOver[ev.pSource->sourceID] != pWidget) return; } // check if the hover has changed HKWidget *pHover = pHoverList[ev.pSource->sourceID]; if(pHover != pWidget) { pHoverList[ev.pSource->sourceID] = pWidget; if(pHover) { HKWidgetInputEvent ie(pHover, ev.pSource); pHover->OnHoverOut(*pHover, ie); } if(pWidget) { HKWidgetInputEvent ie(pWidget, ev.pSource); pWidget->OnHoverOver(*pWidget, ie); } } if(pWidget) { HKInputManager::EventInfo transformedEv = ev; LocaliseInput(transformedEv, pWidget, localPos); // send the input event if(pWidget->InputEvent(manager, transformedEv)) return; } } else if(pFocusWidget) { // non-positional events pFocusWidget->InputEvent(manager, ev); } }
SystemPath SystemPath::toRelative( SystemPath const& aBaseSystemPath ) const { // 1. "" (empty) means Model itself, which is invalid for this method. // 2. Not absolute is invalid (not absolute implies not empty). if( ! isAbsolute() || isModel() ) { return *this; } if( ! aBaseSystemPath.isAbsolute() || aBaseSystemPath.isModel() ) { THROW_EXCEPTION( BadSystemPath, "[" + aBaseSystemPath.asString() + "] is not an absolute SystemPath" ); } SystemPath aThisPathCopy; SystemPath const* thisPath; if ( !isCanonicalized() ) { aThisPathCopy = *this; aThisPathCopy.canonicalize(); thisPath = &aThisPathCopy; } else { thisPath = this; } SystemPath aBaseSystemPathCopy; SystemPath const* aCanonicalizedBaseSystemPath; if ( !aBaseSystemPath.isCanonicalized() ) { aCanonicalizedBaseSystemPath = &aBaseSystemPath; } else { aBaseSystemPathCopy = aBaseSystemPath; aBaseSystemPathCopy.canonicalize(); aCanonicalizedBaseSystemPath = &aBaseSystemPathCopy; } SystemPath aRetval; StringVector::const_iterator j( thisPath->theComponents.begin() ), je( thisPath->theComponents.end() ); StringVector::const_iterator i( aCanonicalizedBaseSystemPath->theComponents.begin() ), ie( aCanonicalizedBaseSystemPath->theComponents.end() ); while ( i != ie && j != je ) { String const& aComp( *i ); if ( aComp != *j ) { break; } ++i, ++j; } if ( i != ie ) { while ( i != ie ) { aRetval.theComponents.push_back( ".." ); ++i; } } std::copy( j, je, std::back_inserter( aRetval.theComponents ) ); if ( aRetval.theComponents.empty() ) { aRetval.theComponents.push_back( "." ); } return aRetval; }