bit.mul

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 faster, yet WASTEFUL in space, compared to the mul_loop macro.
@NOTE: safe when dst and src are the same address (squaring: dst *= dst), unlike mul_loop.
@NOTE: For a faster multiplication see hex.mul (requires hex.init).

Signature

def mul n, dst, src @ shifted_src, res, end { ... }

Defined in bit/mul.fj — lines 59–72 (view on GitHub).

Complexity

  • Time: n*b(8@+14)    if b==n/2:  n^2(4@+7)

  • Space: n^2(8@+14)

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

Source

Depends on


← Previous: bit.mul_loop Next: bit.mul.mul_add_if