diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-12-17 13:56:33 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-12-17 13:56:33 +0100 |
commit | 5ca90e1b0c031eb18ea2096eb2054a19d4e2e146 (patch) | |
tree | cadf98591238928f095200af1a72290bce3c4908 /Eigen/src/Core | |
parent | ebb28788292bc8e76a03044f64ea580b43e03bef (diff) |
some cleaning in DenseStorageBase
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r-- | Eigen/src/Core/CwiseNullaryOp.h | 84 | ||||
-rw-r--r-- | Eigen/src/Core/DenseStorageBase.h | 76 | ||||
-rw-r--r-- | Eigen/src/Core/Matrix.h | 5 |
3 files changed, 62 insertions, 103 deletions
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<Derived>::setConstant(const Scalar& value * * \sa MatrixBase::setConstant(const Scalar&), setConstant(int,int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&) */ -// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -// 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<typename Derived, template<typename> class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase<Derived,_Base,_Options>::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<Derived>::setConstant(const Scalar& value * * \sa MatrixBase::setConstant(const Scalar&), setConstant(int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&) */ -// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -// 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<typename Derived, template<typename> class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase<Derived,_Base,_Options>::setConstant(int rows, int cols, const Scalar& value) +{ + resize(rows, cols); + return setConstant(value); +} // zero: @@ -408,13 +408,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setZero() * * \sa DenseBase::setZero(), setZero(int,int), class CwiseNullaryOp, DenseBase::Zero() */ -// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -// 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<typename Derived, template<typename> class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase<Derived,_Base,_Options>::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<Derived>::setZero() * * \sa DenseBase::setZero(), setZero(int), class CwiseNullaryOp, DenseBase::Zero() */ -// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -// 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<typename Derived, template<typename> class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase<Derived,_Base,_Options>::setZero(int rows, int cols) +{ + resize(rows, cols); + return setConstant(Scalar(0)); +} // ones: @@ -534,13 +534,13 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setOnes() * * \sa MatrixBase::setOnes(), setOnes(int,int), class CwiseNullaryOp, MatrixBase::Ones() */ -// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -// 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<typename Derived, template<typename> class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase<Derived,_Base,_Options>::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<Derived>::setOnes() * * \sa MatrixBase::setOnes(), setOnes(int), class CwiseNullaryOp, MatrixBase::Ones() */ -// template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -// 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<typename Derived, template<typename> class _Base, int _Options> +EIGEN_STRONG_INLINE Derived& +DenseStorageBase<Derived,_Base,_Options>::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 <typename Derived, typename OtherDerived, bool IsVector = static_cast<bool>(Derived::IsVectorAtCompileTime)> struct ei_conservative_resize_like_impl; template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct ei_matrix_swap_impl; -template<typename Derived, template<typename> class _Base, typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> +template<typename Derived, template<typename> class _Base, int _Options> class DenseStorageBase : public _Base<Derived> { public: @@ -402,60 +402,20 @@ class DenseStorageBase : public _Base<Derived> //@} 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<Derived> 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)<Dynamic) + EIGEN_STATIC_ASSERT(((RowsAtCompileTime >= 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)<Dynamic) && (_Options & (DontAlign|RowMajor)) == _Options), INVALID_MATRIX_TEMPLATE_PARAMETERS) } diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 6cd989e22..0d21f9fca 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -124,12 +124,11 @@ struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> class Matrix - : public DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, MatrixBase, _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> -// : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > + : public DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, MatrixBase, _Options> { public: - typedef DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, MatrixBase, _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> Base; + typedef DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, MatrixBase, _Options> Base; _EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix) enum { Options = _Options }; |