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


C++ SVector类代码示例

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


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

示例1: eval

void LinearLaRank::eval(Sample& sample, Result& result) {
    // Evaluate the sample
    if (m_sampleCount) {
        // Convert the Sample to LaRank form
        SVector laX;
        for (int nFeat = 0; nFeat < sample.x.rows(); nFeat++) {
            laX.set(nFeat, sample.x(nFeat));
        }

        m_svm->predict_with_scores(laX, result);

        // Convert the scores to probabilities
        double totalProb = 0.0;
        for (int nClass = 0; nClass < *m_numClasses; nClass++) {
            result.confidence[nClass] = exp(result.confidence[nClass]);
            totalProb += result.confidence[nClass];
        }
        for (int nClass = 0; nClass < *m_numClasses; nClass++) {
            result.confidence[nClass] /= (totalProb + 1e-16);
        }
    } else {
        for (int nClass = 0; nClass < *m_numClasses; nClass++) {
            result.confidence[nClass] = 1.0 / *m_numClasses;
        }
        result.prediction = 0;
    }
}
开发者ID:circlingthesun,项目名称:omclboost,代码行数:27,代码来源:linear_larank.cpp

示例2: saveSvmLight

void
saveSvmLight(const char *fname, docs_t &docs, intvector_t &ids)
{
  cerr << "# Writing " << fname << "."  << endl;
  
  ogzstream f;
  f.open(fname);
  if (! f.good())
    {
      cerr << "ERROR: cannot open " << fname << " for writing." << endl;
      ::exit(10);
    }
  
  for(int i=0; i<(int)ids.size(); i++)
    {
      int id = ids[i];
      bool y = classes[id];
      SVector s = docs[id];
      int p = s.npairs();
      if (p <= 0)
        {
          cerr << "ERROR: empty vector " << id << "." << endl;
          ::exit(10);
        }
      f << ((y) ? +1 : -1);
      f << s;
      if (! f.good())
        {
          cerr << "ERROR: writing " << fname << " for writing." << endl;
          ::exit(10);
        }
    }
  
  cerr << "# Done. Wrote " << ids.size() << " examples." << endl;
}
开发者ID:filannim,项目名称:sgd-1.3-mod,代码行数:35,代码来源:preprocess.cpp

示例3: loadmult_datafile_sub

static void
loadmult_datafile_sub(istream &f, bool binary, const char *fname, 
                  xvec_t &xp, yvec_t &yp, int &maxdim, int maxrows)
{
  cout << "# Reading file " << fname << endl;
  if (! f.good())
    assertfail("Cannot open " << fname);

  int pcount = 0;
  while (f.good() && maxrows--)
    {
	double y;
      	SVector x;
	y = (f.get());
        x.load(f);
      
      if (f.good())
        {          
          xp.push_back(x);
          yp.push_back(y);
          pcount += 1;
          if (x.size() > maxdim)
            maxdim = x.size();
        }
    }
  cout << "# Read " << pcount << " examples." << endl;
  

}
开发者ID:yqxian,项目名称:zsl,代码行数:29,代码来源:data_mult.cpp

示例4: load

void
load(const char *fname, xvec_t &xp, yvec_t &yp)
{
  cout << "Loading " << fname << "." << endl;
  
  igzstream f;
  f.open(fname);
  if (! f.good())
    {
      cerr << "ERROR: cannot open " << fname << "." << endl;
      exit(10);
    }
  int pcount = 0;
  int ncount = 0;

  bool binary;
  string suffix = fname;
  if (suffix.size() >= 7)
    suffix = suffix.substr(suffix.size() - 7);
  if (suffix == ".dat.gz")
    binary = false;
  else if (suffix == ".bin.gz")
    binary = true;
  else
    {
      cerr << "ERROR: filename should end with .bin.gz or .dat.gz" << endl;
      exit(10);
    }

  while (f.good())
    {
      SVector x;
      double y;
      if (binary)
        {
          y = (f.get()) ? +1 : -1;
          x.load(f);
        }
      else
        {
          f >> y >> x;
        }
      if (f.good())
        {
          assert(y == +1 || y == -1);
          xp.push_back(x);
          yp.push_back(y);
          if (y > 0)
            pcount += 1;
          else
            ncount += 1;
          if (x.size() > dim)
            dim = x.size();
        }
      if (trainsize > 0 && xp.size() > (unsigned int)trainsize)
        break;
    }
  cout << "Read " << pcount << "+" << ncount 
       << "=" << pcount + ncount << " examples." << endl;
}
开发者ID:AnryYang,项目名称:cpp_algorithms,代码行数:60,代码来源:svmsgd2.cpp

示例5: DLogWriteSystem

bool DDynamicActor::Collision_IntersectCheck( int )
{
	DLogWriteSystem(" Collision_IntersectCheck : %p", this );
	
	SVector Location = m_Locus.Location;
	SVector Start = Physics::g_vStart;
	if( m_dwColFlag & CF_COLLIDEDBY_ROOT_INTERNAL )
	{
		Location = GMath.ZeroVector;
		SMatrix Matrix = (this->m_matRootMatrixForCollision * m_Locus.LocalToWorld).Inverse();
		Start = Matrix.TransformVector( Physics::g_vStart );
	}

	SVector vExtent = Physics::g_vExtent + this->m_vExtent;
	SVector Delta = Start - Location;
	if( Abs(Delta.Y) >= vExtent.Y ) return false;

	float DeltaSquared2D = Delta.SizeSquared2D();
	float RadiusSquared = Square(vExtent.X);
	if( DeltaSquared2D >= RadiusSquared ) return false;

	float Overlap = appSqrt( RadiusSquared ) - appSqrt( DeltaSquared2D );
	if( Overlap <= Physics::g_SingleResult.m_fTime ) return false;

	Physics::g_SingleResult.m_nActorIndex	= m_dwID;
	Physics::g_SingleResult.m_nMeshIndex	= -1;
	Physics::g_SingleResult.m_fTime		= Overlap;
	Delta.Y = 0.f;
	Physics::g_SingleResult.m_vNormal		= Delta.SafeNormal();
	Physics::g_SingleResult.m_vContactPoint= m_Locus.Location + this->m_vExtent.X * Physics::g_SingleResult.m_vNormal;
	Physics::g_SingleResult.m_ActorType	= this->m_ActorType;
	return true;
}
开发者ID:RaoMiao,项目名称:freestyle,代码行数:33,代码来源:DDynamicActor.cpp

示例6: Evaluate

SValue For::Evaluate(const sptr<BShell>& parent, const sptr<ICommand>& shell, bool* outExit)
{
	SVector<SValue> args;

	for (size_t i = 0 ; i < m_words.CountItems(); i++)
	{
		bool insert_args = false;
		//bout << "WORDS [" << i << "] " << m_words[i] << endl;
		SValue expanded = Expand(shell, m_words.ItemAt(i), &insert_args);
		
		if (insert_args)
		{
			collect_arguments(expanded.AsString(), &args);
		}
		else
		{
			//bout << "adding expanded " << expanded << endl;
			args.AddItem(expanded);
		}
	}
	
	*outExit = false;
	SValue returned = SValue::Status(B_OK);
	
	for (size_t i = 0 ; i < args.CountItems() && !*outExit; i++)
	{
		//bout << "setting m_condition to be " << args.ItemAt(i) << endl;
		shell->SetProperty(SValue::String(m_condition), args.ItemAt(i));
		returned = m_dolist->Evaluate(parent, shell, outExit);
	}
	
	return returned;
}
开发者ID:cambridgehackers,项目名称:openbinder-archive,代码行数:33,代码来源:SyntaxTree.cpp

示例7: assert

Real Vector::operator*(const SVector& v) const
{
   assert(dim() >= v.dim());
   int i;
   Real x = 0;
   for (i = v.size(); i-- > 0;)
      x += val[v.index(i)] * v.value(i);
   return x;
}
开发者ID:nicolaje,项目名称:reliable-slam,代码行数:9,代码来源:vector.cpp

示例8: load_classes

void
load_classes(const char *fname, int &nclass)
{ 
  string filename = fname;
  ifstream f;
  SVector x;
  f.open(fname);
  x.load(f);
  nclass = x.size();  
}
开发者ID:yqxian,项目名称:zsl,代码行数:10,代码来源:data_mult.cpp

示例9: generateBasisFuncVisualizationPoints

void SH::generateBasisFuncVisualizationPoints( int numPoints, int l, int m, const Vector& center )
{
  for( int i = 0 ; i < numPoints ; i++ )
  {
    SVector sv = SVector::random( 1 ) ;
    // get SH value for band.
    real value = Y( l, m, sv.tElevation, sv.pAzimuth ) ;
    window->addDebugPoint( sv.toCartesian() + center, Vector::toRGB( 180*(value+1), 1, 1 ) ) ; // coloration by mag of point
  }
}
开发者ID:sdp0et,项目名称:gtp,代码行数:10,代码来源:SH.cpp

示例10: update

void LinearLaRank::update(Sample& sample) {
    // Convert the Sample to LaRank form
    SVector laX;
    for (int nFeat = 0; nFeat < sample.x.rows(); nFeat++) {
        laX.set(nFeat, sample.x(nFeat));
    }

    // Add the sample to svm
    m_sampleCount++;
    m_svm->add(laX, sample.y, m_sampleCount, sample.w);
}
开发者ID:circlingthesun,项目名称:omclboost,代码行数:11,代码来源:linear_larank.cpp

示例11: call_binder_cleanup_funcs

void call_binder_cleanup_funcs()
{
	SVector<binder_cleanup_func> funcs;
	{
		SAutolock _l(g_cleanupLock.Lock());
		funcs = g_cleanupFuncs;
		g_cleanupFuncs.MakeEmpty();
	}

	size_t N = funcs.CountItems();
	while (N-- > 0) {
		funcs[N]();
	}
}
开发者ID:cambridgehackers,项目名称:openbinder-archive,代码行数:14,代码来源:SupportUtils.cpp

示例12: CollectParents

void CollectParents(InterfaceRec* rec, const SVector<InterfaceRec*>& classes, SVector<InterfaceRec*>* out)
{
	SVector<SString> parents = rec->Parents();
	const size_t N = parents.CountItems();
	for (size_t i=0; i<N; i++) {
		const size_t Nc = classes.CountItems();
		for (size_t c=0; c<Nc; c++) {
			if (parents[i] == classes[c]->ID() || parents[i] == classes[c]->FullInterfaceName()) {
				out->AddItem(classes[c]);
			}
		}
	}
	out->AddItem(rec);
}
开发者ID:cambridgehackers,项目名称:openbinder-archive,代码行数:14,代码来源:OutputUtil.cpp

示例13: saveBinary

void
saveBinary(const char *fname, docs_t &docs, intvector_t &ids)
{
  cerr << "# Writing " << fname << "."  << endl;
  
  ogzstream f;
  f.open(fname);
  if (! f.good())
    {
      cerr << "ERROR: cannot open " << fname << " for writing." << endl;
      ::exit(10);
    }
  
  int pcount = 0;
  int ncount = 0;
  int npairs = 0;
  for(int i=0; i<(int)ids.size(); i++)
    {
      int id = ids[i];
      bool y = classes[id];
      if (y)
        pcount += 1;
      else
        ncount += 1;

      SVector s = docs[id];
      int p = s.npairs();
      npairs += p;
      if (p <= 0)
        {
          cerr << "ERROR: empty vector " << id << "." << endl;
          ::exit(10);
        }
      
      f.put( y ? 1 : 0);
      s.save(f);
      if (! f.good())
        {
          cerr << "ERROR: writing " << fname << " for writing." << endl;
          ::exit(10);
        }
    }

  cerr << "# Done. Wrote " << ids.size() << " examples." << endl;
  cerr << "#   with " << npairs << " pairs, " 
       << pcount << " positives, and "
       << ncount << " negatives." << endl;
}
开发者ID:filannim,项目名称:sgd-1.3-mod,代码行数:48,代码来源:preprocess.cpp

示例14: ExpandBoundBySphere

void GSphere::ExpandBoundBySphere( const GSphere &Src )
{
	// Method 1 = 대상구와의 거리 + 반지름을 한 길이가 더 길면, 그만큼 반지름을 확장한다.
	// Method 2 = Method-1의 체크가 TRUE이면, 두 구의 중심을 잇는 선의 중점에서 두 구와의 거리의 반을 반지름으로 하는
	//            구를 만들면 최적화된 구가 나온다.
	// 여기서는 Method-2를 쓴다.
	SVector vSub;
	vSub = Src.vecCenter - vecCenter;
	float fDistCenter = vSub.Size();

	if( fDistCenter+Src.fRadius > fRadius )
	{
		vecCenter = vecCenter + vSub/2.0f;
		fRadius = fDistCenter/2.0f;
	}
}
开发者ID:RaoMiao,项目名称:freestyle,代码行数:16,代码来源:GraphicTypes.cpp

示例15: load_output

 // Organizing the cache of an output 
 void load_output (LaFVector nbeta, int nl, SVector & rtoi)
 {
   beta = nbeta;
   l = nl;
   for (int r = 0; r < l; r++)
     larank_kcache_swap_ri (kernel, r, (int) rtoi.get (r));
 }
开发者ID:aacharya,项目名称:DSLDA_NPDSLDA,代码行数:8,代码来源:LaRank.cpp


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