IncompleteLU.jl
IncompleteLU.jl copied to clipboard
Generalize to non-scalar matrices by altering drop criterion
Two small improvements:
- Short-circuit drop-tol check when drop == 0
- Use norm (Frobenius/2-norm by default) instead of abs to allow non-scalar element types.
Here's an example of how this can be used with StaticArrays to produce block-preconditioners:
using LinearAlgebra, StaticArrays, SparseArrays
# Make block version of identity matrix
E = SMatrix{2,2}(1, 0, 0, 1.0)
Z = SMatrix{2,2}(0, 0, 0, 0.0)
ii = collect(1:2)
A = sparse(ii, ii, [E, E]) # Identity matrix with blocks
b = [SVector(1., 2.), SVector(3., 4.)] # Just 1, 2, 3, 4 represented as [[1, 2], [3, 4]]
A\b
##
using IncompleteLU
fact = ilu(A, τ = 0.)
##
fact = ilu(A, τ = 0.1)
The tests were not affected by my changes and there shouldn't be any difference for the scalar case unless a type has norm(R) different from sqrt(abs(R)).