aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib
diff options
context:
space:
mode:
authorschnetter <>2004-04-18 11:25:00 +0000
committerschnetter <>2004-04-18 11:25:00 +0000
commitdff0758214da7a2ca77e25695c5ed3e5395eff55 (patch)
treed93e46837ec28d241be3d387a2db522eed9c41a3 /Carpet/CarpetLib
parentabe5824e5ebba883098568ed48fe48a358243d99 (diff)
Handle operator% for double differently.
darcs-hash:20040418112556-07bb3-87cca0e1b0860665e56b2a729a06baba55fa5580.gz
Diffstat (limited to 'Carpet/CarpetLib')
-rw-r--r--Carpet/CarpetLib/src/vect.hh39
1 files changed, 17 insertions, 22 deletions
diff --git a/Carpet/CarpetLib/src/vect.hh b/Carpet/CarpetLib/src/vect.hh
index a8eef5ada..afd38de29 100644
--- a/Carpet/CarpetLib/src/vect.hh
+++ b/Carpet/CarpetLib/src/vect.hh
@@ -1,11 +1,10 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.hh,v 1.25 2004/03/11 12:04:13 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.hh,v 1.26 2004/04/18 13:25:56 schnetter Exp $
#ifndef VECT_HH
#define VECT_HH
-#include <assert.h>
-
#include <algorithm>
+#include <cassert>
#include <cmath>
#include <iostream>
@@ -24,18 +23,6 @@ ostream& operator<< (ostream& os, const vect<T,D>& a);
-template<typename T>
-struct integral {
- typedef T substitute;
-};
-
-template<>
-struct integral<double> {
- typedef int substitute;
-};
-
-
-
/**
* A short vector with a size that is specified at compile time.
*/
@@ -257,13 +244,7 @@ public:
}
vect& operator%=(const vect& a) {
- for (int d=0; d<D; ++d) {
-// elt[d]%=a[d];
- typename integral<T>::substitute se, sa;
- se = elt[d]; sa = a[d];
- se %= sa;
- elt[d] = se;
- }
+ for (int d=0; d<D; ++d) elt[d]%=a[d];
return *this;
}
@@ -764,4 +745,18 @@ inline ostream& operator<< (ostream& os, const vect<T,D>& a) {
+// Specialise for double
+
+template<>
+inline vect<double,3>& vect<double,3>::operator%=(const vect<double,3>& a) {
+ for (int d=0; d<3; ++d) {
+ elt[d]=fmod(elt[d],a[d]);
+ if (elt[d]>a[d]*double(1.0-1.0e-10)) elt[d]=double(0);
+ if (elt[d]<a[d]*double( 1.0e-10)) elt[d]=double(0);
+ }
+ return *this;
+}
+
+
+
#endif // VECT_HH