Skip to content

Compute all-degree Betti numbers for zero loci - #43

Merged
pbelmans merged 4 commits into
mainfrom
feat/full-betti-numbers
Nov 16, 2026
Merged

pbelmans merged 4 commits into
mainfrom
feat/full-betti-numbers

Conversation

@pbelmans

Copy link
Copy Markdown
Member

betti_numbers(X)[k] now gives b_k(X) in every cohomological degree, with indices 0:2*dimension(X). Partial flag varieties include their vanishing odd entries, and smooth zero loci obtain their Betti numbers by summing Hodge anti-diagonals. Unresolved affine parameters are retained.

For example, a cubic threefold has Betti vector [1, 0, 1, 10, 1, 0, 1], so betti_numbers(X)[3] == 10.

Update the Hodge computation and other callers to read the even Betti numbers at b[2*p], and document the convention and the zero-locus method. Construct the homogeneous Hodge matrix with zero-based axes before filling it. The fourfold example keeps its computed and reference Hodge matrices zero-based and reuses hodge_numbers for the ambient calculation. Use the dimensional aliases OffsetMatrix and OffsetVector explicitly. Include the zero-locus Betti method in the precompile workload.

This brings the work from #42 to main. #42 was merged into its former stacked base branch after #41 had already merged, leaving the changes absent from main. It also includes the subsequent simplification of reference-data iteration to ordinary enumerate loops.

Validation on Julia 1.13:

  • All 1,939 package tests pass, covering nonzero odd cohomology, K3 and Calabi–Yau examples, products, disconnected and empty loci, and symbolic Betti numbers.
  • Package/manual doctests and the full documentation build pass.
  • The pinned JuliaFormatter check passes.
  • Fourfold-example checks pass for partial reference data, Serre-duality filling, symbolic variable matching, printing, and the ambient calculation.
  • Coverage confirms the new homogeneous and zero-locus code paths execute.

Warm-cache performance checks with BenchmarkTools 1.8.0 on Julia 1.13, using identical dependency manifests and two sequential alternating runs per branch, found no material slowdown in eight representative workloads. Median-of-run-medians timings (microseconds):

Workload #41 #42 Allocation change
Betti numbers of P⁴ 10.57 10.78 +208 bytes
Betti numbers of Gr(2,8) 56.84 55.95 +336 bytes
Hodge numbers of a cubic threefold 40.26 39.75 none
Hodge numbers of (b8) 566.44 549.88 none

The timing differences are within the observed run-to-run variation; these are not claimed speedups. Direct Betti calls return longer vectors. The zero-locus Betti method has the same allocations as computing Hodge anti-diagonal sums directly on #41.

Cold checks use Julia 1.13 with --startup-file=no --threads=1 --gcthreads=1, identical dependency manifests, and three fresh processes per workload. Call times below exclude loading and constructing the variety. Since #41 has no zero-locus Betti method, its baseline computes the same Hodge anti-diagonal sums directly.

Measurement #41 baseline This PR
Package loading, existing package images 0.469 s 0.466 s
First Betti call, cubic threefold 0.0905 s 0.0649 s
First Betti call, (b8) 0.926 s 0.908 s
Forced PFV precompilation, dependencies cached 7.56 s 7.59 s

Forced precompilation was measured twice per branch in alternating order, verifying that dependency caches did not change during the measured runs. Package-load times aggregate the six fresh processes used for the two zero-locus workloads. Full fresh-process time for the (b8) Betti calculation, including Julia startup, loading, construction, and the call, was 2.02 s versus 1.95 s. These figures do not indicate a material cold-start regression. Precompiling the new method reduces its first-call compilation cost.

@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pbelmans
pbelmans merged commit 236a76f into main Nov 16, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant