JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.73k stars 5.48k forks source link

Support for Complex{BigFloat} in LinearAlgebra #45516

Closed thudjx closed 2 months ago

thudjx commented 2 years ago

I need to use Complex{BigFloat} as elements of matrix in my calculation, but I found that eigen doesn't support this datatype. The mwe is:

julia> σy = Complex{BigFloat}.([0 -im; im 0])
2×2 Matrix{Complex{BigFloat}}:
 0.0+0.0im  0.0-1.0im
 0.0+1.0im  0.0+0.0im
julia> eigen(σy)
ERROR: MethodError: no method matching eigen!(::Matrix{Complex{BigFloat}}; permute=true, scale=true, sortby=LinearAlgebra.eigsortby)
Closest candidates are:
  eigen!(::SymTridiagonal{var"#s861", V} where {var"#s861"<:Union{Float32, Float64}, V<:AbstractVector{var"#s861"}}) at ~/app/julia-1.7.3/share/julia/stdlib/v1.7/LinearAlgebra/src/tridiag.jl:284 got unsupported keyword arguments "permute", "scale", "sortby"
  eigen!(::SymTridiagonal{var"#s861", V} where {var"#s861"<:Union{Float32, Float64}, V<:AbstractVector{var"#s861"}}, ::UnitRange) at ~/app/julia-1.7.3/share/julia/stdlib/v1.7/LinearAlgebra/src/tridiag.jl:287 got unsupported keyword arguments "permute", "scale", "sortby"
  eigen!(::SymTridiagonal{var"#s861", V} where {var"#s861"<:Union{Float32, Float64}, V<:AbstractVector{var"#s861"}}, ::Real, ::Real) at ~/app/julia-1.7.3/share/julia/stdlib/v1.7/LinearAlgebra/src/tridiag.jl:292 got unsupported keyword arguments "permute", "scale", "sortby"

Is this a bug or feature?

oscardssmith commented 2 years ago

it's a complicated. tldr is that base currently uses c/fortran libraries to do it's linear algebra (because writing these and getting top tier performance is work). We do want to fix this eventually, but it's not something that can be done immediately. it will require a few people giving it a bunch of time for a few months. Until this works out of the box, I think there is a package that implements generic linear algebra.

giordano commented 2 months ago

Closing in favour of #48098, which has more discussion about linear algebra with BigFloat, not just Complex{BigFloat}