From 798aa48032e6157c07d74c1ed6ccc1347d2d10e2 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Sat, 11 Jun 2016 17:05:46 -0500 Subject: [PATCH] added normcdf support Change-Id: I4887bc588589ed067eaa339d5eccd988c1c5d649 --- src/device_util.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/device_util.cpp b/src/device_util.cpp index cd57e54af3..29a125dce7 100644 --- a/src/device_util.cpp +++ b/src/device_util.cpp @@ -228,7 +228,14 @@ __device__ float norm4df(float a, float b, float c, float d) float y = c*c + d*d; return hc::precise_math::sqrtf(x+y); } -__device__ float normcdff(float y); +/* +The below conversion seems easy, takes a +full page of integral calculus to deduce the following equation +*/ +__device__ float normcdff(float y) +{ + return ((hc::precise_math::erff(y)/1.41421356237) + 1)/2; +} __device__ float normcdfinvf(float y); __device__ float normf(int dim, const float *a) { @@ -541,6 +548,10 @@ __device__ double norm4d(double a, double b, double c, double d) double y = c*c + d*d; return hc::precise_math::sqrt(x+y); } +__device__ double normcdf(float y) +{ + return ((hc::precise_math::erf(y)/1.41421356237) + 1)/2; +} __device__ double pow(double x, double y) { return hc::precise_math::pow(x, y);