10 #ifndef EIGEN_SELECT_H 11 #define EIGEN_SELECT_H 31 template<
typename ConditionMatrixType,
typename ThenMatrixType,
typename ElseMatrixType>
32 struct traits<
Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
42 RowsAtCompileTime = ConditionMatrixType::RowsAtCompileTime,
43 ColsAtCompileTime = ConditionMatrixType::ColsAtCompileTime,
44 MaxRowsAtCompileTime = ConditionMatrixType::MaxRowsAtCompileTime,
45 MaxColsAtCompileTime = ConditionMatrixType::MaxColsAtCompileTime,
46 Flags = (
unsigned int)ThenMatrixType::Flags & ElseMatrixType::Flags &
RowMajorBit 51 template<
typename ConditionMatrixType,
typename ThenMatrixType,
typename ElseMatrixType>
60 inline EIGEN_DEVICE_FUNC
61 Select(const ConditionMatrixType& a_conditionMatrix,
62 const ThenMatrixType& a_thenMatrix,
63 const ElseMatrixType& a_elseMatrix)
64 : m_condition(a_conditionMatrix), m_then(a_thenMatrix), m_else(a_elseMatrix)
66 eigen_assert(m_condition.rows() == m_then.rows() && m_condition.rows() == m_else.rows());
67 eigen_assert(m_condition.cols() == m_then.cols() && m_condition.cols() == m_else.cols());
70 inline EIGEN_DEVICE_FUNC
Index rows()
const {
return m_condition.rows(); }
71 inline EIGEN_DEVICE_FUNC
Index cols()
const {
return m_condition.cols(); }
73 inline EIGEN_DEVICE_FUNC
76 if (m_condition.coeff(i,j))
77 return m_then.coeff(i,j);
79 return m_else.coeff(i,j);
82 inline EIGEN_DEVICE_FUNC
85 if (m_condition.coeff(i))
86 return m_then.coeff(i);
88 return m_else.coeff(i);
96 inline EIGEN_DEVICE_FUNC
const ThenMatrixType&
thenMatrix()
const 101 inline EIGEN_DEVICE_FUNC
const ElseMatrixType&
elseMatrix()
const 121 template<
typename Derived>
122 template<
typename ThenDerived,
typename ElseDerived>
135 template<
typename Derived>
136 template<
typename ThenDerived>
142 derived(), thenMatrix.derived(), ThenDerived::Constant(
rows(),
cols(),elseScalar));
150 template<
typename Derived>
151 template<
typename ElseDerived>
157 derived(), ElseDerived::Constant(
rows(),
cols(),thenScalar), elseMatrix.derived());
162 #endif // EIGEN_SELECT_H
traits< ThenMatrixType >::XprKind XprKind
Namespace containing all symbols from the Eigen library.
ThenMatrixType::Nested ThenMatrixNested
ElseMatrixType::Nested m_else
const unsigned int RowMajorBit
Base class for all dense matrices, vectors, and arrays.
EIGEN_DEVICE_FUNC const ElseMatrixType & elseMatrix() const
internal::dense_xpr_base< Select >::type Base
EIGEN_DEVICE_FUNC Index rows() const
ElseMatrixType::Nested ElseMatrixNested
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC const Scalar coeff(Index i, Index j) const
EIGEN_DEVICE_FUNC const Scalar coeff(Index i) const
const Select< Derived, ThenDerived, ElseDerived > select(const DenseBase< ThenDerived > &thenMatrix, const DenseBase< ElseDerived > &elseMatrix) const
EIGEN_DEVICE_FUNC const ThenMatrixType & thenMatrix() const
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
traits< ThenMatrixType >::Scalar Scalar
ConditionMatrixType::Nested ConditionMatrixNested
ThenMatrixType::Nested m_then
ConditionMatrixType::Nested m_condition
EIGEN_DEVICE_FUNC Index cols() const
EIGEN_DEVICE_FUNC const ConditionMatrixType & conditionMatrix() const
Expression of a coefficient wise version of the C++ ternary operator ?: