Revision 1141 trunk/src/linad99/posfunv.cpp
posfunv.cpp (revision 1141)  

4  4 
* Author: David Fournier 
5  5 
* Copyright (c) 20082012 Regents of the University of California 
6  6 
*/ 
7 
/** 

8 
* \file 

9 
* Description not yet available. 

10 
*/ 

7  
8 
/** \file posfunv.cpp 

9 
posfun(...) source code for variable arguments. 

10 
*/ 

11  
11  12 
#include <fvar.hpp> 
12  13  
13  14 
/** 
14 
* Description not yet available. 

15 
* \param 

15 
Retuns a positive function of the argument \f$x\f$ and sets a penalty for 

16 
\f$x<0\f$. The penalty should be added to the objective function. 

17 
\param x Argument, \f$x\f$. 

18 
\param eps Threshold, \f$\epsilon\f$, 

19 
a double constant containing the minimum allowed value of \f$x\f$. 

20 
\param _pen The penalty value \b incremented by \f$ 0.01(x\epsilon)^2 \f$ 

21 
if \f$x<\epsilon\f$. 

22 
\return \f$\left\{\begin{array} {r@{\quad:\quad}l} 

23 
x\ge\epsilon & x\\ 

24 
x<\epsilon & \frac{\epsilon}{2x/\epsilon} 

25 
\end{array}\right.\f$ 

26 
\ingroup misc 

16  27 
*/ 
17  28 
dvariable posfun(const dvariable &x, const double eps, const prevariable& _pen) 
18  29 
{ 
...  ...  
30  41 
} 
31  42  
32  43 
/** 
33 
* Description not yet available. 

34 
* \param 

44 
Retuns a positive function of the argument \f$x\f$ and sets a penalty for 

45 
\f$x<0\f$. The penalty should be added to the objective function. 

46 
\param x Argument, \f$x\f$. 

47 
\param eps Threshold, \f$\epsilon\f$, 

48 
a double constant containing the minimum allowed value of \f$x\f$. 

49 
\param _pen The penalty value \b incremented by \f$ 0.01(x\epsilon)^2 \f$ 

50 
if \f$x<\epsilon\f$. 

51 
\return \f$\left\{\begin{array} {r@{\quad:\quad}l} 

52 
x\ge\epsilon & x\\ 

53 
x<\epsilon & \frac{\epsilon}{2x/\epsilon} 

54 
\end{array}\right.\f$ 

55 
\ingroup misc 

35  56 
*/ 
36  57 
dvariable posfun(const dvariable &x, const double eps, const dvariable& _pen) 
37  58 
{ 
...  ...  
49  70 
} 
50  71  
51  72 
/** 
52 
* Description not yet available. 

53 
* \param 

73 
Retuns a positive function of the argument \f$x\f$ and sets a penalty for 

74 
\f$x<0\f$. The penalty should be added to the objective function. 

75 
A more coersive version. 

76 
\param x Argument, \f$x\f$. 

77 
\param eps Threshold, \f$\epsilon\f$, 

78 
a double constant containing the minimum allowed value of \f$x\f$. 

79 
\param _pen The penalty value \b incremented by \f$ 0.01(x\epsilon)^3 \f$ 

80 
if \f$x<\epsilon\f$. 

81 
\return \f$\left\{\begin{array} {r@{\quad:\quad}l} 

82 
x\ge\epsilon & x\\ 

83 
x<\epsilon & \frac{\epsilon}{1+x/\epsilon 

84 
+(x/\epsilon)^2 

85 
+(x/\epsilon)^3} 

86 
\end{array}\right.\f$ 

87 
\ingroup misc 

54  88 
*/ 
55  89 
dvariable posfun2(const dvariable &x, const double eps, const prevariable& _pen) 
56  90 
{ 
...  ...  
71  105 
} 
72  106  
73  107 
/** 
74 
* Description not yet available. 

75 
* \param 

108 
Adjoint code for posfun; possibly not used. 

76  109 
*/ 
77  110 
dvariable dfposfun(const prevariable&x,const double eps) 
78  111 
{ 
Also available in: Unified diff