I want to calcuate the jacobian for a vector calculated with the following function.
function test(A1, A2, x)
A = BlockDiagonal([A1 * x, A2])
return A * vcat(x, x)
end
However, when I calculate the jacobian with ForwardDiff.jacobian
, I get an error.
J = ForwardDiff.jacobian((x) -> test(A1, A2, x), x)
ERROR: MethodError: no method matching BlockDiagonal(::Vector{Array})
How can I resolve this error?