void CoreferenceSentenceNumeric::GenerateMentions( const CoreferenceDictionary &dictionary, CoreferenceSentence* instance) { CoreferenceOptions *options = static_cast<CoreferencePipe*>(dictionary.GetPipe())-> GetCoreferenceOptions(); DeleteMentions(); // Generate mentions for named entities. for (int k = 0; k < entity_spans_.size(); ++k) { if (!dictionary.IsNamedEntity(entity_spans_[k]->id())) continue; int mention_start = entity_spans_[k]->start(); int mention_end = entity_spans_[k]->end(); // Expand named entities to include possessives (this only makes sense for // English). if (mention_end < size() - 1 && instance->GetForm(mention_end) == "'s") { ++mention_end; } AddMention(dictionary, instance, mention_start, mention_end, -1); } std::vector<Span*> named_entity_mentions(mentions_.begin(), mentions_.end()); // If this flag is true, use dependencies and ignore constituents altogether // (should be false for English Ontonotes). bool generate_noun_phrase_mentions_by_dependencies = options->generate_noun_phrase_mentions_by_dependencies(); // Generate mentions for noun phrases and pronouns *except* those contained in // the named entity chunks (the named entity tagger seems more reliable than // the parser). if (!generate_noun_phrase_mentions_by_dependencies) { for (int k = 0; k < constituent_spans_.size(); ++k) { if (!dictionary.IsNounPhrase(constituent_spans_[k]->id())) continue; if (constituent_spans_[k]->FindCoveringSpan(named_entity_mentions)) { continue; } AddMention(dictionary, instance, constituent_spans_[k]->start(), constituent_spans_[k]->end(), -1); } } if (generate_noun_phrase_mentions_by_dependencies) { // Generate mentions for noun descendants *except* those contained in // the named entity chunks (the named entity tagger seems more reliable than // the parser). std::vector<std::set<int> > descendants(size()); for (int i = 1; i < size(); ++i) { descendants[i].insert(i); std::vector<int> ancestors; GetAllAncestors(heads_, i, &ancestors); for (int j = 0; j < ancestors.size(); ++j) { CHECK_GE(ancestors[j], 0); CHECK_LT(ancestors[j], descendants.size()); descendants[ancestors[j]].insert(i); } } for (int i = 0; i < size(); ++i) { if (!dictionary.IsNoun(pos_ids_[i])) continue; // Get largest continuous span of descendants. int start = i; while (start > 0 && descendants[i].find(start) != descendants[i].end()) { --start; } ++start; int end = i; while (end < size() && descendants[i].find(end) != descendants[i].end()) { ++end; } --end; // TODO(atm): add some specificities for Portuguese. if (start > 0 && end > 0 && end >= start) { Span span(start, end); if (span.FindCoveringSpan(named_entity_mentions)) { continue; } AddMention(dictionary, instance, start, end, -1); } } } for (int i = 0; i < size(); ++i) { if (!dictionary.IsPronounTag(pos_ids_[i])) continue; // TODO(atm): for Portuguese need to ignore "se" and "-se". Span span(i, i); if (span.FindCoveringSpan(named_entity_mentions)) continue; AddMention(dictionary, instance, i, i, -1); } // Filter and sort mentions. FilterAndSortMentions(dictionary, instance); }
// Scale object boundings to [-5,5] void DXFRenderer::NormalizeEntities() { // calculate current min and max boundings of object DXFVector minv(10e20f, 10e20f, 10e20f); DXFVector maxv(-10e20f, -10e20f, -10e20f); for (DXFEntityList::compatibility_iterator node = m_entities.GetFirst(); node; node = node->GetNext()) { DXFEntity *p = node->GetData(); if (p->type == DXFEntity::Line) { DXFLine *line = (DXFLine *)p; const DXFVector *v[2] = { &line->v0, &line->v1 }; for (int i = 0; i < 2; ++i) { minv.x = mymin(v[i]->x, minv.x); minv.y = mymin(v[i]->y, minv.y); minv.z = mymin(v[i]->z, minv.z); maxv.x = mymax(v[i]->x, maxv.x); maxv.y = mymax(v[i]->y, maxv.y); maxv.z = mymax(v[i]->z, maxv.z); } } else if (p->type == DXFEntity::Face) { DXFFace *face = (DXFFace *)p; const DXFVector *v[4] = { &face->v0, &face->v1, &face->v2, &face->v3 }; for (int i = 0; i < 4; ++i) { minv.x = mymin(v[i]->x, minv.x); minv.y = mymin(v[i]->y, minv.y); minv.z = mymin(v[i]->z, minv.z); maxv.x = mymax(v[i]->x, maxv.x); maxv.y = mymax(v[i]->y, maxv.y); maxv.z = mymax(v[i]->z, maxv.z); } } } // rescale object down to [-5,5] DXFVector span(maxv.x - minv.x, maxv.y - minv.y, maxv.z - minv.z); float factor = mymin(mymin(10.0f / span.x, 10.0f / span.y), 10.0f / span.z); for (DXFEntityList::compatibility_iterator node2 = m_entities.GetFirst(); node2; node2 = node2->GetNext()) { DXFEntity *p = node2->GetData(); if (p->type == DXFEntity::Line) { DXFLine *line = (DXFLine *)p; DXFVector *v[2] = { &line->v0, &line->v1 }; for (int i = 0; i < 2; ++i) { v[i]->x -= minv.x + span.x/2; v[i]->x *= factor; v[i]->y -= minv.y + span.y/2; v[i]->y *= factor; v[i]->z -= minv.z + span.z/2; v[i]->z *= factor; } } else if (p->type == DXFEntity::Face) { DXFFace *face = (DXFFace *)p; DXFVector *v[4] = { &face->v0, &face->v1, &face->v2, &face->v3 }; for (int i = 0; i < 4; ++i) { v[i]->x -= minv.x + span.x/2; v[i]->x *= factor; v[i]->y -= minv.y + span.y/2; v[i]->y *= factor; v[i]->z -= minv.z + span.z/2; v[i]->z *= factor; } } } }
void main(int argc, char *argv[]) { int c; Binit(&bso, 1, OWRITE); cout = -1; listinit(); memset(debug, 0, sizeof(debug)); nerrors = 0; outfile = nil; HEADTYPE = -1; INITTEXT = -1; INITDAT = -1; INITRND = -1; INITENTRY = 0; ARGBEGIN { default: c = ARGC(); if(c == 'l') usage(); if(c >= 0 && c < sizeof(debug)) debug[c]++; break; case 'o': /* output to (next arg) */ outfile = EARGF(usage()); break; case 'E': INITENTRY = EARGF(usage()); break; case 'H': HEADTYPE = headtype(EARGF(usage())); break; case 'I': interpreter = EARGF(usage()); break; case 'L': Lflag(EARGF(usage())); break; case 'T': INITTEXT = atolwhex(EARGF(usage())); break; case 'D': INITDAT = atolwhex(EARGF(usage())); break; case 'R': INITRND = atolwhex(EARGF(usage())); break; case 'r': rpath = EARGF(usage()); break; case 'V': print("%cl version %s\n", thechar, getgoversion()); errorexit(); } ARGEND if(argc != 1) usage(); mywhatsys(); // get goos if(HEADTYPE == -1) HEADTYPE = headtype(goos); if(outfile == nil) { if(HEADTYPE == Hwindows) outfile = "8.out.exe"; else outfile = "8.out"; } libinit(); switch(HEADTYPE) { default: diag("unknown -H option"); errorexit(); case Hgarbunix: /* this is garbage */ HEADR = 20L+56L; if(INITTEXT == -1) INITTEXT = 0x40004CL; if(INITDAT == -1) INITDAT = 0x10000000L; if(INITRND == -1) INITRND = 0; break; case Hunixcoff: /* is unix coff */ HEADR = 0xd0L; if(INITTEXT == -1) INITTEXT = 0xd0; if(INITDAT == -1) INITDAT = 0x400000; if(INITRND == -1) INITRND = 0; break; case Hplan9x32: /* plan 9 */ tlsoffset = -8; HEADR = 32L; if(INITTEXT == -1) INITTEXT = 4096+32; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hmsdoscom: /* MS-DOS .COM */ HEADR = 0; if(INITTEXT == -1) INITTEXT = 0x0100; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hmsdosexe: /* fake MS-DOS .EXE */ HEADR = 0x200; if(INITTEXT == -1) INITTEXT = 0x0100; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; HEADR += (INITTEXT & 0xFFFF); if(debug['v']) Bprint(&bso, "HEADR = 0x%d\n", HEADR); break; case Hdarwin: /* apple MACH */ /* * OS X system constant - offset from %gs to our TLS. * Explained in ../../libcgo/darwin_386.c. */ tlsoffset = 0x468; machoinit(); HEADR = INITIAL_MACHO_HEADR; if(INITTEXT == -1) INITTEXT = 4096+HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hlinux: /* elf32 executable */ case Hfreebsd: /* * ELF uses TLS offsets negative from %gs. * Translate 0(GS) and 4(GS) into -8(GS) and -4(GS). * Also known to ../../pkg/runtime/linux/386/sys.s * and ../../libcgo/linux_386.c. */ tlsoffset = -8; elfinit(); HEADR = ELFRESERVE; if(INITTEXT == -1) INITTEXT = 0x08048000+HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hwindows: /* PE executable */ peinit(); HEADR = PEFILEHEADR; if(INITTEXT == -1) INITTEXT = PEBASE+PESECTHEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = PESECTALIGN; break; } if(INITDAT != 0 && INITRND != 0) print("warning: -D0x%ux is ignored because of -R0x%ux\n", INITDAT, INITRND); if(debug['v']) Bprint(&bso, "HEADER = -H0x%d -T0x%ux -D0x%ux -R0x%ux\n", HEADTYPE, INITTEXT, INITDAT, INITRND); Bflush(&bso); instinit(); zprg.link = P; zprg.pcond = P; zprg.back = 2; zprg.as = AGOK; zprg.from.type = D_NONE; zprg.from.index = D_NONE; zprg.from.scale = 1; zprg.to = zprg.from; pcstr = "%.6ux "; nuxiinit(); histgen = 0; pc = 0; dtype = 4; version = 0; cbp = buf.cbuf; cbc = sizeof(buf.cbuf); addlibpath("command line", "command line", argv[0], "main"); loadlib(); deadcode(); patch(); follow(); doelf(); if(HEADTYPE == Hdarwin) domacho(); if(HEADTYPE == Hwindows) dope(); dostkoff(); if(debug['p']) if(debug['1']) doprof1(); else doprof2(); span(); addexport(); textaddress(); pclntab(); symtab(); dodata(); address(); doweak(); reloc(); asmb(); undef(); if(debug['v']) { Bprint(&bso, "%5.2f cpu time\n", cputime()); Bprint(&bso, "%d symbols\n", nsymbol); Bprint(&bso, "%d sizeof adr\n", sizeof(Adr)); Bprint(&bso, "%d sizeof prog\n", sizeof(Prog)); } Bflush(&bso); errorexit(); }
string keyword(const string &x) { return span("Keyword", x); }
string symbol(const string &x) { return span("Symbol", x); }
void block_queue::add_blocks(uint64_t height, uint64_t nblocks, const boost::uuids::uuid &connection_id, boost::posix_time::ptime time) { boost::unique_lock<boost::recursive_mutex> lock(mutex); blocks.insert(span(height, nblocks, connection_id, time)); }
string matched(const string &cls, const string &body, int id = -1) { return span(cls + " Matched", body, id); }
TokenSpan span(Position i) const { return span(this->begin() + i); }
Slice inputSlice(const_iterator i) const { return toSlice(*pinput, span(i)); }
char * ovOverlap::toString(char *str, ovOverlapDisplayType type, bool newLine) { switch (type) { case ovOverlapAsHangs: sprintf(str, "%10"F_U32P" %10"F_U32P" %c %6"F_S32P" %6"F_U32P" %6"F_S32P" %7.6f%s%s", a_iid, b_iid, flipped() ? 'I' : 'N', a_hang(), span(), b_hang(), erate(), (overlapIsDovetail()) ? "" : " PARTIAL", (newLine) ? "\n" : ""); break; case ovOverlapAsCoords: sprintf(str, "%10"F_U32P" %10"F_U32P" %c %6"F_U32P" %6"F_U32P" %6"F_U32P" %6"F_U32P" %6"F_U32P" %7.6f%s", a_iid, b_iid, flipped() ? 'I' : 'N', span(), a_bgn(), a_end(), b_bgn(), b_end(), erate(), (newLine) ? "\n" : ""); break; case ovOverlapAsRaw: sprintf(str, "%10"F_U32P" %10"F_U32P" %c %6"F_U32P" %6"F_U64P" %6"F_U64P" %6"F_U64P" %6"F_U64P" %7.6f %s %s %s%s", a_iid, b_iid, flipped() ? 'I' : 'N', span(), dat.ovl.ahg5, dat.ovl.ahg3, dat.ovl.bhg5, dat.ovl.bhg3, erate(), dat.ovl.forOBT ? "OBT" : " ", dat.ovl.forDUP ? "DUP" : " ", dat.ovl.forUTG ? "UTG" : " ", (newLine) ? "\n" : ""); break; case ovOverlapAsCompat: sprintf(str, "%8"F_U32P" %8"F_U32P" %c %6d %6d %5.2f %5.2f%s", a_iid, b_iid, dat.ovl.flipped ? 'I' : 'N', a_hang(), b_hang(), erate() * 100.0, erate() * 100.0, (newLine) ? "\n" : ""); break; case ovOverlapAsPaf: // miniasm/map expects entries to be separated by tabs // no padding spaces on names we don't confuse read identifiers sprintf(str, "%"F_U32P"\t%6"F_U32P"\t%6"F_U32P"\t%6"F_U32P"\t%c\t%"F_U32P"\t%6"F_U32P"\t%6"F_U32P"\t%6"F_U32P"\t%6"F_U32P"\t%6"F_U32P"\t%6"F_U32P" %s", a_iid, (g->gkStore_getRead(a_iid)->gkRead_sequenceLength()), a_bgn(), a_end(), flipped() ? '-' : '+', b_iid, (g->gkStore_getRead(b_iid)->gkRead_sequenceLength()), flipped() ? b_end() : b_bgn(), flipped() ? b_bgn() : b_end(), (uint32)floor(span() == 0 ? (1-erate() * (a_end()-a_bgn())) : (1-erate()) * span()), span() == 0 ? a_end() - a_bgn() : span(), 255, (newLine) ? "\n" : ""); break; } return(str); }
void CCurve::ChangeStart(const Point &p) { CCurve new_curve; bool started = false; bool finished = false; int start_span = 0; bool closed = IsClosed(); for(int i = 0; i < (closed ? 2:1); i++) { const Point *prev_p = NULL; int span_index = 0; for(std::list<CVertex>::const_iterator VIt = m_vertices.begin(); VIt != m_vertices.end() && !finished; VIt++) { const CVertex& vertex = *VIt; if(prev_p) { Span span(*prev_p, vertex); if(span.On(p)) { if(started) { if(p == *prev_p || span_index != start_span) { new_curve.m_vertices.push_back(vertex); } else { if(p == vertex.m_p)new_curve.m_vertices.push_back(vertex); else { CVertex v(vertex); v.m_p = p; new_curve.m_vertices.push_back(v); } finished = true; } } else { new_curve.m_vertices.push_back(CVertex(p)); started = true; start_span = span_index; if(p != vertex.m_p)new_curve.m_vertices.push_back(vertex); } } else { if(started) { new_curve.m_vertices.push_back(vertex); } } span_index++; } prev_p = &(vertex.m_p); } } if(started) { *this = new_curve; } }
int main(){ Mecanismo P = Mecanismo(2); cube I1__; I1__.zeros(3,3,2); I1__.slice(0) << 0 << 0 << 0 << endr << 0 << 107.307e-6 + 146.869e-6 << 0 << endr << 0 << 0 << 107.307e-6 + 146.869e-6 << endr; I1__.slice(1) << 0 << 0 << 0 << endr << 0 << 438.0e-6 << 0 << endr << 0 << 0 << 438.0e-6 << endr; cube I2__; I2__.zeros(3,3,2); I2__.slice(0) << 0 << 0 << 0 << endr << 0 << 107.307e-6 + 188.738e-6 << 0 << endr << 0 << 0 << 107.307e-6 + 188.738e-6 << endr; I2__.slice(1) << 0 << 0 << 0 << endr << 0 << 301.679e-6 << 0 << endr << 0 << 0 << 301.679e-6 << endr; Serial RR1 = Serial(2, {0.12, 0.16}, {0.06, 0.078},{0.062, 0.124}, I1__ , {0, 0, 9.8}, &fDH_RR); Serial RR2 = Serial(2, {0.12, 0.16}, {0.06, 0.058},{0.062, 0.097}, I2__ , {0, 0, 9.8}, &fDH_RR); Serial **RR_ = new Serial* [2]; RR_[0] = &RR1; RR_[1] = &RR2; //Matrizes que descrevem a arquitetura do mecanismo double l0 = 0.05; mat D_ = join_vert((mat)eye(2,2),2); mat E_ = join_diag( Roty(0)(span(0,1),span(0,2)), Roty(PI)(span(0,1),span(0,2)) ); mat F_ = zeros(4,4); vec f_ = {l0,0,-l0,0}; Parallel Robot = Parallel(2, &P, RR_, 2, {2,4}, D_, E_, F_, f_); Reference RefObj = Reference(0.12, {0.08, 0.16}, {-0.08, 0.4}); //Plotar área de trabalho uint nx = 96.0; uint ny = 56.0; double lx = 0.24; double ly = 0.28; double xi = -lx; double xf = lx; double yi = 0.0; double yf = ly; double dx = (xf-xi)/(nx-1); double dy = (yf-yi)/(ny-1); double dl = 0.5*(dx+dy); Mat<int> M; M.zeros(nx,ny); field<mat> fZ_(nx,ny); field<mat> fMh_(nx,ny); field<vec> fgh_(nx,ny); field<vec> fa1_(nx,ny); field<vec> fa2_(nx,ny); field<vec> fa12_(nx,ny); for(uint i=0; i<nx; i++){ for(uint j=0; j<ny; j++){ fZ_(i,j).zeros(2,2); fMh_(i,j).zeros(2,2); fgh_(i,j).zeros(2); fa1_(i,j).zeros(2); fa2_(i,j).zeros(2); fa12_(i,j).zeros(2); } } vec v1_ = {1,0}; vec v2_ = {0,1}; vec v12_ = {1,1}; double r = 0.07; double x0 = 0.0; double y0 = 0.17; uint rows = nx; uint cols = ny; vec q0_ = {0.823167, 1.81774, 0.823167, 1.81774}; GNR2 gnr2 = GNR2("RK6", &Robot, 1e-6, 30); //gnr2.Doit(q0_, {0.05,0.08}); //cout << gnr2.convergiu << endl; //cout << gnr2.x_ << endl; //cout << gnr2.res_ << endl; //cout << gnr2.n << endl; double x; double y; mat A2_; for(uint i=0; i<rows; i++){ for(uint j=0; j<cols; j++){ x = xi + i*dx; y = yi + j*dy; gnr2.Doit(q0_, {x, y}); if(gnr2.convergiu){ q0_ = gnr2.x_; A2_ = join_horiz(Robot.Ah_, join_horiz(Robot.Ao_.col(1), Robot.Ao_.col(3)) ); if(abs(det(Robot.Ao_)) < 1.6*1e-6 || abs(det(A2_)) < 1e-11 ) M(i,j) = 2; else{ M(i,j) = 1; Robot.Doit(Robot.q0_, join_vert(v1_, -solve(Robot.Ao_, Robot.Ah_*v1_)) ); fZ_(i,j) = Robot.Z_; fMh_(i,j) = Robot.dy->Mh_; fgh_(i,j) = Robot.dy->gh_; fa1_(i,j) = Robot.dy->vh_; Robot.Doit(Robot.q0_, Robot.C_*v2_); fa2_(i,j) = Robot.dy->vh_; Robot.Doit(Robot.q0_, Robot.C_*v12_); fa12_(i,j) = Robot.dy->vh_ - fa1_(i,j) - fa2_(i,j); } } gnr2.convergiu = false; if( ((x - x0)*(x - x0) + (y - y0)*(y - y0) <= (r+dl)*(r+dl) ) && ((x - x0)*(x - x0) + (y - y0)*(y - y0) >= (r-dl)*(r-dl) ) && (M(i,j) != 2) ) M(i,j) = 3; } } for(uint i=0; i<rows; i++){ for(uint j=0; j<cols; j++){ cout << M(i,j) << ";" ; if(j==cols-1) cout << endl; } } fZ_.save("fZ_field"); fMh_.save("fMh_field"); fgh_.save("fgh_field"); fa1_.save("fa1_field"); fa2_.save("fa2_field"); fa12_.save("fa12_field"); return 0; }
void main(int argc, char *argv[]) { char *p; Sym *s; Binit(&bso, 1, OWRITE); listinit(); nerrors = 0; outfile = "5.out"; HEADTYPE = -1; INITTEXT = -1; INITDAT = -1; INITRND = -1; INITENTRY = 0; linkmode = LinkAuto; nuxiinit(); p = getgoarm(); if(p != nil) goarm = atoi(p); else goarm = 6; if(goarm == 5) debug['F'] = 1; flagcount("1", "use alternate profiling code", &debug['1']); flagfn1("B", "info: define ELF NT_GNU_BUILD_ID note", addbuildinfo); flagstr("E", "sym: entry symbol", &INITENTRY); flagint32("D", "addr: data address", &INITDAT); flagcount("G", "debug pseudo-ops", &debug['G']); flagfn1("I", "interp: set ELF interp", setinterp); flagfn1("L", "dir: add dir to library path", Lflag); flagfn1("H", "head: header type", setheadtype); flagcount("K", "add stack underflow checks", &debug['K']); flagcount("M", "disable software div/mod", &debug['M']); flagcount("O", "print pc-line tables", &debug['O']); flagcount("P", "debug code generation", &debug['P']); flagint32("R", "rnd: address rounding", &INITRND); flagint32("T", "addr: text address", &INITTEXT); flagfn0("V", "print version and exit", doversion); flagcount("W", "disassemble input", &debug['W']); flagfn2("X", "name value: define string data", addstrdata); flagcount("Z", "clear stack frame on entry", &debug['Z']); flagcount("a", "disassemble output", &debug['a']); flagcount("c", "dump call graph", &debug['c']); flagcount("d", "disable dynamic executable", &debug['d']); flagstr("extld", "linker to run in external mode", &extld); flagstr("extldflags", "flags for external linker", &extldflags); flagcount("f", "ignore version mismatch", &debug['f']); flagcount("g", "disable go package data checks", &debug['g']); flagstr("k", "sym: set field tracking symbol", &tracksym); flagfn1("linkmode", "mode: set link mode (internal, external, auto)", setlinkmode); flagcount("n", "dump symbol table", &debug['n']); flagstr("o", "outfile: set output file", &outfile); flagcount("p", "insert profiling code", &debug['p']); flagstr("r", "dir1:dir2:...: set ELF dynamic linker search path", &rpath); flagcount("race", "enable race detector", &flag_race); flagcount("s", "disable symbol table", &debug['s']); flagcount("shared", "generate shared object (implies -linkmode external)", &flag_shared); flagstr("tmpdir", "leave temporary files in this directory", &tmpdir); flagcount("u", "reject unsafe packages", &debug['u']); flagcount("v", "print link trace", &debug['v']); flagcount("w", "disable DWARF generation", &debug['w']); flagparse(&argc, &argv, usage); if(argc != 1) usage(); if(flag_shared) linkmode = LinkExternal; mywhatsys(); if(HEADTYPE == -1) HEADTYPE = headtype(goos); // getgoextlinkenabled is based on GO_EXTLINK_ENABLED when // Go was built; see ../../make.bash. if(linkmode == LinkAuto && strcmp(getgoextlinkenabled(), "0") == 0) linkmode = LinkInternal; switch(HEADTYPE) { default: if(linkmode == LinkAuto) linkmode = LinkInternal; if(linkmode == LinkExternal && strcmp(getgoextlinkenabled(), "1") != 0) sysfatal("cannot use -linkmode=external with -H %s", headstr(HEADTYPE)); break; case Hlinux: break; } libinit(); switch(HEADTYPE) { default: diag("unknown -H option"); errorexit(); case Hnoheader: /* no header */ HEADR = 0L; if(INITTEXT == -1) INITTEXT = 0; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hrisc: /* aif for risc os */ HEADR = 128L; if(INITTEXT == -1) INITTEXT = 0x10005000 + HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hplan9x32: /* plan 9 */ HEADR = 32L; if(INITTEXT == -1) INITTEXT = 4128; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hixp1200: /* boot for IXP1200 */ HEADR = 0L; if(INITTEXT == -1) INITTEXT = 0x0; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hipaq: /* boot for ipaq */ HEADR = 16L; if(INITTEXT == -1) INITTEXT = 0xC0008010; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 1024; break; case Hlinux: /* arm elf */ case Hfreebsd: case Hnetbsd: debug['d'] = 0; // with dynamic linking tlsoffset = -8; // hardcoded number, first 4-byte word for g, and then 4-byte word for m // this number is known to ../../pkg/runtime/rt0_*_arm.s elfinit(); HEADR = ELFRESERVE; if(INITTEXT == -1) INITTEXT = 0x10000 + HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; } if(INITDAT != 0 && INITRND != 0) print("warning: -D0x%ux is ignored because of -R0x%ux\n", INITDAT, INITRND); if(debug['v']) Bprint(&bso, "HEADER = -H0x%d -T0x%ux -D0x%ux -R0x%ux\n", HEADTYPE, INITTEXT, INITDAT, INITRND); Bflush(&bso); zprg.as = AGOK; zprg.scond = 14; zprg.reg = NREG; zprg.from.name = D_NONE; zprg.from.type = D_NONE; zprg.from.reg = NREG; zprg.to = zprg.from; buildop(); histgen = 0; pc = 0; dtype = 4; version = 0; cbp = buf.cbuf; cbc = sizeof(buf.cbuf); // embed goarm to runtime.goarm s = lookup("runtime.goarm", 0); s->dupok = 1; adduint8(s, goarm); addlibpath("command line", "command line", argv[0], "main"); loadlib(); // mark some functions that are only referenced after linker code editing if(debug['F']) mark(rlookup("_sfloat", 0)); mark(lookup("runtime.read_tls_fallback", 0)); deadcode(); if(textp == nil) { diag("no code"); errorexit(); } patch(); if(debug['p']) if(debug['1']) doprof1(); else doprof2(); doelf(); follow(); softfloat(); // 5l -Z means zero the stack frame on entry. // This slows down function calls but can help avoid // false positives in garbage collection. if(debug['Z']) dozerostk(); noops(); // generate stack split prolog, handle div/mod, etc. dostkcheck(); span(); addexport(); // textaddress() functionality is handled in span() pclntab(); symtab(); dodata(); address(); doweak(); reloc(); asmb(); undef(); hostlink(); if(debug['c']) print("ARM size = %d\n", armsize); if(debug['v']) { Bprint(&bso, "%5.2f cpu time\n", cputime()); Bprint(&bso, "%d sizeof adr\n", sizeof(Adr)); Bprint(&bso, "%d sizeof prog\n", sizeof(Prog)); } Bflush(&bso); errorexit(); }
PLCP augment_plcp(const PLCP & original, vec & x, vec & y, vec & w, double scale){ uint N = original.P.n_rows; uint K = original.P.n_cols; assert(size(K,N) == size(original.U)); sp_mat P = sp_mat(original.P); double I_norm = norm(speye(K,K) - P.t() * P); if(norm(I_norm) >= PRETTY_SMALL){ cerr << "Error: P does not look orthogonal (" << I_norm << ")..." << endl; } assert(I_norm < PRETTY_SMALL); sp_mat U = sp_mat(original.U); vec q = vec(original.q); assert(all(q(find(1 == original.free_vars)) <= 0)); vec q_neg = min(zeros<vec>(N),q); vec q_pos = max(zeros<vec>(N),q); x = ones<vec>(N) - q_neg; y = ones<vec>(N) + q_pos; y(find(1 == original.free_vars)).fill(0); assert(norm(q_pos(find(1 == original.free_vars))) < ALMOST_ZERO); assert(N == x.n_elem); assert(N == y.n_elem); assert(all(x >= 0)); assert(all(y >= 0)); vec res = x - y + q; w = spsolve(P.t()*P + 1e-15*speye(K,K),P.t()*(x - y + q)); vec w_res = P * w - res; if(norm(w_res) >= PRETTY_SMALL){ cerr << "Error: Reduced vector w residual large (" << w_res << ")..." << endl; } assert(norm(w_res) < PRETTY_SMALL); vec b = P.t()*x - U*x - w; assert(K == b.n_elem); P.resize(N+1,K+1); U.resize(K+1,N+1); q.resize(N+1); P(N,K) = 1.0; U(span(0,K-1),N) = b; U(K,N) = scale; q(N) = 0; x.resize(N+1); y.resize(N+1); w.resize(K+1); x(N) = 1; y(N) = scale; w(K) = 1.0 - scale; bvec free_vars = bvec(N+1); free_vars.head(N) = original.free_vars; free_vars(N) = 0; return PLCP(P,U,q,free_vars); }
void Counter::update(){ Model::update(); Poco::Timespan span(ofClamp(70000000-(long)audioClock->getElapsedTimeMicros(),0,70000000)); now = Poco::DateTimeFormatter::format(span,"%M %S %i"); }
std::string input(const_iterator i) const { return substring(*pinput, span(i)); }
int main(int argc, char** argv) { #if !defined(_WIN32) && !defined(_WIN64) printf("Only Windows OS is supported.\n"); #else if(argc < 3) { printf("usage: %s <dir> <command>\n", argv[0]); return -1; } char path[512]; sprintf_s(path, 511, "%s\\%s.pid", argv[1], argv[2]); DWORD pid = 0; FILE* f = NULL; fopen_s(&f, path, "r"); if(!f) { fprintf(stderr, "Can't open file %s\n", path); } else { char* pidbuf[32]; int numread = fread(pidbuf, sizeof(char), 31, f); if(numread > 0) { pidbuf[numread] = '\0'; pid = atoi((const char*)pidbuf); } } if(pid > 0) { printf("ProcessID: %d\n", pid); HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION, false, pid); if(h <= 0) { fprintf(stderr, "Process %d can't be opened.\n", pid); printf("ProcessUpTime: \n"); } else { //Process elapsed time. BIGTIME CreateTime, ExitTime, ElapsedTime, Now; FILETIME KernelTime, UserTime; GetProcessTimes(h, &CreateTime.ft, &ExitTime.ft, &KernelTime, &UserTime); if(ExitTime.li > CreateTime.li) ElapsedTime.li = ExitTime.li - CreateTime.li; else { GetSystemTimeAsFileTime(&Now.ft); ElapsedTime.li = Now.li - CreateTime.li; } unsigned elapsedsecs = (unsigned)(ElapsedTime.li/10000000); TSpan span(elapsedsecs); printf("ProcessUpTime: %d-%02d:%02d:%02d\n", span.d, span.h, span.m, span.s); } } else { printf("ProcessID: \nProcessUpTime: \n"); } //CPU usage BIGTIME idle1, kernel1, user1, idle2, kernel2, user2; GetSystemTimes(&idle1.ft, &kernel1.ft, &user1.ft); Sleep(1000); GetSystemTimes(&idle2.ft, &kernel2.ft, &user2.ft); int IdleTime = (int)(idle2.li - idle1.li); int TotalTime = (int)((kernel2.li + user2.li) - (kernel1.li + user1.li)); int idleRate = (int)(100.0 * IdleTime / TotalTime); printf("CPU-Idle: %d%%\n", idleRate); //Computer uptime LARGE_INTEGER ticks, unit; QueryPerformanceCounter(&ticks); QueryPerformanceFrequency(&unit); int secs = (int)(ticks.QuadPart/unit.QuadPart); TSpan u((int)secs); printf("ComputerUpTime: %d days, %d:%d\n", u.d, u.h, u.m); printf("---SpaceUsedAndFree---\n"); //Physical and virtual memory usage. MEMORYSTATUS memstatus; GlobalMemoryStatus(&memstatus); printf("Physical Memory: %d %d\nVirtual Memory: %d %d\n", (memstatus.dwTotalPhys - memstatus.dwAvailPhys)/1024, memstatus.dwAvailPhys/1024, (memstatus.dwTotalVirtual - memstatus.dwAvailVirtual)/1024, memstatus.dwAvailVirtual/1024); // Disk Usage char drivePath[] = "?:\\"; char driveName; for( driveName = 'A'; driveName <= 'Z'; driveName++ ) { drivePath[0] = driveName; int dtype = GetDriveTypeA(drivePath); if(dtype == DRIVE_FIXED || dtype == DRIVE_RAMDISK || dtype == DRIVE_REMOVABLE || dtype == DRIVE_CDROM) { ULARGE_INTEGER diskAvailStruct; ULARGE_INTEGER diskTotalStruct; diskAvailStruct.QuadPart = 0; diskTotalStruct.QuadPart = 0; GetDiskFreeSpaceExA(drivePath, &diskAvailStruct, &diskTotalStruct, 0); double DiskSize = diskTotalStruct.QuadPart / 1024.0; double FreeSize = diskAvailStruct.QuadPart / 1024.0; printf("%s: %.0f %.0f\n", drivePath, DiskSize - FreeSize, FreeSize); } } #endif return 0; }
void wxTimeSpinCtrl::DoSpin(int diff) { int tp = GetTimePart(); long oldValue = 0, maxValue = 0, mult = 0; switch (tp) { case 0: oldValue = spinValue; maxValue = 60; mult = 1; break; case 1: oldValue = spinValue / 60; maxValue = 60; mult = 60; break; case 2: oldValue = spinValue / 60 / 60; if (hasDay) maxValue = 24; else maxValue = maxSpinValue / 60 / 60; mult = 60 * 60; break; case 3: oldValue = spinValue / 60 / 60 / 24; maxValue = maxSpinValue / 60 / 60 / 24; mult = 60 * 60 * 24; break; default: // can't happen break; } oldValue %= maxValue; int newValue = oldValue + diff; if (!canWrap) { if (newValue < 0) diff += maxValue; else if (newValue >= maxValue) diff -= maxValue; } long newSpinValue = spinValue + diff * mult; if (newSpinValue < 0) newSpinValue = maxSpinValue - 1; else if (newSpinValue > maxSpinValue) newSpinValue = 0; if (spinValue != newSpinValue) { spinValue = newSpinValue; wxTimeSpan span(0, 0, spinValue); wxString txt = span.Format(m_format); m_txt->SetValue(txt); Highlight(tp); wxSpinEvent ev; ev.SetEventObject(this); ev.SetId(GetId()); #if wxCHECK_VERSION(2, 9, 0) GetParent()->GetEventHandler()->ProcessEvent(ev); #else GetParent()->ProcessEvent(ev); #endif } }
void main(int argc, char *argv[]) { int c; char *p, *name, *val; Binit(&bso, 1, OWRITE); listinit(); nerrors = 0; outfile = "5.out"; HEADTYPE = -1; INITTEXT = -1; INITDAT = -1; INITRND = -1; INITENTRY = 0; nuxiinit(); p = getenv("GOARM"); if(p != nil && strcmp(p, "5") == 0) debug['F'] = 1; ARGBEGIN { default: c = ARGC(); if(c == 'l') usage(); if(c >= 0 && c < sizeof(debug)) debug[c]++; break; case 'o': outfile = EARGF(usage()); break; case 'E': INITENTRY = EARGF(usage()); break; case 'I': debug['I'] = 1; // denote cmdline interpreter override interpreter = EARGF(usage()); break; case 'L': Lflag(EARGF(usage())); break; case 'T': INITTEXT = atolwhex(EARGF(usage())); break; case 'D': INITDAT = atolwhex(EARGF(usage())); break; case 'R': INITRND = atolwhex(EARGF(usage())); break; case 'r': rpath = EARGF(usage()); break; case 'H': HEADTYPE = headtype(EARGF(usage())); /* do something about setting INITTEXT */ break; case 'V': print("%cl version %s\n", thechar, getgoversion()); errorexit(); case 'X': name = EARGF(usage()); val = EARGF(usage()); addstrdata(name, val); break; } ARGEND USED(argc); if(argc != 1) usage(); libinit(); if(HEADTYPE == -1) HEADTYPE = Hlinux; switch(HEADTYPE) { default: diag("unknown -H option"); errorexit(); case Hnoheader: /* no header */ HEADR = 0L; if(INITTEXT == -1) INITTEXT = 0; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hrisc: /* aif for risc os */ HEADR = 128L; if(INITTEXT == -1) INITTEXT = 0x10005000 + HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hplan9x32: /* plan 9 */ HEADR = 32L; if(INITTEXT == -1) INITTEXT = 4128; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hnetbsd: /* boot for NetBSD */ HEADR = 32L; if(INITTEXT == -1) INITTEXT = 0xF0000020L; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hixp1200: /* boot for IXP1200 */ HEADR = 0L; if(INITTEXT == -1) INITTEXT = 0x0; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hipaq: /* boot for ipaq */ HEADR = 16L; if(INITTEXT == -1) INITTEXT = 0xC0008010; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 1024; break; case Hlinux: /* arm elf */ debug['d'] = 0; // with dynamic linking tlsoffset = -8; // hardcoded number, first 4-byte word for g, and then 4-byte word for m // this number is known to ../../pkg/runtime/cgo/gcc_linux_arm.c elfinit(); HEADR = ELFRESERVE; if(INITTEXT == -1) INITTEXT = 0x10000 + HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; } if(INITDAT != 0 && INITRND != 0) print("warning: -D0x%ux is ignored because of -R0x%ux\n", INITDAT, INITRND); if(debug['v']) Bprint(&bso, "HEADER = -H0x%d -T0x%ux -D0x%ux -R0x%ux\n", HEADTYPE, INITTEXT, INITDAT, INITRND); Bflush(&bso); zprg.as = AGOK; zprg.scond = 14; zprg.reg = NREG; zprg.from.name = D_NONE; zprg.from.type = D_NONE; zprg.from.reg = NREG; zprg.to = zprg.from; buildop(); histgen = 0; pc = 0; dtype = 4; version = 0; cbp = buf.cbuf; cbc = sizeof(buf.cbuf); addlibpath("command line", "command line", argv[0], "main"); loadlib(); // mark some functions that are only referenced after linker code editing if(debug['F']) mark(rlookup("_sfloat", 0)); deadcode(); if(textp == nil) { diag("no code"); errorexit(); } patch(); if(debug['p']) if(debug['1']) doprof1(); else doprof2(); doelf(); follow(); softfloat(); noops(); dostkcheck(); span(); addexport(); // textaddress() functionality is handled in span() pclntab(); symtab(); dodata(); address(); doweak(); reloc(); asmb(); undef(); if(debug['c']) print("ARM size = %d\n", armsize); if(debug['v']) { Bprint(&bso, "%5.2f cpu time\n", cputime()); Bprint(&bso, "%d sizeof adr\n", sizeof(Adr)); Bprint(&bso, "%d sizeof prog\n", sizeof(Prog)); } Bflush(&bso); errorexit(); }
inline void GenEigsSolver<eT, SelectionRule, OpType>::factorise_from(uword from_k, uword to_m, const Col<eT>& fk) { arma_extra_debug_sigprint(); if(to_m <= from_k) { return; } fac_f = fk; Col<eT> w(dim_n); eT beta = norm(fac_f); // Keep the upperleft k x k submatrix of H and set other elements to 0 fac_H.tail_cols(ncv - from_k).zeros(); fac_H.submat(span(from_k, ncv - 1), span(0, from_k - 1)).zeros(); for(uword i = from_k; i <= to_m - 1; i++) { bool restart = false; // If beta = 0, then the next V is not full rank // We need to generate a new residual vector that is orthogonal // to the current V, which we call a restart if(beta < eps) { // Generate new random vector for fac_f blas_int idist = 2; blas_int iseed[4] = {1, 3, 5, 7}; iseed[0] = (i + 100) % 4095; blas_int n = dim_n; lapack::larnv(&idist, iseed, &n, fac_f.memptr()); // f <- f - V * V' * f, so that f is orthogonal to V Mat<eT> Vs(fac_V.memptr(), dim_n, i, false); // First i columns Col<eT> Vf = Vs.t() * fac_f; fac_f -= Vs * Vf; // beta <- ||f|| beta = norm(fac_f); restart = true; } // v <- f / ||f|| fac_V.col(i) = fac_f / beta; // The (i+1)-th column // Note that H[i+1, i] equals to the unrestarted beta if(restart) { fac_H(i, i - 1) = 0.0; } else { fac_H(i, i - 1) = beta; } // w <- A * v, v = fac_V.col(i) op.perform_op(fac_V.colptr(i), w.memptr()); nmatop++; // First i+1 columns of V Mat<eT> Vs(fac_V.memptr(), dim_n, i + 1, false); // h = fac_H(0:i, i) Col<eT> h(fac_H.colptr(i), i + 1, false); // h <- V' * w h = Vs.t() * w; // f <- w - V * h fac_f = w - Vs * h; beta = norm(fac_f); if(beta > 0.717 * norm(h)) { continue; } // f/||f|| is going to be the next column of V, so we need to test // whether V' * (f/||f||) ~= 0 Col<eT> Vf = Vs.t() * fac_f; // If not, iteratively correct the residual uword count = 0; while(count < 5 && abs(Vf).max() > approx0 * beta) { // f <- f - V * Vf fac_f -= Vs * Vf; // h <- h + Vf h += Vf; // beta <- ||f|| beta = norm(fac_f); Vf = Vs.t() * fac_f; count++; } } }
string matched(const string &body) { return span("Matched", body); }
constexpr length_span message_length_field() noexcept { return span().subspan<message_length_offset, sizeof(uint32_t)>(); }
string type(const string &x) { return span("Type", x); }
constexpr nonce_span followup_nonce_field() noexcept { return span().subspan<followup_nonce_offset, crypto_box_NONCEBYTES>(); }
void plDrawableSpans::decomposeGeometry(bool clearcolors) { for (size_t i=0; i<fIcicles.getSize(); i++) { plIcicle* icicle = fIcicles[i]; std::shared_ptr<plGeometrySpan> span(new plGeometrySpan()); plGBufferGroup* group = fGroups[icicle->getGroupIdx()]; span->setLocalToWorld(icicle->getLocalToWorld()); span->setWorldToLocal(icicle->getWorldToLocal()); span->setLocalBounds(icicle->getLocalBounds()); span->setWorldBounds(icicle->getWorldBounds()); span->setMaterial(fMaterials[icicle->getMaterialIdx()]); span->setFogEnvironment(icicle->getFogEnvironment()); span->setMinDist(icicle->getMinDist()); span->setMaxDist(icicle->getMaxDist()); span->setNumMatrices(icicle->getNumMatrices()); span->setProps(plSpan::swizzleGeoFlags(icicle->getProps())); span->setBaseMatrix(icicle->getBaseMatrix()); span->setLocalUVWChans(icicle->getLocalUVWChans()); span->setMaxBoneIdx(icicle->getMaxBoneIdx()); span->setWaterHeight(icicle->getWaterHeight()); span->setPenBoneIdx(icicle->getPenBoneIdx()); span->setFormat(group->getFormat()); hsTArray<unsigned short> indices; indices = group->getIndices(icicle->getIBufferIdx(), icicle->getIStartIdx(), icicle->getILength()); for (size_t j=0; j<indices.getSize(); j++) indices[j] -= icicle->getVStartIdx(); span->setIndices(indices); hsTArray<plGBufferVertex> vertices; hsTArray<plGeometrySpan::TempVertex> new_vertices; vertices = group->getVertices(icicle->getVBufferIdx(), icicle->getVStartIdx(), icicle->getVLength()); new_vertices.setSize(vertices.getSize()); for (size_t j=0; j<vertices.getSize(); j++) { plGBufferVertex v1 = vertices[j]; plGeometrySpan::TempVertex v2; v2.fPosition = v1.fPos; v2.fNormal = v1.fNormal; for (size_t k=0; k<8; k++) { v2.fUVs[k] = v1.fUVWs[k]; } for (size_t k=0; k<3; k++) { v2.fWeights[k] = v1.fSkinWeights[k]; } v2.fIndices = v1.fSkinIdx; if (clearcolors) v2.fColor = 0xFFFFFFFF; else v2.fColor = v1.fColor; v2.fSpecularColor = 0; v2.fAddColor = hsColorRGBA::kBlack; v2.fMultColor = hsColorRGBA::kWhite; new_vertices[j] = v2; } span->setVertices(new_vertices); fSourceSpans.append(span); } }
// GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with dit. If not, see <http://www.gnu.org/licenses/>. #include "Catch/catch.hpp" #include <vector> #include "utils/containers.hpp" using container = std::vector<int>; TEST_CASE("Empty input yields empty output.", "[utils][containers][span]") { auto split = span(container{}, [](int){ return false; }); REQUIRE(split.first == container{}); REQUIRE(split.second == container{}); } TEST_CASE("Left part takes all.", "[utils][containers][span]") { auto split = span(container{1, 2, 3}, [](int){ return true; }); REQUIRE(split.first == (container{1, 2, 3})); REQUIRE(split.second == container{}); } TEST_CASE("Right part takes all.", "[utils][containers][span]") { auto split = span(container{1, 2, 3}, [](int){ return false; }); REQUIRE(split.first == container{});
int TestCase_Core_Log::Run(int argc, char *argv[]) { LLBC_PrintLine("core/log test:"); #if LLBC_TARGET_PLATFORM_IPHONE const LLBC_Bundle *mainBundle = LLBC_Bundle::GetMainBundle(); if(LLBC_LoggerManagerSingleton->Initialize(mainBundle->GetBundlePath() + "/" + "Logger_Cfg.cfg") != LLBC_OK) #else if(LLBC_LoggerManagerSingleton->Initialize("Logger_Cfg.cfg") != LLBC_OK) #endif { LLBC_FilePrintLine(stderr, "Initialize logger manager failed, err: %s", LLBC_FormatLastError()); LLBC_FilePrintLine(stderr, "Forgot copy Logger_Cfg.cfg test config file to CWD?"); return -1; } // Use root logger to test. LLBC_DEBUG_LOG("This is a debug log message."); LLBC_DEBUG_LOG2("test_tag", "This is a debug log message."); #if LLBC_CFG_LOG_USING_WITH_STREAM LLBC_DEBUG_LOG("Message type test, char: " <<'a' <<", bool: " <<true <<", uint8: " <<(uint8)8 <<", sint16: " <<(sint16)-16 << ", uint16: " <<(uint16)16 <<", sint32: " <<-32 <<", uint32: " <<(uint32)32 <<", long: " <<(long)-1 <<", ulong: " <<(llbc::ulong)1 <<", sint64: " <<(sint64)-64 <<", uint64: " <<(uint64)64 <<", float: " <<(float)1.0 <<", double: " <<2.0 <<", ldouble: " <<(ldouble)3.0); std::string stdStr = "This is a std::string"; LLBC_String llbcStr = "This is a LLBC_String"; LLBC_DEBUG_LOG("std::string operator << test: " <<stdStr <<", LLBC_String operator << test: " <<llbcStr); LLBC_Time now; LLBC_TimeSpan span(-30); LLBC_DEBUG_LOG("Current time: " <<now <<", TimeSpan: " <<span); // Test precision. double f = 3.14159; LLBC_DEBUG_LOG(std::setprecision(5) <<f); LLBC_DEBUG_LOG(std::setprecision(9) <<f); LLBC_DEBUG_LOG(std::setprecision(5) <<std::fixed <<f); LLBC_DEBUG_LOG(std::setprecision(9) <<std::fixed <<f); #endif // LLBC_CFG_LOG_USING_WITH_STREAM` LLBC_INFO_LOG("This is a info log message."); LLBC_INFO_LOG2("test_tag", "This is a info log message."); LLBC_WARN_LOG("This is a warn log message."); LLBC_WARN_LOG2("test_tag", "This is a warn log message."); LLBC_ERROR_LOG("This is a error log message."); LLBC_ERROR_LOG2("test_tag", "This is a error log message."); LLBC_FATAL_LOG("This is a fatal log message."); LLBC_FATAL_LOG2("test_tag", "This is a fatal log message."); // Use test logger to test. LLBC_DEBUG_LOG_SPEC("test", "This is a debug log message."); LLBC_DEBUG_LOG_SPEC2("test", "test_tag", "This is a debug log message."); LLBC_INFO_LOG_SPEC("test", "This is a info log message."); LLBC_INFO_LOG_SPEC2("test", "test_tag", "This is a info log message."); LLBC_WARN_LOG_SPEC("test", "This is a warn log message."); LLBC_WARN_LOG_SPEC2("test", "test_tag", "This is a warn log message."); LLBC_ERROR_LOG_SPEC("test", "This is a error log message."); LLBC_ERROR_LOG_SPEC2("test", "test_tag", "This is a error log message."); LLBC_FATAL_LOG_SPEC("test", "This is a fatal log message."); LLBC_FATAL_LOG_SPEC2("test", "test_tag", "This is a fatal log message."); // Log file delete test. for (int i = 0; i < 20; i++) { LLBC_DEBUG_LOG_SPEC("deltest", "This is a deltest logger message."); LLBC_ThreadManager::Sleep(1000); } // Peform performance test. LLBC_PrintLine("Perform preformance test:"); LLBC_CPUTime begin = LLBC_CPUTime::Current(); const int loopLmt = 500000; for (int i = 0; i < loopLmt; i++) LLBC_DEBUG_LOG_SPEC("perftest", "performance test msg"); LLBC_LoggerManagerSingleton->Finalize(); LLBC_CPUTime elapsed = LLBC_CPUTime::Current() - begin; LLBC_PrintLine("Performance test completed, " "log size:%d, elapsed time: %s", loopLmt, elapsed.ToString().c_str()); LLBC_PrintLine("Press any key to continue ..."); getchar(); return 0; }
int main() { std::srand(static_cast<unsigned int>(std::time(0))); unsigned int len = 1000; span a = span(len); for (unsigned int i = 0; i < len; ++i) { a.addNumber(std::rand() % 1000); } std::list<int>::iterator it; std::cout << "a = "; for (it = a._cont.begin(); it != a._cont.end(); ++it) { std::cout << *it << " "; } std::cout << std::endl; std::cout << "a shortest : " << a.shortestSpan() << std::endl; std::cout << "a longest : " << a.longestSpan() << std::endl; span sp = span(5); sp.addNumber(5); sp.addNumber(3); sp.addNumber(17); sp.addNumber(9); sp.addNumber(11); std::cout << std::endl; std::cout << "sp = "; for (it = sp._cont.begin(); it != sp._cont.end(); ++it) { std::cout << *it << " "; } std::cout << std::endl; std::cout << "sp shortest : " << sp.shortestSpan() << std::endl; std::cout << "sp longest : " << sp.longestSpan() << std::endl; std::cout << std::endl; try { sp.addNumber(12); sp.addNumber(12); } catch (span::LimitReached & e) { std::cout << e.what() << std::endl; } try { span sp = span(5); sp.addNumber(5); std::cout << std::endl; std::cout << "sp = "; for (it = sp._cont.begin(); it != sp._cont.end(); ++it) { std::cout << *it << " "; } std::cout << std::endl; std::cout << "sp shortest : " << sp.shortestSpan() << std::endl; std::cout << "sp longest : " << sp.longestSpan() << std::endl; } catch (span::NoSpanFound & e) { std::cout << e.what() << std::endl; } return 0; }
static bool WriteOutputVT(const matrix<FAR_CHAR_INFO>& Buffer, rectangle const SubRect, const SMALL_RECT& WriteRegion) { const auto Out = ::console.GetOutputHandle(); CONSOLE_SCREEN_BUFFER_INFO csbi; if (!GetConsoleScreenBufferInfo(Out, &csbi)) return false; COORD SavedCursorPosition; if (!::console.GetCursorRealPosition(SavedCursorPosition)) return false; CONSOLE_CURSOR_INFO SavedCursorInfo; if (!::console.GetCursorInfo(SavedCursorInfo)) return false; if ( // Hide cursor !::console.SetCursorInfo({1}) || // Move the viewport down !::console.SetCursorRealPosition({ 0, static_cast<SHORT>(csbi.dwSize.Y - 1) }) || // Set cursor position within the viewport !::console.SetCursorRealPosition({ WriteRegion.Left, WriteRegion.Top })) return false; SCOPE_EXIT { // Move the viewport down ::console.SetCursorRealPosition({ 0, static_cast<SHORT>(csbi.dwSize.Y - 1) }); // Restore cursor position within the viewport ::console.SetCursorRealPosition(SavedCursorPosition); // Restore cursor ::console.SetCursorInfo(SavedCursorInfo); // Restore buffer relative position if (csbi.srWindow.Left || csbi.srWindow.Bottom != csbi.dwSize.Y - 1) ::console.SetWindowRect(csbi.srWindow); }; COORD CursorPosition{ WriteRegion.Left, WriteRegion.Top }; if (sWindowMode) { CursorPosition.Y -= ::GetDelta(csbi); if (CursorPosition.Y < 0) { // Drawing above the viewport CursorPosition.Y = 0; } } string Str; std::optional<FarColor> LastColor; for (short i = SubRect.top; i <= SubRect.bottom; ++i) { if (i != SubRect.top) Str += format(L"\033[{0};{1}H"sv, CursorPosition.Y + 1 + (i - SubRect.top), CursorPosition.X + 1); make_vt_sequence(span(Buffer[i].data() + SubRect.left, SubRect.width()), Str, LastColor); } append(Str, L"\033[0m"sv); return ::console.Write(Str); }
void main(int argc, char *argv[]) { int c, i; char *p; Binit(&bso, 1, OWRITE); cout = -1; listinit(); nerrors = 0; outfile = "5.out"; HEADTYPE = -1; INITTEXT = -1; INITDAT = -1; INITRND = -1; INITENTRY = 0; p = getenv("GOARM"); if(p != nil && strcmp(p, "5") == 0) debug['F'] = 1; ARGBEGIN { default: c = ARGC(); if(c == 'l') usage(); if(c >= 0 && c < sizeof(debug)) debug[c]++; break; case 'o': outfile = EARGF(usage()); break; case 'E': INITENTRY = EARGF(usage()); break; case 'I': interpreter = EARGF(usage()); break; case 'L': Lflag(EARGF(usage())); break; case 'T': INITTEXT = atolwhex(EARGF(usage())); break; case 'D': INITDAT = atolwhex(EARGF(usage())); break; case 'R': INITRND = atolwhex(EARGF(usage())); break; case 'r': rpath = EARGF(usage()); break; case 'H': HEADTYPE = headtype(EARGF(usage())); /* do something about setting INITTEXT */ break; case 'V': print("%cl version %s\n", thechar, getgoversion()); errorexit(); } ARGEND USED(argc); if(argc != 1) usage(); libinit(); if(!debug['9'] && !debug['U'] && !debug['B']) debug[DEFAULT] = 1; if(HEADTYPE == -1) { if(debug['U']) HEADTYPE = Hnoheader; if(debug['B']) HEADTYPE = Hrisc; if(debug['9']) HEADTYPE = Hplan9x32; HEADTYPE = Hlinux; } switch(HEADTYPE) { default: diag("unknown -H option"); errorexit(); case Hnoheader: /* no header */ HEADR = 0L; if(INITTEXT == -1) INITTEXT = 0; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hrisc: /* aif for risc os */ HEADR = 128L; if(INITTEXT == -1) INITTEXT = 0x10005000 + HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hplan9x32: /* plan 9 */ HEADR = 32L; if(INITTEXT == -1) INITTEXT = 4128; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hnetbsd: /* boot for NetBSD */ HEADR = 32L; if(INITTEXT == -1) INITTEXT = 0xF0000020L; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; case Hixp1200: /* boot for IXP1200 */ HEADR = 0L; if(INITTEXT == -1) INITTEXT = 0x0; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hipaq: /* boot for ipaq */ HEADR = 16L; if(INITTEXT == -1) INITTEXT = 0xC0008010; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 1024; break; case Hlinux: /* arm elf */ debug['d'] = 1; // no dynamic linking elfinit(); HEADR = ELFRESERVE; if(INITTEXT == -1) INITTEXT = 0x10000 + HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4096; break; } if(INITDAT != 0 && INITRND != 0) print("warning: -D0x%ux is ignored because of -R0x%ux\n", INITDAT, INITRND); if(debug['v']) Bprint(&bso, "HEADER = -H0x%d -T0x%ux -D0x%ux -R0x%ux\n", HEADTYPE, INITTEXT, INITDAT, INITRND); Bflush(&bso); zprg.as = AGOK; zprg.scond = 14; zprg.reg = NREG; zprg.from.name = D_NONE; zprg.from.type = D_NONE; zprg.from.reg = NREG; zprg.to = zprg.from; buildop(); histgen = 0; pc = 0; dtype = 4; nuxiinit(); version = 0; cbp = buf.cbuf; cbc = sizeof(buf.cbuf); addlibpath("command line", "command line", argv[0], "main"); loadlib(); // mark some functions that are only referenced after linker code editing // TODO(kaib): this doesn't work, the prog can't be found in runtime for(i=0; i<nelem(linkername); i++) mark(lookup(linkername[i], 0)); deadcode(); if(textp == nil) { diag("no code"); errorexit(); } patch(); if(debug['p']) if(debug['1']) doprof1(); else doprof2(); doelf(); follow(); softfloat(); noops(); dostkcheck(); span(); pclntab(); symtab(); dodata(); address(); doweak(); reloc(); asmb(); undef(); if(debug['c']) print("ARM size = %d\n", armsize); if(debug['v']) { Bprint(&bso, "%5.2f cpu time\n", cputime()); Bprint(&bso, "%d sizeof adr\n", sizeof(Adr)); Bprint(&bso, "%d sizeof prog\n", sizeof(Prog)); } Bflush(&bso); errorexit(); }