[eigen] patch (enums) |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
Hi List, please find attached the patch for removing the "static const int" everywhere. Instead, using enums in classes and #defines for the global constants (just to test performance). Here, it does not at all change performance, both with g++-4.2 and g++-4.1! Therefore I am not so sure anymore if I want to move to enums. Please share your opinion! It seems to me that g++ had no problem at all optimizing the "static const int" as mere literals! Even if we move to enums I think I will revert the global constants to be "const int" instead of defines, as that is really cleaner. Cheers, Benoit
diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 92d8a1d..45a1eb7 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -67,8 +67,10 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block) private: - static const int RowsAtCompileTime = BlockRows, - ColsAtCompileTime = BlockCols; + enum{ + RowsAtCompileTime = BlockRows, + ColsAtCompileTime = BlockCols + }; const Block& _ref() const { return *this; } int _rows() const { return BlockRows; } diff --git a/Eigen/src/Core/Cast.h b/Eigen/src/Core/Cast.h index 73fdbc2..6963003 100644 --- a/Eigen/src/Core/Cast.h +++ b/Eigen/src/Core/Cast.h @@ -57,8 +57,10 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals, Cast(const MatRef& matrix) : m_matrix(matrix) {} private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime + }; const Cast& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } int _cols() const { return m_matrix.cols(); } diff --git a/Eigen/src/Core/Column.h b/Eigen/src/Core/Column.h index 53af215..5265bcb 100644 --- a/Eigen/src/Core/Column.h +++ b/Eigen/src/Core/Column.h @@ -63,8 +63,11 @@ template<typename MatrixType> class Column EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column) private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = 1; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = 1 + }; + const Column& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } int _cols() const { return 1; } diff --git a/Eigen/src/Core/Conjugate.h b/Eigen/src/Core/Conjugate.h index 48423e0..e99ca54 100644 --- a/Eigen/src/Core/Conjugate.h +++ b/Eigen/src/Core/Conjugate.h @@ -49,8 +49,10 @@ template<typename MatrixType> class Conjugate : NoOperatorEquals, Conjugate(const MatRef& matrix) : m_matrix(matrix) {} private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime + }; const Conjugate& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } diff --git a/Eigen/src/Core/DiagonalCoeffs.h b/Eigen/src/Core/DiagonalCoeffs.h index b3bc8c7..bd8ac2c 100644 --- a/Eigen/src/Core/DiagonalCoeffs.h +++ b/Eigen/src/Core/DiagonalCoeffs.h @@ -51,8 +51,10 @@ template<typename MatrixType> class DiagonalCoeffs EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs) private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = 1; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = 1 + }; const DiagonalCoeffs& _ref() const { return *this; } int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); } diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 9ce9871..b36bce1 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -52,16 +52,18 @@ class DiagonalMatrix : NoOperatorEquals, DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs) { assert(CoeffsVectorType::Traits::IsVectorAtCompileTime - && coeffs.size() > 0); + && coeffs.coeffs() > 0); } private: - static const int RowsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime, - ColsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime; + enum { + RowsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime, + ColsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime + }; const DiagonalMatrix& _ref() const { return *this; } - int _rows() const { return m_coeffs.size(); } - int _cols() const { return m_coeffs.size(); } + int _rows() const { return m_coeffs.coeffs(); } + int _cols() const { return m_coeffs.coeffs(); } Scalar _coeff(int row, int col) const { diff --git a/Eigen/src/Core/Difference.h b/Eigen/src/Core/Difference.h index 814ab93..ae4424a 100644 --- a/Eigen/src/Core/Difference.h +++ b/Eigen/src/Core/Difference.h @@ -55,8 +55,10 @@ template<typename Lhs, typename Rhs> class Difference : NoOperatorEquals, } private: - static const int RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime, - ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime, + ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime + }; const Difference& _ref() const { return *this; } int _rows() const { return m_lhs.rows(); } diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index 3ff416f..6b3ba11 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -46,7 +46,7 @@ struct DotUnroller<0, Size, Derived1, Derived2> }; template<int Index, typename Derived1, typename Derived2> -struct DotUnroller<Index, Dynamic, Derived1, Derived2> +struct DotUnroller<Index, EIGEN_DYNAMIC, Derived1, Derived2> { static void run(const Derived1&, const Derived2&, typename Derived1::Scalar&) {} }; @@ -74,10 +74,10 @@ Scalar MatrixBase<Scalar, Derived>::dot(const OtherDerived& other) const { assert(Traits::IsVectorAtCompileTime && OtherDerived::Traits::IsVectorAtCompileTime - && size() == other.size()); + && coeffs() == other.coeffs()); Scalar res; if(EIGEN_UNROLLED_LOOPS - && Traits::SizeAtCompileTime != Dynamic + && Traits::SizeAtCompileTime != EIGEN_DYNAMIC && Traits::SizeAtCompileTime <= 16) DotUnroller<Traits::SizeAtCompileTime-1, Traits::SizeAtCompileTime, Derived, OtherDerived> @@ -85,7 +85,7 @@ Scalar MatrixBase<Scalar, Derived>::dot(const OtherDerived& other) const else { res = (*this).coeff(0) * conj(other.coeff(0)); - for(int i = 1; i < size(); i++) + for(int i = 1; i < coeffs(); i++) res += (*this).coeff(i)* conj(other.coeff(i)); } return res; diff --git a/Eigen/src/Core/DynBlock.h b/Eigen/src/Core/DynBlock.h index da32bcd..ce545b3 100644 --- a/Eigen/src/Core/DynBlock.h +++ b/Eigen/src/Core/DynBlock.h @@ -67,9 +67,10 @@ template<typename MatrixType> class DynBlock EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DynBlock) private: - static const int - RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime == 1 ? 1 : Dynamic, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime == 1 ? 1 : Dynamic; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime == 1 ? 1 : EIGEN_DYNAMIC, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime == 1 ? 1 : EIGEN_DYNAMIC + }; const DynBlock& _ref() const { return *this; } int _rows() const { return m_blockRows; } diff --git a/Eigen/src/Core/Identity.h b/Eigen/src/Core/Identity.h index bf40acd..bf7b2de 100644 --- a/Eigen/src/Core/Identity.h +++ b/Eigen/src/Core/Identity.h @@ -45,8 +45,10 @@ template<typename MatrixType> class Identity : NoOperatorEquals, } private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime + }; const Identity& _ref() const { return *this; } int _rows() const { return m_rows; } diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index ca16d1a..e24623a 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -47,9 +47,11 @@ template<typename MatrixType> class Map friend class MatrixBase<Scalar, Map<MatrixType> >; private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; - static const MatrixStorageOrder _Order = MatrixType::StorageOrder; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime, + Order = MatrixType::StorageOrder + }; const Map& _ref() const { return *this; } int _rows() const { return m_rows; } @@ -57,17 +59,17 @@ template<typename MatrixType> class Map const Scalar& _coeff(int row, int col) const { - if(_Order == ColumnMajor) + if(Order == EIGEN_COLUMN_MAJOR) return m_data[row + col * m_rows]; - else // RowMajor + else // EIGEN_ROW_MAJOR return m_data[col + row * m_cols]; } Scalar& _coeffRef(int row, int col) { - if(_Order == ColumnMajor) + if(Order == EIGEN_COLUMN_MAJOR) return const_cast<Scalar*>(m_data)[row + col * m_rows]; - else // RowMajor + else // EIGEN_ROW_MAJOR return const_cast<Scalar*>(m_data)[col + row * m_cols]; } @@ -75,9 +77,9 @@ template<typename MatrixType> class Map Map(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols) { assert(rows > 0 - && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) + && (RowsAtCompileTime == EIGEN_DYNAMIC || RowsAtCompileTime == rows) && cols > 0 - && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); + && (ColsAtCompileTime == EIGEN_DYNAMIC || ColsAtCompileTime == cols)); } EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map) @@ -88,7 +90,7 @@ template<typename MatrixType> class Map }; /** This is the const version of map(Scalar*,int,int). */ -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int rows, int cols) { @@ -96,7 +98,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int rows, } /** This is the const version of map(Scalar*,int). */ -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int size) { @@ -108,7 +110,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int size) } /** This is the const version of map(Scalar*). */ -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data) { @@ -126,7 +128,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data) * * \sa map(const Scalar*, int, int), map(Scalar*, int), map(Scalar*), class Map */ -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int rows, int cols) { @@ -145,7 +147,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int rows, int co * * \sa map(const Scalar*, int), map(Scalar*, int, int), map(Scalar*), class Map */ -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int size) { @@ -165,7 +167,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int size) * * \sa map(const Scalar*), map(Scalar*, int), map(Scalar*, int, int), class Map */ -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data) { @@ -180,7 +182,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data) * * \sa Matrix(const Scalar *), Matrix::map(const Scalar *, int, int) */ -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> Matrix<_Scalar, _Rows, _Cols, _StorageOrder> ::Matrix(const Scalar *data, int rows, int cols) : Storage(rows, cols) @@ -198,7 +200,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder> * * \sa Matrix(const Scalar *), Matrix::map(const Scalar *, int) */ -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> Matrix<_Scalar, _Rows, _Cols, _StorageOrder> ::Matrix(const Scalar *data, int size) : Storage(size) @@ -216,7 +218,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder> * \sa Matrix(const Scalar *, int), Matrix(const Scalar *, int, int), * Matrix::map(const Scalar *) */ -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> Matrix<_Scalar, _Rows, _Cols, _StorageOrder> ::Matrix(const Scalar *data) : Storage() diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 0165d5a..f1e6b8e 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -31,11 +31,11 @@ * \brief The matrix class, also used for vectors and row-vectors * * \param _Scalar the scalar type, i.e. the type of the coefficients - * \param _Rows the number of rows at compile-time. Use the special value \a Dynamic to specify that the number of rows is dynamic, i.e. is not fixed at compile-time. - * \param _Cols the number of columns at compile-time. Use the special value \a Dynamic to specify that the number of columns is dynamic, i.e. is not fixed at compile-time. - * \param _StorageOrder can be either \a RowMajor or \a ColumnMajor. + * \param _Rows the number of rows at compile-time. Use the special value \a EIGEN_DYNAMIC to specify that the number of rows is dynamic, i.e. is not fixed at compile-time. + * \param _Cols the number of columns at compile-time. Use the special value \a EIGEN_DYNAMIC to specify that the number of columns is dynamic, i.e. is not fixed at compile-time. + * \param _StorageOrder can be either \a EIGEN_ROW_MAJOR or \a EIGEN_COLUMN_MAJOR. * This template parameter has a default value (EIGEN_DEFAULT_MATRIX_STORAGE_ORDER) - * which, if not predefined, is defined to \a ColumnMajor. You can override this behavior by + * which, if not predefined, is defined to \a EIGEN_COLUMN_MAJOR. You can override this behavior by * predefining it before including Eigen headers. * * This single class template covers all kinds of matrix and vectors that Eigen can handle. @@ -61,7 +61,7 @@ * * Examples: * \li \c Matrix2d is a typedef for \c Matrix<double,2,2> - * \li \c VectorXf is a typedef for \c Matrix<float,Dynamic,1> + * \li \c VectorXf is a typedef for \c Matrix<float,EIGEN_DYNAMIC,1> * \li \c RowVector3i is a typedef for \c Matrix<int,1,3> * * Of course these typedefs do not exhaust all the possibilities offered by the Matrix class @@ -70,10 +70,10 @@ * \c Matrix<double,3,5>. * * Note that most of the API is in the base class MatrixBase, and that the base class - * MatrixStorage also provides the MatrixStorage::resize() public method. + * MatrixStorage also provides the MatrixStorage::recoeffs() public method. */ template<typename _Scalar, int _Rows, int _Cols, - MatrixStorageOrder _StorageOrder = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER> + int _StorageOrder = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER> class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >, public MatrixStorage<_Scalar, _Rows, _Cols> { @@ -96,24 +96,27 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage { return Storage::m_data; } private: - static const int RowsAtCompileTime = _Rows, ColsAtCompileTime = _Cols; - static const MatrixStorageOrder StorageOrder = _StorageOrder; + enum { + RowsAtCompileTime = _Rows, + ColsAtCompileTime = _Cols, + StorageOrder = _StorageOrder + }; Ref _ref() const { return Ref(*this); } const Scalar& _coeff(int row, int col) const { - if(_StorageOrder == ColumnMajor) + if(_StorageOrder == EIGEN_COLUMN_MAJOR) return (Storage::m_data)[row + col * Storage::_rows()]; - else // RowMajor + else // EIGEN_ROW_MAJOR return (Storage::m_data)[col + row * Storage::_cols()]; } Scalar& _coeffRef(int row, int col) { - if(_StorageOrder == ColumnMajor) + if(_StorageOrder == EIGEN_COLUMN_MAJOR) return (Storage::m_data)[row + col * Storage::_rows()]; - else // RowMajor + else // EIGEN_ROW_MAJOR return (Storage::m_data)[col + row * Storage::_cols()]; } @@ -132,12 +135,12 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage if(RowsAtCompileTime == 1) { assert(other.isVector()); - resize(1, other.size()); + resize(1, other.coeffs()); } else if(ColsAtCompileTime == 1) { assert(other.isVector()); - resize(other.size(), 1); + resize(other.coeffs(), 1); } else resize(other.rows(), other.cols()); return Base::operator=(other); @@ -182,9 +185,9 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage { assert(dim > 0); assert((RowsAtCompileTime == 1 - && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == dim)) + && (ColsAtCompileTime == EIGEN_DYNAMIC || ColsAtCompileTime == dim)) || (ColsAtCompileTime == 1 - && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == dim))); + && (RowsAtCompileTime == EIGEN_DYNAMIC || RowsAtCompileTime == dim))); } /** This constructor has two very different behaviors, depending on the type of *this. @@ -207,8 +210,8 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage } else { - assert(x > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == x) - && y > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == y)); + assert(x > 0 && (RowsAtCompileTime == EIGEN_DYNAMIC || RowsAtCompileTime == x) + && y > 0 && (ColsAtCompileTime == EIGEN_DYNAMIC || ColsAtCompileTime == y)); } } /** constructs an initialized 2D vector with given coefficients */ @@ -275,7 +278,7 @@ typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix; EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ -EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) +EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, EIGEN_DYNAMIC, X) EIGEN_MAKE_TYPEDEFS_ALL_SIZES(int, i) EIGEN_MAKE_TYPEDEFS_ALL_SIZES(float, f) diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index a32568d..a81e0ff 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -62,29 +62,31 @@ template<typename Scalar, typename Derived> class MatrixBase { /** 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. + * it is set to the \a EIGEN_DYNAMIC constant. * \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */ - static const int RowsAtCompileTime = Derived::RowsAtCompileTime; + 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. + * it is set to the \a EIGEN_DYNAMIC constant. * \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */ - static const int ColsAtCompileTime = Derived::ColsAtCompileTime; + 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 + * rows times the number of columns, or to \a EIGEN_DYNAMIC if this is not * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */ - static const int SizeAtCompileTime - = Derived::RowsAtCompileTime == Dynamic || Derived::ColsAtCompileTime == Dynamic - ? Dynamic : Derived::RowsAtCompileTime * Derived::ColsAtCompileTime; + enum { SizeAtCompileTime + = Derived::RowsAtCompileTime == EIGEN_DYNAMIC || Derived::ColsAtCompileTime == EIGEN_DYNAMIC + ? EIGEN_DYNAMIC : Derived::RowsAtCompileTime * Derived::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 IsVectorAtCompileTime - = Derived::RowsAtCompileTime == 1 || Derived::ColsAtCompileTime == 1; + enum { IsVectorAtCompileTime + = Derived::RowsAtCompileTime == 1 || Derived::ColsAtCompileTime == 1 + }; }; /** This is the "reference type" used to pass objects of type MatrixBase as arguments @@ -113,7 +115,7 @@ template<typename Scalar, typename Derived> class MatrixBase 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. */ - int size() const { return rows() * cols(); } + int coeffs() 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 diff --git a/Eigen/src/Core/MatrixRef.h b/Eigen/src/Core/MatrixRef.h index 0d97f9b..ce097fd 100644 --- a/Eigen/src/Core/MatrixRef.h +++ b/Eigen/src/Core/MatrixRef.h @@ -39,8 +39,10 @@ template<typename MatrixType> class MatrixRef EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef) private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime + }; int _rows() const { return m_matrix.rows(); } int _cols() const { return m_matrix.cols(); } diff --git a/Eigen/src/Core/MatrixStorage.h b/Eigen/src/Core/MatrixStorage.h index ebeaf49..cc4b158 100644 --- a/Eigen/src/Core/MatrixStorage.h +++ b/Eigen/src/Core/MatrixStorage.h @@ -55,7 +55,7 @@ class MatrixStorage }; template<typename Scalar, int ColsAtCompileTime> -class MatrixStorage<Scalar, Dynamic, ColsAtCompileTime> +class MatrixStorage<Scalar, EIGEN_DYNAMIC, ColsAtCompileTime> { protected: int m_rows; @@ -98,7 +98,7 @@ class MatrixStorage<Scalar, Dynamic, ColsAtCompileTime> }; template<typename Scalar, int RowsAtCompileTime> -class MatrixStorage<Scalar, RowsAtCompileTime, Dynamic> +class MatrixStorage<Scalar, RowsAtCompileTime, EIGEN_DYNAMIC> { protected: int m_cols; @@ -141,7 +141,7 @@ class MatrixStorage<Scalar, RowsAtCompileTime, Dynamic> }; template<typename Scalar> -class MatrixStorage<Scalar, Dynamic, Dynamic> +class MatrixStorage<Scalar, EIGEN_DYNAMIC, EIGEN_DYNAMIC> { protected: int m_rows, m_cols; diff --git a/Eigen/src/Core/Minor.h b/Eigen/src/Core/Minor.h index c846e16..78ed365 100644 --- a/Eigen/src/Core/Minor.h +++ b/Eigen/src/Core/Minor.h @@ -57,11 +57,12 @@ template<typename MatrixType> class Minor EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor) private: - static const int - RowsAtCompileTime = (MatrixType::Traits::RowsAtCompileTime != Dynamic) ? - MatrixType::Traits::RowsAtCompileTime - 1 : Dynamic, - ColsAtCompileTime = (MatrixType::Traits::ColsAtCompileTime != Dynamic) ? - MatrixType::Traits::ColsAtCompileTime - 1 : Dynamic; + enum { + RowsAtCompileTime = (MatrixType::Traits::RowsAtCompileTime != EIGEN_DYNAMIC) ? + MatrixType::Traits::RowsAtCompileTime - 1 : EIGEN_DYNAMIC, + ColsAtCompileTime = (MatrixType::Traits::ColsAtCompileTime != EIGEN_DYNAMIC) ? + MatrixType::Traits::ColsAtCompileTime - 1 : EIGEN_DYNAMIC + }; const Minor& _ref() const { return *this; } int _rows() const { return m_matrix.rows() - 1; } diff --git a/Eigen/src/Core/NumTraits.h b/Eigen/src/Core/NumTraits.h index bb6d5de..ae540da 100644 --- a/Eigen/src/Core/NumTraits.h +++ b/Eigen/src/Core/NumTraits.h @@ -41,10 +41,10 @@ * \li A typedef \a FloatingPoint, giving the "floating-point type" of \a T. If \a T is * \c int, then \a FloatingPoint is a typedef to \c double. Otherwise, \a FloatingPoint * is a typedef to \a T. - * \li A static const bool \a IsComplex. It is equal to \c true if \a T is a \c std::complex - * type, and to false otherwise. - * \li A static const bool \a HasFloatingPoint. It is equal to \c false if \a T is \c int, - * and to \c true otherwise. + * \li An enum value \a IsComplex. It is equal to 1 if \a T is a \c std::complex + * type, and to 0 otherwise. + * \li An enum \a HasFloatingPoint. It is equal to \c 0 if \a T is \c int, + * and to \c 1 otherwise. */ template<typename T> struct NumTraits; @@ -52,32 +52,40 @@ template<> struct NumTraits<int> { typedef int Real; typedef double FloatingPoint; - static const bool IsComplex = false; - static const bool HasFloatingPoint = false; + enum { + IsComplex = 0, + HasFloatingPoint = 0 + }; }; template<> struct NumTraits<float> { typedef float Real; typedef float FloatingPoint; - static const bool IsComplex = false; - static const bool HasFloatingPoint = true; + enum { + IsComplex = 0, + HasFloatingPoint = 1 + }; }; template<> struct NumTraits<double> { typedef double Real; typedef double FloatingPoint; - static const bool IsComplex = false; - static const bool HasFloatingPoint = true; + enum { + IsComplex = 0, + HasFloatingPoint = 1 + }; }; template<typename _Real> struct NumTraits<std::complex<_Real> > { typedef _Real Real; typedef std::complex<_Real> FloatingPoint; - static const bool IsComplex = true; - static const bool HasFloatingPoint = NumTraits<Real>::HasFloatingPoint; + enum { + IsComplex = 1, + HasFloatingPoint = 1 // anyway we don't allow std::complex<int> + }; }; #endif // EIGEN_NUMTRAITS_H diff --git a/Eigen/src/Core/Ones.h b/Eigen/src/Core/Ones.h index 3bb1142..31a369d 100644 --- a/Eigen/src/Core/Ones.h +++ b/Eigen/src/Core/Ones.h @@ -40,8 +40,10 @@ template<typename MatrixType> class Ones : NoOperatorEquals, friend class MatrixBase<Scalar, Ones<MatrixType> >; private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime + }; const Ones& _ref() const { return *this; } int _rows() const { return m_rows; } @@ -56,9 +58,9 @@ template<typename MatrixType> class Ones : NoOperatorEquals, Ones(int rows, int cols) : m_rows(rows), m_cols(cols) { assert(rows > 0 - && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) + && (RowsAtCompileTime == EIGEN_DYNAMIC || RowsAtCompileTime == rows) && cols > 0 - && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); + && (ColsAtCompileTime == EIGEN_DYNAMIC || ColsAtCompileTime == cols)); } protected: diff --git a/Eigen/src/Core/OperatorEquals.h b/Eigen/src/Core/OperatorEquals.h index 4fe3dbe..5ef20d3 100644 --- a/Eigen/src/Core/OperatorEquals.h +++ b/Eigen/src/Core/OperatorEquals.h @@ -30,8 +30,10 @@ template<typename Derived1, typename Derived2, int UnrollCount> struct MatrixOperatorEqualsUnroller { - static const int col = (UnrollCount-1) / Derived1::Traits::RowsAtCompileTime; - static const int row = (UnrollCount-1) % Derived1::Traits::RowsAtCompileTime; + enum { + col = (UnrollCount-1) / Derived1::Traits::RowsAtCompileTime, + row = (UnrollCount-1) % Derived1::Traits::RowsAtCompileTime + }; static void run(Derived1 &dst, const Derived2 &src) { @@ -57,7 +59,7 @@ struct MatrixOperatorEqualsUnroller<Derived1, Derived2, 0> }; template<typename Derived1, typename Derived2> -struct MatrixOperatorEqualsUnroller<Derived1, Derived2, Dynamic> +struct MatrixOperatorEqualsUnroller<Derived1, Derived2, EIGEN_DYNAMIC> { static void run(Derived1 &, const Derived2 &) {} }; @@ -65,7 +67,7 @@ struct MatrixOperatorEqualsUnroller<Derived1, Derived2, Dynamic> template<typename Derived1, typename Derived2, int UnrollCount> struct VectorOperatorEqualsUnroller { - static const int index = UnrollCount - 1; + enum { index = UnrollCount - 1 }; static void run(Derived1 &dst, const Derived2 &src) { @@ -91,7 +93,7 @@ struct VectorOperatorEqualsUnroller<Derived1, Derived2, 1> }; template<typename Derived1, typename Derived2> -struct VectorOperatorEqualsUnroller<Derived1, Derived2, Dynamic> +struct VectorOperatorEqualsUnroller<Derived1, Derived2, EIGEN_DYNAMIC> { static void run(Derived1 &, const Derived2 &) {} }; @@ -104,20 +106,20 @@ Derived& MatrixBase<Scalar, Derived> if(Traits::IsVectorAtCompileTime && OtherDerived::Traits::IsVectorAtCompileTime) // copying a vector expression into a vector { - assert(size() == other.size()); - if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 25) + assert(coeffs() == other.coeffs()); + if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != EIGEN_DYNAMIC && Traits::SizeAtCompileTime <= 25) VectorOperatorEqualsUnroller <Derived, OtherDerived, Traits::SizeAtCompileTime>::run (*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other)); else - for(int i = 0; i < size(); i++) + for(int i = 0; i < coeffs(); i++) coeffRef(i) = other.coeff(i); return *static_cast<Derived*>(this); } else // copying a matrix expression into a matrix { assert(rows() == other.rows() && cols() == other.cols()); - if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 25) + if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != EIGEN_DYNAMIC && Traits::SizeAtCompileTime <= 25) MatrixOperatorEqualsUnroller <Derived, OtherDerived, Traits::SizeAtCompileTime>::run (*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other)); diff --git a/Eigen/src/Core/Opposite.h b/Eigen/src/Core/Opposite.h index 7f7aabd..93f0fe1 100644 --- a/Eigen/src/Core/Opposite.h +++ b/Eigen/src/Core/Opposite.h @@ -49,8 +49,10 @@ template<typename MatrixType> class Opposite : NoOperatorEquals, Opposite(const MatRef& matrix) : m_matrix(matrix) {} private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime + }; const Opposite& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 71e29a0..ddd90db 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -48,7 +48,7 @@ struct ProductUnroller<0, Size, Lhs, Rhs> }; template<int Index, typename Lhs, typename Rhs> -struct ProductUnroller<Index, Dynamic, Lhs, Rhs> +struct ProductUnroller<Index, EIGEN_DYNAMIC, Lhs, Rhs> { static void run(int, int, const Lhs&, const Rhs&, typename Lhs::Scalar&) {} }; @@ -89,8 +89,10 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals, } private: - static const int RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime, - ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime, + ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime + }; const Product& _ref() const { return *this; } int _rows() const { return m_lhs.rows(); } @@ -100,7 +102,7 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals, { Scalar res; if(EIGEN_UNROLLED_LOOPS - && Lhs::Traits::ColsAtCompileTime != Dynamic + && Lhs::Traits::ColsAtCompileTime != EIGEN_DYNAMIC && Lhs::Traits::ColsAtCompileTime <= 16) ProductUnroller<Lhs::Traits::ColsAtCompileTime-1, Lhs::Traits::ColsAtCompileTime, LhsRef, RhsRef> diff --git a/Eigen/src/Core/Random.h b/Eigen/src/Core/Random.h index bbc74ec..c78808c 100644 --- a/Eigen/src/Core/Random.h +++ b/Eigen/src/Core/Random.h @@ -40,8 +40,10 @@ template<typename MatrixType> class Random : NoOperatorEquals, friend class MatrixBase<Scalar, Random<MatrixType> >; private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime + }; const Random& _ref() const { return *this; } int _rows() const { return m_rows; } @@ -56,9 +58,9 @@ template<typename MatrixType> class Random : NoOperatorEquals, Random(int rows, int cols) : m_rows(rows), m_cols(cols) { assert(rows > 0 - && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) + && (RowsAtCompileTime == EIGEN_DYNAMIC || RowsAtCompileTime == rows) && cols > 0 - && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); + && (ColsAtCompileTime == EIGEN_DYNAMIC || ColsAtCompileTime == cols)); } protected: diff --git a/Eigen/src/Core/Row.h b/Eigen/src/Core/Row.h index 5fcab9e..f120f0c 100644 --- a/Eigen/src/Core/Row.h +++ b/Eigen/src/Core/Row.h @@ -69,8 +69,10 @@ template<typename MatrixType> class Row EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row) private: - static const int RowsAtCompileTime = 1, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = 1, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime + }; const Row& _ref() const { return *this; } diff --git a/Eigen/src/Core/ScalarMultiple.h b/Eigen/src/Core/ScalarMultiple.h index e8261f5..c9f15bf 100644 --- a/Eigen/src/Core/ScalarMultiple.h +++ b/Eigen/src/Core/ScalarMultiple.h @@ -49,8 +49,10 @@ template<typename FactorType, typename MatrixType> class ScalarMultiple : NoOper : m_matrix(matrix), m_factor(factor) {} private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime + }; const ScalarMultiple& _ref() const { return *this; } int _rows() const { return m_matrix.rows(); } diff --git a/Eigen/src/Core/Sum.h b/Eigen/src/Core/Sum.h index 93cfc4e..7cdedcf 100644 --- a/Eigen/src/Core/Sum.h +++ b/Eigen/src/Core/Sum.h @@ -55,8 +55,10 @@ template<typename Lhs, typename Rhs> class Sum : NoOperatorEquals, } private: - static const int RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime, - ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime, + ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime + }; const Sum& _ref() const { return *this; } int _rows() const { return m_lhs.rows(); } diff --git a/Eigen/src/Core/Trace.h b/Eigen/src/Core/Trace.h index e87ffec..0e57696 100644 --- a/Eigen/src/Core/Trace.h +++ b/Eigen/src/Core/Trace.h @@ -43,7 +43,7 @@ template<int Rows, typename Derived> struct TraceUnroller<0, Rows, Derived> } }; -template<int Index, typename Derived> struct TraceUnroller<Index, Dynamic, Derived> +template<int Index, typename Derived> struct TraceUnroller<Index, EIGEN_DYNAMIC, Derived> { static void run(const Derived&, typename Derived::Scalar&) {} }; @@ -62,7 +62,7 @@ Scalar MatrixBase<Scalar, Derived>::trace() const { assert(rows() == cols()); Scalar res; - if(EIGEN_UNROLLED_LOOPS && Traits::RowsAtCompileTime != Dynamic && Traits::RowsAtCompileTime <= 16) + if(EIGEN_UNROLLED_LOOPS && Traits::RowsAtCompileTime != EIGEN_DYNAMIC && Traits::RowsAtCompileTime <= 16) TraceUnroller<Traits::RowsAtCompileTime-1, Traits::RowsAtCompileTime, Derived> ::run(*static_cast<const Derived*>(this), res); else diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index fbb37bc..21e6168 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -51,8 +51,10 @@ template<typename MatrixType> class Transpose EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose) private: - static const int RowsAtCompileTime = MatrixType::Traits::ColsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::RowsAtCompileTime; + enum { + RowsAtCompileTime = MatrixType::Traits::ColsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::RowsAtCompileTime + }; const Transpose& _ref() const { return *this; } int _rows() const { return m_matrix.cols(); } diff --git a/Eigen/src/Core/Util.h b/Eigen/src/Core/Util.h index 288d999..09c2c65 100644 --- a/Eigen/src/Core/Util.h +++ b/Eigen/src/Core/Util.h @@ -32,8 +32,10 @@ #define EIGEN_UNROLLED_LOOPS (true) #endif -#ifndef EIGEN_DEFAULT_MATRIX_STORAGE_ORDER -#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER ColumnMajor +#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR +#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER EIGEN_ROW_MAJOR +#else +#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER EIGEN_COLUMN_MAJOR #endif #undef minor @@ -86,16 +88,13 @@ EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \ EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \ EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=) -const int Dynamic = -1; - -enum MatrixStorageOrder -{ - ColumnMajor, - RowMajor -}; +#define EIGEN_DYNAMIC -1 +#define EIGEN_GENERIC -2 +#define EIGEN_COLUMN_MAJOR 0 +#define EIGEN_ROW_MAJOR 1 //forward declarations -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> class Matrix; template<typename MatrixType> class MatrixRef; template<typename NewScalar, typename MatrixType> class Cast; @@ -125,7 +124,7 @@ template<typename T> struct ForwardDecl typedef T Ref; }; -template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder> +template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder> struct ForwardDecl<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> > { typedef MatrixRef<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> > Ref; diff --git a/Eigen/src/Core/Zero.h b/Eigen/src/Core/Zero.h index 76c13b4..6ed4d65 100644 --- a/Eigen/src/Core/Zero.h +++ b/Eigen/src/Core/Zero.h @@ -40,8 +40,10 @@ template<typename MatrixType> class Zero : NoOperatorEquals, friend class MatrixBase<Scalar, Zero<MatrixType> >; private: - static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime; + enum { + RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime + }; const Zero& _ref() const { return *this; } int _rows() const { return m_rows; } @@ -56,9 +58,9 @@ template<typename MatrixType> class Zero : NoOperatorEquals, Zero(int rows, int cols) : m_rows(rows), m_cols(cols) { assert(rows > 0 - && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) + && (RowsAtCompileTime == EIGEN_DYNAMIC || RowsAtCompileTime == rows) && cols > 0 - && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); + && (ColsAtCompileTime == EIGEN_DYNAMIC || ColsAtCompileTime == cols)); } protected: diff --git a/doc/benchmark_suite b/doc/benchmark_suite index b75a8df..871acf4 100755 --- a/doc/benchmark_suite +++ b/doc/benchmark_suite @@ -1,16 +1,16 @@ -echo "Fixed size 3x3, ColumnMajor, -DNDEBUG" -g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=ColumnMajor -DNDEBUG benchmark.cpp -o benchmark && time ./benchmark >/dev/null -echo "Fixed size 3x3, ColumnMajor, with asserts" -g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=ColumnMajor benchmark.cpp -o benchmark && time ./benchmark >/dev/null -echo "Fixed size 3x3, RowMajor, -DNDEBUG" -g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=RowMajor -DNDEBUG benchmark.cpp -o benchmark && time ./benchmark >/dev/null -echo "Fixed size 3x3, RowMajor, with asserts" -g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=RowMajor benchmark.cpp -o benchmark && time ./benchmark >/dev/null -echo "Dynamic size 20x20, ColumnMajor, -DNDEBUG" -g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=ColumnMajor -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null -echo "Dynamic size 20x20, ColumnMajor, with asserts" -g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=ColumnMajor benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null -echo "Dynamic size 20x20, RowMajor, -DNDEBUG" -g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=RowMajor -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null -echo "Dynamic size 20x20, RowMajor, with asserts" -g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=RowMajor benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null +echo "Fixed size 3x3, EIGEN_COLUMN_MAJOR, -DNDEBUG" +g++ -O3 -I .. -DNDEBUG benchmark.cpp -o benchmark && time ./benchmark >/dev/null +echo "Fixed size 3x3, EIGEN_COLUMN_MAJOR, with asserts" +g++ -O3 -I .. benchmark.cpp -o benchmark && time ./benchmark >/dev/null +echo "Fixed size 3x3, EIGEN_ROW_MAJOR, -DNDEBUG" +g++ -O3 -I .. -DEIGEN_DEFAULT_TO_ROW_MAJOR -DNDEBUG benchmark.cpp -o benchmark && time ./benchmark >/dev/null +echo "Fixed size 3x3, EIGEN_ROW_MAJOR, with asserts" +g++ -O3 -I .. -DEIGEN_DEFAULT_TO_ROW_MAJOR benchmark.cpp -o benchmark && time ./benchmark >/dev/null +echo "EIGEN_DYNAMIC size 20x20, EIGEN_COLUMN_MAJOR, -DNDEBUG" +g++ -O3 -I .. -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null +echo "EIGEN_DYNAMIC size 20x20, EIGEN_COLUMN_MAJOR, with asserts" +g++ -O3 -I .. benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null +echo "EIGEN_DYNAMIC size 20x20, EIGEN_ROW_MAJOR, -DNDEBUG" +g++ -O3 -I .. -DEIGEN_DEFAULT_TO_ROW_MAJOR -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null +echo "EIGEN_DYNAMIC size 20x20, EIGEN_ROW_MAJOR, with asserts" +g++ -O3 -I .. -DEIGEN_DEFAULT_TO_ROW_MAJOR benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null diff --git a/test/main.h b/test/main.h index d914a14..93badad 100644 --- a/test/main.h +++ b/test/main.h @@ -28,7 +28,7 @@ #include <QtTest/QtTest> -//#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor +//#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER EIGEN_ROW_MAJOR #define EIGEN_INTERNAL_DEBUGGING #include <Eigen/Core> diff --git a/test/map.cpp b/test/map.cpp index 4f28a85..99de551 100644 --- a/test/map.cpp +++ b/test/map.cpp @@ -31,7 +31,7 @@ template<typename VectorType> void tmap(const VectorType& m) { typedef typename VectorType::Scalar Scalar; - int size = m.size(); + int size = m.coeffs(); // test Map.h Scalar* array1 = new Scalar[size]; diff --git a/test/submatrices.cpp b/test/submatrices.cpp index 9981d9f..2a61956 100644 --- a/test/submatrices.cpp +++ b/test/submatrices.cpp @@ -67,7 +67,7 @@ template<typename MatrixType> void submatrices(const MatrixType& m) m1.col(c1) += s1 * m1.col(c2); //check dynBlock() - Matrix<Scalar,Dynamic,Dynamic> b1(1,1); b1(0,0) = m1(r1,c1); + Matrix<Scalar,EIGEN_DYNAMIC,EIGEN_DYNAMIC> b1(1,1); b1(0,0) = m1(r1,c1); RowVectorType br1(m1.dynBlock(r1,0,1,cols)); VectorType bc1(m1.dynBlock(0,c1,rows,1)); VERIFY_IS_APPROX(b1, m1.dynBlock(r1,c1,1,1)); @@ -80,7 +80,7 @@ template<typename MatrixType> void submatrices(const MatrixType& m) //check minor() if(rows > 1 && cols > 1) { - Matrix<Scalar, Dynamic, Dynamic> mi = m1.minor(0,0).eval(); + Matrix<Scalar, EIGEN_DYNAMIC, EIGEN_DYNAMIC> mi = m1.minor(0,0).eval(); VERIFY_IS_APPROX(mi, m1.dynBlock(1,1,rows-1,cols-1)); mi = m1.minor(r1,c1); VERIFY_IS_APPROX(mi.transpose(), m1.transpose().minor(c1,r1));
Attachment:
signature.asc
Description: This is a digitally signed message part.
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |