Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/matrix_exponentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

```@docs
exponential!
exponential
phi
phi!
PhiPadeCache
Expand Down
2 changes: 1 addition & 1 deletion src/ExponentialUtilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ include("precompile.jl")
export phi, phi!, KrylovSubspace, arnoldi, arnoldi!, lanczos!, ExpvCache, PhivCache,
expv, expv!, phiv, phiv!, kiops, expv_timestep, expv_timestep!, phiv_timestep,
phiv_timestep!,
StegrCache, PhiPadeCache, get_subspace_cache, exponential!
StegrCache, PhiPadeCache, get_subspace_cache, exponential!, exponential
export ExpMethodHigham2005,
ExpMethodHigham2005Base, ExpMethodGeneric, ExpMethodNative,
ExpMethodDiagonalization
Expand Down
8 changes: 8 additions & 0 deletions src/exp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ function exponential!(A::GPUArraysCore.AbstractGPUArray)
return exponential!(A, ExpMethodHigham2005(false))
end;

"""
exponential(A, [method, [cache]])

Non-mutating counterpart of [`exponential!`](@ref): computes the matrix exponential of a
copy of `A`, so `A` is left unchanged. The optional arguments are passed to `exponential!`.
"""
exponential(A, args...) = exponential!(copy(A), args...)

## The diagonalization based
"""
ExpMethodDiagonalization(enforce_real = true)
Expand Down
9 changes: 9 additions & 0 deletions test/basictests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ end
#
#
exp_generic(A) = exponential!(copy(A), ExpMethodGeneric())
@testset "exponential leaves its input unchanged" begin
A = [0.1 0.4 -0.2; 0.3 -0.5 0.1; 0.0 0.2 0.3]
A0 = copy(A)
@test exponential(A) ≈ exp(A0)
@test exponential(A, ExpMethodGeneric()) ≈ exp(A0)
@test exponential(A, ExpMethodHigham2005(), alloc_mem(A, ExpMethodHigham2005())) ≈ exp(A0)
@test A == A0
@test exponential(SMatrix{3, 3}(A)) ≈ exp(A0)
end
@testset "exp_generic" begin
for n in [5, 10, 30, 50, 100, 500]
M = rand(n, n)
Expand Down
Loading