anchor.diff:  ;;;; © 2016-2019 Marco Heisig         - license: GNU AGPLv3 -*- coding: utf-8 -*-
   
   (in-package #:petalisp.utilities)
  +
  +(deftype small-fixnum ()
  +  `(integer
  +    ,(- (isqrt most-positive-fixnum))
  +    ,(isqrt most-positive-fixnum)))
  +
  +(deftype small-non-negative-fixnum ()
  +  `(integer
  +    0
  +    ,(isqrt most-positive-fixnum)))
   
   (defun extended-euclid (u v)
     "Given nonnegative integers u and v, return the values u1 and u3 such
  
positive.code:   ;; using tail recursion instead of iteration and dropping the redundant
    ;; computation of u2.
    (labels ((fixnum-euclid (u1 u3 v1 v3)
               (declare (fixnum u1 v1)
                        (non-negative-fixnum u3 v3)
                        (optimize (speed 3) (safety 0)))
               (if (zerop v3)
                   (values u1 u3)
                   (let ((q (floor u3 v3)))
                     (fixnum-euclid
                      v1 v3
                      (- u1 (the fixnum (* q v1)))
                      (- u3 (the fixnum (* q v3)))))))
             (bignum-euclid (u1 u3 v1 v3)
               (declare (integer u1 v1)
                        (non-negative-integer u3 v3))
  
negative.code:                  (let ((q (floor u3 v3)))
                     (bignum-euclid
                      v1 v3
                      (- u1 (* q v1))
                      (- u3 (* q v3)))))))
      ;; The absolute values of all coefficients in this algorithm are
      ;; bounded by the least common multiple of U and V.  Computing the
      ;; least common multiple is quite expensive, so instead we use the
  