Add named project for building symmetry-restricted tensors#208
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #208 +/- ##
==========================================
+ Coverage 74.58% 74.62% +0.03%
==========================================
Files 30 30
Lines 1519 1537 +18
==========================================
+ Hits 1133 1147 +14
- Misses 386 390 +4
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:
|
mtfishman
added a commit
to ITensor/TensorAlgebra.jl
that referenced
this pull request
Jul 2, 2026
…support (#203) ## Summary Adds `project`, an owned convenience over the existing `project_map` hook for building a symmetry-restricted array from a dense one. The three-argument form takes an explicit codomain/domain split and the two-argument form takes a flat list of axes (an empty domain), both forwarding to `project_map`, and `checked_project` is the verified counterpart of `checked_project_map`. This mirrors the `zeros`/`zeros_map` pairing, where the unsuffixed name is the convenience that also accepts the codomain/domain split. Also adds the `TensorMap` path in the TensorKit extension so `project` can build a `TensorMap` from a dense array: `similar_map` allocates a same-device buffer whose block storage type follows the dense prototype, `projectto!` fills the symmetry-allowed blocks through `project_symmetric!` and discards the rest, and `checked_projectto!` verifies the projection by densifying the result and reusing the dense path's elementwise `isapprox(src, dest)` check, so it keeps one `InexactError`/`kwargs` contract across backends. The named-index `project` for `AbstractITensor` is added in ITensor/ITensorBase.jl#208.
Adds methods extending TensorAlgebra's `project` and `checked_project` that build a named tensor from a dense array and the indices to attach. The three-argument form takes a codomain/domain split (an operator), the two-argument form a flat list of indices (a state). The index axes select the backend, so the same call builds an `Array`, a block-sparse array, or a `TensorMap`. The named entry strips to the unnamed array plus axes, lowers to `TensorAlgebra.project`, and reattaches the names.
Route `project`/`checked_project` through a shared `project_nameddims` / `checked_project_nameddims` helper and add the empty-codomain method, so an all-domain projection (`project(a, (), (i,))`, the mirror of the flat all-codomain state) strips names correctly instead of falling through to the unnamed-axis generic. This matches the two-dispatch-entry pattern of the `similar_map` construction hooks.
0a59f24 to
c1df9a5
Compare
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 methods extending
TensorAlgebra.projectandTensorAlgebra.checked_project(added in ITensor/TensorAlgebra.jl#203) that build a named tensor from a dense array and the indices to attach. The three-argument form takes a codomain/domain split (an operator), and the two-argument form takes a flat list of indices (a state, i.e. an empty domain). The index axes select the backend, so the same call builds anArrayon dense indices, a block-sparse array on graded indices, and aTensorMapon TensorKit spaces. The named entry strips to the unnamed array plus axes, lowers toTensorAlgebra.project, and reattaches the names.This is the named-index projection primitive for building symmetric operators and states from a dense basis matrix:
project(Sz, (i',), (i,))for an operator,project(v, (i,))for a state.