ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
model2.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 
11 
12 // this should be a resizeable array
14 // this should be a resizeable array
16 
18  {
19  if (num_stddev_params>=150)
20  {
21  cerr << "This version of ADMB only supports " << num_stddev_params
22  << " stddev_params." << endl;
23  ad_exit(1);
24  }
25  stddevptr[num_stddev_params++]= this; // this is the list of
26  }
27 
29  {
30  if (num_stddev_number_params>=150)
31  {
32  cerr << "This version of ADMB only supports " << num_stddev_params
33  << " stddev_params." << endl;
34  ad_exit(1);
35  }
36  stddev_number_ptr[num_stddev_number_params++]= this; // this is the list of
37  }
38 
40  {
42  ivector no(1,ndv);
43  for (int i=0;i<ndv;i++)
44  {
45  no(i+1)=stddev_number_ptr[i]->getindex();
46  }
47  return no;
48  }
49 
50 
52  {
53  int nvar=0;
54  for (int i=0;i<num_stddev_params;i++)
55  {
56  nvar+= (stddevptr[i])->size_count();
57  }
58  return nvar;
59  }
60 
61  void stddev_params::setindex(int _index){;}
62  int stddev_params::getindex(void){return 0;}
63 
65  {
66  return index;
67  }
69  {
70  index=_index;
71  }
72 
74  {
75  int offset=1;
76  int ii=0;
77  for (int i=0;i<num_stddev_params;i++)
78  {
79  if (stddevptr[i]==stddev_number_ptr[ii])
80  {
81  stddev_number_ptr[ii]->setindex(offset);
82  if (++ii>=num_stddev_number_params) break;
83  }
84  offset+= (stddevptr[i])->size_count();
85  }
86  }
87 
89  {
91  }
92 
98  stddev_params(),
99  sd(0)
100 {
101  add_to_list();
102  add_to_gui_list();
103  setindex(0);
104 }
105 
110 {
111  return 1;
112 }
113 
115  {
116  #ifndef __ZTC__
117  dvariable(*this) << dvariable(*this);
118  #else
119  *this << *this;
120  #endif
121  }
122 
123 
124  void param_stddev_number::allocate(const char * _s)
125  {
128  }
129 
134 {
135  return ::size_count(*this);
136 }
137 
139  stddev_params()
140  {
141  add_to_list();
142  }
143 
144  void param_stddev_vector::allocate(int imin,int imax,const char * s)
145  {
146  sd.allocate(imin,imax);
147  named_dvar_vector::allocate(imin,imax,s);
149  }
150 
152  {
153  dvar_vector(*this) << dvar_vector(*this);
154  }
155 
157  stddev_params()
158  {
159  add_to_list();
160  }
161 
166 {
167  return ::size_count(*this);
168 }
169 
170  void param_stddev_matrix::allocate(int rmin,int rmax,int cmin,int cmax,
171  const char * s)
172  {
173  sd.allocate(rmin,rmax,cmin,cmax);
174  named_dvar_matrix::allocate(rmin,rmax,cmin,cmax,s);
176  }
177 
179  {
180  dvar_matrix(*this) << dvar_matrix(*this);
181  }
182 
183 
184 /*
185 dvar_vector& operator<<(const dvar_vector& v, const dvar_vector& w)
186 {
187  int mmin=v.indexmin();
188  int mmax=v.indexmax();
189  for (int i=mmin;i<=mmax;i++)
190  {
191  v[i] << w[i];
192  }
193  return v;
194 }
195 
196 dvar_matrix& operator<<(const dvar_matrix& v, const dvar_matrix& w)
197 {
198  int mmin=v.rowmin();
199  int mmax=v.rowmax();
200  for (int i=mmin;i<=mmax;i++)
201  {
202  v[i] << w[i];
203  }
204  return v;
205 }
206 */
207 
208  const char * param_stddev_vector::label(void)
209  {
210  return model_name_tag::label().mychar();
211  }
212 
213  const char * param_stddev_number::label(void)
214  {
215  return model_name_tag::label().mychar();
216  }
217 
218  const char * param_stddev_matrix::label(void)
219  {
220  return model_name_tag::label().mychar();
221  }
222 
223  /*
224 class param_stddev_number: public named_dvariable , stddev_params
225 {
226  param_stddev_number& operator=(const prevariable&);
227  param_stddev_number& operator = (CGNU_DOUBLE);
228  void allocate(const char *s="UNNAMED");
229  virtual int size_count(void); // get the number of active parameters
230  virtual const char * label(void);
231  param_stddev_number();
232  friend class model_parameters;
233  virtual void set_dependent_variables(void);
234 };
235 
236 class param_stddev_matrix: public named_dvar_matrix , stddev_params
237 {
238  virtual int size_count(void);
239  //virtual void read_value(void);
240  virtual const char * label(void);
241  void allocate(int rmin,int rmax,int cmin,int cmax,
242  const char * s="UNNAMED");
243  param_stddev_matrix(void);
244  friend class model_parameters;
245  virtual void set_dependent_variables(void);
246 };
247 */
param_stddev_matrix(void)
Definition: model2.cpp:156
dvar_vector()
Default constructor.
Definition: fvar_arr.cpp:150
Description not yet available.
Definition: admodel.h:2211
label_class label(void)
Definition: admodel.h:172
void allocate(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat0.cpp:8
virtual unsigned int size_count() const
Return number of active paramters.
Definition: model2.cpp:133
virtual unsigned int size_count() const
Returns the number of active parameters.
Definition: model2.cpp:109
Description not yet available.
Definition: admodel.h:242
const char * mychar(void)
Definition: admodel.h:156
virtual void setindex(int)
Definition: model2.cpp:68
void allocate(int ncl, int ncu)
Allocate memory for a dvector.
Definition: dvector.cpp:409
void allocate(void)
Does not allocate, but initializes dvar_vector to empty.
Definition: fvar_arr.cpp:216
virtual void setindex(int)
Definition: model2.cpp:61
exitptr ad_exit
Definition: gradstrc.cpp:53
void allocate(void)
Definition: admodel.h:2222
static int num_stddev_calc(void)
Definition: model2.cpp:51
virtual void set_dependent_variables(void)
Definition: model2.cpp:178
dvariable()
Default constructor.
Definition: fvar.hpp:1526
Description not yet available.
Definition: admodel.h:271
virtual unsigned int size_count() const =0
virtual void set_dependent_variables(void)
Definition: model2.cpp:151
static int num_stddev_number_calc(void)
Definition: model2.cpp:88
prnstream & endl(prnstream &)
virtual void add_to_gui_list(void)
Definition: model2.cpp:28
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
virtual void set_dependent_variables(void)
Definition: model2.cpp:114
static void get_stddev_number_offset(void)
Definition: model2.cpp:73
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
Description not yet available.
Definition: admodel.h:180
virtual const char * label(void)
Definition: model2.cpp:218
virtual unsigned int size_count() const
Returns the number of active parameters.
Definition: model2.cpp:165
param_stddev_number()
Default constructor.
Definition: model2.cpp:96
static stddev_params * stddev_number_ptr[150]
Definition: admodel.h:2217
dvar_matrix()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_mat.cpp:15
static stddev_params * stddevptr[150]
Definition: admodel.h:2215
virtual int getindex(void)
Definition: model2.cpp:62
static ivector copy_all_number_offsets(void)
Definition: model2.cpp:39
virtual void add_to_list(void)
Definition: model2.cpp:17
unsigned int size_count(const dvector &x)
Returns total size of elements in vector x.
Definition: dsize.cpp:17
virtual const char * label(void)
Definition: model2.cpp:213
static int num_stddev_number_params
Definition: admodel.h:2220
virtual int getindex(void)
Definition: model2.cpp:64
static int num_stddev_params
Definition: admodel.h:2219
virtual const char * label(void)
Definition: model2.cpp:208