diff --git a/src/Core/Column.h b/src/Core/Column.h index feb90fa4f..942b8aaf9 100644 --- a/src/Core/Column.h +++ b/src/Core/Column.h @@ -53,15 +53,13 @@ template class Column int _rows() const { return m_matrix.rows(); } int _cols() const { return 1; } - Scalar& _write(int row, int col) + Scalar& _write(int row, int) { - EIGEN_UNUSED(col); return m_matrix.write(row, m_col); } - Scalar _read(int row, int col) const + Scalar _read(int row, int) const { - EIGEN_UNUSED(col); return m_matrix.read(row, m_col); } diff --git a/src/Core/Dot.h b/src/Core/Dot.h index 96d945c7f..cc603f4ac 100644 --- a/src/Core/Dot.h +++ b/src/Core/Dot.h @@ -48,24 +48,14 @@ struct DotUnroller<0, Size, Derived1, Derived2> template struct DotUnroller { - static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot) - { - EIGEN_UNUSED(v1); - EIGEN_UNUSED(v2); - EIGEN_UNUSED(dot); - } + static void run(const Derived1&, const Derived2&, typename Derived1::Scalar&) {} }; // prevent buggy user code from causing an infinite recursion template struct DotUnroller { - static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot) - { - EIGEN_UNUSED(v1); - EIGEN_UNUSED(v2); - EIGEN_UNUSED(dot); - } + static void run(const Derived1&, const Derived2&, typename Derived1::Scalar&) {} }; template diff --git a/src/Core/MatrixStorage.h b/src/Core/MatrixStorage.h index 3fa50eebe..314183a2a 100644 --- a/src/Core/MatrixStorage.h +++ b/src/Core/MatrixStorage.h @@ -50,13 +50,9 @@ class MatrixStorage public: MatrixStorage() {} - MatrixStorage(int dim) { EIGEN_UNUSED(dim); } + MatrixStorage(int) {} - MatrixStorage(int rows, int cols) - { - EIGEN_UNUSED(rows); - EIGEN_UNUSED(cols); - } + MatrixStorage(int, int) {} ~MatrixStorage() {}; }; @@ -92,9 +88,8 @@ class MatrixStorage m_array = new Scalar[m_rows * ColsAtCompileTime]; } - MatrixStorage(int rows, int cols) : m_rows(rows) + MatrixStorage(int rows, int) : m_rows(rows) { - EIGEN_UNUSED(cols); m_array = new Scalar[m_rows * ColsAtCompileTime]; } @@ -136,9 +131,8 @@ class MatrixStorage m_array = new Scalar[m_cols * RowsAtCompileTime]; } - MatrixStorage(int rows, int cols) : m_cols(cols) + MatrixStorage(int, int cols) : m_cols(cols) { - EIGEN_UNUSED(rows); m_array = new Scalar[m_cols * RowsAtCompileTime]; } diff --git a/src/Core/NumTraits.h b/src/Core/NumTraits.h index 2c0040397..54e357fbc 100644 --- a/src/Core/NumTraits.h +++ b/src/Core/NumTraits.h @@ -57,25 +57,24 @@ template struct NumTraits > }; template inline typename NumTraits::Real precision(); -template inline T random(const T& a, const T& b); +template inline T random(T a, T b); template inline T random(); template<> inline int precision() { return 0; } -inline int real(const int& x) { return x; } -inline int imag(const int& x) { EIGEN_UNUSED(x); return 0; } -inline int conj(const int& x) { return x; } -inline int abs(const int& x) { return std::abs(x); } -inline int abs2(const int& x) { return x*x; } -inline int sqrt(const int& x) +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) { - EIGEN_UNUSED(x); // Taking the square root of integers is not allowed // (the square root does not always exist within the integers). // Please cast to a floating-point type. assert(false); return 0; } -template<> inline int random(const int& a, const int& b) +template<> inline int 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))); @@ -87,31 +86,27 @@ template<> inline int random() // as well, so there's no problem. return random(-10, 10); } -inline bool isMuchSmallerThan(const int& a, const int& b, const int& prec = precision()) +inline bool isMuchSmallerThan(int a, int, int = precision()) { - EIGEN_UNUSED(b); - EIGEN_UNUSED(prec); return a == 0; } -inline bool isApprox(const int& a, const int& b, const int& prec = precision()) +inline bool isApprox(int a, int b, int = precision()) { - EIGEN_UNUSED(prec); return a == b; } -inline bool isApproxOrLessThan(const int& a, const int& b, const int& prec = precision()) +inline bool isApproxOrLessThan(int a, int b, int = precision()) { - EIGEN_UNUSED(prec); return a <= b; } template<> inline float precision() { return 1e-5f; } -inline float real(const float& x) { return x; } -inline float imag(const float& x) { EIGEN_UNUSED(x); return 0.f; } -inline float conj(const float& x) { return x; } -inline float abs(const float& x) { return std::abs(x); } -inline float abs2(const float& x) { return x*x; } -inline float sqrt(const float& x) { return std::sqrt(x); } -template<> inline float random(const float& a, const float& b) +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) { return a + (b-a) * std::rand() / RAND_MAX; } @@ -119,27 +114,27 @@ template<> inline float random() { return random(-10.0f, 10.0f); } -inline bool isMuchSmallerThan(const float& a, const float& b, const float& prec = precision()) +inline bool isMuchSmallerThan(float a, float b, float prec = precision()) { return std::abs(a) <= std::abs(b) * prec; } -inline bool isApprox(const float& a, const float& b, const float& prec = precision()) +inline bool isApprox(float a, float b, float prec = precision()) { return std::abs(a - b) <= std::min(std::abs(a), std::abs(b)) * prec; } -inline bool isApproxOrLessThan(const float& a, const float& b, const float& prec = precision()) +inline bool isApproxOrLessThan(float a, float b, float prec = precision()) { return a <= b || isApprox(a, b, prec); } template<> inline double precision() { return 1e-11; } -inline double real(const double& x) { return x; } -inline double imag(const double& x) { EIGEN_UNUSED(x); return 0.; } -inline double conj(const double& x) { return x; } -inline double abs(const double& x) { return std::abs(x); } -inline double abs2(const double& x) { return x*x; } -inline double sqrt(const double& x) { return std::sqrt(x); } -template<> inline double random(const double& a, const double& b) +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) { return a + (b-a) * std::rand() / RAND_MAX; } @@ -147,15 +142,15 @@ template<> inline double random() { return random(-10.0, 10.0); } -inline bool isMuchSmallerThan(const double& a, const double& b, const double& prec = precision()) +inline bool isMuchSmallerThan(double a, double b, double prec = precision()) { return std::abs(a) <= std::abs(b) * prec; } -inline bool isApprox(const double& a, const double& b, const double& prec = precision()) +inline bool isApprox(double a, double b, double prec = precision()) { return std::abs(a - b) <= std::min(std::abs(a), std::abs(b)) * prec; } -inline bool isApproxOrLessThan(const double& a, const double& b, const double& prec = precision()) +inline bool isApproxOrLessThan(double a, double b, double prec = precision()) { return a <= b || isApprox(a, b, prec); } @@ -166,9 +161,8 @@ 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& x) +inline std::complex sqrt(const std::complex&) { - EIGEN_UNUSED(x); // Taking the square roots of complex numbers is not allowed, // as this is ambiguous (there are two square roots). // What were you trying to do? @@ -179,11 +173,11 @@ template<> inline std::complex random() { return std::complex(random(), random()); } -inline bool isMuchSmallerThan(const std::complex& a, const std::complex& b, const float& prec = precision()) +inline bool isMuchSmallerThan(const std::complex& a, const std::complex& b, float prec = precision()) { return abs2(a) <= abs2(b) * prec * prec; } -inline bool isApprox(const std::complex& a, const std::complex& b, const float& prec = precision()) +inline bool 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); @@ -200,11 +194,11 @@ template<> inline std::complex random() { return std::complex(random(), random()); } -inline bool isMuchSmallerThan(const std::complex& a, const std::complex& b, const double& prec = precision()) +inline bool isMuchSmallerThan(const std::complex& a, const std::complex& b, double prec = precision()) { return abs2(a) <= abs2(b) * prec * prec; } -inline bool isApprox(const std::complex& a, const std::complex& b, const double& prec = precision()) +inline bool 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); diff --git a/src/Core/OperatorEquals.h b/src/Core/OperatorEquals.h index 11075b9b4..bbf55b8f1 100644 --- a/src/Core/OperatorEquals.h +++ b/src/Core/OperatorEquals.h @@ -44,11 +44,7 @@ struct OperatorEqualsUnroller template struct OperatorEqualsUnroller { - static void run(Derived1 &dst, const Derived2 &src) - { - EIGEN_UNUSED(dst); - EIGEN_UNUSED(src); - } + static void run(Derived1 &, const Derived2 &) {} }; template @@ -63,11 +59,7 @@ struct OperatorEqualsUnroller template struct OperatorEqualsUnroller { - static void run(Derived1 &dst, const Derived2 &src) - { - EIGEN_UNUSED(dst); - EIGEN_UNUSED(src); - } + static void run(Derived1 &, const Derived2 &) {} }; template diff --git a/src/Core/Product.h b/src/Core/Product.h index b4acfa2c3..0d76ef2c5 100644 --- a/src/Core/Product.h +++ b/src/Core/Product.h @@ -50,30 +50,14 @@ struct ProductUnroller<0, Size, Lhs, Rhs> template struct ProductUnroller { - static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, - typename Lhs::Scalar &res) - { - EIGEN_UNUSED(row); - EIGEN_UNUSED(col); - EIGEN_UNUSED(lhs); - EIGEN_UNUSED(rhs); - EIGEN_UNUSED(res); - } + static void run(int, int, const Lhs&, const Rhs&, typename Lhs::Scalar&) {} }; // prevent buggy user code from causing an infinite recursion template struct ProductUnroller { - static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, - typename Lhs::Scalar &res) - { - EIGEN_UNUSED(row); - EIGEN_UNUSED(col); - EIGEN_UNUSED(lhs); - EIGEN_UNUSED(rhs); - EIGEN_UNUSED(res); - } + static void run(int, int, const Lhs&, const Rhs&, typename Lhs::Scalar&) {} }; template class Product diff --git a/src/Core/Random.h b/src/Core/Random.h index a7e1d0f80..62012998d 100644 --- a/src/Core/Random.h +++ b/src/Core/Random.h @@ -49,10 +49,8 @@ template class Random int _rows() const { return m_rows; } int _cols() const { return m_cols; } - Scalar _read(int row, int col) const + Scalar _read(int, int) const { - EIGEN_UNUSED(row); - EIGEN_UNUSED(col); return random(); } diff --git a/src/Core/Row.h b/src/Core/Row.h index fc0e2b18e..6da721693 100644 --- a/src/Core/Row.h +++ b/src/Core/Row.h @@ -60,15 +60,13 @@ template class Row int _rows() const { return 1; } int _cols() const { return m_matrix.cols(); } - Scalar& _write(int row, int col) + Scalar& _write(int, int col) { - EIGEN_UNUSED(row); return m_matrix.write(m_row, col); } - Scalar _read(int row, int col) const + Scalar _read(int, int col) const { - EIGEN_UNUSED(row); return m_matrix.read(m_row, col); } diff --git a/src/Core/Trace.h b/src/Core/Trace.h index 16926bedc..e6af33247 100644 --- a/src/Core/Trace.h +++ b/src/Core/Trace.h @@ -45,21 +45,13 @@ template struct TraceUnroller<0, Rows, Derived> template struct TraceUnroller { - static void run(const Derived &mat, typename Derived::Scalar &trace) - { - EIGEN_UNUSED(mat); - EIGEN_UNUSED(trace); - } + static void run(const Derived&, typename Derived::Scalar&) {} }; // prevent buggy user code from causing an infinite recursion template struct TraceUnroller { - static void run(const Derived &mat, typename Derived::Scalar &trace) - { - EIGEN_UNUSED(mat); - EIGEN_UNUSED(trace); - } + static void run(const Derived&, typename Derived::Scalar&) {} }; template diff --git a/src/Core/Util.h b/src/Core/Util.h index e55192ba1..59db711a0 100644 --- a/src/Core/Util.h +++ b/src/Core/Util.h @@ -46,10 +46,8 @@ using Eigen::Matrix; #define eigen_assert(assertLevel, x) if(assertLevel <= EIGEN_ASSERT_LEVEL) assert(x); -#define EIGEN_UNUSED(x) (void)x - #ifdef NDEBUG -#define EIGEN_ONLY_USED_FOR_DEBUG(x) EIGEN_UNUSED(x) +#define EIGEN_ONLY_USED_FOR_DEBUG(x) (void)x #else #define EIGEN_ONLY_USED_FOR_DEBUG(x) #endif diff --git a/src/Core/Zero.h b/src/Core/Zero.h index 12168a4ba..3cea75a68 100644 --- a/src/Core/Zero.h +++ b/src/Core/Zero.h @@ -49,10 +49,8 @@ template class Zero int _rows() const { return m_rows; } int _cols() const { return m_cols; } - Scalar _read(int row, int col) const + Scalar _read(int, int) const { - EIGEN_UNUSED(row); - EIGEN_UNUSED(col); return static_cast(0); }