Skip to content

Commit 04992ea

Browse files
committed
Delete uses of FillArrays
1 parent d4f74a8 commit 04992ea

File tree

3 files changed

+18
-86
lines changed

3 files changed

+18
-86
lines changed

src/KroneckerArrays.jl

Lines changed: 18 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ end
158158

159159
arguments(a::KroneckerArray) = (a.a, a.b)
160160
arguments(a::KroneckerArray, n::Int) = arguments(a)[n]
161+
argument_types(a::KroneckerArray) = argument_types(typeof(a))
162+
argument_types(::Type{<:KroneckerArray{<:Any,<:Any,A,B}}) where {A,B} = (A, B)
161163

162164
function Base.print_array(io::IO, a::KroneckerArray)
163165
Base.print_array(io, a.a)
@@ -609,12 +611,26 @@ end
609611
for f in (:eig, :eigh, :lq, :qr, :polar, :svd)
610612
ff = Symbol("default_", f, "_algorithm")
611613
@eval begin
612-
function MatrixAlgebraKit.$ff(a::KroneckerMatrix; kwargs...)
613-
return KroneckerAlgorithm($ff(a.a; kwargs...), $ff(a.b; kwargs...))
614+
function MatrixAlgebraKit.$ff(A::Type{<:KroneckerMatrix}; kwargs...)
615+
A1, A2 = argument_types(A)
616+
return KroneckerAlgorithm($ff(A1; kwargs...), $ff(A2; kwargs...))
614617
end
615618
end
616619
end
617620

621+
# TODO: Delete this once https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/32 is merged.
622+
function MatrixAlgebraKit.default_algorithm(
623+
::typeof(qr_compact!), A::Type{<:KroneckerMatrix}; kwargs...
624+
)
625+
return default_qr_algorithm(A; kwargs...)
626+
end
627+
# TODO: Delete this once https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/32 is merged.
628+
function MatrixAlgebraKit.default_algorithm(
629+
::typeof(qr_full!), A::Type{<:KroneckerMatrix}; kwargs...
630+
)
631+
return default_qr_algorithm(A; kwargs...)
632+
end
633+
618634
for f in (
619635
:eig_full!,
620636
:eigh_full!,
@@ -689,75 +705,4 @@ for f in (:left_null!, :right_null!)
689705
end
690706
end
691707

692-
# Special case for `FillArrays.Eye` matrices.
693-
struct EyeAlgorithm <: AbstractAlgorithm end
694-
695-
for f in [
696-
:eig_full,
697-
:eigh_full,
698-
:qr_compact,
699-
:qr_full,
700-
:left_polar,
701-
:lq_compact,
702-
:lq_full,
703-
:right_polar,
704-
:svd_compact,
705-
:svd_full,
706-
]
707-
@eval begin
708-
MatrixAlgebraKit.copy_input(::typeof($f), a::Eye) = a
709-
end
710-
end
711-
712-
for f in (:eig, :eigh, :lq, :qr, :polar, :svd)
713-
ff = Symbol("default_", f, "_algorithm")
714-
@eval begin
715-
function MatrixAlgebraKit.$ff(a::Eye; kwargs...)
716-
return EyeAlgorithm()
717-
end
718-
end
719-
end
720-
721-
for f in (
722-
:eig_full!,
723-
:eigh_full!,
724-
:qr_compact!,
725-
:qr_full!,
726-
:left_polar!,
727-
:lq_compact!,
728-
:lq_full!,
729-
:right_polar!,
730-
)
731-
@eval begin
732-
nfactors(::typeof($f)) = 2
733-
end
734-
end
735-
for f in (:svd_compact!, :svd_full!)
736-
@eval begin
737-
nfactors(::typeof($f)) = 3
738-
end
739-
end
740-
741-
for f in (
742-
:eig_full!,
743-
:eigh_full!,
744-
:qr_compact!,
745-
:qr_full!,
746-
:left_polar!,
747-
:lq_compact!,
748-
:lq_full!,
749-
:right_polar!,
750-
:svd_compact!,
751-
:svd_full!,
752-
)
753-
@eval begin
754-
function MatrixAlgebraKit.initialize_output(::typeof($f), a::Eye, alg::EyeAlgorithm)
755-
return ntuple(_ -> a, nfactors($f))
756-
end
757-
function MatrixAlgebraKit.$f(a::Eye, F, alg::EyeAlgorithm; kwargs...)
758-
return ntuple(_ -> a, nfactors($f))
759-
end
760-
end
761-
end
762-
763708
end

test/Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[deps]
22
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3-
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
43
KroneckerArrays = "05d0b138-81bc-4ff7-84be-08becefb1ccc"
54
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
65
MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
@@ -10,7 +9,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
109

1110
[compat]
1211
Aqua = "0.8"
13-
FillArrays = "1"
1412
KroneckerArrays = "0.1"
1513
LinearAlgebra = "1.10"
1614
MatrixAlgebraKit = "0.2"

test/test_matrixalgebrakit.jl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using FillArrays: Eye
21
using KroneckerArrays:
32
using LinearAlgebra: Hermitian, I, diag, hermitianpart, norm
43
using MatrixAlgebraKit:
@@ -33,11 +32,6 @@ herm(a) = hermitianpart(a).data
3332
d, v = eig_full(a)
3433
@test a * v v * d
3534

36-
a = randn(elt, 2, 2) Eye(3)
37-
d, v = eig_full(a)
38-
@test d.b == v.b == Eye(3)
39-
@test a * v v * d
40-
4135
a = randn(elt, 2, 2) randn(elt, 3, 3)
4236
@test_throws MethodError eig_trunc(a)
4337

@@ -110,11 +104,6 @@ herm(a) = hermitianpart(a).data
110104
@test collect(u'u) I
111105
@test collect(v * v') I
112106

113-
a = randn(elt, 2, 2) Eye(3)
114-
u, s, v = svd_compact(a)
115-
@test u * s * v a
116-
@test u.b == s.b == v.b == Eye(3)
117-
118107
a = randn(elt, 2, 2) randn(elt, 3, 3)
119108
u, s, v = svd_full(a)
120109
@test u * s * v a

0 commit comments

Comments
 (0)