Skip to content

Commit 10259da

Browse files
authored
Workaround inference of Cholesky factorisations of BandedMatrices (#67)
* Copy cholesky! definition from LinearAlgebra.jl The _cholesky! definition using `invoke` is left as a fallback. * Add cholesky inference test using BandedMatrix * Don't use BandedMatrices in tests * Bump patch version
1 parent 04c62f5 commit 10259da

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArrayLayouts"
22
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.7.7"
4+
version = "0.7.8"
55

66
[deps]
77
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"

src/factorizations.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,13 @@ _cholesky(layout, axes, A, ::Val{true}; tol = 0.0, check::Bool = true) = cholesk
290290
_cholesky!(layout, axes, A, v::Val{tf}; kwds...) where tf = Base.invoke(cholesky!, Tuple{LinearAlgebra.RealHermSymComplexHerm,Val{tf}}, A, v; kwds...)
291291
_factorize(layout, axes, A) = qr(A) # Default to QR
292292

293+
# Cholesky factorization without pivoting (copied from stdlib/LinearAlgebra).
294+
function _cholesky!(layout, axes, A::LinearAlgebra.RealHermSymComplexHerm, ::Val{false}; check::Bool = true)
295+
C, info = LinearAlgebra._chol!(A.data, A.uplo == 'U' ? UpperTriangular : LowerTriangular)
296+
check && LinearAlgebra.checkpositivedefinite(info)
297+
return Cholesky(C.data, A.uplo, info)
298+
end
299+
293300
_inv_eye(_, ::Type{T}, axs::NTuple{2,Base.OneTo{Int}}) where T = Matrix{T}(I, map(length,axs)...)
294301
function _inv_eye(A, ::Type{T}, (rows,cols)) where T
295302
dest = zero!(similar(A, T, (cols,rows)))

test/test_layoutarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ MemoryLayout(::Type{MyVector}) = DenseColumnMajor()
9999
@test inv(A) inv(A.A)
100100

101101
S = Symmetric(MyMatrix(reshape(inv.(1:25),5,5) + 10I))
102-
@test cholesky(S).U cholesky!(deepcopy(S)).U
102+
@test cholesky(S).U @inferred(cholesky!(deepcopy(S))).U
103103
@test cholesky(S,Val(true)).U cholesky(Matrix(S),Val(true)).U
104104
end
105105
Bin = randn(5,5)
@@ -349,4 +349,4 @@ triangulardata(A::MyUpperTriangular) = triangulardata(A.A)
349349
@test lmul!(U, copy(B)) U * B
350350

351351
@test_skip lmul!(U,view(copy(B),collect(1:5),1:5)) U * B
352-
end
352+
end

0 commit comments

Comments
 (0)