diff options
author | Lucas Crowthers <lucasc@codeaurora.org> | 2012-11-07 16:30:44 -0500 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2012-12-21 17:16:58 -0800 |
commit | 4051162fbcd991e04a2ad1b86a0b2a12718cda20 (patch) | |
tree | 33ddf197a5ed214915606995c892f449722c9b77 | |
parent | 554c1ce09343cb452d86f2805ffa06e4f24590ac (diff) | |
download | bionic-4051162fbcd991e04a2ad1b86a0b2a12718cda20.zip bionic-4051162fbcd991e04a2ad1b86a0b2a12718cda20.tar.gz bionic-4051162fbcd991e04a2ad1b86a0b2a12718cda20.tar.bz2 |
Bionic/libm: Add precision-correct de-serialize sin/cos
Modify sin/cos to improve performance while retaining bit-for-bit
accuracy with existing algorithm.
Change-Id: Icbd6d66fb1c0ceb53f43fed6541e0c89cc6e7a63
-rw-r--r-- | libm/src/k_cos.c | 12 | ||||
-rw-r--r-- | libm/src/k_sin.c | 11 |
2 files changed, 23 insertions, 0 deletions
diff --git a/libm/src/k_cos.c b/libm/src/k_cos.c index 00916d7..b8cdf8f 100644 --- a/libm/src/k_cos.c +++ b/libm/src/k_cos.c @@ -69,6 +69,17 @@ C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ double __kernel_cos(double x, double y) { +#if defined(KRAIT_NEON_OPTIMIZATION) + double hz,z,zz,r,w,k; + + z = x*x; + zz = z*z; + k = x*y; + hz = (float)0.5*z; + r = z*(z*(C1+z*(C2+z*((C3+z*C4)+zz*(C5+z*C6))))); + w = one-hz; + return w + (((one-w)-hz) + (r-k)); +#else double hz,z,r,w; z = x*x; @@ -76,4 +87,5 @@ __kernel_cos(double x, double y) hz = (float)0.5*z; w = one-hz; return w + (((one-w)-hz) + (z*r-x*y)); +#endif } diff --git a/libm/src/k_sin.c b/libm/src/k_sin.c index ae06a9d..ee641d4 100644 --- a/libm/src/k_sin.c +++ b/libm/src/k_sin.c @@ -60,6 +60,16 @@ S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ double __kernel_sin(double x, double y, int iy) { +#if defined(KRAIT_NEON_OPTIMIZATION) + double z,zz,r,v; + + z = x*x; + zz = z*z; + v = z*x; + r = S2+z*((S3+z*S4)+zz*(S5+z*S6)); + if(iy==0) return x+v*(S1+z*r); + else return x-((z*(half*y-v*r)-y)-v*S1); +#else double z,r,v; z = x*x; @@ -67,4 +77,5 @@ __kernel_sin(double x, double y, int iy) r = S2+z*(S3+z*(S4+z*(S5+z*S6))); if(iy==0) return x+v*(S1+z*r); else return x-((z*(half*y-v*r)-y)-v*S1); +#endif } |