Skip to content

Commit

Permalink
Merge pull request #135 from SciML/sparse
Browse files Browse the repository at this point in the history
Allow for sparse matrices in exponential!?
  • Loading branch information
ChrisRackauckas authored Sep 9, 2023
2 parents a2a45ae + 53a3218 commit 942e70d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/exp_generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ function exp_generic!(y1, y2, y3, x, s, ::Val{13})
end
# `lu!` is only defined for `StridedMatrix`, and `lu(::StaticArray)` (note `MArray<:StaticArray`) returns `::StaticArrays.LU !== LinearAlgebra.LU`
_rdiv!(A, B::StridedMatrix) = rdiv!(A, lu!(B))
_rdiv!(A, B::SparseMatrixCSC) = A / Array(B)
_rdiv!(A, B) = A / B

function exp_generic_core!(y1, y2, y3, x, ::Val{13})
Expand Down
7 changes: 7 additions & 0 deletions test/basictests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ exp_generic(A) = exponential!(copy(A), ExpMethodGeneric())
end
end

if VERSION >= v"1.9"
@testset "exponential! sparse" begin
A = sparse([1, 2, 1], [2, 1, 1], [1.0, 2.0, 3.0])
exponential!(copy(A), ExpMethodGeneric()) exp(Array(A))
end
end

@testset "Issue 41" begin
@test ForwardDiff.derivative(exp_generic, 0.1)exp_generic(0.1) atol=1e-15
end
Expand Down

0 comments on commit 942e70d

Please sign in to comment.