Trait malachite_base::num::arithmetic::traits::ModPowerOf2Inverse
source · [−]pub trait ModPowerOf2Inverse {
type Output;
fn mod_power_of_2_inverse(self, pow: u64) -> Option<Self::Output>;
}
Expand description
Finds the multiplicative inverse of a number modulo $2^k$. Assumes the input is already reduced modulo $2^k$.
Required Associated Types
Required Methods
fn mod_power_of_2_inverse(self, pow: u64) -> Option<Self::Output>
Implementations on Foreign Types
sourceimpl ModPowerOf2Inverse for u8
impl ModPowerOf2Inverse for u8
sourcefn mod_power_of_2_inverse(self, pow: u64) -> Option<u8>
fn mod_power_of_2_inverse(self, pow: u64) -> Option<u8>
Computes the multiplicative inverse of a number modulo $2^k$. Assumes the number is already reduced modulo $2^k$.
Returns None
if $x$ is even.
$f(x, k) = y$, where $x, y < 2^k$, $x$ is odd, and $xy \equiv 1 \mod 2^k$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is pow
.
Examples
See here.
type Output = u8
sourceimpl ModPowerOf2Inverse for u16
impl ModPowerOf2Inverse for u16
sourcefn mod_power_of_2_inverse(self, pow: u64) -> Option<u16>
fn mod_power_of_2_inverse(self, pow: u64) -> Option<u16>
Computes the multiplicative inverse of a number modulo $2^k$. Assumes the number is already reduced modulo $2^k$.
Returns None
if $x$ is even.
$f(x, k) = y$, where $x, y < 2^k$, $x$ is odd, and $xy \equiv 1 \mod 2^k$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is pow
.
Examples
See here.
type Output = u16
sourceimpl ModPowerOf2Inverse for u32
impl ModPowerOf2Inverse for u32
sourcefn mod_power_of_2_inverse(self, pow: u64) -> Option<u32>
fn mod_power_of_2_inverse(self, pow: u64) -> Option<u32>
Computes the multiplicative inverse of a number modulo $2^k$. Assumes the number is already reduced modulo $2^k$.
Returns None
if $x$ is even.
$f(x, k) = y$, where $x, y < 2^k$, $x$ is odd, and $xy \equiv 1 \mod 2^k$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is pow
.
Examples
See here.
type Output = u32
sourceimpl ModPowerOf2Inverse for u64
impl ModPowerOf2Inverse for u64
sourcefn mod_power_of_2_inverse(self, pow: u64) -> Option<u64>
fn mod_power_of_2_inverse(self, pow: u64) -> Option<u64>
Computes the multiplicative inverse of a number modulo $2^k$. Assumes the number is already reduced modulo $2^k$.
Returns None
if $x$ is even.
$f(x, k) = y$, where $x, y < 2^k$, $x$ is odd, and $xy \equiv 1 \mod 2^k$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is pow
.
Examples
See here.
type Output = u64
sourceimpl ModPowerOf2Inverse for u128
impl ModPowerOf2Inverse for u128
sourcefn mod_power_of_2_inverse(self, pow: u64) -> Option<u128>
fn mod_power_of_2_inverse(self, pow: u64) -> Option<u128>
Computes the multiplicative inverse of a number modulo $2^k$. Assumes the number is already reduced modulo $2^k$.
Returns None
if $x$ is even.
$f(x, k) = y$, where $x, y < 2^k$, $x$ is odd, and $xy \equiv 1 \mod 2^k$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is pow
.
Examples
See here.
type Output = u128
sourceimpl ModPowerOf2Inverse for usize
impl ModPowerOf2Inverse for usize
sourcefn mod_power_of_2_inverse(self, pow: u64) -> Option<usize>
fn mod_power_of_2_inverse(self, pow: u64) -> Option<usize>
Computes the multiplicative inverse of a number modulo $2^k$. Assumes the number is already reduced modulo $2^k$.
Returns None
if $x$ is even.
$f(x, k) = y$, where $x, y < 2^k$, $x$ is odd, and $xy \equiv 1 \mod 2^k$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is pow
.
Examples
See here.