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;
628 this->_trSigmaPreComputed =
true;
648 std::vector<double> radiiVals1;
649 std::vector<double> radiiVals2;
650 std::vector< std::array<double,2> > radiiVals;
651 std::array<double,2> arrVal1;
652 std::vector<double> glAbscissas;
653 std::vector<double> glWeights;
654 unsigned int glIntegrationOrder = 0;
655 unsigned int index11 = 0;
656 unsigned int index12 = 0;
657 unsigned int index21 = 0;
658 unsigned int index22 = 0;
659 double correlNormFactor = 0.0;
660 unsigned int bandUsageIndex = 0;
661 unsigned int fileUsageIndex = 0;
662 unsigned int noBandsUsed = 0;
663 unsigned int localComparisonBandLim = 0;
664 bool toBeIgnored =
false;
665 unsigned int maxShellsToUse = 0;
666 unsigned int minShellsToUse = 0;
667 bool firstDoneAlready =
false;
670 std::vector<double> trSigmaWeights = std::vector<double> ( this->all->size() + 1 );
671 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( trSigmaWeights.size() ); iter++ )
673 trSigmaWeights.at(iter) = 0.0;
678 for (
unsigned int strIt = 0; strIt < static_cast<unsigned int> ( this->all->size() ); strIt++ )
681 if ( this->_enLevelsDoNotFollow.at(strIt) == 1 ) {
continue; }
684 localComparisonBandLim = std::min( this->one->_bandwidthLimit, this->all->at(strIt)->_bandwidthLimit );
685 for (
unsigned int bandIter = 0; bandIter < localComparisonBandLim ; bandIter++ )
688 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
692 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; } }
693 if ( toBeIgnored ) {
continue; }
701 this->_EMatrices.emplace_back ( std::vector< std::vector< std::vector< std::array<double,2> > > > ( noBandsUsed ) );
702 for (
unsigned int bandIter = 0; bandIter < localComparisonBandLim; bandIter++ )
705 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
709 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; } }
710 if ( toBeIgnored ) {
continue; }
713 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex) = std::vector< std::vector< std::array<double,2> > > (
static_cast<unsigned int> ( ( bandIter * 2 ) + 1 ) );
716 for (
unsigned int lIter = 0; lIter < static_cast<unsigned int> ( ( bandIter * 2 ) + 1 ); lIter++ )
718 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(lIter) = std::vector< std::array<double,2> > (
static_cast<unsigned int> ( ( bandIter * 2 ) + 1 ) );
725 maxShellsToUse = std::max ( this->one->_noShellsWithData, this->all->at(strIt)->_noShellsWithData );
726 minShellsToUse = std::min ( this->one->_noShellsWithData, this->all->at(strIt)->_noShellsWithData );
729 glIntegrationOrder = std::max ( glIntegOrderVec->at(0), glIntegOrderVec->at(strIt+1) );
730 glAbscissas = std::vector<double> ( glIntegrationOrder );
731 glWeights = std::vector<double> ( glIntegrationOrder );
732 ProSHADE_internal_legendre::getLegendreAbscAndWeights ( glIntegrationOrder, &glAbscissas, &glWeights, settings );
736 for (
unsigned int bandIter = 0; bandIter < localComparisonBandLim; bandIter++ )
739 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
743 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; } }
744 if ( toBeIgnored ) {
continue; }
747 for (
unsigned int orderIter = 0; orderIter < ( ( bandIter * 2 ) + 1 ); orderIter++ )
750 radiiVals1.clear ( );
751 radiiVals2.clear ( );
752 radiiVals1 = std::vector<double> ( this->one->_noShellsWithData );
753 radiiVals2 = std::vector<double> ( this->all->at(strIt)->_noShellsWithData );
756 index11 = seanindex ( orderIter-bandIter, bandIter, this->one->_bandwidthLimit );
757 index12 = seanindex ( orderIter-bandIter, bandIter, this->all->at(strIt)->_bandwidthLimit );
760 for (
unsigned int radiusIter = 0; radiusIter < maxShellsToUse; radiusIter++ )
762 if ( !firstDoneAlready )
764 if ( radiusIter < this->one->_noShellsWithData )
767 radiiVals1.at(radiusIter) = ProSHADE_internal_misc::complexMultiplicationConjugReal ( &this->one->_realSHCoeffs[radiusIter][index11],
768 &this->one->_imagSHCoeffs[radiusIter][index11],
769 &this->one->_realSHCoeffs[radiusIter][index11],
770 &this->one->_imagSHCoeffs[radiusIter][index11] );
773 radiiVals1.at(radiusIter) *= pow ( ( static_cast<double> ( radiusIter + 1 ) * shellSpacing ), 2.0 );
777 if ( radiusIter < this->all->at(strIt)->_noShellsWithData )
780 radiiVals2.at(radiusIter) = ProSHADE_internal_misc::complexMultiplicationConjugReal ( &this->all->at(strIt)->_realSHCoeffs[radiusIter][index12],
781 &this->all->at(strIt)->_imagSHCoeffs[radiusIter][index12],
782 &this->all->at(strIt)->_realSHCoeffs[radiusIter][index12],
783 &this->all->at(strIt)->_imagSHCoeffs[radiusIter][index12] );
786 radiiVals2.at(radiusIter) *= pow ( ( static_cast<double> ( radiusIter + 1 ) * shellSpacing ), 2.0 );
791 if ( !firstDoneAlready ) { trSigmaWeights.at(0) += this->glIntRR ( &radiiVals1, shellSpacing, &glAbscissas, &glWeights ); }
792 trSigmaWeights.at(strIt+1) += this->glIntRR ( &radiiVals2, shellSpacing, &glAbscissas, &glWeights );
795 for (
unsigned int order2Iter = 0; order2Iter < ( ( bandIter * 2 ) + 1 ); order2Iter++ )
798 index21 = seanindex ( orderIter-bandIter, bandIter, this->one->_bandwidthLimit );
799 index22 = seanindex ( order2Iter-bandIter, bandIter, this->all->at(strIt)->_bandwidthLimit );
803 radiiVals = std::vector< std::array<double,2> > ( minShellsToUse );
806 for (
unsigned int radiusIter = 0; radiusIter < minShellsToUse; radiusIter++ )
809 radiiVals.at(radiusIter) = ProSHADE_internal_misc::complexMultiplicationConjug ( &this->one->_realSHCoeffs[radiusIter][index21],
810 &this->one->_imagSHCoeffs[radiusIter][index21],
811 &this->all->at(strIt)->_realSHCoeffs[radiusIter][index22],
812 &this->all->at(strIt)->_imagSHCoeffs[radiusIter][index22] );
815 radiiVals.at(radiusIter)[0] *= pow ( ( static_cast<double> ( radiusIter + 1 ) * shellSpacing ), 2.0 );
816 radiiVals.at(radiusIter)[1] *= pow ( ( static_cast<double> ( radiusIter + 1 ) * shellSpacing ), 2.0 );
820 arrVal1 = this->glIntCR ( &radiiVals, shellSpacing, &glAbscissas, &glWeights );
823 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(orderIter).at(order2Iter)[0] = arrVal1[0];
824 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(orderIter).at(order2Iter)[1] = arrVal1[1];
832 correlNormFactor = sqrt ( trSigmaWeights.at(0) * trSigmaWeights.at(strIt+1) );
834 for (
unsigned int bandIter = 0; bandIter < localComparisonBandLim; bandIter++ )
837 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
841 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; } }
842 if ( toBeIgnored ) {
continue; }
845 for (
unsigned int orderIter = 0; orderIter < ( ( bandIter * 2 ) + 1 ); orderIter++ )
847 for (
unsigned int order2Iter = 0; order2Iter < ( ( bandIter * 2 ) + 1 ); order2Iter++ )
850 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(orderIter).at(order2Iter)[0] /= correlNormFactor;
851 this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(orderIter).at(order2Iter)[1] /= correlNormFactor;
857 firstDoneAlready =
true;
862 this->_trSigmaPreComputed =
true;
881 if ( !this->_trSigmaPreComputed )
883 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;
887 std::stringstream hlpSS;
888 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>";
889 rvapi_set_text ( hlpSS.str().c_str(),
903 if ( this->_trSigmaComputed )
905 return ( this->_distancesTraceSigma );
909 std::cout <<
">>>>>>>> Sanity checks passed." << std::endl;
913 this->_distancesTraceSigma = std::vector<double> ( this->all->size() );
914 std::vector<double> hlpVec;
915 unsigned int bandUsageIndex = 0;
916 bool toBeIgnored =
false;
917 unsigned int localComparisonBandLim = 0;
918 unsigned int fileUsageIndex = 0;
921 for (
unsigned int strIt = 0; strIt < static_cast<unsigned int> ( this->all->size() ); strIt++ )
924 if ( this->_enLevelsDoNotFollow.at(strIt) == 1 ) { this->_distancesTraceSigma.at(strIt) = -999.9;
continue; }
928 std::cout <<
">>>>>>>> Now computing distance between structure 0 and structure " << strIt+1 <<
" ." << std::endl;
933 localComparisonBandLim = std::min( this->one->_bandwidthLimit, this->all->at(strIt)->_bandwidthLimit );
934 this->_distancesTraceSigma.at(strIt) = 0.0;
937 for (
unsigned int lIter = 0; lIter < localComparisonBandLim; lIter++ )
940 if ( !this->_keepOrRemove ) {
if ( ( lIter % 2 ) != 0 ) {
continue; } }
944 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; } }
945 if ( toBeIgnored ) {
continue; }
948 hlpVec = this->getSingularValues ( fileUsageIndex, bandUsageIndex, static_cast<unsigned int> ( ( lIter * 2 ) + 1 ), settings );
951 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( hlpVec.size() ); iter++ )
953 this->_distancesTraceSigma.at(strIt) += hlpVec.at(iter);
963 std::cout <<
">>>>> Distance between structure 0 and structure " << strIt+1 <<
" computed." << std::endl;
968 this->_trSigmaComputed =
true;
971 return ( this->_distancesTraceSigma );
990 if ( !this->_wignerMatricesComputed )
992 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;
996 std::stringstream hlpSS;
997 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>";
998 rvapi_set_text ( hlpSS.str().c_str(),
1012 bool toBeIgnored =
false;
1013 double totSum = 0.0;
1014 unsigned int bandUsageIndex = 0;
1017 for (
int bandIter = 0; bandIter < static_cast<int> ( this->_bandwidthLimit ); bandIter++ )
1020 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
1023 toBeIgnored =
false;
1024 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; } }
1025 if ( toBeIgnored ) {
continue; }
1028 for (
int order1 = 0; order1 < static_cast<int> ( ( bandIter * 2 ) + 1 ); order1++ )
1031 for (
int order2 = 0; order2 < static_cast<int> ( ( bandIter * 2 ) + 1 ); order2++ )
1034 totSum += ProSHADE_internal_misc::complexMultiplicationReal ( &this->_wignerMatrices.at(bandIter).at(order1).at(order2)[0],
1035 &this->_wignerMatrices.at(bandIter).at(order1).at(order2)[1],
1036 &this->_trSigmaEMatrix[bandUsageIndex][order2][order1][0],
1037 &this->_trSigmaEMatrix[bandUsageIndex][order2][order1][1] );
1042 bandUsageIndex += 1;
1065 if ( !this->_wignerMatricesComputed )
1067 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;
1071 std::stringstream hlpSS;
1072 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>";
1073 rvapi_set_text ( hlpSS.str().c_str(),
1087 if ( this->_fullDistComputed )
1089 return ( this->_distancesFullRotation );
1093 std::cout <<
">>>>>>>> Sanity checks passed." << std::endl;
1097 bool toBeIgnored =
false;
1098 double totSum = 0.0;
1099 unsigned int bandUsageIndex = 0;
1100 unsigned int fileUsageIndex = 0;
1101 int localComparisonBandLim = 0;
1103 for (
unsigned int strIt = 0; strIt < static_cast<unsigned int> ( this->all->size() ); strIt++ )
1106 if ( this->_enLevelsDoNotFollow.at(strIt) == 1 ) { this->_distancesFullRotation.emplace_back( -999.9 );
continue; }
1107 if ( this->_trSigmaDoNotFollow.at(strIt) == 1 ) { this->_distancesFullRotation.emplace_back( -999.9 ); fileUsageIndex += 1;
continue; }
1111 std::cout <<
">>>>>>>> Now computing distance between structure 0 and structure " << strIt+1 <<
" ." << std::endl;
1115 localComparisonBandLim = std::min ( this->one->_bandwidthLimit, this->all->at(strIt)->_bandwidthLimit );
1118 toBeIgnored =
false;
1123 for (
int bandIter = 0; bandIter < static_cast<int> ( localComparisonBandLim ); bandIter++ )
1126 if ( !this->_keepOrRemove ) {
if ( ( bandIter % 2 ) != 0 ) {
continue; } }
1129 toBeIgnored =
false;
1130 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; } }
1131 if ( toBeIgnored ) {
continue; }
1134 for (
int order1 = 0; order1 < static_cast<int> ( ( bandIter * 2 ) + 1 ); order1++ )
1137 for (
int order2 = 0; order2 < static_cast<int> ( ( bandIter * 2 ) + 1 ); order2++ )
1140 totSum += ProSHADE_internal_misc::complexMultiplicationReal ( &this->_wignerMatrices.at(strIt).at(bandIter).at(order1).at(order2)[0],
1141 &this->_wignerMatrices.at(strIt).at(bandIter).at(order1).at(order2)[1],
1142 &this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(order2).at(order1)[0],
1143 &this->_EMatrices.at(fileUsageIndex).at(bandUsageIndex).at(order2).at(order1)[1] );
1148 bandUsageIndex += 1;
1152 this->_distancesFullRotation.emplace_back ( totSum );
1153 fileUsageIndex += 1;
1157 std::cout <<
">>>>> Distance between structure 0 and structure " << strIt+1 <<
" computed." << std::endl;
1162 this->_fullDistComputed =
true;
1165 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.