Skip to content

Implement the TensorAlgebra 0.17 projection and matrix-function interfaces#207

Merged
mtfishman merged 8 commits into
mainfrom
mf/project-trailing-axes
Jul 7, 2026
Merged

Implement the TensorAlgebra 0.17 projection and matrix-function interfaces#207
mtfishman merged 8 commits into
mainfrom
mf/project-trailing-axes

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

Implements the TensorAlgebra 0.17 projection and matrix-function interfaces for graded arrays. project_hermitian, project_antihermitian, and project_isometric run blockwise, and projectto! accepts a source with trailing length-1 axes. Adds blockwise copy, copyto!, rmul!, lmul!, and Base.Array methods so graded arrays go through block storage instead of falling back to scalar indexing, and removes a duplicate copy that broke precompilation.

Overloads pow_diag_safe! to clamp-power each reduced diagonal block, so gram_eigh_full_with_pinv and the safe spectral functions run on a graded matrix, whose diagonal is stored per sector and cannot go through the generic elementwise path.

Also extends trivialrange to a length-n form for graded ranges, matching the length-n overload added in TensorAlgebra.

mtfishman and others added 5 commits July 5, 2026 15:47
Extends the MatrixAlgebraKit glue to the projection functions (`project_hermitian`, `project_antihermitian`, `project_isometric`) with blockwise algorithm selection, input copies, and outputs. Adds blockwise `copy`, `copyto!`, `rmul!`, and `lmul!` methods so graded arrays do not reach scalar-indexing fallbacks, and removes a duplicate `copy` definition that broke precompilation. `projectto!` accepts a source with trailing length-1 axes. Bumps the `TensorAlgebra` compat to `0.17`.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
`trivialrange(::Type{<:GradedOneTo}, n)` returns a trivial-sector range of dimension n, extending the length-1 overload to the new form.
Adds `Base.Array` methods for `FusedGradedMatrix` and `FusedGradedVector` that copy block by block, matching the existing `AbelianGradedArray` method. The generic `convert(Array, ...)` fallback copies elementwise, which scalar-indexes the block storage and errors.
…pport is in review

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…nputs

Reorganizes the graded projection to match the TensorMap backend: `allocate_project` is now a thin dispatcher and the auxiliary-leg derivation moves into `infer_aux_space`, with `projected_charge` as the abelian per-slice primitive it builds on. Also guards the `reshape` in `projectto!` and in the graded `getindex` with a `check_project_shape` that throws unless the input and destination sizes agree ignoring trailing length-1 axes, so a genuinely misshapen input errors instead of being silently reinterpreted. `check_project_shape` is vendored from TensorAlgebra since it is not part of its public API.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.63158% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.37%. Comparing base (f6e4d2f) to head (17b7dbb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/fusedgradedvector.jl 0.00% 14 Missing ⚠️
src/fusedgradedmatrix.jl 16.66% 10 Missing ⚠️
src/matrixalgebrakit.jl 45.45% 6 Missing ⚠️
src/abeliangradedarray.jl 94.28% 2 Missing ⚠️
src/abstractgradedarray.jl 0.00% 2 Missing ⚠️
src/gradedoneto.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #207      +/-   ##
==========================================
- Coverage   81.77%   80.37%   -1.41%     
==========================================
  Files          24       24              
  Lines        1888     1957      +69     
==========================================
+ Hits         1544     1573      +29     
- Misses        344      384      +40     
Flag Coverage Δ
docs 0.00% <0.00%> (ø)

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

mtfishman and others added 3 commits July 6, 2026 16:47
`allocate_project` for graded axes only dispatched on a non-empty codomain and left the domain axes untyped, so an empty-codomain projection skipped the auxiliary-leg derivation and a dense domain could mis-dispatch. Splits it into two entries, codomain-led and domain-led, sharing an `allocate_project_graded` builder (the same two-entry split `similar_map` uses), and restricts the domain axes to graded ranges. Also renames the vendored shape guard `check_project_shape` to `check_project_size` since it takes sizes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Clamp-power each reduced diagonal block through the new `pow_diag_safe!` hook (ITensor/TensorAlgebra.jl#204). This restores `gram_eigh_full_with_pinv` and the safe spectral functions on a graded matrix, whose diagonal view is stored per sector and cannot go through the generic `map!` path.

Only the reduced degeneracy data is touched, which is correct even for a non-abelian sector type: a diagonal factor is `Diagonal(λ) ⊗ I` per sector, so the power passes to the reduced eigenvalues.
@mtfishman mtfishman changed the title [WIP] Implement the TensorAlgebra 0.17 projection and matrix-function interfaces Implement the TensorAlgebra 0.17 projection and matrix-function interfaces Jul 7, 2026
@mtfishman mtfishman marked this pull request as ready for review July 7, 2026 19:37
@mtfishman mtfishman enabled auto-merge (squash) July 7, 2026 19:37
@mtfishman mtfishman merged commit 53f9ab2 into main Jul 7, 2026
23 of 28 checks passed
@mtfishman mtfishman deleted the mf/project-trailing-axes branch July 7, 2026 19:47
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