Classes | Static Public Member Functions | Public Attributes | Private Types | Static Private Member Functions

cmtk::MathUtil Class Reference
[cmtkBase Library]

General-purpose mathematical functions and function templates. More...

#include <cmtkMathUtil.h>

List of all members.

Classes

class  BitInitializer
 Helper class to initialize a constant 64bit field. More...

Static Public Member Functions

template<class T >
static bool IsNaN (const T value)
 Portable test for "not a number" values.
static double GetDoubleNaN ()
 Get double-precision not-a-number (NaN) value.
static float GetFloatNaN ()
 Get single-precision not-a-number (NaN) value.
static double GetDoubleInf ()
 Get double-precision infinite (Inf) value.
static float GetFloatInf ()
 Get single-precision infinite (Inf) value.
static double Sin (const Units::Radians &radians)
 Unit-safe sin() function.
static double Cos (const Units::Radians &radians)
 Unit-safe cos() function.
static double Tan (const Units::Radians &radians)
 Unit-safe tan() function.
static const Units::Radians ArcSin (const double value)
 Unit-safe asin() function.
static const Units::Radians ArcCos (const double value)
 Unit-safe acos() function.
static const Units::Radians ArcTan (const double value)
 Unit-safe aten() function.
static const Units::Radians ArcTan2 (const double y, const double x)
 Unit-safe atan2() function.
template<class T >
static T Square (const T a)
 Return square of a float value.
template<class T >
static T Min (const int nValues, const T *Values)
 Return minimum of an array of ordered values.
template<class T >
static T Max (const int nValues, const T *Values)
 Return minimum of an array of ordered values.
template<class T >
static T Intersect (const T aMin, const T aMax, const T bMin, const T bMax)
 Return length of intersection of two intervals.
template<class T >
static int Round (const T a)
 Round float value to the nearest integer.
template<class T >
static int Sign (const T a)
 Return sign of float value.
template<class T >
static int CheckRange (const T value, const T a, const T b)
 Check if some float value is within a range.
template<class T >
static double plogp (const T p)
 Compute p*log(p) for a single value.
template<class T >
static T Mean (const unsigned int nValues, const T *values)
 Computes average of an array of float values.
template<class T >
static T Mean (const std::vector< T > &values)
 Computes average of a vector of float values.
template<class T >
static T Variance (const unsigned int nValues, const T *values, T mean, const bool unbiased=false)
 Computes variance of an array of float values.
template<class T >
static T Variance (const std::vector< T > &values, T mean, const bool unbiased=false)
 Computes variance of a vector of float values.
template<class T >
static T Correlation (const std::vector< T > &x, const std::vector< T > &y)
 Normalized correlation coefficient between two float vectors.
static double TStatFromCorrelation (const double r, const size_t df)
 Compute t-statistic from coefficient of correlation.
static double ProbabilityFromTStat (const double t, const size_t df)
 Compute probability from T-statistic.
template<class T >
static T TTest (const std::vector< T > &valuesX, const std::vector< T > &valuesY, T &t)
 Performs two-tailed unpaired t-test on two distributions.
template<class T >
static T TTest (const std::vector< T > &valuesX, const std::vector< T > &valuesY, T &t, T &avgX, T &avgY)
 Performs two-tailed unpaired t-test on two distributions.
template<class T >
static T PairedTTest (const std::vector< T > &valuesX, const std::vector< T > &valuesY, T &t, T &avgX, T &avgY)
 Performs two-tailed paired t-test on two distributions.
template<class T >
static T TTest (const std::vector< T > &valuesX, T &t, T &avgX)
 Performs one-sample t-test on distribution to test for zero mean.
static double Betai (const double a, const double b, const double x)
 Beta-i function.
static double BetaCf (const double a, const double b, const double x)
 Beta-Cf function.
static double GammaLn (const double xx)
 GammaLn function.
static void SVD (Matrix2D< double > *U, size_t m, size_t n, std::vector< double > *W, Matrix2D< double > *V)
 Singular Value Decomposition.
static void SVDLinearRegression (Matrix2D< double > *U, size_t m, size_t n, std::vector< double > *W, Matrix2D< double > *V, double *b, std::vector< double > &lm_params)
 Linear Regression using SVD results.
static int CompareFloat (const void *a, const void *b)
 Function that compares two floats; to be used in qsort().
