Enable fp-exceptions
[alexxy/gromacs.git] / src / gromacs / simd / tests / simd_math.cpp
index 17c61ce05e3b58c717182dd7cd10d070d25ce340..b1f6eca529090642ec8e6a20e27ca9ea115aa8a5 100644 (file)
@@ -125,7 +125,8 @@ SimdMathTest::compareSimdMathFunction(const char * refFuncExpr, const char *simd
         {
             absDiff = fabs(vref[i]-vtst[i]);
             absOk   = absOk  && ( absDiff < absTol_ );
-            signOk  = signOk && ( vref[i]*vtst[i] >= 0 );
+            signOk  = signOk && ( (vref[i] >= 0 && vtst[i] >= 0) ||
+                                  (vref[i] <= 0 && vtst[i] <= 0));
 
             if (absDiff >= absTol_)
             {
@@ -477,8 +478,15 @@ TEST_F(SimdMathTest, gmxSimdAtan2R)
 /*! \brief Evaluate reference version of PME force correction. */
 real ref_pmecorrF(real x)
 {
-    real y = sqrt(x);
-    return 2*exp(-x)/(sqrt(M_PI)*x) - gmx_erfd(y)/(x*y);
+    if (x != 0)
+    {
+        real y = sqrt(x);
+        return 2*exp(-x)/(sqrt(M_PI)*x) - gmx_erfd(y)/(x*y);
+    }
+    else
+    {
+        return -4/(3*sqrt(M_PI));
+    }
 }
 
 // The PME corrections will be added to ~1/r2, so absolute tolerance of EPS is fine.