/**
* A naive implementation of forward propagation of the first order derivatives
* Written during the lecture at the school of Automatic Differentiation
* on 25 January 2010, Geilo Norway
* Author: Daniel Wilczak
*
* Remarks: the code is as bad as possible, but it shows that the basic AD
* can be implemented within a few minutes.
*
* Compile (linux): g++ forwardDiffExample.cpp -o forwardDiffExample
* Run: ./forwardDiffExample
*
* Comments added on 27 January 2010, Oslo Airport
*/
#include
#include
// maxDim is not a number of variables but rather a number of directional derivatives
// we want to propagate.
const int maxDim = 2;
// this class will store the actual value of an expression
// in the member 'value'
// and directional derivatives with respect to maxDim directions
// in the array 'der'
class F
{
public:
F(double _value)
: value(_value)
{
for(int i=0;i