Strictly speaking you can’t: this is a function with side effects so it’s not completely clear what it means to differentiate it. Here the problem is that sto has to be of eltype Dual, not Float64. You can eg do claytonsample(tau; randmat) = claytonsample!(similar(randmat, typeof(tau)), tau; randmat) [untested] and differentiating this function should work (note the similar command constructs an array just like randmat, but of eltype typeof(tau))
1 Like