• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ivector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: x

/**
Allocate variable vector of matrices with dimensions
[sl to sh] x ([nrl to nrh] x [ncl to nch])
where nrl is a vector of indexes.
\param sl lower index of vector
\param sh upper index of vector
\param nrl vector of lower row indexes for matrix
\param nrh upper row index for matrix
\param ncl upper column index for matrix
\param nch upper column index for matrix
*/
void dvar3_array::allocate(int sl, int sh, const ivector& nrl, int nrh,
  int ncl, int nch)
{
  if (sh < sl)
  {
    allocate();
    return;
  }
  if (sl !=nrl.indexmin() || sh !=nrl.indexmax())
  {
    cerr << "Incompatible array bounds in "
     "dmatrix(int nrl,int nrh, const ivector& ncl, const ivector& nch)" << endl;
    ad_exit(1);
  }
  if ( (shape=new three_array_shape(sl,sh)) == 0)
  {
    cerr << " Error allocating memory in dvar3_array contructor" << endl;
  }
  if ( (t = new dvar_matrix[slicesize()]) == 0)
  {
    cerr << " Error allocating memory in dvar3_array contructor" << endl;
    ad_exit(21);
  }
  t -= slicemin();
  for (int i = sl; i <= sh; ++i)
  {
    t[i].allocate(nrl(i), nrh, ncl, nch);
  }
}
开发者ID:johnrsibert,项目名称:admb,代码行数:40,代码来源:f3arr.cpp


