00001
00002
00003
00004
00005
00006
00007
00013 #include <df1b2fun.h>
00014 #if defined(__x86_64) || (defined(_MSC_VER) && defined(_M_X64))
00015 #include <stdint.h>
00016 #endif
00017
00022 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,int cmin,int cmax,
00023 double _minb,double _maxb)
00024 {
00025 minb=_minb;
00026 maxb=_maxb;
00027 df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax);
00028 }
00029
00034 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,int cmin,int cmax,
00035 double _minb,double _maxb,const char * s)
00036 {
00037 minb=_minb;
00038 maxb=_maxb;
00039 df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,s);
00040 }
00041
00046 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,
00047 const index_type& cmin,const index_type& cmax,double _minb,double _maxb,
00048 const char * s)
00049 {
00050 minb=_minb;
00051 maxb=_maxb;
00052 df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,s);
00053 }
00054
00059 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,
00060 const index_type& cmin,const index_type& cmax,double _minb,double _maxb,
00061 int phase,const char * s)
00062 {
00063 minb=_minb;
00064 maxb=_maxb;
00065 df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,phase,s);
00066 df1b2matrix::operator = ((minb+maxb)/2.0);
00067 }
00068
00073 void df1b2_init_bounded_matrix::allocate(int mmin,int mmax,int cmin,int cmax,
00074 double _minb,double _maxb,int phase,const char * s)
00075 {
00076 minb=_minb;
00077 maxb=_maxb;
00078 df1b2_init_matrix::allocate(mmin,mmax,cmin,cmax,phase,s);
00079 }
00080
00085 void set_value(const df1b2matrix& _m,const init_df1b2vector& _v, const int& _ii,
00086 double fmin,double fmax,const df1b2variable& fpen)
00087 {
00088 ADUNCONST(int,ii)
00089 ADUNCONST(df1b2matrix,m)
00090 ADUNCONST(init_df1b2vector,v)
00091 int min=m.indexmin();
00092 int max=m.indexmax();
00093 for (int i=min;i<=max;i++)
00094 {
00095 int cmin=m(i).indexmin();
00096 int cmax=m(i).indexmax();
00097 for (int j=cmin;j<=cmax;j++)
00098 {
00099 m(i,j)=boundp(v(ii++),fmin,fmax,fpen);
00100 }
00101 }
00102 }
00103
00104 void set_value(const df1b2matrix& _m,const init_df1b2vector& _v, const int& _ii,
00105 double fmin,double fmax,const df1b2variable& fpen,double s)
00106 {
00107 ADUNCONST(int,ii)
00108 ADUNCONST(df1b2matrix,m)
00109 ADUNCONST(init_df1b2vector,v)
00110 int min=m.indexmin();
00111 int max=m.indexmax();
00112 for (int i=min;i<=max;i++)
00113 {
00114 int cmin=m(i).indexmin();
00115 int cmax=m(i).indexmax();
00116 for (int j=cmin;j<=cmax;j++)
00117 {
00118 m(i,j)=boundp(v(ii++),fmin,fmax,fpen,s);
00119 }
00120 }
00121 }
00122
00127 void df1b2_init_bounded_matrix::set_value(const init_df1b2vector& _x,
00128 const int& ii,const df1b2variable& pen)
00129 {
00130 init_df1b2vector& x=(init_df1b2vector&) _x;
00131 int ii1=ii;
00132 if (initial_df1b2params::pointer_table)
00133 {
00134 int mmin=indexmin();
00135 int mmax=indexmax();
00136 for (int i=mmin;i<=mmax;i++)
00137 {
00138 int cmin=(*this)(i).indexmin();
00139 int cmax=(*this)(i).indexmax();
00140 for (int j=cmin;j<=cmax;j++)
00141 {
00142 #if defined(__x86_64) || (defined(_MSC_VER) && defined(_M_X64))
00143 intptr_t tmp =(intptr_t)(&((*this)(i,j)));
00144 #else
00145 int tmp= (int)( &((*this)(i,j)) );
00146 #endif
00147 (*initial_df1b2params::pointer_table)(ii1)(1)=tmp;
00148 (*initial_df1b2params::pointer_table)(ii1)(2)=x(ii1).ind_index;
00149 ii1++;
00150 }
00151 }
00152 }
00153 if (scalefactor==0.0)
00154 {
00155 ::set_value(*this,x,ii,minb,maxb,pen);
00156 }
00157 else
00158 {
00159 ::set_value(*this,x,ii,minb,maxb,pen,scalefactor);
00160 }
00161 }
00162
00167 void set_value(const df1b2_init_bounded_matrix & _v,const dvector& x,
00168 const int& _ii,double fmin,double fmax)
00169 {
00170 ADUNCONST(int,ii)
00171 ADUNCONST(df1b2_init_bounded_matrix,v)
00172 double fpen=0.0;
00173 int mmin=v.indexmin();
00174 int mmax=v.indexmax();
00175 for (int i=mmin;i<=mmax;i++)
00176 {
00177 int cmin=v(i).indexmin();
00178 int cmax=v(i).indexmax();
00179 for (int j=cmin;j<=cmax;j++)
00180 {
00181 v(i,j)=boundp(x(ii++),fmin,fmax,fpen);
00182 }
00183 }
00184 }
00185
00186
00187 void set_value(const df1b2_init_bounded_matrix & _v,const dvector& x,
00188 const int& _ii,double fmin,double fmax,double s)
00189 {
00190 ADUNCONST(int,ii)
00191 ADUNCONST(df1b2_init_bounded_matrix,v)
00192 double fpen=0.0;
00193 int mmin=v.indexmin();
00194 int mmax=v.indexmax();
00195 for (int i=mmin;i<=mmax;i++)
00196 {
00197 int cmin=v(i).indexmin();
00198 int cmax=v(i).indexmax();
00199 for (int j=cmin;j<=cmax;j++)
00200 {
00201 v(i,j)=boundp(x(ii++),fmin,fmax,fpen,s);
00202 }
00203 }
00204 }
00205
00210 void df1b2_init_bounded_matrix::set_value(const dvector& x,
00211 const int& ii)
00212 {
00213
00214 ::set_value(*this,x,ii,minb,maxb);
00215 }