subMatrixIterator.hh

Go to the documentation of this file.
1 
6 #ifndef submatrixiterator_hh
7 #define submatrixiterator_hh
8 
9 #include "matrixIterator.hh"
10 #include "space/spaceSet.hh"
11 
12 namespace concepts {
13 
14  template<class F>
15  class SubMatrixN;
16 
17  // *************************************************** _SubMatrix_iterator **
18 
27  template <class F, class _Ref, class _Ptr>
29  public _Matrix_iterator_base<typename F::type, _Ref, _Ptr> {
30  public:
31 
32  template<class F_, class _Ref_, class _Ptr_>
33  struct MatrixType;
34 
35  typedef std::forward_iterator_tag iterator_category;
36  typedef typename F::type value_type;
37  typedef _Ptr pointer;
38  typedef _Ref reference;
39  typedef size_t size_type;
40  typedef ptrdiff_t difference_type;
44  typedef typename _Base::return_type return_type;
45 
46  typedef
48  typedef
50 
60  template<class _RefR, class _PtrR>
62  : _Base(__x), i_(0), iend_(0), iI_(0), lastI_(0), m_(__x.m()) {
63  if (__x.i())
64  i_.reset(new typename MatrixType<F, _Ref, _Ptr>::iterator(*__x.i()));
65  if (__x.iend())
66  iend_.reset
67  (new typename MatrixType<F, _Ref, _Ptr>::iterator(*__x.iend()));
68  if (__x.iI())
69  iI_.reset(new Set<IndexRange>::index_iterator(*__x.iI()));
70  if (__x.lastI())
71  lastI_.reset(new Set<IndexRange>::index_iterator(*__x.lastI()));
72  }
73 
76  conceptsAssert(i_.get(), Assertion());
77  return **i_;
78  }
80  pointer operator->() const {
81  conceptsAssert(i_.get(), Assertion());
82  return securePointer(**i_, m_);
83  }
84 
86  template<class _RefR, class _PtrR>
88  _Base::operator=(__x);
89  if (__x.i())
90  i_.reset(new typename MatrixType<F, _Ref, _Ptr>::iterator(*__x.i()));
91  else i_.reset(0);
92  if (__x.iend())
93  iend_.reset
94  (new typename MatrixType<F, _Ref, _Ptr>::iterator(*__x.iend()));
95  else iend_.reset(0);
96  iI_ = __x.iI(); lastI_ = __x.lastI();
97  m_ = __x.m();
98  return *this;
99  }
100 
104  _Self __tmp = *this;
105  ++*this;
106  return __tmp;
107  }
108 
109  inline typename MatrixType<F, _Ref, _Ptr>::iterator* i() const {
110  return i_.get();
111  }
112  inline const typename MatrixType<F, _Ref, _Ptr>::iterator* iend() const {
113  return iend_.get();
114  }
115  inline Set<IndexRange>::index_iterator* iI() const { return iI_.get(); }
117  return lastI_.get();
118  }
119  inline matrix_type* m() const { return m_; }
120  protected:
121  virtual std::ostream& info(std::ostream& os) const;
122  private:
124  std::shared_ptr<typename MatrixType<F, _Ref, _Ptr>::iterator> i_;
126  std::shared_ptr<const typename MatrixType<F, _Ref, _Ptr>::iterator> iend_;
128  std::shared_ptr<Set<IndexRange>::index_iterator> iI_;
130  std::shared_ptr<const Set<IndexRange>::index_iterator> lastI_;
133 
138  };
139 
141  template <class F, class _Ref, class _Ptr>
142  template<class F_, class _Ref_, class _Ptr_>
143  struct _SubMatrix_iterator<F, _Ref, _Ptr>::MatrixType {
145  typedef typename F_::iterator iterator;
146  };
147 
149  template <class F, class _Ref, class _Ptr>
150  template<class F_>
151  struct _SubMatrix_iterator<F, _Ref, _Ptr>::
152  MatrixType<F_, const typename F::type&, const typename F::type*>
153  {
154  typedef const SubMatrixN<F_> type;
155  typedef typename F_::const_iterator iterator;
156  };
157 
158 } // namespace concepts
159 
160 #endif // submatrixiterator_hh
MatrixType< F, _Ref, _Ptr >::type matrix_type
_SubMatrix_iterator< F, const value_type &, const value_type * > const_iterator
std::shared_ptr< Set< IndexRange >::index_iterator > iI_
Iterator over row index range.
MatrixType< F, _Ref, _Ptr >::iterator * i() const
std::forward_iterator_tag iterator_category
_SubMatrix_iterator(const _SubMatrix_iterator< F, _RefR, _PtrR > &__x)
Copy constructor. Also from iterator to constant iterator.
Set with operations, output operator, and method of the particular element types.
Definition: traces.hh:18
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
_SubMatrix_iterator< F, value_type &, value_type * > iterator
std::shared_ptr< typename MatrixType< F, _Ref, _Ptr >::iterator > i_
Iterator over matrix entries.
std::shared_ptr< const typename MatrixType< F, _Ref, _Ptr >::iterator > iend_
Iterator behind last matrix entry.
std::shared_ptr< const Set< IndexRange >::index_iterator > lastI_
Iterator behind the last row index.
return_type operator*() const
Dereferencation.
F * securePointer(F &value, G *matrix)
Templated function, which prevent a pointer to a temporary value got from constant matrices with inde...
Exception class for assertions.
Definition: exceptions.hh:258
_Self & operator=(const iterator &__x)
Assignment.
_Self & next_()
If the iterator is not standing inside submatrix, raise until it's standing inside.
Abstract class for an operator, which is a sub matrix of another matrix.
Definition: submatrix.hh:26
_SubMatrix_iterator()
Constructor. Iterator stands at the end of any matrix.
const MatrixType< F, _Ref, _Ptr >::iterator * iend() const
ReturnType< _Ref >::type return_type
Base class for STL like iterator for matrices.
_Self & operator++()
Increment operator.
STL like iterator for sub matrices.
_Matrix_iterator_base< value_type, _Ref, _Ptr > _Base
const Set< IndexRange >::index_iterator * lastI() const
Non-constant matrix for non-constant iterator.
_Self & operator=(const _SubMatrix_iterator< F, _RefR, _PtrR > &__x)
Assignment.
Set< IndexRange >::index_iterator * iI() const
matrix_type * m_
Super matrix.
_SubMatrix_iterator(matrix_type &m, uint r=0)
Constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
pointer operator->() const
Returns a pointer to the value.
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich