feat: add plev, TensorTrain, tensor contraction, diag utilities#29
Merged
feat: add plev, TensorTrain, tensor contraction, diag utilities#29
Conversation
Add plev across the Julia wrapper: - C_API.jl: t4a_index_get_plev, t4a_index_set_plev, t4a_index_prime wrappers - Tensor4all.jl: plev(), prime(), noprime(), setprime() functions - Updated ==, hash, sim, show to include plev - commoninds/uniqueinds/replaceinds/hasind/hasinds now plev-aware - ITensors extension preserves plev in both conversion directions - Tests for all plev functionality Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- TensorTrain = TreeTensorNetwork{Int} (same type as MPS/MPO)
- is_chain(ttn): runtime check for chain topology
- Int variant: verifies vertices are 1:n with sequential connectivity
- Generic variant: checks path graph properties (degree ≤ 2, connected)
- _assert_chain(ttn): throws ArgumentError for non-chain topology
- Tests: 121/121 TreeTN tests pass
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- contract(t1::Tensor, t2::Tensor): tensor-tensor contraction via C API - t1 * t2 operator for tensors - is_mps_like(tt): check each vertex has 1 site index - is_mpo_like(tt): check each vertex has 2 site indices - diag_embed(t, idx): duplicate idx as primed copy (MPS→MPO-like) - diag_trace(t, idx, idx'): extract diagonal (MPO→MPS-like) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update TENSOR4ALL_RS_FALLBACK_COMMIT to latest main which includes plev support and t4a_tensor_contract C API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (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
TensorTraintype alias +is_chain/_assert_chainruntime checkscontract(t1::Tensor, t2::Tensor)+*operatoris_mps_like/is_mpo_likeruntime checkersdiag_embed/diag_tracefor MPS-like ↔ MPO-like tensor manipulationDepends on: tensor4all/tensor4all-rs#398 (plev + tensor contraction C API)
Changes
Prime level support
plev(i),prime(i),noprime(i),setprime(i, n)functions==,hash,siminclude plevcommoninds,uniqueinds,replaceinds,hasind,hasindsare plev-awareTensorTrain alias
TensorTrain = TreeTensorNetwork{Int}(same type as MPS/MPO)is_chain(ttn): runtime check for chain topology_assert_chain(ttn): throws for non-chainTensor contraction
contract(t1::Tensor, t2::Tensor): viat4a_tensor_contractC APIt1 * t2operatorUtility functions
is_mps_like(tt): each vertex has 1 site indexis_mpo_like(tt): each vertex has 2 site indicesdiag_embed(t, idx): duplicate idx as primed copy (diagonal)diag_trace(t, idx, idx'): extract diagonalTest plan
🤖 Generated with Claude Code