26 #include <wrap_fftw.h> 27 #include <makeweights.h> 28 #include <s2_primitive.h> 29 #include <s2_cospmls.h> 30 #include <s2_legendreTransforms.h> 31 #include <s2_semi_fly.h> 32 #include <rotate_so3_utils.h> 33 #include <utils_so3.h> 34 #include <soft_fftw.h> 35 #include <rotate_so3_fftw.h> 41 #include <rvapi_interface.h> 69 for (
unsigned int iter = 0; iter < length; iter++ )
71 xMean += valSet1[iter];
72 yMean += valSet2[iter];
74 xMean /=
static_cast<double> ( length );
75 yMean /=
static_cast<double> ( length );
81 for (
unsigned int iter = 0; iter < length; iter++ )
83 xmmymm += ( valSet1[iter] - xMean ) * ( valSet2[iter] - yMean );
84 xmmsq += pow( valSet1[iter] - xMean, 2.0 );
85 ymmsq += pow( valSet2[iter] - yMean, 2.0 );
89 double ret = xmmymm / ( sqrt(xmmsq) * sqrt(ymmsq) );
90 if ( std::isnan (ret) )
118 std::array<double,2> ret;
121 ret[0] = (*r1)*(*r2) - (*i1)*(*i2);
122 ret[1] = (*r1)*(*i2) + (*i1)*(*r2);
149 std::array<double,2> ret;
152 ret[0] = (*r1)*(*r2) + (*i1)*(*i2);
153 ret[1] = -(*r1)*(*i2) + (*i1)*(*r2);
180 return ( (*r1)*(*r2) - (*i1)*(*i2) );
205 return ( (*r1)*(*r2) + (*i1)*(*i2) );
222 if ( !this->_sphericalCoefficientsComputed )
224 std::cerr <<
"!!! ProSHADE ERROR !!! Error in file " << this->_inputFileName <<
" !!! Attempted to pre-compute RRP matrices for RotInv descriptor before computing the spherical harmonics decomposition. Call the getSphericalHarmonicsCoeffs function BEFORE the precomputeRotInvDescriptor function." << std::endl;
228 std::stringstream hlpSS;
229 hlpSS <<
"<font color=\"red\">" <<
"Attempted to pre-compute RRP matrices for RotInv descriptor before computing the spherical harmonics decomposition. This looks like an internal bug, please report this case." <<
"</font>";
230 rvapi_set_text ( hlpSS.str().c_str(),
244 this->_rrpMatrices =
new double** [this->_bandwidthLimit];
245 for (
unsigned int bwIt = 0; bwIt < this->_bandwidthLimit; bwIt++ )
248 if ( !this->_keepOrRemove ) {
if ( ( bwIt % 2 ) != 0 ) {
continue; } }
250 this->_rrpMatrices[bwIt] =
new double* [this->_noShellsWithData];
251 for (
unsigned int shIt = 0; shIt < this->_noShellsWithData; shIt++ )
253 this->_rrpMatrices[bwIt][shIt] =
new double [this->_noShellsWithData];
258 double descValR = 0.0;
259 unsigned int arrPos = 0;
262 for (
unsigned int band = 0; band < this->_bandwidthLimit; band++ )
265 if ( !this->_keepOrRemove ) {
if ( band % 2 == 1 ) {
continue; } }
268 for (
unsigned int shell1 = 0; shell1 < this->_noShellsWithData; shell1++ )
270 for (
unsigned int shell2 = 0; shell2 < this->_noShellsWithData; shell2++ )
273 if ( shell1 > shell2 ) {
continue; }
279 for (
unsigned int order = 0; order < static_cast<unsigned int> ( ( 2 * band ) + 1 ); order++ )
281 arrPos = seanindex ( order-band, band, this->_bandwidthLimit );
282 descValR += ( this->_realSHCoeffs[shell1][arrPos] * this->_realSHCoeffs[shell2][arrPos] ) +
283 ( this->_imagSHCoeffs[shell1][arrPos] * this->_imagSHCoeffs[shell2][arrPos] );
287 this->_rrpMatrices[band][shell1][shell2] = descValR;
288 this->_rrpMatrices[band][shell2][shell1] = descValR;
294 this->_rrpMatricesPrecomputed =
true;
313 if ( !this->one->_rrpMatricesPrecomputed )
315 std::cerr <<
"!!! ProSHADE ERROR !!! Error in file compatison !!! Attempted to get energy level distance for structure objects where at least one of them did not have the RotInv pre-computed. Call the precomputeRotInvDescriptor on all structure objects before giving them to ProSHADE_compareOneAgainstAll constructor." << std::endl;
319 std::stringstream hlpSS;
320 hlpSS <<
"<font color=\"red\">" <<
"Attempted to pre-compute RRP matrices for RotInv descriptor before computing the spherical harmonics decomposition. This looks like an internal bug, please report this case." <<
"</font>";
321 rvapi_set_text ( hlpSS.str().c_str(),
333 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( this->all->size() ); iter++ )
335 if ( !this->all->at(iter)->_rrpMatricesPrecomputed )
337 std::cerr <<
"!!! ProSHADE ERROR !!! Error in file compatison !!! Attempted to get energy level distance for structure objects where at least one of them did not have the RotInv pre-computed. Call the precomputeRotInvDescriptor on all structure objects before giving them to ProSHADE_compareOneAgainstAll constructor." << std::endl;
341 std::stringstream hlpSS;
342 hlpSS <<
"<font color=\"red\">" <<
"Attempted to get energy level distance for structure objects where at least one of them did not have the RotInv pre-computed. This looks like an internal bug, please report this case." <<
"</font>";
343 rvapi_set_text ( hlpSS.str().c_str(),
358 std::cout <<
">>>>>>>> Sanity checks passed." << std::endl;
362 if ( this->_energyLevelsComputed )
364 return ( this->_distancesEnergyLevels );
368 unsigned int arrIter = 0;
369 bool ignoreThisL =
false;
370 std::vector<double> bandDists;
371 this->_distancesEnergyLevels = std::vector<double> (
static_cast<int> ( this->all->size() ) );
373 for (
unsigned int strIt = 0; strIt < static_cast<unsigned int> ( this->all->size() ); strIt++ )
377 std::cout <<
">>>>>>>> Now computing distance for structure 0 against structure " << strIt+1 <<
" ." << std::endl;
384 unsigned int minShellsToUse = std::min ( this->one->_noShellsWithData, this->all->at(strIt)->_noShellsWithData );
385 unsigned int bandLimit = std::min ( this->one->_bandwidthLimit, this->all->at(strIt)->_bandwidthLimit );
388 double *str1Vals =
new double[minShellsToUse * minShellsToUse];
389 double *str2Vals =
new double[minShellsToUse * minShellsToUse];
392 for (
unsigned int band = 0; band < bandLimit; band++ )
395 if ( !this->_keepOrRemove ) {
if ( band % 2 != 0 ) {
continue; } }
398 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( static_cast<unsigned int> ( this->_lsToIgnore.at(igIt) ) == band ) { ignoreThisL =
true; } }
399 if ( ignoreThisL ) {
continue; }
405 for (
unsigned int shell1 = 0; shell1 < minShellsToUse; shell1++ )
407 for (
unsigned int shell2 = 0; shell2 < minShellsToUse; shell2++ )
409 str1Vals[arrIter] = this->one->_rrpMatrices[band][shell1][shell2] *
410 pow ( static_cast<double> ( shell1 ), this->_matrixPowerWeight ) *
411 pow ( static_cast<double> ( shell2 ), this->_matrixPowerWeight );
412 str2Vals[arrIter] = this->all->at(strIt)->_rrpMatrices[band][shell1][shell2] *
413 pow ( static_cast<double> ( shell1 ), this->_matrixPowerWeight ) *
414 pow ( static_cast<double> ( shell2 ), this->_matrixPowerWeight );
421 bandDists.emplace_back ( ProSHADE_internal_misc::pearsonCorrCoeff ( str1Vals, str2Vals, ( minShellsToUse * minShellsToUse ) ) );
425 this->_distancesEnergyLevels.at( strIt ) =
static_cast<double> ( std::accumulate ( bandDists.begin(), bandDists.end(), 0.0 ) ) /
static_cast<double> ( bandDists.size() );
433 std::cout <<
">>>>> Distance for structure 0 against structure " << strIt+1 <<
" complete." << std::endl;
438 this->_energyLevelsComputed =
true;
441 return ( this->_distancesEnergyLevels );
457 unsigned int numberBandsToUse = 0;
458 bool toBeIgnored =
false;
460 for (
unsigned int bandIter = 0; bandIter < this->_bandwidthLimit; bandIter++ )
463 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
467 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( bandIter == static_cast<unsigned int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
468 if ( toBeIgnored ) {
continue; }
471 numberBandsToUse += 1;
475 std::vector<double> radiiVals1;
476 std::vector<double> radiiVals2;
477 std::vector< std::array<double,2> > radiiVals;
478 std::array<double,2> arrVal1;
479 unsigned int index1 = 0;
480 unsigned int index2 = 0;
481 unsigned int bandUsageIndex = 0;
482 double correlNormFactor = 0.0;
485 this->_trSigmaWeights = std::vector<double> ( 2 );
486 this->_trSigmaWeights.at(0) = 0.0;
487 this->_trSigmaWeights.at(1) = 0.0;
489 this->_trSigmaEMatrix =
new std::array<double,2>** [numberBandsToUse];
490 for (
unsigned int bandIter = 0; bandIter < this->_bandwidthLimit; bandIter++ )
493 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
497 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( bandIter == static_cast<unsigned int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
498 if ( toBeIgnored ) {
continue; }
500 this->_trSigmaEMatrix[bandUsageIndex] =
new std::array<double,2>* [
static_cast<unsigned int> ( ( bandIter * 2 ) + 1 )];
501 for (
unsigned int lIter = 0; lIter < static_cast<unsigned int> ( ( bandIter * 2 ) + 1 ); lIter++ )
503 this->_trSigmaEMatrix[bandUsageIndex][lIter] =
new std::array<double,2> [
static_cast<unsigned int> ( ( bandIter * 2 ) + 1 )];
511 for (
unsigned int bandIter = 0; bandIter < this->_bandwidthLimit; bandIter++ )
514 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
518 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( bandIter == static_cast<unsigned int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
519 if ( toBeIgnored ) {
continue; }
522 for (
unsigned int orderIter = 0; orderIter < ( ( bandIter * 2 ) + 1 ); orderIter++ )
525 radiiVals1.clear ( );
526 radiiVals2.clear ( );
527 radiiVals1 = std::vector<double> ( this->_noShellsObj1 );
528 radiiVals2 = std::vector<double> ( this->_noShellsObj2 );
531 index1 = seanindex ( orderIter-bandIter, bandIter, this->_bandwidthLimit );
534 for (
unsigned int radiusIter = 0; radiusIter < this->_maxShellsToUse; radiusIter++ )
536 if ( radiusIter < this->_noShellsObj1 )
539 radiiVals1.at(radiusIter) = ProSHADE_internal_misc::complexMultiplicationConjugReal ( &this->_obj1RealCoeffs[radiusIter][index1],
540 &this->_obj1ImagCoeffs[radiusIter][index1],
541 &this->_obj1RealCoeffs[radiusIter][index1],
542 &this->_obj1ImagCoeffs[radiusIter][index1] );
545 radiiVals1.at(radiusIter)*= pow ( ( static_cast<double> ( radiusIter + 1 ) * this->_shellSpacing ), 2.0 );
548 if ( radiusIter < this->_noShellsObj2 )
551 radiiVals2.at(radiusIter) = ProSHADE_internal_misc::complexMultiplicationConjugReal ( &this->_obj2RealCoeffs[radiusIter][index1],
552 &this->_obj2ImagCoeffs[radiusIter][index1],
553 &this->_obj2RealCoeffs[radiusIter][index1],
554 &this->_obj2ImagCoeffs[radiusIter][index1] );
557 radiiVals2.at(radiusIter)*= pow ( ( static_cast<double> ( radiusIter + 1 ) * this->_shellSpacing ), 2.0 );
562 this->_trSigmaWeights.at(0) += this->gl20IntRR ( &radiiVals1 );
563 this->_trSigmaWeights.at(1) += this->gl20IntRR ( &radiiVals2 );
566 for (
unsigned int order2Iter = 0; order2Iter < ( ( bandIter * 2 ) + 1 ); order2Iter++ )
569 index2 = seanindex ( order2Iter-bandIter, bandIter, this->_bandwidthLimit );
573 radiiVals = std::vector< std::array<double,2> > ( this->_minShellsToUse );
576 for (
unsigned int radiusIter = 0; radiusIter < this->_minShellsToUse; radiusIter++ )
579 radiiVals.at(radiusIter) = ProSHADE_internal_misc::complexMultiplicationConjug ( &this->_obj1RealCoeffs[radiusIter][index1],
580 &this->_obj1ImagCoeffs[radiusIter][index1],
581 &this->_obj2RealCoeffs[radiusIter][index2],
582 &this->_obj2ImagCoeffs[radiusIter][index2] );
585 radiiVals.at(radiusIter)[0] *= pow ( ( static_cast<double> ( radiusIter + 1 ) * this->_shellSpacing ), 2.0 );
586 radiiVals.at(radiusIter)[1] *= pow ( ( static_cast<double> ( radiusIter + 1 ) * this->_shellSpacing ), 2.0 );
590 arrVal1 = this->gl20IntCR ( &radiiVals );
593 this->_trSigmaEMatrix[bandUsageIndex][orderIter][order2Iter][0] = arrVal1[0];
594 this->_trSigmaEMatrix[bandUsageIndex][orderIter][order2Iter][1] = arrVal1[1];
602 correlNormFactor = sqrt ( this->_trSigmaWeights.at(0) * this->_trSigmaWeights.at(1) );
604 for (
unsigned int bandIter = 0; bandIter < this->_bandwidthLimit; bandIter++ )
607 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
611 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( bandIter == static_cast<unsigned int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
612 if ( toBeIgnored ) {
continue; }
615 for (
unsigned int order1Iter = 0; order1Iter < ( ( bandIter * 2 ) + 1 ); order1Iter++ )
617 for (
unsigned int order2Iter = 0; order2Iter < ( ( bandIter * 2 ) + 1 ); order2Iter++ )
620 this->_trSigmaEMatrix[bandUsageIndex][order1Iter][order2Iter][0] /= correlNormFactor;
621 this->_trSigmaEMatrix[bandUsageIndex][order1Iter][order2Iter][1] /= correlNormFactor;
629 this->_trSigmaPreComputed =
true;
649 std::vector<double> radiiVals1;
650 std::vector<double> radiiVals2;
651 std::vector< std::array<double,2> > radiiVals;
652 std::array<double,2> arrVal1;
653 std::vector<double> glAbscissas;
654 std::vector<double> glWeights;
655 unsigned int glIntegrationOrder = 0;
656 unsigned int index11 = 0;
657 unsigned int index12 = 0;
658 unsigned int index21 = 0;
659 unsigned int index22 = 0;
660 double correlNormFactor = 0.0;
661 unsigned int bandUsageIndex = 0;
662 unsigned int fileUsageIndex = 0;
663 unsigned int noBandsUsed = 0;
664 unsigned int localComparisonBandLim = 0;
665 bool toBeIgnored =
false;
666 unsigned int maxShellsToUse = 0;
667 unsigned int minShellsToUse = 0;
668 bool firstDoneAlready =
false;
671 std::vector<double> trSigmaWeights = std::vector<double> ( this->all->size() + 1 );
672 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( trSigmaWeights.size() ); iter++ )
674 trSigmaWeights.at(iter) = 0.0;
679 for (
unsigned int strIt = 0; strIt < static_cast<unsigned int> ( this->all->size() ); strIt++ )
682 if ( this->_enLevelsDoNotFollow.at(strIt) == 1 ) {
continue; }
685 localComparisonBandLim = std::min( this->one->_bandwidthLimit, this->all->at(strIt)->_bandwidthLimit );
686 for (
unsigned int bandIter = 0; bandIter < localComparisonBandLim ; bandIter++ )
689 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
693 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( bandIter == static_cast<unsigned int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
694 if ( toBeIgnored ) {
continue; }
702 this->_EMatrices.emplace_back ( std::vector< std::vector< std::vector< std::array<double,2> > > > ( noBandsUsed ) );
703 for (
unsigned int bandIter = 0; bandIter < localComparisonBandLim; bandIter++ )
706 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
710 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( bandIter == static_cast<unsigned int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
711 if ( toBeIgnored ) {
continue; }
714 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex) = std::vector< std::vector< std::array<double,2> > > (
static_cast<unsigned int> ( ( bandIter * 2 ) + 1 ) );
717 for (
unsigned int lIter = 0; lIter < static_cast<unsigned int> ( ( bandIter * 2 ) + 1 ); lIter++ )
719 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(lIter) = std::vector< std::array<double,2> > (
static_cast<unsigned int> ( ( bandIter * 2 ) + 1 ) );
726 maxShellsToUse = std::max ( this->one->_noShellsWithData, this->all->at(strIt)->_noShellsWithData );
727 minShellsToUse = std::min ( this->one->_noShellsWithData, this->all->at(strIt)->_noShellsWithData );
730 glIntegrationOrder = std::max ( glIntegOrderVec->at(0), glIntegOrderVec->at(strIt+1) );
731 glAbscissas = std::vector<double> ( glIntegrationOrder );
732 glWeights = std::vector<double> ( glIntegrationOrder );
733 ProSHADE_internal_legendre::getLegendreAbscAndWeights ( glIntegrationOrder, &glAbscissas, &glWeights, settings );
737 for (
unsigned int bandIter = 0; bandIter < localComparisonBandLim; bandIter++ )
740 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
744 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( bandIter == static_cast<unsigned int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
745 if ( toBeIgnored ) {
continue; }
748 for (
unsigned int orderIter = 0; orderIter < ( ( bandIter * 2 ) + 1 ); orderIter++ )
751 radiiVals1.clear ( );
752 radiiVals2.clear ( );
753 radiiVals1 = std::vector<double> ( this->one->_noShellsWithData );
754 radiiVals2 = std::vector<double> ( this->all->at(strIt)->_noShellsWithData );
757 index11 = seanindex ( orderIter-bandIter, bandIter, this->one->_bandwidthLimit );
758 index12 = seanindex ( orderIter-bandIter, bandIter, this->all->at(strIt)->_bandwidthLimit );
761 for (
unsigned int radiusIter = 0; radiusIter < maxShellsToUse; radiusIter++ )
763 if ( !firstDoneAlready )
765 if ( radiusIter < this->one->_noShellsWithData )
768 radiiVals1.at(radiusIter) = ProSHADE_internal_misc::complexMultiplicationConjugReal ( &this->one->_realSHCoeffs[radiusIter][index11],
769 &this->one->_imagSHCoeffs[radiusIter][index11],
770 &this->one->_realSHCoeffs[radiusIter][index11],
771 &this->one->_imagSHCoeffs[radiusIter][index11] );
774 radiiVals1.at(radiusIter) *= pow ( ( static_cast<double> ( radiusIter + 1 ) * shellSpacing ), 2.0 );
778 if ( radiusIter < this->all->at(strIt)->_noShellsWithData )
781 radiiVals2.at(radiusIter) = ProSHADE_internal_misc::complexMultiplicationConjugReal ( &this->all->at(strIt)->_realSHCoeffs[radiusIter][index12],
782 &this->all->at(strIt)->_imagSHCoeffs[radiusIter][index12],
783 &this->all->at(strIt)->_realSHCoeffs[radiusIter][index12],
784 &this->all->at(strIt)->_imagSHCoeffs[radiusIter][index12] );
787 radiiVals2.at(radiusIter) *= pow ( ( static_cast<double> ( radiusIter + 1 ) * shellSpacing ), 2.0 );
792 if ( !firstDoneAlready ) { trSigmaWeights.at(0) += this->glIntRR ( &radiiVals1, shellSpacing, &glAbscissas, &glWeights ); }
793 trSigmaWeights.at(strIt+1) += this->glIntRR ( &radiiVals2, shellSpacing, &glAbscissas, &glWeights );
796 for (
unsigned int order2Iter = 0; order2Iter < ( ( bandIter * 2 ) + 1 ); order2Iter++ )
799 index21 = seanindex ( orderIter-bandIter, bandIter, this->one->_bandwidthLimit );
800 index22 = seanindex ( order2Iter-bandIter, bandIter, this->all->at(strIt)->_bandwidthLimit );
804 radiiVals = std::vector< std::array<double,2> > ( minShellsToUse );
807 for (
unsigned int radiusIter = 0; radiusIter < minShellsToUse; radiusIter++ )
810 radiiVals.at(radiusIter) = ProSHADE_internal_misc::complexMultiplicationConjug ( &this->one->_realSHCoeffs[radiusIter][index21],
811 &this->one->_imagSHCoeffs[radiusIter][index21],
812 &this->all->at(strIt)->_realSHCoeffs[radiusIter][index22],
813 &this->all->at(strIt)->_imagSHCoeffs[radiusIter][index22] );
816 radiiVals.at(radiusIter)[0] *= pow ( ( static_cast<double> ( radiusIter + 1 ) * shellSpacing ), 2.0 );
817 radiiVals.at(radiusIter)[1] *= pow ( ( static_cast<double> ( radiusIter + 1 ) * shellSpacing ), 2.0 );
821 arrVal1 = this->glIntCR ( &radiiVals, shellSpacing, &glAbscissas, &glWeights );
824 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(orderIter).at(order2Iter)[0] = arrVal1[0];
825 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(orderIter).at(order2Iter)[1] = arrVal1[1];
833 correlNormFactor = sqrt ( trSigmaWeights.at(0) * trSigmaWeights.at(strIt+1) );
835 for (
unsigned int bandIter = 0; bandIter < localComparisonBandLim; bandIter++ )
838 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
842 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( bandIter == static_cast<unsigned int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
843 if ( toBeIgnored ) {
continue; }
846 for (
unsigned int orderIter = 0; orderIter < ( ( bandIter * 2 ) + 1 ); orderIter++ )
848 for (
unsigned int order2Iter = 0; order2Iter < ( ( bandIter * 2 ) + 1 ); order2Iter++ )
851 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(orderIter).at(order2Iter)[0] /= correlNormFactor;
852 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(orderIter).at(order2Iter)[1] /= correlNormFactor;
858 firstDoneAlready =
true;
863 this->_trSigmaPreComputed =
true;
882 if ( !this->_trSigmaPreComputed )
884 std::cerr <<
"!!! ProSHADE ERROR !!! Error in file compatison !!! Attempted to get TrSigma distance without pre-computing the required data (E matrices). Call the precomputeTrSigmaDescriptor function BEFORE calling the getTrSigmaDistance function." << std::endl;
888 std::stringstream hlpSS;
889 hlpSS <<
"<font color=\"red\">" <<
"Attempted to get TrSigma distance without pre-computing the required data (E matrices). This looks like an internal bug, please report this case." <<
"</font>";
890 rvapi_set_text ( hlpSS.str().c_str(),
904 if ( this->_trSigmaComputed )
906 return ( this->_distancesTraceSigma );
910 std::cout <<
">>>>>>>> Sanity checks passed." << std::endl;
914 this->_distancesTraceSigma = std::vector<double> ( this->all->size() );
915 std::vector<double> hlpVec;
916 unsigned int bandUsageIndex = 0;
917 bool toBeIgnored =
false;
918 unsigned int localComparisonBandLim = 0;
919 unsigned int fileUsageIndex = 0;
922 for (
unsigned int strIt = 0; strIt < static_cast<unsigned int> ( this->all->size() ); strIt++ )
925 if ( this->_enLevelsDoNotFollow.at(strIt) == 1 ) { this->_distancesTraceSigma.at(strIt) = -999.9;
continue; }
929 std::cout <<
">>>>>>>> Now computing distance between structure 0 and structure " << strIt+1 <<
" ." << std::endl;
934 localComparisonBandLim = std::min( this->one->_bandwidthLimit, this->all->at(strIt)->_bandwidthLimit );
935 this->_distancesTraceSigma.at(strIt) = 0.0;
938 for (
unsigned int lIter = 0; lIter < localComparisonBandLim; lIter++ )
941 if ( !this->_keepOrRemove ) {
if ( ( lIter % 2 ) != 0 ) {
continue; } }
945 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( lIter == static_cast<unsigned int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
946 if ( toBeIgnored ) {
continue; }
949 hlpVec = this->getSingularValues ( fileUsageIndex, bandUsageIndex, static_cast<unsigned int> ( ( lIter * 2 ) + 1 ), settings );
952 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( hlpVec.size() ); iter++ )
954 this->_distancesTraceSigma.at(strIt) += hlpVec.at(iter);
964 std::cout <<
">>>>> Distance between structure 0 and structure " << strIt+1 <<
" computed." << std::endl;
969 this->_trSigmaComputed =
true;
972 return ( this->_distancesTraceSigma );
991 if ( !this->_wignerMatricesComputed )
993 std::cerr <<
"!!! ProSHADE ERROR !!! Error in file compatison !!! Attempted to get Full Rotation distance without pre-computing the Wigner D matrices. Call the generateWignerMatrices function BEFORE calling the getRotCoeffDistance function." << std::endl;
997 std::stringstream hlpSS;
998 hlpSS <<
"<font color=\"red\">" <<
"Attempted to get Full Rotation distance without pre-computing the Wigner D matrices. This looks like an internal bug, please report this case." <<
"</font>";
999 rvapi_set_text ( hlpSS.str().c_str(),
1013 bool toBeIgnored =
false;
1014 double totSum = 0.0;
1015 unsigned int bandUsageIndex = 0;
1018 for (
int bandIter = 0; bandIter < static_cast<int> ( this->_bandwidthLimit ); bandIter++ )
1021 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
1024 toBeIgnored =
false;
1025 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( bandIter == static_cast<int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
1026 if ( toBeIgnored ) {
continue; }
1029 for (
int order1 = 0; order1 < static_cast<int> ( ( bandIter * 2 ) + 1 ); order1++ )
1032 for (
int order2 = 0; order2 < static_cast<int> ( ( bandIter * 2 ) + 1 ); order2++ )
1035 totSum += ProSHADE_internal_misc::complexMultiplicationReal ( &this->_wignerMatrices.at(bandIter).at(order1).at(order2)[0],
1036 &this->_wignerMatrices.at(bandIter).at(order1).at(order2)[1],
1037 &this->_trSigmaEMatrix[bandUsageIndex][order2][order1][0],
1038 &this->_trSigmaEMatrix[bandUsageIndex][order2][order1][1] );
1043 bandUsageIndex += 1;
1066 if ( !this->_wignerMatricesComputed )
1068 std::cerr <<
"!!! ProSHADE ERROR !!! Error in file compatison !!! Attempted to get Full Rotation distance without pre-computing the Wigner D matrices. Call the generateWignerMatrices function BEFORE calling the getRotCoeffDistance function." << std::endl;
1072 std::stringstream hlpSS;
1073 hlpSS <<
"<font color=\"red\">" <<
"Attempted to get Full Rotation distance without pre-computing the Wigner D matrices. This looks like an internal bug, please report this case." <<
"</font>";
1074 rvapi_set_text ( hlpSS.str().c_str(),
1088 if ( this->_fullDistComputed )
1090 return ( this->_distancesFullRotation );
1094 std::cout <<
">>>>>>>> Sanity checks passed." << std::endl;
1098 bool toBeIgnored =
false;
1099 double totSum = 0.0;
1100 unsigned int bandUsageIndex = 0;
1101 unsigned int fileUsageIndex = 0;
1102 int localComparisonBandLim = 0;
1104 for (
unsigned int strIt = 0; strIt < static_cast<unsigned int> ( this->all->size() ); strIt++ )
1107 if ( this->_enLevelsDoNotFollow.at(strIt) == 1 ) { this->_distancesFullRotation.emplace_back( -999.9 );
continue; }
1108 if ( this->_trSigmaDoNotFollow.at(strIt) == 1 ) { this->_distancesFullRotation.emplace_back( -999.9 ); fileUsageIndex += 1;
continue; }
1112 std::cout <<
">>>>>>>> Now computing distance between structure 0 and structure " << strIt+1 <<
" ." << std::endl;
1116 localComparisonBandLim = std::min ( this->one->_bandwidthLimit, this->all->at(strIt)->_bandwidthLimit );
1119 toBeIgnored =
false;
1124 for (
int bandIter = 0; bandIter < static_cast<int> ( localComparisonBandLim ); bandIter++ )
1127 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
1130 toBeIgnored =
false;
1131 for (
unsigned int igIt = 0; igIt < static_cast<unsigned int> ( this->_lsToIgnore.size() ); igIt++ ) {
if ( bandIter == static_cast<int> ( this->_lsToIgnore.at(igIt) ) ) { toBeIgnored =
true; } }
1132 if ( toBeIgnored ) {
continue; }
1135 for (
int order1 = 0; order1 < static_cast<int> ( ( bandIter * 2 ) + 1 ); order1++ )
1138 for (
int order2 = 0; order2 < static_cast<int> ( ( bandIter * 2 ) + 1 ); order2++ )
1141 totSum += ProSHADE_internal_misc::complexMultiplicationReal ( &this->_wignerMatrices.at(strIt).at(bandIter).at(order1).at(order2)[0],
1142 &this->_wignerMatrices.at(strIt).at(bandIter).at(order1).at(order2)[1],
1143 &this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(order2).at(order1)[0],
1144 &this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(order2).at(order1)[1] );
1149 bandUsageIndex += 1;
1153 this->_distancesFullRotation.emplace_back ( totSum );
1154 fileUsageIndex += 1;
1158 std::cout <<
">>>>> Distance between structure 0 and structure " << strIt+1 <<
" computed." << std::endl;
1163 this->_fullDistComputed =
true;
1166 return ( this->_distancesFullRotation );
std::vector< double > getRotCoeffDistance(int verbose, ProSHADE::ProSHADE_settings *settings)
This function computes the full rotation function descriptor distances.
bool htmlReport
Should HTML report for the run be created?
std::vector< double > getTrSigmaDistance(int verbose, ProSHADE::ProSHADE_settings *settings)
This function computes the trace sigma descriptor distances.
The main header file containing all declarations the user of the library needs.
double getRotCoeffDistance(ProSHADE::ProSHADE_settings *settings)
This function computes the full rotation function descriptor distances.
void precomputeTrSigmaDescriptor()
This function computes the E matrices required for the trace sigma descriptor, the rotation function ...
This file contains all the functions related to computing the Gauss-Legendre integration variables...
std::array< double, 2 > complexMultiplication(double *r1, double *i1, double *r2, double *i2)
Function to multiply two complex numbers.
void precomputeTrSigmaDescriptor(double shellSpacing, std::vector< unsigned int > *glIntegOrderVec, ProSHADE::ProSHADE_settings *settings)
This function computes the E matrices required for the trace sigma descriptor, the rotation function ...
The main header file containing all declarations for the innter workings of the library.
int htmlReportLineProgress
Iterator for current HTML line in the progress bar.
double complexMultiplicationConjugReal(double *r1, double *i1, double *r2, double *i2)
Function to multiply two complex numbers where the second number is conjugated before the multiplicat...
std::vector< double > getEnergyLevelsDistance(int verbose, ProSHADE::ProSHADE_settings *settings)
This function computes the energy level descriptor value from the first structure to all remaining st...
void precomputeRotInvDescriptor(ProSHADE::ProSHADE_settings *settings)
This function computes the RRP matrices, which are required for the computation of the energy levels ...
This class stores all the settings and is passed to the executive classes instead of multitude of par...
std::array< double, 2 > complexMultiplicationConjug(double *r1, double *i1, double *r2, double *i2)
Function to multiply two complex numbers where the second number is conjugated before the multiplicat...
This file contains the ProSHADE_internal_misc namespace and its miscellaneous functions.
double pearsonCorrCoeff(double *valSet1, double *valSet2, unsigned int length)
Function for computing the Pearson correlation coefficient.
double complexMultiplicationReal(double *r1, double *i1, double *r2, double *i2)
Function to multiply two complex numbers, returning only the real part of the result.