Skip to content

Commit cca4a73

Browse files
jClugstorChrisRackauckas
authored andcommitted
add copy methods for Jacobian Operators
1 parent d1afae0 commit cca4a73

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

lib/SciMLJacobianOperators/src/SciMLJacobianOperators.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,35 @@ function get_dense_ad(ad::AutoSparse)
404404
return dense_ad
405405
end
406406

407+
function Base.copy(J::JacobianOperator)
408+
return JacobianOperator(
409+
J.mode,
410+
J.jvp_op,
411+
J.vjp_op,
412+
copy(J.size),
413+
copy(J.input_cache),
414+
copy(J.output_cache)
415+
)
416+
end
417+
418+
function Base.copy(J::StatefulJacobianOperator)
419+
return StatefulJacobianOperator(
420+
copy(J.jac_op),
421+
copy(u),
422+
copy(p)
423+
)
424+
end
425+
426+
function Base.copy(J::StatefulJacobianNormalFormOperator)
427+
return StatefulJacobianNormalFormOperator(
428+
copy(J.vjp_operator),
429+
copy(J.jvp_operator),
430+
copy(J.cache)
431+
)
432+
433+
end
434+
435+
407436
export JacobianOperator, VecJacOperator, JacVecOperator
408437
export StatefulJacobianOperator
409438
export StatefulJacobianNormalFormOperator

0 commit comments

Comments
 (0)