Skip to content

Add named methods for the Hermitian-safe matrix functions#212

Merged
mtfishman merged 8 commits into
mainfrom
mf/tensoralgebra-0.17
Jul 7, 2026
Merged

Add named methods for the Hermitian-safe matrix functions#212
mtfishman merged 8 commits into
mainfrom
mf/tensoralgebra-0.17

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

Adds AbstractNamedTensor methods for the Hermitian-safe matrix functions (sqrth_safe, invsqrth_safe, sqrth_invsqrth_safe) and project_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 underlying eigh_full.

Generalizes the broadcast alignment barrier to backends that are not AbstractArrays: it now takes the rank from TensorAlgebra.ndims, so a TensorMap operand goes through the same alignment path as a dense array.

Defines conj on an AbstractNamedTensor as conj.(a), so conjugation runs through the broadcast machinery and a named tensor wrapping a TensorMap conjugates 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 (a conj leaf) lands in the correct space.

Changes uniquename on an IndexName to 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.

mtfishman and others added 5 commits July 5, 2026 15:47
…_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

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.50000% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.40%. Comparing base (f875628) to head (efaca10).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/tensoralgebra.jl 56.66% 13 Missing ⚠️
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     
Flag Coverage Δ
docs 23.13% <30.76%> (-0.23%) ⬇️

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 13:12
`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.
@mtfishman mtfishman changed the title [WIP] Add named methods for the Hermitian-safe matrix functions Add named methods for the Hermitian-safe matrix functions Jul 7, 2026
@mtfishman mtfishman marked this pull request as ready for review July 7, 2026 19:58
@mtfishman mtfishman enabled auto-merge (squash) July 7, 2026 19:58
@mtfishman mtfishman merged commit daa7646 into main Jul 7, 2026
24 of 28 checks passed
@mtfishman mtfishman deleted the mf/tensoralgebra-0.17 branch July 7, 2026 20:19
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