Add named methods for the Hermitian-safe matrix functions#212
Merged
Conversation
…_hermitian Adds `AbstractNamedTensor` methods for `sqrth_safe`, `invsqrth_safe`, `sqrth_invsqrth_safe`, and `MatrixAlgebraKit.project_hermitian`, dispatching through TensorAlgebra's labeled forms and returning results with the input's dimension names. Updates the `TensorAlgebra` compat to `0.17`. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Renames `_broadcast_permuteddims_to` to `_broadcast_permuteddims` and merges it into the existing barrier as one untyped method, taking the rank from `TensorAlgebra.ndims` so operands that are not `AbstractArray`s (such as a `TensorMap`) go through the same path.
uniquename on an IndexName now produces a fresh bare name (new id, no tags, prime level zero) instead of keeping the seed's decoration. A fresh name, such as a factorization's new bond, has no relationship to the seed's tags or prime level, and inheriting them made factorization bond names depend on the input tensor's storage order (the first stored dimension seeded the name). Also documents that the named safe spectral functions require Hermitian input, matching the TensorAlgebra change. Co-authored-by: Claude <noreply@anthropic.com>
The named `sqrth_safe`, `invsqrth_safe`, and `project_hermitian` methods for `AbstractNamedTensor` share the same body (lower to the unnamed array, reattach names codomain-first), so generate them from one `@eval` loop. `sqrth_invsqrth_safe` stays a standalone method since it fans the names over a returned pair. The docstrings remain standalone binding docs. Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #212 +/- ##
==========================================
- Coverage 74.80% 74.40% -0.40%
==========================================
Files 30 30
Lines 1564 1567 +3
==========================================
- Hits 1170 1166 -4
- Misses 394 401 +7
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:
|
`uniquename` on an existing `IndexName` now keeps its tags and prime level, minting only a fresh id (the legacy `sim`). Pass the name type instead of an instance to mint a bare name with no tags and prime level zero. The factorization bond names pass the type, since a fresh bond has no relationship to the input's decoration. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Define `conj` on an `AbstractNamedTensor` as `conj.(a)`, so eager conjugation reuses the linear-combination broadcast machinery instead of a separate backend hook. `conj.` lowers to a `ConjBroadcasted` leaf (introduced in ITensor/TensorAlgebra.jl#204) that the op primitives absorb, materializing into an all-codomain destination with dualized axes, so a named tensor wrapping a `TensorMap` can be conjugated. The broadcast destination is now allocated from the flattened expression's axes rather than the prototype's, since an axis-dualizing operand makes them differ.
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
Adds
AbstractNamedTensormethods for the Hermitian-safe matrix functions (sqrth_safe,invsqrth_safe,sqrth_invsqrth_safe) andproject_hermitian, dispatching through the labeled forms in TensorAlgebra 0.17 and returning results carrying the input's dimension names. These are the named-tensor entry points the symmetric ITensor backend builds on, and they require Hermitian input like the underlyingeigh_full.Generalizes the broadcast alignment barrier to backends that are not
AbstractArrays: it now takes the rank fromTensorAlgebra.ndims, so aTensorMapoperand goes through the same alignment path as a dense array.Defines
conjon anAbstractNamedTensorasconj.(a), so conjugation runs through the broadcast machinery and a named tensor wrapping aTensorMapconjugates without a dedicated method. The broadcast destination is allocated from the flattened expression's axes rather than the prototype's, so an axis-dualizing operand (aconjleaf) lands in the correct space.Changes
uniquenameon anIndexNameto mint a fresh bare name (new id, no tags, prime level zero) instead of inheriting the seed's decoration. A factorization's new bond has no relationship to the input's tags or prime level, and inheriting them made bond names depend on the input tensor's storage order, since the first stored dimension seeded the name.