void loop(void) { use_basic(); glEnable(GL_DEPTH_TEST); if(mm) rotz(pview,-mx*50.0f*dt); else if(rx!=0.0f) rotz(pview,-rx*200.0f*dt); else rotz(pview,-10.0f*dt); basic_pview(pview); update_model_vbo(); clear(); use_tex(area_tex); draw_model_vbo(&area_mod); use_text_pro(); glDisable(GL_DEPTH_TEST); use_tex(font.t); draw_text(text.len); if(kp(SDL_SCANCODE_DELETE) || kp(SDL_SCANCODE_ESCAPE) || bp(0)) quit(); }
bool CalibrationData::saveSLCALIB(const QString& filename){ FILE * fp = fopen(qPrintable(filename), "w"); if (!fp) return false; fprintf(fp, "#V1.0 SLStudio calibration\n"); fprintf(fp, "#Calibration time: %s\n\n", calibrationDateTime.c_str()); fprintf(fp, "Kc\n%f %f %f\n%f %f %f\n%f %f %f\n\n", Kc(0,0), Kc(0,1), Kc(0,2), Kc(1,0), Kc(1,1), Kc(1,2), Kc(2,0), Kc(2,1), Kc(2,2)); fprintf(fp, "kc\n%f %f %f %f %f\n\n", kc(0), kc(1), kc(2), kc(3), kc(4)); fprintf(fp, "Kp\n%f %f %f\n%f %f %f\n%f %f %f\n\n", Kp(0,0), Kp(0,1), Kp(0,2), Kp(1,0), Kp(1,1), Kp(1,2), Kp(2,0), Kp(2,1), Kp(2,2)); fprintf(fp, "kp\n%f %f %f %f %f\n\n", kp(0), kp(1), kp(2), kp(3), kp(4)); fprintf(fp, "Rp\n%f %f %f\n%f %f %f\n%f %f %f\n\n", Rp(0,0), Rp(0,1), Rp(0,2), Rp(1,0), Rp(1,1), Rp(1,2), Rp(2,0), Rp(2,1), Rp(2,2)); fprintf(fp, "Tp\n%f %f %f\n\n", Tp(0), Tp(1), Tp(2)); fprintf(fp, "cam_error: %f\n\n", cam_error); fprintf(fp, "proj_error: %f\n\n", proj_error); fprintf(fp, "stereo_error: %f\n\n", stereo_error); fclose(fp); return true; }
static void signal_setup_stack(struct task *current, struct sigaction *action, int signum, struct irq_frame *iframe) { struct signal_context context; char *stack, *signal_ret; context.frame = *iframe; context.old_mask = current->sig_blocked; context.signum = signum; stack = (char *)iframe->esp; kp(KP_TRACE, "iframe->esp: %p\n", stack); stack = ALIGN_2_DOWN(stack, 4); stack -= x86_trampoline_len; memcpy(stack, x86_trampoline_code, x86_trampoline_len); signal_ret = stack; kp(KP_TRACE, "signal_ret: %p\n", signal_ret); stack = ALIGN_2_DOWN(stack, 4); stack -= sizeof(context); *(struct signal_context *)stack = context; stack -= sizeof(signal_ret); *(char **)stack = signal_ret; iframe->esp = (uint32_t)stack; iframe->eip = (uint32_t)action->sa_handler; kp(KP_TRACE, "iframe->eip: %p\n", (void *)iframe->eip); }
static int packet_process_thread(void *p) { while (1) { using_spinlock(&packet_queue_lock) { kp(KP_NORMAL, "packet-queue awake\n"); while (!list_empty(&packet_queue)) { struct packet *packet = list_take_first(&packet_queue, struct packet, packet_entry); kp(KP_NORMAL, "Recieved packet! len: %d\n", packet_len(packet)); kp(KP_NORMAL, "Packets in queue: %d\n", --packet_queue_length); not_using_spinlock(&packet_queue_lock) packet_linklayer_rx(packet); } sleep { if (list_empty(&packet_queue)) { not_using_spinlock(&packet_queue_lock) scheduler_task_yield(); } } } } return 0; }
void IBClient::updateAccountValue(const IBString &key, const IBString &val, const IBString ¤cy, const IBString &accountName) { receiveData("updateAccountValue", knk(4, kp((S)key.c_str()), kp((S)val.c_str()), ks((S)currency.c_str()), ks((S)accountName.c_str()) )); }
void dump_stack_ptr(void *start) { struct stackframe *stack = start; int frame = 0; kp(KP_ERROR, " Stack: %p\n", start); for (; stack != 0; stack = stack->caller_stackframe) { frame++; kp(KP_ERROR, " [%d][0x%08x]\n", frame, stack->return_addr); } }
void IBClient::tickEFP(TickerId tickerId, TickType tickType, double basisPoints, const IBString &formattedBasisPoints, double totalDividends, int holdDays, const IBString &futureExpiry, double dividendImpact, double dividendsToExpiry) { auto dict = createDictionary(std::map<std::string, K> { { "tickerId", kj(tickerId) }, { "tickType", ki(tickType) }, { "basisPoints", kf(basisPoints) }, { "formattedBasisPoints", kp((S)formattedBasisPoints.c_str()) }, { "totalDividends", kf(totalDividends) }, { "holdDays", ki(holdDays) }, { "futureExpiry", kp((S)futureExpiry.c_str()) }, { "dividendImpact", kf(dividendImpact) }, { "dividendsToExpiry", kf(dividendsToExpiry) } }); receiveData("tickEFP", dict); }
Vector3 computeDesiredForce(const SE3Type & pose, const Vector3 & linear_velocity, double delta_time) { Vector3 desired_position(0,0,1); Vector3 desired_velocity(0,0,0); // Vector3 kp(1,1,1) ; // Vector3 kd(1,1,1); // Vector3 ki(0.0015,0.0015,0.0015) ; //for ukf after redirecting to log Vector3 kp(4,4,4) ; Vector3 kd(3,3,3); Vector3 ki(0.002,0.002,0.002) ; Vector3 current_position=pose.translation(); std::cout << "\nCurrent Position" << current_position ; Vector3 proportiona_val= kp.cwiseProduct(desired_position-current_position); Vector3 differential_val=kd.cwiseProduct(desired_velocity-linear_velocity); accumulated_error = accumulated_error+(desired_position-current_position) ; Vector3 integral_value=ki.cwiseProduct(accumulated_error); Vector3 desired_force=proportiona_val+ differential_val+integral_value; std::cout << "\ndesired_force is" << desired_force ; return desired_force; }
//Using lowe's sift format // num dim // y x scale orien bool readKp(const char* kp_file, vector<KeyPoint>& kpts) { ifstream file(kp_file); if(!file.is_open()) { cerr<<"Can NOT open file "<<kp_file<<endl; return false; } int num; int dim; file >> num >> dim; kpts.clear(); kpts.reserve(num); for(int i=0; i<num ; i++) { float x,y,scale,ori,size,angle; file >> y >> x >> scale >> ori; angle = radian2angle(ori); size = scale*FRIF_BASE_SIZE; KeyPoint kp(Point2f(x,y),size,angle, 0, 0, -1); kpts.push_back(kp); } file.close(); return true; }
static void signal_default(struct task *current, int signum) { /* Init ignores every signal */ if (current->pid == 1) return ; switch (signum) { case SIGCHLD: case SIGCONT: case SIGWINCH: /* Ignore */ break; case SIGSTOP: case SIGTSTP: case SIGTTIN: case SIGTTOU: kp(KP_TRACE, "task %d: Handling stop (%d)\n", current->pid, signum); current->ret_signal = TASK_SIGNAL_STOP | signum; current->state = TASK_STOPPED; if (current->parent) scheduler_task_wake(current->parent); scheduler_task_yield(); break; default: current->ret_signal = signum; sys_exit(0); } }
int main() { for ( int level = 1; level != 4; ++level ) { for ( int i = 1; i != 11; ++i ) { std::string filenames[2]; convert_to_filename(level, i, filenames); MyKeyPoints kp(filenames[0], filenames[1]); const auto startTime = std::chrono::system_clock::now(); kp.init(); const auto endTime = std::chrono::system_clock::now(); const auto timeSpan = endTime - startTime; std::cout << "Time:" << std::chrono::duration_cast<std::chrono::milliseconds>( timeSpan ).count() << "[ms]" << std::endl; cv::Mat_< cv::Vec3b > rgb_image1 = cv::imread(filenames[0], 1); cv::Mat_< cv::Vec3b > rgb_image2 = cv::imread(filenames[1], 1); mosaic_with_helmat(rgb_image1, rgb_image2, kp.points1, kp.points2); cv::waitKey(0); cv::destroyAllWindows(); } } return 0; }
// Special-cased helper for deleting ranges out of an index. long long deleteIndexRange(const string &ns, const BSONObj &min, const BSONObj &max, const BSONObj &keyPattern, const bool maxInclusive, const bool fromMigrate) { Collection *cl = getCollection(ns); if (cl == NULL) { return 0; } IndexDetails &i = cl->idx(cl->findIndexByKeyPattern(keyPattern)); // Extend min to get (min, MinKey, MinKey, ....) KeyPattern kp(keyPattern); BSONObj newMin = KeyPattern::toKeyFormat(kp.extendRangeBound(min, false)); // If upper bound is included, extend max to get (max, MaxKey, MaxKey, ...) // If not included, extend max to get (max, MinKey, MinKey, ....) BSONObj newMax = KeyPattern::toKeyFormat(kp.extendRangeBound(max, maxInclusive)); long long nDeleted = 0; for (shared_ptr<Cursor> c(Cursor::make(cl, i, newMin, newMax, maxInclusive, 1)); c->ok(); c->advance()) { const BSONObj pk = c->currPK(); const BSONObj obj = c->current(); OpLogHelpers::logDelete(ns.c_str(), obj, fromMigrate); deleteOneObject(cl, pk, obj); nDeleted++; } return nDeleted; }
void IBClient::orderStatus(OrderId orderId, const IBString &status, int filled, int remaining, double avgFillPrice, int permId, int parentId, double lastFillPrice, int clientId, const IBString &whyHeld) { auto dict = createDictionary(std::map<std::string, K> { { "id", ki(orderId) }, { "status", kp((S)status.c_str()) }, { "filled", ki(filled) }, { "remaining", ki(remaining) }, { "avgFillPrice", kf(avgFillPrice) }, { "permId", ki(permId) }, { "parentId", ki(parentId) }, { "lastFilledPrice", kf(lastFillPrice) }, { "clientId", ki(clientId) }, { "whyHeld", kp((S)whyHeld.c_str()) } }); receiveData("orderStatus", dict); }
bool handleCreateKeyPair( AttributeValueMap & avm, std::string & reply, unsigned requestNumber ) { // fprintf( stdout, "handleCreateKeyPair()\n" ); bool found = false; std::string userID; User & user = validateAndAcquireUser( avm, userID, reply, found ); if( ! found ) { return false; } std::string keyName = getObject< std::string >( avm, "KeyName", found ); if( (! found) || keyName.empty() ) { fprintf( stderr, "Failed to find KeyName in query.\n" ); reply = "Required parameter KeyName missing or empty.\n"; return false; } Keypair kp( keyName, "key-fingerprint", "private-key" ); user.keypairs[ keyName ] = kp; char rID[] = "1234"; snprintf( rID, sizeof( rID ), "%.4x", requestNumber ); std::string requestID = rID; std::ostringstream xml; xml << "<CreateKeyPairResponse xmlns=\"http://ec2.amazonaws.com/doc/2010-11-15/\">" << std::endl; xml << xmlTag( "requestId", rID ) << std::endl; xml << xmlTag( "keyName", kp.keyName ) << std::endl; xml << xmlTag( "keyFingerprint", kp.fingerprint ) << std::endl; xml << xmlTag( "keyMaterial", kp.privateKey ) << std::endl; xml << "/<CreateKeyPairResponse>" << std::endl; reply = xml.str(); return true; }
//initializes hardware void initialize_hardware(void) { dsp(99,0,0); kp(1); TMSK2 = TMSK2 & 0xFC; //set clock to 2MHz - .5 us period TCTL2 = 0x10; //set to read rising edge TFLG1 = 0x04; // }
bool AztecOOSolver::solve() { #ifdef HAVE_AZTECOO assert(m.size == rhs.size); // no output aztec.SetAztecOption(AZ_output, AZ_none); // AZ_all | AZ_warnings | AZ_last | AZ_summary #ifndef COMPLEX // setup the problem aztec.SetUserMatrix(m.mat); aztec.SetRHS(rhs.vec); Epetra_Vector x(*rhs.std_map); aztec.SetLHS(&x); if (pc != NULL) { Epetra_Operator *op = pc->get_obj(); assert(op != NULL); // can work only with Epetra_Operators aztec.SetPrecOperator(op); } // solve it aztec.Iterate(max_iters, tolerance); delete [] sln; sln = new scalar[m.size]; memset(sln, 0, m.size * sizeof(scalar)); // copy the solution into sln vector for (int i = 0; i < m.size; i++) sln[i] = x[i]; #else double c0r = 1.0, c0i = 0.0; double c1r = 0.0, c1i = 1.0; Epetra_Vector xr(*rhs.std_map); Epetra_Vector xi(*rhs.std_map); Komplex_LinearProblem kp(c0r, c0i, *m.mat, c1r, c1i, *m.mat_im, xr, xi, *rhs.vec, *rhs.vec_im); Epetra_LinearProblem *lp = kp.KomplexProblem(); aztec.SetProblem(*lp); // solve it aztec.Iterate(max_iters, tolerance); kp.ExtractSolution(xr, xi); delete [] sln; sln = new scalar[m.size]; memset(sln, 0, m.size * sizeof(scalar)); // copy the solution into sln vector for (int i = 0; i < m.size; i++) sln[i] = scalar(xr[i], xi[i]); #endif return true; #else return false; #endif }
void IBClient::accountSummary(int reqId, const IBString &account, const IBString &tag, const IBString &value, const IBString &curency) { receiveData("accountSummary", knk(5, ki(reqId), ks((S)account.c_str()), ks((S)tag.c_str()), kp((S)value.c_str()), ks((S)curency.c_str()))); }
void kp(node dui[],long a,long b) { long i=a,j=b,k; if(i<j) { k = rand()%(b-a) + a; dui[0] = dui[k]; dui[k] = dui[i]; dui[i] = dui[0]; while(i<j) { while(i<j && dui[0].sc <= dui[j].sc) j--; dui[i] = dui[j]; while(i<j && dui[0].sc >= dui[i].sc) i++; dui[j] = dui[i]; } dui[i] = dui[0]; kp(dui,a,i-1); kp(dui,i+1,b); } }
void IBClient::execDetails(int reqId, const Contract &contract, const Execution &execution) { auto exec = createDictionary(std::map<std::string, K> { { "execId", ks((S)execution.execId.c_str()) }, { "time", kp((S)execution.time.c_str()) }, // TODO: Convert { "acctNumber", ks((S)execution.acctNumber.c_str()) }, { "exchange", ks((S)execution.exchange.c_str()) }, { "side", ks((S)execution.side.c_str()) }, { "shares", ki(execution.shares) }, { "price", kf(execution.price) }, { "permId", ki(execution.permId) }, { "clientId", kj(execution.clientId) }, { "orderId", kj(execution.orderId) }, { "liquidation", ki(execution.liquidation) }, { "cumQty", ki(execution.cumQty) }, { "avgPrice", kf(execution.avgPrice) }, { "evRule", kp((S)execution.evRule.c_str()) }, { "evMultiplier", kf(execution.evMultiplier) } }); receiveData("execDetails", knk(3, ki(reqId), kj(contract.conId), exec)); }
void IBClient::commissionReport( const CommissionReport& commissionReport) { auto dict = createDictionary(std::map<std::string, K> { { "commission", kf(commissionReport.commission) }, { "currency", ks((S)commissionReport.currency.c_str()) }, { "execId", ks((S)commissionReport.execId.c_str()) }, { "realizedPNL", kf(commissionReport.realizedPNL) }, { "yield", kf(commissionReport.yield) }, { "yieldRedemptionDate", kp((S)stringFormat("%i", commissionReport.yieldRedemptionDate).c_str()) } }); receiveData("commissionReport", dict); }
K eval(K x,K y,K z){K*k;S*b,s;SQLULEN w;SQLLEN*nb;SQLINTEGER*wb;H*tb,u,t,j=0,p,m;F f;C c[128];I n=xj<0;D d=d1(n?-xj:xj);U(d)x=y;Q(z->t!=-KJ||xt!=-KS&&xt!=KC,"type") if(z->j)SQLSetStmtAttr(d,SQL_ATTR_QUERY_TIMEOUT,(SQLPOINTER)(SQLULEN)z->j,0); if(xt==-KS)Q1(SQLColumns(d,(S)0,0,(S)0,0,xs,S0,(S)0,0))else{I e;K q=kpn(xG,xn);ja(&q,"\0");e=SQLExecDirect(d,q->G0,xn);r0(q);Q1(e)} SQLNumResultCols(d,&j);P(!j,(d0(d),knk(0))) b=malloc(j*SZ),tb=malloc(j*2),wb=malloc(j*SZ),nb=malloc(j*SZ),x=ktn(KS,j),y=ktn(0,j);// sqlserver: no bind past nonbind DO(j,Q1(SQLDescribeCol(d,(H)(i+1),c,128,&u,&t,&w,&p,&m))xS[i]=sn(c,u); if(t>90)t-=82; Q(t<-11||t>12,xS[i])wb[i]=ut[tb[i]=t=t>0?t:12-t]==KS&&w?w+1:wt[t];if(ut[t]==KS&&(n||!wb[i]||wb[i]>9))tb[i]=13) DO(j,kK(y)[i]=ktn(ut[t=tb[i]],0);if(w=wb[i])Q1(SQLBindCol(d,(H)(i+1),ct[t],b[i]=malloc(w),w,nb+i))) for(;SQL_SUCCEEDED(SQLFetch(d));)DO(j,k=kK(y)+i;u=ut[t=tb[i]];s=b[i];n=SQL_NULL_DATA==(int)nb[i]; if(!u)jk(k,n?ktn(ct[t]?KC:KG,0):wb[i]?kp(s):gb(d,(H)(i+1),t)); else ja(k,n?nu(u):u==KH&&wb[i]==1?(t=(H)*s,(S)&t):u==KS?(s=dtb(s,nb[i]),(S)&s):u<KD?s:u==KZ?(f=ds(s)+(vs(s+6)+*(I*)(s+12)/1e9)/8.64e4,(S)&f):(w=u==KD?ds(s):vs(s),(S)&w))) if(!SQLMoreResults(d))O("more\n");DO(j,if(wb[i])free(b[i]))R free(b),free(tb),free(wb),free(nb),d0(d),xT(xD(x,y));}
void XMLAttributes::set(string key, string value) { XMLAttributes::iterator it; // try to find the key in the map it=find(key); if (it != end()) { (*it).second = value; } else { // insert, because the key-value pair was not found XMLAttributes::value_type kp(key,value); insert(kp); } }
xmltagnamehandle XMLContext::insert_tagname( string &tagname ) { if (!init) init_context(); xmltagnamemap::const_iterator iter; iter=tagnames.begin(); for(;iter!=tagnames.end();iter++) { if ((*iter).second == tagname ) return (*iter).first; } xmltagnamemap::value_type kp(nexthandle,tagname); tagnames.insert(kp); return nexthandle++; }
bool QueryResponseBuilder::chunkMatches( ResultDetails* resultDetails ) { if ( !_collMetadata ) { return true; } // TODO: should make this covered at some point resultDetails->loadedRecord = true; KeyPattern kp( _collMetadata->getKeyPattern() ); if ( _collMetadata->keyBelongsToMe( kp.extractSingleKey( _cursor->current() ) ) ) { return true; } resultDetails->chunkSkip = true; return false; }
KeyPair OpenSSLRSAPermutation::generateKey(int keySize) { RSA* pair = RSA_new(); BIGNUM* bne = BN_new(); BN_set_word(bne, 65537); int ret = RSA_generate_key_ex(pair, keySize, bne, NULL); biginteger mod = opensslbignum_to_biginteger(pair->n); biginteger pubExp = opensslbignum_to_biginteger(pair->e); biginteger privExp = opensslbignum_to_biginteger(pair->d); KeyPair kp(new RSAPublicKey(mod, pubExp), new RSAPrivateKey(mod, privExp)); RSA_free(pair); BN_free(bne); return kp; }
int main(){ int k = 0; while(~scanf("%s", s)){ if(strcmp(s, "END")==0) break; ++k; pre(); kp(); int ans = 0; for(int i = 0; i < n; i++) ans = std::max(ans, p[i]); printf("Case %d: %d\n", k, ans-1); } return 0; }
void TFGeometry1D::addKeyPoint( float position, float alpha) { TFGeometry1D::KeyPoint kp(position, cgt::col4(255)); cgt::col4 color(255); std::vector<TFGeometry1D::KeyPoint>::iterator lb = std::upper_bound(_keyPoints.begin(), _keyPoints.end(), kp); if (lb != _keyPoints.end()) { color = lb->_color; } else { color = _keyPoints.back()._color; } color.a = static_cast<uint8_t>(alpha * 255.f); addKeyPoint(position, color); }
void IBClient::updatePortfolio(const Contract &contract, int position, double marketPrice, double marketValue, double averageCost, double unrealizedPNL, double realizedPNL, const IBString &accountName) { auto dict = createDictionary(std::map<std::string, K> { { "contract", kj(contract.conId) }, { "position", ki(position) }, { "marketPrice", kf(marketPrice) }, { "marketValue", kf(marketValue) }, { "averageCost", kf(averageCost) }, { "unrealizedPNL", kf(unrealizedPNL) }, { "realizedPNL", kf(realizedPNL) }, { "accountName", kp((S)accountName.c_str()) } }); receiveData("updatePortfolio", dict); }
int main() { int i; int N; scanf("%d", &N); while(N--) { scanf("%s", s); n = strlen(s); init(); ans = 0; kp(); printf("%d\n", ans-1); } return 0; }
int main() { init(a1); kp(a2) ; printf("%d\n",a1); a1 = 100 ; printf("%d\n",a1); printf("kp %d %p\n",sizeof(a2),a2); a2 = (void *)malloc(10); printf("kp %d %p\n",sizeof(a2),a2); free(a2); }