示例2: calcGradient

  bool MLP::calcGradient(const dmatrix& inputs,
                         const ivector& ids,
                         dvector& grad) {

    if (inputs.rows() != ids.size()) {
      setStatusString("Number of vectors not consistent with number of ids");
      return false;
    }

    dvector tmp;
    int i;
    double tmpError;

    totalError = 0;
    calcGradient(inputs.getRow(0),ids.at(0),grad);
    computeActualError(ids.at(0),totalError);

    for (i=1;i<inputs.rows();++i) {
      calcGradient(inputs.getRow(i),ids.at(i),tmp);
      computeActualError(ids.at(i),tmpError);
      grad.add(tmp);
      totalError+=tmpError;
    }

    return true;
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:26,代码来源:ltiMLP.cpp


示例3: getMostLabel

  //get most(best) available label from histogram
  int kNearestNeighFilter::getMostLabel(const ivector& histogram,
			       const imatrix& src,
			       const int& row, const int& col) const{

    int numOfMax = 0;
    int maxIndex = -1; // first index, which is max
    int max = 0; //
    for(int i=0;i<histoSize;++i) {
      if(histogram.at(i) < max); // for speed up (probability)
      else if(histogram.at(i) > max) {
	max = histogram.at(i);
	numOfMax = 1;
	maxIndex = i;
      }
      else //if(histogram.at(i) == max)
	++numOfMax;
    }

    //is there more than one possibility ?
    if (numOfMax == 1)
      return maxIndex;
    // is the kernel center one of the max's?
    else if(histogram.at(src.at(row,col)) == max)
      return src.at(row,col);
    else
      return getMedian(histogram,max,numOfMax);
  };
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:28,代码来源:ltiKNearestNeighFilter.cpp


示例4: allocate

/**
 * Description not yet available.
 * \param
 */
 void dmatrix::allocate(int nrl,int nrh,const ivector& ncl,int nch)
 {
   if (nrh<nrl)
   {
     allocate();
     return;
   }
   if (nrl !=ncl.indexmin() || nrh !=ncl.indexmax())
   {
     cerr << "Incompatible array bounds in dmatrix(int nrl,int nrh,"
       " int ncl,const ivector& nch)\n";
     ad_exit(1);
   }
   index_min=nrl;
   index_max=nrh;
   if ( (m = new dvector [rowsize()]) == 0)
   {
     cerr << " Error allocating memory in dmatrix contructor\n";
     ad_exit(21);
   }
   if ( (shape = new mat_shapex(m))== 0)
   {
     cerr << " Error allocating memory in dmatrix contructor\n";
     ad_exit(21);
   }
   m -= rowmin();
   for (int i=rowmin(); i<=rowmax(); i++)
   {
     m[i].allocate(ncl(i),nch);
   }
 }
开发者ID:jimianelli,项目名称:admb,代码行数:35,代码来源:dmat.cpp


示例5: allocate

/**
 * Description not yet available.
 * \param
 */
 void lmatrix::allocate(int nrl, int nrh, int ncl, const ivector& nch)
 {
   if (nrl !=nch.indexmin() || nrh !=nch.indexmax())
   {
     cerr << "Incompatible array bounds in "
     "lmatrix::allocate(int nrl,int nrh,int ncl, const ivector& nch)\n";
     ad_exit(1);
   }
   if ( (shape = new mat_shape(nrl,nrh,ncl,nch(nch.indexmin())))== 0)
   {
     cerr << " Error allocating memory in lmatrix contructor\n";
     ad_exit(21);
   }
   size_t rs=rowsize();
   if ( (m = new lvector [rs]) == 0)
   {
     cerr << " Error allocating memory in lmatrix contructor\n";
     ad_exit(21);
   }
   m -= rowmin();
   for (int i=rowmin(); i<=rowmax(); i++)
   {
     m[i].allocate(ncl,nch(i));
   }
 }
开发者ID:colemonnahan,项目名称:admb,代码行数:29,代码来源:lmat.cpp


示例6: allocate

/**
 * Description not yet available.
 * \param
 */
dvector::dvector(const ivector& u)
 {
   allocate(u.indexmin(),u.indexmax());
   for ( int i=indexmin(); i<=indexmax(); i++)
   {
     elem(i)=u.elem(i);
   }
 }
开发者ID:pwoo,项目名称:admb,代码行数:12,代码来源:dvect8.cpp


示例7: norm2

/**
Returns the sum of the squares of all elements in ivec.

\param ivec ivector
*/
int norm2(const ivector& ivec)
{
  int sum = 0;
  for (int i = ivec.indexmin(); i <= ivec.indexmax(); ++i)
  {
    sum += ivec(i) * ivec(i);
  }
  return sum;
}
开发者ID:colemonnahan,项目名称:admb,代码行数:14,代码来源:ivector.cpp


示例8: operator

/**
 * Description not yet available.
 * \param
 */
dvector dvector::operator ()(const ivector& u)
 {
   dvector tmp(u.indexmin(),u.indexmax());

   for ( int i=u.indexmin(); i<=u.indexmax(); i++)
   {
     tmp(i)=(*this)(u(i));
   }
   return tmp;
 }
开发者ID:pwoo,项目名称:admb,代码行数:14,代码来源:dvect8.cpp


示例9: square

/**
Return dvector results of squaring elements in a values;
constant vector object.

\ingroup misc
\param values of constant object to be squared.
\return vector of the same length as #values containing \f$values_i^2\f$
*/
ivector square(const ivector& values)
{
  ivector results;
  results.allocate(values);
  for (int i = values.indexmin(); i <= values.indexmax(); ++i)
  {
    results(i) = values(i) * values(i);
  }
  return results;
}
开发者ID:colemonnahan,项目名称:admb,代码行数:18,代码来源:d3arr4.cpp


示例10: histogramMethodMiddle

  // the kernel runs inside the image
  void kNearestNeighFilter::histogramMethodMiddle(const imatrix& src,
                                              imatrix& dest,
                                              ivector& histogram,
                                              const int& row,int& col) const {
    int i,j;//index
    int numOfMax, maxIndex;
    int max=0;
    const int maxChange = sizeOfKernel+1;//max change for "max"

    const int limit = sizeOfKernel/2;   //half size of the kernel
    const int lastCol = src.lastColumn()-limit;
    const int r = row+limit;
    col = limit;

    int v; //del test
    while(col <= (lastCol-1)) {
      j = col-limit;
      // sub labels left form the kernel
      for(i=row-limit;i<=r;++i) {
        --histogram.at(src.at(i,j));
      }
      // add labels right from the kernel
      ++col;
      j = col+limit;
      for(i=row-limit;i<=r;++i) {
	v = src.at(i,j);
        ++histogram.at(src.at(i,j));
      }

      //get most(best) available label
      numOfMax = 0;
      maxIndex = -1;
      max -= maxChange; //=0;
      for(i=0;i<histoSize;++i) {
	if(histogram.at(i) < max);// for speed up (probability)
	else if(histogram.at(i) > max) {
	  max = histogram.at(i);
	  numOfMax = 1;
	  maxIndex = i;
	}
	else //if(histogram.at(i) == max)
	  ++numOfMax;
      }

      //is there more than one possibility ?
      if(numOfMax == 1)
	dest.at(row,col) =  maxIndex;
      // is the kernel center one of the max's?
      else if(histogram.at(src.at(row,col)) == max)
	dest.at(row,col) = src.at(row,col);
      else
	dest.at(row,col) = getMedian(histogram,max,numOfMax);
    }//while
  };
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:55,代码来源:ltiKNearestNeighFilter.cpp


示例11: allocate

 void allocate(int lb, int ub)
 {
     indx.allocate(lb, ub);
     indx2.allocate(lb, ub);
     ivector iv(lb + 1, ub);
     iv.fill_seqadd(lb, 1);
     L.allocate(lb + 1, ub, lb, iv);
     ivector iv1(lb, ub);
     iv1.fill_seqadd(lb, 1);
     U.allocate(lb, ub, lb, iv1);
     indx2.fill_seqadd(lb, 1);
 }
开发者ID:pwoo,项目名称:admb,代码行数:12,代码来源:ludcmp.hpp


示例12: makeTargets

 void svm::makeTargets(const ivector& ids) {
   // expand each class label i to a vector v with v[j]=1 if j == i,
   // and j[j]=-1 if j != i
   srcIds=ids;
   dmatrix* t=new dmatrix(nClasses,ids.size(),-1.0);
   // iterate over training labels
   for (int i=0; i<t->columns(); i++) {
     t->at(idMap[ids.at(i)],i)=1;
   }
   if (target != 0) {
     delete target;
   }
   target=t;
 }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:14,代码来源:ltiSVM.cpp


示例13: vect

  int kNearestNeighFilter::getMedian(const ivector& histogram,
                                     const int max,
                                     const int numOfMax) const {
    ivector vect(numOfMax,0);
    int i,z=0;
    const int size=histogram.size();
    for(i=0;i<size;++i) {
      if (histogram.at(i) == max) {
        vect.at(z++) = i;
      }
    }

    return vect.at(z/2);
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:14,代码来源:ltiKNearestNeighFilter.cpp


示例14: buildIdMaps

  void svm::buildIdMaps(const ivector& ids) {
    int j=0;
    // create reverse id map
    idMap.clear();
    for (int i=0; i<ids.size(); i++) {
      if (idMap.find(ids.at(i)) == idMap.end()) {
      _lti_debug("Mapping external id " << ids.at(i) << " to " << j << std::endl);
        rIdMap[j]=ids.at(i);
        idMap[ids.at(i)]=j++;
      }
    }

    nClasses=j;
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:14,代码来源:ltiSVM.cpp


示例15: checkHowManyOutputs

  void MLP::checkHowManyOutputs(const ivector& ids) {
    // count how many different ids are present in the training set
    std::map<int,int> extToInt;
    std::map<int,int>::iterator it;

    int i,k;
    for (i=0,k=0;i<ids.size();++i) {
      it = extToInt.find(ids.at(i));
      if (it == extToInt.end()) {
        extToInt[ids.at(i)] = k;
        ++k;
      }
    }

    outputs = extToInt.size();
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:16,代码来源:ltiMLP.cpp


示例16: SearchTree

void CKDTree::SearchTree(KD_Node *parent, Point &p, float radius, ivector &vec_r)
{
	if (parent==NULL || parent->IsSearched)
		return;
	parent->IsSearched=true;
	//is a child node
	if(parent->m_left==NULL && parent->m_right==NULL)
	{
		int nSize=parent->m_vecIn.size();
		for (int i=0; i<nSize; ++i)
			if(m_regionArray[parent->m_vecIn[i]].IsSeen(p, radius))
				vec_r.push_back(parent->m_vecIn[i]);
	}
	//not a child node
	else
	{
		if(parent->m_left!=NULL && !parent->m_left->IsSearched && 
			(parent->m_left->m_regOverlap.IsSeen(p, radius)))
			SearchTree(parent->m_left, p, radius, vec_r);
		if (parent->m_right!=NULL && !parent->m_right->IsSearched &&
			(parent->m_right->m_regOverlap.IsSeen(p, radius)))
			SearchTree(parent->m_right, p, radius, vec_r);
	}
	//back trace : search parent
	SearchTree(parent->m_parent, p, radius, vec_r);
}
开发者ID:WandermyzGoogleCode,项目名称:LegacyCityAdventure,代码行数:26,代码来源:KDTree.cpp


示例17: clean

/**
Set elements of ivec to zero starting from level + 1;

\param level is the index of ivec
*/
void clean(ivector& v, int level)
{
  int max = v.indexmax();
  for (int i = level + 1; i <= max; ++i)
  {
    v(i) = 0;
  }
}
开发者ID:colemonnahan,项目名称:admb,代码行数:13,代码来源:ivector.cpp


示例18: assign

 void pvm_int::assign(const ivector& u)
 {
   if(ad_comm::pvm_manager)
   {
     int nsp=ad_comm::pvm_manager->num_slave_processes;
     if (u.indexmin() !=0 || u.indexmax() != nsp)
     {
       cerr << "Error in pvm_int::assign  validindex bounds must be 0 "
            << ad_comm::pvm_manager->num_slave_processes << endl;
       ad_exit(1);
     }
     if (allocated(v))
       v.deallocate();
     v.allocate(0,nsp);
     v=u;
     d=u(0);
   }
 }
开发者ID:colemonnahan,项目名称:admb,代码行数:18,代码来源:pvmvar1.cpp


示例19: cltudecomp

 cltudecomp(int lb, int ub):indx(lb, ub), indx2(lb, ub)
 {
     ivector iv(lb + 1, ub);
     iv.fill_seqadd(lb, 1);
     L.allocate(lb + 1, ub, lb, iv);
     ivector iv1(lb, ub);
     iv1.fill_seqadd(lb, 1);
     U.allocate(lb, ub, lb, iv1);
     indx2.fill_seqadd(lb, 1);
 }
开发者ID:pwoo,项目名称:admb,代码行数:10,代码来源:ludcmp.hpp


示例20: assert

  // return probability value of an rgb pixel
  float probabilityMap2D::apply(const ubyte &value1, const ubyte &value2, ivector& theBin) const {

    assert((probabilityHistogram.dimensions() == 2) &&
           (theBin.size() == 2));
    
    theBin[0] = lookupTable[0][static_cast<int>(value1)];
    theBin[1] = lookupTable[1][static_cast<int>(value2)];

    return static_cast<float>(probabilityHistogram.at(theBin));
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:11,代码来源:ltiProbabilityMap2D.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ json类代码示例发布时间:2022-05-31
下一篇:
C++ ivec2类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap