Skip to content

feat: add const-generic Gram matrix construction - #236

Merged
acgetchell merged 1 commit into
mainfrom
feat/219-gram-matrix
Sep 5, 2026
Merged

feat: add const-generic Gram matrix construction#236
acgetchell merged 1 commit into
mainfrom
feat/219-gram-matrix

Conversation

@acgetchell

@acgetchell acgetchell commented Sep 5, 2026

Copy link
Copy Markdown
Owner
  • Add allocation-free, const-evaluable gram_matrix with independent vector count and dimension
  • Preserve bitwise symmetry and typed dot-product overflow diagnostics
  • Document geometric uses, conditioning, and floating-point limitations
  • Add benchmarks for square and rectangular vector collections
  • Simplify exact rational scaling using canonical positive denominators
  • Deduplicate factorization property-test fixtures and assertions

Closes #219

Summary by CodeRabbit

  • New Features

    • Added gram_matrix for allocation-free construction of symmetric Gram matrices from fixed-size vectors.
    • Exported the feature through the crate root and prelude.
    • Preserves computation errors and supports zero-size and compile-time use cases.
  • Documentation

    • Added guidance on Gram matrices, geometric measures, numerical limitations, and benchmarking.
  • Tests

    • Added broad coverage for precision, dependent and orthogonal inputs, scaling, underflow, overflow, and edge cases.
    • Added benchmarks across dimensions and input scenarios.
  • Refactor

    • Simplified rational-number denominator handling.

- Add allocation-free, const-evaluable `gram_matrix` with independent vector count and dimension
- Preserve bitwise symmetry and typed dot-product overflow diagnostics
- Document geometric uses, conditioning, and floating-point limitations
- Add benchmarks for square and rectangular vector collections
- Simplify exact rational scaling using canonical positive denominators
- Deduplicate factorization property-test fixtures and assertions
@acgetchell acgetchell self-assigned this Sep 5, 2026
@acgetchell
acgetchell enabled auto-merge September 5, 2026 00:46
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: cbe92bef-62a2-4f08-a0f6-25e234e5135a

📥 Commits

Reviewing files that changed from the base of the PR and between 8e8c24b and a62e72a.

📒 Files selected for processing (9)
  • Cargo.toml
  • README.md
  • REFERENCES.md
  • benches/gram.rs
  • src/gram.rs
  • src/lib.rs
  • src/rational.rs
  • tests/proptest_factorizations.rs
  • tests/proptest_gram.rs

Included review availability: 2 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

The pull request adds a fixed-size gram_matrix API with public exports, tests, benchmarks, and documentation. It also simplifies rational denominator handling and consolidates factorization property-test helpers.

Changes

Gram matrix API

Layer / File(s) Summary
Gram matrix API and exports
src/gram.rs, src/lib.rs
gram_matrix computes each upper-triangle dot product once, mirrors values for exact symmetry, propagates LaError, and is available from the crate root and prelude.
Gram matrix validation
tests/proptest_gram.rs
Tests cover independent integer oracles, geometric cases, rectangular and zero-size inputs, const evaluation, numerical edge cases, symmetry, and overflow diagnostics.
Gram benchmarks and documentation
Cargo.toml, benches/gram.rs, README.md, REFERENCES.md
Benchmarks compare gram_matrix with checked hand-written assembly across dimensions and fixture families. Documentation describes construction, formulas, limitations, and benchmark usage.

Rational denominator handling

Layer / File(s) Summary
Canonical denominator arithmetic
src/rational.rs
Denominator clearing uses canonical positive denominators directly and removes redundant sign normalization and the unused helper.

Factorization test helpers

Layer / File(s) Summary
Shared factorization verification
tests/proptest_factorizations.rs
LDLT and LU property tests use shared matrix, multiplication, determinant, solve, and row-swap verification helpers.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to a62e7

The Gram matrix API, rational arithmetic cleanup, tests, benchmarks, and documentation do not present an identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: adding const-generic Gram matrix construction.
Linked Issues check ✅ Passed The PR implements the requested fixed-size gram_matrix API, exact symmetric construction, typed dot-product error propagation, allocation-free operation, stable Rust support, documentation, tests, and…
Out of Scope Changes check ✅ Passed The documentation, benchmark additions, rational scaling cleanup, and factorization test deduplication are included in the stated PR objectives and support the Gram matrix feature or its validation. N…
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/219-gram-matrix

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.99%. Comparing base (8e8c24b) to head (a62e72a).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #236      +/-   ##
==========================================
+ Coverage   97.93%   97.99%   +0.06%     
==========================================
  Files          12       13       +1     
  Lines        6574     6579       +5     
==========================================
+ Hits         6438     6447       +9     
+ Misses        136      132       -4     
Flag Coverage Δ
unittests 97.99% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@acgetchell
acgetchell merged commit 25aa4c0 into main Sep 5, 2026
21 checks passed
@acgetchell
acgetchell deleted the feat/219-gram-matrix branch September 5, 2026 00:57
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.

feat: Construct Gram matrices from fixed vectors

1 participant