Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ITensorBase"
uuid = "4795dd04-0d67-49bb-8f44-b89c448a1dc7"
version = "0.15.0"
version = "0.15.1"
authors = ["ITensor developers <support@itensor.org> and contributors"]

[workspace]
Expand Down Expand Up @@ -44,14 +44,14 @@ Adapt = "4.1.1"
ArrayLayouts = "1.11"
Combinatorics = "1"
ConstructionBase = "1.6"
GradedArrays = "0.16.5"
GradedArrays = "0.16.6"
LinearAlgebra = "1.10"
MatrixAlgebraKit = "0.2, 0.3, 0.4, 0.5, 0.6"
Mooncake = "0.4.202, 0.5"
OMEinsumContractionOrders = "1.3"
Random = "1.10"
SimpleTraits = "0.9.4"
TensorAlgebra = "0.21.1"
TensorAlgebra = "0.22"
TensorKit = "0.17"
TensorKitSectors = "0.3.9"
TermInterface = "2"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ITensorBase = "0.15"
ITensorFormatter = "0.2.27"
Literate = "2"
MatrixAlgebraKit = "0.2, 0.3, 0.4, 0.5, 0.6"
TensorAlgebra = "0.21.1"
TensorAlgebra = "0.22"
Test = "1.10"
32 changes: 31 additions & 1 deletion ext/ITensorBaseGradedArraysExt.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
module ITensorBaseGradedArraysExt

using GradedArrays: SectorRange
using GradedArrays: FusedGradedDiagonal, FusedGradedMatrix, SectorRange
using ITensorBase: ITensorBase, NamedTensor, name, uniquename, unnamed
using Random: AbstractRNG, default_rng
using TensorAlgebra: TensorAlgebra as TA
using TensorKitSectors: Sector

const NamedUnitRange = ITensorBase.NamedUnitRange

# GradedArrays defines `unmatricize` for its fused matrices with untyped axes, which ties with
# ITensorBase's methods on named axes. Restate those for each fused matrix type so the named
# unmatricize of a graded matrix has a unique most-specific method.
for M in (:FusedGradedMatrix, :FusedGradedDiagonal)
@eval begin
function TA.unmatricize(
m::$M,
codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}},
domain::Tuple{Vararg{NamedUnitRange}}
)
return ITensorBase.unmatricize_namedtensor(m, codomain, domain)
end
function TA.unmatricize(
m::$M,
codomain::Tuple{Vararg{NamedUnitRange}},
domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}
)
return ITensorBase.unmatricize_namedtensor(m, codomain, domain)
end
function TA.unmatricize(
m::$M,
codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}},
domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}
)
return ITensorBase.unmatricize_namedtensor(m, codomain, domain)
end
end
end

# Flux-canceling constructors at the `Index` level: delegate to the GradedArrays flux backend on
# the unnamed axes, then reattach names, so the flux convention lives only in the backend. The
# sector may be a bare `TensorKitSectors.Sector` or a `SectorRange`; this is an extension because
Expand Down
28 changes: 27 additions & 1 deletion ext/ITensorBaseTensorKitExt.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
module ITensorBaseTensorKitExt

using ITensorBase: ITensorBase, NamedUnitRange
using TensorKit: ElementarySpace, dim
using TensorAlgebra: TensorAlgebra as TA
using TensorKit: AbstractTensorMap, ElementarySpace, dim

# TensorAlgebra's TensorKit extension defines `unmatricize` for `AbstractTensorMap` with untyped
# axes, and a `TensorMap` is not an `AbstractMatrix`, so ITensorBase's named-axes methods do not
# reach it. Restate them for `AbstractTensorMap`.
function TA.unmatricize(
m::AbstractTensorMap,
codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}},
domain::Tuple{Vararg{NamedUnitRange}}
)
return ITensorBase.unmatricize_namedtensor(m, codomain, domain)
end
function TA.unmatricize(
m::AbstractTensorMap,
codomain::Tuple{Vararg{NamedUnitRange}},
domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}
)
return ITensorBase.unmatricize_namedtensor(m, codomain, domain)
end
function TA.unmatricize(
m::AbstractTensorMap,
codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}},
domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}
)
return ITensorBase.unmatricize_namedtensor(m, codomain, domain)
end

# ================================ Index over a native space ==============================
# A native TensorKit space is stored directly as the axis value of a `NamedUnitRange`, so
Expand Down
9 changes: 5 additions & 4 deletions src/tensoralgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,24 @@ end
# Unmatricize an unnamed matrix into the named `codomain`/`domain` axes, giving a named tensor.
# `Tuple{Vararg{NamedUnitRange}}` also matches an empty tuple, so demanding at least one named
# axis across the two groups takes three methods: one per group, plus the both-nonempty case
# that resolves the ambiguity between them.
# that resolves the ambiguity between them. `m::AbstractMatrix` keeps these more specific than
# TensorAlgebra's `unmatricize(::AbstractMatrix, axes_codomain, axes_domain)`.
function TA.unmatricize(
m,
m::AbstractMatrix,
codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}},
domain::Tuple{Vararg{NamedUnitRange}}
)
return unmatricize_namedtensor(m, codomain, domain)
end
function TA.unmatricize(
m,
m::AbstractMatrix,
codomain::Tuple{Vararg{NamedUnitRange}},
domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}
)
return unmatricize_namedtensor(m, codomain, domain)
end
function TA.unmatricize(
m,
m::AbstractMatrix,
codomain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}},
domain::Tuple{NamedUnitRange, Vararg{NamedUnitRange}}
)
Expand Down
4 changes: 2 additions & 2 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ AbstractTrees = "0.4.5"
Adapt = "4"
Aqua = "0.8.9"
Combinatorics = "1"
GradedArrays = "0.16.5"
GradedArrays = "0.16.6"
ITensorBase = "0.15"
ITensorPkgSkeleton = "0.3.42"
JLArrays = "0.2, 0.3"
Expand All @@ -44,7 +44,7 @@ Random = "1.10"
SafeTestsets = "0.1"
StableRNGs = "1"
Suppressor = "0.2"
TensorAlgebra = "0.21.1"
TensorAlgebra = "0.22"
TensorKit = "0.17"
TensorKitSectors = "0.3.9"
TermInterface = "2"
Expand Down
Loading