Raymond Toy pushed to branch issue-461-cdiv-use-4-doubles at cmucl / cmucl
Commits:
-
3353b960
by Raymond Toy at 2026-01-19T16:36:43-08:00
-
96037b55
by Raymond Toy at 2026-01-19T16:37:59-08:00
-
3f733bae
by Raymond Toy at 2026-01-19T16:54:46-08:00
-
f7c31886
by Raymond Toy at 2026-01-19T16:56:53-08:00
2 changed files:
Changes:
| ... | ... | @@ -811,13 +811,13 @@ |
| 811 | 811 | |
| 812 | 812 | ;; Smith's algorithm for complex division for (complex single-float).
|
| 813 | 813 | ;; We convert the parts to double-floats before computing the result.
|
| 814 | -(defun cdiv-single-float (x y)
|
|
| 814 | +(defun cdiv-single-float (xr xi yr yi)
|
|
| 815 | 815 | "Accurate division of complex single-float numbers x and y."
|
| 816 | - (declare (type (complex single-float) x y))
|
|
| 817 | - (let ((a (float (realpart x) 1d0))
|
|
| 818 | - (b (float (imagpart x) 1d0))
|
|
| 819 | - (c (float (realpart y) 1d0))
|
|
| 820 | - (d (float (imagpart y) 1d0)))
|
|
| 816 | + (declare (single-float xr xi yr yi))
|
|
| 817 | + (let ((a (float xr 1d0))
|
|
| 818 | + (b (float xi 1d0))
|
|
| 819 | + (c (float yr 1d0))
|
|
| 820 | + (d (float yi 1d0)))
|
|
| 821 | 821 | (cond ((< (abs c) (abs d))
|
| 822 | 822 | (let* ((r (/ c d))
|
| 823 | 823 | (denom (+ (* c r) d))
|
| ... | ... | @@ -858,7 +858,10 @@ |
| 858 | 858 | |
| 859 | 859 | (((complex single-float)
|
| 860 | 860 | (foreach (complex rational) (complex single-float)))
|
| 861 | - (cdiv-single-float x (coerce y '(complex single-float))))
|
|
| 861 | + (cdiv-single-float (realpart x)
|
|
| 862 | + (imagpart x)
|
|
| 863 | + (coerce (realpart y) 'single-float)
|
|
| 864 | + (coerce (imagpart y) 'single-float)))
|
|
| 862 | 865 | (((complex double-float)
|
| 863 | 866 | (foreach (complex rational) (complex single-float) (complex double-float)))
|
| 864 | 867 | (cdiv-double-float (realpart x)
|
| ... | ... | @@ -868,8 +871,10 @@ |
| 868 | 871 | |
| 869 | 872 | (((foreach integer ratio single-float (complex rational))
|
| 870 | 873 | (complex single-float))
|
| 871 | - (cdiv-single-float (coerce x '(complex single-float))
|
|
| 872 | - y))
|
|
| 874 | + (cdiv-single-float (coerce (realpart x) 'single-float)
|
|
| 875 | + (coerce (imagpart x) 'single-float)
|
|
| 876 | + (realpart y)
|
|
| 877 | + (imagpart y)))
|
|
| 873 | 878 |
|
| 874 | 879 | (((foreach integer ratio single-float double-float (complex rational)
|
| 875 | 880 | (complex single-float))
|
| ... | ... | @@ -1807,10 +1807,10 @@ |
| 1807 | 1807 | (macrolet
|
| 1808 | 1808 | ((frob (type name)
|
| 1809 | 1809 | `(deftransform / ((x y) ((complex ,type) (complex ,type)) *)
|
| 1810 | - (,name (realpart x)
|
|
| 1811 | - (imagpart x)
|
|
| 1812 | - (realpart y)
|
|
| 1813 | - (imagpart y)))))
|
|
| 1810 | + '(,name (realpart x)
|
|
| 1811 | + (imagpart x)
|
|
| 1812 | + (realpart y)
|
|
| 1813 | + (imagpart y)))))
|
|
| 1814 | 1814 | (frob double-float kernel::cdiv-double-float)
|
| 1815 | 1815 | (frob single-float kernel::cdiv-single-float))
|
| 1816 | 1816 |