summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-09-02 23:01:06 -0400
committerErik Schnetter <schnetter@gmail.com>2013-09-02 23:01:06 -0400
commit3ceeb3729cf510ba5c27a1d90d0ff31d0e90c158 (patch)
tree47e7582ebda9c019f22cec1e1cff2011e0645b9d
parent46a79cb4547463b1f4b6269507954c68bd402d6b (diff)
downloadvecmathlib-3ceeb3729cf510ba5c27a1d90d0ff31d0e90c158.zip
vecmathlib-3ceeb3729cf510ba5c27a1d90d0ff31d0e90c158.tar.gz
SSE/AVX: Use nicer type names
-rw-r--r--vec_avx_double4.h232
-rw-r--r--vec_avx_float8.h217
-rw-r--r--vec_sse_double1.h215
-rw-r--r--vec_sse_double2.h207
-rw-r--r--vec_sse_float1.h215
-rw-r--r--vec_sse_float4.h214
6 files changed, 674 insertions, 626 deletions
diff --git a/vec_avx_double4.h b/vec_avx_double4.h
index 7460c12..adc8c48 100644
--- a/vec_avx_double4.h
+++ b/vec_avx_double4.h
@@ -77,7 +77,7 @@ namespace vecmathlib {
{
return to_bool(vecmathlib::get_elt<BV,bvector_t,uint_t>(v, n));
}
- boolvec& set_elt(int n, bool a)
+ boolvec_t& set_elt(int n, bool a)
{
return
vecmathlib::set_elt<BV,bvector_t,uint_t>(v, n, from_bool(a)), *this;
@@ -90,12 +90,12 @@ namespace vecmathlib {
- boolvec operator!() const { return _mm256_xor_pd(boolvec(true), v); }
+ boolvec_t operator!() const { return _mm256_xor_pd(boolvec(true), v); }
- boolvec operator&&(boolvec x) const { return _mm256_and_pd(v, x.v); }
- boolvec operator||(boolvec x) const { return _mm256_or_pd(v, x.v); }
- boolvec operator==(boolvec x) const { return !(*this!=x); }
- boolvec operator!=(boolvec x) const { return _mm256_xor_pd(v, x.v); }
+ boolvec_t operator&&(boolvec_t x) const { return _mm256_and_pd(v, x.v); }
+ boolvec_t operator||(boolvec_t x) const { return _mm256_or_pd(v, x.v); }
+ boolvec_t operator==(boolvec_t x) const { return !(*this!=x); }
+ boolvec_t operator!=(boolvec_t x) const { return _mm256_xor_pd(v, x.v); }
bool all() const
{
@@ -155,7 +155,7 @@ namespace vecmathlib {
intvec(ivector_t x): v(x) {}
intvec(int_t a): v(_mm256_set1_epi64x(a)) {}
intvec(int_t const* as): v(_mm256_set_epi64x(as[3], as[2], as[1], as[0])) {}
- static intvec iota() { return _mm256_set_epi64x(3, 2, 1, 0); }
+ static intvec_t iota() { return _mm256_set_epi64x(3, 2, 1, 0); }
operator ivector_t() const { return v; }
int_t operator[](int n) const
@@ -175,8 +175,8 @@ namespace vecmathlib {
// Result: convert_bool(0)=false, convert_bool(else)=true
// There is no intrinsic to compare with zero. Instead, we check
// whether x is positive and x-1 is negative.
- intvec x = *this;
- // We know that boolvec values depend only on the sign bit
+ intvec_t x = *this;
+ // We know that boolvec_t values depend only on the sign bit
// return (~(x-1) | x).as_bool();
// return x.as_bool() || !(x-1).as_bool();
return x.as_bool() || (x + (FP::signbit_mask - 1)).as_bool();
@@ -188,10 +188,10 @@ namespace vecmathlib {
// Note: not all arithmetic operations are supported!
- intvec operator+() const { return *this; }
- intvec operator-() const { return IV(I(0)) - *this; }
+ intvec_t operator+() const { return *this; }
+ intvec_t operator-() const { return IV(I(0)) - *this; }
- intvec operator+(intvec x) const
+ intvec_t operator+(intvec_t x) const
{
__m128i vlo = _mm256_castsi256_si128(v);
__m128i vhi = _mm256_extractf128_si256(v, 1);
@@ -201,7 +201,7 @@ namespace vecmathlib {
vhi = _mm_add_epi64(vhi, xvhi);
return _mm256_insertf128_si256(_mm256_castsi128_si256(vlo), vhi, 1);
}
- intvec operator-(intvec x) const
+ intvec_t operator-(intvec_t x) const
{
__m128i vlo = _mm256_castsi256_si128(v);
__m128i vhi = _mm256_extractf128_si256(v, 1);
@@ -212,32 +212,32 @@ namespace vecmathlib {
return _mm256_insertf128_si256(_mm256_castsi128_si256(vlo), vhi, 1);
}
- intvec& operator+=(intvec const& x) { return *this=*this+x; }
- intvec& operator-=(intvec const& x) { return *this=*this-x; }
+ intvec_t& operator+=(intvec_t const& x) { return *this=*this+x; }
+ intvec_t& operator-=(intvec_t const& x) { return *this=*this-x; }
- intvec operator~() const { return IV(~U(0)) ^ *this; }
+ intvec_t operator~() const { return IV(~U(0)) ^ *this; }
- intvec operator&(intvec x) const
+ intvec_t operator&(intvec_t x) const
{
return _mm256_castpd_si256(_mm256_and_pd(_mm256_castsi256_pd(v),
_mm256_castsi256_pd(x.v)));
}
- intvec operator|(intvec x) const
+ intvec_t operator|(intvec_t x) const
{
return _mm256_castpd_si256(_mm256_or_pd(_mm256_castsi256_pd(v),
_mm256_castsi256_pd(x.v)));
}
- intvec operator^(intvec x) const
+ intvec_t operator^(intvec_t x) const
{
return _mm256_castpd_si256(_mm256_xor_pd(_mm256_castsi256_pd(v),
_mm256_castsi256_pd(x.v)));
}
- intvec& operator&=(intvec const& x) { return *this=*this&x; }
- intvec& operator|=(intvec const& x) { return *this=*this|x; }
- intvec& operator^=(intvec const& x) { return *this=*this^x; }
+ intvec_t& operator&=(intvec_t const& x) { return *this=*this&x; }
+ intvec_t& operator|=(intvec_t const& x) { return *this=*this|x; }
+ intvec_t& operator^=(intvec_t const& x) { return *this=*this^x; }
intvec_t bitifthen(intvec_t x, intvec_t y) const;
@@ -252,7 +252,7 @@ namespace vecmathlib {
return _mm256_insertf128_si256(_mm256_castsi128_si256(vlo), vhi, 1);
}
intvec_t rotate(int_t n) const;
- intvec operator>>(int_t n) const
+ intvec_t operator>>(int_t n) const
{
__m128i vlo = _mm256_castsi256_si128(v);
__m128i vhi = _mm256_extractf128_si256(v, 1);
@@ -283,7 +283,7 @@ namespace vecmathlib {
#endif
return _mm256_insertf128_si256(_mm256_castsi128_si256(vlo), vhi, 1);
}
- intvec operator<<(int_t n) const
+ intvec_t operator<<(int_t n) const
{
__m128i vlo = _mm256_castsi256_si128(v);
__m128i vhi = _mm256_extractf128_si256(v, 1);
@@ -291,8 +291,8 @@ namespace vecmathlib {
vhi = _mm_slli_epi64(vhi, n);
return _mm256_insertf128_si256(_mm256_castsi128_si256(vlo), vhi, 1);
}
- intvec& operator>>=(int_t n) { return *this=*this>>n; }
- intvec& operator<<=(int_t n) { return *this=*this<<n; }
+ intvec_t& operator>>=(int_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(int_t n) { return *this=*this<<n; }
intvec_t lsr(intvec_t n) const
{
@@ -303,39 +303,39 @@ namespace vecmathlib {
return r;
}
intvec_t rotate(intvec_t n) const;
- intvec operator>>(intvec n) const
+ intvec_t operator>>(intvec_t n) const
{
- intvec r;
+ intvec_t r;
for (int i=0; i<size; ++i) {
r.set_elt(i, (*this)[i] >> n[i]);
}
return r;
}
- intvec operator<<(intvec n) const
+ intvec_t operator<<(intvec_t n) const
{
- intvec r;
+ intvec_t r;
for (int i=0; i<size; ++i) {
r.set_elt(i, (*this)[i] << n[i]);
}
return r;
}
- intvec& operator>>=(intvec n) { return *this=*this>>n; }
- intvec& operator<<=(intvec n) { return *this=*this<<n; }
+ intvec_t& operator>>=(intvec_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(intvec_t n) { return *this=*this<<n; }
intvec_t clz() const;
intvec_t popcount() const;
- boolvec_t operator==(intvec const& x) const
+ boolvec_t operator==(intvec_t const& x) const
{
return ! (*this != x);
}
- boolvec_t operator!=(intvec const& x) const
+ boolvec_t operator!=(intvec_t const& x) const
{
return (*this ^ x).convert_bool();
}
- boolvec_t operator<(intvec const& x) const
+ boolvec_t operator<(intvec_t const& x) const
{
// return (*this - x).as_bool();
boolvec_t r;
@@ -344,15 +344,15 @@ namespace vecmathlib {
}
return r;
}
- boolvec_t operator<=(intvec const& x) const
+ boolvec_t operator<=(intvec_t const& x) const
{
return ! (*this > x);
}
- boolvec_t operator>(intvec const& x) const
+ boolvec_t operator>(intvec_t const& x) const
{
return x < *this;
}
- boolvec_t operator>=(intvec const& x) const
+ boolvec_t operator>=(intvec_t const& x) const
{
return ! (*this < x);
}
@@ -488,10 +488,9 @@ namespace vecmathlib {
if (__builtin_expect(m.all_m, true)) {
storeu(p);
} else {
- if (m.m[0]) p[0] = (*this)[0];
- if (m.m[1]) p[1] = (*this)[1];
- if (m.m[2]) p[2] = (*this)[2];
- if (m.m[3]) p[3] = (*this)[3];
+ for (int d=0; d<size; ++d) {
+ if (m.m[d]) p[d] = (*this)[d];
+ }
}
}
void storeu(real_t* p, std::ptrdiff_t ioff, mask_t const& m) const
@@ -507,27 +506,26 @@ namespace vecmathlib {
intvec_t convert_int() const
{
intvec_t r;
- r.set_elt(0, floatprops::convert_int((*this)[0]));
- r.set_elt(1, floatprops::convert_int((*this)[1]));
- r.set_elt(2, floatprops::convert_int((*this)[2]));
- r.set_elt(3, floatprops::convert_int((*this)[3]));
+ for (int d=0; d<size; ++d) {
+ r.set_elt(d, floatprops::convert_int((*this)[d]));
+ }
return r;
}
- realvec operator+() const { return *this; }
- realvec operator-() const { return RV(0.0) - *this; }
+ realvec_t operator+() const { return *this; }
+ realvec_t operator-() const { return RV(0.0) - *this; }
- realvec operator+(realvec x) const { return _mm256_add_pd(v, x.v); }
- realvec operator-(realvec x) const { return _mm256_sub_pd(v, x.v); }
- realvec operator*(realvec x) const { return _mm256_mul_pd(v, x.v); }
- realvec operator/(realvec x) const { return _mm256_div_pd(v, x.v); }
+ realvec_t operator+(realvec_t x) const { return _mm256_add_pd(v, x.v); }
+ realvec_t operator-(realvec_t x) const { return _mm256_sub_pd(v, x.v); }
+ realvec_t operator*(realvec_t x) const { return _mm256_mul_pd(v, x.v); }
+ realvec_t operator/(realvec_t x) const { return _mm256_div_pd(v, x.v); }
- realvec& operator+=(realvec const& x) { return *this=*this+x; }
- realvec& operator-=(realvec const& x) { return *this=*this-x; }
- realvec& operator*=(realvec const& x) { return *this=*this*x; }
- realvec& operator/=(realvec const& x) { return *this=*this/x; }
+ realvec_t& operator+=(realvec_t const& x) { return *this=*this+x; }
+ realvec_t& operator-=(realvec_t const& x) { return *this=*this-x; }
+ realvec_t& operator*=(realvec_t const& x) { return *this=*this*x; }
+ realvec_t& operator/=(realvec_t const& x) { return *this=*this/x; }
real_t maxval() const
{
@@ -561,65 +559,68 @@ namespace vecmathlib {
// __m256d x = _mm256_hadd_pd(v, v);
// __m128d xlo = _mm256_extractf128_pd(x, 0);
// __m128d xhi = _mm256_extractf128_pd(x, 1);
- realvec x = *this;
+ realvec_t x = *this;
x = _mm256_hadd_pd(x.v, x.v);
return x[0] + x[2];
}
- boolvec_t operator==(realvec const& x) const
+ boolvec_t operator==(realvec_t const& x) const
{
return _mm256_cmp_pd(v, x.v, _CMP_EQ_OQ);
}
- boolvec_t operator!=(realvec const& x) const
+ boolvec_t operator!=(realvec_t const& x) const
{
return _mm256_cmp_pd(v, x.v, _CMP_NEQ_UQ); // Note: _UQ here
}
- boolvec_t operator<(realvec const& x) const
+ boolvec_t operator<(realvec_t const& x) const
{
return _mm256_cmp_pd(v, x.v, _CMP_LT_OQ);
}
- boolvec_t operator<=(realvec const& x) const
+ boolvec_t operator<=(realvec_t const& x) const
{
return _mm256_cmp_pd(v, x.v, _CMP_LE_OQ);
}
- boolvec_t operator>(realvec const& x) const
+ boolvec_t operator>(realvec_t const& x) const
{
return _mm256_cmp_pd(v, x.v, _CMP_GT_OQ);
}
- boolvec_t operator>=(realvec const& x) const
+ boolvec_t operator>=(realvec_t const& x) const
{
return _mm256_cmp_pd(v, x.v, _CMP_GE_OQ);
}
- realvec acos() const { return MF::vml_acos(*this); }
- realvec acosh() const { return MF::vml_acosh(*this); }
- realvec asin() const { return MF::vml_asin(*this); }
- realvec asinh() const { return MF::vml_asinh(*this); }
- realvec atan() const { return MF::vml_atan(*this); }
- realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
- realvec atanh() const { return MF::vml_atanh(*this); }
- realvec cbrt() const { return MF::vml_cbrt(*this); }
- realvec ceil() const { return _mm256_ceil_pd(v); }
- realvec copysign(realvec y) const { return MF::vml_copysign(*this, y); }
- realvec cos() const { return MF::vml_cos(*this); }
- realvec cosh() const { return MF::vml_cosh(*this); }
- realvec exp() const { return MF::vml_exp(*this); }
- realvec exp10() const { return MF::vml_exp10(*this); }
- realvec exp2() const { return MF::vml_exp2(*this); }
- realvec expm1() const { return MF::vml_expm1(*this); }
- realvec fabs() const { return MF::vml_fabs(*this); }
- realvec fdim(realvec y) const { return MF::vml_fdim(*this, y); }
- realvec floor() const { return _mm256_floor_pd(v); }
- realvec fma(realvec y, realvec z) const { return MF::vml_fma(*this, y, z); }
- realvec fmax(realvec y) const { return _mm256_max_pd(v, y.v); }
- realvec fmin(realvec y) const { return _mm256_min_pd(v, y.v); }
- realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); }
- realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); }
- realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); }
+ realvec_t acos() const { return MF::vml_acos(*this); }
+ realvec_t acosh() const { return MF::vml_acosh(*this); }
+ realvec_t asin() const { return MF::vml_asin(*this); }
+ realvec_t asinh() const { return MF::vml_asinh(*this); }
+ realvec_t atan() const { return MF::vml_atan(*this); }
+ realvec_t atan2(realvec_t y) const { return MF::vml_atan2(*this, y); }
+ realvec_t atanh() const { return MF::vml_atanh(*this); }
+ realvec_t cbrt() const { return MF::vml_cbrt(*this); }
+ realvec_t ceil() const { return _mm256_ceil_pd(v); }
+ realvec_t copysign(realvec_t y) const { return MF::vml_copysign(*this, y); }
+ realvec_t cos() const { return MF::vml_cos(*this); }
+ realvec_t cosh() const { return MF::vml_cosh(*this); }
+ realvec_t exp() const { return MF::vml_exp(*this); }
+ realvec_t exp10() const { return MF::vml_exp10(*this); }
+ realvec_t exp2() const { return MF::vml_exp2(*this); }
+ realvec_t expm1() const { return MF::vml_expm1(*this); }
+ realvec_t fabs() const { return MF::vml_fabs(*this); }
+ realvec_t fdim(realvec_t y) const { return MF::vml_fdim(*this, y); }
+ realvec_t floor() const { return _mm256_floor_pd(v); }
+ realvec_t fma(realvec_t y, realvec_t z) const
+ {
+ return MF::vml_fma(*this, y, z);
+ }
+ realvec_t fmax(realvec_t y) const { return _mm256_max_pd(v, y.v); }
+ realvec_t fmin(realvec_t y) const { return _mm256_min_pd(v, y.v); }
+ realvec_t fmod(realvec_t y) const { return MF::vml_fmod(*this, y); }
+ realvec_t frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); }
+ realvec_t hypot(realvec_t y) const { return MF::vml_hypot(*this, y); }
intvec_t ilogb() const { return MF::vml_ilogb(*this); }
boolvec_t isfinite() const { return MF::vml_isfinite(*this); }
boolvec_t isinf() const { return MF::vml_isinf(*this); }
@@ -632,29 +633,35 @@ namespace vecmathlib {
#endif
}
boolvec_t isnormal() const { return MF::vml_isnormal(*this); }
- realvec ldexp(int_t n) const { return MF::vml_ldexp(*this, n); }
- realvec ldexp(intvec_t n) const { return MF::vml_ldexp(*this, n); }
- realvec log() const { return MF::vml_log(*this); }
- realvec log10() const { return MF::vml_log10(*this); }
- realvec log1p() const { return MF::vml_log1p(*this); }
- realvec log2() const { return MF::vml_log2(*this); }
- realvec nextafter(realvec y) const { return MF::vml_nextafter(*this, y); }
- realvec pow(realvec y) const { return MF::vml_pow(*this, y); }
- realvec rcp() const { return _mm256_div_pd(_mm256_set1_pd(1.0), v); }
- realvec remainder(realvec y) const { return MF::vml_remainder(*this, y); }
- realvec rint() const
+ realvec_t ldexp(int_t n) const { return MF::vml_ldexp(*this, n); }
+ realvec_t ldexp(intvec_t n) const { return MF::vml_ldexp(*this, n); }
+ realvec_t log() const { return MF::vml_log(*this); }
+ realvec_t log10() const { return MF::vml_log10(*this); }
+ realvec_t log1p() const { return MF::vml_log1p(*this); }
+ realvec_t log2() const { return MF::vml_log2(*this); }
+ realvec_t nextafter(realvec_t y) const
+ {
+ return MF::vml_nextafter(*this, y);
+ }
+ realvec_t pow(realvec_t y) const { return MF::vml_pow(*this, y); }
+ realvec_t rcp() const { return _mm256_div_pd(_mm256_set1_pd(1.0), v); }
+ realvec_t remainder(realvec_t y) const
+ {
+ return MF::vml_remainder(*this, y);
+ }
+ realvec_t rint() const
{
return _mm256_round_pd(v, _MM_FROUND_TO_NEAREST_INT);
}
- realvec round() const { return MF::vml_round(*this); }
- realvec rsqrt() const { return MF::vml_rsqrt(*this); }
+ realvec_t round() const { return MF::vml_round(*this); }
+ realvec_t rsqrt() const { return MF::vml_rsqrt(*this); }
boolvec_t signbit() const { return v; }
- realvec sin() const { return MF::vml_sin(*this); }
- realvec sinh() const { return MF::vml_sinh(*this); }
- realvec sqrt() const { return _mm256_sqrt_pd(v); }
- realvec tan() const { return MF::vml_tan(*this); }
- realvec tanh() const { return MF::vml_tanh(*this); }
- realvec trunc() const { return _mm256_round_pd(v, _MM_FROUND_TO_ZERO); }
+ realvec_t sin() const { return MF::vml_sin(*this); }
+ realvec_t sinh() const { return MF::vml_sinh(*this); }
+ realvec_t sqrt() const { return _mm256_sqrt_pd(v); }
+ realvec_t tan() const { return MF::vml_tan(*this); }
+ realvec_t tanh() const { return MF::vml_tanh(*this); }
+ realvec_t trunc() const { return _mm256_round_pd(v, _MM_FROUND_TO_ZERO); }
};
@@ -699,8 +706,8 @@ namespace vecmathlib {
return MF::vml_abs(*this);
}
- inline intvec<double,4> intvec<double,4>::bitifthen(intvec_t x,
- intvec_t y) const
+ inline
+ intvec<double,4> intvec<double,4>::bitifthen(intvec_t x, intvec_t y) const
{
return MF::vml_bitifthen(*this, x, y);
}
@@ -718,10 +725,9 @@ namespace vecmathlib {
inline realvec<double,4> intvec<double,4>::convert_float() const
{
realvec_t r;
- r.set_elt(0, floatprops::convert_float((*this)[0]));
- r.set_elt(1, floatprops::convert_float((*this)[1]));
- r.set_elt(2, floatprops::convert_float((*this)[2]));
- r.set_elt(3, floatprops::convert_float((*this)[3]));
+ for (int d=0; d<size; ++d) {
+ r.set_elt(d, floatprops::convert_float((*this)[d]));
+ }
return r;
}
diff --git a/vec_avx_float8.h b/vec_avx_float8.h
index 6a8e4c4..4367969 100644
--- a/vec_avx_float8.h
+++ b/vec_avx_float8.h
@@ -81,7 +81,7 @@ namespace vecmathlib {
{
return to_bool(vecmathlib::get_elt<BV,bvector_t,uint_t>(v, n));
}
- boolvec& set_elt(int n, bool a)
+ boolvec_t& set_elt(int n, bool a)
{
return
vecmathlib::set_elt<BV,bvector_t,uint_t>(v, n, from_bool(a)), *this;
@@ -94,12 +94,12 @@ namespace vecmathlib {
- boolvec operator!() const { return _mm256_xor_ps(boolvec(true), v); }
+ boolvec_t operator!() const { return _mm256_xor_ps(boolvec(true), v); }
- boolvec operator&&(boolvec x) const { return _mm256_and_ps(v, x.v); }
- boolvec operator||(boolvec x) const { return _mm256_or_ps(v, x.v); }
- boolvec operator==(boolvec x) const { return !(*this!=x); }
- boolvec operator!=(boolvec x) const { return _mm256_xor_ps(v, x.v); }
+ boolvec_t operator&&(boolvec_t x) const { return _mm256_and_ps(v, x.v); }
+ boolvec_t operator||(boolvec_t x) const { return _mm256_or_ps(v, x.v); }
+ boolvec_t operator==(boolvec_t x) const { return !(*this!=x); }
+ boolvec_t operator!=(boolvec_t x) const { return _mm256_xor_ps(v, x.v); }
bool all() const
{
@@ -164,7 +164,7 @@ namespace vecmathlib {
intvec(int_t a): v(_mm256_set1_epi32(a)) {}
intvec(int_t const* as): v(_mm256_set_epi32(as[7], as[6], as[5], as[4],
as[3], as[2], as[1], as[0])) {}
- static intvec iota() { return _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); }
+ static intvec_t iota() { return _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); }
operator ivector_t() const { return v; }
int_t operator[](int n) const
@@ -184,8 +184,8 @@ namespace vecmathlib {
// Result: convert_bool(0)=false, convert_bool(else)=true
// There is no intrinsic to compare with zero. Instead, we check
// whether x is positive and x-1 is negative.
- intvec x = *this;
- // We know that boolvec values depend only on the sign bit
+ intvec_t x = *this;
+ // We know that boolvec_t values depend only on the sign bit
// return (~(x-1) | x).as_bool();
// return x.as_bool() || !(x-1).as_bool();
return x.as_bool() || (x + (FP::signbit_mask - 1)).as_bool();
@@ -197,10 +197,10 @@ namespace vecmathlib {
// Note: not all arithmetic operations are supported!
- intvec operator+() const { return *this; }
- intvec operator-() const { return IV(0) - *this; }
+ intvec_t operator+() const { return *this; }
+ intvec_t operator-() const { return IV(0) - *this; }
- intvec operator+(intvec x) const
+ intvec_t operator+(intvec_t x) const
{
__m128i vlo = _mm256_castsi256_si128(v);
__m128i vhi = _mm256_extractf128_si256(v, 1);
@@ -210,7 +210,7 @@ namespace vecmathlib {
vhi = _mm_add_epi32(vhi, xvhi);
return _mm256_insertf128_si256(_mm256_castsi128_si256(vlo), vhi, 1);
}
- intvec operator-(intvec x) const
+ intvec_t operator-(intvec_t x) const
{
__m128i vlo = _mm256_castsi256_si128(v);
__m128i vhi = _mm256_extractf128_si256(v, 1);
@@ -221,32 +221,32 @@ namespace vecmathlib {
return _mm256_insertf128_si256(_mm256_castsi128_si256(vlo), vhi, 1);
}
- intvec& operator+=(intvec const& x) { return *this=*this+x; }
- intvec& operator-=(intvec const& x) { return *this=*this-x; }
+ intvec_t& operator+=(intvec_t const& x) { return *this=*this+x; }
+ intvec_t& operator-=(intvec_t const& x) { return *this=*this-x; }
- intvec operator~() const { return IV(~U(0)) ^ *this; }
+ intvec_t operator~() const { return IV(~U(0)) ^ *this; }
- intvec operator&(intvec x) const
+ intvec_t operator&(intvec_t x) const
{
return _mm256_castps_si256(_mm256_and_ps(_mm256_castsi256_ps(v),
_mm256_castsi256_ps(x.v)));
}
- intvec operator|(intvec x) const
+ intvec_t operator|(intvec_t x) const
{
return _mm256_castps_si256(_mm256_or_ps(_mm256_castsi256_ps(v),
_mm256_castsi256_ps(x.v)));
}
- intvec operator^(intvec x) const
+ intvec_t operator^(intvec_t x) const
{
return _mm256_castps_si256(_mm256_xor_ps(_mm256_castsi256_ps(v),
_mm256_castsi256_ps(x.v)));
}
- intvec& operator&=(intvec const& x) { return *this=*this&x; }
- intvec& operator|=(intvec const& x) { return *this=*this|x; }
- intvec& operator^=(intvec const& x) { return *this=*this^x; }
+ intvec_t& operator&=(intvec_t const& x) { return *this=*this&x; }
+ intvec_t& operator|=(intvec_t const& x) { return *this=*this|x; }
+ intvec_t& operator^=(intvec_t const& x) { return *this=*this^x; }
intvec_t bitifthen(intvec_t x, intvec_t y) const;
@@ -261,7 +261,7 @@ namespace vecmathlib {
return _mm256_insertf128_si256(_mm256_castsi128_si256(vlo), vhi, 1);
}
intvec_t rotate(int_t n) const;
- intvec operator>>(int_t n) const
+ intvec_t operator>>(int_t n) const
{
__m128i vlo = _mm256_castsi256_si128(v);
__m128i vhi = _mm256_extractf128_si256(v, 1);
@@ -269,7 +269,7 @@ namespace vecmathlib {
vhi = _mm_srai_epi32(vhi, n);
return _mm256_insertf128_si256(_mm256_castsi128_si256(vlo), vhi, 1);
}
- intvec operator<<(int_t n) const
+ intvec_t operator<<(int_t n) const
{
__m128i vlo = _mm256_castsi256_si128(v);
__m128i vhi = _mm256_extractf128_si256(v, 1);
@@ -277,8 +277,8 @@ namespace vecmathlib {
vhi = _mm_slli_epi32(vhi, n);
return _mm256_insertf128_si256(_mm256_castsi128_si256(vlo), vhi, 1);
}
- intvec& operator>>=(int_t n) { return *this=*this>>n; }
- intvec& operator<<=(int_t n) { return *this=*this<<n; }
+ intvec_t& operator>>=(int_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(int_t n) { return *this=*this<<n; }
intvec_t lsr(intvec_t n) const
{
@@ -289,39 +289,39 @@ namespace vecmathlib {
return r;
}
intvec_t rotate(intvec_t n) const;
- intvec operator>>(intvec n) const
+ intvec_t operator>>(intvec_t n) const
{
- intvec r;
+ intvec_t r;
for (int i=0; i<size; ++i) {
r.set_elt(i, (*this)[i] >> n[i]);
}
return r;
}
- intvec operator<<(intvec n) const
+ intvec_t operator<<(intvec_t n) const
{
- intvec r;
+ intvec_t r;
for (int i=0; i<size; ++i) {
r.set_elt(i, (*this)[i] << n[i]);
}
return r;
}
- intvec& operator>>=(intvec n) { return *this=*this>>n; }
- intvec& operator<<=(intvec n) { return *this=*this<<n; }
+ intvec_t& operator>>=(intvec_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(intvec_t n) { return *this=*this<<n; }
intvec_t clz() const;
intvec_t popcount() const;
- boolvec_t operator==(intvec const& x) const
+ boolvec_t operator==(intvec_t const& x) const
{
return ! (*this != x);
}
- boolvec_t operator!=(intvec const& x) const
+ boolvec_t operator!=(intvec_t const& x) const
{
return (*this ^ x).convert_bool();
}
- boolvec_t operator<(intvec const& x) const
+ boolvec_t operator<(intvec_t const& x) const
{
// return (*this - x).as_bool();
boolvec_t r;
@@ -330,15 +330,15 @@ namespace vecmathlib {
}
return r;
}
- boolvec_t operator<=(intvec const& x) const
+ boolvec_t operator<=(intvec_t const& x) const
{
return ! (*this > x);
}
- boolvec_t operator>(intvec const& x) const
+ boolvec_t operator>(intvec_t const& x) const
{
return x < *this;
}
- boolvec_t operator>=(intvec const& x) const
+ boolvec_t operator>=(intvec_t const& x) const
{
return ! (*this < x);
}
@@ -493,18 +493,18 @@ namespace vecmathlib {
- realvec operator+() const { return *this; }
- realvec operator-() const { return RV(0.0) - *this; }
+ realvec_t operator+() const { return *this; }
+ realvec_t operator-() const { return RV(0.0) - *this; }
- realvec operator+(realvec x) const { return _mm256_add_ps(v, x.v); }
- realvec operator-(realvec x) const { return _mm256_sub_ps(v, x.v); }
- realvec operator*(realvec x) const { return _mm256_mul_ps(v, x.v); }
- realvec operator/(realvec x) const { return _mm256_div_ps(v, x.v); }
+ realvec_t operator+(realvec_t x) const { return _mm256_add_ps(v, x.v); }
+ realvec_t operator-(realvec_t x) const { return _mm256_sub_ps(v, x.v); }
+ realvec_t operator*(realvec_t x) const { return _mm256_mul_ps(v, x.v); }
+ realvec_t operator/(realvec_t x) const { return _mm256_div_ps(v, x.v); }
- realvec& operator+=(realvec const& x) { return *this=*this+x; }
- realvec& operator-=(realvec const& x) { return *this=*this-x; }
- realvec& operator*=(realvec const& x) { return *this=*this*x; }
- realvec& operator/=(realvec const& x) { return *this=*this/x; }
+ realvec_t& operator+=(realvec_t const& x) { return *this=*this+x; }
+ realvec_t& operator-=(realvec_t const& x) { return *this=*this-x; }
+ realvec_t& operator*=(realvec_t const& x) { return *this=*this*x; }
+ realvec_t& operator/=(realvec_t const& x) { return *this=*this/x; }
real_t maxval() const
{
@@ -556,7 +556,7 @@ namespace vecmathlib {
// __m128 xlo = _mm256_extractf128_ps(x, 0);
// __m128 xhi = _mm256_extractf128_ps(x, 1);
// return _mm_cvtsd_f64(xlo) + _mm_cvtsd_f64(xhi);
- realvec x = *this;
+ realvec_t x = *this;
x = _mm256_hadd_ps(x.v, x.v);
x = _mm256_hadd_ps(x.v, x.v);
return x[0] + x[4];
@@ -564,58 +564,61 @@ namespace vecmathlib {
- boolvec_t operator==(realvec const& x) const
+ boolvec_t operator==(realvec_t const& x) const
{
return _mm256_cmp_ps(v, x.v, _CMP_EQ_OQ);
}
- boolvec_t operator!=(realvec const& x) const
+ boolvec_t operator!=(realvec_t const& x) const
{
return _mm256_cmp_ps(v, x.v, _CMP_NEQ_UQ); // Note: _UQ here
}
- boolvec_t operator<(realvec const& x) const
+ boolvec_t operator<(realvec_t const& x) const
{
return _mm256_cmp_ps(v, x.v, _CMP_LT_OQ);
}
- boolvec_t operator<=(realvec const& x) const
+ boolvec_t operator<=(realvec_t const& x) const
{
return _mm256_cmp_ps(v, x.v, _CMP_LE_OQ);
}
- boolvec_t operator>(realvec const& x) const
+ boolvec_t operator>(realvec_t const& x) const
{
return _mm256_cmp_ps(v, x.v, _CMP_GT_OQ);
}
- boolvec_t operator>=(realvec const& x) const
+ boolvec_t operator>=(realvec_t const& x) const
{
return _mm256_cmp_ps(v, x.v, _CMP_GE_OQ);
}
- realvec acos() const { return MF::vml_acos(*this); }
- realvec acosh() const { return MF::vml_acosh(*this); }
- realvec asin() const { return MF::vml_asin(*this); }
- realvec asinh() const { return MF::vml_asinh(*this); }
- realvec atan() const { return MF::vml_atan(*this); }
- realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
- realvec atanh() const { return MF::vml_atanh(*this); }
- realvec cbrt() const { return MF::vml_cbrt(*this); }
- realvec ceil() const { return _mm256_ceil_ps(v); }
- realvec copysign(realvec y) const { return MF::vml_copysign(*this, y); }
- realvec cos() const { return MF::vml_cos(*this); }
- realvec cosh() const { return MF::vml_cosh(*this); }
- realvec exp() const { return MF::vml_exp(*this); }
- realvec exp10() const { return MF::vml_exp10(*this); }
- realvec exp2() const { return MF::vml_exp2(*this); }
- realvec expm1() const { return MF::vml_expm1(*this); }
- realvec fabs() const { return MF::vml_fabs(*this); }
- realvec fdim(realvec y) const { return MF::vml_fdim(*this, y); }
- realvec floor() const { return _mm256_floor_ps(v); }
- realvec fma(realvec y, realvec z) const { return MF::vml_fma(*this, y, z); }
- realvec fmax(realvec y) const { return _mm256_max_ps(v, y.v); }
- realvec fmin(realvec y) const { return _mm256_min_ps(v, y.v); }
- realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); }
- realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); }
- realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); }
+ realvec_t acos() const { return MF::vml_acos(*this); }
+ realvec_t acosh() const { return MF::vml_acosh(*this); }
+ realvec_t asin() const { return MF::vml_asin(*this); }
+ realvec_t asinh() const { return MF::vml_asinh(*this); }
+ realvec_t atan() const { return MF::vml_atan(*this); }
+ realvec_t atan2(realvec_t y) const { return MF::vml_atan2(*this, y); }
+ realvec_t atanh() const { return MF::vml_atanh(*this); }
+ realvec_t cbrt() const { return MF::vml_cbrt(*this); }
+ realvec_t ceil() const { return _mm256_ceil_ps(v); }
+ realvec_t copysign(realvec_t y) const { return MF::vml_copysign(*this, y); }
+ realvec_t cos() const { return MF::vml_cos(*this); }
+ realvec_t cosh() const { return MF::vml_cosh(*this); }
+ realvec_t exp() const { return MF::vml_exp(*this); }
+ realvec_t exp10() const { return MF::vml_exp10(*this); }
+ realvec_t exp2() const { return MF::vml_exp2(*this); }
+ realvec_t expm1() const { return MF::vml_expm1(*this); }
+ realvec_t fabs() const { return MF::vml_fabs(*this); }
+ realvec_t fdim(realvec_t y) const { return MF::vml_fdim(*this, y); }
+ realvec_t floor() const { return _mm256_floor_ps(v); }
+ realvec_t fma(realvec_t y, realvec_t z) const
+ {
+ return MF::vml_fma(*this, y, z);
+ }
+ realvec_t fmax(realvec_t y) const { return _mm256_max_ps(v, y.v); }
+ realvec_t fmin(realvec_t y) const { return _mm256_min_ps(v, y.v); }
+ realvec_t fmod(realvec_t y) const { return MF::vml_fmod(*this, y); }
+ realvec_t frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); }
+ realvec_t hypot(realvec_t y) const { return MF::vml_hypot(*this, y); }
intvec_t ilogb() const { return MF::vml_ilogb(*this); }
boolvec_t isfinite() const { return MF::vml_isfinite(*this); }
boolvec_t isinf() const { return MF::vml_isinf(*this); }
@@ -628,41 +631,47 @@ namespace vecmathlib {
#endif
}
boolvec_t isnormal() const { return MF::vml_isnormal(*this); }
- realvec ldexp(int_t n) const { return MF::vml_ldexp(*this, n); }
- realvec ldexp(intvec_t n) const { return MF::vml_ldexp(*this, n); }
- realvec log() const { return MF::vml_log(*this); }
- realvec log10() const { return MF::vml_log10(*this); }
- realvec log1p() const { return MF::vml_log1p(*this); }
- realvec log2() const { return MF::vml_log2(*this); }
- realvec nextafter(realvec y) const { return MF::vml_nextafter(*this, y); }
- realvec pow(realvec y) const { return MF::vml_pow(*this, y); }
- realvec rcp() const
- {
- realvec x = *this;
- realvec r = _mm256_rcp_ps(x); // this is only an approximation
+ realvec_t ldexp(int_t n) const { return MF::vml_ldexp(*this, n); }
+ realvec_t ldexp(intvec_t n) const { return MF::vml_ldexp(*this, n); }
+ realvec_t log() const { return MF::vml_log(*this); }
+ realvec_t log10() const { return MF::vml_log10(*this); }
+ realvec_t log1p() const { return MF::vml_log1p(*this); }
+ realvec_t log2() const { return MF::vml_log2(*this); }
+ realvec_t nextafter(realvec_t y) const
+ {
+ return MF::vml_nextafter(*this, y);
+ }
+ realvec_t pow(realvec_t y) const { return MF::vml_pow(*this, y); }
+ realvec_t rcp() const
+ {
+ realvec_t x = *this;
+ realvec_t r = _mm256_rcp_ps(x); // this is only an approximation
r *= RV(2.0) - r*x; // one Newton iteration (see vml_rcp)
return r;
}
- realvec remainder(realvec y) const { return MF::vml_remainder(*this, y); }
- realvec rint() const
+ realvec_t remainder(realvec_t y) const
+ {
+ return MF::vml_remainder(*this, y);
+ }
+ realvec_t rint() const
{
return _mm256_round_ps(v, _MM_FROUND_TO_NEAREST_INT);
}
- realvec round() const { return MF::vml_round(*this); }
- realvec rsqrt() const
+ realvec_t round() const { return MF::vml_round(*this); }
+ realvec_t rsqrt() const
{
- realvec x = *this;
- realvec r = _mm256_rsqrt_ps(x); // this is only an approximation
+ realvec_t x = *this;
+ realvec_t r = _mm256_rsqrt_ps(x); // this is only an approximation
r *= RV(1.5) - RV(0.5)*x * r*r; // one Newton iteration (see vml_rsqrt)
return r;
}
boolvec_t signbit() const { return v; }
- realvec sin() const { return MF::vml_sin(*this); }
- realvec sinh() const { return MF::vml_sinh(*this); }
- realvec sqrt() const { return _mm256_sqrt_ps(v); }
- realvec tan() const { return MF::vml_tan(*this); }
- realvec tanh() const { return MF::vml_tanh(*this); }
- realvec trunc() const { return _mm256_round_ps(v, _MM_FROUND_TO_ZERO); }
+ realvec_t sin() const { return MF::vml_sin(*this); }
+ realvec_t sinh() const { return MF::vml_sinh(*this); }
+ realvec_t sqrt() const { return _mm256_sqrt_ps(v); }
+ realvec_t tan() const { return MF::vml_tan(*this); }
+ realvec_t tanh() const { return MF::vml_tanh(*this); }
+ realvec_t trunc() const { return _mm256_round_ps(v, _MM_FROUND_TO_ZERO); }
};
diff --git a/vec_sse_double1.h b/vec_sse_double1.h
index d021e26..b993ba7 100644
--- a/vec_sse_double1.h
+++ b/vec_sse_double1.h
@@ -78,7 +78,7 @@ namespace vecmathlib {
operator bvector_t() const { return v; }
bool operator[](int n) const { return v; }
- boolvec& set_elt(int n, bool a) { return v=a, *this; }
+ boolvec_t& set_elt(int n, bool a) { return v=a, *this; }
@@ -87,12 +87,12 @@ namespace vecmathlib {
- boolvec operator!() const { return !v; }
+ boolvec_t operator!() const { return !v; }
- boolvec operator&&(boolvec x) const { return v && x.v; }
- boolvec operator||(boolvec x) const { return v || x.v; }
- boolvec operator==(boolvec x) const { return bool(v) == bool(x.v); }
- boolvec operator!=(boolvec x) const { return bool(v) != bool(x.v); }
+ boolvec_t operator&&(boolvec_t x) const { return v && x.v; }
+ boolvec_t operator||(boolvec_t x) const { return v || x.v; }
+ boolvec_t operator==(boolvec_t x) const { return bool(v) == bool(x.v); }
+ boolvec_t operator!=(boolvec_t x) const { return bool(v) != bool(x.v); }
bool all() const { return *this; }
bool any() const { return *this; }
@@ -143,11 +143,11 @@ namespace vecmathlib {
// intvec& operator=(intvec const& x) { return v=x.v, *this; }
intvec(int_t a): v(a) {}
intvec(int_t const* as): v(as[0]) {}
- static intvec iota() { return intvec(I(0)); }
+ static intvec_t iota() { return intvec(I(0)); }
operator ivector_t() const { return v; }
int_t operator[](int n) const { return v; }
- intvec& set_elt(int n, int_t a) { return v=a, *this; }
+ intvec_t& set_elt(int n, int_t a) { return v=a, *this; }
@@ -158,32 +158,32 @@ namespace vecmathlib {
- intvec operator+() const { return +v; }
- intvec operator-() const { return -v; }
+ intvec_t operator+() const { return +v; }
+ intvec_t operator-() const { return -v; }
- intvec operator+(intvec x) const { return v+x.v; }
- intvec operator-(intvec x) const { return v-x.v; }
- intvec operator*(intvec x) const { return v*x.v; }
- intvec operator/(intvec x) const { return v/x.v; }
- intvec operator%(intvec x) const { return v%x.v; }
+ intvec_t operator+(intvec_t x) const { return v+x.v; }
+ intvec_t operator-(intvec_t x) const { return v-x.v; }
+ intvec_t operator*(intvec_t x) const { return v*x.v; }
+ intvec_t operator/(intvec_t x) const { return v/x.v; }
+ intvec_t operator%(intvec_t x) const { return v%x.v; }
- intvec& operator+=(intvec const& x) { return *this=*this+x; }
- intvec& operator-=(intvec const& x) { return *this=*this-x; }
- intvec& operator*=(intvec const& x) { return *this=*this*x; }
- intvec& operator/=(intvec const& x) { return *this=*this/x; }
- intvec& operator%=(intvec const& x) { return *this=*this%x; }
+ intvec_t& operator+=(intvec_t const& x) { return *this=*this+x; }
+ intvec_t& operator-=(intvec_t const& x) { return *this=*this-x; }
+ intvec_t& operator*=(intvec_t const& x) { return *this=*this*x; }
+ intvec_t& operator/=(intvec_t const& x) { return *this=*this/x; }
+ intvec_t& operator%=(intvec_t const& x) { return *this=*this%x; }
- intvec operator~() const { return ~v; }
+ intvec_t operator~() const { return ~v; }
- intvec operator&(intvec x) const { return v&x.v; }
- intvec operator|(intvec x) const { return v|x.v; }
- intvec operator^(intvec x) const { return v^x.v; }
+ intvec_t operator&(intvec_t x) const { return v&x.v; }
+ intvec_t operator|(intvec_t x) const { return v|x.v; }
+ intvec_t operator^(intvec_t x) const { return v^x.v; }
- intvec& operator&=(intvec const& x) { return *this=*this&x; }
- intvec& operator|=(intvec const& x) { return *this=*this|x; }
- intvec& operator^=(intvec const& x) { return *this=*this^x; }
+ intvec_t& operator&=(intvec_t const& x) { return *this=*this&x; }
+ intvec_t& operator|=(intvec_t const& x) { return *this=*this|x; }
+ intvec_t& operator^=(intvec_t const& x) { return *this=*this^x; }
intvec_t bitifthen(intvec_t x, intvec_t y) const;
@@ -191,31 +191,31 @@ namespace vecmathlib {
intvec_t lsr(int_t n) const { return U(v) >> U(n); }
intvec_t rotate(int_t n) const;
- intvec operator>>(int_t n) const { return v>>n; }
- intvec operator<<(int_t n) const { return v<<n; }
+ intvec_t operator>>(int_t n) const { return v>>n; }
+ intvec_t operator<<(int_t n) const { return v<<n; }
- intvec& operator>>=(int_t n) { return *this=*this>>n; }
- intvec& operator<<=(int_t n) { return *this=*this<<n; }
+ intvec_t& operator>>=(int_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(int_t n) { return *this=*this<<n; }
intvec_t lsr(intvec_t n) const { return U(v) >> U(n); }
intvec_t rotate(intvec_t n) const;
- intvec operator>>(intvec n) const { return v>>n; }
- intvec operator<<(intvec n) const { return v<<n; }
+ intvec_t operator>>(intvec_t n) const { return v>>n; }
+ intvec_t operator<<(intvec_t n) const { return v<<n; }
- intvec& operator>>=(intvec n) { return *this=*this>>n; }
- intvec& operator<<=(intvec n) { return *this=*this<<n; }
+ intvec_t& operator>>=(intvec_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(intvec_t n) { return *this=*this<<n; }
intvec_t clz() const { return __builtin_clzll(v); }
intvec_t popcount() const { return __builtin_popcountll(v); }
- 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; }
- 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; }
+ boolvec_t operator==(intvec_t const& x) const { return v==x.v; }
+ boolvec_t operator!=(intvec_t const& x) const { return v!=x.v; }
+ boolvec_t operator<(intvec_t const& x) const { return v<x.v; }
+ boolvec_t operator<=(intvec_t const& x) const { return v<=x.v; }
+ boolvec_t operator>(intvec_t const& x) const { return v>x.v; }
+ boolvec_t operator>=(intvec_t const& x) const { return v>=x.v; }
intvec_t abs() const { return std::abs(v); }
boolvec_t isignbit() const { return v<0; }
@@ -272,7 +272,7 @@ namespace vecmathlib {
operator vector_t() const { return v; }
real_t operator[](int n) const { return v; }
- realvec& set_elt(int n, real_t a) { return v=a, *this; }
+ realvec_t& set_elt(int n, real_t a) { return v=a, *this; }
@@ -361,18 +361,18 @@ namespace vecmathlib {
- realvec operator+() const { return +v; }
- realvec operator-() const { return -v; }
+ realvec_t operator+() const { return +v; }
+ realvec_t operator-() const { return -v; }
- realvec operator+(realvec x) const { return v+x.v; }
- realvec operator-(realvec x) const { return v-x.v; }
- realvec operator*(realvec x) const { return v*x.v; }
- realvec operator/(realvec x) const { return v/x.v; }
+ realvec_t operator+(realvec_t x) const { return v+x.v; }
+ realvec_t operator-(realvec_t x) const { return v-x.v; }
+ realvec_t operator*(realvec_t x) const { return v*x.v; }
+ realvec_t operator/(realvec_t x) const { return v/x.v; }
- realvec& operator+=(realvec const& x) { return *this=*this+x; }
- realvec& operator-=(realvec const& x) { return *this=*this-x; }
- realvec& operator*=(realvec const& x) { return *this=*this*x; }
- realvec& operator/=(realvec const& x) { return *this=*this/x; }
+ realvec_t& operator+=(realvec_t const& x) { return *this=*this+x; }
+ realvec_t& operator-=(realvec_t const& x) { return *this=*this-x; }
+ realvec_t& operator*=(realvec_t const& x) { return *this=*this*x; }
+ realvec_t& operator/=(realvec_t const& x) { return *this=*this/x; }
real_t maxval() const { return *this; }
real_t minval() const { return *this; }
@@ -381,24 +381,24 @@ namespace vecmathlib {
- boolvec_t operator==(realvec const& x) const { return v==x.v; }
- boolvec_t operator!=(realvec const& x) const { return v!=x.v; }
- boolvec_t operator<(realvec const& x) const { return v<x.v; }
- boolvec_t operator<=(realvec const& x) const { return v<=x.v; }
- boolvec_t operator>(realvec const& x) const { return v>x.v; }
- boolvec_t operator>=(realvec const& x) const { return v>=x.v; }
+ boolvec_t operator==(realvec_t const& x) const { return v==x.v; }
+ boolvec_t operator!=(realvec_t const& x) const { return v!=x.v; }
+ boolvec_t operator<(realvec_t const& x) const { return v<x.v; }
+ boolvec_t operator<=(realvec_t const& x) const { return v<=x.v; }
+ boolvec_t operator>(realvec_t const& x) const { return v>x.v; }
+ boolvec_t operator>=(realvec_t const& x) const { return v>=x.v; }
- realvec acos() const { return MF::vml_acos(*this); }
- realvec acosh() const { return MF::vml_acosh(*this); }
- realvec asin() const { return MF::vml_asin(*this); }
- realvec asinh() const { return MF::vml_asinh(*this); }
- realvec atan() const { return MF::vml_atan(*this); }
- realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
- realvec atanh() const { return MF::vml_atanh(*this); }
- realvec cbrt() const { return MF::vml_cbrt(*this); }
- realvec ceil() const
+ realvec_t acos() const { return MF::vml_acos(*this); }
+ realvec_t acosh() const { return MF::vml_acosh(*this); }
+ realvec_t asin() const { return MF::vml_asin(*this); }
+ realvec_t asinh() const { return MF::vml_asinh(*this); }
+ realvec_t atan() const { return MF::vml_atan(*this); }
+ realvec_t atan2(realvec_t y) const { return MF::vml_atan2(*this, y); }
+ realvec_t atanh() const { return MF::vml_atanh(*this); }
+ realvec_t cbrt() const { return MF::vml_cbrt(*this); }
+ realvec_t ceil() const
{
#ifdef __SSE4_1__
return to_double(_mm_ceil_sd(from_double(v), from_double(v)));
@@ -406,16 +406,16 @@ namespace vecmathlib {
return vml_std::ceil(v);
#endif
}
- realvec copysign(realvec y) const { return vml_std::copysign(v, y.v); }
- realvec cos() const { return MF::vml_cos(*this); }
- realvec cosh() const { return MF::vml_cosh(*this); }
- realvec exp() const { return MF::vml_exp(*this); }
- realvec exp10() const { return MF::vml_exp10(*this); }
- realvec exp2() const { return MF::vml_exp2(*this); }
- realvec expm1() const { return MF::vml_expm1(*this); }
- realvec fabs() const { return vml_std::fabs(v); }
- realvec fdim(realvec y) const { return MF::vml_fdim(*this, y); }
- realvec floor() const
+ realvec_t copysign(realvec_t y) const { return vml_std::copysign(v, y.v); }
+ realvec_t cos() const { return MF::vml_cos(*this); }
+ realvec_t cosh() const { return MF::vml_cosh(*this); }
+ realvec_t exp() const { return MF::vml_exp(*this); }
+ realvec_t exp10() const { return MF::vml_exp10(*this); }
+ realvec_t exp2() const { return MF::vml_exp2(*this); }
+ realvec_t expm1() const { return MF::vml_expm1(*this); }
+ realvec_t fabs() const { return vml_std::fabs(v); }
+ realvec_t fdim(realvec_t y) const { return MF::vml_fdim(*this, y); }
+ realvec_t floor() const
{
#ifdef __SSE4_1__
return to_double(_mm_floor_sd(from_double(v), from_double(v)));
@@ -423,27 +423,30 @@ namespace vecmathlib {
return vml_std::floor(v);
#endif
}
- realvec fma(realvec y, realvec z) const { return MF::vml_fma(*this, y, z); }
- realvec fmax(realvec y) const
+ realvec_t fma(realvec_t y, realvec_t z) const
+ {
+ return MF::vml_fma(*this, y, z);
+ }
+ realvec_t fmax(realvec_t y) const
{
return to_double(_mm_max_sd(from_double(v), from_double(y.v)));
}
- realvec fmin(realvec y) const
+ realvec_t fmin(realvec_t y) const
{
return to_double(_mm_min_sd(from_double(v), from_double(y.v)));
}
- realvec fmod(realvec y) const { return vml_std::fmod(v, y.v); }
- realvec frexp(intvec_t* irp) const
+ realvec_t fmod(realvec_t y) const { return vml_std::fmod(v, y.v); }
+ realvec_t frexp(intvec_t* irp) const
{
int iri;
- realvec r = vml_std::frexp(v, &iri);
+ realvec_t r = vml_std::frexp(v, &iri);
int_t ir = iri;
if (isinf()) ir = std::numeric_limits<int_t>::max();
if (isnan()) ir = std::numeric_limits<int_t>::min();
irp->v = ir;
return r;
}
- realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); }
+ realvec_t hypot(realvec_t y) const { return MF::vml_hypot(*this, y); }
intvec_t ilogb() const
{
int_t r = vml_std::ilogb(v);
@@ -475,17 +478,23 @@ namespace vecmathlib {
return vml_std::isnan(v);
}
boolvec_t isnormal() const { return vml_std::isnormal(v); }
- realvec ldexp(int_t n) const { return vml_std::ldexp(v, n); }
- realvec ldexp(intvec_t n) const { return vml_std::ldexp(v, n); }
- realvec log() const { return MF::vml_log(*this); }
- realvec log10() const { return MF::vml_log10(*this); }
- realvec log1p() const { return MF::vml_log1p(*this); }
- realvec log2() const { return MF::vml_log2(*this); }
- realvec nextafter(realvec y) const { return MF::vml_nextafter(*this, y); }
- realvec pow(realvec y) const { return MF::vml_pow(*this, y); }
- realvec rcp() const { return R(1.0)/v; }
- realvec remainder(realvec y) const { return vml_std::remainder(v, y.v); }
- realvec rint() const
+ realvec_t ldexp(int_t n) const { return vml_std::ldexp(v, n); }
+ realvec_t ldexp(intvec_t n) const { return vml_std::ldexp(v, n); }
+ realvec_t log() const { return MF::vml_log(*this); }
+ realvec_t log10() const { return MF::vml_log10(*this); }
+ realvec_t log1p() const { return MF::vml_log1p(*this); }
+ realvec_t log2() const { return MF::vml_log2(*this); }
+ realvec_t nextafter(realvec_t y) const
+ {
+ return MF::vml_nextafter(*this, y);
+ }
+ realvec_t pow(realvec_t y) const { return MF::vml_pow(*this, y); }
+ realvec_t rcp() const { return R(1.0)/v; }
+ realvec_t remainder(realvec_t y) const
+ {
+ return vml_std::remainder(v, y.v);
+ }
+ realvec_t rint() const
{
#ifdef __SSE4_1__
return to_double(_mm_round_sd(from_double(v), from_double(v),
@@ -494,18 +503,18 @@ namespace vecmathlib {
return MF::vml_rint(*this);
#endif
}
- realvec round() const { return MF::vml_round(*this); }
- realvec rsqrt() const { return MF::vml_rsqrt(*this); }
+ realvec_t round() const { return MF::vml_round(*this); }
+ realvec_t rsqrt() const { return MF::vml_rsqrt(*this); }
boolvec_t signbit() const { return vml_std::signbit(v); }
- realvec sin() const { return MF::vml_sin(*this); }
- realvec sinh() const { return MF::vml_sinh(*this); }
- realvec sqrt() const
+ realvec_t sin() const { return MF::vml_sin(*this); }
+ realvec_t sinh() const { return MF::vml_sinh(*this); }
+ realvec_t sqrt() const
{
return to_double(_mm_sqrt_sd(from_double(v), from_double(v)));
}
- realvec tan() const { return MF::vml_tan(*this); }
- realvec tanh() const { return MF::vml_tanh(*this); }
- realvec trunc() const
+ realvec_t tan() const { return MF::vml_tan(*this); }
+ realvec_t tanh() const { return MF::vml_tanh(*this); }
+ realvec_t trunc() const
{
#ifdef __SSE4_1__
return to_double(_mm_round_sd(from_double(v), from_double(v),
diff --git a/vec_sse_double2.h b/vec_sse_double2.h
index 937f114..5728ea5 100644
--- a/vec_sse_double2.h
+++ b/vec_sse_double2.h
@@ -86,7 +86,7 @@ namespace vecmathlib {
{
return to_bool(vecmathlib::get_elt<BV,bvector_t,uint_t>(v, n));
}
- boolvec& set_elt(int n, bool a)
+ boolvec_t& set_elt(int n, bool a)
{
return
vecmathlib::set_elt<BV,bvector_t,uint_t>(v, n, from_bool(a)), *this;
@@ -99,12 +99,12 @@ namespace vecmathlib {
- boolvec operator!() const { return _mm_xor_pd(boolvec(true), v); }
+ boolvec_t operator!() const { return _mm_xor_pd(boolvec(true), v); }
- boolvec operator&&(boolvec x) const { return _mm_and_pd(v, x.v); }
- boolvec operator||(boolvec x) const { return _mm_or_pd(v, x.v); }
- boolvec operator==(boolvec x) const { return !(*this!=x); }
- boolvec operator!=(boolvec x) const { return _mm_xor_pd(v, x.v); }
+ boolvec_t operator&&(boolvec_t x) const { return _mm_and_pd(v, x.v); }
+ boolvec_t operator||(boolvec_t x) const { return _mm_or_pd(v, x.v); }
+ boolvec_t operator==(boolvec_t x) const { return !(*this!=x); }
+ boolvec_t operator!=(boolvec_t x) const { return _mm_xor_pd(v, x.v); }
bool all() const
{
@@ -170,7 +170,7 @@ namespace vecmathlib {
intvec(ivector_t x): v(x) {}
intvec(int_t a): v(_mm_set1_epi64x(a)) {}
intvec(int_t const* as): v(_mm_set_epi64x(as[1], as[0])) {}
- static intvec iota() { return _mm_set_epi64x(1, 0); }
+ static intvec_t iota() { return _mm_set_epi64x(1, 0); }
operator ivector_t() const { return v; }
int_t operator[](int n) const
@@ -190,8 +190,8 @@ namespace vecmathlib {
// Result: convert_bool(0)=false, convert_bool(else)=true
// There is no intrinsic to compare with zero. Instead, we check
// whether x is positive and x-1 is negative.
- intvec x = *this;
- // We know that boolvec values depend only on the sign bit
+ intvec_t x = *this;
+ // We know that boolvec_t values depend only on the sign bit
// return (~(x-1) | x).as_bool();
// return x.as_bool() || !(x-1).as_bool();
return x.as_bool() || (x + (FP::signbit_mask - 1)).as_bool();
@@ -203,38 +203,38 @@ namespace vecmathlib {
// Note: not all arithmetic operations are supported!
- intvec operator+() const { return *this; }
- intvec operator-() const { return IV(I(0)) - *this; }
+ intvec_t operator+() const { return *this; }
+ intvec_t operator-() const { return IV(I(0)) - *this; }
- intvec operator+(intvec x) const { return _mm_add_epi64(v, x.v); }
- intvec operator-(intvec x) const { return _mm_sub_epi64(v, x.v); }
+ intvec_t operator+(intvec_t x) const { return _mm_add_epi64(v, x.v); }
+ intvec_t operator-(intvec_t x) const { return _mm_sub_epi64(v, x.v); }
- intvec& operator+=(intvec const& x) { return *this=*this+x; }
- intvec& operator-=(intvec const& x) { return *this=*this-x; }
+ intvec_t& operator+=(intvec_t const& x) { return *this=*this+x; }
+ intvec_t& operator-=(intvec_t const& x) { return *this=*this-x; }
- intvec operator~() const { return IV(~U(0)) ^ *this; }
+ intvec_t operator~() const { return IV(~U(0)) ^ *this; }
- intvec operator&(intvec x) const
+ intvec_t operator&(intvec_t x) const
{
return _mm_castpd_si128(_mm_and_pd(_mm_castsi128_pd(v),
_mm_castsi128_pd(x.v)));
}
- intvec operator|(intvec x) const
+ intvec_t operator|(intvec_t x) const
{
return _mm_castpd_si128(_mm_or_pd(_mm_castsi128_pd(v),
_mm_castsi128_pd(x.v)));
}
- intvec operator^(intvec x) const
+ intvec_t operator^(intvec_t x) const
{
return _mm_castpd_si128(_mm_xor_pd(_mm_castsi128_pd(v),
_mm_castsi128_pd(x.v)));
}
- intvec& operator&=(intvec const& x) { return *this=*this&x; }
- intvec& operator|=(intvec const& x) { return *this=*this|x; }
- intvec& operator^=(intvec const& x) { return *this=*this^x; }
+ intvec_t& operator&=(intvec_t const& x) { return *this=*this&x; }
+ intvec_t& operator|=(intvec_t const& x) { return *this=*this|x; }
+ intvec_t& operator^=(intvec_t const& x) { return *this=*this^x; }
intvec_t bitifthen(intvec_t x, intvec_t y) const;
@@ -242,12 +242,12 @@ namespace vecmathlib {
intvec_t lsr(int_t n) const { return _mm_srli_epi64(v, n); }
intvec_t rotate(int_t n) const;
- intvec operator>>(int_t n) const
+ intvec_t operator>>(int_t n) const
{
// There is no _mm_srai_epi64. To emulate it, add 0x80000000
// before shifting, and subtract the shifted 0x80000000 after
// shifting
- intvec x = *this;
+ intvec_t x = *this;
// Convert signed to unsiged
x += U(1) << (bits-1);
// Shift
@@ -256,9 +256,9 @@ namespace vecmathlib {
x -= U(1) << (bits-1-n);
return x;
}
- intvec operator<<(int_t n) const { return _mm_slli_epi64(v, n); }
- intvec& operator>>=(int_t n) { return *this=*this>>n; }
- intvec& operator<<=(int_t n) { return *this=*this<<n; }
+ intvec_t operator<<(int_t n) const { return _mm_slli_epi64(v, n); }
+ intvec_t& operator>>=(int_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(int_t n) { return *this=*this<<n; }
intvec_t lsr(intvec_t n) const
{
@@ -269,39 +269,39 @@ namespace vecmathlib {
return r;
}
intvec_t rotate(intvec_t n) const;
- intvec operator>>(intvec n) const
+ intvec_t operator>>(intvec_t n) const
{
- intvec r;
+ intvec_t r;
for (int i=0; i<size; ++i) {
r.set_elt(i, (*this)[i] >> n[i]);
}
return r;
}
- intvec operator<<(intvec n) const
+ intvec_t operator<<(intvec_t n) const
{
- intvec r;
+ intvec_t r;
for (int i=0; i<size; ++i) {
r.set_elt(i, (*this)[i] << n[i]);
}
return r;
}
- intvec& operator>>=(intvec n) { return *this=*this>>n; }
- intvec& operator<<=(intvec n) { return *this=*this<<n; }
+ intvec_t& operator>>=(intvec_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(intvec_t n) { return *this=*this<<n; }
intvec_t clz() const;
intvec_t popcount() const;
- boolvec_t operator==(intvec const& x) const
+ boolvec_t operator==(intvec_t const& x) const
{
return ! (*this != x);
}
- boolvec_t operator!=(intvec const& x) const
+ boolvec_t operator!=(intvec_t const& x) const
{
return (*this ^ x).convert_bool();
}
- boolvec_t operator<(intvec const& x) const
+ boolvec_t operator<(intvec_t const& x) const
{
// return (*this - x).as_bool();
boolvec_t r;
@@ -310,15 +310,15 @@ namespace vecmathlib {
}
return r;
}
- boolvec_t operator<=(intvec const& x) const
+ boolvec_t operator<=(intvec_t const& x) const
{
return ! (*this > x);
}
- boolvec_t operator>(intvec const& x) const
+ boolvec_t operator>(intvec_t const& x) const
{
return x < *this;
}
- boolvec_t operator>=(intvec const& x) const
+ boolvec_t operator>=(intvec_t const& x) const
{
return ! (*this < x);
}
@@ -483,18 +483,18 @@ namespace vecmathlib {
- realvec operator+() const { return *this; }
- realvec operator-() const { return RV(0.0) - *this; }
+ realvec_t operator+() const { return *this; }
+ realvec_t operator-() const { return RV(0.0) - *this; }
- realvec operator+(realvec x) const { return _mm_add_pd(v, x.v); }
- realvec operator-(realvec x) const { return _mm_sub_pd(v, x.v); }
- realvec operator*(realvec x) const { return _mm_mul_pd(v, x.v); }
- realvec operator/(realvec x) const { return _mm_div_pd(v, x.v); }
+ realvec_t operator+(realvec_t x) const { return _mm_add_pd(v, x.v); }
+ realvec_t operator-(realvec_t x) const { return _mm_sub_pd(v, x.v); }
+ realvec_t operator*(realvec_t x) const { return _mm_mul_pd(v, x.v); }
+ realvec_t operator/(realvec_t x) const { return _mm_div_pd(v, x.v); }
- realvec& operator+=(realvec const& x) { return *this=*this+x; }
- realvec& operator-=(realvec const& x) { return *this=*this-x; }
- realvec& operator*=(realvec const& x) { return *this=*this*x; }
- realvec& operator/=(realvec const& x) { return *this=*this/x; }
+ realvec_t& operator+=(realvec_t const& x) { return *this=*this+x; }
+ realvec_t& operator-=(realvec_t const& x) { return *this=*this-x; }
+ realvec_t& operator*=(realvec_t const& x) { return *this=*this*x; }
+ realvec_t& operator/=(realvec_t const& x) { return *this=*this/x; }
real_t maxval() const
{
@@ -519,42 +519,42 @@ namespace vecmathlib {
- boolvec_t operator==(realvec const& x) const
+ boolvec_t operator==(realvec_t const& x) const
{
return _mm_cmpeq_pd(v, x.v);
}
- boolvec_t operator!=(realvec const& x) const
+ boolvec_t operator!=(realvec_t const& x) const
{
return _mm_cmpneq_pd(v, x.v);
}
- boolvec_t operator<(realvec const& x) const
+ boolvec_t operator<(realvec_t const& x) const
{
return _mm_cmplt_pd(v, x.v);
}
- boolvec_t operator<=(realvec const& x) const
+ boolvec_t operator<=(realvec_t const& x) const
{
return _mm_cmple_pd(v, x.v);
}
- boolvec_t operator>(realvec const& x) const
+ boolvec_t operator>(realvec_t const& x) const
{
return _mm_cmpgt_pd(v, x.v);
}
- boolvec_t operator>=(realvec const& x) const
+ boolvec_t operator>=(realvec_t const& x) const
{
return _mm_cmpge_pd(v, x.v);
}
- realvec acos() const { return MF::vml_acos(*this); }
- realvec acosh() const { return MF::vml_acosh(*this); }
- realvec asin() const { return MF::vml_asin(*this); }
- realvec asinh() const { return MF::vml_asinh(*this); }
- realvec atan() const { return MF::vml_atan(*this); }
- realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
- realvec atanh() const { return MF::vml_atanh(*this); }
- realvec cbrt() const { return MF::vml_cbrt(*this); }
- realvec ceil() const
+ realvec_t acos() const { return MF::vml_acos(*this); }
+ realvec_t acosh() const { return MF::vml_acosh(*this); }
+ realvec_t asin() const { return MF::vml_asin(*this); }
+ realvec_t asinh() const { return MF::vml_asinh(*this); }
+ realvec_t atan() const { return MF::vml_atan(*this); }
+ realvec_t atan2(realvec_t y) const { return MF::vml_atan2(*this, y); }
+ realvec_t atanh() const { return MF::vml_atanh(*this); }
+ realvec_t cbrt() const { return MF::vml_cbrt(*this); }
+ realvec_t ceil() const
{
#ifdef __SSE4_1__
return _mm_ceil_pd(v);
@@ -562,16 +562,16 @@ namespace vecmathlib {
return MF::vml_ceil(*this);
#endif
}
- realvec copysign(realvec y) const { return MF::vml_copysign(*this, y); }
- realvec cos() const { return MF::vml_cos(*this); }
- realvec cosh() const { return MF::vml_cosh(*this); }
- realvec exp() const { return MF::vml_exp(*this); }
- realvec exp10() const { return MF::vml_exp10(*this); }
- realvec exp2() const { return MF::vml_exp2(*this); }
- realvec expm1() const { return MF::vml_expm1(*this); }
- realvec fabs() const { return MF::vml_fabs(*this); }
- realvec fdim(realvec y) const { return MF::vml_fdim(*this, y); }
- realvec floor() const
+ realvec_t copysign(realvec_t y) const { return MF::vml_copysign(*this, y); }
+ realvec_t cos() const { return MF::vml_cos(*this); }
+ realvec_t cosh() const { return MF::vml_cosh(*this); }
+ realvec_t exp() const { return MF::vml_exp(*this); }
+ realvec_t exp10() const { return MF::vml_exp10(*this); }
+ realvec_t exp2() const { return MF::vml_exp2(*this); }
+ realvec_t expm1() const { return MF::vml_expm1(*this); }
+ realvec_t fabs() const { return MF::vml_fabs(*this); }
+ realvec_t fdim(realvec_t y) const { return MF::vml_fdim(*this, y); }
+ realvec_t floor() const
{
#ifdef __SSE4_1__
return _mm_floor_pd(v);
@@ -579,12 +579,15 @@ namespace vecmathlib {
return MF::vml_floor(*this);
#endif
}
- realvec fma(realvec y, realvec z) const { return MF::vml_fma(*this, y, z); }
- realvec fmax(realvec y) const { return _mm_max_pd(v, y.v); }
- realvec fmin(realvec y) const { return _mm_min_pd(v, y.v); }
- realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); }
- realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); }
- realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); }
+ realvec_t fma(realvec_t y, realvec_t z) const
+ {
+ return MF::vml_fma(*this, y, z);
+ }
+ realvec_t fmax(realvec_t y) const { return _mm_max_pd(v, y.v); }
+ realvec_t fmin(realvec_t y) const { return _mm_min_pd(v, y.v); }
+ realvec_t fmod(realvec_t y) const { return MF::vml_fmod(*this, y); }
+ realvec_t frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); }
+ realvec_t hypot(realvec_t y) const { return MF::vml_hypot(*this, y); }
intvec_t ilogb() const { return MF::vml_ilogb(*this); }
boolvec_t isfinite() const { return MF::vml_isfinite(*this); }
boolvec_t isinf() const { return MF::vml_isinf(*this); }
@@ -597,17 +600,23 @@ namespace vecmathlib {
#endif
}
boolvec_t isnormal() const { return MF::vml_isnormal(*this); }
- realvec ldexp(int_t n) const { return MF::vml_ldexp(*this, n); }
- realvec ldexp(intvec_t n) const { return MF::vml_ldexp(*this, n); }
- realvec log() const { return MF::vml_log(*this); }
- realvec log10() const { return MF::vml_log10(*this); }
- realvec log1p() const { return MF::vml_log1p(*this); }
- realvec log2() const { return MF::vml_log2(*this); }
- realvec nextafter(realvec y) const { return MF::vml_nextafter(*this, y); }
- realvec pow(realvec y) const { return MF::vml_pow(*this, y); }
- realvec rcp() const { return _mm_div_pd(_mm_set1_pd(1.0), v); }
- realvec remainder(realvec y) const { return MF::vml_remainder(*this, y); }
- realvec rint() const
+ realvec_t ldexp(int_t n) const { return MF::vml_ldexp(*this, n); }
+ realvec_t ldexp(intvec_t n) const { return MF::vml_ldexp(*this, n); }
+ realvec_t log() const { return MF::vml_log(*this); }
+ realvec_t log10() const { return MF::vml_log10(*this); }
+ realvec_t log1p() const { return MF::vml_log1p(*this); }
+ realvec_t log2() const { return MF::vml_log2(*this); }
+ realvec_t nextafter(realvec_t y) const
+ {
+ return MF::vml_nextafter(*this, y);
+ }
+ realvec_t pow(realvec_t y) const { return MF::vml_pow(*this, y); }
+ realvec_t rcp() const { return _mm_div_pd(_mm_set1_pd(1.0), v); }
+ realvec_t remainder(realvec_t y) const
+ {
+ return MF::vml_remainder(*this, y);
+ }
+ realvec_t rint() const
{
#ifdef __SSE4_1__
return _mm_round_pd(v, _MM_FROUND_TO_NEAREST_INT);
@@ -615,15 +624,15 @@ namespace vecmathlib {
return MF::vml_rint(*this);
#endif
}
- realvec round() const { return MF::vml_round(*this); }
- realvec rsqrt() const { return MF::vml_rsqrt(*this); }
+ realvec_t round() const { return MF::vml_round(*this); }
+ realvec_t rsqrt() const { return MF::vml_rsqrt(*this); }
boolvec_t signbit() const { return v; }
- realvec sin() const { return MF::vml_sin(*this); }
- realvec sinh() const { return MF::vml_sinh(*this); }
- realvec sqrt() const { return _mm_sqrt_pd(v); }
- realvec tan() const { return MF::vml_tan(*this); }
- realvec tanh() const { return MF::vml_tanh(*this); }
- realvec trunc() const
+ realvec_t sin() const { return MF::vml_sin(*this); }
+ realvec_t sinh() const { return MF::vml_sinh(*this); }
+ realvec_t sqrt() const { return _mm_sqrt_pd(v); }
+ realvec_t tan() const { return MF::vml_tan(*this); }
+ realvec_t tanh() const { return MF::vml_tanh(*this); }
+ realvec_t trunc() const
{
#ifdef __SSE4_1__
return _mm_round_pd(v, _MM_FROUND_TO_ZERO);
diff --git a/vec_sse_float1.h b/vec_sse_float1.h
index bfc90d9..f038cd6 100644
--- a/vec_sse_float1.h
+++ b/vec_sse_float1.h
@@ -78,7 +78,7 @@ namespace vecmathlib {
operator bvector_t() const { return v; }
bool operator[](int n) const { return v; }
- boolvec& set_elt(int n, bool a) { return v=a, *this; }
+ boolvec_t& set_elt(int n, bool a) { return v=a, *this; }
@@ -87,12 +87,12 @@ namespace vecmathlib {
- boolvec operator!() const { return !v; }
+ boolvec_t operator!() const { return !v; }
- boolvec operator&&(boolvec x) const { return v && x.v; }
- boolvec operator||(boolvec x) const { return v || x.v; }
- boolvec operator==(boolvec x) const { return bool(v) == bool(x.v); }
- boolvec operator!=(boolvec x) const { return bool(v) != bool(x.v); }
+ boolvec_t operator&&(boolvec_t x) const { return v && x.v; }
+ boolvec_t operator||(boolvec_t x) const { return v || x.v; }
+ boolvec_t operator==(boolvec_t x) const { return bool(v) == bool(x.v); }
+ boolvec_t operator!=(boolvec_t x) const { return bool(v) != bool(x.v); }
bool all() const { return *this; }
bool any() const { return *this; }
@@ -143,11 +143,11 @@ namespace vecmathlib {
// intvec& operator=(intvec const& x) { return v=x.v, *this; }
intvec(int_t a): v(a) {}
intvec(int_t const* as): v(as[0]) {}
- static intvec iota() { return intvec(I(0)); }
+ static intvec_t iota() { return intvec(I(0)); }
operator ivector_t() const { return v; }
int_t operator[](int n) const { return v; }
- intvec& set_elt(int n, int_t a) { return v=a, *this; }
+ intvec_t& set_elt(int n, int_t a) { return v=a, *this; }
@@ -158,32 +158,32 @@ namespace vecmathlib {
- intvec operator+() const { return +v; }
- intvec operator-() const { return -v; }
+ intvec_t operator+() const { return +v; }
+ intvec_t operator-() const { return -v; }
- intvec operator+(intvec x) const { return v+x.v; }
- intvec operator-(intvec x) const { return v-x.v; }
- intvec operator*(intvec x) const { return v*x.v; }
- intvec operator/(intvec x) const { return v/x.v; }
- intvec operator%(intvec x) const { return v%x.v; }
+ intvec_t operator+(intvec_t x) const { return v+x.v; }
+ intvec_t operator-(intvec_t x) const { return v-x.v; }
+ intvec_t operator*(intvec_t x) const { return v*x.v; }
+ intvec_t operator/(intvec_t x) const { return v/x.v; }
+ intvec_t operator%(intvec_t x) const { return v%x.v; }
- intvec& operator+=(intvec const& x) { return *this=*this+x; }
- intvec& operator-=(intvec const& x) { return *this=*this-x; }
- intvec& operator*=(intvec const& x) { return *this=*this*x; }
- intvec& operator/=(intvec const& x) { return *this=*this/x; }
- intvec& operator%=(intvec const& x) { return *this=*this%x; }
+ intvec_t& operator+=(intvec_t const& x) { return *this=*this+x; }
+ intvec_t& operator-=(intvec_t const& x) { return *this=*this-x; }
+ intvec_t& operator*=(intvec_t const& x) { return *this=*this*x; }
+ intvec_t& operator/=(intvec_t const& x) { return *this=*this/x; }
+ intvec_t& operator%=(intvec_t const& x) { return *this=*this%x; }
- intvec operator~() const { return ~v; }
+ intvec_t operator~() const { return ~v; }
- intvec operator&(intvec x) const { return v&x.v; }
- intvec operator|(intvec x) const { return v|x.v; }
- intvec operator^(intvec x) const { return v^x.v; }
+ intvec_t operator&(intvec_t x) const { return v&x.v; }
+ intvec_t operator|(intvec_t x) const { return v|x.v; }
+ intvec_t operator^(intvec_t x) const { return v^x.v; }
- intvec& operator&=(intvec const& x) { return *this=*this&x; }
- intvec& operator|=(intvec const& x) { return *this=*this|x; }
- intvec& operator^=(intvec const& x) { return *this=*this^x; }
+ intvec_t& operator&=(intvec_t const& x) { return *this=*this&x; }
+ intvec_t& operator|=(intvec_t const& x) { return *this=*this|x; }
+ intvec_t& operator^=(intvec_t const& x) { return *this=*this^x; }
intvec_t bitifthen(intvec_t x, intvec_t y) const;
@@ -191,31 +191,31 @@ namespace vecmathlib {
intvec_t lsr(int_t n) const { return U(v) >> U(n); }
intvec_t rotate(int_t n) const;
- intvec operator>>(int_t n) const { return v>>n; }
- intvec operator<<(int_t n) const { return v<<n; }
+ intvec_t operator>>(int_t n) const { return v>>n; }
+ intvec_t operator<<(int_t n) const { return v<<n; }
- intvec& operator>>=(int_t n) { return *this=*this>>n; }
- intvec& operator<<=(int_t n) { return *this=*this<<n; }
+ intvec_t& operator>>=(int_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(int_t n) { return *this=*this<<n; }
intvec_t lsr(intvec_t n) const { return U(v) >> U(n); }
intvec_t rotate(intvec_t n) const;
- intvec operator>>(intvec n) const { return v>>n; }
- intvec operator<<(intvec n) const { return v<<n; }
+ intvec_t operator>>(intvec_t n) const { return v>>n; }
+ intvec_t operator<<(intvec_t n) const { return v<<n; }
- intvec& operator>>=(intvec n) { return *this=*this>>n; }
- intvec& operator<<=(intvec n) { return *this=*this<<n; }
+ intvec_t& operator>>=(intvec_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(intvec_t n) { return *this=*this<<n; }
intvec_t clz() const { return __builtin_clz(v); }
intvec_t popcount() const { return __builtin_popcount(v); }
- 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; }
- 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; }
+ boolvec_t operator==(intvec_t const& x) const { return v==x.v; }
+ boolvec_t operator!=(intvec_t const& x) const { return v!=x.v; }
+ boolvec_t operator<(intvec_t const& x) const { return v<x.v; }
+ boolvec_t operator<=(intvec_t const& x) const { return v<=x.v; }
+ boolvec_t operator>(intvec_t const& x) const { return v>x.v; }
+ boolvec_t operator>=(intvec_t const& x) const { return v>=x.v; }
intvec_t abs() const { return std::abs(v); }
boolvec_t isignbit() const { return v<0; }
@@ -272,7 +272,7 @@ namespace vecmathlib {
operator vector_t() const { return v; }
real_t operator[](int n) const { return v; }
- realvec& set_elt(int n, real_t a) { return v=a, *this; }
+ realvec_t& set_elt(int n, real_t a) { return v=a, *this; }
@@ -358,18 +358,18 @@ namespace vecmathlib {
- realvec operator+() const { return +v; }
- realvec operator-() const { return -v; }
+ realvec_t operator+() const { return +v; }
+ realvec_t operator-() const { return -v; }
- realvec operator+(realvec x) const { return v+x.v; }
- realvec operator-(realvec x) const { return v-x.v; }
- realvec operator*(realvec x) const { return v*x.v; }
- realvec operator/(realvec x) const { return v/x.v; }
+ realvec_t operator+(realvec_t x) const { return v+x.v; }
+ realvec_t operator-(realvec_t x) const { return v-x.v; }
+ realvec_t operator*(realvec_t x) const { return v*x.v; }
+ realvec_t operator/(realvec_t x) const { return v/x.v; }
- realvec& operator+=(realvec const& x) { return *this=*this+x; }
- realvec& operator-=(realvec const& x) { return *this=*this-x; }
- realvec& operator*=(realvec const& x) { return *this=*this*x; }
- realvec& operator/=(realvec const& x) { return *this=*this/x; }
+ realvec_t& operator+=(realvec_t const& x) { return *this=*this+x; }
+ realvec_t& operator-=(realvec_t const& x) { return *this=*this-x; }
+ realvec_t& operator*=(realvec_t const& x) { return *this=*this*x; }
+ realvec_t& operator/=(realvec_t const& x) { return *this=*this/x; }
real_t maxval() const { return *this; }
real_t minval() const { return *this; }
@@ -378,24 +378,24 @@ namespace vecmathlib {
- boolvec_t operator==(realvec const& x) const { return v==x.v; }
- boolvec_t operator!=(realvec const& x) const { return v!=x.v; }
- boolvec_t operator<(realvec const& x) const { return v<x.v; }
- boolvec_t operator<=(realvec const& x) const { return v<=x.v; }
- boolvec_t operator>(realvec const& x) const { return v>x.v; }
- boolvec_t operator>=(realvec const& x) const { return v>=x.v; }
+ boolvec_t operator==(realvec_t const& x) const { return v==x.v; }
+ boolvec_t operator!=(realvec_t const& x) const { return v!=x.v; }
+ boolvec_t operator<(realvec_t const& x) const { return v<x.v; }
+ boolvec_t operator<=(realvec_t const& x) const { return v<=x.v; }
+ boolvec_t operator>(realvec_t const& x) const { return v>x.v; }
+ boolvec_t operator>=(realvec_t const& x) const { return v>=x.v; }
- realvec acos() const { return MF::vml_acos(*this); }
- realvec acosh() const { return MF::vml_acosh(*this); }
- realvec asin() const { return MF::vml_asin(*this); }
- realvec asinh() const { return MF::vml_asinh(*this); }
- realvec atan() const { return MF::vml_atan(*this); }
- realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
- realvec atanh() const { return MF::vml_atanh(*this); }
- realvec cbrt() const { return MF::vml_cbrt(*this); }
- realvec ceil() const
+ realvec_t acos() const { return MF::vml_acos(*this); }
+ realvec_t acosh() const { return MF::vml_acosh(*this); }
+ realvec_t asin() const { return MF::vml_asin(*this); }
+ realvec_t asinh() const { return MF::vml_asinh(*this); }
+ realvec_t atan() const { return MF::vml_atan(*this); }
+ realvec_t atan2(realvec_t y) const { return MF::vml_atan2(*this, y); }
+ realvec_t atanh() const { return MF::vml_atanh(*this); }
+ realvec_t cbrt() const { return MF::vml_cbrt(*this); }
+ realvec_t ceil() const
{
#ifdef __SSE4_1__
return to_float(_mm_ceil_ss(from_float(v), from_float(v)));
@@ -403,16 +403,16 @@ namespace vecmathlib {
return vml_std::ceil(v);
#endif
}
- realvec copysign(realvec y) const { return vml_std::copysign(v, y.v); }
- realvec cos() const { return MF::vml_cos(*this); }
- realvec cosh() const { return MF::vml_cosh(*this); }
- realvec exp() const { return MF::vml_exp(*this); }
- realvec exp10() const { return MF::vml_exp10(*this); }
- realvec exp2() const { return MF::vml_exp2(*this); }
- realvec expm1() const { return MF::vml_expm1(*this); }
- realvec fabs() const { return vml_std::fabs(v); }
- realvec fdim(realvec y) const { return MF::vml_fdim(*this, y); }
- realvec floor() const
+ realvec_t copysign(realvec_t y) const { return vml_std::copysign(v, y.v); }
+ realvec_t cos() const { return MF::vml_cos(*this); }
+ realvec_t cosh() const { return MF::vml_cosh(*this); }
+ realvec_t exp() const { return MF::vml_exp(*this); }
+ realvec_t exp10() const { return MF::vml_exp10(*this); }
+ realvec_t exp2() const { return MF::vml_exp2(*this); }
+ realvec_t expm1() const { return MF::vml_expm1(*this); }
+ realvec_t fabs() const { return vml_std::fabs(v); }
+ realvec_t fdim(realvec_t y) const { return MF::vml_fdim(*this, y); }
+ realvec_t floor() const
{
#ifdef __SSE4_1__
return to_float(_mm_floor_ss(from_float(v), from_float(v)));
@@ -420,27 +420,30 @@ namespace vecmathlib {
return vml_std::floor(v);
#endif
}
- realvec fma(realvec y, realvec z) const { return MF::vml_fma(*this, y, z); }
- realvec fmax(realvec y) const
+ realvec_t fma(realvec_t y, realvec_t z) const
+ {
+ return MF::vml_fma(*this, y, z);
+ }
+ realvec_t fmax(realvec_t y) const
{
return to_float(_mm_max_ss(from_float(v), from_float(y.v)));
}
- realvec fmin(realvec y) const
+ realvec_t fmin(realvec_t y) const
{
return to_float(_mm_min_ss(from_float(v), from_float(y.v)));
}
- realvec fmod(realvec y) const { return vml_std::fmod(v, y.v); }
- realvec frexp(intvec_t* irp) const
+ realvec_t fmod(realvec_t y) const { return vml_std::fmod(v, y.v); }
+ realvec_t frexp(intvec_t* irp) const
{
int iri;
- realvec r = vml_std::frexp(v, &iri);
+ realvec_t r = vml_std::frexp(v, &iri);
int_t ir = iri;
if (isinf()) ir = std::numeric_limits<int_t>::max();
if (isnan()) ir = std::numeric_limits<int_t>::min();
irp->v = ir;
return r;
}
- realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); }
+ realvec_t hypot(realvec_t y) const { return MF::vml_hypot(*this, y); }
intvec_t ilogb() const
{
int_t r = vml_std::ilogb(v);
@@ -476,17 +479,23 @@ namespace vecmathlib {
#endif
}
boolvec_t isnormal() const { return vml_std::isnormal(v); }
- realvec ldexp(int_t n) const { return vml_std::ldexp(v, n); }
- realvec ldexp(intvec_t n) const { return vml_std::ldexp(v, n); }
- realvec log() const { return MF::vml_log(*this); }
- realvec log10() const { return MF::vml_log10(*this); }
- realvec log1p() const { return MF::vml_log1p(*this); }
- realvec log2() const { return MF::vml_log2(*this); }
- realvec nextafter(realvec y) const { return MF::vml_nextafter(*this, y); }
- realvec pow(realvec y) const { return MF::vml_pow(*this, y); }
- realvec rcp() const { return R(1.0)/v; }
- realvec remainder(realvec y) const { return vml_std::remainder(v, y.v); }
- realvec rint() const
+ realvec_t ldexp(int_t n) const { return vml_std::ldexp(v, n); }
+ realvec_t ldexp(intvec_t n) const { return vml_std::ldexp(v, n); }
+ realvec_t log() const { return MF::vml_log(*this); }
+ realvec_t log10() const { return MF::vml_log10(*this); }
+ realvec_t log1p() const { return MF::vml_log1p(*this); }
+ realvec_t log2() const { return MF::vml_log2(*this); }
+ realvec_t nextafter(realvec_t y) const
+ {
+ return MF::vml_nextafter(*this, y);
+ }
+ realvec_t pow(realvec_t y) const { return MF::vml_pow(*this, y); }
+ realvec_t rcp() const { return R(1.0)/v; }
+ realvec_t remainder(realvec_t y) const
+ {
+ return vml_std::remainder(v, y.v);
+ }
+ realvec_t rint() const
{
#ifdef __SSE4_1__
return to_float(_mm_round_ss(from_float(v), from_float(v),
@@ -495,15 +504,15 @@ namespace vecmathlib {
return MF::vml_rint(*this);
#endif
}
- realvec round() const { return MF::vml_round(*this); }
- realvec rsqrt() const { return MF::vml_rsqrt(*this); }
+ realvec_t round() const { return MF::vml_round(*this); }
+ realvec_t rsqrt() const { return MF::vml_rsqrt(*this); }
boolvec_t signbit() const { return vml_std::signbit(v); }
- realvec sin() const { return MF::vml_sin(*this); }
- realvec sinh() const { return MF::vml_sinh(*this); }
- realvec sqrt() const { return to_float(_mm_sqrt_ss(from_float(v))); }
- realvec tan() const { return MF::vml_tan(*this); }
- realvec tanh() const { return MF::vml_tanh(*this); }
- realvec trunc() const
+ realvec_t sin() const { return MF::vml_sin(*this); }
+ realvec_t sinh() const { return MF::vml_sinh(*this); }
+ realvec_t sqrt() const { return to_float(_mm_sqrt_ss(from_float(v))); }
+ realvec_t tan() const { return MF::vml_tan(*this); }
+ realvec_t tanh() const { return MF::vml_tanh(*this); }
+ realvec_t trunc() const
{
#ifdef __SSE4_1__
return to_float(_mm_round_ss(from_float(v), from_float(v),
diff --git a/vec_sse_float4.h b/vec_sse_float4.h
index 816e9d3..75e2421 100644
--- a/vec_sse_float4.h
+++ b/vec_sse_float4.h
@@ -92,7 +92,7 @@ namespace vecmathlib {
{
return to_bool(vecmathlib::get_elt<BV,bvector_t,uint_t>(v, n));
}
- boolvec& set_elt(int n, bool a)
+ boolvec_t& set_elt(int n, bool a)
{
return
vecmathlib::set_elt<BV,bvector_t,uint_t>(v, n, from_bool(a)), *this;
@@ -105,12 +105,12 @@ namespace vecmathlib {
- boolvec operator!() const { return _mm_xor_ps(boolvec(true), v); }
+ boolvec_t operator!() const { return _mm_xor_ps(boolvec(true), v); }
- boolvec operator&&(boolvec x) const { return _mm_and_ps(v, x.v); }
- boolvec operator||(boolvec x) const { return _mm_or_ps(v, x.v); }
- boolvec operator==(boolvec x) const { return !(*this!=x); }
- boolvec operator!=(boolvec x) const { return _mm_xor_ps(v, x.v); }
+ boolvec_t operator&&(boolvec_t x) const { return _mm_and_ps(v, x.v); }
+ boolvec_t operator||(boolvec_t x) const { return _mm_or_ps(v, x.v); }
+ boolvec_t operator==(boolvec_t x) const { return !(*this!=x); }
+ boolvec_t operator!=(boolvec_t x) const { return _mm_xor_ps(v, x.v); }
bool all() const
{
@@ -118,7 +118,7 @@ namespace vecmathlib {
#if defined __AVX__
return ! (! *this).any();
#else
- boolvec x = *this;
+ boolvec_t x = *this;
x = x && _mm_shuffle_ps(x.v, x.v, _MM_SHUFFLE(2,3,0,1));
return x[0] && x[2];
#endif
@@ -129,7 +129,7 @@ namespace vecmathlib {
#if defined __AVX__
return ! bool(_mm_testz_ps(v, v));
#else
- boolvec x = *this;
+ boolvec_t x = *this;
x = x || _mm_shuffle_ps(x.v, x.v, _MM_SHUFFLE(2,3,0,1));
return x[0] || x[2];
#endif
@@ -182,7 +182,7 @@ namespace vecmathlib {
intvec(ivector_t x): v(x) {}
intvec(int_t a): v(_mm_set1_epi32(a)) {}
intvec(int_t const* as): v(_mm_set_epi32(as[3], as[2], as[1], as[0])) {}
- static intvec iota() { return _mm_set_epi32(3, 2, 1, 0); }
+ static intvec_t iota() { return _mm_set_epi32(3, 2, 1, 0); }
operator ivector_t() const { return v; }
int_t operator[](int n) const
@@ -209,38 +209,38 @@ namespace vecmathlib {
// Note: not all arithmetic operations are supported!
- intvec operator+() const { return *this; }
- intvec operator-() const { return IV(0) - *this; }
+ intvec_t operator+() const { return *this; }
+ intvec_t operator-() const { return IV(0) - *this; }
- intvec operator+(intvec x) const { return _mm_add_epi32(v, x.v); }
- intvec operator-(intvec x) const { return _mm_sub_epi32(v, x.v); }
+ intvec_t operator+(intvec_t x) const { return _mm_add_epi32(v, x.v); }
+ intvec_t operator-(intvec_t x) const { return _mm_sub_epi32(v, x.v); }
- intvec& operator+=(intvec const& x) { return *this=*this+x; }
- intvec& operator-=(intvec const& x) { return *this=*this-x; }
+ intvec_t& operator+=(intvec_t const& x) { return *this=*this+x; }
+ intvec_t& operator-=(intvec_t const& x) { return *this=*this-x; }
- intvec operator~() const { return IV(~U(0)) ^ *this; }
+ intvec_t operator~() const { return IV(~U(0)) ^ *this; }
- intvec operator&(intvec x) const
+ intvec_t operator&(intvec_t x) const
{
return _mm_castps_si128(_mm_and_ps(_mm_castsi128_ps(v),
_mm_castsi128_ps(x.v)));
}
- intvec operator|(intvec x) const
+ intvec_t operator|(intvec_t x) const
{
return _mm_castps_si128(_mm_or_ps(_mm_castsi128_ps(v),
_mm_castsi128_ps(x.v)));
}
- intvec operator^(intvec x) const
+ intvec_t operator^(intvec_t x) const
{
return _mm_castps_si128(_mm_xor_ps(_mm_castsi128_ps(v),
_mm_castsi128_ps(x.v)));
}
- intvec& operator&=(intvec const& x) { return *this=*this&x; }
- intvec& operator|=(intvec const& x) { return *this=*this|x; }
- intvec& operator^=(intvec const& x) { return *this=*this^x; }
+ intvec_t& operator&=(intvec_t const& x) { return *this=*this&x; }
+ intvec_t& operator|=(intvec_t const& x) { return *this=*this|x; }
+ intvec_t& operator^=(intvec_t const& x) { return *this=*this^x; }
intvec_t bitifthen(intvec_t x, intvec_t y) const;
@@ -248,10 +248,10 @@ namespace vecmathlib {
intvec_t lsr(int_t n) const { return _mm_srli_epi32(v, n); }
intvec_t rotate(int_t n) const;
- intvec operator>>(int_t n) const { return _mm_srai_epi32(v, n); }
- intvec operator<<(int_t n) const { return _mm_slli_epi32(v, n); }
- intvec& operator>>=(int_t n) { return *this=*this>>n; }
- intvec& operator<<=(int_t n) { return *this=*this<<n; }
+ intvec_t operator>>(int_t n) const { return _mm_srai_epi32(v, n); }
+ intvec_t operator<<(int_t n) const { return _mm_slli_epi32(v, n); }
+ intvec_t& operator>>=(int_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(int_t n) { return *this=*this<<n; }
intvec_t lsr(intvec_t n) const
{
@@ -262,39 +262,39 @@ namespace vecmathlib {
return r;
}
intvec_t rotate(intvec_t n) const;
- intvec operator>>(intvec n) const
+ intvec_t operator>>(intvec_t n) const
{
- intvec r;
+ intvec_t r;
for (int i=0; i<size; ++i) {
r.set_elt(i, (*this)[i] >> n[i]);
}
return r;
}
- intvec operator<<(intvec n) const
+ intvec_t operator<<(intvec_t n) const
{
- intvec r;
+ intvec_t r;
for (int i=0; i<size; ++i) {
r.set_elt(i, (*this)[i] << n[i]);
}
return r;
}
- intvec& operator>>=(intvec n) { return *this=*this>>n; }
- intvec& operator<<=(intvec n) { return *this=*this<<n; }
+ intvec_t& operator>>=(intvec_t n) { return *this=*this>>n; }
+ intvec_t& operator<<=(intvec_t n) { return *this=*this<<n; }
intvec_t clz() const;
intvec_t popcount() const;
- boolvec_t operator==(intvec const& x) const
+ boolvec_t operator==(intvec_t const& x) const
{
return ! (*this != x);
}
- boolvec_t operator!=(intvec const& x) const
+ boolvec_t operator!=(intvec_t const& x) const
{
return (*this ^ x).convert_bool();
}
- boolvec_t operator<(intvec const& x) const
+ boolvec_t operator<(intvec_t const& x) const
{
// return (*this - x).as_bool();
boolvec_t r;
@@ -303,15 +303,15 @@ namespace vecmathlib {
}
return r;
}
- boolvec_t operator<=(intvec const& x) const
+ boolvec_t operator<=(intvec_t const& x) const
{
return ! (*this > x);
}
- boolvec_t operator>(intvec const& x) const
+ boolvec_t operator>(intvec_t const& x) const
{
return x < *this;
}
- boolvec_t operator>=(intvec const& x) const
+ boolvec_t operator>=(intvec_t const& x) const
{
return ! (*this < x);
}
@@ -475,18 +475,18 @@ namespace vecmathlib {
- realvec operator+() const { return *this; }
- realvec operator-() const { return RV(0.0) - *this; }
+ realvec_t operator+() const { return *this; }
+ realvec_t operator-() const { return RV(0.0) - *this; }
- realvec operator+(realvec x) const { return _mm_add_ps(v, x.v); }
- realvec operator-(realvec x) const { return _mm_sub_ps(v, x.v); }
- realvec operator*(realvec x) const { return _mm_mul_ps(v, x.v); }
- realvec operator/(realvec x) const { return _mm_div_ps(v, x.v); }
+ realvec_t operator+(realvec_t x) const { return _mm_add_ps(v, x.v); }
+ realvec_t operator-(realvec_t x) const { return _mm_sub_ps(v, x.v); }
+ realvec_t operator*(realvec_t x) const { return _mm_mul_ps(v, x.v); }
+ realvec_t operator/(realvec_t x) const { return _mm_div_ps(v, x.v); }
- realvec& operator+=(realvec const& x) { return *this=*this+x; }
- realvec& operator-=(realvec const& x) { return *this=*this-x; }
- realvec& operator*=(realvec const& x) { return *this=*this*x; }
- realvec& operator/=(realvec const& x) { return *this=*this/x; }
+ realvec_t& operator+=(realvec_t const& x) { return *this=*this+x; }
+ realvec_t& operator-=(realvec_t const& x) { return *this=*this-x; }
+ realvec_t& operator*=(realvec_t const& x) { return *this=*this*x; }
+ realvec_t& operator/=(realvec_t const& x) { return *this=*this/x; }
real_t maxval() const
{
@@ -517,7 +517,7 @@ namespace vecmathlib {
real_t sum() const
{
#ifdef __SSE3__
- realvec x = *this;
+ realvec_t x = *this;
x = _mm_hadd_ps(x.v, x.v);
x = _mm_hadd_ps(x.v, x.v);
return x[0];
@@ -532,42 +532,42 @@ namespace vecmathlib {
- boolvec_t operator==(realvec const& x) const
+ boolvec_t operator==(realvec_t const& x) const
{
return _mm_cmpeq_ps(v, x.v);
}
- boolvec_t operator!=(realvec const& x) const
+ boolvec_t operator!=(realvec_t const& x) const
{
return _mm_cmpneq_ps(v, x.v);
}
- boolvec_t operator<(realvec const& x) const
+ boolvec_t operator<(realvec_t const& x) const
{
return _mm_cmplt_ps(v, x.v);
}
- boolvec_t operator<=(realvec const& x) const
+ boolvec_t operator<=(realvec_t const& x) const
{
return _mm_cmple_ps(v, x.v);
}
- boolvec_t operator>(realvec const& x) const
+ boolvec_t operator>(realvec_t const& x) const
{
return _mm_cmpgt_ps(v, x.v);
}
- boolvec_t operator>=(realvec const& x) const
+ boolvec_t operator>=(realvec_t const& x) const
{
return _mm_cmpge_ps(v, x.v);
}
- realvec acos() const { return MF::vml_acos(*this); }
- realvec acosh() const { return MF::vml_acosh(*this); }
- realvec asin() const { return MF::vml_asin(*this); }
- realvec asinh() const { return MF::vml_asinh(*this); }
- realvec atan() const { return MF::vml_atan(*this); }
- realvec atan2(realvec y) const { return MF::vml_atan2(*this, y); }
- realvec atanh() const { return MF::vml_atanh(*this); }
- realvec cbrt() const { return MF::vml_cbrt(*this); }
- realvec ceil() const
+ realvec_t acos() const { return MF::vml_acos(*this); }
+ realvec_t acosh() const { return MF::vml_acosh(*this); }
+ realvec_t asin() const { return MF::vml_asin(*this); }
+ realvec_t asinh() const { return MF::vml_asinh(*this); }
+ realvec_t atan() const { return MF::vml_atan(*this); }
+ realvec_t atan2(realvec_t y) const { return MF::vml_atan2(*this, y); }
+ realvec_t atanh() const { return MF::vml_atanh(*this); }
+ realvec_t cbrt() const { return MF::vml_cbrt(*this); }
+ realvec_t ceil() const
{
#ifdef __SSE4_1__
return _mm_ceil_ps(v);
@@ -575,16 +575,16 @@ namespace vecmathlib {
return MF::vml_ceil(*this);
#endif
}
- realvec copysign(realvec y) const { return MF::vml_copysign(*this, y); }
- realvec cos() const { return MF::vml_cos(*this); }
- realvec cosh() const { return MF::vml_cosh(*this); }
- realvec exp() const { return MF::vml_exp(*this); }
- realvec exp10() const { return MF::vml_exp10(*this); }
- realvec exp2() const { return MF::vml_exp2(*this); }
- realvec expm1() const { return MF::vml_expm1(*this); }
- realvec fabs() const { return MF::vml_fabs(*this); }
- realvec fdim(realvec y) const { return MF::vml_fdim(*this, y); }
- realvec floor() const
+ realvec_t copysign(realvec_t y) const { return MF::vml_copysign(*this, y); }
+ realvec_t cos() const { return MF::vml_cos(*this); }
+ realvec_t cosh() const { return MF::vml_cosh(*this); }
+ realvec_t exp() const { return MF::vml_exp(*this); }
+ realvec_t exp10() const { return MF::vml_exp10(*this); }
+ realvec_t exp2() const { return MF::vml_exp2(*this); }
+ realvec_t expm1() const { return MF::vml_expm1(*this); }
+ realvec_t fabs() const { return MF::vml_fabs(*this); }
+ realvec_t fdim(realvec_t y) const { return MF::vml_fdim(*this, y); }
+ realvec_t floor() const
{
#ifdef __SSE4_1__
return _mm_floor_ps(v);
@@ -592,12 +592,15 @@ namespace vecmathlib {
return MF::vml_floor(*this);
#endif
}
- realvec fma(realvec y, realvec z) const { return MF::vml_fma(*this, y, z); }
- realvec fmax(realvec y) const { return _mm_max_ps(v, y.v); }
- realvec fmin(realvec y) const { return _mm_min_ps(v, y.v); }
- realvec fmod(realvec y) const { return MF::vml_fmod(*this, y); }
- realvec frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); }
- realvec hypot(realvec y) const { return MF::vml_hypot(*this, y); }
+ realvec_t fma(realvec_t y, realvec_t z) const
+ {
+ return MF::vml_fma(*this, y, z);
+ }
+ realvec_t fmax(realvec_t y) const { return _mm_max_ps(v, y.v); }
+ realvec_t fmin(realvec_t y) const { return _mm_min_ps(v, y.v); }
+ realvec_t fmod(realvec_t y) const { return MF::vml_fmod(*this, y); }
+ realvec_t frexp(intvec_t* r) const { return MF::vml_frexp(*this, r); }
+ realvec_t hypot(realvec_t y) const { return MF::vml_hypot(*this, y); }
intvec_t ilogb() const { return MF::vml_ilogb(*this); }
boolvec_t isfinite() const { return MF::vml_isfinite(*this); }
boolvec_t isinf() const { return MF::vml_isinf(*this); }
@@ -610,23 +613,26 @@ namespace vecmathlib {
#endif
}
boolvec_t isnormal() const { return MF::vml_isnormal(*this); }
- realvec ldexp(int_t n) const { return MF::vml_ldexp(*this, n); }
- realvec ldexp(intvec_t n) const { return MF::vml_ldexp(*this, n); }
- realvec log() const { return MF::vml_log(*this); }
- realvec log10() const { return MF::vml_log10(*this); }
- realvec log1p() const { return MF::vml_log1p(*this); }
- realvec log2() const { return MF::vml_log2(*this); }
- realvec nextafter(realvec y) const { return MF::vml_nextafter(*this, y); }
- realvec pow(realvec y) const { return MF::vml_pow(*this, y); }
- realvec rcp() const
- {
- realvec x = *this;
- realvec r = _mm_rcp_ps(x); // this is only an approximation
+ realvec_t ldexp(int_t n) const { return MF::vml_ldexp(*this, n); }
+ realvec_t ldexp(intvec_t n) const { return MF::vml_ldexp(*this, n); }
+ realvec_t log() const { return MF::vml_log(*this); }
+ realvec_t log10() const { return MF::vml_log10(*this); }
+ realvec_t log1p() const { return MF::vml_log1p(*this); }
+ realvec_t log2() const { return MF::vml_log2(*this); }
+ realvec_t nextafter(realvec_t y) const
+ {
+ return MF::vml_nextafter(*this, y);
+ }
+ realvec_t pow(realvec_t y) const { return MF::vml_pow(*this, y); }
+ realvec_t rcp() const
+ {
+ realvec_t x = *this;
+ realvec_t r = _mm_rcp_ps(x); // this is only an approximation
r *= RV(2.0) - r*x; // one Newton iteration (see vml_rcp)
return r;
}
- realvec remainder(realvec y) const { return MF::vml_remainder(*this, y); }
- realvec rint() const
+ realvec_t remainder(realvec_t y) const { return MF::vml_remainder(*this, y); }
+ realvec_t rint() const
{
#ifdef __SSE4_1__
return _mm_round_ps(v, _MM_FROUND_TO_NEAREST_INT);
@@ -634,21 +640,21 @@ namespace vecmathlib {
return MF::vml_rint(*this);
#endif
}
- realvec round() const { return MF::vml_round(*this); }
- realvec rsqrt() const
+ realvec_t round() const { return MF::vml_round(*this); }
+ realvec_t rsqrt() const
{
- realvec x = *this;
- realvec r = _mm_rsqrt_ps(x); // this is only an approximation
+ realvec_t x = *this;
+ realvec_t r = _mm_rsqrt_ps(x); // this is only an approximation
r *= RV(1.5) - RV(0.5)*x * r*r; // one Newton iteration (see vml_rsqrt)
return r;
}
boolvec_t signbit() const { return v; }
- realvec sin() const { return MF::vml_sin(*this); }
- realvec sinh() const { return MF::vml_sinh(*this); }
- realvec sqrt() const { return _mm_sqrt_ps(v); }
- realvec tan() const { return MF::vml_tan(*this); }
- realvec tanh() const { return MF::vml_tanh(*this); }
- realvec trunc() const
+ realvec_t sin() const { return MF::vml_sin(*this); }
+ realvec_t sinh() const { return MF::vml_sinh(*this); }
+ realvec_t sqrt() const { return _mm_sqrt_ps(v); }
+ realvec_t tan() const { return MF::vml_tan(*this); }
+ realvec_t tanh() const { return MF::vml_tanh(*this); }
+ realvec_t trunc() const
{
#ifdef __SSE4_1__
return _mm_round_ps(v, _MM_FROUND_TO_ZERO);
OpenPOWER on IntegriCloud