mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Complete rework of global math functions and NumTraits.
* Now completely generic so all standard integer types (like char...) are supported. ** add unit test for that (integer_types). * NumTraits does no longer inherit numeric_limits * All math functions are now templated * Better guard (static asserts) against using certain math functions on integer types.
This commit is contained in:
@@ -103,10 +103,12 @@ namespace Eigen {
|
||||
template<> struct NumTraits<adtl::adouble>
|
||||
{
|
||||
typedef adtl::adouble Real;
|
||||
typedef adtl::adouble FloatingPoint;
|
||||
typedef adtl::adouble NonInteger;
|
||||
typedef adtl::adouble Nested;
|
||||
enum {
|
||||
IsComplex = 0,
|
||||
HasFloatingPoint = 1,
|
||||
IsInteger = 0,
|
||||
IsSigned = 1,
|
||||
ReadCost = 1,
|
||||
AddCost = 1,
|
||||
MulCost = 1
|
||||
|
||||
@@ -552,19 +552,10 @@ ei_pow(const AutoDiffScalar<DerType>& x, typename ei_traits<DerType>::Scalar y)
|
||||
#undef EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY
|
||||
|
||||
template<typename DerType> struct NumTraits<AutoDiffScalar<DerType> >
|
||||
: NumTraits< typename NumTraits<typename DerType::Scalar>::Real >
|
||||
{
|
||||
typedef typename NumTraits<typename DerType::Scalar>::Real Real;
|
||||
typedef AutoDiffScalar<DerType> FloatingPoint;
|
||||
typedef AutoDiffScalar<DerType> NonInteger;
|
||||
typedef AutoDiffScalar<DerType>& Nested;
|
||||
enum {
|
||||
IsComplex = 0,
|
||||
HasFloatingPoint = 1,
|
||||
ReadCost = 1,
|
||||
AddCost = 1,
|
||||
MulCost = 1
|
||||
};
|
||||
inline static Real epsilon() { return std::numeric_limits<Real>::epsilon(); }
|
||||
inline static Real dummy_precision() { return NumTraits<Real>::dummy_precision(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class PolynomialSolverBase
|
||||
{
|
||||
hasArealRoot = false;
|
||||
int res=0;
|
||||
RealScalar abs2;
|
||||
RealScalar abs2(0);
|
||||
|
||||
for( int i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
@@ -159,7 +159,7 @@ class PolynomialSolverBase
|
||||
res = i; }
|
||||
}
|
||||
}
|
||||
return m_roots[res].real();
|
||||
return ei_real_ref(m_roots[res]);
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ class PolynomialSolverBase
|
||||
{
|
||||
hasArealRoot = false;
|
||||
int res=0;
|
||||
RealScalar val;
|
||||
RealScalar val(0);
|
||||
|
||||
for( int i=0; i<m_roots.size(); ++i )
|
||||
{
|
||||
@@ -199,7 +199,7 @@ class PolynomialSolverBase
|
||||
res = i; }
|
||||
}
|
||||
}
|
||||
return m_roots[res].real();
|
||||
return ei_real_ref(m_roots[res]);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user