Skip to content

Extend exp(A::AbstractMatrix) #87

Description

@foldfelis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions