Change erfcinv for 2.5, format the file
tabs -> spaces, CLRF -> LF
MODIFY
test/test_random.cpp
test/test_random.cpp
#include <thrust/random.h>
#include <thrust/random/detail/normal_distribution_base.h>
+#include <cmath>
#include <limits>
#include <sstream>
@@ -861,7 +862,7 @@ TEST(RandomTests, erfcinvFunction)
}
float inf_f = std::numeric_limits<float>::infinity();
- float nan_f = std::nan("undefined");
+ float nan_f = std::nanf("undefined");
float float_inputs[8]
= {-3.0f,

MODIFY
thrust/random/detail/erfcinv.h
thrust/random/detail/erfcinv.h
@@ -21,6 +21,9 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma once
+#include <cmath>
+#include <limits>
+
/* sqrt(2pi) */
static double s2pi = 2.50662827463100050242E0;
static const double one_o_sqrt2 = (1/sqrt(2.0));
@@ -141,14 +144,12 @@ static inline double p1evl(double x, double coef[], int N)
return (ans);
}
-__host__
+static inline
double ndtri(double y0)
{
double x, y, z, y2, x0, x1;
int code;
-
-
code = 1;
y = y0;
if (y > (1.0 - 0.13533528323661269189)) { /* 0.135... = exp(-2) */
@@ -178,9 +179,10 @@ double ndtri(double y0)
return (x);
}
- __host__
- double erfcinv(double x){
- if (x < 0.0){
+static inline
+double erfcinv(double x)
+{
+ if (x < 0.0 || x > 2.0) {
return std::nan("undefined");
}
if (x == 0.0) {
@@ -189,9 +191,5 @@ double ndtri(double y0)
if (x == 2.0) {
return -std::numeric_limits<double>::infinity();
}
- if (x > 2.0) {
- return std::nan("undefined");
- }
-
return -ndtri(0.5*x) * one_o_sqrt2;
}

Change erfcinv for 2.5, format the file

tabs -> spaces, CLRF -> LF