18 #ifndef ATOMPROBE_MATHS_MISC_H    19 #define ATOMPROBE_MATHS_MISC_H    21 #include "gsl/gsl_matrix.h"    39 void gsl_matrix_mult(
const gsl_matrix *A, 
const gsl_matrix *B, gsl_matrix* &res,
    45         float tolerance=sqrt(std::numeric_limits<float>::epsilon()));
    52 T 
weightedMean(
const std::vector<T> &values, 
const std::vector<T> &weight)
    62     wTotal= std::accumulate(weight.begin(),weight.end(),(T)0);
    63     for(
size_t ui=0;ui<values.size();ui++)
    66         sumWiXi+=values[ui]*weight[ui];
    72     return sumWiXi/wTotal;
    77             float &stdevVal,
bool normalCorrection=
true)
    80     for(
size_t ui=0;ui<f.size();ui++)
    82     meanVal =meanDbl/f.size();
    86     for(
size_t ui=0;ui<f.size();ui++)
    90         stdevDbl+=delta*delta;
    92     stdevVal = sqrtf( stdevDbl/
float(f.size()-1));
   103         stdevVal*=(1.0 - 1.0/(4.0*n) - 7.0/(32.0*n*n) - 19.0/(128.0*n*n*n));
   129             float b1, 
float b2, 
float b3)
   131     return a1*b1 + a2*b2 + a3* b3;
   136 double det3by3(
const double *ptArray);
 float signedDistanceToFacet(const Point3D &fA, const Point3D &fB, const Point3D &fC, const Point3D &normal, const Point3D &p)
Find the distance between a point, and a triangular facet – may be positive or negative. 
 
double pyramidVol(const Point3D *planarPts, const Point3D &apex)
 
void gsl_matrix_mult(const gsl_matrix *A, const gsl_matrix *B, gsl_matrix *&res, bool alloc=false)
 
bool solveLeastSquares(gsl_matrix *m, gsl_vector *b, gsl_vector *&x)
Use an SVD based least-squares solver to solve Mx=b (for x). 
 
float distanceToSegment(const Point3D &fA, const Point3D &fB, const Point3D &p)
 
void meanAndStdev(const std::vector< T > &f, float &meanVal, float &stdevVal, bool normalCorrection=true)
 
A 3D point data class storage. 
 
T weightedMean(const std::vector< T > &values, const std::vector< T > &weight)
 
double det3by3(const double *ptArray)
 
float dotProduct(float a1, float a2, float a3, float b1, float b2, float b3)
Inline func for calculating a(dot)b. 
 
unsigned int estimateRank(const gsl_matrix *m, float tolerance=sqrt(std::numeric_limits< float >::epsilon()))
Estimate the rank of the given matrix. 
 
bool triIsDegenerate(const Point3D &fA, const Point3D &fB, const Point3D &fC)
 
float distanceToFacet(const Point3D &fA, const Point3D &fB, const Point3D &fC, const Point3D &normal, const Point3D &p)
 
unsigned int vectorPointDir(const Point3D &pA, const Point3D &pB, const Point3D &vC, const Point3D &vD)
Check which way vectors attached to two 3D points "point",.