本文整理汇总了C++中MDArray::getBox方法的典型用法代码示例。如果您正苦于以下问题:C++ MDArray::getBox方法的具体用法?C++ MDArray::getBox怎么用?C++ MDArray::getBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDArray
的用法示例。
在下文中一共展示了MDArray::getBox方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve
void PoissonSolver::solve(MDArray<Real>& a_Rhs) const
{
//create a contructor
Box bx = a_Rhs.getBox();
MDArray<complex<double> > fftwForward(bx);
MDArray<complex<double> > fourierCoef(bx);
double h = 1/m_M;
for (int k = 0; k < bx.sizeOf();k++)
{
fftwForward[k] = complex<double>(a_Rhs[k],0.);
}
FFTMD fftmd = FFTMD(m_fft1dptr);
fftmd.forwardCC(fftwForward);
for (int i= 0; i<m_M; i++)
{
for (int j= 0; j<m_M; j++)
{
int index[2] ={i,j};
if(i ==0 && j ==0)
{
fourierCoef[index] =complex<double>(0,0);
}
else
{
complex <double> div(2*cos(2*M_PI*i*h) - 2*cos(2*M_PI*j*h - 4),0);
fourierCoef[index] = fftwForward[index]/div;
}
}
}
fftmd.inverseCC(fourierCoef);
for (int k= 0; k < bx.sizeOf(); k++)
{
a_Rhs[k] = real(fourierCoef[k])/m_N;
}
}
示例2: solve
void PoissonSolver::solve(MDArray<Real>& a_Rhs) const {
//create a contructor
Box bx = a_Rhs.getBox();
MDArray<complex<double> > fftwForward(bx);
MDArray<complex<double> > fourierCoef(bx);
double h = 1.0/((double)m_N);
h = .0001;
//double h = 1/m_N; // integer division, becomes 0.0 in the end!
for (int k = 0; k < bx.sizeOf(); k++) {
fftwForward[k] = complex<double>(a_Rhs[k], 0.0);
}
FFTMD fftmd = FFTMD(m_fft1dptr);
fftmd.forwardCC(fftwForward);
for (int k=0; k<bx.sizeOf(); k++) {
int index[2];
bx.tupleIndex(k,index);
int i = index[0];
int j = index[1];
if (k == 0) {
fourierCoef[index] = complex<double>(0.0,0.0);
} else {
complex<double> div((2.0*cos(2.0*M_PI*((double)i)*h) - 2.0*cos(2.0*M_PI*((double)j)*h) - 4.0)/h/h,0.0);
fourierCoef[index] =fftwForward[index]/div;
}
}
fftmd.inverseCC(fourierCoef);
for (int k=0; k<bx.sizeOf(); k++) {
a_Rhs[k] = real(fourierCoef[k]) * h * h;
}
}