26 #ifndef _CXSC_INTMATRIX_INL_INCLUDED 27 #define _CXSC_INTMATRIX_INL_INCLUDED 43 dat=
new int[xsize*ysize];
44 for(
int i=0;i<xsize*ysize;i++)
50 throw(ERROR_INTMATRIX_WRONG_BOUNDARIES):lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m)
52 throw():lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m)
56 if((n<0)||(m<0)) cxscthrow(ERROR_INTMATRIX_WRONG_BOUNDARIES(
"intmatrix::intmatrix(const int &m, const int &n)"));
63 throw(ERROR_INTMATRIX_WRONG_BOUNDARIES):lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1)
65 throw():lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1)
69 if((m2<m1)||(n2<n1)) cxscthrow(ERROR_INTMATRIX_WRONG_BOUNDARIES(
"intmatrix::intmatrix(const int &m1, const int &n1, const int &m2, const int &n2)"));
71 dat=
new int[xsize*ysize];
77 for (
int i=0, j=v.start;i<v.size;i++,j+=v.offset)
84 for(
int i=0;i<v.size;i++)
91 for(
int i=0,j=v.start-v.l;i<v.size;i++,j++)
97 throw(ERROR_INTVECTOR_ELEMENT_NOT_IN_VEC)
102 #if(CXSC_INDEX_CHECK) 103 if((i<lb)||(i>ub)) cxscthrow(ERROR_INTVECTOR_ELEMENT_NOT_IN_VEC(
"int &intmatrix_subv::operator [](const int &i)"));
105 return dat[start+((i-lb)*offset)];
112 dat=
new int[xsize*ysize];
113 for (i=0;i<ysize;i++)
117 dat[i*xsize+j]=sl.dat[(sl.offset1+i)*sl.mxsize+sl.offset2+j];
123 #if(CXSC_INDEX_CHECK) 124 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
134 #if(CXSC_INDEX_CHECK) 135 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
144 INLINE intmatrix_subv
Row(
const intmatrix &m,
const int &i)
145 #if(CXSC_INDEX_CHECK) 146 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
156 #if(CXSC_INDEX_CHECK) 157 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
167 #if(CXSC_INDEX_CHECK) 168 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
173 #if(CXSC_INDEX_CHECK) 174 if((i<lb1)||(i>ub1)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT(
"intmatrix_subv intmatrix::operator [](const int &i)"));
180 #if(CXSC_INDEX_CHECK) 181 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
186 #if(CXSC_INDEX_CHECK) 187 if((i.col()<lb2)||(i.col()>ub2)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT(
"intmatrix_subv intmatrix::operator [](const cxscmatrix_column &i)"));
193 #if(CXSC_INDEX_CHECK) 194 throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG)
199 #if(CXSC_INDEX_CHECK) 200 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)"));
206 #if(CXSC_INDEX_CHECK) 207 throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG)
212 #if(CXSC_INDEX_CHECK) 213 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)"));
219 #if(CXSC_INDEX_CHECK) 220 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
225 #if(CXSC_INDEX_CHECK) 226 if((i<start1)||(i>end1)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT(
"intmatrix_subv intmatrix_slice::operator [](const int &i)"));
228 return intmatrix_subv(dat, start2, end2, sxsize, mxsize*(i-start1+offset1)+offset2,1);
232 #if(CXSC_INDEX_CHECK) 233 throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
238 #if(CXSC_INDEX_CHECK) 239 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)"));
241 return intmatrix_subv(dat, start1, end1, sysize, offset1*mxsize+i.col()-start2+offset2, mxsize);
245 #if(CXSC_INDEX_CHECK) 246 throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG)
251 #if(CXSC_INDEX_CHECK) 252 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)"));
258 #if(CXSC_INDEX_CHECK) 259 throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG)
264 #if(CXSC_INDEX_CHECK) 265 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)"));
271 #if(CXSC_INDEX_CHECK) 272 throw(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG)
277 #if(CXSC_INDEX_CHECK) 278 if(1<lb||i>ub) cxscthrow(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG(
"intmatrix_subv intmatrix_subv::operator ()(const int &i)"));
284 #if(CXSC_INDEX_CHECK) 285 throw(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG)
290 #if(CXSC_INDEX_CHECK) 291 if(i1<lb||i2>ub) cxscthrow(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG(
"intmatrix_subv intmatrix_subv::operator ()(const int &i1,const int &i2)"));
293 return intmatrix_subv(dat,i1,i2,i2-i1+1,start+(i1-lb)*offset,offset);
299 #if(CXSC_INDEX_CHECK) 300 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
304 {
return _mvvassign(*
this,v); }
306 #if(CXSC_INDEX_CHECK) 307 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
311 {
return _mvvassign(*
this,
intvector(v)); }
316 INLINE intmatrix::operator
void*()
throw() {
return _mvoid(*
this); }
318 #if(CXSC_INDEX_CHECK) 319 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
323 {
return _msmassign(*
this,m); }
325 #if(CXSC_INDEX_CHECK) 326 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
330 {
return _msmsassign(*
this,ms); }
333 #if(CXSC_INDEX_CHECK) 334 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
338 {
return _msmassign(*
this,
intmatrix(v)); }
340 #if(CXSC_INDEX_CHECK) 341 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
347 #if(CXSC_INDEX_CHECK) 348 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
354 #if(CXSC_INDEX_CHECK) 355 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
359 {
return _msmplusassign(*
this,m1); }
361 #if(CXSC_INDEX_CHECK) 362 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
366 {
return _msmsplusassign(*
this,ms2); }
368 #if(CXSC_INDEX_CHECK) 369 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
373 {
return _msmminusassign(*
this,m1); }
375 #if(CXSC_INDEX_CHECK) 376 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
380 {
return _msmsminusassign(*
this,ms2); }
383 INLINE intmatrix_slice::operator
void*()
throw() {
return _msvoid(*
this); }
396 #if(CXSC_INDEX_CHECK) 397 throw(OP_WITH_WRONG_DIM)
401 { _mvmvaccu(dp,rv1,rv2); }
403 #if(CXSC_INDEX_CHECK) 404 throw(OP_WITH_WRONG_DIM)
408 { _vmvaccu(dp,rv1,rv2); }
410 #if(CXSC_INDEX_CHECK) 411 throw(OP_WITH_WRONG_DIM)
415 { _vmvaccu(dp,rv2,rv1); }
417 #if(CXSC_INDEX_CHECK) 418 throw(OP_WITH_WRONG_DIM)
424 #if(CXSC_INDEX_CHECK) 425 throw(OP_WITH_WRONG_DIM)
431 #if(CXSC_INDEX_CHECK) 432 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
436 {
return _mvmvplus<intmatrix_subv,intmatrix_subv,intvector>(rv1,rv2); }
438 #if(CXSC_INDEX_CHECK) 439 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
443 {
return _mvvplus<intmatrix_subv,intvector,intvector>(rv1,rv2); }
445 #if(CXSC_INDEX_CHECK) 446 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
450 {
return _mvvplus<intmatrix_subv,intvector,intvector>(rv2,rv1); }
452 #if(CXSC_INDEX_CHECK) 453 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
457 {
return _mvvplus<intmatrix_subv,intvector,intvector>(mv,
intvector(sl)); }
459 #if(CXSC_INDEX_CHECK) 460 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
464 {
return _mvvplus<intmatrix_subv,intvector,intvector>(mv,
intvector(sl)); }
466 #if(CXSC_INDEX_CHECK) 467 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
471 {
return _mvvplusassign(*
this,rv); }
473 #if(CXSC_INDEX_CHECK) 474 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
478 {
return _mvvplusassign(*
this,
intvector(rv)); }
480 #if(CXSC_INDEX_CHECK) 481 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
485 {
return _mvmvminus<intmatrix_subv,intmatrix_subv,intvector>(rv1,rv2); }
487 #if(CXSC_INDEX_CHECK) 488 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
492 {
return _vmvminus<intvector,intmatrix_subv,intvector>(rv1,rv2); }
494 #if(CXSC_INDEX_CHECK) 495 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
499 {
return _mvvminus<intmatrix_subv,intvector,intvector>(rv1,rv2); }
501 #if(CXSC_INDEX_CHECK) 502 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
506 {
return _vmvminus<intvector,intmatrix_subv,intvector>(
intvector(sl),mv); }
508 #if(CXSC_INDEX_CHECK) 509 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
513 {
return _mvvminus<intmatrix_subv,intvector,intvector>(mv,
intvector(sl)); }
515 #if(CXSC_INDEX_CHECK) 516 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
520 {
return _mvvminusassign(*
this,rv); }
522 #if(CXSC_INDEX_CHECK) 523 throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
527 {
return _mvvminusassign(*
this,
intvector(rv)); }
554 #if(CXSC_INDEX_CHECK) 555 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
559 {
return _mlb(rm,i); }
561 #if(CXSC_INDEX_CHECK) 562 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
566 {
return _mub(rm,i); }
568 #if(CXSC_INDEX_CHECK) 569 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
573 {
return _mslb(rm,i); }
575 #if(CXSC_INDEX_CHECK) 576 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
580 {
return _msub(rm,i); }
582 #if(CXSC_INDEX_CHECK) 583 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
587 {
return _msetlb(m,i,j); }
589 #if(CXSC_INDEX_CHECK) 590 throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
594 {
return _msetub(m,i,j); }
597 {
return Ub(A,2)-
Lb(A,2)+1; }
600 {
return Ub(A,1)-
Lb(A,1)+1; }
603 {
return Ub(A,2)-
Lb(A,2)+1; }
606 {
return Ub(A,1)-
Lb(A,1)+1; }
610 #if(CXSC_INDEX_CHECK) 611 throw(ERROR_INTMATRIX_WRONG_BOUNDARIES)
615 { _mresize<intmatrix,int>(A,m,n); }
616 INLINE
void Resize(
intmatrix &A,
const int &m1,
const int &m2,
const int &n1,
const int &n2)
617 #if(CXSC_INDEX_CHECK) 618 throw(ERROR_INTMATRIX_WRONG_BOUNDARIES)
622 { _mresize<intmatrix,int>(A,m1,m2,n1,n2); }
634 #if(CXSC_INDEX_CHECK) 635 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
639 { _vmconstr<intvector,intmatrix,int>(*
this,sl); }
641 #if(CXSC_INDEX_CHECK) 642 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
646 { _vmsconstr<intvector,intmatrix_slice,int>(*
this,sl); }
648 #if(CXSC_INDEX_CHECK) 649 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
653 {
return _vmassign<intvector,intmatrix,int>(*
this,m); }
655 #if(CXSC_INDEX_CHECK) 656 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
660 {
return _vmassign<intvector,intmatrix,int>(*
this,
intmatrix(m)); }
662 #if(CXSC_INDEX_CHECK) 663 throw(ERROR__OP_WITH_WRONG_DIM<intvector>,ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
667 {
return _vsvassign(*
this,
intvector(m)); }
669 #if(CXSC_INDEX_CHECK) 670 throw(ERROR__OP_WITH_WRONG_DIM<intvector>,ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
676 #if(CXSC_INDEX_CHECK) 677 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
681 {
return _mvvassign(*
this,
intvector(m)); }
683 #if(CXSC_INDEX_CHECK) 684 throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
693 #if(CXSC_INDEX_CHECK) 694 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
698 {
return _mmplus<intmatrix,intmatrix,intmatrix>(m1,m2); }
700 #if(CXSC_INDEX_CHECK) 701 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
705 {
return _mmsplus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
707 #if(CXSC_INDEX_CHECK) 708 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
712 {
return _mmsplus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
714 #if(CXSC_INDEX_CHECK) 715 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
719 {
return _msmsplus<intmatrix_slice,intmatrix_slice,intmatrix>(m1,m2); }
721 #if(CXSC_INDEX_CHECK) 722 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
726 {
return _mmplusassign(m1,m2); }
728 #if(CXSC_INDEX_CHECK) 729 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
733 {
return _mmsplusassign(m1,ms); }
737 #if(CXSC_INDEX_CHECK) 738 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
742 {
return _mmminus<intmatrix,intmatrix,intmatrix>(m1,m2); }
744 #if(CXSC_INDEX_CHECK) 745 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
749 {
return _mmsminus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
751 #if(CXSC_INDEX_CHECK) 752 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
756 {
return _msmminus<intmatrix_slice,intmatrix,intmatrix>(ms,m); }
758 #if(CXSC_INDEX_CHECK) 759 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
763 {
return _msmsminus<intmatrix_slice,intmatrix_slice,intmatrix>(ms1,ms2); }
765 #if(CXSC_INDEX_CHECK) 766 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
770 {
return _mmminusassign(m1,m2); }
772 #if(CXSC_INDEX_CHECK) 773 throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
777 {
return _mmsminusassign(m1,ms); }
796 INLINE
bool operator !(
const intmatrix &ms)
throw() {
return _mnot(ms); }
798 INLINE std::ostream &operator <<(std::ostream &s,
const intmatrix &r)
throw() {
return _mout(s,r); }
799 INLINE std::ostream &operator <<(std::ostream &s,
const intmatrix_slice &r)
throw() {
return _msout(s,r); }
800 INLINE std::istream &operator >>(std::istream &s,
intmatrix &r)
throw() {
return _min(s,r); }
801 INLINE std::istream &operator >>(std::istream &s,
intmatrix_slice &r)
throw() {
return _msin(s,r); }
803 INLINE intvector permvec(
const intmatrix& A) {
806 for(
int i=0 ; i<
ColLen(A) ; i++)
807 for(
int j=0 ; j<
RowLen(A) ; j++)
808 if(A[i+
Lb(A,1)][j+
Lb(A,2)] != 0) {
815 INLINE intmatrix permmat(
const intvector& x) {
817 for(
int i=0 ; i<
VecLen(x) ; i++)
818 A[i][x[i+
Lb(x)]] = 1;
822 INLINE intmatrix perminv(
const intmatrix& A) {
intmatrix & operator=(const int &r)
Implementation of standard assigning operator.
cimatrix & operator/=(cimatrix &m, const cinterval &c)
Implementation of division and allocation operation.
The Data Type dotprecision.
intmatrix_subv & operator -=(const int &c)
Implementation of subtraction and allocation operation.
int Lb(const cimatrix &rm, const int &i)
Returns the lower bound index.
The namespace cxsc, providing all functionality of the class library C-XSC.
intmatrix_subv & operator+=(const int &c)
Implementation of addition and allocation operation.
The Data Type intmatrix_subv.
int & operator [](const int &i) const
Operator for accessing the single elements of the vector.
cimatrix_subv Col(cimatrix &m, const int &i)
Returns one column of the matrix as a vector.
cimatrix & SetLb(cimatrix &m, const int &i, const int &j)
Sets the lower bound index.
intmatrix & operator()()
Operator for accessing the whole matrix.
int VecLen(const scimatrix_subv &S)
Returns the length of the subvector.
intmatrix()
Constructor of class intmatrix.
intmatrix_slice & operator=(const intmatrix &m)
Implementation of standard assigning operator.
cimatrix & operator *=(cimatrix &m, const cinterval &c)
Implementation of multiplication and allocation operation.
cimatrix & SetUb(cimatrix &m, const int &i, const int &j)
Sets the upper bound index.
civector operator *(const cimatrix_subv &rv, const cinterval &s)
Implementation of multiplication operation.
intmatrix _intmatrix(const intmatrix &rm)
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
void Resize(cimatrix &A)
Resizes the matrix.
intmatrix_slice & operator()()
Operator for accessing the whole matrix.
int ColLen(const cimatrix &)
Returns the column dimension.
The Data Type intvector_slice.
cimatrix_subv Row(cimatrix &m, const int &i)
Returns one row of the matrix as a vector.
The Data Type intmatrix_slice.
int RowLen(const cimatrix &)
Returns the row dimension.
intmatrix_subv & operator *=(const int &c)
Implementation of multiplication and allocation operation.
intmatrix_slice & operator/=(const int &c)
Implementation of division and allocation operation.
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc)
Implementation of standard algebraic addition and allocation operation.
intmatrix_subv & operator()()
Operator for accessing the whole vector.
intmatrix_slice & operator *=(const int &c)
Implementation of multiplication and allocation operation.
intmatrix_subv operator [](const int &i) const
Operator for accessing a single row of the matrix.
intvector()
Constructor of class intvector.
int Ub(const cimatrix &rm, const int &i)
Returns the upper bound index.
intmatrix_subv operator [](const int &i)
Operator for accessing a single row of the matrix.
civector operator/(const cimatrix_subv &rv, const cinterval &s)
Implementation of division operation.
intvector_slice & operator=(const intvector_slice &sl)
Constructor of class intvector_slice.
cimatrix transp(const cimatrix &A)
Returns the transposed matrix.
intvector & operator=(const intvector &rv)
Implementation of standard assigning operator.
intmatrix_subv & operator/=(const int &c)
Implementation of division and allocation operation.
intmatrix_slice & operator+=(const intmatrix &m1)
Implementation of addition and allocation operation.
intmatrix_subv & operator=(const intmatrix_subv &rv)
Implementation of standard assigning operator.
ivector abs(const cimatrix_subv &mv)
Returns the absolute value of the matrix.
intmatrix_slice & operator -=(const intmatrix &m1)
Implementation of subtraction and allocation operation.