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);
}
// template<typename OtherDerived>
// Array& lazyAssign(const ArrayBase<OtherDerived>& other);
// template<typename OtherDerived>
// Array& lazyAssign(const MatrixBase<OtherDerived>& other);
/** \sa MatrixBase::operator=(const AnyMatrixBase<OtherDerived>&) */
template<typename OtherDerived>
EIGEN_STRONG_INLINE Array(const AnyMatrixBase<OtherDerived> &other)

View File

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

View File

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

View File

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

View File

@ -48,6 +48,7 @@ class PartialReduxExpr;
template<typename MatrixType, typename MemberOp, int Direction>
struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
: ei_traits<MatrixType>
{
typedef typename MemberOp::result_type Scalar;
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(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_cols = std::min(tmp.cols(), _this.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;
// 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());
tmp.segment(0,common_size) = _this.segment(0,common_size);
_this.derived().swap(tmp);

View File

@ -44,9 +44,8 @@
*/
template<typename MatrixType, int 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_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {

View File

@ -28,9 +28,9 @@
template<typename MatrixType, typename DiagonalType, int 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_traits<MatrixType>::StorageType StorageType;
enum {
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime,

View File

@ -40,9 +40,8 @@
*/
template<typename 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_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {

View File

@ -29,7 +29,7 @@
*
*/
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<_Rhs>::type Rhs;

View File

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

View File

@ -45,6 +45,7 @@ struct ei_product_packet_impl;
template<typename LhsNested, typename RhsNested>
struct ei_traits<GeneralProduct<LhsNested,RhsNested,UnrolledProduct> >
{
typedef DenseStorageMatrix DenseStorageType;
typedef typename ei_cleantype<LhsNested>::type _LhsNested;
typedef typename ei_cleantype<RhsNested>::type _RhsNested;
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>
struct ei_traits<Homogeneous<MatrixType,Direction> >
: 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_unref<MatrixTypeNested>::type _MatrixTypeNested;

View File

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

View File

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

View File

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