ProSHADE  0.7.6.0 (JUL 2021)
Protein Shape Detection
ProSHADE_maths.hpp
Go to the documentation of this file.
1 
23 //==================================================== ProSHADE
24 #include "ProSHADE_misc.hpp"
25 
26 //==================================================== almostEqual for comparing floating point numbers (BSD License, works on Windows as well as linux)
27 #include <almostEqual.hpp>
28 
29 //==================================================== Overinclusion protection
30 #ifndef PROSHADE_MATHS
31 #define PROSHADE_MATHS
32 
33 //==================================================== Declare LAPACK functions
34 extern "C"
35 {
36  // ... The complex matrix singular value decomposition function
37  extern void zgesdd_( char* jobz, int* m, int* n, std::complex<double>* a, int* lda, double* s, std::complex<double>* u, int* ldu, std::complex<double>* vt, int* ldvt, std::complex<double>* work, int* lwork, double* rwork, int* iwork, int* info );
38 }
39 
40 //==================================================== ProSHADE_internal_spheres Namespace
41 // ... NOTE: The full namespace is defined in ProSHADE_spheres.h ; however, as forward declaration
42 // ... would not work here, the ProSHADE_rotFun_sphere class needs to be defined here, making the
43 // ... organisation a bit messier.
45 {
54  {
55  private:
56  proshade_double radius;
57  proshade_double radiusMax;
58  proshade_double radiusMin;
59  proshade_unsign angularDim;
60  proshade_double representedAngle;
61  proshade_unsign sphereNumber;
62 
63  proshade_double* axesValues;
64  std::vector< std::pair< proshade_unsign,proshade_unsign > > peaks;
65  public:
66  ProSHADE_rotFun_sphere ( proshade_double rad, proshade_double radRange, proshade_unsign dim, proshade_double repAng, proshade_unsign sphNo );
67  ~ProSHADE_rotFun_sphere ( void );
68 
69  public:
70  proshade_double getRadius ( void );
71  proshade_double getMaxRadius ( void );
72  proshade_double getMinRadius ( void );
73  proshade_unsign getAngularDim ( void );
74  proshade_double getRepresentedAngle ( void );
75  proshade_unsign getSphereNumber ( void );
76  std::vector<std::pair<proshade_unsign,proshade_unsign>> getPeaks ( void );
77  proshade_double getSphereLatLonPosition ( proshade_unsign lattitude, proshade_unsign longitude );
78  proshade_double getSphereLatLonLinearInterpolationPos ( proshade_double lattitude, proshade_double longitude );
79 
80 
81  public:
82  void interpolateSphereValues ( proshade_complex* rotFun );
83  void findAllPeaks ( proshade_signed noSmNeighbours, std::vector< proshade_double >* allHeights );
84  void removeSmallPeaks ( proshade_double peakThres );
85  };
86 }
87 
88 //==================================================== ProSHADE_internal_io Namespace
96 {
105  {
106  private:
107  proshade_double a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33;
108  proshade_double xStartIndex, xRange, yStartIndex, yRange;
109 
110  public:
118  BicubicInterpolator ( proshade_double** areaToInterpolate, proshade_double xStart, proshade_double yStart )
119  {
120  //======================================== Save the original non-unit square positions
121  this->xStartIndex = xStart;
122  this->yStartIndex = yStart;
123 
124  //======================================== Prepare variables for converting from original indices to unit square
125  this->xRange = 1.0;
126  this->yRange = 1.0;
127 
128  //======================================== Precompute interpolators
129  this->a00 = areaToInterpolate[1][1];
130  this->a01 = - ( 0.5 * areaToInterpolate[1][0] ) +
131  ( 0.5 * areaToInterpolate[1][2] );
132  this->a02 = areaToInterpolate[1][0] -
133  ( 2.5 * areaToInterpolate[1][1] ) +
134  ( 2.0 * areaToInterpolate[1][2] ) -
135  ( 0.5 * areaToInterpolate[1][3] );
136  this->a03 = - ( 0.5 * areaToInterpolate[1][0] ) +
137  ( 1.5 * areaToInterpolate[1][1] ) -
138  ( 1.5 * areaToInterpolate[1][2] ) +
139  ( 0.5 * areaToInterpolate[1][3] );
140  this->a10 = - ( 0.5 * areaToInterpolate[0][1] ) +
141  ( 0.5 * areaToInterpolate[2][1] );
142  this->a11 = ( 0.25 * areaToInterpolate[0][0] ) -
143  ( 0.25 * areaToInterpolate[0][2] ) -
144  ( 0.25 * areaToInterpolate[2][0] ) +
145  ( 0.25 * areaToInterpolate[2][2] );
146  this->a12 = - ( 0.5 * areaToInterpolate[0][0] ) +
147  ( 1.25 * areaToInterpolate[0][1] ) -
148  areaToInterpolate[0][2] +
149  ( 0.25 * areaToInterpolate[0][3] ) +
150  ( 0.5 * areaToInterpolate[2][0] ) -
151  ( 1.25 * areaToInterpolate[2][1] ) +
152  areaToInterpolate[2][2] -
153  ( 0.25 * areaToInterpolate[2][3] );
154  this->a13 = ( 0.25 * areaToInterpolate[0][0] ) -
155  ( 0.75 * areaToInterpolate[0][1] ) +
156  ( 0.75 * areaToInterpolate[0][2] ) -
157  ( 0.25 * areaToInterpolate[0][3] ) -
158  ( 0.25 * areaToInterpolate[2][0] ) +
159  ( 0.75 * areaToInterpolate[2][1] ) -
160  ( 0.75 * areaToInterpolate[2][2] ) +
161  ( 0.25 * areaToInterpolate[2][3] );
162  this->a20 = areaToInterpolate[0][1] -
163  ( 2.5 * areaToInterpolate[1][1] ) +
164  ( 2.0 * areaToInterpolate[2][1] ) -
165  ( 0.5 * areaToInterpolate[3][1] );
166  this->a21 = - ( 0.5 * areaToInterpolate[0][0] ) +
167  ( 0.5 * areaToInterpolate[0][2] ) +
168  ( 1.25 * areaToInterpolate[1][0] ) -
169  ( 1.25 * areaToInterpolate[1][2] ) -
170  areaToInterpolate[2][0] + areaToInterpolate[2][2] +
171  ( 0.25 * areaToInterpolate[3][0] ) -
172  ( 0.25 * areaToInterpolate[3][2] );
173  this->a22 = areaToInterpolate[0][0] -
174  ( 2.5 * areaToInterpolate[0][1] ) +
175  ( 2.0 * areaToInterpolate[0][2] ) -
176  ( 0.5 * areaToInterpolate[0][3] ) -
177  ( 2.5 * areaToInterpolate[1][0] ) +
178  ( 6.25 * areaToInterpolate[1][1] ) -
179  ( 5.0 * areaToInterpolate[1][2] ) +
180  ( 1.25 * areaToInterpolate[1][3] ) +
181  ( 2.0 * areaToInterpolate[2][0] ) -
182  ( 5.0 * areaToInterpolate[2][1] ) +
183  ( 4.0 * areaToInterpolate[2][2] ) -
184  areaToInterpolate[2][3] -
185  ( 0.5 * areaToInterpolate[3][0] ) +
186  ( 1.25 * areaToInterpolate[3][1] ) -
187  areaToInterpolate[3][2] +
188  ( 0.25 * areaToInterpolate[3][3] );
189  this->a23 = - ( 0.5 * areaToInterpolate[0][0] ) +
190  ( 1.5 * areaToInterpolate[0][1] ) -
191  ( 1.5 * areaToInterpolate[0][2] ) +
192  ( 0.5 * areaToInterpolate[0][3] ) +
193  ( 1.25 * areaToInterpolate[1][0] ) -
194  ( 3.75 * areaToInterpolate[1][1] ) +
195  ( 3.75 * areaToInterpolate[1][2] ) -
196  ( 1.25 * areaToInterpolate[1][3] ) -
197  areaToInterpolate[2][0] +
198  ( 3.0 * areaToInterpolate[2][1] ) -
199  ( 3.0 * areaToInterpolate[2][2] ) +
200  areaToInterpolate[2][3] +
201  ( 0.25 * areaToInterpolate[3][0] ) -
202  ( 0.75 * areaToInterpolate[3][1] ) +
203  ( 0.75 * areaToInterpolate[3][2] ) -
204  ( 0.25 * areaToInterpolate[3][3] );
205  this->a30 = - ( 0.5 * areaToInterpolate[0][1] ) +
206  ( 1.5 * areaToInterpolate[1][1] ) -
207  ( 1.5 * areaToInterpolate[2][1] ) +
208  ( 0.5*areaToInterpolate[3][1] );
209  this->a31 = ( 0.25 * areaToInterpolate[0][0] ) -
210  ( 0.25 * areaToInterpolate[0][2] ) -
211  ( 0.75 * areaToInterpolate[1][0] ) +
212  ( 0.75 * areaToInterpolate[1][2] ) +
213  ( 0.75 * areaToInterpolate[2][0] ) -
214  ( 0.75 * areaToInterpolate[2][2] ) -
215  ( 0.25 * areaToInterpolate[3][0] ) +
216  ( 0.25 * areaToInterpolate[3][2] );
217  this->a32 = - ( 0.5 * areaToInterpolate[0][0] ) +
218  ( 1.25 * areaToInterpolate[0][1] ) -
219  areaToInterpolate[0][2] +
220  ( 0.25 * areaToInterpolate[0][3] ) +
221  ( 1.5 * areaToInterpolate[1][0] ) -
222  ( 3.75 * areaToInterpolate[1][1] ) +
223  ( 3.0 * areaToInterpolate[1][2] ) -
224  ( 0.75 * areaToInterpolate[1][3] ) -
225  ( 1.5 * areaToInterpolate[2][0] ) +
226  ( 3.75 * areaToInterpolate[2][1] ) -
227  ( 3.0 * areaToInterpolate[2][2] ) +
228  ( 0.75 * areaToInterpolate[2][3] ) +
229  ( 0.5 * areaToInterpolate[3][0] ) -
230  ( 1.25 * areaToInterpolate[3][1] ) +
231  areaToInterpolate[3][2] -
232  ( 0.25 * areaToInterpolate[3][3] );
233  this->a33 = ( 0.25 * areaToInterpolate[0][0] ) -
234  ( 0.75 * areaToInterpolate[0][1] ) +
235  ( 0.75 * areaToInterpolate[0][2] ) -
236  ( 0.25 * areaToInterpolate[0][3] ) -
237  ( 0.75 * areaToInterpolate[1][0] ) +
238  ( 2.25 * areaToInterpolate[1][1] ) -
239  ( 2.25 * areaToInterpolate[1][2] ) +
240  ( 0.75 * areaToInterpolate[1][3] ) +
241  ( 0.75 * areaToInterpolate[2][0] ) -
242  ( 2.25 * areaToInterpolate[2][1] ) +
243  ( 2.25 * areaToInterpolate[2][2] ) -
244  ( 0.75 * areaToInterpolate[2][3] ) -
245  ( 0.25 * areaToInterpolate[3][0] ) +
246  ( 0.75 * areaToInterpolate[3][1] ) -
247  ( 0.75 * areaToInterpolate[3][2] ) +
248  ( 0.25 * areaToInterpolate[3][3] );
249  }
250 
255  ~BicubicInterpolator ( void ) { ; }
256 
266  proshade_double getValue ( proshade_double x, proshade_double y )
267  {
268  //======================================== Sanity check
269  if ( ( ( x < this->xStartIndex ) || ( x > ( this->xStartIndex + this->xRange ) ) ) ||
270  ( ( y < this->yStartIndex ) || ( y > ( this->yStartIndex + this->yRange ) ) ) )
271  {
272  if ( ( x < this->xStartIndex ) || ( x > ( this->xStartIndex + this->xRange ) ) ) { std::cout << "PROBLEM WITH LAT" << std::endl; }
273  if ( ( y < this->yStartIndex ) || ( y > ( this->yStartIndex + this->yRange ) ) ) { std::cout << "PROBLEM WITH LON" << std::endl; }
274 
275  throw ProSHADE_exception ( "Requested bicubic interpolation outside of pre-computed\n : square.", "ES00064", __FILE__, __LINE__, __func__, "The supplied x or y value(s) is outside of the range of\n : the bi-cubic interpolator's pre-computed square. Please\n : make sure the start values were correctly supplied when\n : the constructor was called or create a new interpolator\n : for these values." );
276  }
277 
278  //======================================== Convert x and y to unit square
279  proshade_double unitSquareX = ( x - this->xStartIndex ) / this->xRange;
280  proshade_double unitSquareY = ( y - this->yStartIndex ) / this->yRange;
281 
282  //======================================== Precompute powers
283  proshade_double x2 = std::pow ( unitSquareX, 2.0 );
284  proshade_double x3 = std::pow ( unitSquareX, 3.0 );
285  proshade_double y2 = std::pow ( unitSquareY, 2.0 );
286  proshade_double y3 = std::pow ( unitSquareY, 3.0 );
287 
288  //======================================== Done
289  return ( ( this->a00 + this->a01 * unitSquareY + this->a02 * y2 + this->a03 * y3 ) +
290  ( this->a10 + this->a11 * unitSquareY + this->a12 * y2 + this->a13 * y3 ) * unitSquareX +
291  ( this->a20 + this->a21 * unitSquareY + this->a22 * y2 + this->a23 * y3 ) * x2 +
292  ( this->a30 + this->a31 * unitSquareY + this->a32 * y2 + this->a33 * y3 ) * x3 );
293  }
294  };
295 
296  void complexMultiplication ( proshade_double* r1, proshade_double* i1, proshade_double* r2, proshade_double* i2,
297  proshade_double* retReal, proshade_double* retImag );
298  void complexMultiplicationConjug ( proshade_double* r1, proshade_double* i1, proshade_double* r2, proshade_double* i2,
299  proshade_double* retReal, proshade_double* retImag );
300  proshade_double complexMultiplicationRealOnly ( proshade_double* r1, proshade_double* i1, proshade_double* r2, proshade_double* i2 );
301  proshade_double complexMultiplicationConjugRealOnly ( proshade_double* r1, proshade_double* i1, proshade_double* r2, proshade_double* i2 );
302  void vectorMeanAndSD ( std::vector<proshade_double>* vec, proshade_double*& ret );
303  void vectorMedianAndIQR ( std::vector<proshade_double>* vec, proshade_double*& ret );
304  void arrayMedianAndIQR ( proshade_double* vec, proshade_unsign vecSize, proshade_double*& ret );
305  proshade_double pearsonCorrCoeff ( proshade_double* valSet1, proshade_double* valSet2, proshade_unsign length );
306  void getLegendreAbscAndWeights ( proshade_unsign order, proshade_double* abscissas, proshade_double* weights,
307  proshade_unsign taylorSeriesCap );
308  void getGLPolyAtZero ( proshade_unsign order, proshade_double *polyValue, proshade_double *deriValue );
309  void getGLFirstEvenRoot ( proshade_double polyAtZero, proshade_unsign order, proshade_double *abscAtZero,
310  proshade_double *weighAtZero, proshade_unsign taylorSeriesCap );
311  proshade_double evaluateGLSeries ( proshade_double *series, proshade_double target, proshade_unsign terms );
312  proshade_double advanceGLPolyValue ( proshade_double from, proshade_double to, proshade_double valAtFrom,
313  proshade_unsign noSteps, proshade_unsign taylorSeriesCap );
314  void completeLegendreSeries ( proshade_unsign order, proshade_double* abscissa, proshade_double* weights,
315  proshade_unsign taylorSeriesCap );
316  proshade_double gaussLegendreIntegrationReal ( proshade_double* vals, proshade_unsign valsSize, proshade_unsign order,
317  proshade_double* abscissas, proshade_double* weights, proshade_double integralOverRange,
318  proshade_double maxSphereDists );
319  void gaussLegendreIntegration ( proshade_complex* vals, proshade_unsign valsSize, proshade_unsign order,
320  proshade_double* abscissas, proshade_double* weights, proshade_double integralOverRange,
321  proshade_double maxSphereDists, proshade_double* retReal, proshade_double* retImag );
322  void complexMatrixSVDSigmasOnly ( proshade_complex** mat, int dim, double*& singularValues );
323  void complexMatrixSVDUandVOnly ( proshade_double* mat, int dim, proshade_double* uAndV, bool fail = true );
324  void getEulerZXZFromSOFTPosition ( proshade_signed band, proshade_signed x, proshade_signed y, proshade_signed z, proshade_double* eulerAlpha,
325  proshade_double* eulerBeta, proshade_double* eulerGamma );
326  void getSOFTPositionFromEulerZXZ ( proshade_signed band, proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma,
327  proshade_double* x, proshade_double* y, proshade_double* z );
328  void getRotationMatrixFromEulerZXZAngles ( proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma, proshade_double* matrix );
329  void getRotationMatrixFromEulerZXZAngles ( proshade_single eulerAlpha, proshade_single eulerBeta, proshade_single eulerGamma, proshade_single* matrix );
330  void getAxisAngleFromRotationMatrix ( proshade_double* rotMat, proshade_double* x, proshade_double* y, proshade_double* z, proshade_double* ang );
331  void getAxisAngleFromRotationMatrix ( std::vector< proshade_double >* rotMat, proshade_double* x, proshade_double* y, proshade_double* z, proshade_double* ang );
332  void getRotationMatrixFromAngleAxis ( proshade_double* rotMat, proshade_double x, proshade_double y, proshade_double z, proshade_double ang );
333  void getRotationMatrixFromAngleAxis ( proshade_single* rotMat, proshade_double x, proshade_double y, proshade_double z, proshade_double ang );
334  void getEulerZXZFromRotMatrix ( proshade_double* rotMat, proshade_double* eA, proshade_double* eB, proshade_double* eG );
335  void getEulerZXZFromAngleAxis ( proshade_double axX, proshade_double axY, proshade_double axZ, proshade_double axAng, proshade_double* eA,
336  proshade_double* eB, proshade_double* eG );
337  void multiplyTwoSquareMatrices ( proshade_double* A, proshade_double* B, proshade_double* res, proshade_unsign dim = 3 );
338  std::vector < proshade_signed > primeFactorsDecomp ( proshade_signed number );
339  proshade_double normalDistributionValue ( proshade_double mean, proshade_double standardDev, proshade_double value );
340  proshade_double computeDotProduct ( proshade_double* x1, proshade_double* y1, proshade_double* z1, proshade_double* x2, proshade_double* y2,
341  proshade_double* z2 );
342  proshade_double computeDotProduct ( proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2,
343  proshade_double z2 );
344  proshade_double* computeCrossProduct ( proshade_double* x1, proshade_double* y1, proshade_double* z1, proshade_double* x2, proshade_double* y2,
345  proshade_double* z2 );
346  proshade_double* compute3x3MatrixMultiplication ( proshade_double* mat1, proshade_double* mat2 );
347  proshade_double* compute3x3MatrixVectorMultiplication ( proshade_double* mat, proshade_double x, proshade_double y, proshade_double z );
348  proshade_single* compute3x3MatrixVectorMultiplication ( proshade_single* mat, proshade_single x, proshade_single y, proshade_single z );
349  proshade_double* compute3x3MatrixInverse ( proshade_double* mat );
350  void transpose3x3MatrixInPlace ( proshade_double* mat );
351  proshade_double* findRotMatMatchingVectors ( proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2,
352  proshade_double z2 );
353  std::vector < proshade_double > findVectorFromTwoVAndTwoD ( proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2,
354  proshade_double z2, proshade_double dot1, proshade_double dot2 );
355  std::vector < proshade_double > findVectorFromThreeVAndThreeD ( proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2,
356  proshade_double z2, proshade_double x3, proshade_double y3, proshade_double z3, proshade_double dot1,
357  proshade_double dot2, proshade_double dot3 );
358  std::vector< proshade_double > multiplyGroupElementMatrices ( std::vector< proshade_double >* el1, std::vector< proshade_double >* el2 );
359  bool rotationMatrixSimilarity ( std::vector< proshade_double >* mat1, std::vector< proshade_double >* mat2, proshade_double tolerance = 0.1 );
360  bool vectorOrientationSimilarity ( proshade_double a1, proshade_double a2, proshade_double a3, proshade_double b1, proshade_double b2,
361  proshade_double b3, proshade_double tolerance = 0.1 );
362  bool vectorOrientationSimilaritySameDirection ( proshade_double a1, proshade_double a2, proshade_double a3, proshade_double b1, proshade_double b2,
363  proshade_double b3, proshade_double tolerance = 0.1 );
364  void optimiseAxisBiCubicInterpolation ( proshade_double* bestLattitude, proshade_double* bestLongitude, proshade_double* bestSum, std::vector<proshade_unsign>* sphereList,
365  std::vector<ProSHADE_internal_spheres::ProSHADE_rotFun_sphere*>* sphereMappedRotFun, proshade_double step = 0.05 );
366  void prepareBiCubicInterpolatorsMinusMinus ( proshade_double bestLattitude, proshade_double bestLongitude, std::vector<proshade_unsign>* sphereList,
367  std::vector<ProSHADE_internal_maths::BicubicInterpolator*>* interpols, std::vector<ProSHADE_internal_spheres::ProSHADE_rotFun_sphere*>* sphereMappedRotFun );
368  void prepareBiCubicInterpolatorsMinusPlus ( proshade_double bestLattitude, proshade_double bestLongitude, std::vector<proshade_unsign>* sphereList,
369  std::vector<ProSHADE_internal_maths::BicubicInterpolator*>* interpols, std::vector<ProSHADE_internal_spheres::ProSHADE_rotFun_sphere*>* sphereMappedRotFun );
370  void prepareBiCubicInterpolatorsPlusMinus ( proshade_double bestLattitude, proshade_double bestLongitude, std::vector<proshade_unsign>* sphereList,
371  std::vector<ProSHADE_internal_maths::BicubicInterpolator*>* interpols, std::vector<ProSHADE_internal_spheres::ProSHADE_rotFun_sphere*>* sphereMappedRotFun );
372  void prepareBiCubicInterpolatorsPlusPlus ( proshade_double bestLattitude, proshade_double bestLongitude, std::vector<proshade_unsign>* sphereList,
373  std::vector<ProSHADE_internal_maths::BicubicInterpolator*>* interpols, std::vector<ProSHADE_internal_spheres::ProSHADE_rotFun_sphere*>* sphereMappedRotFun );
374  bool isAxisUnique ( std::vector< proshade_double* >* CSymList, proshade_double* axis, proshade_double tolerance = 0.1, bool improve = false );
375  bool isAxisUnique ( std::vector< proshade_double* >* CSymList, proshade_double X, proshade_double Y, proshade_double Z, proshade_double fold, proshade_double tolerance );
376  std::vector< proshade_unsign > findAllPrimes ( proshade_unsign upTo );
377  proshade_double computeGaussian ( proshade_double val, proshade_double sigma );
378  std::vector < proshade_double > smoothen1D ( proshade_double step, proshade_signed windowSize, proshade_double sigma, std::vector< proshade_double > data );
379  proshade_single getResolutionOfReflection ( proshade_single h, proshade_single k, proshade_single l, proshade_single xDim, proshade_single yDim, proshade_single zDim );
380  void binReciprocalSpaceReflections ( proshade_unsign xInds, proshade_unsign yInds, proshade_unsign zInds, proshade_signed* noBin, proshade_signed*& binIndexing );
381  proshade_double computeFSC ( fftw_complex *fCoeffs1, fftw_complex *fCoeffs2, proshade_unsign xInds, proshade_unsign yInds, proshade_unsign zInds,
382  proshade_signed noBins, proshade_signed* binIndexing, proshade_double**& binData, proshade_signed*& binCounts );
383 }
384 
385 #endif
ProSHADE_internal_maths::gaussLegendreIntegration
void gaussLegendreIntegration(proshade_complex *vals, proshade_unsign valsSize, proshade_unsign order, proshade_double *abscissas, proshade_double *weights, proshade_double integralOverRange, proshade_double maxSphereDists, proshade_double *retReal, proshade_double *retImag)
Function to compute the complete complex Gauss-Legendre integration over spherical harmonic values in...
Definition: ProSHADE_maths.cpp:711
ProSHADE_internal_maths::findVectorFromThreeVAndThreeD
std::vector< proshade_double > findVectorFromThreeVAndThreeD(proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2, proshade_double z2, proshade_double x3, proshade_double y3, proshade_double z3, proshade_double dot1, proshade_double dot2, proshade_double dot3)
Function for finding a vector which would have a given three dot products to three other vectors.
Definition: ProSHADE_maths.cpp:2201
ProSHADE_internal_maths::gaussLegendreIntegrationReal
proshade_double gaussLegendreIntegrationReal(proshade_double *vals, proshade_unsign valsSize, proshade_unsign order, proshade_double *abscissas, proshade_double *weights, proshade_double integralOverRange, proshade_double maxSphereDists)
Function to compute real part of the Gauss-Legendre integration over spherical harmonic values in dif...
Definition: ProSHADE_maths.cpp:621
ProSHADE_internal_maths::vectorMeanAndSD
void vectorMeanAndSD(std::vector< proshade_double > *vec, proshade_double *&ret)
Function to get vector mean and standard deviation.
Definition: ProSHADE_maths.cpp:121
ProSHADE_internal_maths::prepareBiCubicInterpolatorsMinusPlus
void prepareBiCubicInterpolatorsMinusPlus(proshade_double bestLattitude, proshade_double bestLongitude, std::vector< proshade_unsign > *sphereList, std::vector< ProSHADE_internal_maths::BicubicInterpolator * > *interpols, std::vector< ProSHADE_internal_spheres::ProSHADE_rotFun_sphere * > *sphereMappedRotFun)
This function prepares the interpolation objects for the bi-cubic interpolation.
Definition: ProSHADE_maths.cpp:2556
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getMinRadius
proshade_double getMinRadius(void)
Accessor function for the private variable minimal radius.
Definition: ProSHADE_spheres.cpp:713
ProSHADE_internal_maths::computeCrossProduct
proshade_double * computeCrossProduct(proshade_double *x1, proshade_double *y1, proshade_double *z1, proshade_double *x2, proshade_double *y2, proshade_double *z2)
Simple 3D vector cross product computation.
Definition: ProSHADE_maths.cpp:1809
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getSphereNumber
proshade_unsign getSphereNumber(void)
Accessor function for the private variable sphere number.
Definition: ProSHADE_spheres.cpp:735
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere
This class contains all inputed data for the rotation function angle-axis converted spheres.
Definition: ProSHADE_maths.hpp:54
ProSHADE_internal_maths::getEulerZXZFromRotMatrix
void getEulerZXZFromRotMatrix(proshade_double *rotMat, proshade_double *eA, proshade_double *eB, proshade_double *eG)
This function converts rotation matrix to the Euler ZXZ angles representation.
Definition: ProSHADE_maths.cpp:1551
ProSHADE_exception
This class is the representation of ProSHADE exception.
Definition: ProSHADE_exceptions.hpp:37
ProSHADE_internal_maths::normalDistributionValue
proshade_double normalDistributionValue(proshade_double mean, proshade_double standardDev, proshade_double value)
Function to the heiht of normal distribution given by mean and standard deviation for a given value.
Definition: ProSHADE_maths.cpp:1760
ProSHADE_internal_maths::prepareBiCubicInterpolatorsPlusMinus
void prepareBiCubicInterpolatorsPlusMinus(proshade_double bestLattitude, proshade_double bestLongitude, std::vector< proshade_unsign > *sphereList, std::vector< ProSHADE_internal_maths::BicubicInterpolator * > *interpols, std::vector< ProSHADE_internal_spheres::ProSHADE_rotFun_sphere * > *sphereMappedRotFun)
This function prepares the interpolation objects for the bi-cubic interpolation.
Definition: ProSHADE_maths.cpp:2611
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::~ProSHADE_rotFun_sphere
~ProSHADE_rotFun_sphere(void)
Destructor for releasing memory from the ProSHADE_rotFun_sphere class.
Definition: ProSHADE_spheres.cpp:668
ProSHADE_internal_maths::evaluateGLSeries
proshade_double evaluateGLSeries(proshade_double *series, proshade_double target, proshade_unsign terms)
This function evaluates the Taylor expansion.
Definition: ProSHADE_maths.cpp:449
ProSHADE_internal_maths::getSOFTPositionFromEulerZXZ
void getSOFTPositionFromEulerZXZ(proshade_signed band, proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma, proshade_double *x, proshade_double *y, proshade_double *z)
Function to find the index position in the inverse SOFT map from given Euler angles (ZXZ convention).
Definition: ProSHADE_maths.cpp:988
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getRepresentedAngle
proshade_double getRepresentedAngle(void)
Accessor function for the private variable represented angle.
Definition: ProSHADE_spheres.cpp:724
ProSHADE_internal_maths::BicubicInterpolator::getValue
proshade_double getValue(proshade_double x, proshade_double y)
This function allows accessing the interpolated value for a given position x and y.
Definition: ProSHADE_maths.hpp:266
ProSHADE_internal_maths::getRotationMatrixFromEulerZXZAngles
void getRotationMatrixFromEulerZXZAngles(proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma, proshade_double *matrix)
Function to find the rotation matrix from Euler angles (ZXZ convention).
Definition: ProSHADE_maths.cpp:1011
ProSHADE_misc.hpp
This header file declares all miscellaneous functions.
ProSHADE_internal_maths::complexMultiplication
void complexMultiplication(proshade_double *r1, proshade_double *i1, proshade_double *r2, proshade_double *i2, proshade_double *retReal, proshade_double *retImag)
Function to multiply two complex numbers.
Definition: ProSHADE_maths.cpp:38
ProSHADE_internal_maths::BicubicInterpolator::~BicubicInterpolator
~BicubicInterpolator(void)
This is the destructor for the BicubicInterpolator class.
Definition: ProSHADE_maths.hpp:255
ProSHADE_internal_maths::getGLFirstEvenRoot
void getGLFirstEvenRoot(proshade_double polyAtZero, proshade_unsign order, proshade_double *abscAtZero, proshade_double *weighAtZero, proshade_unsign taylorSeriesCap)
This function finds the first root for Legendre polynomials of odd order.
Definition: ProSHADE_maths.cpp:386
ProSHADE_internal_maths::getEulerZXZFromAngleAxis
void getEulerZXZFromAngleAxis(proshade_double axX, proshade_double axY, proshade_double axZ, proshade_double axAng, proshade_double *eA, proshade_double *eB, proshade_double *eG)
This function converts angle-axis representation to the Euler ZXZ angles representation.
Definition: ProSHADE_maths.cpp:1602
ProSHADE_internal_maths::optimiseAxisBiCubicInterpolation
void optimiseAxisBiCubicInterpolation(proshade_double *bestLattitude, proshade_double *bestLongitude, proshade_double *bestSum, std::vector< proshade_unsign > *sphereList, std::vector< ProSHADE_internal_spheres::ProSHADE_rotFun_sphere * > *sphereMappedRotFun, proshade_double step=0.05)
This function provides axis optimisation given starting lattitude and longitude indices.
Definition: ProSHADE_maths.cpp:2400
ProSHADE_internal_maths::vectorOrientationSimilarity
bool vectorOrientationSimilarity(proshade_double a1, proshade_double a2, proshade_double a3, proshade_double b1, proshade_double b2, proshade_double b3, proshade_double tolerance=0.1)
This function compares two vectors using cosine distance and decides if they are similar using tolera...
Definition: ProSHADE_maths.cpp:2336
ProSHADE_internal_maths::complexMatrixSVDSigmasOnly
void complexMatrixSVDSigmasOnly(proshade_complex **mat, int dim, double *&singularValues)
Function to compute the complete complex matrix SVD and return only the sigmas.
Definition: ProSHADE_maths.cpp:804
ProSHADE_internal_maths::prepareBiCubicInterpolatorsMinusMinus
void prepareBiCubicInterpolatorsMinusMinus(proshade_double bestLattitude, proshade_double bestLongitude, std::vector< proshade_unsign > *sphereList, std::vector< ProSHADE_internal_maths::BicubicInterpolator * > *interpols, std::vector< ProSHADE_internal_spheres::ProSHADE_rotFun_sphere * > *sphereMappedRotFun)
This function prepares the interpolation objects for the bi-cubic interpolation.
Definition: ProSHADE_maths.cpp:2501
ProSHADE_internal_maths::vectorOrientationSimilaritySameDirection
bool vectorOrientationSimilaritySameDirection(proshade_double a1, proshade_double a2, proshade_double a3, proshade_double b1, proshade_double b2, proshade_double b3, proshade_double tolerance=0.1)
This function compares two vectors using cosine distance and decides if they are similar using tolera...
Definition: ProSHADE_maths.cpp:2370
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getMaxRadius
proshade_double getMaxRadius(void)
Accessor function for the private variable maximum radius.
Definition: ProSHADE_spheres.cpp:691
ProSHADE_internal_maths::computeGaussian
proshade_double computeGaussian(proshade_double val, proshade_double sigma)
This function computes a Gaussian (normal) distribution value given distance from mean and sigma.
Definition: ProSHADE_maths.cpp:2847
ProSHADE_internal_maths::pearsonCorrCoeff
proshade_double pearsonCorrCoeff(proshade_double *valSet1, proshade_double *valSet2, proshade_unsign length)
Function for computing the Pearson's correlation coefficient.
Definition: ProSHADE_maths.cpp:246
ProSHADE_internal_maths::computeFSC
proshade_double computeFSC(fftw_complex *fCoeffs1, fftw_complex *fCoeffs2, proshade_unsign xInds, proshade_unsign yInds, proshade_unsign zInds, proshade_signed noBins, proshade_signed *binIndexing, proshade_double **&binData, proshade_signed *&binCounts)
This function computes the FSC.
Definition: ProSHADE_maths.cpp:3090
ProSHADE_internal_maths::BicubicInterpolator::BicubicInterpolator
BicubicInterpolator(proshade_double **areaToInterpolate, proshade_double xStart, proshade_double yStart)
This is the constructor for the BicubicInterpolator class.
Definition: ProSHADE_maths.hpp:118
ProSHADE_internal_maths::computeDotProduct
proshade_double computeDotProduct(proshade_double *x1, proshade_double *y1, proshade_double *z1, proshade_double *x2, proshade_double *y2, proshade_double *z2)
Simple 3D vector dot product computation.
Definition: ProSHADE_maths.cpp:1777
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::findAllPeaks
void findAllPeaks(proshade_signed noSmNeighbours, std::vector< proshade_double > *allHeights)
Function for finding all peaks in the sampling grid.
Definition: ProSHADE_spheres.cpp:921
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::removeSmallPeaks
void removeSmallPeaks(proshade_double peakThres)
Function for removing peaks with too small height.
Definition: ProSHADE_spheres.cpp:983
ProSHADE_internal_maths::complexMultiplicationConjugRealOnly
proshade_double complexMultiplicationConjugRealOnly(proshade_double *r1, proshade_double *i1, proshade_double *r2, proshade_double *i2)
Function to conjuggate multiply two complex numbers and return the real part only.
Definition: ProSHADE_maths.cpp:103
ProSHADE_internal_maths::getRotationMatrixFromAngleAxis
void getRotationMatrixFromAngleAxis(proshade_double *rotMat, proshade_double x, proshade_double y, proshade_double z, proshade_double ang)
This function converts the axis-angle representation to the rotation matrix representation.
Definition: ProSHADE_maths.cpp:1448
ProSHADE_internal_maths::binReciprocalSpaceReflections
void binReciprocalSpaceReflections(proshade_unsign xInds, proshade_unsign yInds, proshade_unsign zInds, proshade_signed *noBin, proshade_signed *&binIndexing)
This function does binning of the reciprocal space reflections.
Definition: ProSHADE_maths.cpp:2943
ProSHADE_internal_maths
This namespace contains the internal functions for common mathematical operations.
ProSHADE_internal_maths::smoothen1D
std::vector< proshade_double > smoothen1D(proshade_double step, proshade_signed windowSize, proshade_double sigma, std::vector< proshade_double > data)
This function takes a 1D vector and computes smoothened version based on the parameters.
Definition: ProSHADE_maths.cpp:2873
ProSHADE_internal_maths::BicubicInterpolator
Definition: ProSHADE_maths.hpp:105
ProSHADE_internal_maths::primeFactorsDecomp
std::vector< proshade_signed > primeFactorsDecomp(proshade_signed number)
Function to find prime factors of an integer.
Definition: ProSHADE_maths.cpp:1711
ProSHADE_internal_maths::getGLPolyAtZero
void getGLPolyAtZero(proshade_unsign order, proshade_double *polyValue, proshade_double *deriValue)
This function obtains the Legendre polynomial values and its derivative at zero for any positive inte...
Definition: ProSHADE_maths.cpp:349
ProSHADE_internal_maths::isAxisUnique
bool isAxisUnique(std::vector< proshade_double * > *CSymList, proshade_double *axis, proshade_double tolerance=0.1, bool improve=false)
This function checks if new axis is unique, or already detected.
Definition: ProSHADE_maths.cpp:2721
ProSHADE_internal_maths::getLegendreAbscAndWeights
void getLegendreAbscAndWeights(proshade_unsign order, proshade_double *abscissas, proshade_double *weights, proshade_unsign taylorSeriesCap)
Function to prepare abscissas and weights for Gauss-Legendre integration.
Definition: ProSHADE_maths.cpp:289
ProSHADE_internal_maths::getAxisAngleFromRotationMatrix
void getAxisAngleFromRotationMatrix(proshade_double *rotMat, proshade_double *x, proshade_double *y, proshade_double *z, proshade_double *ang)
This function converts rotation matrix to the axis-angle representation.
Definition: ProSHADE_maths.cpp:1128
ProSHADE_internal_maths::advanceGLPolyValue
proshade_double advanceGLPolyValue(proshade_double from, proshade_double to, proshade_double valAtFrom, proshade_unsign noSteps, proshade_unsign taylorSeriesCap)
This function finds the next value of the polynomial.
Definition: ProSHADE_maths.cpp:479
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::ProSHADE_rotFun_sphere
ProSHADE_rotFun_sphere(proshade_double rad, proshade_double radRange, proshade_unsign dim, proshade_double repAng, proshade_unsign sphNo)
Constructor for getting empty ProSHADE_rotFun_sphere class.
Definition: ProSHADE_spheres.cpp:645
ProSHADE_internal_maths::findRotMatMatchingVectors
proshade_double * findRotMatMatchingVectors(proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2, proshade_double z2)
Computation of rotation matrix rotating one vector onto the other.
Definition: ProSHADE_maths.cpp:1979
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getSphereLatLonPosition
proshade_double getSphereLatLonPosition(proshade_unsign lattitude, proshade_unsign longitude)
Accessor function for specific lattitude and longitude point of the sphere sampling grid.
Definition: ProSHADE_spheres.cpp:861
ProSHADE_internal_maths::compute3x3MatrixVectorMultiplication
proshade_double * compute3x3MatrixVectorMultiplication(proshade_double *mat, proshade_double x, proshade_double y, proshade_double z)
Function for computing a 3x3 matrix to 3x1 vector multiplication.
Definition: ProSHADE_maths.cpp:1861
ProSHADE_internal_spheres
This namespace contains the structure and functions required for storing internal map projections ont...
Definition: ProSHADE_maths.hpp:45
ProSHADE_internal_maths::rotationMatrixSimilarity
bool rotationMatrixSimilarity(std::vector< proshade_double > *mat1, std::vector< proshade_double > *mat2, proshade_double tolerance=0.1)
This function compares the distance between two rotation matrices and decides if they are similar usi...
Definition: ProSHADE_maths.cpp:2299
ProSHADE_internal_maths::getEulerZXZFromSOFTPosition
void getEulerZXZFromSOFTPosition(proshade_signed band, proshade_signed x, proshade_signed y, proshade_signed z, proshade_double *eulerAlpha, proshade_double *eulerBeta, proshade_double *eulerGamma)
Function to find Euler angles (ZXZ convention) from index position in the inverse SOFT map.
Definition: ProSHADE_maths.cpp:963
ProSHADE_internal_maths::vectorMedianAndIQR
void vectorMedianAndIQR(std::vector< proshade_double > *vec, proshade_double *&ret)
Function to get vector median and inter-quartile range.
Definition: ProSHADE_maths.cpp:149
ProSHADE_internal_maths::complexMultiplicationConjug
void complexMultiplicationConjug(proshade_double *r1, proshade_double *i1, proshade_double *r2, proshade_double *i2, proshade_double *retReal, proshade_double *retImag)
Function to multiply two complex numbers by using the second number's conjugate.
Definition: ProSHADE_maths.cpp:62
ProSHADE_internal_maths::transpose3x3MatrixInPlace
void transpose3x3MatrixInPlace(proshade_double *mat)
Transposes 3x3 matrix in place.
Definition: ProSHADE_maths.cpp:1939
ProSHADE_internal_maths::completeLegendreSeries
void completeLegendreSeries(proshade_unsign order, proshade_double *abscissa, proshade_double *weights, proshade_unsign taylorSeriesCap)
This function completes the Legendre polynomial series assuming you have obtained the first values.
Definition: ProSHADE_maths.cpp:523
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getRadius
proshade_double getRadius(void)
Accessor function for the private variable radius.
Definition: ProSHADE_spheres.cpp:681
ProSHADE_internal_maths::findVectorFromTwoVAndTwoD
std::vector< proshade_double > findVectorFromTwoVAndTwoD(proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2, proshade_double z2, proshade_double dot1, proshade_double dot2)
Function for finding a vector which would have a given two dot products to two other vectors.
Definition: ProSHADE_maths.cpp:2055
ProSHADE_internal_maths::prepareBiCubicInterpolatorsPlusPlus
void prepareBiCubicInterpolatorsPlusPlus(proshade_double bestLattitude, proshade_double bestLongitude, std::vector< proshade_unsign > *sphereList, std::vector< ProSHADE_internal_maths::BicubicInterpolator * > *interpols, std::vector< ProSHADE_internal_spheres::ProSHADE_rotFun_sphere * > *sphereMappedRotFun)
This function prepares the interpolation objects for the bi-cubic interpolation.
Definition: ProSHADE_maths.cpp:2666
ProSHADE_internal_maths::multiplyTwoSquareMatrices
void multiplyTwoSquareMatrices(proshade_double *A, proshade_double *B, proshade_double *res, proshade_unsign dim=3)
Function to compute matrix multiplication.
Definition: ProSHADE_maths.cpp:1685
ProSHADE_internal_maths::getResolutionOfReflection
proshade_single getResolutionOfReflection(proshade_single h, proshade_single k, proshade_single l, proshade_single xDim, proshade_single yDim, proshade_single zDim)
This function computes the resolution of a particular reflection.
Definition: ProSHADE_maths.cpp:2909
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getSphereLatLonLinearInterpolationPos
proshade_double getSphereLatLonLinearInterpolationPos(proshade_double lattitude, proshade_double longitude)
Function for obtaining sphere values outside of the grid points.
Definition: ProSHADE_spheres.cpp:875
ProSHADE_internal_maths::findAllPrimes
std::vector< proshade_unsign > findAllPrimes(proshade_unsign upTo)
This function finds all prime numbers up to the supplied limit.
Definition: ProSHADE_maths.cpp:2802
ProSHADE_internal_maths::compute3x3MatrixInverse
proshade_double * compute3x3MatrixInverse(proshade_double *mat)
Function for computing a 3x3 matrix inverse.
Definition: ProSHADE_maths.cpp:1906
ProSHADE_internal_maths::complexMatrixSVDUandVOnly
void complexMatrixSVDUandVOnly(proshade_double *mat, int dim, proshade_double *uAndV, bool fail=true)
Function to compute the real matrix SVD and return the U and V matrices.
Definition: ProSHADE_maths.cpp:871
ProSHADE_internal_maths::arrayMedianAndIQR
void arrayMedianAndIQR(proshade_double *vec, proshade_unsign vecSize, proshade_double *&ret)
Function to get array median and inter-quartile range.
Definition: ProSHADE_maths.cpp:200
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getAngularDim
proshade_unsign getAngularDim(void)
Accessor function for the private variable angular dim.
Definition: ProSHADE_spheres.cpp:702
ProSHADE_internal_maths::multiplyGroupElementMatrices
std::vector< proshade_double > multiplyGroupElementMatrices(std::vector< proshade_double > *el1, std::vector< proshade_double > *el2)
This function computes matrix multiplication using the ProSHADE group element matrix format as input ...
Definition: ProSHADE_maths.cpp:2245
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::interpolateSphereValues
void interpolateSphereValues(proshade_complex *rotFun)
Function for interpolating the sphere grid values from angle-axis converted rotation function.
Definition: ProSHADE_spheres.cpp:762
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getPeaks
std::vector< std::pair< proshade_unsign, proshade_unsign > > getPeaks(void)
Accessor function for the private variable containing all detected peaks.
Definition: ProSHADE_spheres.cpp:746
ProSHADE_internal_maths::complexMultiplicationRealOnly
proshade_double complexMultiplicationRealOnly(proshade_double *r1, proshade_double *i1, proshade_double *r2, proshade_double *i2)
Function to multiply two complex numbers and return the real part only.
Definition: ProSHADE_maths.cpp:83
ProSHADE_internal_maths::compute3x3MatrixMultiplication
proshade_double * compute3x3MatrixMultiplication(proshade_double *mat1, proshade_double *mat2)
Function for computing a 3x3 matrix multiplication.
Definition: ProSHADE_maths.cpp:1831