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


C++ vector_t::size方法代码示例

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


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

示例1: deriveEquiFreqAndGtrParamsForReversibleRM

  void deriveEquiFreqAndGtrParamsForReversibleRM(matrix_t const & Q, vector_t & equiFreq, vector_t & gtrParams)
  {
    equiFreq = deriveEquiFreqForReversibleRM(Q);
    unsigned n = equiFreq.size();
   
    // check
    for (unsigned i = 0; i < n; i++)
      assert(equiFreq[i] > 0);
    
    matrix_t pm = Q;  // parameter matrix
    for (unsigned i = 0; i < n; i++)
      for (unsigned j = 0; j < n; j++)
	pm(i, j) = Q(i, j) / equiFreq[j];

    // check grtParams size
    unsigned paramCount = (n * (n - 1) / 2);
    if (gtrParams.size() != paramCount)
      gtrParams.resize(paramCount);

    // reverse of gtrRateParametersToMatrix
    unsigned idx = 0;
    for (unsigned i = 0; i < n; i++)
      for (unsigned j = i + 1; j < n; j++) {
	gtrParams[idx] = pm(i, j);
	idx++;
      }
  }
开发者ID:jakob-skou-pedersen,项目名称:phy,代码行数:27,代码来源:RateMatrix.cpp

示例2: lfit

void lfit(vector_t &x, vector_t &y, vector_t &sig, vector_t &a,
 	  vector<bool> &ia, matrix_t &covar, double &chisq, matrix_t & X)
{
  int i,j,k,l,m,mfit=0;
  double ym,wt,sum,sig2i;
  
  int ndat=x.size();
  int ma=a.size();
  vector_t afunc(ma);
  matrix_t beta;
  sizeMatrix(beta,ma,1);
  for (j=0;j<ma;j++)
    if (ia[j]) mfit++;
  if (mfit == 0) error("lfit: no parameters to be fitted");
  for (j=0;j<mfit;j++) {
    for (k=0;k<mfit;k++) covar[j][k]=0.0;
    beta[j][0]=0.0;
  }
  for (i=0;i<ndat;i++) {
    afunc = X[i];

    ym=y[i];
    if (mfit < ma) {
      for (j=0;j<ma;j++)
	if (!ia[j]) ym -= a[j]*afunc[j];
    }
    sig2i=1.0/SQR(sig[i]);
    for (j=0,l=0;l<ma;l++) {
      if (ia[l]) {
	wt=afunc[l]*sig2i;
	for (k=0,m=0;m<=l;m++)
	  if (ia[m]) covar[j][k++] += wt*afunc[m];
	beta[j++][0] += ym*wt;
      }
    }
  }
  for (j=1;j<mfit;j++)
    for (k=0;k<j;k++)
      covar[k][j]=covar[j][k];
  vector<vector<double> >  temp;
  sizeMatrix(temp,mfit,mfit);
  for (j=0;j<mfit;j++)
    for (k=0;k<mfit;k++)
      temp[j][k]=covar[j][k];
  gaussj(temp,beta);
  for (j=0;j<mfit;j++)
    for (k=0;k<mfit;k++)
      covar[j][k]=temp[j][k];
  for (j=0,l=0;l<ma;l++)
    if (ia[l]) a[l]=beta[j++][0];
  chisq=0.0;
  for (i=0;i<ndat;i++) {
    afunc = X[i];
    sum=0.0;
    for (j=0;j<ma;j++) sum += a[j]*afunc[j];
    chisq += SQR((y[i]-sum)/sig[i]);
  }
  covsrt(covar,ia,mfit);
}
开发者ID:francois-boyer,项目名称:plink,代码行数:59,代码来源:linear.cpp

示例3: next_vec

vector_t next_vec( const vector_t &current, const vector_t &grad,
                   const vector_t &lapl ) {
    vector_t next( current.size() );
//    std::cout << "next_vec" << std::endl;
//    std::cout << current.size() << " " << grad.size() << " "
//        << lapl.size() << std::endl;
    for ( unsigned int i = 0; i < current.size(); ++i ) {
        next[i] = current[i] - grad[i] / lapl[i]; }
    return next; }
