]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - Vc/include/Vc/sse/math.h
update to Vc 0.7.3-dev
[u/mrichter/AliRoot.git] / Vc / include / Vc / sse / math.h
index d6e34309096d3972de3fb6e65505e9a60f2b7c95..57ad7e16a19339d2c05d0cf24e4339dde9ed3f97 100644 (file)
@@ -21,7 +21,9 @@
 #define VC_SSE_MATH_H
 
 #include "const.h"
+#include "macros.h"
 
+namespace AliRoot {
 namespace Vc
 {
 namespace SSE
@@ -97,10 +99,16 @@ namespace SSE
     }
 
 #ifdef VC_IMPL_SSE4_1
+    inline double_v trunc(double_v::AsArg v) { return _mm_round_pd(v.data(), 0x3); }
+    inline float_v trunc(float_v::AsArg v) { return _mm_round_ps(v.data(), 0x3); }
+    inline sfloat_v trunc(sfloat_v::AsArg v) { return M256::create(_mm_round_ps(v.data()[0], 0x3),
+            _mm_round_ps(v.data()[1], 0x3)); }
+
     inline double_v floor(double_v::AsArg v) { return _mm_floor_pd(v.data()); }
     inline float_v floor(float_v::AsArg v) { return _mm_floor_ps(v.data()); }
     inline sfloat_v floor(sfloat_v::AsArg v) { return M256::create(_mm_floor_ps(v.data()[0]),
             _mm_floor_ps(v.data()[1])); }
+
     inline double_v ceil(double_v::AsArg v) { return _mm_ceil_pd(v.data()); }
     inline float_v ceil(float_v::AsArg v) { return _mm_ceil_ps(v.data()); }
     inline sfloat_v ceil(sfloat_v::AsArg v) { return M256::create(_mm_ceil_ps(v.data()[0]),
@@ -139,7 +147,25 @@ namespace SSE
     }
 
     template<typename T>
-    inline Vector<T> floor(Vector<T> _v) {
+    inline Vector<T> trunc(VC_ALIGNED_PARAMETER(Vector<T>) _v) {
+        typedef Vector<T> V;
+        typedef typename V::Mask M;
+
+        V v = _v;
+        V e = abs(v).exponent();
+        const M negativeExponent = e < 0;
+        e.setZero(negativeExponent);
+        //const M negativeInput = v < V::Zero();
+
+        floor_shift(v, e);
+
+        v.setZero(negativeExponent);
+        //v(negativeInput && _v != v) -= V::One();
+        return v;
+    }
+
+    template<typename T>
+    inline Vector<T> floor(VC_ALIGNED_PARAMETER(Vector<T>) _v) {
         typedef Vector<T> V;
         typedef typename V::Mask M;
 
@@ -157,7 +183,7 @@ namespace SSE
     }
 
     template<typename T>
-    inline Vector<T> ceil(Vector<T> _v) {
+    inline Vector<T> ceil(VC_ALIGNED_PARAMETER(Vector<T>) _v) {
         typedef Vector<T> V;
         typedef typename V::Mask M;
 
@@ -176,6 +202,9 @@ namespace SSE
 #endif
 } // namespace SSE
 } // namespace Vc
+} // namespace AliRoot
+
+#include "undomacros.h"
 
 #define VC__USE_NAMESPACE SSE
 #include "../common/trigonometric.h"