diff options
author | David H. Bailey <anonymous@invalid.net> | 2011-05-23 11:20:13 +0200 |
---|---|---|
committer | David H. Bailey <anonymous@invalid.net> | 2011-05-23 11:20:13 +0200 |
commit | 074b067624e45c8e9f42f2347509d06d0d437226 (patch) | |
tree | e3c83271afbb175a05970b213aa841075a99cd4f /Eigen | |
parent | 7209d6a12610d4682c65a99f12b0d0278fbbe81d (diff) |
fix implicit scalar conversions (needed to support fancy scalar types, see bug #276)
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Core/TriangularMatrix.h | 8 | ||||
-rw-r--r-- | Eigen/src/Eigenvalues/EigenSolver.h | 10 | ||||
-rw-r--r-- | Eigen/src/Eigenvalues/RealSchur.h | 6 | ||||
-rw-r--r-- | Eigen/src/Householder/Householder.h | 2 | ||||
-rw-r--r-- | Eigen/src/Jacobi/Jacobi.h | 16 | ||||
-rw-r--r-- | Eigen/src/LU/PartialPivLU.h | 2 | ||||
-rw-r--r-- | Eigen/src/QR/ColPivHouseholderQR.h | 4 | ||||
-rw-r--r-- | Eigen/src/SVD/JacobiSVD.h | 6 |
8 files changed, 27 insertions, 27 deletions
diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index fee751acd..38c4f1949 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -468,7 +468,7 @@ struct triangular_assignment_selector if (Mode&UnitDiag && row==col) dst.coeffRef(row, col) = 1; else - dst.coeffRef(row, col) = 0; + dst.coeffRef(row, col) = static_cast<typename Derived1::Scalar>(0); } } }; @@ -493,7 +493,7 @@ struct triangular_assignment_selector<Derived1, Derived2, Upper, Dynamic, ClearO dst.copyCoeff(i, j, src); if (ClearOpposite) for(Index i = maxi+1; i < dst.rows(); ++i) - dst.coeffRef(i, j) = 0; + dst.coeffRef(i, j) = static_cast<typename Derived1::Scalar>(0); } } }; @@ -511,7 +511,7 @@ struct triangular_assignment_selector<Derived1, Derived2, Lower, Dynamic, ClearO Index maxi = std::min(j, dst.rows()); if (ClearOpposite) for(Index i = 0; i < maxi; ++i) - dst.coeffRef(i, j) = 0; + dst.coeffRef(i, j) = static_cast<typename Derived1::Scalar>(0); } } }; @@ -547,7 +547,7 @@ struct triangular_assignment_selector<Derived1, Derived2, StrictlyLower, Dynamic Index maxi = std::min(j, dst.rows()-1); if (ClearOpposite) for(Index i = 0; i <= maxi; ++i) - dst.coeffRef(i, j) = 0; + dst.coeffRef(i, j) = static_cast<typename Derived1::Scalar>(0); } } }; diff --git a/Eigen/src/Eigenvalues/EigenSolver.h b/Eigen/src/Eigenvalues/EigenSolver.h index 1ff24e5c0..af9cf357b 100644 --- a/Eigen/src/Eigenvalues/EigenSolver.h +++ b/Eigen/src/Eigenvalues/EigenSolver.h @@ -450,7 +450,7 @@ void EigenSolver<MatrixType>::doComputeEigenvectors() Scalar q = m_eivalues.coeff(n).imag(); // Scalar vector - if (q == 0) + if (q == static_cast<Scalar>(0)) { Scalar lastr=0, lastw=0; Index l = n; @@ -491,12 +491,12 @@ void EigenSolver<MatrixType>::doComputeEigenvectors() // Overflow control Scalar t = internal::abs(m_matT.coeff(i,n)); - if ((eps * t) * t > 1) + if ((eps * t) * t > Scalar(1)) m_matT.col(n).tail(size-i) /= t; } } } - else if (q < 0 && n > 0) // Complex vector + else if (q < Scalar(0) && n > 0) // Complex vector { Scalar lastra=0, lastsa=0, lastw=0; Index l = n-1; @@ -530,7 +530,7 @@ void EigenSolver<MatrixType>::doComputeEigenvectors() else { l = i; - if (m_eivalues.coeff(i).imag() == 0) + if (m_eivalues.coeff(i).imag() == static_cast<Scalar>(0)) { std::complex<Scalar> cc = cdiv(-ra,-sa,w,q); m_matT.coeffRef(i,n-1) = internal::real(cc); @@ -564,7 +564,7 @@ void EigenSolver<MatrixType>::doComputeEigenvectors() // Overflow control Scalar t = std::max(internal::abs(m_matT.coeff(i,n-1)),internal::abs(m_matT.coeff(i,n))); - if ((eps * t) * t > 1) + if ((eps * t) * t > static_cast<Scalar>(1)) m_matT.block(i, n-1, size-i, 2) /= t; } diff --git a/Eigen/src/Eigenvalues/RealSchur.h b/Eigen/src/Eigenvalues/RealSchur.h index e8b2f1a99..11ee5f5e8 100644 --- a/Eigen/src/Eigenvalues/RealSchur.h +++ b/Eigen/src/Eigenvalues/RealSchur.h @@ -324,11 +324,11 @@ inline void RealSchur<MatrixType>::splitOffTwoRows(Index iu, bool computeU, Scal m_matT.coeffRef(iu,iu) += exshift; m_matT.coeffRef(iu-1,iu-1) += exshift; - if (q >= 0) // Two real eigenvalues + if (q >= static_cast<Scalar>(0)) // Two real eigenvalues { Scalar z = internal::sqrt(internal::abs(q)); JacobiRotation<Scalar> rot; - if (p >= 0) + if (p >= static_cast<Scalar>(0)) rot.makeGivens(p + z, m_matT.coeff(iu, iu-1)); else rot.makeGivens(p - z, m_matT.coeff(iu, iu-1)); @@ -369,7 +369,7 @@ inline void RealSchur<MatrixType>::computeShift(Index iu, Index iter, Scalar& ex { Scalar s = (shiftInfo.coeff(1) - shiftInfo.coeff(0)) / Scalar(2.0); s = s * s + shiftInfo.coeff(2); - if (s > 0) + if (s > static_cast<Scalar>(0)) { s = internal::sqrt(s); if (shiftInfo.coeff(1) < shiftInfo.coeff(0)) diff --git a/Eigen/src/Householder/Householder.h b/Eigen/src/Householder/Householder.h index a38d3cfca..74139c0dc 100644 --- a/Eigen/src/Householder/Householder.h +++ b/Eigen/src/Householder/Householder.h @@ -72,7 +72,7 @@ void MatrixBase<Derived>::makeHouseholder( if(tailSqNorm == RealScalar(0) && internal::imag(c0)==RealScalar(0)) { - tau = 0; + tau = RealScalar(0); beta = internal::real(c0); essential.setZero(); } diff --git a/Eigen/src/Jacobi/Jacobi.h b/Eigen/src/Jacobi/Jacobi.h index fb5a2c717..27058a97e 100644 --- a/Eigen/src/Jacobi/Jacobi.h +++ b/Eigen/src/Jacobi/Jacobi.h @@ -104,9 +104,9 @@ bool JacobiRotation<Scalar>::makeJacobi(RealScalar x, Scalar y, RealScalar z) else { RealScalar tau = (x-z)/(RealScalar(2)*internal::abs(y)); - RealScalar w = internal::sqrt(internal::abs2(tau) + 1); + RealScalar w = internal::sqrt(internal::abs2(tau) + static_cast<RealScalar>(1)); RealScalar t; - if(tau>0) + if(tau>static_cast<RealScalar>(0)) { t = RealScalar(1) / (tau + w); } @@ -114,8 +114,8 @@ bool JacobiRotation<Scalar>::makeJacobi(RealScalar x, Scalar y, RealScalar z) { t = RealScalar(1) / (tau - w); } - RealScalar sign_t = t > 0 ? 1 : -1; - RealScalar n = RealScalar(1) / internal::sqrt(internal::abs2(t)+1); + RealScalar sign_t = t > static_cast<RealScalar>(0) ? static_cast<RealScalar>(1) : static_cast<RealScalar>(-1); + RealScalar n = RealScalar(1) / internal::sqrt(internal::abs2(t)+static_cast<RealScalar>(1)); m_s = - sign_t * (internal::conj(y) / internal::abs(y)) * internal::abs(t) * n; m_c = n; return true; @@ -221,15 +221,15 @@ template<typename Scalar> void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::false_type) { - if(q==0) + if(q==static_cast<Scalar>(0)) { m_c = p<Scalar(0) ? Scalar(-1) : Scalar(1); - m_s = 0; + m_s = Scalar(0); if(r) *r = internal::abs(p); } - else if(p==0) + else if(p==static_cast<Scalar>(0)) { - m_c = 0; + m_c = Scalar(0); m_s = q<Scalar(0) ? Scalar(1) : Scalar(-1); if(r) *r = internal::abs(q); } diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h index 2533a3874..a6d6e99a8 100644 --- a/Eigen/src/LU/PartialPivLU.h +++ b/Eigen/src/LU/PartialPivLU.h @@ -268,7 +268,7 @@ struct partial_lu_impl row_transpositions[k] = row_of_biggest_in_col; - if(biggest_in_corner != 0) + if(biggest_in_corner != static_cast<RealScalar>(0)) { if(k != row_of_biggest_in_col) { diff --git a/Eigen/src/QR/ColPivHouseholderQR.h b/Eigen/src/QR/ColPivHouseholderQR.h index 6c7d1d486..8a81fa8ed 100644 --- a/Eigen/src/QR/ColPivHouseholderQR.h +++ b/Eigen/src/QR/ColPivHouseholderQR.h @@ -387,7 +387,7 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const for(Index k = 0; k < cols; ++k) m_colSqNorms.coeffRef(k) = m_qr.col(k).squaredNorm(); - RealScalar threshold_helper = m_colSqNorms.maxCoeff() * internal::abs2(NumTraits<Scalar>::epsilon()) / rows; + RealScalar threshold_helper = m_colSqNorms.maxCoeff() * internal::abs2(NumTraits<Scalar>::epsilon()) / static_cast<double>(rows); m_nonzero_pivots = size; // the generic case is that in which all pivots are nonzero (invertible case) m_maxpivot = RealScalar(0); @@ -413,7 +413,7 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const // Note that here, if we test instead for "biggest == 0", we get a failure every 1000 (or so) // repetitions of the unit test, with the result of solve() filled with large values of the order // of 1/(size*epsilon). - if(biggest_col_sq_norm < threshold_helper * (rows-k)) + if(biggest_col_sq_norm < threshold_helper * static_cast<double>(rows-k)) { m_nonzero_pivots = k; m_hCoeffs.tail(size-k).setZero(); diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index 6c13255f5..93e176c68 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h @@ -271,13 +271,13 @@ void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, RealScalar d = m.coeff(1,0) - m.coeff(0,1); if(t == RealScalar(0)) { - rot1.c() = 0; - rot1.s() = d > 0 ? 1 : -1; + rot1.c() = static_cast<RealScalar>(0); + rot1.s() = d > static_cast<RealScalar>(0) ? static_cast<RealScalar>(1) : static_cast<RealScalar>(-1); } else { RealScalar u = d / t; - rot1.c() = RealScalar(1) / sqrt(1 + abs2(u)); + rot1.c() = RealScalar(1) / sqrt(static_cast<RealScalar>(1) + abs2(u)); rot1.s() = rot1.c() * u; } m.applyOnTheLeft(0,1,rot1); |