SparsityDetection.jl
SparsityDetection.jl copied to clipboard
Structured Matrix Detection
If the sparse matrix actually has structure, it would be nice to have a way to detect that and return the structured matrix type.
If the sparse matrix actually has structure
Which matrix? :-)
I think it's just determine_structure(A::SparseMatrixCSC)
. Completely not type-stable of course, but analyses the sparsity pattern and spits out the matrix type.
Does anyone have that function somewhere?
Not that I know of. There are pieces of it in factorize:
https://github.com/JuliaLang/julia/blob/2fcb1b16fc734be41ebf348ddfe37809b081f027/stdlib/LinearAlgebra/src/dense.jl#L1196-L1224
I'd also want to catch if it's Banded, BlockBanded, or BandedBlockBanded. @dlfivefifty are constructors from sparse matrices implemented anywhere for those?
Constructors to sparse are implemented (sparse(::BandedMatrix)
). From sparse is not but should be pretty easy, at least for banded: only need to overload bandwidths(A::SparseMatrixCSC)
. Something like this (though should be rewritten not to allocate):
function bandwidths(A::SparseMatrixCSC)
Is, Js = ??? # Don't remember how to get the I and J indices from a sparse matrix
maximum(Is - Js),maximum(Js - Is)
end