12#ifndef EIGEN_CWISE_TERNARY_OP_H
13#define EIGEN_CWISE_TERNARY_OP_H
15#include "./InternalHeaderCheck.h"
20template <
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3>
21struct traits<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > {
24 typedef remove_all_t<Arg1> Ancestor;
25 typedef typename traits<Ancestor>::XprKind XprKind;
27 RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,
28 ColsAtCompileTime = traits<Ancestor>::ColsAtCompileTime,
29 MaxRowsAtCompileTime = traits<Ancestor>::MaxRowsAtCompileTime,
30 MaxColsAtCompileTime = traits<Ancestor>::MaxColsAtCompileTime
36 typedef typename result_of<TernaryOp(
37 const typename Arg1::Scalar&,
const typename Arg2::Scalar&,
38 const typename Arg3::Scalar&)>::type Scalar;
40 typedef typename internal::traits<Arg1>::StorageKind StorageKind;
41 typedef typename internal::traits<Arg1>::StorageIndex StorageIndex;
43 typedef typename Arg1::Nested Arg1Nested;
44 typedef typename Arg2::Nested Arg2Nested;
45 typedef typename Arg3::Nested Arg3Nested;
46 typedef std::remove_reference_t<Arg1Nested> Arg1Nested_;
47 typedef std::remove_reference_t<Arg2Nested> Arg2Nested_;
48 typedef std::remove_reference_t<Arg3Nested> Arg3Nested_;
53template <
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3,
55class CwiseTernaryOpImpl;
84template <
typename TernaryOp,
typename Arg1Type,
typename Arg2Type,
87 TernaryOp, Arg1Type, Arg2Type, Arg3Type,
88 typename internal::traits<Arg1Type>::StorageKind>,
89 internal::no_assignment_operator
92 typedef internal::remove_all_t<Arg1Type> Arg1;
93 typedef internal::remove_all_t<Arg2Type> Arg2;
94 typedef internal::remove_all_t<Arg3Type> Arg3;
97 EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Arg1, Arg2)
98 EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Arg1, Arg3)
101 EIGEN_STATIC_ASSERT((internal::is_same<
102 typename internal::traits<Arg1Type>::StorageKind,
103 typename internal::traits<Arg2Type>::StorageKind>::value),
104 STORAGE_KIND_MUST_MATCH)
105 EIGEN_STATIC_ASSERT((internal::is_same<
106 typename internal::traits<Arg1Type>::StorageKind,
107 typename internal::traits<Arg3Type>::StorageKind>::value),
108 STORAGE_KIND_MUST_MATCH)
110 typedef typename CwiseTernaryOpImpl<
111 TernaryOp, Arg1Type, Arg2Type, Arg3Type,
112 typename internal::traits<Arg1Type>::StorageKind>::Base Base;
115 typedef typename internal::ref_selector<Arg1Type>::type Arg1Nested;
116 typedef typename internal::ref_selector<Arg2Type>::type Arg2Nested;
117 typedef typename internal::ref_selector<Arg3Type>::type Arg3Nested;
118 typedef std::remove_reference_t<Arg1Nested> Arg1Nested_;
119 typedef std::remove_reference_t<Arg2Nested> Arg2Nested_;
120 typedef std::remove_reference_t<Arg3Nested> Arg3Nested_;
123 EIGEN_STRONG_INLINE
CwiseTernaryOp(
const Arg1& a1,
const Arg2& a2,
125 const TernaryOp& func = TernaryOp())
126 : m_arg1(a1), m_arg2(a2), m_arg3(a3), m_functor(func) {
127 eigen_assert(a1.rows() == a2.rows() && a1.cols() == a2.cols() &&
128 a1.rows() == a3.rows() && a1.cols() == a3.cols());
132 EIGEN_STRONG_INLINE
Index rows()
const {
135 if (internal::traits<internal::remove_all_t<Arg1Nested>>::
136 RowsAtCompileTime ==
Dynamic &&
137 internal::traits<internal::remove_all_t<Arg2Nested>>::
139 return m_arg3.rows();
140 else if (internal::traits<internal::remove_all_t<Arg1Nested>>::
141 RowsAtCompileTime ==
Dynamic &&
142 internal::traits<internal::remove_all_t<Arg3Nested>>::
144 return m_arg2.rows();
146 return m_arg1.rows();
149 EIGEN_STRONG_INLINE
Index cols()
const {
152 if (internal::traits<internal::remove_all_t<Arg1Nested>>::
153 ColsAtCompileTime ==
Dynamic &&
154 internal::traits<internal::remove_all_t<Arg2Nested>>::
156 return m_arg3.cols();
157 else if (internal::traits<internal::remove_all_t<Arg1Nested>>::
158 ColsAtCompileTime ==
Dynamic &&
159 internal::traits<internal::remove_all_t<Arg3Nested>>::
161 return m_arg2.cols();
163 return m_arg1.cols();
168 const Arg1Nested_&
arg1()
const {
return m_arg1; }
171 const Arg2Nested_&
arg2()
const {
return m_arg2; }
174 const Arg3Nested_&
arg3()
const {
return m_arg3; }
177 const TernaryOp&
functor()
const {
return m_functor; }
183 const TernaryOp m_functor;
187template <
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3,
188 typename StorageKind>
189class CwiseTernaryOpImpl
190 :
public internal::generic_xpr_base<
191 CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >::type {
193 typedef typename internal::generic_xpr_base<
194 CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >::type Base;
Generic expression where a coefficient-wise ternary operator is applied to two expressions.
Definition CwiseTernaryOp.h:90
const Arg3Nested_ & arg3() const
Definition CwiseTernaryOp.h:174
const Arg2Nested_ & arg2() const
Definition CwiseTernaryOp.h:171
const TernaryOp & functor() const
Definition CwiseTernaryOp.h:177
const Arg1Nested_ & arg1() const
Definition CwiseTernaryOp.h:168
const unsigned int RowMajorBit
Definition Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
const int Dynamic
Definition Constants.h:24