Implement constant() and variable() in terms of function()

Specifically,

  - A constant is a function with zero derivative
  - A variable is a function with unit derivative with respect to
    itself.
This commit is contained in:
Bård Skaflestad 2013-04-30 13:41:13 +02:00
parent 70996fb195
commit 6ed2b129cb

View File

@ -45,13 +45,15 @@ namespace AutoDiff {
static Forward
constant(const Scalar x)
{
return Forward(x, Scalar(0));
// Constant is function with zero derivative.
return function(x, Scalar(0));
}
static Forward
variable(const Scalar x)
{
return Forward(x, Scalar(1));
// Variable is function with unit derivative (wrt. itself).
return function(x, Scalar(1));
}
static Forward