ug4
Loading...
Searching...
No Matches
math_vector_functions_common_impl.hpp
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 file supplies a general implementation of vector_functions.
36// The methods implemented here work on every vector-type, that supports
37// the vector-description in lgmath_vector_descriptor.h.
38// Since this implementation is quite general it is not the fastest.
39// One should consider implementing specializations for commonly used types
40// like vector3 etc.
42
43#ifndef __H__COMMON__VECTOR_FUNCTIONS_COMMON_IMPL__
44#define __H__COMMON__VECTOR_FUNCTIONS_COMMON_IMPL__
45
46#include <cmath>
47#include <algorithm>
48#include "common/error.h"
49#include "common/assert.h"
51
52namespace ug
53{
54
55template <typename vector_target_t, typename vector_source_t>
56void VecCopy(vector_target_t& target, const vector_source_t& source,
57 typename vector_target_t::value_type fill)
58{
59 using std::min;
60 size_t minSize = min(target.size(), source.size());
61 for(size_t i = 0; i < minSize; ++i)
62 target[i] = source[i];
63
64 for(size_t i = minSize; i < target.size(); ++i)
65 target[i] = fill;
66}
67
69template <typename vector_t>
70inline
71void
72VecAppend(vector_t& vOut, const vector_t& v1)
73{
74 typedef typename vector_t::size_type size_type;
75 for(size_type i = 0; i < vOut.size(); ++i)
76 {
77 vOut[i] += v1[i];
78 }
79}
80
82template <typename vector_t>
83inline
84void
85VecAppend(vector_t& vOut, const vector_t& v1, const vector_t& v2)
86{
87 typedef typename vector_t::size_type size_type;
88 for(size_type i = 0; i < vOut.size(); ++i)
89 {
90 vOut[i] += v1[i] + v2[i];
91 }
92}
93
95template <typename vector_t>
96inline
97void
98VecAppend(vector_t& vOut, const vector_t& v1, const vector_t& v2,
99 const vector_t& v3)
100{
101 typedef typename vector_t::size_type size_type;
102 for(size_type i = 0; i < vOut.size(); ++i)
103 {
104 vOut[i] += v1[i] + v2[i] + v3[i];
105 }
106}
107
109template <typename vector_t>
110inline
111void
112VecAppend(vector_t& vOut, const vector_t& v1, const vector_t& v2,
113 const vector_t& v3, const vector_t& v4)
114{
115 typedef typename vector_t::size_type size_type;
116 for(size_type i = 0; i < vOut.size(); ++i)
117 {
118 vOut[i] += v1[i] + v2[i] + v3[i] + v4[i];
119 }
120}
121
123template <typename vector_t>
124inline
125void
126VecScaleAppend(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1)
127{
128 typedef typename vector_t::size_type size_type;
129 for(size_type i = 0; i < vOut.size(); ++i)
130 {
131 vOut[i] += s1 * v1[i];
132 }
133}
134
136template <typename vector_t>
137inline
138void
139VecScaleAppend(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
140 typename vector_t::value_type s2, const vector_t& v2)
141{
142 typedef typename vector_t::size_type size_type;
143 for(size_type i = 0; i < vOut.size(); ++i)
144 {
145 vOut[i] += s1 * v1[i] + s2 * v2[i];
146 }
147}
148
150template <typename vector_t>
151inline
152void
153VecScaleAppend(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
154 typename vector_t::value_type s2, const vector_t& v2,
155 typename vector_t::value_type s3, const vector_t& v3)
156{
157 typedef typename vector_t::size_type size_type;
158 for(size_type i = 0; i < vOut.size(); ++i)
159 {
160 vOut[i] += s1 * v1[i] + s2 * v2[i] + s3 * v3[i];
161 }
162}
163
165template <typename vector_t>
166inline
167void
168VecScaleAppend(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
169 typename vector_t::value_type s2, const vector_t& v2,
170 typename vector_t::value_type s3, const vector_t& v3,
171 typename vector_t::value_type s4, const vector_t& v4)
172{
173 typedef typename vector_t::size_type size_type;
174 for(size_type i = 0; i < vOut.size(); ++i)
175 {
176 vOut[i] += s1 * v1[i] + s2 * v2[i] + s3 * v3[i] + s4 * v4[i];
177 }
178}
179
180
182template <typename vector_t>
183inline
184void
185VecAdd(vector_t& vOut, const vector_t& v1, const vector_t& v2)
186{
187 typedef typename vector_t::size_type size_type;
188 for(size_type i = 0; i < vOut.size(); ++i)
189 {
190 vOut[i] = v1[i] + v2[i];
191 }
192}
193
195template <typename vector_t>
196inline
197void
198VecAdd(vector_t& vOut, const vector_t& v1, const vector_t& v2,
199 const vector_t& v3)
200{
201 typedef typename vector_t::size_type size_type;
202 for(size_type i = 0; i < vOut.size(); ++i)
203 {
204 vOut[i] = v1[i] + v2[i] + v3[i];
205 }
206}
207
209template <typename vector_t>
210inline
211void
212VecAdd(vector_t& vOut, const vector_t& v1, const vector_t& v2,
213 const vector_t& v3, const vector_t& v4)
214{
215 typedef typename vector_t::size_type size_type;
216 for(size_type i = 0; i < vOut.size(); ++i)
217 {
218 vOut[i] = v1[i] + v2[i] + v3[i] + v4[i];
219 }
220}
221
223template <typename vector_t>
224inline
225void
226VecSubtract(vector_t& vOut, const vector_t& v1, const vector_t& v2)
227{
228 typedef typename vector_t::size_type size_type;
229 for(size_type i = 0; i < vOut.size(); ++i)
230 {
231 vOut[i] = v1[i] - v2[i];
232 }
233}
234
236template <typename vector_t>
237inline
238void
239VecPow(vector_t& vOut, const vector_t& v1, typename vector_t::value_type s)
240{
241 typedef typename vector_t::size_type size_type;
242 for(size_type i = 0; i < vOut.size(); ++i)
243 {
244 vOut[i] = std::pow(v1[i], s);
245 }
246}
247
249template <typename vector_t>
250inline
251void
252VecScale(vector_t& vOut, const vector_t& v, typename vector_t::value_type s)
253{
254 typedef typename vector_t::size_type size_type;
255 for(size_type i = 0; i < vOut.size(); ++i)
256 {
257 vOut[i] = s * v[i];
258 }
259}
260
262template <typename vector_t>
263inline
264void
265VecScaleAdd(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
266 typename vector_t::value_type s2, const vector_t& v2)
267{
268 typedef typename vector_t::size_type size_type;
269 for(size_type i = 0; i < vOut.size(); ++i)
270 {
271 vOut[i] = s1 * v1[i] + s2 * v2[i];
272 }
273}
274
276template <typename vector_t>
277inline
278void
279VecScaleAdd(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
280 typename vector_t::value_type s2, const vector_t& v2,
281 typename vector_t::value_type s3, const vector_t& v3)
282{
283 typedef typename vector_t::size_type size_type;
284 for(size_type i = 0; i < vOut.size(); ++i)
285 {
286 vOut[i] = s1 * v1[i] + s2 * v2[i] + s3 * v3[i];
287 }
288}
289
291template <typename vector_t>
292inline
293void
294VecScaleAdd(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
295 typename vector_t::value_type s2, const vector_t& v2,
296 typename vector_t::value_type s3, const vector_t& v3,
297 typename vector_t::value_type s4, const vector_t& v4)
298{
299 typedef typename vector_t::size_type size_type;
300 for(size_type i = 0; i < vOut.size(); ++i)
301 {
302 vOut[i] = s1 * v1[i] + s2 * v2[i] + s3 * v3[i] + s4 * v4[i];
303 }
304}
305
306// performs linear interpolation between two MathVector<N>s.
307template <typename vector_t>
308inline
309void
310VecInterpolateLinear(vector_t& vOut, const vector_t& v1, const vector_t& v2,
311 typename vector_t::value_type interpAmount)
312{
313 typedef typename vector_t::size_type size_type;
314 for(size_type i = 0; i < vOut.size(); ++i)
315 {
316 vOut[i] = (1. - interpAmount) * v1[i] + interpAmount * v2[i];
317 }
318}
319
321template <typename vector_t>
322inline
323typename vector_t::value_type
324VecLengthSq(const vector_t& v)
325{
326 typename vector_t::value_type len = 0;
327 typedef typename vector_t::size_type size_type;
328
329 for(size_type i = 0; i < v.size(); ++i)
330 {
331 len += v[i] * v[i];
332 }
333
334 return len;
335}
336
338template <typename vector_t>
339inline
340typename vector_t::value_type
341VecLength(const vector_t& v)
342{
343 return static_cast<typename vector_t::value_type>(
344 std::sqrt(VecLengthSq(v)));
345}
346
348template <typename vector_t>
349inline
350typename vector_t::value_type
351VecDistanceSq(const vector_t& v1, const vector_t& v2)
352{
353 vector_t v;
354 VecSubtract(v, v1, v2);
355 return VecLengthSq(v);
356}
357
359template <typename TVector, typename TMatrix>
360inline
361typename TVector::value_type
362VecDistanceSq(const TVector& v1, const TVector& v2, const TMatrix& M)
363{
364 TVector delta;
365 TVector deltaM;
366 VecSubtract(delta, v1, v2);
367 MatVecMult(deltaM, M, delta);
368 return VecDot(deltaM, delta);
369}
370
372template <typename vector_t>
373inline
374typename vector_t::value_type
375VecDistance(const vector_t& v1, const vector_t& v2)
376{
377 return static_cast<typename vector_t::value_type>
378 (std::sqrt(VecDistanceSq(v1, v2)));
379}
380
382template <typename vector_t>
383inline
384typename vector_t::value_type
385VecDot(const vector_t& v1, const vector_t& v2)
386{
387 typename vector_t::value_type dp = 0;
388 typedef typename vector_t::size_type size_type;
389
390 for(size_type i = 0; i < v1.size(); ++i)
391 {
392 dp += v1[i] * v2[i];
393 }
394
395 return dp;
396}
397
398template <typename vector_t>
399inline
400typename vector_t::value_type
401VecAngle(const vector_t& v1, const vector_t& v2)
402{
403 typedef typename vector_t::value_type value_t;
404
405 value_t l = sqrt(VecLengthSq(v1) * VecLengthSq(v2));
406 if(l > 0){
407 number a = VecDot(v1, v2) / l;
408 if(a >= 1)
409 return 0;
410 else if(a <= -1)
411 return PI;
412 return acos(a);
413 }
414
415 return 0;
416}
417
418template <typename vector_t>
419inline
420typename vector_t::value_type
421VecAngleNorm(const vector_t& v1, const vector_t& v2)
422{
423 number a = VecDot(v1, v2);
424 if(a >= 1)
425 return 0;
426 else if(a <= -1)
427 return PI;
428 return acos(a);
429}
430
434template <typename vector_t>
435inline
436void
437VecCross(vector_t& vOut, const vector_t& v1, const vector_t& v2)
438{
439 if(&vOut != &v1 && &vOut != &v2)
440 {
441 vOut[0] = v1[1] * v2[2] - v2[1] * v1[2];
442 vOut[1] = v1[2] * v2[0] - v2[2] * v1[0];
443 vOut[2] = v1[0] * v2[1] - v2[0] * v1[1];
444 }
445 else
446 {
447 vector_t _temp;
448 _temp[0] = v1[1] * v2[2] - v2[1] * v1[2];
449 _temp[1] = v1[2] * v2[0] - v2[2] * v1[0];
450 _temp[2] = v1[0] * v2[1] - v2[0] * v1[1];
451 vOut = _temp;
452 }
453}
454
463template <size_t dim>
464inline void GenVecCross
465(
466 MathVector<dim> & result,
467 const MathVector<dim> & v_1, const MathVector<dim> & v_2
468)
469{
470 /* Cf. the specializations below! */
471 UG_THROW ("The generalized vector product is defined only in 2 and 3 dimensions");
472};
473
475template <>
476inline void GenVecCross<2>
477(
478 MathVector<2> & result,
479 const MathVector<2> & v_1, const MathVector<2> & v_2
480)
481{
482 result[0] = v_1[0] * v_2[1] - v_1[1] * v_2[0];
483 result[1] = 0;
484};
485
487template <>
488inline void GenVecCross<3>
489(
490 MathVector<3> & result,
491 const MathVector<3> & v_1, const MathVector<3> & v_2
492)
493{
494 VecCross (result, v_1, v_2);
495};
496
498template <typename vector_t>
499inline
500void
501VecNormalize(vector_t& vOut, const vector_t& v)
502{
503 typename vector_t::value_type len = VecLength(v);
504 if(len > 0)
505 VecScale(vOut, v, (typename vector_t::value_type) 1 / len);
506 else
507 vOut = v;
508}
509
511template <typename vector_t>
512inline
513void
514CalculateTriangleNormalNoNormalize(vector_t& vOut, const vector_t& v1,
515 const vector_t& v2, const vector_t& v3)
516{
517 vector_t e1, e2;
518 VecSubtract(e1, v2, v1);
519 VecSubtract(e2, v3, v1);
520
521 VecCross(vOut, e1, e2);
522}
523
525template <typename vector_t>
526inline
527void
528CalculateTriangleNormal(vector_t& vOut, const vector_t& v1,
529 const vector_t& v2, const vector_t& v3)
530{
531 CalculateTriangleNormalNoNormalize(vOut, v1, v2, v3);
532 VecNormalize(vOut, vOut);
533}
534
536template <typename vector_t>
537inline
538void
539VecSet(vector_t& vInOut, typename vector_t::value_type s)
540{
541 typedef typename vector_t::size_type size_type;
542 for(size_type i = 0; i < vInOut.size(); ++i)
543 {
544 vInOut[i] = s;
545 }
546}
547
549template <typename vector_t>
550inline
551void
552VecAdd(vector_t& vOut, const vector_t& v, typename vector_t::value_type s)
553{
554 typedef typename vector_t::size_type size_type;
555 for(size_type i = 0; i < vOut.size(); ++i)
556 {
557 vOut[i] = v[i] + s;
558 }
559}
560
562template <typename vector_t>
563inline
564void
565VecSubtract(vector_t& vOut, const vector_t& v, typename vector_t::value_type s)
566{
567 typedef typename vector_t::size_type size_type;
568 for(size_type i = 0; i < vOut.size(); ++i)
569 {
570 vOut[i] = v[i] - s;
571 }
572}
573
574template <typename vector_t>
575inline
576typename vector_t::value_type
577VecTwoNorm(const vector_t& v)
578{
579 return VecLength(v);
580}
581
582template <typename vector_t>
583inline
584typename vector_t::value_type
585VecTwoNormSq(const vector_t& v)
586{
587 return VecLengthSq(v);
588}
589
590template <typename vector_t>
591inline
592typename vector_t::value_type
593VecOneNorm(const vector_t& v)
594{
595 typename vector_t::value_type len = 0;
596 typedef typename vector_t::size_type size_type;
597
598 for(size_type i = 0; i < v.size(); ++i)
599 {
600 len += std::abs(v[i]);
601 }
602
603 return len;
604}
605
606template <typename vector_t>
607inline
608typename vector_t::value_type
609VecPNorm(const vector_t& v, unsigned int p)
610{
611 typename vector_t::value_type len = 0;
612 typedef typename vector_t::size_type size_type;
613
614 for(size_type i = 0; i < v.size(); ++i)
615 {
616 len += std::pow(v[i], p);
617 }
618
619 return std::pow(len, (typename vector_t::value_type) 1/ p);
620}
621
622template <typename vector_t>
623inline
624typename vector_t::value_type
625VecMaxNorm(const vector_t& v)
626{
627 typename vector_t::value_type m = 0;
628 typedef typename vector_t::size_type size_type;
629
630 for(size_type i = 0; i < v.size(); ++i)
631 {
632 m = std::max(m, v[i]);
633 }
634
635 return m;
636}
637
638template <typename vector_t>
639inline
640typename vector_t::value_type
641VecInftyNorm(const vector_t& v)
642{
643 return VecMaxNorm(v);
644}
645
646
648template <typename vector_t>
649inline
650void
651VecElemProd(vector_t& vOut, const vector_t& v1, const vector_t& v2)
652{
653 typedef typename vector_t::size_type size_type;
654 for(size_type i = 0; i < vOut.size(); ++i)
655 {
656 vOut[i] = v1[i] * v2[i];
657 }
658}
659
661template <typename vector_t>
662inline
663void
664VecElemSqrt(vector_t& vOut, const vector_t& v1)
665{
666 typedef typename vector_t::size_type size_type;
667 for(size_type i = 0; i < vOut.size(); ++i)
668 {
669 vOut[i] = sqrt(v1[i]);
670 }
671}
672
674template <typename vector_t>
675inline
676bool
677VecAbsIsLess(const vector_t& v1, const vector_t& v2)
678{
679 for(typename vector_t::size_type i = 0; i < v1.size(); ++i)
680 if (std::abs (v1[i]) >= std::abs (v2[i]))
681 return false;
682 return true;
683}
684
686template <typename vector_t>
687inline
688bool
689VecAbsIsLess(const vector_t& v1, const typename vector_t::value_type s)
690{
691 for(typename vector_t::size_type i = 0; i < v1.size(); ++i)
692 if (std::abs (v1[i]) >= s)
693 return false;
694 return true;
695}
696
698template <typename vector_t>
699inline
700bool
701VecIsInBB(const vector_t& v, const vector_t& low, const vector_t& high)
702{
703 for(typename vector_t::size_type i = 0; i < v.size(); ++i)
704 if (v[i] < low[i] || high[i] < v[i])
705 return false;
706 return true;
707}
708
709}// end of namespace
710
711#endif /* __H__COMMON__MathVector_FUNCTIONS_COMMON_IMPL__ */
712
parameterString p
parameterString s
a mathematical Vector with N entries.
Definition math_vector.h:97
function util fill(N, c)
#define UG_THROW(msg)
Definition error.h:57
double number
Definition types.h:124
void MatVecMult(vector_t_out &vOut, const matrix_t &m, const vector_t_in &v)
Matrix - Vector Multiplication.
Definition math_matrix_vector_functions_common_impl.hpp:49
vector_t::value_type VecLength(const vector_t &v)
returns the length of v. Slower than VecLengthSq.
Definition math_vector_functions_common_impl.hpp:341
void VecScaleAppend(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1)
Scales a Vector and adds it to a second vector.
Definition math_vector_functions_common_impl.hpp:126
void VecCopy(vector_target_t &target, const vector_source_t &source, typename vector_target_t::value_type fill)
Copy contents between vectors of possibly different types.
Definition math_vector_functions_common_impl.hpp:56
vector_t::value_type VecMaxNorm(const vector_t &v)
Definition math_vector_functions_common_impl.hpp:625
void GenVecCross(MathVector< dim > &result, const MathVector< dim > &v_1, const MathVector< dim > &v_2)
calculates the usual cross product in 3d, and the (det, 0) vector as a cross product in 2d
Definition math_vector_functions_common_impl.hpp:465
void VecSet(vector_t &vInOut, typename vector_t::value_type s)
Set each vector component to scalar (componentwise)
Definition math_vector_functions_common_impl.hpp:539
void VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition math_vector_functions_common_impl.hpp:265
vector_t::value_type VecTwoNormSq(const vector_t &v)
Definition math_vector_functions_common_impl.hpp:585
vector_t::value_type VecOneNorm(const vector_t &v)
Definition math_vector_functions_common_impl.hpp:593
void VecNormalize(vector_t &vOut, const vector_t &v)
scales a vector_t to unit length
Definition math_vector_functions_common_impl.hpp:501
void CalculateTriangleNormalNoNormalize(vector_t &vOut, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Calculates a triangle-normal in 3d (no normalization is performed).
Definition math_vector_functions_common_impl.hpp:514
void VecSubtract(vector_t &vOut, const vector_t &v1, const vector_t &v2)
subtracts v2 from v1 and stores the result in a vOut
Definition math_vector_functions_common_impl.hpp:226
vector_t::value_type VecAngle(const vector_t &v1, const vector_t &v2)
returns the angle between two vectors in radiants
Definition math_vector_functions_common_impl.hpp:401
vector_t::value_type VecDistanceSq(const vector_t &v1, const vector_t &v2)
returns the squared distance of two vector_ts.
Definition math_vector_functions_common_impl.hpp:351
void CalculateTriangleNormal(vector_t &vOut, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Calculates a triangle-normal in 3d (output has length 1).
Definition math_vector_functions_common_impl.hpp:528
void VecAppend(vector_t &vOut, const vector_t &v1)
adds a MathVector<N> to a second one
Definition math_vector_functions_common_impl.hpp:72
vector_t::value_type VecLengthSq(const vector_t &v)
returns the squared length of v. Faster than VecLength.
Definition math_vector_functions_common_impl.hpp:324
vector_t::value_type VecDistance(const vector_t &v1, const vector_t &v2)
returns the distance of two vector_ts.
Definition math_vector_functions_common_impl.hpp:375
void VecAdd(vector_t &vOut, const vector_t &v1, const vector_t &v2)
adds two MathVector<N>s and stores the result in a third one
Definition math_vector_functions_common_impl.hpp:185
void VecScale(vector_t &vOut, const vector_t &v, typename vector_t::value_type s)
scales a MathVector<N>
Definition math_vector_functions_common_impl.hpp:252
vector_t::value_type VecTwoNorm(const vector_t &v)
Definition math_vector_functions_common_impl.hpp:577
void VecCross(vector_t &vOut, const vector_t &v1, const vector_t &v2)
calculates the cross product of two Vectors of dimension 3. It makes no sense to use VecCross for vec...
Definition math_vector_functions_common_impl.hpp:437
void VecPow(vector_t &vOut, const vector_t &v1, typename vector_t::value_type s)
component-wise exponentiation of a vector
Definition math_vector_functions_common_impl.hpp:239
vector_t::value_type VecAngleNorm(const vector_t &v1, const vector_t &v2)
returns the angle between two vectors of length 1 in radiants
Definition math_vector_functions_common_impl.hpp:421
void VecInterpolateLinear(vector_t &vOut, const vector_t &v1, const vector_t &v2, typename vector_t::value_type interpAmount)
Definition math_vector_functions_common_impl.hpp:310
vector_t::value_type VecDot(const vector_t &v1, const vector_t &v2)
returns the dot-product of two vector_ts
Definition math_vector_functions_common_impl.hpp:385
vector_t::value_type VecInftyNorm(const vector_t &v)
Definition math_vector_functions_common_impl.hpp:641
vector_t::value_type VecPNorm(const vector_t &v, unsigned int p)
Definition math_vector_functions_common_impl.hpp:609
the ug namespace
bool VecIsInBB(const vector_t &v, const vector_t &low, const vector_t &high)
checks if the given point is in the bounding box given by two other points
Definition math_vector_functions_common_impl.hpp:701
const number PI
Definition math_constants.h:45
void GenVecCross< 2 >(MathVector< 2 > &result, const MathVector< 2 > &v_1, const MathVector< 2 > &v_2)
specialization of the "generalized vector product" in 2d.
Definition math_vector_functions_common_impl.hpp:477
void GenVecCross< 3 >(MathVector< 3 > &result, const MathVector< 3 > &v_1, const MathVector< 3 > &v_2)
specialization of the "generalized vector product" in 3d.
Definition math_vector_functions_common_impl.hpp:489
void VecElemProd(vector_t &vOut, const vector_t &v1, const vector_t &v2)
component-wise product: vOut_i = v1_i*v2_i
Definition math_vector_functions_common_impl.hpp:651
bool VecAbsIsLess(const vector_t &v1, const vector_t &v2)
component-wise comparison of two vectors (in the absolute values)
Definition math_vector_functions_common_impl.hpp:677
void VecElemSqrt(vector_t &vOut, const vector_t &v1)
component-wise square root:
Definition math_vector_functions_common_impl.hpp:664