diff --git a/ext/crates/algebra/src/lib.rs b/ext/crates/algebra/src/lib.rs index 4826f627f..9d79d1a8b 100644 --- a/ext/crates/algebra/src/lib.rs +++ b/ext/crates/algebra/src/lib.rs @@ -60,11 +60,11 @@ pub(crate) fn module_gens_from_json( gen_to_idx.insert(name.clone(), (degree, graded_dimension[degree])); graded_dimension[degree] += 1; } - (graded_dimension, gen_names, move |r#gen| { + (graded_dimension, gen_names, move |g| { gen_to_idx - .get(r#gen) + .get(g) .copied() - .ok_or_else(|| anyhow!("Invalid generator: {gen}")) + .ok_or_else(|| anyhow!("Invalid generator: {g}")) }) } diff --git a/ext/crates/algebra/src/module/finite_dimensional_module.rs b/ext/crates/algebra/src/module/finite_dimensional_module.rs index 094bca794..253efd7e8 100644 --- a/ext/crates/algebra/src/module/finite_dimensional_module.rs +++ b/ext/crates/algebra/src/module/finite_dimensional_module.rs @@ -480,8 +480,8 @@ impl FiniteDimensionalModule { json["type"] = Value::from("finite dimensional module"); json["gens"] = json!({}); for (i, deg_i_gens) in self.gen_names.iter_enum() { - for gen in deg_i_gens { - json["gens"][gen] = Value::from(i); + for g in deg_i_gens { + json["gens"][g] = Value::from(i); } } @@ -500,7 +500,7 @@ impl FiniteDimensionalModule { .split_once(" = ") .ok_or_else(|| anyhow!("Invalid action: {entry}"))?; - let (action, gen) = lhs + let (action, g) = lhs .rsplit_once(' ') .ok_or_else(|| anyhow!("Invalid action: {entry}"))?; @@ -508,7 +508,7 @@ impl FiniteDimensionalModule { .basis_element_from_string(action) .ok_or_else(|| anyhow!("Invalid algebra element: {action}"))?; - let (input_deg, input_idx) = gen_to_idx(gen.trim())?; + let (input_deg, input_idx) = gen_to_idx(g.trim())?; let row = self.action_mut(op_deg, op_idx, input_deg, input_idx); @@ -521,18 +521,18 @@ impl FiniteDimensionalModule { } for item in rhs.split(" + ") { - let (coef, gen) = match item.split_once(' ') { - Some((coef, gen)) => ( + let (coef, g) = match item.split_once(' ') { + Some((coef, g)) => ( str::parse(coef) .map_err(|_| anyhow!("Invalid item on right-hand side: {item}"))?, - gen, + g, ), None => (1, item), }; - let (deg, idx) = gen_to_idx(gen.trim())?; + let (deg, idx) = gen_to_idx(g.trim())?; if deg != input_deg + op_deg { return Err(anyhow!( - "Degree of {gen} is {deg} but degree of LHS is {}", + "Degree of {g} is {deg} but degree of LHS is {}", input_deg + op_deg )); } diff --git a/ext/crates/algebra/src/module/finitely_presented_module.rs b/ext/crates/algebra/src/module/finitely_presented_module.rs index 214832e51..3d07b64d9 100644 --- a/ext/crates/algebra/src/module/finitely_presented_module.rs +++ b/ext/crates/algebra/src/module/finitely_presented_module.rs @@ -130,11 +130,11 @@ impl FinitelyPresentedModule { let (term, coef) = opt(digits)(term).unwrap(); let coef: u32 = coef.unwrap_or(1); - let (op, gen) = term.rsplit_once(' ').unwrap_or(("1", term)); + let (op, g) = term.rsplit_once(' ').unwrap_or(("1", term)); let (op_deg, op_idx) = algebra .basis_element_from_string(op) .ok_or_else(|| anyhow!("Invalid term in relation: {term}"))?; - let (gen_deg, gen_idx) = gen_to_deg_idx(gen)?; + let (gen_deg, gen_idx) = gen_to_deg_idx(g)?; if v.is_empty() { deg = op_deg + gen_deg; diff --git a/ext/crates/algebra/src/steenrod_evaluator.rs b/ext/crates/algebra/src/steenrod_evaluator.rs index 92151fd7c..fafdbcd0e 100644 --- a/ext/crates/algebra/src/steenrod_evaluator.rs +++ b/ext/crates/algebra/src/steenrod_evaluator.rs @@ -64,13 +64,13 @@ impl SteenrodEvaluator { if items.is_empty() { return Ok(result); } - for (op, gen) in parse_module(items)? { - if let Some((deg, vec)) = result.get_mut(&gen) { + for (op, g) in parse_module(items)? { + if let Some((deg, vec)) = result.get_mut(&g) { let (_, adem_v) = self.evaluate_algebra_node(Some(*deg), op)?; vec.add(&adem_v, 1); } else { let (deg, adem_v) = self.evaluate_algebra_node(None, op)?; - result.insert(gen, (deg, adem_v)); + result.insert(g, (deg, adem_v)); } } Ok(result) diff --git a/ext/crates/algebra/src/steenrod_parser.rs b/ext/crates/algebra/src/steenrod_parser.rs index b800479ef..67fc86654 100644 --- a/ext/crates/algebra/src/steenrod_parser.rs +++ b/ext/crates/algebra/src/steenrod_parser.rs @@ -207,7 +207,7 @@ fn module_term(i: &str) -> IResult<&str, ModuleNode> { .unwrap(); match space(module_generator)(i) { - Ok((i, gen)) => return Ok((i, vec![(prefix.unwrap_or(Scalar(1)), gen)])), + Ok((i, g)) => return Ok((i, vec![(prefix.unwrap_or(Scalar(1)), g)])), Err(nom::Err::Error(_)) => (), Err(e) => return Err(e), } diff --git a/ext/crates/fp/benches/criterion.rs b/ext/crates/fp/benches/criterion.rs index bc3457629..ce5fbe00d 100644 --- a/ext/crates/fp/benches/criterion.rs +++ b/ext/crates/fp/benches/criterion.rs @@ -1,5 +1,8 @@ use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; -use fp::{matrix::Matrix, prime::ValidPrime}; +use fp::{ + matrix::Matrix, + prime::{Prime, ValidPrime}, +}; use rand::Rng; fn random_matrix(p: ValidPrime, dimension: usize) -> Matrix { @@ -33,7 +36,7 @@ fn row_reductions(c: &mut Criterion) { fn random_vector(p: ValidPrime, dimension: usize) -> Vec { let mut result = Vec::with_capacity(dimension); let mut rng = rand::thread_rng(); - result.resize_with(dimension, || rng.gen::() % p); + result.resize_with(dimension, || rng.gen_range(0..p.as_u32())); result } diff --git a/ext/crates/fp/src/matrix/subquotient.rs b/ext/crates/fp/src/matrix/subquotient.rs index 9a71826ff..51d68d58d 100644 --- a/ext/crates/fp/src/matrix/subquotient.rs +++ b/ext/crates/fp/src/matrix/subquotient.rs @@ -133,10 +133,10 @@ impl Subquotient { self.dimension = 0; } - pub fn add_gen(&mut self, gen: FpSlice) { + pub fn add_gen(&mut self, g: FpSlice) { self.gens.update_then_row_reduce(|gens_matrix| { let mut new_row = gens_matrix.row_mut(self.dimension); - new_row.assign(gen); + new_row.assign(g); self.quotient.reduce(new_row); }); self.dimension = self.gens.dimension(); diff --git a/ext/crates/sseq/src/coordinates/element.rs b/ext/crates/sseq/src/coordinates/element.rs index c12e8b98b..7b7dcf6f0 100644 --- a/ext/crates/sseq/src/coordinates/element.rs +++ b/ext/crates/sseq/src/coordinates/element.rs @@ -55,13 +55,13 @@ impl BidegreeElement { self.vec .iter_nonzero() .map(|(i, v)| { - let gen = BidegreeGenerator::new(self.degree(), i); + let g = BidegreeGenerator::new(self.degree(), i); let coeff_str = if v != 1 { format!("{v} ") } else { String::new() }; - format!("{coeff_str}x_{gen}") + format!("{coeff_str}x_{g}") }) .collect::>() .join(" + ") @@ -91,15 +91,15 @@ impl BidegreeElement { } else { String::new() }; - let gen = BidegreeGenerator::s_t( + let g = BidegreeGenerator::s_t( self.s() - 1, opgen.generator_degree, opgen.generator_index, ); let gen_str = if compact { - format!("x_{gen:#}") + format!("x_{g:#}") } else { - format!("x_{gen}") + format!("x_{g}") }; format!("{coeff_str}{op_str}{gen_str}") }) diff --git a/ext/crates/sseq/src/sseq.rs b/ext/crates/sseq/src/sseq.rs index b041485fd..be93c3d51 100644 --- a/ext/crates/sseq/src/sseq.rs +++ b/ext/crates/sseq/src/sseq.rs @@ -280,8 +280,8 @@ impl Sseq

{ if r > self.differentials[x][y].len() || self.page_data[tx][ty][r - 1].is_empty() { let (prev, cur) = self.page_data[x][y].split_borrow_mut(r - 1, r); - for gen in prev.gens() { - cur.add_gen(gen); + for g in prev.gens() { + cur.add_gen(g); } if r - 1 < self.differentials[x][y].len() { differentials.push(vec![Vec::new(); self.page_data[x][y][r].dimension()]); @@ -302,13 +302,12 @@ impl Sseq

{ source_dim + target_dim, ); - for (row, gen) in + for (row, g) in std::iter::zip(matrix.iter_mut(), self.page_data[x][y][r - 1].gens()) { - row.slice_mut(target_dim, target_dim + source_dim) - .assign(gen); + row.slice_mut(target_dim, target_dim + source_dim).assign(g); - d.evaluate(gen, dvec.as_slice_mut()); + d.evaluate(g, dvec.as_slice_mut()); row.slice_mut(0, target_dim).assign(dvec.as_slice()); drawn_differentials diff --git a/ext/examples/bruner.rs b/ext/examples/bruner.rs index 547a04e04..c7ac66bef 100644 --- a/ext/examples/bruner.rs +++ b/ext/examples/bruner.rs @@ -198,9 +198,9 @@ fn read_bruner_resolution(data_dir: &Path, max_n: i32) -> Result<(u32, FiniteCha let mut entries: Vec = Vec::new(); let mut cur_degree: i32 = 0; - while let Some((t, gen)) = get_element(algebra, cc.module(s - 1).as_ref(), &mut f)? { + while let Some((t, g)) = get_element(algebra, cc.module(s - 1).as_ref(), &mut f)? { if t == cur_degree { - entries.push(gen); + entries.push(g); } else { m.add_generators(cur_degree, entries.len(), None); d.add_generators_from_rows(cur_degree, entries); @@ -208,7 +208,7 @@ fn read_bruner_resolution(data_dir: &Path, max_n: i32) -> Result<(u32, FiniteCha m.extend_by_zero(t - 1); d.extend_by_zero(t - 1); - entries = vec![gen]; + entries = vec![g]; cur_degree = t; } } @@ -262,8 +262,8 @@ fn main() { let matrix = hom.get_map(b.s()).hom_k(b.t()); for (i, row) in matrix.into_iter().enumerate() { - let gen = BidegreeGenerator::new(b, i); - println!("x_{gen:#} = {row:?}"); + let g = BidegreeGenerator::new(b, i); + println!("x_{g:#} = {row:?}"); } } } diff --git a/ext/examples/define_module.rs b/ext/examples/define_module.rs index e0ec4bbb6..508efff05 100644 --- a/ext/examples/define_module.rs +++ b/ext/examples/define_module.rs @@ -28,8 +28,8 @@ pub fn get_gens() -> anyhow::Result>> { if gen_deg.is_none() { eprintln!("This is the list of generators and degrees:"); for (i, deg_i_gens) in gens.iter_enum() { - for gen in deg_i_gens.iter() { - eprint!("({i}, {gen}) "); + for g in deg_i_gens.iter() { + eprint!("({i}, {g}) "); } } eprintln!(); @@ -78,8 +78,8 @@ pub fn get_gens() -> anyhow::Result>> { pub fn gens_to_json(gens: &BiVec>) -> serde_json::Value { let mut gens_json = json!({}); for (i, deg_i_gens) in gens.iter_enum() { - for gen in deg_i_gens { - gens_json[gen] = json!(i); + for g in deg_i_gens { + gens_json[g] = json!(i); } } gens_json @@ -106,8 +106,8 @@ pub fn interactive_module_define_fdmodule( let mut module = FDModule::new(Arc::clone(&algebra), String::new(), graded_dim); for (i, deg_i_gens) in gens.iter_enum() { - for (j, gen) in deg_i_gens.iter().enumerate() { - module.set_basis_element_name(i, j, gen.to_string()); + for (j, g) in deg_i_gens.iter().enumerate() { + module.set_basis_element_name(i, j, g.to_string()); } } @@ -139,19 +139,16 @@ pub fn interactive_module_define_fdmodule( } for term in expr.split('+') { let term = term.trim(); - let (coef, gen) = match term.split_once(' ') { - Some((coef, gen)) => (str::parse::(coef)?, gen), + let (coef, g) = match term.split_once(' ') { + Some((coef, g)) => (str::parse::(coef)?, g), None => (1, term), }; - if let Some(gen_idx) = - gens[output_deg].iter().position(|d| d == gen) + if let Some(gen_idx) = gens[output_deg].iter().position(|d| d == g) { result[gen_idx] += coef; } else { - return Err(anyhow!( - "No generator {gen} in degree {output_deg}" - )); + return Err(anyhow!("No generator {g} in degree {output_deg}")); } } @@ -173,8 +170,8 @@ pub fn interactive_module_define_fdmodule( /// Given a string representation of an element in an algebra together with a generator, multiply /// each term on the right with the generator. -fn replace(algebra_elt: &str, gen: &str) -> String { - algebra_elt.replace('+', &format!("{gen} +")) + " " + gen +fn replace(algebra_elt: &str, g: &str) -> String { + algebra_elt.replace('+', &format!("{g} +")) + " " + g } pub fn interactive_module_define_fpmodule( @@ -203,8 +200,8 @@ pub fn interactive_module_define_fpmodule( let mut degree_lookup = HashMap::default(); for (i, deg_i_gens) in gens.iter_enum() { - for gen in deg_i_gens.iter() { - degree_lookup.insert(gen.clone(), i); + for g in deg_i_gens.iter() { + degree_lookup.insert(g.clone(), i); } } @@ -221,11 +218,11 @@ pub fn interactive_module_define_fpmodule( // Check that the generators exist and the terms all have the same degree let mut deg = None; - for (gen, (op_deg, _)) in result.iter() { + for (g, (op_deg, _)) in result.iter() { let cur_deg = op_deg + degree_lookup - .get(gen) - .ok_or_else(|| anyhow!("Unknown generator: {gen}"))?; + .get(g) + .ok_or_else(|| anyhow!("Unknown generator: {g}"))?; if deg.is_none() { deg = Some(cur_deg); } else if deg != Some(cur_deg) { @@ -247,7 +244,7 @@ pub fn interactive_module_define_fpmodule( let mut milnor_relation = String::new(); let mut milnor_op = FpVector::new(p, 0); - for (gen, (op_deg, adem_op)) in relation.iter() { + for (g, (op_deg, adem_op)) in relation.iter() { if adem_op.is_zero() { continue; } @@ -258,10 +255,10 @@ pub fn interactive_module_define_fpmodule( milnor_op.set_scratch_vector_size(adem_op.len()); ev.adem_to_milnor(&mut milnor_op, 1, *op_deg, adem_op); - adem_relation += &replace(&ev.adem.element_to_string(*op_deg, adem_op.as_slice()), gen); + adem_relation += &replace(&ev.adem.element_to_string(*op_deg, adem_op.as_slice()), g); milnor_relation += &replace( &ev.milnor.element_to_string(*op_deg, milnor_op.as_slice()), - gen, + g, ); } if !adem_relation.is_empty() { @@ -273,8 +270,8 @@ pub fn interactive_module_define_fpmodule( output_json["p"] = Value::from(p.as_u32()); output_json["type"] = Value::String("finitely presented module".to_owned()); for (i, deg_i_gens) in gens.iter_enum() { - for gen in deg_i_gens { - output_json["gens"][gen] = Value::from(i); + for g in deg_i_gens { + output_json["gens"][g] = Value::from(i); } } output_json["adem_relations"] = Value::Array(adem_relations); diff --git a/ext/examples/differentials.rs b/ext/examples/differentials.rs index 88a4311fa..3b27ebb12 100644 --- a/ext/examples/differentials.rs +++ b/ext/examples/differentials.rs @@ -13,9 +13,9 @@ fn main() -> anyhow::Result<()> { for b in resolution.iter_stem() { for i in 0..resolution.number_of_gens_in_bidegree(b) { - let gen = BidegreeGenerator::new(b, i); - let boundary = resolution.boundary_string(gen, true); - println!("d x_{gen:#} = {boundary}"); + let g = BidegreeGenerator::new(b, i); + let boundary = resolution.boundary_string(g, true); + println!("d x_{g:#} = {boundary}"); } } Ok(()) diff --git a/ext/examples/filtration_one.rs b/ext/examples/filtration_one.rs index cb2a3ae77..73537c1fb 100644 --- a/ext/examples/filtration_one.rs +++ b/ext/examples/filtration_one.rs @@ -21,9 +21,9 @@ fn main() -> anyhow::Result<()> { // TODO: This doesn't work with the reordered Adams basis let products = resolution.filtration_one_product(1 << i, 0, b).unwrap(); for (idx, row) in products.into_iter().enumerate() { - let gen = BidegreeGenerator::new(b, idx); + let g = BidegreeGenerator::new(b, idx); if !row.is_empty() { - println!("h_{i} x_{gen} = {row:?}"); + println!("h_{i} x_{g} = {row:?}"); } } i += 1; diff --git a/ext/examples/lift_hom.rs b/ext/examples/lift_hom.rs index fb706045d..b4c51c5c1 100644 --- a/ext/examples/lift_hom.rs +++ b/ext/examples/lift_hom.rs @@ -119,8 +119,8 @@ fn main() -> anyhow::Result<()> { hom.extend_step(input, None); } else { for (idx, row) in matrix.iter_mut().enumerate() { - let gen = BidegreeGenerator::new(input, idx); - let v: Vec = query::vector(&format!("f(x_{gen}"), row.len()); + let g = BidegreeGenerator::new(input, idx); + let v: Vec = query::vector(&format!("f(x_{g}"), row.len()); for (i, &x) in v.iter().enumerate() { row.set_entry(i, x); } @@ -140,8 +140,8 @@ fn main() -> anyhow::Result<()> { } let matrix = hom.get_map(shifted_b2.s()).hom_k(b2.t()); for (i, r) in matrix.iter().enumerate() { - let gen = BidegreeGenerator::new(b2, i); - println!("{name} x_{gen} = {r:?}"); + let g = BidegreeGenerator::new(b2, i); + println!("{name} x_{g} = {r:?}"); } } Ok(()) diff --git a/ext/examples/mahowald_invariant.rs b/ext/examples/mahowald_invariant.rs index 44c1fae18..cca280263 100644 --- a/ext/examples/mahowald_invariant.rs +++ b/ext/examples/mahowald_invariant.rs @@ -100,7 +100,7 @@ struct PKData { } struct MahowaldInvariant { - gen: BidegreeGenerator, + g: BidegreeGenerator, output_t: i32, invariant: FpVector, indeterminacy_basis: Vec, @@ -217,13 +217,13 @@ impl PKData { let it = (0..minus_one_s_2_gens).filter_map(move |i| { let mut image = FpVector::new(TWO, p_k_gens); - let gen = BidegreeGenerator::new(b, i); - self.minus_one_cell.act(image.as_slice_mut(), 1, gen); + let g = BidegreeGenerator::new(b, i); + self.minus_one_cell.act(image.as_slice_mut(), 1, g); if !image.is_zero() && image_subspace.contains(image.as_slice()) { let mut invariant = FpVector::new(TWO, bottom_s_2_gens); quasi_inverse.apply(invariant.as_slice_mut(), 1, image.as_slice()); Some(MahowaldInvariant { - gen, + g, output_t: b_bottom.t(), invariant, indeterminacy_basis: indeterminacy_basis.clone(), @@ -245,7 +245,7 @@ impl fmt::Display for MahowaldInvariant { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result { let output_t = self.output_t; let f2_vec_to_sum = |v: &FpVector| { - let elt = BidegreeElement::new(Bidegree::s_t(self.gen.s(), output_t), v.clone()); + let elt = BidegreeElement::new(Bidegree::s_t(self.g.s(), output_t), v.clone()); elt.to_basis_string() }; let indeterminacy_info = if self.indeterminacy_basis.is_empty() { @@ -262,11 +262,7 @@ impl fmt::Display for MahowaldInvariant { ) }; let invariant = f2_vec_to_sum(&self.invariant); - write!( - f, - "M(x_{gen}) = {invariant}{indeterminacy_info}", - gen = self.gen - ) + write!(f, "M(x_{g}) = {invariant}{indeterminacy_info}", g = self.g) } } @@ -290,11 +286,11 @@ mod tests { #[case] invariant: Vec, #[case] indeterminacy_dim: usize, ) { - let gen = BidegreeGenerator::new(Bidegree::s_t(s, input_t), input_i); + let g = BidegreeGenerator::new(Bidegree::s_t(s, input_t), input_i); let s_2_resolution = resolve_s_2(None, k).unwrap(); let p_k = PKData::try_new(k, &None, &s_2_resolution).unwrap(); - for mi in p_k.mahowald_invariants_for_bidegree(gen.degree()) { - if mi.gen.idx() == gen.idx() { + for mi in p_k.mahowald_invariants_for_bidegree(g.degree()) { + if mi.g.idx() == g.idx() { assert_eq!(mi.output_t, output_t); assert_eq!(Vec::from(&mi.invariant), invariant); assert_eq!(mi.indeterminacy_basis.len(), indeterminacy_dim); diff --git a/ext/examples/massey.rs b/ext/examples/massey.rs index 1c1019908..1abaa38ef 100644 --- a/ext/examples/massey.rs +++ b/ext/examples/massey.rs @@ -115,8 +115,8 @@ fn main() -> anyhow::Result<()> { for (k, &v) in b_class.iter().enumerate() { if v != 0 { - let gen = BidegreeGenerator::new(b, k); - hom.act(product[idx].slice_mut(0, product_num_gens), v, gen); + let g = BidegreeGenerator::new(b, k); + hom.act(product[idx].slice_mut(0, product_num_gens), v, g); } } } diff --git a/ext/examples/secondary_massey.rs b/ext/examples/secondary_massey.rs index 90d0ee976..d0eea7ddc 100644 --- a/ext/examples/secondary_massey.rs +++ b/ext/examples/secondary_massey.rs @@ -297,13 +297,13 @@ fn main() -> anyhow::Result<()> { .get_map(c.s() + b.underlying().shift.s()) .hom_k(c.t()), ); - for (gen, out) in target_page_data + for (g, out) in target_page_data .subspace_gens() .zip_eq(product_matrix.iter_mut()) { out.slice_mut(prod_num_gens, prod_num_gens + target_num_gens) - .add(gen, 1); - for (i, v) in gen.iter_nonzero() { + .add(g, 1); + for (i, v) in g.iter_nonzero() { out.slice_mut(0, prod_num_gens).add(m0[i].as_slice(), v); } } @@ -386,12 +386,12 @@ fn main() -> anyhow::Result<()> { .hom_k(c.t() + b_shift.t()); let mb = b.underlying().get_map(c.s() + b_shift.s()).hom_k(c.t()); - for gen in e3_kernel.iter() { + for g in e3_kernel.iter() { // Print name { print!("<{a_name}, {b_name}, "); let has_ext = { - let ext_part = gen.slice(0, target_num_gens); + let ext_part = g.slice(0, target_num_gens); if ext_part.iter_nonzero().count() > 0 { print!( "[{basis_string}]", @@ -404,7 +404,7 @@ fn main() -> anyhow::Result<()> { } }; - let tau_part = gen.slice(target_num_gens, target_all_gens); + let tau_part = g.slice(target_num_gens, target_all_gens); let num_entries = tau_part.iter_nonzero().count(); if num_entries > 0 { if has_ext { @@ -414,7 +414,7 @@ fn main() -> anyhow::Result<()> { let basis_string = BidegreeElement::new( c + TAU_BIDEGREE, - gen.slice(target_num_gens, target_all_gens).to_owned(), + g.slice(target_num_gens, target_all_gens).to_owned(), ) .to_basis_string(); if num_entries == 1 { @@ -431,20 +431,20 @@ fn main() -> anyhow::Result<()> { scratch1.set_scratch_vector_size(source_tau_num_gens); // First deal with the null-homotopy of ab - for (i, v) in gen.slice(0, target_num_gens).iter_nonzero() { + for (i, v) in g.slice(0, target_num_gens).iter_nonzero() { scratch0 .iter_mut() .zip_eq(&m0[i]) .for_each(|(a, b)| *a += v * b); scratch1.add(&m1[i], v); } - for (i, v) in gen.slice(target_num_gens, target_all_gens).iter_nonzero() { + for (i, v) in g.slice(target_num_gens, target_all_gens).iter_nonzero() { scratch1.add(&mt[i], v); } // Now do the -1 part of the null-homotopy of bc. { let sign = p * p - 1; - let out = b.product_nullhomotopy(b_tau.as_deref(), &unit_sseq, c, gen); + let out = b.product_nullhomotopy(b_tau.as_deref(), &unit_sseq, c, g); for (i, v) in out.iter_nonzero() { scratch0 .iter_mut() @@ -465,7 +465,7 @@ fn main() -> anyhow::Result<()> { scratch0.clear(); scratch0.resize(prod_num_gens, 0); - for (i, v) in gen.slice(0, target_num_gens).iter_nonzero() { + for (i, v) in g.slice(0, target_num_gens).iter_nonzero() { scratch0 .iter_mut() .zip_eq(&mb[i]) diff --git a/ext/examples/secondary_product.rs b/ext/examples/secondary_product.rs index 4e578804e..31bf48729 100644 --- a/ext/examples/secondary_product.rs +++ b/ext/examples/secondary_product.rs @@ -150,8 +150,8 @@ fn main() -> anyhow::Result<()> { if target_num_gens > 0 { let hom_k = hom.get_map((b + shift).s()).hom_k(b.t()); for i in page_data.complement_pivots() { - let gen = BidegreeGenerator::new(b, i); - println!("{name} τ x_{gen} = τ {:?}", &hom_k[i]); + let g = BidegreeGenerator::new(b, i); + println!("{name} τ x_{g} = τ {:?}", &hom_k[i]); } } @@ -169,12 +169,12 @@ fn main() -> anyhow::Result<()> { page_data.subspace_gens(), outputs.iter_mut().map(FpVector::as_slice_mut), ); - for (gen, output) in page_data.subspace_gens().zip_eq(outputs) { + for (g, output) in page_data.subspace_gens().zip_eq(outputs) { println!( "{name} [{basis_string}] = {} + τ {}", output.slice(0, target_num_gens), output.slice(target_num_gens, target_num_gens + tau_num_gens), - basis_string = BidegreeElement::new(b, gen.to_owned()).to_basis_string(), + basis_string = BidegreeElement::new(b, g.to_owned()).to_basis_string(), ); } } diff --git a/ext/examples/sq0.rs b/ext/examples/sq0.rs index 9f984f648..fda6a3812 100644 --- a/ext/examples/sq0.rs +++ b/ext/examples/sq0.rs @@ -48,9 +48,9 @@ fn main() -> anyhow::Result<()> { let map = hom.get_map(b.s()); for i in 0..res.number_of_gens_in_bidegree(b) { - let gen = BidegreeGenerator::new(b, i); + let g = BidegreeGenerator::new(b, i); println!( - "Sq^0 x_{gen} = [{}]", + "Sq^0 x_{g} = [{}]", (0..source_num_gens) .map(|j| map.output(doubled_b.t(), j).entry(offset + i)) .format(", ") diff --git a/ext/src/chain_complex/mod.rs b/ext/src/chain_complex/mod.rs index 737b9c504..1d5838c47 100644 --- a/ext/src/chain_complex/mod.rs +++ b/ext/src/chain_complex/mod.rs @@ -142,13 +142,12 @@ where } /// Get a string representation of d(gen), where d is the differential of the resolution. - fn boundary_string(&self, gen: BidegreeGenerator, compact: bool) -> String { - let d = self.differential(gen.s()); + fn boundary_string(&self, g: BidegreeGenerator, compact: bool) -> String { + let d = self.differential(g.s()); let target = d.target(); - let result_vector = d.output(gen.t(), gen.idx()); + let result_vector = d.output(g.t(), g.idx()); - BidegreeElement::new(gen.degree(), result_vector.clone()) - .to_string_module(&*target, compact) + BidegreeElement::new(g.degree(), result_vector.clone()).to_string_module(&*target, compact) } } diff --git a/ext/src/resolution_homomorphism.rs b/ext/src/resolution_homomorphism.rs index bbde94942..20b8fabfb 100644 --- a/ext/src/resolution_homomorphism.rs +++ b/ext/src/resolution_homomorphism.rs @@ -471,8 +471,8 @@ where /// Given a chain map $f: C \to C'$ between free chain complexes, apply /// $$ \Hom(f, k): \Hom(C', k) \to \Hom(C, k) $$ /// to the specified generator of $\Hom(C', k)$. - pub fn act(&self, mut result: FpSliceMut, coef: u32, gen: BidegreeGenerator) { - let source = gen.degree() + self.shift; + pub fn act(&self, mut result: FpSliceMut, coef: u32, g: BidegreeGenerator) { + let source = g.degree() + self.shift; assert_eq!( result.as_slice().len(), @@ -481,10 +481,10 @@ where .number_of_gens_in_degree(source.t()) ); - let target_module = self.target.module(gen.s()); + let target_module = self.target.module(g.s()); let map = self.get_map(source.s()); - let j = target_module.operation_generator_to_index(0, 0, gen.t(), gen.idx()); + let j = target_module.operation_generator_to_index(0, 0, g.t(), g.idx()); for i in 0..result.as_slice().len() { result.add_basis_element(i, coef * map.output(source.t(), i).entry(j)); } diff --git a/ext/src/secondary.rs b/ext/src/secondary.rs index 013eb3859..99058031f 100644 --- a/ext/src/secondary.rs +++ b/ext/src/secondary.rs @@ -246,18 +246,18 @@ impl SecondaryHomotopy { let tracing_span = tracing::Span::current(); let f = |t, idx| { let _tracing_guard = tracing_span.enter(); - let gen = BidegreeGenerator::s_t(s, t, idx); + let g = BidegreeGenerator::s_t(s, t, idx); let save_file = SaveFile { algebra: self.target.algebra(), kind: SaveKind::SecondaryComposite, - b: gen.degree(), - idx: Some(gen.idx()), + b: g.degree(), + idx: Some(g.idx()), }; if let Some(dir) = dir.read() { if let Some(mut f) = save_file.open_file(dir.to_owned()) { return SecondaryComposite::from_bytes( Arc::clone(&self.target), - gen.t() - self.shift_t, + g.t() - self.shift_t, self.hit_generator, &mut f, ) @@ -267,13 +267,13 @@ impl SecondaryHomotopy { let mut composite = SecondaryComposite::new( Arc::clone(&self.target), - gen.t() - self.shift_t, + g.t() - self.shift_t, self.hit_generator, ); - tracing::info_span!("Computing composite", gen = %gen).in_scope(|| { + tracing::info_span!("Computing composite", g = %g).in_scope(|| { for (coef, d1, d0) in &maps { - composite.add_composite(*coef, gen.t(), gen.idx(), d1, d0); + composite.add_composite(*coef, g.t(), g.idx(), d1, d0); } composite.finalize(); }); @@ -381,7 +381,7 @@ pub trait SecondaryLift: Sync + Sized { fn save_dir(&self) -> &SaveDirectory; - fn compute_intermediate(&self, gen: BidegreeGenerator) -> FpVector; + fn compute_intermediate(&self, g: BidegreeGenerator) -> FpVector; fn composite(&self, s: u32) -> CompositeData; #[tracing::instrument(skip(self))] @@ -417,17 +417,17 @@ pub trait SecondaryLift: Sync + Sized { self.homotopies().range().into_maybe_par_iter().for_each(f); } - #[tracing::instrument(skip(self), ret(Display, level = Level::DEBUG), fields(gen = %gen))] - fn get_intermediate(&self, gen: BidegreeGenerator) -> FpVector { - if let Some((_, v)) = self.intermediates().remove(&gen) { + #[tracing::instrument(skip(self), ret(Display, level = Level::DEBUG), fields(g = %g))] + fn get_intermediate(&self, g: BidegreeGenerator) -> FpVector { + if let Some((_, v)) = self.intermediates().remove(&g) { return v; } let save_file = SaveFile { algebra: self.algebra(), kind: SaveKind::SecondaryIntermediate, - b: gen.degree(), - idx: Some(gen.idx()), + b: g.degree(), + idx: Some(g.idx()), }; if let Some(dir) = self.save_dir().read() { @@ -438,7 +438,7 @@ pub trait SecondaryLift: Sync + Sized { } } - let result = self.compute_intermediate(gen); + let result = self.compute_intermediate(g); if let Some(dir) = self.save_dir().write() { let mut f = save_file.create_file(dir.to_owned(), false); @@ -485,11 +485,11 @@ pub trait SecondaryLift: Sync + Sized { #[tracing::instrument(skip(self))] fn compute_intermediates(&self) { let tracing_span = tracing::Span::current(); - let f = |gen: BidegreeGenerator| { + let f = |g: BidegreeGenerator| { let _tracing_guard = tracing_span.enter(); // If we already have homotopies, we don't need to compute intermediate - if self.homotopies()[gen.s() as i32].homotopies.next_degree() >= gen.t() { + if self.homotopies()[g.s() as i32].homotopies.next_degree() >= g.t() { return; } // Check if we have a saved homotopy @@ -497,7 +497,7 @@ pub trait SecondaryLift: Sync + Sized { let save_file = SaveFile { algebra: self.algebra(), kind: SaveKind::SecondaryHomotopy, - b: gen.degree(), + b: g.degree(), idx: None, }; @@ -505,7 +505,7 @@ pub trait SecondaryLift: Sync + Sized { return; } } - self.intermediates().insert(gen, self.get_intermediate(gen)); + self.intermediates().insert(g, self.get_intermediate(g)); }; self.homotopies() @@ -565,14 +565,14 @@ pub trait SecondaryLift: Sync + Sized { let get_intermediate = |i| { let _tracing_guard = tracing_span.enter(); - let gen = BidegreeGenerator::new(b, i); - let mut v = self.get_intermediate(gen); - if gen.s() > shift.s() + 1 { - self.homotopies()[gen.s() as i32 - 1].homotopies.apply( + let g = BidegreeGenerator::new(b, i); + let mut v = self.get_intermediate(g); + if g.s() > shift.s() + 1 { + self.homotopies()[g.s() as i32 - 1].homotopies.apply( v.as_slice_mut(), 1, - gen.t(), - d.output(gen.t(), gen.idx()).as_slice(), + g.t(), + d.output(g.t(), g.idx()).as_slice(), ); } v @@ -727,16 +727,16 @@ where vec![(1, d1, d0)] } - fn compute_intermediate(&self, gen: BidegreeGenerator) -> FpVector { + fn compute_intermediate(&self, g: BidegreeGenerator) -> FpVector { let p = self.prime(); - let target = self.underlying.module(gen.s() - 3); - let mut result = FpVector::new(p, target.dimension(gen.t() - 1)); - let d = self.underlying.differential(gen.s()); - self.homotopies[gen.s() as i32 - 1].act( + let target = self.underlying.module(g.s() - 3); + let mut result = FpVector::new(p, target.dimension(g.t() - 1)); + let d = self.underlying.differential(g.s()); + self.homotopies[g.s() as i32 - 1].act( result.as_slice_mut(), 1, - gen.t(), - d.output(gen.t(), gen.idx()).as_slice(), + g.t(), + d.output(g.t(), g.idx()).as_slice(), false, ); result @@ -912,20 +912,20 @@ where vec![(neg_1, d_source, c0), (1, c1, d_target)] } - fn compute_intermediate(&self, gen: BidegreeGenerator) -> FpVector { + fn compute_intermediate(&self, g: BidegreeGenerator) -> FpVector { let p = self.prime(); let neg_1 = p - 1; - let shifted_b = gen.degree() - self.shift(); + let shifted_b = g.degree() - self.shift(); let target = self.target().module(shifted_b.s() - 1); let mut result = FpVector::new(p, target.dimension(shifted_b.t() - 1)); - let d = self.source().differential(gen.s()); + let d = self.source().differential(g.s()); - self.homotopies[gen.s() as i32 - 1].act( + self.homotopies[g.s() as i32 - 1].act( result.as_slice_mut(), neg_1, - gen.t(), - d.output(gen.t(), gen.idx()).as_slice(), + g.t(), + d.output(g.t(), g.idx()).as_slice(), false, ); self.target.homotopy(shifted_b.s() + 1).act( @@ -933,19 +933,19 @@ where neg_1, shifted_b.t(), self.underlying - .get_map(gen.s()) - .output(gen.t(), gen.idx()) + .get_map(g.s()) + .output(g.t(), g.idx()) .as_slice(), true, ); - self.underlying.get_map(gen.s() - 2).apply( + self.underlying.get_map(g.s() - 2).apply( result.as_slice_mut(), 1, - gen.t() - 1, + g.t() - 1, self.source - .homotopy(gen.s()) + .homotopy(g.s()) .homotopies - .output(gen.t(), gen.idx()) + .output(g.t(), g.idx()) .as_slice(), ); @@ -1240,22 +1240,22 @@ where self.underlying.save_dir() } - fn compute_intermediate(&self, gen: BidegreeGenerator) -> FpVector { + fn compute_intermediate(&self, g: BidegreeGenerator) -> FpVector { let p = self.prime(); let neg_1 = p - 1; - let shifted_b = gen.degree() - self.shift(); + let shifted_b = g.degree() - self.shift(); let target = self.target().module(shifted_b.s() - 1); let mut result = FpVector::new(p, target.dimension(shifted_b.t() - 1)); - self.homotopies[gen.s() as i32 - 1].act( + self.homotopies[g.s() as i32 - 1].act( result.as_slice_mut(), 1, - gen.t(), + g.t(), self.source() - .differential(gen.s()) - .output(gen.t(), gen.idx()) + .differential(g.s()) + .output(g.t(), g.idx()) .as_slice(), false, ); @@ -1265,31 +1265,31 @@ where 1, shifted_b.t(), self.underlying - .homotopy(gen.s()) - .output(gen.t(), gen.idx()) + .homotopy(g.s()) + .output(g.t(), g.idx()) .as_slice(), true, ); - self.underlying.homotopy(gen.s() - 2).apply( + self.underlying.homotopy(g.s() - 2).apply( result.as_slice_mut(), neg_1, - gen.t() - 1, - self.left.source.homotopies()[gen.s() as i32] + g.t() - 1, + self.left.source.homotopies()[g.s() as i32] .homotopies - .output(gen.t(), gen.idx()) + .output(g.t(), g.idx()) .as_slice(), ); - let left_shifted_b = gen.degree() - self.left.underlying.shift; + let left_shifted_b = g.degree() - self.left.underlying.shift; self.right.homotopies()[left_shifted_b.s() as i32].act( result.as_slice_mut(), neg_1, left_shifted_b.t(), self.left .underlying - .get_map(gen.s()) - .output(gen.t(), gen.idx()) + .get_map(g.s()) + .output(g.t(), g.idx()) .as_slice(), true, ); @@ -1303,8 +1303,8 @@ where left_shifted_b.t(), self.left .underlying - .get_map(gen.s()) - .output(gen.t(), gen.idx()) + .get_map(g.s()) + .output(g.t(), g.idx()) .as_slice(), ); } @@ -1313,9 +1313,9 @@ where result.as_slice_mut(), neg_1, left_shifted_b.t() - 1, - self.left.homotopies()[gen.s() as i32] + self.left.homotopies()[g.s() as i32] .homotopies - .output(gen.t(), gen.idx()) + .output(g.t(), g.idx()) .as_slice(), ); @@ -1324,10 +1324,7 @@ where result.as_slice_mut(), neg_1, left_shifted_b.t() - 1, - left_tau - .get_map(gen.s()) - .output(gen.t(), gen.idx()) - .as_slice(), + left_tau.get_map(g.s()).output(g.t(), g.idx()).as_slice(), ); } result