aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Lukierski <robert@lukierski.eu>2016-10-13 15:00:22 +0100
committerGravatar Robert Lukierski <robert@lukierski.eu>2016-10-13 15:00:22 +0100
commita94791b69a53504aba88f06caad596afa1ac6a34 (patch)
treeaad3c9de62cdc9f4bdad4ca1d006c2be3bf8fd61
parent471075f7ad8e78d4d3e400bc1124e39102515aec (diff)
Fixes for min and abs after Benoit's comments, switched to numext.
-rw-r--r--Eigen/src/Core/AssignEvaluator.h3
-rw-r--r--Eigen/src/Core/CwiseNullaryOp.h3
-rw-r--r--Eigen/src/Core/DiagonalMatrix.h3
-rw-r--r--Eigen/src/Core/PlainObjectBase.h10
-rw-r--r--Eigen/src/Core/TriangularMatrix.h19
-rw-r--r--Eigen/src/Geometry/Hyperplane.h5
-rw-r--r--Eigen/src/Geometry/Quaternion.h6
7 files changed, 18 insertions, 31 deletions
diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h
index 844b85ab3..abad8c790 100644
--- a/Eigen/src/Core/AssignEvaluator.h
+++ b/Eigen/src/Core/AssignEvaluator.h
@@ -517,7 +517,6 @@ struct dense_assignment_loop<Kernel, SliceVectorizedTraversal, NoUnrolling>
{
EIGEN_DEVICE_FUNC static inline void run(Kernel &kernel)
{
- EIGEN_USING_STD_MATH(min)
typedef typename Kernel::Scalar Scalar;
typedef typename Kernel::PacketType PacketType;
enum {
@@ -555,7 +554,7 @@ struct dense_assignment_loop<Kernel, SliceVectorizedTraversal, NoUnrolling>
for(Index inner = alignedEnd; inner<innerSize ; ++inner)
kernel.assignCoeffByOuterInner(outer, inner);
- alignedStart = (min)((Index)(alignedStart+alignedStep)%packetSize, (Index)innerSize);
+ alignedStart = numext::mini((alignedStart+alignedStep)%packetSize, innerSize);
}
}
};
diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h
index c47993e88..1caf37bb7 100644
--- a/Eigen/src/Core/CwiseNullaryOp.h
+++ b/Eigen/src/Core/CwiseNullaryOp.h
@@ -752,8 +752,7 @@ struct setIdentity_impl<Derived, true>
static EIGEN_STRONG_INLINE Derived& run(Derived& m)
{
m.setZero();
- EIGEN_USING_STD_MATH(min)
- const Index size = (min)(m.rows(), m.cols());
+ const Index size = numext::mini(m.rows(), m.cols());
for(Index i = 0; i < size; ++i) m.coeffRef(i,i) = typename Derived::Scalar(1);
return m;
}
diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h
index f04facecc..c682c6d7f 100644
--- a/Eigen/src/Core/DiagonalMatrix.h
+++ b/Eigen/src/Core/DiagonalMatrix.h
@@ -290,12 +290,11 @@ MatrixBase<Derived>::asDiagonal() const
template<typename Derived>
bool MatrixBase<Derived>::isDiagonal(const RealScalar& prec) const
{
- EIGEN_USING_STD_MATH(abs)
if(cols() != rows()) return false;
RealScalar maxAbsOnDiagonal = static_cast<RealScalar>(-1);
for(Index j = 0; j < cols(); ++j)
{
- RealScalar absOnDiagonal = abs(coeff(j,j));
+ RealScalar absOnDiagonal = numext::abs(coeff(j,j));
if(absOnDiagonal > maxAbsOnDiagonal) maxAbsOnDiagonal = absOnDiagonal;
}
for(Index j = 0; j < cols(); ++j)
diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h
index a4ade63b8..2dcd929e6 100644
--- a/Eigen/src/Core/PlainObjectBase.h
+++ b/Eigen/src/Core/PlainObjectBase.h
@@ -916,9 +916,8 @@ struct conservative_resize_like_impl
{
// The storage order does not allow us to use reallocation.
typename Derived::PlainObject tmp(rows,cols);
- EIGEN_USING_STD_MATH(min)
- const Index common_rows = (min)(rows, _this.rows());
- const Index common_cols = (min)(cols, _this.cols());
+ const Index common_rows = numext::mini(rows, _this.rows());
+ const Index common_cols = numext::mini(cols, _this.cols());
tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
_this.derived().swap(tmp);
}
@@ -951,9 +950,8 @@ struct conservative_resize_like_impl
{
// The storage order does not allow us to use reallocation.
typename Derived::PlainObject tmp(other);
- EIGEN_USING_STD_MATH(min)
- const Index common_rows = (min)(tmp.rows(), _this.rows());
- const Index common_cols = (min)(tmp.cols(), _this.cols());
+ const Index common_rows = numext::mini(tmp.rows(), _this.rows());
+ const Index common_cols = numext::mini(tmp.cols(), _this.cols());
tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
_this.derived().swap(tmp);
}
diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h
index 17fcfeeb9..71f5d4f29 100644
--- a/Eigen/src/Core/TriangularMatrix.h
+++ b/Eigen/src/Core/TriangularMatrix.h
@@ -641,22 +641,20 @@ MatrixBase<Derived>::triangularView() const
template<typename Derived>
bool MatrixBase<Derived>::isUpperTriangular(const RealScalar& prec) const
{
- EIGEN_USING_STD_MATH(abs)
RealScalar maxAbsOnUpperPart = static_cast<RealScalar>(-1);
- EIGEN_USING_STD_MATH(min)
for(Index j = 0; j < cols(); ++j)
{
- Index maxi = (min)(j, rows()-1);
+ Index maxi = numext::mini(j, rows()-1);
for(Index i = 0; i <= maxi; ++i)
{
- RealScalar absValue = abs(coeff(i,j));
+ RealScalar absValue = numext::abs(coeff(i,j));
if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue;
}
}
RealScalar threshold = maxAbsOnUpperPart * prec;
for(Index j = 0; j < cols(); ++j)
for(Index i = j+1; i < rows(); ++i)
- if(abs(coeff(i, j)) > threshold) return false;
+ if(numext::abs(coeff(i, j)) > threshold) return false;
return true;
}
@@ -668,21 +666,19 @@ bool MatrixBase<Derived>::isUpperTriangular(const RealScalar& prec) const
template<typename Derived>
bool MatrixBase<Derived>::isLowerTriangular(const RealScalar& prec) const
{
- EIGEN_USING_STD_MATH(abs)
- EIGEN_USING_STD_MATH(min)
RealScalar maxAbsOnLowerPart = static_cast<RealScalar>(-1);
for(Index j = 0; j < cols(); ++j)
for(Index i = j; i < rows(); ++i)
{
- RealScalar absValue = abs(coeff(i,j));
+ RealScalar absValue = numext::abs(coeff(i,j));
if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue;
}
RealScalar threshold = maxAbsOnLowerPart * prec;
for(Index j = 1; j < cols(); ++j)
{
- Index maxi = (min)(j, rows()-1);
+ Index maxi = numext::mini(j, rows()-1);
for(Index i = 0; i < maxi; ++i)
- if(abs(coeff(i, j)) > threshold) return false;
+ if(numext::abs(coeff(i, j)) > threshold) return false;
}
return true;
}
@@ -893,10 +889,9 @@ struct triangular_assignment_loop<Kernel, Mode, Dynamic, SetOpposite>
EIGEN_DEVICE_FUNC
static inline void run(Kernel &kernel)
{
- EIGEN_USING_STD_MATH(min)
for(Index j = 0; j < kernel.cols(); ++j)
{
- Index maxi = (min)(j, kernel.rows());
+ Index maxi = numext::mini(j, kernel.rows());
Index i = 0;
if (((Mode&Lower) && SetOpposite) || (Mode&Upper))
{
diff --git a/Eigen/src/Geometry/Hyperplane.h b/Eigen/src/Geometry/Hyperplane.h
index d66194287..07f2659b2 100644
--- a/Eigen/src/Geometry/Hyperplane.h
+++ b/Eigen/src/Geometry/Hyperplane.h
@@ -145,7 +145,7 @@ public:
/** \returns the absolute distance between the plane \c *this and a point \a p.
* \sa signedDistance()
*/
- EIGEN_DEVICE_FUNC inline Scalar absDistance(const VectorType& p) const { EIGEN_USING_STD_MATH(abs) return abs(signedDistance(p)); }
+ EIGEN_DEVICE_FUNC inline Scalar absDistance(const VectorType& p) const { return numext::abs(signedDistance(p)); }
/** \returns the projection of a point \a p onto the plane \c *this.
*/
@@ -188,14 +188,13 @@ public:
*/
EIGEN_DEVICE_FUNC VectorType intersection(const Hyperplane& other) const
{
- EIGEN_USING_STD_MATH(abs)
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
Scalar det = coeffs().coeff(0) * other.coeffs().coeff(1) - coeffs().coeff(1) * other.coeffs().coeff(0);
// since the line equations ax+by=c are normalized with a^2+b^2=1, the following tests
// whether the two lines are approximately parallel.
if(internal::isMuchSmallerThan(det, Scalar(1)))
{ // special case where the two lines are approximately parallel. Pick any point on the first line.
- if(abs(coeffs().coeff(1))>abs(coeffs().coeff(0)))
+ if(numext::abs(coeffs().coeff(1))>numext::abs(coeffs().coeff(0)))
return VectorType(coeffs().coeff(1), -coeffs().coeff(2)/coeffs().coeff(1)-coeffs().coeff(0));
else
return VectorType(-coeffs().coeff(2)/coeffs().coeff(0)-coeffs().coeff(1), coeffs().coeff(0));
diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h
index 932f149e3..f6ef1bcf6 100644
--- a/Eigen/src/Geometry/Quaternion.h
+++ b/Eigen/src/Geometry/Quaternion.h
@@ -705,9 +705,8 @@ EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Scalar
QuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& other) const
{
EIGEN_USING_STD_MATH(atan2)
- EIGEN_USING_STD_MATH(abs)
Quaternion<Scalar> d = (*this) * other.conjugate();
- return Scalar(2) * atan2( d.vec().norm(), abs(d.w()) );
+ return Scalar(2) * atan2( d.vec().norm(), numext::abs(d.w()) );
}
@@ -725,10 +724,9 @@ QuaternionBase<Derived>::slerp(const Scalar& t, const QuaternionBase<OtherDerive
{
EIGEN_USING_STD_MATH(acos)
EIGEN_USING_STD_MATH(sin)
- EIGEN_USING_STD_MATH(abs)
const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon();
Scalar d = this->dot(other);
- Scalar absD = abs(d);
+ Scalar absD = numext::abs(d);
Scalar scale0;
Scalar scale1;