ug4
Loading...
Searching...
No Matches
math_vector.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009-2015: G-CSC, Goethe University Frankfurt
3 * Author: Sebastian Reiter
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
35// This header defines common vector-types.
36// It is possible to completely avoid these vectors and to use your own.
37// Have a look at lgmath.h to see which typedefs have to be replaced.
38// You have to make sure that your vector-types specialize the
39// template methods defined in lgmath_vector_descriptor.
40
41#ifndef __H__COMMON__MATH_VECTOR__
42#define __H__COMMON__MATH_VECTOR__
43
44#include <cstddef>
45#include <iostream>
46#include <algorithm>
47#include "../../ug_config.h"
48#include "../../types.h"
50
51
52namespace ug
53{
54
63// MathMathVector
65template <std::size_t N, typename T = number> class MathVector;
66
68
71template <std::size_t fromN, std::size_t toN, typename T>
73{
75 static const size_t minN = std::min(toN, fromN);
76 static const size_t maxN = std::max(toN, fromN);
77 for(size_t i = 0; i < minN; ++i)
78 r[i] = v[i];
79 for(size_t i = minN; i < maxN; ++i)
80 r[i] = 0;
81 return r;
82}
83
84template <std::size_t N, typename T>
86{
87 return v;
88}
95template <std::size_t N, typename T>
97{
98 public:
99 typedef T value_type;
100 typedef std::size_t size_type;
101 static const std::size_t Size = N;
102
103 public:
104 MathVector() {for(std::size_t i = 0; i < N; ++i) m_data[i] = 0.0;}
105 MathVector(const value_type& val) {for(std::size_t i = 0; i < N; ++i) m_data[i] = val;}
107
108 template <std::size_t fromN>
109 static inline MathVector from(const MathVector<fromN, T>& v)
110 {
111 return MathVectorFrom<fromN, N, T>(v);
112 }
113
114 // operations with other vectors
116 {
117 if(this != &v)
118 {
119 assign(v);
120 }
121 return *this;
122 }
123 MathVector& operator+= (const MathVector& v) {for(std::size_t i = 0; i < N; ++i) m_data[i] += v.coord(i);return *this;}
124 MathVector& operator-= (const MathVector& v) {for(std::size_t i = 0; i < N; ++i) m_data[i] -= v.coord(i);return *this;}
125
126 // operations with scalar
127 MathVector& operator= (const value_type& val) {for(std::size_t i = 0; i < N; ++i) m_data[i] = val;return *this;}
128 MathVector& operator+= (const value_type& val) {for(std::size_t i = 0; i < N; ++i) m_data[i] += val;return *this;}
129 MathVector& operator-= (const value_type& val) {for(std::size_t i = 0; i < N; ++i) m_data[i] -= val;return *this;}
130 MathVector& operator*= (const value_type& val) {for(std::size_t i = 0; i < N; ++i) m_data[i] *= val;return *this;}
131 MathVector& operator/= (const value_type& val) {for(std::size_t i = 0; i < N; ++i) m_data[i] /= val;return *this;}
132
133 // negation
134 MathVector operator- () const { MathVector<N, T> v; for (std::size_t i = 0; i < N; ++i) v.set_coord(i, -m_data[i]); return v; }
135
136 // scalar product
137 value_type operator* (const MathVector& v) const {value_type res = 0.0; for(std::size_t i = 0; i < N; ++i) res += m_data[i] * v.coord(i);return res;}
138
139 inline std::size_t size() const {return N;}
140
141 inline value_type& coord(size_t index) {return m_data[index];}
142 inline value_type coord(size_t index) const {return m_data[index];}
143
144 inline value_type& operator[](size_t index) {return m_data[index];}
145 inline const value_type& operator[](size_t index) const {return m_data[index];}
146
147 inline void set_coord(std::size_t index, value_type v) {m_data[index] = v;}
148
149 protected:
151
152 protected:
153 inline void assign(const MathVector<N>& v) {for(std::size_t i = 0; i < N; ++i) m_data[i] = v.coord(i);}
154
155};
156
161template <typename T>
162class MathVector<0, T>
163{
164 public:
165 typedef std::size_t size_type;
166 typedef T value_type;
167 static const std::size_t Size = 1;
168
169 public:
172 {
173 m_data[0] = x;
174 }
176
177 static inline MathVector from(const MathVector<0, T>& v) {return v;}
178 static inline MathVector from(const MathVector<1, T>& v) {return MathVector();}
179 static inline MathVector from(const MathVector<2, T>& v) {return MathVector();}
180 static inline MathVector from(const MathVector<3, T>& v) {return MathVector();}
181 static inline MathVector from(const MathVector<4, T>& v) {return MathVector();}
182 template <std::size_t fromN>
183 static inline MathVector from(const MathVector<fromN, T>& v)
184 {
185 return MathVectorFrom<0, fromN, T>(v);
186 }
187
188 // operations with other vectors
189 MathVector& operator= (const MathVector& v) {assign(v); return *this;}
190 MathVector& operator+= (const MathVector& v) {m_data[0] += v.x(); return *this;}
191 MathVector& operator-= (const MathVector& v) {m_data[0] -= v.x(); return *this;}
192
193 // operations with scalar
194 MathVector& operator= (const value_type& val) {m_data[0] = val;return *this;}
195 MathVector& operator+= (const value_type& val) {m_data[0] += val;return *this;}
196 MathVector& operator-= (const value_type& val) {m_data[0] -= val;return *this;}
197 MathVector& operator*= (const value_type& val) {m_data[0] *= val;return *this;}
198 MathVector& operator/= (const value_type& val) {m_data[0] /= val;return *this;}
199
200 // negation
202
203 // scalar product
204 value_type operator* (const MathVector& v) const {return m_data[0] * v.x();}
205
206 inline std::size_t size() const {return 1;}
207
208 inline value_type& coord(std::size_t index) {return m_data[0];}
209 inline value_type coord(std::size_t index) const {return m_data[0];}
210
211 inline value_type& operator[](std::size_t index) {return m_data[0];}
212 inline const value_type& operator[](std::size_t index) const {return m_data[0];}
213
214 inline void set_coord(std::size_t index, value_type v) {m_data[0] = v;}
215
216 inline value_type& x() {return m_data[0];}
217 inline const value_type& x() const {return m_data[0];}
218
220 protected:
221 inline void assign(const MathVector<0, T>& v) {m_data[0] = v.m_data[0];}
222
223};
224
228template <typename T>
229class MathVector<1, T>
230{
231 public:
232 typedef std::size_t size_type;
233 typedef T value_type;
234 static const std::size_t Size = 1;
235
236 public:
237 MathVector() {m_data[0] = 0.0;}
240
241 static inline MathVector from(const MathVector<0, T>& v) {return MathVector(0);}
242 static inline MathVector from(const MathVector<1, T>& v) {return v;}
243 static inline MathVector from(const MathVector<2, T>& v) {return MathVector(v[0]);}
244 static inline MathVector from(const MathVector<3, T>& v) {return MathVector(v[0]);}
245 static inline MathVector from(const MathVector<4, T>& v) {return MathVector(v[0]);}
246 template <std::size_t fromN>
247 static inline MathVector from(const MathVector<fromN, T>& v)
248 {
249 return MathVectorFrom<1, fromN, T>(v);
250 }
251
252 // operations with other vectors
253 MathVector& operator= (const MathVector& v) {assign(v); return *this;}
254 MathVector& operator+= (const MathVector& v) {m_data[0] += v.x(); return *this;}
255 MathVector& operator-= (const MathVector& v) {m_data[0] -= v.x(); return *this;}
256
257 // operations with scalar
258 MathVector& operator= (const value_type& val) {m_data[0] = val;return *this;}
259 MathVector& operator+= (const value_type& val) {m_data[0] += val;return *this;}
260 MathVector& operator-= (const value_type& val) {m_data[0] -= val;return *this;}
261 MathVector& operator*= (const value_type& val) {m_data[0] *= val;return *this;}
262 MathVector& operator/= (const value_type& val) {m_data[0] /= val;return *this;}
263
264 // negation
266
267 // scalar product
268 value_type operator* (const MathVector& v) const {return m_data[0] * v.x();}
269
270 inline std::size_t size() const {return 1;}
271
272 inline value_type& coord(std::size_t index) {return m_data[0];}
273 inline value_type coord(std::size_t index) const {return m_data[0];}
274
275 inline value_type& operator[](std::size_t index) {return m_data[0];}
276 inline const value_type& operator[](std::size_t index) const {return m_data[0];}
277
278 inline void set_coord(std::size_t index, value_type v) {m_data[0] = v;}
279
280 inline value_type& x() {return m_data[0];}
281 inline const value_type& x() const {return m_data[0];}
282
284 protected:
285 inline void assign(const MathVector<1, T>& v) {m_data[0] = v.m_data[0];}
286
287};
288
292template <typename T>
293class MathVector<2, T>
294{
295 public:
296 typedef std::size_t size_type;
297 typedef T value_type;
298 static const std::size_t Size = 2;
299
300 public:
301 MathVector() {m_data[0] = m_data[1] = 0.0;}
302 MathVector(const value_type& val) {m_data[0] = m_data[1] = val;}
304 {
305 m_data[0] = x;
306 m_data[1] = y;
307 }
309
310 static inline MathVector from(const MathVector<0, T>& v) {return MathVector(0, 0);}
311 static inline MathVector from(const MathVector<1, T>& v) {return MathVector(v[0], 0);}
312 static inline MathVector from(const MathVector<2, T>& v) {return v;}
313 static inline MathVector from(const MathVector<3, T>& v) {return MathVector(v[0], v[1]);}
314 static inline MathVector from(const MathVector<4, T>& v) {return MathVector(v[0], v[1]);}
315 template <std::size_t fromN>
316 static inline MathVector from(const MathVector<fromN, T>& v)
317 {
318 return MathVectorFrom<2, fromN, T>(v);
319 }
320
321 // operations with other vectors
322 MathVector& operator= (const MathVector& v) {assign(v); return *this;}
323 MathVector& operator+= (const MathVector& v) {for(std::size_t i = 0; i < 2; ++i) m_data[i] += v.coord(i);return *this;}
324 MathVector& operator-= (const MathVector& v) {for(std::size_t i = 0; i < 2; ++i) m_data[i] -= v.coord(i);return *this;}
325
326 // operations with scalar
327 MathVector& operator= (const value_type& val) {for(std::size_t i = 0; i < 2; ++i) m_data[i] = val;return *this;}
328 MathVector& operator+= (const value_type& val) {for(std::size_t i = 0; i < 2; ++i) m_data[i] += val;return *this;}
329 MathVector& operator-= (const value_type& val) {for(std::size_t i = 0; i < 2; ++i) m_data[i] -= val;return *this;}
330 MathVector& operator*= (const value_type& val) {for(std::size_t i = 0; i < 2; ++i) m_data[i] *= val;return *this;}
331 MathVector& operator/= (const value_type& val) {for(std::size_t i = 0; i < 2; ++i) m_data[i] /= val;return *this;}
332
333 // negation
334 MathVector operator- () const { return MathVector<2, T>(-m_data[0], -m_data[1]); }
335
336 // scalar product
337 value_type operator* (const MathVector& v) const {value_type res = 0.0; for(std::size_t i = 0; i < 2; ++i) res += m_data[i] * v.coord(i);return res;}
338
339 inline std::size_t size() const {return 2;}
340
341 inline value_type& coord(std::size_t index) {return m_data[index];}
342 inline value_type coord(std::size_t index) const {return m_data[index];}
343
344 inline value_type& operator[](std::size_t index) {return m_data[index];}
345 inline const value_type& operator[](std::size_t index) const {return m_data[index];}
346
347 inline void set_coord(std::size_t index, value_type v) {m_data[index] = v;}
348
349 inline value_type& x() {return m_data[0];}
350 inline const value_type& x() const {return m_data[0];}
351
352 inline value_type& y() {return m_data[1];}
353 inline const value_type& y() const {return m_data[1];}
354
356 protected:
357 inline void assign(const MathVector<2,T>& v) {m_data[0] = v.m_data[0];
358 m_data[1] = v.m_data[1];}
359};
360
364template <typename T>
365class MathVector<3, T>
366{
367 public:
368 typedef std::size_t size_type;
369 typedef T value_type;
370 static const std::size_t Size = 3;
371
372 public:
373 MathVector() {m_data[0] = m_data[1] = m_data[2] = 0.0;}
374 MathVector(const value_type& val) {m_data[0] = m_data[1] = m_data[2] = val;}
376 {
377 m_data[0] = x;
378 m_data[1] = y;
379 m_data[2] = z;
380 }
382
383 static inline MathVector from(const MathVector<0, T>& v) {return MathVector(0, 0, 0);}
384 static inline MathVector from(const MathVector<1, T>& v) {return MathVector(v[0], 0, 0);}
385 static inline MathVector from(const MathVector<2, T>& v) {return MathVector(v[0], v[1], 0);}
386 static inline MathVector from(const MathVector<3, T>& v) {return v;}
387 static inline MathVector from(const MathVector<4, T>& v) {return MathVector(v[0], v[1], v[2]);}
388 template <std::size_t fromN>
389 static inline MathVector from(const MathVector<fromN, T>& v)
390 {
391 return MathVectorFrom<3, fromN, T>(v);
392 }
393
394 // operations with other vectors
395 MathVector& operator= (const MathVector& v) {assign(v); return *this;}
396 MathVector& operator+= (const MathVector& v) {for(std::size_t i = 0; i < 3; ++i) m_data[i] += v.coord(i);return *this;}
397 MathVector& operator-= (const MathVector& v) {for(std::size_t i = 0; i < 3; ++i) m_data[i] -= v.coord(i);return *this;}
398
399 // operations with scalar
400 MathVector& operator= (const value_type& val) {for(std::size_t i = 0; i < 3; ++i) m_data[i] = val;return *this;}
401 MathVector& operator+= (const value_type& val) {for(std::size_t i = 0; i < 3; ++i) m_data[i] += val;return *this;}
402 MathVector& operator-= (const value_type& val) {for(std::size_t i = 0; i < 3; ++i) m_data[i] -= val;return *this;}
403 MathVector& operator*= (const value_type& val) {for(std::size_t i = 0; i < 3; ++i) m_data[i] *= val;return *this;}
404 MathVector& operator/= (const value_type& val) {for(std::size_t i = 0; i < 3; ++i) m_data[i] /= val;return *this;}
405
406 // negation
407 MathVector operator- () const { return MathVector<3, T>(-m_data[0], -m_data[1], -m_data[2]); }
408
409 // scalar product
410 value_type operator* (const MathVector& v) const {value_type res = 0.0; for(std::size_t i = 0; i < 3; ++i) res += m_data[i] * v.coord(i);return res;}
411
412 inline std::size_t size() const {return 3;}
413
414 inline value_type& coord(std::size_t index) {return m_data[index];}
415 inline value_type coord(std::size_t index) const {return m_data[index];}
416
417 inline value_type& operator[](std::size_t index) {return m_data[index];}
418 inline const value_type& operator[](std::size_t index) const {return m_data[index];}
419
420 inline void set_coord(std::size_t index, value_type v) {m_data[index] = v;}
421
422 inline value_type& x() {return m_data[0];}
423 inline const value_type& x() const {return m_data[0];}
424
425 inline value_type& y() {return m_data[1];}
426 inline const value_type& y() const {return m_data[1];}
427
428 inline value_type& z() {return m_data[2];}
429 inline const value_type& z() const {return m_data[2];}
430
432 protected:
433 inline void assign(const MathVector<3,T>& v) {m_data[0] = v.m_data[0];
434 m_data[1] = v.m_data[1];
435 m_data[2] = v.m_data[2];}
436
437};
438
442template <typename T>
443class MathVector<4, T>
444{
445 public:
446 typedef std::size_t size_type;
447 typedef T value_type;
448 static const std::size_t Size = 4;
449
450 public:
451 MathVector() {m_data[0] = m_data[1] = m_data[2] = m_data[3] = 0.0;}
452 MathVector(const value_type& val) {m_data[0] = m_data[1] = m_data[2] = m_data[3] =val;}
454 {
455 m_data[0] = x;
456 m_data[1] = y;
457 m_data[2] = z;
458 m_data[3] = w;
459 }
461
462 static inline MathVector from(const MathVector<0, T>& v) {return MathVector(0, 0, 0, 0);}
463 static inline MathVector from(const MathVector<1, T>& v) {return MathVector(v[0], 0, 0, 0);}
464 static inline MathVector from(const MathVector<2, T>& v) {return MathVector(v[0], v[1], 0, 0);}
465 static inline MathVector from(const MathVector<3, T>& v) {return MathVector(v[0], v[1], v[2], 0);}
466 static inline MathVector from(const MathVector<4, T>& v) {return v;}
467 template <std::size_t fromN>
468 static inline MathVector from(const MathVector<fromN, T>& v)
469 {
470 return MathVectorFrom<4, fromN, T>(v);
471 }
472
473 // operations with other vectors
474 MathVector& operator= (const MathVector& v) {assign(v); return *this;}
475 MathVector& operator+= (const MathVector& v) {for(std::size_t i = 0; i < 4; ++i) m_data[i] += v.coord(i);return *this;}
476 MathVector& operator-= (const MathVector& v) {for(std::size_t i = 0; i < 4; ++i) m_data[i] -= v.coord(i);return *this;}
477
478 // operations with scalar
479 MathVector& operator= (const value_type& val) {for(std::size_t i = 0; i < 4; ++i) m_data[i] = val;return *this;}
480 MathVector& operator+= (const value_type& val) {for(std::size_t i = 0; i < 4; ++i) m_data[i] += val;return *this;}
481 MathVector& operator-= (const value_type& val) {for(std::size_t i = 0; i < 4; ++i) m_data[i] -= val;return *this;}
482 MathVector& operator*= (const value_type& val) {for(std::size_t i = 0; i < 4; ++i) m_data[i] *= val;return *this;}
483 MathVector& operator/= (const value_type& val) {for(std::size_t i = 0; i < 4; ++i) m_data[i] /= val;return *this;}
484
485 // negation
486 MathVector operator- () const { return MathVector<4, T>(-m_data[0], -m_data[1], -m_data[2], -m_data[3]); }
487
488 // scalar product
489 value_type operator* (const MathVector& v) const {value_type res = 0.0; for(std::size_t i = 0; i < 4; ++i) res += m_data[i] * v.coord(i);return res;}
490
491 inline std::size_t size() const {return 4;}
492
493 inline value_type& coord(std::size_t index) {return m_data[index];}
494 inline value_type coord(std::size_t index) const {return m_data[index];}
495
496 inline value_type& operator[](std::size_t index) {return m_data[index];}
497 inline const value_type& operator[](std::size_t index) const {return m_data[index];}
498
499 inline void set_coord(std::size_t index, value_type v) {m_data[index] = v;}
500
501 inline value_type& x() {return m_data[0];}
502 inline const value_type& x() const {return m_data[0];}
503
504 inline value_type& y() {return m_data[1];}
505 inline const value_type& y() const {return m_data[1];}
506
507 inline value_type& z() {return m_data[2];}
508 inline const value_type& z() const {return m_data[2];}
509
510 inline value_type& w() {return m_data[3];}
511 inline const value_type& w() const {return m_data[3];}
512
514 protected:
515 inline void assign(const MathVector<4,T>& v) {m_data[0] = v.m_data[0];
516 m_data[1] = v.m_data[1];
517 m_data[2] = v.m_data[2];
518 m_data[3] = v.m_data[3];}
519
520};
521
522template <std::size_t N, typename T>
524{
525 for(std::size_t i = 0; i < N; ++i)
526 {
527 if(v[i] != w[i]) return false;
528 }
529 return true;
530}
531
532template <typename T>
534{
535 return true;
536}
537
538// NOTE: this implementation determines the state of the relation '<'
539// by considering the FIRST vector-entry, which is not equal
540template <std::size_t N, typename T>
542{
543 for(std::size_t i = 0; i < N; ++i)
544 {
545 if(v[i] < w[i] - SMALL) return true;
546 else if(v[i] > w[i] + SMALL) return false;
547 }
548 return false;
549}
550
551template <std::size_t N, typename T>
553{
554 return !(v == w);
555}
556
557template <std::size_t N, typename T>
558std::ostream& operator<< (std::ostream& outStream, const ug::MathVector<N,T>& v)
559{
560 for(std::size_t i = 0; i < N; ++i)
561 outStream << "[" << i << "]: " << v.coord(i) << std::endl;
562 return outStream;
563}
564
565template <typename T>
566std::ostream& operator<< (std::ostream& outStream, const ug::MathVector<0,T>& v)
567{
568 outStream << "(empty)";
569 return outStream;
570}
571
572template <typename T>
573std::ostream& operator<< (std::ostream& outStream, const ug::MathVector<1,T>& v)
574{
575 outStream << "(" << v[0] << ")";
576 return outStream;
577}
578template <typename T>
579std::ostream& operator<< (std::ostream& outStream, const ug::MathVector<2,T>& v)
580{
581 outStream << "("<<v[0]<<", "<<v[1]<<")";
582 return outStream;
583}
584template <typename T>
585std::ostream& operator<< (std::ostream& outStream, const ug::MathVector<3,T>& v)
586{
587 outStream << "("<<v[0]<<", "<<v[1]<<", "<<v[2]<<")";
588 return outStream;
589}
590template <typename T>
591std::ostream& operator<< (std::ostream& outStream, const ug::MathVector<4,T>& v)
592{
593 outStream << "("<<v[0]<<", "<<v[1]<<", "<<v[2]<<", "<<v[3]<<")";
594 return outStream;
595}
596
597UG_API std::ostream& operator<< (std::ostream& outStream, const ug::MathVector<1>& v);
598UG_API std::ostream& operator<< (std::ostream& outStream, const ug::MathVector<2>& v);
599UG_API std::ostream& operator<< (std::ostream& outStream, const ug::MathVector<3>& v);
600UG_API std::ostream& operator<< (std::ostream& outStream, const ug::MathVector<4>& v);
601
602UG_API std::ostream& write_plain_txt (std::ostream& outStream, const ug::MathVector<1>& v);
603UG_API std::ostream& write_plain_txt (std::ostream& outStream, const ug::MathVector<2>& v);
604UG_API std::ostream& write_plain_txt (std::ostream& outStream, const ug::MathVector<3>& v);
605UG_API std::ostream& write_plain_txt (std::ostream& outStream, const ug::MathVector<4>& v);
606
607UG_API std::istream& read_plain_txt (std::istream& inStream, ug::MathVector<1>& v);
608UG_API std::istream& read_plain_txt (std::istream& inStream, ug::MathVector<2>& v);
609UG_API std::istream& read_plain_txt (std::istream& inStream, ug::MathVector<3>& v);
610UG_API std::istream& read_plain_txt (std::istream& inStream, ug::MathVector<4>& v);
611
612template <class TStream, std::size_t N, class T>
613void Serialize(TStream& out, const MathVector<N, T>& val)
614{
615 out.write((char*)val.m_data, sizeof(T) * N);
616}
617
618template <class TStream, std::size_t N, class T>
619void Deserialize(TStream& out, MathVector<N, T>& valOut)
620{
621 out.read((char*)valOut.m_data, sizeof(T) * N);
622}
623
624// end group vectors
626
627}// end of namespace
628
629
630#endif /* __H__COMMON__MATH_MathVector__ */
static MathVector from(const MathVector< 4, T > &v)
Definition math_vector.h:181
value_type & coord(std::size_t index)
Definition math_vector.h:208
MathVector(const MathVector< 0, T > &v)
Definition math_vector.h:175
const value_type & operator[](std::size_t index) const
Definition math_vector.h:212
value_type & operator[](std::size_t index)
Definition math_vector.h:211
static MathVector from(const MathVector< 3, T > &v)
Definition math_vector.h:180
std::size_t size_type
Definition math_vector.h:165
const value_type & x() const
Definition math_vector.h:217
std::size_t size() const
Definition math_vector.h:206
value_type & x()
Definition math_vector.h:216
MathVector(value_type x)
Definition math_vector.h:171
value_type coord(std::size_t index) const
Definition math_vector.h:209
MathVector()
Definition math_vector.h:170
static MathVector from(const MathVector< fromN, T > &v)
Definition math_vector.h:183
static MathVector from(const MathVector< 1, T > &v)
Definition math_vector.h:178
T value_type
Definition math_vector.h:166
void assign(const MathVector< 0, T > &v)
Definition math_vector.h:221
static MathVector from(const MathVector< 0, T > &v)
Definition math_vector.h:177
static MathVector from(const MathVector< 2, T > &v)
Definition math_vector.h:179
void set_coord(std::size_t index, value_type v)
Definition math_vector.h:214
static MathVector from(const MathVector< 4, T > &v)
Definition math_vector.h:245
static MathVector from(const MathVector< 1, T > &v)
Definition math_vector.h:242
void set_coord(std::size_t index, value_type v)
Definition math_vector.h:278
std::size_t size_type
Definition math_vector.h:232
value_type & operator[](std::size_t index)
Definition math_vector.h:275
const value_type & operator[](std::size_t index) const
Definition math_vector.h:276
MathVector(value_type x)
Definition math_vector.h:238
void assign(const MathVector< 1, T > &v)
Definition math_vector.h:285
value_type & coord(std::size_t index)
Definition math_vector.h:272
value_type & x()
Definition math_vector.h:280
value_type coord(std::size_t index) const
Definition math_vector.h:273
static MathVector from(const MathVector< 2, T > &v)
Definition math_vector.h:243
static MathVector from(const MathVector< 3, T > &v)
Definition math_vector.h:244
static MathVector from(const MathVector< 0, T > &v)
Definition math_vector.h:241
T value_type
Definition math_vector.h:233
const value_type & x() const
Definition math_vector.h:281
MathVector(const MathVector< 1, T > &v)
Definition math_vector.h:239
MathVector()
Definition math_vector.h:237
std::size_t size() const
Definition math_vector.h:270
static MathVector from(const MathVector< fromN, T > &v)
Definition math_vector.h:247
std::size_t size_type
Definition math_vector.h:296
T value_type
Definition math_vector.h:297
static MathVector from(const MathVector< 1, T > &v)
Definition math_vector.h:311
value_type & x()
Definition math_vector.h:349
static MathVector from(const MathVector< 0, T > &v)
Definition math_vector.h:310
void assign(const MathVector< 2, T > &v)
Definition math_vector.h:357
MathVector()
Definition math_vector.h:301
static MathVector from(const MathVector< 2, T > &v)
Definition math_vector.h:312
value_type & y()
Definition math_vector.h:352
static MathVector from(const MathVector< 4, T > &v)
Definition math_vector.h:314
MathVector(value_type x, value_type y)
Definition math_vector.h:303
const value_type & x() const
Definition math_vector.h:350
const value_type & y() const
Definition math_vector.h:353
MathVector(const value_type &val)
Definition math_vector.h:302
static MathVector from(const MathVector< fromN, T > &v)
Definition math_vector.h:316
std::size_t size() const
Definition math_vector.h:339
value_type & coord(std::size_t index)
Definition math_vector.h:341
static MathVector from(const MathVector< 3, T > &v)
Definition math_vector.h:313
const value_type & operator[](std::size_t index) const
Definition math_vector.h:345
value_type coord(std::size_t index) const
Definition math_vector.h:342
void set_coord(std::size_t index, value_type v)
Definition math_vector.h:347
MathVector(const MathVector< 2, T > &v)
Definition math_vector.h:308
value_type & operator[](std::size_t index)
Definition math_vector.h:344
value_type & x()
Definition math_vector.h:422
MathVector(value_type x, value_type y, value_type z)
Definition math_vector.h:375
static MathVector from(const MathVector< fromN, T > &v)
Definition math_vector.h:389
static MathVector from(const MathVector< 3, T > &v)
Definition math_vector.h:386
void set_coord(std::size_t index, value_type v)
Definition math_vector.h:420
const value_type & z() const
Definition math_vector.h:429
value_type & operator[](std::size_t index)
Definition math_vector.h:417
value_type & z()
Definition math_vector.h:428
static MathVector from(const MathVector< 1, T > &v)
Definition math_vector.h:384
const value_type & operator[](std::size_t index) const
Definition math_vector.h:418
value_type & coord(std::size_t index)
Definition math_vector.h:414
const value_type & y() const
Definition math_vector.h:426
T value_type
Definition math_vector.h:369
MathVector(const MathVector< 3, T > &v)
Definition math_vector.h:381
void assign(const MathVector< 3, T > &v)
Definition math_vector.h:433
MathVector()
Definition math_vector.h:373
static MathVector from(const MathVector< 2, T > &v)
Definition math_vector.h:385
static MathVector from(const MathVector< 0, T > &v)
Definition math_vector.h:383
MathVector(const value_type &val)
Definition math_vector.h:374
value_type & y()
Definition math_vector.h:425
std::size_t size() const
Definition math_vector.h:412
static MathVector from(const MathVector< 4, T > &v)
Definition math_vector.h:387
std::size_t size_type
Definition math_vector.h:368
value_type coord(std::size_t index) const
Definition math_vector.h:415
const value_type & x() const
Definition math_vector.h:423
MathVector(value_type x, value_type y, value_type z, value_type w)
Definition math_vector.h:453
value_type coord(std::size_t index) const
Definition math_vector.h:494
void set_coord(std::size_t index, value_type v)
Definition math_vector.h:499
const value_type & x() const
Definition math_vector.h:502
T value_type
Definition math_vector.h:447
value_type & y()
Definition math_vector.h:504
value_type & operator[](std::size_t index)
Definition math_vector.h:496
MathVector(const value_type &val)
Definition math_vector.h:452
const value_type & operator[](std::size_t index) const
Definition math_vector.h:497
static MathVector from(const MathVector< 4, T > &v)
Definition math_vector.h:466
static MathVector from(const MathVector< 2, T > &v)
Definition math_vector.h:464
static MathVector from(const MathVector< 0, T > &v)
Definition math_vector.h:462
const value_type & w() const
Definition math_vector.h:511
const value_type & y() const
Definition math_vector.h:505
MathVector()
Definition math_vector.h:451
static MathVector from(const MathVector< fromN, T > &v)
Definition math_vector.h:468
value_type & w()
Definition math_vector.h:510
MathVector(const MathVector< 4, T > &v)
Definition math_vector.h:460
static MathVector from(const MathVector< 1, T > &v)
Definition math_vector.h:463
const value_type & z() const
Definition math_vector.h:508
std::size_t size() const
Definition math_vector.h:491
std::size_t size_type
Definition math_vector.h:446
static MathVector from(const MathVector< 3, T > &v)
Definition math_vector.h:465
void assign(const MathVector< 4, T > &v)
Definition math_vector.h:515
value_type & z()
Definition math_vector.h:507
value_type & coord(std::size_t index)
Definition math_vector.h:493
value_type & x()
Definition math_vector.h:501
a mathematical Vector with N entries.
Definition math_vector.h:97
MathVector(const MathVector &v)
Definition math_vector.h:106
MathVector(const value_type &val)
Definition math_vector.h:105
value_type m_data[N]
Definition math_vector.h:150
MathVector()
Definition math_vector.h:104
void set_coord(std::size_t index, value_type v)
Definition math_vector.h:147
value_type operator*(const MathVector &v) const
Definition math_vector.h:137
MathVector & operator-=(const MathVector &v)
Definition math_vector.h:124
MathVector & operator/=(const value_type &val)
Definition math_vector.h:131
const value_type & operator[](size_t index) const
Definition math_vector.h:145
T value_type
Definition math_vector.h:99
value_type & operator[](size_t index)
Definition math_vector.h:144
MathVector & operator*=(const value_type &val)
Definition math_vector.h:130
value_type coord(size_t index) const
Definition math_vector.h:142
value_type & coord(size_t index)
Definition math_vector.h:141
MathVector & operator+=(const MathVector &v)
Definition math_vector.h:123
static MathVector from(const MathVector< fromN, T > &v)
Definition math_vector.h:109
MathVector & operator=(const MathVector &v)
Definition math_vector.h:115
MathVector operator-() const
Definition math_vector.h:134
void assign(const MathVector< N > &v)
Definition math_vector.h:153
std::size_t size_type
Definition math_vector.h:100
static const std::size_t Size
Definition math_vector.h:101
std::size_t size() const
Definition math_vector.h:139
std::ostream & operator<<(std::ostream &outStream, const ug::MathMatrix< 2, 2 > &m)
Definition math_matrix.cpp:38
#define UG_API
Definition ug_config.h:65
std::ostream & write_plain_txt(std::ostream &outStream, const ug::MathVector< 1 > &v)
plain text output of MathVector objects: space-separated coordinates
Definition math_vector.cpp:67
MathVector< toN, T > MathVectorFrom(const MathVector< fromN, T > &v)
helper method which creates a vector from another vector of different dimensionality
Definition math_vector.h:72
bool operator==(const MathVector< N, T > &v, const MathVector< N, T > &w)
Definition math_vector.h:523
std::istream & read_plain_txt(std::istream &inStream, ug::MathVector< 1 > &v)
plain text input of MathVectors: read space-separated coordinates
Definition math_vector.cpp:95
bool operator<(const MathVector< N, T > &v, const MathVector< N, T > &w)
Definition math_vector.h:541
bool operator!=(const MathVector< N, T > &v, const MathVector< N, T > &w)
Definition math_vector.h:552
the ug namespace
const number SMALL
Definition math_constants.h:41
void Deserialize(TIStream &buf, ParallelVector< T > &v)
Deerialize for ParallelVector<T>
Definition restart_bridge.cpp:112
void Serialize(TOStream &buf, const ParallelVector< T > &v)
Serialize for ParallelVector<T>
Definition restart_bridge.cpp:103