diff --git a/src/Core/Block.h b/src/Core/Block.h index d705133b5..d3a00f6c8 100644 --- a/src/Core/Block.h +++ b/src/Core/Block.h @@ -54,8 +54,7 @@ template class Block EI_INHERIT_ASSIGNMENT_OPERATORS(Block) private: - Block& _ref() { return *this; } - const Block& _constRef() const { return *this; } + const Block& _ref() const { return *this; } int _rows() const { return m_endRow - m_startRow + 1; } int _cols() const { return m_endCol - m_startCol + 1; } diff --git a/src/Core/Column.h b/src/Core/Column.h index 5367c39f1..d8ed8e0a7 100644 --- a/src/Core/Column.h +++ b/src/Core/Column.h @@ -49,8 +49,7 @@ template class Column EI_INHERIT_ASSIGNMENT_OPERATORS(Column) private: - Column& _ref() { return *this; } - const Column& _constRef() const { return *this; } + const Column& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } int _cols() const { return 1; } diff --git a/src/Core/Conjugate.h b/src/Core/Conjugate.h index 541f47da7..dae265953 100644 --- a/src/Core/Conjugate.h +++ b/src/Core/Conjugate.h @@ -31,7 +31,7 @@ template class Conjugate { public: typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::ConstRef MatRef; + typedef typename MatrixType::Ref MatRef; friend class Object >; static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, @@ -45,8 +45,7 @@ template class Conjugate EI_INHERIT_ASSIGNMENT_OPERATORS(Conjugate) private: - Conjugate& _ref() { return *this; } - const Conjugate& _constRef() const { return *this; } + const Conjugate& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } int _cols() const { return m_matrix.cols(); } @@ -63,7 +62,7 @@ template Conjugate Object::conjugate() const { - return Conjugate(static_cast(this)->constRef()); + return Conjugate(static_cast(this)->ref()); } #endif // EI_CONJUGATE_H diff --git a/src/Core/Difference.h b/src/Core/Difference.h index 182555c83..6184090fc 100644 --- a/src/Core/Difference.h +++ b/src/Core/Difference.h @@ -31,8 +31,8 @@ template class Difference { public: typedef typename Lhs::Scalar Scalar; - typedef typename Lhs::ConstRef LhsRef; - typedef typename Rhs::ConstRef RhsRef; + typedef typename Lhs::Ref LhsRef; + typedef typename Rhs::Ref RhsRef; friend class Object; static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, @@ -51,7 +51,6 @@ template class Difference private: const Difference& _ref() const { return *this; } - const Difference& _constRef() const { return *this; } int _rows() const { return m_lhs.rows(); } int _cols() const { return m_lhs.cols(); } @@ -69,7 +68,7 @@ template Difference operator-(const Object &mat1, const Object &mat2) { - return Difference(mat1.constRef(), mat2.constRef()); + return Difference(mat1.ref(), mat2.ref()); } template diff --git a/src/Core/Dot.h b/src/Core/Dot.h index e630d669c..43df2766e 100644 --- a/src/Core/Dot.h +++ b/src/Core/Dot.h @@ -77,7 +77,6 @@ Scalar Object::dot(const OtherDerived& other) const template typename NumTraits::Real Object::norm2() const { - assert(IsVector); return NumTraits::real(dot(*this)); } diff --git a/src/Core/FromArray.h b/src/Core/FromArray.h index 30ee567cb..ab144ed13 100644 --- a/src/Core/FromArray.h +++ b/src/Core/FromArray.h @@ -45,7 +45,7 @@ template class FromArray private: FromArray& _ref() { return *this; } - const FromArray& _constRef() const { return *this; } + const FromArray& _ref() const { return *this; } int _rows() const { return m_rows; } int _cols() const { return m_cols; } diff --git a/src/Core/Identity.h b/src/Core/Identity.h index 4b437a844..e6f7cdd5e 100644 --- a/src/Core/Identity.h +++ b/src/Core/Identity.h @@ -44,7 +44,7 @@ template class Identity private: Identity& _ref() { return *this; } - const Identity& _constRef() const { return *this; } + const Identity& _ref() const { return *this; } int _rows() const { return m_rows; } int _cols() const { return m_rows; } diff --git a/src/Core/Matrix.h b/src/Core/Matrix.h index 518057d9f..0d714faac 100644 --- a/src/Core/Matrix.h +++ b/src/Core/Matrix.h @@ -32,13 +32,11 @@ class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, { public: friend class Object<_Scalar, Matrix>; - typedef Object<_Scalar, Matrix> Base; - typedef MatrixStorage<_Scalar, _Rows, _Cols> Storage; + typedef Object<_Scalar, Matrix> Base; + typedef MatrixStorage<_Scalar, _Rows, _Cols> Storage; typedef _Scalar Scalar; - typedef MatrixRef Ref; - typedef MatrixConstRef ConstRef; + typedef MatrixRef Ref; friend class MatrixRef; - friend class MatrixConstRef; static const int RowsAtCompileTime = _Rows, ColsAtCompileTime = _Cols; @@ -49,8 +47,7 @@ class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, { return Storage::m_array; } private: - Ref _ref() { return Ref(*this); } - ConstRef _constRef() const { return ConstRef(*this); } + Ref _ref() const { return Ref(*this); } const Scalar& _read(int row, int col) const { diff --git a/src/Core/MatrixRef.h b/src/Core/MatrixRef.h index 7e6aea5e6..8fab9d06a 100644 --- a/src/Core/MatrixRef.h +++ b/src/Core/MatrixRef.h @@ -26,31 +26,6 @@ #ifndef EI_MATRIXREF_H #define EI_MATRIXREF_H -template class MatrixConstRef - : public Object > -{ - public: - typedef typename MatrixType::Scalar Scalar; - friend class Object; - - MatrixConstRef(const MatrixType& matrix) : m_matrix(matrix) {} - MatrixConstRef(const MatrixConstRef& other) : m_matrix(other.m_matrix) {} - ~MatrixConstRef() {} - - EI_INHERIT_ASSIGNMENT_OPERATORS(MatrixConstRef) - - private: - int _rows() const { return m_matrix.rows(); } - int _cols() const { return m_matrix.cols(); } - - const Scalar& _read(int row, int col) const - { - return m_matrix._read(row, col); - } - - const MatrixType& m_matrix; -}; - template class MatrixRef : public Object > { @@ -58,7 +33,7 @@ template class MatrixRef typedef typename MatrixType::Scalar Scalar; friend class Object; - MatrixRef(MatrixType& matrix) : m_matrix(matrix) {} + MatrixRef(const MatrixType& matrix) : m_matrix(*const_cast(&matrix)) {} MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {} ~MatrixRef() {} diff --git a/src/Core/Minor.h b/src/Core/Minor.h index 95d52f293..bc9025d3a 100644 --- a/src/Core/Minor.h +++ b/src/Core/Minor.h @@ -54,7 +54,7 @@ template class Minor private: Minor& _ref() { return *this; } - const Minor& _constRef() const { return *this; } + const Minor& _ref() const { return *this; } int _rows() const { return m_matrix.rows() - 1; } int _cols() const { return m_matrix.cols() - 1; } diff --git a/src/Core/Object.h b/src/Core/Object.h index 96eb83cfd..93871a1d6 100644 --- a/src/Core/Object.h +++ b/src/Core/Object.h @@ -55,18 +55,14 @@ template class Object static const bool IsVector = RowsAtCompileTime == 1 || ColsAtCompileTime == 1; typedef typename ForwardDecl::Ref Ref; - typedef typename ForwardDecl::ConstRef ConstRef; typedef typename NumTraits::Real RealScalar; int rows() const { return static_cast(this)->_rows(); } int cols() const { return static_cast(this)->_cols(); } int size() const { return rows() * cols(); } - Ref ref() - { return static_cast(this)->_ref(); } - - ConstRef constRef() const - { return static_cast(this)->_constRef(); } + Ref ref() const + { return static_cast(this)->_ref(); } Scalar& write(int row, int col) { diff --git a/src/Core/Opposite.h b/src/Core/Opposite.h index e99a8f2ee..06d77c767 100644 --- a/src/Core/Opposite.h +++ b/src/Core/Opposite.h @@ -31,7 +31,7 @@ template class Opposite { public: typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::ConstRef MatRef; + typedef typename MatrixType::Ref MatRef; friend class Object >; static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, @@ -45,8 +45,7 @@ template class Opposite EI_INHERIT_ASSIGNMENT_OPERATORS(Opposite) private: - Opposite& _ref() { return *this; } - const Opposite& _constRef() const { return *this; } + const Opposite& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } int _cols() const { return m_matrix.cols(); } @@ -63,7 +62,7 @@ template Opposite Object::operator-() const { - return Opposite(static_cast(this)->constRef()); + return Opposite(static_cast(this)->ref()); } #endif // EI_OPPOSITE_H diff --git a/src/Core/Product.h b/src/Core/Product.h index 29b11b74d..854816a71 100644 --- a/src/Core/Product.h +++ b/src/Core/Product.h @@ -66,8 +66,8 @@ template class Product { public: typedef typename Lhs::Scalar Scalar; - typedef typename Lhs::ConstRef LhsRef; - typedef typename Rhs::ConstRef RhsRef; + typedef typename Lhs::Ref LhsRef; + typedef typename Rhs::Ref RhsRef; friend class Object; static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, @@ -86,7 +86,6 @@ template class Product private: const Product& _ref() const { return *this; } - const Product& _constRef() const { return *this; } int _rows() const { return m_lhs.rows(); } int _cols() const { return m_rhs.cols(); } @@ -115,7 +114,7 @@ template Product Object::lazyProduct(const Object &other) const { - return Product(constRef(), other.constRef()); + return Product(ref(), other.ref()); } template diff --git a/src/Core/Random.h b/src/Core/Random.h index 872ed6878..f4e301f4f 100644 --- a/src/Core/Random.h +++ b/src/Core/Random.h @@ -42,8 +42,7 @@ template class Random } private: - Random& _ref() { return *this; } - const Random& _constRef() const { return *this; } + const Random& _ref() const { return *this; } int _rows() const { return m_rows; } int _cols() const { return m_cols; } diff --git a/src/Core/Row.h b/src/Core/Row.h index 7b8a8a9b4..00ec34d9a 100644 --- a/src/Core/Row.h +++ b/src/Core/Row.h @@ -55,8 +55,7 @@ template class Row EI_INHERIT_ASSIGNMENT_OPERATORS(Row) private: - Row& _ref() { return *this; } - const Row& _constRef() const { return *this; } + const Row& _ref() const { return *this; } int _rows() const { return 1; } int _cols() const { return m_matrix.cols(); } diff --git a/src/Core/ScalarMultiple.h b/src/Core/ScalarMultiple.h index 137804c43..060adf185 100644 --- a/src/Core/ScalarMultiple.h +++ b/src/Core/ScalarMultiple.h @@ -31,7 +31,7 @@ template class ScalarMultiple { public: typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::ConstRef MatRef; + typedef typename MatrixType::Ref MatRef; friend class Object >; static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, @@ -47,7 +47,6 @@ template class ScalarMultiple private: const ScalarMultiple& _ref() const { return *this; } - const ScalarMultiple& _constRef() const { return *this; } int _rows() const { return m_matrix.rows(); } int _cols() const { return m_matrix.cols(); } @@ -67,7 +66,7 @@ ScalarMultiple \ operator*(const Object& matrix, \ OtherScalar scalar) \ { \ - return ScalarMultiple(matrix.constRef(), scalar); \ + return ScalarMultiple(matrix.ref(), scalar); \ } \ \ template \ @@ -75,7 +74,7 @@ ScalarMultiple \ operator*(OtherScalar scalar, \ const Object& matrix) \ { \ - return ScalarMultiple(matrix.constRef(), scalar); \ + return ScalarMultiple(matrix.ref(), scalar); \ } \ \ template \ diff --git a/src/Core/Sum.h b/src/Core/Sum.h index 2b3ec5807..49968c238 100644 --- a/src/Core/Sum.h +++ b/src/Core/Sum.h @@ -31,8 +31,8 @@ template class Sum { public: typedef typename Lhs::Scalar Scalar; - typedef typename Lhs::ConstRef LhsRef; - typedef typename Rhs::ConstRef RhsRef; + typedef typename Lhs::Ref LhsRef; + typedef typename Rhs::Ref RhsRef; friend class Object; static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, @@ -50,9 +50,7 @@ template class Sum EI_INHERIT_ASSIGNMENT_OPERATORS(Sum) private: - const Sum& _ref() const { return *this; } - const Sum& _constRef() const { return *this; } int _rows() const { return m_lhs.rows(); } int _cols() const { return m_lhs.cols(); } @@ -70,7 +68,7 @@ template Sum operator+(const Object &mat1, const Object &mat2) { - return Sum(mat1.constRef(), mat2.constRef()); + return Sum(mat1.ref(), mat2.ref()); } template diff --git a/src/Core/Transpose.h b/src/Core/Transpose.h index b15ad4691..c9c4f669e 100644 --- a/src/Core/Transpose.h +++ b/src/Core/Transpose.h @@ -45,8 +45,7 @@ template class Transpose EI_INHERIT_ASSIGNMENT_OPERATORS(Transpose) private: - Transpose& _ref() { return *this; } - const Transpose& _constRef() const { return *this; } + const Transpose& _ref() const { return *this; } int _rows() const { return m_matrix.cols(); } int _cols() const { return m_matrix.rows(); } diff --git a/src/Core/Util.h b/src/Core/Util.h index fdc6b27a1..5dcc5c4a1 100644 --- a/src/Core/Util.h +++ b/src/Core/Util.h @@ -43,7 +43,6 @@ using Eigen::Matrix; //forward declarations template class Matrix; template class MatrixRef; -template class MatrixConstRef; template class Row; template class Column; template class Minor; @@ -64,14 +63,12 @@ template class FromArray; template struct ForwardDecl { typedef T Ref; - typedef T ConstRef; }; template struct ForwardDecl > { typedef MatrixRef > Ref; - typedef MatrixConstRef > ConstRef; }; const int Dynamic = -1; diff --git a/src/Core/Zero.h b/src/Core/Zero.h index 16a5747e2..ca599c937 100644 --- a/src/Core/Zero.h +++ b/src/Core/Zero.h @@ -42,8 +42,7 @@ template class Zero } private: - Zero& _ref() { return *this; } - const Zero& _constRef() const { return *this; } + const Zero& _ref() const { return *this; } int _rows() const { return m_rows; } int _cols() const { return m_cols; }