当前位置: 首页>>代码示例>>C++>>正文


C++ da函数代码示例

本文整理汇总了C++中da函数的典型用法代码示例。如果您正苦于以下问题:C++ da函数的具体用法?C++ da怎么用?C++ da使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了da函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: newPolygon

Polygon* newPolygon(unsigned int nbVx, ...)
{
	unsigned int i;
	va_list ap;
	Polygon* newPoly = (Polygon*) malloc(sizeof(Polygon));

	/* Pas d'appel à polyInit possible à cause de la liste d'arguments...

	Initialisation des Dynamic Arrays */
	newPoly->Rigids = da();
	newPoly->Vertices = da();
	newPoly->InternalRigids = da();
	daReserve(&newPoly->Rigids, nbVx);
	daReserve(&newPoly->Vertices, nbVx);
	newPoly->Center = NULL;
	newPoly->Fixed = FALSE;
	newPoly->GridPos.Valid = FALSE;
	newPoly->Collided = FALSE;

	va_start(ap, nbVx);
	/* Ajoute les Vertices */
	for(i = 0; i < nbVx; i++)
		daAdd(&newPoly->Vertices, va_arg(ap, Vertex*));
	va_end(ap);
	/* Construit les limites, i.e. Créé un nouveau Rigid à partir de
	deux Vertices de la liste et la distance les séparant, puis l'ajoute
	 à la liste */
	for(i = 0; i < nbVx; i++)
		daAdd(&newPoly->Rigids, newRigid((Vertex*)daGet(&newPoly->Vertices, i),
			(Vertex*)daGet(&newPoly->Vertices, (i+1)%nbVx),
			vec2Length(vec2Sub(vxGetPosition((Vertex*)daGet(&newPoly->Vertices, i)),
					vxGetPosition((Vertex*)daGet(&newPoly->Vertices, (i+1)%nbVx))))));
	return newPoly;
}
开发者ID:posva,项目名称:jump-n-run,代码行数:34,代码来源:Polygon.cpp

示例2: polyInit

void polyInit(Polygon* P, unsigned int nbVx, ...)
{
	unsigned int i;
	va_list ap;

	/* Initialisation des Dynamic Arrays */
	P->Rigids = da();
	P->Vertices = da();
	P->InternalRigids = da();
	daReserve(&P->Rigids, nbVx);
	daReserve(&P->Vertices, nbVx);
	P->Center = NULL;
	P->Fixed = FALSE;
	P->GridPos.Valid = FALSE;
	P->Collided = FALSE;

	va_start(ap, nbVx);
	/* Ajoute les Vertices */
	for(i = 0; i < nbVx; i++)
		daAdd(&P->Vertices, va_arg(ap, Vertex*));
	va_end(ap);
	/* Construit les limites, i.e. Créé un nouveau Rigid à partir de
	deux Vertices de la liste et la distance les séparant, puis l'ajoute
	 à la liste */
	for(i = 0; i < nbVx; i++)
		daAdd(&P->Rigids, newRigid((Vertex*)daGet(&P->Vertices, i),
			(Vertex*)daGet(&P->Vertices, (i+1)%nbVx),
			vec2Length(vec2Sub(vxGetPosition((Vertex*)daGet(&P->Vertices, i)),
					vxGetPosition((Vertex*)daGet(&P->Vertices, (i+1)%nbVx))))));
}
开发者ID:posva,项目名称:jump-n-run,代码行数:30,代码来源:Polygon.cpp

示例3: newPolygonL

Polygon* newPolygonL(List L)
{
	unsigned int i = 0, nbVx = lstCount(&L);
	Polygon* newPoly = (Polygon*) malloc(sizeof(Polygon));
	Node* it = lstFirst(&L);
	/*Initialisation des Dynamic Arrays */
	newPoly->Rigids = da();
	newPoly->Vertices = da();
	newPoly->InternalRigids = da();
	daReserve(&newPoly->Rigids, nbVx);
	daReserve(&newPoly->Vertices, nbVx);
	newPoly->Center = NULL;
	newPoly->Fixed = FALSE;
	newPoly->GridPos.Valid = FALSE;
	newPoly->Collided = FALSE;

	/* Ajoute les Vertices */
	while(!nodeEnd(it))
	{
		daAdd(&newPoly->Vertices, (Vertex*) nodeGetData(it));
		it = nodeGetNext(it);
	}

	/* Construit les limites, i.e. Créé un nouveau Rigid à partir de
	deux Vertices de la liste et la distance les séparant, puis l'ajoute
	 à la liste */
	for(i = 0; i < nbVx; i++)
		daAdd(&newPoly->Rigids, newRigid((Vertex*)daGet(&newPoly->Vertices, i),
			(Vertex*)daGet(&newPoly->Vertices, (i+1)%nbVx),
			vec2Length(vec2Sub(vxGetPosition((Vertex*)daGet(&newPoly->Vertices, i)),
					vxGetPosition((Vertex*)daGet(&newPoly->Vertices, (i+1)%nbVx))))));
	return newPoly;
}
开发者ID:posva,项目名称:jump-n-run,代码行数:33,代码来源:Polygon.cpp

