ADMB Documentation  11.1.2274
 All Classes Files Functions Variables Typedefs Friends Defines
dvect19.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: dvect19.cpp 1942 2014-04-28 22:22:45Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00018 dvector mfexp(const dvector& v1)
00019 {
00020   int mmin=v1.indexmin();
00021   int mmax=v1.indexmax();
00022   dvector vtmp(mmin,mmax);
00023   for (int i=mmin;i<=mmax;i++)
00024   {
00025     if (v1.elem(i)<60.)
00026     {
00027       vtmp.elem(i)=exp(v1.elem(i));
00028     }
00029     else
00030     {
00031       double x=v1.elem(i)-60.;
00032       vtmp.elem(i)=exp(60.)*(1.+2.*x)/(1.+x);
00033     }
00034   }
00035   return vtmp;
00036 }
00037 
00044 dvector mfexp(const dvector& v1, const double d)
00045 {
00046   int mmin=v1.indexmin();
00047   int mmax=v1.indexmax();
00048   dvector vtmp(mmin,mmax);
00049   for (int i=mmin;i<=mmax;i++)
00050   {
00051     if (v1.elem(i)<d)
00052     {
00053       vtmp.elem(i)=exp(v1.elem(i));
00054     }
00055     else
00056     {
00057       double x=v1.elem(i)-d;
00058       vtmp.elem(i)=exp(d)*(1.+2.*x)/(1.+x);
00059     }
00060   }
00061   return vtmp;
00062 }