ADMB Documentation  11.1.1907
 All Classes Files Functions Variables Typedefs Friends Defines
mfexp.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: mfexp.cpp 1112 2013-07-12 21:41:41Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <fvar.hpp>
00012 
00021 dvariable mfexp(const prevariable& x)
00022   {
00023     double b=60;
00024     if (x<=b && x>=-b)
00025     {
00026       return exp(x);
00027     }
00028     else if (x>b)
00029     {
00030       return exp(b)*(1.+2.*(x-b))/(1.+x-b);
00031     }
00032     else
00033     {
00034       return exp(-b)*(1.-x-b)/(1.+2.*(-x-b));
00035     }
00036   }
00037 
00046 dvariable mfexp(const prevariable& x, double b)
00047   {
00048     if (x<=b && x>=-b)
00049     {
00050       return exp(x);
00051     }
00052     else if (x>b)
00053     {
00054       return exp(b)*(1.+2.*(x-b))/(1.+x-b);
00055     }
00056     else
00057     {
00058       return exp(-b)*(1.-x-b)/(1.+2.*(-x-b));
00059     }
00060   }