KrisLibrary  1.0.0
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
Math Namespace Reference

Contains all definitions in the Math package. More...

Namespaces

 Quadrature
 Namespace for quadrature functions.
 

Classes

class  AddFunction
 
struct  AngleInterval
 A contiguous range of angles. More...
 
struct  AngleSet
 A set of AngleIntervals. More...
 
struct  BLASInterface
 An interface to BLAS. Activated with the preprocessor flag HAVE_BLAS=1. More...
 
struct  BlockPrinter
 
class  BlockTridiagonalMatrix
 
class  BlockVector
 
class  CholeskyDecomposition
 Performs the Cholesky decomposition. More...
 
struct  ClosedInterval
 A closed interval [a,b]. More...
 
struct  ClosedIntervalSet
 
class  Complex
 Complex number class (x + iy). More...
 
class  ComponentVectorFieldFunction
 
class  Compose_SF_VF_Function
 A scalar field function h(x) = f(g(x)) (g vector-valued) More...
 
class  Compose_VF_VF_Function
 A vector field function h(x) = f(g(x)) (f,g vector fields) More...
 
class  ComposeFunction
 
class  ComposeScalarFieldFunction
 A scalar field h(x) = f(g(x)) More...
 
class  CompositeInequalityConstraint
 
class  CompositeVectorFieldFunction
 
struct  Conditioner_SymmDiag
 A matrix conditioner that does a pre/postmultiply with a diagonal S. More...
 
class  DiagonalMatrixTemplate
 A templated diagonal matrix, represented by a vector of the entries on the diagonal. More...
 
class  DiffEqFunction
 
struct  EquationTerm
 
class  Gaussian
 Multivariate gaussian N(mu,K) of d dimensions. More...
 
struct  IndexAndPriority
 
class  IndexedVectorFieldFunction
 A vector field function f(x) = g(x[xindices])[findices]. More...
 
class  InequalityConstraint
 A vector field with constraints s.t. ci(x) >= 0. More...
 
struct  InequalityConstraintAdaptor
 A class that makes it easier to construct "plugin" classes to alter constraint behavior. More...
 
struct  Interval
 A generic interval {a,b}, where { and } can be either (,[ or ),]. More...
 
class  InverseFunction
 
struct  IterativeMethod
 
struct  JacobiPreconditioner
 Jacobi preconditioning (inverse of diagonal) More...
 
struct  LAPACKInterface
 An interface to LAPACK. Activated with the preprocessor flag HAVE_CLAPACK=1. More...
 
struct  LDLDecomposition
 Performs the LDL^t decompositoin of a symmetric matrix A. More...
 
class  LimitConstraint
 
class  LinearConstraint
 constraint represented as A*x >= b i.e. constraint value is A*x-b More...
 
class  LinearFunction
 
class  LinearScalarFieldFunction
 
class  LinearVectorFieldFunction
 
class  LUDecomposition
 Forms the LU decomposition A=PLU. More...
 
struct  MatrixEquation
 
class  MatrixEquationPrinter
 
class  MatrixIterator
 An iterator through MatrixTemplate elements. More...
 
struct  MatrixPrinter
 
class  MatrixTemplate
 A matrix over the field T. More...
 
class  MaximumScalarFieldFunction
 A scalar field max_i xi. More...
 
class  MinimumScalarFieldFunction
 A scalar field min_i xi. More...
 
class  MulFunction
 
class  NormAccumulator
 
struct  NormScalarFieldFunction
 A scalar field for the L-d norm, where d is passed into the constructor. More...
 
struct  NormSquaredScalarFieldFunction
 A scalar field ||x||^2. More...
 
class  NRQRDecomposition
 The QR decomposition as computed by the algorithm in Numerical Recipes in C. More...
 
struct  NullPreconditioner
 Identity precondtioner. More...
 
struct  OpenInterval
 An open interval (a,b) More...
 
struct  OpenIntervalSet
 
class  PiecewiseLinearFunction
 
class  PiecewiseLinearPath
 
struct  QNHessianUpdater
 Maintains the Cholesky decomposition of the hessian H over Quasi-Newton steps. More...
 
class  QRDecomposition
 Calculates the QR decomposition. More...
 
class  QuadraticScalarFieldFunction
 
class  Quaternion
 Complex quaternion class (w + ix + jy + kz). More...
 
class  RealFunction
 A function from R to R. More...
 
class  RealFunction2
 
class  RobustSVD
 Performs a pre/postconditioned singular value decomposition. More...
 
class  RowEchelon
 Compute reduced row-eschelon form for a matrix A. More...
 
class  ScalarFieldDirectionalFunction
 A function g(t) that returns f(x+tn) for a scalar field f(x) If ref is true, then x,n are set to refer to the x,n provided in the constructor, rather than to copy. More...
 
class  ScalarFieldFunction
 A function from R^n to R. More...
 
class  ScalarFieldProjectionFunction
 
class  ScaledOffsetConstraint
 
class  SliceVectorFieldFunction
 A vector field function f(x) = g(x0 | x0[xindices]=x) More...
 
class  SparseMatrixTemplate_CR
 Row-major, compressed-row sparse matrix. More...
 
class  SparseMatrixTemplate_RM
 Row-major sparse matrix. More...
 
struct  SparseVectorAccessor
 
class  SparseVectorCompressed
 
class  SparseVectorFunction
 A vector field function with a sparse jacobian. The Jacobian_Sparse and Jacobian_i_Sparse methods must be overridden. More...
 
class  SparseVectorTemplate
 
class  SVDecomposition
 Performs the singular value decomposition. More...
 
class  UniformScaledOffsetConstraint
 
class  Vector3FieldFunction
 
class  VectorFieldFunction
 A function from R^n to R^m. More...
 
class  VectorFieldProjectionFunction
 A function g(x) that returns the i'th component of vector field f(x) More...
 
class  VectorFunction
 A function from R to R^n, identical to RealFunction except a vector is returned. More...
 
class  VectorIterator
 An iterator through VectorTemplate elements. More...
 
struct  VectorPrinter
 
class  VectorTemplate
 A vector over the field T. More...
 

Typedefs

typedef DiagonalMatrixTemplate< float > fDiagonalMatrix
 
typedef DiagonalMatrixTemplate< double > dDiagonalMatrix
 
typedef DiagonalMatrixTemplate< ComplexcDiagonalMatrix
 
typedef DiagonalMatrixTemplate< Real > DiagonalMatrix
 
typedef VectorTemplate< Real > Vector
 
typedef MatrixTemplate< Real > Matrix
 
typedef double Real
 
typedef class MatrixTemplate< float > fMatrix
 
typedef class MatrixTemplate< double > dMatrix
 
typedef class MatrixTemplate< ComplexcMatrix
 
typedef Real(* QuadratureFunction) (RealFunction &, Real, Real)
 
typedef SparseMatrixTemplate_RM< Real > SparseMatrix
 
typedef SparseMatrixTemplate_RM< float > fSparseMatrix_RM
 
typedef SparseMatrixTemplate_RM< double > dSparseMatrix_RM
 
typedef SparseMatrixTemplate_RM< ComplexcSparseMatrix_RM
 
typedef SparseMatrixTemplate_CR< float > fSparseMatrix_CR
 
typedef SparseMatrixTemplate_CR< double > dSparseMatrix_CR
 
typedef SparseMatrixTemplate_CR< ComplexcSparseMatrix_CR
 
typedef SparseVectorTemplate< Real > SparseVector
 
typedef SparseVectorTemplate< float > fSparseVector
 
typedef SparseVectorTemplate< double > dSparseVector
 
typedef SparseVectorTemplate< ComplexcSparseVector
 
typedef class VectorTemplate< float > fVector
 
typedef class VectorTemplate< double > dVector
 
typedef class VectorTemplate< ComplexcVector
 

Enumerations

enum  ConvergenceResult {
  ConvergenceX, ConvergenceF, Divergence, LocalMinimum,
  MaxItersReached, ConvergenceError
}
 

Functions

int AABBLineSearch (const Vector &x0, const Vector &dx, const Vector &bmin, const Vector &bmax, Real &t)
 
bool ClipLine1D (Real q, Real p, Real &umin, Real &umax)
 
bool AABBClipLine (const Vector &x0, const Vector &dx, const Vector &bmin, const Vector &bmax, Real &u0, Real &u1)
 
void AABBClamp (Vector &x, const Vector &bmin, const Vector &bmax, Real d=Zero)
 Clamps x to be contained in the AABB (bmin,bmax)
 
Real AABBMargin (const Vector &x, const Vector &bmin, const Vector &bmax, int &index)
 
Real AABBMargin (const Vector &x, const Vector &bmin, const Vector &bmax)
 
bool AABBContains (const Vector &x, const Vector &bmin, const Vector &bmax, Real d=Zero)
 Returns true if the AABB (bmin,bmax) contains x.
 
