Add out-of-place permutedims with an optional bipartition#202
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #202 +/- ##
==========================================
+ Coverage 84.16% 84.28% +0.11%
==========================================
Files 24 24
Lines 758 770 +12
==========================================
+ Hits 638 649 +11
- Misses 120 121 +1
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:
|
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mtfishman
added a commit
to ITensor/ITensorBase.jl
that referenced
this pull request
Jul 3, 2026
…207) ## Summary Map-shaped construction now forwards a codomain/domain split down to the backing storage instead of flattening. `randn`, `rand`, and `zeros` take a codomain and a domain index tuple (`randn((i,), (j,))`), and the `rand_map`/`randn_map`/`zeros_map` hooks on indices build a backing object partitioned accordingly: a TensorKit `TensorMap` stores a `codomain ← domain` map, a dense backend stores flat. Following the `similar_map` convention the domain is conjugated in the flattened view, so the result is an ordinary tensor over the codomain indices and the duals of the domain indices. This fixes `rand_map((i,), (j,))` on TensorMap-backed indices, which previously flattened everything into the codomain. `aligndims` gains a map form `aligndims(a, codomain, domain)` that both repartitions and permutes, and its existing single-tuple form now routes through `TensorAlgebra.permutedims` so a `TensorMap`-backed tensor permutes correctly (a `TensorMap` has no flat `permutedims`). Both ride the `permutedims` seam from ITensor/TensorAlgebra.jl#202, so any backend implementing it works with no dedicated method, and a dense backend ignores the split and stores flat. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
TensorAlgebra.permutedimsandTensorAlgebra.permutedims!, out-of-place and in-place permutation with an optional codomain/domain bipartition, mirroringTensorKit.permute. The single-permutation form reorders all dimensions into one permutation, giving an all-codomain result. The two-permutation form additionally splits them into a codomain/domain bipartition, including the degenerate case of an empty codomain that sends every dimension to the domain. Both go through the existingbipermutedimsopadd!interface (the out-of-place form allocating its destination withsimilar_map), so any operand implementing that interface, whether a dense array, a graded array, or aTensorMap, is permuted with no dedicated method. A dense operand ignores the bipartition and stores the result flat.