C-XSC - A C++ Class Library for Extended Scientific Computing
2.5.4
|
00001 /* 00002 ** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4) 00003 ** 00004 ** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik, 00005 ** Universitaet Karlsruhe, Germany 00006 ** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie 00007 ** Universitaet Wuppertal, Germany 00008 ** 00009 ** This library is free software; you can redistribute it and/or 00010 ** modify it under the terms of the GNU Library General Public 00011 ** License as published by the Free Software Foundation; either 00012 ** version 2 of the License, or (at your option) any later version. 00013 ** 00014 ** This library is distributed in the hope that it will be useful, 00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 ** Library General Public License for more details. 00018 ** 00019 ** You should have received a copy of the GNU Library General Public 00020 ** License along with this library; if not, write to the Free 00021 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 00024 /* CVS $Id: intmatrix.inl,v 1.19 2014/01/30 17:23:45 cxsc Exp $ */ 00025 00026 #ifndef _CXSC_INTMATRIX_INL_INCLUDED 00027 #define _CXSC_INTMATRIX_INL_INCLUDED 00028 00029 namespace cxsc { 00030 00031 INLINE intmatrix::intmatrix() throw():dat(NULL),lb1(1),ub1(0),lb2(1),ub2(0),xsize(0),ysize(0) 00032 { 00033 } 00034 00035 INLINE intmatrix::intmatrix(const int &r) throw():lb1(1),ub1(1),lb2(1),ub2(1),xsize(1),ysize(1) 00036 { 00037 dat=new int[1]; 00038 *dat=r; 00039 } 00040 00041 INLINE intmatrix::intmatrix(const intmatrix &rm) throw():lb1(rm.lb1),ub1(rm.ub1),lb2(rm.lb2),ub2(rm.ub2),xsize(rm.xsize),ysize(rm.ysize) 00042 { 00043 dat=new int[xsize*ysize]; 00044 for(int i=0;i<xsize*ysize;i++) 00045 dat[i]=rm.dat[i]; 00046 } 00047 00048 INLINE intmatrix::intmatrix(const int &m, const int &n) 00049 #if(CXSC_INDEX_CHECK) 00050 throw(ERROR_INTMATRIX_WRONG_BOUNDARIES):lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m) 00051 #else 00052 throw():lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m) 00053 #endif 00054 { 00055 #if(CXSC_INDEX_CHECK) 00056 if((n<0)||(m<0)) cxscthrow(ERROR_INTMATRIX_WRONG_BOUNDARIES("intmatrix::intmatrix(const int &m, const int &n)")); 00057 #endif 00058 dat=new int[m*n]; 00059 } 00060 00061 INLINE intmatrix::intmatrix(const int &m1, const int &m2, const int &n1, const int &n2) 00062 #if(CXSC_INDEX_CHECK) 00063 throw(ERROR_INTMATRIX_WRONG_BOUNDARIES):lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1) 00064 #else 00065 throw():lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1) 00066 #endif 00067 { 00068 #if(CXSC_INDEX_CHECK) 00069 if((m2<m1)||(n2<n1)) cxscthrow(ERROR_INTMATRIX_WRONG_BOUNDARIES("intmatrix::intmatrix(const int &m1, const int &n1, const int &m2, const int &n2)")); 00070 #endif 00071 dat=new int[xsize*ysize]; 00072 } 00073 00074 INLINE intvector::intvector(const intmatrix_subv &v) throw():l(v.lb),u(v.ub),size(v.size) 00075 { 00076 dat=new int[size]; 00077 for (int i=0, j=v.start;i<v.size;i++,j+=v.offset) 00078 dat[i]=v.dat[j]; 00079 } 00080 00081 INLINE intmatrix::intmatrix(const intvector &v) throw():lb1(v.l),ub1(v.u),lb2(1),ub2(1),xsize(1),ysize(v.size) 00082 { 00083 dat=new int[v.size]; 00084 for(int i=0;i<v.size;i++) 00085 dat[i]=v.dat[i]; 00086 } 00087 00088 INLINE intmatrix::intmatrix(const intvector_slice &v) throw():lb1(v.start),ub1(v.end),lb2(1),ub2(1),xsize(1),ysize(v.size) 00089 { 00090 dat=new int[v.size]; 00091 for(int i=0,j=v.start-v.l;i<v.size;i++,j++) 00092 dat[i]=v.dat[j]; 00093 } 00094 00095 INLINE int &intmatrix_subv::operator [](const int &i) const 00096 #if(CXSC_INDEX_CHECK) 00097 throw(ERROR_INTVECTOR_ELEMENT_NOT_IN_VEC) 00098 #else 00099 throw() 00100 #endif 00101 { 00102 #if(CXSC_INDEX_CHECK) 00103 if((i<lb)||(i>ub)) cxscthrow(ERROR_INTVECTOR_ELEMENT_NOT_IN_VEC("int &intmatrix_subv::operator [](const int &i)")); 00104 #endif 00105 return dat[start+((i-lb)*offset)]; 00106 } 00107 00108 INLINE intmatrix::intmatrix(const intmatrix_slice &sl) throw():lb1(sl.start1),ub1(sl.end1),lb2(sl.start2),ub2(sl.end2),xsize(sl.sxsize),ysize(sl.sysize) 00109 { 00110 int i,j; 00111 00112 dat=new int[xsize*ysize]; 00113 for (i=0;i<ysize;i++) 00114 { 00115 for(j=0;j<xsize;j++) 00116 { 00117 dat[i*xsize+j]=sl.dat[(sl.offset1+i)*sl.mxsize+sl.offset2+j]; 00118 } 00119 } 00120 } 00121 00122 INLINE intmatrix_subv Row(intmatrix &m,const int &i) 00123 #if(CXSC_INDEX_CHECK) 00124 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT) 00125 #else 00126 throw() 00127 #endif 00128 00129 { 00130 return m[i]; 00131 } 00132 00133 INLINE intmatrix_subv Col(intmatrix &m,const int &i) 00134 #if(CXSC_INDEX_CHECK) 00135 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT) 00136 #else 00137 throw() 00138 #endif 00139 00140 { 00141 return m[Col(i)]; 00142 } 00143 00144 INLINE intmatrix_subv Row(const intmatrix &m,const int &i) 00145 #if(CXSC_INDEX_CHECK) 00146 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT) 00147 #else 00148 throw() 00149 #endif 00150 00151 { 00152 return m[i]; 00153 } 00154 00155 INLINE intmatrix_subv Col(const intmatrix &m,const int &i) 00156 #if(CXSC_INDEX_CHECK) 00157 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT) 00158 #else 00159 throw() 00160 #endif 00161 00162 { 00163 return m[Col(i)]; 00164 } 00165 00166 INLINE intmatrix_subv intmatrix::operator [](const int &i) const 00167 #if(CXSC_INDEX_CHECK) 00168 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT) 00169 #else 00170 throw() 00171 #endif 00172 { 00173 #if(CXSC_INDEX_CHECK) 00174 if((i<lb1)||(i>ub1)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT("intmatrix_subv intmatrix::operator [](const int &i)")); 00175 #endif 00176 return intmatrix_subv(dat, lb2, ub2, xsize, xsize*(i-lb1),1); 00177 } 00178 00179 INLINE intmatrix_subv intmatrix::operator [](const cxscmatrix_column &i) const 00180 #if(CXSC_INDEX_CHECK) 00181 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT) 00182 #else 00183 throw() 00184 #endif 00185 { 00186 #if(CXSC_INDEX_CHECK) 00187 if((i.col()<lb2)||(i.col()>ub2)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT("intmatrix_subv intmatrix::operator [](const cxscmatrix_column &i)")); 00188 #endif 00189 return intmatrix_subv(dat, lb1, ub1, ysize, i.col()-lb2, xsize); 00190 } 00191 00192 INLINE intmatrix_slice intmatrix::operator ()(const int &m, const int &n) 00193 #if(CXSC_INDEX_CHECK) 00194 throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG) 00195 #else 00196 throw() 00197 #endif 00198 { 00199 #if(CXSC_INDEX_CHECK) 00200 if((m<1)||(n<1)||(m<lb1)||(n<lb2)||(m>ub1)||(n>ub2)) cxscthrow(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG("intmatrix_slice intmatrix::operator ()(const int &m, const int &n)")); 00201 #endif 00202 return intmatrix_slice(*this,1,m,1,n); 00203 } 00204 00205 INLINE intmatrix_slice intmatrix::operator ()(const int &m1, const int &m2, const int &n1, const int &n2) 00206 #if(CXSC_INDEX_CHECK) 00207 throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG) 00208 #else 00209 throw() 00210 #endif 00211 { 00212 #if(CXSC_INDEX_CHECK) 00213 if((m1<lb1)||(n1<lb2)||(m2>ub1)||(n2>ub2)) cxscthrow(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG("intmatrix_slice intmatrix::operator ()(const int &m1, const int &n1, const int &m2, const int &n2)")); 00214 #endif 00215 return intmatrix_slice(*this,m1,m2,n1,n2); 00216 } 00217 00218 INLINE intmatrix_subv intmatrix_slice::operator [](const int &i) 00219 #if(CXSC_INDEX_CHECK) 00220 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT) 00221 #else 00222 throw() 00223 #endif 00224 { 00225 #if(CXSC_INDEX_CHECK) 00226 if((i<start1)||(i>end1)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT("intmatrix_subv intmatrix_slice::operator [](const int &i)")); 00227 #endif 00228 return intmatrix_subv(dat, start2, end2, sxsize, mxsize*(i-start1+offset1)+offset2,1); 00229 } 00230 00231 INLINE intmatrix_subv intmatrix_slice::operator [](const cxscmatrix_column &i) 00232 #if(CXSC_INDEX_CHECK) 00233 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT) 00234 #else 00235 throw() 00236 #endif 00237 { 00238 #if(CXSC_INDEX_CHECK) 00239 if((i.col()<start2)||(i.col()>end2)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT("intmatrix_subv intmatrix_slice::operator [](const cxscmatrix_column &i)")); 00240 #endif 00241 return intmatrix_subv(dat, start1, end1, sysize, offset1*mxsize+i.col()-start2+offset2, mxsize); 00242 } 00243 00244 INLINE intmatrix_slice intmatrix_slice::operator ()(const int &m, const int &n) 00245 #if(CXSC_INDEX_CHECK) 00246 throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG) 00247 #else 00248 throw() 00249 #endif 00250 { 00251 #if(CXSC_INDEX_CHECK) 00252 if((m<1)||(n<1)||(m<start1)||(n<start2)||(m>end1)||(n>end2)) cxscthrow(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG("intmatrix_slice intmatrix_slice::operator ()(const int &m, const int &n)")); 00253 #endif 00254 return intmatrix_slice(*this,1,m,1,n); 00255 } 00256 00257 INLINE intmatrix_slice intmatrix_slice::operator ()(const int &m1, const int &m2, const int &n1, const int &n2) 00258 #if(CXSC_INDEX_CHECK) 00259 throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG) 00260 #else 00261 throw() 00262 #endif 00263 { 00264 #if(CXSC_INDEX_CHECK) 00265 if((m1<start1)||(n1<start2)||(m2>end1)||(n2>end2)) cxscthrow(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG("intmatrix_slice intmatrix_slice::operator ()(const int &m1, const int &m2, const int &n1, const int &n2)")); 00266 #endif 00267 return intmatrix_slice(*this,m1,m2,n1,n2); 00268 } 00269 00270 INLINE intmatrix_subv intmatrix_subv::operator ()(const int &i) 00271 #if(CXSC_INDEX_CHECK) 00272 throw(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG) 00273 #else 00274 throw() 00275 #endif 00276 { 00277 #if(CXSC_INDEX_CHECK) 00278 if(1<lb||i>ub) cxscthrow(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG("intmatrix_subv intmatrix_subv::operator ()(const int &i)")); 00279 #endif 00280 return intmatrix_subv(dat,1,i,i,start+(1-lb)*offset,offset); 00281 } 00282 00283 INLINE intmatrix_subv intmatrix_subv::operator ()(const int &i1,const int &i2) 00284 #if(CXSC_INDEX_CHECK) 00285 throw(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG) 00286 #else 00287 throw() 00288 #endif 00289 { 00290 #if(CXSC_INDEX_CHECK) 00291 if(i1<lb||i2>ub) cxscthrow(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG("intmatrix_subv intmatrix_subv::operator ()(const int &i1,const int &i2)")); 00292 #endif 00293 return intmatrix_subv(dat,i1,i2,i2-i1+1,start+(i1-lb)*offset,offset); 00294 } 00295 00296 INLINE intmatrix_subv &intmatrix_subv::operator =(const intmatrix_subv &rv) throw() { return _mvmvassign(*this,rv); } 00297 INLINE intmatrix_subv &intmatrix_subv::operator =(const int &r) throw() { return _mvsassign(*this,r); } 00298 INLINE intmatrix_subv &intmatrix_subv::operator =(const intvector &v) 00299 #if(CXSC_INDEX_CHECK) 00300 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00301 #else 00302 throw() 00303 #endif 00304 { return _mvvassign(*this,v); } 00305 INLINE intmatrix_subv &intmatrix_subv::operator =(const intvector_slice &v) 00306 #if(CXSC_INDEX_CHECK) 00307 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00308 #else 00309 throw() 00310 #endif 00311 { return _mvvassign(*this,intvector(v)); } 00312 INLINE intmatrix &intmatrix::operator =(const int &r) throw() { return _msassign(*this,r); } 00313 INLINE intmatrix &intmatrix::operator =(const intmatrix &m) throw() { return _mmassign<intmatrix,intmatrix,int>(*this,m,0); } 00314 INLINE intmatrix &intmatrix::operator =(const intvector &v) throw() { return _mvassign<intmatrix,intvector,int>(*this,v); } 00315 INLINE intmatrix &intmatrix::operator =(const intvector_slice &v) throw() { return _mvassign<intmatrix,intvector,int>(*this,intvector(v)); } 00316 INLINE intmatrix::operator void*() throw() { return _mvoid(*this); } 00317 INLINE intmatrix_slice &intmatrix_slice::operator =(const intmatrix &m) 00318 #if(CXSC_INDEX_CHECK) 00319 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00320 #else 00321 throw() 00322 #endif 00323 { return _msmassign(*this,m); } 00324 INLINE intmatrix_slice &intmatrix_slice::operator =(const intmatrix_slice &ms) 00325 #if(CXSC_INDEX_CHECK) 00326 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00327 #else 00328 throw() 00329 #endif 00330 { return _msmsassign(*this,ms); } 00331 INLINE intmatrix_slice &intmatrix_slice::operator =(const int &r) throw() { return _mssassign(*this,r); } 00332 INLINE intmatrix_slice &intmatrix_slice::operator =(const intvector &v) 00333 #if(CXSC_INDEX_CHECK) 00334 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00335 #else 00336 throw() 00337 #endif 00338 { return _msmassign(*this,intmatrix(v)); } 00339 INLINE intmatrix_slice &intmatrix_slice::operator =(const intvector_slice &v) 00340 #if(CXSC_INDEX_CHECK) 00341 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00342 #else 00343 throw() 00344 #endif 00345 { return _msmassign(*this,intmatrix(intvector(v))); } 00346 INLINE intmatrix_slice &intmatrix_slice::operator =(const intmatrix_subv &v) 00347 #if(CXSC_INDEX_CHECK) 00348 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00349 #else 00350 throw() 00351 #endif 00352 { return _msmassign(*this,intmatrix(intvector(v))); } 00353 INLINE intmatrix_slice &intmatrix_slice::operator +=(const intmatrix &m1) 00354 #if(CXSC_INDEX_CHECK) 00355 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00356 #else 00357 throw() 00358 #endif 00359 { return _msmplusassign(*this,m1); } 00360 INLINE intmatrix_slice &intmatrix_slice::operator +=(const intmatrix_slice &ms2) 00361 #if(CXSC_INDEX_CHECK) 00362 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00363 #else 00364 throw() 00365 #endif 00366 { return _msmsplusassign(*this,ms2); } 00367 INLINE intmatrix_slice &intmatrix_slice::operator -=(const intmatrix &m1) 00368 #if(CXSC_INDEX_CHECK) 00369 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00370 #else 00371 throw() 00372 #endif 00373 { return _msmminusassign(*this,m1); } 00374 INLINE intmatrix_slice &intmatrix_slice::operator -=(const intmatrix_slice &ms2) 00375 #if(CXSC_INDEX_CHECK) 00376 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00377 #else 00378 throw() 00379 #endif 00380 { return _msmsminusassign(*this,ms2); } 00381 INLINE intmatrix_slice &intmatrix_slice::operator *=(const int &c) throw() { return _mssmultassign(*this,c); } 00382 INLINE intmatrix_slice &intmatrix_slice::operator /=(const int &c) throw() { return _mssdivassign(*this,c); } 00383 INLINE intmatrix_slice::operator void*() throw() { return _msvoid(*this); } 00384 INLINE intvector operator /(const intmatrix_subv &rv, const int &s) throw() { return _mvsdiv<intmatrix_subv,int,intvector>(rv,s); } 00385 INLINE intvector operator *(const intmatrix_subv &rv, const int &s) throw() { return _mvsmult<intmatrix_subv,int,intvector>(rv,s); } 00386 INLINE intvector operator *(const int &s, const intmatrix_subv &rv) throw() { return _mvsmult<intmatrix_subv,int,intvector>(rv,s); } 00387 INLINE intmatrix_subv &intmatrix_subv::operator *=(const int &c) throw() { return _mvsmultassign(*this,c); } 00388 INLINE intmatrix_subv &intmatrix_subv::operator +=(const int &c) throw() { return _mvsplusassign(*this,c); } 00389 INLINE intmatrix_subv &intmatrix_subv::operator -=(const int &c) throw() { return _mvsminusassign(*this,c); } 00390 INLINE intmatrix_subv &intmatrix_subv::operator /=(const int &c) throw() { return _mvsdivassign(*this,c); } 00391 INLINE intvector abs(const intmatrix_subv &mv) throw() { return _mvabs<intmatrix_subv,intvector>(mv); } 00392 INLINE intvector &intvector::operator =(const intmatrix_subv &mv) throw() { return _vmvassign<intvector,intmatrix_subv,int>(*this,mv); } 00393 INLINE intvector_slice &intvector_slice::operator =(const intmatrix_subv &mv) throw() { return _vsvassign(*this,intvector(mv)); } 00394 00395 INLINE void accumulate(dotprecision &dp, const intmatrix_subv & rv1, const intmatrix_subv &rv2) 00396 #if(CXSC_INDEX_CHECK) 00397 throw(OP_WITH_WRONG_DIM) 00398 #else 00399 throw() 00400 #endif 00401 { _mvmvaccu(dp,rv1,rv2); } 00402 INLINE void accumulate(dotprecision &dp, const intvector & rv1, const intmatrix_subv &rv2) 00403 #if(CXSC_INDEX_CHECK) 00404 throw(OP_WITH_WRONG_DIM) 00405 #else 00406 throw() 00407 #endif 00408 { _vmvaccu(dp,rv1,rv2); } 00409 INLINE void accumulate(dotprecision &dp, const intmatrix_subv & rv1, const intvector &rv2) 00410 #if(CXSC_INDEX_CHECK) 00411 throw(OP_WITH_WRONG_DIM) 00412 #else 00413 throw() 00414 #endif 00415 { _vmvaccu(dp,rv2,rv1); } 00416 INLINE void accumulate(dotprecision &dp,const intvector_slice &sl,const intmatrix_subv &sv) 00417 #if(CXSC_INDEX_CHECK) 00418 throw(OP_WITH_WRONG_DIM) 00419 #else 00420 throw() 00421 #endif 00422 { _vmvaccu(dp,intvector(sl),sv); } 00423 INLINE void accumulate(dotprecision &dp,const intmatrix_subv &mv,const intvector_slice &vs) 00424 #if(CXSC_INDEX_CHECK) 00425 throw(OP_WITH_WRONG_DIM) 00426 #else 00427 throw() 00428 #endif 00429 { _vmvaccu(dp,intvector(vs),mv); } 00430 INLINE intvector operator +(const intmatrix_subv & rv1, const intmatrix_subv &rv2) 00431 #if(CXSC_INDEX_CHECK) 00432 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00433 #else 00434 throw() 00435 #endif 00436 { return _mvmvplus<intmatrix_subv,intmatrix_subv,intvector>(rv1,rv2); } 00437 INLINE intvector operator +(const intmatrix_subv &rv1,const intvector &rv2) 00438 #if(CXSC_INDEX_CHECK) 00439 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00440 #else 00441 throw() 00442 #endif 00443 { return _mvvplus<intmatrix_subv,intvector,intvector>(rv1,rv2); } 00444 INLINE intvector operator +(const intvector & rv1, const intmatrix_subv &rv2) 00445 #if(CXSC_INDEX_CHECK) 00446 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00447 #else 00448 throw() 00449 #endif 00450 { return _mvvplus<intmatrix_subv,intvector,intvector>(rv2,rv1); } 00451 INLINE intvector operator +(const intvector_slice &sl,const intmatrix_subv &mv) 00452 #if(CXSC_INDEX_CHECK) 00453 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00454 #else 00455 throw() 00456 #endif 00457 { return _mvvplus<intmatrix_subv,intvector,intvector>(mv,intvector(sl)); } 00458 INLINE intvector operator +(const intmatrix_subv &mv,const intvector_slice &sl) 00459 #if(CXSC_INDEX_CHECK) 00460 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00461 #else 00462 throw() 00463 #endif 00464 { return _mvvplus<intmatrix_subv,intvector,intvector>(mv,intvector(sl)); } 00465 INLINE intmatrix_subv &intmatrix_subv::operator +=(const intvector &rv) 00466 #if(CXSC_INDEX_CHECK) 00467 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00468 #else 00469 throw() 00470 #endif 00471 { return _mvvplusassign(*this,rv); } 00472 INLINE intmatrix_subv &intmatrix_subv::operator +=(const intvector_slice &rv) 00473 #if(CXSC_INDEX_CHECK) 00474 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00475 #else 00476 throw() 00477 #endif 00478 { return _mvvplusassign(*this,intvector(rv)); } 00479 INLINE intvector operator -(const intmatrix_subv & rv1, const intmatrix_subv &rv2) 00480 #if(CXSC_INDEX_CHECK) 00481 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00482 #else 00483 throw() 00484 #endif 00485 { return _mvmvminus<intmatrix_subv,intmatrix_subv,intvector>(rv1,rv2); } 00486 INLINE intvector operator -(const intvector & rv1, const intmatrix_subv &rv2) 00487 #if(CXSC_INDEX_CHECK) 00488 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00489 #else 00490 throw() 00491 #endif 00492 { return _vmvminus<intvector,intmatrix_subv,intvector>(rv1,rv2); } 00493 INLINE intvector operator -(const intmatrix_subv &rv1,const intvector &rv2) 00494 #if(CXSC_INDEX_CHECK) 00495 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00496 #else 00497 throw() 00498 #endif 00499 { return _mvvminus<intmatrix_subv,intvector,intvector>(rv1,rv2); } 00500 INLINE intvector operator -(const intvector_slice &sl,const intmatrix_subv &mv) 00501 #if(CXSC_INDEX_CHECK) 00502 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00503 #else 00504 throw() 00505 #endif 00506 { return _vmvminus<intvector,intmatrix_subv,intvector>(intvector(sl),mv); } 00507 INLINE intvector operator -(const intmatrix_subv &mv,const intvector_slice &sl) 00508 #if(CXSC_INDEX_CHECK) 00509 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00510 #else 00511 throw() 00512 #endif 00513 { return _mvvminus<intmatrix_subv,intvector,intvector>(mv,intvector(sl)); } 00514 INLINE intmatrix_subv &intmatrix_subv::operator -=(const intvector &rv) 00515 #if(CXSC_INDEX_CHECK) 00516 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00517 #else 00518 throw() 00519 #endif 00520 { return _mvvminusassign(*this,rv); } 00521 INLINE intmatrix_subv &intmatrix_subv::operator -=(const intvector_slice &rv) 00522 #if(CXSC_INDEX_CHECK) 00523 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM) 00524 #else 00525 throw() 00526 #endif 00527 { return _mvvminusassign(*this,intvector(rv)); } 00533 INLINE intmatrix _intmatrix(const intmatrix &rm) throw() { return rm; } 00539 INLINE intmatrix _intmatrix(const intvector &v) throw() { return intmatrix(v); } 00545 INLINE intmatrix _intmatrix(const intvector_slice &v) throw() { return intmatrix(v); } 00551 INLINE intmatrix _intmatrix(const int &r) throw() { return intmatrix(r); } 00552 INLINE intmatrix &intmatrix::operator =(const intmatrix_slice &ms) throw() { return _mmsassign<intmatrix,intmatrix_slice,int>(*this,ms); } 00553 INLINE int Lb(const intmatrix &rm, const int &i) 00554 #if(CXSC_INDEX_CHECK) 00555 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL) 00556 #else 00557 throw() 00558 #endif 00559 { return _mlb(rm,i); } 00560 INLINE int Ub(const intmatrix &rm, const int &i) 00561 #if(CXSC_INDEX_CHECK) 00562 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL) 00563 #else 00564 throw() 00565 #endif 00566 { return _mub(rm,i); } 00567 INLINE int Lb(const intmatrix_slice &rm, const int &i) 00568 #if(CXSC_INDEX_CHECK) 00569 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL) 00570 #else 00571 throw() 00572 #endif 00573 { return _mslb(rm,i); } 00574 INLINE int Ub(const intmatrix_slice &rm, const int &i) 00575 #if(CXSC_INDEX_CHECK) 00576 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL) 00577 #else 00578 throw() 00579 #endif 00580 { return _msub(rm,i); } 00581 INLINE intmatrix &SetLb(intmatrix &m, const int &i,const int &j) 00582 #if(CXSC_INDEX_CHECK) 00583 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL) 00584 #else 00585 throw() 00586 #endif 00587 { return _msetlb(m,i,j); } 00588 INLINE intmatrix &SetUb(intmatrix &m, const int &i,const int &j) 00589 #if(CXSC_INDEX_CHECK) 00590 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL) 00591 #else 00592 throw() 00593 #endif 00594 { return _msetub(m,i,j); } 00595 00596 INLINE int RowLen ( const intmatrix& A ) // Length of the rows of a integer matrix 00597 { return Ub(A,2)-Lb(A,2)+1; } //--------------------------------------- 00598 00599 INLINE int ColLen ( const intmatrix& A ) // Length of the columns of an integer matrix 00600 { return Ub(A,1)-Lb(A,1)+1; } //------------------------------------------- 00601 00602 INLINE int RowLen ( const intmatrix_slice& A ) // Length of the rows of a integer matrix 00603 { return Ub(A,2)-Lb(A,2)+1; } //--------------------------------------- 00604 00605 INLINE int ColLen ( const intmatrix_slice& A ) // Length of the columns of an integer matrix 00606 { return Ub(A,1)-Lb(A,1)+1; } //------------------------------------------- 00607 00608 INLINE void Resize(intmatrix &A) throw() { _mresize(A); } 00609 INLINE void Resize(intmatrix &A,const int &m, const int &n) 00610 #if(CXSC_INDEX_CHECK) 00611 throw(ERROR_INTMATRIX_WRONG_BOUNDARIES) 00612 #else 00613 throw() 00614 #endif 00615 { _mresize<intmatrix,int>(A,m,n); } 00616 INLINE void Resize(intmatrix &A,const int &m1, const int &m2,const int &n1,const int &n2) 00617 #if(CXSC_INDEX_CHECK) 00618 throw(ERROR_INTMATRIX_WRONG_BOUNDARIES) 00619 #else 00620 throw() 00621 #endif 00622 { _mresize<intmatrix,int>(A,m1,m2,n1,n2); } 00623 INLINE intmatrix abs(const intmatrix &m) throw() { return _mabs<intmatrix,intmatrix>(m); } 00624 INLINE intmatrix abs(const intmatrix_slice &ms) throw() { return _msabs<intmatrix_slice,intmatrix>(ms); } 00625 INLINE intmatrix operator *(const int &c, const intmatrix &m) throw() { return _smmult<int,intmatrix,intmatrix>(c,m); } 00626 INLINE intmatrix operator *(const int &c, const intmatrix_slice &ms) throw() { return _smsmult<int,intmatrix_slice,intmatrix>(c,ms); } 00627 INLINE intmatrix operator *(const intmatrix &m,const int &c) throw() { return _smmult<int,intmatrix,intmatrix>(c,m); } 00628 INLINE intmatrix operator *(const intmatrix_slice &ms,const int &c) throw() { return _smsmult<int,intmatrix_slice,intmatrix>(c,ms); } 00629 INLINE intmatrix &operator *=(intmatrix &m,const int &c) throw() { return _msmultassign(m,c); } 00630 INLINE intmatrix operator /(const intmatrix &m,const int &c) throw() { return _msdiv<intmatrix,int,intmatrix>(m,c); } 00631 INLINE intmatrix operator /(const intmatrix_slice &ms, const int &c) throw() { return _mssdiv<intmatrix_slice,int,intmatrix>(ms,c); } 00632 INLINE intmatrix &operator /=(intmatrix &m,const int &c) throw() { return _msdivassign(m,c); } 00633 INLINE intvector::intvector(const intmatrix &sl) 00634 #if(CXSC_INDEX_CHECK) 00635 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ) 00636 #else 00637 throw() 00638 #endif 00639 { _vmconstr<intvector,intmatrix,int>(*this,sl); } 00640 INLINE intvector::intvector(const intmatrix_slice &sl) 00641 #if(CXSC_INDEX_CHECK) 00642 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ) 00643 #else 00644 throw() 00645 #endif 00646 { _vmsconstr<intvector,intmatrix_slice,int>(*this,sl); } 00647 INLINE intvector &intvector::operator =(const intmatrix &m) 00648 #if(CXSC_INDEX_CHECK) 00649 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ) 00650 #else 00651 throw() 00652 #endif 00653 { return _vmassign<intvector,intmatrix,int>(*this,m); } 00654 INLINE intvector &intvector::operator =(const intmatrix_slice &m) 00655 #if(CXSC_INDEX_CHECK) 00656 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ) 00657 #else 00658 throw() 00659 #endif 00660 { return _vmassign<intvector,intmatrix,int>(*this,intmatrix(m)); } 00661 INLINE intvector_slice &intvector_slice::operator =(const intmatrix &m) 00662 #if(CXSC_INDEX_CHECK) 00663 throw(ERROR__OP_WITH_WRONG_DIM<intvector>,ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ) 00664 #else 00665 throw() 00666 #endif 00667 { return _vsvassign(*this,intvector(m)); } 00668 INLINE intvector_slice & intvector_slice::operator =(const intmatrix_slice &m) 00669 #if(CXSC_INDEX_CHECK) 00670 throw(ERROR__OP_WITH_WRONG_DIM<intvector>,ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ) 00671 #else 00672 throw() 00673 #endif 00674 { return _vsvassign(*this,intvector(intmatrix(m))); } 00675 INLINE intmatrix_subv &intmatrix_subv::operator =(const intmatrix &m) 00676 #if(CXSC_INDEX_CHECK) 00677 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ) 00678 #else 00679 throw() 00680 #endif 00681 { return _mvvassign(*this,intvector(m)); } 00682 INLINE intmatrix_subv &intmatrix_subv::operator =(const intmatrix_slice &m) 00683 #if(CXSC_INDEX_CHECK) 00684 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ) 00685 #else 00686 throw() 00687 #endif 00688 { return _mvvassign(*this,intvector(intmatrix(m))); } 00689 00690 INLINE const intmatrix &operator +(const intmatrix &m) throw() { return m; } 00691 INLINE intmatrix operator +(const intmatrix_slice &m) throw() { return intmatrix(m); } 00692 INLINE intmatrix operator +(const intmatrix &m1,const intmatrix &m2) 00693 #if(CXSC_INDEX_CHECK) 00694 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00695 #else 00696 throw() 00697 #endif 00698 { return _mmplus<intmatrix,intmatrix,intmatrix>(m1,m2); } 00699 INLINE intmatrix operator +(const intmatrix &m,const intmatrix_slice &ms) 00700 #if(CXSC_INDEX_CHECK) 00701 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00702 #else 00703 throw() 00704 #endif 00705 { return _mmsplus<intmatrix,intmatrix_slice,intmatrix>(m,ms); } 00706 INLINE intmatrix operator +(const intmatrix_slice &ms,const intmatrix &m) 00707 #if(CXSC_INDEX_CHECK) 00708 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00709 #else 00710 throw() 00711 #endif 00712 { return _mmsplus<intmatrix,intmatrix_slice,intmatrix>(m,ms); } 00713 INLINE intmatrix operator +(const intmatrix_slice &m1,const intmatrix_slice &m2) 00714 #if(CXSC_INDEX_CHECK) 00715 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00716 #else 00717 throw() 00718 #endif 00719 { return _msmsplus<intmatrix_slice,intmatrix_slice,intmatrix>(m1,m2); } 00720 INLINE intmatrix &operator +=(intmatrix &m1,const intmatrix &m2) 00721 #if(CXSC_INDEX_CHECK) 00722 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00723 #else 00724 throw() 00725 #endif 00726 { return _mmplusassign(m1,m2); } 00727 INLINE intmatrix &operator +=(intmatrix &m1,const intmatrix_slice &ms) 00728 #if(CXSC_INDEX_CHECK) 00729 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00730 #else 00731 throw() 00732 #endif 00733 { return _mmsplusassign(m1,ms); } 00734 INLINE intmatrix operator -(const intmatrix &m) throw() { return _mminus(m); } 00735 INLINE intmatrix operator -(const intmatrix_slice &m) throw() { return _msminus<intmatrix_slice,intmatrix>(m); } 00736 INLINE intmatrix operator -(const intmatrix &m1,const intmatrix &m2) 00737 #if(CXSC_INDEX_CHECK) 00738 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00739 #else 00740 throw() 00741 #endif 00742 { return _mmminus<intmatrix,intmatrix,intmatrix>(m1,m2); } 00743 INLINE intmatrix operator -(const intmatrix &m,const intmatrix_slice &ms) 00744 #if(CXSC_INDEX_CHECK) 00745 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00746 #else 00747 throw() 00748 #endif 00749 { return _mmsminus<intmatrix,intmatrix_slice,intmatrix>(m,ms); } 00750 INLINE intmatrix operator -(const intmatrix_slice &ms,const intmatrix &m) 00751 #if(CXSC_INDEX_CHECK) 00752 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00753 #else 00754 throw() 00755 #endif 00756 { return _msmminus<intmatrix_slice,intmatrix,intmatrix>(ms,m); } 00757 INLINE intmatrix operator -(const intmatrix_slice &ms1,const intmatrix_slice &ms2) 00758 #if(CXSC_INDEX_CHECK) 00759 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00760 #else 00761 throw() 00762 #endif 00763 { return _msmsminus<intmatrix_slice,intmatrix_slice,intmatrix>(ms1,ms2); } 00764 INLINE intmatrix &operator -=(intmatrix &m1,const intmatrix &m2) 00765 #if(CXSC_INDEX_CHECK) 00766 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00767 #else 00768 throw() 00769 #endif 00770 { return _mmminusassign(m1,m2); } 00771 INLINE intmatrix &operator -=(intmatrix &m1,const intmatrix_slice &ms) 00772 #if(CXSC_INDEX_CHECK) 00773 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM) 00774 #else 00775 throw() 00776 #endif 00777 { return _mmsminusassign(m1,ms); } 00778 INLINE bool operator ==(const intmatrix &m1,const intmatrix &m2) throw() { return _mmeq(m1,m2); } 00779 INLINE bool operator !=(const intmatrix &m1,const intmatrix &m2) throw() { return _mmneq(m1,m2); } 00780 INLINE bool operator <(const intmatrix &m1,const intmatrix &m2) throw() { return _mmless(m1,m2); } 00781 INLINE bool operator <=(const intmatrix &m1,const intmatrix &m2) throw() { return _mmleq(m1,m2); } 00782 INLINE bool operator >(const intmatrix &m1,const intmatrix &m2) throw() { return _mmless(m2,m1); } 00783 INLINE bool operator >=(const intmatrix &m1,const intmatrix &m2) throw() { return _mmleq(m2,m1); } 00784 INLINE bool operator ==(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _mmseq(m1,ms); } 00785 INLINE bool operator !=(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _mmsneq(m1,ms); } 00786 INLINE bool operator <(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _mmsless(m1,ms); } 00787 INLINE bool operator <=(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _mmsleq(m1,ms); } 00788 INLINE bool operator >(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _msmless(ms,m1); } 00789 INLINE bool operator >=(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _msmleq(ms,m1); } 00790 INLINE bool operator ==(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmseq(m1,m2); } 00791 INLINE bool operator !=(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmsneq(m1,m2); } 00792 INLINE bool operator <(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmsless(m1,m2); } 00793 INLINE bool operator <=(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmsleq(m1,m2); } 00794 INLINE bool operator >(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmsless(m2,m1); } 00795 INLINE bool operator >=(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmsleq(m2,m1); } 00796 INLINE bool operator !(const intmatrix &ms) throw() { return _mnot(ms); } 00797 INLINE bool operator !(const intmatrix_slice &ms) throw() { return _msnot(ms); } 00798 INLINE std::ostream &operator <<(std::ostream &s,const intmatrix &r) throw() { return _mout(s,r); } 00799 INLINE std::ostream &operator <<(std::ostream &s,const intmatrix_slice &r) throw() { return _msout(s,r); } 00800 INLINE std::istream &operator >>(std::istream &s,intmatrix &r) throw() { return _min(s,r); } 00801 INLINE std::istream &operator >>(std::istream &s,intmatrix_slice &r) throw() { return _msin(s,r); } 00802 00803 INLINE intvector permvec(const intmatrix& A) { 00804 intvector p(RowLen(A)); 00805 SetLb(p,0); 00806 for(int i=0 ; i<ColLen(A) ; i++) 00807 for(int j=0 ; j<RowLen(A) ; j++) 00808 if(A[i+Lb(A,1)][j+Lb(A,2)] != 0) { 00809 p[i] = j; 00810 j = RowLen(A); 00811 } 00812 return p; 00813 } 00814 00815 INLINE intmatrix permmat(const intvector& x) { 00816 intmatrix A(0,VecLen(x)-1,0,VecLen(x)-1); 00817 for(int i=0 ; i<VecLen(x) ; i++) 00818 A[i][x[i+Lb(x)]] = 1; 00819 return A; 00820 } 00821 00822 INLINE intmatrix perminv(const intmatrix& A) { 00823 return transp(A); 00824 } 00825 00826 } // namespace cxsc 00827 00828 #endif