diff options
author | schnetter <> | 2004-02-18 14:10:00 +0000 |
---|---|---|
committer | schnetter <> | 2004-02-18 14:10:00 +0000 |
commit | ae39a590322624742c090d21d71afce4bd053a81 (patch) | |
tree | 643212e6bb18e4b3c5eba5e127776facb0508b18 | |
parent | 4dab789bbe10a9d86c61af1986c1a34e0dfcec23 (diff) |
Add functions for element-wise floor, ceil, and pow.
darcs-hash:20040218141045-07bb3-0e60f56d44aa61e0e3190d5d27b9a0bfab3f2d38.gz
-rw-r--r-- | Carpet/CarpetLib/src/vect.hh | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/Carpet/CarpetLib/src/vect.hh b/Carpet/CarpetLib/src/vect.hh index 1df8f874c..4d82b6c43 100644 --- a/Carpet/CarpetLib/src/vect.hh +++ b/Carpet/CarpetLib/src/vect.hh @@ -1,11 +1,12 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.hh,v 1.22 2004/01/25 14:57:30 schnetter Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.hh,v 1.23 2004/02/18 15:10:45 schnetter Exp $ #ifndef VECT_HH #define VECT_HH #include <assert.h> -#include <math.h> +#include <algorithm> +#include <cmath> #include <iostream> using namespace std; @@ -531,6 +532,22 @@ inline vect<T,D> abs (const vect<T,D>& a) { return r; } +/** Return the element-wise ceiling. */ +template<class T,int D> +inline vect<T,D> ceil (const vect<T,D>& a) { + vect<T,D> r; + for (int d=0; d<D; ++d) r[d]=ceil(a[d]); + return r; +} + +/** Return the element-wise floor. */ +template<class T,int D> +inline vect<T,D> floor (const vect<T,D>& a) { + vect<T,D> r; + for (int d=0; d<D; ++d) r[d]=floor(a[d]); + return r; +} + /** Return the element-wise maximum of two vectors. */ template<class T,int D> inline vect<T,D> max (const vect<T,D>& a, const vect<T,D>& b) { @@ -547,6 +564,14 @@ inline vect<T,D> min (const vect<T,D>& a, const vect<T,D>& b) { return r; } +/** Return the element-wise power of two vectors. */ +template<class T,class U,int D> +inline vect<T,D> pow (const vect<T,D>& a, const vect<U,D>& b) { + vect<T,D> r; + for (int d=0; d<D; ++d) r[d]=pow(a[d],b[d]); + return r; +} + // Reduction operators |