Trait malachite_base::num::arithmetic::traits::ModPowerOf2Neg
source · [−]pub trait ModPowerOf2Neg {
type Output;
fn mod_power_of_2_neg(self, pow: u64) -> Self::Output;
}
Expand description
Negates a number modulo $2^k$. Assumes the input is already reduced modulo $2^k$.
Required Associated Types
Required Methods
fn mod_power_of_2_neg(self, pow: u64) -> Self::Output
Implementations on Foreign Types
sourceimpl ModPowerOf2Neg for u8
impl ModPowerOf2Neg for u8
sourcefn mod_power_of_2_neg(self, pow: u64) -> u8
fn mod_power_of_2_neg(self, pow: u64) -> u8
Negates a number modulo another number $2^k$. Assumes the input is already reduced modulo $2^k$.
$f(x, k) = y$, where $x, y < 2^k$ and $-x \equiv y \mod 2^k$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if pow
is greater than Self::WIDTH
.
Examples
See here.
type Output = u8
sourceimpl ModPowerOf2Neg for u16
impl ModPowerOf2Neg for u16
sourcefn mod_power_of_2_neg(self, pow: u64) -> u16
fn mod_power_of_2_neg(self, pow: u64) -> u16
Negates a number modulo another number $2^k$. Assumes the input is already reduced modulo $2^k$.
$f(x, k) = y$, where $x, y < 2^k$ and $-x \equiv y \mod 2^k$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if pow
is greater than Self::WIDTH
.
Examples
See here.
type Output = u16
sourceimpl ModPowerOf2Neg for u32
impl ModPowerOf2Neg for u32
sourcefn mod_power_of_2_neg(self, pow: u64) -> u32
fn mod_power_of_2_neg(self, pow: u64) -> u32
Negates a number modulo another number $2^k$. Assumes the input is already reduced modulo $2^k$.
$f(x, k) = y$, where $x, y < 2^k$ and $-x \equiv y \mod 2^k$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if pow
is greater than Self::WIDTH
.
Examples
See here.
type Output = u32
sourceimpl ModPowerOf2Neg for u64
impl ModPowerOf2Neg for u64
sourcefn mod_power_of_2_neg(self, pow: u64) -> u64
fn mod_power_of_2_neg(self, pow: u64) -> u64
Negates a number modulo another number $2^k$. Assumes the input is already reduced modulo $2^k$.
$f(x, k) = y$, where $x, y < 2^k$ and $-x \equiv y \mod 2^k$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if pow
is greater than Self::WIDTH
.
Examples
See here.
type Output = u64
sourceimpl ModPowerOf2Neg for u128
impl ModPowerOf2Neg for u128
sourcefn mod_power_of_2_neg(self, pow: u64) -> u128
fn mod_power_of_2_neg(self, pow: u64) -> u128
Negates a number modulo another number $2^k$. Assumes the input is already reduced modulo $2^k$.
$f(x, k) = y$, where $x, y < 2^k$ and $-x \equiv y \mod 2^k$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if pow
is greater than Self::WIDTH
.
Examples
See here.
type Output = u128
sourceimpl ModPowerOf2Neg for usize
impl ModPowerOf2Neg for usize
sourcefn mod_power_of_2_neg(self, pow: u64) -> usize
fn mod_power_of_2_neg(self, pow: u64) -> usize
Negates a number modulo another number $2^k$. Assumes the input is already reduced modulo $2^k$.
$f(x, k) = y$, where $x, y < 2^k$ and $-x \equiv y \mod 2^k$.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if pow
is greater than Self::WIDTH
.
Examples
See here.