mod arithmetic;
mod artin_schreier;
mod galois;
pub use arithmetic::*;
pub use artin_schreier::*;
pub use galois::*;
use crate::scalar::Scalar;
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct Nimber(pub u128);
impl Nimber {
pub fn fuzzy(&self, other: &Self) -> bool {
self != other
}
}
impl std::fmt::Display for Nimber {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "*{}", self.0)
}
}
impl std::fmt::Debug for Nimber {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self, f)
}
}
impl Scalar for Nimber {
fn zero() -> Self {
Nimber(0)
}
fn one() -> Self {
Nimber(1)
}
fn add(&self, rhs: &Self) -> Self {
Nimber(nim_add(self.0, rhs.0))
}
fn neg(&self) -> Self {
*self
}
fn mul(&self, rhs: &Self) -> Self {
Nimber(nim_mul(self.0, rhs.0))
}
fn characteristic() -> u128 {
2
}
fn inv(&self) -> Option<Self> {
nim_inv(self.0).map(Nimber)
}
}
#[cfg(test)]
mod tests;