Raymond Toy pushed to branch issue-459-more-accurate-dd-complex-div at cmucl / cmucl Commits: ad096e15 by Raymond Toy at 2026-01-08T16:20:50-08:00 Add some comments for the constants for cdiv-double-double-float. - - - - - 4f573964 by Raymond Toy at 2026-01-08T16:52:37-08:00 Fix typo using the incorrect package for cdiv-double-double-float A left over from when `cdiv-double-double-float` was in the C package but is now in the KERNEL package. - - - - - f1d99fbc by Raymond Toy at 2026-01-08T16:54:20-08:00 Update pot file for new docstrings - - - - - 2 changed files: - src/code/numbers.lisp - src/i18n/locale/cmucl.pot Changes: ===================================== src/code/numbers.lisp ===================================== @@ -612,6 +612,31 @@ (defconstant +cdiv-be+ (/ 2 (* +cdiv-eps+ +cdiv-eps+))) (defconstant +cdiv-2/eps+ (/ 2 +cdiv-eps+)) +;; Same constants but for double-double-floats. Some of these aren't +;; well-defined for double-double-floats so we make our best guess at +;; what they might be. Since double-doubles have about twice as many +;; bits of precision as a double-float, we generally just double the +;; exponent of the corresponding double-float values above. +(defconstant +cdiv-dd-rmin+ + least-positive-normalized-double-double-float) +(defconstant +cdiv-dd-rbig+ + (/ most-positive-double-double-float 2)) +(defconstant +cdiv-dd-rmin2+ + (scale-float 1w0 -106)) +(defconstant +cdiv-dd-rminscal+ + (scale-float 1w0 102)) +(defconstant +cdiv-dd-rmax2+ + (* +cdiv-dd-rbig+ +cdiv-dd-rmin2+)) +;; Epsilon for double-doubles isn't really well-defined because things +;; like (+ 1w0 1w-200) is a valid double-double float. +(defconstant +cdiv-dd-eps+ + (scale-float 1w0 -104)) +(defconstant +cdiv-dd-be+ + (/ 2 (* +cdiv-dd-eps+ +cdiv-dd-eps+))) +(defconstant +cdiv-dd-2/eps+ + (/ 2 +cdiv-dd-eps+)) + + ;; Make these functions accessible. cdiv-double-float and ;; cdiv-single-float are used by deftransforms. Of course, two-arg-/ ;; is the interface to division. cdiv-generic isn't used anywhere @@ -781,24 +806,8 @@ (f (float (/ (- b (* a r)) denom) 1f0))) (complex e f)))))) -(defconstant +cdiv-dd-eps+ - (scale-float 1w0 -104)) -(defconstant +cdiv-dd-rmin+ - least-positive-normalized-double-double-float) -(defconstant +cdiv-dd-rbig+ - (/ most-positive-double-double-float 2)) -(defconstant +cdiv-dd-rmin2+ - (scale-float 1w0 -105)) -(defconstant +cdiv-dd-rminscal+ - (scale-float 1w0 102)) -(defconstant +cdiv-dd-rmax2+ - (* +cdiv-dd-rbig+ +cdiv-dd-rmin2+)) -(defconstant +cdiv-dd-be+ - (/ 2 (* +cdiv-dd-eps+ +cdiv-dd-eps+))) -(defconstant +cdiv-dd-2/eps+ - (/ 2 +cdiv-dd-eps+)) - (defun cdiv-double-double-float (x y) + "Accurate division of complex double-double-float numbers x and y." (declare (type (complex double-double-float) x y) (optimize (speed 2) (safety 0))) (labels @@ -982,13 +991,13 @@ (((complex double-double-float) (foreach (complex rational) (complex single-float) (complex double-float) (complex double-double-float))) - (c::cdiv-double-double-float x + (cdiv-double-double-float x (coerce y '(complex double-double-float)))) (((foreach integer ratio single-float double-float double-double-float (complex rational) (complex single-float) (complex double-float)) (complex double-double-float)) - (c::cdiv-double-double-float (coerce x '(complex double-double-float)) + (cdiv-double-double-float (coerce x '(complex double-double-float)) y)) (((foreach integer ratio single-float double-float double-double-float) ===================================== src/i18n/locale/cmucl.pot ===================================== @@ -4385,6 +4385,24 @@ msgstr "" msgid "Returns NUMBER - 1." msgstr "" +#: src/code/numbers.lisp +msgid "Accurate division of complex double-float numbers x and y." +msgstr "" + +#: src/code/numbers.lisp +msgid "Accurate division of complex single-float numbers x and y." +msgstr "" + +#: src/code/numbers.lisp +msgid "Accurate division of complex double-double-float numbers x and y." +msgstr "" + +#: src/code/numbers.lisp +msgid "" +"Complex division of generic numbers x and y. One of x or y should be\n" +" a complex." +msgstr "" + #: src/code/numbers.lisp msgid "" "Returns number (or number/divisor) as an integer, rounded toward 0.\n" View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/a8e2a8bfad7a75d5977a7c1... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/a8e2a8bfad7a75d5977a7c1... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)