10 #ifndef EIGEN_SPARSE_CWISE_BINARY_OP_H 11 #define EIGEN_SPARSE_CWISE_BINARY_OP_H 35 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
49 THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH);
59 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
76 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor)
83 if (m_lhsIter && m_rhsIter && (m_lhsIter.index() == m_rhsIter.index()))
85 m_id = m_lhsIter.
index();
86 m_value = m_functor(m_lhsIter.value(), m_rhsIter.value());
90 else if (m_lhsIter && (!m_rhsIter || (m_lhsIter.index() < m_rhsIter.index())))
92 m_id = m_lhsIter.index();
93 m_value = m_functor(m_lhsIter.value(), Scalar(0));
96 else if (m_rhsIter && (!m_lhsIter || (m_lhsIter.index() > m_rhsIter.index())))
98 m_id = m_rhsIter.index();
99 m_value = m_functor(Scalar(0), m_rhsIter.value());
130 Flags = XprType::Flags
134 : m_functor(xpr.functor()),
135 m_lhsImpl(xpr.lhs()),
143 return m_lhsImpl.nonZerosEstimate() + m_rhsImpl.nonZerosEstimate();
153 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
170 : m_lhsEval(aEval.m_lhsImpl), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor), m_value(0), m_id(-1), m_innerSize(aEval.m_expr.rhs().innerSize())
180 Scalar lhsVal = m_lhsEval.coeff(IsRowMajor?m_rhsIter.outer():m_id,
181 IsRowMajor?m_id:m_rhsIter.outer());
182 if(m_rhsIter && m_rhsIter.index()==m_id)
184 m_value = m_functor(lhsVal, m_rhsIter.value());
188 m_value = m_functor(lhsVal, Scalar(0));
220 : m_functor(xpr.functor()),
221 m_lhsImpl(xpr.lhs()),
222 m_rhsImpl(xpr.rhs()),
230 return m_expr.size();
241 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
258 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsEval(aEval.m_rhsImpl), m_functor(aEval.m_functor), m_value(0), m_id(-1), m_innerSize(aEval.m_expr.lhs().innerSize())
268 Scalar rhsVal = m_rhsEval.coeff(IsRowMajor?m_lhsIter.outer():m_id,
269 IsRowMajor?m_id:m_lhsIter.outer());
270 if(m_lhsIter && m_lhsIter.index()==m_id)
272 m_value = m_functor(m_lhsIter.value(), rhsVal);
276 m_value = m_functor(Scalar(0),rhsVal);
308 : m_functor(xpr.functor()),
309 m_lhsImpl(xpr.lhs()),
310 m_rhsImpl(xpr.rhs()),
318 return m_expr.size();
335 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
344 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
353 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
363 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
373 template<
typename Lhs,
typename Rhs>
382 template<
typename Lhs,
typename Rhs>
391 template<
typename Lhs,
typename Rhs>
401 template<
typename XprType>
420 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor)
422 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
424 if (m_lhsIter.index() < m_rhsIter.index())
435 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
437 if (m_lhsIter.index() < m_rhsIter.index())
463 Flags = XprType::Flags
467 : m_functor(xpr.functor()),
468 m_lhsImpl(xpr.lhs()),
476 return (std::min)(m_lhsImpl.nonZerosEstimate(), m_rhsImpl.nonZerosEstimate());
486 template<
typename XprType>
507 : m_lhsEval(aEval.m_lhsImpl), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor), m_outer(outer)
517 {
return m_functor(m_lhsEval.coeff(IsRowMajor?m_outer:m_rhsIter.index(),IsRowMajor?m_rhsIter.index():m_outer), m_rhsIter.value()); }
541 : m_functor(xpr.functor()),
542 m_lhsImpl(xpr.lhs()),
550 return m_rhsImpl.nonZerosEstimate();
560 template<
typename XprType>
581 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsEval(aEval.m_rhsImpl), m_functor(aEval.m_functor), m_outer(outer)
591 {
return m_functor(m_lhsIter.value(),
592 m_rhsEval.coeff(IsRowMajor?m_outer:m_lhsIter.index(),IsRowMajor?m_lhsIter.index():m_outer)); }
616 : m_functor(xpr.functor()),
617 m_lhsImpl(xpr.lhs()),
625 return m_lhsImpl.nonZerosEstimate();
640 template<
typename Derived>
641 template<
typename OtherDerived>
648 template<
typename Derived>
649 template<
typename OtherDerived>
656 template<
typename Derived>
657 template<
typename OtherDerived>
661 return derived() = derived() - other.
derived();
664 template<
typename Derived>
665 template<
typename OtherDerived>
669 return derived() = derived() + other.
derived();
672 template<
typename Derived>
673 template<
typename OtherDerived>
680 template<
typename Derived>
681 template<
typename OtherDerived>
688 template<
typename Derived>
689 template<
typename OtherDerived>
696 template<
typename DenseDerived,
typename SparseDerived>
700 return CwiseBinaryOp<internal::scalar_sum_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>(a.derived(), b.
derived());
703 template<
typename SparseDerived,
typename DenseDerived>
707 return CwiseBinaryOp<internal::scalar_sum_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>(a.
derived(), b.derived());
710 template<
typename DenseDerived,
typename SparseDerived>
714 return CwiseBinaryOp<internal::scalar_difference_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>(a.derived(), b.
derived());
717 template<
typename SparseDerived,
typename DenseDerived>
721 return CwiseBinaryOp<internal::scalar_difference_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>(a.
derived(), b.derived());
726 #endif // EIGEN_SPARSE_CWISE_BINARY_OP_H evaluator< Lhs > m_lhsImpl
EIGEN_DEVICE_FUNC const Derived & derived() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
EIGEN_STRONG_INLINE Index col() const
evaluator< Rhs > m_rhsImpl
#define EIGEN_STRONG_INLINE
evaluator< Rhs > m_rhsImpl
evaluator< LhsArg > m_lhsImpl
const BinaryOp & m_functor
EIGEN_STRONG_INLINE Index row() const
EIGEN_STRONG_INLINE Scalar value() const
CwiseBinaryOp< scalar_product_op< T1, T2 >, Lhs, Rhs > XprType
EIGEN_STRONG_INLINE Index col() const
EIGEN_STRONG_INLINE const CwiseProductDenseReturnType< OtherDerived >::Type cwiseProduct(const MatrixBase< OtherDerived > &other) const
EIGEN_STRONG_INLINE StorageIndex index() const
EIGEN_STRONG_INLINE InnerIterator(const sparse_conjunction_evaluator &aEval, Index outer)
EIGEN_STRONG_INLINE Index row() const
EIGEN_STRONG_INLINE Scalar value() const
traits< XprType >::Scalar Scalar
Index nonZerosEstimate() const
evaluator< Rhs >::InnerIterator RhsIterator
XprType::StorageIndex StorageIndex
EIGEN_STRONG_INLINE StorageIndex index() const
CwiseBinaryOp< scalar_boolean_and_op, Lhs, Rhs > XprType
sparse_conjunction_evaluator< XprType > Base
XprType::Functor BinaryOp
Derived & operator+=(const SparseMatrixBase< OtherDerived > &other)
XprType::Functor BinaryOp
binary_evaluator(const XprType &xpr)
EIGEN_STRONG_INLINE InnerIterator(const sparse_conjunction_evaluator &aEval, Index outer)
sparse_conjunction_evaluator< XprType > Base
EIGEN_STRONG_INLINE Index row() const
EIGEN_STRONG_INLINE InnerIterator & operator++()
EIGEN_STRONG_INLINE Index outer() const
EIGEN_STRONG_INLINE const CwiseBinaryOp< internal::scalar_sum_op< typename DenseDerived::Scalar, typename SparseDerived::Scalar >, const DenseDerived, const SparseDerived > operator+(const MatrixBase< DenseDerived > &a, const SparseMatrixBase< SparseDerived > &b)
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
EIGEN_STRONG_INLINE InnerIterator & operator++()
evaluator< RhsArg > m_rhsImpl
CwiseBinaryOp< scalar_boolean_and_op, Lhs, Rhs > XprType
const evaluator< RhsArg > & m_rhsEval
binary_evaluator(const XprType &xpr)
const unsigned int RowMajorBit
sparse_conjunction_evaluator< XprType > Base
evaluator< Lhs >::InnerIterator LhsIterator
sparse_conjunction_evaluator(const XprType &xpr)
traits< XprType >::Scalar Scalar
XprType::StorageIndex StorageIndex
traits< XprType >::Scalar Scalar
traits< XprType >::Scalar Scalar
EIGEN_STRONG_INLINE InnerIterator(const sparse_conjunction_evaluator &aEval, Index outer)
evaluator< Rhs >::InnerIterator RhsIterator
EIGEN_STRONG_INLINE Index index() const
Index nonZerosEstimate() const
EIGEN_STRONG_INLINE StorageIndex index() const
binary_evaluator(const XprType &xpr)
EIGEN_STRONG_INLINE Scalar value() const
sparse_conjunction_evaluator< XprType > Base
#define EIGEN_INTERNAL_CHECK_COST_VALUE(C)
Generic expression where a coefficient-wise binary operator is applied to two expressions.
const BinaryOp & m_functor
const LhsEvaluator & m_lhsEval
Index nonZerosEstimate() const
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
evaluator< LhsArg > LhsEvaluator
binary_evaluator(const XprType &xpr)
const BinaryOp & m_functor
binary_evaluator(const XprType &xpr)
Base class of any sparse matrices or sparse expressions.
CwiseBinaryOp< BinaryOp, Lhs, Rhs > XprType
EIGEN_STRONG_INLINE InnerIterator(const binary_evaluator &aEval, Index outer)
XprType::StorageIndex StorageIndex
const evaluator< Rhs > & m_rhsEval
CwiseBinaryOp< scalar_quotient_op< T1, T2 >, Lhs, Rhs > XprType
EIGEN_STRONG_INLINE Index col() const
EIGEN_STRONG_INLINE Index outer() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
evaluator< LhsArg >::InnerIterator LhsIterator
XprType::StorageIndex StorageIndex
const BinaryOp & m_functor
binary_evaluator(const XprType &xpr)
sparse_conjunction_evaluator< XprType > Base
EIGEN_STRONG_INLINE const CwiseBinaryOp< internal::scalar_difference_op< typename DenseDerived::Scalar, typename SparseDerived::Scalar >, const DenseDerived, const SparseDerived > operator-(const MatrixBase< DenseDerived > &a, const SparseMatrixBase< SparseDerived > &b)
sparse_conjunction_evaluator(const XprType &xpr)
EIGEN_STRONG_INLINE InnerIterator(const binary_evaluator &aEval, Index outer)
evaluator< RhsArg > m_rhsImpl
EIGEN_STRONG_INLINE Index outer() const
evaluator< Lhs >::InnerIterator LhsIterator
CwiseBinaryOp< scalar_boolean_and_op, Lhs, Rhs > XprType
EIGEN_STRONG_INLINE Scalar value() const
const BinaryOp & m_functor
binary_evaluator(const XprType &xpr)
CwiseBinaryOp< BinaryOp, Lhs, Rhs > XprType
sparse_conjunction_evaluator< XprType > Base
Index nonZerosEstimate() const
binary_evaluator(const XprType &xpr)
evaluator< RhsArg > RhsEvaluator
EIGEN_STRONG_INLINE InnerIterator & operator++()
CwiseBinaryOp< BinaryOp, Lhs, Rhs > XprType
EIGEN_STRONG_INLINE Index row() const
EIGEN_STRONG_INLINE Index col() const
traits< XprType >::Scalar Scalar
XprType::StorageIndex StorageIndex
evaluator< LhsArg > m_lhsImpl
evaluator< Lhs > m_lhsImpl
XprType::Functor BinaryOp
CwiseBinaryOp< BinaryOp, Lhs, Rhs > Derived
evaluator< RhsArg >::InnerIterator RhsIterator
EIGEN_STRONG_INLINE StorageIndex index() const
XprType::StorageIndex StorageIndex
EIGEN_STRONG_INLINE InnerIterator(const binary_evaluator &aEval, Index outer)
EIGEN_STRONG_INLINE Scalar value() const
CwiseBinaryOp< scalar_product_op< T1, T2 >, Lhs, Rhs > XprType
sparse_conjunction_evaluator< XprType > Base
const Derived & derived() const
EIGEN_STRONG_INLINE Index outer() const
evaluator< Rhs > m_rhsImpl
traits< XprType >::Scalar Scalar
EIGEN_STRONG_INLINE Index row() const
binary_evaluator(const XprType &xpr)
Derived & operator-=(const SparseMatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE StorageIndex index() const
SparseMatrixBase< Derived > Base
const evaluator< Lhs > & m_lhsEval
EIGEN_STRONG_INLINE StorageIndex index() const
evaluator< LhsArg >::InnerIterator LhsIterator
EIGEN_STRONG_INLINE Index outer() const
EIGEN_STRONG_INLINE InnerIterator & operator++()
EIGEN_STRONG_INLINE Index col() const
sparse_conjunction_evaluator(const XprType &xpr)
#define eigen_internal_assert(x)
evaluator< Lhs > m_lhsImpl
Index nonZerosEstimate() const
EIGEN_STRONG_INLINE Index row() const
binary_evaluator(const XprType &xpr)
CwiseBinaryOp< scalar_product_op< T1, T2 >, Lhs, Rhs > XprType
evaluator< RhsArg > m_rhsImpl
EIGEN_STRONG_INLINE Scalar value() const
EIGEN_STRONG_INLINE InnerIterator & operator++()
EIGEN_DEVICE_FUNC const Scalar & b
evaluator< RhsArg >::InnerIterator RhsIterator
EIGEN_DEVICE_FUNC Derived & derived()
Index nonZerosEstimate() const
EIGEN_STRONG_INLINE Index outer() const
Base class for all dense matrices, vectors, and expressions.
EIGEN_STRONG_INLINE InnerIterator & operator++()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment(Dst &dst, const Src &src)
const BinaryOp & m_functor
An InnerIterator allows to loop over the element of any matrix expression.
EIGEN_STRONG_INLINE Index col() const
evaluator< LhsArg > m_lhsImpl