ADMB Documentation  11.5.3260
 All Classes Files Functions Variables Typedefs Friends Defines
mfexp.cpp
Go to the documentation of this file.
00001 /*
00002 \file Robust exponential functions for variable scalar objects.
00003 
00004 Author: David Fournier
00005 Copyright (c) 2008-2015 Regents of the University of California
00006 */
00007 #include <fvar.hpp>
00008 
00022 dvariable mfexp(const prevariable& x, double b)
00023 {
00024   if (x > b)
00025   {
00026     return exp(b)*(1.+2.*(x-b))/(1.+x-b);
00027   }
00028   else if (x < -b)
00029   {
00030     return exp(-b)*(1.-x-b)/(1.+2.*(-x-b));
00031   }
00032   return exp(x);
00033 }
00047 dvariable mfexp(const prevariable& x)
00048 {
00049   double b = 60;
00050   return mfexp(x, b);
00051 }