Cond() error: LinearAlgebra and BigFloats incompatible?

In the course of building my simulation of chemicals in an operating battery, I need to invert matrices that are ill-conditioned (condition number near 1E15). My strategy was to use a matrix of BigFloats because they can offer ~50 significant digits and thus the matrix inversion should theoretically be possible despite the loss of 15 significant digits from the ill-conditioning of the matrix.

During the course of my attempts to make this inversion work, I often need to use cond() or other LinearAlgebra functions to investigate the mathematics of the situation. But I encounter this incompatibility between LinearAlgebra and BigFloat (MWE written below using a matrix that has good conditioning)

A = zeros(BigFloat,3,3)
A[:,:] = [big"1.0" big"2.0" big"3.0"; big"4.0" big"1.0" big"6.0"; big"7.0" big"8.0" big"1.0"]
cond(A)
ERROR: MethodError: no method matching svdvals!(::Matrix{BigFloat})
.. etc ..

This makes me reluctant to proceed further with any Julia/LinearAlgebra/BigFloat work. Is the package LinearAlgebra generally not compatible with BigFloats?

I think you should consider if you can get away with calling the one or infinity norm based condition number (i.e. cond(A, Inf)) instead of the two norm since they’ll be much cheaper to compute. If you have to stick with the two norm based condition number then you should be able to get it working if you also load the GenericLinearAlgebra package which extends svdvals to cover Matrix{BigFloat}.

4 Likes

Hey Damon (long time no talk!)—

I thought the code ran fine for me and was asking about your version and stuff, but turns out that was wrong. I can’t figure out how to strikethrough my text, so I’m just deleting it in an edit. Turns out DoubleFloats.jl, a package I happened to have loaded when I tried this, depends on GenericLinearAlgebra, which I had loaded when I ran this test, and so that was why it worked for me. Here is the second paragraph of the note in any case, though:

You might also look into DoubleFloats.jl, by the way, which will probably give you a lot more speed and may be enough extra precision.

Much thanks Andreas! I will try those ideas.

Chris, I will look into DoubleFloats and do some speed tests, hopefully report back to this thread. Thank you.