ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
model45.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  const double_index_type& _it)
11  {
12  it=new double_index_type(_it);
13  }
14 
19  v(NULL),
20  index_min(0),
21  index_max(0),
22  it(NULL)
23 {
24 }
25 
27  int min1,
28  int max1,
29  const index_type& min,
30  const index_type& max,
31  const double_index_type& dmin,
32  const double_index_type& dmax,
33  const char* s)
34 {
35  allocate(min1,max1,min,max,dmin,dmax,1,s);
36 }
37 
39  int min1,
40  int max1,
41  const index_type& min,
42  const index_type& max,
43  const double_index_type& dmin,
44  const double_index_type& dmax,
45  const index_type& phase_start,
46  const char* s)
47 {
48  int size = max1 - min1 + 1;
49  if (size > 0)
50  {
51  v = new param_init_bounded_vector[static_cast<unsigned int>(size)];
52  if (!v)
53  {
54  cerr << " error trying to allocate memory in "
55  "param_init_vector_vector " << endl;
56  ad_exit(1);
57  }
58 
59  index_min=min1;
60  index_max=max1;
61  v-=indexmin();
62  for (int i=indexmin();i<=indexmax();i++)
63  {
64  if (it) v[i].set_initial_value(ad_double((*it)[i]));
65  adstring ss=s + adstring("[") + str(i) + adstring("]");
66  v[i].allocate(ad_integer(min[i]),ad_integer(max[i]),
67  ad_double(dmin[i]),ad_double(dmax[i]),
68  ad_integer(phase_start[i]),(char*)(ss) );
69  }
70  }
71 }
76 {
77  deallocate();
78 }
83 {
84  if (it)
85  {
86  delete it;
87  it = NULL;
88  }
89  if (v)
90  {
91  v += indexmin();
92  delete [] v;
93  v = NULL;
94  }
95 }
void allocate(int min1, int max1, const index_type &min, const index_type &max, const double_index_type &dmin, const double_index_type &dmax, const index_type &phase_start, const char *s)
Definition: model45.cpp:38
Uses polymorphism to get index information from various data types to be used in constructing and all...
Definition: fvar.hpp:7731
double_index_type * it
Definition: admodel.h:2723
Stores double value.
Definition: fvar.hpp:8499
exitptr ad_exit
Definition: gradstrc.cpp:53
void set_initial_value(double x)
Definition: model.cpp:90
#define dmin(a, b)
Definition: cbivnorm.cpp:190
param_init_bounded_vector_vector()
Default constructor.
Definition: model45.cpp:18
param_init_bounded_vector * v
Definition: admodel.h:2720
#define dmax(a, b)
Definition: cbivnorm.cpp:191
Description not yet available.
Definition: admodel.h:1058
prnstream & endl(prnstream &)
#define min(a, b)
Definition: cbivnorm.cpp:188
Description not yet available.
~param_init_bounded_vector_vector()
Destructor.
Definition: model45.cpp:75
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: model45.cpp:9
Stores integer.
Definition: fvar.hpp:7654
void allocate(int imin, int imax, double _minb, double _maxb, int phasestart=1, const char *name="UNNAMED")
Definition: model.cpp:932
#define max(a, b)
Definition: cbivnorm.cpp:189
void deallocate(void)
Free member allocated memory.
Definition: model45.cpp:82
Description not yet available.
Definition: fvar.hpp:8564