42 proshade_unsign oneDimmension = 2 * band;
45 inputReal =
new proshade_double [oneDimmension * oneDimmension];
46 inputImag =
new proshade_double [oneDimmension * oneDimmension];
49 outputReal =
new proshade_double [oneDimmension * oneDimmension];
50 outputImag =
new proshade_double [oneDimmension * oneDimmension];
53 shWeights =
new proshade_double [band * 4];
54 tableSpaceHelper =
new proshade_double [
static_cast<proshade_unsign
> ( Reduced_Naive_TableSize ( band, band ) +
55 Reduced_SpharmonicTableSize ( band, band ) )];
56 workspace =
new fftw_complex [( 8 * band * band ) + ( 10 * band )];
87 rres =
reinterpret_cast<proshade_double*
> ( workspace );
88 ires = rres + ( oDim * oDim );
89 fltres = ires + ( oDim * oDim );
90 scratchpad = fltres + ( oDim / 2 );
115 fftw_iodim howmany_dims[1];
118 int howmany_rank = 1;
120 dims[0].n =
static_cast<int> ( band * 2 );
122 dims[0].os =
static_cast<int> ( band * 2 );
124 howmany_dims[0].n =
static_cast<int> ( band * 2 );
125 howmany_dims[0].is =
static_cast<int> ( band * 2 );
126 howmany_dims[0].os = 1;
129 fftPlan = fftw_plan_guru_split_dft ( rank,
140 dctPlan = fftw_plan_r2r_1d (
static_cast<int> ( band * 2 ),
142 scratchpad +
static_cast<int> ( band * 2 ),
168 void ProSHADE_internal_sphericalHarmonics::releaseSphericalMemory ( proshade_double*& inputReal, proshade_double*& inputImag, proshade_double*& outputReal, proshade_double*& outputImag,
double*& tableSpaceHelper,
double**& tableSpace,
double*& shWeights, fftw_complex*& workspace, fftw_plan& fftPlan, fftw_plan& dctPlan )
176 delete[] tableSpaceHelper;
180 fftw_free ( workspace );
182 tableSpaceHelper = NULL;
187 fftw_destroy_plan ( dctPlan );
188 fftw_destroy_plan ( fftPlan );
216 void ProSHADE_internal_sphericalHarmonics::initialiseAllMemory ( proshade_unsign band, proshade_double*& inputReal, proshade_double*& inputImag, proshade_double*& outputReal, proshade_double*& outputImag,
double*& shWeights,
double**& tableSpace,
double*& tableSpaceHelper, fftw_complex*& workspace, proshade_double*& rres, proshade_double*& ires, proshade_double*& fltres, proshade_double*& scratchpad, fftw_plan& fftPlan, fftw_plan& dctPlan )
219 proshade_unsign oneDim = band * 2;
222 allocateComputationMemory ( band, inputReal, inputImag, outputReal, outputImag, shWeights, tableSpaceHelper, workspace );
228 tableSpace = SemiNaive_Naive_Pml_Table ( band, band, tableSpaceHelper,
reinterpret_cast<double*
> ( workspace ) );
231 makeweights ( band, shWeights );
234 initialiseFFTWPlans ( band, fftPlan, dctPlan, inputReal, inputImag, rres, ires, scratchpad );
259 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( oneDim * oneDim ); iter++ )
261 inputReal[iter] = mappedData[iter];
262 inputImag[iter] = 0.0;
266 fftw_execute_split_dft ( fftPlan, inputReal, inputImag, rres, ires ) ;
269 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( oneDim * oneDim ); iter++ )
271 rres[iter] *= normCoeff;
272 ires[iter] *= normCoeff;
299 void ProSHADE_internal_sphericalHarmonics::computeSphericalTransformCoeffs ( proshade_unsign band, proshade_double*& rdataptr, proshade_double*& idataptr, proshade_double*& outputReal, proshade_double*& outputImag, proshade_double*& rres, proshade_double*& ires, proshade_double*& fltres, proshade_double*& scratchpad,
double**& tablePml,
double*& shWeights, fftw_plan& dctPlan )
302 rdataptr = outputReal;
303 idataptr = outputImag;
304 for ( proshade_unsign bandIter = 0; bandIter < band; bandIter++ )
307 SemiNaiveReduced ( rres + ( bandIter * ( band * 2 ) ),
317 memcpy ( rdataptr, fltres,
sizeof(proshade_double) * ( band - bandIter ) );
318 rdataptr += band - bandIter;
321 SemiNaiveReduced ( ires + ( bandIter * ( band * 2 ) ),
331 memcpy ( idataptr, fltres,
sizeof(proshade_double) * ( band - bandIter ) );
332 idataptr += band - bandIter;
354 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( (band * 2) * (band * 2) ); iter++ )
356 shArray[iter][0] = outputReal[iter];
357 shArray[iter][1] = outputImag[iter];
361 proshade_double powerOne = 1.0;
362 proshade_unsign hlp1 = 0;
363 proshade_unsign hlp2 = 0;
364 for ( proshade_signed order = 1; order < static_cast<proshade_signed> ( band ); order++)
367 for ( proshade_signed bandIter = order; bandIter < static_cast<proshade_signed> ( band ); bandIter++)
369 hlp1 = seanindex ( order, bandIter, band );
370 hlp2 = seanindex ( -order, bandIter, band );
372 shArray[hlp2][0] = powerOne *
static_cast<proshade_double
> ( outputReal[hlp1] );
373 shArray[hlp2][1] = -powerOne *
static_cast<proshade_double
> ( outputImag[hlp1] );
396 proshade_double *inputReal = NULL, *inputImag = NULL, *outputReal = NULL, *outputImag = NULL;
397 double *shWeights = NULL, *tableSpaceHelper = NULL;
398 double** tablePml = NULL;
399 fftw_complex* workspace = NULL;
400 proshade_unsign oneDim =
static_cast<proshade_unsign
> ( band * 2 );
401 proshade_double normCoeff = ( 1.0 / (
static_cast<proshade_double
> ( band * 2 ) ) ) * sqrt( 2.0 * M_PI );
404 for ( proshade_unsign i = 0; i < ( 2 * band * 2 * band); i++ )
411 proshade_double *rres = NULL, *ires = NULL, *fltres = NULL, *scratchpad = NULL, *rdataptr = NULL, *idataptr = NULL;
414 fftw_plan fftPlan = NULL;
415 fftw_plan dctPlan = NULL;
418 initialiseAllMemory ( band, inputReal, inputImag, outputReal, outputImag, shWeights, tablePml, tableSpaceHelper, workspace,
419 rres, ires, fltres, scratchpad, fftPlan, dctPlan );
425 computeSphericalTransformCoeffs ( band, rdataptr, idataptr, outputReal, outputImag, rres, ires, fltres, scratchpad, tablePml, shWeights, dctPlan );
431 releaseSphericalMemory ( inputReal, inputImag, outputReal, outputImag, tableSpaceHelper, tablePml, shWeights, workspace, fftPlan, dctPlan );