Skip to main content

inv

Function inv 

Source
pub fn inv(x: u64) -> u64
Expand description

Field inverse via Fermat’s little theorem: x^(p-2) mod p.

p - 2 = 0xFFFF_FFFE_FFFF_FFFF — popcount = 63, so ~63 muls + ~64 squares per inversion. Heavy: a single inverse costs ~127 mul- shaped ops. Montgomery’s batch trick amortizes this to ~3 muls per inverse over N elements.