10 #ifndef EIGEN_SPARSE_CWISE_BINARY_OP_H 11 #define EIGEN_SPARSE_CWISE_BINARY_OP_H 35 {
typedef Sparse ret; };
38 {
typedef Sparse ret; };
40 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename Derived,
47 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
53 class ReverseInnerIterator;
55 EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
61 || ((Lhs::Flags&
RowMajorBit) == (Rhs::Flags&RowMajorBit))),
62 THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH);
66 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
71 typedef typename Lhs::Index Index;
77 : Base(binOp.derived(),outer)
93 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename Derived>
100 typedef typename _LhsNested::InnerIterator LhsIterator;
101 typedef typename _RhsNested::InnerIterator RhsIterator;
102 typedef typename Lhs::Index Index;
107 : m_lhsIter(xpr.
lhs(),outer), m_rhsIter(xpr.
rhs(),outer), m_functor(xpr.
functor())
112 EIGEN_STRONG_INLINE Derived& operator++()
114 if (m_lhsIter && m_rhsIter && (m_lhsIter.index() == m_rhsIter.index()))
116 m_id = m_lhsIter.index();
117 m_value = m_functor(m_lhsIter.value(), m_rhsIter.value());
121 else if (m_lhsIter && (!m_rhsIter || (m_lhsIter.index() < m_rhsIter.index())))
123 m_id = m_lhsIter.index();
124 m_value = m_functor(m_lhsIter.value(),
Scalar(0));
127 else if (m_rhsIter && (!m_lhsIter || (m_lhsIter.index() > m_rhsIter.index())))
129 m_id = m_rhsIter.index();
130 m_value = m_functor(
Scalar(0), m_rhsIter.value());
138 return *
static_cast<Derived*
>(
this);
141 EIGEN_STRONG_INLINE Scalar value()
const {
return m_value; }
143 EIGEN_STRONG_INLINE Index index()
const {
return m_id; }
144 EIGEN_STRONG_INLINE Index row()
const {
return Lhs::IsRowMajor ? m_lhsIter.row() : index(); }
145 EIGEN_STRONG_INLINE Index col()
const {
return Lhs::IsRowMajor ? index() : m_lhsIter.col(); }
147 EIGEN_STRONG_INLINE
operator bool()
const {
return m_id>=0; }
150 LhsIterator m_lhsIter;
151 RhsIterator m_rhsIter;
152 const BinaryOp& m_functor;
158 template<
typename T,
typename Lhs,
typename Rhs,
typename Derived>
165 typedef typename _LhsNested::InnerIterator LhsIterator;
167 typedef typename _RhsNested::InnerIterator RhsIterator;
168 typedef typename Lhs::Index Index;
172 : m_lhsIter(xpr.
lhs(),outer), m_rhsIter(xpr.
rhs(),outer), m_functor(xpr.
functor())
174 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
176 if (m_lhsIter.index() < m_rhsIter.index())
183 EIGEN_STRONG_INLINE Derived& operator++()
187 while (m_lhsIter && m_rhsIter && (m_lhsIter.index() != m_rhsIter.index()))
189 if (m_lhsIter.index() < m_rhsIter.index())
194 return *
static_cast<Derived*
>(
this);
197 EIGEN_STRONG_INLINE Scalar value()
const {
return m_functor(m_lhsIter.value(), m_rhsIter.value()); }
199 EIGEN_STRONG_INLINE Index index()
const {
return m_lhsIter.index(); }
200 EIGEN_STRONG_INLINE Index row()
const {
return m_lhsIter.row(); }
201 EIGEN_STRONG_INLINE Index col()
const {
return m_lhsIter.col(); }
203 EIGEN_STRONG_INLINE
operator bool()
const {
return (m_lhsIter && m_rhsIter); }
206 LhsIterator m_lhsIter;
207 RhsIterator m_rhsIter;
208 const BinaryFunc& m_functor;
212 template<
typename T,
typename Lhs,
typename Rhs,
typename Derived>
220 typedef typename _LhsNested::InnerIterator LhsIterator;
221 typedef typename Lhs::Index Index;
226 : m_rhs(xpr.
rhs()), m_lhsIter(xpr.
lhs(),outer), m_functor(xpr.
functor()), m_outer(outer)
229 EIGEN_STRONG_INLINE Derived& operator++()
232 return *
static_cast<Derived*
>(
this);
235 EIGEN_STRONG_INLINE Scalar value()
const 236 {
return m_functor(m_lhsIter.value(),
237 m_rhs.coeff(IsRowMajor?m_outer:m_lhsIter.index(),IsRowMajor?m_lhsIter.index():m_outer)); }
239 EIGEN_STRONG_INLINE Index index()
const {
return m_lhsIter.index(); }
240 EIGEN_STRONG_INLINE Index row()
const {
return m_lhsIter.row(); }
241 EIGEN_STRONG_INLINE Index col()
const {
return m_lhsIter.col(); }
243 EIGEN_STRONG_INLINE
operator bool()
const {
return m_lhsIter; }
247 LhsIterator m_lhsIter;
248 const BinaryFunc m_functor;
253 template<
typename T,
typename Lhs,
typename Rhs,
typename Derived>
260 typedef typename _RhsNested::InnerIterator RhsIterator;
261 typedef typename Lhs::Index Index;
267 : m_xpr(xpr), m_rhsIter(xpr.
rhs(),outer), m_functor(xpr.
functor()), m_outer(outer)
270 EIGEN_STRONG_INLINE Derived& operator++()
273 return *
static_cast<Derived*
>(
this);
276 EIGEN_STRONG_INLINE Scalar value()
const 277 {
return m_functor(m_xpr.lhs().coeff(IsRowMajor?m_outer:m_rhsIter.index(),IsRowMajor?m_rhsIter.index():m_outer), m_rhsIter.value()); }
279 EIGEN_STRONG_INLINE Index index()
const {
return m_rhsIter.index(); }
280 EIGEN_STRONG_INLINE Index row()
const {
return m_rhsIter.row(); }
281 EIGEN_STRONG_INLINE Index col()
const {
return m_rhsIter.col(); }
283 EIGEN_STRONG_INLINE
operator bool()
const {
return m_rhsIter; }
286 const CwiseBinaryXpr& m_xpr;
287 RhsIterator m_rhsIter;
288 const BinaryFunc& m_functor;
298 template<
typename Derived>
299 template<
typename OtherDerived>
300 EIGEN_STRONG_INLINE Derived &
303 return derived() = derived() - other.derived();
306 template<
typename Derived>
307 template<
typename OtherDerived>
308 EIGEN_STRONG_INLINE Derived &
311 return derived() = derived() + other.derived();
314 template<
typename Derived>
315 template<
typename OtherDerived>
319 return typename CwiseProductDenseReturnType<OtherDerived>::Type(derived(), other.derived());
324 #endif // EIGEN_SPARSE_CWISE_BINARY_OP_H Definition: SparseCwiseBinaryOp.h:43
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:53
const _LhsNested & lhs() const
Definition: CwiseBinaryOp.h:151
Definition: CwiseBinaryOp.h:104
Definition: Functors.h:47
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:107
const _RhsNested & rhs() const
Definition: CwiseBinaryOp.h:153
Base class of any sparse matrices or sparse expressions.
Definition: ForwardDeclarations.h:239
Definition: BandTriangularSolver.h:13
An InnerIterator allows to loop over the element of a sparse (or dense) matrix or expression...
The type used to identify a dense storage.
Definition: Constants.h:428
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: ForwardDeclarations.h:17
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48
const BinaryOp & functor() const
Definition: CwiseBinaryOp.h:155