示例4: da

void WeightedDerivativesToRefined::apply_index(Model *m,
                                       ParticleIndex pi) const {
  // retrieving pis by ref if possible is cumbersome but is required for speed
  ParticleIndexes pis_if_not_byref;
  ParticleIndexes const* pPis;
  if(refiner_->get_is_by_ref_supported()){
    ParticleIndexes const& pis =
      refiner_->get_refined_indexes_by_ref(m, pi);
    pPis = &pis;
  } else{
    pis_if_not_byref = refiner_->get_refined_indexes(m, pi);
    pPis = &pis_if_not_byref;
  }
  ParticleIndexes const& pis = *pPis;
  //  Prepare derivative accumulator to normalize by total weight
  Float total_weight;
  if(w_ != FloatKey()){
    total_weight = m->get_attribute(w_, pi);
  } else {
    total_weight = pis.size();
  }
  DerivativeAccumulator da( 1.0 / total_weight);
  // read K values for each key in keys_
  Floats Ks(keys_.size());
  for (unsigned int j = 0; j < Ks.size(); ++j){
    Ks[j] = m->get_derivative(keys_[j], pi);
  }
  // store K reweighted per each particle, normalized with da
  for (unsigned int i = 0; i < pis.size(); ++i) {
    Float w = m->get_attribute(w_, pis[i]);
    for (unsigned int j = 0; j < keys_.size(); ++j) {
      m->add_to_derivative(keys_[j], pis[i], w * Ks[j], da);
    }
  }
}
开发者ID:AljGaber,项目名称:imp,代码行数:35,代码来源:WeightedDerivativesToRefined.cpp

示例5: main

int main()
{
    int i,n,t,ans;
    //scanf("%d",&t);
    //while(t-->0)
    {
      while (scanf("%s",s)==1)
      {

      n=strlen(s);
      for(i=0;i<n;i++) r[i]=s[i];
      r[n]=0;
      da(r,sa,n+1,128);
      calheight(r,sa,n);

        for (int i = 0;i < n;i++)
            printf("%s\n",s+sa[i]);
        puts("");
      ans=n*(n+1)/2;
      for(i=1;i<=n;i++) ans-=height[i];
      printf("%d\n",ans);
      }
    }
    return 0;
}
开发者ID:mzry1992,项目名称:workspace,代码行数:25,代码来源:I+-+Bacon’s+Cypher.cpp

示例6: main

int main() {
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) {scanf("%d",&r[i]);}
    r[n]=0;
    da(r,sa,rank,height,n,MAXM);
    /*
    printa(sa,n);
    printa(rank,n);
    printa(height,n);
    */
    int low=1,high=n,mid;
    while(low<high) {
        mid=(low+high+1)/2;
        //printf("%d %d %d\n",low,mid,high);
        if(valid(mid,n,k)) {
            low=mid;
        } else {
            high=mid-1;
        }
    }
    //if(flag==0) printf("%d\n",)
    printf("%d\n",low);
    return 0;
}
开发者ID:Ycoronene,项目名称:OJ,代码行数:25,代码来源:poj-3261.cpp

示例7: main

int main(int, char*[])
{
    /// leveraging our data abstraction
    tut::data_abstraction da(10);
    std::cout << tut::func(da) << std::endl;
    std::cout << tut::func_ex(da) << std::endl;

    /// we don't need std::bind for stand-alone functions - they're much easier to pass around than
    /// member functions.
    const auto fp(&tut::func);
    std::cout << fp(da) << std::endl;

    /// leveraging structural polymorphism
    std::cout << tut::pow(da) << std::endl;
    std::cout << tut::pow_ex(da) << std::endl;

    /// leveraging static polymorphism
    std::cout << tut::op(3, 5) << std::endl;
    std::cout << tut::op(3.0f, 5.0f) << std::endl;
    std::cout << tut::op('3', '5') << std::endl;

    /// make a widget, and cast it back and forth
    auto widget = std::make_unique<tut::widget>(12345, 101.0f, true);
    auto castable = das::cast_unique<das::castable>(std::move(widget));
    auto widget_again = das::cast_unique<tut::widget>(std::move(castable));

    /// check its replacability :)
    std::cout << tut::should_replace_with(*widget_again, 100.0f, 12345) << std::endl;
    return 0;
}
开发者ID:bryanedds,项目名称:das,代码行数:30,代码来源:tut.cpp

