# Svd accelerated with the MKL package, what about schur?

**URL:** <https://discourse.julialang.org/t/svd-accelerated-with-the-mkl-package-what-about-schur/97559>\
**Category:** General Usage\
**Tags:** question, linearalgebra\
**Created:** [April 17, 2023, 3:39am UTC](https://discourse.julialang.org/t/svd-accelerated-with-the-mkl-package-what-about-schur/97559 "2023-04-17T03:39:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![13299118606](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/13299118606/32/49095_2.png) [@13299118606](https://discourse.julialang.org/u/13299118606)\
**Post date:** [April 17, 2023, 3:39am UTC](https://discourse.julialang.org/t/svd-accelerated-with-the-mkl-package-what-about-schur/97559/1 "2023-04-17T03:39:42Z")

</div>

LinearAlgebra’s svd can be accelerated with the MKL package, what about schur? much slower than matlab  
In order to avoid the unstable performance of matlab alone, and schur is iterating, it has a better effect on symmetric matrices. My research is mainly on symmetric matrices, so the test  
First look at the matlab results:

* * *

> Blockquote  
> a=rand(1000,1000);c=a\*a’;  
> tic;for i=1:100 ;[q t]=schur(c) ;end;toc ---------2.5s  
> tic;for i=1:100 ;[u e v]=svd(c) ;end;toc ---------4.9s

* * *

In julia, to be similar to maltab, use @time:

* * *

> Blockquote  
> using LinearAlgebra  
> a=rand(1000,1000);c=a\*a’;  
> @time for i=1:100;q,t=schur(c);end  
> 51.006555 seconds (8.23 k allocations: 1.519 GiB, 0.11% gc time, 0.01% compilation time)  
> @time for i=1:100;u,e,v=svd(c);end  
> 39.062737 seconds (1.60 k allocations: 4.482 GiB, 0.19% gc time)  
> using MKL  
> #svd time ===matlab  
> @time for i=1:100;u,e,v=svd(c);end  
> 5.043008 seconds (1.60 k allocations: 4.482 GiB, 2.47% gc time)  
> #but schur slower for matlab  
> @time for i=1:100;q,t=schur(c);end  
> 20.999963 seconds (1.40 k allocations: 1.518 GiB, 0.35% gc time)

* * *

It can be seen that MKL does not improve schur. Is there a method similar to matlab for improving schur?

---

<div class="post-metadata">

**Author:** ![antoine-levitt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-levitt/32/4008_2.png) [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)\
**Post date:** [April 17, 2023, 5:20am UTC](https://discourse.julialang.org/t/svd-accelerated-with-the-mkl-package-what-about-schur/97559/2 "2023-04-17T05:20:44Z")

</div>

Looks like julia doesn’t check for symmetry, it probably should. Can you try schur(Symmetric(A))?

---

<div class="post-metadata">

**Author:** ![13299118606](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/13299118606/32/49095_2.png) [@13299118606](https://discourse.julialang.org/u/13299118606)\
**Post date:** [April 17, 2023, 9:18am UTC](https://discourse.julialang.org/t/svd-accelerated-with-the-mkl-package-what-about-schur/97559/3 "2023-04-17T09:18:53Z")

</div>

Thank you for your answer. This can indeed speed up a lot. It is indeed caused by this mechanism, but there should be other mechanisms. Compared with maltab, this speed worse than the svd time of maltab, but theoretically QR should It is much faster than svd, it should be at least 2 times, what judgment mechanism can speed it up?

---

<div class="post-metadata">

**Author:** ![antoine-levitt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-levitt/32/4008_2.png) [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)\
**Post date:** [April 17, 2023, 12:03pm UTC](https://discourse.julialang.org/t/svd-accelerated-with-the-mkl-package-what-about-schur/97559/4 "2023-04-17T12:03:44Z")

</div>

The issue is that [julia/schur.jl at master · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/schur.jl) doesn’t check symmetry. By comparison eigen does: [julia/eigen.jl at master · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/eigen.jl#L152) so Someone ™ should probably make a PR that does this.
