Skip to content

Commit

Permalink
Fix Ambiguities
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarmesin committed Nov 14, 2024
1 parent 8dcf245 commit 230e046
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/ExponentialUtilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include("exp.jl")
include("exp_baseexp.jl")
include("exp_noalloc.jl")
include("exp_generic.jl")
include("exp_sparse.jl")
include("phi.jl")
include("arnoldi.jl")
include("krylov_phiv.jl")
Expand Down
9 changes: 1 addition & 8 deletions src/exp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ExpMethodDiagonalization() = ExpMethodDiagonalization(true);
Computes the matrix exponential with the method specified in `method`. The contents of `A` are modified, allowing for fewer allocations. The `method` parameter specifies the implementation and implementation parameters, e.g. [`ExpMethodNative`](@ref), [`ExpMethodDiagonalization`](@ref), [`ExpMethodGeneric`](@ref), [`ExpMethodHigham2005`](@ref). Memory
needed can be preallocated and provided in the parameter `cache` such that the memory can be recycled when calling `exponential!` several times. The preallocation is done with the command [`alloc_mem`](@ref): `cache=alloc_mem(A,method)`.
A may not be sparse matrix type, since exp(A) is likely to be dense.
`A` may not be sparse matrix type, since exp(A) is likely to be dense.
Example
Expand Down Expand Up @@ -71,10 +71,3 @@ struct ExpMethodNative end
function exponential!(A, method::ExpMethodNative, cache = nothing)
return exp(A)
end

function exponential!(A::AbstractSparseArray, method=nothing, cache=nothing)
throw(ErrorException("exp(A) on a sparse matrix is generally dense. This operation is "*
"not allowed with exponential. If you wished to compute exp(At)*v, see expv. "*
"Otherwise to override this error, densify the matrix before calling, "*
"i.e. exponential!(Matrix(A))"))
end
9 changes: 9 additions & 0 deletions src/exp_sparse.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

for expmeth in [ExpMethodDiagonalization, ExpMethodGeneric, ExpMethodHigham2005, ExpMethodHigham2005Base, ExpMethodNative]
@eval function exponential!(A::AbstractSparseArray, method::$expmeth, cache=nothing)
throw(ErrorException("exp(A) on a sparse matrix is generally dense. This operation is "*
"not allowed with exponential. If you wished to compute exp(At)*v, see expv. "*
"Otherwise to override this error, densify the matrix before calling, "*
"i.e. exponential!(Matrix(A))"))
end
end

0 comments on commit 230e046

Please sign in to comment.