Real AngleNormalize (Real a)
 Normalizes an angle to [0,2pi)
 
Real AngleDiff (Real a, Real b)
 Returns the closest distance to get to a from b (range [-pi,pi])
 
Real AngleCCWDiff (Real a, Real b)
 Returns the CCW distance needed to get to a from b.
 
Real AngleInterp (Real a, Real b, Real u)
 Interpolates between rotations a and b (u from 0 to 1)
 
bool IsValidAngle (Real a)
 
void TransformCosSin_Cos (Real a, Real b, Real &c, Real &d)
 
void TransformCosSin_Sin (Real a, Real b, Real &c, Real &d)
 Same as above, but returns c*sin(x+d)
 
bool SolveCosSinEquation (Real a, Real b, Real c, Real &t1, Real &t2)
 
void SolveCosSinGreater (Real a, Real b, Real c, AngleInterval &i)
 Same as above, but a cos(x) + b sin(x) >= c.
 
void Acos_All (Real x, Real &a, Real &b)
 returns all solutions y to cos(y)=x in a,b
 
void Asin_All (Real x, Real &a, Real &b)
 returns all solutions y to sin(y)=x in a,b
 
void Atan_All (Real x, Real &a, Real &b)
 returns all solutions y to tan(y)=x in a,b
 
char ASCIIShade (double x)
 
void OutputASCIIShade (ostream &out, double x)
 
void OutputASCIIShade (ostream &out, const fVector &x, float scale)
 
void OutputASCIIShade (ostream &out, const dVector &x, double scale)
 
void OutputASCIIShade (ostream &out, const fMatrix &A, float scale, int indent)
 
void OutputASCIIShade (ostream &out, const dMatrix &A, double scale, int indent)
 
void OutputASCIIShade (std::ostream &out, double x)
 
void OutputASCIIShade (std::ostream &out, const fVector &x, float scale=0)
 
void OutputASCIIShade (std::ostream &out, const fMatrix &A, float scale=0, int indent=0)
 
void OutputASCIIShade (std::ostream &out, const dVector &x, double scale=0)
 
void OutputASCIIShade (std::ostream &out, const dMatrix &A, double scale=0, int indent=0)
 
template<class T >
bool UBackSubstitute (const MatrixTemplate< T > &a, const VectorTemplate< T > &b, VectorTemplate< T > &x)
 
template<class T >
bool LBackSubstitute (const MatrixTemplate< T > &a, const VectorTemplate< T > &b, VectorTemplate< T > &x)
 
template<class T >
bool LtBackSubstitute (const MatrixTemplate< T > &a, const VectorTemplate< T > &b, VectorTemplate< T > &x)
 
template<class T >
void U1BackSubstitute (const MatrixTemplate< T > &a, const VectorTemplate< T > &b, VectorTemplate< T > &x)
 
template<class T >
void L1BackSubstitute (const MatrixTemplate< T > &a, const VectorTemplate< T > &b, VectorTemplate< T > &x)
 
template<class T >
void Lt1BackSubstitute (const MatrixTemplate< T > &a, const VectorTemplate< T > &b, VectorTemplate< T > &x)
 
template<class T >
bool UBackSubstitute (const MatrixTemplate< T > &a, const MatrixTemplate< T > &b, MatrixTemplate< T > &x)
 
template<class T >
bool LBackSubstitute (const MatrixTemplate< T > &a, const MatrixTemplate< T > &b, MatrixTemplate< T > &x)
 
template<class T >
bool LtBackSubstitute (const MatrixTemplate< T > &a, const MatrixTemplate< T > &b, MatrixTemplate< T > &x)
 
template<class T >
void U1BackSubstitute (const MatrixTemplate< T > &a, const MatrixTemplate< T > &b, MatrixTemplate< T > &x)
 
template<class T >
void L1BackSubstitute (const MatrixTemplate< T > &a, const MatrixTemplate< T > &b, MatrixTemplate< T > &x)
 
template<class T >
void Lt1BackSubstitute (const MatrixTemplate< T > &a, const MatrixTemplate< T > &b, MatrixTemplate< T > &x)
 
 DEFINEBACKSUBSTITUTE (float)
 
 DEFINEBACKSUBSTITUTE (double)
 
 DEFINEBACKSUBSTITUTE (Complex)
 
void PrintBlockVector (const BlockVector &v, ostream &out, char delim, char bracket)
 
void PrintBlockMatrix (const BlockTridiagonalMatrix &m, ostream &out, char delim, char bracket)
 
ostream & operator<< (ostream &out, const BlockPrinter &bp)
 
std::ostream & operator<< (std::ostream &out, const BlockPrinter &bp)
 
Real ParabolicExtremum (Real a, Real b, Real c, Real fa, Real fb, Real fc)
 
void BracketMin (Real &a, Real &b, Real &c, Real &fa, Real &fb, Real &fc, RealFunction &func)
 Returns a bracketing triplet given some a,b. More...
 
ConvergenceResult ParabolicMinimization (Real ax, Real bx, Real cx, RealFunction &f, int &maxIters, Real tol, Real &xmin)
 Brent's algorithm for parabolic minimization. More...
 
ConvergenceResult ParabolicMinimization (Real x, RealFunction &f, int &maxIters, Real tol, Real &xmin)
 
Real ParabolicLineMinimization (ScalarFieldFunction &f, const Vector &x, const Vector &n, int maxIters, Real tol)
 
Real ParabolicLineMinimization_i (ScalarFieldFunction &f, const Vector &x, int i, int maxIters, Real tol)
 Same as above, but minimizes f(x + t*ei).
 
std::ostream & operator<< (std::ostream &out, const Complex &x)
 
std::istream & operator>> (std::istream &in, Complex &x)
 
std::ostream & operator<< (std::ostream &out, const Quaternion &q)
 
std::istream & operator>> (std::istream &in, Quaternion &q)
 
Real dot (const Complex &a, const Complex &b)
 
Complex operator- (const Complex &a)
 
Complex operator+ (const Complex &a, const Complex &b)
 
Complex operator- (const Complex &a, const Complex &b)
 
Complex operator* (const Complex &a, const Complex &b)
 
Complex operator/ (const Complex &a, const Complex &b)
 
Complex operator+ (const Complex &a, Real b)
 
Complex operator- (const Complex &a, Real b)
 
Complex operator* (const Complex &a, Real b)
 
Complex operator/ (const Complex &a, Real b)
 
Real Abs (const Complex &x)
 
Complex Sqr (const Complex &x)
 
Complex Sqrt (const Complex &x)
 
Complex Exp (const Complex &x)
 
Complex Log (const Complex &x)
 
Complex Pow (const Complex &x, Real y)
 
Complex Pow (const Complex &x, const Complex &y)
 
Complex Sin (const Complex &z)
 
Complex Cos (const Complex &z)
 
Complex Tan (const Complex &z)
 
Complex Sinh (const Complex &z)
 
Complex Cosh (const Complex &z)
 
Complex Tanh (const Complex &z)
 
Complex Inv (const Complex &x)
 
bool FuzzyEquals (const Complex &a, const Complex &b, Real eps=Epsilon)
 
bool FuzzyZero (const Complex &a, Real eps=Epsilon)
 
Complex PseudoInv (const Complex &x, Real eps=Epsilon)
 
bool FuzzyEquals (const Complex &a, const Complex &b, const Complex &eps)
 
bool FuzzyZero (const Complex &a, const Complex &eps)
 
Complex PseudoInv (const Complex &x, const Complex &eps)
 
Real dot (const Quaternion &a, const Quaternion &b)
 
Quaternion operator- (const Quaternion &a)
 
Quaternion operator+ (const Quaternion &a, const Quaternion &b)
 
Quaternion operator- (const Quaternion &a, const Quaternion &b)
 
Quaternion operator* (const Quaternion &a, const Quaternion &b)
 
Quaternion operator/ (const Quaternion &a, const Quaternion &b)
 
Quaternion operator+ (const Quaternion &a, Real b)
 
Quaternion operator- (const Quaternion &a, Real b)
 
Quaternion operator* (const Quaternion &a, Real b)
 
Quaternion operator/ (const Quaternion &a, Real b)
 
template<class Matrix , class Preconditioner >
int CG (const Matrix &A, Vector &x, const Vector &b, const Preconditioner &M, int &max_iter, Real &tol)
 
Real RungeKutta4_step (RealFunction2 *f, Real t0, Real h, Real w)
 Runge-Kutta 4 step for 1D ODEs. More...
 
Real RungeKutta4 (RealFunction2 *f, Real a, Real b, Real alpha, int n)
 Runge-Kutta 4 method for 1D ODEs. More...
 
Real RKF (RealFunction2 *f, Real a, Real b, Real alpha, Real tol, Real hmax, Real hmin)
 Runge-Kutta-Fehlberg method for 1D ODEs. More...
 
