ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
df1b2f24.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 
13 #include <df1b2fun.h>
14 #include <stdint.h>
15 
20 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,int cmin,int cmax,
21  double _minb,double _maxb)
22 {
23  minb=_minb;
24  maxb=_maxb;
25  df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax);
26 }
27 
32 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,int cmin,int cmax,
33  double _minb,double _maxb,const char * s)
34 {
35  minb=_minb;
36  maxb=_maxb;
37  df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,s);
38 }
39 
44 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,
45  const index_type& cmin,const index_type& cmax,double _minb,double _maxb,
46  const char * s)
47 {
48  minb=_minb;
49  maxb=_maxb;
50  df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,s);
51 }
52 
57 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,
58  const index_type& cmin,const index_type& cmax,double _minb,double _maxb,
59  int phase,const char * s)
60 {
61  minb=_minb;
62  maxb=_maxb;
63  df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,phase,s);
65 }
66 
71 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,int cmin,int cmax,
72  double _minb,double _maxb,int phase,const char * s)
73 {
74  minb=_minb;
75  maxb=_maxb;
76  df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,phase,s);
77 }
78 
83 void set_value(const df1b2matrix& _m,const init_df1b2vector& _v, const int& _ii,
84  double fmin,double fmax,const df1b2variable& fpen)
85 {
86  ADUNCONST(int,ii)
89  int min=m.indexmin();
90  int max=m.indexmax();
91  for (int i=min;i<=max;i++)
92  {
93  int cmin=m(i).indexmin();
94  int cmax=m(i).indexmax();
95  for (int j=cmin;j<=cmax;j++)
96  {
97  m(i,j)=boundp(v(ii++),fmin,fmax,fpen);
98  }
99  }
100 }
101 
102 void set_value(const df1b2matrix& _m,const init_df1b2vector& _v, const int& _ii,
103  double fmin,double fmax,const df1b2variable& fpen,double s)
104 {
105  ADUNCONST(int,ii)
108  int min=m.indexmin();
109  int max=m.indexmax();
110  for (int i=min;i<=max;i++)
111  {
112  int cmin=m(i).indexmin();
113  int cmax=m(i).indexmax();
114  for (int j=cmin;j<=cmax;j++)
115  {
116  m(i,j)=boundp(v(ii++),fmin,fmax,fpen,s);
117  }
118  }
119 }
120 
126  const int& ii,const df1b2variable& pen)
127 {
129  int ii1=ii;
131  {
132  int mmin=indexmin();
133  int mmax=indexmax();
134  for (int i=mmin;i<=mmax;i++)
135  {
136  int cmin=(*this)(i).indexmin();
137  int cmax=(*this)(i).indexmax();
138  for (int j=cmin;j<=cmax;j++)
139  {
140 #if (defined(__GNUC__) && defined(__i386)) || (defined(_MSC_VER) && defined(_M_IX86))
141  int tmp= (int)( &((*this)(i,j)) );
142 #else
143  intptr_t tmp =(intptr_t)(&((*this)(i,j)));
144 #endif
145  (*initial_df1b2params::pointer_table)(ii1)(1)=tmp;
146  (*initial_df1b2params::pointer_table)(ii1)(2)=x(ii1).ind_index;
147  ii1++;
148  }
149  }
150  }
151  if (scalefactor==0.0)
152  {
153  ::set_value(*this,x,ii,minb,maxb,pen);
154  }
155  else
156  {
157  ::set_value(*this,x,ii,minb,maxb,pen,scalefactor);
158  }
159 }
160 
166  const int& _ii,double fmin,double fmax)
167 {
168  ADUNCONST(int,ii)
170  double fpen=0.0;
171  int mmin=v.indexmin();
172  int mmax=v.indexmax();
173  for (int i=mmin;i<=mmax;i++)
174  {
175  int cmin=v(i).indexmin();
176  int cmax=v(i).indexmax();
177  for (int j=cmin;j<=cmax;j++)
178  {
179  v(i,j)=boundp(x(ii++),fmin,fmax,fpen);
180  }
181  }
182 }
183 
184 
186  const int& _ii,double fmin,double fmax,double s)
187 {
188  ADUNCONST(int,ii)
190  double fpen=0.0;
191  int mmin=v.indexmin();
192  int mmax=v.indexmax();
193  for (int i=mmin;i<=mmax;i++)
194  {
195  int cmin=v(i).indexmin();
196  int cmax=v(i).indexmax();
197  for (int j=cmin;j<=cmax;j++)
198  {
199  v(i,j)=boundp(x(ii++),fmin,fmax,fpen,s);
200  }
201  }
202 }
203 
209  const int& ii)
210 {
211  //double pen=0.0;
212  ::set_value(*this,x,ii,minb,maxb);
213 }
Uses polymorphism to get index information from various data types to be used in constructing and all...
Definition: fvar.hpp:7731
#define x
#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(void) const
Definition: df1b2fun.h:1054
void fmin(double f, const independent_variables &x, const dvector &g, const int &n, const dvector &w, const dvector &h, const fmm_control &fmc)
virtual void set_value(const dvector &x, const int &_ii)
Description not yet available.
Definition: df1b2f24.cpp:208
Description not yet available.
Definition: df1b2fun.h:266
df1b2matrix & operator=(const df3_one_matrix &)
Definition: df3fun.cpp:741
#define min(a, b)
Definition: cbivnorm.cpp:188
Description not yet available.
Definition: df1b2fun.h:1642
void set_value(const dvar_matrix &x, const dvar_vector &v, const int &_ii, double s)
Description not yet available.
Definition: set.cpp:235
Description not yet available.
Definition: df1b2fun.h:373
Description not yet available.
Definition: df1b2fun.h:1042
int indexmax(void) const
Definition: df1b2fun.h:1055
dvariable boundp(const prevariable &x, double fmin, double fmax, const prevariable &_fpen, double s)
Compute penalty for exceeding bounds on parameter; variable ojbects.
Definition: boundfun.cpp:89
Description not yet available.
static lmatrix * pointer_table
Definition: df1b2fun.h:1365
#define max(a, b)
Definition: cbivnorm.cpp:189
void allocate(void)
Description not yet available.
Definition: f1b2vc5.cpp:781