Skip to content

Commit 82d14ca

Browse files
authored
Consistent ::AbstractMatrix annotations (#198)
* correct `SubArray` dispatch signatures * defaultalgorithm with AbstractMatrix * default LQ/QR algorithms for Vector * consistent AbstractMatrix annotations
1 parent efe23be commit 82d14ca

File tree

14 files changed

+66
-66
lines changed

14 files changed

+66
-66
lines changed

src/implementations/eig.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ end
7979
# DefaultAlgorithm intercepts
8080
# ---------------------------
8181
for f! in (:eig_full!, :eig_vals!, :eig_trunc!, :eig_trunc_no_error!)
82-
@eval function $f!(A, alg::DefaultAlgorithm)
82+
@eval function $f!(A::AbstractMatrix, alg::DefaultAlgorithm)
8383
return $f!(A, select_algorithm($f!, A, nothing; alg.kwargs...))
8484
end
85-
@eval function $f!(A, out, alg::DefaultAlgorithm)
85+
@eval function $f!(A::AbstractMatrix, out, alg::DefaultAlgorithm)
8686
return $f!(A, out, select_algorithm($f!, A, nothing; alg.kwargs...))
8787
end
8888
end
@@ -190,20 +190,20 @@ end
190190
for lapack_algtype in (:LAPACK_Simple, :LAPACK_Expert)
191191
@eval begin
192192
Base.@deprecate(
193-
eig_full!(A, DV, alg::$lapack_algtype),
193+
eig_full!(A::AbstractMatrix, DV, alg::$lapack_algtype),
194194
eig_full!(A, DV, QRIteration(; alg.kwargs...))
195195
)
196196
Base.@deprecate(
197-
eig_vals!(A, D, alg::$lapack_algtype),
197+
eig_vals!(A::AbstractMatrix, D, alg::$lapack_algtype),
198198
eig_vals!(A, D, QRIteration(; alg.kwargs...))
199199
)
200200
end
201201
end
202202
Base.@deprecate(
203-
eig_full!(A, DV, alg::CUSOLVER_Simple),
203+
eig_full!(A::AbstractMatrix, DV, alg::CUSOLVER_Simple),
204204
eig_full!(A, DV, QRIteration(; driver = CUSOLVER(), alg.kwargs...))
205205
)
206206
Base.@deprecate(
207-
eig_vals!(A, D, alg::CUSOLVER_Simple),
207+
eig_vals!(A::AbstractMatrix, D, alg::CUSOLVER_Simple),
208208
eig_vals!(A, D, QRIteration(; driver = CUSOLVER(), alg.kwargs...))
209209
)

src/implementations/eigh.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ end
8787
# DefaultAlgorithm intercepts
8888
# ---------------------------
8989
for f! in (:eigh_full!, :eigh_vals!, :eigh_trunc!, :eigh_trunc_no_error!)
90-
@eval function $f!(A, alg::DefaultAlgorithm)
90+
@eval function $f!(A::AbstractMatrix, alg::DefaultAlgorithm)
9191
return $f!(A, select_algorithm($f!, A, nothing; alg.kwargs...))
9292
end
93-
@eval function $f!(A, out, alg::DefaultAlgorithm)
93+
@eval function $f!(A::AbstractMatrix, out, alg::DefaultAlgorithm)
9494
return $f!(A, out, select_algorithm($f!, A, nothing; alg.kwargs...))
9595
end
9696
end
@@ -208,22 +208,22 @@ end
208208
# Deprecations
209209
# ------------
210210
Base.@deprecate(
211-
eigh_full!(A, DV, alg::LAPACK_MultipleRelativelyRobustRepresentations),
211+
eigh_full!(A::AbstractMatrix, DV, alg::LAPACK_MultipleRelativelyRobustRepresentations),
212212
eigh_full!(A, DV, RobustRepresentations(; driver = LAPACK(), alg.kwargs...))
213213
)
214214
Base.@deprecate(
215-
eigh_vals!(A, D, alg::LAPACK_MultipleRelativelyRobustRepresentations),
215+
eigh_vals!(A::AbstractMatrix, D, alg::LAPACK_MultipleRelativelyRobustRepresentations),
216216
eigh_vals!(A, D, RobustRepresentations(; driver = LAPACK(), alg.kwargs...))
217217
)
218218
for algtype in (:DivideAndConquer, :QRIteration, :Bisection)
219219
lapack_algtype = Symbol(:LAPACK_, algtype)
220220
@eval begin
221221
Base.@deprecate(
222-
eigh_full!(A, DV, alg::$lapack_algtype),
222+
eigh_full!(A::AbstractMatrix, DV, alg::$lapack_algtype),
223223
eigh_full!(A, DV, $algtype(; driver = LAPACK(), alg.kwargs...))
224224
)
225225
Base.@deprecate(
226-
eigh_vals!(A, D, alg::$lapack_algtype),
226+
eigh_vals!(A::AbstractMatrix, D, alg::$lapack_algtype),
227227
eigh_vals!(A, D, $algtype(; driver = LAPACK(), alg.kwargs...))
228228
)
229229
end
@@ -238,20 +238,20 @@ for (algtype, newtype, drivertype) in (
238238
)
239239
@eval begin
240240
Base.@deprecate(
241-
eigh_full!(A, DV, alg::$algtype),
241+
eigh_full!(A::AbstractMatrix, DV, alg::$algtype),
242242
eigh_full!(A, DV, $newtype(; driver = $drivertype(), alg.kwargs...))
243243
)
244244
Base.@deprecate(
245-
eigh_vals!(A, D, alg::$algtype),
245+
eigh_vals!(A::AbstractMatrix, D, alg::$algtype),
246246
eigh_vals!(A, D, $newtype(; driver = $drivertype(), alg.kwargs...))
247247
)
248248
end
249249
end
250250
Base.@deprecate(
251-
eigh_full!(A, DV, alg::GLA_QRIteration),
251+
eigh_full!(A::AbstractMatrix, DV, alg::GLA_QRIteration),
252252
eigh_full!(A, DV, QRIteration(; driver = GLA(), alg.kwargs...))
253253
)
254254
Base.@deprecate(
255-
eigh_vals!(A, D, alg::GLA_QRIteration),
255+
eigh_vals!(A::AbstractMatrix, D, alg::GLA_QRIteration),
256256
eigh_vals!(A, D, QRIteration(; driver = GLA(), alg.kwargs...))
257257
)

src/implementations/gen_eig.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ end
4949
# DefaultAlgorithm intercepts
5050
# ---------------------------
5151
for f! in (:gen_eig_full!, :gen_eig_vals!)
52-
@eval function $f!(A, B, alg::DefaultAlgorithm)
52+
@eval function $f!(A::AbstractMatrix, B::AbstractMatrix, alg::DefaultAlgorithm)
5353
return $f!(A, B, select_algorithm($f!, (A, B), nothing; alg.kwargs...))
5454
end
55-
@eval function $f!(A, B, out, alg::DefaultAlgorithm)
55+
@eval function $f!(A::AbstractMatrix, B::AbstractMatrix, out, alg::DefaultAlgorithm)
5656
return $f!(A, B, out, select_algorithm($f!, (A, B), nothing; alg.kwargs...))
5757
end
5858
end

src/implementations/lq.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ end
8989
# DefaultAlgorithm intercepts
9090
# ---------------------------
9191
for f! in (:lq_full!, :lq_compact!, :lq_null!)
92-
@eval function $f!(A, alg::DefaultAlgorithm)
92+
@eval function $f!(A::AbstractMatrix, alg::DefaultAlgorithm)
9393
return $f!(A, select_algorithm($f!, A, nothing; alg.kwargs...))
9494
end
95-
@eval function $f!(A, out, alg::DefaultAlgorithm)
95+
@eval function $f!(A::AbstractMatrix, out, alg::DefaultAlgorithm)
9696
return $f!(A, out, select_algorithm($f!, A, nothing; alg.kwargs...))
9797
end
9898
end
@@ -103,15 +103,15 @@ end
103103

104104
# Householder
105105
# -----------
106-
function lq_full!(A, LQ, alg::Householder)
106+
function lq_full!(A::AbstractMatrix, LQ, alg::Householder)
107107
check_input(lq_full!, A, LQ, alg)
108108
return lq_householder!(A, LQ...; alg.kwargs...)
109109
end
110-
function lq_compact!(A, LQ, alg::Householder)
110+
function lq_compact!(A::AbstractMatrix, LQ, alg::Householder)
111111
check_input(lq_compact!, A, LQ, alg)
112112
return lq_householder!(A, LQ...; alg.kwargs...)
113113
end
114-
function lq_null!(A, Nᴴ, alg::Householder)
114+
function lq_null!(A::AbstractMatrix, Nᴴ, alg::Householder)
115115
check_input(lq_null!, A, Nᴴ, alg)
116116
return lq_null_householder!(A, Nᴴ; alg.kwargs...)
117117
end
@@ -382,15 +382,15 @@ for drivertype in (:LAPACK, :Native)
382382
algtype = Symbol(drivertype, :_HouseholderLQ)
383383
@eval begin
384384
Base.@deprecate(
385-
lq_full!(A, LQ, alg::$algtype),
385+
lq_full!(A::AbstractMatrix, LQ, alg::$algtype),
386386
lq_full!(A, LQ, Householder(; driver = $drivertype(), alg.kwargs...))
387387
)
388388
Base.@deprecate(
389-
lq_compact!(A, LQ, alg::$algtype),
389+
lq_compact!(A::AbstractMatrix, LQ, alg::$algtype),
390390
lq_compact!(A, LQ, Householder(; driver = $drivertype(), alg.kwargs...))
391391
)
392392
Base.@deprecate(
393-
lq_null!(A, Nᴴ, alg::$algtype),
393+
lq_null!(A::AbstractMatrix, Nᴴ, alg::$algtype),
394394
lq_null!(A, Nᴴ, Householder(; driver = $drivertype(), alg.kwargs...))
395395
)
396396
end

src/implementations/orthnull.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ initialize_output(::typeof(right_null!), A, alg::RightNullViaSVD) = nothing
6666
# DefaultAlgorithm intercepts
6767
# ---------------------------
6868
for f! in (:left_orth!, :right_orth!, :left_null!, :right_null!)
69-
@eval function $f!(A, alg::DefaultAlgorithm)
69+
@eval function $f!(A::AbstractMatrix, alg::DefaultAlgorithm)
7070
return $f!(A, select_algorithm($f!, A, nothing; alg.kwargs...))
7171
end
72-
@eval function $f!(A, out, alg::DefaultAlgorithm)
72+
@eval function $f!(A::AbstractMatrix, out, alg::DefaultAlgorithm)
7373
return $f!(A, out, select_algorithm($f!, A, nothing; alg.kwargs...))
7474
end
7575
end

src/implementations/polar.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ end
4646
# DefaultAlgorithm intercepts
4747
# ---------------------------
4848
for f! in (:left_polar!, :right_polar!)
49-
@eval function $f!(A, alg::DefaultAlgorithm)
49+
@eval function $f!(A::AbstractMatrix, alg::DefaultAlgorithm)
5050
return $f!(A, select_algorithm($f!, A, nothing; alg.kwargs...))
5151
end
52-
@eval function $f!(A, out, alg::DefaultAlgorithm)
52+
@eval function $f!(A::AbstractMatrix, out, alg::DefaultAlgorithm)
5353
return $f!(A, out, select_algorithm($f!, A, nothing; alg.kwargs...))
5454
end
5555
end

src/implementations/qr.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ end
8989
# DefaultAlgorithm intercepts
9090
# ---------------------------
9191
for f! in (:qr_full!, :qr_compact!, :qr_null!)
92-
@eval function $f!(A, alg::DefaultAlgorithm)
92+
@eval function $f!(A::AbstractMatrix, alg::DefaultAlgorithm)
9393
return $f!(A, select_algorithm($f!, A, nothing; alg.kwargs...))
9494
end
95-
@eval function $f!(A, out, alg::DefaultAlgorithm)
95+
@eval function $f!(A::AbstractMatrix, out, alg::DefaultAlgorithm)
9696
return $f!(A, out, select_algorithm($f!, A, nothing; alg.kwargs...))
9797
end
9898
end
@@ -103,15 +103,15 @@ end
103103

104104
# Householder
105105
# -----------
106-
function qr_full!(A, QR, alg::Householder)
106+
function qr_full!(A::AbstractMatrix, QR, alg::Householder)
107107
check_input(qr_full!, A, QR, alg)
108108
return qr_householder!(A, QR...; alg.kwargs...)
109109
end
110-
function qr_compact!(A, QR, alg::Householder)
110+
function qr_compact!(A::AbstractMatrix, QR, alg::Householder)
111111
check_input(qr_compact!, A, QR, alg)
112112
return qr_householder!(A, QR...; alg.kwargs...)
113113
end
114-
function qr_null!(A, N, alg::Householder)
114+
function qr_null!(A::AbstractMatrix, N, alg::Householder)
115115
check_input(qr_null!, A, N, alg)
116116
return qr_null_householder!(A, N; alg.kwargs...)
117117
end
@@ -324,19 +324,19 @@ end
324324

325325
# Diagonal
326326
# --------
327-
function qr_full!(A, QR, alg::DiagonalAlgorithm)
327+
function qr_full!(A::AbstractMatrix, QR, alg::DiagonalAlgorithm)
328328
check_input(qr_full!, A, QR, alg)
329329
Q, R = QR
330330
_diagonal_qr!(A, Q, R; alg.kwargs...)
331331
return Q, R
332332
end
333-
function qr_compact!(A, QR, alg::DiagonalAlgorithm)
333+
function qr_compact!(A::AbstractMatrix, QR, alg::DiagonalAlgorithm)
334334
check_input(qr_compact!, A, QR, alg)
335335
Q, R = QR
336336
_diagonal_qr!(A, Q, R; alg.kwargs...)
337337
return Q, R
338338
end
339-
function qr_null!(A, N, alg::DiagonalAlgorithm)
339+
function qr_null!(A::AbstractMatrix, N, alg::DiagonalAlgorithm)
340340
check_input(qr_null!, A, N, alg)
341341
_diagonal_qr_null!(A, N; alg.kwargs...)
342342
return N
@@ -367,15 +367,15 @@ for drivertype in (:LAPACK, :CUSOLVER, :ROCSOLVER, :Native, :GLA)
367367
algtype = Symbol(drivertype, :_HouseholderQR)
368368
@eval begin
369369
Base.@deprecate(
370-
qr_full!(A, QR, alg::$algtype),
370+
qr_full!(A::AbstractMatrix, QR, alg::$algtype),
371371
qr_full!(A, QR, Householder(; driver = $drivertype(), alg.kwargs...))
372372
)
373373
Base.@deprecate(
374-
qr_compact!(A, QR, alg::$algtype),
374+
qr_compact!(A::AbstractMatrix, QR, alg::$algtype),
375375
qr_compact!(A, QR, Householder(; driver = $drivertype(), alg.kwargs...))
376376
)
377377
Base.@deprecate(
378-
qr_null!(A, N, alg::$algtype),
378+
qr_null!(A::AbstractMatrix, N, alg::$algtype),
379379
qr_null!(A, N, Householder(; driver = $drivertype(), alg.kwargs...))
380380
)
381381
end

src/implementations/schur.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ end
4141
# DefaultAlgorithm intercepts
4242
# ---------------------------
4343
for f! in (:schur_full!, :schur_vals!)
44-
@eval function $f!(A, alg::DefaultAlgorithm)
44+
@eval function $f!(A::AbstractMatrix, alg::DefaultAlgorithm)
4545
return $f!(A, select_algorithm($f!, A, nothing; alg.kwargs...))
4646
end
47-
@eval function $f!(A, out, alg::DefaultAlgorithm)
47+
@eval function $f!(A::AbstractMatrix, out, alg::DefaultAlgorithm)
4848
return $f!(A, out, select_algorithm($f!, A, nothing; alg.kwargs...))
4949
end
5050
end
@@ -105,11 +105,11 @@ end
105105
for (lapack_algtype, expert_val) in ((:LAPACK_Simple, false), (:LAPACK_Expert, true))
106106
@eval begin
107107
Base.@deprecate(
108-
schur_full!(A, TZv, alg::$lapack_algtype),
108+
schur_full!(A::AbstractMatrix, TZv, alg::$lapack_algtype),
109109
schur_full!(A, TZv, QRIteration(; expert = $expert_val, alg.kwargs...))
110110
)
111111
Base.@deprecate(
112-
schur_vals!(A, vals, alg::$lapack_algtype),
112+
schur_vals!(A::AbstractMatrix, vals, alg::$lapack_algtype),
113113
schur_vals!(A, vals, QRIteration(; expert = $expert_val, alg.kwargs...))
114114
)
115115
end

src/implementations/svd.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ end
108108
# DefaultAlgorithm intercepts
109109
# ---------------------------
110110
for f! in (:svd_full!, :svd_compact!, :svd_vals!, :svd_trunc!, :svd_trunc_no_error!)
111-
@eval function $f!(A, alg::DefaultAlgorithm)
111+
@eval function $f!(A::AbstractMatrix, alg::DefaultAlgorithm)
112112
return $f!(A, select_algorithm($f!, A, nothing; alg.kwargs...))
113113
end
114-
@eval function $f!(A, out, alg::DefaultAlgorithm)
114+
@eval function $f!(A::AbstractMatrix, out, alg::DefaultAlgorithm)
115115
return $f!(A, out, select_algorithm($f!, A, nothing; alg.kwargs...))
116116
end
117117
end
@@ -166,15 +166,15 @@ for (f, f_lapack!, Alg) in (
166166

167167
# MatrixAlgebraKit wrappers
168168
@eval begin
169-
function svd_compact!(A, USVᴴ, alg::$Alg)
169+
function svd_compact!(A::AbstractMatrix, USVᴴ, alg::$Alg)
170170
check_input(svd_compact!, A, USVᴴ, alg)
171171
return $svd_compact_f!(A, USVᴴ...; alg.kwargs...)
172172
end
173-
function svd_full!(A, USVᴴ, alg::$Alg)
173+
function svd_full!(A::AbstractMatrix, USVᴴ, alg::$Alg)
174174
check_input(svd_full!, A, USVᴴ, alg)
175175
return $svd_full_f!(A, USVᴴ...; alg.kwargs...)
176176
end
177-
function svd_vals!(A, S, alg::$Alg)
177+
function svd_vals!(A::AbstractMatrix, S, alg::$Alg)
178178
check_input(svd_vals!, A, S, alg)
179179
return $svd_vals_f!(A, S; alg.kwargs...)
180180
end
@@ -353,15 +353,15 @@ for algtype in (:SafeDivideAndConquer, :DivideAndConquer, :QRIteration, :Jacobi,
353353
lapack_algtype = Symbol(:LAPACK_, algtype)
354354
@eval begin
355355
Base.@deprecate(
356-
svd_compact!(A, USVᴴ, alg::$lapack_algtype),
356+
svd_compact!(A::AbstractMatrix, USVᴴ, alg::$lapack_algtype),
357357
svd_compact!(A, USVᴴ, $algtype(; driver = LAPACK(), alg.kwargs...))
358358
)
359359
Base.@deprecate(
360-
svd_full!(A, USVᴴ, alg::$lapack_algtype),
360+
svd_full!(A::AbstractMatrix, USVᴴ, alg::$lapack_algtype),
361361
svd_full!(A, USVᴴ, $algtype(; driver = LAPACK(), alg.kwargs...))
362362
)
363363
Base.@deprecate(
364-
svd_vals!(A, S, alg::$lapack_algtype),
364+
svd_vals!(A::AbstractMatrix, S, alg::$lapack_algtype),
365365
svd_vals!(A, S, $algtype(; driver = LAPACK(), alg.kwargs...))
366366
)
367367
end
@@ -376,30 +376,30 @@ for (algtype, newtype, drivertype) in (
376376
)
377377
@eval begin
378378
Base.@deprecate(
379-
svd_compact!(A, USVᴴ, alg::$algtype),
379+
svd_compact!(A::AbstractMatrix, USVᴴ, alg::$algtype),
380380
svd_compact!(A, USVᴴ, $newtype(; driver = $drivertype(), alg.kwargs...))
381381
)
382382
Base.@deprecate(
383-
svd_full!(A, USVᴴ, alg::$algtype),
383+
svd_full!(A::AbstractMatrix, USVᴴ, alg::$algtype),
384384
svd_full!(A, USVᴴ, $newtype(; driver = $drivertype(), alg.kwargs...))
385385
)
386386
Base.@deprecate(
387-
svd_vals!(A, S, alg::$algtype),
387+
svd_vals!(A::AbstractMatrix, S, alg::$algtype),
388388
svd_vals!(A, S, $newtype(; driver = $drivertype(), alg.kwargs...))
389389
)
390390
end
391391
end
392392

393393
# GLA_QRIteration SVD deprecations (eigh methods remain in the GLA extension)
394394
Base.@deprecate(
395-
svd_compact!(A, USVᴴ, alg::GLA_QRIteration),
395+
svd_compact!(A::AbstractMatrix, USVᴴ, alg::GLA_QRIteration),
396396
svd_compact!(A, USVᴴ, QRIteration(; driver = GLA(), alg.kwargs...))
397397
)
398398
Base.@deprecate(
399-
svd_full!(A, USVᴴ, alg::GLA_QRIteration),
399+
svd_full!(A::AbstractMatrix, USVᴴ, alg::GLA_QRIteration),
400400
svd_full!(A, USVᴴ, QRIteration(; driver = GLA(), alg.kwargs...))
401401
)
402402
Base.@deprecate(
403-
svd_vals!(A, S, alg::GLA_QRIteration),
403+
svd_vals!(A::AbstractMatrix, S, alg::GLA_QRIteration),
404404
svd_vals!(A, S, QRIteration(; driver = GLA(), alg.kwargs...))
405405
)

src/interface/eig.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ end
170170
function default_eig_algorithm(::Type{<:Base.ReshapedArray{T, N, A}}) where {T, N, A}
171171
return default_eig_algorithm(A)
172172
end
173-
function default_eig_algorithm(::Type{SubArray{T, N, A}}) where {T, N, A}
173+
function default_eig_algorithm(::Type{<:SubArray{T, N, A}}) where {T, N, A}
174174
return default_eig_algorithm(A)
175175
end
176176

0 commit comments

Comments
 (0)