summaryrefslogtreecommitdiffstats
path: root/vec_test.h
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-07-07 15:55:45 -0400
committerErik Schnetter <schnetter@gmail.com>2013-07-07 15:55:45 -0400
commit308259ef14ea04b6888d372b2dbe65d48760b7a9 (patch)
tree07e45b0aee39af37ba8e90404ceb1c387ead1196 /vec_test.h
parenta505a64345a0d43e212bba31694f48790a5eac2f (diff)
downloadvecmathlib-308259ef14ea04b6888d372b2dbe65d48760b7a9.zip
vecmathlib-308259ef14ea04b6888d372b2dbe65d48760b7a9.tar.gz
Implement ifthen with boolvec arguments
Diffstat (limited to 'vec_test.h')
-rw-r--r--vec_test.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/vec_test.h b/vec_test.h
index f9678e0..e370157 100644
--- a/vec_test.h
+++ b/vec_test.h
@@ -116,6 +116,7 @@ namespace vecmathlib {
// ifthen(condition, then-value, else-value)
+ boolvec_t ifthen(boolvec_t x, boolvec_t y) const;
intvec_t ifthen(intvec_t x, intvec_t y) const; // defined after inttestvec
realvec_t ifthen(realvec_t x, realvec_t y) const; // defined after realtestvec
};
@@ -757,6 +758,16 @@ namespace vecmathlib {
template<typename T, int N>
inline
+ typename booltestvec<T,N>::boolvec_t
+ booltestvec<T,N>::ifthen(boolvec_t x, boolvec_t y) const
+ {
+ boolvec_t res;
+ for (int d=0; d<size; ++d) res.v[d] = v[d] ? x.v[d] : y.v[d];
+ return res;
+ }
+
+ template<typename T, int N>
+ inline
typename booltestvec<T,N>::intvec_t
booltestvec<T,N>::ifthen(intvec_t x, intvec_t y) const
{
@@ -821,6 +832,15 @@ namespace vecmathlib {
template<typename real_t, int size>
inline
+ booltestvec<real_t, size> ifthen(booltestvec<real_t, size> c,
+ booltestvec<real_t, size> x,
+ booltestvec<real_t, size> y)
+ {
+ return c.ifthen(x, y);
+ }
+
+ template<typename real_t, int size>
+ inline
inttestvec<real_t, size> ifthen(booltestvec<real_t, size> c,
inttestvec<real_t, size> x,
inttestvec<real_t, size> y)
OpenPOWER on IntegriCloud