| ... |
... |
@@ -32,6 +32,28 @@ extern double cr_hypot(double, double); |
|
32
|
32
|
extern double cr_log1p(double);
|
|
33
|
33
|
extern double cr_expm1(double);
|
|
34
|
34
|
extern void cr_sincos(double, double *, double *);
|
|
|
35
|
+
|
|
|
36
|
+extern float cr_sinf(float);
|
|
|
37
|
+extern float cr_cosf(float);
|
|
|
38
|
+extern float cr_tanf(float);
|
|
|
39
|
+extern float cr_atanf(float);
|
|
|
40
|
+extern float cr_atan2f(float, float);
|
|
|
41
|
+extern float cr_asinf(float);
|
|
|
42
|
+extern float cr_acosf(float);
|
|
|
43
|
+extern float cr_sinhf(float);
|
|
|
44
|
+extern float cr_coshf(float);
|
|
|
45
|
+extern float cr_tanhf(float);
|
|
|
46
|
+extern float cr_asinhf(float);
|
|
|
47
|
+extern float cr_acoshf(float);
|
|
|
48
|
+extern float cr_atanhf(float);
|
|
|
49
|
+extern float cr_expf(float);
|
|
|
50
|
+extern float cr_logf(float);
|
|
|
51
|
+extern float cr_log10f(float);
|
|
|
52
|
+extern float cr_powf(float, float);
|
|
|
53
|
+extern float cr_hypotf(float, float);
|
|
|
54
|
+extern float cr_log1pf(float);
|
|
|
55
|
+extern float cr_expm1f(float);
|
|
|
56
|
+extern void cr_sincosf(float, float *, float *);
|
|
35
|
57
|
#endif
|
|
36
|
58
|
|
|
37
|
59
|
|
| ... |
... |
@@ -141,6 +163,8 @@ double |
|
141
|
163
|
lisp_cosh(double x)
|
|
142
|
164
|
{
|
|
143
|
165
|
#ifdef FEATURE_CORE_MATH
|
|
|
166
|
+ MAYBE_SIGNAL_OVERFLOW(fabs(x))
|
|
|
167
|
+
|
|
144
|
168
|
return cr_cosh(x);
|
|
145
|
169
|
#else
|
|
146
|
170
|
return __ieee754_cosh(x);
|
| ... |
... |
@@ -284,6 +308,10 @@ double |
|
284
|
308
|
lisp_expm1(double x)
|
|
285
|
309
|
{
|
|
286
|
310
|
#ifdef FEATURE_CORE_MATH
|
|
|
311
|
+ if (isinf(x) == 1) {
|
|
|
312
|
+ return fdlibm_setexception(x, FDLIBM_OVERFLOW);
|
|
|
313
|
+ }
|
|
|
314
|
+
|
|
287
|
315
|
return cr_expm1(x);
|
|
288
|
316
|
#else
|
|
289
|
317
|
return fdlibm_expm1(x);
|
| ... |
... |
@@ -297,7 +325,7 @@ lisp_scalbn(double x, int n) |
|
297
|
325
|
}
|
|
298
|
326
|
|
|
299
|
327
|
void
|
|
300
|
|
-lisp_sincos (double x, double *s, double *c)
|
|
|
328
|
+lisp_sincos(double x, double *s, double *c)
|
|
301
|
329
|
{
|
|
302
|
330
|
#ifdef FEATURE_CORE_MATH
|
|
303
|
331
|
cr_sincos(x, s, c);
|
| ... |
... |
@@ -307,3 +335,236 @@ lisp_sincos (double x, double *s, double *c) |
|
307
|
335
|
cmucl_sincos(x, s, c);
|
|
308
|
336
|
#endif
|
|
309
|
337
|
}
|
|
|
338
|
+
|
|
|
339
|
+/*
|
|
|
340
|
+ * The single-float versions of the special functions. When core-math
|
|
|
341
|
+ * is set, we use the single-float core-math functions. Otherwise, we
|
|
|
342
|
+ * use the double-float versions from fdlibm, with appropriate
|
|
|
343
|
+ * coercions.
|
|
|
344
|
+ */
|
|
|
345
|
+float
|
|
|
346
|
+lisp_sinf(float x)
|
|
|
347
|
+{
|
|
|
348
|
+#ifdef FEATURE_CORE_MATH
|
|
|
349
|
+ return cr_sinf(x);
|
|
|
350
|
+#else
|
|
|
351
|
+ return (float) fdlibm_sin((double) x);
|
|
|
352
|
+#endif
|
|
|
353
|
+}
|
|
|
354
|
+
|
|
|
355
|
+float
|
|
|
356
|
+lisp_cosf(float x)
|
|
|
357
|
+{
|
|
|
358
|
+#ifdef FEATURE_CORE_MATH
|
|
|
359
|
+ return cr_cosf(x);
|
|
|
360
|
+#else
|
|
|
361
|
+ return (float) fdlibm_cos((double) x);
|
|
|
362
|
+#endif
|
|
|
363
|
+}
|
|
|
364
|
+
|
|
|
365
|
+float
|
|
|
366
|
+lisp_tanf(float x)
|
|
|
367
|
+{
|
|
|
368
|
+#ifdef FEATURE_CORE_MATH
|
|
|
369
|
+ return cr_tanf(x);
|
|
|
370
|
+#else
|
|
|
371
|
+ return (float) fdlibm_tan((double) x);
|
|
|
372
|
+#endif
|
|
|
373
|
+}
|
|
|
374
|
+
|
|
|
375
|
+float
|
|
|
376
|
+lisp_atanf(float x)
|
|
|
377
|
+{
|
|
|
378
|
+#ifdef FEATURE_CORE_MATH
|
|
|
379
|
+ return cr_atanf(x);
|
|
|
380
|
+#else
|
|
|
381
|
+ return (float) fdlibm_atan((double) x);
|
|
|
382
|
+#endif
|
|
|
383
|
+}
|
|
|
384
|
+
|
|
|
385
|
+float
|
|
|
386
|
+lisp_atan2f(float y, float x)
|
|
|
387
|
+{
|
|
|
388
|
+#ifdef FEATURE_CORE_MATH
|
|
|
389
|
+ return cr_atan2f(y, x);
|
|
|
390
|
+#else
|
|
|
391
|
+ return (float) __ieee754_atan2((double) y, (double) x);
|
|
|
392
|
+#endif
|
|
|
393
|
+}
|
|
|
394
|
+
|
|
|
395
|
+float
|
|
|
396
|
+lisp_asinf(float x)
|
|
|
397
|
+{
|
|
|
398
|
+#ifdef FEATURE_CORE_MATH
|
|
|
399
|
+ return cr_asinf(x);
|
|
|
400
|
+#else
|
|
|
401
|
+ return (float) __ieee754_asin((double) x);
|
|
|
402
|
+#endif
|
|
|
403
|
+}
|
|
|
404
|
+
|
|
|
405
|
+float
|
|
|
406
|
+lisp_acosf(float x)
|
|
|
407
|
+{
|
|
|
408
|
+#ifdef FEATURE_CORE_MATH
|
|
|
409
|
+ return cr_acosf(x);
|
|
|
410
|
+#else
|
|
|
411
|
+ return (float) __ieee754_acos((double) x);
|
|
|
412
|
+#endif
|
|
|
413
|
+}
|
|
|
414
|
+
|
|
|
415
|
+float
|
|
|
416
|
+lisp_sinhf(float x)
|
|
|
417
|
+{
|
|
|
418
|
+#ifdef FEATURE_CORE_MATH
|
|
|
419
|
+ return cr_sinhf(x);
|
|
|
420
|
+#else
|
|
|
421
|
+ return (float) __ieee754_sinh((double) x);
|
|
|
422
|
+#endif
|
|
|
423
|
+}
|
|
|
424
|
+
|
|
|
425
|
+float
|
|
|
426
|
+lisp_coshf(float x)
|
|
|
427
|
+{
|
|
|
428
|
+#ifdef FEATURE_CORE_MATH
|
|
|
429
|
+ return cr_coshf(x);
|
|
|
430
|
+#else
|
|
|
431
|
+ return (float) __ieee754_cosh((double) x);
|
|
|
432
|
+#endif
|
|
|
433
|
+}
|
|
|
434
|
+
|
|
|
435
|
+float
|
|
|
436
|
+lisp_tanhf(float x)
|
|
|
437
|
+{
|
|
|
438
|
+#ifdef FEATURE_CORE_MATH
|
|
|
439
|
+ return cr_tanhf(x);
|
|
|
440
|
+#else
|
|
|
441
|
+ return (float) fdlibm_tanh((double) x);
|
|
|
442
|
+#endif
|
|
|
443
|
+}
|
|
|
444
|
+
|
|
|
445
|
+float
|
|
|
446
|
+lisp_asinhf(float x)
|
|
|
447
|
+{
|
|
|
448
|
+#ifdef FEATURE_CORE_MATH
|
|
|
449
|
+ return cr_asinhf(x);
|
|
|
450
|
+#else
|
|
|
451
|
+ return (float) fdlibm_asinh((double) x);
|
|
|
452
|
+#endif
|
|
|
453
|
+}
|
|
|
454
|
+
|
|
|
455
|
+float
|
|
|
456
|
+lisp_acoshf(float x)
|
|
|
457
|
+{
|
|
|
458
|
+#ifdef FEATURE_CORE_MATH
|
|
|
459
|
+ return cr_acoshf(x);
|
|
|
460
|
+#else
|
|
|
461
|
+ return (float) __ieee754_acosh((double) x);
|
|
|
462
|
+#endif
|
|
|
463
|
+}
|
|
|
464
|
+
|
|
|
465
|
+float
|
|
|
466
|
+lisp_atanhf(float x)
|
|
|
467
|
+{
|
|
|
468
|
+#ifdef FEATURE_CORE_MATH
|
|
|
469
|
+ return cr_atanhf(x);
|
|
|
470
|
+#else
|
|
|
471
|
+ return (float) __ieee754_atanh((double) x);
|
|
|
472
|
+#endif
|
|
|
473
|
+}
|
|
|
474
|
+
|
|
|
475
|
+float
|
|
|
476
|
+lisp_expf(float x)
|
|
|
477
|
+{
|
|
|
478
|
+#ifdef FEATURE_CORE_MATH
|
|
|
479
|
+ return cr_expf(x);
|
|
|
480
|
+#else
|
|
|
481
|
+ return (float) __ieee754_exp((double) x);
|
|
|
482
|
+#endif
|
|
|
483
|
+}
|
|
|
484
|
+
|
|
|
485
|
+float
|
|
|
486
|
+lisp_logf(float x)
|
|
|
487
|
+{
|
|
|
488
|
+#ifdef FEATURE_CORE_MATH
|
|
|
489
|
+ return cr_logf(x);
|
|
|
490
|
+#else
|
|
|
491
|
+ return (float) __ieee754_log((double) x);
|
|
|
492
|
+#endif
|
|
|
493
|
+}
|
|
|
494
|
+
|
|
|
495
|
+float
|
|
|
496
|
+lisp_log10f(float x)
|
|
|
497
|
+{
|
|
|
498
|
+#ifdef FEATURE_CORE_MATH
|
|
|
499
|
+ return cr_log10f(x);
|
|
|
500
|
+#else
|
|
|
501
|
+ return (float) __ieee754_log10((double) x);
|
|
|
502
|
+#endif
|
|
|
503
|
+}
|
|
|
504
|
+
|
|
|
505
|
+float
|
|
|
506
|
+lisp_powf(float x, float y)
|
|
|
507
|
+{
|
|
|
508
|
+#ifdef FEATURE_CORE_MATH
|
|
|
509
|
+ /*
|
|
|
510
|
+ * cr_pow when compiled with older versions of gcc or clang can
|
|
|
511
|
+ * cause failures in the ansi-tests [#469]. Ubuntu 25.10 and Fedora 41
|
|
|
512
|
+ * (gcc only) are known to have compilers that work well enough
|
|
|
513
|
+ * that the ansi-tests pass.
|
|
|
514
|
+ */
|
|
|
515
|
+ return cr_powf(x, y);
|
|
|
516
|
+#else
|
|
|
517
|
+ /*
|
|
|
518
|
+ * cr_pow seems causes ansi-tests to fail in test WRITE.1 among
|
|
|
519
|
+ * others. Somewhere an invalid operation is occurring. Thus
|
|
|
520
|
+ * just use fdlibm for now until we can figure out what's causing
|
|
|
521
|
+ * the failure.
|
|
|
522
|
+ */
|
|
|
523
|
+ return (float) __ieee754_pow((double) x, (double) y);
|
|
|
524
|
+#endif
|
|
|
525
|
+}
|
|
|
526
|
+
|
|
|
527
|
+float
|
|
|
528
|
+lisp_hypotf(float x, float y)
|
|
|
529
|
+{
|
|
|
530
|
+#ifdef FEATURE_CORE_MATH
|
|
|
531
|
+ return cr_hypotf(x, y);
|
|
|
532
|
+#else
|
|
|
533
|
+ return (float) __ieee754_hypot((double) x, (double) y);
|
|
|
534
|
+#endif
|
|
|
535
|
+}
|
|
|
536
|
+
|
|
|
537
|
+float
|
|
|
538
|
+lisp_log1pf(float x)
|
|
|
539
|
+{
|
|
|
540
|
+#ifdef FEATURE_CORE_MATH
|
|
|
541
|
+ return cr_log1pf(x);
|
|
|
542
|
+#else
|
|
|
543
|
+ return (float) fdlibm_log1p((double) x);
|
|
|
544
|
+#endif
|
|
|
545
|
+}
|
|
|
546
|
+
|
|
|
547
|
+float
|
|
|
548
|
+lisp_expm1f(float x)
|
|
|
549
|
+{
|
|
|
550
|
+#ifdef FEATURE_CORE_MATH
|
|
|
551
|
+ return cr_expm1f(x);
|
|
|
552
|
+#else
|
|
|
553
|
+ return (float) fdlibm_expm1((double) x);
|
|
|
554
|
+#endif
|
|
|
555
|
+}
|
|
|
556
|
+
|
|
|
557
|
+void
|
|
|
558
|
+lisp_sincosf(float x, float *s, float *c)
|
|
|
559
|
+{
|
|
|
560
|
+#ifdef FEATURE_CORE_MATH
|
|
|
561
|
+ cr_sincosf(x, s, c);
|
|
|
562
|
+#else
|
|
|
563
|
+ extern void cmucl_sincos(double, double*, double*);
|
|
|
564
|
+ double ds, dc;
|
|
|
565
|
+
|
|
|
566
|
+ cmucl_sincos((double) x, &ds, &dc);
|
|
|
567
|
+ *s = (float) ds;
|
|
|
568
|
+ *c = (float) dc;
|
|
|
569
|
+#endif
|
|
|
570
|
+} |