Skip to content

Commit 03f2255

Browse files
github-actions[bot]CompatHelper Juliamtfishman
authored
CompatHelper: bump compat for MatrixAlgebraKit to 0.6, (keep existing compat) (#57)
Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: mtfishman <[email protected]>
1 parent adbd300 commit 03f2255

File tree

5 files changed

+120
-22
lines changed

5 files changed

+120
-22
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "KroneckerArrays"
22
uuid = "05d0b138-81bc-4ff7-84be-08becefb1ccc"
3+
version = "0.3.1"
34
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.3.0"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -35,7 +35,7 @@ FillArrays = "1.13"
3535
GPUArraysCore = "0.2"
3636
LinearAlgebra = "1.10"
3737
MapBroadcast = "0.1.10"
38-
MatrixAlgebraKit = "0.2, 0.3, 0.4, 0.5"
38+
MatrixAlgebraKit = "0.6"
3939
TensorAlgebra = "0.3.10, 0.4"
4040
TensorProducts = "0.1.7"
4141
TypeParameterAccessors = "0.4.2"

src/KroneckerArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ kroneckerfactortypes(T::Type) = throw(MethodError(kroneckerfactortypes, (T,)))
4242
4343
Construct an object that represents the Kronecker product of the provided `args`.
4444
""" ()
45-
function (a, b) end
45+
function end
4646
const otimes = # non-unicode alternative
4747

4848
# Includes

src/kroneckerarray.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,29 @@ function Base.reshape(
415415
return reshape(a, kroneckerfactors.(ax, 1)) reshape(b, kroneckerfactors.(ax, 2))
416416
end
417417

418+
function Base.fill!(ab::AbstractKroneckerArray, v)
419+
a, b = kroneckerfactors(ab)
420+
fill!(a, v)
421+
fill!(b, v)
422+
return ab
423+
end
424+
function Base.fill!(ab::AbstractKroneckerMatrix, v)
425+
a, b = kroneckerfactors(ab)
426+
(!isactive(a) && isone(a)) && (fill!(b, v); return ab)
427+
(!isactive(b) && isone(b)) && (fill!(a, v); return ab)
428+
fill!(a, v)
429+
fill!(b, v)
430+
return ab
431+
end
432+
function Base.fill!(ab::AbstractKroneckerVector, v)
433+
a, b = kroneckerfactors(ab)
434+
(!isactive(a) && all(isone, a)) && (fill!(b, v); return ab)
435+
(!isactive(b) && all(isone, b)) && (fill!(a, v); return ab)
436+
fill!(a, v)
437+
fill!(b, v)
438+
return ab
439+
end
440+
418441
using Base.Broadcast: Broadcast, AbstractArrayStyle, BroadcastStyle, Broadcasted
419442

420443
struct KroneckerStyle{N, A, B} <: BC.AbstractArrayStyle{N} end

src/matrixalgebrakit.jl

Lines changed: 93 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,34 +80,109 @@ end
8080

8181
for f in (:eig_vals, :eigh_vals, :svd_vals)
8282
f! = Symbol(f, :!)
83-
@eval MAK.initialize_output(::typeof($f!), a::AbstractMatrix, alg::KroneckerAlgorithm) = nothing
83+
@eval function MAK.initialize_output(
84+
::typeof($f!), a::AbstractMatrix, alg::KroneckerAlgorithm
85+
)
86+
return nothing
87+
end
8488
@eval function MAK.$f!(ab::AbstractKroneckerMatrix, F, alg::KroneckerAlgorithm)
8589
a, b = kroneckerfactors(ab)
8690
algA, algB = kroneckerfactors(alg)
8791
return MAK.$f(a, algA) MAK.$f(b, algB)
8892
end
8993
end
9094

91-
for f in (:left_orth, :right_orth)
92-
f! = Symbol(f, :!)
93-
@eval MAK.initialize_output(::typeof($f!), a::AbstractKroneckerMatrix) = nothing
94-
@eval function MAK.$f!(ab::AbstractKroneckerMatrix, F; kwargs1 = (;), kwargs2 = (;), kwargs...)
95-
a, b = kroneckerfactors(ab)
96-
Fa = MAK.$f(a; kwargs..., kwargs1...)
97-
Fb = MAK.$f(b; kwargs..., kwargs2...)
98-
return Fa .⊗ Fb
95+
# TODO: Delete this loop once https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/104
96+
# is merged.
97+
for kind in ("polar", "qr", "svd")
98+
@eval begin
99+
function MAK.initialize_output(
100+
::typeof(left_orth!), a::AbstractKroneckerMatrix,
101+
alg::MAK.LeftOrthAlgorithm{Symbol($kind)},
102+
)
103+
return nothing
104+
end
105+
function MAK.left_orth!(
106+
ab::AbstractKroneckerMatrix, F, alg::MAK.LeftOrthAlgorithm{Symbol($kind)};
107+
kwargs1 = (;), kwargs2 = (;), kwargs...,
108+
)
109+
a, b = kroneckerfactors(ab)
110+
Fa = MAK.left_orth!(a; kwargs..., kwargs1...)
111+
Fb = MAK.left_orth!(b; kwargs..., kwargs2...)
112+
return Fa .⊗ Fb
113+
end
99114
end
100115
end
101116

102-
for f in [:left_null, :right_null]
103-
f! = Symbol(f, :!)
104-
@eval MAK.initialize_output(::typeof($f!), a::AbstractKroneckerMatrix) =
105-
nothing
106-
@eval function MAK.$f!(ab::AbstractKroneckerMatrix, F; kwargs1 = (;), kwargs2 = (;), kwargs...)
107-
a, b = kroneckerfactors(ab)
108-
Na = MAK.$f(a; kwargs..., kwargs1...)
109-
Nb = MAK.$f(b; kwargs..., kwargs2...)
110-
return Na Nb
117+
# TODO: Delete this loop once https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/104
118+
# is merged.
119+
for kind in ("lq", "polar", "svd")
120+
@eval begin
121+
function MAK.initialize_output(
122+
::typeof(right_orth!), a::AbstractKroneckerMatrix,
123+
alg::MAK.RightOrthAlgorithm{Symbol($kind)},
124+
)
125+
return nothing
126+
end
127+
function MAK.right_orth!(
128+
ab::AbstractKroneckerMatrix, F, alg::MAK.RightOrthAlgorithm{Symbol($kind)};
129+
kwargs1 = (;), kwargs2 = (;), kwargs...,
130+
)
131+
a, b = kroneckerfactors(ab)
132+
Fa = MAK.right_orth!(a; kwargs..., kwargs1...)
133+
Fb = MAK.right_orth!(b; kwargs..., kwargs2...)
134+
return Fa .⊗ Fb
135+
end
136+
end
137+
end
138+
139+
# TODO: Delete this loop once https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/104
140+
# is merged.
141+
for Alg in (
142+
:(MAK.LeftNullViaQR),
143+
:(MAK.LeftNullViaSVD{<:MAK.TruncatedAlgorithm}),
144+
:(MAK.LeftNullViaSVD{<:MAK.TruncatedAlgorithm{<:MAK.GPU_Randomized}}),
145+
)
146+
@eval begin
147+
function MAK.initialize_output(
148+
::typeof(left_null!), a::AbstractKroneckerMatrix, alg::$Alg
149+
)
150+
return nothing
151+
end
152+
function MAK.left_null!(
153+
ab::AbstractKroneckerMatrix, F, alg::$Alg;
154+
kwargs1 = (;), kwargs2 = (;), kwargs...,
155+
)
156+
a, b = kroneckerfactors(ab)
157+
Na = MAK.left_null!(a; kwargs..., kwargs1...)
158+
Nb = MAK.left_null!(b; kwargs..., kwargs2...)
159+
return Na Nb
160+
end
161+
end
162+
end
163+
164+
# TODO: Delete this loop once https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/104
165+
# is merged.
166+
for Alg in (
167+
:(MAK.RightNullViaLQ),
168+
:(MAK.RightNullViaSVD{<:MAK.TruncatedAlgorithm}),
169+
:(MAK.RightNullViaSVD{<:MAK.TruncatedAlgorithm{<:MAK.GPU_Randomized}}),
170+
)
171+
@eval begin
172+
function MAK.initialize_output(
173+
::typeof(right_null!), a::AbstractKroneckerMatrix, alg::$Alg
174+
)
175+
return nothing
176+
end
177+
function MAK.right_null!(
178+
ab::AbstractKroneckerMatrix, F, alg::$Alg;
179+
kwargs1 = (;), kwargs2 = (;), kwargs...,
180+
)
181+
a, b = kroneckerfactors(ab)
182+
Na = MAK.right_null!(a; kwargs..., kwargs1...)
183+
Nb = MAK.right_null!(b; kwargs..., kwargs2...)
184+
return Na Nb
185+
end
111186
end
112187
end
113188

test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ GPUArraysCore = "0.2"
3131
JLArrays = "0.2, 0.3"
3232
KroneckerArrays = "0.3"
3333
LinearAlgebra = "1.10"
34-
MatrixAlgebraKit = "0.2, 0.3, 0.4, 0.5"
34+
MatrixAlgebraKit = "0.6"
3535
SafeTestsets = "0.1"
3636
StableRNGs = "1.0"
3737
Suppressor = "0.2"

0 commit comments

Comments
 (0)