10#ifndef EIGEN_ADLOC_FORWARD
11#define EIGEN_ADLOC_FORWARD
25#ifndef NUMBER_DIRECTIONS
26# define NUMBER_DIRECTIONS 2
28#include <adolc/adtl.h>
71inline const adouble& conj(
const adouble& x) {
return x; }
72inline const adouble& real(
const adouble& x) {
return x; }
73inline adouble imag(
const adouble&) {
return 0.; }
74inline adouble abs(
const adouble& x) {
return fabs(x); }
75inline adouble abs2(
const adouble& x) {
return x*x; }
81template<>
struct NumTraits<adtl::adouble>
84 typedef adtl::adouble Real;
85 typedef adtl::adouble NonInteger;
86 typedef adtl::adouble Nested;
91 RequireInitialization = 1,
98template<
typename Functor>
class AdolcForwardJacobian :
public Functor
100 typedef adtl::adouble ActiveScalar;
103 AdolcForwardJacobian() : Functor() {}
104 AdolcForwardJacobian(
const Functor& f) : Functor(f) {}
107 template<
typename T0>
108 AdolcForwardJacobian(
const T0& a0) : Functor(a0) {}
109 template<
typename T0,
typename T1>
110 AdolcForwardJacobian(
const T0& a0,
const T1& a1) : Functor(a0, a1) {}
111 template<
typename T0,
typename T1,
typename T2>
112 AdolcForwardJacobian(
const T0& a0,
const T1& a1,
const T1& a2) : Functor(a0, a1, a2) {}
114 typedef typename Functor::InputType InputType;
115 typedef typename Functor::ValueType ValueType;
116 typedef typename Functor::JacobianType JacobianType;
118 typedef Matrix<ActiveScalar, InputType::SizeAtCompileTime, 1> ActiveInput;
119 typedef Matrix<ActiveScalar, ValueType::SizeAtCompileTime, 1> ActiveValue;
121 void operator() (
const InputType& x, ValueType* v, JacobianType* _jac)
const
126 Functor::operator()(x, v);
130 JacobianType& jac = *_jac;
132 ActiveInput ax = x.template cast<ActiveScalar>();
133 ActiveValue av(jac.rows());
135 for (
int j=0; j<jac.cols(); j++)
136 for (
int i=0; i<jac.cols(); i++)
137 ax[i].setADValue(j, i==j ? 1 : 0);
139 Functor::operator()(ax, &av);
141 for (
int i=0; i<jac.rows(); i++)
143 (*v)[i] = av[i].getValue();
144 for (
int j=0; j<jac.cols(); j++)
145 jac.coeffRef(i,j) = av[i].getADValue(j);
Namespace containing all symbols from the Eigen library.
Definition AdolcForward:45