10#ifndef EIGEN_SPARSE_CWISE_BINARY_OP_H
11#define EIGEN_SPARSE_CWISE_BINARY_OP_H
35template<
typename BinaryOp,
typename Lhs,
typename Rhs>
36class CwiseBinaryOpImpl<BinaryOp, Lhs, Rhs, Sparse>
37 :
public SparseMatrixBase<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
40 typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> Derived;
41 typedef SparseMatrixBase<Derived> Base;
42 EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
46 (!internal::is_same<
typename internal::traits<Lhs>::StorageKind,
47 typename internal::traits<Rhs>::StorageKind>::value)
49 THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH);
57template<
typename XprType>
struct binary_sparse_evaluator;
59template<
typename BinaryOp,
typename Lhs,
typename Rhs>
60struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IteratorBased, IteratorBased>
61 : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
64 typedef typename evaluator<Lhs>::InnerIterator LhsIterator;
65 typedef typename evaluator<Rhs>::InnerIterator RhsIterator;
66 typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
67 typedef typename traits<XprType>::Scalar Scalar;
68 typedef typename XprType::StorageIndex StorageIndex;
75 EIGEN_STRONG_INLINE InnerIterator(
const binary_evaluator& aEval, Index outer)
76 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor)
81 EIGEN_STRONG_INLINE InnerIterator& operator++()
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());
110 EIGEN_STRONG_INLINE Scalar value()
const {
return m_value; }
112 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_id; }
113 EIGEN_STRONG_INLINE
Index outer()
const {
return m_lhsIter.outer(); }
114 EIGEN_STRONG_INLINE
Index row()
const {
return Lhs::IsRowMajor ? m_lhsIter.row() : index(); }
115 EIGEN_STRONG_INLINE
Index col()
const {
return Lhs::IsRowMajor ? index() : m_lhsIter.col(); }
117 EIGEN_STRONG_INLINE
operator bool()
const {
return m_id>=0; }
120 LhsIterator m_lhsIter;
121 RhsIterator m_rhsIter;
122 const BinaryOp& m_functor;
129 CoeffReadCost = int(evaluator<Lhs>::CoeffReadCost) + int(evaluator<Rhs>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
130 Flags = XprType::Flags
133 explicit binary_evaluator(
const XprType& xpr)
134 : m_functor(xpr.functor()),
135 m_lhsImpl(xpr.lhs()),
138 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
139 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
142 inline Index nonZerosEstimate()
const {
143 return m_lhsImpl.nonZerosEstimate() + m_rhsImpl.nonZerosEstimate();
147 const BinaryOp m_functor;
148 evaluator<Lhs> m_lhsImpl;
149 evaluator<Rhs> m_rhsImpl;
153template<
typename BinaryOp,
typename Lhs,
typename Rhs>
154struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IteratorBased>
155 : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
158 typedef typename evaluator<Rhs>::InnerIterator RhsIterator;
159 typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
160 typedef typename traits<XprType>::Scalar Scalar;
161 typedef typename XprType::StorageIndex StorageIndex;
166 enum { IsRowMajor = (int(Rhs::Flags)&
RowMajorBit)==RowMajorBit };
169 EIGEN_STRONG_INLINE InnerIterator(
const binary_evaluator& aEval, Index outer)
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())
175 EIGEN_STRONG_INLINE InnerIterator& operator++()
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));
194 EIGEN_STRONG_INLINE Scalar value()
const { eigen_internal_assert(m_id<m_innerSize);
return m_value; }
196 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_id; }
197 EIGEN_STRONG_INLINE
Index outer()
const {
return m_rhsIter.outer(); }
198 EIGEN_STRONG_INLINE
Index row()
const {
return IsRowMajor ? m_rhsIter.outer() : m_id; }
199 EIGEN_STRONG_INLINE
Index col()
const {
return IsRowMajor ? m_id : m_rhsIter.outer(); }
201 EIGEN_STRONG_INLINE
operator bool()
const {
return m_id<m_innerSize; }
204 const evaluator<Lhs> &m_lhsEval;
205 RhsIterator m_rhsIter;
206 const BinaryOp& m_functor;
209 StorageIndex m_innerSize;
214 CoeffReadCost = int(evaluator<Lhs>::CoeffReadCost) + int(evaluator<Rhs>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
215 Flags = XprType::Flags
218 explicit binary_evaluator(
const XprType& xpr)
219 : m_functor(xpr.functor()),
220 m_lhsImpl(xpr.lhs()),
221 m_rhsImpl(xpr.rhs()),
224 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
225 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
228 inline Index nonZerosEstimate()
const {
229 return m_expr.size();
233 const BinaryOp m_functor;
234 evaluator<Lhs> m_lhsImpl;
235 evaluator<Rhs> m_rhsImpl;
236 const XprType &m_expr;
240template<
typename BinaryOp,
typename Lhs,
typename Rhs>
241struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IteratorBased, IndexBased>
242 : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
245 typedef typename evaluator<Lhs>::InnerIterator LhsIterator;
246 typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
247 typedef typename traits<XprType>::Scalar Scalar;
248 typedef typename XprType::StorageIndex StorageIndex;
253 enum { IsRowMajor = (int(Lhs::Flags)&
RowMajorBit)==RowMajorBit };
256 EIGEN_STRONG_INLINE InnerIterator(
const binary_evaluator& aEval, Index outer)
257 : 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())
262 EIGEN_STRONG_INLINE InnerIterator& operator++()
267 Scalar rhsVal = m_rhsEval.coeff(IsRowMajor?m_lhsIter.outer():m_id,
268 IsRowMajor?m_id:m_lhsIter.outer());
269 if(m_lhsIter && m_lhsIter.index()==m_id)
271 m_value = m_functor(m_lhsIter.value(), rhsVal);
275 m_value = m_functor(Scalar(0),rhsVal);
281 EIGEN_STRONG_INLINE Scalar value()
const { eigen_internal_assert(m_id<m_innerSize);
return m_value; }
283 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_id; }
284 EIGEN_STRONG_INLINE
Index outer()
const {
return m_lhsIter.outer(); }
285 EIGEN_STRONG_INLINE
Index row()
const {
return IsRowMajor ? m_lhsIter.outer() : m_id; }
286 EIGEN_STRONG_INLINE
Index col()
const {
return IsRowMajor ? m_id : m_lhsIter.outer(); }
288 EIGEN_STRONG_INLINE
operator bool()
const {
return m_id<m_innerSize; }
291 LhsIterator m_lhsIter;
292 const evaluator<Rhs> &m_rhsEval;
293 const BinaryOp& m_functor;
296 StorageIndex m_innerSize;
301 CoeffReadCost = int(evaluator<Lhs>::CoeffReadCost) + int(evaluator<Rhs>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
302 Flags = XprType::Flags
305 explicit binary_evaluator(
const XprType& xpr)
306 : m_functor(xpr.functor()),
307 m_lhsImpl(xpr.lhs()),
308 m_rhsImpl(xpr.rhs()),
311 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
312 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
315 inline Index nonZerosEstimate()
const {
316 return m_expr.size();
320 const BinaryOp m_functor;
321 evaluator<Lhs> m_lhsImpl;
322 evaluator<Rhs> m_rhsImpl;
323 const XprType &m_expr;
327 typename LhsKind =
typename evaluator_traits<typename T::Lhs>::Kind,
328 typename RhsKind =
typename evaluator_traits<typename T::Rhs>::Kind,
329 typename LhsScalar =
typename traits<typename T::Lhs>::Scalar,
330 typename RhsScalar =
typename traits<typename T::Rhs>::Scalar>
struct sparse_conjunction_evaluator;
333template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
334struct binary_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs>, IteratorBased, IteratorBased>
335 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> >
337 typedef CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> XprType;
338 typedef sparse_conjunction_evaluator<XprType> Base;
339 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
342template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
343struct binary_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs>, IndexBased, IteratorBased>
344 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> >
346 typedef CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> XprType;
347 typedef sparse_conjunction_evaluator<XprType> Base;
348 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
351template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
352struct binary_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs>, IteratorBased, IndexBased>
353 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> >
355 typedef CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> XprType;
356 typedef sparse_conjunction_evaluator<XprType> Base;
357 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
361template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
362struct binary_evaluator<CwiseBinaryOp<scalar_quotient_op<T1,T2>, Lhs, Rhs>, IteratorBased, IndexBased>
363 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_quotient_op<T1,T2>, Lhs, Rhs> >
365 typedef CwiseBinaryOp<scalar_quotient_op<T1,T2>, Lhs, Rhs> XprType;
366 typedef sparse_conjunction_evaluator<XprType> Base;
367 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
371template<
typename Lhs,
typename Rhs>
372struct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IteratorBased, IteratorBased>
373 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >
375 typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;
376 typedef sparse_conjunction_evaluator<XprType> Base;
377 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
380template<
typename Lhs,
typename Rhs>
381struct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IndexBased, IteratorBased>
382 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >
384 typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;
385 typedef sparse_conjunction_evaluator<XprType> Base;
386 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
389template<
typename Lhs,
typename Rhs>
390struct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IteratorBased, IndexBased>
391 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >
393 typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;
394 typedef sparse_conjunction_evaluator<XprType> Base;
395 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
399template<
typename XprType>
400struct sparse_conjunction_evaluator<XprType, IteratorBased, IteratorBased>
401 : evaluator_base<XprType>
404 typedef typename XprType::Functor BinaryOp;
405 typedef typename XprType::Lhs LhsArg;
406 typedef typename XprType::Rhs RhsArg;
407 typedef typename evaluator<LhsArg>::InnerIterator LhsIterator;
408 typedef typename evaluator<RhsArg>::InnerIterator RhsIterator;
409 typedef typename XprType::StorageIndex StorageIndex;
410 typedef typename traits<XprType>::Scalar Scalar;
417 EIGEN_STRONG_INLINE InnerIterator(
const sparse_conjunction_evaluator& aEval, Index outer)
418 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor)
420 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
422 if (m_lhsIter.index() < m_rhsIter.index())
429 EIGEN_STRONG_INLINE InnerIterator& operator++()
433 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
435 if (m_lhsIter.index() < m_rhsIter.index())
443 EIGEN_STRONG_INLINE Scalar value()
const {
return m_functor(m_lhsIter.value(), m_rhsIter.value()); }
445 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_lhsIter.index(); }
446 EIGEN_STRONG_INLINE
Index outer()
const {
return m_lhsIter.outer(); }
447 EIGEN_STRONG_INLINE
Index row()
const {
return m_lhsIter.row(); }
448 EIGEN_STRONG_INLINE
Index col()
const {
return m_lhsIter.col(); }
450 EIGEN_STRONG_INLINE
operator bool()
const {
return (m_lhsIter && m_rhsIter); }
453 LhsIterator m_lhsIter;
454 RhsIterator m_rhsIter;
455 const BinaryOp& m_functor;
460 CoeffReadCost = int(evaluator<LhsArg>::CoeffReadCost) + int(evaluator<RhsArg>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
461 Flags = XprType::Flags
464 explicit sparse_conjunction_evaluator(
const XprType& xpr)
465 : m_functor(xpr.functor()),
466 m_lhsImpl(xpr.lhs()),
469 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
470 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
473 inline Index nonZerosEstimate()
const {
474 return (std::min)(m_lhsImpl.nonZerosEstimate(), m_rhsImpl.nonZerosEstimate());
478 const BinaryOp m_functor;
479 evaluator<LhsArg> m_lhsImpl;
480 evaluator<RhsArg> m_rhsImpl;
484template<
typename XprType>
485struct sparse_conjunction_evaluator<XprType, IndexBased, IteratorBased>
486 : evaluator_base<XprType>
489 typedef typename XprType::Functor BinaryOp;
490 typedef typename XprType::Lhs LhsArg;
491 typedef typename XprType::Rhs RhsArg;
492 typedef evaluator<LhsArg> LhsEvaluator;
493 typedef typename evaluator<RhsArg>::InnerIterator RhsIterator;
494 typedef typename XprType::StorageIndex StorageIndex;
495 typedef typename traits<XprType>::Scalar Scalar;
500 enum { IsRowMajor = (int(RhsArg::Flags)&
RowMajorBit)==RowMajorBit };
504 EIGEN_STRONG_INLINE InnerIterator(
const sparse_conjunction_evaluator& aEval, Index outer)
505 : m_lhsEval(aEval.m_lhsImpl), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor), m_outer(outer)
508 EIGEN_STRONG_INLINE InnerIterator& operator++()
514 EIGEN_STRONG_INLINE Scalar value()
const
515 {
return m_functor(m_lhsEval.coeff(IsRowMajor?m_outer:m_rhsIter.index(),IsRowMajor?m_rhsIter.index():m_outer), m_rhsIter.value()); }
517 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_rhsIter.index(); }
518 EIGEN_STRONG_INLINE
Index outer()
const {
return m_rhsIter.outer(); }
519 EIGEN_STRONG_INLINE
Index row()
const {
return m_rhsIter.row(); }
520 EIGEN_STRONG_INLINE
Index col()
const {
return m_rhsIter.col(); }
522 EIGEN_STRONG_INLINE
operator bool()
const {
return m_rhsIter; }
525 const LhsEvaluator &m_lhsEval;
526 RhsIterator m_rhsIter;
527 const BinaryOp& m_functor;
533 CoeffReadCost = int(evaluator<LhsArg>::CoeffReadCost) + int(evaluator<RhsArg>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
534 Flags = XprType::Flags
537 explicit sparse_conjunction_evaluator(
const XprType& xpr)
538 : m_functor(xpr.functor()),
539 m_lhsImpl(xpr.lhs()),
542 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
543 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
546 inline Index nonZerosEstimate()
const {
547 return m_rhsImpl.nonZerosEstimate();
551 const BinaryOp m_functor;
552 evaluator<LhsArg> m_lhsImpl;
553 evaluator<RhsArg> m_rhsImpl;
557template<
typename XprType>
558struct sparse_conjunction_evaluator<XprType, IteratorBased, IndexBased>
559 : evaluator_base<XprType>
562 typedef typename XprType::Functor BinaryOp;
563 typedef typename XprType::Lhs LhsArg;
564 typedef typename XprType::Rhs RhsArg;
565 typedef typename evaluator<LhsArg>::InnerIterator LhsIterator;
566 typedef evaluator<RhsArg> RhsEvaluator;
567 typedef typename XprType::StorageIndex StorageIndex;
568 typedef typename traits<XprType>::Scalar Scalar;
573 enum { IsRowMajor = (int(LhsArg::Flags)&
RowMajorBit)==RowMajorBit };
577 EIGEN_STRONG_INLINE InnerIterator(
const sparse_conjunction_evaluator& aEval, Index outer)
578 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsEval(aEval.m_rhsImpl), m_functor(aEval.m_functor), m_outer(outer)
581 EIGEN_STRONG_INLINE InnerIterator& operator++()
587 EIGEN_STRONG_INLINE Scalar value()
const
588 {
return m_functor(m_lhsIter.value(),
589 m_rhsEval.coeff(IsRowMajor?m_outer:m_lhsIter.index(),IsRowMajor?m_lhsIter.index():m_outer)); }
591 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_lhsIter.index(); }
592 EIGEN_STRONG_INLINE
Index outer()
const {
return m_lhsIter.outer(); }
593 EIGEN_STRONG_INLINE
Index row()
const {
return m_lhsIter.row(); }
594 EIGEN_STRONG_INLINE
Index col()
const {
return m_lhsIter.col(); }
596 EIGEN_STRONG_INLINE
operator bool()
const {
return m_lhsIter; }
599 LhsIterator m_lhsIter;
600 const evaluator<RhsArg> &m_rhsEval;
601 const BinaryOp& m_functor;
607 CoeffReadCost = int(evaluator<LhsArg>::CoeffReadCost) + int(evaluator<RhsArg>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
608 Flags = XprType::Flags
611 explicit sparse_conjunction_evaluator(
const XprType& xpr)
612 : m_functor(xpr.functor()),
613 m_lhsImpl(xpr.lhs()),
616 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
617 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
620 inline Index nonZerosEstimate()
const {
621 return m_lhsImpl.nonZerosEstimate();
625 const BinaryOp m_functor;
626 evaluator<LhsArg> m_lhsImpl;
627 evaluator<RhsArg> m_rhsImpl;
636template<
typename Derived>
637template<
typename OtherDerived>
638Derived& SparseMatrixBase<Derived>::operator+=(
const EigenBase<OtherDerived> &other)
640 call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
644template<
typename Derived>
645template<
typename OtherDerived>
646Derived& SparseMatrixBase<Derived>::operator-=(
const EigenBase<OtherDerived> &other)
648 call_assignment(derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
652template<
typename Derived>
653template<
typename OtherDerived>
654EIGEN_STRONG_INLINE Derived &
655SparseMatrixBase<Derived>::operator-=(
const SparseMatrixBase<OtherDerived> &other)
657 return derived() = derived() - other.derived();
660template<
typename Derived>
661template<
typename OtherDerived>
662EIGEN_STRONG_INLINE Derived &
663SparseMatrixBase<Derived>::operator+=(
const SparseMatrixBase<OtherDerived>& other)
665 return derived() = derived() + other.derived();
668template<
typename Derived>
669template<
typename OtherDerived>
670Derived& SparseMatrixBase<Derived>::operator+=(
const DiagonalBase<OtherDerived>& other)
672 call_assignment_no_alias(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
676template<
typename Derived>
677template<
typename OtherDerived>
678Derived& SparseMatrixBase<Derived>::operator-=(
const DiagonalBase<OtherDerived>& other)
680 call_assignment_no_alias(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
684template<
typename Derived>
685template<
typename OtherDerived>
686EIGEN_STRONG_INLINE
const typename SparseMatrixBase<Derived>::template CwiseProductDenseReturnType<OtherDerived>::Type
687SparseMatrixBase<Derived>::cwiseProduct(
const MatrixBase<OtherDerived> &other)
const
689 return typename CwiseProductDenseReturnType<OtherDerived>::Type(derived(), other.derived());
692template<
typename DenseDerived,
typename SparseDerived>
693EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_sum_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>
694operator+(
const MatrixBase<DenseDerived> &a,
const SparseMatrixBase<SparseDerived> &b)
696 return CwiseBinaryOp<internal::scalar_sum_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>(a.derived(), b.derived());
699template<
typename SparseDerived,
typename DenseDerived>
700EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_sum_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>
701operator+(
const SparseMatrixBase<SparseDerived> &a,
const MatrixBase<DenseDerived> &b)
703 return CwiseBinaryOp<internal::scalar_sum_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>(a.derived(), b.derived());
706template<
typename DenseDerived,
typename SparseDerived>
707EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_difference_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>
708operator-(
const MatrixBase<DenseDerived> &a,
const SparseMatrixBase<SparseDerived> &b)
710 return CwiseBinaryOp<internal::scalar_difference_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>(a.derived(), b.derived());
713template<
typename SparseDerived,
typename DenseDerived>
714EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_difference_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>
715operator-(
const SparseMatrixBase<SparseDerived> &a,
const MatrixBase<DenseDerived> &b)
717 return CwiseBinaryOp<internal::scalar_difference_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>(a.derived(), b.derived());
const unsigned int RowMajorBit
Definition: Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74