From 5ca90e1b0c031eb18ea2096eb2054a19d4e2e146 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 17 Dec 2009 13:56:33 +0100 Subject: some cleaning in DenseStorageBase --- Eigen/src/Core/CwiseNullaryOp.h | 84 +++++++++++++++++++-------------------- Eigen/src/Core/DenseStorageBase.h | 76 +++++++++-------------------------- Eigen/src/Core/Matrix.h | 5 +-- 3 files changed, 62 insertions(+), 103 deletions(-) (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h index 9b4c705cd..c326ebae2 100644 --- a/Eigen/src/Core/CwiseNullaryOp.h +++ b/Eigen/src/Core/CwiseNullaryOp.h @@ -278,13 +278,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase::setConstant(const Scalar& value * * \sa MatrixBase::setConstant(const Scalar&), setConstant(int,int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&) */ -// template -// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& -// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setConstant(int size, const Scalar& value) -// { -// resize(size); -// return setConstant(value); -// } +template class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase::setConstant(int size, const Scalar& value) +{ + resize(size); + return setConstant(value); +} /** Resizes to the given size, and sets all coefficients in this expression to the given \a value. * @@ -296,13 +296,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase::setConstant(const Scalar& value * * \sa MatrixBase::setConstant(const Scalar&), setConstant(int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&) */ -// template -// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& -// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setConstant(int rows, int cols, const Scalar& value) -// { -// resize(rows, cols); -// return setConstant(value); -// } +template class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase::setConstant(int rows, int cols, const Scalar& value) +{ + resize(rows, cols); + return setConstant(value); +} // zero: @@ -408,13 +408,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase::setZero() * * \sa DenseBase::setZero(), setZero(int,int), class CwiseNullaryOp, DenseBase::Zero() */ -// template -// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& -// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setZero(int size) -// { -// resize(size); -// return setConstant(Scalar(0)); -// } +template class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase::setZero(int size) +{ + resize(size); + return setConstant(Scalar(0)); +} /** Resizes to the given size, and sets all coefficients in this expression to zero. * @@ -426,13 +426,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase::setZero() * * \sa DenseBase::setZero(), setZero(int), class CwiseNullaryOp, DenseBase::Zero() */ -// template -// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& -// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setZero(int rows, int cols) -// { -// resize(rows, cols); -// return setConstant(Scalar(0)); -// } +template class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase::setZero(int rows, int cols) +{ + resize(rows, cols); + return setConstant(Scalar(0)); +} // ones: @@ -534,13 +534,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase::setOnes() * * \sa MatrixBase::setOnes(), setOnes(int,int), class CwiseNullaryOp, MatrixBase::Ones() */ -// template -// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& -// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setOnes(int size) -// { -// resize(size); -// return setConstant(Scalar(1)); -// } +template class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase::setOnes(int size) +{ + resize(size); + return setConstant(Scalar(1)); +} /** Resizes to the given size, and sets all coefficients in this expression to one. * @@ -552,13 +552,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase::setOnes() * * \sa MatrixBase::setOnes(), setOnes(int), class CwiseNullaryOp, MatrixBase::Ones() */ -// template -// EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& -// Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setOnes(int rows, int cols) -// { -// resize(rows, cols); -// return setConstant(Scalar(1)); -// } +template class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase::setOnes(int rows, int cols) +{ + resize(rows, cols); + return setConstant(Scalar(1)); +} // Identity: diff --git a/Eigen/src/Core/DenseStorageBase.h b/Eigen/src/Core/DenseStorageBase.h index 67506d80b..abe57b6bc 100644 --- a/Eigen/src/Core/DenseStorageBase.h +++ b/Eigen/src/Core/DenseStorageBase.h @@ -35,7 +35,7 @@ template (Derived::IsVectorAtCompileTime)> struct ei_conservative_resize_like_impl; template struct ei_matrix_swap_impl; -template class _Base, typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> +template class _Base, int _Options> class DenseStorageBase : public _Base { public: @@ -402,60 +402,20 @@ class DenseStorageBase : public _Base //@} using Base::setConstant; - /** Resizes to the given \a size, and sets all coefficients in this expression to the given \a value. - * - * \only_for_vectors - * - * Example: \include Matrix_setConstant_int.cpp - * Output: \verbinclude Matrix_setConstant_int.out - * - * \sa MatrixBase::setConstant(const Scalar&), setConstant(int,int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&) - */ - Derived& setConstant(int size, const Scalar& value) - { - resize(size); - return setConstant(value); - } - - /** Resizes to the given size, and sets all coefficients in this expression to the given \a value. - * - * \param rows the new number of rows - * \param cols the new number of columns - * - * Example: \include Matrix_setConstant_int_int.cpp - * Output: \verbinclude Matrix_setConstant_int_int.out - * - * \sa MatrixBase::setConstant(const Scalar&), setConstant(int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&) - */ - Derived& setConstant(int rows, int cols, const Scalar& value) - { - resize(rows, cols); - return setConstant(value); - } + Derived& setConstant(int size, const Scalar& value); + Derived& setConstant(int rows, int cols, const Scalar& value); using Base::setZero; - Derived& setZero(int size) - { return setConstant(size, Scalar(0)); } - Derived& setZero(int rows, int cols) - { return setConstant(rows, cols, Scalar(0)); } + Derived& setZero(int size); + Derived& setZero(int rows, int cols); using Base::setOnes; - Derived& setOnes(int size) - { return setConstant(size, Scalar(1)); } - Derived& setOnes(int rows, int cols) - { return setConstant(rows, cols, Scalar(1)); } + Derived& setOnes(int size); + Derived& setOnes(int rows, int cols); using Base::setRandom; - Derived& setRandom(int size) - { - resize(size); - return setRandom(); - } - Derived& setRandom(int rows, int cols) - { - resize(rows, cols); - return setRandom(); - } + Derived& setRandom(int size); + Derived& setRandom(int rows, int cols); #ifdef EIGEN_DENSESTORAGEBASE_PLUGIN #include EIGEN_DENSESTORAGEBASE_PLUGIN @@ -524,15 +484,15 @@ class DenseStorageBase : public _Base EIGEN_DEBUG_MATRIX_CTOR; #endif - EIGEN_STATIC_ASSERT(((_Rows >= _MaxRows) - && (_Cols >= _MaxCols) - && (_MaxRows >= 0) - && (_MaxCols >= 0) - && (_Rows <= Dynamic) - && (_Cols <= Dynamic) - && (_MaxRows == _Rows || _Rows==Dynamic) - && (_MaxCols == _Cols || _Cols==Dynamic) - && ((_MaxRows==Dynamic?1:_MaxRows)*(_MaxCols==Dynamic?1:_MaxCols)= MaxRowsAtCompileTime) + && (ColsAtCompileTime >= MaxColsAtCompileTime) + && (MaxRowsAtCompileTime >= 0) + && (MaxColsAtCompileTime >= 0) + && (RowsAtCompileTime <= Dynamic) + && (ColsAtCompileTime <= Dynamic) + && (MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==Dynamic) + && (MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==Dynamic) + && ((MaxRowsAtCompileTime==Dynamic?1:MaxRowsAtCompileTime)*(MaxColsAtCompileTime==Dynamic?1:MaxColsAtCompileTime) > template class Matrix - : public DenseStorageBase, MatrixBase, _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> -// : public MatrixBase > + : public DenseStorageBase, MatrixBase, _Options> { public: - typedef DenseStorageBase, MatrixBase, _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> Base; + typedef DenseStorageBase, MatrixBase, _Options> Base; _EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix) enum { Options = _Options }; -- cgit v1.2.3