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