ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
model44.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 
10  {
11  it=new double_index_type(_it);
12  }
13 
18  v(NULL),
19  index_min(0),
20  index_max(0),
21  it(NULL)
22 {
23 }
24 
26  int min1,
27  int max1,
28  const index_type& min,
29  const index_type& max,
30  const index_type& min2,
31  const index_type& max2,
32  const char* s)
33 {
34  allocate(min1,max1,min,max,min2,max2,1,s);
35 }
36 
38  int min1,
39  int max1,
40  const index_type& min,
41  const index_type& max,
42  const index_type& min2,
43  const index_type& max2,
44  const index_type& phase_start,
45  const char * s)
46 {
47  int size = max1 - min1 + 1;
48  if (size > 0)
49  {
50  v = new param_init_matrix[static_cast<unsigned int>(size)];
51  if (!v)
52  {
53  cerr << " error trying to allocate memory in "
54  "param_init_vector_vector " << endl;
55  ad_exit(1);
56  }
57  index_min=min1;
58  index_max=max1;
59  v-=indexmin();
60  for (int i=indexmin();i<=indexmax();i++)
61  {
62  if (it) v[i].set_initial_value(ad_double((*it)[i]));
63  adstring ss=s + adstring("[") + str(i) + adstring("]");
64  v[i].allocate(min[i],max[i],min2[i],max2[i], phase_start[i],
65  (char*)(ss));
66  }
67  }
68 }
74  const ad_integer& imin,
75  const ad_integer& imax,
76  const index_type& imin2,
77  const index_type& imax2,
78  const ad_integer& _phase_start,
79  const char* s)
80 {
81  named_dvar_matrix::allocate(imin,imax,imin2,imax2,s);
82  if (!(!(*this)))
83  {
84  initial_params::allocate(_phase_start);
86  {
88  }
89  else if (ad_comm::global_parfile)
90  {
92  }
93  else
94  {
96  }
97  }
98  else
99  {
101  }
102 }
107 {
108  deallocate();
109 }
114 {
115  if (it)
116  {
117  delete it;
118  it = NULL;
119  }
120  if (v)
121  {
122  v += indexmin();
123  delete [] v;
124  v = NULL;
125  }
126 }
void deallocate(void)
Free member allocated memory.
Definition: model44.cpp:113
Uses polymorphism to get index information from various data types to be used in constructing and all...
Definition: fvar.hpp:7731
int imax2(int a, double v)
Definition: dtweedie.cpp:5
param_init_matrix * v
Definition: admodel.h:2769
void allocate(int min0, int max0, const index_type &min, const index_type &max, const index_type &min1, const index_type &max1, const index_type &phase_start, const char *s)
Definition: model44.cpp:37
static uistream * global_bparfile
Definition: fvar.hpp:8859
void allocate(int rmin, int rmax, int cmin, int cmax, int phase_start=1, const char *="UNNAMED")
Definition: model.cpp:821
Stores double value.
Definition: fvar.hpp:8499
exitptr ad_exit
Definition: gradstrc.cpp:53
void set_initial_value(double x)
Definition: model.cpp:90
double_index_type * it
Definition: admodel.h:2772
prnstream & endl(prnstream &)
#define min(a, b)
Definition: cbivnorm.cpp:188
int indexmin() const
Definition: admodel.h:2803
void allocate(void)
Does not allocate, but initializes members.
Definition: fvar_mat.cpp:479
Description not yet available.
int indexmax() const
Definition: admodel.h:2804
Description not yet available.
Definition: admodel.h:1316
param_init_matrix_vector()
Default constructor.
Definition: model44.cpp:17
adstring str(double x, int minwidth=17, int decplaces=-1)
Convert x to adstring with minimum width and total number of decimal places.
Definition: str.cpp:25
void set_initial_value(const double_index_type &it)
Definition: model44.cpp:9
void allocate(int _phase_start)
Definition: model.cpp:117
dvar_matrix()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_mat.cpp:15
dvar_matrix & operator=(const dvar_matrix &)
Assigns other values to dvar_matrix.
Definition: fvar_mat.cpp:515
double initial_value
Definition: admodel.h:823
Stores integer.
Definition: fvar.hpp:7654
static cifstream * global_parfile
Definition: fvar.hpp:8857
#define max(a, b)
Definition: cbivnorm.cpp:189
int imin2(int a, int b)
Definition: dtweedie.cpp:10
Description not yet available.
Definition: fvar.hpp:8564
~param_init_matrix_vector()
Destructor.
Definition: model44.cpp:106