本文整理汇总了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];
}
}
示例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.);
}
}
示例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;
}
示例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());
}
示例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];
}
示例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];
}
示例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;
}
示例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];
}
示例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];
}
示例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];
}
示例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];
}
示例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;
}
示例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;
}
示例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;
}
示例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];
}