37 for ( proshade_unsign bwIt = 0; bwIt < this->
maxShellBand; bwIt++ )
43 for ( proshade_unsign shIt = 0; shIt < this->
noSpheres; shIt++ )
65 this->allocateRRPMemory ( );
68 proshade_double descValR = 0.0;
69 proshade_unsign arrPos1, arrPos2;
70 for ( proshade_unsign band = 0; band < this->maxShellBand; band++ )
73 for ( proshade_unsign shell1 = 0; shell1 < this->noSpheres; shell1++ )
78 for ( proshade_unsign shell2 = 0; shell2 < this->noSpheres; shell2++ )
80 this->rrpMatrices[band][shell1][shell2] = 0.0;
81 this->rrpMatrices[band][shell2][shell1] = 0.0;
86 for ( proshade_unsign shell2 = 0; shell2 < this->noSpheres; shell2++ )
89 if ( shell1 > shell2 ) {
continue; }
94 this->rrpMatrices[band][shell1][shell2] = 0.0;
95 this->rrpMatrices[band][shell2][shell1] = 0.0;
103 for ( proshade_unsign order = 0; order < static_cast< proshade_unsign > ( ( 2 * band ) + 1 ); order++ )
105 arrPos1 =
static_cast< proshade_unsign
> ( seanindex (
static_cast< int > ( order ) -
static_cast<int > ( band ),
106 static_cast< int > ( band ),
static_cast< int > ( this->spheres[shell1]->getLocalBandwidth() ) ) );
107 arrPos2 =
static_cast< proshade_unsign
> ( seanindex (
static_cast< int > ( order ) -
static_cast< int > ( band ),
108 static_cast< int > ( band ),
static_cast< int > ( this->spheres[shell2]->getLocalBandwidth() ) ) );
110 &this->sphericalHarmonics[shell1][arrPos1][1],
111 &this->sphericalHarmonics[shell2][arrPos2][0],
112 &this->sphericalHarmonics[shell2][arrPos2][1] );
116 this->rrpMatrices[band][shell1][shell2] = descValR;
117 this->rrpMatrices[band][shell2][shell1] = descValR;
141 if ( bandInQuestion < spheres[shellInQuestion]->getLocalBandwidth() )
167 proshade_double ret = 0.0;
168 std::vector<proshade_double> bandDists;
173 throw ProSHADE_exception (
"Attempted computing energy levels descriptors when it was not required.",
"ED00017", __FILE__, __LINE__, __func__,
"Attempted to pre-compute the RRP matrices, when the user\n : has specifically stated that these should not be computed.\n : Unless you manipulated the code, this error should never\n : occur; if you see this, I made a large blunder. Please let\n : me know!" );
188 ret =
static_cast<proshade_double
> ( std::accumulate ( bandDists.begin(), bandDists.end(), 0.0 ) ) /
189 static_cast<proshade_double
> ( bandDists.size() );
217 proshade_double *str1Vals =
new proshade_double[minCommonShells * minCommonShells];
218 proshade_double *str2Vals =
new proshade_double[minCommonShells * minCommonShells];
221 proshade_unsign arrIter = 0;
224 for ( proshade_unsign band = 0; band < minCommonBands; band++ )
230 for ( proshade_unsign shell1 = 0; shell1 < minCommonShells; shell1++ )
235 for ( proshade_unsign shell2 = 0; shell2 < minCommonShells; shell2++ )
241 str1Vals[arrIter] = obj1->
getRRPValue ( band, shell1, shell2 ) *
244 str2Vals[arrIter] = obj2->
getRRPValue ( band, shell1, shell2 ) *
279 proshade_unsign oversampleEMatricesBy =
static_cast< proshade_unsign
> (
static_cast< proshade_single
> ( band ) * ( 1.0f - oversamplingRatio ) );
282 this->maxEMatDim = band + oversampleEMatricesBy;
285 this->eMatrices =
new proshade_complex** [this->maxEMatDim];
288 for ( proshade_unsign bandIter = 0; bandIter < this->maxEMatDim; bandIter++ )
291 this->eMatrices[bandIter] =
new proshade_complex* [
static_cast<proshade_unsign
> ( ( bandIter * 2 ) + 1 )];
294 for ( proshade_unsign band2Iter = 0; band2Iter < static_cast<proshade_unsign> ( ( bandIter * 2 ) + 1 ); band2Iter++ )
296 this->eMatrices[bandIter][band2Iter] =
new proshade_complex [
static_cast<proshade_unsign
> ( ( bandIter * 2 ) + 1 )];
302 for ( proshade_unsign bandIter = 0; bandIter < this->maxEMatDim; bandIter++ )
304 for ( proshade_unsign band2Iter = 0; band2Iter < static_cast<proshade_unsign> ( ( bandIter * 2 ) + 1 ); band2Iter++ )
306 for ( proshade_unsign band3Iter = 0; band3Iter < static_cast<proshade_unsign> ( ( bandIter * 2 ) + 1 ); band3Iter++ )
308 this->eMatrices[bandIter][band2Iter][band3Iter][0] = 0.0;
309 this->eMatrices[bandIter][band2Iter][band3Iter][1] = 0.0;
332 obj1Vals =
new proshade_double [minSpheres];
333 obj2Vals =
new proshade_double [minSpheres];
334 radiiVals =
new proshade_complex[minSpheres];
335 GLabscissas =
new proshade_double [intOrder];
336 GLweights =
new proshade_double [intOrder];
362 int objArrPos = seanindex ( order - band, band, locBand );
371 *result *= pow (
static_cast<proshade_double
> ( obj->
getAnySphereRadius( radius ) ), 2.0 );
394 proshade_unsign objCombValsIter = 0;
395 proshade_double hlpReal, hlpImag, rSquared;
396 proshade_complex arrVal;
397 int o1ArrPos, o2ArrPos, locBand;
398 proshade_unsign integOrderU =
static_cast< proshade_unsign
> ( integOrder );
401 for (
int order2Iter = 0; order2Iter < ( ( bandIter * 2 ) + 1 ); order2Iter++ )
413 rSquared = pow ( (
static_cast<proshade_double
> ( obj1->
getAnySphereRadius( radiusIter ) ) ), 2.0 );
417 o1ArrPos = seanindex ( orderIter - bandIter, bandIter, locBand );
418 o2ArrPos = seanindex ( order2Iter - bandIter, bandIter, locBand );
424 &hlpReal, &hlpImag );
427 radiiVals[objCombValsIter][0] = hlpReal * rSquared;
428 radiiVals[objCombValsIter][1] = hlpImag * rSquared;
430 objCombValsIter += 1;
465 proshade_unsign obj1ValsIter = 0;
466 proshade_unsign obj2ValsIter = 0;
467 proshade_unsign integOrderU =
static_cast< proshade_unsign
> ( integOrder );
471 proshade_unsign maxSphere = 0;
478 minSphere = std::min ( radiusIter, minSphere );
479 maxSphere = std::max ( radiusIter, maxSphere );
489 proshade_single minSphereRad = obj1->
getSpherePosValue ( minSphere ) - ( sphereDist * 0.5f );
490 proshade_single maxSphereRad = obj1->
getSpherePosValue ( maxSphere ) + ( sphereDist * 0.5f );
496 return (
static_cast< proshade_double
> ( maxSphereRad - minSphereRad ) );
514 delete[] GLabscissas;
521 GLabscissas =
nullptr;
549 proshade_double *obj1Vals, *obj2Vals, *GLAbscissas, *GLWeights;
550 proshade_complex* radiiVals;
551 proshade_double integRange;
557 for (
int bandIter = 0; bandIter < static_cast< int > ( std::min ( obj1->
getMaxBand(), obj2->
getMaxBand() ) ); bandIter++ )
560 int localIntegOrder = std::min (
static_cast< int > ( std::max ( bandIter, 5 ) ),
static_cast< int > ( settings->
integOrder ) );
565 for (
int orderIter = 0; orderIter < ( ( bandIter * 2 ) + 1 ); orderIter++ )
571 computeEMatricesForLM ( obj1, obj2, bandIter, orderIter, radiiVals, localIntegOrder, GLAbscissas, GLWeights, integRange,
static_cast< proshade_double
> ( settings->
maxSphereDists ) );
577 std::stringstream hlpSS;
578 hlpSS <<
"E matrices computed for band " << bandIter;
615 for ( proshade_unsign bandIter = 0; bandIter < std::min ( obj1->
getMaxBand(), obj2->
getMaxBand() ); bandIter++ )
618 for ( proshade_unsign orderIter = 0; orderIter < ( ( bandIter * 2 ) + 1 ); orderIter++ )
620 for ( proshade_unsign order2Iter = 0; order2Iter < ( ( bandIter * 2 ) + 1 ); order2Iter++ )
654 proshade_double ret = 0.0;
659 throw ProSHADE_exception (
"Attempted computing trace sigma descriptors when it was\n : not required.",
"ED00018", __FILE__, __LINE__, __func__,
"Attempted to pre-compute the E matrices, when the user\n : has specifically stated that these should not be computed.\n : Unless you manipulated the code, this error should never\n : occur; if you see this, I made a large blunder. Please let\n : me know!" );
673 double* singularValues =
new double[( ( std::min ( obj1->
getMaxBand(), obj2->
getMaxBand() ) * 2 ) + 1 )];
677 for ( proshade_unsign lIter = 0; lIter < std::min ( obj1->
getMaxBand(), obj2->
getMaxBand() ); lIter++ )
683 for ( proshade_unsign iter = 0; iter < ( ( lIter * 2 ) + 1 ); iter++ )
685 ret += singularValues[iter];
693 delete[] singularValues;
710 this->so3Coeffs =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) *
static_cast<proshade_unsign
>( ( 4 * pow(
static_cast<proshade_double
> ( band ), 3.0 ) -
static_cast<proshade_double
> ( band ) ) / 3.0 ) ) );
711 this->so3CoeffsInverse =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) *
static_cast<proshade_unsign
>( pow(
static_cast<proshade_double
> ( band ) * 2.0, 3.0 ) ) ) );
741 proshade_double wigNorm, hlpValReal, hlpValImag;
742 proshade_double signValue = 1.0;
743 proshade_unsign indexO;
744 proshade_complex hlpVal;
747 for ( proshade_signed bandIter = 0; bandIter < static_cast<proshade_signed> ( obj2->
getEMatDim ( ) ); bandIter++ )
750 wigNorm = 2.0 * M_PI * sqrt ( 2.0 / (2.0 *
static_cast< proshade_double
> ( bandIter ) + 1.0 ) );
753 for ( proshade_signed orderIter = 0; orderIter < ( ( bandIter * 2 ) + 1 ); orderIter++ )
756 if ( ( orderIter - bandIter + bandIter ) % 2 ) { signValue = -1.0 ; }
757 else { signValue = 1.0 ; }
760 for ( proshade_signed order2Iter = 0; order2Iter < ( ( bandIter * 2 ) + 1 ); order2Iter++ )
763 indexO =
static_cast< proshade_unsign
> ( so3CoefLoc (
static_cast< int > ( orderIter - bandIter ),
static_cast< int > ( order2Iter - bandIter ),
static_cast< int > ( bandIter ),
static_cast< int > ( obj2->
getEMatDim ( ) ) ) );
766 obj2->
getEMatrixValue (
static_cast< proshade_unsign
> ( bandIter ),
static_cast< proshade_unsign
> ( orderIter ),
static_cast< proshade_unsign
> ( order2Iter ), &hlpValReal, &hlpValImag );
767 hlpVal[0] = hlpValReal * wigNorm * signValue;
768 hlpVal[1] = hlpValImag * wigNorm * signValue;
795 work1 =
new proshade_complex[8 *
static_cast<proshade_unsign
> ( pow(
static_cast<double> ( band ), 3.0 ) )];
796 work2 =
new proshade_complex[14 *
static_cast<proshade_unsign
> ( pow(
static_cast<double> ( band ), 2.0 ) ) + (48 * band)];
797 work3 =
new proshade_double [2 *
static_cast<proshade_unsign
> ( pow(
static_cast<double> ( band ), 2.0 ) ) + (24 * band)];
819 int howmany = 4 * band * band;
820 int idist = 2 * band;
821 int odist = 2 * band;
824 int inembed[2], onembed[2];
825 inembed[0] = 2 * band;
826 inembed[1] = 4 * band * band;
827 onembed[0] = 2 * band;
828 onembed[1] = 4 * band * band;
838 *inverseSO3 = fftw_plan_many_dft ( rank,
891 proshade_complex *workspace1, *workspace2;
892 proshade_double *workspace3;
893 fftw_plan inverseSO3;
902 Inverse_SO3_Naive_fftw (
static_cast< int > ( obj2->
getEMatDim ( ) ),
913 fftw_destroy_plan ( inverseSO3 );
945 proshade_double ret = 0.0;
946 proshade_double eulA, eulB, eulG, EMatR, EMatI, WigDR, WigDI;
951 throw ProSHADE_exception (
"Attempted computing rotation function descriptors when it\n : was not required.",
"ED00023", __FILE__, __LINE__, __func__,
"Attempted to compute the SO(3) transform and the rotation \n : function descriptor when the user did not request this. \n : Unless you manipulated the code, this error should never \n : occur; if you see this, I made a large blunder. \n : Please let me know!" );
970 &eulA, &eulB, &eulG, settings );
976 for ( proshade_unsign bandIter = 0; bandIter < obj2->
getEMatDim(); bandIter++ )
979 for ( proshade_unsign order1 = 0; order1 < ( ( bandIter * 2 ) + 1 ); order1++ )
982 for ( proshade_unsign order2 = 0; order2 < ( ( bandIter * 2 ) + 1 ); order2++ )