Skip to content

Commit

Permalink
Merge pull request #63 from kanav99/resize_jac
Browse files Browse the repository at this point in the history
Adds `resize!` for JacobianCache
  • Loading branch information
ChrisRackauckas committed Jul 2, 2019
2 parents c4be5ff + aecb30e commit 48897f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/DiffEqDiffTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module DiffEqDiffTools

using LinearAlgebra, SparseArrays, StaticArrays

import Base: resize!

include("function_wrappers.jl")
include("finitediff.jl")
include("derivatives.jl")
Expand Down
10 changes: 9 additions & 1 deletion src/jacobians.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct JacobianCache{CacheType1,CacheType2,CacheType3,ColorType,fdtype,returntype,inplace}
mutable struct JacobianCache{CacheType1,CacheType2,CacheType3,ColorType,fdtype,returntype,inplace}
x1 :: CacheType1
fx :: CacheType2
fx1 :: CacheType3
Expand Down Expand Up @@ -450,3 +450,11 @@ function finite_difference_jacobian!(
end
J
end

function resize!(cache::JacobianCache, i::Int)
resize!(cache.x1, i)
resize!(cache.fx, i)
cache.fx1 != nothing && resize!(cache.fx1, i)
cache.color = 1:i
nothing
end

0 comments on commit 48897f0

Please sign in to comment.