Add name-aware VectorInterface methods for ITensors#186
Merged
Conversation
Adds zerovector, scale, scale!!, add!! and inner for AbstractITensor, alongside the existing scalartype, so an ITensor can be used directly as a vector in iterative solvers like KrylovKit.eigsolve that drive their Krylov vectors through VectorInterface. The generic AbstractArray fallbacks are not name-aware.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #186 +/- ##
==========================================
+ Coverage 71.60% 72.22% +0.62%
==========================================
Files 28 28
Lines 1451 1480 +29
==========================================
+ Hits 1039 1069 +30
+ Misses 412 411 -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:
|
Cover the complete interface (add/scale/zerovector and their in-place ! and maybe-in-place !! variants, inner, scalartype) rather than only the methods KrylovKit.eigsolve happens to call. The in-place methods use broadcasting. Each !! method stays in place when the result fits the destination element type and otherwise allocates. zerovector goes through a new in-place TensorAlgebra.zero! method for AbstractITensor.
mtfishman
added a commit
to ITensor/ITensorNetworksNext.jl
that referenced
this pull request
Jun 25, 2026
The DMRG code predated the INN v0.7 upgrade. Move it onto the released stack: named arrays and operators now come from ITensorBase rather than NamedDimsArrays (state, operator, apply, lazy, dimnames, replacedimnames, uniquename), the QR and SVD factorizations go through MatrixAlgebraKit (qr_compact, svd_trunc), and the tensor network types are ITensorNetwork and AbstractITensorNetwork. The VectorInterface methods that KrylovKit needs were dropped here and moved into ITensorBase (ITensor/ITensorBase.jl#186), so the Aqua piracy check is back to the full default.
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
Implements
VectorInterfaceforAbstractITensorso an ITensor works directly as a vector in iterative solvers likeKrylovKit.eigsolve, which drive their Krylov vectors throughVectorInterfaceand whose genericAbstractArrayfallbacks are not name-aware. This covers the full interface (add,scale,zerovector, their in-place!and maybe-in-place!!variants,inner, andscalartype), with the in-place methods implemented via broadcasting andzerovectorgoing through a new in-placeTensorAlgebra.zero!method forAbstractITensor. The tree-DMRG work in ITensor/ITensorNetworksNext.jl#122 had been carrying a partial set of these downstream as type piracy on the named-array type, so this moves them to where the type lives.