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 workspace =
new fftw_complex [( 8 * band * band ) + ( 10 * band )];
57 tableSpaceHelper =
new proshade_double [
static_cast<proshade_unsign
> ( Reduced_Naive_TableSize (
static_cast< int > ( band ),
static_cast< int > ( band ) ) +
58 Reduced_SpharmonicTableSize (
static_cast< int > ( band ),
static_cast< int > ( band ) ) )];
89 rres =
reinterpret_cast<proshade_double*
> ( workspace );
90 ires = rres + ( oDim * oDim );
91 fltres = ires + ( oDim * oDim );
92 scratchpad = fltres + ( oDim / 2 );
117 fftw_iodim howmany_dims[1];
120 int howmany_rank = 1;
122 dims[0].n =
static_cast<int> ( band * 2 );
124 dims[0].os =
static_cast<int> ( band * 2 );
126 howmany_dims[0].n =
static_cast<int> ( band * 2 );
127 howmany_dims[0].is =
static_cast<int> ( band * 2 );
128 howmany_dims[0].os = 1;
131 fftPlan = fftw_plan_guru_split_dft ( rank,
142 dctPlan = fftw_plan_r2r_1d (
static_cast<int> ( band * 2 ),
144 scratchpad +
static_cast<int> ( band * 2 ),
170 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 )
177 delete[] tableSpaceHelper;
182 tableSpaceHelper =
nullptr;
183 tableSpace =
nullptr;
188 fftw_destroy_plan ( dctPlan );
189 fftw_destroy_plan ( fftPlan );
217 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 )
220 proshade_unsign oneDim = band * 2;
223 allocateComputationMemory ( band, inputReal, inputImag, outputReal, outputImag, shWeights, tableSpaceHelper, workspace );
229 tableSpace = SemiNaive_Naive_Pml_Table (
static_cast< int > ( band ),
static_cast< int > ( band ), tableSpaceHelper,
reinterpret_cast<double*
> ( workspace ) );
232 makeweights (
static_cast< int > ( band ), shWeights );
235 initialiseFFTWPlans ( band, fftPlan, dctPlan, inputReal, inputImag, rres, ires, scratchpad );
260 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( oneDim * oneDim ); iter++ )
262 inputReal[iter] = mappedData[iter];
263 inputImag[iter] = 0.0;
267 fftw_execute_split_dft ( fftPlan, inputReal, inputImag, rres, ires ) ;
270 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( oneDim * oneDim ); iter++ )
272 rres[iter] *= normCoeff;
273 ires[iter] *= normCoeff;
300 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 )
303 rdataptr = outputReal;
304 idataptr = outputImag;
305 for ( proshade_unsign bandIter = 0; bandIter < band; bandIter++ )
308 SemiNaiveReduced ( rres + ( bandIter * ( band * 2 ) ),
309 static_cast< int > ( band ),
310 static_cast< int > ( bandIter ),
318 memcpy ( rdataptr, fltres,
sizeof(proshade_double) * ( band - bandIter ) );
319 rdataptr += band - bandIter;
322 SemiNaiveReduced ( ires + ( bandIter * ( band * 2 ) ),
323 static_cast< int > ( band ),
324 static_cast< int > ( bandIter ),
332 memcpy ( idataptr, fltres,
sizeof(proshade_double) * ( band - bandIter ) );
333 idataptr += band - bandIter;
355 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( (band * 2) * (band * 2) ); iter++ )
357 shArray[iter][0] = outputReal[iter];
358 shArray[iter][1] = outputImag[iter];
362 proshade_double powerOne = 1.0;
363 proshade_unsign hlp1 = 0;
364 proshade_unsign hlp2 = 0;
365 for ( proshade_signed order = 1; order < static_cast<proshade_signed> ( band ); order++)
368 for ( proshade_signed bandIter = order; bandIter < static_cast<proshade_signed> ( band ); bandIter++)
370 hlp1 =
static_cast< proshade_unsign
> ( seanindex (
static_cast< int > ( order ),
static_cast< int > ( bandIter ),
static_cast< int > ( band ) ) );
371 hlp2 =
static_cast< proshade_unsign
> ( seanindex (
static_cast< int > ( -order ),
static_cast< int > ( bandIter ),
static_cast< int > ( band ) ) );
373 shArray[hlp2][0] = powerOne *
static_cast<proshade_double
> ( outputReal[hlp1] );
374 shArray[hlp2][1] = -powerOne *
static_cast<proshade_double
> ( outputImag[hlp1] );
397 proshade_double *inputReal =
nullptr, *inputImag =
nullptr, *outputReal =
nullptr, *outputImag =
nullptr;
398 double *shWeights =
nullptr, *tableSpaceHelper =
nullptr;
399 double** tablePml =
nullptr;
400 fftw_complex* workspace =
nullptr;
401 proshade_unsign oneDim =
static_cast<proshade_unsign
> ( band * 2 );
402 proshade_double normCoeff = ( 1.0 / (
static_cast<proshade_double
> ( band * 2 ) ) ) * sqrt( 2.0 * M_PI );
405 for ( proshade_unsign i = 0; i < ( 2 * band * 2 * band); i++ )
412 proshade_double *rres =
nullptr, *ires =
nullptr, *fltres =
nullptr, *scratchpad =
nullptr, *rdataptr =
nullptr, *idataptr =
nullptr;
415 fftw_plan fftPlan =
nullptr;
416 fftw_plan dctPlan =
nullptr;
419 initialiseAllMemory ( band, inputReal, inputImag, outputReal, outputImag, shWeights, tablePml, tableSpaceHelper, workspace,
420 rres, ires, fltres, scratchpad, fftPlan, dctPlan );
426 computeSphericalTransformCoeffs ( band, rdataptr, idataptr, outputReal, outputImag, rres, ires, fltres, scratchpad, tablePml, shWeights, dctPlan );
432 releaseSphericalMemory ( inputReal, inputImag, outputReal, outputImag, tableSpaceHelper, tablePml, shWeights, workspace, fftPlan, dctPlan );