static int CompareDouble (const void *a, const void *b)
 Function that compares two doubles; to be used in qsort().
static double NormalRandom (const double sigma)
 Generate normally distributed random numbers.
static double NormalRandom (const double sigma, const unsigned int seed)
 Generate normally distributed random numbers with explicit seed.
static double UniformRandom ()
 Uniform random number generator.
template<class T >
static void ComputeEigensystem (const Matrix2D< T > &matrix, Matrix2D< T > &eigensystem, std::vector< T > &eigenvalues)
 Compute eigensystem and eigenvalues for square real matrix using Jacobi rotation.
template<class T >
static void ComputeEigenvalues (const Matrix2D< T > &matrix, std::vector< T > &eigenvalues)
 Compute eigenvalues for square real matrix using Jacobi rotation.
template<class T >
static T CholeskyDeterminant (const Matrix2D< T > &matrix, int n)
 Determinant of an n x n square matrix.

Public Attributes

const FPInitializeUnion FPInitializeNaN
const FPInitializeUnion FPInitializeInf
const void * FPInitializeNaN_P = &FPInitializeNaN
const void * FPInitializeInf_P = &FPInitializeInf
const void * FPInitializeNaN_fP = &FPInitializeNaN.f[1]
const void * FPInitializeInf_fP = &FPInitializeInf.f[1]

Private Types

typedef MathUtil Self
 This class.

Static Private Member Functions

static const Self::BitInitializerGetInternalNaN ()
 Get reference to internal representation of NaN.
static const Self::BitInitializerGetInternalInf ()
 Get reference to internal representation of Inf.

Detailed Description

General-purpose mathematical functions and function templates.

Definition at line 83 of file cmtkMathUtil.h.


Member Typedef Documentation

typedef MathUtil cmtk::MathUtil::Self [private]

This class.

Definition at line 87 of file cmtkMathUtil.h.


Member Function Documentation

static const Units::Radians cmtk::MathUtil::ArcCos ( const double  value ) [inline, static]

Unit-safe acos() function.

Definition at line 154 of file cmtkMathUtil.h.

Referenced by cmtk::ParametricPlane::SetNormal().

static const Units::Radians cmtk::MathUtil::ArcSin ( const double  value ) [inline, static]

Unit-safe asin() function.

Definition at line 148 of file cmtkMathUtil.h.

Referenced by cmtk::ParametricPlane::SetNormal().

static const Units::Radians cmtk::MathUtil::ArcTan ( const double  value ) [inline, static]

Unit-safe aten() function.

Definition at line 160 of file cmtkMathUtil.h.

static const Units::Radians cmtk::MathUtil::ArcTan2 ( const double  y,
const double  x 
) [inline, static]

Unit-safe atan2() function.

Definition at line 166 of file cmtkMathUtil.h.

Referenced by cmtk::ParametricPlane::GetAlignmentXform().

static double cmtk::MathUtil::BetaCf ( const double  a,
const double  b,
const double  x 
) [static]

Beta-Cf function.

static double cmtk::MathUtil::Betai ( const double  a,
const double  b,
const double  x 
) [static]

Beta-i function.

template<class T >
static int cmtk::MathUtil::CheckRange ( const T  value,
const T  a,
const T  b 
) [inline, static]

Check if some float value is within a range.

Returns:
0 if value is in range, -1 if value is below minumum, 1 if value is above maximum.

Definition at line 214 of file cmtkMathUtil.h.

static int cmtk::MathUtil::CompareDouble ( const void *  a,
const void *  b 
) [inline, static]

Function that compares two doubles; to be used in qsort().

Definition at line 323 of file cmtkMathUtil.h.

Referenced by cmtk::ScalarImage::GetMedianFiltered().

static int cmtk::MathUtil::CompareFloat ( const void *  a,
const void *  b 
) [inline, static]

Function that compares two floats; to be used in qsort().

Definition at line 313 of file cmtkMathUtil.h.

Referenced by cmtk::ScalarImage::GetMedianFiltered().

static double cmtk::MathUtil::Cos ( const Units::Radians radians ) [inline, static]

Unit-safe cos() function.

Definition at line 136 of file cmtkMathUtil.h.

References cmtk::Units::UnitBase::Value().

