10 #ifndef EIGEN_SPARSE_CWISE_BINARY_OP_H 11 #define EIGEN_SPARSE_CWISE_BINARY_OP_H 35 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
48 || ((Lhs::Flags&
RowMajorBit) == (Rhs::Flags&RowMajorBit))),
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());
129 Flags = XprType::Flags
133 : m_functor(xpr.functor()),
134 m_lhsImpl(xpr.lhs()),
142 return m_lhsImpl.nonZerosEstimate() + m_rhsImpl.nonZerosEstimate();
152 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
169 : 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())
179 Scalar lhsVal = m_lhsEval.coeff(IsRowMajor?m_rhsIter.outer():m_id,
180 IsRowMajor?m_id:m_rhsIter.outer());
181 if(m_rhsIter && m_rhsIter.index()==m_id)
183 m_value = m_functor(lhsVal, m_rhsIter.value());
187 m_value = m_functor(lhsVal, Scalar(0));
218 : m_functor(xpr.functor()),
219 m_lhsImpl(xpr.lhs()),
220 m_rhsImpl(xpr.rhs()),
228 return m_expr.size();
239 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
256 : 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())
266 Scalar rhsVal = m_rhsEval.coeff(IsRowMajor?m_lhsIter.outer():m_id,
267 IsRowMajor?m_id:m_lhsIter.outer());
268 if(m_lhsIter && m_lhsIter.index()==m_id)
270 m_value = m_functor(m_lhsIter.value(), rhsVal);
274 m_value = m_functor(Scalar(0),rhsVal);
305 : m_functor(xpr.functor()),
306 m_lhsImpl(xpr.lhs()),
307 m_rhsImpl(xpr.rhs()),
315 return m_expr.size();
332 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
341 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
350 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
360 template<
typename Lhs,
typename Rhs>
369 template<
typename Lhs,
typename Rhs>
378 template<
typename Lhs,
typename Rhs>
388 template<
typename XprType>
407 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor)
409 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
411 if (m_lhsIter.index() < m_rhsIter.index())
422 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
424 if (m_lhsIter.index() < m_rhsIter.index())
449 Flags = XprType::Flags
453 : m_functor(xpr.functor()),
454 m_lhsImpl(xpr.lhs()),
462 return (
std::min)(m_lhsImpl.nonZerosEstimate(), m_rhsImpl.nonZerosEstimate());
472 template<
typename XprType>
493 : m_lhsEval(aEval.m_lhsImpl), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor), m_outer(outer)
503 {
return m_functor(m_lhsEval.coeff(IsRowMajor?m_outer:m_rhsIter.index(),IsRowMajor?m_rhsIter.index():m_outer), m_rhsIter.value()); }
526 : m_functor(xpr.functor()),
527 m_lhsImpl(xpr.lhs()),
535 return m_rhsImpl.nonZerosEstimate();
545 template<
typename XprType>
566 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsEval(aEval.m_rhsImpl), m_functor(aEval.m_functor), m_outer(outer)
576 {
return m_functor(m_lhsIter.value(),
577 m_rhsEval.coeff(IsRowMajor?m_outer:m_lhsIter.index(),IsRowMajor?m_lhsIter.index():m_outer)); }
600 : m_functor(xpr.functor()),
601 m_lhsImpl(xpr.lhs()),
609 return m_lhsImpl.nonZerosEstimate();
624 template<
typename Derived>
625 template<
typename OtherDerived>
629 return derived() = derived() - other.
derived();
632 template<
typename Derived>
633 template<
typename OtherDerived>
637 return derived() = derived() + other.
derived();
640 template<
typename Derived>
641 template<
typename OtherDerived>
648 template<
typename Derived>
649 template<
typename OtherDerived>
656 template<
typename Derived>
657 template<
typename OtherDerived>
664 template<
typename DenseDerived,
typename SparseDerived>
668 return CwiseBinaryOp<internal::scalar_sum_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>(a.derived(), b.
derived());
671 template<
typename SparseDerived,
typename DenseDerived>
675 return CwiseBinaryOp<internal::scalar_sum_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>(a.
derived(), b.derived());
678 template<
typename DenseDerived,
typename SparseDerived>
682 return CwiseBinaryOp<internal::scalar_difference_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>(a.derived(), b.
derived());
685 template<
typename SparseDerived,
typename DenseDerived>
689 return CwiseBinaryOp<internal::scalar_difference_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>(a.
derived(), b.derived());
694 #endif // EIGEN_SPARSE_CWISE_BINARY_OP_H evaluator< Lhs > m_lhsImpl
Index nonZerosEstimate() const
EIGEN_STRONG_INLINE Scalar value() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
evaluator< Rhs > m_rhsImpl
EIGEN_STRONG_INLINE Index col() const
#define EIGEN_STRONG_INLINE
evaluator< Rhs > m_rhsImpl
evaluator< LhsArg > m_lhsImpl
EIGEN_STRONG_INLINE Scalar value() const
const BinaryOp & m_functor
EIGEN_STRONG_INLINE Index index() const
CwiseBinaryOp< scalar_product_op< T1, T2 >, Lhs, Rhs > XprType
Index nonZerosEstimate() const
EIGEN_STRONG_INLINE Scalar value() const
EIGEN_STRONG_INLINE InnerIterator(const sparse_conjunction_evaluator &aEval, Index outer)
traits< XprType >::Scalar Scalar
Index nonZerosEstimate() const
evaluator< Rhs >::InnerIterator RhsIterator
XprType::StorageIndex StorageIndex
CwiseBinaryOp< scalar_boolean_and_op, Lhs, Rhs > XprType
EIGEN_STRONG_INLINE StorageIndex index() const
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)
EIGEN_STRONG_INLINE Index row() const
EIGEN_STRONG_INLINE InnerIterator & operator++()
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
Index nonZerosEstimate() const
EIGEN_STRONG_INLINE Index row() const
Index nonZerosEstimate() const
EIGEN_STRONG_INLINE StorageIndex index() const
binary_evaluator(const XprType &xpr)
const unsigned int RowMajorBit
sparse_conjunction_evaluator< XprType > Base
EIGEN_STRONG_INLINE Index col() const
EIGEN_STRONG_INLINE Index row() const
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 row() 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
EIGEN_STRONG_INLINE Index col() const
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
evaluator< LhsArg > LhsEvaluator
EIGEN_STRONG_INLINE StorageIndex index() const
const BinaryOp & m_functor
binary_evaluator(const XprType &xpr)
Base class of any sparse matrices or sparse expressions.
EIGEN_STRONG_INLINE const CwiseProductDenseReturnType< OtherDerived >::Type cwiseProduct(const MatrixBase< OtherDerived > &other) const
CwiseBinaryOp< BinaryOp, Lhs, Rhs > XprType
EIGEN_STRONG_INLINE InnerIterator(const binary_evaluator &aEval, Index outer)
XprType::StorageIndex StorageIndex
const evaluator< Rhs > & m_rhsEval
EIGEN_STRONG_INLINE Index col() 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
EIGEN_STRONG_INLINE Scalar value() const
binary_evaluator(const XprType &xpr)
sparse_conjunction_evaluator< XprType > Base
EIGEN_STRONG_INLINE Index row() const
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
evaluator< Lhs >::InnerIterator LhsIterator
CwiseBinaryOp< scalar_boolean_and_op, Lhs, Rhs > XprType
const BinaryOp & m_functor
binary_evaluator(const XprType &xpr)
CwiseBinaryOp< BinaryOp, Lhs, Rhs > XprType
sparse_conjunction_evaluator< XprType > Base
binary_evaluator(const XprType &xpr)
evaluator< RhsArg > RhsEvaluator
EIGEN_STRONG_INLINE InnerIterator & operator++()
CwiseBinaryOp< BinaryOp, Lhs, Rhs > XprType
traits< XprType >::Scalar Scalar
EIGEN_STRONG_INLINE StorageIndex index() const
XprType::StorageIndex StorageIndex
evaluator< LhsArg > m_lhsImpl
evaluator< Lhs > m_lhsImpl
EIGEN_STRONG_INLINE Index col() const
XprType::Functor BinaryOp
CwiseBinaryOp< BinaryOp, Lhs, Rhs > Derived
evaluator< RhsArg >::InnerIterator RhsIterator
XprType::StorageIndex StorageIndex
EIGEN_STRONG_INLINE InnerIterator(const binary_evaluator &aEval, Index outer)
CwiseBinaryOp< scalar_product_op< T1, T2 >, Lhs, Rhs > XprType
sparse_conjunction_evaluator< XprType > Base
EIGEN_STRONG_INLINE Index col() const
evaluator< Rhs > m_rhsImpl
traits< XprType >::Scalar Scalar
binary_evaluator(const XprType &xpr)
Derived & operator-=(const SparseMatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE Scalar value() const
const Derived & derived() const
SparseMatrixBase< Derived > Base
const evaluator< Lhs > & m_lhsEval
evaluator< LhsArg >::InnerIterator LhsIterator
EIGEN_STRONG_INLINE InnerIterator & operator++()
sparse_conjunction_evaluator(const XprType &xpr)
#define eigen_internal_assert(x)
evaluator< Lhs > m_lhsImpl
binary_evaluator(const XprType &xpr)
CwiseBinaryOp< scalar_product_op< T1, T2 >, Lhs, Rhs > XprType
evaluator< RhsArg > m_rhsImpl
EIGEN_STRONG_INLINE Index row() const
EIGEN_STRONG_INLINE InnerIterator & operator++()
evaluator< RhsArg >::InnerIterator RhsIterator
Base class for all dense matrices, vectors, and expressions.
EIGEN_STRONG_INLINE InnerIterator & operator++()
EIGEN_STRONG_INLINE StorageIndex index() const
const BinaryOp & m_functor
Index nonZerosEstimate() const
EIGEN_STRONG_INLINE StorageIndex index() const
EIGEN_DEVICE_FUNC const Derived & derived() const
An InnerIterator allows to loop over the element of any matrix expression.
evaluator< LhsArg > m_lhsImpl