Real AM2I (RealFunction2 *f, Real h, Real t0, Real t1, Real t2, Real w0, Real w1, Real w2)
 Adams-Moulton 2 step implicit method for 1D ODEs. More...
 
Real AM2E (RealFunction2 *f, Real h, Real t0, Real t1, Real w0, Real w1)
 Adams-Bashforth 2 step explicit method for 1D ODEs. More...
 
Real AM2_predictor_corrector_step (RealFunction2 *f, Real h, Real t0, Real t1, Real t2, Real w0, Real w1)
 Adams-Moulton predictor-corrector step of order 2 for 1D ODEs.
 
Real AM2_predictor_corrector (RealFunction2 *f, Real a, Real b, Real alpha0, Real alpha1, int n)
 Adams-Moulton predictor-corrector of order 2 for 1D ODEs.
 
void Euler_step (DiffEqFunction *f, Real t0, Real h, const Vector &w0, Vector &w1)
 Euler step for an ODE system. More...
 
void RungeKutta4_step (DiffEqFunction *f, Real t0, Real h, const Vector &w0, Vector &w1)
 Runge-Kutta 4 step for an ODE system. More...
 
void Euler (DiffEqFunction *f, Real a, Real b, const Vector &alpha, int n, Vector &wn)
 Solve an ODE system using Euler's method. More...
 
void RungeKutta4 (DiffEqFunction *f, Real a, Real b, const Vector &alpha, int n, Vector &wn)
 Solve an ODE system using the Runge Kutta 4 method. More...
 
void Div (Vector &x, Real h)
 
void Div (Matrix &x, Real h)
 
Real dfCenteredDifference (RealFunction &f, Real x, Real h)
 
void dfCenteredDifference (VectorFunction &f, Real x, Real h, Vector &df)
 
Real dfCenteredDifferenceAdaptive (RealFunction &f, Real x, Real h0, Real tol)
 
void dfCenteredDifferenceAdaptive (VectorFunction &f, Real x, Real h0, Real tol, Vector &df)
 
Real ddfCenteredDifference (RealFunction &f, Real x, Real h)
 
void ddfCenteredDifference (VectorFunction &f, Real x, Real h, Vector &ddf)
 
void GradientForwardDifference (ScalarFieldFunction &f, Vector &x, Real h, Vector &g)
 x is provided as a temporary, it's restored to its original value later
 
void JacobianForwardDifference (VectorFieldFunction &f, Vector &x, Real h, Matrix &J)
 
void HessianForwardDifference (ScalarFieldFunction &f, Vector &x, Real h, Matrix &H)
 
void HessianForwardDifference_Grad (ScalarFieldFunction &f, Vector &x, Real h, Matrix &H)
 
void GradientCenteredDifference (ScalarFieldFunction &f, Vector &x, Real h, Vector &g)
 
void GradientCenteredDifferenceAdaptive (ScalarFieldFunction &f, Vector &x, Real h0, Real tol, Vector &g)
 
void JacobianCenteredDifference (VectorFieldFunction &f, Vector &x, Real h, Matrix &J)
 
void HessianCenteredDifference (ScalarFieldFunction &f, Vector &x, Real h, Matrix &H)
 
void HessianCenteredDifference_Grad (ScalarFieldFunction &f, Vector &x, Real h, Matrix &H)
 
void GradientForwardDifference (ScalarFieldFunction &f, Vector &x, const Vector &h, Vector &g)
 specified hi in each direction xi
 
void JacobianForwardDifference (VectorFieldFunction &f, Vector &x, const Vector &h, Matrix &J)
 
void HessianForwardDifference (ScalarFieldFunction &f, Vector &x, const Vector &h, Matrix &H)
 
void HessianForwardDifference_Grad (ScalarFieldFunction &f, Vector &x, const Vector &h, Matrix &H)
 
void GradientCenteredDifference (ScalarFieldFunction &f, Vector &x, const Vector &h, Vector &g)
 
void JacobianCenteredDifference (VectorFieldFunction &f, Vector &x, const Vector &h, Matrix &J)
 
void HessianCenteredDifference (ScalarFieldFunction &f, Vector &x, const Vector &h, Matrix &H)
 
void HessianCenteredDifference_Grad (ScalarFieldFunction &f, Vector &x, const Vector &h, Matrix &H)
 
template<class T >
T * array_create (int n)
 
template<class T >
void array_delete (T *v)
 
template<class T >
void array_equal (T *a, const T *b, int n)
 
template<class T >
T * array_copy (T *a, int n)
 
template<class T >
void array_fill (T *a, const T &c, int n)
 
template<class T >
void array_zero (T *a, int n)
 
template<class T >
void array_negate (T *x, const T *a, int n)
 
template<class T >
void array_add (T *x, const T *a, const T *b, int n)
 
template<class T >
void array_sub (T *x, const T *a, const T *b, int n)
 
template<class T >
void array_mul (T *x, const T *a, T s, int n)
 
template<class T >
void array_div (T *x, const T *a, T s, int n)
 
template<class T >
void array_acc (T *x, const T *a, int n)
 
template<class T >
void array_dec (T *x, const T *a, int n)
 
template<class T >
void array_madd (T *x, const T *a, const T &s, int n)
 
template<class T >
void array_axpby (T *z, T a, const T *x, T b, const T *y, int n)
 
template<class T >
void array_mul (T *a, const T &s, int n)
 
template<class T >
void array_div (T *a, const T &s, int n)
 
template<class T >
array_sum_product (const T *a, const T *b, int n)
 
template<class T >
array_dot (const T *a, const T *b, int n)
 
template<class T >
array_norm_squared (const T *a, int n)
 
template<class T >
void gen_array_fill (T *x, int xstride, T c, int n)
 
template<class T >
void gen_array_mul (T *x, int xstride, T c, int n)
 
template<class T >
void gen_array_div (T *x, int xstride, T c, int n)
 
template<class T >
void gen_array_negate (T *x, int xstride, const T *a, int astride, int n)
 
template<class T >
void gen_array_equal (T *x, int xstride, const T *a, int astride, int n)
 
template<class T >
void gen_array_swap (T *x, int xstride, T *y, int ystride, int n)
 
template<class T >
void gen_array_mul (T *x, int xstride, const T *a, int astride, T c, int n)
 
template<class T >
void gen_array_div (T *x, int xstride, const T *a, int astride, T c, int n)
 
template<class T >
void gen_array_add (T *x, int xstride, const T *a, int astride, const T *b, int bstride, int n)
 
template<class T >
void gen_array_sub (T *x, int xstride, const T *a, int astride, const T *b, int bstride, int n)
 
template<class T >
void gen_array_acc (T *x, int xstride, const T *a, int astride, int n)
 
template<class T >
void gen_array_dec (T *x, int xstride, const T *a, int astride, int n)
 
template<class T >
void gen_array_madd (T *x, int xstride, const T *a, int astride, T s, int n)
 
template<class T >
void gen_array_axpby (T *z, int zstride, T a, const T *x, int xstride, T b, const T *y, int ystride, int n)
 
template<class T >
gen_array_sum_product (const T *a, int astride, const T *b, int bstride, int n)
 
template<class T >
gen_array_dot (const T *a, int astride, const T *b, int bstride, int n)
 
template<class T >
gen_array_norm_squared (const T *a, int astride, int n)
 
template<class T >
T ** array2d_create (int m, int n)
 
template<class T >
void array2d_delete (T **v)
 
template<class T >
void array2d_fill (T **X, const T &c, int m, int n)
 
template<class T >
void array2d_identity (T **X, int m, int n)
 
template<class T >
void array2d_equal (T **X, T **const A, int m, int n)
 
template<class T >
T ** array2d_copy (T **A, int m, int n)
 
template<class T >
void array2d_transpose (T **X, T **const A, int m, int n)
 
template<class T >
void array2d_add (T **x, T **const a, T **const b, int m, int n)
 
template<class T >
void array2d_sub (T **x, T **const a, T **const b, int m, int n)
 
template<class T >
void array2d_mul (T **x, T **const a, T **const b, int m, int n, int p)
 
template<class T >
void array2d_multiply_transposeA (T **x, T **const a, T **const b, int m, int n, int p)
 
template<class T >
void array2d_multiply_transposeB (T **x, T **const a, T **const b, int m, int n, int p)
 
template<class T >
void array2d_vector_multiply (T *x, T **const a, const T *b, int m, int n)
 
template<class T >
void array2d_vector_multiply_transpose (T *x, T **const a, const T *b, int m, int n)
 
template<class T >
void array2d_vector_madd (T *x, T **const a, const T *b, int m, int n)
 
template<class T >
void array2d_vector_madd_transpose (T *x, T **const a, const T *b, int m, int n)
 
template<class T >
array2d_row_dot (T **const a, int i, const T *v, int m, int n)
 
