ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
df1b2tweak.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 
18  mult(_mult), eps(_eps), coffs(1, 3)
19 {
20  double e=eps;
21  double e2=e*e;
22  double e3=e*e2;
23  double e4=e*e3;
24  double e5=e*e4;
25 
26  dmatrix M(1,3,1,3);
27  M(1,1)=e3;
28  M(1,2)=e4;
29  M(1,3)=e5;
30 
31  M(2,1)=3*e2;
32  M(2,2)=4*e3;
33  M(2,3)=5*e4;
34 
35  M(3,1)=6*e;
36  M(3,2)=12*e2;
37  M(3,3)=20*e3;
38 
39  dvector y(1,3);
40  y(1)=-mult*eps;
41  y(2)=0.0;
42  y(3)=0;
43 
44  coffs=solve(M,y);
45 }
46 
52 {
53  if (value(x)>=eps &&value(x)<=1-eps)
54  {
55  return x;
56  }
57  else if (value(x)<eps)
58  {
59  df1b2variable x2=x*x;
60  df1b2variable x3=x2*x;
61  df1b2variable x4=x3*x;
62  df1b2variable x5=x4*x;
63  return mult*eps+x+coffs(3)*x5+coffs(2)*x4+coffs(1)*x3;
64  }
65  else
66  {
67  df1b2variable y=1-x;
68  df1b2variable y2=y*y;
69  df1b2variable y3=y2*y;
70  df1b2variable y4=y3*y;
71  df1b2variable y5=y4*y;
72  double tmp=value(mult*eps+y+coffs(3)*y5+coffs(2)*y4+coffs(1)*y3);
73  if (tmp>1.0)
74  cout << "H" << endl;
75  return 1.0 -(mult*eps+y+coffs(3)*y5+coffs(2)*y4+coffs(1)*y3);
76  }
77 }
#define x
Vector of double precision numbers.
Definition: dvector.h:50
df1b2function_tweaker(double eps, double mult)
Description not yet available.
Definition: df1b2tweak.cpp:17
Description not yet available.
Definition: df1b2fun.h:266
dvector solve(const dmatrix &aa, const dvector &z)
Solve a linear system using LU decomposition.
Definition: dmat34.cpp:46
prnstream & endl(prnstream &)
#define M
Definition: rngen.cpp:57
Description not yet available.
Definition: fvar.hpp:2819
dvector coffs
Definition: ftweak.cpp:14
double eps
Definition: ftweak.cpp:13
Description not yet available.
double mult
Definition: ftweak.cpp:12
df1b2variable operator()(const df1b2variable &)
Description not yet available.
Definition: df1b2tweak.cpp:51
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69