def ms_p

bendtorch-gpu@1.3.0.0 · main.bend:1201

import bendtorch-gpu@1.3.0.0/main.bend as BendtorchGpu
import Base

1201# the largest p <= k with 2^p dividing m (m > 0)
1202def ms_p(k: Nat, +m: U32) -> Nat:
1203  match k:
1204    case 0n: 0n
1205    # bend-lint: disable-next bend-lint-rules/performance/eager_branch -- a loop of at most 32 U32 steps on the host, once per bang launch not-expected-because: a launch costs about 1 ms, the whole walk well under a microsecond
1206    case 1n+q: Bool.pick(Nat, U32.is_eq(U32.mod(m, 2), 0), 1n+ms_p(q, U32.div(m, 2)), 0n)

Uses (6)

Used by (2)