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


C++ TVector类代码示例

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


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

示例1: TrainModel

 void TrainModel(
     const NJson::TJsonValue& params,
     const NCatboostOptions::TOutputFilesOptions& outputOptions,
     const TMaybe<TCustomObjectiveDescriptor>& objectiveDescriptor,
     const TMaybe<TCustomMetricDescriptor>& evalMetricDescriptor,
     TPool& learnPool,
     bool allowClearPool,
     const TVector<const TPool*>& testPoolPtrs,
     TFullModel* model,
     const TVector<TEvalResult*>& evalResultPtrs) const override {
     Y_UNUSED(objectiveDescriptor);
     Y_UNUSED(evalMetricDescriptor);
     Y_UNUSED(allowClearPool);
     CB_ENSURE(testPoolPtrs.size() == 1, "Multiple eval sets not supported for GPU");
     Y_VERIFY(evalResultPtrs.size() == testPoolPtrs.size());
     NCatboostCuda::TrainModel(params, outputOptions, learnPool, *testPoolPtrs[0], model);
     evalResultPtrs[0]->GetRawValuesRef().resize(model->ObliviousTrees.ApproxDimension);
 }
开发者ID:Xiaodingdangguaiguai,项目名称:catboost,代码行数:18,代码来源:train.cpp

示例2: OutputShapValues

static void OutputShapValues(const TVector<TVector<double>>& shapValues,
                             TFileOutput& out) {
    for (size_t documentIdx = 0; documentIdx < shapValues.size(); ++documentIdx) {
        int featureCount = shapValues[documentIdx].size();
        for (int featureIdx = 0; featureIdx < featureCount; ++featureIdx) {
            out << shapValues[documentIdx][featureIdx] << (featureIdx + 1 == featureCount ? '\n' : '\t');
        }
    }
}
开发者ID:Xiaodingdangguaiguai,项目名称:catboost,代码行数:9,代码来源:shap_values.cpp

示例3: Transform

void Matrix::Transform(const TVector<Point>& vSource, TVector<Point>& vDest) const
{
    int count = vSource.GetCount();
    vDest.SetCount(count);

    for (int index = 0; index < count; index++) {
        float x = vSource[index].X();
        float y = vSource[index].Y();

        vDest.Set(
            index,
            Point(
                m_m[0][0] * x + m_m[0][1] * y + m_m[0][3],
                m_m[1][0] * x + m_m[1][1] * y + m_m[1][3]
            )
        );
    }
}
开发者ID:FreeAllegiance,项目名称:Allegiance-R7-With-R4-Engine,代码行数:18,代码来源:matrix.cpp

示例4: ExtendFeaturePath

static TVector<TFeaturePathElement> ExtendFeaturePath(const TVector<TFeaturePathElement>& oldFeaturePath,
                                                      double zeroPathsFraction,
                                                      double onePathsFraction,
                                                      int feature) {
    const size_t pathLength = oldFeaturePath.size();

    TVector<TFeaturePathElement> newFeaturePath(pathLength + 1);
    Copy(oldFeaturePath.begin(), oldFeaturePath.begin() + pathLength, newFeaturePath.begin());

    const double weight = pathLength == 0 ? 1.0 : 0.0;
    newFeaturePath[pathLength] = TFeaturePathElement(feature, zeroPathsFraction, onePathsFraction, weight);

    for (int elementIdx = pathLength - 1; elementIdx >= 0; --elementIdx) {
        newFeaturePath[elementIdx + 1].Weight += onePathsFraction * newFeaturePath[elementIdx].Weight * (elementIdx + 1) / (pathLength + 1);
        newFeaturePath[elementIdx].Weight = zeroPathsFraction * newFeaturePath[elementIdx].Weight * (pathLength - elementIdx) / (pathLength + 1);
    }

    return newFeaturePath;
}
开发者ID:Xiaodingdangguaiguai,项目名称:catboost,代码行数:19,代码来源:shap_values.cpp

