本文整理汇总了C++中std::valarray::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ valarray::resize方法的具体用法?C++ valarray::resize怎么用?C++ valarray::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::valarray
的用法示例。
在下文中一共展示了valarray::resize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
NLDRNeighborList& operator=(const NLDRNeighborList& nn)
{
if (&nn==this) return *this;
nlist.resize(nn.nlist.size()); nlist=nn.nlist;
npoint.resize(nn.npoint.size()); npoint=nn.npoint;
opts=nn.opts;
}
示例2: RandomTestOctic
void RandomTestOctic(std::valarray<T> & coefficients, std::valarray<T> & solutions)
{
solutions.resize(8);
for (int ii=0; ii<8; ii++)
solutions[ii] = Random<T>::Generate();
const T& s0 = solutions[0];
const T& s1 = solutions[1];
const T& s2 = solutions[2];
const T& s3 = solutions[3];
const T& s4 = solutions[4];
const T& s5 = solutions[5];
const T& s6 = solutions[6];
const T& s7 = solutions[7];
coefficients.resize(8); // omitting the 1, so it's monic
coefficients[0] = s0*s1*s2*s3*s4*s5*s6*s7;
coefficients[1] = - s7*(s6*(s5*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) + s0*s1*s2*s3*s4) + s0*s1*s2*s3*s4*s5) - s0*s1*s2*s3*s4*s5*s6;
coefficients[2] = s7*(s6*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s5*(s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) + s5*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) + s0*s1*s2*s3*s4) + s6*(s5*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) + s0*s1*s2*s3*s4) + s0*s1*s2*s3*s4*s5;
coefficients[3] = - s7*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s5*(s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s6*(s5*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) + s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) - s6*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s5*(s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) - s5*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) - s0*s1*s2*s3*s4;
coefficients[4] = s7*(s5*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) + s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s6*(s2*(s0 + s1) + s0*s1 + s5*(s0 + s1 + s2 + s3 + s4) + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s5*(s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s6*(s5*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) + s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3;
coefficients[5] = - s5*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) - s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) - s7*(s2*(s0 + s1) + s0*s1 + s5*(s0 + s1 + s2 + s3 + s4) + s3*(s0 + s1 + s2) + s6*(s0 + s1 + s2 + s3 + s4 + s5) + s4*(s0 + s1 + s2 + s3)) - s6*(s2*(s0 + s1) + s0*s1 + s5*(s0 + s1 + s2 + s3 + s4) + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) - s3*(s2*(s0 + s1) + s0*s1) - s0*s1*s2;
coefficients[6] = s2*(s0 + s1) + s0*s1 + s7*(s0 + s1 + s2 + s3 + s4 + s5 + s6) + s5*(s0 + s1 + s2 + s3 + s4) + s3*(s0 + s1 + s2) + s6*(s0 + s1 + s2 + s3 + s4 + s5) + s4*(s0 + s1 + s2 + s3);
coefficients[7] = - s0 - s1 - s2 - s3 - s4 - s5 - s6 - s7;
}
示例3: sizeof
AsebaNode()
{
// create VM
vm.nodeId = 0;
bytecode.resize(512);
vm.bytecode = &bytecode[0];
vm.bytecodeSize = bytecode.size();
stack.resize(64);
vm.stack = &stack[0];
vm.stackSize = stack.size();
vm.variables = reinterpret_cast<sint16 *>(&variables);
vm.variablesSize = sizeof(variables) / sizeof(sint16);
AsebaVMInit(&vm);
// fill description accordingly
d.name = L"testvm";
d.protocolVersion = ASEBA_PROTOCOL_VERSION;
d.bytecodeSize = vm.bytecodeSize;
d.variablesSize = vm.variablesSize;
d.stackSize = vm.stackSize;
/*d.namedVariables.push_back(TargetDescription::NamedVariable("id", 1));
d.namedVariables.push_back(TargetDescription::NamedVariable("source", 1));
d.namedVariables.push_back(TargetDescription::NamedVariable("args", 32));*/
}
示例4: rfsum
void rfsum(const std::valarray<tblapack::complex>& p1, const std::valarray<tblapack::complex>& q1,
const std::valarray<tblapack::complex>& p2, const std::valarray<tblapack::complex>& q2,
std::valarray<tblapack::complex>& p, std::valarray<tblapack::complex>& q)
{
//given the coefficients of the polynomials in P1/Q1+P2/Q2 computes the coefficients
//in the polynomials in P/Q (the reduced sum). NO SIMPLIFICATIONS ARE DONE (OF COURSE)
q.resize(q1.size()+q2.size()-1); q=0.;
for (int i=0; i<q1.size(); i++) for (int j=0; j<q2.size(); j++) q[i+j]+=q1[i]*q2[j];
if (p1.size()==0 || (p2.size()>0 && q1.size()+p2.size()>p1.size()+q2.size())) p.resize(q1.size()+p2.size()-1);
else if (p1.size()>0) p.resize(p1.size()+q2.size()-1);
else p.resize(0);
for (int i=0; i<q1.size(); i++) for (int j=0; j<p2.size(); j++) p[i+j]+=q1[i]*p2[j];
for (int i=0; i<q2.size(); i++) for (int j=0; j<p1.size(); j++) p[i+j]+=q2[i]*p1[j];
}
示例5: set_points
void set_points(const FMatrix<double>& nP, const FMatrix<double>& np, const std::valarray<double>& nw=std::valarray<double>(0))
{
if ((n=nP.rows())<1 || (D=nP.cols())<1) ERROR("Hi-dimensional array has inconsistent sizes.");
if (np.rows()!=n || (d=np.cols())<1 || d>D) ERROR("Low-dimensional array has inconsistent sizes.");
P=nP; p=np; ftainted=true;
w.resize(n); if (nw.size()==0) w=1.0; else w=nw;
}
示例6: diff
void diff(const std::valarray<double>& a, const std::valarray<double>& b, std::valarray<double>& c) const
{
#ifdef DEBUG
if (a.size()!=b.size()) ERROR("Vector size mismatch in distance.");
#endif
c.resize(a.size()); pdiff(&a[0], &b[0], &c[0], a.size());
}
示例7: sizeof
AsebaNode()
{
// setup variables
vm.nodeId = 1;
bytecode.resize(512);
vm.bytecode = &bytecode[0];
vm.bytecodeSize = bytecode.size();
stack.resize(64);
vm.stack = &stack[0];
vm.stackSize = stack.size();
vm.variables = reinterpret_cast<sint16 *>(&variables);
vm.variablesSize = sizeof(variables) / sizeof(sint16);
}
示例8: halve
void halve(std:: valarray<float> &imap, int inx, int iny, std:: valarray<float> &omap) {
if(inx % 2) {
// it is odd
std:: cout << " nx of the input map is odd " << std:: endl;
std:: cout << " I cannot process ... I will STOP here!!! " << std:: endl;
exit(1);
}
if(iny % 2) {
// it is odd
std:: cout << " ny of the input map is odd " << std:: endl;
std:: cout << " I cannot process ... I will STOP here!!! " << std:: endl;
exit(1);
}
int nx = inx/2;
int ny = iny/2;
omap.resize(nx*ny);
for(int i=0; i<nx; i++) for(int j=0; j<ny; j++) {
omap[i+nx*j] = (imap[(2*i)+inx*(2*j)] +
imap[(2*i+1)+inx*(2*j)] +
imap[(2*i)+inx*(2*j+1)] +
imap[(2*i+1)+inx*(2*j+1)])/4;
}
}
示例9: resize
inline
void DMatrix::resize(size_type rows, size_type cols, value_type val)
{
v_.resize(rows*cols,val);
v_ = val;
rows_ = rows;
}
示例10: find_histogram
int find_histogram(const std::valarray<T>& vol, std::valarray<int>& hist, unsigned int bins,
T& min, T& max)
{
// size and zero the histogram
hist.resize(bins); hist = 0;
if(min == max) { min = vol.min(); max = vol.max(); }
int validsize(-1);
if(min != max) {
double fA = bins / double(max - min);
double fB = (bins * -min) / double(max - min);
validsize = 0;
for(unsigned int i = 0; i < vol.size(); ++i) {
unsigned int idx = unsigned(fA * vol[i] + fB);
++hist[ std::max(unsigned(0), std::min(idx, bins - 1)) ];
++validsize;
}
}
return validsize;
}
示例11:
frame& operator=(const frame& nf)
{
if (&nf==this) return *this;
nat=nf.nat; comment=nf.comment;
ats.resize(nf.ats.size()); ats=nf.ats;
return *this;
}
示例12: get_evA
void GLEABC::get_evA(std::valarray<tblapack::complex>& ra)
{
if (!fr_eva)
{
EigenDecomposition(A, O, O1, a); fr_eva=true;
}
ra.resize(a.size()); ra=a;
}
示例13: ode
void KinematicCarModel::ode(const ob::State *state, const oc::Control *control, std::valarray<double> &dstate) const
{
const double *u = control->as<oc::RealVectorControlSpace::ControlType>()->values;
const double theta = state->as<ob::SE2StateSpace::StateType>()->getYaw();
dstate.resize(3);
dstate[0] = u[0] * cos(theta);
dstate[1] = u[0] * sin(theta);
dstate[2] = u[0] * tan(u[1]) / carLength_;
}
示例14: ar
//! Loading for std::valarray arithmetic types, using binary serialization, if supported
template <class Archive, class T> inline
typename std::enable_if<traits::is_input_serializable<BinaryData<T>, Archive>::value
&& std::is_arithmetic<T>::value, void>::type
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::valarray<T> & valarray )
{
size_type valarraySize;
ar( make_size_tag( valarraySize ) );
valarray.resize( static_cast<std::size_t>( valarraySize ) );
ar( binary_data( &valarray[0], static_cast<std::size_t>( valarraySize ) * sizeof(T) ) );
}
示例15:
//! Loading for std::valarray all other types
template<class Archive, class T> inline typename std::enable_if<
!traits::is_input_serializable<BinaryData<T>, Archive>::value
|| !std::is_arithmetic<T>::value, void>::type CEREAL_LOAD_FUNCTION_NAME(
Archive & ar, std::valarray<T> & valarray) {
size_type valarraySize;
ar(make_size_tag(valarraySize));
valarray.resize(static_cast<size_t>(valarraySize));
for (auto && v : valarray)
ar(v);
}