diff --git a/src/exp_generic.jl b/src/exp_generic.jl index c55213e..b3a7112 100644 --- a/src/exp_generic.jl +++ b/src/exp_generic.jl @@ -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}) diff --git a/test/basictests.jl b/test/basictests.jl index 77300d2..bd95507 100644 --- a/test/basictests.jl +++ b/test/basictests.jl @@ -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