示例5: SplitInto

        TVector<TString> SplitInto(const TString &s, char delim, TVector<TString> &elems, ui32 numberOfSplits) {
            std::stringstream ss(s);
            TString item;

            ui32 iter = 0;
            while (std::getline(ss, item, delim)) {
                elems.push_back(item);
                iter++;
                if (iter >= numberOfSplits) {
                    TString rest;
                    while (std::getline(ss, item)) {
                        rest += item;
                    }
                    elems.push_back(rest);
                    break;
                }
            }
            return elems;
        }
开发者ID:alexeyche,项目名称:alexeyche-junk,代码行数:19,代码来源:string.cpp

示例6: Save

void FBinarySerializer::Save(TVector<bool>& VectorData)
{
	const SizeT VectorSize = VectorData.size();
	Serialize(VectorSize);

	for (auto&& Element: VectorData)
	{
		Serialize(static_cast<bool>(Element));
	}
}
开发者ID:PhoenixOrg,项目名称:PhoenixEngine,代码行数:10,代码来源:BinarySerializer.cpp

示例7: find_collision

/* find if any of the current balls intersect with each other in the 
 * current timestep.  returns the index of the 2 intersecting balls, 
 * the point and time of intersection */
int find_collision(TVector& point, double& timePoint, double time2, 
	     int& ball1, int& ball2) {

  TVector relativeV;
  TRay rays;
  double Mytime = 0.0, Add = time2/150.0, timedummy = 10000, timedummy2 = -1;
  TVector posi;
  
  /* Test all balls against each other in 150 small steps */
  for (int i = 0; i < ball_count - 1; i++){
    for (int j = i+1; j < ball_count; j++){

      // Find Distance
      relativeV = ball_vel[i]-ball_vel[j];
      rays = TRay(old_pos[i],TVector::unit(relativeV));
      Mytime = 0.0;
      
      // If distance detween centers greater than 2*radius an 
      // intersection occurred loop to find the exact intersection point
      if ( (rays.dist(old_pos[j])) > ball_r * 2 ) 
	continue;  
      
      while (Mytime < time2) {
	Mytime += Add;
	posi = old_pos[i] + relativeV*Mytime;
	if (posi.dist(old_pos[j]) <= ball_r * 2 ) {
	  point = posi;
	  if (timedummy > (Mytime - Add)) timedummy = Mytime-Add;
	  ball1 = i;
	  ball2 = j;
	  break;
	}
      }
    }
  }
  
  if (timedummy!=10000) { 
    timePoint=timedummy;
    return 1;
  }
  
  return 0;
}
开发者ID:seebq,项目名称:cs4451-project4-the-tring-game,代码行数:46,代码来源:prj4.cpp

示例8: aaSearch

void FindSequenceDialog::aaSearch ()
    {
    int a , b ;
    TVector *v = c->vec ;
    if ( v->getType() != TYPE_VECTOR && 
    	 v->getType() != TYPE_SEQUENCE && 
    	 v->getType() != TYPE_PRIMER )
    	 return ;
    	 
    wxString s = getQuery() ;
    for ( a = 0 ; a < v->items.size() ; a++ )
        {
        wxString ls = v->items[a].getAminoAcidSequence() ;
        if ( ls.IsEmpty() ) continue ;
        int dir = v->items[a].getDirection() ;
        int off = v->items[a].getOffset() ;
        vector <Tdna2aa> dna2aa ;
        p = 0 ;
        b = subsearch ( ls , s , p ) ;
        while ( b != -1 )
           {
           if ( lb->GetCount() > FIND_MAX ) return ;
           if ( dna2aa.size() == 0 )
              v->items[a].translate ( v , NULL , dna2aa ) ;
           int from = dir==1?b:last ;
           int to = dir==1?last:b ;
           wxString msg ;
           if ( off != -1 )
              msg = wxString::Format ( _T(" [%d-%d]") , from+off , to+off ) ;
           from = dna2aa[from].dna[0] + 1 ;
           to = dna2aa[to].dna[2] + 1 ;
           if ( from > to ) { int x = from ; from = to ; to = x ; }
           lb->Append ( wxString::Format ( _T("%s: %s (%d-%d)%s") ,
                                 txt("amino_acid").c_str() ,
                                 v->items[a].name.c_str() ,
                                 from , to , msg.c_str() ) ) ;
           vi.Add ( -1 ) ;
           p = b + 1 ;
           b = subsearch ( ls , s , p ) ;
           }
        }   
        
    // Fixed reading frames
    wxString ss ;
    ss = v->getSequence() ;
    if ( v->isCircular() ) ss += ss.Left ( 2 ) ;
    else ss += _T("  ") ;
    aaSubSearch ( ss , 0 , 1 , txt("m_aa_1") ) ; // Reading frame +1
    aaSubSearch ( ss , 1 , 1 , txt("m_aa_2") ) ; // Reading frame +2     
    aaSubSearch ( ss , 2 , 1 , txt("m_aa_3") ) ; // Reading frame +3
    ss = v->transformSequence ( true , false ) ;
    if ( v->isCircular() ) ss = ss.Right ( 2 ) + ss ;
    else ss = _T("  ") + ss ;
    aaSubSearch ( ss , -1 , -1 , txt("m_aa_m1") ) ; // Reading frame -1     
    aaSubSearch ( ss , -2 , -1 , txt("m_aa_m2") ) ; // Reading frame -2     
    aaSubSearch ( ss , -3 , -1 , txt("m_aa_m3") ) ; // Reading frame -3    
    }    
开发者ID:magnusmanske,项目名称:gentle-m,代码行数:57,代码来源:FindSequenceDialog.cpp

示例9: AssignRandomWeights

static void AssignRandomWeights(int learnSampleCount,
                                TLearnContext* ctx,
                                TFold* fold) {
    TVector<float> sampleWeights;
    sampleWeights.yresize(learnSampleCount);

    const ui64 randSeed = ctx->Rand.GenRand();
    NPar::TLocalExecutor::TExecRangeParams blockParams(0, learnSampleCount);
    blockParams.SetBlockSize(10000);
    ctx->LocalExecutor.ExecRange([&](int blockIdx) {
        TFastRng64 rand(randSeed + blockIdx);
        rand.Advance(10); // reduce correlation between RNGs in different threads
        const float baggingTemperature = ctx->Params.ObliviousTreeOptions->BootstrapConfig->GetBaggingTemperature();
        float* sampleWeightsData = sampleWeights.data();
        NPar::TLocalExecutor::BlockedLoopBody(blockParams, [&rand, sampleWeightsData, baggingTemperature](int i) {
            const float w = -FastLogf(rand.GenRandReal1() + 1e-100);
            sampleWeightsData[i] = powf(w, baggingTemperature);
        })(blockIdx);
    }, 0, blockParams.GetBlockCount(), NPar::TLocalExecutor::WAIT_COMPLETE);

    TFold& ff = *fold;
    ff.AssignPermuted(sampleWeights, &ff.SampleWeights);
    if (!ff.LearnWeights.empty()) {
        for (int i = 0; i < learnSampleCount; ++i) {
            ff.SampleWeights[i] *= ff.LearnWeights[i];
        }
    }

    const int approxDimension = ff.GetApproxDimension();
    for (TFold::TBodyTail& bt : ff.BodyTailArr) {
        for (int dim = 0; dim < approxDimension; ++dim) {
            double* weightedDerData = bt.WeightedDer[dim].data();
            const double* derData = bt.Derivatives[dim].data();
            const float* sampleWeightsData = ff.SampleWeights.data();
            ctx->LocalExecutor.ExecRange([=](int z) {
                weightedDerData[z] = derData[z] * sampleWeightsData[z];
            }, NPar::TLocalExecutor::TExecRangeParams(bt.BodyFinish, bt.TailFinish).SetBlockSize(4000)
             , NPar::TLocalExecutor::WAIT_COMPLETE);
        }
    }
}
开发者ID:iamnik13,项目名称:catboost,代码行数:41,代码来源:greedy_tensor_search.cpp

