ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
model31.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  */
7 #include <admodel.h>
8 
9 void dll_data_int::allocate(int *_pi,const char * _s)
10 {
12  pi=_pi;
13  val=*_pi;
14 }
15 
16 void dll_data_number::allocate(double *_pd,const char * _s)
17 {
19  pd=_pd;
20  val=*_pd;
21 }
22 
24 {
26  return *this;
27 }
29 {
31  return *this;
32 }
33 
35 {
37  return *this;
38 }
39 
48  (double * _pd,int _phase_start,const char *_s)
49 {
51  initial_params::allocate(_phase_start);
52  pd=_pd;
53  value(*this)=*_pd;
54 }
55 
57  (double * _pd,const char *_s)
58 {
60  pd=_pd;
61  value(*this)=*_pd;
62 }
71  double* _pd,
72  const char* _s)
73 {
74  allocate(_pd, 1, _s);
75 }
82 {
84  return *this;
85 }
92 {
94  return *this;
95 }
96 
98 {
100  return (*this);
101 }
102 
104 {
106  return (*this);
107 }
108 
109 dll_param_init_vector& dll_param_init_vector::operator =
110  (const prevariable& x)
111 {
113  return (*this);
114 }
115 
117 {
119  return (*this);
120 }
121 
122 void dll_param_init_vector::allocate(double * _pd,int imin,int imax,
123  int _phase_start,const char * _s)
124 {
125  pd=_pd;
126  named_dvar_vector::allocate(imin,imax,_s);
127  if (pd && allocated(*this))
128  {
129  initial_params::allocate(_phase_start);
130  double * tmp=_pd;
131  for (int i=imin;i<=imax;i++)
132  {
133  (*this)[i]=*tmp++;
134  }
135  }
136 }
137 
139 {
141  return *this;
142 }
143 
145 {
147  return *this;
148 }
149 
151 {
153  return *this;
154 }
155 
157 {
159  return *this;
160 }
161 
162 void dll_param_vector::allocate(double *_pd,int imin,int imax,
163  const char * _s)
164 {
165  pd=_pd;
166  named_dvar_vector::allocate(imin,imax,_s);
167  if (pd && allocated(*this))
168  {
169  double * tmp=_pd;
170  for (int i=imin;i<=imax;i++)
171  {
172  (*this)[i]=*tmp++;
173  }
174  }
175 }
176 void dll_param_init_vector::allocate(double * _pd,int imin,int imax,
177  const char * _s)
178 {
179  allocate(_pd,imin,imax,1,_s);
180 }
181 
182 void dll_data_vector::allocate(double * _pd,int imin,int imax,const char * _s)
183 {
184  pd=_pd;
185  named_dvector::allocate(imin,imax,_s);
186  if (pd && allocated())
187  {
188  double * tmp=_pd;
189  for (int i=imin;i<=imax;i++)
190  {
191  (*this)[i]=*tmp++;
192  }
193  }
194 }
196 {
198  return (*this);
199 }
200 
202 {
204  return (*this);
205 }
206 
207 void dll_data_matrix::allocate(double * _d,int rmin,int rmax,
208  int cmin,int cmax,const char * _s)
209 {
210  d=_d;
211  named_dmatrix::allocate(rmin,rmax,cmin,cmax,_s);
212  if (d && allocated(*this))
213  {
214  double * tmp=_d;
215  if (!AD_gaussflag)
216  {
217  for (int j=cmin;j<=cmax;j++)
218  {
219  for (int i=rmin;i<=rmax;i++)
220  {
221  (*this)(i,j)=*tmp++;
222  }
223  }
224  }
225  else
226  {
227  for (int i=rmin;i<=rmax;i++)
228  {
229  for (int j=cmin;j<=cmax;j++)
230  {
231  (*this)(i,j)=*tmp++;
232  }
233  }
234  }
235  }
236 }
237 
243 {
245  return *this;
246 }
252 {
253  data_matrix::operator=(value);
254  return *this;
255 }
256 
257 void dll_param_init_matrix::allocate(double* _d,int rmin,int rmax,
258  int cmin,int cmax,const char *_s )
259 {
260  allocate(_d,rmin,rmax,cmin,cmax,1,_s );
261 }
262 
263 
264 void dll_param_init_matrix::allocate(double* _d,int rmin,int rmax,
265  int cmin,int cmax,int _phase_start,const char *_s )
266 {
267  d=_d;
268  named_dvar_matrix::allocate(rmin,rmax,cmin,cmax,_s);
269  initial_params::allocate(_phase_start);
270  if (d && allocated(*this))
271  {
272  double * tmp=_d;
273  if (!AD_gaussflag)
274  {
275  for (int j=cmin;j<=cmax;j++)
276  {
277  for (int i=rmin;i<=rmax;i++)
278  {
279  (*this)(i,j)=*tmp++;
280  }
281  }
282  }
283  else
284  {
285  for (int i=rmin;i<=rmax;i++)
286  {
287  for (int j=cmin;j<=cmax;j++)
288  {
289  (*this)(i,j)=*tmp++;
290  }
291  }
292  }
293  }
294 }
295 
296 void dll_param_matrix::allocate(double* _pd,int rmin,int rmax,
297  int cmin,int cmax,const char *_s )
298 {
299  pd=_pd;
300  named_dvar_matrix::allocate(rmin,rmax,cmin,cmax,_s);
301  if (pd && allocated(*this))
302  {
303  double * tmp=_pd;
304  if (!AD_gaussflag)
305  {
306  for (int j=cmin;j<=cmax;j++)
307  {
308  for (int i=rmin;i<=rmax;i++)
309  {
310  (*this)(i,j)=*tmp++;
311  }
312  }
313  }
314  else
315  {
316  for (int i=rmin;i<=rmax;i++)
317  {
318  for (int j=cmin;j<=cmax;j++)
319  {
320  (*this)(i,j)=*tmp++;
321  }
322  }
323  }
324  }
325 }
326 
327 void dll_param_init_bounded_number::allocate(double *_pd,double _minb,
328  double _maxb,const char * _s)
329 {
330  allocate(_pd,_minb,_maxb,1,_s);
331 }
332 
333 void dll_param_init_bounded_number::allocate(double *_pd,double _minb,
334  double _maxb,int _phase_start,const char * _s)
335 {
336  pd=_pd;
337  minb=_minb;
338  maxb=_maxb;
340  initial_params::allocate(_phase_start);
341  {
342  if (!pd)
344  else
345  {
346  double iv=*pd;
347  if ( iv <=minb || iv >= maxb)
348  {
350  }
351  else
352  {
354  }
355  }
356  }
357 }
358 
369  int imin, int imax, double _minb, double _maxb,
370  int _phase_start, const char* s)
371 {
372  pd=_pd;
373  minb=_minb;
374  maxb=_maxb;
375  named_dvar_vector::allocate(imin,imax,s);
376  initial_params::allocate(_phase_start);
377  if (pd && allocated(*this))
378  {
379  double * tmp=_pd;
380  for (int i=imin;i<=imax;i++)
381  {
382  double td=*tmp++;
383  if (td<minb || td>maxb) td=(minb+maxb)/2.;
384  (*this)[i]=td;
385  }
386  }
387 }
388 
389 void dll_param_init_bounded_vector::allocate(double* _pd,int imin,int imax,
390  double _minb,double _maxb,const char * s)
391 {
392  allocate(_pd,imin,imax,_minb,_maxb,1,s);
393 }
394 
396 {
397  param_matrix::operator=(varmat);
398  return *this;
399 }
401 {
402  param_matrix::operator=(value);
403  return *this;
404 }
406 {
407  param_matrix::operator=(var);
408  return *this;
409 }
411 {
412  param_matrix::operator=(mat);
413  return *this;
414 }
416 {
418  return *this;
419 }
421  const dvar_matrix& varmat)
422 {
424  return *this;
425 }
427 {
429  return *this;
430 }
432 {
434  return *this;
435 }
double val
Definition: admodel.h:1806
dll_data_matrix & operator=(const dmatrix &m)
Assign values from mat to elements of dll_data_matrix.
Definition: model31.cpp:242
Base class for dvariable.
Definition: fvar.hpp:1315
void allocate(double *_pd, double _minb, double _maxb, int phase_start=1, const char *s="UNNAMED")
Definition: model31.cpp:333
int allocated(void) const
Returns 1 (TRUE) if memory is allocated.
Definition: dvector.h:71
void allocate(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat0.cpp:8
data_matrix & operator=(const dmatrix &m)
Assign data_matrix with values.
Definition: model11.cpp:534
void allocate(int *_pi, const char *s)
Definition: model31.cpp:9
#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
Vector of double precision numbers.
Definition: dvector.h:50
dll_param_vector & operator=(const dvar_vector &m)
Definition: model31.cpp:138
void val(const adstring &s, int &v, int &code)
Definition: val.cpp:11
dll_data_number & operator=(const double &m)
Definition: model31.cpp:23
int AD_gaussflag
Definition: model.cpp:27
void allocate(void)
Does not allocate, but initializes dvar_vector to empty.
Definition: fvar_arr.cpp:216
void allocate(double *pd, int phase_start=1, const char *s="UNNAMED")
Allocate param_init_number and sets pd = _pd.
Definition: model31.cpp:48
void allocate(void)
Allocate dvector without allocating memory.
Definition: dvector.cpp:495
ADMB variable vector.
Definition: fvar.hpp:2172
param_init_vector & operator=(const dvector &)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: model20.cpp:13
Description not yet available.
Definition: admodel.h:1776
void allocate(double *_pd, const char *s)
Definition: model31.cpp:16
double * pd
Definition: admodel.h:1823
Description not yet available.
Definition: admodel.h:1820
void allocate(const char *s)
Definition: model.cpp:112
dll_param_init_vector & operator=(const dvector &)
Definition: model31.cpp:97
double * pd
Definition: admodel.h:228
double var(const dvector &vec)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: cranfill.cpp:23
data_vector & operator=(const dvector &m)
Definition: model11.cpp:186
int val
Definition: admodel.h:1477
void allocate(void)
Does not allocate, but initializes members.
Definition: fvar_mat.cpp:479
Description not yet available.
void allocate(const char *s)
Definition: model.cpp:583
double * pd
Definition: admodel.h:295
Description not yet available.
Definition: fvar.hpp:2819
dll_param_init_matrix & operator=(const dmatrix &m)
Definition: model31.cpp:415
Description not yet available.
Definition: admodel.h:1610
dll_param_init_number & operator=(const double m)
Assigns val to parameter value.
Definition: model31.cpp:81
Description not yet available.
Definition: admodel.h:256
Description not yet available.
Definition: admodel.h:293
dvariable & operator=(const double x)
Assigns a value to a dvariable object.
Definition: fvar.hpp:1595
void allocate(int _phase_start)
Definition: model.cpp:117
dll_param_matrix & operator=(const dvariable &m)
Definition: model31.cpp:405
prevariable & operator=(const prevariable &)
Assigns a value to a prevariable object.
Definition: fvar_o10.cpp:61
double * d
Definition: admodel.h:1612
Description not yet available.
Definition: admodel.h:1206
double * pd
Definition: admodel.h:1779
dll_param_number & operator=(const prevariable &m)
Definition: model31.cpp:28
int * pi
Definition: admodel.h:1580
param_init_matrix & operator=(const dmatrix &m)
Assigns values from mat to param_init_matrix.
Definition: model20.cpp:81
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
Description not yet available.
Definition: admodel.h:226
data_number & operator=(const double &m)
Definition: model.cpp:570
dvar_vector & operator=(const dvar_vector &t)
Assign values from other t to dvar_vector.
Definition: fvar_a20.cpp:31
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
Description not yet available.
Definition: admodel.h:1033
Description not yet available.
Definition: admodel.h:1389
dll_data_vector & operator=(const dvector &x)
Definition: model31.cpp:195
void allocate(double *_d, const char *s)
Definition: model31.cpp:57
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518