aboutsummaryrefslogtreecommitdiff
path: root/Carpet
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2007-01-12 20:55:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2007-01-12 20:55:00 +0000
commit3c4993dd3e36426d62cbf8e574cba9ec6cf2ec89 (patch)
tree4557ac69688e85200764e0af9ef31b5ae7c1bc93 /Carpet
parent46b7adb8ce67d530d807293109b1759662a1ffa4 (diff)
CarpetLib: Updates to vect class
Add some new functions to make the vect class more convenient. Remove some unused functions. Instantiate some more templates. darcs-hash:20070112205505-dae7b-12a0ea160b9740cdbe60d89d9e9100fc06a1faa7.gz
Diffstat (limited to 'Carpet')
-rw-r--r--Carpet/CarpetLib/src/vect.cc1
-rw-r--r--Carpet/CarpetLib/src/vect.hh45
2 files changed, 45 insertions, 1 deletions
diff --git a/Carpet/CarpetLib/src/vect.cc b/Carpet/CarpetLib/src/vect.cc
index 42bb5f725..e42ba04aa 100644
--- a/Carpet/CarpetLib/src/vect.cc
+++ b/Carpet/CarpetLib/src/vect.cc
@@ -50,6 +50,7 @@ template class vect<int,3>;
template void vect<CCTK_REAL,3>::input (istream& is);
template void vect<vect<bool,2>,3>::input (istream& is);
+template void vect<vect<bool,3>,2>::input (istream& is);
template void vect<bool,2>::output (ostream& os) const;
template void vect<bool,3>::output (ostream& os) const;
diff --git a/Carpet/CarpetLib/src/vect.hh b/Carpet/CarpetLib/src/vect.hh
index f58f1e07b..17c75b2b2 100644
--- a/Carpet/CarpetLib/src/vect.hh
+++ b/Carpet/CarpetLib/src/vect.hh
@@ -545,12 +545,23 @@ inline vect<T,D> either (const vect<S,D>& a,
const vect<T,D>& b, const vect<T,D>& c) PURE;
template<typename S,typename T,int D>
inline vect<T,D> either (const vect<S,D>& a,
- const vect<T,D>& b, const vect<T,D>& c) {
+ const vect<T,D>& b, const vect<T,D>& c)
+{
vect<T,D> r;
for (int d=0; d<D; ++d) r[d]=a[d]?b[d]:c[d];
return r;
}
+template<typename S,typename T,int D>
+inline vect<T,D> either (const vect<S,D>& a,
+ const T& b, const T& c) PURE;
+template<typename S,typename T,int D>
+inline vect<T,D> either (const vect<S,D>& a,
+ const T& b, const T& c)
+{
+ return either (a, vect<T,D>(b), vect<T,D>(c));
+}
+
/** Transpose a vector of a vector */
template<typename T, int D, int DD>
inline vect<vect<T,D>,DD> xpose (vect<vect<T,DD>,D> const & a) PURE;
@@ -1171,6 +1182,9 @@ inline T sum (const vect<T,D>& a) {
// Higher order functions
+#if 0
+// They are rarely used, so disable them
+
/** Return a new vector where the function func() has been applied to
all elements. */
template<typename T, typename U, int D>
@@ -1238,6 +1252,7 @@ inline vect<U,D> scan1 (U (* const func)(U val, T x), U val,
}
return r;
}
+#endif
@@ -1291,6 +1306,34 @@ vect (const T& x, const T& y, const T& z, const T& t) {
+////////////////////////////////////////////////////////////////////////////////
+
+// Special versions for vect<vect>
+
+template<typename T,int D,int E>
+inline vect<vect<bool,D>,E> operator== (const vect<vect<T,D>,E>& a, const vect<vect<T,D>,E>& b) PURE;
+template<typename T,int D,int E>
+inline vect<vect<bool,D>,E> operator== (const vect<vect<T,D>,E>& a, const vect<vect<T,D>,E>& b) {
+ vect<vect<bool,D>,E> r;
+ for (int e=0; e<E; ++e) r[e]=a[e]==b[e];
+ return r;
+}
+
+/** Return true iff all of the elements are true (boolean product). */
+template<int D,int E>
+inline vect<bool,E> all (const vect<vect<bool,D>,E>& a) PURE;
+template<int D,int E>
+inline vect<bool,E> all (const vect<vect<bool,D>,E>& a) {
+ vect<bool,E> r;
+ for (int e=0; e<E; ++e) r[e]=all(a[e]);
+ return r;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+
// Specialise some constructors for lower dimensions
// These functions are declared, but never defined, so that using them
// will result in a linker error