diff options
-rw-r--r-- | Eigen/src/Cholesky/LDLT.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/MathFunctions.h | 15 | ||||
-rw-r--r-- | Eigen/src/LU/LU.h | 2 | ||||
-rw-r--r-- | Eigen/src/SVD/JacobiSquareSVD.h | 2 |
4 files changed, 10 insertions, 11 deletions
diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index e652fd213..1cb1294ac 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -180,7 +180,7 @@ void LDLT<MatrixType>::compute(const MatrixType& a) // in "Analysis of the Cholesky Decomposition of a Semi-definite Matrix" by // Nicholas J. Higham. Also see "Accuracy and Stability of Numerical // Algorithms" page 217, also by Higham. - cutoff = ei_abs(machine_epsilon<Scalar>() * size * biggest_in_corner); + cutoff = ei_abs(epsilon<Scalar>() * size * biggest_in_corner); m_sign = ei_real(m_matrix.diagonal().coeff(index_of_biggest_in_corner)) > 0 ? 1 : -1; } diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index d68c483b2..16091caf0 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -1,7 +1,7 @@ // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // -// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com> +// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com> // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,8 +25,13 @@ #ifndef EIGEN_MATHFUNCTIONS_H #define EIGEN_MATHFUNCTIONS_H +template<typename T> typename NumTraits<T>::Real epsilon() +{ + return std::numeric_limits<typename NumTraits<T>::Real>::epsilon(); +} + template<typename T> inline typename NumTraits<T>::Real precision(); -template<typename T> inline typename NumTraits<T>::Real machine_epsilon(); + template<typename T> inline T ei_random(T a, T b); template<typename T> inline T ei_random(); template<typename T> inline T ei_random_amplitude() @@ -51,7 +56,6 @@ template<typename T> inline typename NumTraits<T>::Real ei_hypot(T x, T y) **************/ template<> inline int precision<int>() { return 0; } -template<> inline int machine_epsilon<int>() { return 0; } inline int ei_real(int x) { return x; } inline int& ei_real_ref(int& x) { return x; } inline int ei_imag(int) { return 0; } @@ -106,7 +110,6 @@ inline bool ei_isApproxOrLessThan(int a, int b, int = precision<int>()) **************/ template<> inline float precision<float>() { return 1e-5f; } -template<> inline float machine_epsilon<float>() { return 1.192e-07f; } inline float ei_real(float x) { return x; } inline float& ei_real_ref(float& x) { return x; } inline float ei_imag(float) { return 0.f; } @@ -154,7 +157,6 @@ inline bool ei_isApproxOrLessThan(float a, float b, float prec = precision<float **************/ template<> inline double precision<double>() { return 1e-12; } -template<> inline double machine_epsilon<double>() { return 2.220e-16; } inline double ei_real(double x) { return x; } inline double& ei_real_ref(double& x) { return x; } @@ -203,7 +205,6 @@ inline bool ei_isApproxOrLessThan(double a, double b, double prec = precision<do *********************/ template<> inline float precision<std::complex<float> >() { return precision<float>(); } -template<> inline float machine_epsilon<std::complex<float> >() { return machine_epsilon<float>(); } inline float ei_real(const std::complex<float>& x) { return std::real(x); } inline float ei_imag(const std::complex<float>& x) { return std::imag(x); } inline float& ei_real_ref(std::complex<float>& x) { return reinterpret_cast<float*>(&x)[0]; } @@ -240,7 +241,6 @@ inline bool ei_isApprox(const std::complex<float>& a, const std::complex<float>& **********************/ template<> inline double precision<std::complex<double> >() { return precision<double>(); } -template<> inline double machine_epsilon<std::complex<double> >() { return machine_epsilon<double>(); } inline double ei_real(const std::complex<double>& x) { return std::real(x); } inline double ei_imag(const std::complex<double>& x) { return std::imag(x); } inline double& ei_real_ref(std::complex<double>& x) { return reinterpret_cast<double*>(&x)[0]; } @@ -278,7 +278,6 @@ inline bool ei_isApprox(const std::complex<double>& a, const std::complex<double ******************/ template<> inline long double precision<long double>() { return precision<double>(); } -template<> inline long double machine_epsilon<long double>() { return 1.084e-19l; } inline long double ei_real(long double x) { return x; } inline long double& ei_real_ref(long double& x) { return x; } inline long double ei_imag(long double) { return 0.; } diff --git a/Eigen/src/LU/LU.h b/Eigen/src/LU/LU.h index f36951fda..733fa0cbc 100644 --- a/Eigen/src/LU/LU.h +++ b/Eigen/src/LU/LU.h @@ -390,7 +390,7 @@ void LU<MatrixType>::compute(const MatrixType& matrix) // this formula comes from experimenting (see "LU precision tuning" thread on the list) // and turns out to be identical to Higham's formula used already in LDLt. - m_precision = machine_epsilon<Scalar>() * size; + m_precision = epsilon<Scalar>() * size; IntColVectorType rows_transpositions(matrix.rows()); IntRowVectorType cols_transpositions(matrix.cols()); diff --git a/Eigen/src/SVD/JacobiSquareSVD.h b/Eigen/src/SVD/JacobiSquareSVD.h index 82133f7be..32adb1301 100644 --- a/Eigen/src/SVD/JacobiSquareSVD.h +++ b/Eigen/src/SVD/JacobiSquareSVD.h @@ -102,7 +102,7 @@ void JacobiSquareSVD<MatrixType, ComputeU, ComputeV>::compute(const MatrixType& if(ComputeU) m_matrixU = MatrixUType::Identity(size,size); if(ComputeV) m_matrixV = MatrixUType::Identity(size,size); m_singularValues.resize(size); - const RealScalar precision = 2 * machine_epsilon<Scalar>(); + const RealScalar precision = 2 * epsilon<Scalar>(); sweep_again: for(int p = 1; p < size; ++p) |