| 1 |
diff --git a/k_exp.cpp b/k_exp.cpp |
| 2 |
--- a/k_exp.cpp |
| 3 |
+++ b/k_exp.cpp |
| 4 |
@@ -24,18 +24,16 @@ |
| 5 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 6 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 7 |
* SUCH DAMAGE. |
| 8 |
*/ |
| 9 |
|
| 10 |
//#include <sys/cdefs.h> |
| 11 |
//__FBSDID("$FreeBSD$"); |
| 12 |
|
| 13 |
-#include <complex.h> |
| 14 |
- |
| 15 |
#include "math_private.h" |
| 16 |
|
| 17 |
static const uint32_t k = 1799; /* constant for reduction */ |
| 18 |
static const double kln2 = 1246.97177782734161156; /* k * ln2 */ |
| 19 |
|
| 20 |
/* |
| 21 |
* Compute exp(x), scaled to avoid spurious overflow. An exponent is |
| 22 |
* returned separately in 'expt'. |
| 23 |
@@ -78,33 +76,8 @@ __ldexp_exp(double x, int expt) |
| 24 |
double exp_x, scale; |
| 25 |
int ex_expt; |
| 26 |
|
| 27 |
exp_x = __frexp_exp(x, &ex_expt); |
| 28 |
expt += ex_expt; |
| 29 |
INSERT_WORDS(scale, (0x3ff + expt) << 20, 0); |
| 30 |
return (exp_x * scale); |
| 31 |
} |
| 32 |
- |
| 33 |
-double complex |
| 34 |
-__ldexp_cexp(double complex z, int expt) |
| 35 |
-{ |
| 36 |
- double c, exp_x, s, scale1, scale2, x, y; |
| 37 |
- int ex_expt, half_expt; |
| 38 |
- |
| 39 |
- x = creal(z); |
| 40 |
- y = cimag(z); |
| 41 |
- exp_x = __frexp_exp(x, &ex_expt); |
| 42 |
- expt += ex_expt; |
| 43 |
- |
| 44 |
- /* |
| 45 |
- * Arrange so that scale1 * scale2 == 2**expt. We use this to |
| 46 |
- * compensate for scalbn being horrendously slow. |
| 47 |
- */ |
| 48 |
- half_expt = expt / 2; |
| 49 |
- INSERT_WORDS(scale1, (0x3ff + half_expt) << 20, 0); |
| 50 |
- half_expt = expt - half_expt; |
| 51 |
- INSERT_WORDS(scale2, (0x3ff + half_expt) << 20, 0); |
| 52 |
- |
| 53 |
- sincos(y, &s, &c); |
| 54 |
- return (CMPLX(c * exp_x * scale1 * scale2, |
| 55 |
- s * exp_x * scale1 * scale2)); |
| 56 |
-} |
| 57 |
--- a/k_expf.cpp 2022-12-13 14:39:11.791594163 -0500 |
| 58 |
+++ b/k_expf.cpp 2022-12-13 14:39:18.631622916 -0500 |
| 59 |
@@ -24,18 +24,16 @@ |
| 60 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 61 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 62 |
* SUCH DAMAGE. |
| 63 |
*/ |
| 64 |
|
| 65 |
//#include <sys/cdefs.h> |
| 66 |
//__FBSDID("$FreeBSD$"); |
| 67 |
|
| 68 |
-#include <complex.h> |
| 69 |
- |
| 70 |
#include "math_private.h" |
| 71 |
|
| 72 |
static const uint32_t k = 235; /* constant for reduction */ |
| 73 |
static const float kln2 = 162.88958740F; /* k * ln2 */ |
| 74 |
|
| 75 |
/* |
| 76 |
* See k_exp.c for details. |
| 77 |
* |
| 78 |
@@ -61,29 +59,8 @@ |
| 79 |
float exp_x, scale; |
| 80 |
int ex_expt; |
| 81 |
|
| 82 |
exp_x = __frexp_expf(x, &ex_expt); |
| 83 |
expt += ex_expt; |
| 84 |
SET_FLOAT_WORD(scale, (0x7f + expt) << 23); |
| 85 |
return (exp_x * scale); |
| 86 |
} |
| 87 |
- |
| 88 |
-float complex |
| 89 |
-__ldexp_cexpf(float complex z, int expt) |
| 90 |
-{ |
| 91 |
- float c, exp_x, s, scale1, scale2, x, y; |
| 92 |
- int ex_expt, half_expt; |
| 93 |
- |
| 94 |
- x = crealf(z); |
| 95 |
- y = cimagf(z); |
| 96 |
- exp_x = __frexp_expf(x, &ex_expt); |
| 97 |
- expt += ex_expt; |
| 98 |
- |
| 99 |
- half_expt = expt / 2; |
| 100 |
- SET_FLOAT_WORD(scale1, (0x7f + half_expt) << 23); |
| 101 |
- half_expt = expt - half_expt; |
| 102 |
- SET_FLOAT_WORD(scale2, (0x7f + half_expt) << 23); |
| 103 |
- |
| 104 |
- sincosf(y, &s, &c); |
| 105 |
- return (CMPLXF(c * exp_x * scale1 * scale2, |
| 106 |
- s * exp_x * scale1 * scale2)); |
| 107 |
-} |