Skip to content
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

Extend exp(A::AbstractMatrix) #87

Open
foldfelis opened this issue Jan 17, 2022 · 3 comments
Open

Extend exp(A::AbstractMatrix) #87

foldfelis opened this issue Jan 17, 2022 · 3 comments

Comments

@foldfelis
Copy link

The method exp(A::AbstractMatrix) is too limited and doesn't support most of the lazy types:

julia> using InfiniteArrays

julia> a = cache(Ones(∞, ∞)); a[1, 1] = 0; b = view(a, 1:5, 1:5);

julia> typeof(b)
SubArray{Float64, 2, LazyArrays.CachedArray{Float64, 2, Matrix{Float64}, Ones{Float64, 2, Tuple{InfiniteArrays.OneToInf{Int64}, InfiniteArrays.OneToInf{Int64}}}}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}

julia> exp(b)
ERROR: MethodError: no method matching exp(::SubArray{Float64, 2, LazyArrays.CachedArray{Float64, 2, Matrix{Float64}, Ones{Float64, 2, Tuple{InfiniteArrays.OneToInf{Int64}, InfiniteArrays.OneToInf{Int64}}}}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false})
Closest candidates are:
  exp(::Union{Float16, Float32, Float64}) at /usr/share/julia/base/special/exp.jl:296
  exp(::StridedMatrix{var"#s859"} where var"#s859"<:Union{Float32, Float64, ComplexF32, ComplexF64}) at /usr/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:560
  exp(::StridedMatrix{var"#s859"} where var"#s859"<:Union{Integer, Complex{<:Integer}}) at /usr/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:561
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

or

julia> exp(.√(Diagonal(0:∞)[:, 2:end]))
ERROR: MethodError: no method matching exp(::LazyArrays.BroadcastMatrix{Float64, typeof(sqrt), Tuple{SubArray{Int64, 2, Diagonal{Int64, InfiniteArrays.InfUnitRange{Int64}}, Tuple{Base.Slice{InfiniteArrays.OneToInf{Int64}}, InfiniteArrays.InfUnitRange{Int64}}, false}}})
Closest candidates are:
  exp(::Union{Float16, Float32, Float64}) at /usr/share/julia/base/special/exp.jl:296
  exp(::StridedMatrix{var"#s859"} where var"#s859"<:Union{Float32, Float64, ComplexF32, ComplexF64}) at /usr/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:560
  exp(::StridedMatrix{var"#s859"} where var"#s859"<:Union{Integer, Complex{<:Integer}}) at /usr/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:561
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[19]:1

julia> exp(5exp(3im) * (.√(Diagonal(0:∞)[:, 2:end]))^2)
ERROR: MethodError: no method matching exp(::LazyArrays.ApplyArray{ComplexF64, 2, typeof(*), Tuple{LazyArrays.BroadcastMatrix{ComplexF64, typeof(*), Tuple{ComplexF64, LazyArrays.BroadcastMatrix{Float64, typeof(sqrt), Tuple{SubArray{Int64, 2, Diagonal{Int64, InfiniteArrays.InfUnitRange{Int64}}, Tuple{Base.Slice{InfiniteArrays.OneToInf{Int64}}, InfiniteArrays.InfUnitRange{Int64}}, false}}}}}, LazyArrays.BroadcastMatrix{Float64, typeof(sqrt), Tuple{SubArray{Int64, 2, Diagonal{Int64, InfiniteArrays.InfUnitRange{Int64}}, Tuple{Base.Slice{InfiniteArrays.OneToInf{Int64}}, InfiniteArrays.InfUnitRange{Int64}}, false}}}}})
Closest candidates are:
  exp(::Union{Float16, Float32, Float64}) at /usr/share/julia/base/special/exp.jl:296
  exp(::StridedMatrix{var"#s859"} where var"#s859"<:Union{Float32, Float64, ComplexF32, ComplexF64}) at /usr/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:560
  exp(::StridedMatrix{var"#s859"} where var"#s859"<:Union{Integer, Complex{<:Integer}}) at /usr/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:561
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[23]:1
@dlfivefifty
Copy link
Member

How do you propose to calculate the entries of a non-diagonal matrix exponential?

@foldfelis foldfelis reopened this Jan 18, 2022
@foldfelis
Copy link
Author

Sorry, I accidentally closed the issue. Just reopened.

@foldfelis
Copy link
Author

How do you propose to calculate the entries of a non-diagonal matrix exponential?

As the exp function implemented in the Base, it tries to calculate the Taylor expansion series.

Is it possible to have a lazy implementation of that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants