aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2007-12-11 15:25:43 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2007-12-11 15:25:43 +0000
commitfa8009c6b726e402baec20543abadbac540482f9 (patch)
tree1523ef0ad8dcf67eb39976e584e0c1ec381b7d2f
parent0cbdaf6bb8cd2565997f75a0804972b1e9ffb520 (diff)
1) remove EIGEN_UNUSED, instead use non-named arguments.
2) use T instead of const T& when that makes more sense Thanks to Christian Mayer a.k.a Mekhzolan for the tips.
-rw-r--r--src/Core/Column.h6
-rw-r--r--src/Core/Dot.h14
-rw-r--r--src/Core/MatrixStorage.h14
-rw-r--r--src/Core/NumTraits.h80
-rw-r--r--src/Core/OperatorEquals.h12
-rw-r--r--src/Core/Product.h20
-rw-r--r--src/Core/Random.h4
-rw-r--r--src/Core/Row.h6
-rw-r--r--src/Core/Trace.h12
-rw-r--r--src/Core/Util.h4
-rw-r--r--src/Core/Zero.h4
11 files changed, 56 insertions, 120 deletions
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<typename MatrixType> 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<int Index, typename Derived1, typename Derived2>
struct DotUnroller<Index, Dynamic, Derived1, Derived2>
{
- 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<int Index, typename Derived1, typename Derived2>
struct DotUnroller<Index, 0, Derived1, Derived2>
{
- 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<typename Scalar, typename Derived>
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<Scalar, Dynamic, ColsAtCompileTime>
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<Scalar, RowsAtCompileTime, Dynamic>
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<typename _Real> struct NumTraits<std::complex<_Real> >
};
template<typename T> inline typename NumTraits<T>::Real precision();
-template<typename T> inline T random(const T& a, const T& b);
+template<typename T> inline T random(T a, T b);
template<typename T> inline T random();
template<> inline int precision<int>() { 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)
-{
- EIGEN_UNUSED(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)
+{
// 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<int>((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<int>(-10, 10);
}
-inline bool isMuchSmallerThan(const int& a, const int& b, const int& prec = precision<int>())
+inline bool isMuchSmallerThan(int a, int, int = precision<int>())
{
- EIGEN_UNUSED(b);
- EIGEN_UNUSED(prec);
return a == 0;
}
-inline bool isApprox(const int& a, const int& b, const int& prec = precision<int>())
+inline bool isApprox(int a, int b, int = precision<int>())
{
- EIGEN_UNUSED(prec);
return a == b;
}
-inline bool isApproxOrLessThan(const int& a, const int& b, const int& prec = precision<int>())
+inline bool isApproxOrLessThan(int a, int b, int = precision<int>())
{
- EIGEN_UNUSED(prec);
return a <= b;
}
template<> inline float precision<float>() { 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<float>(-10.0f, 10.0f);
}
-inline bool isMuchSmallerThan(const float& a, const float& b, const float& prec = precision<float>())
+inline bool isMuchSmallerThan(float a, float b, float prec = precision<float>())
{
return std::abs(a) <= std::abs(b) * prec;
}
-inline bool isApprox(const float& a, const float& b, const float& prec = precision<float>())
+inline bool isApprox(float a, float b, float prec = precision<float>())
{
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<float>())
+inline bool isApproxOrLessThan(float a, float b, float prec = precision<float>())
{
return a <= b || isApprox(a, b, prec);
}
template<> inline double precision<double>() { 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<double>(-10.0, 10.0);
}
-inline bool isMuchSmallerThan(const double& a, const double& b, const double& prec = precision<double>())
+inline bool isMuchSmallerThan(double a, double b, double prec = precision<double>())
{
return std::abs(a) <= std::abs(b) * prec;
}
-inline bool isApprox(const double& a, const double& b, const double& prec = precision<double>())
+inline bool isApprox(double a, double b, double prec = precision<double>())
{
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<double>())
+inline bool isApproxOrLessThan(double a, double b, double prec = precision<double>())
{
return a <= b || isApprox(a, b, prec);
}
@@ -166,9 +161,8 @@ 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>& x)
+inline std::complex<float> sqrt(const std::complex<float>&)
{
- 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<float> random()
{
return std::complex<float>(random<float>(), random<float>());
}
-inline bool isMuchSmallerThan(const std::complex<float>& a, const std::complex<float>& b, const float& prec = precision<float>())
+inline bool isMuchSmallerThan(const std::complex<float>& a, const std::complex<float>& b, float prec = precision<float>())
{
return abs2(a) <= abs2(b) * prec * prec;
}
-inline bool isApprox(const std::complex<float>& a, const std::complex<float>& b, const float& prec = precision<float>())
+inline bool 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);
@@ -200,11 +194,11 @@ template<> inline std::complex<double> random()
{
return std::complex<double>(random<double>(), random<double>());
}
-inline bool isMuchSmallerThan(const std::complex<double>& a, const std::complex<double>& b, const double& prec = precision<double>())
+inline bool isMuchSmallerThan(const std::complex<double>& a, const std::complex<double>& b, double prec = precision<double>())
{
return abs2(a) <= abs2(b) * prec * prec;
}
-inline bool isApprox(const std::complex<double>& a, const std::complex<double>& b, const double& prec = precision<double>())
+inline bool 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);
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<typename Derived1, typename Derived2, int UnrollCount>
struct OperatorEqualsUnroller<Derived1, Derived2, UnrollCount, 0>
{
- static void run(Derived1 &dst, const Derived2 &src)
- {
- EIGEN_UNUSED(dst);
- EIGEN_UNUSED(src);
- }
+ static void run(Derived1 &, const Derived2 &) {}
};
template<typename Derived1, typename Derived2, int Rows>
@@ -63,11 +59,7 @@ struct OperatorEqualsUnroller<Derived1, Derived2, 1, Rows>
template<typename Derived1, typename Derived2, int Rows>
struct OperatorEqualsUnroller<Derived1, Derived2, Dynamic, Rows>
{
- static void run(Derived1 &dst, const Derived2 &src)
- {
- EIGEN_UNUSED(dst);
- EIGEN_UNUSED(src);
- }
+ static void run(Derived1 &, const Derived2 &) {}
};
template<typename Scalar, typename Derived>
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<int Index, typename Lhs, typename Rhs>
struct ProductUnroller<Index, Dynamic, Lhs, Rhs>
{
- 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<int Index, typename Lhs, typename Rhs>
struct ProductUnroller<Index, 0, Lhs, Rhs>
{
- 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<typename Lhs, typename Rhs> 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<typename MatrixType> 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<Scalar>();
}
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<typename MatrixType> 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<int Rows, typename Derived> struct TraceUnroller<0, Rows, Derived>
template<int Index, typename Derived> struct TraceUnroller<Index, Dynamic, Derived>
{
- 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<int Index, typename Derived> struct TraceUnroller<Index, 0, Derived>
{
- 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<typename Scalar, typename Derived>
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<typename MatrixType> 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<Scalar>(0);
}