aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-05-20 09:05:04 -0500
committerErik Schnetter <schnetter@gmail.com>2013-05-20 09:05:04 -0500
commit1e86f8d4df69edd816f6de837343c852027e9d79 (patch)
tree0126b203702d545fefee171353ecf93ea305f38c /Carpet/CarpetLib
parentb441d66d16d0c81d83a7d52121f9f76b341b9262 (diff)
CarpetLib: Add constructors to create a vector from a low-dimensional vector and a scalar
Diffstat (limited to 'Carpet/CarpetLib')
-rw-r--r--Carpet/CarpetLib/src/vect.hh16
1 files changed, 16 insertions, 0 deletions
diff --git a/Carpet/CarpetLib/src/vect.hh b/Carpet/CarpetLib/src/vect.hh
index 8a1e1b6f8..142cabc15 100644
--- a/Carpet/CarpetLib/src/vect.hh
+++ b/Carpet/CarpetLib/src/vect.hh
@@ -53,6 +53,22 @@ public:
/** Explicit empty constructor. */
explicit vect () { }
+ /** Create a vector from a lower-dimensional vector. */
+ vect (const vect<T,D==0?0:D-1>& x, const T& a)
+ {
+ assert(D>0);
+ for (int d=0; d<D-1; ++d) elt[d]=x[d];
+ elt[D-1] = a;
+ }
+
+ /** Create a vector from a lower-dimensional vector. */
+ vect (const T& a, const vect<T,D==0?0:D-1>& x)
+ {
+ assert(D>0);
+ elt[0] = a;
+ for (int d=0; d<D-1; ++d) elt[d+1]=x[d];
+ }
+
/** Copy constructor. */
vect (const vect& a)
{