10 #ifndef EIGEN_SPARSE_CWISE_BINARY_OP_H 11 #define EIGEN_SPARSE_CWISE_BINARY_OP_H 35 {
typedef Sparse
ret; };
38 {
typedef Sparse
ret; };
40 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename Derived,
47 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
53 class ReverseInnerIterator;
62 || ((Lhs::Flags&
RowMajorBit) == (Rhs::Flags&RowMajorBit))),
63 THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH);
67 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
72 typedef typename Lhs::Index
Index;
77 : Base(binOp.derived(),outer)
93 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename Derived>
107 : m_lhsIter(xpr.lhs(),outer), m_rhsIter(xpr.rhs(),outer), m_functor(xpr.functor())
114 if (m_lhsIter && m_rhsIter && (m_lhsIter.index() == m_rhsIter.index()))
116 m_id = m_lhsIter.index();
117 m_value = m_functor(m_lhsIter.value(), m_rhsIter.value());
121 else if (m_lhsIter && (!m_rhsIter || (m_lhsIter.index() < m_rhsIter.index())))
123 m_id = m_lhsIter.index();
124 m_value = m_functor(m_lhsIter.value(), Scalar(0));
127 else if (m_rhsIter && (!m_lhsIter || (m_lhsIter.index() > m_rhsIter.index())))
129 m_id = m_rhsIter.index();
130 m_value = m_functor(Scalar(0), m_rhsIter.value());
138 return *
static_cast<Derived*
>(
this);
158 template<
typename T,
typename Lhs,
typename Rhs,
typename Derived>
163 typedef typename CwiseBinaryXpr::Scalar
Scalar;
172 : m_lhsIter(xpr.lhs(),outer), m_rhsIter(xpr.rhs(),outer), m_functor(xpr.functor())
174 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
176 if (m_lhsIter.index() < m_rhsIter.index())
187 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
189 if (m_lhsIter.index() < m_rhsIter.index())
194 return *
static_cast<Derived*
>(
this);
212 template<
typename T,
typename Lhs,
typename Rhs,
typename Derived>
217 typedef typename CwiseBinaryXpr::Scalar
Scalar;
226 : m_rhs(xpr.rhs()), m_lhsIter(xpr.lhs(),outer), m_functor(xpr.functor()), m_outer(outer)
232 return *
static_cast<Derived*
>(
this);
236 {
return m_functor(m_lhsIter.value(),
237 m_rhs.coeff(IsRowMajor?m_outer:m_lhsIter.index(),IsRowMajor?m_lhsIter.index():m_outer)); }
253 template<
typename T,
typename Lhs,
typename Rhs,
typename Derived>
258 typedef typename CwiseBinaryXpr::Scalar
Scalar;
267 : m_xpr(xpr), m_rhsIter(xpr.rhs(),outer), m_functor(xpr.functor()), m_outer(outer)
273 return *
static_cast<Derived*
>(
this);
277 {
return m_functor(m_xpr.lhs().coeff(IsRowMajor?m_outer:m_rhsIter.index(),IsRowMajor?m_rhsIter.index():m_outer), m_rhsIter.value()); }
298 template<
typename Derived>
299 template<
typename OtherDerived>
303 return derived() = derived() - other.
derived();
306 template<
typename Derived>
307 template<
typename OtherDerived>
311 return derived() = derived() + other.
derived();
314 template<
typename Derived>
315 template<
typename OtherDerived>
324 #endif // EIGEN_SPARSE_CWISE_BINARY_OP_H EIGEN_STRONG_INLINE Index row() const
traits< CwiseBinaryXpr >::_RhsNested _RhsNested
scalar_product_op< T > BinaryFunc
EIGEN_STRONG_INLINE Index index() const
EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE cwiseProduct(const MatrixBase< OtherDerived > &other) const
traits< CwiseBinaryXpr >::Scalar Scalar
#define EIGEN_STRONG_INLINE
scalar_product_op< T > BinaryFunc
EIGEN_STRONG_INLINE Index col() const
const BinaryFunc & m_functor
const BinaryFunc m_functor
traits< CwiseBinaryXpr >::_RhsNested _RhsNested
Derived & operator+=(const SparseMatrixBase< OtherDerived > &other)
CwiseBinaryXpr::Scalar Scalar
EIGEN_STRONG_INLINE Scalar value() const
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
traits< CwiseBinaryXpr >::_LhsNested _LhsNested
const unsigned int RowMajorBit
_LhsNested::InnerIterator LhsIterator
const BinaryOp & m_functor
EIGEN_STRONG_INLINE Scalar value() const
EIGEN_STRONG_INLINE Index col() const
traits< CwiseBinaryXpr >::_RhsNested _RhsNested
_RhsNested::InnerIterator RhsIterator
Generic expression where a coefficient-wise binary operator is applied to two expressions.
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
Base class of any sparse matrices or sparse expressions.
_RhsNested::InnerIterator RhsIterator
CwiseBinaryOp< BinaryFunc, Lhs, Rhs > CwiseBinaryXpr
EIGEN_STRONG_INLINE Derived & operator++()
EIGEN_STRONG_INLINE sparse_cwise_binary_op_inner_iterator_selector(const CwiseBinaryXpr &xpr, Index outer)
EIGEN_STRONG_INLINE Scalar value() const
EIGEN_STRONG_INLINE Derived & operator++()
EIGEN_STRONG_INLINE Derived & operator++()
traits< CwiseBinaryXpr >::_LhsNested _LhsNested
scalar_product_op< T > BinaryFunc
EIGEN_STRONG_INLINE sparse_cwise_binary_op_inner_iterator_selector(const CwiseBinaryXpr &xpr, Index outer)
const BinaryFunc & m_functor
EIGEN_STRONG_INLINE Index col() const
traits< CwiseBinaryXpr >::RhsNested RhsNested
EIGEN_STRONG_INLINE Index row() const
EIGEN_STRONG_INLINE Scalar value() const
CwiseBinaryOp< BinaryOp, Lhs, Rhs > CwiseBinaryXpr
EIGEN_STRONG_INLINE Index row() const
#define EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
internal::sparse_cwise_binary_op_inner_iterator_selector< BinaryOp, Lhs, Rhs, InnerIterator > Base
EIGEN_STRONG_INLINE Index row() const
CwiseBinaryOp< BinaryOp, Lhs, Rhs > Derived
An InnerIterator allows to loop over the element of a sparse (or dense) matrix or expression...
_LhsNested::InnerIterator LhsIterator
const Derived & derived() const
EIGEN_STRONG_INLINE Index index() const
EIGEN_STRONG_INLINE Index index() const
EIGEN_STRONG_INLINE Index index() const
CwiseBinaryOp< BinaryFunc, Lhs, Rhs > CwiseBinaryXpr
Derived & operator-=(const SparseMatrixBase< OtherDerived > &other)
CwiseBinaryXpr::Scalar Scalar
EIGEN_STRONG_INLINE sparse_cwise_binary_op_inner_iterator_selector(const CwiseBinaryXpr &xpr, Index outer)
_LhsNested::InnerIterator LhsIterator
EIGEN_STRONG_INLINE sparse_cwise_binary_op_inner_iterator_selector(const CwiseBinaryXpr &xpr, Index outer)
const CwiseBinaryXpr & m_xpr
Base class for all dense matrices, vectors, and expressions.
EIGEN_STRONG_INLINE Derived & operator++()
CwiseBinaryXpr::Scalar Scalar
_RhsNested::InnerIterator RhsIterator
traits< CwiseBinaryXpr >::_LhsNested _LhsNested
EIGEN_STRONG_INLINE InnerIterator(const CwiseBinaryOpImpl &binOp, Index outer)
CwiseBinaryOp< BinaryFunc, Lhs, Rhs > CwiseBinaryXpr
EIGEN_STRONG_INLINE Index col() const