mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-14 20:56:00 +08:00
Avoid pow(Scalar, int) for C++11 conformance.
This commit is contained in:
parent
04a9ad6e10
commit
c273a6c37c
@ -157,6 +157,24 @@ class MatrixExponential {
|
|||||||
|
|
||||||
/** \brief L1 norm of m_M. */
|
/** \brief L1 norm of m_M. */
|
||||||
RealScalar m_l1norm;
|
RealScalar m_l1norm;
|
||||||
|
|
||||||
|
/** \brief Scaling operator. */
|
||||||
|
struct ScalingOp;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename MatrixType>
|
||||||
|
struct MatrixExponential<MatrixType>::ScalingOp
|
||||||
|
{
|
||||||
|
ScalingOp(int squarings) : m_squarings(squarings) { }
|
||||||
|
|
||||||
|
inline const RealScalar operator() (const RealScalar& x) const
|
||||||
|
{ return std::ldexp(x, -m_squarings); }
|
||||||
|
|
||||||
|
inline const ComplexScalar operator() (const ComplexScalar& x) const
|
||||||
|
{ return ComplexScalar(std::ldexp(x.real(), -m_squarings), std::ldexp(x.imag(), -m_squarings)); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_squarings;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename MatrixType>
|
template <typename MatrixType>
|
||||||
@ -283,17 +301,15 @@ EIGEN_STRONG_INLINE void MatrixExponential<MatrixType>::pade17(const MatrixType
|
|||||||
template <typename MatrixType>
|
template <typename MatrixType>
|
||||||
void MatrixExponential<MatrixType>::computeUV(float)
|
void MatrixExponential<MatrixType>::computeUV(float)
|
||||||
{
|
{
|
||||||
using std::frexp;
|
|
||||||
using std::pow;
|
|
||||||
if (m_l1norm < 4.258730016922831e-001) {
|
if (m_l1norm < 4.258730016922831e-001) {
|
||||||
pade3(m_M);
|
pade3(m_M);
|
||||||
} else if (m_l1norm < 1.880152677804762e+000) {
|
} else if (m_l1norm < 1.880152677804762e+000) {
|
||||||
pade5(m_M);
|
pade5(m_M);
|
||||||
} else {
|
} else {
|
||||||
const float maxnorm = 3.925724783138660f;
|
const float maxnorm = 3.925724783138660f;
|
||||||
frexp(m_l1norm / maxnorm, &m_squarings);
|
std::frexp(m_l1norm / maxnorm, &m_squarings);
|
||||||
if (m_squarings < 0) m_squarings = 0;
|
if (m_squarings < 0) m_squarings = 0;
|
||||||
MatrixType A = m_M / pow(Scalar(2), m_squarings);
|
MatrixType A = CwiseUnaryOp<ScalingOp, MatrixType>(m_M, m_squarings);
|
||||||
pade7(A);
|
pade7(A);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,8 +317,6 @@ void MatrixExponential<MatrixType>::computeUV(float)
|
|||||||
template <typename MatrixType>
|
template <typename MatrixType>
|
||||||
void MatrixExponential<MatrixType>::computeUV(double)
|
void MatrixExponential<MatrixType>::computeUV(double)
|
||||||
{
|
{
|
||||||
using std::frexp;
|
|
||||||
using std::pow;
|
|
||||||
if (m_l1norm < 1.495585217958292e-002) {
|
if (m_l1norm < 1.495585217958292e-002) {
|
||||||
pade3(m_M);
|
pade3(m_M);
|
||||||
} else if (m_l1norm < 2.539398330063230e-001) {
|
} else if (m_l1norm < 2.539398330063230e-001) {
|
||||||
@ -313,9 +327,9 @@ void MatrixExponential<MatrixType>::computeUV(double)
|
|||||||
pade9(m_M);
|
pade9(m_M);
|
||||||
} else {
|
} else {
|
||||||
const double maxnorm = 5.371920351148152;
|
const double maxnorm = 5.371920351148152;
|
||||||
frexp(m_l1norm / maxnorm, &m_squarings);
|
std::frexp(m_l1norm / maxnorm, &m_squarings);
|
||||||
if (m_squarings < 0) m_squarings = 0;
|
if (m_squarings < 0) m_squarings = 0;
|
||||||
MatrixType A = m_M / pow(Scalar(2), m_squarings);
|
MatrixType A = CwiseUnaryOp<ScalingOp, MatrixType>(m_M, m_squarings);
|
||||||
pade13(A);
|
pade13(A);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,8 +337,6 @@ void MatrixExponential<MatrixType>::computeUV(double)
|
|||||||
template <typename MatrixType>
|
template <typename MatrixType>
|
||||||
void MatrixExponential<MatrixType>::computeUV(long double)
|
void MatrixExponential<MatrixType>::computeUV(long double)
|
||||||
{
|
{
|
||||||
using std::frexp;
|
|
||||||
using std::pow;
|
|
||||||
#if LDBL_MANT_DIG == 53 // double precision
|
#if LDBL_MANT_DIG == 53 // double precision
|
||||||
computeUV(double());
|
computeUV(double());
|
||||||
#elif LDBL_MANT_DIG <= 64 // extended precision
|
#elif LDBL_MANT_DIG <= 64 // extended precision
|
||||||
@ -338,9 +350,9 @@ void MatrixExponential<MatrixType>::computeUV(long double)
|
|||||||
pade9(m_M);
|
pade9(m_M);
|
||||||
} else {
|
} else {
|
||||||
const long double maxnorm = 4.0246098906697353063L;
|
const long double maxnorm = 4.0246098906697353063L;
|
||||||
frexp(m_l1norm / maxnorm, &m_squarings);
|
std::frexp(m_l1norm / maxnorm, &m_squarings);
|
||||||
if (m_squarings < 0) m_squarings = 0;
|
if (m_squarings < 0) m_squarings = 0;
|
||||||
MatrixType A = m_M / pow(Scalar(2), m_squarings);
|
MatrixType A = CwiseUnaryOp<ScalingOp, MatrixType>(m_M, m_squarings);
|
||||||
pade13(A);
|
pade13(A);
|
||||||
}
|
}
|
||||||
#elif LDBL_MANT_DIG <= 106 // double-double
|
#elif LDBL_MANT_DIG <= 106 // double-double
|
||||||
@ -356,9 +368,9 @@ void MatrixExponential<MatrixType>::computeUV(long double)
|
|||||||
pade13(m_M);
|
pade13(m_M);
|
||||||
} else {
|
} else {
|
||||||
const long double maxnorm = 3.2579440895405400856599663723517L;
|
const long double maxnorm = 3.2579440895405400856599663723517L;
|
||||||
frexp(m_l1norm / maxnorm, &m_squarings);
|
std::frexp(m_l1norm / maxnorm, &m_squarings);
|
||||||
if (m_squarings < 0) m_squarings = 0;
|
if (m_squarings < 0) m_squarings = 0;
|
||||||
MatrixType A = m_M / pow(Scalar(2), m_squarings);
|
MatrixType A = CwiseUnaryOp<ScalingOp, MatrixType>(m_M, m_squarings);
|
||||||
pade17(A);
|
pade17(A);
|
||||||
}
|
}
|
||||||
#elif LDBL_MANT_DIG <= 112 // quadruple precison
|
#elif LDBL_MANT_DIG <= 112 // quadruple precison
|
||||||
@ -374,9 +386,9 @@ void MatrixExponential<MatrixType>::computeUV(long double)
|
|||||||
pade13(m_M);
|
pade13(m_M);
|
||||||
} else {
|
} else {
|
||||||
const long double maxnorm = 2.884233277829519311757165057717815L;
|
const long double maxnorm = 2.884233277829519311757165057717815L;
|
||||||
frexp(m_l1norm / maxnorm, &m_squarings);
|
std::frexp(m_l1norm / maxnorm, &m_squarings);
|
||||||
if (m_squarings < 0) m_squarings = 0;
|
if (m_squarings < 0) m_squarings = 0;
|
||||||
MatrixType A = m_M / pow(Scalar(2), m_squarings);
|
MatrixType A = CwiseUnaryOp<ScalingOp, MatrixType>(m_M, m_squarings);
|
||||||
pade17(A);
|
pade17(A);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user