bit.mul_loop

dst[:n] *= src[:n]
b is the number of 1-bits in src.
@NOTE: this implementation works with both signed and unsigned numbers.
@NOTE: this is slower, yet it saves space, compared to the mul macro.
@Assumes: dst and src are NOT the same address (aliasing makes this macro loop forever).
For squaring (dst==src) use the mul macro, which handles aliasing safely.
@NOTE: For a faster multiplication see hex.mul (requires hex.init).

Signature

def mul_loop n, dst, src @ start, after_add, src_copy, res, end { ... }

Defined in bit/mul.fj — lines 27–48 (view on GitHub).

Complexity

  • Time: n^2(6@+2) + n*b(8@+14)    if b==n/2:  n^2(10@+9)

  • Space: n(21@+11)

See the complexity glossary for what @, w, dw, dbit, n mean.

Source

Depends on


← Previous: bit.mul10 Next: bit.mul