Add coordinate types to index SecondaryExtAlgebra as a Cλ²-module#250
Add coordinate types to index SecondaryExtAlgebra as a Cλ²-module#250JoeyBF wants to merge 1 commit into
Conversation
ExtAlgebra is a first-class Cλ-module, indexed by the coordinate triple Bidegree / BidegreeGenerator / BidegreeElement. SecondaryExtAlgebra is the analogous Cλ²-module but lacked the matching coordinate types; this adds them so you can index into it the same way. New secondary coordinate triple in ext/src/secondary.rs: - Weight: the λ-adic weight (Ext = 0, Lambda = 1; only two weights since λ² = 0), with an as_i32 synthetic coordinate. - SecondaryDegree: a base bidegree b — weight-0 part at b, weight-1 (λ) part at b + LAMBDA_BIDEGREE. Analog of Bidegree. - SecondaryGenerator: base + Weight + idx; into_element places the unit entry in the ext or λ part. Analog of BidegreeGenerator. - SecondaryElement: base + ext/λ FpVectors (promoted from the earlier SyntheticElement). A generic class is not weight-homogeneous, so both parts are stored. Analog of BidegreeElement. Indexing methods on SecondaryExtAlgebra mirror ExtAlgebra (dimension/basis/element/generator, weight_dimension, and unit_* variants). They read ambient generator counts like ExtAlgebra::dimension, so the secondary d2/E3 structure stays a separate computation; undefined bidegrees panic rather than yielding a silent 0. SecondaryProduct.value and both examples use SecondaryElement. The Weight enum is designed to feed a future 3-graded synthetic spectral sequence; the B/Z/E differential filtration is left for that later layer. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0125sG5YPRQVfTs5eZ7hN7hA
📝 WalkthroughWalkthroughIntroduces ChangesSecondary Homotopy Types and API
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ext/src/ext_algebra/secondary.rs`:
- Around line 430-479: Extend the existing `test_secondary_indexing` fixture to
also exercise the new `SecondaryExtAlgebra` unit-side indexing API
(`unit_weight_dimension`, `unit_dimension`, `unit_basis`, `unit_element`, and
`unit_generator`) alongside the current `weight_dimension`, `dimension`,
`basis`, `element`, and `generator` checks. Reuse the same
`SecondaryDegree`/`Bidegree` cases and verify the unit methods return consistent
dimensions, basis ordering, round-tripping, and single-entry coordinates so both
coordinate paths are covered by the same test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 023db473-9591-4d01-a7ec-4c94e1eb7565
📒 Files selected for processing (5)
ext/examples/secondary_massey.rsext/examples/secondary_product.rsext/src/ext_algebra/mod.rsext/src/ext_algebra/secondary.rsext/src/secondary.rs
| fn test_secondary_indexing() { | ||
| let res = Arc::new(construct_standard::<false, _, _>("S_2", None).unwrap()); | ||
| res.compute_through_stem(Bidegree::n_s(8, 8)); | ||
| let e2 = Arc::new(ExtAlgebra::new(Arc::clone(&res), res)); | ||
| let sec = SecondaryExtAlgebra::new(Arc::clone(&e2)); | ||
|
|
||
| // (0,0): bottom class + λh0; (0,1): h0 + λh0²; (1,1): h1 + λ-part. | ||
| for (n, s) in [(0, 0), (0, 1), (1, 1)] { | ||
| let base = Bidegree::n_s(n, s); | ||
| let deg = SecondaryDegree::new(base); | ||
|
|
||
| let ext_dim = e2.resolution().number_of_gens_in_bidegree(base); | ||
| let lambda_dim = e2 | ||
| .resolution() | ||
| .number_of_gens_in_bidegree(base + LAMBDA_BIDEGREE); | ||
|
|
||
| assert_eq!(sec.weight_dimension(deg, Weight::Ext), ext_dim); | ||
| assert_eq!(sec.weight_dimension(deg, Weight::Lambda), lambda_dim); | ||
| assert_eq!(sec.dimension(deg), ext_dim + lambda_dim); | ||
|
|
||
| let basis = sec.basis(deg); | ||
| assert_eq!(basis.len(), sec.dimension(deg)); | ||
|
|
||
| for (i, g) in basis.iter().enumerate() { | ||
| // Weight-0 generators come first, then weight-1. | ||
| let (expected_weight, expected_idx) = if i < ext_dim { | ||
| (Weight::Ext, i) | ||
| } else { | ||
| (Weight::Lambda, i - ext_dim) | ||
| }; | ||
| assert_eq!(g.weight(), expected_weight); | ||
| assert_eq!(g.idx(), expected_idx); | ||
| assert_eq!(g.base(), base); | ||
|
|
||
| // generator(g) round-trips to element(...) with a single 1 in the right part. | ||
| let elt = sec.generator(*g); | ||
| let mut ext_coords = vec![0u32; ext_dim]; | ||
| let mut lambda_coords = vec![0u32; lambda_dim]; | ||
| match g.weight() { | ||
| Weight::Ext => ext_coords[g.idx()] = 1, | ||
| Weight::Lambda => lambda_coords[g.idx()] = 1, | ||
| } | ||
| assert_eq!(elt, sec.element(deg, &ext_coords, &lambda_coords)); | ||
| assert_eq!( | ||
| elt.ext().iter_nonzero().count() + elt.lambda().iter_nonzero().count(), | ||
| 1 | ||
| ); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Add coverage for the new unit_* indexing methods.
This test validates the module-side indexing API, but the PR also adds the parallel public unit_weight_dimension, unit_dimension, unit_basis, unit_element, and unit_generator methods. Extending this fixture to exercise those variants would catch drift between the two coordinate paths.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@ext/src/ext_algebra/secondary.rs` around lines 430 - 479, Extend the existing
`test_secondary_indexing` fixture to also exercise the new `SecondaryExtAlgebra`
unit-side indexing API (`unit_weight_dimension`, `unit_dimension`, `unit_basis`,
`unit_element`, and `unit_generator`) alongside the current `weight_dimension`,
`dimension`, `basis`, `element`, and `generator` checks. Reuse the same
`SecondaryDegree`/`Bidegree` cases and verify the unit methods return consistent
dimensions, basis ordering, round-tripping, and single-entry coordinates so both
coordinate paths are covered by the same test.
Use prod.value (SecondaryElement) instead of the removed ext_part/lambda_part fields in lambda2.rs Table IV. Fix nightly rustfmt import grouping. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017kezHiWcYod7hYovRPczz9
ExtAlgebra is a first-class Cλ-module, indexed by the coordinate triple Bidegree / BidegreeGenerator / BidegreeElement. SecondaryExtAlgebra is the analogous Cλ²-module but lacked the matching coordinate types; this adds them so you can index into it the same way.
New secondary coordinate triple in ext/src/secondary.rs:
Indexing methods on SecondaryExtAlgebra mirror ExtAlgebra (dimension/basis/element/generator, weight_dimension, and unit_* variants). They read ambient generator counts like ExtAlgebra::dimension, so the secondary d2/E3 structure stays a separate computation; undefined bidegrees panic rather than yielding a silent 0. SecondaryProduct.value and both examples use SecondaryElement.
The Weight enum is designed to feed a future 3-graded synthetic spectral sequence; the B/Z/E differential filtration is left for that later layer.
Claude-Session: https://claude.ai/code/session_0125sG5YPRQVfTs5eZ7hN7hA
Summary by CodeRabbit
New Features
Bug Fixes