Bigint.Mag.kmul: def of bend-kit-bignum@0.1.0.0 Import: import bend-kit-bignum@0.1.0.0/bigint.bend as Bigint Lines 172-187 of bend-kit-bignum@0.1.0.0/bigint.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&start_line=172&end_line=187 import Base # Karatsuba while both sides have at least 32 limbs, schoolbook below. f caps # the depth; 32 halvings outrun any list that fits in memory. def Mag.kmul(+f: Nat, +a: List<&2, U32>, +b: List<&2, U32>) -> List<&2, U32>: match f: case 0n: Mag.school(a, b) case 1n+p: +k = Nat.div(Nat.min(Mag.len(a), Mag.len(b)), 2n) +a0 = Mag.lo(a, k) +a1 = List.drop(&2, U32, a, k) +b0 = Mag.lo(b, k) +b1 = List.drop(&2, U32, b, k) Mag.if(List<&2, U32>, Nat.is_lt(k, 16n), u => Mag.school(a, b), u => Mag.kara(k, Mag.kmul(p, a0, b0), Mag.kmul(p, a1, b1), Mag.kmul(p, Mag.add(a0, a1, 0), Mag.add(b0, b1, 0)))) Uses (13): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.drop https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_lt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.min https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&name=Mag.add https://jend.leeeet.dev/definition.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&name=Mag.if https://jend.leeeet.dev/definition.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&name=Mag.kara https://jend.leeeet.dev/definition.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&name=Mag.len https://jend.leeeet.dev/definition.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&name=Mag.lo https://jend.leeeet.dev/definition.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&name=Mag.school