diff options
author | schnetter <> | 2001-12-14 15:39:00 +0000 |
---|---|---|
committer | schnetter <> | 2001-12-14 15:39:00 +0000 |
commit | f78f6ff07a44eb285372f776c1d8de5db9be141b (patch) | |
tree | 8c04630d5a45413d436e224290387ac6a316e8f7 /Carpet/CarpetLib/src/vect.hh | |
parent | 326f9f5e459037c9c35d845ba699e7cfaacf65a5 (diff) |
Added a bit of convenient functionality.
Added a bit of convenient functionality.
Fixed a few bugs that were uncovered by dynamic regridding.
darcs-hash:20011214153941-07bb3-c31c15cec651b5c3c992f529b7409c081fda5ba8.gz
Diffstat (limited to 'Carpet/CarpetLib/src/vect.hh')
-rw-r--r-- | Carpet/CarpetLib/src/vect.hh | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/Carpet/CarpetLib/src/vect.hh b/Carpet/CarpetLib/src/vect.hh index 5905d14b9..00a31da04 100644 --- a/Carpet/CarpetLib/src/vect.hh +++ b/Carpet/CarpetLib/src/vect.hh @@ -5,7 +5,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.hh,v 1.5 2001/12/05 03:31:57 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.hh,v 1.6 2001/12/14 16:39:43 schnetter Exp $ ***************************************************************************/ @@ -505,7 +505,7 @@ template<class T,int D> inline T maxval (const vect<T,D>& a) { assert (D>0); T r(a[0]); - for (int d=0; d<D; ++d) r=max(r,a[d]); + for (int d=1; d<D; ++d) r=max(r,a[d]); return r; } @@ -513,7 +513,23 @@ template<class T,int D> inline T minval (const vect<T,D>& a) { assert (D>0); T r(a[0]); - for (int d=0; d<D; ++d) r=min(r,a[d]); + for (int d=1; d<D; ++d) r=min(r,a[d]); + return r; +} + +template<class T,int D> +inline int maxloc (const vect<T,D>& a) { + assert (D>0); + int r(0); + for (int d=1; d<D; ++d) if (a[d]>a[r]) r=d; + return r; +} + +template<class T,int D> +inline int minloc (const vect<T,D>& a) { + assert (D>0); + int r(0); + for (int d=1; d<D; ++d) if (a[d]<a[r]) r=d; return r; } |