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


C++ DblVec::push_back方法代码示例

本文整理汇总了C++中DblVec::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ DblVec::push_back方法的具体用法?C++ DblVec::push_back怎么用?C++ DblVec::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DblVec的用法示例。


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

示例1: cal_score

double cal_score(vector <size_t> instance){
	//f(x)=(UW)(TV)' + Px
	double score = 0.0;
	DblVec UW;
	DblVec TV;
	int dimLatent = W.size() / getUserFeaCount();
	for (size_t j = 0 ; j < dimLatent; j++){
		UW.push_back(0);
		TV.push_back(0);
	}
	for (size_t j = 0; j < instance.size(); j++){
		score += P[instance[j]] * 1.0;
		if(instance[j] < getAdFeaCount()){
			for(size_t k = 0; k < dimLatent; k++){
				int v_index = instance[j] * dimLatent + k;
				TV[k]+=V[v_index];
			}
		} 
		else if(instance[j] < getAdFeaCount() + getUserFeaCount()){
			for(size_t k = 0; k < dimLatent; k++){
				int w_index = (instance[j] - getAdFeaCount())*dimLatent + k;
				UW[k] += W[w_index];
			}
		}
	}
	
	for (size_t j = 0; j < dimLatent; j++){
		score += UW[j]*TV[j];
	}

	return score;
}
开发者ID:SUYONGJIAN,项目名称:Luna,代码行数:32,代码来源:score.cpp

示例2: load_model

int load_model(const char* model_path){
	string line;
	char model_file_name[50];
	sprintf(model_file_name, "%sP", model_path);
	double fea_weight;
	
	//load P
	ifstream pmodel(model_file_name);
	if(!pmodel.good()){
		cerr << "error model file " << model_file_name << endl;
		exit(1);
	}
	while (getline(pmodel, line)){
    	fea_weight = atof(line.c_str());
    	P.push_back(fea_weight);
	}
	pmodel.close();
	
	
	//load W
	sprintf(model_file_name, "%sX", model_path);
	ifstream xmodel(model_file_name);
	if(!xmodel.good()){
		cerr << "error model file " << model_file_name  << endl;
		exit(1);
	}
	while (getline(xmodel, line)){
    	fea_weight = atof(line.c_str());
    	X.push_back(fea_weight);
	}
	xmodel.close();
	
	return 0;
}
开发者ID:SUYONGJIAN,项目名称:Luna,代码行数:34,代码来源:score.cpp

示例3: CalcDists

void SingleTimestepCollisionEvaluator::CalcDists(const DblVec& x, DblVec& dists, DblVec& weights) {
  DblVec dofvals = getDblVec(x, m_vars);
  m_rad->SetDOFValues(dofvals);
  vector<Collision> collisions;
  GetCollisionsCached(dofvals, collisions);
  dists.reserve(dists.size() + collisions.size());
  weights.reserve(weights.size() + collisions.size());
  BOOST_FOREACH(const Collision& col, collisions) {
    Link2Int::iterator itA = m_link2ind.find(col.linkA),
                       itB = m_link2ind.find(col.linkB);
    if (itA != m_link2ind.end() || itB != m_link2ind.end()) {
      dists.push_back(col.distance);
      weights.push_back(col.weight);
    }
  }
开发者ID:,项目名称:,代码行数:15,代码来源:

示例4: value

 double NeedleCollisionClearanceCost::value(const vector<double>& x, Model* model) {
   DblVec dists;
   EnvironmentBasePtr env = helper->pis[0]->local_configs[0]->GetEnv();
   BOOST_FOREACH(const CollisionEvaluatorPtr& cc, this->ccs) {
     DblVec tmp_dists;
     cc->CalcDists(x, tmp_dists);
     for (int i = 0; i < tmp_dists.size(); ++i) {
       dists.push_back(-tmp_dists[i]);
     }
   }
   if (dists.size() > 0) {
     return vecMax(dists) * this->coeff;
   } else {
     return - helper->collision_clearance_threshold * this->coeff;
   }
 }
开发者ID:panjia1983,项目名称:channel_backward,代码行数:16,代码来源:costs.cpp


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