template<class T >
array2d_col_dot (T **const a, int i, const T *v, int m, int n)
 
template<class T >
T * gen_array2d_entry (T *X, int xis, int xjs, int i, int j)
 
template<class T >
T * gen_array2d_row (T *X, int xis, int xjs, int i)
 
template<class T >
T * gen_array2d_col (T *X, int xis, int xjs, int j)
 
template<class T >
void gen_array2d_fill (T *X, int xis, int xjs, const T &c, int m, int n)
 
template<class T >
void gen_array2d_identity (T *X, int xis, int xjs, int m, int n)
 
template<class T >
void gen_array2d_equal (T *X, int xis, int xjs, const T *A, int ais, int ajs, int m, int n)
 
template<class T >
void gen_array2d_transpose (T *X, int xis, int xjs, const T *A, int ais, int ajs, int m, int n)
 
template<class T >
void gen_array2d_add (T *X, int xis, int xjs, const T *A, int ais, int ajs, const T *B, int bis, int bjs, int m, int n)
 
template<class T >
void gen_array2d_sub (T *X, int xis, int xjs, const T *A, int ais, int ajs, const T *B, int bis, int bjs, int m, int n)
 
template<class T >
void gen_array2d_mul (T *X, int xis, int xjs, const T *A, int ais, int ajs, const T &c, int m, int n)
 
template<class T >
void gen_array2d_mul (T *X, int xis, int xjs, const T &c, int m, int n)
 
template<class T >
void gen_array2d_div (T *X, int xis, int xjs, const T &c, int m, int n)
 
template<class T >
void gen_array2d_acc (T *X, int xis, int xjs, const T *A, int ais, int ajs, int m, int n)
 
template<class T >
void gen_array2d_dec (T *X, int xis, int xjs, const T *A, int ais, int ajs, int m, int n)
 
template<class T >
void gen_array2d_madd (T *X, int xis, int xjs, const T *A, int ais, int ajs, const T &c, int m, int n)
 
template<class T >
void gen_array2d_negate (T *X, int xis, int xjs, const T *A, int ais, int ajs, int m, int n)
 
template<class T >
void gen_array2d_multiply (T *X, int xis, int xjs, const T *A, int ais, int ajs, const T *B, int bis, int bjs, int m, int n, int p)
 
template<class T >
void gen_array2d_multiply_transposeA (T *X, int xis, int xjs, const T *A, int ais, int ajs, const T *B, int bis, int bjs, int m, int n, int p)
 
template<class T >
void gen_array2d_multiply_transposeB (T *X, int xis, int xjs, const T *A, int ais, int ajs, const T *B, int bis, int bjs, int m, int n, int p)
 
template<class T >
void gen_array2d_vector_multiply (T *x, int xs, const T *A, int ais, int ajs, const T *b, int bs, int m, int n)
 
template<class T >
void gen_array2d_vector_multiply_transpose (T *x, int xs, const T *A, int ais, int ajs, const T *b, int bs, int m, int n)
 
template<class T >
void gen_array2d_vector_madd (T *x, int xs, const T *A, int ais, int ajs, const T *b, int bs, int m, int n)
 
template<class T >
void gen_array2d_vector_madd_transpose (T *x, int xs, const T *A, int ais, int ajs, const T *b, int bs, int m, int n)
 
template<class T >
void GaussianCondition (const VectorTemplate< T > &mean, const MatrixTemplate< T > &cov, const VectorTemplate< T > &x, const std::vector< int > &elements, VectorTemplate< T > &newmean, MatrixTemplate< T > &newcov)
 
template<class T >
void GaussianMarginalize (const VectorTemplate< T > &mean, const MatrixTemplate< T > &cov, const std::vector< int > &elements, VectorTemplate< T > &newmean, MatrixTemplate< T > &newcov)
 marginalizes the distribution N(mean,cov) over the given elements
 
template<class T >
void GaussianTransform (const VectorTemplate< T > &mean, const MatrixTemplate< T > &cov, const MatrixTemplate< T > &A, const VectorTemplate< T > &b, VectorTemplate< T > &newmean, MatrixTemplate< T > &newcov)
 transforms the distribution N(mean,cov) with the linear transform Ax+b
 
template<class T >
void GaussianTransformJoint (const VectorTemplate< T > &xmean, const MatrixTemplate< T > &xcov, const MatrixTemplate< T > &A, const VectorTemplate< T > &b, VectorTemplate< T > &jointmean, MatrixTemplate< T > &jointcov)
 
template void GaussianCondition (const VectorTemplate< float > &mean, const MatrixTemplate< float > &cov, const VectorTemplate< float > &x, const std::vector< int > &elements, VectorTemplate< float > &newmean, MatrixTemplate< float > &newcov)
 
template void GaussianMarginalize (const VectorTemplate< float > &mean, const MatrixTemplate< float > &cov, const std::vector< int > &elements, VectorTemplate< float > &newmean, MatrixTemplate< float > &newcov)
 
template void GaussianTransform (const VectorTemplate< float > &mean, const MatrixTemplate< float > &cov, const MatrixTemplate< float > &A, const VectorTemplate< float > &b, VectorTemplate< float > &newmean, MatrixTemplate< float > &newcov)
 
template void GaussianTransformJoint (const VectorTemplate< float > &mean, const MatrixTemplate< float > &cov, const MatrixTemplate< float > &A, const VectorTemplate< float > &b, VectorTemplate< float > &jointmean, MatrixTemplate< float > &jointcov)
 
template void GaussianCondition (const VectorTemplate< double > &mean, const MatrixTemplate< double > &cov, const VectorTemplate< double > &x, const std::vector< int > &elements, VectorTemplate< double > &newmean, MatrixTemplate< double > &newcov)
 
template void GaussianMarginalize (const VectorTemplate< double > &mean, const MatrixTemplate< double > &cov, const std::vector< int > &elements, VectorTemplate< double > &newmean, MatrixTemplate< double > &newcov)
 
template void GaussianTransform (const VectorTemplate< double > &mean, const MatrixTemplate< double > &cov, const MatrixTemplate< double > &A, const VectorTemplate< double > &b, VectorTemplate< double > &newmean, MatrixTemplate< double > &newcov)
 
template void GaussianTransformJoint (const VectorTemplate< double > &mean, const MatrixTemplate< double > &cov, const MatrixTemplate< double > &A, const VectorTemplate< double > &b, VectorTemplate< double > &jointmean, MatrixTemplate< double > &jointcov)
 
template<class T >
int OrthonormalBasis (const VectorTemplate< T > *x, VectorTemplate< T > *basis, int n)
 
template<class T >
int OrthogonalBasis (const VectorTemplate< T > *x, VectorTemplate< T > *basis, int n)
 Same as above, but does not normalize.
 
template<class T >
void Orthogonalize (VectorTemplate< T > &x, const VectorTemplate< T > *basis, int n)
 orthogonalizes a vector w.r.t the orthogonal basis of n vectors
 
 DEFINEGRAMSCHMIDT (float)
 
 DEFINEGRAMSCHMIDT (double)
 
 DEFINEGRAMSCHMIDT (Complex)
 
template<class T >
HouseholderTransform (VectorTemplate< T > &v)
 
template<class T >
void HouseholderPreMultiply (T tau, const VectorTemplate< T > &v, MatrixTemplate< T > &A)
 
template<class T >
void HouseholderPostMultiply (T tau, const VectorTemplate< T > &v, MatrixTemplate< T > &A)
 
template<class T >
void HouseholderApply (T tau, const VectorTemplate< T > &v, VectorTemplate< T > &w)
 
template<class T >
void HouseholderHM1 (T tau, MatrixTemplate< T > &A)
 
 DEFINEHH (float)
 
 DEFINEHH (double)
 
template<class T >
void SetElements (VectorTemplate< T > &A, const std::vector< int > &indices, T fill)
 Sets A[indices] = fill.
 
template<class T >
void SetElements (VectorTemplate< T > &A, const std::vector< int > &indices, const VectorTemplate< T > &fill)
 Sets A[indices] = fill. More...
 
template<class T >
void GetElements (const VectorTemplate< T > &A, const std::vector< int > &indices, VectorTemplate< T > &B)
 Sets B = A[indices].
 
template<class T >
void CopyElements (VectorTemplate< T > &A, const std::vector< int > &aindices, const VectorTemplate< T > &B, const std::vector< int > &bindices)
 Sets A[aindices] = B[bindices].
 
template<class T >
void RemoveElements (VectorTemplate< T > &A, const std::vector< int > &indices)
 Removes the indexed elements of A (shrinking A)
 
template<class T >
void RemoveElements (SparseArray< T > &A, const std::vector< int > &indices)
 Removes the indexed elements of A (shrinking A)
 
template<class T >
void AddElements (VectorTemplate< T > &A, const std::vector< int > &indices, T fill)
 The inverse of RemoveElements. More...
 
