[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
DualVector< T, N > Class Template Reference |
#include <vigra/autodiff.hxx>
Public Types | |
typedef TinyVector< T, N > | Gradient |
type of the gradient vector | |
typedef T | value_type |
type of function values and gradient elements | |
Public Member Functions | |
DualVector () | |
DualVector (T const &val) | |
DualVector (T const &val, Gradient const &grad) | |
DualVector (T const &val, T const &g0) | |
DualVector (T const &val, T const &g0, T const &g1) | |
DualVector (T const &val, int targetElement) | |
Gradient const & | gradient () const |
T | value () const |
Number type for automatic differentiation.
Automatic differentiation allows one to compute the value of a numeric expression and its gradient with respect to the expression's arguments automatically and in one go. To support this, one needs a special number type that holds a scalar value and the corresponding gradient vector of appropriate length. This is the purpose of hte template class DualVector<T, N>
, where T
is the underlying numerical type (usually 'double'), and N
denotes the length of the gradient vector.
The standard arithmetic and algebraic functions are overloaded for DualVector
in order to implement the required arithmetic of dual numbers. When you replace all arguments in a numeric expression with the appropriate DualVector
instances, the result will be a DualVector
that contains the result value and gradient of the expression, evaluated at the point defined by the input values.
Usage:
#include <vigra/autodiff.hxx>
Namespace: vigra::autodiff
Note that the second argument of the DualVector
constructors specifies that the derivative w.r.t 'x' shall be the element 0 of the gradient vector, and the derivative w.r.t. 's' shall be element 1.
DualVector | ( | ) |
Zero initialization.
|
explicit |
Provide a value, but zero-initialize the gradient.
DualVector | ( | T const & | val, |
Gradient const & | grad | ||
) |
Initialize with given value and gradient.
DualVector | ( | T const & | val, |
T const & | g0 | ||
) |
Shorthand for DualVector(val, Gradient(g0))
when N == 1
.
Not to be used when N != 1
.
DualVector | ( | T const & | val, |
T const & | g0, | ||
T const & | g1 | ||
) |
Shorthand for DualVector(val, Gradient(g0, g1))
when N == 2
.
Not to be used when N != 2
.
DualVector | ( | T const & | val, |
int | targetElement | ||
) |
Initialize value to represent the argument number 'targetElement' in an expression.
The derivative of the expression w.r.t. this variable will be element 'targetElement' of the resulting gradient vector.
T value | ( | ) | const |
Get current value.
Gradient const& gradient | ( | ) | const |
Get current gradient.
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |
html generated using doxygen and Python
|