Implement the TensorAlgebra 0.17 projection and matrix-function interfaces#207
Merged
Conversation
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 Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`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.
…both are registered
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the TensorAlgebra 0.17 projection and matrix-function interfaces for graded arrays.
project_hermitian,project_antihermitian, andproject_isometricrun blockwise, andprojectto!accepts a source with trailing length-1 axes. Adds blockwisecopy,copyto!,rmul!,lmul!, andBase.Arraymethods so graded arrays go through block storage instead of falling back to scalar indexing, and removes a duplicatecopythat broke precompilation.Overloads
pow_diag_safe!to clamp-power each reduced diagonal block, sogram_eigh_full_with_pinvand 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
trivialrangeto a length-nform for graded ranges, matching the length-noverload added in TensorAlgebra.