remove MakeBase, use ei_dense_xpr_base instead

(yes, it was only used in dense xprs anyway)
This commit is contained in:
Benoit Jacob 2010-04-23 12:16:30 -04:00
parent a16ba80bfa
commit e3e34b5920
19 changed files with 52 additions and 52 deletions

View File

@ -54,8 +54,6 @@ template<typename Derived> class ArrayBase
#ifndef EIGEN_PARSED_BY_DOXYGEN #ifndef EIGEN_PARSED_BY_DOXYGEN
/** The base class for a given storage type. */ /** The base class for a given storage type. */
typedef ArrayBase StorageBaseType; typedef ArrayBase StorageBaseType;
/** Construct the base class type for the derived class OtherDerived */
template <typename OtherDerived> struct MakeBase { typedef ArrayBase<OtherDerived> Type; };
using ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar, using ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar,
typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>::operator*; typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>::operator*;

View File

@ -44,6 +44,7 @@ struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> >
{ {
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename ei_traits<MatrixType>::StorageKind StorageKind; typedef typename ei_traits<MatrixType>::StorageKind StorageKind;
typedef typename ei_traits<MatrixType>::XprKind XprKind;
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 {
@ -65,11 +66,11 @@ struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> >
}; };
template<typename MatrixType,int RowFactor,int ColFactor> class Replicate template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
: public MatrixType::template MakeBase< Replicate<MatrixType,RowFactor,ColFactor> >::Type : public ei_dense_xpr_base< Replicate<MatrixType,RowFactor,ColFactor> >::type
{ {
public: public:
typedef typename MatrixType::template MakeBase< Replicate<MatrixType,RowFactor,ColFactor> >::Type Base; typedef typename ei_dense_xpr_base<Replicate>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Replicate) EIGEN_DENSE_PUBLIC_INTERFACE(Replicate)
template<typename OriginalMatrixType> template<typename OriginalMatrixType>

View File

@ -47,6 +47,7 @@ struct ei_traits<Reverse<MatrixType, Direction> >
{ {
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename ei_traits<MatrixType>::StorageKind StorageKind; typedef typename ei_traits<MatrixType>::StorageKind StorageKind;
typedef typename ei_traits<MatrixType>::XprKind XprKind;
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 {
@ -75,11 +76,11 @@ template<typename PacketScalar> struct ei_reverse_packet_cond<PacketScalar,false
}; };
template<typename MatrixType, int Direction> class Reverse template<typename MatrixType, int Direction> class Reverse
: public MatrixType::template MakeBase< Reverse<MatrixType, Direction> >::Type : public ei_dense_xpr_base< Reverse<MatrixType, Direction> >::type
{ {
public: public:
typedef typename MatrixType::template MakeBase< Reverse<MatrixType, Direction> >::Type Base; typedef typename ei_dense_xpr_base<Reverse>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Reverse) EIGEN_DENSE_PUBLIC_INTERFACE(Reverse)
using Base::IsRowMajor; using Base::IsRowMajor;

View File

@ -47,6 +47,7 @@ struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
{ {
typedef typename ei_traits<ThenMatrixType>::Scalar Scalar; typedef typename ei_traits<ThenMatrixType>::Scalar Scalar;
typedef Dense StorageKind; typedef Dense StorageKind;
typedef typename ei_traits<ThenMatrixType>::XprKind XprKind;
typedef typename ConditionMatrixType::Nested ConditionMatrixNested; typedef typename ConditionMatrixType::Nested ConditionMatrixNested;
typedef typename ThenMatrixType::Nested ThenMatrixNested; typedef typename ThenMatrixType::Nested ThenMatrixNested;
typedef typename ElseMatrixType::Nested ElseMatrixNested; typedef typename ElseMatrixType::Nested ElseMatrixNested;
@ -64,11 +65,11 @@ struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
class Select : ei_no_assignment_operator, class Select : ei_no_assignment_operator,
public ThenMatrixType::template MakeBase< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::Type public ei_dense_xpr_base< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::type
{ {
public: public:
typedef typename ThenMatrixType::template MakeBase< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::Type Base; typedef typename ei_dense_xpr_base<Select>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Select) EIGEN_DENSE_PUBLIC_INTERFACE(Select)
Select(const ConditionMatrixType& conditionMatrix, Select(const ConditionMatrixType& conditionMatrix,

View File

@ -52,6 +52,7 @@ struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
{ {
typedef typename MemberOp::result_type Scalar; typedef typename MemberOp::result_type Scalar;
typedef typename ei_traits<MatrixType>::StorageKind StorageKind; typedef typename ei_traits<MatrixType>::StorageKind StorageKind;
typedef typename ei_traits<MatrixType>::XprKind XprKind;
typedef typename MatrixType::Scalar InputScalar; typedef typename MatrixType::Scalar InputScalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested; typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested; typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested;
@ -76,11 +77,11 @@ struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
template< typename MatrixType, typename MemberOp, int Direction> template< typename MatrixType, typename MemberOp, int Direction>
class PartialReduxExpr : ei_no_assignment_operator, class PartialReduxExpr : ei_no_assignment_operator,
public MatrixType::template MakeBase< PartialReduxExpr<MatrixType, MemberOp, Direction> >::Type public ei_dense_xpr_base< PartialReduxExpr<MatrixType, MemberOp, Direction> >::type
{ {
public: public:
typedef typename MatrixType::template MakeBase< PartialReduxExpr<MatrixType, MemberOp, Direction> >::Type Base; typedef typename ei_dense_xpr_base<PartialReduxExpr>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(PartialReduxExpr) EIGEN_DENSE_PUBLIC_INTERFACE(PartialReduxExpr)
typedef typename ei_traits<PartialReduxExpr>::MatrixTypeNested MatrixTypeNested; typedef typename ei_traits<PartialReduxExpr>::MatrixTypeNested MatrixTypeNested;
typedef typename ei_traits<PartialReduxExpr>::_MatrixTypeNested _MatrixTypeNested; typedef typename ei_traits<PartialReduxExpr>::_MatrixTypeNested _MatrixTypeNested;

View File

@ -104,7 +104,7 @@ template<typename XprType, int BlockRows, int BlockCols, bool HasDirectAccess> c
{ {
public: public:
typedef typename XprType::template MakeBase<Block>::Type Base; typedef typename ei_dense_xpr_base<Block>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Block) EIGEN_DENSE_PUBLIC_INTERFACE(Block)
class InnerIterator; class InnerIterator;

View File

@ -153,12 +153,12 @@ class CwiseBinaryOp : ei_no_assignment_operator,
template<typename BinaryOp, typename Lhs, typename Rhs> template<typename BinaryOp, typename Lhs, typename Rhs>
class CwiseBinaryOpImpl<BinaryOp, Lhs, Rhs, Dense> class CwiseBinaryOpImpl<BinaryOp, Lhs, Rhs, Dense>
: public Lhs::template MakeBase< CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::Type : public ei_dense_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type
{ {
typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> Derived; typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> Derived;
public: public:
typedef typename Lhs::template MakeBase< CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::Type Base; typedef typename ei_dense_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE( Derived ) EIGEN_DENSE_PUBLIC_INTERFACE( Derived )
EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const

View File

@ -56,11 +56,11 @@ struct ei_traits<CwiseNullaryOp<NullaryOp, PlainObjectType> > : ei_traits<PlainO
template<typename NullaryOp, typename PlainObjectType> template<typename NullaryOp, typename PlainObjectType>
class CwiseNullaryOp : ei_no_assignment_operator, class CwiseNullaryOp : ei_no_assignment_operator,
public PlainObjectType::template MakeBase< CwiseNullaryOp<NullaryOp, PlainObjectType> >::Type public ei_dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type
{ {
public: public:
typedef typename PlainObjectType::template MakeBase< CwiseNullaryOp<NullaryOp, PlainObjectType> >::Type Base; typedef typename ei_dense_xpr_base<CwiseNullaryOp>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp) EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp)
CwiseNullaryOp(int rows, int cols, const NullaryOp& func = NullaryOp()) CwiseNullaryOp(int rows, int cols, const NullaryOp& func = NullaryOp())

View File

@ -99,13 +99,13 @@ class CwiseUnaryOp : ei_no_assignment_operator,
// It can be used for any expression types implementing the dense concept. // It can be used for any expression types implementing the dense concept.
template<typename UnaryOp, typename XprType> template<typename UnaryOp, typename XprType>
class CwiseUnaryOpImpl<UnaryOp,XprType,Dense> class CwiseUnaryOpImpl<UnaryOp,XprType,Dense>
: public XprType::template MakeBase< CwiseUnaryOp<UnaryOp, XprType> >::Type : public ei_dense_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type
{ {
typedef CwiseUnaryOp<UnaryOp, XprType> Derived; typedef CwiseUnaryOp<UnaryOp, XprType> Derived;
public: public:
typedef typename XprType::template MakeBase< CwiseUnaryOp<UnaryOp, XprType> >::Type Base; typedef typename ei_dense_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Derived) EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const

View File

@ -91,13 +91,13 @@ class CwiseUnaryView : ei_no_assignment_operator,
template<typename ViewOp, typename MatrixType> template<typename ViewOp, typename MatrixType>
class CwiseUnaryViewImpl<ViewOp,MatrixType,Dense> class CwiseUnaryViewImpl<ViewOp,MatrixType,Dense>
: public MatrixType::template MakeBase< CwiseUnaryView<ViewOp, MatrixType> >::Type : public ei_dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type
{ {
typedef CwiseUnaryView<ViewOp, MatrixType> Derived; typedef CwiseUnaryView<ViewOp, MatrixType> Derived;
public: public:
typedef typename MatrixType::template MakeBase< CwiseUnaryView<ViewOp, MatrixType> >::Type Base; typedef typename ei_dense_xpr_base<CwiseUnaryView<ViewOp, MatrixType> >::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Derived) EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const

View File

@ -50,24 +50,6 @@ struct ei_outer_stride_at_compile_time<Derived, false>
enum { ret = 0 }; enum { ret = 0 };
}; };
template<typename Derived, typename XprKind = typename ei_traits<Derived>::XprKind>
struct ei_dense_xpr_base
{
/* ei_dense_xpr_base should only ever be used on dense expressions, thus falling either into the MatrixXpr or into the ArrayXpr cases */
};
template<typename Derived>
struct ei_dense_xpr_base<Derived, MatrixXpr>
{
typedef MatrixBase<Derived> type;
};
template<typename Derived>
struct ei_dense_xpr_base<Derived, ArrayXpr>
{
typedef ArrayBase<Derived> type;
};
/** \class DenseBase /** \class DenseBase
* *
* \brief Base class for all dense matrices, vectors, and arrays * \brief Base class for all dense matrices, vectors, and arrays

View File

@ -64,7 +64,7 @@ struct ei_traits<Diagonal<MatrixType,Index> >
}; };
template<typename MatrixType, int Index> class Diagonal template<typename MatrixType, int Index> class Diagonal
: public MatrixType::template MakeBase< Diagonal<MatrixType,Index> >::Type : public ei_dense_xpr_base< Diagonal<MatrixType,Index> >::type
{ {
// some compilers may fail to optimize std::max etc in case of compile-time constants... // some compilers may fail to optimize std::max etc in case of compile-time constants...
EIGEN_STRONG_INLINE int absIndex() const { return m_index.value()>0 ? m_index.value() : -m_index.value(); } EIGEN_STRONG_INLINE int absIndex() const { return m_index.value()>0 ? m_index.value() : -m_index.value(); }
@ -73,7 +73,7 @@ template<typename MatrixType, int Index> class Diagonal
public: public:
typedef typename MatrixType::template MakeBase<Diagonal>::Type Base; typedef typename ei_dense_xpr_base<Diagonal>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal) EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal)
inline Diagonal(const MatrixType& matrix, int index = Index) : m_matrix(matrix), m_index(index) {} inline Diagonal(const MatrixType& matrix, int index = Index) : m_matrix(matrix), m_index(index) {}

View File

@ -41,11 +41,11 @@ struct ei_traits<ForceAlignedAccess<ExpressionType> > : public ei_traits<Express
{}; {};
template<typename ExpressionType> class ForceAlignedAccess template<typename ExpressionType> class ForceAlignedAccess
: public ExpressionType::template MakeBase< ForceAlignedAccess<ExpressionType> >::Type : public ei_dense_xpr_base< ForceAlignedAccess<ExpressionType> >::type
{ {
public: public:
typedef typename ExpressionType::template MakeBase<ForceAlignedAccess<ExpressionType> >::Type Base; typedef typename ei_dense_xpr_base<ForceAlignedAccess>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess) EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess)
inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {} inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}

View File

@ -58,8 +58,6 @@ template<typename Derived> class MatrixBase
#ifndef EIGEN_PARSED_BY_DOXYGEN #ifndef EIGEN_PARSED_BY_DOXYGEN
/** The base class for a given storage type. */ /** The base class for a given storage type. */
typedef MatrixBase StorageBaseType; typedef MatrixBase StorageBaseType;
/** Construct the base class type for the derived class OtherDerived */
template <typename OtherDerived> struct MakeBase { typedef MatrixBase<OtherDerived> Type; };
typedef typename ei_traits<Derived>::Scalar Scalar; typedef typename ei_traits<Derived>::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar; typedef typename ei_packet_traits<Scalar>::type PacketScalar;

View File

@ -42,11 +42,11 @@ struct ei_traits<NestByValue<ExpressionType> > : public ei_traits<ExpressionType
{}; {};
template<typename ExpressionType> class NestByValue template<typename ExpressionType> class NestByValue
: public ExpressionType::template MakeBase< NestByValue<ExpressionType> >::Type : public ei_dense_xpr_base< NestByValue<ExpressionType> >::type
{ {
public: public:
typedef typename ExpressionType::template MakeBase<NestByValue<ExpressionType> >::Type Base; typedef typename ei_dense_xpr_base<NestByValue>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue)
inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}

View File

@ -2,7 +2,7 @@
// for linear algebra. // for linear algebra.
// //
// Copyright (C) 2009-2010 Gael Guennebaud <g.gael@free.fr> // Copyright (C) 2009-2010 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com> // Copyright (C) 2009-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -53,11 +53,11 @@ struct ei_nested<ReturnByValue<Derived>, n, PlainObject>
}; };
template<typename Derived> class ReturnByValue template<typename Derived> class ReturnByValue
: public ei_traits<Derived>::ReturnType::template MakeBase<ReturnByValue<Derived> >::Type : public ei_dense_xpr_base< ReturnByValue<Derived> >::type
{ {
public: public:
typedef typename ei_traits<Derived>::ReturnType ReturnType; typedef typename ei_traits<Derived>::ReturnType ReturnType;
typedef typename ReturnType::template MakeBase<ReturnByValue<Derived> >::Type Base; typedef typename ei_dense_xpr_base<ReturnByValue>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue) EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue)
template<typename Dest> template<typename Dest>

View File

@ -42,11 +42,11 @@ template<typename BinaryOp, typename MatrixType>
struct ei_traits<SelfCwiseBinaryOp<BinaryOp,MatrixType> > : ei_traits<MatrixType> {}; struct ei_traits<SelfCwiseBinaryOp<BinaryOp,MatrixType> > : ei_traits<MatrixType> {};
template<typename BinaryOp, typename MatrixType> class SelfCwiseBinaryOp template<typename BinaryOp, typename MatrixType> class SelfCwiseBinaryOp
: public MatrixType::template MakeBase< SelfCwiseBinaryOp<BinaryOp, MatrixType> >::Type : public ei_dense_xpr_base< SelfCwiseBinaryOp<BinaryOp, MatrixType> >::type
{ {
public: public:
typedef typename MatrixType::template MakeBase< SelfCwiseBinaryOp<BinaryOp, MatrixType> >::Type Base; typedef typename ei_dense_xpr_base<SelfCwiseBinaryOp>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(SelfCwiseBinaryOp) EIGEN_DENSE_PUBLIC_INTERFACE(SelfCwiseBinaryOp)
typedef typename ei_packet_traits<Scalar>::type Packet; typedef typename ei_packet_traits<Scalar>::type Packet;

View File

@ -35,11 +35,11 @@ template<typename ExpressionType>
struct ei_traits<SwapWrapper<ExpressionType> > : ei_traits<ExpressionType> {}; struct ei_traits<SwapWrapper<ExpressionType> > : ei_traits<ExpressionType> {};
template<typename ExpressionType> class SwapWrapper template<typename ExpressionType> class SwapWrapper
: public ExpressionType::template MakeBase<SwapWrapper<ExpressionType> >::Type : public ei_dense_xpr_base<SwapWrapper<ExpressionType> >::type
{ {
public: public:
typedef typename ExpressionType::template MakeBase<SwapWrapper<ExpressionType> >::Type Base; typedef typename ei_dense_xpr_base<SwapWrapper>::type Base;
EIGEN_DENSE_PUBLIC_INTERFACE(SwapWrapper) EIGEN_DENSE_PUBLIC_INTERFACE(SwapWrapper)
typedef typename ei_packet_traits<Scalar>::type Packet; typedef typename ei_packet_traits<Scalar>::type Packet;

View File

@ -303,6 +303,24 @@ template<unsigned int Flags> struct ei_are_flags_consistent
enum { ret = true }; enum { ret = true };
}; };
template<typename Derived, typename XprKind = typename ei_traits<Derived>::XprKind>
struct ei_dense_xpr_base
{
/* ei_dense_xpr_base should only ever be used on dense expressions, thus falling either into the MatrixXpr or into the ArrayXpr cases */
};
template<typename Derived>
struct ei_dense_xpr_base<Derived, MatrixXpr>
{
typedef MatrixBase<Derived> type;
};
template<typename Derived>
struct ei_dense_xpr_base<Derived, ArrayXpr>
{
typedef ArrayBase<Derived> type;
};
/** \internal Helper base class to add a scalar multiple operator /** \internal Helper base class to add a scalar multiple operator
* overloads for complex types */ * overloads for complex types */
template<typename Derived,typename Scalar,typename OtherScalar, template<typename Derived,typename Scalar,typename OtherScalar,