JuliaArrays / JuliaArrays/InfiniteArrays.jl

Extend `exp(A::AbstractMatrix)`

Open
#87 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
76
Forks
9
Avg merge
16h 56m
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementation of exp(::AbstractMatrix) and any existing tests for matrix exponentials. Reproduce the SubArray and lazy-array examples in the issue to identify the unsupported dispatch cases. Done means exp works for the demonstrated lazy matrix types without the reported MethodErrors.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.