ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
df1b2loc.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include <df1b2fun.h>
12 #include <df1b2loc.h>
13 
18  int operator >= (const double& x,const df1b2variable& y)
19  {
20  if (x>=value(y))
21  return 1;
22  else
23  return 0;
24  }
25 
30  int operator >= (double x,const df1b2variable& y)
31  {
32  if (value(x)>=value(y))
33  return 1;
34  else
35  return 0;
36  }
37 
42  int operator >= (const df1b2variable& x,double y)
43  {
44  if (value(x)>=y)
45  return 1;
46  else
47  return 0;
48  }
49 
54  int operator > (const double& x,const df1b2variable& y)
55  {
56  if (x>value(y))
57  return 1;
58  else
59  return 0;
60  }
61 
66  int operator > (double x,const df1b2variable& y)
67  {
68  if (value(x)>value(y))
69  return 1;
70  else
71  return 0;
72  }
73 
78  int operator > (const df1b2variable& x,double y)
79  {
80  if (value(x)>y)
81  return 1;
82  else
83  return 0;
84  }
85 
90  int operator <= (const double& x,const df1b2variable& y)
91  {
92  if (x<=value(y))
93  return 1;
94  else
95  return 0;
96  }
97 
102  int operator <= (double x,const df1b2variable& y)
103  {
104  if (value(x)<=value(y))
105  return 1;
106  else
107  return 0;
108  }
109 
114  int operator <= (const df1b2variable& x,double y)
115  {
116  if (value(x)<=y)
117  return 1;
118  else
119  return 0;
120  }
121 
126  int operator < (const double& x,const df1b2variable& y)
127  {
128  if (x<value(y))
129  return 1;
130  else
131  return 0;
132  }
133 
138  int operator < (double x,const df1b2variable& y)
139  {
140  if (value(x)<value(y))
141  return 1;
142  else
143  return 0;
144  }
145 
150  int operator < (const df1b2variable& x,double y)
151  {
152  if (value(x)<y)
153  return 1;
154  else
155  return 0;
156  }
157 
162  int operator == (const double& x,const df1b2variable& y)
163  {
164  if (x==value(y))
165  return 1;
166  else
167  return 0;
168  }
169 
174  int operator == (double x,const df1b2variable& y)
175  {
176  if (value(x)==value(y))
177  return 1;
178  else
179  return 0;
180  }
181 
186  int operator == (const df1b2variable& x,double y)
187  {
188  if (value(x)==y)
189  return 1;
190  else
191  return 0;
192  }
193 
199  const df1b2variable& _pen)
200 {
201  int mmin=x.indexmin();
202  int mmax=x.indexmax();
203  df1b2vector tmp(mmin,mmax);
204  for (int i=mmin;i<=mmax;i++)
205  {
206  tmp(i)=posfun(x(i),eps,_pen);
207  }
208  return tmp;
209 }
210 
216  const df1b2variable& _pen)
217 {
218  df1b2variable& pen= (df1b2variable&) _pen;
219  if (x>=eps)
220  {
221  return x;
222  }
223  else
224  {
225  pen+=.01*square(x-eps);
226  return eps/(2-x/eps);
227  }
228 }
229 
235 {
236  if (x>=eps)
237  {
238  return 1;
239  }
240  else
241  {
242  //double z=eps/(2-x/eps);
243  df1b2variable dfx=1.0/square(2-x/eps);
244  return dfx;
245  }
246 }
247 
253 {
254  if (x>=eps)
255  {
256  return x;
257  }
258  else
259  {
260  return eps/(2-x/eps);
261  }
262 }
263 
269  const df1b2variable& _pen)
270 {
271  df1b2variable& pen= (df1b2variable&) _pen;
272  if (x>=eps)
273  {
274  return x;
275  }
276  else
277  {
278  df1b2variable y=eps-x;
279  df1b2variable tmp=y/eps;
280  df1b2variable tmp2=tmp*tmp;
281  df1b2variable tmp3=tmp2*tmp;
282  pen+=.01*tmp3;
283  return eps/(1.0+tmp+tmp2+tmp3);
284  }
285 }
double dfposfun(const double &x, const double eps)
Adjoint code for posfun; possibly not used.
Definition: posfunc.cpp:19
#define x
Description not yet available.
Description not yet available.
Definition: df1b2fun.h:953
int indexmin(void) const
Definition: df1b2fun.h:969
dvar_vector posfun(const dvar_vector &x, double eps, const prevariable &pen)
Description not yet available.
Definition: fvar_a62.cpp:17
int operator<(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:53
Description not yet available.
Definition: df1b2fun.h:266
int operator==(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:17
int operator>(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:44
int operator<=(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:26
double eps
Definition: ftweak.cpp:13
int indexmax(void) const
Definition: df1b2fun.h:970
Description not yet available.
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
dvariable posfun2(const dvariable &x, const double eps, const prevariable &pen)
Retuns a positive function of the argument and sets a penalty for .
Definition: posfunv.cpp:88
int operator>=(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:35
double square(const double value)
Return square of value; constant object.
Definition: d3arr4.cpp:16