Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 724792b

Browse files
more JacVec fixes
1 parent cd9201a commit 724792b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/jacvec_operators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ mutable struct JacVecOperator{T,F,T1,T2,uType,P,tType,O} <:
4242
opnorm = true,
4343
) where {T}
4444
if autodiff
45-
cache1 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(),eltype(x))),eltype(x),1}.(u, u)
46-
cache2 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(),eltype(x))),eltype(x),1}.(u, u)
45+
cache1 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(),eltype(x))),eltype(x),1}.(u, ForwardDiff.Partials.(tuple.(u)))
46+
cache2 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(),eltype(x))),eltype(x),1}.(u, ForwardDiff.Partials.(tuple.(u)))
4747
else
4848
cache1 = similar(u)
4949
cache2 = similar(u)

test/Misc/jacvec_operators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ x = rand(300)
77
v = rand(300)
88
du = similar(x)
99

10-
cache1 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(),eltype(x))),eltype(x),1}.(x, v)
11-
cache2 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(),eltype(x))),eltype(x),1}.(x, v)
10+
cache1 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(),eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(reshape(v, size(x)))))
11+
cache2 = ForwardDiff.Dual{typeof(ForwardDiff.Tag(SparseDiffTools.DeivVecTag(),eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(reshape(v, size(x)))))
1212
@test num_jacvec!(du, f, x, v) ForwardDiff.jacobian(f, similar(x), x) * v rtol =
1313
1e-6
1414
@test num_jacvec!(du, f, x, v, similar(v), similar(v))

0 commit comments

Comments
 (0)