From ae370822f291af84098b7d56721fa25b38b70a8b Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 1 Sep 2013 23:45:23 -0400 Subject: Implement more integer functions: abs bitifthen clz isignbit max min popcount rotate Rename integer signbit to isignbit to avoid name conflicts. --- vec_pseudo.h | 200 +++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 166 insertions(+), 34 deletions(-) (limited to 'vec_pseudo.h') diff --git a/vec_pseudo.h b/vec_pseudo.h index f079bdb..9e2d1e0 100644 --- a/vec_pseudo.h +++ b/vec_pseudo.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -185,7 +186,7 @@ namespace vecmathlib { { // Result: convert_bool(0)=false, convert_bool(else)=true boolvec_t res; - for (int d=0; d> U(n)); return res; } + intvec_t rotate(int_t n) const; intpseudovec& operator>>=(int_t n) { for (int d=0; d>= n; @@ -328,12 +332,13 @@ namespace vecmathlib { return res <<= n; } - intpseudovec lsr(intpseudovec n) const + intvec_t lsr(intvec_t n) const { - intpseudovec res; + intvec_t res; for (int d=0; d> U(n.v[d])); return res; } + intvec_t rotate(intvec_t n) const; intpseudovec& operator>>=(intpseudovec n) { for (int d=0; d>= n.v[d]; @@ -355,49 +360,101 @@ namespace vecmathlib { return res <<= n; } - - - boolvec_t signbit() const + intvec_t clz() const { - boolvec_t res; - for (int d=0; d(intpseudovec const& x) const { boolvec_t res; - for (int d=0; d x.v[d]); + for (int d=0; d x.v[d]; return res; } boolvec_t operator>=(intpseudovec const& x) const { boolvec_t res; - for (int d=0; d= x.v[d]); + for (int d=0; d= x.v[d]; + return res; + } + + intvec_t abs() const + { + intvec_t res; + for (int d=0; d(realpseudovec const& x) const { boolvec_t res; - for (int d=0; d x.v[d]); + for (int d=0; d x.v[d]; return res; } boolvec_t operator>=(realpseudovec const& x) const { boolvec_t res; - for (int d=0; d= x.v[d]); + for (int d=0; d= x.v[d]; return res; } @@ -912,6 +969,13 @@ namespace vecmathlib { template inline + intpseudovec intpseudovec::bitifthen(intvec_t x, intvec_t y) const + { + return MF::vml_bitifthen(*this, x, y); + } + + template + inline typename intpseudovec::realvec_t intpseudovec::convert_float() const { realvec_t res; @@ -919,6 +983,18 @@ namespace vecmathlib { return res; } + template + inline intpseudovec intpseudovec::rotate(int_t n) const + { + return MF::vml_rotate(*this, n); + } + + template + inline intpseudovec intpseudovec::rotate(intvec_t n) const + { + return MF::vml_rotate(*this, n); + } + // Wrappers @@ -975,15 +1051,15 @@ namespace vecmathlib { // intpseudovec wrappers template - inline boolpseudovec as_bool(intpseudovec x) + inline intpseudovec abs(intpseudovec x) { - return x.as_bool(); + return x.abs(); } template - inline boolpseudovec convert_bool(intpseudovec x) + inline boolpseudovec as_bool(intpseudovec x) { - return x.convert_bool(); + return x.as_bool(); } template @@ -993,12 +1069,38 @@ namespace vecmathlib { } template + inline intpseudovec bitifthen(intpseudovec x, + intpseudovec y, + intpseudovec z) + { + return x.bitifthen(y, z); + } + + template + inline intpseudovec clz(intpseudovec x) + { + return x.clz(); + } + + template + inline boolpseudovec convert_bool(intpseudovec x) + { + return x.convert_bool(); + } + + template inline realpseudovec convert_float(intpseudovec x) { return x.convert_float(); } template + inline boolpseudovec isignbit(intpseudovec x) + { + return x.isignbit(); + } + + template inline intpseudovec lsr(intpseudovec x, typename intpseudovec::int_t n) @@ -1014,9 +1116,39 @@ namespace vecmathlib { } template - inline boolpseudovec signbit(intpseudovec x) + inline intpseudovec max(intpseudovec x, + intpseudovec y) { - return x.signbit(); + return x.max(y); + } + + template + inline intpseudovec min(intpseudovec x, + intpseudovec y) + { + return x.min(y); + } + + template + inline intpseudovec popcount(intpseudovec x) + { + return x.popcount(); + } + + template + inline + intpseudovec rotate(intpseudovec x, + typename + intpseudovec::int_t n) + { + return x.rotate(n); + } + + template + inline intpseudovec rotate(intpseudovec x, + intpseudovec n) + { + return x.rotate(n); } -- cgit v1.1