Skip to main content

ModPowerOf2AbsSquared

Trait ModPowerOf2AbsSquared 

Source
pub trait ModPowerOf2AbsSquared {
    type Output;

    // Required method
    fn mod_power_of_2_abs_squared(self, pow: u64) -> Self::Output;
}
Expand description

Computes the squared absolute value of a number modulo $2^k$. The input must be already reduced modulo $2^k$.

For a real number this is its square modulo $2^k$; the trait exists for the types where it is not, such as complex numbers and vectors, for which it is the reduced sum of squares.

Required Associated Types§

Required Methods§

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ModPowerOf2AbsSquared for u8

Source§

fn mod_power_of_2_abs_squared(self, pow: u64) -> u8

Computes the squared absolute value of a number modulo $2^k$, which for an unsigned number is its square modulo $2^k$. The input must be already reduced modulo $2^k$.

$f(x, k) = y$, where $x, y < 2^k$ and $|x|^2 = x^2 \equiv y \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self is greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u8

Source§

impl ModPowerOf2AbsSquared for u16

Source§

fn mod_power_of_2_abs_squared(self, pow: u64) -> u16

Computes the squared absolute value of a number modulo $2^k$, which for an unsigned number is its square modulo $2^k$. The input must be already reduced modulo $2^k$.

$f(x, k) = y$, where $x, y < 2^k$ and $|x|^2 = x^2 \equiv y \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self is greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u16

Source§

impl ModPowerOf2AbsSquared for u32

Source§

fn mod_power_of_2_abs_squared(self, pow: u64) -> u32

Computes the squared absolute value of a number modulo $2^k$, which for an unsigned number is its square modulo $2^k$. The input must be already reduced modulo $2^k$.

$f(x, k) = y$, where $x, y < 2^k$ and $|x|^2 = x^2 \equiv y \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self is greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u32

Source§

impl ModPowerOf2AbsSquared for u64

Source§

fn mod_power_of_2_abs_squared(self, pow: u64) -> u64

Computes the squared absolute value of a number modulo $2^k$, which for an unsigned number is its square modulo $2^k$. The input must be already reduced modulo $2^k$.

$f(x, k) = y$, where $x, y < 2^k$ and $|x|^2 = x^2 \equiv y \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self is greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u64

Source§

impl ModPowerOf2AbsSquared for u128

Source§

fn mod_power_of_2_abs_squared(self, pow: u64) -> u128

Computes the squared absolute value of a number modulo $2^k$, which for an unsigned number is its square modulo $2^k$. The input must be already reduced modulo $2^k$.

$f(x, k) = y$, where $x, y < 2^k$ and $|x|^2 = x^2 \equiv y \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self is greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u128

Source§

impl ModPowerOf2AbsSquared for usize

Source§

fn mod_power_of_2_abs_squared(self, pow: u64) -> usize

Computes the squared absolute value of a number modulo $2^k$, which for an unsigned number is its square modulo $2^k$. The input must be already reduced modulo $2^k$.

$f(x, k) = y$, where $x, y < 2^k$ and $|x|^2 = x^2 \equiv y \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self is greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = usize

Implementors§