diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-07-04 15:34:24 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-07-04 15:34:24 -0400 |
commit | 5941fd3d7816669eee6dd078a3f8711f7e691d47 (patch) | |
tree | d704d8e756dae6c016e73c3b9543fe903690fc31 /vec_sse_float4.h | |
parent | 8d00c5fb205e9df9c8899910ab4528bbbd2f2d4d (diff) | |
download | vecmathlib-5941fd3d7816669eee6dd078a3f8711f7e691d47.zip vecmathlib-5941fd3d7816669eee6dd078a3f8711f7e691d47.tar.gz |
Implement maxval and minval reduction operations
Diffstat (limited to 'vec_sse_float4.h')
-rw-r--r-- | vec_sse_float4.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/vec_sse_float4.h b/vec_sse_float4.h index c50eb2e..1466013 100644 --- a/vec_sse_float4.h +++ b/vec_sse_float4.h @@ -479,6 +479,24 @@ namespace vecmathlib { realvec& operator*=(realvec const& x) { return *this=*this*x; } realvec& operator/=(realvec const& x) { return *this=*this/x; } + real_t maxval() const + { + // return std::fmax(std::fmax((*this)[0], (*this)[1]), + // std::fmax((*this)[2], (*this)[3])); + realvec_t x0123 = *this; + realvec_t x1032 = _mm_shuffle_ps(x0123, x0123, 0b10110001); + realvec_t y0022 = x0123.fmax(x1032); + return std::fmax(y0022[0], y0022[2]); + } + real_t minval() const + { + // return std::fmin(std::fmin((*this)[0], (*this)[1]), + // std::fmin((*this)[2], (*this)[3])); + realvec_t x0123 = *this; + realvec_t x1032 = _mm_shuffle_ps(x0123, x0123, 0b10110001); + realvec_t y0022 = x0123.fmin(x1032); + return std::fmin(y0022[0], y0022[2]); + } real_t prod() const { return (*this)[0] * (*this)[1] * (*this)[2] * (*this)[3]; |