Enum galois_2p8::field::IrreducablePolynomial
source · pub enum IrreducablePolynomial {
Show 30 variants
Poly84310,
Poly84320,
Poly85310,
Poly85320,
Poly85430,
Poly8543210,
Poly86320,
Poly8643210,
Poly86510,
Poly86520,
Poly86530,
Poly86540,
Poly8654210,
Poly8654310,
Poly87210,
Poly87310,
Poly87320,
Poly8743210,
Poly87510,
Poly87530,
Poly87540,
Poly8754320,
Poly87610,
Poly8763210,
Poly8764210,
Poly8764320,
Poly8765210,
Poly8765410,
Poly8765420,
Poly8765430,
}
Expand description
Represents an irreducable polynomial of GF(2^8)
.
Each polynomial is named according to the nonzero positions of
the coefficients. Each digit after the Poly
prefix corresponds to
the exponent of the variable for which a nonzero coefficient is
present. Recall that in GF(2^x)
, the only possible coefficients are
either 0
or 1
.
For example, Poly84310
represents x^8 + x^4 + x^3 + x + 1
.
Variants§
Poly84310
Poly84320
Poly85310
Poly85320
Poly85430
Poly8543210
Poly86320
Poly8643210
Poly86510
Poly86520
Poly86530
Poly86540
Poly8654210
Poly8654310
Poly87210
Poly87310
Poly87320
Poly8743210
Poly87510
Poly87530
Poly87540
Poly8754320
Poly87610
Poly8763210
Poly8764210
Poly8764320
Poly8765210
Poly8765410
Poly8765420
Poly8765430
Implementations§
source§impl IrreducablePolynomial
impl IrreducablePolynomial
sourcepub fn to_u16(&self) -> u16
pub fn to_u16(&self) -> u16
Converts the IrreducablePolynomial
to its binary representation.
In GF(2^x)
, coefficients in the extension polynomial may only take
values of 0
or 1
. As a result, there is a natural mapping of values
in GF(2^x)
to bits. 0b1011
maps to x^3 + x^1 + 1
, for example.
The greatest degree that can be encoded by an eight-bit byte is
7, as a consequence of the least significant bit being treated as
x^0 == 1
. In order to represent a degree 8 polynomial, there must be
at least 9 bits available, so it can be encoded as a 16-bit value.
sourcepub fn is_primitive(&self) -> bool
pub fn is_primitive(&self) -> bool
Determines whether the IrreducablePolynomial
is a primitive polynomial.
In GF(2^x)
wherein arithmetic operations are performed modulo a
polynomial, the polynomial is said to be primitive if for some alpha,
each nonzero member value of the field can be uniquely represented by
alpha ^ p
for p < 2^x
, where alpha is a root of the polynomial. That
is, for some root of the polynomial, every member of the field can
be represented as the exponentiation of said root.
In GF(2^x)
, the only nontrivial prime root of any given
IrreducablePolynomial
is two. We say “is primitive” as a shorthand
for meaning that the IrreducablePolynomial
is primitive assuming
a root of two.
The use of primitive polynomials confers an immediate performance benefit for single values: we can represent multiplication and division as addition and subtraction within logarithms and exponents. Additionally, some usages of Galois fields, e.g. Reed-Solomon syndrome coding, require primitive polynomials to function properly.
This method consults the PRIMITIVES
table to determine if the
IrreducablePolynomial
is actually primitive. That is to say,
poly.is_primitive() == PRIMITIVES.binary_search(&poly).is_ok()
Trait Implementations§
source§impl Clone for IrreducablePolynomial
impl Clone for IrreducablePolynomial
source§fn clone(&self) -> IrreducablePolynomial
fn clone(&self) -> IrreducablePolynomial
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for IrreducablePolynomial
impl Debug for IrreducablePolynomial
source§impl Hash for IrreducablePolynomial
impl Hash for IrreducablePolynomial
source§impl Ord for IrreducablePolynomial
impl Ord for IrreducablePolynomial
source§fn cmp(&self, other: &IrreducablePolynomial) -> Ordering
fn cmp(&self, other: &IrreducablePolynomial) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<IrreducablePolynomial> for IrreducablePolynomial
impl PartialEq<IrreducablePolynomial> for IrreducablePolynomial
source§fn eq(&self, other: &IrreducablePolynomial) -> bool
fn eq(&self, other: &IrreducablePolynomial) -> bool
source§impl PartialOrd<IrreducablePolynomial> for IrreducablePolynomial
impl PartialOrd<IrreducablePolynomial> for IrreducablePolynomial
source§fn partial_cmp(&self, other: &IrreducablePolynomial) -> Option<Ordering>
fn partial_cmp(&self, other: &IrreducablePolynomial) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more