Trait malachite_base::num::arithmetic::traits::ModPow
source · [−]pub trait ModPow<RHS = Self, M = Self> {
type Output;
fn mod_pow(self, exp: RHS, m: M) -> Self::Output;
}
Expand description
Raises a number to a power modulo another number $m$. Assumes the input is already reduced modulo $m$.
Required Associated Types
Required Methods
Implementations on Foreign Types
sourceimpl ModPow<u64, u8> for u8
impl ModPow<u64, u8> for u8
sourcefn mod_pow(self, exp: u64, m: u8) -> u8
fn mod_pow(self, exp: u64, m: u8) -> u8
Raises a number to a power modulo another number $m$. Assumes the input is already reduced modulo $m$.
$f(x, n, m) = y$, where $x, y < m$ and $x^n \equiv y \mod m$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is exp.significant_bits()
.
Examples
See here.
type Output = u8
sourceimpl ModPow<u64, u16> for u16
impl ModPow<u64, u16> for u16
sourcefn mod_pow(self, exp: u64, m: u16) -> u16
fn mod_pow(self, exp: u64, m: u16) -> u16
Raises a number to a power modulo another number $m$. Assumes the input is already reduced modulo $m$.
$f(x, n, m) = y$, where $x, y < m$ and $x^n \equiv y \mod m$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is exp.significant_bits()
.
Examples
See here.
type Output = u16
sourceimpl ModPow<u64, u32> for u32
impl ModPow<u64, u32> for u32
sourcefn mod_pow(self, exp: u64, m: u32) -> u32
fn mod_pow(self, exp: u64, m: u32) -> u32
Raises a number to a power modulo another number $m$. Assumes the input is already reduced modulo $m$.
$f(x, n, m) = y$, where $x, y < m$ and $x^n \equiv y \mod m$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is exp.significant_bits()
.
Examples
See here.
type Output = u32
sourceimpl ModPow<u64, u64> for u64
impl ModPow<u64, u64> for u64
sourcefn mod_pow(self, exp: u64, m: u64) -> u64
fn mod_pow(self, exp: u64, m: u64) -> u64
Raises a number to a power modulo another number $m$. Assumes the input is already reduced modulo $m$.
$f(x, n, m) = y$, where $x, y < m$ and $x^n \equiv y \mod m$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is exp.significant_bits()
.
Examples
See here.
type Output = u64
sourceimpl ModPow<u64, u128> for u128
impl ModPow<u64, u128> for u128
sourcefn mod_pow(self, exp: u64, m: u128) -> u128
fn mod_pow(self, exp: u64, m: u128) -> u128
Raises a number to a power modulo another number $m$. Assumes the input is already reduced modulo $m$.
$f(x, n, m) = y$, where $x, y < m$ and $x^n \equiv y \mod m$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is exp.significant_bits()
.
Examples
See here.
type Output = u128
sourceimpl ModPow<u64, usize> for usize
impl ModPow<u64, usize> for usize
sourcefn mod_pow(self, exp: u64, m: usize) -> usize
fn mod_pow(self, exp: u64, m: usize) -> usize
Raises a number to a power modulo another number $m$. Assumes the input is already reduced modulo $m$.
$f(x, n, m) = y$, where $x, y < m$ and $x^n \equiv y \mod m$.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is exp.significant_bits()
.
Examples
See here.