template<class T >
void SetRows (MatrixTemplate< T > &A, const std::vector< int > &indices, T fill)
 Sets the indexed rows of A to fill.
 
template<class T >
void SetElements (MatrixTemplate< T > &A, const std::vector< int > &rows, const std::vector< int > &cols, T fill)
 Sets A[r,c] = fill for all r in rows and all c in columns.
 
template<class T >
void SetElements (MatrixTemplate< T > &A, const std::vector< int > &rows, const std::vector< int > &cols, const MatrixTemplate< T > &fill)
 Sets A[r,c] = fill for all r in rows and all c in columns. More...
 
template<class T >
void GetElements (const MatrixTemplate< T > &A, const std::vector< int > &rows, const std::vector< int > &cols, MatrixTemplate< T > &B)
 Sets B[i,j] = A[rows[i],cols[j]] for all i and j.
 
template<class T >
void CopyElements (MatrixTemplate< T > &A, const std::vector< int > &arows, const std::vector< int > &acols, const MatrixTemplate< T > &B, const std::vector< int > &brows, const std::vector< int > &bcols)
 Sets A[ar,ac] = B[br,bc] for all (ar,br) in arows x brows, (ac,bc) in acols x bcols.
 
template<class T >
void RemoveElements (MatrixTemplate< T > &A, const std::vector< int > &rows, const std::vector< int > &cols)
 Removes the indexed rows and columns of A (shrinking A)
 
template<class T >
void SetColumns (MatrixTemplate< T > &A, const std::vector< int > &indices, T fill)
 Sets the indexed columns of A to fill.
 
template<class T >
void SetRows (MatrixTemplate< T > &A, const std::vector< int > &indices, const VectorTemplate< T > &fill)
 Sets the indexed rows of A to the vector fill.
 
template<class T >
void SetColumns (MatrixTemplate< T > &A, const std::vector< int > &indices, const VectorTemplate< T > &fill)
 Sets the indexed columns of A to the vector fill.
 
template<class T >
void SetRows (MatrixTemplate< T > &A, const std::vector< int > &indices, const MatrixTemplate< T > &fill)
 Sets the indexed rows of A to the columns of the matrix fill. More...
 
template<class T >
void SetColumns (MatrixTemplate< T > &A, const std::vector< int > &indices, const MatrixTemplate< T > &fill)
 Sets the indexed columns of A to the columns of the matrix fill. More...
 
template<class T >
void GetRows (const MatrixTemplate< T > &A, const std::vector< int > &indices, MatrixTemplate< T > &B)
 Copies the indexed rows in A into B. More...
 
template<class T >
void GetColumns (const MatrixTemplate< T > &A, const std::vector< int > &indices, MatrixTemplate< T > &B)
 Copies the indexed columns in A into B. More...
 
template<class T >
void RemoveRows (MatrixTemplate< T > &A, const std::vector< int > &indices)
 Removes the rows of A indexed by the sorted list indices.
 
template<class T >
void RemoveColumns (MatrixTemplate< T > &A, const std::vector< int > &indices)
 Removes the columns of A indexed by the sorted indices.
 
template<class T >
void RemoveRows (SparseMatrixTemplate_RM< T > &A, const std::vector< int > &indices)
 Removes the rows of A indexed by the sorted list indices.
 
template<class T >
void RemoveColumns (SparseMatrixTemplate_RM< T > &A, const std::vector< int > &indices)
 Removes the columns of A indexed by the sorted indices.
 
int IsNaN (double x)
 Returns nonzero if x is not-a-number (NaN)
 
int IsFinite (double x)
 Returns nonzero unless x is infinite or a NaN.
 
int IsInf (double x)
 Returns +1 if x is +inf, -1 if x is -inf, and 0 otherwise.
 
int IsNaN (float x)
 
int IsFinite (float x)
 
int IsInf (float x)
 
template<class type >
void interpolate (const type &a, const type &b, Real u, type &x)
 
template<class T >
void interpolate (const VectorTemplate< T > &a, const VectorTemplate< T > &b, Real u, VectorTemplate< T > &x)
 
template<class T >
void interpolate (const MatrixTemplate< T > &a, const MatrixTemplate< T > &b, Real u, MatrixTemplate< T > &x)
 
template<class T >
bool LinearlyDependent_Robust (const VectorTemplate< T > &a, const VectorTemplate< T > &b, T &c, bool &cb, T eps=Epsilon)
 Robust determination of linear dependence. More...
 
template<class T >
bool LinearlyDependent_Robust (const MatrixTemplate< T > &A, VectorTemplate< T > &c, T eps=Epsilon)
 A matrix version of the function above. More...
 
double Abs (double x)
 
double Sqr (double x)
 
double Sqrt (double x)
 
double Exp (double x)
 
double Log (double x)
 
double Pow (double x, double y)
 
double Sin (double x)
 
double Cos (double x)
 
double Tan (double x)
 
double Sinh (double x)
 
double Cosh (double x)
 
double Tanh (double x)
 
double Asin (double x)
 
double Acos (double x)
 
double Atan (double x)
 
double Atan2 (double y, double x)
 
double Floor (double x)
 
double Ceil (double x)
 
double Mod (double x, double y)
 
float Abs (float x)
 
float Sqr (float x)
 
float Sqrt (float x)
 
float Exp (float x)
 
float Log (float x)
 
float Pow (float x, float y)
 
float Sin (float x)
 
float Cos (float x)
 
float Tan (float x)
 
float Sinh (float x)
 
float Cosh (float x)
 
float Tanh (float x)
 
float Asin (float x)
 
float Acos (float x)
 
float Atan (float x)
 
float Atan2 (float y, float x)
 
float Floor (float x)
 
float Ceil (float x)
 
float Mod (float x, float y)
 
double Inv (double x)
 1/x
 
double Sign (double x)
 Returns {-1,0,1} if x is {<0,0,>0}.
 
double Clamp (double x, double a, double b)
 Returns a if x < a, b if x > b, otherwise x.
 
double Trunc (double x)
 
double Frac (double x)
 
float Inv (float x)
 
float Sign (float x)
 
float Clamp (float x, float a, float b)
 
float Trunc (float x)
 
float Frac (float x)
 
double dot (double a, double b)
 Dot product of a scalar as a 1-d vector.
 
bool FuzzyEquals (double a, double b, double eps=dEpsilon)
 Returns true if a and b are within +/- eps.
 
bool FuzzyZero (double a, double eps=dEpsilon)
 Returns true if a is zero within +/- eps.
 
double PseudoInv (double x, double eps=dZero)
 Returns 1/x if x is nonzero, otherwise 0.
 
float dot (float a, float b)
 
bool FuzzyEquals (float a, float b, float eps=fEpsilon)
 
bool FuzzyZero (float a, float eps=fEpsilon)
 
float PseudoInv (float x, float eps=fZero)
 
template<class T >
Real Delta (T i, T j)
 Kronecker delta.
 
template<class T >
Real Delta (T x)
 
double DtoR (double f)
 Degree to radian conversion.
 
double RtoD (double f)
 Radian to degree conversion.
 
float DtoR (float f)
 
float RtoD (float f)
 
template<class T >
void PrintMatrix (const MatrixTemplate< T > &x, ostream &out, char delim, char bracket, int indent=0)
 
template<class T >
void OutputPlusMinus (ostream &out, const MatrixTemplate< T > &x, int indent, T zeroTolerance=Epsilon)
 
ostream & operator<< (ostream &out, const MatrixPrinter &mp)
 
std::ostream & operator<< (std::ostream &out, const MatrixPrinter &mp)
 
template<class T >
ostream & operator<< (ostream &out, const MatrixTemplate< T > &mat)
 
template<class T >
istream & operator>> (istream &in, MatrixTemplate< T > &mat)
 
template ostream & operator<< (ostream &out, const MatrixTemplate< float > &v)
 
template ostream & operator<< (ostream &out, const MatrixTemplate< double > &v)
 
template ostream & operator<< (ostream &out, const MatrixTemplate< Complex > &v)
 
template istream & operator>> (istream &in, MatrixTemplate< float > &v)
 
template istream & operator>> (istream &in, MatrixTemplate< double > &v)
 
template istream & operator>> (istream &in, MatrixTemplate< Complex > &v)
 
template<class T >
bool IsFinite (const MatrixTemplate< T > &A)
 returns true if all elements of A are finite
 
template<class T >
bool HasNaN (const MatrixTemplate< T > &A)
 returns true if any element of A is NaN
 
template<class T >
int HasInf (const MatrixTemplate< T > &A)
 returns nonzero if any element of A is infinite
 
template<class T >
std::ostream & operator<< (std::ostream &, const MatrixTemplate< T > &)
 
template<class T >
std::istream & operator>> (std::istream &, MatrixTemplate< T > &)
 
