mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
- 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.
This commit is contained in:
@@ -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
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
//@}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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; };
|
||||
|
||||
Reference in New Issue
Block a user