extend the DenseStorageMatrix mechanism to all expressions

This commit is contained in:
Gael Guennebaud 2009-12-22 17:37:11 +01:00
parent af4d8c5cec
commit e182e9c616
16 changed files with 20 additions and 22 deletions

View File

@ -189,11 +189,6 @@ class Array
other.evalTo(*this); other.evalTo(*this);
} }
// template<typename OtherDerived>
// Array& lazyAssign(const ArrayBase<OtherDerived>& other);
// template<typename OtherDerived>
// Array& lazyAssign(const MatrixBase<OtherDerived>& other);
/** \sa MatrixBase::operator=(const AnyMatrixBase<OtherDerived>&) */ /** \sa MatrixBase::operator=(const AnyMatrixBase<OtherDerived>&) */
template<typename OtherDerived> template<typename OtherDerived>
EIGEN_STRONG_INLINE Array(const AnyMatrixBase<OtherDerived> &other) EIGEN_STRONG_INLINE Array(const AnyMatrixBase<OtherDerived> &other)

View File

@ -40,6 +40,7 @@
*/ */
template<typename MatrixType,int RowFactor,int ColFactor> template<typename MatrixType,int RowFactor,int ColFactor>
struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> > struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> >
: ei_traits<MatrixType>
{ {
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename ei_traits<MatrixType>::StorageType StorageType; typedef typename ei_traits<MatrixType>::StorageType StorageType;

View File

@ -43,6 +43,7 @@
*/ */
template<typename MatrixType, int Direction> template<typename MatrixType, int Direction>
struct ei_traits<Reverse<MatrixType, Direction> > struct ei_traits<Reverse<MatrixType, Direction> >
: ei_traits<MatrixType>
{ {
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename ei_traits<MatrixType>::StorageType StorageType; typedef typename ei_traits<MatrixType>::StorageType StorageType;

View File

@ -43,6 +43,7 @@
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
: ei_traits<ThenMatrixType>
{ {
typedef typename ei_traits<ThenMatrixType>::Scalar Scalar; typedef typename ei_traits<ThenMatrixType>::Scalar Scalar;
typedef Dense StorageType; typedef Dense StorageType;

View File

@ -48,6 +48,7 @@ class PartialReduxExpr;
template<typename MatrixType, typename MemberOp, int Direction> template<typename MatrixType, typename MemberOp, int Direction>
struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> > struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
: ei_traits<MatrixType>
{ {
typedef typename MemberOp::result_type Scalar; typedef typename MemberOp::result_type Scalar;
typedef typename ei_traits<MatrixType>::StorageType StorageType; typedef typename ei_traits<MatrixType>::StorageType StorageType;

View File

@ -546,7 +546,7 @@ struct ei_conservative_resize_like_impl
EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived) EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived) EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
typename DenseBase<Derived>::PlainMatrixType tmp(other); typename Derived::PlainMatrixType tmp(other);
const int common_rows = std::min(tmp.rows(), _this.rows()); const int common_rows = std::min(tmp.rows(), _this.rows());
const int common_cols = std::min(tmp.cols(), _this.cols()); const int common_cols = std::min(tmp.cols(), _this.cols());
tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols); tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
@ -562,7 +562,7 @@ struct ei_conservative_resize_like_impl<Derived,OtherDerived,true>
if (_this.rows() == other.rows() && _this.cols() == other.cols()) return; if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
// segment(...) will check whether Derived/OtherDerived are vectors! // segment(...) will check whether Derived/OtherDerived are vectors!
typename DenseBase<Derived>::PlainMatrixType tmp(other); typename Derived::PlainMatrixType tmp(other);
const int common_size = std::min<int>(_this.size(),tmp.size()); const int common_size = std::min<int>(_this.size(),tmp.size());
tmp.segment(0,common_size) = _this.segment(0,common_size); tmp.segment(0,common_size) = _this.segment(0,common_size);
_this.derived().swap(tmp); _this.derived().swap(tmp);

View File

@ -44,9 +44,8 @@
*/ */
template<typename MatrixType, int Index> template<typename MatrixType, int Index>
struct ei_traits<Diagonal<MatrixType,Index> > struct ei_traits<Diagonal<MatrixType,Index> >
: ei_traits<MatrixType>
{ {
typedef typename MatrixType::Scalar Scalar;
typedef typename ei_traits<MatrixType>::StorageType StorageType;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested; typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum { enum {

View File

@ -28,9 +28,9 @@
template<typename MatrixType, typename DiagonalType, int ProductOrder> template<typename MatrixType, typename DiagonalType, int ProductOrder>
struct ei_traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> > struct ei_traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> >
: ei_traits<MatrixType>
{ {
typedef typename ei_scalar_product_traits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType Scalar; typedef typename ei_scalar_product_traits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType Scalar;
typedef typename ei_traits<MatrixType>::StorageType StorageType;
enum { enum {
RowsAtCompileTime = MatrixType::RowsAtCompileTime, RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime,

View File

@ -40,9 +40,8 @@
*/ */
template<typename MatrixType> template<typename MatrixType>
struct ei_traits<Minor<MatrixType> > struct ei_traits<Minor<MatrixType> >
: ei_traits<MatrixType>
{ {
typedef typename MatrixType::Scalar Scalar;
typedef typename ei_traits<MatrixType>::StorageType StorageType;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested; typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum { enum {

View File

@ -29,7 +29,7 @@
* *
*/ */
template<typename Derived, typename _Lhs, typename _Rhs> template<typename Derived, typename _Lhs, typename _Rhs>
struct ei_traits<ProductBase<Derived,_Lhs,_Rhs> > struct ei_traits<ProductBase<Derived,_Lhs,_Rhs> > : ei_traits<typename ei_cleantype<_Lhs>::type>
{ {
typedef typename ei_cleantype<_Lhs>::type Lhs; typedef typename ei_cleantype<_Lhs>::type Lhs;
typedef typename ei_cleantype<_Rhs>::type Rhs; typedef typename ei_cleantype<_Rhs>::type Rhs;

View File

@ -38,7 +38,7 @@
* \sa MatrixBase::transpose(), MatrixBase::adjoint() * \sa MatrixBase::transpose(), MatrixBase::adjoint()
*/ */
template<typename MatrixType> template<typename MatrixType>
struct ei_traits<Transpose<MatrixType> > struct ei_traits<Transpose<MatrixType> > : ei_traits<MatrixType>
{ {
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested; typedef typename ei_nested<MatrixType>::type MatrixTypeNested;

View File

@ -45,6 +45,7 @@ struct ei_product_packet_impl;
template<typename LhsNested, typename RhsNested> template<typename LhsNested, typename RhsNested>
struct ei_traits<GeneralProduct<LhsNested,RhsNested,UnrolledProduct> > struct ei_traits<GeneralProduct<LhsNested,RhsNested,UnrolledProduct> >
{ {
typedef DenseStorageMatrix DenseStorageType;
typedef typename ei_cleantype<LhsNested>::type _LhsNested; typedef typename ei_cleantype<LhsNested>::type _LhsNested;
typedef typename ei_cleantype<RhsNested>::type _RhsNested; typedef typename ei_cleantype<RhsNested>::type _RhsNested;
typedef typename ei_scalar_product_traits<typename _LhsNested::Scalar, typename _RhsNested::Scalar>::ReturnType Scalar; typedef typename ei_scalar_product_traits<typename _LhsNested::Scalar, typename _RhsNested::Scalar>::ReturnType Scalar;

View File

@ -41,8 +41,8 @@
*/ */
template<typename MatrixType,int Direction> template<typename MatrixType,int Direction>
struct ei_traits<Homogeneous<MatrixType,Direction> > struct ei_traits<Homogeneous<MatrixType,Direction> >
: ei_traits<MatrixType>
{ {
typedef typename MatrixType::Scalar Scalar;
typedef typename ei_traits<MatrixType>::StorageType StorageType; typedef typename ei_traits<MatrixType>::StorageType StorageType;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested; typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;

View File

@ -109,13 +109,7 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
Transpose<Derived> Transpose<Derived>
>::ret AdjointReturnType; >::ret AdjointReturnType;
// typedef Matrix<typename ei_traits<Derived>::Scalar, typedef SparseMatrix<Scalar, Flags&RowMajorBit ? RowMajor : ColMajor> PlainMatrixType;
// ei_traits<Derived>::RowsAtCompileTime,
// ei_traits<Derived>::ColsAtCompileTime,
// AutoAlign | (ei_traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
// ei_traits<Derived>::MaxRowsAtCompileTime,
// ei_traits<Derived>::MaxColsAtCompileTime
// > PlainMatrixType;
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
#include "../plugins/CommonCwiseUnaryOps.h" #include "../plugins/CommonCwiseUnaryOps.h"
@ -376,6 +370,7 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
template<typename OtherDerived> template<typename OtherDerived>
Derived& operator*=(const SparseMatrixBase<OtherDerived>& other); Derived& operator*=(const SparseMatrixBase<OtherDerived>& other);
#ifdef EIGEN2_SUPPORT
// deprecated // deprecated
template<typename OtherDerived> template<typename OtherDerived>
typename ei_plain_matrix_type_column_major<OtherDerived>::type typename ei_plain_matrix_type_column_major<OtherDerived>::type
@ -386,6 +381,7 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
void solveTriangularInPlace(MatrixBase<OtherDerived>& other) const; void solveTriangularInPlace(MatrixBase<OtherDerived>& other) const;
// template<typename OtherDerived> // template<typename OtherDerived>
// void solveTriangularInPlace(SparseMatrixBase<OtherDerived>& other) const; // void solveTriangularInPlace(SparseMatrixBase<OtherDerived>& other) const;
#endif // EIGEN2_SUPPORT
template<int Mode> template<int Mode>
inline const SparseTriangularView<Derived, Mode> triangularView() const; inline const SparseTriangularView<Derived, Mode> triangularView() const;

View File

@ -52,6 +52,7 @@ struct SparseProductReturnType
template<typename LhsNested, typename RhsNested> template<typename LhsNested, typename RhsNested>
struct ei_traits<SparseProduct<LhsNested, RhsNested> > struct ei_traits<SparseProduct<LhsNested, RhsNested> >
{ {
typedef DenseStorageMatrix DenseStorageType;
// clean the nested types: // clean the nested types:
typedef typename ei_cleantype<LhsNested>::type _LhsNested; typedef typename ei_cleantype<LhsNested>::type _LhsNested;
typedef typename ei_cleantype<RhsNested>::type _RhsNested; typedef typename ei_cleantype<RhsNested>::type _RhsNested;
@ -261,6 +262,7 @@ struct ei_traits<SparseTimeDenseProduct<Lhs,Rhs> >
: ei_traits<ProductBase<SparseTimeDenseProduct<Lhs,Rhs>, Lhs, Rhs> > : ei_traits<ProductBase<SparseTimeDenseProduct<Lhs,Rhs>, Lhs, Rhs> >
{ {
typedef Dense StorageType; typedef Dense StorageType;
typedef DenseStorageMatrix DenseStorageType;
}; };
template<typename Lhs, typename Rhs> template<typename Lhs, typename Rhs>

View File

@ -302,6 +302,7 @@ void SparseTriangularView<ExpressionType,Mode>::solveInPlace(SparseMatrixBase<Ot
// other = otherCopy; // other = otherCopy;
} }
#ifdef EIGEN2_SUPPORT
// deprecated stuff: // deprecated stuff:
@ -323,5 +324,6 @@ SparseMatrixBase<Derived>::solveTriangular(const MatrixBase<OtherDerived>& other
derived().solveTriangularInPlace(res); derived().solveTriangularInPlace(res);
return res; return res;
} }
#endif // EIGEN2_SUPPORT
#endif // EIGEN_SPARSETRIANGULARSOLVER_H #endif // EIGEN_SPARSETRIANGULARSOLVER_H