Factorization of Integer Sparse Matrices Throws Error

Hello fellow julia-users.

I have been working with sparse matrices recently, and have come across a counter-intuitive method error when applying a QR factorization to a matrix with integer entries. The function qrfact works for sparse matrices with Float64 entries, but not with Int64 entries.

Here’s a minimal example:

A = sparse([1 2; 3 4]) 
qrfact(A)

Which generates a method error.
On the other hand, the following works as expected.

A = sparse([1.0 2.0; 3.0 4.0]) 
qrfact(A)

Is this the intended behavior?

My only hint as to what’s going on is that, according to the documentation, lufact returns always returns floating point numbers because that is the type that the SuiteSparse package supports. But lufact will work even when called on integer data, it’s just that the return value in non-integer. The qrfact function has a different backend (SPQR), so I am not sure if this observation is related to the problem at all.

The underling SuiteSparse QR routines work only on floating-point data, but for an integer (etc.) matrix we should have a method that converts to floating-point as needed. (This is what happens for LU.) Should be an easy patch for someone to contribute.

Great. Thank you for the feedback, Steven. I’ve been looking for a way to get more involved with julia on the development side, so I will contribute the patch.