14#include "./InternalHeaderCheck.h"
34template <
typename ConditionMatrixType,
typename ThenMatrixType,
typename ElseMatrixType>
35struct traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > : traits<ThenMatrixType> {
36 typedef typename traits<ThenMatrixType>::Scalar Scalar;
37 typedef Dense StorageKind;
38 typedef typename traits<ThenMatrixType>::XprKind XprKind;
39 typedef typename ConditionMatrixType::Nested ConditionMatrixNested;
40 typedef typename ThenMatrixType::Nested ThenMatrixNested;
41 typedef typename ElseMatrixType::Nested ElseMatrixNested;
43 RowsAtCompileTime = ConditionMatrixType::RowsAtCompileTime,
44 ColsAtCompileTime = ConditionMatrixType::ColsAtCompileTime,
45 MaxRowsAtCompileTime = ConditionMatrixType::MaxRowsAtCompileTime,
46 MaxColsAtCompileTime = ConditionMatrixType::MaxColsAtCompileTime,
47 Flags = (
unsigned int)ThenMatrixType::Flags & ElseMatrixType::Flags & RowMajorBit
52template <
typename ConditionMatrixType,
typename ThenMatrixType,
typename ElseMatrixType>
53class Select :
public internal::dense_xpr_base<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::type,
54 internal::no_assignment_operator {
56 typedef typename internal::dense_xpr_base<Select>::type Base;
57 EIGEN_DENSE_PUBLIC_INTERFACE(
Select)
59 inline EIGEN_DEVICE_FUNC
Select(
const ConditionMatrixType& a_conditionMatrix,
const ThenMatrixType& a_thenMatrix,
60 const ElseMatrixType& a_elseMatrix)
61 : m_condition(a_conditionMatrix), m_then(a_thenMatrix), m_else(a_elseMatrix) {
62 eigen_assert(m_condition.rows() == m_then.rows() && m_condition.rows() == m_else.rows());
63 eigen_assert(m_condition.cols() == m_then.cols() && m_condition.cols() == m_else.cols());
66 inline EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
Index rows()
const EIGEN_NOEXCEPT {
return m_condition.rows(); }
67 inline EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
Index cols()
const EIGEN_NOEXCEPT {
return m_condition.cols(); }
69 inline EIGEN_DEVICE_FUNC
const Scalar coeff(
Index i,
Index j)
const {
70 if (m_condition.coeff(i, j))
71 return m_then.coeff(i, j);
73 return m_else.coeff(i, j);
76 inline EIGEN_DEVICE_FUNC
const Scalar coeff(
Index i)
const {
77 if (m_condition.coeff(i))
78 return m_then.coeff(i);
80 return m_else.coeff(i);
83 inline EIGEN_DEVICE_FUNC
const ConditionMatrixType& conditionMatrix()
const {
return m_condition; }
85 inline EIGEN_DEVICE_FUNC
const ThenMatrixType& thenMatrix()
const {
return m_then; }
87 inline EIGEN_DEVICE_FUNC
const ElseMatrixType& elseMatrix()
const {
return m_else; }
90 typename ConditionMatrixType::Nested m_condition;
91 typename ThenMatrixType::Nested m_then;
92 typename ElseMatrixType::Nested m_else;
103template <
typename Derived>
104template <
typename ThenDerived,
typename ElseDerived>
108 ThenDerived, ElseDerived, Derived>
110 using Op = internal::scalar_boolean_select_op<typename DenseBase<ThenDerived>::Scalar,
120template <
typename Derived>
121template <
typename ThenDerived>
129 using Op = internal::scalar_boolean_select_op<typename DenseBase<ThenDerived>::Scalar,
132 thenMatrix.
derived(), ElseConstantType(rows(), cols(), elseScalar), derived(), Op());
139template <
typename Derived>
140template <
typename ElseDerived>
148 using Op = internal::scalar_boolean_select_op<typename DenseBase<ElseDerived>::Scalar,
151 elseMatrix.
derived(), derived(), Op());
Generic expression where a coefficient-wise ternary operator is applied to two expressions.
Definition CwiseTernaryOp.h:86
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:44
internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:62
Derived & derived()
Definition EigenBase.h:49
Expression of a coefficient wise version of the C++ ternary operator ?:
Definition Select.h:54
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83