LoAdSG
depth.h
1/**********************************************************************************
2* Author: Christoph Pflaum, Riccarda Scherner-Griesshammer
3 * Department Informatik Lehrstuhl 10 - Systemsimulation
4 * Friedrich-Alexander Universität Erlangen-Nürnberg
5 *
6*********************************************/
7#ifndef DEPTH_H
8#define DEPTH_H
9
10#include "../myAssert.h"
11
12
13#include <iostream>
14#include <fstream>
15#include <list>
16
17#include "../indices/index.h"
18
19
20
21
22/***
23 * Einfache KLasse fuer Tiefe
24 ***/
25class Depth {
26public:
27
28
29 inline Depth(){
30 for (int d = 0; d < DimensionSparseGrid; d++)
31 depth[d] = 0;
32 };
33
34 inline explicit Depth(int depthall) {
35
36 for (int d = 0; d < DimensionSparseGrid; d++)
37 depth[d] = depthall;
38 };
39
40 inline explicit Depth(IndexDimension indexD);
41
42 inline Depth(const Depth &T_) {
43 for (int d = 0; d < DimensionSparseGrid; d++) depth[d] = T_.depth[d];
44 };
45
46 inline int *returnTiefen() {
47 return depth;
48 };
49
54 inline void set(int t, int d);
55
56 inline int at(int d) const;
57
58
59 inline unsigned int maxNorm();
60
61 inline unsigned int LoneNorm();
62
63 inline bool operator==(const Depth &TR) const;
64
65 inline bool operator<=(const Depth &TR);
66
67 inline bool operator<(const Depth &TR);
68
69 inline bool operator>(const Depth &TR);
70
71 inline bool operator>(int t);
72
73 inline bool operator>>(int t);
74
75 inline bool operator==(int t);
76
77 inline void operator++(){
78 for(int d=0;d<DimensionSparseGrid; d++){
79 depth[d]++;
80 }
81 }
82
83
84 inline void Print();
85
86private:
87 int depth[DimensionSparseGrid];
88};
89
90
91
92
93
94
95
97// implementation of inline functions
99
100
101inline Depth::Depth(IndexDimension indexD) {
102 for (int d = 0; d < DimensionSparseGrid; ++d)
103 depth[d] = indexD.getDepth(d);
104}
105
106inline int Depth::at(int d) const{
107 assertDimension(d);
108 return depth[d];
109}
110
111
112inline void Depth::set(int t, int d) {
113 assertDimension(d);
114 depth[d] = t;
115}
116
117inline bool Depth::operator==(const Depth &TR) const{
118 for (int d = 0; d < DimensionSparseGrid; ++d) {
119 if (depth[d] != TR.depth[d]) return false;
120 }
121 return true;
122}
123
124inline bool Depth::operator<=(const Depth &TR) {
125 for (int d = 0; d < DimensionSparseGrid; ++d) {
126 if (depth[d] > TR.depth[d]) return false;
127 }
128 return true;
129}
130
131inline bool Depth::operator<(const Depth &TR) {
132 for (int d = 0; d < DimensionSparseGrid; ++d) {
133 if (depth[d] >= TR.depth[d]) return false;
134 }
135 return true;
136}
137
138inline bool Depth::operator>(const Depth &TR) {
139 for (int d = 0; d < DimensionSparseGrid; ++d) {
140 if (depth[d] <= TR.depth[d]) return false;
141 }
142 return true;
143}
144
145inline bool Depth::operator>(int t) {
146
147
148 for (int d = 0; d < DimensionSparseGrid; ++d) {
149 if (depth[d] <= t) return false;
150 }
151 return true;
152}
153
154inline bool Depth::operator>>(int t) {
155
156 bool checkall = true;
157 for (int d = 0; d < DimensionSparseGrid; ++d) {
158 if (depth[d] <= t) checkall = false;
159
160 }
161 return checkall;
162}
163
164inline bool Depth::operator==(int t) {
165 for (int d = 0; d < DimensionSparseGrid; d++) {
166 if (depth[d] != t)return false;
167 }
168 return true;
169}
170
171inline unsigned int Depth::maxNorm() {
172 unsigned int maxN = depth[0];
173 for (int d = 1; d < DimensionSparseGrid; ++d) {
174 if (maxN < depth[d]) maxN = depth[d];
175 }
176 return maxN;
177}
178
179inline unsigned int Depth::LoneNorm() {
180 unsigned int loneN = depth[0];
181 for(int d=1;d<DimensionSparseGrid;++d) {
182 loneN = loneN + depth[d];
183 }
184 return loneN;
185}
186
187inline void Depth::Print() {
188 std::cout << "Depth ";
189 std::cout << " (" << depth[0];
190 for (int d = 1; d < DimensionSparseGrid; ++d) {
191 std::cout << ", " << depth[d];
192 }
193 std::cout << ") " ;
194
195}
196
198
199
201
202
203
204#endif // DEPTH_H
205