Referenced by cmtk::AffineXform::RotateWXYZ(), and cmtk::ParametricPlane::Update().

static double cmtk::MathUtil::GammaLn ( const double  xx ) [static]

GammaLn function.

static double cmtk::MathUtil::GetDoubleInf (  ) [inline, static]

Get double-precision infinite (Inf) value.

Definition at line 114 of file cmtkMathUtil.h.

static double cmtk::MathUtil::GetDoubleNaN (  ) [inline, static]

Get double-precision not-a-number (NaN) value.

Definition at line 98 of file cmtkMathUtil.h.

static float cmtk::MathUtil::GetFloatInf (  ) [inline, static]

Get single-precision infinite (Inf) value.

Definition at line 120 of file cmtkMathUtil.h.

static float cmtk::MathUtil::GetFloatNaN (  ) [inline, static]

Get single-precision not-a-number (NaN) value.

Definition at line 104 of file cmtkMathUtil.h.

static const Self::BitInitializer& cmtk::MathUtil::GetInternalInf (  ) [inline, static, private]

Get reference to internal representation of Inf.

Definition at line 425 of file cmtkMathUtil.h.

static const Self::BitInitializer& cmtk::MathUtil::GetInternalNaN (  ) [inline, static, private]

Get reference to internal representation of NaN.

Definition at line 414 of file cmtkMathUtil.h.

template<class T >
static T cmtk::MathUtil::Intersect ( const T  aMin,
const T  aMax,
const T  bMin,
const T  bMax 
) [inline, static]

Return length of intersection of two intervals.

Definition at line 197 of file cmtkMathUtil.h.

template<class T >
static bool cmtk::MathUtil::IsNaN ( const T  value ) [inline, static]

Portable test for "not a number" values.

Definition at line 92 of file cmtkMathUtil.h.

template<class T >
static T cmtk::MathUtil::Max ( const int  nValues,
const T *  Values 
) [inline, static]

Return minimum of an array of ordered values.

Definition at line 187 of file cmtkMathUtil.h.

template<class T >
static T cmtk::MathUtil::Min ( const int  nValues,
const T *  Values 
) [inline, static]
static double cmtk::MathUtil::NormalRandom ( const double  sigma ) [inline, static]

Generate normally distributed random numbers.

This function uses the Box-Muller method to transform a pair of uniformly distributed random numbers into a pair of normally (ie., Gaussian) distributed random numbers. One of the two generated numbers is returned while the other is stored so that, when this function is called the next time, the previously computed value can be returned without further computational expense.

Parameters:
sigmaStandard deviation of the resulting distribution.

Definition at line 341 of file cmtkMathUtil.h.

static double cmtk::MathUtil::NormalRandom ( const double  sigma,
const unsigned int  seed 
) [inline, static]

Generate normally distributed random numbers with explicit seed.

Parameters:
sigmaStandard deviation of the resulting distribution.
seedRandom seed given to srandom() function.

Definition at line 367 of file cmtkMathUtil.h.

template<class T >
static double cmtk::MathUtil::plogp ( const T  p ) [inline, static]

Compute p*log(p) for a single value.

Definition at line 221 of file cmtkMathUtil.h.

template<class T >
static int cmtk::MathUtil::Round ( const T  a ) [inline, static]

Round float value to the nearest integer.

Definition at line 203 of file cmtkMathUtil.h.

Referenced by cmtk::ScalarImage::ProjectPixel().

template<class T >
static int cmtk::MathUtil::Sign ( const T  a ) [inline, static]

Return sign of float value.

Returns:
-1 if a<0, 1 if a>0, 0 if a==0.

Definition at line 208 of file cmtkMathUtil.h.

Referenced by cmtk::ParametricPlane::GetAlignmentXform().

static double cmtk::MathUtil::Sin ( const Units::Radians radians ) [inline, static]
template<class T >
static T cmtk::MathUtil::Square ( const T  a ) [inline, static]
static double cmtk::MathUtil::Tan ( const Units::Radians radians ) [inline, static]

Unit-safe tan() function.

Definition at line 142 of file cmtkMathUtil.h.

References cmtk::Units::UnitBase::Value().


Member Data Documentation

const FPInitializeUnion cmtk::MathUtil::FPInitializeNaN
Initial value:
 {
}

Definition at line 47 of file cmtkMathUtil_NaNInf.cxx.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines