diff options
author | 2007-12-19 09:30:53 +0000 | |
---|---|---|
committer | 2007-12-19 09:30:53 +0000 | |
commit | cddeeee17d0bac36f9fa0fa8177792b6ce7a2c35 (patch) | |
tree | 850858da1d4a47a0ff2e5d7e16e4f92661c826dc | |
parent | 59be5c31242a333502a76b53122f69306382cd6f (diff) |
- make RowsAtCompileTime and ColsAtCompileTime public in
MatrixBase and private in derived types
- initial documentation in MatrixBase
-rw-r--r-- | src/Core/Block.h | 6 | ||||
-rw-r--r-- | src/Core/Cast.h | 5 | ||||
-rw-r--r-- | src/Core/Column.h | 5 | ||||
-rw-r--r-- | src/Core/Conjugate.h | 6 | ||||
-rw-r--r-- | src/Core/DiagonalCoeffs.h | 6 | ||||
-rw-r--r-- | src/Core/DiagonalMatrix.h | 10 | ||||
-rw-r--r-- | src/Core/Difference.h | 6 | ||||
-rw-r--r-- | src/Core/DynBlock.h | 8 | ||||
-rw-r--r-- | src/Core/Identity.h | 8 | ||||
-rw-r--r-- | src/Core/Map.h | 12 | ||||
-rw-r--r-- | src/Core/Matrix.h | 38 | ||||
-rw-r--r-- | src/Core/MatrixBase.h | 71 | ||||
-rw-r--r-- | src/Core/MatrixRef.h | 6 | ||||
-rw-r--r-- | src/Core/Minor.h | 12 | ||||
-rw-r--r-- | src/Core/Ones.h | 6 | ||||
-rw-r--r-- | src/Core/Opposite.h | 6 | ||||
-rw-r--r-- | src/Core/Product.h | 6 | ||||
-rw-r--r-- | src/Core/Random.h | 6 | ||||
-rw-r--r-- | src/Core/Row.h | 6 | ||||
-rw-r--r-- | src/Core/ScalarMultiple.h | 6 | ||||
-rw-r--r-- | src/Core/Sum.h | 6 | ||||
-rw-r--r-- | src/Core/Transpose.h | 6 | ||||
-rw-r--r-- | src/Core/Zero.h | 6 |
23 files changed, 157 insertions, 96 deletions
diff --git a/src/Core/Block.h b/src/Core/Block.h index 55ba7830f..54a93b40f 100644 --- a/src/Core/Block.h +++ b/src/Core/Block.h @@ -35,9 +35,6 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block typedef typename MatrixType::Ref MatRef; friend class MatrixBase<Scalar, Block<MatrixType, BlockRows, BlockCols> >; - static const int RowsAtCompileTime = BlockRows, - ColsAtCompileTime = BlockCols; - Block(const MatRef& matrix, int startRow, int startCol) : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol) { @@ -52,6 +49,9 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block) private: + static const int _RowsAtCompileTime = BlockRows, + _ColsAtCompileTime = BlockCols; + const Block& _ref() const { return *this; } int _rows() const { return BlockRows; } int _cols() const { return BlockCols; } diff --git a/src/Core/Cast.h b/src/Core/Cast.h index 58a731522..7dfce45b0 100644 --- a/src/Core/Cast.h +++ b/src/Core/Cast.h @@ -34,15 +34,14 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals, typedef typename MatrixType::Ref MatRef; friend class MatrixBase<Scalar, Cast<Scalar, MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - Cast(const MatRef& matrix) : m_matrix(matrix) {} Cast(const Cast& other) : m_matrix(other.m_matrix) {} private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; const Cast& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } int _cols() const { return m_matrix.cols(); } diff --git a/src/Core/Column.h b/src/Core/Column.h index fc24fb484..39b8263e7 100644 --- a/src/Core/Column.h +++ b/src/Core/Column.h @@ -34,9 +34,6 @@ template<typename MatrixType> class Column typedef typename MatrixType::Ref MatRef; friend class MatrixBase<Scalar, Column<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = 1; - Column(const MatRef& matrix, int col) : m_matrix(matrix), m_col(col) { @@ -49,6 +46,8 @@ template<typename MatrixType> class Column EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column) private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = 1; 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 87054efa8..5254660ac 100644 --- a/src/Core/Conjugate.h +++ b/src/Core/Conjugate.h @@ -34,15 +34,15 @@ template<typename MatrixType> class Conjugate : NoOperatorEquals, typedef typename MatrixType::Ref MatRef; friend class MatrixBase<Scalar, Conjugate<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - Conjugate(const MatRef& matrix) : m_matrix(matrix) {} Conjugate(const Conjugate& other) : m_matrix(other.m_matrix) {} private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + const Conjugate& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } int _cols() const { return m_matrix.cols(); } diff --git a/src/Core/DiagonalCoeffs.h b/src/Core/DiagonalCoeffs.h index 8b788feea..b20e188b7 100644 --- a/src/Core/DiagonalCoeffs.h +++ b/src/Core/DiagonalCoeffs.h @@ -34,9 +34,6 @@ template<typename MatrixType> class DiagonalCoeffs typedef typename MatrixType::Ref MatRef; friend class MatrixBase<Scalar, DiagonalCoeffs<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = 1; - DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {} DiagonalCoeffs(const DiagonalCoeffs& other) : m_matrix(other.m_matrix) {} @@ -44,6 +41,9 @@ template<typename MatrixType> class DiagonalCoeffs EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs) private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = 1; + const DiagonalCoeffs& _ref() const { return *this; } int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); } int _cols() const { return 1; } diff --git a/src/Core/DiagonalMatrix.h b/src/Core/DiagonalMatrix.h index 624eec353..0ae9399e8 100644 --- a/src/Core/DiagonalMatrix.h +++ b/src/Core/DiagonalMatrix.h @@ -36,18 +36,18 @@ class DiagonalMatrix : NoOperatorEquals, typedef typename CoeffsVectorType::Ref CoeffsVecRef; friend class MatrixBase<Scalar, DiagonalMatrix<MatrixType, CoeffsVectorType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs) { assert(CoeffsVectorType::IsVector - && RowsAtCompileTime == ColsAtCompileTime - && RowsAtCompileTime == CoeffsVectorType::SizeAtCompileTime + && _RowsAtCompileTime == _ColsAtCompileTime + && _RowsAtCompileTime == CoeffsVectorType::SizeAtCompileTime && coeffs.size() > 0); } private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + const DiagonalMatrix& _ref() const { return *this; } int _rows() const { return m_coeffs.size(); } int _cols() const { return m_coeffs.size(); } diff --git a/src/Core/Difference.h b/src/Core/Difference.h index 525741bc2..a03e3c937 100644 --- a/src/Core/Difference.h +++ b/src/Core/Difference.h @@ -35,9 +35,6 @@ template<typename Lhs, typename Rhs> class Difference : NoOperatorEquals, typedef typename Rhs::Ref RhsRef; friend class MatrixBase<Scalar, Difference>; - static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, - ColsAtCompileTime = Rhs::ColsAtCompileTime; - Difference(const LhsRef& lhs, const RhsRef& rhs) : m_lhs(lhs), m_rhs(rhs) { @@ -48,6 +45,9 @@ template<typename Lhs, typename Rhs> class Difference : NoOperatorEquals, : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {} private: + static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime, + _ColsAtCompileTime = Rhs::ColsAtCompileTime; + const Difference& _ref() const { return *this; } int _rows() const { return m_lhs.rows(); } int _cols() const { return m_lhs.cols(); } diff --git a/src/Core/DynBlock.h b/src/Core/DynBlock.h index 024a0c030..3fa0e9c9b 100644 --- a/src/Core/DynBlock.h +++ b/src/Core/DynBlock.h @@ -34,10 +34,6 @@ template<typename MatrixType> class DynBlock typedef typename MatrixType::Ref MatRef; friend class MatrixBase<Scalar, DynBlock<MatrixType> >; - static const int - RowsAtCompileTime = MatrixType::RowsAtCompileTime == 1 ? 1 : Dynamic, - ColsAtCompileTime = MatrixType::ColsAtCompileTime == 1 ? 1 : Dynamic; - DynBlock(const MatRef& matrix, int startRow, int startCol, int blockRows, int blockCols) @@ -56,6 +52,10 @@ template<typename MatrixType> class DynBlock EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DynBlock) private: + static const int + _RowsAtCompileTime = MatrixType::RowsAtCompileTime == 1 ? 1 : Dynamic, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime == 1 ? 1 : Dynamic; + const DynBlock& _ref() const { return *this; } int _rows() const { return m_blockRows; } int _cols() const { return m_blockCols; } diff --git a/src/Core/Identity.h b/src/Core/Identity.h index ca785f3e4..a24a30224 100644 --- a/src/Core/Identity.h +++ b/src/Core/Identity.h @@ -33,15 +33,15 @@ template<typename MatrixType> class Identity : NoOperatorEquals, typedef typename MatrixType::Scalar Scalar; friend class MatrixBase<Scalar, Identity<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - Identity(int rows) : m_rows(rows) { - assert(rows > 0 && RowsAtCompileTime == ColsAtCompileTime); + assert(rows > 0 && _RowsAtCompileTime == _ColsAtCompileTime); } private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + const Identity& _ref() const { return *this; } int _rows() const { return m_rows; } int _cols() const { return m_rows; } diff --git a/src/Core/Map.h b/src/Core/Map.h index e8300a7c3..79951b226 100644 --- a/src/Core/Map.h +++ b/src/Core/Map.h @@ -23,8 +23,8 @@ // License. This exception does not invalidate any other reasons why a work // based on this file might be covered by the GNU General Public License. -#ifndef EIGEN_FROMARRAY_H -#define EIGEN_FROMARRAY_H +#ifndef EIGEN_MAP_H +#define EIGEN_MAP_H template<typename MatrixType> class Map : public MatrixBase<typename MatrixType::Scalar, Map<MatrixType> > @@ -33,9 +33,6 @@ template<typename MatrixType> class Map typedef typename MatrixType::Scalar Scalar; friend class MatrixBase<Scalar, Map<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - Map(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols) { assert(rows > 0 && cols > 0); @@ -44,6 +41,9 @@ template<typename MatrixType> class Map EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map) private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + const Map& _ref() const { return *this; } int _rows() const { return m_rows; } int _cols() const { return m_cols; } @@ -131,4 +131,4 @@ Matrix<_Scalar, _Rows, _Cols> *this = map(data); } -#endif // EIGEN_FROMARRAY_H +#endif // EIGEN_MAP_H diff --git a/src/Core/Matrix.h b/src/Core/Matrix.h index 92eb38725..989b1a550 100644 --- a/src/Core/Matrix.h +++ b/src/Core/Matrix.h @@ -38,8 +38,6 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, typedef MatrixRef<Matrix> Ref; friend class MatrixRef<Matrix>; - static const int RowsAtCompileTime = _Rows, ColsAtCompileTime = _Cols; - const Scalar* data() const { return Storage::m_data; } @@ -47,6 +45,8 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, { return Storage::m_data; } private: + static const int _RowsAtCompileTime = _Rows, _ColsAtCompileTime = _Cols; + Ref _ref() const { return Ref(*this); } const Scalar& _coeff(int row, int col) const @@ -80,15 +80,15 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, explicit Matrix() : Storage() { - assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0); + assert(_RowsAtCompileTime > 0 && _ColsAtCompileTime > 0); } explicit Matrix(int dim) : Storage(dim) { assert(dim > 0); - assert((RowsAtCompileTime == 1 - && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == dim)) - || (ColsAtCompileTime == 1 - && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == dim))); + assert((_RowsAtCompileTime == 1 + && (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == dim)) + || (_ColsAtCompileTime == 1 + && (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == dim))); } // this constructor is very tricky. @@ -101,44 +101,44 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, // does what we want to, so it only remains to add some asserts. Matrix(int x, int y) : Storage(x, y) { - if((RowsAtCompileTime == 1 && ColsAtCompileTime == 2) - || (RowsAtCompileTime == 2 && ColsAtCompileTime == 1)) + if((_RowsAtCompileTime == 1 && _ColsAtCompileTime == 2) + || (_RowsAtCompileTime == 2 && _ColsAtCompileTime == 1)) { (Storage::m_data)[0] = x; (Storage::m_data)[1] = y; } else { - assert(x > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == x) - && y > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == y)); + assert(x > 0 && (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == x) + && y > 0 && (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == y)); } } Matrix(const float& x, const float& y) { - assert((RowsAtCompileTime == 1 && ColsAtCompileTime == 2) - || (RowsAtCompileTime == 2 && ColsAtCompileTime == 1)); + assert((_RowsAtCompileTime == 1 && _ColsAtCompileTime == 2) + || (_RowsAtCompileTime == 2 && _ColsAtCompileTime == 1)); (Storage::m_data)[0] = x; (Storage::m_data)[1] = y; } Matrix(const double& x, const double& y) { - assert((RowsAtCompileTime == 1 && ColsAtCompileTime == 2) - || (RowsAtCompileTime == 2 && ColsAtCompileTime == 1)); + assert((_RowsAtCompileTime == 1 && _ColsAtCompileTime == 2) + || (_RowsAtCompileTime == 2 && _ColsAtCompileTime == 1)); (Storage::m_data)[0] = x; (Storage::m_data)[1] = y; } Matrix(const Scalar& x, const Scalar& y, const Scalar& z) { - assert((RowsAtCompileTime == 1 && ColsAtCompileTime == 3) - || (RowsAtCompileTime == 3 && ColsAtCompileTime == 1)); + assert((_RowsAtCompileTime == 1 && _ColsAtCompileTime == 3) + || (_RowsAtCompileTime == 3 && _ColsAtCompileTime == 1)); (Storage::m_data)[0] = x; (Storage::m_data)[1] = y; (Storage::m_data)[2] = z; } Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w) { - assert((RowsAtCompileTime == 1 && ColsAtCompileTime == 4) - || (RowsAtCompileTime == 4 && ColsAtCompileTime == 1)); + assert((_RowsAtCompileTime == 1 && _ColsAtCompileTime == 4) + || (_RowsAtCompileTime == 4 && _ColsAtCompileTime == 1)); (Storage::m_data)[0] = x; (Storage::m_data)[1] = y; (Storage::m_data)[2] = z; diff --git a/src/Core/MatrixBase.h b/src/Core/MatrixBase.h index 83b6fa169..db8eaadb5 100644 --- a/src/Core/MatrixBase.h +++ b/src/Core/MatrixBase.h @@ -26,41 +26,104 @@ #ifndef EIGEN_MATRIXBASE_H #define EIGEN_MATRIXBASE_H +/** \class MatrixBase + * + * \brief Base class for all matrices, vectors, and expressions + * + * This class is the base that is inherited by all matrix, vector, and expression + * types. Most of the Eigen API is contained in this class. + * + * This class takes two template parameters: + * \param Scalar the type of the coefficients, e.g. float, double, etc. + * \param Derived the derived type, e.g. a matrix type, or an expression, etc. + * Indeed, a separate MatrixBase type is generated for each derived type + * so one knows from inside MatrixBase, at compile-time, what the derived type is. + * + * When writing a function taking Eigen objects as argument, if you want your function + * to take as argument any matrix, vector, or expression, just let it take a + * MatrixBase argument. As an example, here is a function printFirstRow which, given + * a matrix, vector, or expression \a x, prints the first row of \a x. + * + * \code + template<typename Scalar, typename Derived> + void printFirstRow(const Eigen::MatrixBase<Scalar, Derived>& m) + { + cout << x.row(0) << endl; + } + * \endcode + */ template<typename Scalar, typename Derived> class MatrixBase { - static const int RowsAtCompileTime = Derived::RowsAtCompileTime, - ColsAtCompileTime = Derived::ColsAtCompileTime; - public: + /** The number of rows and of columns at compile-time. These are just + * copies of the values provided by the \a Derived type. If a value + * is not known at compile-time, it is set to the \a Dynamic constant. + * \sa rows(), cols(), SizeAtCompileTime */ + static const int RowsAtCompileTime = Derived::_RowsAtCompileTime, + ColsAtCompileTime = Derived::_ColsAtCompileTime; + + /** This is equal to the number of coefficients, i.e. the number of + * rows times the number of columns, or to \a Dynamic if this is not + * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */ static const int SizeAtCompileTime = RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic ? Dynamic : RowsAtCompileTime * ColsAtCompileTime; + /** This is set to true if either the number of rows or the number of + * columns is known at compile-time to be equal to 1. Indeed, in that case, + * we are dealing with a column-vector (if there is only one column) or with + * a row-vector (if there is only one row). */ static const bool IsVector = RowsAtCompileTime == 1 || ColsAtCompileTime == 1; + /** This is the "reference type" used to pass objects of type MatrixBase as arguments + * to functions. If this MatrixBase type represents an expression, then \a Ref + * is just this MatrixBase type itself, i.e. expressions are just passed by value + * and the compiler is supposed to be clever enough to optimize that. If, on the + * other hand, this MatrixBase type is an actual matrix or vector, then \a Ref is + * a typedef MatrixRef, which is like a reference, so that matrices and vectors + * are passed by reference, not by value. \sa ref()*/ typedef typename ForwardDecl<Derived>::Ref Ref; + + /** This is the "real scalar" type; if the \a Scalar type is already real numbers + * (e.g. int, float or double) then RealScalar is just the same as \a Scalar. If + * \Scalar is \a std::complex<T> then RealScalar is \a T. */ typedef typename NumTraits<Scalar>::Real RealScalar; + /** \returns the number of rows. \sa cols(), RowsAtCompileTime */ int rows() const { return static_cast<const Derived *>(this)->_rows(); } + /** \returns the number of columns. \sa row(), ColsAtCompileTime*/ int cols() const { return static_cast<const Derived *>(this)->_cols(); } + /** \returns the number of coefficients, which is \a rows()*cols(). + * \sa rows(), cols(). */ int size() const { return rows() * cols(); } + /** \returns a Ref to *this. \sa Ref */ Ref ref() const { return static_cast<const Derived *>(this)->_ref(); } + /** Copies \a other into *this. \returns a reference to *this. */ template<typename OtherDerived> Derived& operator=(const MatrixBase<Scalar, OtherDerived>& other); - //special case of the above template operator=, in order to prevent the compiler + // Special case of the above template operator=, in order to prevent the compiler //from generating a default operator= (issue hit with g++ 4.1) Derived& operator=(const MatrixBase& other) { return this->operator=<Derived>(other); } + /** \returns an expression of *this with the \a Scalar type casted to + * \a NewScalar. */ template<typename NewScalar> const Cast<NewScalar, Derived> cast() const; + /** \returns an expression of the \a i-th row of *this. + * \sa col(int)*/ Row<Derived> row(int i) const; + /** \returns an expression of the \a i-th column of *this. + * \sa row(int) */ Column<Derived> col(int i) const; + /** \return an expression of the (\a row, \a col)-minor of *this, + * i.e. an expression constructed from *this by removing the specified + * row and column. */ Minor<Derived> minor(int row, int col) const; DynBlock<Derived> dynBlock(int startRow, int startCol, diff --git a/src/Core/MatrixRef.h b/src/Core/MatrixRef.h index b5f0a1eef..ac4fe4bc0 100644 --- a/src/Core/MatrixRef.h +++ b/src/Core/MatrixRef.h @@ -33,9 +33,6 @@ template<typename MatrixType> class MatrixRef typedef typename MatrixType::Scalar Scalar; friend class MatrixBase<Scalar, MatrixRef>; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - MatrixRef(const MatrixType& matrix) : m_matrix(*const_cast<MatrixType*>(&matrix)) {} MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {} ~MatrixRef() {} @@ -43,6 +40,9 @@ template<typename MatrixType> class MatrixRef EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef) private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + int _rows() const { return m_matrix.rows(); } int _cols() const { return m_matrix.cols(); } diff --git a/src/Core/Minor.h b/src/Core/Minor.h index d238d5084..01389ed22 100644 --- a/src/Core/Minor.h +++ b/src/Core/Minor.h @@ -34,12 +34,6 @@ template<typename MatrixType> class Minor typedef typename MatrixType::Ref MatRef; friend class MatrixBase<Scalar, Minor<MatrixType> >; - static const int - RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ? - MatrixType::RowsAtCompileTime - 1 : Dynamic, - ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ? - MatrixType::ColsAtCompileTime - 1 : Dynamic; - Minor(const MatRef& matrix, int row, int col) : m_matrix(matrix), m_row(row), m_col(col) @@ -54,6 +48,12 @@ template<typename MatrixType> class Minor EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor) private: + static const int + _RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ? + MatrixType::RowsAtCompileTime - 1 : Dynamic, + _ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ? + MatrixType::ColsAtCompileTime - 1 : Dynamic; + 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/Ones.h b/src/Core/Ones.h index 020e5031f..76a3665c6 100644 --- a/src/Core/Ones.h +++ b/src/Core/Ones.h @@ -33,15 +33,15 @@ template<typename MatrixType> class Ones : NoOperatorEquals, typedef typename MatrixType::Scalar Scalar; friend class MatrixBase<Scalar, Ones<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - Ones(int rows, int cols) : m_rows(rows), m_cols(cols) { assert(rows > 0 && cols > 0); } private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + const Ones& _ref() const { return *this; } int _rows() const { return m_rows; } int _cols() const { return m_cols; } diff --git a/src/Core/Opposite.h b/src/Core/Opposite.h index 627b0c0b5..21be7f614 100644 --- a/src/Core/Opposite.h +++ b/src/Core/Opposite.h @@ -34,15 +34,15 @@ template<typename MatrixType> class Opposite : NoOperatorEquals, typedef typename MatrixType::Ref MatRef; friend class MatrixBase<Scalar, Opposite<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - Opposite(const MatRef& matrix) : m_matrix(matrix) {} Opposite(const Opposite& other) : m_matrix(other.m_matrix) {} private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + const Opposite& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } int _cols() const { return m_matrix.cols(); } diff --git a/src/Core/Product.h b/src/Core/Product.h index 8403cb3ba..506df2160 100644 --- a/src/Core/Product.h +++ b/src/Core/Product.h @@ -69,9 +69,6 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals, typedef typename Rhs::Ref RhsRef; friend class MatrixBase<Scalar, Product>; - static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, - ColsAtCompileTime = Rhs::ColsAtCompileTime; - Product(const LhsRef& lhs, const RhsRef& rhs) : m_lhs(lhs), m_rhs(rhs) { @@ -82,6 +79,9 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals, : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {} private: + static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime, + _ColsAtCompileTime = Rhs::ColsAtCompileTime; + const Product& _ref() const { return *this; } int _rows() const { return m_lhs.rows(); } int _cols() const { return m_rhs.cols(); } diff --git a/src/Core/Random.h b/src/Core/Random.h index 905010553..769e737ee 100644 --- a/src/Core/Random.h +++ b/src/Core/Random.h @@ -33,15 +33,15 @@ template<typename MatrixType> class Random : NoOperatorEquals, typedef typename MatrixType::Scalar Scalar; friend class MatrixBase<Scalar, Random<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - Random(int rows, int cols) : m_rows(rows), m_cols(cols) { assert(rows > 0 && cols > 0); } private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + 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 71acbf51f..af46dc280 100644 --- a/src/Core/Row.h +++ b/src/Core/Row.h @@ -34,9 +34,6 @@ template<typename MatrixType> class Row typedef typename MatrixType::Ref MatRef; friend class MatrixBase<Scalar, Row<MatrixType> >; - static const int RowsAtCompileTime = 1, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - Row(const MatRef& matrix, int row) : m_matrix(matrix), m_row(row) { @@ -55,6 +52,9 @@ template<typename MatrixType> class Row EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row) private: + static const int _RowsAtCompileTime = 1, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + const Row& _ref() const { return *this; } int _rows() const { return 1; } diff --git a/src/Core/ScalarMultiple.h b/src/Core/ScalarMultiple.h index 0f269c197..95c44fc0f 100644 --- a/src/Core/ScalarMultiple.h +++ b/src/Core/ScalarMultiple.h @@ -34,9 +34,6 @@ template<typename MatrixType> class ScalarMultiple : NoOperatorEquals, typedef typename MatrixType::Ref MatRef; friend class MatrixBase<typename MatrixType::Scalar, ScalarMultiple<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - ScalarMultiple(const MatRef& matrix, Scalar scalar) : m_matrix(matrix), m_scalar(scalar) {} @@ -44,6 +41,9 @@ template<typename MatrixType> class ScalarMultiple : NoOperatorEquals, : m_matrix(other.m_matrix), m_scalar(other.m_scalar) {} private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + const ScalarMultiple& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } int _cols() const { return m_matrix.cols(); } diff --git a/src/Core/Sum.h b/src/Core/Sum.h index cbf1b736a..3f5f45c7d 100644 --- a/src/Core/Sum.h +++ b/src/Core/Sum.h @@ -35,9 +35,6 @@ template<typename Lhs, typename Rhs> class Sum : NoOperatorEquals, typedef typename Rhs::Ref RhsRef; friend class MatrixBase<Scalar, Sum>; - static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, - ColsAtCompileTime = Rhs::ColsAtCompileTime; - Sum(const LhsRef& lhs, const RhsRef& rhs) : m_lhs(lhs), m_rhs(rhs) { @@ -47,6 +44,9 @@ template<typename Lhs, typename Rhs> class Sum : NoOperatorEquals, Sum(const Sum& other) : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {} private: + static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime, + _ColsAtCompileTime = Rhs::ColsAtCompileTime; + const Sum& _ref() const { return *this; } int _rows() const { return m_lhs.rows(); } int _cols() const { return m_lhs.cols(); } diff --git a/src/Core/Transpose.h b/src/Core/Transpose.h index f10de9256..7cf989886 100644 --- a/src/Core/Transpose.h +++ b/src/Core/Transpose.h @@ -34,9 +34,6 @@ template<typename MatrixType> class Transpose typedef typename MatrixType::Ref MatRef; friend class MatrixBase<Scalar, Transpose<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::ColsAtCompileTime, - ColsAtCompileTime = MatrixType::RowsAtCompileTime; - Transpose(const MatRef& matrix) : m_matrix(matrix) {} Transpose(const Transpose& other) @@ -45,6 +42,9 @@ template<typename MatrixType> class Transpose EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose) private: + static const int _RowsAtCompileTime = MatrixType::ColsAtCompileTime, + _ColsAtCompileTime = MatrixType::RowsAtCompileTime; + 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/Zero.h b/src/Core/Zero.h index 0f983ce20..95685df48 100644 --- a/src/Core/Zero.h +++ b/src/Core/Zero.h @@ -33,15 +33,15 @@ template<typename MatrixType> class Zero : NoOperatorEquals, typedef typename MatrixType::Scalar Scalar; friend class MatrixBase<Scalar, Zero<MatrixType> >; - static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime; - Zero(int rows, int cols) : m_rows(rows), m_cols(cols) { assert(rows > 0 && cols > 0); } private: + static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime, + _ColsAtCompileTime = MatrixType::ColsAtCompileTime; + const Zero& _ref() const { return *this; } int _rows() const { return m_rows; } int _cols() const { return m_cols; } |