mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
Silenced several double-promotion warnings
This commit is contained in:
parent
b5a7603822
commit
718521d5cf
@ -11,7 +11,9 @@
|
||||
#define EIGEN_MATHFUNCTIONS_H
|
||||
|
||||
// source: http://www.geom.uiuc.edu/~huberty/math5337/groupe/digits.html
|
||||
#define EIGEN_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406
|
||||
// TODO this should better be moved to NumTraits
|
||||
#define EIGEN_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406L
|
||||
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
|
@ -713,11 +713,11 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
|
||||
|
||||
template<typename T0, typename T1>
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_STRONG_INLINE void _init2(const Scalar& val0, const Scalar& val1, typename internal::enable_if<Base::SizeAtCompileTime==2,T0>::type* = 0)
|
||||
EIGEN_STRONG_INLINE void _init2(const T0& val0, const T1& val1, typename internal::enable_if<Base::SizeAtCompileTime==2,T0>::type* = 0)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
|
||||
m_storage.data()[0] = val0;
|
||||
m_storage.data()[1] = val1;
|
||||
m_storage.data()[0] = Scalar(val0);
|
||||
m_storage.data()[1] = Scalar(val1);
|
||||
}
|
||||
|
||||
template<typename T0, typename T1>
|
||||
|
@ -503,7 +503,7 @@ void EigenSolver<MatrixType>::doComputeEigenvectors()
|
||||
Scalar lastr(0), lastw(0);
|
||||
Index l = n;
|
||||
|
||||
m_matT.coeffRef(n,n) = 1.0;
|
||||
m_matT.coeffRef(n,n) = Scalar(1);
|
||||
for (Index i = n-1; i >= 0; i--)
|
||||
{
|
||||
Scalar w = m_matT.coeff(i,i) - p;
|
||||
|
@ -55,7 +55,7 @@ template<typename Scalar, int Options> void quaternion(void)
|
||||
|
||||
Scalar largeEps = test_precision<Scalar>();
|
||||
if (internal::is_same<Scalar,float>::value)
|
||||
largeEps = 1e-3f;
|
||||
largeEps = Scalar(1e-3);
|
||||
|
||||
Scalar eps = internal::random<Scalar>() * Scalar(1e-2);
|
||||
|
||||
|
@ -431,7 +431,7 @@ template<typename Scalar> void packetmath_real()
|
||||
// VERIFY_IS_EQUAL(std::log(std::numeric_limits<Scalar>::denorm_min()), data2[0]);
|
||||
VERIFY((numext::isnan)(data2[1]));
|
||||
|
||||
data1[0] = -1.0f;
|
||||
data1[0] = Scalar(-1.0f);
|
||||
h.store(data2, internal::plog(h.load(data1)));
|
||||
VERIFY((numext::isnan)(data2[0]));
|
||||
#if !EIGEN_FAST_MATH
|
||||
|
@ -204,9 +204,11 @@ template<typename MatrixType> void qr_kahan_matrix()
|
||||
m1.setZero(rows,cols);
|
||||
RealScalar s = std::pow(NumTraits<RealScalar>::epsilon(), 1.0 / rows);
|
||||
RealScalar c = std::sqrt(1 - s*s);
|
||||
RealScalar pow_s_i(1.0); // pow(s,i)
|
||||
for (Index i = 0; i < rows; ++i) {
|
||||
m1(i, i) = pow(s, i);
|
||||
m1.row(i).tail(rows - i - 1) = -RealScalar(pow(s, i)) * c * MatrixType::Ones(1, rows - i - 1);
|
||||
m1(i, i) = pow_s_i;
|
||||
m1.row(i).tail(rows - i - 1) = -pow_s_i * c * MatrixType::Ones(1, rows - i - 1);
|
||||
pow_s_i *= s;
|
||||
}
|
||||
m1 = (m1 + m1.transpose()).eval();
|
||||
ColPivHouseholderQR<MatrixType> qr(m1);
|
||||
|
@ -65,7 +65,7 @@ template <typename MatrixType>
|
||||
void matrix_exp_pade3(const MatrixType &A, MatrixType &U, MatrixType &V)
|
||||
{
|
||||
typedef typename NumTraits<typename traits<MatrixType>::Scalar>::Real RealScalar;
|
||||
const RealScalar b[] = {120., 60., 12., 1.};
|
||||
const RealScalar b[] = {120.L, 60.L, 12.L, 1.L};
|
||||
const MatrixType A2 = A * A;
|
||||
const MatrixType tmp = b[3] * A2 + b[1] * MatrixType::Identity(A.rows(), A.cols());
|
||||
U.noalias() = A * tmp;
|
||||
@ -81,7 +81,7 @@ template <typename MatrixType>
|
||||
void matrix_exp_pade5(const MatrixType &A, MatrixType &U, MatrixType &V)
|
||||
{
|
||||
typedef typename NumTraits<typename traits<MatrixType>::Scalar>::Real RealScalar;
|
||||
const RealScalar b[] = {30240., 15120., 3360., 420., 30., 1.};
|
||||
const RealScalar b[] = {30240.L, 15120.L, 3360.L, 420.L, 30.L, 1.L};
|
||||
const MatrixType A2 = A * A;
|
||||
const MatrixType A4 = A2 * A2;
|
||||
const MatrixType tmp = b[5] * A4 + b[3] * A2 + b[1] * MatrixType::Identity(A.rows(), A.cols());
|
||||
@ -98,7 +98,7 @@ template <typename MatrixType>
|
||||
void matrix_exp_pade7(const MatrixType &A, MatrixType &U, MatrixType &V)
|
||||
{
|
||||
typedef typename NumTraits<typename traits<MatrixType>::Scalar>::Real RealScalar;
|
||||
const RealScalar b[] = {17297280., 8648640., 1995840., 277200., 25200., 1512., 56., 1.};
|
||||
const RealScalar b[] = {17297280.L, 8648640.L, 1995840.L, 277200.L, 25200.L, 1512.L, 56.L, 1.L};
|
||||
const MatrixType A2 = A * A;
|
||||
const MatrixType A4 = A2 * A2;
|
||||
const MatrixType A6 = A4 * A2;
|
||||
@ -118,8 +118,8 @@ template <typename MatrixType>
|
||||
void matrix_exp_pade9(const MatrixType &A, MatrixType &U, MatrixType &V)
|
||||
{
|
||||
typedef typename NumTraits<typename traits<MatrixType>::Scalar>::Real RealScalar;
|
||||
const RealScalar b[] = {17643225600., 8821612800., 2075673600., 302702400., 30270240.,
|
||||
2162160., 110880., 3960., 90., 1.};
|
||||
const RealScalar b[] = {17643225600.L, 8821612800.L, 2075673600.L, 302702400.L, 30270240.L,
|
||||
2162160.L, 110880.L, 3960.L, 90.L, 1.L};
|
||||
const MatrixType A2 = A * A;
|
||||
const MatrixType A4 = A2 * A2;
|
||||
const MatrixType A6 = A4 * A2;
|
||||
@ -139,9 +139,9 @@ template <typename MatrixType>
|
||||
void matrix_exp_pade13(const MatrixType &A, MatrixType &U, MatrixType &V)
|
||||
{
|
||||
typedef typename NumTraits<typename traits<MatrixType>::Scalar>::Real RealScalar;
|
||||
const RealScalar b[] = {64764752532480000., 32382376266240000., 7771770303897600.,
|
||||
1187353796428800., 129060195264000., 10559470521600., 670442572800.,
|
||||
33522128640., 1323241920., 40840800., 960960., 16380., 182., 1.};
|
||||
const RealScalar b[] = {64764752532480000.L, 32382376266240000.L, 7771770303897600.L,
|
||||
1187353796428800.L, 129060195264000.L, 10559470521600.L, 670442572800.L,
|
||||
33522128640.L, 1323241920.L, 40840800.L, 960960.L, 16380.L, 182.L, 1.L};
|
||||
const MatrixType A2 = A * A;
|
||||
const MatrixType A4 = A2 * A2;
|
||||
const MatrixType A6 = A4 * A2;
|
||||
|
@ -233,8 +233,8 @@ void matrix_log_compute_big(const MatrixType& A, MatrixType& result)
|
||||
MatrixType T = A, sqrtT;
|
||||
|
||||
int maxPadeDegree = matrix_log_max_pade_degree<Scalar>::value;
|
||||
const RealScalar maxNormForPade = maxPadeDegree<= 5? 5.3149729967117310e-1: // single precision
|
||||
maxPadeDegree<= 7? 2.6429608311114350e-1: // double precision
|
||||
const RealScalar maxNormForPade = maxPadeDegree<= 5? 5.3149729967117310e-1L: // single precision
|
||||
maxPadeDegree<= 7? 2.6429608311114350e-1L: // double precision
|
||||
maxPadeDegree<= 8? 2.32777776523703892094e-1L: // extended precision
|
||||
maxPadeDegree<=10? 1.05026503471351080481093652651105e-1L: // double-double
|
||||
1.1880960220216759245467951592883642e-1L; // quadruple precision
|
||||
|
@ -196,11 +196,11 @@ void MatrixPowerAtomic<MatrixType>::computeBig(ResultType& res) const
|
||||
{
|
||||
using std::ldexp;
|
||||
const int digits = std::numeric_limits<RealScalar>::digits;
|
||||
const RealScalar maxNormForPade = digits <= 24? 4.3386528e-1f: // sigle precision
|
||||
digits <= 53? 2.789358995219730e-1: // double precision
|
||||
digits <= 64? 2.4471944416607995472e-1L: // extended precision
|
||||
digits <= 106? 1.1016843812851143391275867258512e-1L: // double-double
|
||||
9.134603732914548552537150753385375e-2L; // quadruple precision
|
||||
const RealScalar maxNormForPade = digits <= 24? 4.3386528e-1L // single precision
|
||||
: digits <= 53? 2.789358995219730e-1L // double precision
|
||||
: digits <= 64? 2.4471944416607995472e-1L // extended precision
|
||||
: digits <= 106? 1.1016843812851143391275867258512e-1L // double-double
|
||||
: 9.134603732914548552537150753385375e-2L; // quadruple precision
|
||||
MatrixType IminusT, sqrtT, T = m_A.template triangularView<Upper>();
|
||||
RealScalar normIminusT;
|
||||
int degree, degree2, numberOfSquareRoots = 0;
|
||||
@ -264,7 +264,7 @@ inline int MatrixPowerAtomic<MatrixType>::getPadeDegree(long double normIminusT)
|
||||
1.999045567181744e-1L, 2.789358995219730e-1L };
|
||||
#elif LDBL_MANT_DIG <= 64
|
||||
const int maxPadeDegree = 8;
|
||||
const double maxNormForPade[] = { 6.3854693117491799460e-3L /* degree = 3 */ , 2.6394893435456973676e-2L,
|
||||
const long double maxNormForPade[] = { 6.3854693117491799460e-3L /* degree = 3 */ , 2.6394893435456973676e-2L,
|
||||
6.4216043030404063729e-2L, 1.1701165502926694307e-1L, 1.7904284231268670284e-1L, 2.4471944416607995472e-1L };
|
||||
#elif LDBL_MANT_DIG <= 106
|
||||
const int maxPadeDegree = 10;
|
||||
|
@ -113,8 +113,8 @@ void testMatrixLogarithm(const MatrixType& A)
|
||||
|
||||
MatrixType scaledA;
|
||||
RealScalar maxImagPartOfSpectrum = A.eigenvalues().imag().cwiseAbs().maxCoeff();
|
||||
if (maxImagPartOfSpectrum >= RealScalar(0.9 * EIGEN_PI))
|
||||
scaledA = A * RealScalar(0.9 * EIGEN_PI) / maxImagPartOfSpectrum;
|
||||
if (maxImagPartOfSpectrum >= RealScalar(0.9L * EIGEN_PI))
|
||||
scaledA = A * RealScalar(0.9L * EIGEN_PI) / maxImagPartOfSpectrum;
|
||||
else
|
||||
scaledA = A;
|
||||
|
||||
|
@ -61,7 +61,7 @@ struct generateTestMatrix<MatrixType,1>
|
||||
};
|
||||
|
||||
template <typename Derived, typename OtherDerived>
|
||||
double relerr(const MatrixBase<Derived>& A, const MatrixBase<OtherDerived>& B)
|
||||
typename Derived::RealScalar relerr(const MatrixBase<Derived>& A, const MatrixBase<OtherDerived>& B)
|
||||
{
|
||||
return std::sqrt((A - B).cwiseAbs2().sum() / (std::min)(A.cwiseAbs2().sum(), B.cwiseAbs2().sum()));
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "matrix_functions.h"
|
||||
|
||||
template<typename T>
|
||||
void test2dRotation(double tol)
|
||||
void test2dRotation(const T& tol)
|
||||
{
|
||||
Matrix<T,2,2> A, B, C;
|
||||
T angle, c, s;
|
||||
@ -19,7 +19,7 @@ void test2dRotation(double tol)
|
||||
MatrixPower<Matrix<T,2,2> > Apow(A);
|
||||
|
||||
for (int i=0; i<=20; ++i) {
|
||||
angle = pow(10, (i-10) / 5.);
|
||||
angle = std::pow(T(10), (i-10) / T(5.));
|
||||
c = std::cos(angle);
|
||||
s = std::sin(angle);
|
||||
B << c, s, -s, c;
|
||||
@ -31,7 +31,7 @@ void test2dRotation(double tol)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void test2dHyperbolicRotation(double tol)
|
||||
void test2dHyperbolicRotation(const T& tol)
|
||||
{
|
||||
Matrix<std::complex<T>,2,2> A, B, C;
|
||||
T angle, ch = std::cosh((T)1);
|
||||
@ -53,7 +53,7 @@ void test2dHyperbolicRotation(double tol)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void test3dRotation(double tol)
|
||||
void test3dRotation(const T& tol)
|
||||
{
|
||||
Matrix<T,3,1> v;
|
||||
T angle;
|
||||
@ -61,13 +61,13 @@ void test3dRotation(double tol)
|
||||
for (int i=0; i<=20; ++i) {
|
||||
v = Matrix<T,3,1>::Random();
|
||||
v.normalize();
|
||||
angle = pow(10, (i-10) / 5.);
|
||||
angle = std::pow(T(10), (i-10) / T(5.));
|
||||
VERIFY(AngleAxis<T>(angle, v).matrix().isApprox(AngleAxis<T>(1,v).matrix().pow(angle), tol));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
void testGeneral(const MatrixType& m, double tol)
|
||||
void testGeneral(const MatrixType& m, const typename MatrixType::RealScalar& tol)
|
||||
{
|
||||
typedef typename MatrixType::RealScalar RealScalar;
|
||||
MatrixType m1, m2, m3, m4, m5;
|
||||
@ -97,7 +97,7 @@ void testGeneral(const MatrixType& m, double tol)
|
||||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
void testSingular(const MatrixType& m_const, double tol)
|
||||
void testSingular(const MatrixType& m_const, const typename MatrixType::RealScalar& tol)
|
||||
{
|
||||
// we need to pass by reference in order to prevent errors with
|
||||
// MSVC for aligned data types ...
|
||||
@ -119,18 +119,18 @@ void testSingular(const MatrixType& m_const, double tol)
|
||||
MatrixPower<MatrixType> mpow(m);
|
||||
|
||||
T = T.sqrt();
|
||||
VERIFY(mpow(0.5).isApprox(U * (TriangularType(T) * U.adjoint()), tol));
|
||||
VERIFY(mpow(0.5L).isApprox(U * (TriangularType(T) * U.adjoint()), tol));
|
||||
|
||||
T = T.sqrt();
|
||||
VERIFY(mpow(0.25).isApprox(U * (TriangularType(T) * U.adjoint()), tol));
|
||||
VERIFY(mpow(0.25L).isApprox(U * (TriangularType(T) * U.adjoint()), tol));
|
||||
|
||||
T = T.sqrt();
|
||||
VERIFY(mpow(0.125).isApprox(U * (TriangularType(T) * U.adjoint()), tol));
|
||||
VERIFY(mpow(0.125L).isApprox(U * (TriangularType(T) * U.adjoint()), tol));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
void testLogThenExp(const MatrixType& m_const, double tol)
|
||||
void testLogThenExp(const MatrixType& m_const, const typename MatrixType::RealScalar& tol)
|
||||
{
|
||||
// we need to pass by reference in order to prevent errors with
|
||||
// MSVC for aligned data types ...
|
||||
@ -154,14 +154,14 @@ void test_matrix_power()
|
||||
{
|
||||
CALL_SUBTEST_2(test2dRotation<double>(1e-13));
|
||||
CALL_SUBTEST_1(test2dRotation<float>(2e-5)); // was 1e-5, relaxed for clang 2.8 / linux / x86-64
|
||||
CALL_SUBTEST_9(test2dRotation<long double>(1e-13));
|
||||
CALL_SUBTEST_9(test2dRotation<long double>(1e-13L));
|
||||
CALL_SUBTEST_2(test2dHyperbolicRotation<double>(1e-14));
|
||||
CALL_SUBTEST_1(test2dHyperbolicRotation<float>(1e-5));
|
||||
CALL_SUBTEST_9(test2dHyperbolicRotation<long double>(1e-14));
|
||||
CALL_SUBTEST_9(test2dHyperbolicRotation<long double>(1e-14L));
|
||||
|
||||
CALL_SUBTEST_10(test3dRotation<double>(1e-13));
|
||||
CALL_SUBTEST_11(test3dRotation<float>(1e-5));
|
||||
CALL_SUBTEST_12(test3dRotation<long double>(1e-13));
|
||||
CALL_SUBTEST_12(test3dRotation<long double>(1e-13L));
|
||||
|
||||
CALL_SUBTEST_2(testGeneral(Matrix2d(), 1e-13));
|
||||
CALL_SUBTEST_7(testGeneral(Matrix3dRowMajor(), 1e-13));
|
||||
@ -171,10 +171,10 @@ void test_matrix_power()
|
||||
CALL_SUBTEST_5(testGeneral(Matrix3cf(), 1e-4));
|
||||
CALL_SUBTEST_8(testGeneral(Matrix4f(), 1e-4));
|
||||
CALL_SUBTEST_6(testGeneral(MatrixXf(2,2), 1e-3)); // see bug 614
|
||||
CALL_SUBTEST_9(testGeneral(MatrixXe(7,7), 1e-13));
|
||||
CALL_SUBTEST_9(testGeneral(MatrixXe(7,7), 1e-13L));
|
||||
CALL_SUBTEST_10(testGeneral(Matrix3d(), 1e-13));
|
||||
CALL_SUBTEST_11(testGeneral(Matrix3f(), 1e-4));
|
||||
CALL_SUBTEST_12(testGeneral(Matrix3e(), 1e-13));
|
||||
CALL_SUBTEST_12(testGeneral(Matrix3e(), 1e-13L));
|
||||
|
||||
CALL_SUBTEST_2(testSingular(Matrix2d(), 1e-13));
|
||||
CALL_SUBTEST_7(testSingular(Matrix3dRowMajor(), 1e-13));
|
||||
@ -184,10 +184,10 @@ void test_matrix_power()
|
||||
CALL_SUBTEST_5(testSingular(Matrix3cf(), 1e-4));
|
||||
CALL_SUBTEST_8(testSingular(Matrix4f(), 1e-4));
|
||||
CALL_SUBTEST_6(testSingular(MatrixXf(2,2), 1e-3));
|
||||
CALL_SUBTEST_9(testSingular(MatrixXe(7,7), 1e-13));
|
||||
CALL_SUBTEST_9(testSingular(MatrixXe(7,7), 1e-13L));
|
||||
CALL_SUBTEST_10(testSingular(Matrix3d(), 1e-13));
|
||||
CALL_SUBTEST_11(testSingular(Matrix3f(), 1e-4));
|
||||
CALL_SUBTEST_12(testSingular(Matrix3e(), 1e-13));
|
||||
CALL_SUBTEST_12(testSingular(Matrix3e(), 1e-13L));
|
||||
|
||||
CALL_SUBTEST_2(testLogThenExp(Matrix2d(), 1e-13));
|
||||
CALL_SUBTEST_7(testLogThenExp(Matrix3dRowMajor(), 1e-13));
|
||||
@ -197,8 +197,8 @@ void test_matrix_power()
|
||||
CALL_SUBTEST_5(testLogThenExp(Matrix3cf(), 1e-4));
|
||||
CALL_SUBTEST_8(testLogThenExp(Matrix4f(), 1e-4));
|
||||
CALL_SUBTEST_6(testLogThenExp(MatrixXf(2,2), 1e-3));
|
||||
CALL_SUBTEST_9(testLogThenExp(MatrixXe(7,7), 1e-13));
|
||||
CALL_SUBTEST_9(testLogThenExp(MatrixXe(7,7), 1e-13L));
|
||||
CALL_SUBTEST_10(testLogThenExp(Matrix3d(), 1e-13));
|
||||
CALL_SUBTEST_11(testLogThenExp(Matrix3f(), 1e-4));
|
||||
CALL_SUBTEST_12(testLogThenExp(Matrix3e(), 1e-13));
|
||||
CALL_SUBTEST_12(testLogThenExp(Matrix3e(), 1e-13L));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user