JuliaArrays / BlockDiagonals.jl

Functionality for working efficiently with block diagonal matrices.
MIT License
49 stars 11 forks source link

Support `cholesky` `check` argument. #133

Open btmit opened 5 months ago

btmit commented 5 months ago

Currently passing this argument is causing dispatch back to the original LinearAlgebra methods.

Here's a first cut at replacing the existing method:

function LinearAlgebra.cholesky(B::BlockDiagonal{T,M}; check=true)::Cholesky where {T,M}
    N = nblocks(B)
    blks = Vector{M}(undef, N)
    valid = true
    for (i, b) in enumerate(blocks(B))
        c = cholesky(b; check)
        valid = valid && issuccess(c)
        blks[i] = parent(UpperTriangular(c.U))
    end
    return Cholesky(BlockDiagonal(blks), 'U', valid ? 0 : -1)
end