adapt select, replicate and reverse

This commit is contained in:
Gael Guennebaud
2009-12-10 22:00:35 +01:00
parent 8e05f9cfa1
commit 7caf751fdd
12 changed files with 71 additions and 94 deletions

View File

@@ -179,27 +179,6 @@ template<typename Derived> class ArrayBase
// const VectorwiseOp<Derived,Vertical> colwise() const;
// VectorwiseOp<Derived,Vertical> colwise();
// template<typename ThenDerived,typename ElseDerived>
// const Select<Derived,ThenDerived,ElseDerived>
// select(const ArrayBase<ThenDerived>& thenMatrix,
// const ArrayBase<ElseDerived>& elseMatrix) const;
// template<typename ThenDerived>
// inline const Select<Derived,ThenDerived, NestByValue<typename ThenDerived::ConstantReturnType> >
// select(const ArrayBase<ThenDerived>& thenMatrix, typename ThenDerived::Scalar elseScalar) const;
// template<typename ElseDerived>
// inline const Select<Derived, NestByValue<typename ElseDerived::ConstantReturnType>, ElseDerived >
// select(typename ElseDerived::Scalar thenScalar, const ArrayBase<ElseDerived>& elseMatrix) const;
// template<int RowFactor, int ColFactor>
// const Replicate<Derived,RowFactor,ColFactor> replicate() const;
// const Replicate<Derived,Dynamic,Dynamic> replicate(int rowFacor,int colFactor) const;
// Eigen::Reverse<Derived, BothDirections> reverse();
// const Eigen::Reverse<Derived, BothDirections> reverse() const;
// void reverseInPlace();
#ifdef EIGEN_ARRAYBASE_PLUGIN
#include EIGEN_ARRAYBASE_PLUGIN
#endif

View File

@@ -33,10 +33,10 @@
* \param MatrixType the type of the object we are replicating
*
* This class represents an expression of the multiple replication of a matrix or vector.
* It is the return type of MatrixBase::replicate() and most of the time
* It is the return type of DenseBase::replicate() and most of the time
* this is the only way it is used.
*
* \sa MatrixBase::replicate()
* \sa DenseBase::replicate()
*/
template<typename MatrixType,int RowFactor,int ColFactor>
struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> >
@@ -60,11 +60,12 @@ struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> >
};
template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
: public MatrixBase<Replicate<MatrixType,RowFactor,ColFactor> >
: public MatrixType::template MakeBase< Replicate<MatrixType,RowFactor,ColFactor> >::Type
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Replicate)
typedef typename MatrixType::template MakeBase< Replicate<MatrixType,RowFactor,ColFactor> >::Type Base;
_EIGEN_GENERIC_PUBLIC_INTERFACE(Replicate)
template<typename OriginalMatrixType>
inline explicit Replicate(const OriginalMatrixType& matrix)
@@ -106,12 +107,12 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
* Example: \include MatrixBase_replicate.cpp
* Output: \verbinclude MatrixBase_replicate.out
*
* \sa VectorwiseOp::replicate(), MatrixBase::replicate(int,int), class Replicate
* \sa VectorwiseOp::replicate(), DenseBase::replicate(int,int), class Replicate
*/
template<typename Derived>
template<int RowFactor, int ColFactor>
inline const Replicate<Derived,RowFactor,ColFactor>
MatrixBase<Derived>::replicate() const
DenseBase<Derived>::replicate() const
{
return Replicate<Derived,RowFactor,ColFactor>(derived());
}
@@ -122,11 +123,11 @@ MatrixBase<Derived>::replicate() const
* Example: \include MatrixBase_replicate_int_int.cpp
* Output: \verbinclude MatrixBase_replicate_int_int.out
*
* \sa VectorwiseOp::replicate(), MatrixBase::replicate<int,int>(), class Replicate
* \sa VectorwiseOp::replicate(), DenseBase::replicate<int,int>(), class Replicate
*/
template<typename Derived>
inline const Replicate<Derived,Dynamic,Dynamic>
MatrixBase<Derived>::replicate(int rowFactor,int colFactor) const
DenseBase<Derived>::replicate(int rowFactor,int colFactor) const
{
return Replicate<Derived,Dynamic,Dynamic>(derived(),rowFactor,colFactor);
}
@@ -137,7 +138,7 @@ MatrixBase<Derived>::replicate(int rowFactor,int colFactor) const
* Example: \include DirectionWise_replicate_int.cpp
* Output: \verbinclude DirectionWise_replicate_int.out
*
* \sa VectorwiseOp::replicate(), MatrixBase::replicate(), class Replicate
* \sa VectorwiseOp::replicate(), DenseBase::replicate(), class Replicate
*/
template<typename ExpressionType, int Direction>
const Replicate<ExpressionType,(Direction==Vertical?Dynamic:1),(Direction==Horizontal?Dynamic:1)>

View File

@@ -76,11 +76,12 @@ template<typename PacketScalar> struct ei_reverse_packet_cond<PacketScalar,false
};
template<typename MatrixType, int Direction> class Reverse
: public MatrixBase<Reverse<MatrixType, Direction> >
: public MatrixType::template MakeBase< Reverse<MatrixType, Direction> >::Type
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Reverse)
typedef typename MatrixType::template MakeBase< Reverse<MatrixType, Direction> >::Type Base;
_EIGEN_GENERIC_PUBLIC_INTERFACE(Reverse)
protected:
enum {
@@ -168,7 +169,7 @@ template<typename MatrixType, int Direction> class Reverse
*/
template<typename Derived>
inline Reverse<Derived, BothDirections>
MatrixBase<Derived>::reverse()
DenseBase<Derived>::reverse()
{
return derived();
}
@@ -176,7 +177,7 @@ MatrixBase<Derived>::reverse()
/** This is the const version of reverse(). */
template<typename Derived>
inline const Reverse<Derived, BothDirections>
MatrixBase<Derived>::reverse() const
DenseBase<Derived>::reverse() const
{
return derived();
}
@@ -194,7 +195,7 @@ MatrixBase<Derived>::reverse() const
*
* \sa reverse() */
template<typename Derived>
inline void MatrixBase<Derived>::reverseInPlace()
inline void DenseBase<Derived>::reverseInPlace()
{
derived() = derived().reverse().eval();
}

View File

@@ -36,9 +36,9 @@
* \param ElseMatrixType the type of the \em else expression
*
* This class represents an expression of a coefficient wise version of the C++ ternary operator ?:.
* It is the return type of MatrixBase::select() and most of the time this is the only way it is used.
* It is the return type of DenseBase::select() and most of the time this is the only way it is used.
*
* \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const
* \sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const
*/
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
@@ -63,11 +63,12 @@ struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
class Select : ei_no_assignment_operator,
public MatrixBase<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
public ConditionMatrixType::template MakeBase< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::Type
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Select)
typedef typename ConditionMatrixType::template MakeBase< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::Type Base;
_EIGEN_GENERIC_PUBLIC_INTERFACE(Select)
Select(const ConditionMatrixType& conditionMatrix,
const ThenMatrixType& thenMatrix,
@@ -117,23 +118,23 @@ class Select : ei_no_assignment_operator,
template<typename Derived>
template<typename ThenDerived,typename ElseDerived>
inline const Select<Derived,ThenDerived,ElseDerived>
MatrixBase<Derived>::select(const MatrixBase<ThenDerived>& thenMatrix,
const MatrixBase<ElseDerived>& elseMatrix) const
DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,
const DenseBase<ElseDerived>& elseMatrix) const
{
return Select<Derived,ThenDerived,ElseDerived>(derived(), thenMatrix.derived(), elseMatrix.derived());
}
/** \array_module
*
* Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with
* Version of DenseBase::select(const DenseBase&, const DenseBase&) with
* the \em else expression being a scalar value.
*
* \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const, class Select
* \sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const, class Select
*/
template<typename Derived>
template<typename ThenDerived>
inline const Select<Derived,ThenDerived, NestByValue<typename ThenDerived::ConstantReturnType> >
MatrixBase<Derived>::select(const MatrixBase<ThenDerived>& thenMatrix,
DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,
typename ThenDerived::Scalar elseScalar) const
{
return Select<Derived,ThenDerived,NestByValue<typename ThenDerived::ConstantReturnType> >(
@@ -142,16 +143,16 @@ MatrixBase<Derived>::select(const MatrixBase<ThenDerived>& thenMatrix,
/** \array_module
*
* Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with
* Version of DenseBase::select(const DenseBase&, const DenseBase&) with
* the \em then expression being a scalar value.
*
* \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const, class Select
* \sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const, class Select
*/
template<typename Derived>
template<typename ElseDerived>
inline const Select<Derived, NestByValue<typename ElseDerived::ConstantReturnType>, ElseDerived >
MatrixBase<Derived>::select(typename ElseDerived::Scalar thenScalar,
const MatrixBase<ElseDerived>& elseMatrix) const
DenseBase<Derived>::select(typename ElseDerived::Scalar thenScalar,
const DenseBase<ElseDerived>& elseMatrix) const
{
return Select<Derived,NestByValue<typename ElseDerived::ConstantReturnType>,ElseDerived>(
derived(), ElseDerived::Constant(rows(),cols(),thenScalar), elseMatrix.derived());

View File

@@ -74,11 +74,12 @@ struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
template< typename MatrixType, typename MemberOp, int Direction>
class PartialReduxExpr : ei_no_assignment_operator,
public MatrixBase<PartialReduxExpr<MatrixType, MemberOp, Direction> >
public MatrixType::template MakeBase< PartialReduxExpr<MatrixType, MemberOp, Direction> >::Type
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(PartialReduxExpr)
typedef typename MatrixType::template MakeBase< PartialReduxExpr<MatrixType, MemberOp, Direction> >::Type Base;
_EIGEN_GENERIC_PUBLIC_INTERFACE(PartialReduxExpr)
typedef typename ei_traits<PartialReduxExpr>::MatrixTypeNested MatrixTypeNested;
typedef typename ei_traits<PartialReduxExpr>::_MatrixTypeNested _MatrixTypeNested;