pub type Word = u64; // element type of the vectors we use
const WORDLEVELS: usize = 6; // 2^{2^6} = 64 = size of Word
+/// A type representing a finite nimber.
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct FiniteNimber(Vec<Word>);
}
}
-impl FiniteNimber {
- /// Compute the square of a nimber, faster than the general
- /// multiplication algorithm performed by the `Mul` trait can do
- /// it.
- pub fn square(&self) -> FiniteNimber {
- let r = self.to_ref();
- r.square_recurse(r.level())
- }
-}
-
impl<'a, 'b> Mul<FiniteNimberRef<'a>> for FiniteNimberRef<'b> {
type Output = FiniteNimber;
fn mul(self, other: FiniteNimberRef<'a>) -> FiniteNimber {
}
impl FiniteNimber {
+ /// Compute the square of a nimber, faster than the general
+ /// multiplication algorithm performed by the `Mul` trait can do
+ /// it.
+ pub fn square(&self) -> FiniteNimber {
+ let r = self.to_ref();
+ r.square_recurse(r.level())
+ }
+
/// Compute the square root of a nimber. Every nimber has a unique
- /// square root, so this function can't fail, and doesn't need to
- /// return a list or a tuple or anything more complicated than a
- /// single nimber.
+ /// square root, and the square root of a finite nimber is finite.
+ /// So this function can't fail, and doesn't need to return a list
+ /// or a tuple or anything more complicated than a single nimber.
pub fn sqrt(&self) -> FiniteNimber {
let r = self.to_ref();
r.sqrt_recurse(r.level())