diff options
author | mingli <mingli@multicorewareinc.com> | 2013-12-05 09:54:10 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-12-18 20:34:58 -0600 |
commit | 3c32af65d42b2091e0557e238581fead39dea072 (patch) | |
tree | d28988ee473fa023e6d9fa10446e1c57915f5305 /sc/source/core/opencl/opinlinefun_statistical.cxx | |
parent | d2fe0c84f30092ba7da2d9d5d8a39841608336c1 (diff) |
GPU Calc: Optimized GAUSS
AMLOEXT-276
Change-Id: I29517305ffda2673961c2fa4dc46503690933645
Signed-off-by: haochen <haochen@multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei@multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc/source/core/opencl/opinlinefun_statistical.cxx')
-rw-r--r-- | sc/source/core/opencl/opinlinefun_statistical.cxx | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/sc/source/core/opencl/opinlinefun_statistical.cxx b/sc/source/core/opencl/opinlinefun_statistical.cxx index 81e8150b06bf..ab034794dc15 100644 --- a/sc/source/core/opencl/opinlinefun_statistical.cxx +++ b/sc/source/core/opencl/opinlinefun_statistical.cxx @@ -1272,7 +1272,76 @@ std::string lcl_IterateInverse = " }\n" " return fRx;\n" "}\n"; - +std::string phiDecl= +"double phi(double x);\n"; +std::string phi = +"double phi(double x)\n" +"{\n" +" return 0.39894228040143268 * exp(-(x * x) / 2.0);\n" +"}\n"; +std::string taylorDecl = +"double taylor(double* pPolynom, uint nMax, double x);\n"; +std::string taylor = +"double taylor(double* pPolynom, uint nMax, double x)\n" +"{\n" +" double nVal = pPolynom[nMax];\n" +" for (short i = nMax-1; i >= 0; i--)\n" +" {\n" +" nVal = pPolynom[i] + (nVal * x);\n" +" }\n" +" return nVal;\n" +"}"; +std::string gaussDecl = "double gauss(double x);\n"; +std::string gauss = +"double gauss(double x)\n" +"{\n" +" double xAbs = fabs(x);\n" +" uint xShort = (uint)(floor(xAbs));\n" +" double nVal = 0.0;\n" +" if (xShort == 0)\n" +" {\n" +" double t0[] =\n" +" { 0.39894228040143268, -0.06649038006690545, 0.00997355701003582,\n" +" -0.00118732821548045, 0.00011543468761616, -0.00000944465625950,\n" +" 0.00000066596935163, -0.00000004122667415, 0.00000000227352982,\n" +" 0.00000000011301172, 0.00000000000511243, -0.00000000000021218 };\n" +" nVal = taylor(t0, 11, (xAbs * xAbs)) * xAbs;\n" +" }\n" +" else if ((xShort >= 1) && (xShort <= 2))\n" +" {\n" +" double t2[] =\n" +" { 0.47724986805182079, 0.05399096651318805, -0.05399096651318805,\n" +" 0.02699548325659403, -0.00449924720943234, -0.00224962360471617,\n" +" 0.00134977416282970, -0.00011783742691370, -0.00011515930357476,\n" +" 0.00003704737285544, 0.00000282690796889, -0.00000354513195524,\n" +" 0.00000037669563126, 0.00000019202407921, -0.00000005226908590,\n" +" -0.00000000491799345, 0.00000000366377919, -0.00000000015981997,\n" +" -0.00000000017381238, 0.00000000002624031, 0.00000000000560919,\n" +" -0.00000000000172127, -0.00000000000008634, 0.00000000000007894 };\n" +" nVal = taylor(t2, 23, (xAbs - 2.0));\n" +" }\n" +" else if ((xShort >= 3) && (xShort <= 4))\n" +" {\n" +" double t4[] =\n" +" { 0.49996832875816688, 0.00013383022576489, -0.00026766045152977,\n" +" 0.00033457556441221, -0.00028996548915725, 0.00018178605666397,\n" +" -0.00008252863922168, 0.00002551802519049, -0.00000391665839292,\n" +" -0.00000074018205222, 0.00000064422023359, -0.00000017370155340,\n" +" 0.00000000909595465, 0.00000000944943118, -0.00000000329957075,\n" +" 0.00000000029492075, 0.00000000011874477, -0.00000000004420396,\n" +" 0.00000000000361422, 0.00000000000143638, -0.00000000000045848 };\n" +" nVal = taylor(t4, 20, (xAbs - 4.0));\n" +" }\n" +" else\n" +" {\n" +" double asympt[] = { -1.0, 1.0, -3.0, 15.0, -105.0 };\n" +" nVal = 0.5 + phi(xAbs) * taylor(asympt, 4, 1.0/(xAbs * xAbs))/xAbs;\n" +" }\n" +" if (x < 0.0)\n" +" return -nVal;\n" +" else\n" +" return nVal;\n" +"}\n"; #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |