summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test.cc2
-rw-r--r--vec_base.h6
-rw-r--r--vec_double_avx.h5
-rw-r--r--vec_double_qpx.h5
-rw-r--r--vec_double_sse2.h5
-rw-r--r--vec_double_sse2_scalar.h2
-rw-r--r--vec_double_vsx.h5
-rw-r--r--vec_float_altivec.h5
-rw-r--r--vec_float_avx.h5
-rw-r--r--vec_float_sse2.h5
-rw-r--r--vec_float_sse2_scalar.h5
-rw-r--r--vec_pseudo.h13
-rw-r--r--vec_test.h13
13 files changed, 76 insertions, 0 deletions
diff --git a/test.cc b/test.cc
index 5a7a9f8..d26ad6c 100644
--- a/test.cc
+++ b/test.cc
@@ -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);
diff --git a/vec_base.h b/vec_base.h
index 5908026..ee7864a 100644
--- a/vec_base.h
+++ b/vec_base.h
@@ -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
diff --git a/vec_test.h b/vec_test.h
index f05115f..bbcaadb 100644
--- a/vec_test.h
+++ b/vec_test.h
@@ -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
OpenPOWER on IntegriCloud