Git Product home page Git Product logo

genericschur.jl's People

Contributors

chrisrackauckas avatar ralphas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

genericschur.jl's Issues

Type pirated `eigen!` no longer effective for `eigen` on Julia 1.7

This package type pirates the eigen! function to provide support for bigfloat numbers:

function eigen!(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true,
sortby::Union{Function,Nothing}=eigsortby, kwargs...
) where {T <: STypes}
if permute || scale
A, B = balance!(A, scale=scale, permute=permute)
end
if T <: Real
S = triangularize(schur(A))
VT = Complex{T}
else
S = schur(A)
VT = T
end
if isempty(kwargs)
v = _geigvecs!(S.T,S.Z)
if permute || scale
lmul!(B, v)
end
_enormalize!(v)
if sortby !== nothing
return LinearAlgebra.Eigen(sorteig!(S.values, v, sortby)...)
else
return LinearAlgebra.Eigen(S.values,v)
end
end
do_vr = get(kwargs, :jvr, true)
if do_vr
v = _geigvecs!(S.T,S.Z)
if permute || scale
lmul!(B, v)
end
_enormalize!(v)
else
v = zeros(VT,0,0)
end
do_vl = get(kwargs, :jvl, false)
if do_vl
vl = _gleigvecs!(S.T,S.Z)
if permute || scale
ldiv!(B, vl)
end
_enormalize!(vl)
else
vl = zeros(VT,0,0)
end
do_econd = get(kwargs, :jce, false)
do_vcond = get(kwargs, :jcv, false)
if do_econd || do_vcond
Ttmp = similar(S.T)
n = length(S.values)
sel = falses(n)
rconde = zeros(real(T), do_econd ? n : 0)
rcondv = zeros(real(T), do_vcond ? n : 0)
for j in 1:n
copyto!(Ttmp, S.T)
Stmp = Schur(Ttmp,similar(S.Z,0,0),copy(S.values))
sel[j] = true
ordschur!(Stmp,sel)
sel[j] = false
if do_econd
rconde[j] = eigvalscond(Stmp,1)
end
if do_vcond
rcondv[j] = subspacesep(Stmp,1)
end
end
else
rconde = zeros(real(T),0)
rcondv = zeros(real(T),0)
end
if sortby !== nothing
return LinearAlgebra.Eigen(sorteig!(S.values, v, sortby, vl, rconde, rcondv)...)
else
return LinearAlgebra.Eigen(S.values,v,vl,false,rconde,rcondv)
end
end

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}}}
...

should these eigenvecs differ this much?

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

Lyapunov and Sylvester equation solvers for BigFloat and DoubleFloats

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.

Use of ForwardDiff through `schur`

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.

cond not working properly

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.

better Hessenberg solvers

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.

generalised Schur decomposition for non-symmetric matrices on GPU

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.

TagBot trigger 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!

Usage of vector with abstract eltype

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:

gvec = Vector{Givens}(undef, wantZ ? n : 0)

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.