template<class T >
DotSelf (const T &a)
 
double Pow (double a, float b)
 
float Pow (float a, double b)
 
template<class T >
Norm (const V< T > &x, Real norm)
 
template<class T >
Norm_L1 (const V< T > &x)
 
template<class T >
Norm_L2 (const V< T > &x)
 
template<class T >
Norm_L2_Safe (const V< T > &x)
 
template<class T >
Norm_LInf (const V< T > &x)
 
template<class T >
Norm_Mahalanobis (const V< T > &x, const M< T > &A)
 
template<class T >
Norm_Weighted (const V< T > &x, Real norm, const V< T > &w)
 
template<class T >
Norm_WeightedL1 (const V< T > &x, const V< T > &w)
 
template<class T >
Norm_WeightedL2 (const V< T > &x, const V< T > &w)
 
template<class T >
Norm_WeightedLInf (const V< T > &x, const V< T > &w)
 
template<class T >
Distance (const V< T > &x, const V< T > &y, Real norm)
 
template<class T >
Distance_L1 (const V< T > &x, const V< T > &y)
 
template<class T >
Distance_L2 (const V< T > &x, const V< T > &y)
 
template<class T >
Distance_L2_Safe (const V< T > &x, const V< T > &y)
 
template<class T >
Distance_LInf (const V< T > &x, const V< T > &y)
 
template<class T >
Distance_Mahalanobis (const V< T > &x, const V< T > &y, const M< T > &A)
 
template<class T >
Distance_Weighted (const V< T > &x, const V< T > &y, Real norm, const V< T > &w)
 
template<class T >
Distance_WeightedL1 (const V< T > &x, const V< T > &y, const V< T > &w)
 
template<class T >
Distance_WeightedL2 (const V< T > &x, const V< T > &y, const V< T > &w)
 
template<class T >
Distance_WeightedLInf (const V< T > &x, const V< T > &y, const V< T > &w)
 
template<class T >
Norm_L1 (const M< T > &A)
 
template<class T >
Norm_LInf (const M< T > &A)
 
template<class T >
Norm_Frobenius (const M< T > &A)
 
template<class T >
Norm_Frobenius_Safe (const M< T > &A)
 
template<class T >
Distance_L1 (const M< T > &A, const M< T > &B)
 
template<class T >
Distance_LInf (const M< T > &A, const M< T > &B)
 
template<class T >
Distance_Frobenius (const M< T > &A, const M< T > &B)
 
template<class T >
Distance_Frobenius_Safe (const M< T > &A, const M< T > &B)
 
template<>
Complex Norm_LInf (const V< Complex > &x)
 
template<>
Complex Norm_WeightedLInf (const V< Complex > &x, const V< Complex > &w)
 
template<>
Complex Distance_LInf (const V< Complex > &x, const V< Complex > &y)
 
template<>
Complex Distance_WeightedLInf (const V< Complex > &x, const V< Complex > &y, const V< Complex > &w)
 
template<>
Complex Distance_L2_Safe (const V< Complex > &x, const V< Complex > &y)
 
template<>
Complex Norm_L1 (const M< Complex > &A)
 
template<>
Complex Norm_LInf (const M< Complex > &A)
 
template<>
Complex Distance_L1 (const M< Complex > &A, const M< Complex > &B)
 
template<>
Complex Distance_LInf (const M< Complex > &A, const M< Complex > &B)
 
template<>
Complex Distance_Frobenius_Safe (const M< Complex > &A, const M< Complex > &B)
 
 DEFINEMETRIC (float)
 
 DEFINEMETRIC (double)
 
template Complex Norm (const V< Complex > &x, Real norm)
 
template Complex Norm_L1 (const V< Complex > &x)
 
template Complex Norm_L2 (const V< Complex > &x)
 
template Complex Norm_L2_Safe (const V< Complex > &x)
 
template Complex Norm_Mahalanobis (const V< Complex > &x, const M< Complex > &k)
 
template Complex Norm_Weighted (const V< Complex > &x, Real norm, const V< Complex > &w)
 
template Complex Norm_WeightedL1 (const V< Complex > &x, const V< Complex > &w)
 
template Complex Norm_WeightedL2 (const V< Complex > &x, const V< Complex > &w)
 
template Complex Distance (const V< Complex > &x, const V< Complex > &y, Real norm)
 
template Complex Distance_L1 (const V< Complex > &x, const V< Complex > &y)
 
template Complex Distance_L2 (const V< Complex > &x, const V< Complex > &y)
 
template Complex Distance_Mahalanobis (const V< Complex > &x, const V< Complex > &y, const M< Complex > &A)
 
template Complex Distance_Weighted (const V< Complex > &x, const V< Complex > &y, Real norm, const V< Complex > &w)
 
template Complex Distance_WeightedL1 (const V< Complex > &x, const V< Complex > &y, const V< Complex > &w)
 
template Complex Distance_WeightedL2 (const V< Complex > &x, const V< Complex > &y, const V< Complex > &w)
 
template Complex Norm_Frobenius (const M< Complex > &A)
 
template Complex Norm_Frobenius_Safe (const M< Complex > &A)
 
template Complex Distance_Frobenius (const M< Complex > &A, const M< Complex > &B)
 
template<class T >
Norm (const VectorTemplate< T > &x, Real norm)
 
template<class T >
Norm_L1 (const VectorTemplate< T > &x)
 
template<class T >
Norm_L2 (const VectorTemplate< T > &x)
 
template<class T >
Norm_L2_Safe (const VectorTemplate< T > &x)
 Same as above, but robust to over/underflow.
 
template<class T >
Norm_LInf (const VectorTemplate< T > &x)
 
template<class T >
Norm_Mahalanobis (const VectorTemplate< T > &x, const MatrixTemplate< T > &A)
 
template<class T >
Norm_Weighted (const VectorTemplate< T > &x, Real norm, const VectorTemplate< T > &w)
 
template<class T >
Norm_WeightedL1 (const VectorTemplate< T > &x, const VectorTemplate< T > &w)
 
template<class T >
Norm_WeightedL2 (const VectorTemplate< T > &x, const VectorTemplate< T > &w)
 
template<class T >
Norm_WeightedLInf (const VectorTemplate< T > &x, const VectorTemplate< T > &w)
 
template<class T >
Distance (const VectorTemplate< T > &x, const VectorTemplate< T > &y, Real norm)
 
template<class T >
Distance_L1 (const VectorTemplate< T > &x, const VectorTemplate< T > &y)
 
template<class T >
Distance_L2 (const VectorTemplate< T > &x, const VectorTemplate< T > &y)
 
template<class T >
Distance_L2_Safe (const VectorTemplate< T > &x, const VectorTemplate< T > &y)
 Same as above, but robust to over/underflow.
 
template<class T >
Distance_LInf (const VectorTemplate< T > &x, const VectorTemplate< T > &y)
 
template<class T >
Distance_Mahalanobis (const VectorTemplate< T > &x, const VectorTemplate< T > &y, const MatrixTemplate< T > &A)
 
template<class T >
Distance_Weighted (const VectorTemplate< T > &x, const VectorTemplate< T > &y, Real norm, const VectorTemplate< T > &w)
 
template<class T >
Distance_WeightedL1 (const VectorTemplate< T > &x, const VectorTemplate< T > &y, const VectorTemplate< T > &w)
 
template<class T >
Distance_WeightedL2 (const VectorTemplate< T > &x, const VectorTemplate< T > &y, const VectorTemplate< T > &w)
 
template<class T >
Distance_WeightedLInf (const VectorTemplate< T > &x, const VectorTemplate< T > &y, const VectorTemplate< T > &w)
 
template<class T >
Norm_L1 (const MatrixTemplate< T > &A)
 
template<class T >
Norm_LInf (const MatrixTemplate< T > &A)
 
template<class T >
Norm_Frobenius (const MatrixTemplate< T > &A)
 
template<class T >
Norm_Frobenius_Safe (const MatrixTemplate< T > &A)
 Same as above, but robust to over/underflow.
 
template<class T >
Distance_L1 (const MatrixTemplate< T > &A, const MatrixTemplate< T > &B)
 
template<class T >
Distance_LInf (const MatrixTemplate< T > &A, const MatrixTemplate< T > &B)
 
template<class T >
Distance_Frobenius (const MatrixTemplate< T > &A, const MatrixTemplate< T > &B)
 
template<class T >
Distance_Frobenius_Safe (const MatrixTemplate< T > &A, const MatrixTemplate< T > &B)
 Same as above, but robust to over/underflow.
 
int quadratic (double a, double b, double c, double &x1, double &x2)
 
int cubic (double a, double b, double c, double d, double x[3])
 
double pythag (double a, double b)
 Returns c where a^2+b^2=c^2.
 
double pythag_leg (double a, double c)
 Returns b where a^2+b^2=c^2.
 
