Skip to content

Commit

Permalink
Clearer MilnorSubalgebra::optimal_for
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyBF committed Oct 9, 2024
1 parent d7ef550 commit b12b53b
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions ext/src/nassau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,14 @@ impl MilnorSubalgebra {
}

fn optimal_for(b: Bidegree) -> Self {
let mut result = Self::zero_algebra();
for subalgebra in SubalgebraIterator::new() {
let b_is_in_vanishing_region = |subalgebra: &MilnorSubalgebra| {
let coeff = (1 << subalgebra.profile.len()) - 1;
if b.t() < coeff * (b.s() as i32 + 1) + subalgebra.top_degree() {
// (s,t) is not in the vanishing region of `subalgebra` or any further subalgebra
break;
}
result = subalgebra;
}
result
b.t() >= coeff * (b.s() as i32 + 1) + subalgebra.top_degree()
};
SubalgebraIterator::new()
.take_while(b_is_in_vanishing_region)
.last()
.unwrap_or(MilnorSubalgebra::zero_algebra())
}

fn to_bytes(&self, buffer: &mut impl Write) -> std::io::Result<()> {
Expand Down

0 comments on commit b12b53b

Please sign in to comment.