Factorize changes the float type from Float32 to Float64

I’m solving a sparse linear system with Float32 precision for speed. The problem is the function factorize when taken input a ComplexF32 sparse matrix, the lu factors are ComplexF64.

julia> factorize(sprand(ComplexF32,6,6,.5))
SuiteSparse.UMFPACK.UmfpackLU{ComplexF64, Int64}
L factor:
6×6 SparseMatrixCSC{ComplexF64, Int64} with 15 stored entries:
      1.0+0.0im                 ⋅                   ⋅           …           ⋅               ⋅    
          ⋅                 1.0+0.0im               ⋅                       ⋅               ⋅    
 0.476748-0.0795929im  0.887996+0.627102im      1.0+0.0im                   ⋅               ⋅    
          ⋅            0.929102-0.150806im  0.94275-0.464643im              ⋅               ⋅    
          ⋅             1.25378+0.955292im  1.33148-0.134533im          1.0+0.0im           ⋅    
          ⋅              1.0496-0.659284im          ⋅           …  -1.10939-0.878131im  1.0+0.0im
U factor:
6×6 SparseMatrixCSC{ComplexF64, Int64} with 15 stored entries:
 0.206957+0.0988239im           ⋅            …             ⋅             0.145353+0.288693im
          ⋅            0.143392+0.0900774im       0.296915+0.30586im    0.0419717+0.121784im
          ⋅                     ⋅               -0.0718537-0.457798im  -0.0237227+0.0599139im
          ⋅                     ⋅                0.0262482+0.162971im   0.0197284-0.0697312im
          ⋅                     ⋅                  0.15896-0.103255im   0.0411273-0.222886im
          ⋅                     ⋅            …             ⋅             0.342257-0.0929653im

Currently, UMFPACK (which we use for the sparse LU factorization) only supports double precision, apparently: SuiteSparse.jl/umfpack.jl at 76856153eef26c008f13520ffa12288e214fe02c · JuliaSparse/SuiteSparse.jl · GitHub

1 Like

Time to rewrite in Julia?

Thank you for your quick reply.

The LU factors are not ComplexF64 matrices all times, I played with changing the density of zeros in the factorized matrix, and sometimes I got ComplexF32 as output.