#include <codi.hpp>
#include <iostream>
return x * x * x;
}
Identifier t_i = data->
getData<
int>();
double scale = data->
getData<
double>();
std::cout << " Reverse: t_b = " << t_b << ", scale = " << scale << std::endl;
}
void extFunc_del(Tape* t, void* d) {
delete data;
std::cout << " Reset: data is deleted." << std::endl;
}
int main(int nargs, char** args) {
tape.setActive();
tape.registerInput(x);
tape.registerOutput(y);
tape.setPassive();
tape.evaluate();
std::cout << "f(f(4.0)) = " << y << std::endl;
std::cout <<
"d(f ○ f)/dx(4.0) = " << x.
getGradient() << std::endl;
tape.reset();
return 0;
}
RealReverseGen< double > RealReverse
Definition: codi.hpp:120
Identifier & getIdentifier()
Definition: activeTypeBase.hpp:156
typename Tape::Identifier Identifier
See LhsExpressionInterface.
Definition: activeTypeBase.hpp:78
static Tape & getTape()
Get a reference to the tape which manages this expression.
Definition: activeType.hpp:99
T_Tape Tape
See ActiveType.
Definition: activeType.hpp:55
typename Tape::Real Real
See LhsExpressionInterface.
Definition: activeTypeBase.hpp:76
Ease of access structure for user-provided data on the tape for external functions....
Definition: externalFunctionUserData.hpp:59
void getData(Type &value)
Get a copy of the next data item.
Definition: externalFunctionUserData.hpp:171
size_t addData(Type const &value)
Definition: externalFunctionUserData.hpp:151
User-defined evaluation functions for the taping process.
Definition: externalFunction.hpp:102
void setGradient(Gradient const &g)
Set the gradient of this lvalue in the tape.
Definition: lhsExpressionInterface.hpp:120
Gradient getGradient() const
Get the gradient of this lvalue from the tape.
Definition: lhsExpressionInterface.hpp:115
Unified access to the adjoint vector and primal vector in a tape evaluation.
Definition: vectorAccessInterface.hpp:91
virtual Real getAdjoint(Identifier const &index, size_t dim)=0
Get the adjoint component.