Statistics
| Revision:

root / branches / pthreads-737 / src / linad99 / bounder.cpp @ 765

History | View | Annotate | Download (833 Bytes)

1
/*
2
 * $Id: bounder.cpp 542 2012-07-10 21:04:06Z johnoel $
3
 *
4
 * Author: David Fournier
5
 * Copyright (c) 2008-2012 Regents of the University of California
6
 */
7
/**
8
 * \file
9
 * Description not yet available.
10
 */
11
#include "fvar.hpp"
12

    
13
/**
14
 * Description not yet available.
15
 * \param
16
 */
17
  double bounder(double x,double min,double max, double scale)
18
  {
19
    double y=x/scale;
20
    double z;
21
    if (y<20.0)
22
    {
23
      z=exp(y)/(1.0+exp(y));
24
    }
25
    else
26
    {
27
      z=1.0/(1+exp(-y));
28
    }
29
    return min+(max-min)*z;
30
  }
31

    
32
/**
33
 * Description not yet available.
34
 * \param
35
 */
36
  dvariable bounder(const prevariable&  x,double min,double max, double scale)
37
  {
38
    dvariable y=x/scale;
39
    dvariable z;
40
    if (y<20.0)
41
    {
42
      z=exp(y)/(1.0+exp(y));
43
    }
44
    else
45
    {
46
      z=1.0/(1+exp(-y));
47
    }
48
    return min+(max-min)*z;
49
  }