diff options
author | 2008-09-03 17:16:28 +0000 | |
---|---|---|
committer | 2008-09-03 17:16:28 +0000 | |
commit | 59dc1da5bf6b5c57205ee8d695e0f6e852ca74ae (patch) | |
tree | 6e1b3bba60675b5544cc59e29f402aa247298257 /Eigen/src/Core | |
parent | 622f2d5eae03cdf1c268e64b40f38bf20bc13c86 (diff) |
Add a Select expression in the Array module which mimics a coeff-wise ?: operator.
Example:
mat = (mat.cwise().abs().cwise() < Ones()).select(0,mat);
replaces all small values by 0. (the scalar version is "s = abs(s)<1 ? 0 : s")
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 12 | ||||
-rw-r--r-- | Eigen/src/Core/util/ForwardDeclarations.h | 7 |
2 files changed, 17 insertions, 2 deletions
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 4248ae523..e6af97bb3 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -539,6 +539,18 @@ template<typename Derived> class MatrixBase static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(int size); static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(); + template<typename ThenDerived,typename ElseDerived> + const Select<Derived,ThenDerived,ElseDerived> + select(const MatrixBase<ThenDerived>& thenMatrix, + const MatrixBase<ElseDerived>& elseMatrix) const; + + template<typename ThenDerived> + inline const Select<Derived,ThenDerived, NestByValue<typename ThenDerived::ConstantReturnType> > + select(const MatrixBase<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 MatrixBase<ElseDerived>& elseMatrix) const; /////////// LU module /////////// diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index 92852cbfa..8a8beb9b7 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -50,8 +50,6 @@ template<typename MatrixType, int PacketAccess = AsRequested> class Map; template<typename MatrixType, unsigned int Mode> class Part; template<typename MatrixType, unsigned int Mode> class Extract; template<typename ExpressionType> class Cwise; -template<typename ExpressionType, int Direction> class PartialRedux; -template<typename MatrixType, typename BinaryOp, int Direction> class PartialReduxExpr; template<typename ExpressionType> class WithFormat; template<typename Lhs, typename Rhs> struct ei_product_mode; @@ -94,6 +92,11 @@ void ei_cache_friendly_product( bool _rhsRowMajor, const Scalar* _rhs, int _rhsStride, bool resRowMajor, Scalar* res, int resStride); +// Array module +template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> class Select; +template<typename MatrixType, typename BinaryOp, int Direction> class PartialReduxExpr; +template<typename ExpressionType, int Direction> class PartialRedux; + template<typename MatrixType> class LU; template<typename MatrixType> class QR; template<typename MatrixType> class SVD; |