Trait guff::GaloisField [−][src]
pub trait GaloisField where
Self::EE: From<Self::E>, { type E: ElementStore; type EE: ElementStore; type SEE: ElementStore; const ORDER: u16; const HIGH_BIT: Self::E; const POLY_BIT: Self::EE; const FIELD_MASK: Self::E;}Show methods
fn poly(&self) -> Self::E; fn full_poly(&self) -> Self::EE; fn add(&self, a: Self::E, b: Self::E) -> Self::E { ... } fn sub(&self, a: Self::E, b: Self::E) -> Self::E { ... } fn mul(&self, a: Self::E, b: Self::E) -> Self::E { ... } fn div(&self, a: Self::E, b: Self::E) -> Self::E { ... } fn inv(&self, a: Self::E) -> Self::E { ... } fn pow(&self, a: Self::E, b: Self::EE) -> Self::E
where
Self::E: Into<Self::EE>, { ... } fn vec_sum_elements(&self, v: &[Self::E]) -> Self::E { ... } fn vec_add_vec_in_place(&self, dest: &mut [Self::E], other: &[Self::E]) { ... } fn vec_add_vecs_giving_other(
&self,
dest: &mut [Self::E],
a: &[Self::E],
b: &[Self::E]
) { ... } fn vec_cross_product(
&self,
dest: &mut [Self::E],
a: &[Self::E],
b: &[Self::E]
) { ... } fn vec_dot_product(&self, a: &[Self::E], b: &[Self::E]) -> Self::E { ... } fn vec_constant_scale_in_place(&self, dest: &mut [Self::E], a: Self::E) { ... } fn vec_fma_in_place(&self, dest: &mut [Self::E], a: Self::E, b: Self::E) { ... } fn high_bit(&self) -> Self::E { ... } fn order(&self) -> u16 { ... } fn field_mask(&self) -> Self::E { ... }
Expand description
Collection of methods needed to implement maths in GF(2x). Provides (slow) default implementations that can be overriden by optimised versions.
Associated Types
type E: ElementStore
type E: ElementStore
Natural storage class (u8, u16, u32, etc.) for storing elements of the field.
type EE: ElementStore
type EE: ElementStore
The next largest natural storage class, eg if E is u8, then EE should be U16. Used for:
-
storing/returning field polynomial, which is always larger than the largest field element
-
storing the result of a non-modular (overflowing) multiply of two field elements
type SEE: ElementStore
type SEE: ElementStore
As EE, but signed. Used internally to implement some lookup tables.
Associated Constants
const FIELD_MASK: Self::E
const FIELD_MASK: Self::E
Mask for selecting all bits of field value, eg GF(28) → 0xff
Required methods
Provided methods
Polynomial multiplication modulo the field polynomial
Division modulo to the field polynomial (default implementation calculated as a・b-1)
Calculate polynomial a-1 modulo the field polynomial (using Extended Euclidean method)
Calculate polynomial ab modulo the field polynomial
fn field_mask(&self) -> Self::E
fn field_mask(&self) -> Self::E
Access Self::FIELD_MASK as a method