diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2008-04-16 07:18:27 +0000 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2008-04-16 07:18:27 +0000 |
commit | acfd6f3bdad9f7a690f4fd860a637f1f488e619c (patch) | |
tree | 577299488c003df093767b26ef3dc02f14283656 /Eigen/src/Core | |
parent | 43e2bc14fe06186d75580b93ffaf83fde4f4e823 (diff) |
- add _packetCoeff() to Inverse, allowing vectorization.
- let Inverse take template parameter MatrixType instead
of ExpressionType, in order to reduce executable code size
when taking inverses of xpr's.
- introduce ei_corrected_matrix_flags : the flags template
parameter to the Matrix class is only a suggestion. This
is also useful in ei_eval.
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r-- | Eigen/src/Core/Matrix.h | 12 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/util/ForwardDeclarations.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/util/Meta.h | 60 |
4 files changed, 41 insertions, 37 deletions
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 740d6fc9a..92f726011 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -35,7 +35,7 @@ * 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 _Flags allows to control certain features such as storage order. See MatrixBase::Flags. + * \param _SuggestedFlags allows to control certain features such as storage order. See MatrixBase::Flags. * * This single class template covers all kinds of matrix and vectors that Eigen can handle. * All matrix and vector types are just typedefs to specializations of this class template. @@ -70,8 +70,8 @@ * * Note that most of the API is in the base class MatrixBase. */ -template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols> -struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> > +template<typename _Scalar, int _Rows, int _Cols, unsigned int _SuggestedFlags, int _MaxRows, int _MaxCols> +struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _SuggestedFlags, _MaxRows, _MaxCols> > { typedef _Scalar Scalar; enum { @@ -79,11 +79,7 @@ struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> > ColsAtCompileTime = _Cols, MaxRowsAtCompileTime = _MaxRows, MaxColsAtCompileTime = _MaxCols, - Flags = (_Flags & ~VectorizableBit) - | ( - ei_is_matrix_vectorizable<Scalar, _Rows, _Cols, _Flags>::ret - ? VectorizableBit : 0 - ), + Flags = ei_corrected_matrix_flags<_Scalar, _Rows, _Cols, _SuggestedFlags>::ret, CoeffReadCost = NumTraits<Scalar>::ReadCost }; }; diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 23a82051f..d0faa88bf 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -511,8 +511,8 @@ template<typename Derived> class MatrixBase * \code #include <Eigen/LU> \endcode */ //@{ - const Inverse<Derived, true> inverse() const; - const Inverse<Derived, false> quickInverse() const; + const Inverse<typename ei_eval<Derived>::type, true> inverse() const; + const Inverse<typename ei_eval<Derived>::type, false> quickInverse() const; Scalar determinant() const; //@} diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index 86eaf4e54..0bdfb4ea1 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -30,7 +30,7 @@ template<typename Lhs, typename Rhs> struct ei_product_eval_mode; template<typename T> struct NumTraits; template<typename _Scalar, int _Rows, int _Cols, - unsigned int _Flags = EIGEN_DEFAULT_MATRIX_FLAGS, + unsigned int _SuggestedFlags = EIGEN_DEFAULT_MATRIX_FLAGS, int _MaxRows = _Rows, int _MaxCols = _Cols> class Matrix; diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 8eafec2f5..ce0c4a21b 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -145,36 +145,44 @@ template<typename T> struct ei_packet_traits enum {size=1}; }; -template<typename Scalar, int Rows, int Cols, unsigned int Flags> -struct ei_is_matrix_vectorizable +template<typename Scalar, int Rows, int Cols, unsigned int SuggestedFlags> +class ei_corrected_matrix_flags { - enum { ret = ei_packet_traits<Scalar>::size > 1 - && Rows!=Dynamic - && Cols!=Dynamic - && - ( - (Flags&RowMajorBit && Cols%ei_packet_traits<Scalar>::size==0) - || (Rows%ei_packet_traits<Scalar>::size==0) - ) - }; + enum { is_vectorizable + = ei_packet_traits<Scalar>::size > 1 + && Rows!=Dynamic + && Cols!=Dynamic + && + ( + SuggestedFlags&RowMajorBit + ? Cols%ei_packet_traits<Scalar>::size==0 + : Rows%ei_packet_traits<Scalar>::size==0 + ), + _flags1 = SuggestedFlags & ~(EvalBeforeNestingBit | EvalBeforeAssigningBit) + }; + + public: + enum { ret = is_vectorizable + ? _flags1 | VectorizableBit + : _flags1 & ~VectorizableBit + }; }; -template<typename T> struct ei_eval +template<typename T> class ei_eval { - typedef typename ei_traits<T>::Scalar _Scalar; - enum { _Rows = ei_traits<T>::RowsAtCompileTime, - _Cols = ei_traits<T>::ColsAtCompileTime, - _Flags = ei_traits<T>::Flags - }; - typedef Matrix<_Scalar, - _Rows, - _Cols, - (_Flags & ~(EvalBeforeNestingBit | EvalBeforeAssigningBit)) - | - (ei_is_matrix_vectorizable<_Scalar, _Rows, _Cols, _Flags>::ret - ? VectorizableBit : 0), - ei_traits<T>::MaxRowsAtCompileTime, - ei_traits<T>::MaxColsAtCompileTime> type; + typedef typename ei_traits<T>::Scalar _Scalar; + enum { _Rows = ei_traits<T>::RowsAtCompileTime, + _Cols = ei_traits<T>::ColsAtCompileTime, + _Flags = ei_traits<T>::Flags + }; + + public: + typedef Matrix<_Scalar, + _Rows, + _Cols, + ei_corrected_matrix_flags<_Scalar, _Rows, _Cols, _Flags>::ret, + ei_traits<T>::MaxRowsAtCompileTime, + ei_traits<T>::MaxColsAtCompileTime> type; }; template<typename T> struct ei_unref { typedef T type; }; |