hashedSMatrixIterator.hh

Go to the documentation of this file.
1 
6 #ifndef hSparseMatrixIterator_hh
7 #define hSparseMatrixIterator_hh
8 
9 #include "matrixIterator.hh"
10 #include "basics/debug.hh"
11 
12 namespace concepts {
13 
14  // forward declaration
15  template<class T>
16  class HashedSparseMatrix;
17 
18 // template<class T>
19 // struct HashedSparseMatrix<T>::Value;
20 
21  // *********************************************** _HashedSMatrix_iterator **
22 
27  template <class _Tp, class _Ref, class _Ptr>
29  public _Matrix_iterator_base<_Tp, _Ref, _Ptr> {
30  public:
33 
34  template<class _Tp_, class _Ref_, class _Ptr_>
35  struct MatrixType;
36 
37  typedef std::forward_iterator_tag iterator_category;
38  typedef _Tp value_type;
39  typedef _Ptr pointer;
40  typedef _Ref reference;
41  typedef size_t size_type;
42  typedef ptrdiff_t difference_type;
46  typedef typename _Base::return_type return_type;
47 
53  _HashedSMatrix_iterator(matrix_type& m, const unsigned int r = 0);
57  template<class _RefR, class _PtrR>
60  : _Base(__x), v_(__x.v()), hashBits_(__x.hashBits()),
61  pPerRow_(__x.pPerRow()), nofPages_(__x.nofPages()),
62  p_(__x.p()), pNextRow_(__x.pNextRow()), page_(__x.page()) {
63  conceptsAssert(v_ == 0 || v_->val != 0.0, Assertion());
64  }
65 
67  /*return_type*/ reference operator*() const {
68  conceptsAssert(v_ != 0 && v_->val != 0.0, Assertion());
69  return v_->val;
70  }
72  pointer operator->() const {
73  conceptsAssert(v_ != 0 && v_->val != 0.0, Assertion());
74  return &v_->val;
75  }
76 
78  template<class _RefR, class _PtrR>
80  _Base::operator=(__x);
81  v_ = __x.v(); hashBits_ = __x.hashBits();
82  pPerRow_ = __x.pPerRow(); nofPages_ = __x.nofPages();
83  p_ = __x.p(); pNextRow_ = __x.pNextRow(); page_ = __x.page();
84  conceptsAssert(v_ == 0 || v_->val != 0.0, Assertion());
85  return *this;
86  }
87 
96 
98  typename HashedSparseMatrix<_Tp>::Value* v() const { return v_; }
99  int hashBits() const { return hashBits_; }
100  int pPerRow() const { return pPerRow_; }
101  int nofPages() const { return nofPages_; }
102  int p() const { return p_; }
103  int pNextRow() const { return pNextRow_; }
104  typename HashedSparseMatrix<_Tp>::Value** page() const { return page_; }
105  protected:
106  virtual std::ostream& info(std::ostream& os) const;
107  private:
113  int p_, pNextRow_;
116  };
117 
119  template <class _Tp, class _Ref, class _Ptr>
120  template<class _Tp_, class _Ref_, class _Ptr_>
121  struct _HashedSMatrix_iterator<_Tp, _Ref, _Ptr>::MatrixType {
123  };
124 
126  template <class _Tp, class _Ref, class _Ptr>
127  template<class _Tp_>
128  struct _HashedSMatrix_iterator<_Tp, _Ref, _Ptr>::
129  MatrixType<_Tp_, const _Tp_&, const _Tp_*>
130  {
132  };
133 
134 } // namespace concepts
135 
136 #endif // hSparseMatrixIterator_hh
137 
_HashedSMatrix_iterator(matrix_type &m, const unsigned int r=0)
Constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
HashedSparseMatrix< _Tp >::Value * v() const
Data defining the position of the iterator.
HashedSparseMatrix< _Tp >::Value ** page() const
_HashedSMatrix_iterator(const _HashedSMatrix_iterator< _Tp, _RefR, _PtrR > &__x)
Copy constructor. Also from iterator to constant iterator.
int hashBits_
Hash bits, number of pages per row (2 ^ hash bits), number of pages.
_Self pre_increment()
Pre-increment operator, exportable to Python.
HashedSparseMatrix< _Tp >::Value ** page_
Pointer to the first entrance in the page.
_HashedSMatrix_iterator()
Constructor. Iterator stands at the end of any matrix.
_HashedSMatrix_iterator< _Tp, _Tp &, _Tp * > iterator
_Self & operator=(const _HashedSMatrix_iterator< _Tp, _RefR, _PtrR > &__x)
Assignment.
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
_Matrix_iterator_base< _Tp, _Ref, _Ptr > _Base
Non-constant matrix for non-constant iterator.
_Self & operator++()
Pre-increment operator.
reference operator*() const
Dereferencation.
Exception class for assertions.
Definition: exceptions.hh:258
_Self & operator=(const iterator &__x)
Assignment.
MatrixType< _Tp, _Ref, _Ptr >::type matrix_type
_Self operator++(int)
Post-increment operator.
ReturnType< _Ref >::type return_type
Base class for STL like iterator for matrices.
HashedSparseMatrix< _Tp >::Value * v_
Pointer to the current entrance. If its zero, the end is reached.
_HashedSMatrix_iterator< _Tp, const _Tp &, const _Tp * > const_iterator
int p_
Current page number, first page number of next row.
STL like iterator for hashed sparse matrices.
std::forward_iterator_tag iterator_category
_Self post_increment()
Post-increment operator, exportable to Python.
pointer operator->() const
Returns a pointer to the value.
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich