template<typename T>
T func(const T& x) {
T t = x * x * x * x * x * x * x;
return t * 3.0;
}
int main() {
{
DH::setAllDerivatives<1>(aFor, 1.0);
std::cout << "t0s: " << DH::derivative<0, 0>(cFor) << std::endl;
std::cout << "t1_1s: " << DH::derivative<1, 0>(cFor) << std::endl;
std::cout << "t1_2s: " << DH::derivative<1, 1>(cFor) << std::endl;
std::cout << "t2s: " << DH::derivative<2, 0>(cFor) << std::endl;
}
{
DH::setAllDerivatives<1>(aFor, 1.0);
std::cout << "t0s: " << cFor << std::endl;
std::cout << "t6s: " << DH::derivative<6, 0>(cFor) << std::endl;
}
{
DH::setAllDerivativesForward<1>(aRev, 1.0);
tape.setActive();
tape.registerInput(aRev);
tape.registerOutput(cRev);
DH::setAllDerivativesReverse<1>(cRev, 1.0);
tape.setPassive();
tape.evaluate();
std::cout << "r0s: " << cRev << std::endl;
std::cout << "r6s: " << DH::derivative<6, 0>(aRev) << std::endl;
tape.reset();
}
{
DH::derivative<1, 0>(aFor) = {1.0, 2.0};
DH::derivative<1, 1>(aFor) = 1.0;
std::cout << "t0v: " << DH::derivative<0, 0>(cFor) << std::endl;
std::cout << "t1_1v: " << DH::derivative<1, 0>(cFor) << std::endl;
std::cout << "t1_2v: " << DH::derivative<1, 1>(cFor) << std::endl;
std::cout << "t2v: " << DH::derivative<2, 0>(cFor) << std::endl;
}
return 0;
}
A helper class for the access of the various derivatives in higher order AD types.
Definition derivativeAccess.hpp:267