ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
df1b2f25.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  */
12 #include <df1b2fun.h>
13 #include <admodel.h>
14 
15 #ifdef ISZERO
16  #undef ISZERO
17 #endif
18 #define ISZERO(d) ((d)==0.0)
19 
20 //double ndfboundp( double x, double fmin, double fmax,const double& fpen);
21 
27  {
28  int ii=1;
29  for (int i=0;i<num_initial_df1b2params;i++)
30  {
32  (varsptr[i])->sd_scale(d,x,ii);
33  }
34  return ii-1;
35  }
36 
42  const int& _ii)
43  {
44  int& ii=(int&) _ii;
45  dvector& d=(dvector&) _d;
46  d(ii)=1;
47  if (!ISZERO(scalefactor)) d(ii)/=scalefactor;
48  ii++;
49  }
50 
56  const int& _ii)
57  {
58  int& ii=(int&) _ii;
59  dvector& d=(dvector&) _d;
60  double pen=0;
62  {
63  if (ISZERO(scalefactor))
64  d(ii)=ndfboundp(x(ii),minb,maxb,pen);
65  else
66  d(ii)=ndfboundp(x(ii)/scalefactor,minb,maxb,pen)/scalefactor;
67  }
68  else
69  {
70  if (ISZERO(scalefactor))
71  d(ii)=ndfboundp_mc(x(ii),minb,maxb,pen);
72  else
74  }
75 
76  //d(ii)=(boundp(x(ii)+1.e-6,minb,maxb,pen)-
77  //boundp(x(ii)-1.e-6,minb,maxb,pen))/2.e-6;
78  ii++;
79  }
80 
86  const int& _ii)
87  {
88  if (allocated())
89  {
90  int& ii=(int&) _ii;
91  dvector& v=(dvector&) _v;
92  int mmin=indexmin();
93  int mmax=indexmax();
94  for (int i=mmin;i<=mmax;i++)
95  {
96  v(ii)=1.;
97  if (!ISZERO(scalefactor)) v(ii)/=scalefactor;
98  ii++;
99  }
100  }
101  }
102 
108  const int& _ii)
109  {
110  if (allocated())
111  {
112  int& ii=(int&) _ii;
113  dvector& v=(dvector&) _v;
114  int mmin=indexmin();
115  int mmax=indexmax();
116  for (int i=mmin;i<=mmax;i++)
117  {
118  if (::allocated((*this)(i)))
119  {
120  int cmin=((*this)(i)).indexmin();
121  int cmax=((*this)(i)).indexmax();
122  for (int j=cmin;j<=cmax;j++)
123  {
124  v(ii)=1.;
125  if (!ISZERO(scalefactor)) v(ii)/=scalefactor;
126  ii++;
127  }
128  }
129  }
130  }
131  }
132 
138  const int& _ii)
139  {
140  if (allocated())
141  {
142  int& ii=(int&) _ii;
143  dvector& v=(dvector&) _v;
144  int mmin=indexmin();
145  int mmax=indexmax();
146  double pen=0;
148  {
149  for (int i=mmin;i<=mmax;i++)
150  {
151  if (ISZERO(scalefactor))
152  v(ii)=ndfboundp(x(ii),minb,maxb,pen);
153  else
155  ii++;
156  }
157  }
158  else
159  {
160  for (int i=mmin;i<=mmax;i++)
161  {
162  v(ii)=ndfboundp_mc(x(ii),minb,maxb,pen);
163  ii++;
164  }
165  }
166  }
167  }
168 
174  const int& _ii)
175  {
176  if (allocated())
177  {
178  int& ii=(int&) _ii;
179  dvector& v=(dvector&) _v;
180  int rmin=indexmin();
181  int rmax=indexmax();
182  double pen=0;
183  for (int i=rmin;i<=rmax;i++)
184  {
185  if (::allocated((*this)(i)))
186  {
187  int cmin=(*this)(i).indexmin();
188  int cmax=(*this)(i).indexmax();
189  for (int j=cmin;j<=cmax;j++)
190  {
191  if (ISZERO(scalefactor))
192  v(ii)=ndfboundp(x(ii),minb,maxb,pen);
193  else
194  v(ii)=ndfboundp(x(ii)/scalefactor,minb,maxb,pen)/
195  scalefactor;
196  ii++;
197  }
198  }
199  }
200  }
201  }
202 
207 int allocated(const df1b2vector& _x)
208 {
210  return x.allocated();
211 }
212 
218 {
220  return x.allocated();
221 }
222 
228 {
230  return x.allocated();
231 }
232 
237 int allocated(const df1b2matrix& _x)
238 {
240  return x.allocated();
241 }
virtual void sd_scale(const dvector &d, const dvector &x, const int &ii)
Description not yet available.
Definition: df1b2f25.cpp:55
int withinbound(int lb, int n, int ub)
Definition: model.cpp:45
#define x
int allocated(const ivector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_a59.cpp:13
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Definition: fvar.hpp:140
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin(void) const
Definition: df1b2fun.h:1054
Description not yet available.
Definition: df1b2fun.h:1401
Description not yet available.
Definition: df1b2fun.h:1420
#define ISZERO(d)
Definition: df1b2f25.cpp:18
Description not yet available.
Definition: df1b2fun.h:953
int indexmin(void) const
Definition: df1b2fun.h:969
static initial_df1b2params ** varsptr
Definition: df1b2fun.h:1367
int allocated(void)
Definition: df1b2fun.h:1049
df1b2vector * v
Definition: df1b2fun.h:1046
static int current_phase
Definition: df1b2fun.h:1350
static int num_initial_df1b2params
Definition: df1b2fun.h:1369
virtual void sd_scale(const dvector &d, const dvector &x, const int &ii)
Description not yet available.
Definition: df1b2f25.cpp:85
virtual void sd_scale(const dvector &d, const dvector &x, const int &ii)
Description not yet available.
Definition: df1b2f25.cpp:107
virtual void sd_scale(const dvector &d, const dvector &x, const int &ii)
Description not yet available.
Definition: df1b2f25.cpp:41
Description not yet available.
static int stddev_scale(const dvector &d, const dvector &x)
Description not yet available.
Definition: df1b2f25.cpp:26
double ndfboundp(double x, double fmin, double fmax, const double &fpen)
Derivatative code for double nd2fboundp( double x, double fmin, double fmax,const double&amp; fpen) ...
Definition: boundfun.cpp:210
Description not yet available.
Definition: df1b2fun.h:1042
virtual void sd_scale(const dvector &d, const dvector &x, const int &ii)
Description not yet available.
Definition: df1b2f25.cpp:173
int indexmax(void) const
Definition: df1b2fun.h:970
double ndfboundp_mc(double x, double fmin, double fmax, const double &fpen)
Description not yet available.
Definition: mc_scale.cpp:63
int indexmax(void) const
Definition: df1b2fun.h:1055
Description not yet available.
df1b2variable * v
Definition: df1b2fun.h:955
static int mc_phase
Definition: admodel.h:846
virtual void sd_scale(const dvector &d, const dvector &x, const int &ii)=0
int allocated(void)
Definition: df1b2fun.h:968
virtual void sd_scale(const dvector &d, const dvector &x, const int &ii)
Description not yet available.
Definition: df1b2f25.cpp:137