diff options
author | Stefan Eßer <se@FreeBSD.org> | 2020-09-20 05:32:53 +0000 |
---|---|---|
committer | Stefan Eßer <se@FreeBSD.org> | 2020-09-20 05:32:53 +0000 |
commit | fcce470c2ba5e2ce59d6091fd5be6d6050948d5f (patch) | |
tree | 4537144ff1eea274f7db5ab9d97fae89f5c747aa /lib/msun/src/k_exp.c | |
parent | a67cc943273ba7cba2f78e33fc5897e1fbecd462 (diff) | |
download | src-fcce470c2ba5e2ce59d6091fd5be6d6050948d5f.tar.gz src-fcce470c2ba5e2ce59d6091fd5be6d6050948d5f.zip |
Apply an opimization for the kernels used by cexp(x) and cexpf(x) submitted
by Steve Kargl:
- Use sincos[f] instead of a call to cos[f] and a call to sin[f].
- While here, alphabetize declaration.
Submitted by: sgk at troutmask.apl.washington.edu (Steve Kargl)
Notes
Notes:
svn path=/head/; revision=365922
Diffstat (limited to 'lib/msun/src/k_exp.c')
-rw-r--r-- | lib/msun/src/k_exp.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/msun/src/k_exp.c b/lib/msun/src/k_exp.c index c6dfc953c39d..dd15ff4cb0ed 100644 --- a/lib/msun/src/k_exp.c +++ b/lib/msun/src/k_exp.c @@ -88,7 +88,7 @@ __ldexp_exp(double x, int expt) double complex __ldexp_cexp(double complex z, int expt) { - double x, y, exp_x, scale1, scale2; + double c, exp_x, s, scale1, scale2, x, y; int ex_expt, half_expt; x = creal(z); @@ -105,6 +105,7 @@ __ldexp_cexp(double complex z, int expt) half_expt = expt - half_expt; INSERT_WORDS(scale2, (0x3ff + half_expt) << 20, 0); - return (CMPLX(cos(y) * exp_x * scale1 * scale2, - sin(y) * exp_x * scale1 * scale2)); + sincos(y, &s, &c); + return (CMPLX(c * exp_x * scale1 * scale2, + s * exp_x * scale1 * scale2)); } |