[Beignet] [PATCH] Improve the accuracy of built-in function asin.
Yi Sun
yi.sun at intel.com
Tue Aug 6 07:02:49 PDT 2013
Method: asin(x) = x + (1 * x^3)/(2 * 3) + (1 * 3 * x^5)/(2*4 * 5) + \
(1 * 3 * 5 * x^7)/(2*4*6 * 7) + ...
Iterate this for 30 times.
Signed-off-by: Yi Sun <yi.sun at intel.com>
---
backend/src/ocl_stdlib.tmpl.h | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
index c972a3e..8002a85 100644
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -562,7 +562,16 @@ INLINE_OVERLOADABLE float __gen_ocl_internal_tanh(float x) {
return (1 - y) / (1 + y);
}
INLINE_OVERLOADABLE float __gen_ocl_internal_asin(float x) {
- return x + __gen_ocl_pow(x, 3) / 6 + __gen_ocl_pow(x, 5) * 3 / 40 + __gen_ocl_pow(x, 7) * 5 / 112;
+ float sum = x, c = x, m = 1.0;
+ int n = 1;
+ do
+ {
+ c *= (2 * n - 1) * x * x;
+ m *= (2 * n);
+ sum += ( c / m / (2 * n + 1));
+ n++;
+ }while( n < 30);
+ return sum;
}
INLINE_OVERLOADABLE float __gen_ocl_internal_asinpi(float x) {
return __gen_ocl_internal_asin(x) / M_PI_F;
--
1.7.6.4
More information about the Beignet
mailing list