ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
model47.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  }
17  v(NULL),
18  index_min(0),
19  index_max(0),
20  it(NULL)
21 {
22 }
27 {
28  deallocate();
29 }
34 {
35  if(it)
36  {
37  delete it;
38  it = NULL;
39  }
40  if (v)
41  {
42  v+=indexmin();
43  delete [] v;
44  v = NULL;
45  }
46 }
47 
49  int min1,
50  int max1,
51  const char* s)
52 {
53  allocate(min1,max1,1,s);
54 }
55 
57  int min1,
58  int max1,
59  const index_type& phase_start,
60  const char* s)
61 {
62  int size = max1 - min1 + 1;
63  if (size > 0)
64  {
65  v = new param_init_number[static_cast<unsigned int>(size)];
66  if (!v)
67  {
68  cerr << " error trying to allocate memory in "
69  "param_init_vector_vector " << endl;
70  ad_exit(1);
71  }
72 
73  index_min=min1;
74  index_max=max1;
75  v-=indexmin();
76  for (int i=indexmin();i<=indexmax();i++)
77  {
78  if (it) v[i].set_initial_value(ad_double((*it)[i]));
79  adstring ss=s + adstring("[") + str(i) + adstring("]");
80  v[i].allocate(ad_integer(phase_start[i]),(char*)(ss) );
81  }
82  }
83 }
84 
86  {
88  const int min = t.indexmin();
89  const int max = t.indexmax();
90  dvector vt(min, max);
91  for (int i = min; i <= max; i++)
92  {
93  vt(i) = value(t(i));
94  }
95  return vt;
96  }
97 
99  {
101  const int min = t.indexmin();
102  const int max = t.indexmax();
103  dvector vt(min, max);
104  for (int i = min; i <= max; i++)
105  {
106  vt(i) = value(t(i));
107  }
108  return vt;
109  }
void set_initial_value(const double_index_type &it)
Definition: model47.cpp:9
void allocate(int min1, int max1, const index_type &phase_start, const char *s)
Definition: model47.cpp:56
Uses polymorphism to get index information from various data types to be used in constructing and all...
Definition: fvar.hpp:7731
#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() const
Definition: admodel.h:2901
Description not yet available.
Definition: admodel.h:1151
Stores double value.
Definition: fvar.hpp:8499
exitptr ad_exit
Definition: gradstrc.cpp:53
void set_initial_value(double x)
Definition: model.cpp:90
param_init_number_vector()
Default constructor.
Definition: model47.cpp:16
prnstream & endl(prnstream &)
#define min(a, b)
Definition: cbivnorm.cpp:188
~param_init_number_vector()
Destructor.
Definition: model47.cpp:26
Description not yet available.
void deallocate(void)
Free member allocated memory.
Definition: model47.cpp:33
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
param_init_number * v
Definition: admodel.h:2875
void allocate(int phase_start=1, const char *s="UNNAMED")
Definition: model.cpp:629
Description not yet available.
Definition: admodel.h:2873
int indexmax() const
Definition: admodel.h:2902
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
Stores integer.
Definition: fvar.hpp:7654
#define max(a, b)
Definition: cbivnorm.cpp:189
Class object for init_bounded_number vector.
Definition: admodel.h:2915
Description not yet available.
Definition: fvar.hpp:8564
double_index_type * it
Definition: admodel.h:2878