You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't allow non-differentiable non-const array parameters in forward mode
All parameters w.r.t. which we don't differentiate still require adjoints. Since the user doesn't provide it, we have to construct it ourselves. However, if the parameter is a pointer array (e.g., `double*`), we don't know its size and, therefore, cannot initialize the adjoint.
If the array is const, it's guaranteed that it doesn't require an adjoint. If it's a const array (e.g., `double[3]`), we can initialize it. In other cases, we have to produce an error. We've been doing the same in the reverse mode for a while.
Fixes#1035.
doublenonConstNonDiffArr(doublex, double*y) { // expected-error {{dependent non-const pointer and array parameters are not supported; differentiate w.r.t. 'y' or mark it const}}
18
+
y[0] =3; // expected-warning {{derivative of an assignment attempts to assign to unassignable expr, assignment ignored}}
clad::differentiate(addArr, "arr[1:2]"); // expected-error {{Forward mode differentiation w.r.t. several parameters at once is not supported, call 'clad::differentiate' for each parameter separately}}
19
29
20
30
clad::differentiate(addArr, "arr[2:1]"); // expected-error {{Range specified in 'arr[2:1]' is in incorrect format}}
0 commit comments