diff options
author | 2012-08-30 23:40:30 +0800 | |
---|---|---|
committer | 2012-08-30 23:40:30 +0800 | |
commit | d23134e4a7d689431a717a1ecf376b12b01afa24 (patch) | |
tree | d28a79e969a31a2bf70549d11b1a5938fdbd7828 /unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h | |
parent | 9da41cc527ec595feb3377d089db6cd3adc9a5c8 (diff) |
Avoid inefficient 2x2 LU. Move atanh to internal for maintainability.
Diffstat (limited to 'unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h')
-rw-r--r-- | unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h b/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h index 18bcf3d0d..e1e5b770c 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h @@ -51,7 +51,6 @@ private: void compute2x2(const MatrixType& A, MatrixType& result); void computeBig(const MatrixType& A, MatrixType& result); - static Scalar atanh2(Scalar y, Scalar x); int getPadeDegree(float normTminusI); int getPadeDegree(double normTminusI); int getPadeDegree(long double normTminusI); @@ -93,20 +92,6 @@ MatrixType MatrixLogarithmAtomic<MatrixType>::compute(const MatrixType& A) return result; } -/** \brief Compute atanh (inverse hyperbolic tangent) for \f$ y / x \f$. */ -template <typename MatrixType> -typename MatrixType::Scalar MatrixLogarithmAtomic<MatrixType>::atanh2(Scalar y, Scalar x) -{ - using std::abs; - using std::sqrt; - - Scalar z = y / x; - if (abs(z) > sqrt(NumTraits<Scalar>::epsilon())) - return Scalar(0.5) * log((x + y) / (x - y)); - else - return z + z*z*z / Scalar(3); -} - /** \brief Compute logarithm of 2x2 triangular matrix. */ template <typename MatrixType> void MatrixLogarithmAtomic<MatrixType>::compute2x2(const MatrixType& A, MatrixType& result) @@ -131,7 +116,7 @@ void MatrixLogarithmAtomic<MatrixType>::compute2x2(const MatrixType& A, MatrixTy // computation in previous branch is inaccurate if A(1,1) \approx A(0,0) int unwindingNumber = static_cast<int>(ceil((imag(logA11 - logA00) - M_PI) / (2*M_PI))); Scalar y = A(1,1) - A(0,0), x = A(1,1) + A(0,0); - result(0,1) = A(0,1) * (Scalar(2) * atanh2(y,x) + Scalar(0,2*M_PI*unwindingNumber)) / y; + result(0,1) = A(0,1) * (Scalar(2) * internal::atanh2(y,x) + Scalar(0,2*M_PI*unwindingNumber)) / y; } } |