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

\ does not work for sparse matrices with Float32 elements #111

Open
ViralBShah opened this issue Jan 11, 2022 · 4 comments
Open

\ does not work for sparse matrices with Float32 elements #111

ViralBShah opened this issue Jan 11, 2022 · 4 comments
Assignees

Comments

@ViralBShah
Copy link
Member

As discussed in https://stackoverflow.com/questions/70648351/getting-an-error-when-using-backslash-operator-on-sparse-matrix-and-dense-vector/70662601#70662601, \ does not work for sparse matrices with Float32 elements.

It would be nice to bring back Float32 support in sparse solvers. The issue is that \ calls lu!, which does not have a matching method. Naturally lu! should not promote, but \ should check and promote.

@rayegun rayegun self-assigned this Jan 11, 2022
@KristofferC
Copy link
Member

KristofferC commented Jan 11, 2022

I think the core problem is that you cannot change between float32 and float64 support in suitesparse during runtime.

Edit: Actually JuliaLang/julia#14076 (comment) says that it's not even supported.

@rayegun
Copy link
Member

rayegun commented Jan 11, 2022

It's not supported in at least UMFPACK and KLU. I think there's promotions to Float64 somewhere, they just may not be available in the \ interface. I'm not sure about CHOLMOD.

@dkarrasch
Copy link
Member

The issue with the given problem is that the sparse matrix is recognized as Hermitian, so it gets wrapped as Hermitian(A). The next step would be that SuiteSparse.jl takes over, but it doesn't because this signature is too narrow:

https://github.com/JuliaLang/SuiteSparse.jl/blob/2f355a266ac3439c98c531f0fc774bcccb2dd43d/src/cholmod.jl#L1568-L1585

It should perhaps be widened to include all those nzval-types that get promoted to Float64 if necessary.

@rayegun rayegun transferred this issue from JuliaSparse/SuiteSparse.jl Jun 7, 2022
@ViralBShah
Copy link
Member Author

ViralBShah commented Jun 21, 2022

Note that CHOLMOD does not support Float32, but UMFPACK does (and Julia should probably as well).

We do emit the warning for CHOLMOD

┌ Warning: 2022-06-21 14:36:17 : CHOLMOD only works with double precision. Converting single precision matrix to double
└ @ Circuitscape ~/.julia/packages/Circuitscape/XpftG/src/logging.jl:25

So what we need to do is what @dkarrasch suggests above.

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

No branches or pull requests

4 participants