// Filter a vertex using the method of [Jones et al. 2003] // For pass 1, do simple smoothing and write to mpoints // For pass 2, do bilateral, using mpoints, and write to themesh->vertices static void jones_filter(TriMesh *themesh, vector<unsigned> &flags, unsigned &flag_curr, int v, float invsigma2_1, float invsigma2_2, bool pass1, vector<point> &mpoints) { const point &p = pass1 ? themesh->vertices[v] : mpoints[v]; point &flt = pass1 ? mpoints[v] : themesh->vertices[v]; flt = point(); float sum_w = 0.0f; flag_curr++; vector<int> boundary = themesh->adjacentfaces[v]; while (!boundary.empty()) { int f = boundary.back(); boundary.pop_back(); if (flags[f] == flag_curr) continue; flags[f] = flag_curr; int v0 = themesh->faces[f][0]; int v1 = themesh->faces[f][1]; int v2 = themesh->faces[f][2]; const point &p0 = themesh->vertices[v0]; const point &p1 = themesh->vertices[v1]; const point &p2 = themesh->vertices[v2]; point c = (p0 + p1 + p2) * (1.0f / 3.0f); float w = wt(p, c, invsigma2_1); if (w == 0.0f) continue; w *= len(trinorm(p0, p1, p2)); if (pass1) { flt += w * c; sum_w += w; } else { vec fn = trinorm(mpoints[v0], mpoints[v1], mpoints[v2]); normalize(fn); point prediction = p - fn * ((p - c) DOT fn); w *= wt(p, prediction, invsigma2_2); if (w == 0.0f) continue; flt += w * prediction; sum_w += w; } for (int i = 0; i < 3; i++) { int ae = themesh->across_edge[f][i]; if (ae < 0 || flags[ae] == flag_curr) continue; boundary.push_back(ae); } } if (sum_w == 0.0f) flt = p; else flt *= 1.0f / sum_w; }
// Return coviarance of two sets of points. MatrixXd GPCMMLPKernel::covariance( const MatrixXd* const *X1, // First data matrix. const MatrixXd* const *X2 // Second data matrix. ) { assert(X1[0] != NULL && X1[1] == NULL); // Make sure we have only one element. assert(X2[0] != NULL && X2[1] == NULL); // Make sure we have only one element. return var(0,0)*(((((*X1[0])*X2[0]->transpose())*wt(0,0) + MatrixXd::Constant(X1[0]->rows(),X1[0]->rows(),bias(0,0))).cwiseQuotient( ((X1[0]->rowwise().squaredNorm()*wt(0,0) + MatrixXd::Constant(X1[0]->rows(),1,bias(0,0)+1.0))* (X2[0]->rowwise().squaredNorm()*wt(0,0) + MatrixXd::Constant(X1[0]->rows(),1,bias(0,0)+1.0)).transpose()).cwiseSqrt())).array().asin().matrix()); }
int check_comb(i_64 d, i_64 rowcomb) { i_64 codeword = d; int i; for (i = 1; i < K; i++) if (rowcomb & (1ULL << i)) (codeword ^= rowi(d, i)); if ((wt(codeword) + wt(rowcomb)) < D) return(0); else return(1); }
VectorXf PBSeqWeightEstimator::calc_residue_weight(const vector<string>& msa, const int& idx) const { VectorXf s = VectorXf::Zero(dim); // number of times a particular residue appears char c; for (vector<string>::const_iterator pos = msa.begin(); pos != msa.end(); ++pos) { c = (*pos)[idx]; if (is_allowed(c)) s(abc_idx(c)) += 1; } double r = (double) (s.array() > 0).count(); // number of different residues VectorXf wt(dim); for (int k = 0; k < dim; ++k) { if (s(k) > 0) wt(k) = 1. / (r * s(k)); else wt(k) = 0; } return wt; }
InterpolateBicubic::InterpolateBicubic( const std::vector<unsigned>& dd, const std::vector<double>& fmin, const std::vector<double>& fmax ) : CInterpolation(dd,fmin,fmax) { plumed_massert(np.size()==2,"should be two dimensional data"); static int wt_d[16*16]= {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 3, 0, 0, 0, 0,-2, 0, 0,-1, 0, 0, 0, 0, 2, 0, 0,-2, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,-3, 0, 0, 3, 0, 0, 0, 0,-2, 0, 0,-1, 0, 0, 0, 0, 2, 0, 0,-2, 0, 0, 0, 0, 1, 0, 0, 1, -3, 3, 0, 0,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0, 0,-2,-1, 0, 0, 9,-9, 9,-9, 6, 3,-3,-6, 6,-6,-3, 3, 4, 2, 1, 2, -6, 6,-6, 6,-4,-2, 2, 4,-3, 3, 3,-3,-2,-1,-1,-2, 2,-2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,-2, 0, 0, 1, 1, 0, 0, -6, 6,-6, 6,-3,-3, 3, 3,-4, 4, 2,-2,-2,-2,-1,-1, 4,-4, 4,-4, 2, 2,-2,-2, 2,-2,-2, 2, 1, 1, 1, 1}; // This is to set up the coefficient matrix unsigned l=0; wt.resize(16,16); t1.resize(16); t2.resize(16); for (unsigned i=0;i<16;i++) for (unsigned j=0;j<16;j++){ wt(i,j)=wt_d[l++]; } // Resize everything dcross.resize( np[0], np[1] ); clist.resize( np[0] * np[1] * 4 * 4 ); }
BOOL tr_instr_jump(LmnTranslated f, LmnReactCxt *rc, LmnMembrane *thisisrootmembutnotused, LmnRule rule, int newid_num, const int *newid) { LmnRegister *v, *tmp; unsigned int org_use, org_size; BOOL ret; int i; org_use = warry_use_size(rc); org_size = warry_size(rc); v = lmn_register_make(org_size); for (i = 0; i < newid_num; i++){ v[i].wt = wt(rc, newid[i]); v[i].at = at(rc, newid[i]); v[i].tt = tt(rc, newid[i]); } tmp = rc_warry(rc); rc_warry_set(rc, v); ret = (*f)(rc, thisisrootmembutnotused, rule); lmn_register_free(rc_warry(rc)); rc_warry_set(rc, tmp); warry_size_set(rc, org_size); warry_use_size_set(rc, org_use); return ret; }
void deadline_timer::async_wait(event_handler const &h) { std::auto_ptr<waiter> wt(new waiter); wt->h=h; wt->self = this; event_id_ = get_io_service().set_timer_event(deadline_,wt); }
void InterpolateBicubic::IBicCoeff( const std::vector<double>& y, const std::vector<double>& dy1, const std::vector<double>& dy2, const std::vector<double>& d2y12, const double& d1, const double& d2, Matrix<double>& c ){ double xx, d1d2=d1*d2; for(unsigned i=0;i<4;i++){ t1[i] = y[i]; t1[i+4] = dy1[i]*d1; t1[i+8] = dy2[i]*d2; t1[i+12] = d2y12[i]*d1d2; } for(unsigned i=0;i<16;i++){ xx=0.0; for(unsigned k=0;k<16;k++){ xx += wt(i,k)*t1[k]; } t2[i]=xx; } unsigned l=0; for(unsigned i=0;i<4;i++){ for(unsigned j=0;j<4;j++){ c(i,j)=t2[l++]; } } }
// --------------------------------------------------------------------------- // // ------------ int bXMapNetClean::join_on_edges(bArray& loop, int* fields, bool report){ _bTrace_("bXMapNetClean::join_on_edges",true); bGenericGeoElement *oa,*ob; ivertices *vsa,*vsb; i2dvertex vx,vmin; bArray edg(sizeof(bGenericGeoElement*)); bArray bdg(sizeof(bGenericGeoElement*)); double dte,dab; bool flg; char msg[__MESSAGE_STRING_LENGTH_MAX__]; char ttl[__MESSAGE_STRING_LENGTH_MAX__]; get_localized_name(ttl,getbundle()); b_message_string(kXMapNetCleanJoinOnEdgesMessage,msg,getbundle(),0); bProgressWait wt(ttl,msg,true,true,loop.count()); for(long i=1;i<=loop.count();i++){ if(!wt.set_progress(i)){ break; } loop.get(i,&oa); oa->getVertices(&vsa); get_bridges(&vsa->vx.vx2[0],bdg); if(bdg.count()!=0){ continue; } get_edges(&vsa->vx.vx2[0],edg,true); flg=(edg.count()>0); for(long j=1;j<=edg.count();j++){ edg.get(j,&ob); ob->getVertices(&vsb); dte=ivx2_dist(&vsa->vx.vx2[0],&vsb->vx.vx2[0]); dab=ivx2_dist(&vsa->vx.vx2[0],&vsb->vx.vx2[vsb->nv-1]); if(dte<dab){ vx=vsb->vx.vx2[0]; } else{ vx=vsb->vx.vx2[vsb->nv-1]; } if(j==1){ vmin=vx; } else{ if(!eq_ivx2(&vmin,&vx)){ flg=false; break; } } } if(!flg){ continue; } vsa->vx.vx2[0]=vmin; oa->setVertices(vsa); if(report){ set_net_flag(oa,fields[oa->getType()-1],_kNodeJoined); } } return(0); }
void write_lines(const ustring & file, vector < ustring > &lines, bool append) { WriteText wt(file, append); for (unsigned int i = 0; i < lines.size(); i++) { wt.text(lines[i]); wt.text("\n"); } }
double v(double m, double phi, double v_0, double mu, double k, double l_0) { /* Calculates the velocity at a point given the velocity d_phi away from the point we care about. Derivation explained in lab report. */ return sqrt(((2*r*d_phi)/m)*(wt(m,phi)-Fst(phi,k,l_0)-mu*wn(m,phi) -mu*Fsn(phi,k,l_0)+((mu*m*pow(v_0,2))/(r)) +(m*pow(v_0,2)/(2*r*d_phi)))); }
void initial_parse(ReviewParser<std::istream>::sets &funny, ReviewParser<std::istream>::sets &normal, const std::string &prefix, const std::string &conf, const std::string &nope){ auto &funny_reviews = funny.rs; NLTKInstance::Word_Tokenizer wt(nltk); NLTKInstance::Stemmer stemmer(nltk); { parse(funny, prefix, conf); parse(normal, prefix, nope); std::cout << "parsing done" << std::endl; } }
// --------------------------------------------------------------------------- // // ------------ bool bXMapCloneDetector::detect(clonedetector_prm* prm){ bArray sel(*(_gapp->selMgr()->elements())); bArray* arr; char msg[__MESSAGE_STRING_LENGTH_MAX__]; message_string(kMsgProgress,msg,1); bProgressWait wt("",msg,true,true,sel.count()); _gapp->cntMgr()->flush(); bGenericGeoElement *oa,*ob; bGenericType* tp; ivx_rect vxr; int i,j; bool flg=false; for(i=1;i<=sel.count();i++){ if(!wt.set_progress(i)){ break; } sel.get(i,&oa); if(oa->contrasted()){ continue; } tp=_gapp->typesMgr()->get(oa->getType()); oa->getBounds(&vxr); tp->iterator()->objs_in_rect(&arr,&vxr); if(!arr){ continue; } for(j=1;j<=arr->count();j++){ arr->get(j,&ob); if(oa==ob){ continue; } if(ob->contrasted()){ continue; } if(obj_comp(oa,ob,prm)){ flg=true; if(ob->masked()){ ob->setmasked(false,true); } ob->setcontrast(true,true); } } delete arr; } if(flg){ b_message_string(kXMapCloneFoundMessageID,msg,getbundle(),0); } else{ b_message_string(kXMapNoCloneFoundMessageID,msg,getbundle(),0); } bAlertStop alrt(msg,""); return(true); }
// --------------------------------------------------------------------------- // // ------------ int bXMapNetClean::join_on_nodes(bArray& loop, int* fields, bool report){ _bTrace_("bXMapNetClean::join_on_nodes",true); bGenericGeoElement *oa,*op; ivertices *vsa,*vsp; bArray bdg(sizeof(bGenericGeoElement*)); bArray nod(sizeof(bGenericGeoElement*)); bool mod; char msg[__MESSAGE_STRING_LENGTH_MAX__]; char ttl[__MESSAGE_STRING_LENGTH_MAX__]; get_localized_name(ttl,getbundle()); b_message_string(kXMapNetCleanJoinOnNodesMessage,msg,getbundle(),0); bProgressWait wt(ttl,msg,true,true,loop.count()); for(long i=1;i<=loop.count();i++){ if(!wt.set_progress(i)){ break; } loop.get(i,&oa); oa->getVertices(&vsa); mod=false; get_bridges(&vsa->vx.vx2[0],bdg); if(bdg.count()==0){ get_nodes(&vsa->vx.vx2[0],nod); if(nod.count()==1){ nod.get(1,&op); op->getVertices(&vsp); vsa->vx.vx2[0]=vsp->vx.vx2[0]; mod=true; } } get_bridges(&vsa->vx.vx2[vsa->nv-1],bdg); if(bdg.count()==0){ get_nodes(&vsa->vx.vx2[vsa->nv-1],nod); if(nod.count()==1){ nod.get(1,&op); op->getVertices(&vsp); vsa->vx.vx2[vsa->nv-1]=vsp->vx.vx2[0]; mod=true; } } if(mod){ oa->setVertices(vsa); if(report){ set_net_flag(oa,fields[oa->getType()-1],_kEdgeJoined); } } } return(0); }
/** * <JA> * adinnetサーバにセグメント終了信号を送信する * * </JA> * <EN> * Send end-of-segment singal to adinnet server. * * </EN> */ static void adin_send_end_of_segment() { char p; int i; for(i=0;i<adinnet_servnum;i++) { if (wt(sd[i], &p, 0) < 0) { perror("adintool: cannot write"); fprintf(stderr, "failed to send EOS to %s:%d\n", adinnet_serv[i], adinnet_port[i]); } } }
// Recompute gradients of hyperparameters and latent coordinates. void GPCMMLPKernel::recompute( const MatrixXd &gK, // Gradient of objective with respect to kernel. const MatrixXd &gKd, // Gradient of objective with respect to diagonal kernel. const MatrixXd* const *X, // Current latent positions. MatrixXd **Xgrad // Latent position gradient. ) { assert(X[0] != NULL && X[1] == NULL); // Make sure we have only one element. assert(Xgrad[1] == NULL); // Make sure we have only one element. // Constants. int N = gKd.rows(); // Compute gradient of variance. vargrad(0,0) += kmat.cwiseProduct(gKd).sum(); // Compute gradient of weight and bias. denominatorCubed.noalias() = denominator.array().pow(3).matrix(); baseCovGrad.noalias() = var(0,0)*gKd.cwiseQuotient((MatrixXd::Ones(arg.rows(),arg.cols()) - arg.cwiseProduct(arg)).cwiseSqrt()); vec.noalias() = innerProducts.diagonal(); wtgrad(0,0) += (innerProducts.cwiseQuotient(denominator) - 0.5*(numerator.cwiseQuotient(denominatorCubed)).cwiseProduct( (wt(0,0)*vec + MatrixXd::Constant(vec.rows(),vec.cols(),bias(0,0)+1.0))*vec.transpose() + vec*(wt(0,0)*vec + MatrixXd::Constant(vec.rows(),vec.cols(),bias(0,0)+1.0)).transpose())).cwiseProduct(baseCovGrad).sum(); biasgrad(0,0) += (denominator.array().inverse().matrix() - 0.5*(numerator.cwiseQuotient(denominatorCubed)).cwiseProduct( (wt(0,0)*vec + MatrixXd::Constant(vec.rows(),vec.cols(),2.0*bias(0,0)+2.0)).replicate(1,vec.rows()) + (wt(0,0)*vec.transpose()).replicate(vec.rows(),1))).cwiseProduct(baseCovGrad).sum(); // Compute X gradients. if (Xgrad[0]) { for (int d = 0; d < X[0]->cols(); d++) { MatrixXd b = (X[0]->rowwise().squaredNorm()*wt(0,0) + VectorXd::Constant(N,bias(0,0)+1.0)).replicate(1,N).cwiseProduct( numerator).cwiseProduct((X[0]->col(d)*wt(0,0)*2.0).transpose().replicate(N,1)).cwiseQuotient(denominatorCubed); Xgrad[0]->col(d) += ((X[0]->col(d)*(2.0*wt(0,0))).replicate(1,N).cwiseQuotient(denominator) - ((X[0]->rowwise().squaredNorm()*wt(0,0) + VectorXd::Constant(N,bias(0,0)+1.0)).replicate(1,N).cwiseProduct( numerator).cwiseProduct((X[0]->col(d)*wt(0,0)*2.0).transpose().replicate(N,1)).cwiseQuotient(denominatorCubed))).cwiseProduct( baseCovGrad).transpose().rowwise().sum(); } } }
void SpotLight::apply() { const math::Matrix4x4& wt = cachedWorldTransform(); math::Vector3 wrotz = math::Vector3( wt(0,2),wt(1,2),wt(2,2) ); float wrotzlen = wrotz.length(); if ( wrotzlen > Float::MIN_VALUE ) { wrotz *= 1.f / wrotzlen; float intens = intensity(); gd::LightState ls; GdUtil::setLightState( ls, gd::LightState::LIGHT_SPOT, diffuseColor()*intens, specularColor()*intens, ambientColor()*intens, wt.translation(), wrotz, m_range, m_atten[0], m_atten[1], m_atten[2], 1.f, m_inner, m_outer ); gd::GraphicsDevice* dev = Context::device(); dev->addLight( ls ); } }
void DirectLight::apply() { const Matrix4x4& wt = cachedWorldTransform(); Vector3 wrotz = Vector3( wt(0,2),wt(1,2),wt(2,2) ); float wrotzlen = wrotz.length(); if ( wrotzlen > Float::MIN_VALUE ) { wrotz *= 1.f / wrotzlen; float intens = intensity(); gd::LightState ls; GdUtil::setLightState( ls, gd::LightState::LIGHT_DIRECT, diffuseColor()*intens, specularColor()*intens, ambientColor()*intens, wt.translation(), wrotz.normalize(), MAX_RANGE, 1.f, 0.f, 0.f, 1.f, MAX_CONE_ANGLE, MAX_CONE_ANGLE ); gd::GraphicsDevice* dev = Context::device(); dev->addLight( ls ); } }
// Return covariance of a single set of points. MatrixXd GPCMMLPKernel::covariance( const MatrixXd* const *X // Data matrix. ) { assert(X[0] != NULL && X[1] == NULL); // Make sure we have only one element. innerProducts.noalias() = (*X[0])*X[0]->transpose(); numerator.noalias() = innerProducts*wt(0,0) + MatrixXd::Constant(X[0]->rows(),X[0]->rows(),bias(0,0)); vec.noalias() = numerator.diagonal() + VectorXd::Constant(X[0]->rows(),1.0); denominator.noalias() = (vec*vec.transpose()).cwiseSqrt(); arg.noalias() = numerator.cwiseQuotient(denominator); kmat.noalias() = arg.array().asin().matrix(); return var(0,0)*kmat; }
static void diffuse_vert_field(TriMesh *themesh, vector<unsigned> &flags, unsigned &flag_curr, const ACCUM &accum, int v, float invsigma2, T &flt) { if (themesh->neighbors[v].empty()) { flt = T(); accum(themesh, v, flt, 1.0f, v); return; } flt = T(); accum(themesh, v, flt, themesh->pointareas[v], v); float sum_w = themesh->pointareas[v]; const vec &nv = themesh->normals[v]; flag_curr++; flags[v] = flag_curr; vector<int> boundary = themesh->neighbors[v]; while (!boundary.empty()) { int n = boundary.back(); boundary.pop_back(); if (flags[n] == flag_curr) continue; flags[n] = flag_curr; if ((nv DOT themesh->normals[n]) <= 0.0f) continue; // Gaussian weight float w = wt(themesh, n, v, invsigma2); if (w == 0.0f) continue; // Downweight things pointing in different directions w *= nv DOT themesh->normals[n]; // Surface area "belonging" to each point w *= themesh->pointareas[n]; // Accumulate weight times field at neighbor accum(themesh, v, flt, w, n); sum_w += w; for (size_t i = 0; i < themesh->neighbors[n].size(); i++) { int nn = themesh->neighbors[n][i]; if (flags[nn] == flag_curr) continue; boundary.push_back(nn); } } flt /= sum_w; }
void encodeArray(const uint32_t *in, uint64_t len, uint32_t *out, uint64_t *nvalue) const { if (len > UINT32_MAX || *nvalue > UINT32_MAX) THROW_ENCODING_EXCEPTION( "BinaryInterpolative only supports 32-bit length"); /* Write a maximum value in the head of out */ out[0] = in[len - 1]; /* Do actual binary interpolative code */ BitsWriter wt(out + 1, len - 1); wt.intrpolatvArray(in, len, 0, 0, in[len - 1]); wt.flush_bits(); *nvalue = wt.size() + 1; }
// --------------------------------------------------------------------------- // // ------------ void bXMapSHPExport::objs_dump(bArray& arr) { _bTrace_("bXMapSHPExport::objs_dump",false); char msg[__MESSAGE_STRING_LENGTH_MAX__]; b_message_string(kXMapSHPExportProcessingID,msg,getbundle(),0); bProgressWait wt("",msg,true,true,arr.count()); extype et; for(int i=1; i<=arr.count(); i++) { if(!wt.set_progress(i)) { break; } arr.get(i,&et); if(!et.tp) { continue; } et.tp->iterator()->iterate(&et,obj_dump); } }
// --------------------------------------------------------------------------- // // ------------ int bXMapNetClean::check_nodes(bArray& loop, int* fields){ _bTrace_("bXMapNetClean::check_nodes",true); bGenericGeoElement *oa; ivertices *vsa; bArray edg(sizeof(bGenericGeoElement*)); bArray nod(sizeof(bGenericGeoElement*)); double dbk=_cfg_prm.dnod; char msg[__MESSAGE_STRING_LENGTH_MAX__]; char ttl[__MESSAGE_STRING_LENGTH_MAX__]; _cfg_prm.dnod=0; get_localized_name(ttl,getbundle()); b_message_string(kXMapNetCleanCheckNodesMessage,msg,getbundle(),0); bProgressWait wt(ttl,msg,true,true,loop.count()); for(long i=1;i<=loop.count();i++){ if(!wt.set_progress(i)){ break; } loop.get(i,&oa); oa->getVertices(&vsa); get_nodes(&vsa->vx.vx2[0],nod); if(nod.count()>1){ set_net_flag(oa,fields[oa->getType()-1],_kNodeDoubled); } get_edges(&vsa->vx.vx2[0],nod,true); if(edg.count()==0){ set_net_flag(oa,fields[oa->getType()-1],_kNodeAlone); set_net_flag(oa,fields[oa->getType()-1],_kNodeNot3); } else if(edg.count()==1){ set_net_flag(oa,fields[oa->getType()-1],_kNodeDeadEnd); set_net_flag(oa,fields[oa->getType()-1],_kNodeNot3); } else if(edg.count()==2){ set_net_flag(oa,fields[oa->getType()-1],_kNodeNot3); } } _cfg_prm.dnod=dbk; return(0); }
int main(int argc, char **argv) { int port = 9000; char *host = "localhost"; if(argc >= 2) host = argv[1]; if(argc >= 3) port = atoi(argv[2]); sock = socketOpen(host, port); if(sock == -1) { printf("#### Can't connect to %s on port %d\n", host, port); return 1; } printf("Connected to %s on port %d\n", host, port); done = 0; Thread rt(reader); rt.start(0); Thread wt(writer); wt.start(0); while(!done) { System::ssleep(500); } Thread::join(&rt); Thread::join(&wt); socketClose(sock); printf("Disconnected\n"); return 0; }
// --------------------------------------------------------------------------- // // ------------ void bXMapReverse::reverse(int dummy){ ivertices* vxs; bGenericGeoElement* o; bArray sel(*(_gapp->selMgr()->elements())); char mess[__MESSAGE_STRING_LENGTH_MAX__]; message_string(kMsgProgress,mess,1); bProgressWait wt("",mess,true,false,sel.count()); _gapp->layersMgr()->SetObjInvalidation(false); for(int i=1;i<=sel.count();i++){ if(!wt.set_progress(i)){ break; } sel.get(i,&o); o->getVertices(&vxs); ivs_reverse(vxs); o->setVertices(vxs); } _gapp->layersMgr()->SetObjInvalidation(true); }
// --------------------------------------------------------------------------- // // ------------ void bXMapSHPExport::objs_dump(bArray& arr, bArray& sel) { _bTrace_("bXMapSHPExport::objs_dump",false); char msg[__MESSAGE_STRING_LENGTH_MAX__]; b_message_string(kXMapSHPExportProcessingID,msg,getbundle(),0); bProgressWait wt("",msg,true,true,sel.count()); extype et; bGenericGeoElement* o; for(int i=1; i<=sel.count(); i++) { if(!wt.set_progress(i)) { break; } sel.get(i,&o); arr.get(o->getType(),&et); if(et.tp) { if(obj_dump(o,&et)) { _te_("obj_dump error"); break; } } } }
// Write kernel data to file. void GPCMMLPKernel::write( GPCMMatWriter *writer // Writing interface. ) { GPCMKernel::write(writer); // Let superclass write first. // Write parameters. writer->writeDouble(wt(0,0),"weightVariance"); writer->writeDouble(bias(0,0),"biasVariance"); writer->writeDouble(var(0,0),"variance"); // Write priors. GPCMMatWriter *cellWriter = writer->writeCell("priors",1,3); GPCMMatWriter *priorStruct = cellWriter->writeStruct("",1,1); priorStruct->writeDouble(1.0,"index"); wtprior->write(priorStruct); priorStruct = cellWriter->closeStruct(); priorStruct = cellWriter->writeStruct("",1,1); priorStruct->writeDouble(2.0,"index"); biasprior->write(priorStruct); priorStruct = cellWriter->closeStruct(); priorStruct = cellWriter->writeStruct("",1,1); priorStruct->writeDouble(3.0,"index"); varprior->write(priorStruct); cellWriter->closeStruct(); writer->closeCell(); // Write transforms struct. GPCMMatWriter *xformStruct = writer->writeStruct("transforms",1,3); xformStruct->writeDouble(1.0,"index"); xformStruct->writeString("exp","type"); xformStruct = writer->closeStruct(); xformStruct->writeDouble(2.0,"index"); xformStruct->writeString("exp","type"); xformStruct = writer->closeStruct(); xformStruct->writeDouble(3.0,"index"); xformStruct->writeString("exp","type"); writer->closeStruct(); }
virtual int operator()( const ChunkObstacle & obstacle, const WorldTriangle & triangle, float dist ) { WorldTriangle wt( obstacle.transform_.applyPoint( triangle.v0() ), obstacle.transform_.applyPoint( triangle.v1() ), obstacle.transform_.applyPoint( triangle.v2() ), triangle.flags() ); // only add it if we don't already have it // (not sure why this happens, but it does) uint sz = tris_.size(); uint i; for (i = 0; i < sz; i++) { if (tris_[i].v0() == wt.v0() && tris_[i].v1() == wt.v1() && tris_[i].v2() == wt.v2()) break; } if (i >= sz) tris_.push_back( wt ); return 1 | 2; }
bool Wtr::init( bool p_binary ) { bool sucessfulWt = false; m_outputStream = new std::ofstream(); if( p_binary==true ) { m_outputStream->open( m_filename, std::ios::out | std::ios::binary ); } else { m_outputStream->open ( m_filename, std::ios::out ); } m_wtrStatus = WtrStatuses_OK; getWtrStatus( m_wtrStatus ); if( m_wtrStatus == WtrStatuses_OK ) { wt(); m_outputStream->close(); sucessfulWt = true; } return sucessfulWt; }
/** * <JA> * 読み込んだサンプル列をソケットデスクリプタ "fd" 上のadinnetサーバに送信 * するコールバック関数 * * @param now [in] 録音されたサンプル列 * @param len [in] 長さ(サンプル数) * * @return エラー時 -1,処理成功時 0,処理成功+区間終端検出時 1 を返す. * </JA> * <EN> * Callback handler to record the sample fragments to adinnet server * pointed by the socket descriptor "fd". * * @param now [in] recorded fragments of speech sample * @param len [in] length of above in samples * * @return -1 on device error (require caller to exit and terminate input), * 0 on success (allow caller to continue), * 1 on succeeded but segmentation detected (require caller to exit but * input will continue in the next call. * </EN> */ static int adin_callback_adinnet(SP16 *now, int len, Recog *recog) { int count; int start, w; int i; start = 0; if (recog->jconf->input.speech_input == SP_MIC && speechlen == 0) { /* this is first up-trigger */ if (rewind_msec > 0 && !recog->adin->is_valid_data) { /* not spoken currently but has data to process at first trigger */ /* it means that there are old spoken segments */ /* disgard them */ printf("disgard already recorded %d samples\n", len); return 0; } /* erase "<<<please speak>>>" text on tty */ fprintf(stderr, "\r \r"); if (rewind_msec > 0) { /* when -rewind value set larger than 0, the speech data spoken while pause will be considered back to the specified msec. */ printf("buffered samples=%d\n", len); w = rewind_msec * sfreq / 1000; if (len > w) { start = len - w; len = w; } else { start = 0; } printf("will process from %d\n", start); } } #ifdef WORDS_BIGENDIAN swap_sample_bytes(&(now[start]), len); #endif for (i=0;i<adinnet_servnum;i++) { count = wt(sd[i], (char *)&(now[start]), len * sizeof(SP16)); if (count < 0) { perror("adintool: cannot write"); fprintf(stderr, "failed to send data to %s:%d\n", adinnet_serv[i], adinnet_port[i]); } } #ifdef WORDS_BIGENDIAN swap_sample_bytes(&(now[start]), len); #endif /* accumulate sample num of this segment */ speechlen += len; #ifdef HAVE_PTHREAD if (recog->adin->enable_thread) { /* if input length reaches limit, rehash the ad-in buffer */ if (recog->adin->speechlen > MAXSPEECHLEN - 16000) { recog->adin->rehash = TRUE; fprintf(stderr, "+"); } } #endif /* display progress in dots */ fprintf(stderr, "."); return(0); }