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 Lhs,
typename Rhs>
364 struct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IteratorBased, IteratorBased>
365 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >
367 typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;
368 typedef sparse_conjunction_evaluator<XprType> Base;
369 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
372 template<
typename Lhs,
typename Rhs>
373 struct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IndexBased, IteratorBased>
374 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >
376 typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;
377 typedef sparse_conjunction_evaluator<XprType> Base;
378 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
381 template<
typename Lhs,
typename Rhs>
382 struct binary_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs>, IteratorBased, IndexBased>
383 : sparse_conjunction_evaluator<CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> >
385 typedef CwiseBinaryOp<scalar_boolean_and_op, Lhs, Rhs> XprType;
386 typedef sparse_conjunction_evaluator<XprType> Base;
387 explicit binary_evaluator(
const XprType& xpr) : Base(xpr) {}
391 template<
typename XprType>
392 struct sparse_conjunction_evaluator<XprType, IteratorBased, IteratorBased>
393 : evaluator_base<XprType>
396 typedef typename XprType::Functor BinaryOp;
397 typedef typename XprType::Lhs LhsArg;
398 typedef typename XprType::Rhs RhsArg;
399 typedef typename evaluator<LhsArg>::InnerIterator LhsIterator;
400 typedef typename evaluator<RhsArg>::InnerIterator RhsIterator;
401 typedef typename XprType::StorageIndex StorageIndex;
402 typedef typename traits<XprType>::Scalar Scalar;
409 EIGEN_STRONG_INLINE InnerIterator(
const sparse_conjunction_evaluator& aEval,
Index outer)
410 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor)
412 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
414 if (m_lhsIter.index() < m_rhsIter.index())
421 EIGEN_STRONG_INLINE InnerIterator& operator++()
425 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
427 if (m_lhsIter.index() < m_rhsIter.index())
435 EIGEN_STRONG_INLINE Scalar value()
const {
return m_functor(m_lhsIter.value(), m_rhsIter.value()); }
437 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_lhsIter.index(); }
438 EIGEN_STRONG_INLINE
Index outer()
const {
return m_lhsIter.outer(); }
439 EIGEN_STRONG_INLINE
Index row()
const {
return m_lhsIter.row(); }
440 EIGEN_STRONG_INLINE
Index col()
const {
return m_lhsIter.col(); }
442 EIGEN_STRONG_INLINE
operator bool()
const {
return (m_lhsIter && m_rhsIter); }
445 LhsIterator m_lhsIter;
446 RhsIterator m_rhsIter;
447 const BinaryOp& m_functor;
452 CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
453 Flags = XprType::Flags
456 explicit sparse_conjunction_evaluator(
const XprType& xpr)
457 : m_functor(xpr.functor()),
458 m_lhsImpl(xpr.lhs()),
461 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
462 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
465 inline Index nonZerosEstimate()
const {
466 return (std::min)(m_lhsImpl.nonZerosEstimate(), m_rhsImpl.nonZerosEstimate());
470 const BinaryOp m_functor;
471 evaluator<LhsArg> m_lhsImpl;
472 evaluator<RhsArg> m_rhsImpl;
476 template<
typename XprType>
477 struct sparse_conjunction_evaluator<XprType, IndexBased, IteratorBased>
478 : evaluator_base<XprType>
481 typedef typename XprType::Functor BinaryOp;
482 typedef typename XprType::Lhs LhsArg;
483 typedef typename XprType::Rhs RhsArg;
484 typedef evaluator<LhsArg> LhsEvaluator;
485 typedef typename evaluator<RhsArg>::InnerIterator RhsIterator;
486 typedef typename XprType::StorageIndex StorageIndex;
487 typedef typename traits<XprType>::Scalar Scalar;
496 EIGEN_STRONG_INLINE InnerIterator(
const sparse_conjunction_evaluator& aEval,
Index outer)
497 : m_lhsEval(aEval.m_lhsImpl), m_rhsIter(aEval.m_rhsImpl,outer), m_functor(aEval.m_functor), m_outer(outer)
500 EIGEN_STRONG_INLINE InnerIterator& operator++()
506 EIGEN_STRONG_INLINE Scalar value()
const 507 {
return m_functor(m_lhsEval.coeff(IsRowMajor?m_outer:m_rhsIter.index(),IsRowMajor?m_rhsIter.index():m_outer), m_rhsIter.value()); }
509 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_rhsIter.index(); }
510 EIGEN_STRONG_INLINE
Index outer()
const {
return m_rhsIter.outer(); }
511 EIGEN_STRONG_INLINE
Index row()
const {
return m_rhsIter.row(); }
512 EIGEN_STRONG_INLINE
Index col()
const {
return m_rhsIter.col(); }
514 EIGEN_STRONG_INLINE
operator bool()
const {
return m_rhsIter; }
517 const LhsEvaluator &m_lhsEval;
518 RhsIterator m_rhsIter;
519 const BinaryOp& m_functor;
525 CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
530 explicit sparse_conjunction_evaluator(
const XprType& xpr)
531 : m_functor(xpr.functor()),
532 m_lhsImpl(xpr.lhs()),
535 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
536 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
539 inline Index nonZerosEstimate()
const {
540 return m_rhsImpl.nonZerosEstimate();
544 const BinaryOp m_functor;
545 evaluator<LhsArg> m_lhsImpl;
546 evaluator<RhsArg> m_rhsImpl;
550 template<
typename XprType>
551 struct sparse_conjunction_evaluator<XprType, IteratorBased, IndexBased>
552 : evaluator_base<XprType>
555 typedef typename XprType::Functor BinaryOp;
556 typedef typename XprType::Lhs LhsArg;
557 typedef typename XprType::Rhs RhsArg;
558 typedef typename evaluator<LhsArg>::InnerIterator LhsIterator;
559 typedef evaluator<RhsArg> RhsEvaluator;
560 typedef typename XprType::StorageIndex StorageIndex;
561 typedef typename traits<XprType>::Scalar Scalar;
570 EIGEN_STRONG_INLINE InnerIterator(
const sparse_conjunction_evaluator& aEval,
Index outer)
571 : m_lhsIter(aEval.m_lhsImpl,outer), m_rhsEval(aEval.m_rhsImpl), m_functor(aEval.m_functor), m_outer(outer)
574 EIGEN_STRONG_INLINE InnerIterator& operator++()
580 EIGEN_STRONG_INLINE Scalar value()
const 581 {
return m_functor(m_lhsIter.value(),
582 m_rhsEval.coeff(IsRowMajor?m_outer:m_lhsIter.index(),IsRowMajor?m_lhsIter.index():m_outer)); }
584 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_lhsIter.index(); }
585 EIGEN_STRONG_INLINE
Index outer()
const {
return m_lhsIter.outer(); }
586 EIGEN_STRONG_INLINE
Index row()
const {
return m_lhsIter.row(); }
587 EIGEN_STRONG_INLINE
Index col()
const {
return m_lhsIter.col(); }
589 EIGEN_STRONG_INLINE
operator bool()
const {
return m_lhsIter; }
592 LhsIterator m_lhsIter;
593 const evaluator<RhsArg> &m_rhsEval;
594 const BinaryOp& m_functor;
600 CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
605 explicit sparse_conjunction_evaluator(
const XprType& xpr)
606 : m_functor(xpr.functor()),
607 m_lhsImpl(xpr.lhs()),
610 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
611 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
614 inline Index nonZerosEstimate()
const {
615 return m_lhsImpl.nonZerosEstimate();
619 const BinaryOp m_functor;
620 evaluator<LhsArg> m_lhsImpl;
621 evaluator<RhsArg> m_rhsImpl;
630 template<
typename Derived>
631 template<
typename OtherDerived>
632 Derived& SparseMatrixBase<Derived>::operator+=(
const EigenBase<OtherDerived> &other)
634 call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
638 template<
typename Derived>
639 template<
typename OtherDerived>
640 Derived& SparseMatrixBase<Derived>::operator-=(
const EigenBase<OtherDerived> &other)
642 call_assignment(derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
646 template<
typename Derived>
647 template<
typename OtherDerived>
648 EIGEN_STRONG_INLINE Derived &
649 SparseMatrixBase<Derived>::operator-=(
const SparseMatrixBase<OtherDerived> &other)
651 return derived() = derived() - other.derived();
654 template<
typename Derived>
655 template<
typename OtherDerived>
656 EIGEN_STRONG_INLINE Derived &
657 SparseMatrixBase<Derived>::operator+=(
const SparseMatrixBase<OtherDerived>& other)
659 return derived() = derived() + other.derived();
662 template<
typename Derived>
663 template<
typename OtherDerived>
664 Derived& SparseMatrixBase<Derived>::operator+=(
const DiagonalBase<OtherDerived>& other)
666 call_assignment_no_alias(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
670 template<
typename Derived>
671 template<
typename OtherDerived>
672 Derived& SparseMatrixBase<Derived>::operator-=(
const DiagonalBase<OtherDerived>& other)
674 call_assignment_no_alias(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
678 template<
typename Derived>
679 template<
typename OtherDerived>
680 EIGEN_STRONG_INLINE
const typename SparseMatrixBase<Derived>::template CwiseProductDenseReturnType<OtherDerived>::Type
683 return typename CwiseProductDenseReturnType<OtherDerived>::Type(derived(), other.derived());
686 template<
typename DenseDerived,
typename SparseDerived>
687 EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_sum_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>
688 operator+(
const MatrixBase<DenseDerived> &a,
const SparseMatrixBase<SparseDerived> &b)
690 return CwiseBinaryOp<internal::scalar_sum_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>(a.derived(), b.derived());
693 template<
typename SparseDerived,
typename DenseDerived>
694 EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_sum_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>
695 operator+(
const SparseMatrixBase<SparseDerived> &a,
const MatrixBase<DenseDerived> &b)
697 return CwiseBinaryOp<internal::scalar_sum_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>(a.derived(), b.derived());
700 template<
typename DenseDerived,
typename SparseDerived>
701 EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_difference_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>
702 operator-(
const MatrixBase<DenseDerived> &a,
const SparseMatrixBase<SparseDerived> &b)
704 return CwiseBinaryOp<internal::scalar_difference_op<typename DenseDerived::Scalar,typename SparseDerived::Scalar>,
const DenseDerived,
const SparseDerived>(a.derived(), b.derived());
707 template<
typename SparseDerived,
typename DenseDerived>
708 EIGEN_STRONG_INLINE
const CwiseBinaryOp<internal::scalar_difference_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>
709 operator-(
const SparseMatrixBase<SparseDerived> &a,
const MatrixBase<DenseDerived> &b)
711 return CwiseBinaryOp<internal::scalar_difference_op<typename SparseDerived::Scalar,typename DenseDerived::Scalar>,
const SparseDerived,
const DenseDerived>(a.derived(), b.derived());
716 #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