double Sinc (double x)
 Computes the sinc function sin(x)/x (stable for small x)
 
double Sinc_Dx (double x)
 Computes the derivative of the sinc function.
 
double dFactorial (unsigned int n)
 Computes the factorial of n, with double precision.
 
double dLogFactorial (unsigned int n)
 Computes the log of the factorial of n.
 
double dChoose (unsigned int n, unsigned int k)
 Computes n choose k in double precision.
 
double dLogChoose (unsigned int n, unsigned int k)
 Computes the log of n choose k.
 
double TaylorCoeff (double x, unsigned int n)
 Computes the taylor series coefficient x^n/n!
 
double Gamma (double x)
 Computes the gamma function.
 
double LogGamma (double x)
 Computes log gamma(x)
 
double GammaInv (double x)
 Computes 1 / gamma(x)
 
double Beta (double a, double b)
 Computes the beta function B(a,b)
 
double LogBeta (double a, double b)
 Computes log B(a,b)
 
double NormalizedIncompleteBeta (double a, double b, double x)
 Computes the normalized incomplete beta function B(a,b,x)
 
double Erf (double x)
 Computes the error function.
 
double ErfComplimentary (double x)
 Computes the complimentary error function?
 
int quadratic (float a, float b, float c, float &x1, float &x2)
 
int cubic (float a, float b, float c, float d, float x[3])
 
float pythag (float a, float b)
 
float pythag_leg (float a, float c)
 
float Sinc (float x)
 
float Sinc_Dx (float x)
 
float fFactorial (unsigned int n)
 
float fLogFactorial (unsigned int n)
 
float fChoose (unsigned int n, unsigned int k)
 
float fLogChoose (unsigned int n, unsigned int k)
 
float TaylorCoeff (float x, unsigned int n)
 
float Gamma (float x)
 
float LogGamma (float x)
 
float GammaInv (float x)
 
float Beta (float a, float b)
 
float LogBeta (float a, float b)
 
float NormalizedIncompleteBeta (float a, float b, float x)
 
float Erf (float x)
 
float ErfComplimentary (float x)
 
int FuzzySign (double x, double eps=dEpsilon)
 Returns -1 if x<eps, 0 if |x|<=eps, 1 if x>eps.
 
bool OpposingSigns_pos (double a, double b)
 
bool OpposingSigns_neg (double a, double b)
 Same as above, but treats 0 as a negative number.
 
int FuzzySign (float x, float eps=fEpsilon)
 
bool OpposingSigns_pos (float a, float b)
 
bool OpposingSigns_neg (float a, float b)
 
template<class T >
IntegerPower (const T x, int i)
 Calculates x^i where i is an integer (in O(log i) time)
 
unsigned int Factorial (unsigned int n)
 Returns n! in O(n) time.
 
unsigned int FactorialTruncated (unsigned int n, unsigned int k)
 Returns n!/(n-k)! in O(k) time.
 
