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
clad::gradient returns NaN values due to (unused) std::acos in the function definition receiving invalid input, while clad::differentiate calculates the derivatives. So this:
doublef(double C, double A)
{
double a = std::acos(-C / A); // valid input is -1 <= -C/A <= 1return2 * C * C * A;
}
intmain()
{
auto f_grad = clad::gradient(f);
double dC = 0, dA = 0;
f_grad.execute(/*C=*/5, /*A=*/3, &dC, &dA);
std::cout << "clad::gradient results: " << std::endl;
std::cout << dC << "" << dA << std::endl;
std::cout << "clad::differentiate results: " << std::endl;
auto f_dC = clad::differentiate(f, "C");
std::cout << f_dC.execute(/*C=*/5, /*A=*/3) << "";
auto f_dA = clad::differentiate(f, "A");
std::cout << f_dA.execute(/*C=*/5, /*A=*/3) << std::endl;
}
on Clad version 1.8~dev produces these results:
clad::gradient results:
nan -nan
clad::differentiate results:
6050
The text was updated successfully, but these errors were encountered:
clad::gradient returns NaN values due to (unused) std::acos in the function definition receiving invalid input, while clad::differentiate calculates the derivatives. So this:
on Clad version 1.8~dev produces these results:
The text was updated successfully, but these errors were encountered: