本文整理汇总了C++中MultidimArray::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ MultidimArray::clear方法的具体用法?C++ MultidimArray::clear怎么用?C++ MultidimArray::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultidimArray
的用法示例。
在下文中一共展示了MultidimArray::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: produceSideInfo
void FourierProjector::produceSideInfo()
{
// Zero padding
MultidimArray<double> Vpadded;
int paddedDim=(int)(paddingFactor*volumeSize);
// JMRT: TODO: I think it is a very poor design to modify the volume passed
// in the construct, it will be padded anyway, so new memory should be allocated
volume->window(Vpadded,FIRST_XMIPP_INDEX(paddedDim),FIRST_XMIPP_INDEX(paddedDim),FIRST_XMIPP_INDEX(paddedDim),
LAST_XMIPP_INDEX(paddedDim),LAST_XMIPP_INDEX(paddedDim),LAST_XMIPP_INDEX(paddedDim));
volume->clear();
// Make Fourier transform, shift the volume origin to the volume center and center it
MultidimArray< std::complex<double> > Vfourier;
transformer3D.completeFourierTransform(Vpadded,Vfourier);
ShiftFFT(Vfourier, FIRST_XMIPP_INDEX(XSIZE(Vpadded)), FIRST_XMIPP_INDEX(YSIZE(Vpadded)), FIRST_XMIPP_INDEX(ZSIZE(Vpadded)));
CenterFFT(Vfourier,true);
Vfourier.setXmippOrigin();
// Compensate for the Fourier normalization factor
double K=(double)(XSIZE(Vpadded)*XSIZE(Vpadded)*XSIZE(Vpadded))/(double)(volumeSize*volumeSize);
FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(Vfourier)
DIRECT_MULTIDIM_ELEM(Vfourier,n)*=K;
Vpadded.clear();
// Compute Bspline coefficients
if (BSplineDeg==3)
{
MultidimArray< double > VfourierRealAux, VfourierImagAux;
Complex2RealImag(Vfourier, VfourierRealAux, VfourierImagAux);
Vfourier.clear();
produceSplineCoefficients(BSPLINE3,VfourierRealCoefs,VfourierRealAux);
produceSplineCoefficients(BSPLINE3,VfourierImagCoefs,VfourierImagAux);
//VfourierRealAux.clear();
//VfourierImagAux.clear();
}
else
Complex2RealImag(Vfourier, VfourierRealCoefs, VfourierImagCoefs);
// Allocate memory for the 2D Fourier transform
projection().initZeros(volumeSize,volumeSize);
projection().setXmippOrigin();
transformer2D.FourierTransform(projection(),projectionFourier,false);
// Calculate phase shift terms
phaseShiftImgA.initZeros(projectionFourier);
phaseShiftImgB.initZeros(projectionFourier);
double shift=-FIRST_XMIPP_INDEX(volumeSize);
double xxshift = -2 * PI * shift / volumeSize;
for (size_t i=0; i<YSIZE(projectionFourier); ++i)
{
double phasey=(double)(i) * xxshift;
for (size_t j=0; j<XSIZE(projectionFourier); ++j)
{
// Phase shift to move the origin of the image to the corner
double dotp = (double)(j) * xxshift + phasey;
sincos(dotp,&DIRECT_A2D_ELEM(phaseShiftImgB,i,j),&DIRECT_A2D_ELEM(phaseShiftImgA,i,j));
}
}
}
示例2: produceSideInfo
void FourierProjector::produceSideInfo()
{
// Zero padding
MultidimArray<double> Vpadded;
int paddedDim=(int)(paddingFactor*volumeSize);
volume->window(Vpadded,FIRST_XMIPP_INDEX(paddedDim),FIRST_XMIPP_INDEX(paddedDim),FIRST_XMIPP_INDEX(paddedDim),
LAST_XMIPP_INDEX(paddedDim),LAST_XMIPP_INDEX(paddedDim),LAST_XMIPP_INDEX(paddedDim));
volume->clear();
// Make Fourier transform, shift the volume origin to the volume center and center it
MultidimArray< std::complex<double> > Vfourier;
transformer3D.completeFourierTransform(Vpadded,Vfourier);
ShiftFFT(Vfourier, FIRST_XMIPP_INDEX(XSIZE(Vpadded)), FIRST_XMIPP_INDEX(YSIZE(Vpadded)), FIRST_XMIPP_INDEX(ZSIZE(Vpadded)));
CenterFFT(Vfourier,true);
Vfourier.setXmippOrigin();
// Compensate for the Fourier normalization factor
double K=(double)(XSIZE(Vpadded)*XSIZE(Vpadded)*XSIZE(Vpadded))/(double)(volumeSize*volumeSize);
FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(Vfourier)
DIRECT_MULTIDIM_ELEM(Vfourier,n)*=K;
Vpadded.clear();
// Compute Bspline coefficients
if (BSplineDeg==3)
{
MultidimArray< double > VfourierRealAux, VfourierImagAux;
Complex2RealImag(Vfourier, VfourierRealAux, VfourierImagAux);
Vfourier.clear();
produceSplineCoefficients(BSPLINE3,VfourierRealCoefs,VfourierRealAux);
produceSplineCoefficients(BSPLINE3,VfourierImagCoefs,VfourierImagAux);
//VfourierRealAux.clear();
//VfourierImagAux.clear();
}
else
Complex2RealImag(Vfourier, VfourierRealCoefs, VfourierImagCoefs);
// Allocate memory for the 2D Fourier transform
projection().initZeros(volumeSize,volumeSize);
projection().setXmippOrigin();
transformer2D.FourierTransform(projection(),projectionFourier,false);
}
示例3: computeFourierTransformMap
// Fill data array with oversampled Fourier transform, and calculate its power spectrum
void Projector::computeFourierTransformMap(MultidimArray<DOUBLE> &vol_in, MultidimArray<DOUBLE> &power_spectrum, int current_size, int nr_threads, bool do_gridding)
{
MultidimArray<DOUBLE> Mpad;
MultidimArray<Complex > Faux;
FourierTransformer transformer;
// DEBUGGING: multi-threaded FFTWs are giving me a headache?
// For a long while: switch them off!
//transformer.setThreadsNumber(nr_threads);
DOUBLE normfft;
// Size of padded real-space volume
int padoridim = padding_factor * ori_size;
// Initialize data array of the oversampled transform
ref_dim = vol_in.getDim();
// Make Mpad
switch (ref_dim)
{
case 2:
Mpad.initZeros(padoridim, padoridim);
normfft = (DOUBLE)(padding_factor * padding_factor);
break;
case 3:
Mpad.initZeros(padoridim, padoridim, padoridim);
if (data_dim ==3)
normfft = (DOUBLE)(padding_factor * padding_factor * padding_factor);
else
normfft = (DOUBLE)(padding_factor * padding_factor * padding_factor * ori_size);
break;
default:
REPORT_ERROR("Projector::computeFourierTransformMap%%ERROR: Dimension of the data array should be 2 or 3");
}
// First do a gridding pre-correction on the real-space map:
// Divide by the inverse Fourier transform of the interpolator in Fourier-space
// 10feb11: at least in 2D case, this seems to be the wrong thing to do!!!
// TODO: check what is best for subtomo!
if (do_gridding)// && data_dim != 3)
griddingCorrect(vol_in);
// Pad translated map with zeros
vol_in.setXmippOrigin();
Mpad.setXmippOrigin();
FOR_ALL_ELEMENTS_IN_ARRAY3D(vol_in) // This will also work for 2D
A3D_ELEM(Mpad, k, i, j) = A3D_ELEM(vol_in, k, i, j);
// Translate padded map to put origin of FT in the center
CenterFFT(Mpad, true);
// Calculate the oversampled Fourier transform
transformer.FourierTransform(Mpad, Faux, false);
// Free memory: Mpad no longer needed
Mpad.clear();
// Resize data array to the right size and initialise to zero
initZeros(current_size);
// Fill data only for those points with distance to origin less than max_r
// (other points will be zero because of initZeros() call above
// Also calculate radial power spectrum
power_spectrum.initZeros(ori_size / 2 + 1);
MultidimArray<DOUBLE> counter(power_spectrum);
counter.initZeros();
int max_r2 = r_max * r_max * padding_factor * padding_factor;
FOR_ALL_ELEMENTS_IN_FFTW_TRANSFORM(Faux) // This will also work for 2D
{
int r2 = kp*kp + ip*ip + jp*jp;
// The Fourier Transforms are all "normalised" for 2D transforms of size = ori_size x ori_size
if (r2 <= max_r2)
{
// Set data array
A3D_ELEM(data, kp, ip, jp) = DIRECT_A3D_ELEM(Faux, k, i, j) * normfft;
// Calculate power spectrum
int ires = ROUND( sqrt((DOUBLE)r2) / padding_factor );
// Factor two because of two-dimensionality of the complex plane
DIRECT_A1D_ELEM(power_spectrum, ires) += norm(A3D_ELEM(data, kp, ip, jp)) / 2.;
DIRECT_A1D_ELEM(counter, ires) += 1.;
}
}
// Calculate radial average of power spectrum
FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY1D(power_spectrum)
{
if (DIRECT_A1D_ELEM(counter, i) < 1.)
DIRECT_A1D_ELEM(power_spectrum, i) = 0.;
else
DIRECT_A1D_ELEM(power_spectrum, i) /= DIRECT_A1D_ELEM(counter, i);
}
transformer.cleanup();
}