# What is the correct order to use factorization matrices in multiplication?

**URL:** <https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 2, 2022, 8:41pm UTC](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194 "2022-08-02T20:41:31Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [September 27, 2022, 2:51pm UTC](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194/23 "2022-09-27T14:51:56Z")

</div>

Ok, thanks!  
Is there a package to solve klu(A)x=b in parallel similar to [MKLPardisoSolver](https://github.com/JuliaSparse/Pardiso.jl)?

---

<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:** [September 27, 2022, 2:58pm UTC](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194/24 "2022-09-27T14:58:50Z")

</div>

> [@Amro](#):
>
> Is there a package to solve klu(A)x=b in parallel similar to [MKLPardisoSolver](https://github.com/JuliaSparse/Pardiso.jl)?

You mean like [Pardiso.jl](https://github.com/JuliaSparse/Pardiso.jl) or [MUMPS.jl](https://github.com/JuliaSmoothOptimizers/MUMPS.jl)? Most parallel solvers will want to do their own matrix factorization for you; you won’t just hand them a factorization you got elsewhere. Also, usually the expensive part is computing the factorization itself, so that’s the main target for parallelization.

---

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [September 27, 2022, 2:59pm UTC](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194/25 "2022-09-27T14:59:22Z")

</div>

Yes

---

<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:** [September 27, 2022, 3:00pm UTC](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194/26 "2022-09-27T15:00:48Z")

</div>

What’s wrong with Pardiso.jl or MUMPS.jl?

---

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [September 27, 2022, 3:08pm UTC](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194/27 "2022-09-27T15:08:48Z")

</div>

When I tried to use `Pardisco.jl`, it seems it does not accept the KLU factor. For example as below:

```julia
using Pardiso, SparseArrays, LinearAlgebra, KLU
ps = MKLPardisoSolver()
A_Mat = sprand(100, 100, 0.1);
I_Mat = rand(100, 2);  
I_Mat = I_Mat[:, 1];    
V_Mat = zeros(100, 2);
V_Mat = V_Mat[:, 1];

ulia> solve!(ps, V_Mat, A_Mat, I_Mat);

julia> factor = klu(A_Mat);

julia> solve!(ps, V_Mat, factor, I_Mat);
ERROR: MethodError: no method matching solve!(::MKLPardisoSolver, ::Vector{Float64}, ::KLU.KLUFactorization{Float64, Int64}, ::Vector{Float64})

```

---

<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:** [September 27, 2022, 4:29pm UTC](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194/28 "2022-09-27T16:29:24Z")

</div>

> [@Amro](#):
>
> When I tried to use `Pardisco.jl`, it seems it does not accept the KLU factor.

Pardiso ([Pardisco](https://www.youtube.com/watch?v=YxvBPH4sArQ) became abandonware after the 1970s) provides its own LU factorization; similarly for MUMPS. Why do you need to use KLU.jl?

---

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [September 27, 2022, 4:36pm UTC](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194/29 "2022-09-27T16:36:45Z")

</div>

> [@stevengj](#):
>
> Pardiso ([Pardisco](https://www.youtube.com/watch?v=YxvBPH4sArQ) became abandonware after the 1970s)

I clicked on the link but it seems not relevant? 🙂  
I have designed a circuit-based simulation tool in Julia which uses KLU for the solution (gives fast speed). So, I want to continue working at this point to parallelize the solution.

---

<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:** [September 27, 2022, 4:42pm UTC](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194/30 "2022-09-27T16:42:28Z")

</div>

> [@Amro](#):
>
> I have designed a circuit-based simulation tool in Julia which uses KLU for the solution (gives fast speed). So, I want to continue working at this point to parallelize the solution.

In order to effectively parallelize a direct solver, the factorization algorithm has to change. That’s why e.g. PARDISO and MUMPS have their own sparse factorization algorithms. You should try different algorithms to see which work well for you.

Note also that parallelizing the sparse solve is only going to work well if your matrices are huge. Unless your circuits are enormous, you should probably look elsewhere for ways to parallelize or optimize.

---

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [September 27, 2022, 4:54pm UTC](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194/31 "2022-09-27T16:54:17Z")

</div>

> [@stevengj](#):
>
> You should try different algorithms to see which work well for you.

Thanks for your helpful comment.

[Previous page](https://discourse.julialang.org/t/what-is-the-correct-order-to-use-factorization-matrices-in-multiplication/85194.md?page=1)
