# How to use Pardiso with single-precision matrices

**URL:** <https://discourse.julialang.org/t/how-to-use-pardiso-with-single-precision-matrices/125520>\
**Category:** Numerics\
**Tags:** question\
**Created:** [February 4, 2025, 8:23am UTC](https://discourse.julialang.org/t/how-to-use-pardiso-with-single-precision-matrices/125520 "2025-02-04T08:23:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RayleighLord](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rayleighlord/32/33592_2.png) [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Post date:** [February 4, 2025, 8:23am UTC](https://discourse.julialang.org/t/how-to-use-pardiso-with-single-precision-matrices/125520/1 "2025-02-04T08:23:12Z")

</div>

I would like to ask if it is possible to run Pardiso from the `LinearSolve` library using single precision matrices. I am running

```julia
using SparseArrays, LinearSolve, MKL, Pardiso
prob = LinearProblem(A, b)
sol = LinearSolve.solve(prob, MKLPardisoFactorize())

```

and I get

```julia
ERROR: MethodError: no method matching pardiso(::MKLPardisoSolver, ::SparseMatrixCSC{ComplexF32, Int64}, ::Vector{ComplexF32})

Closest candidates are:
  pardiso(::Pardiso.AbstractPardisoSolver, ::SparseMatrixCSC{Tv, Ti}, ::StridedVecOrMat{Tv}) where {Ti, Tv<:Union{Float64, ComplexF64}}
   @ Pardiso ~/.julia/packages/Pardiso/z4YUw/src/Pardiso.jl:367
  pardiso(::Pardiso.AbstractPardisoSolver)
   @ Pardiso ~/.julia/packages/Pardiso/z4YUw/src/Pardiso.jl:366
  pardiso(::Pardiso.AbstractPardisoSolver, ::StridedVecOrMat{Tv}, ::SparseMatrixCSC{Tv, Ti}, ::StridedVecOrMat{Tv}) where {Ti, Tv<:Union{Float64, ComplexF64}}
   @ Pardiso ~/.julia/packages/Pardiso/z4YUw/src/Pardiso.jl:341

Stacktrace:
 [1] solve!(cache::LinearSolve.LinearCache{…}, alg::PardisoJL{…}; kwargs::@Kwargs{})
   @ LinearSolvePardisoExt ~/.julia/packages/LinearSolve/WDeMC/ext/LinearSolvePardisoExt.jl:137
 [2] solve!(cache::LinearSolve.LinearCache{…}, alg::PardisoJL{…})
   @ LinearSolvePardisoExt ~/.julia/packages/LinearSolve/WDeMC/ext/LinearSolvePardisoExt.jl:131
 [3] solve!(::LinearSolve.LinearCache{…}; kwargs::@Kwargs{})
   @ LinearSolve ~/.julia/packages/LinearSolve/WDeMC/src/common.jl:269
 [4] solve!(::LinearSolve.LinearCache{…})
   @ LinearSolve ~/.julia/packages/LinearSolve/WDeMC/src/common.jl:268
 [5] solve(::LinearProblem{…}, ::PardisoJL{…}; kwargs::@Kwargs{})
   @ LinearSolve ~/.julia/packages/LinearSolve/WDeMC/src/common.jl:265
 [6] solve(::LinearProblem{…}, ::PardisoJL{…})
   @ LinearSolve ~/.julia/packages/LinearSolve/WDeMC/src/common.jl:263
 [7] top-level scope
   @ ~/Desktop/LinearSystem_GiulioD/forced_response.jl:11
Some type information was truncated. Use `show(err)` to see complete types.

```

---

<div class="post-metadata">

**Author:** ![MikkelPaltorp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikkelpaltorp/32/215055_2.png) [@MikkelPaltorp](https://discourse.julialang.org/u/MikkelPaltorp)\
**Post date:** [February 4, 2025, 10:27am UTC](https://discourse.julialang.org/t/how-to-use-pardiso-with-single-precision-matrices/125520/2 "2025-02-04T10:27:56Z")

</div>

In the case of PanuaPardiso you still need to pass in the matrix in double precision even if the factorization is done in single precision. I thought the same was the case for MKLPardiso, but having looked at ‘iparm[27]’ in the oneMKL documentation it seems as it is not the case. As such I have a feeling that the single precision precision feature of MKLPardiso is simply not exposed.

Can you please make an issue with an MWE on Pardiso.jl?

---

<div class="post-metadata">

**Author:** ![RayleighLord](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rayleighlord/32/33592_2.png) [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Post date:** [February 4, 2025, 11:49am UTC](https://discourse.julialang.org/t/how-to-use-pardiso-with-single-precision-matrices/125520/3 "2025-02-04T11:49:53Z")

</div>

Sure, I will make a MWE. By the way, what parameter do you need to pass to PanuaPardiso if you want the factorization to be done in single precision? Can you do it using `LinearSolve` or do I have to use the API of `Pardiso.jl`?

---

<div class="post-metadata">

**Author:** ![MikkelPaltorp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikkelpaltorp/32/215055_2.png) [@MikkelPaltorp](https://discourse.julialang.org/u/MikkelPaltorp)\
**Post date:** [February 4, 2025, 12:12pm UTC](https://discourse.julialang.org/t/how-to-use-pardiso-with-single-precision-matrices/125520/4 "2025-02-04T12:12:40Z")

</div>

I do not know how to pass parameters to LinearSolve.jl. In Pardiso.jl you should change `iparm` by using the `set_iparm` function. For PanuaPardiso it should be `iparm(29)` that is of interest to you (see [https://panua.ch/static/manual/manual.pdf](https://panua.ch/static/manual/manual.pdf)) - but I am fairly certain that this only changes the factorization to single precision, meaning that the input matrix still has to be given in double precision.

---

<div class="post-metadata">

**Author:** ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)\
**Post date:** [February 4, 2025, 12:24pm UTC](https://discourse.julialang.org/t/how-to-use-pardiso-with-single-precision-matrices/125520/5 "2025-02-04T12:24:00Z")

</div>

In LinearSolve, you should be able to pass the iparm data  
in the constructor:

> **[Linear System Solvers · LinearSolve.jl](https://docs.sciml.ai/LinearSolve/stable/solvers/solvers/#LinearSolve.MKLPardisoFactorize)**
>
> Documentation for LinearSolve.jl.

However, this appears to be not well tested. A good MWE might be helpful here.

---

<div class="post-metadata">

**Author:** ![RayleighLord](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rayleighlord/32/33592_2.png) [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Post date:** [February 4, 2025, 9:06pm UTC](https://discourse.julialang.org/t/how-to-use-pardiso-with-single-precision-matrices/125520/6 "2025-02-04T21:06:44Z")

</div>

Thank you for the answer. But I just discovered that Panua is not free and will not suit my needs. I’ll have to wait if the MKL Pardiso gets fixed for single-precision in Julia, since I tried to “hack” the library locally but I do not have the experience with it to make it work.

Thank you very much for the help, though.
