Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include <admodel.h>
00008
00009 void param_init_bounded_number_vector::set_initial_value(
00010 const double_index_type& _it)
00011 {
00012 if (it)
00013 {
00014 delete it;
00015 it = 0;
00016 }
00017 it = new double_index_type(_it);
00018
00019 if (v)
00020 {
00021 int mmin = indexmin();
00022 int mmax = indexmax();
00023 for (int i = mmin; i <= mmax; i++)
00024 {
00025 v[i] = ad_double(_it(i));
00026 }
00027 }
00028 }
00029
00033 param_init_bounded_number_vector::param_init_bounded_number_vector():
00034 v(NULL),
00035 index_min(0),
00036 index_max(0),
00037 it(NULL)
00038 {
00039 }
00043 param_init_bounded_number_vector::~param_init_bounded_number_vector()
00044 {
00045 deallocate();
00046 }
00050 void param_init_bounded_number_vector::deallocate(void)
00051 {
00052 if(it)
00053 {
00054 delete it;
00055 it = NULL;
00056 }
00057 if (v)
00058 {
00059 v += indexmin();
00060 delete [] v;
00061 v = NULL;
00062 }
00063 index_min = 0;
00064 index_max = 0;
00065 }
00070 void param_init_bounded_number_vector::allocate(const data_matrix &m,
00071 const char *s)
00072 {
00073 int min1 = m.rowmin();
00074 int max1 = m.rowmax();
00075 double_index_type bmin = column(m,1);
00076 double_index_type bmax = column(m,2);
00077 index_type phz1 = ivector(column(m,3));
00078 allocate(min1,max1,bmin,bmax,phz1,s);
00079 }
00080
00081 void param_init_bounded_number_vector::allocate(int min1,int max1,
00082 const double_index_type & bmin,const double_index_type & bmax,const char * s)
00083 {
00084 allocate(min1,max1,bmin,bmax,1,s);
00085 }
00086
00087 void param_init_bounded_number_vector::allocate(int min1,int max1,
00088 const double_index_type & bmin,const double_index_type & bmax,
00089 const index_type& phase_start,const char * s)
00090 {
00091 int size = max1 - min1 + 1;
00092 if (size > 0)
00093 {
00094 v = new param_init_bounded_number[size];
00095 if (!v)
00096 {
00097 cerr << " error trying to allocate memory in "
00098 "param_init_bounded_number_vector " << endl;
00099 exit(1);
00100 }
00101 index_min=min1;
00102 index_max=max1;
00103 v-=indexmin();
00104 for (int i=indexmin();i<=indexmax();i++)
00105 {
00106 if (it) v[i].set_initial_value(ad_double((*it)[i]));
00107 adstring ss=s + adstring("[") + str(i) + adstring("]");
00108 v[i].allocate(ad_double(bmin[i]),ad_double(bmax[i]),
00109 ad_integer(phase_start[i]),(char*)(ss) );
00110 }
00111 }
00112 }
00113
00114 dvector param_init_number_vector::get_scalefactor(void)
00115 {
00116 int mmin=indexmin();
00117 int mmax=indexmax();
00118 dvector s(mmin,mmax);
00119 for (int i=mmin;i<=mmax;i++)
00120 {
00121 s(i)=(*this)(i).get_scalefactor();
00122 }
00123 return s;
00124 }
00125 void param_init_number_vector::set_scalefactor(const dvector& s)
00126 {
00127 int mmin=indexmin();
00128 int mmax=indexmax();
00129 if (s.indexmin()!=mmin || s.indexmax() != mmax)
00130 {
00131 cerr << "non matching vector bounds in"
00132 " init_number_vector::set_scalefactor" << endl;
00133 ad_exit(1);
00134 }
00135
00136 for (int i=mmin;i<=mmax;i++)
00137 {
00138 (*this)(i).set_scalefactor(s(i));
00139 }
00140 }
00141
00142 void param_init_number_vector::set_scalefactor(double s)
00143 {
00144 int mmin=indexmin();
00145 int mmax=indexmax();
00146 for (int i=mmin;i<=mmax;i++)
00147 {
00148 (*this)(i).set_scalefactor(s);
00149 }
00150 }
00151
00152 dvector param_init_vector_vector::get_scalefactor(void)
00153 {
00154 int mmin=indexmin();
00155 int mmax=indexmax();
00156 dvector s(mmin,mmax);
00157 for (int i=mmin;i<=mmax;i++)
00158 {
00159 s(i)=(*this)(i).get_scalefactor();
00160 }
00161 return s;
00162 }
00163 void param_init_vector_vector::set_scalefactor(const dvector& s)
00164 {
00165 int mmin=indexmin();
00166 int mmax=indexmax();
00167 if (s.indexmin()!=mmin || s.indexmax() != mmax)
00168 {
00169 cerr << "non matching vector bounds in"
00170 " init_vector_vector::set_scalefactor" << endl;
00171 ad_exit(1);
00172 }
00173
00174 for (int i=mmin;i<=mmax;i++)
00175 {
00176 (*this)(i).set_scalefactor(s(i));
00177 }
00178 }
00179
00180 void param_init_vector_vector::set_scalefactor(double s)
00181 {
00182 int mmin=indexmin();
00183 int mmax=indexmax();
00184 for (int i=mmin;i<=mmax;i++)
00185 {
00186 (*this)(i).set_scalefactor(s);
00187 }
00188 }
00189
00190 dvector param_init_matrix_vector::get_scalefactor(void)
00191 {
00192 int mmin=indexmin();
00193 int mmax=indexmax();
00194 dvector s(mmin,mmax);
00195 for (int i=mmin;i<=mmax;i++)
00196 {
00197 s(i)=(*this)(i).get_scalefactor();
00198 }
00199 return s;
00200 }
00201 void param_init_matrix_vector::set_scalefactor(const dvector& s)
00202 {
00203 int mmin=indexmin();
00204 int mmax=indexmax();
00205 if (s.indexmin()!=mmin || s.indexmax() != mmax)
00206 {
00207 cerr << "non matching vector bounds in"
00208 " init_matrix_vector::set_scalefactor" << endl;
00209 ad_exit(1);
00210 }
00211
00212 for (int i=mmin;i<=mmax;i++)
00213 {
00214 (*this)(i).set_scalefactor(s(i));
00215 }
00216 }
00217
00218 void param_init_matrix_vector::set_scalefactor(double s)
00219 {
00220 int mmin=indexmin();
00221 int mmax=indexmax();
00222 for (int i=mmin;i<=mmax;i++)
00223 {
00224 (*this)(i).set_scalefactor(s);
00225 }
00226 }
00227
00228 dvector param_init_bounded_number_vector::get_scalefactor(void)
00229 {
00230 int mmin=indexmin();
00231 int mmax=indexmax();
00232 dvector s(mmin,mmax);
00233 for (int i=mmin;i<=mmax;i++)
00234 {
00235 s(i)=(*this)(i).get_scalefactor();
00236 }
00237 return s;
00238 }
00239 void param_init_bounded_number_vector::set_scalefactor(const dvector& s)
00240 {
00241 int mmin=indexmin();
00242 int mmax=indexmax();
00243 if (s.indexmin()!=mmin || s.indexmax() != mmax)
00244 {
00245 cerr << "non matching vector bounds in"
00246 " init_bounded_number_vector::set_scalefactor" << endl;
00247 ad_exit(1);
00248 }
00249
00250 for (int i=mmin;i<=mmax;i++)
00251 {
00252 (*this)(i).set_scalefactor(s(i));
00253 }
00254 }
00255
00256 void param_init_bounded_number_vector::set_scalefactor(double s)
00257 {
00258 int mmin=indexmin();
00259 int mmax=indexmax();
00260 for (int i=mmin;i<=mmax;i++)
00261 {
00262 (*this)(i).set_scalefactor(s);
00263 }
00264 }
00265
00266 dvector param_init_bounded_vector_vector::get_scalefactor(void)
00267 {
00268 int mmin=indexmin();
00269 int mmax=indexmax();
00270 dvector s(mmin,mmax);
00271 for (int i=mmin;i<=mmax;i++)
00272 {
00273 s(i)=(*this)(i).get_scalefactor();
00274 }
00275 return s;
00276 }
00277 void param_init_bounded_vector_vector::set_scalefactor(const dvector& s)
00278 {
00279 int mmin=indexmin();
00280 int mmax=indexmax();
00281 if (s.indexmin()!=mmin || s.indexmax() != mmax)
00282 {
00283 cerr << "non matching vector bounds in"
00284 " init_bounded_vector_vector::set_scalefactor" << endl;
00285 ad_exit(1);
00286 }
00287
00288 for (int i=mmin;i<=mmax;i++)
00289 {
00290 (*this)(i).set_scalefactor(s(i));
00291 }
00292 }
00293
00294 void param_init_bounded_vector_vector::set_scalefactor(double s)
00295 {
00296 int mmin=indexmin();
00297 int mmax=indexmax();
00298 for (int i=mmin;i<=mmax;i++)
00299 {
00300 (*this)(i).set_scalefactor(s);
00301 }
00302 }
00303
00304 dvector param_init_bounded_matrix_vector::get_scalefactor(void)
00305 {
00306 int mmin=indexmin();
00307 int mmax=indexmax();
00308 dvector s(mmin,mmax);
00309 for (int i=mmin;i<=mmax;i++)
00310 {
00311 s(i)=(*this)(i).get_scalefactor();
00312 }
00313 return s;
00314 }
00315 void param_init_bounded_matrix_vector::set_scalefactor(const dvector& s)
00316 {
00317 int mmin=indexmin();
00318 int mmax=indexmax();
00319 if (s.indexmin()!=mmin || s.indexmax() != mmax)
00320 {
00321 cerr << "non matching vector bounds in"
00322 " init_bounded_matrix_vector::set_scalefactor" << endl;
00323 ad_exit(1);
00324 }
00325
00326 for (int i=mmin;i<=mmax;i++)
00327 {
00328 (*this)(i).set_scalefactor(s(i));
00329 }
00330 }
00331
00332 void param_init_bounded_matrix_vector::set_scalefactor(double s)
00333 {
00334 int mmin=indexmin();
00335 int mmax=indexmax();
00336 for (int i=mmin;i<=mmax;i++)
00337 {
00338 (*this)(i).set_scalefactor(s);
00339 }
00340 }