10 #ifndef EIGEN_SPARSE_CWISE_BINARY_OP_H 11 #define EIGEN_SPARSE_CWISE_BINARY_OP_H 35 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
36 class 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)
48 || ((internal::evaluator<Lhs>::Flags&
RowMajorBit) == (internal::evaluator<Rhs>::Flags&RowMajorBit))),
49 THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH);
57 template<
typename XprType>
struct binary_sparse_evaluator;
59 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
60 struct 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 = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + 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;
153 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
154 struct 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;
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 = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
219 explicit binary_evaluator(
const XprType& xpr)
220 : m_functor(xpr.functor()),
221 m_lhsImpl(xpr.lhs()),
222 m_rhsImpl(xpr.rhs()),
225 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
226 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
229 inline Index nonZerosEstimate()
const {
230 return m_expr.size();
234 const BinaryOp m_functor;
235 evaluator<Lhs> m_lhsImpl;
236 evaluator<Rhs> m_rhsImpl;
237 const XprType &m_expr;
241 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
242 struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IteratorBased, IndexBased>
243 : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
246 typedef typename evaluator<Lhs>::InnerIterator LhsIterator;
247 typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
248 typedef typename traits<XprType>::Scalar Scalar;
249 typedef typename XprType::StorageIndex StorageIndex;
257 EIGEN_STRONG_INLINE InnerIterator(
const binary_evaluator& aEval,
Index outer)
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())
263 EIGEN_STRONG_INLINE InnerIterator& operator++()
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);
282 EIGEN_STRONG_INLINE Scalar value()
const { eigen_internal_assert(m_id<m_innerSize);
return m_value; }
284 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_id; }
285 EIGEN_STRONG_INLINE
Index outer()
const {
return m_lhsIter.outer(); }
286 EIGEN_STRONG_INLINE
Index row()
const {
return IsRowMajor ? m_lhsIter.outer() : m_id; }
287 EIGEN_STRONG_INLINE
Index col()
const {
return IsRowMajor ? m_id : m_lhsIter.outer(); }
289 EIGEN_STRONG_INLINE
operator bool()
const {
return m_id<m_innerSize; }
292 LhsIterator m_lhsIter;
293 const evaluator<Rhs> &m_rhsEval;
294 const BinaryOp& m_functor;
297 StorageIndex m_innerSize;
302 CoeffReadCost = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
307 explicit binary_evaluator(
const XprType& xpr)
308 : m_functor(xpr.functor()),
309 m_lhsImpl(xpr.lhs()),
310 m_rhsImpl(xpr.rhs()),
313 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
314 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
317 inline Index nonZerosEstimate()
const {
318 return m_expr.size();
322 const BinaryOp m_functor;
323 evaluator<Lhs> m_lhsImpl;
324 evaluator<Rhs> m_rhsImpl;
325 const XprType &m_expr;
329 typename LhsKind =
typename evaluator_traits<typename T::Lhs>::Kind,
330 typename RhsKind =
typename evaluator_traits<typename T::Rhs>::Kind,
331 typename LhsScalar =
typename traits<typename T::Lhs>::Scalar,
332 typename RhsScalar =
typename traits<typename T::Rhs>::Scalar>
struct sparse_conjunction_evaluator;
335 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
336 struct binary_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs>, IteratorBased, IteratorBased>
337 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> >
339 typedef CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> XprType;
340 typedef sparse_conjunction_evaluator<XprType> Base;
341 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
344 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
345 struct binary_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs>, IndexBased, IteratorBased>
346 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> >
348 typedef CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> XprType;
349 typedef sparse_conjunction_evaluator<XprType> Base;
350 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
353 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
354 struct binary_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs>, IteratorBased, IndexBased>
355 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> >
357 typedef CwiseBinaryOp<scalar_product_op<T1,T2>, Lhs, Rhs> XprType;
358 typedef sparse_conjunction_evaluator<XprType> Base;
359 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
363 template<
typename T1,
typename T2,
typename Lhs,
typename Rhs>
364 struct binary_evaluator<CwiseBinaryOp<scalar_quotient_op<T1,T2>, Lhs, Rhs>, IteratorBased, IndexBased>
365 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_quotient_op<T1,T2>, Lhs, Rhs> >
367 typedef CwiseBinaryOp<scalar_quotient_op<T1,T2>, Lhs, Rhs> XprType;
368 typedef sparse_conjunction_evaluator<XprType> Base;
369 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
373 template<
typename Lhs,
typename Rhs>
374 struct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IteratorBased, IteratorBased>
375 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >
377 typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;
378 typedef sparse_conjunction_evaluator<XprType> Base;
379 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
382 template<
typename Lhs,
typename Rhs>
383 struct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IndexBased, IteratorBased>
384 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >
386 typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;
387 typedef sparse_conjunction_evaluator<XprType> Base;
388 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
391 template<
typename Lhs,
typename Rhs>
392 struct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IteratorBased, IndexBased>
393 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >
395 typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;
396 typedef sparse_conjunction_evaluator<XprType> Base;
397 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
401 template<
typename XprType>
402 struct sparse_conjunction_evaluator<XprType, IteratorBased, IteratorBased>
403 : evaluator_base<XprType>
406 typedef typename XprType::Functor BinaryOp;
407 typedef typename XprType::Lhs LhsArg;
408 typedef typename XprType::Rhs RhsArg;
409 typedef typename evaluator<LhsArg>::InnerIterator LhsIterator;
410 typedef typename evaluator<RhsArg>::InnerIterator RhsIterator;
411 typedef typename XprType::StorageIndex StorageIndex;
412 typedef typename traits<XprType>::Scalar Scalar;
419 EIGEN_STRONG_INLINE InnerIterator(
const sparse_conjunction_evaluator& aEval,
Index outer)
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())
431 EIGEN_STRONG_INLINE InnerIterator& operator++()
435 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
437 if (m_lhsIter.index() < m_rhsIter.index())
445 EIGEN_STRONG_INLINE Scalar value()
const {
return m_functor(m_lhsIter.value(), m_rhsIter.value()); }
447 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_lhsIter.index(); }
448 EIGEN_STRONG_INLINE
Index outer()
const {
return m_lhsIter.outer(); }
449 EIGEN_STRONG_INLINE
Index row()
const {
return m_lhsIter.row(); }
450 EIGEN_STRONG_INLINE
Index col()
const {
return m_lhsIter.col(); }
452 EIGEN_STRONG_INLINE
operator bool()
const {
return (m_lhsIter && m_rhsIter); }
455 LhsIterator m_lhsIter;
456 RhsIterator m_rhsIter;
457 const BinaryOp& m_functor;
462 CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
463 Flags = XprType::Flags
466 explicit sparse_conjunction_evaluator(
const XprType& xpr)
467 : m_functor(xpr.functor()),
468 m_lhsImpl(xpr.lhs()),
471 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
472 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
475 inline Index nonZerosEstimate()
const {
476 return (std::min)(m_lhsImpl.nonZerosEstimate(), m_rhsImpl.nonZerosEstimate());
480 const BinaryOp m_functor;
481 evaluator<LhsArg> m_lhsImpl;
482 evaluator<RhsArg> m_rhsImpl;
486 template<
typename XprType>
487 struct sparse_conjunction_evaluator<XprType, IndexBased, IteratorBased>
488 : evaluator_base<XprType>
491 typedef typename XprType::Functor BinaryOp;
492 typedef typename XprType::Lhs LhsArg;
493 typedef typename XprType::Rhs RhsArg;
494 typedef evaluator<LhsArg> LhsEvaluator;
495 typedef typename evaluator<RhsArg>::InnerIterator RhsIterator;
496 typedef typename XprType::StorageIndex StorageIndex;
497 typedef typename traits<XprType>::Scalar Scalar;
506 EIGEN_STRONG_INLINE InnerIterator(
const sparse_conjunction_evaluator& aEval,
Index outer)
507 : m_lhsEval(aEval.m_lhsImpl), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor), m_outer(outer)
510 EIGEN_STRONG_INLINE InnerIterator& operator++()
516 EIGEN_STRONG_INLINE Scalar value()
const 517 {
return m_functor(m_lhsEval.coeff(IsRowMajor?m_outer:m_rhsIter.index(),IsRowMajor?m_rhsIter.index():m_outer), m_rhsIter.value()); }
519 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_rhsIter.index(); }
520 EIGEN_STRONG_INLINE
Index outer()
const {
return m_rhsIter.outer(); }
521 EIGEN_STRONG_INLINE
Index row()
const {
return m_rhsIter.row(); }
522 EIGEN_STRONG_INLINE
Index col()
const {
return m_rhsIter.col(); }
524 EIGEN_STRONG_INLINE
operator bool()
const {
return m_rhsIter; }
527 const LhsEvaluator &m_lhsEval;
528 RhsIterator m_rhsIter;
529 const BinaryOp& m_functor;
535 CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
540 explicit sparse_conjunction_evaluator(
const XprType& xpr)
541 : m_functor(xpr.functor()),
542 m_lhsImpl(xpr.lhs()),
545 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
546 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
549 inline Index nonZerosEstimate()
const {
550 return m_rhsImpl.nonZerosEstimate();
554 const BinaryOp m_functor;
555 evaluator<LhsArg> m_lhsImpl;
556 evaluator<RhsArg> m_rhsImpl;
560 template<
typename XprType>
561 struct sparse_conjunction_evaluator<XprType, IteratorBased, IndexBased>
562 : evaluator_base<XprType>
565 typedef typename XprType::Functor BinaryOp;
566 typedef typename XprType::Lhs LhsArg;
567 typedef typename XprType::Rhs RhsArg;
568 typedef typename evaluator<LhsArg>::InnerIterator LhsIterator;
569 typedef evaluator<RhsArg> RhsEvaluator;
570 typedef typename XprType::StorageIndex StorageIndex;
571 typedef typename traits<XprType>::Scalar Scalar;
580 EIGEN_STRONG_INLINE InnerIterator(
const sparse_conjunction_evaluator& aEval,
Index outer)
581 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsEval(aEval.m_rhsImpl), m_functor(aEval.m_functor), m_outer(outer)
584 EIGEN_STRONG_INLINE InnerIterator& operator++()
590 EIGEN_STRONG_INLINE Scalar value()
const 591 {
return m_functor(m_lhsIter.value(),
592 m_rhsEval.coeff(IsRowMajor?m_outer:m_lhsIter.index(),IsRowMajor?m_lhsIter.index():m_outer)); }
594 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_lhsIter.index(); }
595 EIGEN_STRONG_INLINE
Index outer()
const {
return m_lhsIter.outer(); }
596 EIGEN_STRONG_INLINE
Index row()
const {
return m_lhsIter.row(); }
597 EIGEN_STRONG_INLINE
Index col()
const {
return m_lhsIter.col(); }
599 EIGEN_STRONG_INLINE
operator bool()
const {
return m_lhsIter; }
602 LhsIterator m_lhsIter;
603 const evaluator<RhsArg> &m_rhsEval;
604 const BinaryOp& m_functor;
610 CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
615 explicit sparse_conjunction_evaluator(
const XprType& xpr)
616 : m_functor(xpr.functor()),
617 m_lhsImpl(xpr.lhs()),
620 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
621 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
624 inline Index nonZerosEstimate()
const {
625 return m_lhsImpl.nonZerosEstimate();
629 const BinaryOp m_functor;
630 evaluator<LhsArg> m_lhsImpl;
631 evaluator<RhsArg> m_rhsImpl;
640 template<
typename Derived>
641 template<
typename OtherDerived>
642 Derived& SparseMatrixBase<Derived>::operator+=(
const EigenBase<OtherDerived> &other)
644 call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
648 template<
typename Derived>
649 template<
typename OtherDerived>
650 Derived& SparseMatrixBase<Derived>::operator-=(
const EigenBase<OtherDerived> &other)
652 call_assignment(derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
656 template<
typename Derived>
657 template<
typename OtherDerived>
658 EIGEN_STRONG_INLINE Derived &
659 SparseMatrixBase<Derived>::operator-=(
const SparseMatrixBase<OtherDerived> &other)
661 return derived() = derived() - other.derived();
664 template<
typename Derived>
665 template<
typename OtherDerived>
666 EIGEN_STRONG_INLINE Derived &
667 SparseMatrixBase<Derived>::operator+=(
const SparseMatrixBase<OtherDerived>& other)
669 return derived() = derived() + other.derived();
672 template<
typename Derived>
673 template<
typename OtherDerived>
674 Derived& SparseMatrixBase<Derived>::operator+=(
const DiagonalBase<OtherDerived>& other)
676 call_assignment_no_alias(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
680 template<
typename Derived>
681 template<
typename OtherDerived>
682 Derived& SparseMatrixBase<Derived>::operator-=(
const DiagonalBase<OtherDerived>& other)
684 call_assignment_no_alias(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
688 template<
typename Derived>
689 template<
typename OtherDerived>
690 EIGEN_STRONG_INLINE
const typename SparseMatrixBase<Derived>::template CwiseProductDenseReturnType<OtherDerived>::Type
693 return typename CwiseProductDenseReturnType<OtherDerived>::Type(derived(), other.derived());
696 template<
typename DenseDerived,
typename SparseDerived>
697 EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_sum_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>
698 operator+(
const MatrixBase<DenseDerived> &a,
const SparseMatrixBase<SparseDerived> &b)
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>
704 EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_sum_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>
705 operator+(
const SparseMatrixBase<SparseDerived> &a,
const MatrixBase<DenseDerived> &b)
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>
711 EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_difference_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>
712 operator-(
const MatrixBase<DenseDerived> &a,
const SparseMatrixBase<SparseDerived> &b)
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>
718 EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_difference_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>
719 operator-(
const SparseMatrixBase<SparseDerived> &a,
const MatrixBase<DenseDerived> &b)
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 const CwiseBinaryOp< internal::scalar_product_op< Derived ::Scalar, OtherDerived ::Scalar >, const Derived, const OtherDerived > cwiseProduct(const Eigen::SparseMatrixBase< OtherDerived > &other) const
Definition: SparseMatrixBase.h:24
Namespace containing all symbols from the Eigen library.
Definition: Core:287
const unsigned int RowMajorBit
Definition: Constants.h:61
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: Eigen_Colamd.h:50