ralphas / genericschur.jl Goto Github PK
View Code? Open in Web Editor NEWJulia package for Schur decomposition of matrices with generic element types
License: Other
Julia package for Schur decomposition of matrices with generic element types
License: Other
This package type pirates the eigen!
function to provide support for bigfloat numbers:
GenericSchur.jl/src/GenericSchur.jl
Lines 50 to 125 in 9dec823
This is no longer effective on 1.7 when one calls eigen
.:
1.7:
julia> R = rand(BigFloat, 20, 20);
julia> using GenericSchur, LinearAlgebra
julia> eigen(R)
ERROR: MethodError: no method matching eigen!(::Matrix{BigFloat}; permute=true, scale=true, sortby=LinearAlgebra.eigsortby, jvl=false, jvr=true, jce=false, jcv=false)
1.6:
julia> R = rand(BigFloat, 20, 20);
julia> using GenericSchur, LinearAlgebra
julia> eigen(R)
Eigen{Complex{BigFloat}, Complex{BigFloat}, Matrix{Complex{BigFloat}}, Vector{Complex{BigFloat}}}
...
julia> using GenericSchur, LinearAlgebra
julia> setprecision(BigFloat,53)
53
julia> m = reshape([1.0, 12.0, 8.0, 5.0],2,2)
2×2 Array{Float64,2}:
1.0 8.0
12.0 5.0
julia> b=BigFloat.(m)
2×2 Array{BigFloat,2}:
1.0 8.0
12.0 5.0
julia> eigen(m)
Eigen{Float64,Float64,Array{Float64,2},Array{Float64,1}}
eigenvalues:
2-element Array{Float64,1}:
-7.0
13.0
eigenvectors:
2×2 Array{Float64,2}:
-0.707107 -0.5547
0.707107 -0.83205
julia> eigen(b)
Eigen{Complex{BigFloat},Complex{BigFloat},Array{Complex{BigFloat},2},Array{Complex{BigFloat},1}}
eigenvalues:
2-element Array{Complex{BigFloat},1}:
-7.0 + 0.0im
13.0 + 0.0im
eigenvectors:
2×2 Array{Complex{BigFloat},2}:
-1.0+0.0im 0.666667+0.0im
1.0+0.0im 1.0+0.0im
I am pondering to propose a roadmap for the extension of the MatrixEquations package to address the solution of Lyapunov, Sylvester and even Riccati equations for data types not covered by LAPACK (e.g., BigFloat, DoubleFloats). In the matrix equation solvers a central role is played by the Schur decomposition of the involved matrices or matrix pairs, both real and complex. In MatrixEquations , schur(A)
and schur(A,B)
are used for all element types covered by BlasReal and BlasComplex types. I wonder if I could entirely rely on the GenericSchur
package to cover the required functionality for extended precision data types.
Hello there 👋
I am wondering if it would make sense to allow ForwardDiff.Dual
numbers through the schur
factorization in this package? Currently, many methods are restricted to
StridedMatrix{Complex{T}} where T<:AbstractFloat
which prevents the use of ForwardDiff.Dual
since they are not <:AbstractFloat
.
ilo, ihi, scale = LAPACK.gebal!('B', A) # modifies A
It looks like this is:
A, B = balance!(A::AbstractMatrix{T})
ilo, ihi, scale = B.ilo, B.ihi, ?
What matches the scale
?
Is this B.D
?
MWE:
using GenericSchur
A = [big"2937189730080557577" big"9536995145808582886" big"11892438427558067162";big"6599805415728025309" big"21429433573366650048" big"26722066585196691901";big"5292633011830041853" big"17185071439388109015" big"21429433573366650048"]
cond(A) # does not work
cond(BigFloat.(A)) # does not work
Same thing works with GenericLinearAlgebra.jl
using GenericLinearAlgebra
A = [big"2937189730080557577" big"9536995145808582886" big"11892438427558067162";big"6599805415728025309" big"21429433573366650048" big"26722066585196691901";big"5292633011830041853" big"17185071439388109015" big"21429433573366650048"]
cond(A) # works 4.791463623157561751482371727718662967237981800410446716813214586738373018559972e+46
cond(BigFloat.(A)) # works 4.791463623157561751482371727718662967237981800410446716813214586738373018559972e+46
Tested on 1.8.5 and 1.9.
I noticed that you implemented Hessenberg solvers in https://github.com/RalphAS/GenericSchur.jl/blob/a361308be3b52faee82a9db30ea87d40d82fb0c4/src/hessenberg.jl
In JuliaLang/julia#31853 we are adding such solvers to LinearAlgebra — the algorithm we are using seems to be significantly faster (5-10x) than what you are doing now because it combines the RQ factorization and the triangular backsolve, and is able to do them both without modifying H.
In the near future, if you already have an upper-Hessenberg matrix H
, you will be able to do Hessenberg(H) \ b
to use the LinearAlgebra solver. If you need any additional functionality, please comment.
Hi,
I tried running GenericSchur on GPU (via Google Colab) and unfortunately get stuck very early on. He is resorting to LAPACK Schur, which is not implemented for GPUs.
Having a GPU implementation of generalised Schur for non-symmetric matrices would be a great addition. So far, neither cublas, arrayfire, nor any other blas/lapack alternative has it. Julia seems to be promising in getting there.
I am not proficient enough to debug the code myself but happy to help testing. I ran the following notebook to test and added the following code snippets to have GPU support in Julia:
using Pkg Pkg.add(["BenchmarkTools","CUDA","GenericSchur","GenericLinearAlgebra"]) using BenchmarkTools,CUDA,GenericLinearAlgebra import GenericSchur size = 50 arand = rand(size,size) brand = rand(size,size) GenericSchur.schur(arand,brand) agpu = CuArray(arand) bgpu = CuArray(brand) GenericSchur.schur(agpu,bgpu)
I hope this helps in getting closer to the issue.
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
This came up in a nanosoldier run. I noticed that in this line, a vector is allocated whose eltype is abstract, since there is no eltype to Givens
:
GenericSchur.jl/src/symtridiag.jl
Line 74 in 48bff35
In every subsequent setindex!
, this calls a convert routine (which does nothing I guess), but in case it's possible, it may be beneficial to precompute the correct eltype and set it upfront?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.