MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / CND

Function CND

cpp/5_Domain_Specific/binomialOptions/binomialOptions_gold.cpp:37–54  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Polynomial approximation of cumulative normal distribution function //////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

35// Polynomial approximation of cumulative normal distribution function
36///////////////////////////////////////////////////////////////////////////////
37static real CND(real d)
38{
39 const real A1 = (real)0.31938153;
40 const real A2 = (real)-0.356563782;
41 const real A3 = (real)1.781477937;
42 const real A4 = (real)-1.821255978;
43 const real A5 = (real)1.330274429;
44 const real RSQRT2PI = (real)0.39894228040143267793994605993438;
45
46 real K = (real)(1.0 / (1.0 + 0.2316419 * (real)fabs(d)));
47
48 real cnd = (real)RSQRT2PI * (real)exp(-0.5 * d * d) * (K * (A1 + K * (A2 + K * (A3 + K * (A4 + K * A5)))));
49
50 if (d > 0)
51 cnd = (real)1.0 - cnd;
52
53 return cnd;
54}
55
56extern "C" void BlackScholesCall(real &callResult, TOptionData optionData)
57{

Callers 1

BlackScholesCallFunction · 0.70

Calls 2

fabsFunction · 0.85
expFunction · 0.85

Tested by

no test coverage detected