Conversation
…ames Repoints ITensorBase's `AbstractITensor` factorization layer onto the explicit factorization names TensorAlgebra v0.10 exposes (introduced in ITensor/TensorAlgebra.jl#180), replacing the catch-all `svd` / `qr` / `lq` / `eigen` / `eigvals` / `svdvals` with MatrixAlgebraKit's explicit `svd_compact` / `svd_trunc` / `qr_compact` / `eigh_full` / `eig_full` / `eigh_vals` variants and the rest. Also drops the `LinearAlgebra` factorization overloads for named tensors, since overloading `LinearAlgebra` for a type that is not an `AbstractArray` is questionable and the factorizations are now exposed under the explicit names only. Bumps to 0.7.0 and requires TensorAlgebra 0.10.
The README example used `LinearAlgebra.qr` on a named tensor, which relied on the LinearAlgebra factorization overload this branch drops. Switches it to `TensorAlgebra.qr_compact` and swaps the examples project's `LinearAlgebra` dependency for `TensorAlgebra` accordingly.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #183 +/- ##
==========================================
+ Coverage 71.05% 71.14% +0.08%
==========================================
Files 28 28
Lines 1451 1438 -13
==========================================
- Hits 1031 1023 -8
+ Misses 420 415 -5
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:
|
Define the named-tensor factorizations as overloads of `MatrixAlgebraKit`'s functions (`qr_compact`, `svd_compact`, `left_orth`, and the rest) on `AbstractITensor`, each forwarding to the matching `TensorAlgebra` array-level method on the unnamed data. This mirrors how `*` on `AbstractITensor` forwards to `TensorAlgebra.contract`: `MatrixAlgebraKit.f(t)` acts as `f` on the matricized tensor, with `TensorAlgebra` doing the matricization. For `gram_eigh_full` and `gram_eigh_full_with_pinv`, which have no `MatrixAlgebraKit` counterpart, overload `TensorAlgebra.MatrixAlgebra` instead, following the same pattern. Adds `MatrixAlgebraKit` as a direct dependency.
Renames the unnamed-array accessors `dename`/`denamed` to `unname`/`unnamed` throughout, including the `Denamed`/`DenamedT` type and type parameter, the `denamedtype` and `denamed_prototype` helpers, and the internal `*_denamed` locals. `unnamed(a)` returns the unnamed array underlying a named tensor and `unname(a, names)` returns it permuted to the given names. Also moves the `ITensorOperator` `gram_eigh_full` and `gram_eigh_full_with_pinv` methods (and their docstrings) onto the `TensorAlgebra.MatrixAlgebra` namespace, matching where the `AbstractITensor` overloads live, so the operator entry points dispatch to the named-tensor methods.
Makes `length` and `size` of a named array or named unit range return a plain
`Int` count, and `axes`/`eachindex` return plain unnamed ranges, so the count
and positional-index layer match Base and the `AbstractArray` contract (`axes`
must be `AbstractUnitRange{Int}`). The name stays on the elements (`a[i]`,
`first`, `last`, iteration) and on a tensor's named indices via `inds` /
`axes(::AbstractITensor)`, which are unchanged. Defines `length(::AbstractITensor)`
as the product of its size (the plain element count), which previously errored
because `size` returned named integers and `prod` has no named `*`. Removes the
now-redundant unwrapping at the count call sites.
With `length`/`size` of a named array or named unit range now returning a plain `Int`, the `length(unnamed(x))` / `length ∘ unnamed` / `size`-then-unname wrapping at the count call sites is redundant (`length(x) == length(unnamed(x))`). Drops it in the contraction-cost and symbolic-tensor paths, the `NamedDimsCartesianIndices` `axes`/`size`, and the TensorOperations extension.
mtfishman
commented
Jun 23, 2026
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
Adapts ITensorBase to TensorAlgebra v0.10 and tightens the named-array surface, as one breaking release.
Defines ITensorBase's
AbstractITensorfactorizations as overloads ofMatrixAlgebraKit's functions (qr_compact,svd_compact,left_orth, and the rest), each forwarding to the matchingTensorAlgebraarray-level method on the unnamed data. This mirrors how*onAbstractITensorforwards toTensorAlgebra.contract: a factorization of a named tensor acts as that factorization on its matricized form, withTensorAlgebrahandling the matricization. It replaces the previousLinearAlgebra-stylesvd/qr/lq/eigencatch-alls, which overloadedLinearAlgebrafor a type that is not anAbstractArray, and adopts the explicit factorization names TensorAlgebra v0.10 exposes (ITensor/TensorAlgebra.jl#180). Forgram_eigh_fullandgram_eigh_full_with_pinv, which have noMatrixAlgebraKitcounterpart, the overloads targetTensorAlgebra.MatrixAlgebra. AddsMatrixAlgebraKitas a direct dependency.Renames the unnamed-array accessors
dename/denamedtounname/unnamedthroughout, including theUnnamedtype, theunnamedtypeandunnamed_prototypehelpers, and internal locals.Makes
lengthandsizeof a named array or named unit range return a plainInt, andaxes/eachindexreturn plain unnamed ranges, so the count and positional-index layer match Base and theAbstractArraycontract thataxesareAbstractUnitRange{Int}. The name stays on the elements (a[i],first,last, iteration) and on a tensor's named indices viainds/axes(::AbstractITensor). This letslength(::AbstractITensor)be the plain element count (the product of its size), which previously errored.Bumps to 0.7.0 and requires TensorAlgebra 0.10.