Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/crates/algebra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ nom = { version = "7.0.0", default-features = false, features = ["alloc"] }
rustc-hash = "1.1.0"
serde = { version = "1.0.0", features = ["derive"] }
serde_json = "1.0.0"
enum_dispatch = "0.3.13"

[dev-dependencies]
bencher = "0.1.5"
Expand Down
17 changes: 0 additions & 17 deletions ext/crates/algebra/src/algebra/adem_algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,6 @@ use crate::algebra::{
Algebra, Bialgebra, GeneratedAlgebra, UnstableAlgebra,
};

/// An algebra that can be viewed as an Adem algebra.
///
/// This is here so that the Python bindings can use modules defined for AdemAlgebraT
/// with their version of [`SteenrodAlgebra`].
///
/// In order for things to work `AdemAlgebraT` cannot implement [`Algebra`].
/// Otherwise, the algebra enum for our bindings will see an implementation clash.
pub trait AdemAlgebraT: Send + Sync + Algebra {
fn adem_algebra(&self) -> &AdemAlgebra;
}

impl AdemAlgebraT for AdemAlgebra {
fn adem_algebra(&self) -> &AdemAlgebra {
self
}
}

/// An Adem basis element for the Steenrod algebra.
///
/// To encode an element
Expand Down
65 changes: 4 additions & 61 deletions ext/crates/algebra/src/algebra/algebra_trait.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use enum_dispatch::enum_dispatch;
#[cfg(doc)]
use fp::vector::FpVector;
use fp::{
Expand All @@ -19,6 +20,7 @@ use itertools::Itertools;
/// this function before performing other operations at that degree.
///
/// Algebras may have a distinguished set of generators; see [`GeneratedAlgebra`].
#[enum_dispatch]
pub trait Algebra: std::fmt::Display + Send + Sync + 'static {
/// A name for the algebra to use in serialization operations. This defaults to "" for algebras
/// that don't care about this problem.
Expand Down Expand Up @@ -189,6 +191,7 @@ pub trait Algebra: std::fmt::Display + Send + Sync + 'static {
}
}

#[enum_dispatch]
pub trait UnstableAlgebra: Algebra {
fn dimension_unstable(&self, degree: i32, excess: i32) -> usize;

Expand Down Expand Up @@ -476,6 +479,7 @@ impl<A: UnstableAlgebra> MuAlgebra<true> for A {
/// An [`Algebra`] equipped with a distinguished presentation.
///
/// These data can be used to specify finite modules as the actions of the distinguished generators.
#[enum_dispatch]
pub trait GeneratedAlgebra: Algebra {
/// Return generators in `degree`.
///
Expand Down Expand Up @@ -528,64 +532,3 @@ pub trait GeneratedAlgebra: Algebra {
/// arbitrary degree.
fn generating_relations(&self, degree: i32) -> Vec<Vec<(u32, (i32, usize), (i32, usize))>>;
}

#[macro_export]
macro_rules! dispatch_algebra {
($struct:ty, $dispatch_macro:ident) => {
impl Algebra for $struct {
$dispatch_macro! {
fn prefix(&self) -> &str;
fn magic(&self) -> u32;
fn prime(&self) -> ValidPrime;
fn compute_basis(&self, degree: i32);
fn dimension(&self, degree: i32) -> usize;
fn multiply_basis_elements(
&self,
result: FpSliceMut,
coeff: u32,
r_degree: i32,
r_idx: usize,
s_degree: i32,
s_idx: usize,
);

fn multiply_basis_element_by_element(
&self,
result: FpSliceMut,
coeff: u32,
r_degree: i32,
r_idx: usize,
s_degree: i32,
s: FpSlice,
);

fn multiply_element_by_basis_element(
&self,
result: FpSliceMut,
coeff: u32,
r_degree: i32,
r: FpSlice,
s_degree: i32,
s_idx: usize,
);

fn multiply_element_by_element(
&self,
result: FpSliceMut,
coeff: u32,
r_degree: i32,
r: FpSlice,
s_degree: i32,
s: FpSlice,
);

fn default_filtration_one_products(&self) -> Vec<(String, i32, usize)>;

fn basis_element_to_string(&self, degree: i32, idx: usize) -> String;
fn basis_element_from_string(&self, elt: &str) -> Option<(i32, usize)>;

fn element_to_string(&self, degree: i32, element: FpSlice) -> String;
}
}
};
}
1 change: 1 addition & 0 deletions ext/crates/algebra/src/algebra/bialgebra_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::algebra::Algebra;

/// An [`Algebra`] equipped with a coproduct operation that makes it into a
/// bialgebra.
#[enum_dispatch::enum_dispatch]
pub trait Bialgebra: Algebra {
/// Computes a coproduct $\Delta(x)$, expressed as
///
Expand Down
13 changes: 0 additions & 13 deletions ext/crates/algebra/src/algebra/milnor_algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@ use serde::{Deserialize, Serialize};

use crate::algebra::{combinatorics, Algebra, Bialgebra, GeneratedAlgebra, UnstableAlgebra};

// This is here so that the Python bindings can use modules defined for AdemAlgebraT with their own algebra enum.
// In order for things to work AdemAlgebraT cannot implement Algebra.
// Otherwise, the algebra enum for our bindings will see an implementation clash.
pub trait MilnorAlgebraT: Send + Sync + Algebra {
fn milnor_algebra(&self) -> &MilnorAlgebra;
}

impl MilnorAlgebraT for MilnorAlgebra {
fn milnor_algebra(&self) -> &MilnorAlgebra {
self
}
}

fn q_part_default() -> u32 {
!0
}
Expand Down
11 changes: 3 additions & 8 deletions ext/crates/algebra/src/algebra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! representations of the Steenrod algebra.

pub mod adem_algebra;
pub use adem_algebra::{AdemAlgebra, AdemAlgebraT};
pub use adem_algebra::AdemAlgebra;

mod algebra_trait;
pub use algebra_trait::{Algebra, GeneratedAlgebra, MuAlgebra, UnstableAlgebra};
Expand All @@ -16,14 +16,9 @@ pub mod field;
pub use field::Field;

pub mod milnor_algebra;
pub use milnor_algebra::{MilnorAlgebra, MilnorAlgebraT};

mod polynomial_algebra;
pub use polynomial_algebra::{
PolynomialAlgebra, PolynomialAlgebraMonomial, PolynomialAlgebraTableEntry,
};
pub use milnor_algebra::MilnorAlgebra;

mod steenrod_algebra;
pub use steenrod_algebra::{AlgebraType, SteenrodAlgebra, SteenrodAlgebraBorrow, SteenrodAlgebraT};
pub use steenrod_algebra::{AlgebraType, SteenrodAlgebra};

pub mod pair_algebra;
1 change: 1 addition & 0 deletions ext/crates/algebra/src/algebra/pair_algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type HashMap<K, V> = hashbrown::HashMap<K, V, std::hash::BuildHasherDefault<FxHa
use std::io;

/// A lift of an algebra to a split pair algebra. See module introduction for more.
// We can't use `enum_dispatch` here because of the associated type.
pub trait PairAlgebra: Algebra {
/// An element in the cohomological degree zero part of the pair algebra. This tends to not be
/// a ring over Fp, so we let the algebra specify how it wants to represent the elements.
Expand Down
Loading
Loading