diff --git a/Eigen/Core b/Eigen/Core index a897e4f45..79b326792 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -1,3 +1,5 @@ +#include +#include #include #include #include diff --git a/Eigen/src/Core/Conjugate.h b/Eigen/src/Core/Conjugate.h index 839a43bc7..21f256c76 100644 --- a/Eigen/src/Core/Conjugate.h +++ b/Eigen/src/Core/Conjugate.h @@ -63,7 +63,7 @@ template class Conjugate : NoOperatorEquals, Scalar _coeff(int row, int col) const { - return conj(m_matrix.coeff(row, col)); + return ei_conj(m_matrix.coeff(row, col)); } protected: diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index b8ce5d2d5..583eb68c5 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -109,14 +109,14 @@ bool MatrixBase::isDiagonal RealScalar maxAbsOnDiagonal = static_cast(-1); for(int j = 0; j < cols(); j++) { - RealScalar absOnDiagonal = abs(coeff(j,j)); + RealScalar absOnDiagonal = ei_abs(coeff(j,j)); if(absOnDiagonal > maxAbsOnDiagonal) maxAbsOnDiagonal = absOnDiagonal; } for(int j = 0; j < cols(); j++) for(int i = 0; i < j; i++) { - if(!Eigen::isMuchSmallerThan(coeff(i, j), maxAbsOnDiagonal, prec)) return false; - if(!Eigen::isMuchSmallerThan(coeff(j, i), maxAbsOnDiagonal, prec)) return false; + if(!ei_isMuchSmallerThan(coeff(i, j), maxAbsOnDiagonal, prec)) return false; + if(!ei_isMuchSmallerThan(coeff(j, i), maxAbsOnDiagonal, prec)) return false; } return true; } diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index 3ff416fba..168cf65a3 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -32,7 +32,7 @@ struct DotUnroller static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot) { DotUnroller::run(v1, v2, dot); - dot += v1.coeff(Index) * conj(v2.coeff(Index)); + dot += v1.coeff(Index) * ei_conj(v2.coeff(Index)); } }; @@ -41,7 +41,7 @@ struct DotUnroller<0, Size, Derived1, Derived2> { static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot) { - dot = v1.coeff(0) * conj(v2.coeff(0)); + dot = v1.coeff(0) * ei_conj(v2.coeff(0)); } }; @@ -84,9 +84,9 @@ Scalar MatrixBase::dot(const OtherDerived& other) const ::run(*static_cast(this), other, res); else { - res = (*this).coeff(0) * conj(other.coeff(0)); + res = (*this).coeff(0) * ei_conj(other.coeff(0)); for(int i = 1; i < size(); i++) - res += (*this).coeff(i)* conj(other.coeff(i)); + res += (*this).coeff(i)* ei_conj(other.coeff(i)); } return res; } @@ -100,7 +100,7 @@ Scalar MatrixBase::dot(const OtherDerived& other) const template typename NumTraits::Real MatrixBase::norm2() const { - return real(dot(*this)); + return ei_real(dot(*this)); } /** \returns the norm of *this, i.e. the square root of the dot product of *this with itself. @@ -112,7 +112,7 @@ typename NumTraits::Real MatrixBase::norm2() const template typename NumTraits::Real MatrixBase::norm() const { - return sqrt(norm2()); + return ei_sqrt(norm2()); } /** \returns an expression of the quotient of *this by its own norm. @@ -140,7 +140,7 @@ bool MatrixBase::isOrtho (const OtherDerived& other, typename NumTraits::Real prec) const { - return abs2(dot(other)) <= prec * prec * norm2() * other.norm2(); + return ei_abs2(dot(other)) <= prec * prec * norm2() * other.norm2(); } /** \returns true if *this is approximately an unitary matrix, @@ -160,10 +160,10 @@ bool MatrixBase::isOrtho { for(int i = 0; i < cols(); i++) { - if(!Eigen::isApprox(col(i).norm2(), static_cast(1), prec)) + if(!ei_isApprox(col(i).norm2(), static_cast(1), prec)) return false; for(int j = 0; j < i; j++) - if(!Eigen::isMuchSmallerThan(col(i).dot(col(j)), static_cast(1), prec)) + if(!ei_isMuchSmallerThan(col(i).dot(col(j)), static_cast(1), prec)) return false; } return true; diff --git a/Eigen/src/Core/Fuzzy.h b/Eigen/src/Core/Fuzzy.h index 261f14b4a..c16438a2c 100644 --- a/Eigen/src/Core/Fuzzy.h +++ b/Eigen/src/Core/Fuzzy.h @@ -37,10 +37,10 @@ * \note Because of the multiplicativeness of this comparison, one can't use this function * to check whether \c *this is approximately equal to the zero matrix or vector. * Indeed, \c isApprox(zero) returns false unless \c *this itself is exactly the zero matrix - * or vector. If you want to test whether \c *this is zero, use isMuchSmallerThan(const + * or vector. If you want to test whether \c *this is zero, use ei_isMuchSmallerThan(const * RealScalar&, RealScalar) instead. * - * \sa isMuchSmallerThan(const RealScalar&, RealScalar) const + * \sa ei_isMuchSmallerThan(const RealScalar&, RealScalar) const */ template template @@ -82,12 +82,12 @@ bool MatrixBase::isMuchSmallerThan( { if(Traits::IsVectorAtCompileTime) { - return(norm2() <= abs2(other * prec)); + return(norm2() <= ei_abs2(other * prec)); } else { for(int i = 0; i < cols(); i++) - if(col(i).norm2() > abs2(other * prec)) + if(col(i).norm2() > ei_abs2(other * prec)) return false; return true; } diff --git a/Eigen/src/Core/Identity.h b/Eigen/src/Core/Identity.h index a74ad0247..4cb9073a6 100644 --- a/Eigen/src/Core/Identity.h +++ b/Eigen/src/Core/Identity.h @@ -125,12 +125,12 @@ bool MatrixBase::isIdentity { if(i == j) { - if(!Eigen::isApprox(coeff(i, j), static_cast(1), prec)) + if(!ei_isApprox(coeff(i, j), static_cast(1), prec)) return false; } else { - if(!Eigen::isMuchSmallerThan(coeff(i, j), static_cast(1), prec)) + if(!ei_isMuchSmallerThan(coeff(i, j), static_cast(1), prec)) return false; } } diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 3b72a29c0..e8348dd6f 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -27,16 +27,16 @@ #define EIGEN_MATHFUNCTIONS_H template inline typename NumTraits::Real precision(); -template inline T random(T a, T b); -template inline T random(); +template inline T ei_random(T a, T b); +template inline T ei_random(); template<> inline int precision() { return 0; } -inline int real(int x) { return x; } -inline int imag(int) { return 0; } -inline int conj(int x) { return x; } -inline int abs(int x) { return std::abs(x); } -inline int abs2(int x) { return x*x; } -inline int sqrt(int) +inline int ei_real(int x) { return x; } +inline int ei_imag(int) { return 0; } +inline int ei_conj(int x) { return x; } +inline int ei_abs(int x) { return abs(x); } +inline int ei_abs2(int x) { return x*x; } +inline int ei_sqrt(int) { // Taking the square root of integers is not allowed // (the square root does not always exist within the integers). @@ -44,91 +44,91 @@ inline int sqrt(int) assert(false); return 0; } -template<> inline int random(int a, int b) +template<> inline int ei_random(int a, int b) { // We can't just do rand()%n as only the high-order bits are really random return a + static_cast((b-a+1) * (rand() / (RAND_MAX + 1.0))); } -template<> inline int random() +template<> inline int ei_random() { - return random(-10, 10); + return ei_random(-10, 10); } -inline bool isMuchSmallerThan(int a, int, int = precision()) +inline bool ei_isMuchSmallerThan(int a, int, int = precision()) { return a == 0; } -inline bool isApprox(int a, int b, int = precision()) +inline bool ei_isApprox(int a, int b, int = precision()) { return a == b; } -inline bool isApproxOrLessThan(int a, int b, int = precision()) +inline bool ei_isApproxOrLessThan(int a, int b, int = precision()) { return a <= b; } template<> inline float precision() { return 1e-5f; } -inline float real(float x) { return x; } -inline float imag(float) { return 0.f; } -inline float conj(float x) { return x; } -inline float abs(float x) { return std::abs(x); } -inline float abs2(float x) { return x*x; } -inline float sqrt(float x) { return std::sqrt(x); } -template<> inline float random(float a, float b) +inline float ei_real(float x) { return x; } +inline float ei_imag(float) { return 0.f; } +inline float ei_conj(float x) { return x; } +inline float ei_abs(float x) { return std::abs(x); } +inline float ei_abs2(float x) { return x*x; } +inline float ei_sqrt(float x) { return std::sqrt(x); } +template<> inline float ei_random(float a, float b) { return a + (b-a) * std::rand() / RAND_MAX; } -template<> inline float random() +template<> inline float ei_random() { - return random(-10.0f, 10.0f); + return ei_random(-10.0f, 10.0f); } -inline bool isMuchSmallerThan(float a, float b, float prec = precision()) +inline bool ei_isMuchSmallerThan(float a, float b, float prec = precision()) { - return std::abs(a) <= std::abs(b) * prec; + return ei_abs(a) <= ei_abs(b) * prec; } -inline bool isApprox(float a, float b, float prec = precision()) +inline bool ei_isApprox(float a, float b, float prec = precision()) { - return std::abs(a - b) <= std::min(std::abs(a), std::abs(b)) * prec; + return ei_abs(a - b) <= std::min(ei_abs(a), ei_abs(b)) * prec; } -inline bool isApproxOrLessThan(float a, float b, float prec = precision()) +inline bool ei_isApproxOrLessThan(float a, float b, float prec = precision()) { - return a <= b || isApprox(a, b, prec); + return a <= b || ei_isApprox(a, b, prec); } template<> inline double precision() { return 1e-11; } -inline double real(double x) { return x; } -inline double imag(double) { return 0.; } -inline double conj(double x) { return x; } -inline double abs(double x) { return std::abs(x); } -inline double abs2(double x) { return x*x; } -inline double sqrt(double x) { return std::sqrt(x); } -template<> inline double random(double a, double b) +inline double ei_real(double x) { return x; } +inline double ei_imag(double) { return 0.; } +inline double ei_conj(double x) { return x; } +inline double ei_abs(double x) { return std::abs(x); } +inline double ei_abs2(double x) { return x*x; } +inline double ei_sqrt(double x) { return std::sqrt(x); } +template<> inline double ei_random(double a, double b) { return a + (b-a) * std::rand() / RAND_MAX; } -template<> inline double random() +template<> inline double ei_random() { - return random(-10.0, 10.0); + return ei_random(-10.0, 10.0); } -inline bool isMuchSmallerThan(double a, double b, double prec = precision()) +inline bool ei_isMuchSmallerThan(double a, double b, double prec = precision()) { - return std::abs(a) <= std::abs(b) * prec; + return ei_abs(a) <= ei_abs(b) * prec; } -inline bool isApprox(double a, double b, double prec = precision()) +inline bool ei_isApprox(double a, double b, double prec = precision()) { - return std::abs(a - b) <= std::min(std::abs(a), std::abs(b)) * prec; + return ei_abs(a - b) <= std::min(ei_abs(a), ei_abs(b)) * prec; } -inline bool isApproxOrLessThan(double a, double b, double prec = precision()) +inline bool ei_isApproxOrLessThan(double a, double b, double prec = precision()) { - return a <= b || isApprox(a, b, prec); + return a <= b || ei_isApprox(a, b, prec); } template<> inline float precision >() { return precision(); } -inline float real(const std::complex& x) { return std::real(x); } -inline float imag(const std::complex& x) { return std::imag(x); } -inline std::complex conj(const std::complex& x) { return std::conj(x); } -inline float abs(const std::complex& x) { return std::abs(x); } -inline float abs2(const std::complex& x) { return std::norm(x); } -inline std::complex sqrt(const std::complex&) +inline float ei_real(const std::complex& x) { return std::real(x); } +inline float ei_imag(const std::complex& x) { return std::imag(x); } +inline std::complex ei_conj(const std::complex& x) { return std::conj(x); } +inline float ei_abs(const std::complex& x) { return std::abs(x); } +inline float ei_abs2(const std::complex& x) { return std::norm(x); } +inline std::complex ei_sqrt(const std::complex&) { // Taking the square roots of complex numbers is not allowed, // as this is ambiguous (there are two square roots). @@ -136,49 +136,49 @@ inline std::complex sqrt(const std::complex&) assert(false); return 0; } -template<> inline std::complex random() +template<> inline std::complex ei_random() { - return std::complex(random(), random()); + return std::complex(ei_random(), ei_random()); } -inline bool isMuchSmallerThan(const std::complex& a, const std::complex& b, float prec = precision()) +inline bool ei_isMuchSmallerThan(const std::complex& a, const std::complex& b, float prec = precision()) { - return abs2(a) <= abs2(b) * prec * prec; + return ei_abs2(a) <= ei_abs2(b) * prec * prec; } -inline bool isMuchSmallerThan(const std::complex& a, float b, float prec = precision()) +inline bool ei_isMuchSmallerThan(const std::complex& a, float b, float prec = precision()) { - return abs2(a) <= abs2(b) * prec * prec; + return ei_abs2(a) <= ei_abs2(b) * prec * prec; } -inline bool isApprox(const std::complex& a, const std::complex& b, float prec = precision()) +inline bool ei_isApprox(const std::complex& a, const std::complex& b, float prec = precision()) { - return isApprox(std::real(a), std::real(b), prec) - && isApprox(std::imag(a), std::imag(b), prec); + return ei_isApprox(ei_real(a), ei_real(b), prec) + && ei_isApprox(ei_imag(a), ei_imag(b), prec); } -// isApproxOrLessThan wouldn't make sense for complex numbers +// ei_isApproxOrLessThan wouldn't make sense for complex numbers template<> inline double precision >() { return precision(); } -inline double real(const std::complex& x) { return std::real(x); } -inline double imag(const std::complex& x) { return std::imag(x); } -inline std::complex conj(const std::complex& x) { return std::conj(x); } -inline double abs(const std::complex& x) { return std::abs(x); } -inline double abs2(const std::complex& x) { return std::norm(x); } -template<> inline std::complex random() +inline double ei_real(const std::complex& x) { return std::real(x); } +inline double ei_imag(const std::complex& x) { return std::imag(x); } +inline std::complex ei_conj(const std::complex& x) { return std::conj(x); } +inline double ei_abs(const std::complex& x) { return std::abs(x); } +inline double ei_abs2(const std::complex& x) { return std::norm(x); } +template<> inline std::complex ei_random() { - return std::complex(random(), random()); + return std::complex(ei_random(), ei_random()); } -inline bool isMuchSmallerThan(const std::complex& a, const std::complex& b, double prec = precision()) +inline bool ei_isMuchSmallerThan(const std::complex& a, const std::complex& b, double prec = precision()) { - return abs2(a) <= abs2(b) * prec * prec; + return ei_abs2(a) <= ei_abs2(b) * prec * prec; } -inline bool isMuchSmallerThan(const std::complex& a, double b, double prec = precision()) +inline bool ei_isMuchSmallerThan(const std::complex& a, double b, double prec = precision()) { - return abs2(a) <= abs2(b) * prec * prec; + return ei_abs2(a) <= ei_abs2(b) * prec * prec; } -inline bool isApprox(const std::complex& a, const std::complex& b, double prec = precision()) +inline bool ei_isApprox(const std::complex& a, const std::complex& b, double prec = precision()) { - return isApprox(std::real(a), std::real(b), prec) - && isApprox(std::imag(a), std::imag(b), prec); + return ei_isApprox(ei_real(a), ei_real(b), prec) + && ei_isApprox(ei_imag(a), ei_imag(b), prec); } -// isApproxOrLessThan wouldn't make sense for complex numbers +// ei_isApproxOrLessThan wouldn't make sense for complex numbers #define EIGEN_MAKE_MORE_OVERLOADED_COMPLEX_OPERATOR_STAR(T,U) \ inline std::complex operator*(U a, const std::complex& b) \ diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index fce3a441d..cb7186729 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -314,7 +314,7 @@ template class MatrixBase for(int j = 0; j < cols(); j++) for(int i = 0; i < rows(); i++) { - RealScalar x = abs(coeff(i,j)); + RealScalar x = ei_abs(coeff(i,j)); if(x > biggest) { biggest = x; diff --git a/Eigen/src/Core/Ones.h b/Eigen/src/Core/Ones.h index 4e5a2e7ca..cd7f5903a 100644 --- a/Eigen/src/Core/Ones.h +++ b/Eigen/src/Core/Ones.h @@ -146,7 +146,7 @@ bool MatrixBase::isOnes { for(int j = 0; j < cols(); j++) for(int i = 0; i < rows(); i++) - if(!Eigen::isApprox(coeff(i, j), static_cast(1), prec)) + if(!ei_isApprox(coeff(i, j), static_cast(1), prec)) return false; return true; } diff --git a/Eigen/src/Core/Random.h b/Eigen/src/Core/Random.h index 89febe4f3..793e45505 100644 --- a/Eigen/src/Core/Random.h +++ b/Eigen/src/Core/Random.h @@ -55,7 +55,7 @@ template class Random : NoOperatorEquals, Scalar _coeff(int, int) const { - return Eigen::random(); + return ei_random(); } public: @@ -78,13 +78,13 @@ template class Random : NoOperatorEquals, * the returned matrix. Must be compatible with this MatrixBase type. * * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so random() should be used + * it is redundant to pass \a rows and \a cols as arguments, so ei_random() should be used * instead. * * Example: \include MatrixBase_random_int_int.cpp * Output: \verbinclude MatrixBase_random_int_int.out * - * \sa random(), random(int) + * \sa ei_random(), ei_random(int) */ template const Eval > @@ -101,13 +101,13 @@ MatrixBase::random(int rows, int cols) * \only_for_vectors * * This variant is meant to be used for dynamic-size vector types. For fixed-size types, - * it is redundant to pass \a size as argument, so random() should be used + * it is redundant to pass \a size as argument, so ei_random() should be used * instead. * * Example: \include MatrixBase_random_int.cpp * Output: \verbinclude MatrixBase_random_int.out * - * \sa random(), random(int,int) + * \sa ei_random(), ei_random(int,int) */ template const Eval > @@ -127,7 +127,7 @@ MatrixBase::random(int size) * Example: \include MatrixBase_random.cpp * Output: \verbinclude MatrixBase_random.out * - * \sa random(int), random(int,int) + * \sa ei_random(int), ei_random(int,int) */ template const Eval > @@ -141,7 +141,7 @@ MatrixBase::random() * Example: \include MatrixBase_setRandom.cpp * Output: \verbinclude MatrixBase_setRandom.out * - * \sa class Random, random() + * \sa class Random, ei_random() */ template Derived& MatrixBase::setRandom() diff --git a/Eigen/src/Core/Zero.h b/Eigen/src/Core/Zero.h index 625804059..a8b003493 100644 --- a/Eigen/src/Core/Zero.h +++ b/Eigen/src/Core/Zero.h @@ -146,7 +146,7 @@ bool MatrixBase::isZero { for(int j = 0; j < cols(); j++) for(int i = 0; i < rows(); i++) - if(!Eigen::isMuchSmallerThan(coeff(i, j), static_cast(1), prec)) + if(!ei_isMuchSmallerThan(coeff(i, j), static_cast(1), prec)) return false; return true; } diff --git a/doc/benchmark.cpp b/doc/benchmark.cpp index b2ab9a3b0..ad515e04e 100644 --- a/doc/benchmark.cpp +++ b/doc/benchmark.cpp @@ -1,8 +1,9 @@ // g++ -O3 -DNDEBUG benchmark.cpp -o benchmark && time ./benchmark - +#include +#include #include -using namespace std; +//using namespace std; USING_PART_OF_NAMESPACE_EIGEN int main(int argc, char *argv[]) @@ -18,6 +19,6 @@ int main(int argc, char *argv[]) { m = I + 0.00005 * (m + m*m); } - cout << m << endl; + std::cout << m << std::endl; return 0; } diff --git a/test/adjoint.cpp b/test/adjoint.cpp index f6cd53631..b30deb6a9 100644 --- a/test/adjoint.cpp +++ b/test/adjoint.cpp @@ -51,8 +51,8 @@ template void adjoint(const MatrixType& m) v3 = VectorType::random(rows), vzero = VectorType::zero(rows); - Scalar s1 = random(), - s2 = random(); + Scalar s1 = ei_random(), + s2 = ei_random(); // check involutivity of adjoint, transpose, conjugate VERIFY_IS_APPROX(m1.transpose().transpose(), m1); @@ -70,18 +70,18 @@ template void adjoint(const MatrixType& m) VERIFY_IS_APPROX((m1.adjoint() * m2).adjoint(), m2.adjoint() * m1); VERIFY_IS_APPROX((m1.transpose() * m2).conjugate(), m1.adjoint() * m2.conjugate()); VERIFY_IS_APPROX((s1 * m1).transpose(), s1 * m1.transpose()); - VERIFY_IS_APPROX((s1 * m1).conjugate(), conj(s1) * m1.conjugate()); - VERIFY_IS_APPROX((s1 * m1).adjoint(), conj(s1) * m1.adjoint()); + VERIFY_IS_APPROX((s1 * m1).conjugate(), ei_conj(s1) * m1.conjugate()); + VERIFY_IS_APPROX((s1 * m1).adjoint(), ei_conj(s1) * m1.adjoint()); // check basic properties of dot, norm, norm2 typedef typename NumTraits::Real RealScalar; VERIFY_IS_APPROX((s1 * v1 + s2 * v2).dot(v3), s1 * v1.dot(v3) + s2 * v2.dot(v3)); - VERIFY_IS_APPROX(v3.dot(s1 * v1 + s2 * v2), conj(s1)*v3.dot(v1)+conj(s2)*v3.dot(v2)); - VERIFY_IS_APPROX(conj(v1.dot(v2)), v2.dot(v1)); - VERIFY_IS_APPROX(abs(v1.dot(v1)), v1.norm2()); + VERIFY_IS_APPROX(v3.dot(s1 * v1 + s2 * v2), ei_conj(s1)*v3.dot(v1)+ei_conj(s2)*v3.dot(v2)); + VERIFY_IS_APPROX(ei_conj(v1.dot(v2)), v2.dot(v1)); + VERIFY_IS_APPROX(ei_abs(v1.dot(v1)), v1.norm2()); if(NumTraits::HasFloatingPoint) VERIFY_IS_APPROX(v1.norm2(), v1.norm() * v1.norm()); - VERIFY_IS_MUCH_SMALLER_THAN(abs(vzero.dot(v1)), static_cast(1)); + VERIFY_IS_MUCH_SMALLER_THAN(ei_abs(vzero.dot(v1)), static_cast(1)); if(NumTraits::HasFloatingPoint) VERIFY_IS_MUCH_SMALLER_THAN(vzero.norm(), static_cast(1)); @@ -89,10 +89,10 @@ template void adjoint(const MatrixType& m) VERIFY_IS_APPROX(v1.dot(square * v2), (square.adjoint() * v1).dot(v2)); // like in testBasicStuff, test operator() to check const-qualification - int r = random(0, rows-1), - c = random(0, cols-1); - VERIFY_IS_APPROX(m1.conjugate()(r,c), conj(m1(r,c))); - VERIFY_IS_APPROX(m1.adjoint()(c,r), conj(m1(r,c))); + int r = ei_random(0, rows-1), + c = ei_random(0, cols-1); + VERIFY_IS_APPROX(m1.conjugate()(r,c), ei_conj(m1(r,c))); + VERIFY_IS_APPROX(m1.adjoint()(c,r), ei_conj(m1(r,c))); } diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp index f8a651a73..456275a09 100644 --- a/test/basicstuff.cpp +++ b/test/basicstuff.cpp @@ -49,8 +49,8 @@ template void basicStuff(const MatrixType& m) v2 = VectorType::random(rows), vzero = VectorType::zero(rows); - int r = random(0, rows-1), - c = random(0, cols-1); + int r = ei_random(0, rows-1), + c = ei_random(0, cols-1); VERIFY_IS_APPROX( v1, v1); VERIFY_IS_NOT_APPROX( v1, 2*v1); diff --git a/test/linearstructure.cpp b/test/linearstructure.cpp index 682315c7a..f1869f5d1 100644 --- a/test/linearstructure.cpp +++ b/test/linearstructure.cpp @@ -53,11 +53,11 @@ template void linearStructure(const MatrixType& m) v2 = VectorType::random(rows), vzero = VectorType::zero(rows); - Scalar s1 = random(), - s2 = random(); + Scalar s1 = ei_random(), + s2 = ei_random(); - int r = random(0, rows-1), - c = random(0, cols-1); + int r = ei_random(0, rows-1), + c = ei_random(0, cols-1); VERIFY_IS_APPROX(-(-m1), m1); VERIFY_IS_APPROX(m1+m1, 2*m1); diff --git a/test/main.h b/test/main.h index d914a14f5..2699e4bae 100644 --- a/test/main.h +++ b/test/main.h @@ -38,12 +38,12 @@ #define DEFAULT_REPEAT 50 #define VERIFY(a) QVERIFY(a) -#define VERIFY_IS_APPROX(a, b) QVERIFY(test_isApprox(a, b)) -#define VERIFY_IS_NOT_APPROX(a, b) QVERIFY(!test_isApprox(a, b)) -#define VERIFY_IS_MUCH_SMALLER_THAN(a, b) QVERIFY(test_isMuchSmallerThan(a, b)) -#define VERIFY_IS_NOT_MUCH_SMALLER_THAN(a, b) QVERIFY(!test_isMuchSmallerThan(a, b)) -#define VERIFY_IS_APPROX_OR_LESS_THAN(a, b) QVERIFY(test_isApproxOrLessThan(a, b)) -#define VERIFY_IS_NOT_APPROX_OR_LESS_THAN(a, b) QVERIFY(!test_isApproxOrLessThan(a, b)) +#define VERIFY_IS_APPROX(a, b) QVERIFY(test_ei_isApprox(a, b)) +#define VERIFY_IS_NOT_APPROX(a, b) QVERIFY(!test_ei_isApprox(a, b)) +#define VERIFY_IS_MUCH_SMALLER_THAN(a, b) QVERIFY(test_ei_isMuchSmallerThan(a, b)) +#define VERIFY_IS_NOT_MUCH_SMALLER_THAN(a, b) QVERIFY(!test_ei_isMuchSmallerThan(a, b)) +#define VERIFY_IS_APPROX_OR_LESS_THAN(a, b) QVERIFY(test_ei_isApproxOrLessThan(a, b)) +#define VERIFY_IS_NOT_APPROX_OR_LESS_THAN(a, b) QVERIFY(!test_ei_isApproxOrLessThan(a, b)) namespace Eigen { @@ -54,53 +54,53 @@ template<> inline double test_precision() { return 1e-5; } template<> inline float test_precision >() { return test_precision(); } template<> inline double test_precision >() { return test_precision(); } -inline bool test_isApprox(const int& a, const int& b) -{ return isApprox(a, b, test_precision()); } -inline bool test_isMuchSmallerThan(const int& a, const int& b) -{ return isMuchSmallerThan(a, b, test_precision()); } -inline bool test_isApproxOrLessThan(const int& a, const int& b) -{ return isApproxOrLessThan(a, b, test_precision()); } +inline bool test_ei_isApprox(const int& a, const int& b) +{ return ei_isApprox(a, b, test_precision()); } +inline bool test_ei_isMuchSmallerThan(const int& a, const int& b) +{ return ei_isMuchSmallerThan(a, b, test_precision()); } +inline bool test_ei_isApproxOrLessThan(const int& a, const int& b) +{ return ei_isApproxOrLessThan(a, b, test_precision()); } -inline bool test_isApprox(const float& a, const float& b) -{ return isApprox(a, b, test_precision()); } -inline bool test_isMuchSmallerThan(const float& a, const float& b) -{ return isMuchSmallerThan(a, b, test_precision()); } -inline bool test_isApproxOrLessThan(const float& a, const float& b) -{ return isApproxOrLessThan(a, b, test_precision()); } +inline bool test_ei_isApprox(const float& a, const float& b) +{ return ei_isApprox(a, b, test_precision()); } +inline bool test_ei_isMuchSmallerThan(const float& a, const float& b) +{ return ei_isMuchSmallerThan(a, b, test_precision()); } +inline bool test_ei_isApproxOrLessThan(const float& a, const float& b) +{ return ei_isApproxOrLessThan(a, b, test_precision()); } -inline bool test_isApprox(const double& a, const double& b) -{ return isApprox(a, b, test_precision()); } -inline bool test_isMuchSmallerThan(const double& a, const double& b) -{ return isMuchSmallerThan(a, b, test_precision()); } -inline bool test_isApproxOrLessThan(const double& a, const double& b) -{ return isApproxOrLessThan(a, b, test_precision()); } +inline bool test_ei_isApprox(const double& a, const double& b) +{ return ei_isApprox(a, b, test_precision()); } +inline bool test_ei_isMuchSmallerThan(const double& a, const double& b) +{ return ei_isMuchSmallerThan(a, b, test_precision()); } +inline bool test_ei_isApproxOrLessThan(const double& a, const double& b) +{ return ei_isApproxOrLessThan(a, b, test_precision()); } -inline bool test_isApprox(const std::complex& a, const std::complex& b) -{ return isApprox(a, b, test_precision >()); } -inline bool test_isMuchSmallerThan(const std::complex& a, const std::complex& b) -{ return isMuchSmallerThan(a, b, test_precision >()); } +inline bool test_ei_isApprox(const std::complex& a, const std::complex& b) +{ return ei_isApprox(a, b, test_precision >()); } +inline bool test_ei_isMuchSmallerThan(const std::complex& a, const std::complex& b) +{ return ei_isMuchSmallerThan(a, b, test_precision >()); } -inline bool test_isApprox(const std::complex& a, const std::complex& b) -{ return isApprox(a, b, test_precision >()); } -inline bool test_isMuchSmallerThan(const std::complex& a, const std::complex& b) -{ return isMuchSmallerThan(a, b, test_precision >()); } +inline bool test_ei_isApprox(const std::complex& a, const std::complex& b) +{ return ei_isApprox(a, b, test_precision >()); } +inline bool test_ei_isMuchSmallerThan(const std::complex& a, const std::complex& b) +{ return ei_isMuchSmallerThan(a, b, test_precision >()); } template -inline bool test_isApprox(const MatrixBase& m1, +inline bool test_ei_isApprox(const MatrixBase& m1, const MatrixBase& m2) { return m1.isApprox(m2, test_precision()); } template -inline bool test_isMuchSmallerThan(const MatrixBase& m1, +inline bool test_ei_isMuchSmallerThan(const MatrixBase& m1, const MatrixBase& m2) { return m1.isMuchSmallerThan(m2, test_precision()); } template -inline bool test_isMuchSmallerThan(const MatrixBase& m, +inline bool test_ei_isMuchSmallerThan(const MatrixBase& m, const typename NumTraits::Real& s) { return m.isMuchSmallerThan(s, test_precision()); diff --git a/test/miscmatrices.cpp b/test/miscmatrices.cpp index 42f808b1a..70e77403d 100644 --- a/test/miscmatrices.cpp +++ b/test/miscmatrices.cpp @@ -39,7 +39,7 @@ template void miscMatrices(const MatrixType& m) int rows = m.rows(); int cols = m.cols(); - int r = random(0, rows-1), r2 = random(0, rows-1), c = random(0, cols-1); + int r = ei_random(0, rows-1), r2 = ei_random(0, rows-1), c = ei_random(0, cols-1); VERIFY_IS_APPROX(MatrixType::ones(rows,cols)(r,c), static_cast(1)); MatrixType m1 = MatrixType::ones(rows,cols); VERIFY_IS_APPROX(m1(r,c), static_cast(1)); diff --git a/test/product.cpp b/test/product.cpp index 9bba45c48..2ee39acab 100644 --- a/test/product.cpp +++ b/test/product.cpp @@ -53,10 +53,10 @@ template void product(const MatrixType& m) v2 = VectorType::random(rows), vzero = VectorType::zero(rows); - Scalar s1 = random(); + Scalar s1 = ei_random(); - int r = random(0, rows-1), - c = random(0, cols-1); + int r = ei_random(0, rows-1), + c = ei_random(0, cols-1); // begin testing Product.h: only associativity for now // (we use Transpose.h but this doesn't count as a test for it) diff --git a/test/smallvectors.cpp b/test/smallvectors.cpp index 3496733e2..458b79ce7 100644 --- a/test/smallvectors.cpp +++ b/test/smallvectors.cpp @@ -32,10 +32,10 @@ template void smallVectors() typedef Matrix V2; typedef Matrix V3; typedef Matrix V4; - Scalar x1 = random(), - x2 = random(), - x3 = random(), - x4 = random(); + Scalar x1 = ei_random(), + x2 = ei_random(), + x3 = ei_random(), + x4 = ei_random(); V2 v2(x1, x2); V3 v3(x1, x2, x3); V4 v4(x1, x2, x3, x4); diff --git a/test/submatrices.cpp b/test/submatrices.cpp index aa189476e..633bcb302 100644 --- a/test/submatrices.cpp +++ b/test/submatrices.cpp @@ -52,12 +52,12 @@ template void submatrices(const MatrixType& m) v3 = VectorType::random(rows), vzero = VectorType::zero(rows); - Scalar s1 = random(); + Scalar s1 = ei_random(); - int r1 = random(0,rows-1); - int r2 = random(r1,rows-1); - int c1 = random(0,cols-1); - int c2 = random(c1,cols-1); + int r1 = ei_random(0,rows-1); + int r2 = ei_random(r1,rows-1); + int c1 = ei_random(0,cols-1); + int c2 = ei_random(c1,cols-1); //check row() and col() VERIFY_IS_APPROX(m1.col(c1).transpose(), m1.transpose().row(c1)); @@ -108,7 +108,7 @@ void EigenTest::testSubmatrices() // being called as a member of a class that is itself a template parameter // (at least as of g++ 4.2) Matrix m = Matrix::random(); - float s = random(); + float s = ei_random(); // test fixedBlock() as lvalue m.fixedBlock<2,5>(1,1) *= s; // test operator() on fixedBlock() both as constant and non-constant