Skip to content

Commit 116da7d

Browse files
authored
Merge branch 'master' into index-traits
2 parents 9ac437d + 796eb67 commit 116da7d

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterface"
22
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3-
version = "7.5.0"
3+
version = "7.4.8"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/ArrayInterface.jl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -468,45 +468,53 @@ Returns the number.
468468
"""
469469
bunchkaufman_instance(a::Any) = bunchkaufman(a, check = false)
470470

471+
@static if VERSION < v"1.7beta"
472+
const DEFAULT_CHOLESKY_PIVOT = Val(false)
473+
else
474+
const DEFAULT_CHOLESKY_PIVOT = LinearAlgebra.NoPivot()
475+
end
476+
471477
"""
472478
cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
473479
474480
Returns an instance of the Cholesky factorization object with the correct type
475481
cheaply.
476482
"""
477-
function cholesky_instance(A::Matrix{T}, pivot = LinearAlgebra.RowMaximum()) where {T}
483+
function cholesky_instance(A::Matrix{T}, pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
478484
return cholesky(similar(A, 0, 0), pivot, check = false)
479485
end
480-
function cholesky_instance(A::SparseMatrixCSC, pivot = LinearAlgebra.RowMaximum())
486+
487+
function cholesky_instance(A::Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}}, pivot = DEFAULT_CHOLESKY_PIVOT)
481488
cholesky(sparse(similar(A, 1, 1)), check = false)
482489
end
490+
483491

484492
"""
485493
cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) -> a
486494
487495
Returns the number.
488496
"""
489-
cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) = a
497+
cholesky_instance(a::Number, pivot = DEFAULT_CHOLESKY_PIVOT) = a
490498

491499
"""
492500
cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
493501
494502
Slow fallback which gets the instance via factorization. Should get
495503
specialized for new matrix types.
496504
"""
497-
cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) = cholesky(a, pivot, check = false)
505+
cholesky_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky(a, pivot, check = false)
498506

499507
"""
500508
ldlt_instance(A) -> ldlt_factorization_instance
501509
502510
Returns an instance of the LDLT factorization object with the correct type
503511
cheaply.
504512
"""
505-
function ldlt_instance(A::Matrix{T}) where {T}
506-
return ldlt(SymTridiagonal(similar(A, 0, 0)), check = false)
513+
function ldlt_instance(A::Matrix{T}) where {T}
514+
return ldlt(SymTridiagonal(similar(A, 0, 0)))
507515
end
508516
function ldlt_instance(A::SparseMatrixCSC)
509-
ldlt(sparse(similar(A, 1, 1)), check = false)
517+
ldlt(sparse(similar(A, 1, 1)), check=false)
510518
end
511519

512520
"""
@@ -574,7 +582,7 @@ Returns an instance of the QR factorization object with the correct type
574582
cheaply.
575583
"""
576584
function qr_instance(A::Matrix{T}) where {T}
577-
LinearAlgebra.QRCompactWYQ(zeros(T,0,0),zeros(T,0,0))
585+
LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0))
578586
end
579587

580588
function qr_instance(A::Matrix{BigFloat})

test/core.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,21 @@ end
266266
@test ArrayInterface.qr_instance(A) isa typeof(qr(A))
267267

268268
if !(eltype(A) <: BigFloat)
269-
@test ArrayInterface.bunchkaufman_instance(A) isa typeof(bunchkaufman(A' * A))
270-
@test ArrayInterface.cholesky_instance(A) isa typeof(cholesky(A' * A))
271-
@test ArrayInterface.ldlt_instance(A) isa typeof(ldlt(SymTridiagonal(A' * A)))
269+
@test ArrayInterface.bunchkaufman_instance(A' * A) isa typeof(bunchkaufman(A' * A))
270+
@test ArrayInterface.cholesky_instance(A' * A) isa typeof(cholesky(A' * A))
271+
@test ArrayInterface.ldlt_instance(SymTridiagonal(A' * A)) isa typeof(ldlt(SymTridiagonal(A' * A)))
272272
@test ArrayInterface.svd_instance(A) isa typeof(svd(A))
273273
end
274274
end
275+
276+
for A in [sparse([1.0 2.0; 3.0 4.0])]
277+
@test ArrayInterface.lu_instance(A) isa typeof(lu(A))
278+
@test ArrayInterface.qr_instance(A) isa typeof(qr(A))
279+
if VERSION >= v"1.9-"
280+
@test ArrayInterface.cholesky_instance(A' * A) isa typeof(cholesky(A' * A))
281+
end
282+
@test ArrayInterface.ldlt_instance(SymTridiagonal(A' * A)) isa typeof(ldlt(SymTridiagonal(A' * A)))
283+
end
275284
end
276285

277286
@testset "known values" begin
@@ -322,4 +331,3 @@ end
322331
@test @inferred(ArrayInterface.known_length(CartesianIndex(1, 2, 3))) === 3
323332
@test @inferred(ArrayInterface.known_length((x = 1, y = 2))) === 2
324333
end
325-

0 commit comments

Comments
 (0)