6#ifndef matrixIterator_hh
7#define matrixIterator_hh
10#include <bits/stl_iterator_base_types.h>
27 template <
class _Tp,
class _Ref,
class _Ptr>
40 typedef _Tp value_type;
42 typedef _Ref reference;
43 typedef size_t size_type;
45 typedef typename ReturnType<_Ref>::type return_type;
56 const unsigned int r,
const unsigned int c);
63 template<
class _RefR,
class _PtrR>
71 inline const unsigned int nofCols()
const {
return nofCols_; }
73 inline unsigned int row()
const {
return row_; }
75 inline unsigned int col()
const {
return col_; }
89 virtual std::ostream&
info(std::ostream&
os)
const;
101 template <
class _Tp,
class _Ref,
class _Ptr>
110 template <
class _Tp,
class _Ref,
class _Ptr>
113 typedef const _Tp_ type;
116 template <
class _Tp,
class _Ref,
class _Ptr>
119 os <<
"_Matrix_iterator_base(pos = ";
121 os <<
"(" << row_ <<
", " << col_ <<
")";
128 template <
class _Tp,
class _Ref,
class _Ptr>
133 return (
__x.last() &&
__y.last()) ||
134 (!
__x.last() && !
__y.last() &&
138 template <
class _Tp,
class _RefL,
class _PtrL,
class _RefR,
class _PtrR>
143 return (
__x.last() &&
__y.last()) ||
144 (!
__x.last() && !
__y.last() &&
148 template <
class _Tp,
class _Ref,
class _Ptr>
156 template <
class _Tp,
class _RefL,
class _PtrL,
class _RefR,
class _PtrR>
164 template <
class _Tp,
class _Ref,
class _Ptr>
169 return !
__x.last() &&
170 (
__y.last() || ((!
__y.last() &&
__x.row() <
__y.row()) ||
174 template <
class _Tp,
class _RefL,
class _PtrL,
class _RefR,
class _PtrR>
179 return !
__x.last() &&
180 (
__y.last() || (!
__y.last() &&
__x.row() <
__y.row()) ||
184 template <
class _Tp,
class _Ref,
class _Ptr>
192 template <
class _Tp,
class _RefL,
class _PtrL,
class _RefR,
class _PtrR>
200 template <
class _Tp,
class _Ref,
class _Ptr>
208 template <
class _Tp,
class _RefL,
class _PtrL,
class _RefR,
class _PtrR>
216 template <
class _Tp,
class _Ref,
class _Ptr>
224 template <
class _Tp,
class _RefL,
class _PtrL,
class _RefR,
class _PtrR>
234 inline typename _Matrix_iterator_base<_Tp, _RefL, _PtrL>::difference_type
239 if (
__y.last())
return 0;
240 else return __y.nofRows() * (
__y.nofCols() -
__y.row()) -
__y.col();
242 return __x.nofRows() * (
__x.nofCols() -
__x.row()) -
__x.col();
243 return typename _Matrix_iterator_base<_Tp, _RefL, _PtrL>::difference_type
247 template <
class _Tp,
class _Ref,
class _Ptr>
261 template<
class F,
class G>
264 template<
class F,
class G>
267 (
"inapplicable for constant matrices"));
277 template <
class _Tp,
class _Ref,
class _Ptr>
283 template<
class _Tp_,
class _Ref_,
class _Ptr_>
286 typedef std::random_access_iterator_tag iterator_category;
287 typedef _Tp value_type;
288 typedef _Ptr pointer;
289 typedef _Ref reference;
290 typedef size_t size_type;
295 typedef typename _Base::return_type return_type;
307 template<
class _RefR,
class _PtrR>
314 return (*matrix_)(this->
row_, this->col_);
337 _Self& operator++() {
339 if (++this->col_ >= this->nofCols_) {
347 _Self operator++(
int) {
353 _Self& operator--() {
356 this->col_ = this->nofCols_ - 1;
360 if (this->col_ > 0) --this->col_;
364 this->col_ = this->nofCols_ - 1;
369 _Self operator--(
int) {
375 _Self& operator+=(difference_type
__n)
377 if (this->
last_ && __n < 0) {
384 int col =
__n + this->col_;
388 this->col_ =
col % this->nofCols_;
394 _Self operator+(difference_type
__n)
const
400 _Self& operator-=(difference_type
__n) {
return *
this += -
__n; }
402 _Self operator-(difference_type
__n)
const {
407 return_type operator[](difference_type
__n)
const {
408 return *(*
this +
__n);
411 virtual std::ostream&
info(std::ostream&
os)
const;
418 template <
class _Tp,
class _Ref,
class _Ptr>
419 template<
class _Tp_,
class _Ref_,
class _Ptr_>
425 template <
class _Tp,
class _Ref,
class _Ptr>
#define conceptsException(exc)
const unsigned int nofRows_
Number of rows and columns.
_Matrix_iterator_base(const unsigned int nofRows, const unsigned int nofCols, const unsigned int r, const unsigned int c)
_Matrix_iterator_base()
Constructor. Iterator stands at the end of any matrix.
unsigned int row() const
Row.
unsigned int row_
Current row and column.
_Self & operator=(const iterator &__x)
Assignment.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
unsigned int col() const
Column.
_Matrix_iterator_base(const _Matrix_iterator_base< _Tp, _RefR, _PtrR > &__x)
bool last() const
Returns true, if iterator is behind the last entry.
const unsigned int nofCols() const
Number of columns.
const unsigned int nofRows() const
Number of rows.
bool last_
Iterator is behind the last entrance.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
_Matrix_iterator()
Constructor. Iterator stands at the end of any matrix.
_Matrix_iterator(matrix_type &m, const unsigned int r=0, const unsigned int c=0)
_Matrix_iterator(const _Matrix_iterator< _Tp, _RefR, _PtrR > &__x)
Copy constructor. Also from iterator to constant iterator.
_Self & operator=(const iterator &__x)
Assignment.
return_type operator*() const
Dereferencation.
pointer operator->() const
matrix_type * matrix() const
Pointer to the matrix, needed for copy constructor.
#define conceptsAssert(cond, exc)
bool operator<(const Cell &cell_x, const Cell &cell_y)
<-operator could be useful for sorting, e.g. in std::set.
ElementFormulaContainer< Real > operator-(const ElementFormulaContainer< Real > frm, const Real a)
Simple subtracting of a element formulas and a constant via –operator.
Frm_Sum< Real > operator+(const Formula< Real > &frm, const Real a)
F * securePointer(F &value, G *matrix)
Set< F > makeSet(uint n, const F &first,...)
Non-constant matrix for non-constant iterator.