示例8: main

int main()
{
    int i,j=0,k,n;
    int min,mid,max;
    scanf("%d",&n);
    while(n!=0)
    {
      n--;
      scanf("%d",&j);
      for(i=0;i<n;i++)
      {
        scanf("%d",&k);
        r[i]=k-j+100;
        j=k;
      }
      r[n]=0;
      da(r,sa,n+1,200);
      calheight(r,sa,n);
      min=1;max=n/2;
      while(min<=max)
      {
        mid=(min+max)/2;
        if(check(sa,n,mid)) min=mid+1;
        else max=mid-1;
      }
      if(max>=4) printf("%d\n",max+1);
      else printf("0\n");
      scanf("%d",&n);
    }
    return 0;
}
开发者ID:Voleking,项目名称:ICPC,代码行数:31,代码来源:pku1743_da.cpp

示例9: getPntrToVessel

vesselbase::StoreDataVessel* MultiColvarBase::buildDataStashes( const bool& allow_wcutoff, const double& wtol ){
  // Check if vessels have already been setup
  for(unsigned i=0;i<getNumberOfVessels();++i){
     StoreColvarVessel* ssc=dynamic_cast<StoreColvarVessel*>( getPntrToVessel(i) );
     if(ssc){
        if( allow_wcutoff && !ssc->weightCutoffIsOn() ) error("Cannot have more than one data stash with different properties");
        if( !allow_wcutoff && ssc->weightCutoffIsOn() ) error("Cannot have more than one data stash with different properties");
        return ssc;
     }
  }
 
  // Setup central atoms
  vesselbase::VesselOptions da("","",0,"",this);
  mycatoms=new StoreCentralAtomsVessel(da);
  if( allow_wcutoff ) mycatoms->setHardCutoffOnWeight( wtol );
  addVessel(mycatoms); 

  // Setup store values vessel
  vesselbase::VesselOptions ta("","",0,"",this);
  myvalues=new StoreColvarVessel(ta);   
  if( allow_wcutoff ) myvalues->setHardCutoffOnWeight( wtol );
  addVessel(myvalues);

  // Make sure resizing of vessels is done
  resizeFunctions();
  return myvalues;
}
开发者ID:whitead,项目名称:plumed2,代码行数:27,代码来源:MultiColvarBase.cpp

示例10: create_rand_dense_table

dense_table_t create_rand_dense_table(unsigned v0_id, unsigned v1_id, unsigned v2_id) 
{
  variable_t v0(v0_id, 4);
  variable_t v1(v1_id, 3);
  variable_t v2(v2_id, 2);

  std::vector<variable_t> vars;
  vars.push_back(v0);
  vars.push_back(v1);
  vars.push_back(v2);
  domain_t domain(vars); 

  dense_table_t dt(domain);
  assignment_t da(domain);

  for(int i=0; i < domain.var(0).size(); ++i) {
    da.set_asg(v0, i);
    for(int j=0; j < domain.var(1).size(); ++j) {
      da.set_asg(v1, j);
      for(int k=0; k < domain.var(2).size(); ++k) {
        da.set_asg(v2, k);

        if(rand() % 100 <= 20) {
          dt.set_logP(da, -1 * (rand() % 100));
        }
      }
    }
  }

  return dt;
}
开发者ID:Alienfeel,项目名称:graphlab,代码行数:31,代码来源:test_dense_table.cpp

示例11: if

double bsmodel_4_vr::d(int pno, const double params[]) {
	if (pno == 0) return(vega(params));
	else if (pno == 1) return(rho(params));
	else if (pno == 2) return(da(params));
	else if (pno == 3) return(db(params));
	else return(0.0);
}
开发者ID:bnsh,项目名称:fortrevor,代码行数:7,代码来源:bsmodel_4_vr.C

示例12: while

void GrVertexBatch::onDraw(GrBatchFlushState* state) {
    int uploadCnt = fInlineUploads.count();
    int currUpload = 0;

    // Iterate of all the drawArrays. Before issuing the draws in each array, perform any inline
    // uploads.
    for (SkTLList<DrawArray>::Iter da(fDrawArrays); da.get(); da.next()) {
        state->advanceLastFlushedToken();
        while (currUpload < uploadCnt &&
               fInlineUploads[currUpload]->lastUploadToken() <= state->lastFlushedToken()) {
            fInlineUploads[currUpload++]->upload(state->uploader());
        }
        const GrVertexBatch::DrawArray& drawArray = *da.get();
        GrProgramDesc desc;
        const GrPipeline* pipeline = this->pipeline();
        const GrPrimitiveProcessor* primProc = drawArray.fPrimitiveProcessor.get();
        state->gpu()->buildProgramDesc(&desc, *primProc, *pipeline, fBatchTracker);
        GrGpu::DrawArgs args(primProc, pipeline, &desc, &fBatchTracker);

        int drawCount = drawArray.fDraws.count();
        for (int i = 0; i < drawCount; i++) {
            state->gpu()->draw(args,  drawArray.fDraws[i]);
        }
    }
}
开发者ID:zhiqiang-li,项目名称:skia,代码行数:25,代码来源:GrVertexBatch.cpp

示例13: procedure

/*! \section example33 Example 33: Oscillating Search in very high-dimensional feature selection.

Very high-dimensional feature selection in text categorization, with 
dimensionality in the order of 10000 or 100000.
The standard approach is BIF, yet we show here that a non-trivial
search procedure (OS) can be feasible. Here OS is applied in its
fastest form (delta=1), initialized by means of BIF. We use Multinomial
Bhattacharyya distance as the feature selection criterion (it has been
shown capable of overperforming traditional tools like Information
Gain etc., cf. Novovicova et al., LNCS 4109, 2006). 
Randomly sampled 50% of data is used for multinomial
model parameter estimation to be used in the actual feature selection
process, another (disjunct) 40% of data is randomly sampled for testing. 
The selected subset is eventually used for validation; multinomial Naive Bayes
classifier is trained on the training data on the selected subset
and classification accuracy is finally estimated on the test data.
*/
int main()
{
	try{
	typedef double RETURNTYPE; 	typedef double DATATYPE;  typedef double REALTYPE;
	typedef unsigned int IDXTYPE;  typedef unsigned int DIMTYPE;  typedef short BINTYPE;
	typedef FST::Subset<BINTYPE, DIMTYPE> SUBSET;
	typedef FST::Data_Intervaller<std::vector<FST::Data_Interval<IDXTYPE> >,IDXTYPE> INTERVALLER;
	typedef boost::shared_ptr<FST::Data_Splitter<INTERVALLER,IDXTYPE> > PSPLITTER;
	typedef FST::Data_Splitter_RandomRandom<INTERVALLER,IDXTYPE,BINTYPE> SPLITTERRR;
	//typedef FST::Data_Accessor_Splitting_MemTRN<DATATYPE,IDXTYPE,INTERVALLER> DATAACCESSOR; // uncomment for TRN data format
	typedef FST::Data_Accessor_Splitting_MemARFF<DATATYPE,IDXTYPE,INTERVALLER> DATAACCESSOR; // uncomment for ARFF data format
	typedef FST::Criterion_Multinomial_Bhattacharyya<RETURNTYPE,DATATYPE,REALTYPE,IDXTYPE,DIMTYPE,SUBSET,DATAACCESSOR> BHATTMULTINOMIALDIST;
	typedef FST::Classifier_Multinomial_NaiveBayes<RETURNTYPE,DATATYPE,REALTYPE,IDXTYPE,DIMTYPE,SUBSET,DATAACCESSOR> CLASSIFIERMULTINOMIAL;
	typedef FST::Sequential_Step_Straight<RETURNTYPE,DIMTYPE,SUBSET,BHATTMULTINOMIALDIST> EVALUATOR;

		std::cout << "Starting Example 33: Oscillating Search in very high-dimensional feature selection..." << std::endl;
	// randomly sample 50% of data for training and randomly sample (disjunct) 40% for independent testing of final classification performance 
		PSPLITTER dsp_outer(new SPLITTERRR(1, 50, 40)); // (there will be one outer randomized split only)
	// do not scale data
		boost::shared_ptr<FST::Data_Scaler<DATATYPE> > dsc(new FST::Data_Scaler_void<DATATYPE>());
	// set-up data access
		boost::shared_ptr<std::vector<PSPLITTER> > splitters(new std::vector<PSPLITTER>); splitters->push_back(dsp_outer);
		boost::shared_ptr<DATAACCESSOR> da(new DATAACCESSOR("data/reuters_apte.arff",splitters,dsc));
		da->initialize();
	// initiate access to split data parts
		da->setSplittingDepth(0); if(!da->getFirstSplit()) throw FST::fst_error("50/40 random data split failed.");
	// initiate the storage for subset to-be-selected
		boost::shared_ptr<SUBSET> sub(new SUBSET(da->getNoOfFeatures()));
	// set-up multinomial Bhattacharyya distance criterion
		boost::shared_ptr<BHATTMULTINOMIALDIST> dmultinom(new BHATTMULTINOMIALDIST);
		dmultinom->initialize(da); // (initialization = multinomial model parameter estimation on training data)
	// set-up individual feature ranking to serve as OS initialization
		FST::Search_BIF<RETURNTYPE,DIMTYPE,SUBSET,BHATTMULTINOMIALDIST> srch_bif;
	// set-up the standard sequential search step object (option: hybrid, ensemble, etc.)
		boost::shared_ptr<EVALUATOR> eval(new EVALUATOR);
	// set-up the Oscillating Search procedure in its fastest setting
		FST::Search_OS<RETURNTYPE,DIMTYPE,SUBSET,BHATTMULTINOMIALDIST,EVALUATOR> srch(eval);
		srch.set_delta(1);
	// target subset size must be set because a) Bhattacharyya is monotonous with respect to subset size,
	// b) in very-high-dimensional problem d-optimizing search is not feasible due to search complexity
		DIMTYPE target_subsize=500;
	// run the search - first find the initial subset by means of BIF, then improve it by means of OS
		std::cout << "Feature selection setup:" << std::endl << *da << std::endl << srch_bif << std::endl << srch << std::endl << *dmultinom << std::endl << std::endl;
		RETURNTYPE critval_train, critval_test;
		if(!srch_bif.search(target_subsize,critval_train,sub,dmultinom,std::cout)) throw FST::fst_error("Search (BIF) not finished.");
		std::cout << std::endl << "Initialization result: " << std::endl << *sub << "Criterion value=" << critval_train << std::endl << std::endl;
		if(!srch.search(target_subsize,critval_train,sub,dmultinom,std::cout)) throw FST::fst_error("Search (OS) not finished.");
		std::cout << std::endl << "Search result: " << std::endl << *sub << "Criterion value=" << critval_train << std::endl;
	// (optionally) validate result by estimating Naive Multinomial Bayes classifier accuracy on selected feature sub-space on independent test data
		boost::shared_ptr<CLASSIFIERMULTINOMIAL> cmultinom(new CLASSIFIERMULTINOMIAL);
		cmultinom->initialize(da);
		cmultinom->train(da,sub);
		cmultinom->test(critval_test,da);
		std::cout << "Validated Multinomial NaiveBayes accuracy=" << critval_test << std::endl << std::endl;
	}
	catch(FST::fst_error &e) {std::cerr<<"FST ERROR: "<< e.what() << ", code=" << e.code() << std::endl;}
	catch(std::exception &e) {std::cerr<<"non-FST ERROR: "<< e.what() << std::endl;}
	return 0;
}
开发者ID:fgtlss,项目名称:sol,代码行数:76,代码来源:demo33.cpp

示例14: dump_code

void
dump_code(void)
{
    fdump();			/* dumps all user functions */
    if (begin_start) {
	fprintf(stdout, "BEGIN\n");
	da(begin_start, stdout);
    }
    if (end_start) {
	fprintf(stdout, "END\n");
	da(end_start, stdout);
    }
    if (main_start) {
	fprintf(stdout, "MAIN\n");
	da(main_start, stdout);
    }
}
开发者ID:ThomasDickey,项目名称:mawk-20120627,代码行数:17,代码来源:code.c

示例15: da

BridgeVessel* ActionWithVessel::addBridgingVessel( ActionWithVessel* tome ){
  VesselOptions da("","",0,"",this); 
  BridgeVessel* bv=new BridgeVessel(da);
  bv->setOutputAction( tome );
  functions.push_back( dynamic_cast<Vessel*>(bv) );
  resizeFunctions();
  return bv; 
}
开发者ID:apoma,项目名称:plumed2,代码行数:8,代码来源:ActionWithVessel.cpp


注:本文中的da函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。