-
Notifications
You must be signed in to change notification settings - Fork 9
/
DaetkPetscVecConstIterator.h
163 lines (128 loc) · 2.75 KB
/
DaetkPetscVecConstIterator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#ifndef DAETKPETSCVECCONSTITERATOR_H
#define DAETKPETSCVECCONSTITERATOR_H
#include "Definitions.h"
#include "DaetkPetscVec.h"
///
namespace Daetk
{
namespace Petsc
{
class VecConstIterator
{
public:
///
inline VecConstIterator(const Vec& V);
///
inline VecConstIterator(const VecConstIterator& I);
///
inline const real& operator*();
///
inline VecConstIterator& operator=(const real* rhs);
///
inline VecConstIterator& operator++();
///
inline VecConstIterator operator++(int);
///
inline VecConstIterator& operator--();
///
inline VecConstIterator operator--(int);
///
inline VecConstIterator& operator+=(const int& n);
///
inline VecConstIterator& operator-=(const int& n);
///
inline VecConstIterator operator+(const int& n);
///
inline VecConstIterator operator-(const int& n);
///
inline const real& operator[](const int& n);
///
inline bool operator==(const real* rhs);
///
inline bool operator!=(const real* rhs);
///
inline bool operator<(const real* rhs);
private:
const real* p_;
const unsigned int& stride_;
};
inline VecConstIterator::VecConstIterator(const Vec& V):
p_(V.begin()),
stride_(V.stride_)
{}
inline VecConstIterator::VecConstIterator(const VecConstIterator& I):
stride_(I.stride_),
p_(I.p_)
{}
inline const real& VecConstIterator::operator*()
{
return *p_;
}
inline VecConstIterator& VecConstIterator::operator=(const real* rhs)
{
p_=rhs;
return *this;
}
inline VecConstIterator& VecConstIterator::operator++()
{
p_+=stride_;
return *this;
}
inline VecConstIterator VecConstIterator::operator++(int)
{
VecConstIterator temporary(*this);
p_+=stride_;
return temporary;
}
inline VecConstIterator& VecConstIterator::operator--()
{
p_-=stride_;
return *this;
}
inline VecConstIterator VecConstIterator::operator--(int)
{
VecConstIterator temporary(*this);
p_-=stride_;
return temporary;
}
inline VecConstIterator& VecConstIterator::operator+=(const int& n)
{
p_+=n*stride_;
return *this;
}
inline VecConstIterator& VecConstIterator::operator-=(const int& n)
{
p_-=n*stride_;
return *this;
}
inline VecConstIterator VecConstIterator::operator+(const int& n)
{
VecConstIterator temporary(*this);
temporary+=n;
return temporary;
}
inline VecConstIterator VecConstIterator::operator-(const int& n)
{
VecConstIterator temporary(*this);
temporary-=n;
return temporary;
}
inline const real& VecConstIterator::operator[](const int& n)
{
return *(p_+n*stride_);
}
inline bool VecConstIterator::operator==(const real* rhs)
{
return p_ == rhs;
}
inline bool VecConstIterator::operator!=(const real* rhs)
{
return p_ != rhs;
}
inline bool VecConstIterator::operator<(const real* rhs)
{
return p_ < rhs;
}
}//Petsc
}//Daetk
#endif