From 729618c945aaf5183316abd1badc4921cecd86f1 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 26 Mar 2008 08:48:04 +0000 Subject: * #define EIGEN_NDEBUG now also disables asserts. Useful to disable eigen's asserts without disabling one's own program's asserts. Notice that Eigen code should now use ei_assert() instead of assert(). * Remove findBiggestCoeff() as it's now almost redundant. * Improve echelon.cpp: inner for loop replaced by xprs. * remove useless "(*this)." here and there. I think they were first introduced by automatic search&replace. * fix compilation in Visitor.h (issue triggered by echelon.cpp) * improve comment on swap(). --- Eigen/src/Core/Block.h | 22 +++++++++++----------- Eigen/src/Core/Coeffs.h | 32 ++++++++++++++++---------------- Eigen/src/Core/CommaInitializer.h | 14 +++++++------- Eigen/src/Core/CwiseBinaryOp.h | 2 +- Eigen/src/Core/DiagonalMatrix.h | 2 +- Eigen/src/Core/Dot.h | 2 +- Eigen/src/Core/Fuzzy.h | 4 ++-- Eigen/src/Core/Identity.h | 2 +- Eigen/src/Core/Map.h | 6 +++--- Eigen/src/Core/MathFunctions.h | 10 +++++----- Eigen/src/Core/Matrix.h | 22 +++++++++++----------- Eigen/src/Core/MatrixBase.h | 13 ------------- Eigen/src/Core/Minor.h | 2 +- Eigen/src/Core/Ones.h | 4 ++-- Eigen/src/Core/OperatorEquals.h | 6 +++--- Eigen/src/Core/Product.h | 6 +++--- Eigen/src/Core/Random.h | 4 ++-- Eigen/src/Core/Swap.h | 11 ++++++++++- Eigen/src/Core/Util.h | 10 ++++++++-- Eigen/src/Core/Visitor.h | 5 ++--- Eigen/src/Core/Zero.h | 4 ++-- 21 files changed, 92 insertions(+), 91 deletions(-) (limited to 'Eigen') diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index c83cdc0de..6d39efe7e 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -90,7 +90,7 @@ template class Block m_blockRows(matrix.rows()), // if it is a row, then m_blockRows has a fixed-size of 1, so no pb to try to overwrite it m_blockCols(matrix.cols()) // same for m_blockCols { - assert( (i>=0) && ( + ei_assert( (i>=0) && ( ((BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) && i class Block Block(const MatrixType& matrix, int startRow, int startCol) : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol) { - assert(RowsAtCompileTime!=Dynamic && RowsAtCompileTime!=Dynamic); - assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= matrix.rows() + ei_assert(RowsAtCompileTime!=Dynamic && RowsAtCompileTime!=Dynamic); + ei_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= matrix.rows() && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= matrix.cols()); } @@ -113,9 +113,9 @@ template class Block : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol), m_blockRows(blockRows), m_blockCols(blockCols) { - assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==1) + ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==1) && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==1)); - assert(startRow >= 0 && blockRows >= 1 && startRow + blockRows <= matrix.rows() + ei_assert(startRow >= 0 && blockRows >= 1 && startRow + blockRows <= matrix.rows() && startCol >= 0 && blockCols >= 1 && startCol + blockCols <= matrix.cols()); } @@ -197,7 +197,7 @@ template Block MatrixBase ::block(int start, int size) { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); return Block(derived(), RowsAtCompileTime == 1 ? 0 : start, ColsAtCompileTime == 1 ? 0 : start, RowsAtCompileTime == 1 ? 1 : size, @@ -209,7 +209,7 @@ template const Block MatrixBase ::block(int start, int size) const { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); return Block(derived(), RowsAtCompileTime == 1 ? 0 : start, ColsAtCompileTime == 1 ? 0 : start, RowsAtCompileTime == 1 ? 1 : size, @@ -235,7 +235,7 @@ template Block MatrixBase ::start(int size) { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); return Block(derived(), 0, 0, RowsAtCompileTime == 1 ? 1 : size, ColsAtCompileTime == 1 ? 1 : size); @@ -246,7 +246,7 @@ template const Block MatrixBase ::start(int size) const { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); return Block(derived(), 0, 0, RowsAtCompileTime == 1 ? 1 : size, ColsAtCompileTime == 1 ? 1 : size); @@ -271,7 +271,7 @@ template Block MatrixBase ::end(int size) { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); return Block(derived(), RowsAtCompileTime == 1 ? 0 : rows() - size, ColsAtCompileTime == 1 ? 0 : cols() - size, @@ -284,7 +284,7 @@ template const Block MatrixBase ::end(int size) const { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); return Block(derived(), RowsAtCompileTime == 1 ? 0 : rows() - size, ColsAtCompileTime == 1 ? 0 : cols() - size, diff --git a/Eigen/src/Core/Coeffs.h b/Eigen/src/Core/Coeffs.h index 905093f7b..d0b211314 100644 --- a/Eigen/src/Core/Coeffs.h +++ b/Eigen/src/Core/Coeffs.h @@ -43,7 +43,7 @@ template typename ei_traits::Scalar MatrixBase ::coeff(int row, int col) const { - eigen_internal_assert(row >= 0 && row < rows() + ei_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return derived()._coeff(row, col); } @@ -56,7 +56,7 @@ template typename ei_traits::Scalar MatrixBase ::operator()(int row, int col) const { - assert(row >= 0 && row < rows() + ei_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return derived()._coeff(row, col); } @@ -79,7 +79,7 @@ template typename ei_traits::Scalar& MatrixBase ::coeffRef(int row, int col) { - eigen_internal_assert(row >= 0 && row < rows() + ei_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return derived()._coeffRef(row, col); } @@ -92,7 +92,7 @@ template typename ei_traits::Scalar& MatrixBase ::operator()(int row, int col) { - assert(row >= 0 && row < rows() + ei_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return derived()._coeffRef(row, col); } @@ -115,15 +115,15 @@ template typename ei_traits::Scalar MatrixBase ::coeff(int index) const { - eigen_internal_assert(IsVectorAtCompileTime); + ei_internal_assert(IsVectorAtCompileTime); if(RowsAtCompileTime == 1) { - eigen_internal_assert(index >= 0 && index < cols()); + ei_internal_assert(index >= 0 && index < cols()); return coeff(0, index); } else { - eigen_internal_assert(index >= 0 && index < rows()); + ei_internal_assert(index >= 0 && index < rows()); return coeff(index, 0); } } @@ -139,15 +139,15 @@ template typename ei_traits::Scalar MatrixBase ::operator[](int index) const { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); if(RowsAtCompileTime == 1) { - assert(index >= 0 && index < cols()); + ei_assert(index >= 0 && index < cols()); return coeff(0, index); } else { - assert(index >= 0 && index < rows()); + ei_assert(index >= 0 && index < rows()); return coeff(index, 0); } } @@ -170,15 +170,15 @@ template typename ei_traits::Scalar& MatrixBase ::coeffRef(int index) { - eigen_internal_assert(IsVectorAtCompileTime); + ei_internal_assert(IsVectorAtCompileTime); if(RowsAtCompileTime == 1) { - eigen_internal_assert(index >= 0 && index < cols()); + ei_internal_assert(index >= 0 && index < cols()); return coeffRef(0, index); } else { - eigen_internal_assert(index >= 0 && index < rows()); + ei_internal_assert(index >= 0 && index < rows()); return coeffRef(index, 0); } } @@ -193,15 +193,15 @@ template typename ei_traits::Scalar& MatrixBase ::operator[](int index) { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); if(RowsAtCompileTime == 1) { - assert(index >= 0 && index < cols()); + ei_assert(index >= 0 && index < cols()); return coeffRef(0, index); } else { - assert(index >= 0 && index < rows()); + ei_assert(index >= 0 && index < rows()); return coeffRef(index, 0); } } diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h index c7a292437..656ee3002 100644 --- a/Eigen/src/Core/CommaInitializer.h +++ b/Eigen/src/Core/CommaInitializer.h @@ -52,12 +52,12 @@ struct MatrixBase::CommaInitializer m_row+=m_currentBlockRows; m_col = 0; m_currentBlockRows = 1; - assert(m_row::CommaInitializer m_row+=m_currentBlockRows; m_col = 0; m_currentBlockRows = other.rows(); - assert(m_row+m_currentBlockRows<=m_matrix.rows() + ei_assert(m_row+m_currentBlockRows<=m_matrix.rows() && "Too many rows passed to MatrixBase::operator<<"); } - assert(m_col0 && OtherDerived::ColsAtCompileTime>0) m_matrix.block< (OtherDerived::RowsAtCompileTime>0?OtherDerived::RowsAtCompileTime:1) , (OtherDerived::ColsAtCompileTime>0?OtherDerived::ColsAtCompileTime:1) >(m_row, m_col) = other; @@ -87,7 +87,7 @@ struct MatrixBase::CommaInitializer ~CommaInitializer(void) { - assert((m_row+m_currentBlockRows) == m_matrix.rows() + ei_assert((m_row+m_currentBlockRows) == m_matrix.rows() && m_col == m_matrix.cols() && "Too few coefficients passed to Matrix::operator<<"); } diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index 1ab759241..ff7e8661c 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -74,7 +74,7 @@ class CwiseBinaryOp : ei_no_assignment_operator, CwiseBinaryOp(const Lhs& lhs, const Rhs& rhs, const BinaryOp& func = BinaryOp()) : m_lhs(lhs), m_rhs(rhs), m_functor(func) { - assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols()); + ei_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols()); } private: diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 79fa562d9..36d2c656b 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -60,7 +60,7 @@ class DiagonalMatrix : ei_no_assignment_operator, DiagonalMatrix(const CoeffsVectorType& coeffs) : m_coeffs(coeffs) { - assert(CoeffsVectorType::IsVectorAtCompileTime + ei_assert(CoeffsVectorType::IsVectorAtCompileTime && coeffs.size() > 0); } diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index 33f69f987..248fbca79 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -72,7 +72,7 @@ template typename ei_traits::Scalar MatrixBase::dot(const MatrixBase& other) const { - assert(IsVectorAtCompileTime + ei_assert(IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime && size() == other.size()); Scalar res; diff --git a/Eigen/src/Core/Fuzzy.h b/Eigen/src/Core/Fuzzy.h index 0f601a8f5..4ebe9d2a7 100644 --- a/Eigen/src/Core/Fuzzy.h +++ b/Eigen/src/Core/Fuzzy.h @@ -48,7 +48,7 @@ bool MatrixBase::isApprox( typename NumTraits::Real prec ) const { - assert(rows() == other.rows() && cols() == other.cols()); + ei_assert(rows() == other.rows() && cols() == other.cols()); if(IsVectorAtCompileTime) { return((*this - other).norm2() <= std::min(norm2(), other.norm2()) * prec * prec); @@ -109,7 +109,7 @@ bool MatrixBase::isMuchSmallerThan( typename NumTraits::Real prec ) const { - assert(rows() == other.rows() && cols() == other.cols()); + ei_assert(rows() == other.rows() && cols() == other.cols()); if(IsVectorAtCompileTime) { return(norm2() <= other.norm2() * prec * prec); diff --git a/Eigen/src/Core/Identity.h b/Eigen/src/Core/Identity.h index 129786e4b..0b39a4274 100644 --- a/Eigen/src/Core/Identity.h +++ b/Eigen/src/Core/Identity.h @@ -52,7 +52,7 @@ template class Identity : ei_no_assignment_operator, Identity(int rows, int cols) : m_rows(rows), m_cols(cols) { - assert(rows > 0 + ei_assert(rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index d0f9cd940..5d08ef542 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -81,7 +81,7 @@ template class Map public: Map(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols) { - assert(rows > 0 + ei_assert(rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); @@ -107,7 +107,7 @@ template > Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(const Scalar* data, int size) { - assert(_Cols == 1 || _Rows ==1); + ei_assert(_Cols == 1 || _Rows ==1); if(_Cols == 1) return Map(data, size, 1); else @@ -156,7 +156,7 @@ template > Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(Scalar* data, int size) { - assert(_Cols == 1 || _Rows ==1); + ei_assert(_Cols == 1 || _Rows ==1); if(_Cols == 1) return Map(data, size, 1); else diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index a1a54cc38..df30c5ad4 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -35,11 +35,11 @@ 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) { assert(false); return 0; } -inline int ei_exp(int) { assert(false); return 0; } -inline int ei_log(int) { assert(false); return 0; } -inline int ei_sin(int) { assert(false); return 0; } -inline int ei_cos(int) { assert(false); return 0; } +inline int ei_sqrt(int) { ei_assert(false); return 0; } +inline int ei_exp(int) { ei_assert(false); return 0; } +inline int ei_log(int) { ei_assert(false); return 0; } +inline int ei_sin(int) { ei_assert(false); return 0; } +inline int ei_cos(int) { ei_assert(false); return 0; } #if (defined __ICC) || (defined __GNUC__ && (__GNUC__<4 || __GNUC_MINOR__<3)) inline int ei_pow(int x, int y) { return int(std::pow(double(x), y)); } #else diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 9452906d0..60365f625 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -131,7 +131,7 @@ class Matrix : public MatrixBase 0 + ei_assert(rows > 0 && (MaxRowsAtCompileTime == Dynamic || MaxRowsAtCompileTime >= rows) && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols > 0 @@ -153,12 +153,12 @@ class Matrix : public MatrixBase 0 && ColsAtCompileTime > 0); + ei_assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0); } /** Constructs a vector or row-vector with given dimension. \only_for_vectors @@ -202,8 +202,8 @@ class Matrix : public MatrixBase 0); - assert((RowsAtCompileTime == 1 + ei_assert(dim > 0); + ei_assert((RowsAtCompileTime == 1 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == dim)) || (ColsAtCompileTime == 1 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == dim))); @@ -229,14 +229,14 @@ class Matrix : public MatrixBase 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == x) + ei_assert(x > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == x) && y > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == y)); } } /** constructs an initialized 2D vector with given coefficients */ Matrix(const float& x, const float& y) { - assert((RowsAtCompileTime == 1 && ColsAtCompileTime == 2) + ei_assert((RowsAtCompileTime == 1 && ColsAtCompileTime == 2) || (RowsAtCompileTime == 2 && ColsAtCompileTime == 1)); m_storage.data()[0] = x; m_storage.data()[1] = y; @@ -244,7 +244,7 @@ class Matrix : public MatrixBase class MatrixBase RealScalar prec = precision()) const; bool isOrtho(RealScalar prec = precision()) const; - /** puts in *row and *col the location of the coefficient of *this - * which has the biggest absolute value. - */ - void findBiggestCoeff(int *row, int *col) const - { (*this).cwiseAbs().maxCoeff(row, col); } - //@} - /// \name Special functions //@{ template @@ -358,12 +351,6 @@ template class MatrixBase const Eval eval() const EIGEN_ALWAYS_INLINE; const EvalOMP evalOMP() const EIGEN_ALWAYS_INLINE; - /** swaps *this with the expression \a other. - * - * \note \a other is only marked const because I couln't find another way - * to get g++ 4.2 to accept that template parameter resolution. It gets const_cast'd - * of course. TODO: get rid of const here. - */ template void swap(const MatrixBase& other); //@} diff --git a/Eigen/src/Core/Minor.h b/Eigen/src/Core/Minor.h index 6c755bb74..3897c8bac 100644 --- a/Eigen/src/Core/Minor.h +++ b/Eigen/src/Core/Minor.h @@ -64,7 +64,7 @@ template class Minor int row, int col) : m_matrix(matrix), m_row(row), m_col(col) { - assert(row >= 0 && row < matrix.rows() + ei_assert(row >= 0 && row < matrix.rows() && col >= 0 && col < matrix.cols()); } diff --git a/Eigen/src/Core/Ones.h b/Eigen/src/Core/Ones.h index 15ecc04e0..0d0f002bd 100644 --- a/Eigen/src/Core/Ones.h +++ b/Eigen/src/Core/Ones.h @@ -64,7 +64,7 @@ template class Ones : ei_no_assignment_operator, public: Ones(int rows, int cols) : m_rows(rows), m_cols(cols) { - assert(rows > 0 + ei_assert(rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); @@ -114,7 +114,7 @@ const Ones MatrixBase::ones(int rows, int cols) template const Ones MatrixBase::ones(int size) { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); if(RowsAtCompileTime == 1) return Ones(1, size); else return Ones(size, 1); } diff --git a/Eigen/src/Core/OperatorEquals.h b/Eigen/src/Core/OperatorEquals.h index 82ef13ead..babd51776 100644 --- a/Eigen/src/Core/OperatorEquals.h +++ b/Eigen/src/Core/OperatorEquals.h @@ -105,7 +105,7 @@ Derived& MatrixBase if(IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime) // copying a vector expression into a vector { - assert(size() == other.size()); + ei_assert(size() == other.size()); if(EIGEN_UNROLLED_LOOPS && SizeAtCompileTime != Dynamic && SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT) @@ -120,7 +120,7 @@ Derived& MatrixBase } else // copying a matrix expression into a matrix { - assert(rows() == other.rows() && cols() == other.cols()); + ei_assert(rows() == other.rows() && cols() == other.cols()); if(EIGEN_UNROLLED_LOOPS && SizeAtCompileTime != Dynamic && SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT) @@ -148,7 +148,7 @@ Derived& MatrixBase coeffRef(i, j) = other.coeff(i, j); } } - return (*this).derived(); + return derived(); } } diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 28602d8a0..13a995ad0 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -106,7 +106,7 @@ template class Product : ei_no_assignm Product(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) { - assert(lhs.cols() == rhs.rows()); + ei_assert(lhs.cols() == rhs.rows()); } /** \internal */ @@ -172,7 +172,7 @@ template const Eval > MatrixBase::operator*(const MatrixBase &other) const { - return (*this).lazyProduct(other).eval(); + return lazyProduct(other).eval(); } /** replaces \c *this by \c *this * \a other. @@ -192,7 +192,7 @@ template Derived& MatrixBase::operator=(const Product& product) { product._cacheOptimalEval(*this); - return (*this).derived(); + return derived(); } template diff --git a/Eigen/src/Core/Random.h b/Eigen/src/Core/Random.h index 188f7513a..f756c9649 100644 --- a/Eigen/src/Core/Random.h +++ b/Eigen/src/Core/Random.h @@ -65,7 +65,7 @@ template class Random : ei_no_assignment_operator, Random(int rows, int cols) : m_rows(rows), m_cols(cols) { - assert(rows > 0 + ei_assert(rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); @@ -117,7 +117,7 @@ template const Eval > MatrixBase::random(int size) { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); if(RowsAtCompileTime == 1) return Random(1, size).eval(); else return Random(size, 1).eval(); } diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h index 5bd16530e..db096e6f2 100644 --- a/Eigen/src/Core/Swap.h +++ b/Eigen/src/Core/Swap.h @@ -25,6 +25,15 @@ #ifndef EIGEN_SWAP_H #define EIGEN_SWAP_H +/** swaps *this with the expression \a other. + * + * \note \a other is only marked const because I couln't find another way + * to get g++ (4.2 and 4.3) to accept that template parameter resolution. + * The problem seems to be that when swapping expressions as in + * m.row(i).swap(m.row(j)); the Row object returned by row(j) is a temporary + * and g++ doesn't dare to pass it by non-constant reference. + * It gets const_cast'd of course. TODO: get rid of const here. + */ template template void MatrixBase::swap(const MatrixBase& other) @@ -35,7 +44,7 @@ void MatrixBase::swap(const MatrixBase& other) Scalar tmp; if(IsVectorAtCompileTime) { - assert(OtherDerived::IsVectorAtCompileTime && size() == _other->size()); + ei_assert(OtherDerived::IsVectorAtCompileTime && size() == _other->size()); for(int i = 0; i < size(); i++) { tmp = coeff(i); diff --git a/Eigen/src/Core/Util.h b/Eigen/src/Core/Util.h index 454edd4cb..b458fe4ae 100644 --- a/Eigen/src/Core/Util.h +++ b/Eigen/src/Core/Util.h @@ -49,10 +49,16 @@ EIGEN_USING_MATRIX_TYPEDEFS \ using Eigen::Matrix; \ using Eigen::MatrixBase; +#ifdef EIGEN_NDEBUG +#define ei_assert(x) +#else +#define ei_assert(x) assert(x) +#endif + #ifdef EIGEN_INTERNAL_DEBUGGING -#define eigen_internal_assert(x) assert(x); +#define ei_internal_assert(x) ei_assert(x); #else -#define eigen_internal_assert(x) +#define ei_internal_assert(x) #endif #ifdef NDEBUG diff --git a/Eigen/src/Core/Visitor.h b/Eigen/src/Core/Visitor.h index d5b6fb167..7e3a7b819 100644 --- a/Eigen/src/Core/Visitor.h +++ b/Eigen/src/Core/Visitor.h @@ -82,13 +82,12 @@ void MatrixBase::visit(Visitor& visitor) const SizeAtCompileTime : Dynamic>::run(derived(), visitor); else { - Scalar res; visitor.init(coeff(0,0), 0, 0); for(int i = 1; i < rows(); i++) - visitor(res, coeff(i, 0), i, 0); + visitor(coeff(i, 0), i, 0); for(int j = 1; j < cols(); j++) for(int i = 0; i < rows(); i++) - visitor(res, coeff(i, j), i, j); + visitor(coeff(i, j), i, j); } } diff --git a/Eigen/src/Core/Zero.h b/Eigen/src/Core/Zero.h index 97bb8b9e9..33792f0b1 100644 --- a/Eigen/src/Core/Zero.h +++ b/Eigen/src/Core/Zero.h @@ -65,7 +65,7 @@ template class Zero : ei_no_assignment_operator, Zero(int rows, int cols) : m_rows(rows), m_cols(cols) { - assert(rows > 0 + ei_assert(rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); @@ -115,7 +115,7 @@ const Zero MatrixBase::zero(int rows, int cols) template const Zero MatrixBase::zero(int size) { - assert(IsVectorAtCompileTime); + ei_assert(IsVectorAtCompileTime); if(RowsAtCompileTime == 1) return Zero(1, size); else return Zero(size, 1); } -- cgit v1.2.3