diff --git a/Eigen/src/Core/Eval.h b/Eigen/src/Core/Eval.h index b41ee0d7c..f4ffca655 100644 --- a/Eigen/src/Core/Eval.h +++ b/Eigen/src/Core/Eval.h @@ -45,25 +45,53 @@ * * \sa MatrixBase::eval() */ -template class Eval : NoOperatorEquals, - public Matrix< typename Expression::Scalar, - Expression::Traits::RowsAtCompileTime, - Expression::Traits::ColsAtCompileTime, - EIGEN_DEFAULT_MATRIX_STORAGE_ORDER, - Expression::Traits::MaxRowsAtCompileTime, - Expression::Traits::MaxColsAtCompileTime> +template class Eval + : public MatrixBase > { public: - typedef typename Expression::Scalar Scalar; - typedef Matrix; + typedef MatrixBase Base; + friend class MatrixRef; + typedef MatrixRef Ref; + + private: + enum { + RowsAtCompileTime = ExpressionType::Traits::RowsAtCompileTime, + ColsAtCompileTime = ExpressionType::Traits::ColsAtCompileTime, + MaxRowsAtCompileTime = ExpressionType::Traits::MaxRowsAtCompileTime, + MaxColsAtCompileTime = ExpressionType::Traits::MaxColsAtCompileTime + }; + typedef Matrix Base; + ExpressionType::Traits::MaxRowsAtCompileTime, + ExpressionType::Traits::MaxColsAtCompileTime> MatrixType; - Eval() : Base() {} - explicit Eval(const Expression& other) : Base(other) {} + int _rows() const { return m_matrix.rows(); } + int _cols() const { return m_matrix.cols(); } + Ref _ref() const { return Ref(*this); } + + const Scalar& _coeff(int row, int col) const + { + return m_matrix._coeff(row, col); + } + + Scalar& _coeffRef(int row, int col) + { + return m_matrix._coeffRef(row, col); + } + + public: + template + Eval(const MatrixBase& other) : m_matrix(other) {} + ~Eval() {} + + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Eval) + + protected: + MatrixType m_matrix; }; /** Evaluates *this, which can be any expression, and returns the obtained matrix. @@ -82,7 +110,7 @@ template class Eval : NoOperatorEquals, template const Eval MatrixBase::eval() const { - return Eval(*static_cast(this)); + return Eval(ref()); } #endif // EIGEN_EVAL_H diff --git a/Eigen/src/Core/ForwardDeclarations.h b/Eigen/src/Core/ForwardDeclarations.h index 5f969667c..834a99f55 100644 --- a/Eigen/src/Core/ForwardDeclarations.h +++ b/Eigen/src/Core/ForwardDeclarations.h @@ -61,4 +61,10 @@ struct Reference > Type; }; +template +struct Reference > +{ + typedef MatrixRef > Type; +}; + #endif // EIGEN_FORWARDDECLARATIONS_H diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 6b3c98fda..3dba1f5da 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -111,6 +111,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, typedef _Scalar Scalar; typedef MatrixRef Ref; friend class MatrixRef; + template friend class Eval; private: enum { @@ -150,24 +151,6 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, } public: - /** This type can be used to declare any matrix with smaller dimensions. - */ - typedef Matrix< - Scalar, - RowsAtCompileTime == 1 ? 1 : Dynamic, - ColsAtCompileTime == 1 ? 1 : Dynamic, - StorageOrder, - RowsAtCompileTime == 1 ? 1 : MaxRowsAtCompileTime, - ColsAtCompileTime == 1 ? 1 : MaxColsAtCompileTime - > BlockType; - - /** This type can be used to declare a column-vector */ - typedef Matrix ColumnType; - /** This type can be used to declare a row-vector */ - typedef Matrix RowType; - /** \returns a const pointer to the data array of this matrix */ const Scalar *data() const { return m_array.data(); }