11 #ifndef EIGEN_CWISE_BINARY_OP_H
12 #define EIGEN_CWISE_BINARY_OP_H
37 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
38 struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
42 typedef typename remove_all<Lhs>::type Ancestor;
43 typedef typename traits<Ancestor>::XprKind XprKind;
45 RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,
46 ColsAtCompileTime = traits<Ancestor>::ColsAtCompileTime,
47 MaxRowsAtCompileTime = traits<Ancestor>::MaxRowsAtCompileTime,
48 MaxColsAtCompileTime = traits<Ancestor>::MaxColsAtCompileTime
53 typedef typename result_of<
59 typedef typename cwise_promote_storage_type<typename traits<Lhs>::StorageKind,
60 typename traits<Rhs>::StorageKind,
61 BinaryOp>::ret StorageKind;
62 typedef typename promote_index_type<typename traits<Lhs>::StorageIndex,
63 typename traits<Rhs>::StorageIndex>::type StorageIndex;
64 typedef typename Lhs::Nested LhsNested;
65 typedef typename Rhs::Nested RhsNested;
66 typedef typename remove_reference<LhsNested>::type _LhsNested;
67 typedef typename remove_reference<RhsNested>::type _RhsNested;
74 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename StorageKind>
75 class CwiseBinaryOpImpl;
77 template<
typename BinaryOp,
typename LhsType,
typename RhsType>
79 public CwiseBinaryOpImpl<
80 BinaryOp, LhsType, RhsType,
81 typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
82 typename internal::traits<RhsType>::StorageKind,
84 internal::no_assignment_operator
88 typedef typename internal::remove_all<LhsType>::type Lhs;
89 typedef typename internal::remove_all<RhsType>::type Rhs;
91 typedef typename CwiseBinaryOpImpl<
92 BinaryOp, LhsType, RhsType,
93 typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
94 typename internal::traits<Rhs>::StorageKind,
95 BinaryOp>::ret>::Base Base;
98 typedef typename internal::ref_selector<LhsType>::type LhsNested;
99 typedef typename internal::ref_selector<RhsType>::type RhsNested;
100 typedef typename internal::remove_reference<LhsNested>::type _LhsNested;
101 typedef typename internal::remove_reference<RhsNested>::type _RhsNested;
104 EIGEN_STRONG_INLINE
CwiseBinaryOp(
const Lhs& aLhs,
const Rhs& aRhs,
const BinaryOp& func = BinaryOp())
105 : m_lhs(aLhs), m_rhs(aRhs), m_functor(func)
107 EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,
typename Lhs::Scalar,
typename Rhs::Scalar);
109 EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs)
110 eigen_assert(aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols());
114 EIGEN_STRONG_INLINE Index rows()
const {
116 if (internal::traits<
typename internal::remove_all<LhsNested>::type>::RowsAtCompileTime==Dynamic)
122 EIGEN_STRONG_INLINE Index cols()
const {
124 if (internal::traits<
typename internal::remove_all<LhsNested>::type>::ColsAtCompileTime==Dynamic)
132 const _LhsNested&
lhs()
const {
return m_lhs; }
135 const _RhsNested&
rhs()
const {
return m_rhs; }
138 const BinaryOp&
functor()
const {
return m_functor; }
143 const BinaryOp m_functor;
147 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename StorageKind>
148 class CwiseBinaryOpImpl
149 :
public internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type
152 typedef typename internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type Base;
159 template<
typename Derived>
160 template<
typename OtherDerived>
161 EIGEN_STRONG_INLINE Derived &
164 call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar>());
172 template<
typename Derived>
173 template<
typename OtherDerived>
174 EIGEN_STRONG_INLINE Derived &
177 call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar>());
183 #endif // EIGEN_CWISE_BINARY_OP_H
const BinaryOp & functor() const
Definition: CwiseBinaryOp.h:138
const unsigned int RowMajorBit
Definition: Constants.h:61
Derived & operator+=(const MatrixBase< OtherDerived > &other)
Definition: CwiseBinaryOp.h:175
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:78
const _LhsNested & lhs() const
Definition: CwiseBinaryOp.h:132
Definition: Eigen_Colamd.h:54
Derived & operator-=(const MatrixBase< OtherDerived > &other)
Definition: CwiseBinaryOp.h:162
const _RhsNested & rhs() const
Definition: CwiseBinaryOp.h:135
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48