Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize to non-scalar matrices by altering drop criterion #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

moyner
Copy link

@moyner moyner commented May 24, 2021

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)).

Two small improvements:
- Short-circuit check when drop == 0
- Use norm (Frobenius/2-norm by default) instead of abs to allow non-scalar element types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant