ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
linad99/bounder.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00017   double bounder(double x,double min,double max, double scale)
00018   {
00019     double y=x/scale;
00020     double z;
00021     if (y<20.0)
00022     {
00023       z=exp(y)/(1.0+exp(y));
00024     }
00025     else
00026     {
00027       z=1.0/(1+exp(-y));
00028     }
00029     return min+(max-min)*z;
00030   }
00031 
00036   dvariable bounder(const prevariable&  x,double min,double max, double scale)
00037   {
00038     dvariable y=x/scale;
00039     dvariable z;
00040     if (y<20.0)
00041     {
00042       z=exp(y)/(1.0+exp(y));
00043     }
00044     else
00045     {
00046       z=1.0/(1+exp(-y));
00047     }
00048     return min+(max-min)*z;
00049   }