diff options
-rw-r--r-- | test.cc | 2 | ||||
-rw-r--r-- | vec_base.h | 6 | ||||
-rw-r--r-- | vec_double_avx.h | 5 | ||||
-rw-r--r-- | vec_double_qpx.h | 5 | ||||
-rw-r--r-- | vec_double_sse2.h | 5 | ||||
-rw-r--r-- | vec_double_sse2_scalar.h | 2 | ||||
-rw-r--r-- | vec_double_vsx.h | 5 | ||||
-rw-r--r-- | vec_float_altivec.h | 5 | ||||
-rw-r--r-- | vec_float_avx.h | 5 | ||||
-rw-r--r-- | vec_float_sse2.h | 5 | ||||
-rw-r--r-- | vec_float_sse2_scalar.h | 5 | ||||
-rw-r--r-- | vec_pseudo.h | 13 | ||||
-rw-r--r-- | vec_test.h | 13 |
13 files changed, 76 insertions, 0 deletions
@@ -887,6 +887,7 @@ struct vecmathlib_test { template<typename T> static T local_sr(T x, T y) { return x>>y; } template<typename T> static T local_sl(T x, T y) { return x<<y; } + template<typename T> static bool local_signbit(T x) { return x<0; } template<typename T> static bool local_eq(T x, T y) { return x==y; } template<typename T> static bool local_ne(T x, T y) { return x!=y; } template<typename T> static bool local_lt(T x, T y) { return x<y; } @@ -967,6 +968,7 @@ struct vecmathlib_test { check_int<IV,IV>(">>", local_sr, local_sr, x, y & IV(bits-1)); check_int<IV,IV>("<<", local_sl, local_sl, x, y & IV(bits-1)); + check_bool<IV>("signbit", local_signbit, vecmathlib::signbit, x); check_bool<IV,IV>("==", local_eq, local_veq, x, y); check_bool<IV,IV>("!=", local_ne, local_vne, x, y); check_bool<IV,IV>("<", local_lt, local_vlt, x, y); @@ -105,6 +105,12 @@ namespace vecmathlib { return x.lsr(n); } + template<typename real_t, int size> + inline boolvec<real_t, size> signbit(intvec<real_t, size> x) + { + return x.signbit(); + } + // realvec wrappers diff --git a/vec_double_avx.h b/vec_double_avx.h index e4c092a..1ec8376 100644 --- a/vec_double_avx.h +++ b/vec_double_avx.h @@ -317,6 +317,11 @@ namespace vecmathlib { + boolvec_t signbit() const + { + return as_bool(); + } + boolvec_t operator==(intvec const& x) const { return ! (*this != x); diff --git a/vec_double_qpx.h b/vec_double_qpx.h index c88dab7..e4d14a2 100644 --- a/vec_double_qpx.h +++ b/vec_double_qpx.h @@ -292,6 +292,11 @@ namespace vecmathlib { + boolvec_t signbit() const + { + return *this < IV(I(0)); + } + boolvec_t operator==(intvec const& x) const { boolvec_t r; diff --git a/vec_double_sse2.h b/vec_double_sse2.h index 1a16758..81e9d46 100644 --- a/vec_double_sse2.h +++ b/vec_double_sse2.h @@ -273,6 +273,11 @@ namespace vecmathlib { + boolvec_t signbit() const + { + return as_bool(); + } + boolvec_t operator==(intvec const& x) const { return ! (*this != x); diff --git a/vec_double_sse2_scalar.h b/vec_double_sse2_scalar.h index 16e6c04..4c3b4b6 100644 --- a/vec_double_sse2_scalar.h +++ b/vec_double_sse2_scalar.h @@ -203,6 +203,8 @@ namespace vecmathlib { + boolvec_t signbit() const { return *this < IV(I(0)); } + boolvec_t operator==(intvec const& x) const { return v==x.v; } boolvec_t operator!=(intvec const& x) const { return v!=x.v; } boolvec_t operator<(intvec const& x) const { return v<x.v; } diff --git a/vec_double_vsx.h b/vec_double_vsx.h index 67395d3..67b4b36 100644 --- a/vec_double_vsx.h +++ b/vec_double_vsx.h @@ -311,6 +311,11 @@ namespace vecmathlib { + boolvec_t signbit() const + { + return (*this >> (bits-1)).as_bool(); + } + boolvec_t operator==(intvec const& x) const { // return vec_cmpeq(v, x.v); diff --git a/vec_float_altivec.h b/vec_float_altivec.h index 6f2d3ac..1fdcbb4 100644 --- a/vec_float_altivec.h +++ b/vec_float_altivec.h @@ -209,6 +209,11 @@ namespace vecmathlib { + boolvec_t signbit() const + { + return *this < IV(I(0)); + } + boolvec_t operator==(intvec const& x) const { return vec_cmpeq(v, x.v); } boolvec_t operator!=(intvec const& x) const { return !(*this == x); } boolvec_t operator<(intvec const& x) const { return vec_cmplt(v, x.v); } diff --git a/vec_float_avx.h b/vec_float_avx.h index 2fbb219..bd4ef1f 100644 --- a/vec_float_avx.h +++ b/vec_float_avx.h @@ -305,6 +305,11 @@ namespace vecmathlib { + boolvec_t signbit() const + { + return as_bool(); + } + boolvec_t operator==(intvec const& x) const { return ! (*this != x); diff --git a/vec_float_sse2.h b/vec_float_sse2.h index 27a604c..86a4708 100644 --- a/vec_float_sse2.h +++ b/vec_float_sse2.h @@ -259,6 +259,11 @@ namespace vecmathlib { + boolvec_t signbit() const + { + return as_bool(); + } + boolvec_t operator==(intvec const& x) const { return ! (*this != x); diff --git a/vec_float_sse2_scalar.h b/vec_float_sse2_scalar.h index 3e35fdd..8dcb5b4 100644 --- a/vec_float_sse2_scalar.h +++ b/vec_float_sse2_scalar.h @@ -203,6 +203,11 @@ namespace vecmathlib { + boolvec_t signbit() const + { + return *this < IV(I(0)); + } + boolvec_t operator==(intvec const& x) const { return v==x.v; } boolvec_t operator!=(intvec const& x) const { return v!=x.v; } boolvec_t operator<(intvec const& x) const { return v<x.v; } diff --git a/vec_pseudo.h b/vec_pseudo.h index 3bacd9d..09de4a5 100644 --- a/vec_pseudo.h +++ b/vec_pseudo.h @@ -355,6 +355,13 @@ namespace vecmathlib { + boolvec_t signbit() const + { + boolvec_t res; + for (int d=0; d<size; ++d) res.set_elt(d, v[d] < 0); + return res; + } + boolvec_t operator==(intpseudovec const& x) const { boolvec_t res; @@ -918,6 +925,12 @@ namespace vecmathlib { return x.lsr(n); } + template<typename real_t, int size> + inline boolpseudovec<real_t, size> signbit(intpseudovec<real_t, size> x) + { + return x.signbit(); + } + // realpseudovec wrappers @@ -349,6 +349,13 @@ namespace vecmathlib { + boolvec_t signbit() const + { + boolvec_t res; + for (int d=0; d<size; ++d) res.set_elt(d, v[d] < 0); + return res; + } + boolvec_t operator==(inttestvec const& x) const { boolvec_t res; @@ -852,6 +859,12 @@ namespace vecmathlib { return x.lsr(n); } + template<typename real_t, int size> + inline booltestvec<real_t, size> signbit(inttestvec<real_t, size> x) + { + return x.signbit(); + } + // realtestvec wrappers |