void Test4() { LoadBCP("data.bcp"); InitWindow(); Mesh tm("Warrior Kings Game Set\\Characters\\Abaddon\\ABADDON_MOVE.MESH3"); Mesh tn("Warrior Kings Game Set\\Characters\\Michael\\MICHAEL1.MESH3"); //InitMeshDrawing(); while(!appexit) { BeginDrawing(); BeginMeshDrawing(); SetModelMatrices(); tm.draw(1); tn.draw(2); EndDrawing(); HandleWindow(); } }
/// Retrieve conversion service by name SmartIF<IConversionSvc>& PersistencySvc::service(const std::string& nam) { Gaudi::Utils::TypeNameString tn(nam); IConversionSvc* svc = 0; for ( Services::iterator it = m_cnvServices.begin(); it != m_cnvServices.end(); it++ ) { if ( (*it).second.service()->name() == tn.name() ) { return (*it).second.conversionSvc(); } } StatusCode status = Service::service(nam, svc, true); if ( status.isSuccess() ) { if ( addCnvService(svc).isSuccess() ) { svc->release(); // Do not double-reference count return service(nam); // now it is in the list } } info() << "Cannot access Conversion service:" << nam << endmsg; static SmartIF<IConversionSvc> no_svc; return no_svc; }
//Scale triangle, used for improve do_intersect results: scale the triangle on its plane, centred in its barycenter inline Triangle triangleScale(Triangle t) { Plane p = t.supporting_plane(); KPoint2 a = p.to_2d(t.vertex(0)); KPoint2 b = p.to_2d(t.vertex(1)); KPoint2 c = p.to_2d(t.vertex(2)); KPoint2 baryc((a.x() + b.x() +c.x())/3.0, (a.y() + b.y() +c.y())/3.0); //TODO: usare margine invece di scale CGAL::Aff_transformation_2<Kernel> translate1(CGAL::TRANSLATION, CGAL::Vector_2<Kernel>(-baryc.x(), -baryc.y())); CGAL::Aff_transformation_2<Kernel> translate2(CGAL::TRANSLATION, CGAL::Vector_2<Kernel>(baryc.x(), baryc.y())); CGAL::Aff_transformation_2<Kernel> scale(CGAL::SCALING, DISJOINTMESH_TRIANGLE_SCALE_VALUE); CGAL::Aff_transformation_2<Kernel> transform = translate2 * (scale * translate1); KPoint2 an = transform(a); KPoint2 bn = transform(b); KPoint2 cn = transform(c); Point an3 = p.to_3d(an); Point bn3 = p.to_3d(bn); Point cn3 = p.to_3d(cn); Triangle tn(an3, bn3, cn3); return tn; }
inline std::string associated_type_name(lua_State* L, int index, type t) { switch (t) { case type::poly: return "anything"; case type::userdata: { if (lua_getmetatable(L, index) == 0) { break; } lua_pushlstring(L, "__name", 6); lua_rawget(L, -2); size_t sz; const char* name = lua_tolstring(L, -1, &sz); std::string tn(name, static_cast<std::string::size_type>(sz)); lua_pop(L, 2); return name; } default: break; } return lua_typename(L, static_cast<int>(t)); }
void Creature::updateCurrent(sf::Time dt, CommandQueue &commands) { updateAnimation(dt); if(isDestroyed() && !hasBeenSacrificed()) { if(mEmitter) { mEmitter->update(dt, commands); mDestroyedSince += dt; } else { // blood std::unique_ptr<EmitterNode> e(new EmitterNode(Particle::Default)); e->setPosition(sf::Vector2f(0.f, -32.f)); mEmitter = e.get(); attachChild(std::move(e)); // text if(randomInt(4) == 0) { Command command; command.category = Category::UILayer; command.action = derivedAction<SceneNode>([this] (SceneNode& node, sf::Time) { std::string str = StringTable[randomInt(StringTable.size())]; std::unique_ptr<CombatTextNode> tn(new CombatTextNode(str, mFonts)); tn->setPosition(sf::Vector2f(getPosition().x, getPosition().y-getBoundingRect().height/2)); node.attachChild(std::move(tn)); }); commands.push(command); } } } mAIController.update(commands, *this); Entity::updateCurrent(dt, commands); }
// // Calculate confusion matrices for all possible threshold values // // [[Rcpp::export]] Rcpp::List create_confusion_matrices(const Rcpp::IntegerVector& olabs, const Rcpp::NumericVector& ranks, const Rcpp::IntegerVector& rank_idx) { // Variables Rcpp::List ret_val; std::string errmsg = ""; int n = olabs.size(); // Input data size int np; // # of positive int nn; // # of negatives std::vector<double> tp(n+1); // TPs std::vector<double> fp(n+1); // FPs std::vector<double> tn(n+1); // TNs std::vector<double> fn(n+1); // FNs std::vector<double> sorted_ranks(n+1); // Ranks // Calculate TPs and FPs calc_tp_fp(olabs, ranks, rank_idx, n, np, nn, tp, fp, sorted_ranks); // Calculate TNs and FNs for (int i = 0; i < n+1; ++i) { tn[i] = nn - fp[i]; fn[i] = np - tp[i]; } // Return a list with P, N, TPs, FP, TNs, FN, and ranks ret_val["pos_num"] = np; ret_val["neg_num"] = nn; ret_val["tp"] = tp; ret_val["fp"] = fp; ret_val["tn"] = tn; ret_val["fn"] = fn; ret_val["ranks"] = sorted_ranks; ret_val["errmsg"] = errmsg; return ret_val; }
float* FlowError::calcError(flowUV& UV, flowUV& GT, bool display){ int size = 0; cv::Mat mask(UV.getU().rows, UV.getU().cols, CV_8U,cv::Scalar(0)); float* gu = (float*)GT.getU().data; float* gv = (float*)GT.getV().data; uchar* m = mask.data; for (int i = 0 ; i < GT.getU().rows * GT.getU().cols; ++i, ++gu, ++gv, ++m){ if ((std::abs(*gv) == 0 && std::abs(*gu) == 0) | (std::abs(*gv) > 1000000000) | (std::abs(*gu) > 1000000000)) { *m = 0; } else { *m = 1; ++size; } } float* u = (float*)UV.getU().data; float* v = (float*)UV.getV().data; gu = (float*)GT.getU().data; gv = (float*)GT.getV().data; cv::Mat msu(size, 1, OPTFLOW_TYPE); cv::Mat msv(size, 1, OPTFLOW_TYPE); cv::Mat mstu(size, 1, OPTFLOW_TYPE); cv::Mat mstv(size, 1, OPTFLOW_TYPE); float* pmsu = (float*)msu.data; float* pmsv = (float*)msv.data; float* pmstu = (float*)mstu.data; float* pmstv = (float*)mstv.data; m = mask.data; for(int i = 0; i < UV.getU().rows * UV.getU().cols; ++i, ++u, ++v, ++gu, ++gv, ++m){ if (*m){ *(pmsu++) = *(u); *(pmsv++) = *(v); *(pmstu++) = *(gu); *(pmstv++) = *(gv); } } cv::Mat n(size, 1, OPTFLOW_TYPE,cv::Scalar(0)); pmsu = (float*)msu.data; pmsv = (float*)msv.data; float* pn = (float*)n.data; for(int i = 0; i < size; ++i, ++pmsu, ++pmsv, ++pn){ *pn = (1.0f/ std::sqrtf((*pmsu) * (*pmsu) + (*pmsv) * (*pmsv) + 1)); } cv::Mat un = msu.mul(n); cv::Mat vn = msv.mul(n); cv::Mat tn(size, 1, OPTFLOW_TYPE,cv::Scalar(0)); pmstu = (float*)mstu.data; pmstv = (float*)mstv.data; float* ptn = (float*)tn.data; for(int i = 0; i < size; ++i, ++pmstu, ++pmstv, ++ptn){ *ptn = (1.0f/ std::sqrtf((*pmstu) * (*pmstu) + (*pmstv) * (*pmstv) + 1)); } cv::Mat tun = mstu.mul(tn); cv::Mat tvn = mstv.mul(tn); cv::Mat ang(size, 1, OPTFLOW_TYPE,cv::Scalar(0)); cv::Mat angtmp = un.mul(tun)+ vn.mul(tvn) +(n.mul(tn)); float* pAng = (float*)ang.data; float* pAngtmp = (float*)angtmp.data; ptn = (float*)tn.data; for(int i = 0; i < size; ++i){ *(pAng++) = std::acos(std::max<float>(-1, std::min<float>(1,*(pAngtmp++)))); } float mang = (float)cv::mean(ang).val[0]; static float pi = 3.14159265358979323846f; mang = mang * 180 / pi; cv::Scalar meanTmp, meanStd; cv::meanStdDev(cv::Mat(ang*180/pi), meanTmp, meanStd); float stdang = (float)meanStd.val[0]; cv::Mat epe1 = (GT.getU() - UV.getU()).mul((GT.getU() - UV.getU())) + (GT.getV() - UV.getV()).mul((GT.getV() - UV.getV())); cv::Mat epe2(UV.getU().rows, UV.getU().cols, OPTFLOW_TYPE,cv::Scalar(0));; cv::sqrt(epe1, epe2); cv::Mat epe(size, 1, OPTFLOW_TYPE,cv::Scalar(0)); float* pepe2 = (float*)epe2.data; float* pepe = (float*)epe.data; m = mask.data; for(int i = 0; i < UV.getU().rows * UV.getU().cols; ++i, ++pepe2, ++m){ if (*m){ *(pepe++) = *(pepe2); } } float mepe = (float)cv::mean(epe).val[0]; float* ret = new float[3]; ret[0] = mang; ret[1] = stdang; ret[2] = mepe; if (display){ UtilsMat::clamp<float>(epe2,0,1); pepe2 = (float*)epe2.data; m = mask.data; for(int i = 0; i < epe2.cols * epe2.rows; ++i, ++pepe2, ++m) *(pepe2) = *(pepe2) * *(m); cv::imshow("End Point Error Visualization", epe2); cv::waitKey(1); } return ret; }
int main(int argc, char **argv) { int ch; char *user; setprogname(argv[0]); #ifdef KRB5 krb5_init(); #endif tninit(); /* Clear out things */ TerminalSaveState(); if ((prompt = strrchr(argv[0], '/'))) ++prompt; else prompt = argv[0]; user = NULL; rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE; /* * if AUTHENTICATION and ENCRYPTION is set autologin will be * se to true after the getopt switch; unless the -K option is * passed */ autologin = -1; if (argc == 2 && strcmp(argv[1], "--version") == 0) { print_version(NULL); exit(0); } if (argc == 2 && strcmp(argv[1], "--help") == 0) usage(0); while((ch = getopt(argc, argv, "78DEKLS:X:abcde:fFk:l:n:rxG")) != -1) { switch(ch) { case '8': eight = 3; /* binary output and input */ break; case '7': eight = 0; break; case 'b': binary = 3; break; case 'D': { /* sometimes we don't want a mangled display */ char *p; if((p = getenv("DISPLAY"))) env_define((unsigned char*)"DISPLAY", (unsigned char*)p); break; } case 'E': rlogin = escape = _POSIX_VDISABLE; break; case 'K': #ifdef AUTHENTICATION autologin = 0; #endif break; case 'L': eight |= 2; /* binary output only */ break; case 'S': { #ifdef HAVE_PARSETOS extern int tos; if ((tos = parsetos(optarg, "tcp")) < 0) fprintf(stderr, "%s%s%s%s\n", prompt, ": Bad TOS argument '", optarg, "; will try to use default TOS"); #else fprintf(stderr, "%s: Warning: -S ignored, no parsetos() support.\n", prompt); #endif } break; case 'X': #ifdef AUTHENTICATION auth_disable_name(optarg); #endif break; case 'a': autologin = 1; break; case 'c': skiprc = 1; break; case 'd': debug = 1; break; case 'e': set_escape_char(optarg); break; case 'f': case 'F': case 'G': #if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD) if (forward_option) { fprintf(stderr, "%s: Only one of -f, -F and -G allowed.\n", prompt); usage(1); } forward_option = ch; #else fprintf(stderr, "%s: Warning: -%c ignored, no Kerberos V5 support.\n", prompt, ch); #endif break; case 'k': #if defined(AUTHENTICATION) && defined(KRB4) { dest_realm = dst_realm_buf; strlcpy(dest_realm, optarg, dst_realm_sz); } #else fprintf(stderr, "%s: Warning: -k ignored, no Kerberos V4 support.\n", prompt); #endif break; case 'l': if(autologin == 0){ fprintf(stderr, "%s: Warning: -K ignored\n", prompt); autologin = -1; } user = optarg; break; case 'n': SetNetTrace(optarg); break; case 'r': rlogin = '******'; break; case 'x': #ifdef ENCRYPTION encrypt_auto(1); decrypt_auto(1); wantencryption = 1; EncryptVerbose(1); #else fprintf(stderr, "%s: Warning: -x ignored, no ENCRYPT support.\n", prompt); #endif break; case '?': default: usage(1); /* NOTREACHED */ } } if (autologin == -1) { /* [email protected]; force */ #if defined(AUTHENTICATION) autologin = 1; #endif #if defined(ENCRYPTION) encrypt_auto(1); decrypt_auto(1); wantencryption = -1; #endif } if (autologin == -1) autologin = (rlogin == _POSIX_VDISABLE) ? 0 : 1; argc -= optind; argv += optind; if (argc) { char *args[7], **argp = args; if (argc > 2) usage(1); *argp++ = prompt; if (user) { *argp++ = "-l"; *argp++ = user; } *argp++ = argv[0]; /* host */ if (argc > 1) *argp++ = argv[1]; /* port */ *argp = 0; if (setjmp(toplevel) != 0) Exit(0); if (tn(argp - args, args) == 1) return (0); else return (1); } setjmp(toplevel); for (;;) { command(1, 0, 0); } }
int main(int argc, char *argv[]) { u_long ultmp; int ch; char *ep, *user; char *src_addr = NULL; #ifdef FORWARD extern int forward_flags; #endif /* FORWARD */ tninit(); /* Clear out things */ TerminalSaveState(); if ((prompt = strrchr(argv[0], '/'))) ++prompt; else prompt = argv[0]; user = NULL; rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE; #ifdef AUTHENTICATION autologin = 1; #else autologin = -1; #endif #ifdef ENCRYPTION encrypt_auto(1); decrypt_auto(1); #endif #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) #define IPSECOPT "P:" #else #define IPSECOPT #endif while ((ch = getopt(argc, argv, "468B:EKLNS:X:acde:fFk:l:n:rs:uxy" IPSECOPT)) != -1) #undef IPSECOPT { switch(ch) { case '4': family = AF_INET; break; #ifdef INET6 case '6': family = AF_INET6; break; #endif case '8': eight = 3; /* binary output and input */ break; case 'B': DoBaudRate(optarg); break; case 'E': rlogin = escape = _POSIX_VDISABLE; break; case 'K': #ifdef AUTHENTICATION autologin = 0; #endif break; case 'L': eight |= 2; /* binary output only */ break; case 'N': doaddrlookup = 0; break; case 'S': #ifdef HAS_GETTOS if ((tos = parsetos(optarg, "tcp")) < 0) fprintf(stderr, "%s%s%s%s\n", prompt, ": Bad TOS argument '", optarg, "; will try to use default TOS"); #else #define MAXTOS 255 ultmp = strtoul(optarg, &ep, 0); if (*ep || ep == optarg || ultmp > MAXTOS) fprintf(stderr, "%s%s%s%s\n", prompt, ": Bad TOS argument '", optarg, "; will try to use default TOS"); else tos = ultmp; #endif break; case 'X': #ifdef AUTHENTICATION auth_disable_name(optarg); #endif break; case 'a': #ifdef AUTHENTICATION /* It's the default now, so ignore */ #else autologin = 1; #endif break; case 'c': skiprc = 1; break; case 'd': telnet_debug = 1; break; case 'e': set_escape_char(optarg); break; case 'f': #ifdef AUTHENTICATION #if defined(KRB5) && defined(FORWARD) if (forward_flags & OPTS_FORWARD_CREDS) { fprintf(stderr, "%s: Only one of -f and -F allowed.\n", prompt); usage(); } forward_flags |= OPTS_FORWARD_CREDS; #else fprintf(stderr, "%s: Warning: -f ignored, no Kerberos V5 support.\n", prompt); #endif #else fprintf(stderr, "%s: Warning: -f ignored, no Kerberos V5 support.\n", prompt); #endif break; case 'F': #ifdef AUTHENTICATION #if defined(KRB5) && defined(FORWARD) if (forward_flags & OPTS_FORWARD_CREDS) { fprintf(stderr, "%s: Only one of -f and -F allowed.\n", prompt); usage(); } forward_flags |= OPTS_FORWARD_CREDS; forward_flags |= OPTS_FORWARDABLE_CREDS; #else fprintf(stderr, "%s: Warning: -F ignored, no Kerberos V5 support.\n", prompt); #endif #else fprintf(stderr, "%s: Warning: -F ignored, no Kerberos V5 support.\n", prompt); #endif break; case 'k': #ifdef AUTHENTICATION #if defined(KRB4) { extern char *dest_realm, dst_realm_buf[], dst_realm_sz; dest_realm = dst_realm_buf; (void)strncpy(dest_realm, optarg, dst_realm_sz); } #else fprintf(stderr, "%s: Warning: -k ignored, no Kerberos V4 support.\n", prompt); #endif #else fprintf(stderr, "%s: Warning: -k ignored, no Kerberos V4 support.\n", prompt); #endif break; case 'l': #ifdef AUTHENTICATION /* This is the default now, so ignore it */ #else autologin = 1; #endif user = optarg; break; case 'n': SetNetTrace(optarg); break; case 'r': rlogin = '******'; break; case 's': src_addr = optarg; break; case 'u': family = AF_UNIX; break; case 'x': #ifndef ENCRYPTION fprintf(stderr, "%s: Warning: -x ignored, no ENCRYPT support.\n", prompt); #endif /* ENCRYPTION */ break; case 'y': #ifdef ENCRYPTION encrypt_auto(0); decrypt_auto(0); #else fprintf(stderr, "%s: Warning: -y ignored, no ENCRYPT support.\n", prompt); #endif /* ENCRYPTION */ break; #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) case 'P': if (!strncmp("in", optarg, 2)) ipsec_policy_in = strdup(optarg); else if (!strncmp("out", optarg, 3)) ipsec_policy_out = strdup(optarg); else usage(); break; #endif case '?': default: usage(); /* NOTREACHED */ } } if (autologin == -1) autologin = (rlogin == _POSIX_VDISABLE) ? 0 : 1; argc -= optind; argv = argv + optind; if (argc) { char *args[9], **argp = args; if (argc > 2) usage(); *argp++ = prompt; if (user) { *argp++ = strdup("-l"); *argp++ = user; } if (src_addr) { *argp++ = strdup("-s"); *argp++ = src_addr; } *argp++ = argv[0]; /* host */ if (argc > 1) *argp++ = argv[1]; /* port */ *argp = 0; if (setjmp(toplevel) != 0) Exit(0); if (tn(argp - args, args) == 1) return (0); else return (1); } (void)setjmp(toplevel); for (;;) { command(1, 0, 0); } return 0; }
static void listdevices() { netlist_tool_t nt("netlist"); nt.init(); netlist::factory_list_t &list = nt.setup().factory(); nt.setup().register_source(std::make_shared<netlist::source_proc_t>("dummy", &netlist_dummy)); nt.setup().include("dummy"); nt.setup().start_devices(); nt.setup().resolve_inputs(); std::vector<plib::owned_ptr<netlist::core_device_t>> devs; for (auto & f : list) { pstring out = plib::pfmt("{1} {2}(<id>")(f->classname(),"-20")(f->name()); pstring terms(""); auto d = f->Create(nt.setup().netlist(), f->name() + "_lc"); // get the list of terminals ... for (auto & t : nt.setup().m_terminals) { if (t.second->name().startsWith(d->name())) { pstring tn(t.second->name().substr(d->name().len()+1)); if (tn.find(".")<0) terms += ", " + tn; } } for (auto & t : nt.setup().m_alias) { if (t.first.startsWith(d->name())) { pstring tn(t.first.substr(d->name().len()+1)); if (tn.find(".")<0) terms += ", " + tn; } } if (f->param_desc().startsWith("+")) { out += "," + f->param_desc().substr(1); terms = ""; } else if (f->param_desc() == "-") { /* no params at all */ } else { out += "," + f->param_desc(); } out += ")"; printf("%s\n", out.cstr()); if (terms != "") printf("Terminals: %s\n", terms.substr(1).cstr()); devs.push_back(std::move(d)); } }
/* * main. Parse arguments, invoke the protocol or command parser. */ int main (int argc, char *argv[]) { int ch; char *user, *alias; #ifdef FORWARD extern int forward_flags; #endif /* FORWARD */ tninit (); /* Clear out things */ TerminalSaveState (); if ((prompt = strrchr (argv[0], '/'))) ++prompt; else prompt = argv[0]; user = alias = NULL; rlogin = (strncmp (prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE; autologin = -1; while ((ch = getopt (argc, argv, "78DEKLS:X:ab:cde:fFk:l:n:rt:x")) != -1) { switch (ch) { case '8': eight = 3; /* binary output and input */ break; case '7': eight = 0; break; case 'D': { /* sometimes we don't want a mangled display */ char *p; if ((p = getenv ("DISPLAY"))) env_define ("DISPLAY", (unsigned char *) p); break; } case 'E': rlogin = escape = _POSIX_VDISABLE; break; case 'K': /* autologin = 0; */ break; case 'L': eight |= 2; /* binary output only */ break; case 'S': { #ifdef HAS_GETTOS extern int tos; if ((tos = parsetos (optarg, "tcp")) < 0) fprintf (stderr, "%s%s%s%s\n", prompt, ": Bad TOS argument '", optarg, "; will try to use default TOS"); #else fprintf (stderr, "%s: Warning: -S ignored, no parsetos() support.\n", prompt); #endif } break; case 'X': #ifdef AUTHENTICATION auth_disable_name (optarg); #endif break; case 'a': autologin = 1; break; case 'c': skiprc = 1; break; case 'd': debug = 1; break; case 'e': set_escape_char (optarg); break; case 'f': fprintf (stderr, "%s: Warning: -f ignored, no Kerberos V5 support.\n", prompt); break; case 'F': fprintf (stderr, "%s: Warning: -F ignored, no Kerberos V5 support.\n", prompt); break; case 'k': fprintf (stderr, "%s: Warning: -k ignored, no Kerberos V4 support.\n", prompt); break; case 'l': autologin = -1; user = optarg; break; case 'b': alias = optarg; break; case 'n': #if defined(TN3270) && defined(__unix__) /* distinguish between "-n oasynch" and "-noasynch" */ if (argv[optind - 1][0] == '-' && argv[optind - 1][1] == 'n' && argv[optind - 1][2] == 'o') { if (!strcmp (optarg, "oasynch")) { noasynchtty = 1; noasynchnet = 1; } else if (!strcmp (optarg, "oasynchtty")) noasynchtty = 1; else if (!strcmp (optarg, "oasynchnet")) noasynchnet = 1; } else #endif /* defined(TN3270) && defined(__unix__) */ SetNetTrace (optarg); break; case 'r': rlogin = '******'; break; case 't': #if defined(TN3270) && defined(__unix__) transcom = tline; strncpy (transcom, optarg, sizeof (tline)); #else fprintf (stderr, "%s: Warning: -t ignored, no TN3270 support.\n", prompt); #endif break; case 'x': fprintf (stderr, "%s: Warning: -x ignored, no ENCRYPT support.\n", prompt); break; case '?': default: usage (); /* NOTREACHED */ } } if (autologin == -1) autologin = (rlogin == _POSIX_VDISABLE) ? 0 : 1; argc -= optind; argv += optind; if (argc) { char *args[7], **argp = args; if (argc > 2) usage (); *argp++ = prompt; if (user) { *argp++ = "-l"; *argp++ = user; } if (alias) { *argp++ = "-b"; *argp++ = alias; } *argp++ = argv[0]; /* host */ if (argc > 1) *argp++ = argv[1]; /* port */ *argp = 0; if (sigsetjmp (toplevel, 1) != 0) Exit (0); if (tn (argp - args, args) == 1) return (0); else return (1); } sigsetjmp (toplevel, 1); for (;;) { #ifdef TN3270 if (shell_active) shell_continue (); else #endif command (1, 0, 0); } return 0; }
void cPlayerMngr::AddPlayer(cPlayer *p) { cPlayerNode tn(p); m_plist->append(tn); }
int main(int argc, char *argv[]) { extern char *optarg; extern int optind; int ch; char *user; #ifdef FORWARD extern int forward_flags; #endif /* FORWARD */ tninit(); /* Clear out things */ TerminalSaveState(); if ((prompt = strrchr(argv[0], '/')) != NULL) ++prompt; else prompt = argv[0]; user = NULL; rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE; autologin = -1; #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) #define IPSECOPT "P:" #else #define IPSECOPT #endif while ((ch = getopt(argc, argv, "468EKLNS:X:acde:fFk:l:n:rt:x" IPSECOPT)) != -1) { #undef IPSECOPT switch(ch) { case '4': family = AF_INET; break; case '6': family = AF_INET6; break; case '8': eight = 3; /* binary output and input */ break; case 'E': rlogin = escape = _POSIX_VDISABLE; break; case 'K': #ifdef AUTHENTICATION autologin = 0; #endif break; case 'L': eight |= 2; /* binary output only */ break; case 'N': doaddrlookup = 0; break; case 'S': { fprintf(stderr, "%s: Warning: -S ignored, no parsetos() support.\n", prompt); } break; case 'X': #ifdef AUTHENTICATION auth_disable_name(optarg); #endif break; case 'a': autologin = 1; break; case 'c': skiprc = 1; break; case 'd': telnet_debug = 1; break; case 'e': set_escape_char(optarg); break; case 'f': #if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD) if (forward_flags & OPTS_FORWARD_CREDS) { fprintf(stderr, "%s: Only one of -f and -F allowed.\n", prompt); usage(); } forward_flags |= OPTS_FORWARD_CREDS; #else fprintf(stderr, "%s: Warning: -f ignored, no Kerberos V5 support.\n", prompt); #endif break; case 'F': #if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD) if (forward_flags & OPTS_FORWARD_CREDS) { fprintf(stderr, "%s: Only one of -f and -F allowed.\n", prompt); usage(); } forward_flags |= OPTS_FORWARD_CREDS; forward_flags |= OPTS_FORWARDABLE_CREDS; #else fprintf(stderr, "%s: Warning: -F ignored, no Kerberos V5 support.\n", prompt); #endif break; case 'k': fprintf(stderr, "%s: Warning: -k ignored, no Kerberos V4 support.\n", prompt); break; case 'l': if(autologin == 0) { autologin = -1; } user = optarg; break; case 'n': #ifdef TN3270 /* distinguish between "-n oasynch" and "-noasynch" */ if (argv[optind - 1][0] == '-' && argv[optind - 1][1] == 'n' && argv[optind - 1][2] == 'o') { if (!strcmp(optarg, "oasynch")) { noasynchtty = 1; noasynchnet = 1; } else if (!strcmp(optarg, "oasynchtty")) noasynchtty = 1; else if (!strcmp(optarg, "oasynchnet")) noasynchnet = 1; } else #endif /* defined(TN3270) */ SetNetTrace(optarg); break; case 'r': rlogin = '******'; break; case 't': #ifdef TN3270 (void)strlcpy(tline, optarg, sizeof(tline)); transcom = tline; #else fprintf(stderr, "%s: Warning: -t ignored, no TN3270 support.\n", prompt); #endif break; case 'x': #ifdef ENCRYPTION encrypt_auto(1); decrypt_auto(1); #else /* ENCRYPTION */ fprintf(stderr, "%s: Warning: -x ignored, no ENCRYPT support.\n", prompt); #endif /* ENCRYPTION */ break; #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) case 'P': if (!strncmp("in", optarg, 2)) ipsec_policy_in = strdup(optarg); else if (!strncmp("out", optarg, 3)) ipsec_policy_out = strdup(optarg); else usage(); break; #endif case '?': default: usage(); /* NOTREACHED */ } } if (autologin == -1) { /* [email protected]; force */ #if defined(AUTHENTICATION) autologin = 1; #endif #if defined(ENCRYPTION) encrypt_auto(1); decrypt_auto(1); #endif } if (autologin == -1) autologin = (rlogin == _POSIX_VDISABLE) ? 0 : 1; argc -= optind; argv += optind; if (argc) { static char ml[] = "-l"; char *args[7]; char ** volatile argp; /* avoid longjmp clobbering */ argp = args; if (argc > 2) usage(); *argp++ = prompt; if (user) { *argp++ = ml; *argp++ = user; } *argp++ = argv[0]; /* host */ if (argc > 1) *argp++ = argv[1]; /* port */ *argp = 0; if (setjmp(toplevel) != 0) Exit(0); if (tn(argp - args, args) == 1) return (0); else return (1); } (void)setjmp(toplevel); for (;;) { #ifdef TN3270 if (shell_active) shell_continue(); else #endif command(1, 0, 0); } }
void tool_app_t::listdevices() { netlist_tool_t nt(*this, "netlist"); nt.init(); if (!opt_verb()) nt.log().verbose.set_enabled(false); if (opt_quiet()) nt.log().warning.set_enabled(false); netlist::factory::list_t &list = nt.setup().factory(); nt.setup().register_source(plib::make_unique_base<netlist::source_t, netlist::source_proc_t>(nt.setup(), "dummy", &netlist_dummy)); nt.setup().include("dummy"); nt.start(); std::vector<plib::owned_ptr<netlist::core_device_t>> devs; for (auto & f : list) { pstring out = plib::pfmt("{1:-20} {2}(<id>")(f->classname())(f->name()); std::vector<pstring> terms; f->macro_actions(nt.setup().netlist(), f->name() + "_lc"); auto d = f->Create(nt.setup().netlist(), f->name() + "_lc"); // get the list of terminals ... for (auto & t : nt.setup().m_terminals) { if (t.second->name().startsWith(d->name())) { pstring tn(t.second->name().substr(d->name().length()+1)); if (tn.find(".") == pstring::npos) terms.push_back(tn); } } for (auto & t : nt.setup().m_alias) { if (t.first.startsWith(d->name())) { pstring tn(t.first.substr(d->name().length()+1)); //printf("\t%s %s %s\n", t.first.c_str(), t.second.c_str(), tn.c_str()); if (tn.find(".") == pstring::npos) { terms.push_back(tn); pstring resolved = nt.setup().resolve_alias(t.first); //printf("\t%s %s %s\n", t.first.c_str(), t.second.c_str(), resolved.c_str()); if (resolved != t.first) { auto found = std::find(terms.begin(), terms.end(), resolved.substr(d->name().length()+1)); if (found!=terms.end()) terms.erase(found); } } } } out += "," + f->param_desc(); for (auto p : plib::psplit(f->param_desc(),",") ) { if (p.startsWith("+")) { plib::container::remove(terms, p.substr(1)); } } out += ")"; printf("%s\n", out.c_str()); if (terms.size() > 0) { pstring t = ""; for (auto & j : terms) t += "," + j; printf("\tTerminals: %s\n", t.substr(1).c_str()); } devs.push_back(std::move(d)); } }
// ------------------------------------------------------------------------- // http://www.kddcup-orange.com/evaluation.php void OutputInfo::outputBalancedError(InputData* pData, BaseLearner* pWeakHypothesis) { int numClasses = pData->getNumClasses(); const int numExamples = pData->getNumExamples(); vector< int > tp( numClasses ); fill( tp.begin(), tp.end(), 0 ); vector< int > tn( numClasses ); fill( tn.begin(), tn.end(), 0 ); vector< float > bacPerClass( numClasses ); fill( bacPerClass.begin(), bacPerClass.end(), 0.0 ); table& g = _gTableMap[pData]; vector<Label>::const_iterator lIt; // Building the strong learner (discriminant function) //for (int i = 0; i < numExamples; ++i) //{ // const vector<Label>& labels = pData->getLabels(i); // for (lIt = labels.begin(); lIt != labels.end(); ++lIt ) // { // g[i][lIt->idx] += pWeakHypothesis->getAlpha() * // alpha // pWeakHypothesis->classify( pData, i, lIt->idx ); // } //} //for (int i = 0; i < numExamples; ++i) //{ // for (int l = 0; l < numClasses; ++l) // { // g[i][l] += pWeakHypothesis->getAlpha() * // alpha // pWeakHypothesis->classify( pData, i, l ); // h_l(x) // } //} for (int i = 0; i < numExamples; ++i) { const vector<Label>& labels = pData->getLabels(i); // the vote of the winning negative class float maxNegClass = -numeric_limits<float>::max(); // the vote of the winning positive class float minPosClass = numeric_limits<float>::max(); for ( lIt = labels.begin(); lIt != labels.end(); ++lIt ) { // get the negative winner class if ( lIt->y < 0 && g[i][lIt->idx] > maxNegClass ) maxNegClass = g[i][lIt->idx]; // get the positive winner class if ( lIt->y > 0 && g[i][lIt->idx] < minPosClass ) minPosClass = g[i][lIt->idx]; } // if the vote for the worst positive label is higher than the // vote for the highest negative label -> good label if (minPosClass > maxNegClass){ for ( lIt = labels.begin(); lIt != labels.end(); ++lIt ) { if ( lIt->y > 0 ) { tp[ lIt->idx]++; } else { tn[ lIt->idx]++; } } } } float bACC = 0.0; for( int i = 0; i < numClasses; i++ ) { float specificity = (((float)tp[i]) / ((float) pData->getNumExamplesPerClass( i ) )); float sensitivity = ( ((float)tn[i]) / ((float) ( numExamples - pData->getNumExamplesPerClass( i ))) ); //_outStream << '\t' << numExamples - pData->getNumExamplesPerClass( i ); //_outStream << '\t' << specificity << '\t' << sensitivity; bacPerClass[ i ] = 0.5 * ( specificity + sensitivity ); bACC += bacPerClass[i]; } bACC /= (float) numClasses; _outStream << '\t' << bACC; for( int i = 0; i < numClasses; i++ ) { _outStream << '\t' << bacPerClass[i]; } }
bool isNodeSupported(MString typeName, ShaderNode& sn) { std::string tn(typeName.asChar()); return mtm_findShaderTypeByName(tn, sn); }
void airport::BasicCrawler::set_node_name (const char *node_name) { std::string tn(node_name); set_node_name(tn); }
void NSModel<SortPolicy>::BuildModel(arma::mat&& referenceSet, const size_t leafSize, const bool naive, const bool singleMode, const double epsilon) { // Initialize random basis if necessary. if (randomBasis) { Log::Info << "Creating random basis..." << std::endl; while (true) { // [Q, R] = qr(randn(d, d)); // Q = Q * diag(sign(diag(R))); arma::mat r; if (arma::qr(q, r, arma::randn<arma::mat>(referenceSet.n_rows, referenceSet.n_rows))) { arma::vec rDiag(r.n_rows); for (size_t i = 0; i < rDiag.n_elem; ++i) { if (r(i, i) < 0) rDiag(i) = -1; else if (r(i, i) > 0) rDiag(i) = 1; else rDiag(i) = 0; } q *= arma::diagmat(rDiag); // Check if the determinant is positive. if (arma::det(q) >= 0) break; } } } // Clean memory, if necessary. boost::apply_visitor(DeleteVisitor(), nSearch); // Do we need to modify the reference set? if (randomBasis) referenceSet = q * referenceSet; if (!naive) { Timer::Start("tree_building"); Log::Info << "Building reference tree..." << std::endl; } switch (treeType) { case KD_TREE: nSearch = new NSType<SortPolicy, tree::KDTree>(naive, singleMode, epsilon); break; case COVER_TREE: nSearch = new NSType<SortPolicy, tree::StandardCoverTree>(naive, singleMode, epsilon); break; case R_TREE: nSearch = new NSType<SortPolicy, tree::RTree>(naive, singleMode, epsilon); break; case R_STAR_TREE: nSearch = new NSType<SortPolicy, tree::RStarTree>(naive, singleMode, epsilon); break; case BALL_TREE: nSearch = new NSType<SortPolicy, tree::BallTree>(naive, singleMode, epsilon); break; case X_TREE: nSearch = new NSType<SortPolicy, tree::XTree>(naive, singleMode, epsilon); break; case HILBERT_R_TREE: nSearch = new NSType<SortPolicy, tree::HilbertRTree>(naive, singleMode, epsilon); break; case R_PLUS_TREE: nSearch = new NSType<SortPolicy, tree::RPlusTree>(naive, singleMode, epsilon); break; case R_PLUS_PLUS_TREE: nSearch = new NSType<SortPolicy, tree::RPlusPlusTree>(naive, singleMode, epsilon); break; } TrainVisitor<SortPolicy> tn(std::move(referenceSet), leafSize); boost::apply_visitor(tn, nSearch); if (!naive) { Timer::Stop("tree_building"); Log::Info << "Tree built." << std::endl; } }
bool wxFont::Create(const wxString& fontname, wxFontEncoding enc) { if( !fontname ) { *this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT); return true; } m_refData = new wxFontRefData(); M_FONTDATA->m_nativeFontInfo.SetXFontName(fontname); // X font name wxString tmp; wxStringTokenizer tn( fontname, wxT("-") ); tn.GetNextToken(); // skip initial empty token tn.GetNextToken(); // foundry M_FONTDATA->m_faceName = tn.GetNextToken(); // family tmp = tn.GetNextToken().MakeUpper(); // weight if (tmp == wxT("BOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("BLACK")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("EXTRABOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("DEMIBOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("ULTRABOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("LIGHT")) M_FONTDATA->m_weight = wxFONTWEIGHT_LIGHT; if (tmp == wxT("THIN")) M_FONTDATA->m_weight = wxFONTWEIGHT_LIGHT; tmp = tn.GetNextToken().MakeUpper(); // slant if (tmp == wxT("I")) M_FONTDATA->m_style = wxFONTSTYLE_ITALIC; if (tmp == wxT("O")) M_FONTDATA->m_style = wxFONTSTYLE_ITALIC; tn.GetNextToken(); // set width tn.GetNextToken(); // add. style tn.GetNextToken(); // pixel size tmp = tn.GetNextToken(); // pointsize if (tmp != wxT("*")) { long num = wxStrtol (tmp.c_str(), (wxChar **) NULL, 10); M_FONTDATA->m_pointSize = (int)(num / 10); } tn.GetNextToken(); // x-res tn.GetNextToken(); // y-res tmp = tn.GetNextToken().MakeUpper(); // spacing if (tmp == wxT("M")) M_FONTDATA->m_family = wxFONTFAMILY_MODERN; else if (M_FONTDATA->m_faceName == wxT("TIMES")) M_FONTDATA->m_family = wxFONTFAMILY_ROMAN; else if (M_FONTDATA->m_faceName == wxT("HELVETICA")) M_FONTDATA->m_family = wxFONTFAMILY_SWISS; else if (M_FONTDATA->m_faceName == wxT("LUCIDATYPEWRITER")) M_FONTDATA->m_family = wxFONTFAMILY_TELETYPE; else if (M_FONTDATA->m_faceName == wxT("LUCIDA")) M_FONTDATA->m_family = wxFONTFAMILY_DECORATIVE; else if (M_FONTDATA->m_faceName == wxT("UTOPIA")) M_FONTDATA->m_family = wxFONTFAMILY_SCRIPT; tn.GetNextToken(); // avg width // deal with font encoding M_FONTDATA->m_encoding = enc; if ( M_FONTDATA->m_encoding == wxFONTENCODING_SYSTEM ) { wxString registry = tn.GetNextToken().MakeUpper(), encoding = tn.GetNextToken().MakeUpper(); if ( registry == wxT("ISO8859") ) { int cp; if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 ) { M_FONTDATA->m_encoding = (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1); } } else if ( registry == wxT("MICROSOFT") ) { int cp; if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 ) { M_FONTDATA->m_encoding = (wxFontEncoding)(wxFONTENCODING_CP1250 + cp); } } else if ( registry == wxT("KOI8") ) { M_FONTDATA->m_encoding = wxFONTENCODING_KOI8; } //else: unknown encoding - may be give a warning here? else return false; } return true; }
void recursive(JFile from, JFile to) { JFile ff, tf; JString fn, tn; int attr = JFile::LA_DIRECTORY | JFile::LA_SORT; JArray fa = from.list(attr, "*.*"); JArray ta = to.list(attr, "*.*"); if (*(JString*)fa[0] == dotdot) fa.del(0); if (*(JString*)ta[0] == dotdot) ta.del(0); int i, sz = fa.size(); int tsz = ta.size(); for (i=0; i<sz; i++) { fn = *(JString*)fa[i]; ff = JFile(from, fn(1, fn.length()-1)); if (i < tsz) { tn = *(JString*)ta[i]; tf = JFile(to, tn(1, tn.length()-1)); } else tf = JFile(to, "*"); if ((i >= tsz) || (ff.getName() != tf.getName())) { if ((i < tsz) && (ff.getName() > tf.getName())) { printf("Remove Extra Directory %s\n", (char*)tf.getPath()); removeDir(tf); ta.del(i); tsz--; i--; continue; } tf = JFile(to, ff.getName()); printf("Create Directory %s\n", (char*)tf.getPath()); tf.makeDir(); ta.insert(JString("[")+ff.getName()+"]", i); tsz++; } if ((ff.getName() == tf.getName()) && tf.exists()) { printf("Check Directory %s\n", (char*)tf.getPath()); recursive(ff, tf); } } for (; i<tsz; i++) { tn = *(JString*)ta[i]; tf = JFile(to, tn(1, tn.length()-1)); printf("Remove Extra Directory %s\n", (char*)tf.getPath()); removeDir(tf); } attr = JFile::LA_FILE | JFile::LA_SORT; fa = from.list(attr, "*.*"); ta = to.list(attr, "*.*"); sz = fa.size(); tsz = ta.size(); for (i=0; i<sz; i++) { ff = JFile(from, *(JString*)fa[i]); if (i < tsz) tf = JFile(to, *(JString*)ta[i]); else tf = JFile(to, "*"); if ((i >= tsz) || (ff.getName() != tf.getName())) { if ((i < tsz) && (ff.getName() > tf.getName())) { printf("Delete Extra File %s\n", (char*)tf.getPath()); tf.remove(); ta.del(i); tsz--; i--; continue; } tf = JFile(to, ff.getName()); printf("Create File %s\n", (char*)tf.getPath()); copy(ff, tf); ta.insert(ff.getName(), i); tsz++; } if ((ff.getName() == tf.getName()) && tf.exists()) { if (ff.lastModified() > tf.lastModified()) { printf("Update File %s\n", (char*)tf.getPath()); copy(ff, tf); } } } for (; i<tsz; i++) { tf = JFile(to, *(JString*)ta[i]); printf("Delete Extra File %s\n", (char*)tf.getPath()); tf.remove(); } }
UtlString TestOsSysLogListener::getLogFilename(const UtlString& testName) { UtlString tn(testName); tn.replace(':','_').append(".log"); return tn; }
long long fibonicci(int n,long long MOD) { long long T[2][2]={{0,1},{1,1}}; tn(T,n,MOD); return T[1][0]%MOD; }