diff options
Diffstat (limited to 'Eigen/src/Core/MatrixBase.h')
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 142 |
1 files changed, 70 insertions, 72 deletions
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 57ef46560..62dfc6bee 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -55,76 +55,74 @@ template<typename Derived> class MatrixBase public: - typedef typename Scalar<Derived>::Type Scalar; + typedef typename ei_traits<Derived>::Scalar Scalar; + + /** The number of rows at compile-time. This is just a copy of the value provided + * by the \a Derived type. If a value is not known at compile-time, + * it is set to the \a Dynamic constant. + * \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */ + enum { RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime }; + + /** The number of columns at compile-time. This is just a copy of the value provided + * by the \a Derived type. If a value is not known at compile-time, + * it is set to the \a Dynamic constant. + * \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */ + enum { ColsAtCompileTime = ei_traits<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 */ + enum { SizeAtCompileTime + = ei_traits<Derived>::RowsAtCompileTime == Dynamic + || ei_traits<Derived>::ColsAtCompileTime == Dynamic + ? Dynamic + : ei_traits<Derived>::RowsAtCompileTime * ei_traits<Derived>::ColsAtCompileTime + }; - /** \brief Some traits provided by the Derived type. + /** This value is equal to the maximum possible number of rows that this expression + * might have. If this expression might have an arbitrarily high number of rows, + * this value is set to \a Dynamic. * - * Grouping these in a nested subclass is what was needed for ICC compatibility. */ - struct Traits - { - /** The number of rows at compile-time. This is just a copy of the value provided - * by the \a Derived type. If a value is not known at compile-time, - * it is set to the \a Dynamic constant. - * \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */ - enum { RowsAtCompileTime = Derived::RowsAtCompileTime }; - - /** The number of columns at compile-time. This is just a copy of the value provided - * by the \a Derived type. If a value is not known at compile-time, - * it is set to the \a Dynamic constant. - * \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */ - enum { 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 */ - enum { SizeAtCompileTime - = Derived::RowsAtCompileTime == Dynamic || Derived::ColsAtCompileTime == Dynamic - ? Dynamic : Derived::RowsAtCompileTime * Derived::ColsAtCompileTime - }; - - /** This value is equal to the maximum possible number of rows that this expression - * might have. If this expression might have an arbitrarily high number of rows, - * this value is set to \a Dynamic. - * - * This value is useful to know when evaluating an expression, in order to determine - * whether it is possible to avoid doing a dynamic memory allocation. - * - * \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime - */ - enum { MaxRowsAtCompileTime = Derived::MaxRowsAtCompileTime }; - - /** This value is equal to the maximum possible number of columns that this expression - * might have. If this expression might have an arbitrarily high number of columns, - * this value is set to \a Dynamic. - * - * This value is useful to know when evaluating an expression, in order to determine - * whether it is possible to avoid doing a dynamic memory allocation. - * - * \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime - */ - enum { MaxColsAtCompileTime = Derived::MaxColsAtCompileTime }; - - /** This value is equal to the maximum possible number of coefficients that this expression - * might have. If this expression might have an arbitrarily high number of coefficients, - * this value is set to \a Dynamic. - * - * This value is useful to know when evaluating an expression, in order to determine - * whether it is possible to avoid doing a dynamic memory allocation. - * - * \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime - */ - enum { MaxSizeAtCompileTime - = Derived::MaxRowsAtCompileTime == Dynamic || Derived::MaxColsAtCompileTime == Dynamic - ? Dynamic : Derived::MaxRowsAtCompileTime * Derived::MaxColsAtCompileTime - }; - - /** 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). */ - enum { IsVectorAtCompileTime - = Derived::RowsAtCompileTime == 1 || Derived::ColsAtCompileTime == 1 - }; + * This value is useful to know when evaluating an expression, in order to determine + * whether it is possible to avoid doing a dynamic memory allocation. + * + * \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime + */ + enum { MaxRowsAtCompileTime = ei_traits<Derived>::MaxRowsAtCompileTime }; + + /** This value is equal to the maximum possible number of columns that this expression + * might have. If this expression might have an arbitrarily high number of columns, + * this value is set to \a Dynamic. + * + * This value is useful to know when evaluating an expression, in order to determine + * whether it is possible to avoid doing a dynamic memory allocation. + * + * \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime + */ + enum { MaxColsAtCompileTime = ei_traits<Derived>::MaxColsAtCompileTime }; + + /** This value is equal to the maximum possible number of coefficients that this expression + * might have. If this expression might have an arbitrarily high number of coefficients, + * this value is set to \a Dynamic. + * + * This value is useful to know when evaluating an expression, in order to determine + * whether it is possible to avoid doing a dynamic memory allocation. + * + * \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime + */ + enum { MaxSizeAtCompileTime + = ei_traits<Derived>::MaxRowsAtCompileTime == Dynamic + || ei_traits<Derived>::MaxColsAtCompileTime == Dynamic + ? Dynamic + : ei_traits<Derived>::MaxRowsAtCompileTime * ei_traits<Derived>::MaxColsAtCompileTime + }; + + /** 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). */ + enum { IsVectorAtCompileTime + = ei_traits<Derived>::RowsAtCompileTime == 1 || ei_traits<Derived>::ColsAtCompileTime == 1 }; /** This is the "reference type" used to pass objects of type MatrixBase as arguments @@ -149,17 +147,17 @@ template<typename Derived> class MatrixBase /// \name matrix properties //@{ - /** \returns the number of rows. \sa cols(), Traits::RowsAtCompileTime */ + /** \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(), Traits::ColsAtCompileTime*/ + /** \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(), Traits::SizeAtCompileTime. */ + * \sa rows(), cols(), SizeAtCompileTime. */ int size() const { return rows() * cols(); } /** \returns true if either the number of rows or the number of columns is equal to 1. * In other words, this function returns * \code rows()==1 || cols()==1 \endcode - * \sa rows(), cols(), Traits::IsVectorAtCompileTime. */ + * \sa rows(), cols(), IsVectorAtCompileTime. */ bool isVector() const { return rows()==1 || cols()==1; } //@} |