How do I customize the derivative of a matrix using Zygote: @adjoint

It’s deceptive, but this is not actually doing the same thing as:

c̄ .* (Grad_of_Mat(x,t),(zeros(2,2),zeros(2,2)))

At the same time, I would recommend you use ChainRulesCore.rrule instead of Zygote.@adjoint for this. Converting ZygoteRules.@adjoint to rrules · ChainRules has a migration guide for converting between the two. The reason is that we plan on deprecating @adjoint in the near future and asking users to move to ChainRules. Bonus, your rule will work with other ChainRules-compatible ADs!