From 6ed2b129cbd174f91b0d8bdf446542c852474bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 30 Apr 2013 13:41:13 +0200 Subject: [PATCH] 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. --- AutoDiff.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AutoDiff.hpp b/AutoDiff.hpp index aa19343c7..8a758c453 100644 --- a/AutoDiff.hpp +++ b/AutoDiff.hpp @@ -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