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
12 changes: 4 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
*.jl.*.cov
*.jl.cov
*.jl.mem
*.cov
*.mem
*.o
*.swp
.DS_Store
.benchmarkci
.tmp
.vscode/
Manifest.toml
LocalPreferences.toml
Manifest*.toml
benchmark/*.json
dev/
docs/LocalPreferences.toml
docs/Manifest.toml
docs/build/
docs/src/index.md
examples/LocalPreferences.toml
test/LocalPreferences.toml
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "GradedArrays"
uuid = "bc96ca6e-b7c8-4bb6-888e-c93f838762c2"
version = "0.5.3"
version = "0.5.4"
authors = ["ITensor developers <[email protected]> and contributors"]

[deps]
Expand Down Expand Up @@ -37,7 +37,7 @@ MatrixAlgebraKit = "0.6"
Random = "1.10"
SUNRepresentations = "0.3"
SplitApplyCombine = "1.2.3"
TensorAlgebra = "0.3.2, 0.4"
TensorAlgebra = "0.5"
TensorKitSectors = "0.1, 0.2"
TensorProducts = "0.1.3"
TypeParameterAccessors = "0.4"
Expand Down
12 changes: 8 additions & 4 deletions src/tensoralgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,25 @@ function matricize_axes(
return codomain_axis, flip(unflipped_domain_axis)
end

using TensorAlgebra: blockedtrivialperm
function TensorAlgebra.matricize(
::SectorFusion, a::AbstractArray, biperm::AbstractBlockPermutation{2}
::SectorFusion, a::AbstractArray, codomain_length::Val, domain_length::Val
)
a_perm = permutedims(a, Tuple(biperm))
biperm = blockedtrivialperm((codomain_length, domain_length))
codomain_axis, domain_axis = matricize_axes(axes(a)[biperm])
a_reshaped = blockreshape(a_perm, (codomain_axis, domain_axis))
a_reshaped = blockreshape(a, (codomain_axis, domain_axis))
# Sort the blocks by sector and merge the equivalent sectors.
return sectormergesort(a_reshaped)
end

using TensorAlgebra: tuplemortar
function TensorAlgebra.unmatricize(
::SectorFusion,
m::AbstractMatrix,
blocked_axes::BlockedTuple{2, <:Any, <:Tuple{Vararg{AbstractUnitRange}}},
codomain_axes::Tuple{Vararg{AbstractUnitRange}},
domain_axes::Tuple{Vararg{AbstractUnitRange}},
)
blocked_axes = tuplemortar((codomain_axes, domain_axes))
if isempty(blocked_axes)
# Handle edge case of empty blocked_axes, which can occur
# when matricizing a 0-dimensional array (a scalar).
Expand Down
5 changes: 4 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ TensorProducts = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"

[sources]
GradedArrays = {path = ".."}

[compat]
Aqua = "0.8.11"
BlockArrays = "1.6"
Expand All @@ -28,7 +31,7 @@ SUNRepresentations = "0.3"
SafeTestsets = "0.1"
SparseArraysBase = "0.7"
Suppressor = "0.2.8"
TensorAlgebra = "0.3.2, 0.4"
TensorAlgebra = "0.5"
TensorKitSectors = "0.1, 0.2"
TensorProducts = "0.1.3"
Test = "1.10"
Expand Down
Loading