Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2): Difference between revisions
Content added Content deleted
Line 1,965: | Line 1,965: | ||
(multiple-value-list (floor u v)))) |
(multiple-value-list (floor u v)))) |
||
(defmacro absorb-x-term (ng xsource |
(defmacro absorb-x-term (ng xsource) |
||
`(let ((a12 (ng8-a12 ,ng)) |
`(let ((a12 (ng8-a12 ,ng)) |
||
(a1 (ng8-a1 ,ng)) |
(a1 (ng8-a1 ,ng)) |
||
Line 1,974: | Line 1,974: | ||
(b2 (ng8-b2 ,ng)) |
(b2 (ng8-b2 ,ng)) |
||
(b (ng8-b ,ng)) |
(b (ng8-b ,ng)) |
||
(term (funcall ,xsource |
(term (funcall ,xsource))) |
||
⚫ | |||
(if term |
(if term |
||
(let ((ng^ (ng8 (+ a2 (* a12 term)) |
(let ((ng^ (ng8 (+ a2 (* a12 term)) |
||
Line 1,986: | Line 1,985: | ||
;; Replace the x source with one that never |
;; Replace the x source with one that never |
||
;; returns a term. |
;; returns a term. |
||
(setf ,xsource #' |
(setf ,xsource #'no-terms-thunk)))) |
||
(setf ,ng (ng8 a12 a1 a12 a1 b12 b1 b12 b1))))) |
(setf ,ng (ng8 a12 a1 a12 a1 b12 b1 b12 b1))))) |
||
(defmacro absorb-y-term (ng ysource |
(defmacro absorb-y-term (ng ysource) |
||
`(let ((a12 (ng8-a12 ,ng)) |
`(let ((a12 (ng8-a12 ,ng)) |
||
(a1 (ng8-a1 ,ng)) |
(a1 (ng8-a1 ,ng)) |
||
Line 1,998: | Line 1,997: | ||
(b2 (ng8-b2 ,ng)) |
(b2 (ng8-b2 ,ng)) |
||
(b (ng8-b ,ng)) |
(b (ng8-b ,ng)) |
||
(term (funcall ,ysource |
(term (funcall ,ysource))) |
||
(setf ,iy (1+ ,iy)) |
|||
(if term |
(if term |
||
(let ((ng^ (ng8 (+ a1 (* a12 term)) a12 |
(let ((ng^ (ng8 (+ a1 (* a12 term)) a12 |
||
Line 2,010: | Line 2,008: | ||
;; Replace the y source with one that never |
;; Replace the y source with one that never |
||
;; returns a term. |
;; returns a term. |
||
(setf ysource #' |
(setf ysource #'no-terms-thunk)))) |
||
(setf ,ng (ng8 a12 a12 a2 a2 b12 b12 b2 b2))))) |
(setf ,ng (ng8 a12 a12 a2 a2 b12 b12 b2 b2))))) |
||
(defun cf->thunk (cf) |
|||
⚫ | |||
#'(lambda () |
|||
(let ((term (cf-ref cf i))) |
|||
⚫ | |||
⚫ | |||
(defun no-terms-thunk () |
|||
nil) |
|||
(defun apply-ng8 (ng8 x y) |
(defun apply-ng8 (ng8 x y) |
||
(declare (ng8 ng8)) |
(declare (ng8 ng8)) |
||
(let ((ng ng8) |
(let ((ng ng8) |
||
(xsource |
(xsource (cf->thunk x)) |
||
(ysource |
(ysource (cf->thunk y))) |
||
⚫ | |||
⚫ | |||
(flet |
(flet |
||
((main () |
((main () |
||
Line 2,063: | Line 2,069: | ||
when (eq absorb 'x) |
when (eq absorb 'x) |
||
do (absorb-x-term ng xsource |
do (absorb-x-term ng xsource) |
||
when (eq absorb 'y) |
when (eq absorb 'y) |
||
do (absorb-y-term ng ysource |
do (absorb-y-term ng ysource)))) |
||
(make-cf #'main)))) |
(make-cf #'main)))) |