ProSHADE  0.7.5.4 (MAR 2021)
Protein Shape Detection
ProSHADE_maths.hpp
Go to the documentation of this file.
1 
23 //==================================================== ProSHADE
24 #include "ProSHADE_misc.hpp"
25 
26 //==================================================== Overinclusion protection
27 #ifndef __PROSHADE_MATHS__
28 #define __PROSHADE_MATHS__
29 
30 //==================================================== Declare LAPACK functions
31 extern "C"
32 {
33  // ... The complex matrix singular value decomposition function
34  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 );
35 }
36 
37 //==================================================== ProSHADE_internal_spheres Namespace
38 // ... NOTE: The full namespace is defined in ProSHADE_spheres.h ; however, as forward declaration
39 // ... would not work here, the ProSHADE_rotFun_sphere class needs to be defined here, making the
40 // ... organisation a bit messier.
42 {
51  {
52  private:
53  proshade_double radius;
54  proshade_double radiusMax;
55  proshade_double radiusMin;
56  proshade_unsign angularDim;
57  proshade_double representedAngle;
58  proshade_unsign sphereNumber;
59 
60  proshade_double* axesValues;
61  std::vector< std::pair< proshade_unsign,proshade_unsign > > peaks;
62  public:
63  ProSHADE_rotFun_sphere ( proshade_double rad, proshade_double radRange, proshade_unsign dim, proshade_double repAng, proshade_unsign sphNo );
64  ~ProSHADE_rotFun_sphere ( void );
65 
66  public:
67  proshade_double getRadius ( void );
68  proshade_double getMaxRadius ( void );
69  proshade_double getMinRadius ( void );
70  proshade_unsign getAngularDim ( void );
71  proshade_double getRepresentedAngle ( void );
72  proshade_unsign getSphereNumber ( void );
73  std::vector<std::pair<proshade_unsign,proshade_unsign>> getPeaks ( void );
74  proshade_double getSphereLatLonPosition ( proshade_unsign lattitude, proshade_unsign longitude );
75  proshade_double getSphereLatLonLinearInterpolationPos ( proshade_double lattitude, proshade_double longitude );
76 
77 
78  public:
79  void interpolateSphereValues ( proshade_complex* rotFun );
80  void findAllPeaks ( proshade_signed noSmNeighbours, std::vector< proshade_double >* allHeights );
81  void removeSmallPeaks ( proshade_double peakThres );
82  };
83 }
84 
85 //==================================================== ProSHADE_internal_io Namespace
93 {
102  {
103  private:
104  proshade_double a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33;
105  proshade_double xStartIndex, xRange, yStartIndex, yRange;
106 
107  public:
115  BicubicInterpolator ( proshade_double** areaToInterpolate, proshade_double xStart, proshade_double yStart )
116  {
117  //======================================== Save the original non-unit square positions
118  this->xStartIndex = xStart;
119  this->yStartIndex = yStart;
120 
121  //======================================== Prepare variables for converting from original indices to unit square
122  this->xRange = 1.0;
123  this->yRange = 1.0;
124 
125  //======================================== Precompute interpolators
126  this->a00 = areaToInterpolate[1][1];
127  this->a01 = - ( 0.5 * areaToInterpolate[1][0] ) +
128  ( 0.5 * areaToInterpolate[1][2] );
129  this->a02 = areaToInterpolate[1][0] -
130  ( 2.5 * areaToInterpolate[1][1] ) +
131  ( 2.0 * areaToInterpolate[1][2] ) -
132  ( 0.5 * areaToInterpolate[1][3] );
133  this->a03 = - ( 0.5 * areaToInterpolate[1][0] ) +
134  ( 1.5 * areaToInterpolate[1][1] ) -
135  ( 1.5 * areaToInterpolate[1][2] ) +
136  ( 0.5 * areaToInterpolate[1][3] );
137  this->a10 = - ( 0.5 * areaToInterpolate[0][1] ) +
138  ( 0.5 * areaToInterpolate[2][1] );
139  this->a11 = ( 0.25 * areaToInterpolate[0][0] ) -
140  ( 0.25 * areaToInterpolate[0][2] ) -
141  ( 0.25 * areaToInterpolate[2][0] ) +
142  ( 0.25 * areaToInterpolate[2][2] );
143  this->a12 = - ( 0.5 * areaToInterpolate[0][0] ) +
144  ( 1.25 * areaToInterpolate[0][1] ) -
145  areaToInterpolate[0][2] +
146  ( 0.25 * areaToInterpolate[0][3] ) +
147  ( 0.5 * areaToInterpolate[2][0] ) -
148  ( 1.25 * areaToInterpolate[2][1] ) +
149  areaToInterpolate[2][2] -
150  ( 0.25 * areaToInterpolate[2][3] );
151  this->a13 = ( 0.25 * areaToInterpolate[0][0] ) -
152  ( 0.75 * areaToInterpolate[0][1] ) +
153  ( 0.75 * areaToInterpolate[0][2] ) -
154  ( 0.25 * areaToInterpolate[0][3] ) -
155  ( 0.25 * areaToInterpolate[2][0] ) +
156  ( 0.75 * areaToInterpolate[2][1] ) -
157  ( 0.75 * areaToInterpolate[2][2] ) +
158  ( 0.25 * areaToInterpolate[2][3] );
159  this->a20 = areaToInterpolate[0][1] -
160  ( 2.5 * areaToInterpolate[1][1] ) +
161  ( 2.0 * areaToInterpolate[2][1] ) -
162  ( 0.5 * areaToInterpolate[3][1] );
163  this->a21 = - ( 0.5 * areaToInterpolate[0][0] ) +
164  ( 0.5 * areaToInterpolate[0][2] ) +
165  ( 1.25 * areaToInterpolate[1][0] ) -
166  ( 1.25 * areaToInterpolate[1][2] ) -
167  areaToInterpolate[2][0] + areaToInterpolate[2][2] +
168  ( 0.25 * areaToInterpolate[3][0] ) -
169  ( 0.25 * areaToInterpolate[3][2] );
170  this->a22 = areaToInterpolate[0][0] -
171  ( 2.5 * areaToInterpolate[0][1] ) +
172  ( 2.0 * areaToInterpolate[0][2] ) -
173  ( 0.5 * areaToInterpolate[0][3] ) -
174  ( 2.5 * areaToInterpolate[1][0] ) +
175  ( 6.25 * areaToInterpolate[1][1] ) -
176  ( 5.0 * areaToInterpolate[1][2] ) +
177  ( 1.25 * areaToInterpolate[1][3] ) +
178  ( 2.0 * areaToInterpolate[2][0] ) -
179  ( 5.0 * areaToInterpolate[2][1] ) +
180  ( 4.0 * areaToInterpolate[2][2] ) -
181  areaToInterpolate[2][3] -
182  ( 0.5 * areaToInterpolate[3][0] ) +
183  ( 1.25 * areaToInterpolate[3][1] ) -
184  areaToInterpolate[3][2] +
185  ( 0.25 * areaToInterpolate[3][3] );
186  this->a23 = - ( 0.5 * areaToInterpolate[0][0] ) +
187  ( 1.5 * areaToInterpolate[0][1] ) -
188  ( 1.5 * areaToInterpolate[0][2] ) +
189  ( 0.5 * areaToInterpolate[0][3] ) +
190  ( 1.25 * areaToInterpolate[1][0] ) -
191  ( 3.75 * areaToInterpolate[1][1] ) +
192  ( 3.75 * areaToInterpolate[1][2] ) -
193  ( 1.25 * areaToInterpolate[1][3] ) -
194  areaToInterpolate[2][0] +
195  ( 3.0 * areaToInterpolate[2][1] ) -
196  ( 3.0 * areaToInterpolate[2][2] ) +
197  areaToInterpolate[2][3] +
198  ( 0.25 * areaToInterpolate[3][0] ) -
199  ( 0.75 * areaToInterpolate[3][1] ) +
200  ( 0.75 * areaToInterpolate[3][2] ) -
201  ( 0.25 * areaToInterpolate[3][3] );
202  this->a30 = - ( 0.5 * areaToInterpolate[0][1] ) +
203  ( 1.5 * areaToInterpolate[1][1] ) -
204  ( 1.5 * areaToInterpolate[2][1] ) +
205  ( 0.5*areaToInterpolate[3][1] );
206  this->a31 = ( 0.25 * areaToInterpolate[0][0] ) -
207  ( 0.25 * areaToInterpolate[0][2] ) -
208  ( 0.75 * areaToInterpolate[1][0] ) +
209  ( 0.75 * areaToInterpolate[1][2] ) +
210  ( 0.75 * areaToInterpolate[2][0] ) -
211  ( 0.75 * areaToInterpolate[2][2] ) -
212  ( 0.25 * areaToInterpolate[3][0] ) +
213  ( 0.25 * areaToInterpolate[3][2] );
214  this->a32 = - ( 0.5 * areaToInterpolate[0][0] ) +
215  ( 1.25 * areaToInterpolate[0][1] ) -
216  areaToInterpolate[0][2] +
217  ( 0.25 * areaToInterpolate[0][3] ) +
218  ( 1.5 * areaToInterpolate[1][0] ) -
219  ( 3.75 * areaToInterpolate[1][1] ) +
220  ( 3.0 * areaToInterpolate[1][2] ) -
221  ( 0.75 * areaToInterpolate[1][3] ) -
222  ( 1.5 * areaToInterpolate[2][0] ) +
223  ( 3.75 * areaToInterpolate[2][1] ) -
224  ( 3.0 * areaToInterpolate[2][2] ) +
225  ( 0.75 * areaToInterpolate[2][3] ) +
226  ( 0.5 * areaToInterpolate[3][0] ) -
227  ( 1.25 * areaToInterpolate[3][1] ) +
228  areaToInterpolate[3][2] -
229  ( 0.25 * areaToInterpolate[3][3] );
230  this->a33 = ( 0.25 * areaToInterpolate[0][0] ) -
231  ( 0.75 * areaToInterpolate[0][1] ) +
232  ( 0.75 * areaToInterpolate[0][2] ) -
233  ( 0.25 * areaToInterpolate[0][3] ) -
234  ( 0.75 * areaToInterpolate[1][0] ) +
235  ( 2.25 * areaToInterpolate[1][1] ) -
236  ( 2.25 * areaToInterpolate[1][2] ) +
237  ( 0.75 * areaToInterpolate[1][3] ) +
238  ( 0.75 * areaToInterpolate[2][0] ) -
239  ( 2.25 * areaToInterpolate[2][1] ) +
240  ( 2.25 * areaToInterpolate[2][2] ) -
241  ( 0.75 * areaToInterpolate[2][3] ) -
242  ( 0.25 * areaToInterpolate[3][0] ) +
243  ( 0.75 * areaToInterpolate[3][1] ) -
244  ( 0.75 * areaToInterpolate[3][2] ) +
245  ( 0.25 * areaToInterpolate[3][3] );
246  }
247 
252  ~BicubicInterpolator ( void ) { ; }
253 
263  proshade_double getValue ( proshade_double x, proshade_double y )
264  {
265  //======================================== Sanity check
266  if ( ( ( x < this->xStartIndex ) || ( x > ( this->xStartIndex + this->xRange ) ) ) ||
267  ( ( y < this->yStartIndex ) || ( y > ( this->yStartIndex + this->yRange ) ) ) )
268  {
269  if ( ( x < this->xStartIndex ) || ( x > ( this->xStartIndex + this->xRange ) ) ) { std::cout << "PROBLEM WITH LAT" << std::endl; }
270  if ( ( y < this->yStartIndex ) || ( y > ( this->yStartIndex + this->yRange ) ) ) { std::cout << "PROBLEM WITH LON" << std::endl; }
271 
272  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." );
273  }
274 
275  //======================================== Convert x and y to unit square
276  proshade_double unitSquareX = ( x - this->xStartIndex ) / this->xRange;
277  proshade_double unitSquareY = ( y - this->yStartIndex ) / this->yRange;
278 
279  //======================================== Precompute powers
280  proshade_double x2 = std::pow ( unitSquareX, 2.0 );
281  proshade_double x3 = std::pow ( unitSquareX, 3.0 );
282  proshade_double y2 = std::pow ( unitSquareY, 2.0 );
283  proshade_double y3 = std::pow ( unitSquareY, 3.0 );
284 
285  //======================================== Done
286  return ( ( this->a00 + this->a01 * unitSquareY + this->a02 * y2 + this->a03 * y3 ) +
287  ( this->a10 + this->a11 * unitSquareY + this->a12 * y2 + this->a13 * y3 ) * unitSquareX +
288  ( this->a20 + this->a21 * unitSquareY + this->a22 * y2 + this->a23 * y3 ) * x2 +
289  ( this->a30 + this->a31 * unitSquareY + this->a32 * y2 + this->a33 * y3 ) * x3 );
290  }
291  };
292 
293  void complexMultiplication ( proshade_double* r1, proshade_double* i1, proshade_double* r2, proshade_double* i2,
294  proshade_double* retReal, proshade_double* retImag );
295  void complexMultiplicationConjug ( proshade_double* r1, proshade_double* i1, proshade_double* r2, proshade_double* i2,
296  proshade_double* retReal, proshade_double* retImag );
297  proshade_double complexMultiplicationRealOnly ( proshade_double* r1, proshade_double* i1, proshade_double* r2, proshade_double* i2 );
298  proshade_double complexMultiplicationConjugRealOnly ( proshade_double* r1, proshade_double* i1, proshade_double* r2, proshade_double* i2 );
299  void vectorMeanAndSD ( std::vector<proshade_double>* vec, proshade_double*& ret );
300  void vectorMedianAndIQR ( std::vector<proshade_double>* vec, proshade_double*& ret );
301  void arrayMedianAndIQR ( proshade_double* vec, proshade_unsign vecSize, proshade_double*& ret );
302  proshade_double pearsonCorrCoeff ( proshade_double* valSet1, proshade_double* valSet2, proshade_unsign length );
303  void getLegendreAbscAndWeights ( proshade_unsign order, proshade_double* abscissas, proshade_double* weights,
304  proshade_unsign taylorSeriesCap );
305  void getGLPolyAtZero ( proshade_unsign order, proshade_double *polyValue, proshade_double *deriValue );
306  void getGLFirstEvenRoot ( proshade_double polyAtZero, proshade_unsign order, proshade_double *abscAtZero,
307  proshade_double *weighAtZero, proshade_unsign taylorSeriesCap );
308  proshade_double evaluateGLSeries ( proshade_double *series, proshade_double target, proshade_unsign terms );
309  proshade_double advanceGLPolyValue ( proshade_double from, proshade_double to, proshade_double valAtFrom,
310  proshade_unsign noSteps, proshade_unsign taylorSeriesCap );
311  void completeLegendreSeries ( proshade_unsign order, proshade_double* abscissa, proshade_double* weights,
312  proshade_unsign taylorSeriesCap );
313  proshade_double gaussLegendreIntegrationReal ( proshade_double* vals, proshade_unsign valsSize, proshade_unsign order,
314  proshade_double* abscissas, proshade_double* weights, proshade_double integralOverRange,
315  proshade_double maxSphereDists );
316  void gaussLegendreIntegration ( proshade_complex* vals, proshade_unsign valsSize, proshade_unsign order,
317  proshade_double* abscissas, proshade_double* weights, proshade_double integralOverRange,
318  proshade_double maxSphereDists, proshade_double* retReal, proshade_double* retImag );
319  void complexMatrixSVDSigmasOnly ( proshade_complex** mat, int dim, double*& singularValues );
320  void complexMatrixSVDUandVOnly ( proshade_double* mat, int dim, proshade_double* uAndV, bool fail = true );
321  void getEulerZXZFromSOFTPosition ( proshade_signed band, proshade_signed x, proshade_signed y, proshade_signed z, proshade_double* eulerAlpha,
322  proshade_double* eulerBeta, proshade_double* eulerGamma );
323  void getSOFTPositionFromEulerZXZ ( proshade_signed band, proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma,
324  proshade_double* x, proshade_double* y, proshade_double* z );
325  void getRotationMatrixFromEulerZXZAngles ( proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma, proshade_double* matrix );
326  void getAxisAngleFromRotationMatrix ( proshade_double* rotMat, proshade_double* x, proshade_double* y, proshade_double* z, proshade_double* ang );
327  void getAxisAngleFromRotationMatrix ( std::vector< proshade_double >* rotMat, proshade_double* x, proshade_double* y, proshade_double* z, proshade_double* ang );
328  void getRotationMatrixFromAngleAxis ( proshade_double* rotMat, proshade_double x, proshade_double y, proshade_double z, proshade_double ang );
329  void getEulerZXZFromRotMatrix ( proshade_double* rotMat, proshade_double* eA, proshade_double* eB, proshade_double* eG );
330  void getEulerZXZFromAngleAxis ( proshade_double axX, proshade_double axY, proshade_double axZ, proshade_double axAng, proshade_double* eA,
331  proshade_double* eB, proshade_double* eG, proshade_unsign angDim );
332  void getEulerZXZFromAngleAxisFullSearch ( proshade_double axX, proshade_double axY, proshade_double axZ, proshade_double axAng, proshade_double* eA,
333  proshade_double* eB, proshade_double* eG, proshade_signed angDim );
334  void multiplyTwoSquareMatrices ( proshade_double* A, proshade_double* B, proshade_double* res, proshade_unsign dim = 3 );
335  std::vector < proshade_signed > primeFactorsDecomp ( proshade_signed number );
336  proshade_double normalDistributionValue ( proshade_double mean, proshade_double standardDev, proshade_double value );
337  proshade_double computeDotProduct ( proshade_double* x1, proshade_double* y1, proshade_double* z1, proshade_double* x2, proshade_double* y2,
338  proshade_double* z2 );
339  proshade_double computeDotProduct ( proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2,
340  proshade_double z2 );
341  proshade_double* computeCrossProduct ( proshade_double* x1, proshade_double* y1, proshade_double* z1, proshade_double* x2, proshade_double* y2,
342  proshade_double* z2 );
343  proshade_double* compute3x3MatrixMultiplication ( proshade_double* mat1, proshade_double* mat2 );
344  proshade_double* compute3x3MatrixVectorMultiplication ( proshade_double* mat, proshade_double x, proshade_double y, proshade_double z );
345  proshade_double* compute3x3MatrixInverse ( proshade_double* mat );
346  void transpose3x3MatrixInPlace ( proshade_double* mat );
347  proshade_double* findRotMatMatchingVectors ( proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2,
348  proshade_double z2 );
349  std::vector < proshade_double > findVectorFromTwoVAndTwoD ( proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2,
350  proshade_double z2, proshade_double dot1, proshade_double dot2 );
351  std::vector < proshade_double > findVectorFromThreeVAndThreeD ( proshade_double x1, proshade_double y1, proshade_double z1, proshade_double x2, proshade_double y2,
352  proshade_double z2, proshade_double x3, proshade_double y3, proshade_double z3, proshade_double dot1,
353  proshade_double dot2, proshade_double dot3 );
354  std::vector< proshade_double > multiplyGroupElementMatrices ( std::vector< proshade_double >* el1, std::vector< proshade_double >* el2 );
355  bool rotationMatrixSimilarity ( std::vector< proshade_double >* mat1, std::vector< proshade_double >* mat2, proshade_double tolerance = 0.1 );
356  bool vectorOrientationSimilarity ( proshade_double a1, proshade_double a2, proshade_double a3, proshade_double b1, proshade_double b2,
357  proshade_double b3, proshade_double tolerance = 0.1 );
358  bool vectorOrientationSimilaritySameDirection ( proshade_double a1, proshade_double a2, proshade_double a3, proshade_double b1, proshade_double b2,
359  proshade_double b3, proshade_double tolerance = 0.1 );
360  void optimiseAxisBiCubicInterpolation ( proshade_double* bestLattitude, proshade_double* bestLongitude, proshade_double* bestSum, std::vector<proshade_unsign>* sphereList,
361  std::vector<ProSHADE_internal_spheres::ProSHADE_rotFun_sphere*>* sphereMappedRotFun, proshade_double step = 0.05 );
362  void prepareBiCubicInterpolatorsMinusMinus ( proshade_double bestLattitude, proshade_double bestLongitude, std::vector<proshade_unsign>* sphereList,
363  std::vector<ProSHADE_internal_maths::BicubicInterpolator*>* interpols, std::vector<ProSHADE_internal_spheres::ProSHADE_rotFun_sphere*>* sphereMappedRotFun );
364  void prepareBiCubicInterpolatorsMinusPlus ( proshade_double bestLattitude, proshade_double bestLongitude, std::vector<proshade_unsign>* sphereList,
365  std::vector<ProSHADE_internal_maths::BicubicInterpolator*>* interpols, std::vector<ProSHADE_internal_spheres::ProSHADE_rotFun_sphere*>* sphereMappedRotFun );
366  void prepareBiCubicInterpolatorsPlusMinus ( 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 prepareBiCubicInterpolatorsPlusPlus ( 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  bool isAxisUnique ( std::vector< proshade_double* >* CSymList, proshade_double* axis, proshade_double tolerance = 0.1, bool improve = false );
371  bool isAxisUnique ( std::vector< proshade_double* >* CSymList, proshade_double X, proshade_double Y, proshade_double Z, proshade_double fold, proshade_double tolerance );
372  std::vector< proshade_unsign > findAllPrimes ( proshade_unsign upTo );
373 }
374 
375 #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:709
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:2101
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:619
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:2448
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getMinRadius
proshade_double getMinRadius(void)
Accessor function for the private variable minimal radius.
Definition: ProSHADE_spheres.cpp:716
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:1737
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getSphereNumber
proshade_unsign getSphereNumber(void)
Accessor function for the private variable sphere number.
Definition: ProSHADE_spheres.cpp:738
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere
This class contains all inputed data for the rotation function angle-axis converted spheres.
Definition: ProSHADE_maths.hpp:51
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:1394
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:1688
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:2503
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:671
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:447
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:986
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, proshade_unsign angDim)
This function converts angle-axis representation to the Euler ZXZ angles representation.
Definition: ProSHADE_maths.cpp:1437
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getRepresentedAngle
proshade_double getRepresentedAngle(void)
Accessor function for the private variable represented angle.
Definition: ProSHADE_spheres.cpp:727
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:263
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:1005
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:252
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:384
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:2296
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:2232
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:802
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:2393
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:2266
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getMaxRadius
proshade_double getMaxRadius(void)
Accessor function for the private variable maximum radius.
Definition: ProSHADE_spheres.cpp:694
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:244
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:115
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:1705
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:924
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::removeSmallPeaks
void removeSmallPeaks(proshade_double peakThres)
Function for removing peaks with too small height.
Definition: ProSHADE_spheres.cpp:986
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:1343
ProSHADE_internal_maths
This namespace contains the internal functions for common mathematical operations.
ProSHADE_internal_maths::BicubicInterpolator
Definition: ProSHADE_maths.hpp:102
ProSHADE_internal_maths::primeFactorsDecomp
std::vector< proshade_signed > primeFactorsDecomp(proshade_signed number)
Function to find prime factors of an integer.
Definition: ProSHADE_maths.cpp:1639
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:347
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:2613
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:287
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:1039
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:477
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:648
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:1883
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:864
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:1789
ProSHADE_internal_spheres
This namespace contains the structure and functions required for storing internal map projections ont...
Definition: ProSHADE_maths.hpp:42
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:2195
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:961
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:147
ProSHADE_internal_maths::getEulerZXZFromAngleAxisFullSearch
void getEulerZXZFromAngleAxisFullSearch(proshade_double axX, proshade_double axY, proshade_double axZ, proshade_double axAng, proshade_double *eA, proshade_double *eB, proshade_double *eG, proshade_signed angDim)
This function converts angle-axis representation to the Euler ZXZ angles representation using full se...
Definition: ProSHADE_maths.cpp:1526
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:1843
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:521
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getRadius
proshade_double getRadius(void)
Accessor function for the private variable radius.
Definition: ProSHADE_spheres.cpp:684
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:1959
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:2558
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:1613
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:878
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:2693
ProSHADE_internal_maths::compute3x3MatrixInverse
proshade_double * compute3x3MatrixInverse(proshade_double *mat)
Function for computing a 3x3 matrix inverse.
Definition: ProSHADE_maths.cpp:1810
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:869
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:198
ProSHADE_internal_spheres::ProSHADE_rotFun_sphere::getAngularDim
proshade_unsign getAngularDim(void)
Accessor function for the private variable angular dim.
Definition: ProSHADE_spheres.cpp:705
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:2141
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:765
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:749
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:1759