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


C++ valarray::resize方法代码示例

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


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

示例1: MakeChiZeroBuffers

	void MakeChiZeroBuffers(valarray<cl_float> & data, valarray<cl_float> & data_err, valarray<cl_float> & model, valarray<cl_float> & output, unsigned int test_size)
	{
		unsigned int n = 2*test_size;
		// Create buffers
		data.resize(n);
		data_err.resize(n);
		model.resize(n);
		output.resize(n);

		valarray<cl_float2> temp = CModel::GenerateUVSpiral_CL(test_size);

		// Set data = model to produce a zero chi result.
		for(int i = 0; i < test_size; i++)
		{
			data[i] = temp[i].s0;
			data[test_size + i] = temp[i].s1;

			model[i] = temp[i].s0;
			model[test_size + i] = temp[i].s1;

			// 1% error on amplitudes, 10% error on phases
			data_err[i] = amp_err * data[i];
			data_err[test_size + i] = phi_err * data[i];
		}
	}
开发者ID:fabienbaron,项目名称:liboi,代码行数:25,代码来源:CRoutine_Chi_test.cpp

示例2: randTest

/**
 * generates a random set of n points in X and Y.
 */
void randTest(unsigned n, valarray<double>& X, valarray<double>& Y) {
    X.resize(n);
    Y.resize(n);
    srand(time(NULL));
	for(unsigned i=0;i<n;i++) {
		X[i]=getRand(1.);
		Y[i]=getRand(1.);
	}
}
开发者ID:AidanDelaney,项目名称:adaptagrams,代码行数:12,代码来源:convex_hull.cpp

示例3: ADvector

bool spk_sode_model<Scalar>::doDataMean_indPar(valarray<double> &F_eta) const
{	size_t Ni = N_[i_];
	F_eta.resize( Ni * m_ );

	assert( i_ < N_.size() );
	size_t j_start = S_[i_];
	size_t j_end   = j_start + Ni + 1;
	vector< AD<double> > F_ad( Ni );
	vector< AD<double> > alpha_ad = ADvector(alpha_);
	vector< AD<double> > eta_ad   = ADvector(eta_);
	vector< AD<double> > t_ad     = ADvector(t_);
	Independent(eta_ad);
	data_mean(F_ad, t_ad, j_start, j_end, alpha_ad, eta_ad);
	ADFun<double> ad_fun(eta_ad, F_ad);
	vector<double> eta( eta_.size() );
	size_t k;
	for(k = 0; k < eta_.size(); k++)
		eta[k] = Value( eta_[k] );
	vector<double> jacobian = ad_fun.Jacobian(eta);
	bool all_zero = true;
	size_t j;
	for(j = 0; j < Ni; j++)
	{	for(k = 0; k < m_; k++)
		{	F_eta[j + k * Ni] = jacobian[j * m_ + k]; 
			all_zero &= (0. == F_eta[j + k * Ni]);
		}
	}
	return ! all_zero;
}
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:29,代码来源:spk_sode_model.hpp

示例4: tworects

/**
 * generates a set of 8 points (actually the vertices of two rectangles)
 * which lineup horizontally.  The expected hull are the lower-left and
 * top-left corners of the left rectangle and the top-right/lower-right
 * corners of the right rectangle.
 */
void tworects(valarray<double>& X, valarray<double>& Y, Hull& expectedHull) {
    const unsigned n=8;
    X.resize(n);
    Y.resize(n);
    X[0]=330.011898, Y[0]=203.250425;
    X[1]=330.011898, Y[1]=237.250425;
    X[2]=276.011898, Y[2]=237.250425;
    X[3]=276.011898, Y[3]=203.250425;
    X[4]=459.998300, Y[4]=203.250425;
    X[5]=459.998300, Y[5]=237.250425;
    X[6]=405.998300, Y[6]=237.250425;
    X[7]=405.998300, Y[7]=203.250425;
    unsigned hull[]={3,4,5,2};
    unsigned m=sizeof(hull)/sizeof(unsigned);
    expectedHull.resize(m);
    copy(hull,hull+m,expectedHull.begin());
}
开发者ID:AidanDelaney,项目名称:adaptagrams,代码行数:23,代码来源:convex_hull.cpp

示例5: doDataMean

    void doDataMean( valarray<double>& ret ) const
    {
      //
      // f(alpha, b) = [ alp(2) + b(2) ]
      //               [ alp(2) + b(2) ]
      //
      ret.resize(_nYi);
      ret[0] = _a[1] + _b[1];
      ret[1] = _a[1] + _b[1];

    }
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:11,代码来源:lambdaTest.cpp

示例6: doIndParVarianceInv

 void doIndParVarianceInv( valarray<double>& ret ) const
 {
   //
   // Dinv = [ alp(1)^-1      0     ]
   //        [     0      alp(1)^-1 ]
   //
   ret.resize(_nB * _nB);
   ret[0] = 1.0 / _a[0];
   ret[1] = 0.0;
   ret[2] = 0.0;
   ret[3] = 1.0 / _a[0];
 }
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:12,代码来源:lambdaTest.cpp

示例7: exp

void spk_sode_model<Scalar>::doDataVariance(valarray<Scalar> &R) const
{	size_t Ni = N_[i_];
	R.resize(Ni * Ni);

	size_t j1, j2;
	for(j1 = 0; j1 < Ni; j1++)
	{	for(j2 = 0; j2 < Ni; j2++)
			R[j1 + j2 * Ni] = 0.;
		R[j1 + j1 * Ni] = exp( alpha_[ell_-1] );
	}
	return;
}
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:12,代码来源:spk_sode_model.hpp

示例8: doDataVariance

 void doDataVariance( valarray<double>& ret ) const
 {
   //
   // R(alp, b) = [ b(1)  0   ]
   //             [  0   b(1) ]
   //
   ret.resize(_nYi * _nYi);
   ret[0] = _b[0];
   ret[1] =  0.0;
   ret[2] =  0.0;
   ret[3] = _b[0];
 }
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:12,代码来源:lambdaTest.cpp

示例9: doDataMean

    void doDataMean( valarray<double>& ret ) const
    {
      //
      // h(x) = [ x(3) ]
      //        [ x(3) ]
      //
      ret.resize(_nY);
      const double *pX = _b.data();

      ret[0] = 1.0 * pX[2];
      ret[1] = 1.0 * pX[2];
    }
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:12,代码来源:elsqTest.cpp

示例10: doIndParVariance

 void doIndParVariance( valarray<double>& ret ) const
 {
   //
   // D = [alp(1)   0   ]
   //     [   0   alp(1)]
   //
   ret.resize(_nB * _nB);
   ret[0] = _a[0];
   ret[1] = 0.0;
   ret[2] = 0.0;
   ret[3] = _a[0];
 }
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:12,代码来源:lambdaTest.cpp

示例11: doDataVarianceInv

 void doDataVarianceInv( valarray<double>& ret ) const
 {
   //
   // R(alp, b)^-1 = [ 1 / b(1)      0   ]
   //                [  0       1 / b(1) ]
   //
   ret.resize(_nYi * _nYi);
   ret[0] = 1.0 / _b[0];
   ret[1] =  0.0;
   ret[2] =  0.0;
   ret[3] = 1.0 / _b[0];
 }
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:12,代码来源:lambdaTest.cpp

示例12: doDataMean_indPar

 bool doDataMean_indPar( valarray<double>& ret ) const
 {
   //
   // f_b   = [ 0  1 ]
   //         [ 0  1 ]
   //
   ret.resize(_nYi * _nB);
   ret[0] = 0.0;
   ret[1] = 0.0;
   ret[2] = 1.0;
   ret[3] = 1.0;
   return true;
 }
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:13,代码来源:lambdaTest.cpp

示例13:

void spk_sode_model<Scalar>::doDataMean(valarray<Scalar> &F) const
{	size_t Ni = N_[i_];
	F.resize(Ni);
	assert( i_ < N_.size() );
	vector<Scalar> F_vec( Ni );
	size_t j_start = S_[i_];
	size_t j_end   = j_start + Ni + 1;
	data_mean(F_vec, t_, j_start, j_end, alpha_, eta_);
	size_t j;
	for(j = 0; j < Ni; j++)
		F[j] = F_vec[j];
	return;
}
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:13,代码来源:spk_sode_model.hpp

示例14: doDataVarianceInv_popPar

 bool doDataVarianceInv_popPar( valarray<double>& ret ) const
 {
   //
   // R^(-1)_alp = [ 0  0 ]
   //              [ 0  0 ]
   //              [ 0  0 ]
   //              [ 0  0 ]
   //
   ret.resize(_nYi * _nYi * _nA);
   for( int i=0; i<_nYi*_nYi*_nA; i++ )
     ret[i] = 0.0;
   return false;
 }
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:13,代码来源:lambdaTest.cpp

示例15: doDataVarianceInv

    void doDataVarianceInv( valarray<double>& ret ) const
    {
      //
      // Q(x)^-1 = [ 1.0 / (2.0*x(1)),   0.0        ]
      //           [ 0.0                 1.0 / x(2) ]
      //
      ret.resize(_nY * _nY);
      const double *x = _b.data();

      ret[0] = 1.0 / (2.0 * x[0]);
      ret[1] = 0.0;
      ret[2] = 0.0;
      ret[3] = 1.0 / x[1];
    }
开发者ID:ernstae,项目名称:sysforpopkinetics,代码行数:14,代码来源:elsqTest.cpp


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