示例10: FindBallCol

int FindBallCol(TVector& point, double& TimePoint, double Time2, int& BallNr1, int& BallNr2)
{
	TVector RelativeV;
	TRay rays;
	double MyTime=0.0, Add=Time2/150.0, Timedummy=10000, Timedummy2=-1;
	TVector posi;
	
	//Test all balls against eachother in 150 small steps
	for (int i=0;i<NrOfBalls-1;i++)
	{
	 for (int j=i+1;j<NrOfBalls;j++)
	 {	
		    RelativeV=ArrayVel[i]-ArrayVel[j];
			rays=TRay(OldPos[i],TVector::unit(RelativeV));
			MyTime=0.0;

			if ( (rays.dist(OldPos[j])) > 40) continue; 

			while (MyTime<Time2)
			{
			   MyTime+=Add;
			   posi=OldPos[i]+RelativeV*MyTime;
			   if (posi.dist(OldPos[j])<=40) {
										   point=posi;
										   if (Timedummy>(MyTime-Add)) Timedummy=MyTime-Add;
										   BallNr1=i;
										   BallNr2=j;
										   break;
										}
			
			}
	 }

	}

	if (Timedummy!=10000) { TimePoint=Timedummy;
	                        return 1;
	}

	return 0;
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:41,代码来源:Lesson30.cpp

示例11: InsertItem

    void InsertItem(int iItem, ListItem* pListItem)
    {
        for (int i = 0; i < pListItem->GetItemHeight(); i++) {
            m_vItems.Insert(iItem, pListItem);
        }

        if (iItem <= m_iSelItem) {
            SetSelItemByIdx(m_iSelItem + pListItem->GetItemHeight());
        }

        if (m_pScrollPane) {
            m_pScrollPane->SetSize(m_vItems.GetCount());
            if (iItem <= m_iTopItem) {
                m_pScrollPane->SetPos(m_iTopItem + pListItem->GetItemHeight());
            }
        }
        NeedPaint();
    }
开发者ID:kgersen,项目名称:Allegiance,代码行数:18,代码来源:trekctrls.cpp

示例12: GetItemIdx

 int GetItemIdx(ListItem* pListItem)
 {
     int cItems = m_vItems.GetCount();
     for (int iItem = 0; iItem < cItems; iItem++)
         {
         if (m_vItems[iItem] == pListItem)
             return iItem;
         }
     return -1;
 }
开发者ID:kgersen,项目名称:Allegiance,代码行数:10,代码来源:trekctrls.cpp

示例13: GetItemIdxByData

 int GetItemIdxByData(long lItemData)
 {
     int cItems = m_vItems.GetCount();
     for (int iItem = 0; iItem < cItems; iItem++)
         {
         if (m_vItems[iItem]->GetItemData() == lItemData)
             return iItem;
         }
     return -1;
 }
开发者ID:kgersen,项目名称:Allegiance,代码行数:10,代码来源:trekctrls.cpp

示例14: get

 TValue get(const TId id) const final {
     if (id >= m_vector.size()) {
         throw osmium::not_found{id};
     }
     const TValue value = m_vector[id];
     if (value == osmium::index::empty_value<TValue>()) {
         throw osmium::not_found{id};
     }
     return value;
 }
开发者ID:alex85k,项目名称:osm2pgsql,代码行数:10,代码来源:vector_map.hpp

示例15: GetRadius

    float GetRadius(const Matrix& mat)
    {
        float radius = 0;
        int count = m_vvertex.GetCount();
        for(int index = 0; index < count; index++) {
            Vector vec = mat.Transform(m_vvertex[index].GetPosition());
            radius = max(radius, vec.Length());
        }

        return radius;
    }
开发者ID:AllegianceZone,项目名称:Allegiance,代码行数:11,代码来源:bspgeo.cpp


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