unsigned int Choose (unsigned int n, unsigned int k)
 Returns `n choose k' = n!/k!(n-k)! in O(k) time.
 
Real rFactorial (unsigned int n)
 
Real LogFactorial (unsigned int n)
 
Real rChoose (unsigned int n, unsigned int k)
 
Real LogChoose (unsigned int n, unsigned int k)
 
void Srand (unsigned long seed)
 
long int RandInt ()
 Generates a random int.
 
long int RandInt (long int n)
 
Real Rand ()
 Generates a random Real uniformly in [0,1].
 
Real Rand (Real a, Real b)
 Generates a random Real uniformly in [a,b].
 
Real RandGaussian ()
 
Real RandGaussian (Real mean, Real stddev)
 Generates a random Real in a Gaussian distribution.
 
bool RandBool ()
 Generates a random boolean that is true with probability 0.5.
 
bool RandBool (Real p)
 Generates a random boolean that is true with probability p.
 
std::ostream & operator<< (std::ostream &out, ConvergenceResult r)
 
ConvergenceResult Root_Bisection (RealFunction &f, Real &a, Real &b, Real &x, Real tol)
 Uses bisection to bracket f's root. More...
 
ConvergenceResult Root_Secant (RealFunction &f, Real x0, Real &x1, int &maxIters, Real tolx, Real tolf)
 Uses the secant method to search for f's root. More...
 
ConvergenceResult Root_SecantBracket (RealFunction &f, Real &a, Real &b, Real &x, int &iters, Real tolx, Real tolf)
 
ConvergenceResult Root_Newton (RealFunction &f, Real &x, int &maxIters, Real tolx, Real tolf)
 Performs Newton's method, which uses the derivative of f to search for it's root. More...
 
ConvergenceResult Root_NewtonBracket (RealFunction &f, Real a, Real b, Real &x, int &maxIters, Real tolx, Real tolf)
 Same as above, but the interval [a,b] must be known to contain a root.
 
ConvergenceResult Root_Newton (ScalarFieldFunction &f, const Vector &x0, Vector &x, int &maxIters, Real tolx, Real tolf)
 Same as Root_Newton(), but takes a scalar field function as input.
 
ConvergenceResult Root_Newton (VectorFieldFunction &f, const Vector &x0, Vector &x, int &maxIters, Real tolx, Real tolf)
 Same as Root_Newton(), but takes a vector field function as input.
 
template<class T >
int RowEchelonDecompose (MatrixTemplate< T > &A, MatrixTemplate< T > &B, Real zeroTol)
 
template<class T >
void ReduceRowEchelon (MatrixTemplate< T > &A, MatrixTemplate< T > &B)
 
template<class T >
bool IsRowEchelon (const MatrixTemplate< T > &A)
 
template<class T >
bool IsReducedRowEchelon (const MatrixTemplate< T > &A)
 
template bool IsRowEchelon< float > (const MatrixTemplate< float > &A)
 
template bool IsRowEchelon< double > (const MatrixTemplate< double > &A)
 
template bool IsReducedRowEchelon< float > (const MatrixTemplate< float > &A)
 
template bool IsReducedRowEchelon< double > (const MatrixTemplate< double > &A)
 
int WeightedSample (const vector< Real > &weights)
 Samples an integer with weighted probability. More...
 
int WeightedSample (const vector< Real > &weights, Real totWeight)
 Same as above, but the sum of all weights, W, is provided.
 
int CumulativeWeightedSample (const std::vector< Real > &partialSumWeights)
 
void RandomAllocate (vector< int > &num, size_t total)
 allocates total samples within the buckets in num, roughly evenly More...
 
void RandomAllocate (vector< int > &num, size_t total, const vector< Real > &weights)
 allocates total samples within the buckets in num More...
 
Real Sample (const Interval &s)
 Uniformly samples the given intervals.
 
Real Sample (const ClosedIntervalSet &s)
 Uniformly samples the interval set.
 
void SampleCircle (Real r, Real &x, Real &y)
 Uniform distribution on boundary of a circle with radius r.
 
void SampleDisk (Real r, Real &x, Real &y)
 Uniform distribution inside a circle with radius r.
 
void SampleTriangle (Real &x, Real &y)
 Uniform distribution in the triangle whose vertices are (0,0),(1,0),(0,1)
 
void SampleSphere (Real r, Real &x, Real &y, Real &z)
 Uniform distribution inside a sphere with radius r.
 
void SampleBall (Real r, Real &x, Real &y, Real &z)
 Uniform distribution on boundary of a sphere with radius r.
 
void SampleHyperSphere (Real r, std::vector< Real > &v)
 Uniformly samples from a hyper-sphere of dimension v.size()
 
void SampleHyperBall (Real r, std::vector< Real > &v)
 Uniformly samples from a hyper-ball of dimension v.size()
 
int WeightedSample (const std::vector< Real > &weights)
 Samples an integer with weighted probability. More...
 
int WeightedSample (const std::vector< Real > &weights, Real totWeight)
 Same as above, but the sum of all weights, W, is provided.
 
void RandomAllocate (std::vector< int > &num, size_t total)
 Allocates total samples within the buckets in num, roughly evenly. An O(n) algorithm where n is the number of buckets. More...
 
void RandomAllocate (std::vector< int > &num, size_t total, const std::vector< Real > &weights)
 Same as above, but with weights. More...
 
bool RFuzzyEquals (Real a, Real b, Real rtol)
 
bool CheckError (Real a, Real b, Real atol, Real rtol)
 
bool CheckError (const Vector &a, const Vector &b, Vector &err, Real atol, Real rtol)
 
bool CheckError (const Matrix &a, const Matrix &b, Matrix &err, Real atol, Real rtol)
 
void SelfTest ()
 
void BasicSelfTest ()
 
void TestVectorBasic ()
 
void TestVectorOps ()
 
void VectorSelfTest ()
 
void MatrixSelfTest ()
 
void DifferentiationSelfTest ()
 
void QuadratureSelfTest ()
 
void BlockVectorSelfTest ()
 
void BlockMatrixSelfTest ()
 
void BLASSelfTest ()
 
void TestDifferentiation (VectorFieldFunction &f, Vector &x, Real h, Real eps)
 
void DebugVector (const char *name, const Vector &v)
 
void DebugMatrix (const char *name, const Matrix &v)
 
bool TestDeriv (RealFunction *f, Real t, Real h, Real atol, Real rtol)
 
bool TestDeriv (VectorFunction *f, Real t, Real h, Real atol, Real rtol)
 
bool TestGradient (ScalarFieldFunction *f, Vector &x, Real h, Real atol, Real rtol)
 
bool TestGradients (ScalarFieldFunction *f, Vector &x, Real h, Real atol, Real rtol)
 these versions test the methods Gradient_i, Jacobian_i, etc.
 
bool TestDeriv2 (RealFunction *f, Real t, Real h, Real atol, Real rtol)
 
bool TestDeriv2 (VectorFunction *f, Real t, Real h, Real atol, Real rtol)
 
bool TestHessian (ScalarFieldFunction *f, Vector &x, Real h, Real atol, Real rtol)
 
bool TestJacobian (VectorFieldFunction *f, Vector &x, Real h, Real atol, Real rtol)
 
bool TestJacobians (VectorFieldFunction *f, Vector &x, Real h, Real atol, Real rtol)
 
void LAPACKSelfTest ()
 
bool TestHessians (VectorFieldFunction *f, Vector &x, Real h, Real atol, Real rtol)
 
template<class T >
std::ostream & operator<< (std::ostream &out, const SparseMatrixTemplate_RM< T > &A)
 
template<class T >
std::istream & operator>> (std::istream &in, SparseMatrixTemplate_RM< T > &A)
 
template ostream & operator<< (ostream &out, const SparseMatrixTemplate_RM< float > &v)
 
template ostream & operator<< (ostream &out, const SparseMatrixTemplate_RM< double > &v)
 
template ostream & operator<< (ostream &out, const SparseMatrixTemplate_RM< Complex > &v)
 
template istream & operator>> (istream &in, SparseMatrixTemplate_RM< float > &v)
 
template istream & operator>> (istream &in, SparseMatrixTemplate_RM< double > &v)
 
template istream & operator>> (istream &in, SparseMatrixTemplate_RM< Complex > &v)
 
template<class T >
bool IsFinite (const SparseMatrixTemplate_RM< T > &x)
 returns true if all elements of x are finite
 
template<class T >
std::ostream & operator<< (std::ostream &, const SparseMatrixTemplate_CR< T > &)
 
template<class T >
bool IsFinite (const SparseVectorTemplate< T > &x)
 returns true if all elements of x are finite
 
template<class T >
bool HasNaN (const SparseVectorTemplate< T > &x)
 returns true if any element of x is NaN
 
template<class T >
bool HasInf (const SparseVectorTemplate< T > &x)
 returns nonzero if any element of x is infininte
 
template<class T >
void Stack (const std::vector< VectorTemplate< T > > &vs, VectorTemplate< T > &out)
 
template<class T >
void Stack (const VectorTemplate< T > &v1, const VectorTemplate< T > &v2, VectorTemplate< T > &out)
 
template<class T >
void HStack (const std::vector< VectorTemplate< T > > &vs, MatrixTemplate< T > &out)
 
template<class T >
void VStack (const std::vector< VectorTemplate< T > > &vs, MatrixTemplate< T > &out)
 
template<class T >
void HStack (const MatrixTemplate< T > &v1, const MatrixTemplate< T > &v2, MatrixTemplate< T > &out)
 
template<class T >
void VStack (const MatrixTemplate< T > &v1, const MatrixTemplate< T > &v2, MatrixTemplate< T > &out)
 
template<class T >
void PrintVector (const VectorTemplate< T > &x, ostream &out, char delim, char bracket)
 
template<class T >
void OutputPlusMinus (ostream &out, const VectorTemplate< T > &x, T zeroTolerance=Epsilon)
 
ostream & operator<< (ostream &out, const VectorPrinter &vp)
 
std::ostream & operator<< (std::ostream &out, const VectorPrinter &vp)
 
template<class T >
ostream & operator<< (ostream &out, const VectorTemplate< T > &v)
 
template<class T >
istream & operator>> (istream &in, VectorTemplate< T > &v)
 
template ostream & operator<< (ostream &out, const VectorTemplate< float > &v)
 
template ostream & operator<< (ostream &out, const VectorTemplate< double > &v)
 
template ostream & operator<< (ostream &out, const VectorTemplate< Complex > &v)
 
template istream & operator>> (istream &in, VectorTemplate< float > &v)
 
template istream & operator>> (istream &in, VectorTemplate< double > &v)
 
template istream & operator>> (istream &in, VectorTemplate< Complex > &v)
 
template<class T >
std::ostream & operator<< (std::ostream &, const VectorTemplate< T > &)
 
template<class T >
std::istream & operator>> (std::istream &, VectorTemplate< T > &)
 
template<class T >
bool FuzzyEquals (const VectorTemplate< T > &a, const VectorTemplate< T > &b, T eps)
 
template<class T >
bool FuzzyZero (const VectorTemplate< T > &a, T eps)
 
template<class T >
dot (const VectorTemplate< T > &a, const VectorTemplate< T > &b)
 
template<class T >
norm (const VectorTemplate< T > &a)
 
template<class T >
bool IsFinite (const VectorTemplate< T > &x)
 returns true if all elements of x are finite
 
template<class T >
bool HasNaN (const VectorTemplate< T > &x)
 returns true if any element of x is NaN
 
template<class T >
int HasInf (const VectorTemplate< T > &x)
 returns nonzero if any element of x is infinite
 
template<class T >
VectorTemplate< T > operator+ (const VectorTemplate< T > &a, const VectorTemplate< T > &b)
 
template<class T >
VectorTemplate< T > operator- (const VectorTemplate< T > &a, const VectorTemplate< T > &b)
 
template<class T >
VectorTemplate< T > operator* (const VectorTemplate< T > &a, T c)
 
template<class T >
VectorTemplate< T > operator* (T c, const VectorTemplate< T > &a)
 
template<class T >
VectorTemplate< T > operator/ (const VectorTemplate< T > &a, T c)
 
template<class T >
VectorTemplate< T > operator/ (T c, const VectorTemplate< T > &a)
 

Variables

const char * MatrixError_IncompatibleDimensions = "Matrices have incompatible dimensions, %d x %d != %d x %d"
 
const char * MatrixError_ArgIncompatibleDimensions = "Matrix arguments have incompatible dimensions"
 
const char * MatrixError_DestIncompatibleDimensions = "Matrix destination has incompatible dimensions"
 
const char * MatrixError_SizeZero = "Matrix has size 0x0"
 
const char * MatrixError_NotSquare = "Matrix is not square"
 
const char * MatrixError_NotSymmetric = "Matrix is not square"
 
const char * MatrixError_InvalidRow = "Matrix row index [%d] out of range"
 
const char * MatrixError_InvalidCol = "Matrix column index [%d] out of range"
 
StandardRNG rng
 

Detailed Description

Contains all definitions in the Math package.

Function Documentation

template<class T >
void Math::GaussianCondition ( const VectorTemplate< T > &  mean,
const MatrixTemplate< T > &  cov,
const VectorTemplate< T > &  x,
const std::vector< int > &  elements,
VectorTemplate< T > &  newmean,
MatrixTemplate< T > &  newcov 
)

sets the conditional distribution of N(mean,cov) given elements x(elements[i]) = x(i)

Referenced by GaussianTransformJoint(), Math::Gaussian< T >::generate(), and Statistics::LinearProcessHMM::Posterior().

template<class T >
void Math::GaussianTransformJoint ( const VectorTemplate< T > &  mean,
const MatrixTemplate< T > &  cov,
const MatrixTemplate< T > &  A,
const VectorTemplate< T > &  b,
VectorTemplate< T > &  jointmean,
MatrixTemplate< T > &  jointcov 
)

if y=Ax+b and x is distributed w.r.t. N(mean,cov), returns a gaussian over the vector [x,y]

References GaussianCondition(), GaussianMarginalize(), and GaussianTransform().

template<class T >
VectorTemplate<T> Math::operator+ ( const VectorTemplate< T > &  a,
const VectorTemplate< T > &  b 
)
inline

The following are potentially very inefficient, depending on the ability of your compiler to optimize the code to eliminate copy constructor calls.

bool Math::TestDeriv ( RealFunction f,
Real  t,
Real  h,
Real  atol,
Real  rtol 
)

the TestX functions test the methods of the function objects and prints errors if the error e=x1-x2 exceeds atol and rtol*max(|x1|,|x2|)

References dfCenteredDifference(), and TestDeriv().

Referenced by TestDeriv().