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
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Adapt = "4.3"
Aqua = "0.8"
ArrayInterface = "7.1"
DoubleFloats = "1.1.14"
FixedSizeArrays = "1"
ForwardDiff = "1"
GPUArraysCore = "0.1, 0.2"
GenericSchur = "0.5.3"
Expand All @@ -48,6 +49,7 @@ julia = "1.10"
[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
DoubleFloats = "497a8b3b-efae-58df-a0af-a86822472b78"
FixedSizeArrays = "3821ddf9-e5b5-40d5-8e25-6813ab96b5e2"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -57,4 +59,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "DoubleFloats", "ForwardDiff", "JLArrays", "Test", "SafeTestsets", "SciMLTesting", "StaticArrays", "Random"]
test = ["Aqua", "DoubleFloats", "FixedSizeArrays", "ForwardDiff", "JLArrays", "Test", "SafeTestsets", "SciMLTesting", "StaticArrays", "Random"]
4 changes: 1 addition & 3 deletions src/exp_noalloc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ end
function ldiv_for_generated!(C, A, B, ::Nothing) # lu! fallback (GPU, BigFloat, ...)
F = lu!(A)
ldiv!(F, B) # Result stored in B
if (pointer_from_objref(C) != pointer_from_objref(B)) # Aliasing allowed
copyto!(C, B)
end
copyto!(C, B)
return C
end

Expand Down
17 changes: 16 additions & 1 deletion test/basictests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Test, LinearAlgebra, Random, SparseArrays, ExponentialUtilities
using ExponentialUtilities: getH, getV, exponential!, ExpMethodNative,
ExpMethodDiagonalization, ExpMethodHigham2005, ExpMethodGeneric,
ExpMethodHigham2005Base, alloc_mem
using ForwardDiff, StaticArrays, DoubleFloats
using ForwardDiff, StaticArrays, DoubleFloats, FixedSizeArrays
using GenericSchur
using JLArrays

Expand Down Expand Up @@ -230,6 +230,21 @@ end
end
end

# Immutable array type; duals take the lu! fallback (#306)
@testset "ExpMethodHigham2005 on FixedSizeArrays" begin
Random.seed!(306)
A = 3 .* rand(4, 4) # needs squaring
E = exponential!(FixedSizeMatrix(A))
@test E isa FixedSizeMatrix{Float64}
@test E ≈ exp(A)

Jref = ForwardDiff.jacobian(exp_generic, A)
for method in (ExpMethodHigham2005(true), ExpMethodHigham2005(false), ExpMethodHigham2005Base())
J = ForwardDiff.jacobian(x -> exponential!(FixedSizeMatrix(x), method), A)
@test J ≈ Jref
end
end

@testset "Krylov products with ForwardDiff duals" begin
v = [0.3, 0.7, -0.2]
A = [0.1 0.2 0.0; 0.3 0.4 0.1; 0.0 0.2 -0.3]
Expand Down
Loading