开发者ID:mark-burnett,项目名称:dressed-extended-rpa,代码行数:9,代码来源:fit.cpp

示例4: EarlyStop

bool ModelUtil::EarlyStop(vector_t val_losses, size_t patience, float delta) {
  // Check for edge cases
  PELOTON_ASSERT(patience > 1);
  PELOTON_ASSERT(delta > 0);
  if (val_losses.size() < patience) return false;
  float cur_loss = val_losses[val_losses.size() - 1];
  float pat_loss = val_losses[val_losses.size() - patience];
  // Loss should have at least dropped by delta at this point
  return (pat_loss - cur_loss) < delta;
}
开发者ID:cmu-db,项目名称:peloton,代码行数:10,代码来源:model_util.cpp

示例5: to

		static std::uint32_t to(state_t &state, const vector_t &val)
		{
			::lua_createtable(state, (int)val.size(), (int)val.size());

			std::uint32_t i = 1;
			std::for_each(val.cbegin(), val.cend(), 
				[&state, &i](const T &t)
			{
				convertion_t<T>::to(state, t);
				::lua_rawseti(state, -2, i++);
			});

			return 1;
		}
开发者ID:Strongc,项目名称:lua_reg,代码行数:14,代码来源:converter.hpp

示例6: check_gas_common

void pvt_base::check_gas_common (const vector_t &pressure, const vector_t &fvf, const vector_t &visc)
{
    for (t_long i = 1, cnt = (t_long)pressure.size (); i < cnt; ++i)
    {
        if (pressure[i] - pressure[i - 1] < EPS_DIFF)
        {
            throw bs_exception ("", "pressure curve should be monotonically increasing function");
        }
        if (fvf[i] - fvf[i - 1] >= 0)
        {
            BOSOUT (section::pvt, level::critical) << "gas: fvf" << bs_end;
            for (t_long j = 0; j < cnt; ++j)
            {
                BOSOUT (section::pvt, level::critical) << fvf[j] << bs_end;
            }

            throw bs_exception ("", "FVF curve should be monotonically decreasing function");
        }
        if (visc[i] - visc[i - 1] <= 0)
        {
            BOSOUT (section::pvt, level::critical) << "gas: visc" << bs_end;
            for (t_long j = 0; j < cnt; ++j)
            {
                BOSOUT (section::pvt, level::critical) << visc[j] << bs_end;
            }

            throw bs_exception ("", "Viscosity curve should be monotonically increasing function");
        }
    }
}
开发者ID:brbr520,项目名称:bs-eagle,代码行数:30,代码来源:pvt_base.cpp

示例7: bs_exception

void
pvt_base::check_oil_common (const vector_t &pressure, const vector_t &fvf, const vector_t &visc)
{
    for (t_long i = 0, cnt = (t_long)pressure.size (); i < cnt; ++i)
    {
        if (pressure[i] < 0)
        {
            // TODO: LOG
            BS_ASSERT (false) (pressure[i]);
            throw bs_exception ("", "pressure should be greater than 0");
        }
        if (fvf[i] < 0)
        {
            // TODO:LOG
            BS_ASSERT (false) (fvf[i]);
            throw bs_exception ("", "fvf should be greater than 0");
        }
        if (visc[i] < 0)
        {
            // TODO: LOG
            BS_ASSERT (false) (visc[i]);
            throw bs_exception ("", "viscosity should be greater than 0");
        }
    }
}
开发者ID:brbr520,项目名称:bs-eagle,代码行数:25,代码来源:pvt_base.cpp

示例8: countNonZeroEntries

  unsigned countNonZeroEntries(vector_t const & v)
  {

    unsigned n = 0;
    for (unsigned i = 0; i < v.size(); i++)
      if ( v(i) )
	n++;
    return n;
  }
