diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-04-28 18:51:38 -0400 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-04-28 18:51:38 -0400 |
commit | e2775869588e1df2d19265eac5c167651168a414 (patch) | |
tree | 8ca0d2fdbc1f8945405fb3fd99c5634b60f3189f /Eigen/src/Geometry | |
parent | 4f83d6ad1959f3c76cd5eb328ec65ced4ca4f339 (diff) |
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.
Diffstat (limited to 'Eigen/src/Geometry')
-rw-r--r-- | Eigen/src/Geometry/AlignedBox.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Eigen/src/Geometry/AlignedBox.h b/Eigen/src/Geometry/AlignedBox.h index b5b40a82d..f3bee6f7d 100644 --- a/Eigen/src/Geometry/AlignedBox.h +++ b/Eigen/src/Geometry/AlignedBox.h @@ -46,7 +46,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim) typedef _Scalar Scalar; typedef NumTraits<Scalar> ScalarTraits; typedef typename ScalarTraits::Real RealScalar; - typedef typename ScalarTraits::FloatingPoint FloatingPoint; + typedef typename ScalarTraits::NonInteger NonInteger; typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType; /** Define constants to name the corners of a 1D, 2D or 3D axis aligned bounding box */ @@ -174,11 +174,10 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim) VectorType r; for(int d=0; d<dim(); ++d) { - if(ScalarTraits::HasFloatingPoint) + if(!ScalarTraits::IsInteger) { r[d] = m_min[d] + (m_max[d]-m_min[d]) - * (ei_random<Scalar>() + ei_random_amplitude<Scalar>()) - / (Scalar(2)*ei_random_amplitude<Scalar>() ); + * ei_random<Scalar>(Scalar(0), Scalar(1)); } else r[d] = ei_random(m_min[d], m_max[d]); @@ -260,15 +259,15 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim) * \sa squaredExteriorDistance() */ template<typename Derived> - inline FloatingPoint exteriorDistance(const MatrixBase<Derived>& p) const - { return ei_sqrt(FloatingPoint(squaredExteriorDistance(p))); } + inline NonInteger exteriorDistance(const MatrixBase<Derived>& p) const + { return ei_sqrt(NonInteger(squaredExteriorDistance(p))); } /** \returns the distance between the boxes \a b and \c *this, * and zero if the boxes intersect. * \sa squaredExteriorDistance() */ - inline FloatingPoint exteriorDistance(const AlignedBox& b) const - { return ei_sqrt(FloatingPoint(squaredExteriorDistance(b))); } + inline NonInteger exteriorDistance(const AlignedBox& b) const + { return ei_sqrt(NonInteger(squaredExteriorDistance(b))); } /** \returns \c *this with scalar type casted to \a NewScalarType * |