Skip to content

Commit 6d2a13d

Browse files
authored
generalize unmatricize to arbitrary axes (#66)
1 parent 9341d1d commit 6d2a13d

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TensorAlgebra"
22
uuid = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.3.9"
4+
version = "0.3.10"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/matricize.jl

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,30 +74,19 @@ function matricize(a::AbstractArray, permblock1::Tuple, permblock2::Tuple)
7474
end
7575

7676
# ==================================== unmatricize =======================================
77-
function unmatricize(
78-
m::AbstractMatrix,
79-
axes::Tuple{Vararg{AbstractUnitRange}},
80-
biperm::AbstractBlockPermutation{2},
81-
)
77+
function unmatricize(m::AbstractMatrix, axes, biperm::AbstractBlockPermutation{2})
8278
length(axes) == length(biperm) || throw(ArgumentError("axes do not match permutation"))
8379
return unmatricize(FusionStyle(m), m, axes, biperm)
8480
end
8581

8682
function unmatricize(
87-
::FusionStyle,
88-
m::AbstractMatrix,
89-
axes::Tuple{Vararg{AbstractUnitRange}},
90-
biperm::AbstractBlockPermutation{2},
83+
::FusionStyle, m::AbstractMatrix, axes, biperm::AbstractBlockPermutation{2}
9184
)
9285
blocked_axes = axes[biperm]
9386
a_perm = unmatricize(m, blocked_axes)
9487
return permuteblockeddims(a_perm, invperm(biperm))
9588
end
9689

97-
function unmatricize(::ReshapeFusion, m::AbstractMatrix, axes::AbstractUnitRange...)
98-
return reshape(m, axes...)
99-
end
100-
10190
function unmatricize(
10291
::ReshapeFusion,
10392
m::AbstractMatrix,
@@ -106,9 +95,7 @@ function unmatricize(
10695
return reshape(m, Tuple(blocked_axes)...)
10796
end
10897

109-
function unmatricize(
110-
m::AbstractMatrix, blocked_axes::BlockedTuple{2,<:Any,<:Tuple{Vararg{AbstractUnitRange}}}
111-
)
98+
function unmatricize(m::AbstractMatrix, blocked_axes)
11299
return unmatricize(FusionStyle(m), m, blocked_axes)
113100
end
114101

@@ -121,9 +108,7 @@ function unmatricize(
121108
return unmatricize(m, blocked_axes)
122109
end
123110

124-
function unmatricize!(
125-
a::AbstractArray, m::AbstractMatrix, biperm::AbstractBlockPermutation{2}
126-
)
111+
function unmatricize!(a, m::AbstractMatrix, biperm::AbstractBlockPermutation{2})
127112
ndims(a) == length(biperm) ||
128113
throw(ArgumentError("destination does not match permutation"))
129114
blocked_axes = axes(a)[biperm]

0 commit comments

Comments
 (0)