# Factorize changes the float type from Float32 to Float64

**URL:** <https://discourse.julialang.org/t/factorize-changes-the-float-type-from-float32-to-float64/63308>\
**Category:** Numerics\
**Created:** [June 21, 2021, 3:42pm UTC](https://discourse.julialang.org/t/factorize-changes-the-float-type-from-float32-to-float64/63308 "2021-06-21T15:42:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohamed\_AbdElrahman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed_abdelrahman/32/8112_2.png) [@Mohamed\_AbdElrahman](https://discourse.julialang.org/u/Mohamed_AbdElrahman)\
**Post date:** [June 21, 2021, 3:42pm UTC](https://discourse.julialang.org/t/factorize-changes-the-float-type-from-float32-to-float64/63308/1 "2021-06-21T15:42:07Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 21, 2021, 5:09pm UTC](https://discourse.julialang.org/t/factorize-changes-the-float-type-from-float32-to-float64/63308/2 "2021-06-21T17:09:04Z")

</div>

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](https://github.com/JuliaLang/SuiteSparse.jl/blob/76856153eef26c008f13520ffa12288e214fe02c/src/umfpack.jl#L189-L193)

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [June 21, 2021, 5:10pm UTC](https://discourse.julialang.org/t/factorize-changes-the-float-type-from-float32-to-float64/63308/3 "2021-06-21T17:10:58Z")

</div>

Time to rewrite in Julia?

---

<div class="post-metadata">

**Author:** ![Mohamed\_AbdElrahman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed_abdelrahman/32/8112_2.png) [@Mohamed\_AbdElrahman](https://discourse.julialang.org/u/Mohamed_AbdElrahman)\
**Post date:** [June 22, 2021, 10:10am UTC](https://discourse.julialang.org/t/factorize-changes-the-float-type-from-float32-to-float64/63308/4 "2021-06-22T10:10:13Z")

</div>

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.