开发者ID:jakob-skou-pedersen,项目名称:phy,代码行数:9,代码来源:RateMatrix.cpp

示例9: CheckVector

static void CheckVector( const vector_t& cv, size_t expected_size, size_t old_size ) {
    ASSERT( cv.capacity()>=expected_size, NULL );
    ASSERT( cv.size()==expected_size, NULL );
    ASSERT( cv.empty()==(expected_size==0), NULL );
    for( int j=0; j<int(expected_size); ++j ) {
        if( cv[j].bar()!=~j )
            REPORT("ERROR on line %d for old_size=%ld expected_size=%ld j=%d\n",__LINE__,long(old_size),long(expected_size),j);
    }
}
开发者ID:Multi2Sim,项目名称:m2s-bench-parsec-3.0-src,代码行数:9,代码来源:test_concurrent_vector.cpp

示例10: TRRateMatrixDispatcher

  boost::shared_ptr<BaseTRRateMatrix> TRRateMatrixDispatcher(string const & substModel, vector_t const & rateParameters, vector_t const & equiFreq, StateMap const & alphabet)
  {
    boost::shared_ptr<BaseTRRateMatrix> rmPtr;

    if (substModel == "GTR")
      rmPtr = boost::shared_ptr<GTRRateMatrix>( new GTRRateMatrix(alphabet) );
    // define other substitution models here ...
    else
      errorAbort("substitution model '" + substModel + "' not defined. If newly implemented, add to TRRateMatrixDispatcher.");


    if (equiFreq.size() > 0) // not defined, stick with default
      rmPtr->resetEquiFreqs(equiFreq);
    if (rateParameters.size() > 0) // not defined, stick with default
      rmPtr->resetRateParameters(rateParameters);

    return rmPtr;
  }
开发者ID:jakob-skou-pedersen,项目名称:phy,代码行数:18,代码来源:RateMatrix.cpp

示例11: vgrad

 scalar_t vgrad(const vector_t& x, vector_t* gx) const override
 {
         m_idata = map_tensor(x.data(), m_idata.dims());
         m_op.output(m_idata, m_wdata, m_bdata, m_odata);
         if (gx)
         {
                 gx->resize(x.size());
                 auto idata = map_tensor(gx->data(), m_idata.dims());
                 m_op.ginput(idata, m_wdata, m_bdata, m_odata);
         }
         return m_odata.array().square().sum() / 2;
 }
开发者ID:accosmin,项目名称:nano,代码行数:12,代码来源:test_affine.cpp

示例12: geqrf

// QR Factorization of a MxN General Matrix A.
//    a       (IN/OUT - matrix(M,N)) On entry, the coefficient matrix A. On exit , the upper triangle and diagonal is the min(M,N) by N upper triangular matrix R.  The lower triangle, together with the tau vector, is the orthogonal matrix Q as a product of min(M,N) elementary reflectors.
//    tau     (OUT - vector (min(M,N))) Vector of the same numerical type as A. The scalar factors of the elementary reflectors.
//    info    (OUT - int)
//   0   : function completed normally
//   < 0 : The ith argument, where i = abs(return value) had an illegal value.
int geqrf (matrix_t& a, vector_t& tau)
{
	int              _m = int(a.size1());
	int              _n = int(a.size2());
	int              _lda = int(a.size1());
	int              _info;

	// make_sure tau's size is greater than or equal to min(m,n)
	if (int(tau.size()) < (_n<_m ? _n : _m) )
		return -104;

	int ldwork = _n*_n;
	vector_t dwork(ldwork);
	rawLAPACK::geqrf (_m, _n, a.data().begin(), _lda, tau.data().begin(), dwork.data().begin(), ldwork, _info);

	return _info;
}
开发者ID:GangDesign,项目名称:open_ptrack,代码行数:23,代码来源:uLAPACK.hpp

