-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use LAPack for polynomials ≤ degree ~450 (real) ~250 (complex)? #3
Comments
I think it depends on scope of this package. For a roots function in a general polynomial package I completely agree with you, but this package was mainly meant as a wrapper for the code in the paper. I think the best thing would be to let the Polynomials package depend of this package and use the AMVW solver when the degree is very high. |
I am confused with this observation. In my tests comparing the Fortran code of AMVW with Fortran LAPACK the LAPACK code is only faster for degree smaller than 20. |
gc_disable() @time for k=1:30 import Base.BLAS: blas_int,BlasChar,BlasInt
end for (hseqr,elty) in ((:dhseqr_,:Float64),)
end function companion_matrix{T}(c::Vector{T})
end rootshess(c)=hesseneigvals(companion_matrix(c))
|
I just tried this on my machine and I also get a crossover at 75. This was the same for OpenBLAS and MKL (which is not surprising because the QR algorithm is not that BLAS heavy). The dhseqr routine is pretty wild and it appears to change algorithm at exactly |
I've tried to change the default in LAPACK's dhseqr such that it uses the algorithm for small problems until the size is 500. This gives the following plot and the crossover is somewhere around 120-130. @thomasmach The timings include the construction of the companion matrix. |
Encouragement: glad you guys are looking into this. |
For some reason Lapack is a relative factor of two than in my Fortran tests for AMVW. I don't why and will have a look into this next week. |
The scaling coefficients of the last plots are
|
@andreasnoack Does you last comment mean that dhseqr is not in O(n^3)? For the complex case the crossover point is much smaller, since AMVW's complex single shift version is only slightly slower, while zhseqr is almost 3 times slower than dhseqr. |
@thomasmach No I don't think so. The asymptotic behavior just takes a little longer to kick in. There is a significant second order effect in the fit of the You are also completely right about the complex case. The plot for the complex case looks and the cross over is 40. Why is your real solver relatively slower than LAPACK's? |
Why is the complex code of AMVW almost as fast as the real code?
Additionally, the real double shift code needs slightly more iterations to converge. |
In my tests LAPack's zhseqr_/dhseqr_ is faster unless the polynomials are of higher degree, using my wrapper
https://github.com/ApproxFun/ApproxFun.jl/blob/master/src/LinearAlgebra/hesseneigs.jl
Maybe its worth wrapping these in AMVW for such cases? Unless I'm missing something.
The text was updated successfully, but these errors were encountered: