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 =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( 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 ) ) )];
70 for (
size_t iter = 0; iter < static_cast< size_t > ( oneDimmension * oneDimmension ); iter++ )
72 inputReal[iter] = 0.0;
73 inputImag[iter] = 0.0;
74 outputReal[iter] = 0.0;
75 outputImag[iter] = 0.0;
98 rres =
reinterpret_cast<proshade_double*
> ( workspace );
99 ires = rres + ( oDim * oDim );
100 fltres = ires + ( oDim * oDim );
101 scratchpad = fltres + ( oDim / 2 );
126 fftw_iodim howmany_dims[1];
129 int howmany_rank = 1;
131 dims[0].n =
static_cast<int> ( band * 2 );
133 dims[0].os =
static_cast<int> ( band * 2 );
135 howmany_dims[0].n =
static_cast<int> ( band * 2 );
136 howmany_dims[0].is =
static_cast<int> ( band * 2 );
137 howmany_dims[0].os = 1;
140 fftPlan = fftw_plan_guru_split_dft ( rank,
151 dctPlan = fftw_plan_r2r_1d (
static_cast<int> ( band * 2 ),
153 scratchpad +
static_cast<int> ( band * 2 ),
179 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 )
186 delete[] tableSpaceHelper;
188 fftw_free ( workspace );
191 tableSpaceHelper =
nullptr;
192 tableSpace =
nullptr;
197 fftw_destroy_plan ( dctPlan );
198 fftw_destroy_plan ( fftPlan );
226 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 )
229 proshade_unsign oneDim = band * 2;
232 allocateComputationMemory ( band, inputReal, inputImag, outputReal, outputImag, shWeights, tableSpaceHelper, workspace );
238 tableSpace = SemiNaive_Naive_Pml_Table (
static_cast< int > ( band ),
static_cast< int > ( band ), tableSpaceHelper,
reinterpret_cast<double*
> ( workspace ) );
241 makeweights (
static_cast< int > ( band ), shWeights );
244 initialiseFFTWPlans ( band, fftPlan, dctPlan, inputReal, inputImag, rres, ires, scratchpad );
269 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( oneDim * oneDim ); iter++ )
271 inputReal[iter] = mappedData[iter];
272 inputImag[iter] = 0.0;
276 fftw_execute_split_dft ( fftPlan, inputReal, inputImag, rres, ires ) ;
279 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( oneDim * oneDim ); iter++ )
281 rres[iter] *= normCoeff;
282 ires[iter] *= normCoeff;
309 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 )
312 rdataptr = outputReal;
313 idataptr = outputImag;
314 for ( proshade_unsign bandIter = 0; bandIter < band; bandIter++ )
317 SemiNaiveReduced ( rres + ( bandIter * ( band * 2 ) ),
318 static_cast< int > ( band ),
319 static_cast< int > ( bandIter ),
327 memcpy ( rdataptr, fltres,
sizeof(proshade_double) * ( band - bandIter ) );
328 rdataptr += band - bandIter;
331 SemiNaiveReduced ( ires + ( bandIter * ( band * 2 ) ),
332 static_cast< int > ( band ),
333 static_cast< int > ( bandIter ),
341 memcpy ( idataptr, fltres,
sizeof(proshade_double) * ( band - bandIter ) );
342 idataptr += band - bandIter;
364 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( (band * 2) * (band * 2) ); iter++ )
366 shArray[iter][0] = outputReal[iter];
367 shArray[iter][1] = outputImag[iter];
371 proshade_double powerOne = 1.0;
372 proshade_unsign hlp1 = 0;
373 proshade_unsign hlp2 = 0;
374 for ( proshade_signed order = 1; order < static_cast<proshade_signed> ( band ); order++)
377 for ( proshade_signed bandIter = order; bandIter < static_cast<proshade_signed> ( band ); bandIter++)
379 hlp1 =
static_cast< proshade_unsign
> ( seanindex (
static_cast< int > ( order ),
static_cast< int > ( bandIter ),
static_cast< int > ( band ) ) );
380 hlp2 =
static_cast< proshade_unsign
> ( seanindex (
static_cast< int > ( -order ),
static_cast< int > ( bandIter ),
static_cast< int > ( band ) ) );
382 shArray[hlp2][0] = powerOne *
static_cast<proshade_double
> ( outputReal[hlp1] );
383 shArray[hlp2][1] = -powerOne *
static_cast<proshade_double
> ( outputImag[hlp1] );
406 proshade_double *inputReal =
nullptr, *inputImag =
nullptr, *outputReal =
nullptr, *outputImag =
nullptr;
407 double *shWeights =
nullptr, *tableSpaceHelper =
nullptr;
408 double** tablePml =
nullptr;
409 fftw_complex* workspace =
nullptr;
410 proshade_unsign oneDim =
static_cast<proshade_unsign
> ( band * 2 );
411 proshade_double normCoeff = ( 1.0 / (
static_cast<proshade_double
> ( band * 2 ) ) ) * sqrt( 2.0 * M_PI );
414 for ( proshade_unsign i = 0; i < ( 2 * band * 2 * band); i++ )
421 proshade_double *rres =
nullptr, *ires =
nullptr, *fltres =
nullptr, *scratchpad =
nullptr, *rdataptr =
nullptr, *idataptr =
nullptr;
424 fftw_plan fftPlan =
nullptr;
425 fftw_plan dctPlan =
nullptr;
428 initialiseAllMemory ( band, inputReal, inputImag, outputReal, outputImag, shWeights, tablePml, tableSpaceHelper, workspace,
429 rres, ires, fltres, scratchpad, fftPlan, dctPlan );
435 computeSphericalTransformCoeffs ( band, rdataptr, idataptr, outputReal, outputImag, rres, ires, fltres, scratchpad, tablePml, shWeights, dctPlan );
441 releaseSphericalMemory ( inputReal, inputImag, outputReal, outputImag, tableSpaceHelper, tablePml, shWeights, workspace, fftPlan, dctPlan );