SparseView.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2011 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2010 Daniel Lowengrub <lowdanie@gmail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_SPARSEVIEW_H
12 #define EIGEN_SPARSEVIEW_H
13 
14 namespace Eigen {
15 
16 namespace internal {
17 
18 template<typename MatrixType>
19 struct traits<SparseView<MatrixType> > : traits<MatrixType>
20 {
21  typedef typename MatrixType::Index Index;
22  typedef Sparse StorageKind;
23  enum {
25  };
26 };
27 
28 } // end namespace internal
29 
30 template<typename MatrixType>
31 class SparseView : public SparseMatrixBase<SparseView<MatrixType> >
32 {
33  typedef typename MatrixType::Nested MatrixTypeNested;
35 public:
37 
38  SparseView(const MatrixType& mat, const Scalar& m_reference = Scalar(0),
39  typename NumTraits<Scalar>::Real m_epsilon = NumTraits<Scalar>::dummy_precision()) :
40  m_matrix(mat), m_reference(m_reference), m_epsilon(m_epsilon) {}
41 
42  class InnerIterator;
43 
44  inline Index rows() const { return m_matrix.rows(); }
45  inline Index cols() const { return m_matrix.cols(); }
46 
47  inline Index innerSize() const { return m_matrix.innerSize(); }
48  inline Index outerSize() const { return m_matrix.outerSize(); }
49 
50 protected:
51  MatrixTypeNested m_matrix;
52  Scalar m_reference;
54 };
55 
56 template<typename MatrixType>
57 class SparseView<MatrixType>::InnerIterator : public _MatrixTypeNested::InnerIterator
58 {
59  typedef typename SparseView::Index Index;
60 public:
61  typedef typename _MatrixTypeNested::InnerIterator IterBase;
62  InnerIterator(const SparseView& view, Index outer) :
63  IterBase(view.m_matrix, outer), m_view(view)
64  {
65  incrementToNonZero();
66  }
67 
69  {
70  IterBase::operator++();
71  incrementToNonZero();
72  return *this;
73  }
74 
75  using IterBase::value;
76 
77 protected:
79 
80 private:
82  {
83  while((bool(*this)) && internal::isMuchSmallerThan(value(), m_view.m_reference, m_view.m_epsilon))
84  {
85  IterBase::operator++();
86  }
87  }
88 };
89 
90 template<typename Derived>
92  const typename NumTraits<Scalar>::Real& m_epsilon) const
93 {
94  return SparseView<Derived>(derived(), m_reference, m_epsilon);
95 }
96 
97 } // end namespace Eigen
98 
99 #endif
Index cols() const
Definition: SparseView.h:45
#define EIGEN_STRONG_INLINE
EIGEN_STRONG_INLINE InnerIterator & operator++()
Definition: SparseView.h:68
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: matrix.hpp:471
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
Index innerSize() const
Definition: SparseView.h:47
bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, typename NumTraits< Scalar >::Real precision=NumTraits< Scalar >::dummy_precision())
internal::traits< Derived >::Scalar Scalar
Definition: MatrixBase.h:56
const unsigned int RowMajorBit
const SparseView< Derived > sparseView(const Scalar &m_reference=Scalar(0), const typename NumTraits< Scalar >::Real &m_epsilon=NumTraits< Scalar >::dummy_precision()) const
Definition: SparseView.h:91
InnerIterator(const SparseView &view, Index outer)
Definition: SparseView.h:62
NumTraits< Scalar >::Real m_epsilon
Definition: SparseView.h:53
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
Definition: SparseUtil.h:62
Base class of any sparse matrices or sparse expressions.
MatrixType::Nested MatrixTypeNested
Definition: SparseView.h:33
internal::remove_all< MatrixTypeNested >::type _MatrixTypeNested
Definition: SparseView.h:34
MatrixTypeNested m_matrix
Definition: SparseView.h:51
const SparseView & m_view
Definition: SparseView.h:78
Index outerSize() const
Definition: SparseView.h:48
internal::traits< Derived >::Index Index
Definition: EigenBase.h:31
_MatrixTypeNested::InnerIterator IterBase
Definition: SparseView.h:61
Scalar m_reference
Definition: SparseView.h:52
Index rows() const
Definition: SparseView.h:44


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:10