product_quotient.tri (761B)
1 -- Pure binary64 implementation; trusted internal helpers. 2 !import native_math as N 3 !import binary64_kernels as K 4 !import binary64_fast as F 5 !export boundedQuotient 6 !export jam 7 8 walk count divisor q r = K.lazy (_ : t q r) 9 (_ : K.lazy (_ : t (F.shiftPositive count q) 0) 10 (_ : let shifted = F.zeros1 r in K.lazy 11 (_ : walk (N.predecessor count) divisor (K.node t q) shifted) 12 (_ : walk (N.predecessor count) divisor (N.successor (K.node t q)) (N.subtract shifted divisor)) 13 (N.lt shifted divisor)) (N.zero r)) (N.zero count) 14 boundedQuotient a b = K.lazy (_ : walk 56 b 0 a) 15 (_ : walk 56 b 1 (N.subtract a b)) (N.lt a b) 16 jam split = let q = K.head split in K.lazy (_ : q) 17 (_ : K.choose q (N.successor q) (N.zero (K.tail split))) (N.odd q)