本文整理汇总了C++中ColumnVector::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ ColumnVector::resize方法的具体用法?C++ ColumnVector::resize怎么用?C++ ColumnVector::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColumnVector
的用法示例。
在下文中一共展示了ColumnVector::resize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RealFFT
void RealFFT(const ColumnVector& U, ColumnVector& X, ColumnVector& Y)
{
// Fourier transform of a real series
Tracer trace("RealFFT");
REPORT
const int n = U.Nrows(); // length of arrays
const int n2 = n / 2;
if (n != 2 * n2)
Throw(ProgramException("Vector length not multiple of 2", U));
ColumnVector A(n2), B(n2);
Real* a = A.Store(); Real* b = B.Store(); Real* u = U.Store(); int i = n2;
while (i--) { *a++ = *u++; *b++ = *u++; }
FFT(A,B,A,B);
int n21 = n2 + 1;
X.resize(n21); Y.resize(n21);
i = n2 - 1;
a = A.Store(); b = B.Store(); // first els of A and B
Real* an = a + i; Real* bn = b + i; // last els of A and B
Real* x = X.Store(); Real* y = Y.Store(); // first els of X and Y
Real* xn = x + n2; Real* yn = y + n2; // last els of X and Y
*x++ = *a + *b; *y++ = 0.0; // first complex element
*xn-- = *a++ - *b++; *yn-- = 0.0; // last complex element
int j = -1; i = n2/2;
while (i--)
{
Real c,s; cossin(j--,n,c,s);
Real am = *a - *an; Real ap = *a++ + *an--;
Real bm = *b - *bn; Real bp = *b++ + *bn--;
Real samcbp = s * am + c * bp; Real sbpcam = s * bp - c * am;
*x++ = 0.5 * ( ap + samcbp); *y++ = 0.5 * ( bm + sbpcam);
*xn-- = 0.5 * ( ap - samcbp); *yn-- = 0.5 * (-bm + sbpcam);
}
}
示例2: Helmert
// Multiply X by n-1 x n matrix to give n-1 contrasts
// Return a ColumnVector
ReturnMatrix Helmert(const ColumnVector& X, bool full)
{
REPORT
Tracer et("Helmert * CV");
int n = X.nrows();
if (n == 0) Throw(ProgramException("X Vector of length 0", X));
Real sum = 0.0; ColumnVector Y;
if (full) Y.resize(n); else Y.resize(n-1);
for (int i = 1; i < n; ++i)
{ sum += X(i); Y(i) = (i * X(i+1) - sum) / sqrt((Real)i * (i+1)); }
if (full) { sum += X(n); Y(n) = sum / sqrt((Real)n); }
Y.release(); return Y.for_return();
}
示例3: RealFFTI
void RealFFTI(const ColumnVector& A, const ColumnVector& B, ColumnVector& U)
{
// inverse of a Fourier transform of a real series
Tracer trace("RealFFTI");
REPORT
const int n21 = A.Nrows(); // length of arrays
if (n21 != B.Nrows() || n21 == 0)
Throw(ProgramException("Vector lengths unequal or zero", A, B));
const int n2 = n21 - 1; const int n = 2 * n2; int i = n2 - 1;
ColumnVector X(n2), Y(n2);
Real* a = A.Store(); Real* b = B.Store(); // first els of A and B
Real* an = a + n2; Real* bn = b + n2; // last els of A and B
Real* x = X.Store(); Real* y = Y.Store(); // first els of X and Y
Real* xn = x + i; Real* yn = y + i; // last els of X and Y
Real hn = 0.5 / n2;
*x++ = hn * (*a + *an); *y++ = - hn * (*a - *an);
a++; an--; b++; bn--;
int j = -1; i = n2/2;
while (i--)
{
Real c,s; cossin(j--,n,c,s);
Real am = *a - *an; Real ap = *a++ + *an--;
Real bm = *b - *bn; Real bp = *b++ + *bn--;
Real samcbp = s * am - c * bp; Real sbpcam = s * bp + c * am;
*x++ = hn * ( ap + samcbp); *y++ = - hn * ( bm + sbpcam);
*xn-- = hn * ( ap - samcbp); *yn-- = - hn * (-bm + sbpcam);
}
FFT(X,Y,X,Y); // have done inverting elsewhere
U.resize(n); i = n2;
x = X.Store(); y = Y.Store(); Real* u = U.Store();
while (i--) { *u++ = *x++; *u++ = - *y++; }
}
示例4: allocate
/*
* helper function to allocate all the memory necessary to respresent the responsabilities.
* @param N_meas number of points
* @param N_comp number of clusters
*/
void allocate(int N_meas, int N_comp)
{
R.assign(N_meas,ColumnVector(N_comp));
responsibleCluster.assign(N_meas,-1);
sumR.resize(N_meas);
N.resize(N_comp);
}
示例5: FFT
void FFT(const ColumnVector& U, const ColumnVector& V,
ColumnVector& X, ColumnVector& Y)
{
// from Carl de Boor (1980), Siam J Sci Stat Comput, 1 173-8
// but first try Sande and Gentleman
Tracer trace("FFT");
REPORT
const int n = U.Nrows(); // length of arrays
if (n != V.Nrows() || n == 0)
Throw(ProgramException("Vector lengths unequal or zero", U, V));
if (n == 1) { REPORT X = U; Y = V; return; }
// see if we can use the newfft routine
if (!FFT_Controller::OnlyOldFFT && FFT_Controller::CanFactor(n))
{
REPORT
X = U; Y = V;
if ( FFT_Controller::ar_1d_ft(n,X.Store(),Y.Store()) ) return;
}
ColumnVector B = V;
ColumnVector A = U;
X.resize(n); Y.resize(n);
const int nextmx = 8;
int prime[8] = { 2,3,5,7,11,13,17,19 };
int after = 1; int before = n; int next = 0; bool inzee = true;
int now = 0; int b1; // initialised to keep gnu happy
do
{
for (;;)
{
if (next < nextmx) { REPORT now = prime[next]; }
b1 = before / now; if (b1 * now == before) { REPORT break; }
next++; now += 2;
}
before = b1;
if (inzee) { REPORT fftstep(A, B, X, Y, after, now, before); }
else { REPORT fftstep(X, Y, A, B, after, now, before); }
inzee = !inzee; after *= now;
}
示例6: AnalyticConditionalGaussianAdditiveNoise
LinearAnalyticConditionalGaussian::LinearAnalyticConditionalGaussian(const vector<Matrix> & ratio,
const Gaussian& additiveNoise)
: AnalyticConditionalGaussianAdditiveNoise(additiveNoise,ratio.size())
, _ratio(ratio)
, _mean_temp(DimensionGet())
, _arg(DimensionGet())
{
// Initialise ConditionalArguments to 0
ColumnVector arg;
for (unsigned int i=0; i < NumConditionalArgumentsGet() ; i++)
{
arg.resize(_ratio[i].columns());
arg = 0.0;
ConditionalArgumentSet(i,arg);
}
}
示例7: feedForward
ColumnVector
MLP<Model, Tuple>::predict(
const model_type &model,
const independent_variables_type &x,
const bool get_class) {
std::vector<ColumnVector> net, o;
feedForward(model, x, net, o);
ColumnVector output = o.back();
if(get_class){ // Return a length 1 array with the predicted index
int max_idx;
output.maxCoeff(&max_idx);
output.resize(1);
output[0] = (double) max_idx;
}
return output;
}