示例13: BaseRateMatrix

 BaseTRRateMatrix::BaseTRRateMatrix (vector_t const & rateParameters, vector_t const & equiFreqs, string const & name, bool equiFreqsFixed) 
   : BaseRateMatrix(name), rateParameterCount_(rateParameters.size() ), equiFreqCount_(equiFreqs.size() ), rateParameters_(rateParameters), equiFreqs_(equiFreqs), equiFreqsFixed_(equiFreqsFixed)
 {}
开发者ID:jakob-skou-pedersen,项目名称:phy,代码行数:3,代码来源:RateMatrix.cpp

示例14: build_morton

void build_morton(vector_t<PrimRef>& prims, isa::PrimInfo& pinfo)
{
  size_t N = pinfo.size();
  /* array for morton builder */
  vector_t<isa::MortonID32Bit> morton_src(N);
  vector_t<isa::MortonID32Bit> morton_tmp(N);
  for (size_t i=0; i<N; i++) 
    morton_src[i].index = i;

  /* fast allocator that supports thread local operation */
  FastAllocator allocator;

  for (size_t i=0; i<2; i++)
  {
    std::cout << "iteration " << i << ": building BVH over " << N << " primitives, " << std::flush;
    double t0 = getSeconds();
    
    allocator.reset();

    std::pair<Node*,BBox3fa> node_bounds = isa::bvh_builder_morton<Node*>(

      /* thread local allocator for fast allocations */
      [&] () -> FastAllocator::ThreadLocal* { 
        return allocator.threadLocal(); 
      },

      BBox3fa(empty),

      /* lambda function that allocates BVH nodes */
      [&] ( isa::MortonBuildRecord<Node*>& current, isa::MortonBuildRecord<Node*>* children, size_t N, FastAllocator::ThreadLocal* alloc ) -> InnerNode*
      {
        assert(N <= 2);
        InnerNode* node = new (alloc->malloc(sizeof(InnerNode))) InnerNode;
        *current.parent = node;
        for (size_t i=0; i<N; i++) 
          children[i].parent = &node->children[i];
        return node;
      },

      /* lambda function that sets bounds */
      [&] (InnerNode* node, const BBox3fa* bounds, size_t N) -> BBox3fa
      {
        BBox3fa res = empty;
        for (size_t i=0; i<N; i++) {
          const BBox3fa b = bounds[i];
          res.extend(b);
          node->bounds[i] = b;
        }
        return res;
      },

      /* lambda function that creates BVH leaves */
      [&]( isa::MortonBuildRecord<Node*>& current, FastAllocator::ThreadLocal* alloc, BBox3fa& box_o) -> Node*
      {
        assert(current.size() == 1);
        const size_t id = morton_src[current.begin].index;
        const BBox3fa bounds = prims[id].bounds(); // FIXME: dont use morton_src, should be input
        Node* node = new (alloc->malloc(sizeof(LeafNode))) LeafNode(id,bounds);
        *current.parent = node;
        box_o = bounds;
        return node;
      },

      /* lambda that calculates the bounds for some primitive */
      [&] (const isa::MortonID32Bit& morton) -> BBox3fa {
        return prims[morton.index].bounds();
      },

      /* progress monitor function */
      [&] (size_t dn) { 
        // throw an exception here to cancel the build operation
      },

      morton_src.data(),morton_tmp.data(),prims.size(),2,1024,1,1);

    Node* root = node_bounds.first;
    
    double t1 = getSeconds();

    std::cout << 1000.0f*(t1-t0) << "ms, " << 1E-6*double(N)/(t1-t0) << " Mprims/s, sah = " << root->sah() << " [DONE]" << std::endl;
  }
}
开发者ID:davenso,项目名称:embree,代码行数:82,代码来源:tutorial11_device.cpp

示例15: ToEigenVec

vector_eig EigenUtil::ToEigenVec(const vector_t &mat) {
  return vector_eig::Map(mat.data(), mat.size());
}
开发者ID:cmu-db,项目名称:peloton,代码行数:3,代码来源:eigen_util.cpp


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