diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2008-02-28 12:38:12 +0000 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2008-02-28 12:38:12 +0000 |
commit | 6907886a156c4b94ec7530351b271e1c1bc5b81b (patch) | |
tree | 9c9431ba83e0234e5f199031ed48915ad6365422 /Eigen/src/Core | |
parent | c67e717404258d3625a74c67f50be34939af6d95 (diff) |
prefix global functions with ei_ as previous solution was rather
fragile. also fix compilation with g++ 4.3.
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r-- | Eigen/src/Core/Conjugate.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/DiagonalMatrix.h | 6 | ||||
-rw-r--r-- | Eigen/src/Core/Dot.h | 18 | ||||
-rw-r--r-- | Eigen/src/Core/Fuzzy.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/Identity.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/MathFunctions.h | 150 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/Ones.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/Random.h | 14 | ||||
-rw-r--r-- | Eigen/src/Core/Zero.h | 2 |
10 files changed, 104 insertions, 104 deletions
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<typename MatrixType> 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<Scalar, Derived>::isDiagonal RealScalar maxAbsOnDiagonal = static_cast<RealScalar>(-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<Index-1, Size, Derived1, Derived2>::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<Scalar, Derived>::dot(const OtherDerived& other) const ::run(*static_cast<const Derived*>(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<Scalar, Derived>::dot(const OtherDerived& other) const template<typename Scalar, typename Derived> typename NumTraits<Scalar>::Real MatrixBase<Scalar, Derived>::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<Scalar>::Real MatrixBase<Scalar, Derived>::norm2() const template<typename Scalar, typename Derived> typename NumTraits<Scalar>::Real MatrixBase<Scalar, Derived>::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<Scalar, Derived>::isOrtho (const OtherDerived& other, typename NumTraits<Scalar>::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<Scalar, Derived>::isOrtho { for(int i = 0; i < cols(); i++) { - if(!Eigen::isApprox(col(i).norm2(), static_cast<Scalar>(1), prec)) + if(!ei_isApprox(col(i).norm2(), static_cast<Scalar>(1), prec)) return false; for(int j = 0; j < i; j++) - if(!Eigen::isMuchSmallerThan(col(i).dot(col(j)), static_cast<Scalar>(1), prec)) + if(!ei_isMuchSmallerThan(col(i).dot(col(j)), static_cast<Scalar>(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<typename Scalar, typename Derived> template<typename OtherDerived> @@ -82,12 +82,12 @@ bool MatrixBase<Scalar, Derived>::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<Scalar, Derived>::isIdentity { if(i == j) { - if(!Eigen::isApprox(coeff(i, j), static_cast<Scalar>(1), prec)) + if(!ei_isApprox(coeff(i, j), static_cast<Scalar>(1), prec)) return false; } else { - if(!Eigen::isMuchSmallerThan(coeff(i, j), static_cast<RealScalar>(1), prec)) + if(!ei_isMuchSmallerThan(coeff(i, j), static_cast<RealScalar>(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<typename T> inline typename NumTraits<T>::Real precision(); -template<typename T> inline T random(T a, T b); -template<typename T> inline T random(); +template<typename T> inline T ei_random(T a, T b); +template<typename T> inline T ei_random(); template<> inline int precision<int>() { 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<int>((b-a+1) * (rand() / (RAND_MAX + 1.0))); } -template<> inline int random() +template<> inline int ei_random() { - return random<int>(-10, 10); + return ei_random<int>(-10, 10); } -inline bool isMuchSmallerThan(int a, int, int = precision<int>()) +inline bool ei_isMuchSmallerThan(int a, int, int = precision<int>()) { return a == 0; } -inline bool isApprox(int a, int b, int = precision<int>()) +inline bool ei_isApprox(int a, int b, int = precision<int>()) { return a == b; } -inline bool isApproxOrLessThan(int a, int b, int = precision<int>()) +inline bool ei_isApproxOrLessThan(int a, int b, int = precision<int>()) { return a <= b; } template<> inline float precision<float>() { 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<float>(-10.0f, 10.0f); + return ei_random<float>(-10.0f, 10.0f); } -inline bool isMuchSmallerThan(float a, float b, float prec = precision<float>()) +inline bool ei_isMuchSmallerThan(float a, float b, float prec = precision<float>()) { - 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<float>()) +inline bool ei_isApprox(float a, float b, float prec = precision<float>()) { - 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<float>()) +inline bool ei_isApproxOrLessThan(float a, float b, float prec = precision<float>()) { - return a <= b || isApprox(a, b, prec); + return a <= b || ei_isApprox(a, b, prec); } template<> inline double precision<double>() { 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<double>(-10.0, 10.0); + return ei_random<double>(-10.0, 10.0); } -inline bool isMuchSmallerThan(double a, double b, double prec = precision<double>()) +inline bool ei_isMuchSmallerThan(double a, double b, double prec = precision<double>()) { - 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<double>()) +inline bool ei_isApprox(double a, double b, double prec = precision<double>()) { - 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<double>()) +inline bool ei_isApproxOrLessThan(double a, double b, double prec = precision<double>()) { - return a <= b || isApprox(a, b, prec); + return a <= b || ei_isApprox(a, b, prec); } template<> inline float precision<std::complex<float> >() { return precision<float>(); } -inline float real(const std::complex<float>& x) { return std::real(x); } -inline float imag(const std::complex<float>& x) { return std::imag(x); } -inline std::complex<float> conj(const std::complex<float>& x) { return std::conj(x); } -inline float abs(const std::complex<float>& x) { return std::abs(x); } -inline float abs2(const std::complex<float>& x) { return std::norm(x); } -inline std::complex<float> sqrt(const std::complex<float>&) +inline float ei_real(const std::complex<float>& x) { return std::real(x); } +inline float ei_imag(const std::complex<float>& x) { return std::imag(x); } +inline std::complex<float> ei_conj(const std::complex<float>& x) { return std::conj(x); } +inline float ei_abs(const std::complex<float>& x) { return std::abs(x); } +inline float ei_abs2(const std::complex<float>& x) { return std::norm(x); } +inline std::complex<float> ei_sqrt(const std::complex<float>&) { // 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<float> sqrt(const std::complex<float>&) assert(false); return 0; } -template<> inline std::complex<float> random() +template<> inline std::complex<float> ei_random() { - return std::complex<float>(random<float>(), random<float>()); + return std::complex<float>(ei_random<float>(), ei_random<float>()); } -inline bool isMuchSmallerThan(const std::complex<float>& a, const std::complex<float>& b, float prec = precision<float>()) +inline bool ei_isMuchSmallerThan(const std::complex<float>& a, const std::complex<float>& b, float prec = precision<float>()) { - return abs2(a) <= abs2(b) * prec * prec; + return ei_abs2(a) <= ei_abs2(b) * prec * prec; } -inline bool isMuchSmallerThan(const std::complex<float>& a, float b, float prec = precision<float>()) +inline bool ei_isMuchSmallerThan(const std::complex<float>& a, float b, float prec = precision<float>()) { - return abs2(a) <= abs2(b) * prec * prec; + return ei_abs2(a) <= ei_abs2(b) * prec * prec; } -inline bool isApprox(const std::complex<float>& a, const std::complex<float>& b, float prec = precision<float>()) +inline bool ei_isApprox(const std::complex<float>& a, const std::complex<float>& b, float prec = precision<float>()) { - 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<std::complex<double> >() { return precision<double>(); } -inline double real(const std::complex<double>& x) { return std::real(x); } -inline double imag(const std::complex<double>& x) { return std::imag(x); } -inline std::complex<double> conj(const std::complex<double>& x) { return std::conj(x); } -inline double abs(const std::complex<double>& x) { return std::abs(x); } -inline double abs2(const std::complex<double>& x) { return std::norm(x); } -template<> inline std::complex<double> random() +inline double ei_real(const std::complex<double>& x) { return std::real(x); } +inline double ei_imag(const std::complex<double>& x) { return std::imag(x); } +inline std::complex<double> ei_conj(const std::complex<double>& x) { return std::conj(x); } +inline double ei_abs(const std::complex<double>& x) { return std::abs(x); } +inline double ei_abs2(const std::complex<double>& x) { return std::norm(x); } +template<> inline std::complex<double> ei_random() { - return std::complex<double>(random<double>(), random<double>()); + return std::complex<double>(ei_random<double>(), ei_random<double>()); } -inline bool isMuchSmallerThan(const std::complex<double>& a, const std::complex<double>& b, double prec = precision<double>()) +inline bool ei_isMuchSmallerThan(const std::complex<double>& a, const std::complex<double>& b, double prec = precision<double>()) { - return abs2(a) <= abs2(b) * prec * prec; + return ei_abs2(a) <= ei_abs2(b) * prec * prec; } -inline bool isMuchSmallerThan(const std::complex<double>& a, double b, double prec = precision<double>()) +inline bool ei_isMuchSmallerThan(const std::complex<double>& a, double b, double prec = precision<double>()) { - return abs2(a) <= abs2(b) * prec * prec; + return ei_abs2(a) <= ei_abs2(b) * prec * prec; } -inline bool isApprox(const std::complex<double>& a, const std::complex<double>& b, double prec = precision<double>()) +inline bool ei_isApprox(const std::complex<double>& a, const std::complex<double>& b, double prec = precision<double>()) { - 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<T> operator*(U a, const std::complex<T>& 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<typename Scalar, typename Derived> 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<Scalar, Derived>::isOnes { for(int j = 0; j < cols(); j++) for(int i = 0; i < rows(); i++) - if(!Eigen::isApprox(coeff(i, j), static_cast<Scalar>(1), prec)) + if(!ei_isApprox(coeff(i, j), static_cast<Scalar>(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<typename MatrixType> class Random : NoOperatorEquals, Scalar _coeff(int, int) const { - return Eigen::random<Scalar>(); + return ei_random<Scalar>(); } public: @@ -78,13 +78,13 @@ template<typename MatrixType> 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<typename Scalar, typename Derived> const Eval<Random<Derived> > @@ -101,13 +101,13 @@ MatrixBase<Scalar, Derived>::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<typename Scalar, typename Derived> const Eval<Random<Derived> > @@ -127,7 +127,7 @@ MatrixBase<Scalar, Derived>::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<typename Scalar, typename Derived> const Eval<Random<Derived> > @@ -141,7 +141,7 @@ MatrixBase<Scalar, Derived>::random() * Example: \include MatrixBase_setRandom.cpp * Output: \verbinclude MatrixBase_setRandom.out * - * \sa class Random, random() + * \sa class Random, ei_random() */ template<typename Scalar, typename Derived> Derived& MatrixBase<Scalar, Derived>::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<Scalar, Derived>::isZero { for(int j = 0; j < cols(); j++) for(int i = 0; i < rows(); i++) - if(!Eigen::isMuchSmallerThan(coeff(i, j), static_cast<Scalar>(1), prec)) + if(!ei_isMuchSmallerThan(coeff(i, j), static_cast<Scalar>(1), prec)) return false; return true; } |