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 :lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m)
52 noexcept: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 :lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1)
65 noexcept: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++)
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)
134 #if(CXSC_INDEX_CHECK)
145 #if(CXSC_INDEX_CHECK)
156 #if(CXSC_INDEX_CHECK)
167 #if(CXSC_INDEX_CHECK)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
304 {
return _mvvassign(*
this,v); }
306 #if(CXSC_INDEX_CHECK)
311 {
return _mvvassign(*
this,
intvector(v)); }
316 INLINE intmatrix::operator
void*() noexcept {
return _mvoid(*
this); }
318 #if(CXSC_INDEX_CHECK)
323 {
return _msmassign(*
this,m); }
325 #if(CXSC_INDEX_CHECK)
330 {
return _msmsassign(*
this,ms); }
333 #if(CXSC_INDEX_CHECK)
338 {
return _msmassign(*
this,
intmatrix(v)); }
340 #if(CXSC_INDEX_CHECK)
347 #if(CXSC_INDEX_CHECK)
354 #if(CXSC_INDEX_CHECK)
359 {
return _msmplusassign(*
this,m1); }
361 #if(CXSC_INDEX_CHECK)
366 {
return _msmsplusassign(*
this,ms2); }
368 #if(CXSC_INDEX_CHECK)
373 {
return _msmminusassign(*
this,m1); }
375 #if(CXSC_INDEX_CHECK)
380 {
return _msmsminusassign(*
this,ms2); }
383 INLINE intmatrix_slice::operator
void*() noexcept {
return _msvoid(*
this); }
396 #if(CXSC_INDEX_CHECK)
401 { _mvmvaccu(dp,rv1,rv2); }
403 #if(CXSC_INDEX_CHECK)
408 { _vmvaccu(dp,rv1,rv2); }
410 #if(CXSC_INDEX_CHECK)
415 { _vmvaccu(dp,rv2,rv1); }
417 #if(CXSC_INDEX_CHECK)
424 #if(CXSC_INDEX_CHECK)
431 #if(CXSC_INDEX_CHECK)
436 {
return _mvmvplus<intmatrix_subv,intmatrix_subv,intvector>(rv1,rv2); }
438 #if(CXSC_INDEX_CHECK)
443 {
return _mvvplus<intmatrix_subv,intvector,intvector>(rv1,rv2); }
445 #if(CXSC_INDEX_CHECK)
450 {
return _mvvplus<intmatrix_subv,intvector,intvector>(rv2,rv1); }
452 #if(CXSC_INDEX_CHECK)
457 {
return _mvvplus<intmatrix_subv,intvector,intvector>(mv,
intvector(sl)); }
459 #if(CXSC_INDEX_CHECK)
464 {
return _mvvplus<intmatrix_subv,intvector,intvector>(mv,
intvector(sl)); }
466 #if(CXSC_INDEX_CHECK)
471 {
return _mvvplusassign(*
this,rv); }
473 #if(CXSC_INDEX_CHECK)
478 {
return _mvvplusassign(*
this,
intvector(rv)); }
480 #if(CXSC_INDEX_CHECK)
485 {
return _mvmvminus<intmatrix_subv,intmatrix_subv,intvector>(rv1,rv2); }
487 #if(CXSC_INDEX_CHECK)
492 {
return _vmvminus<intvector,intmatrix_subv,intvector>(rv1,rv2); }
494 #if(CXSC_INDEX_CHECK)
499 {
return _mvvminus<intmatrix_subv,intvector,intvector>(rv1,rv2); }
501 #if(CXSC_INDEX_CHECK)
506 {
return _vmvminus<intvector,intmatrix_subv,intvector>(
intvector(sl),mv); }
508 #if(CXSC_INDEX_CHECK)
513 {
return _mvvminus<intmatrix_subv,intvector,intvector>(mv,
intvector(sl)); }
515 #if(CXSC_INDEX_CHECK)
520 {
return _mvvminusassign(*
this,rv); }
522 #if(CXSC_INDEX_CHECK)
527 {
return _mvvminusassign(*
this,
intvector(rv)); }
554 #if(CXSC_INDEX_CHECK)
559 {
return _mlb(rm,i); }
561 #if(CXSC_INDEX_CHECK)
566 {
return _mub(rm,i); }
568 #if(CXSC_INDEX_CHECK)
573 {
return _mslb(rm,i); }
575 #if(CXSC_INDEX_CHECK)
580 {
return _msub(rm,i); }
582 #if(CXSC_INDEX_CHECK)
587 {
return _msetlb(m,i,j); }
589 #if(CXSC_INDEX_CHECK)
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)
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)
622 { _mresize<intmatrix,int>(A,m1,m2,n1,n2); }
634 #if(CXSC_INDEX_CHECK)
639 { _vmconstr<intvector,intmatrix,int>(*
this,sl); }
641 #if(CXSC_INDEX_CHECK)
646 { _vmsconstr<intvector,intmatrix_slice,int>(*
this,sl); }
648 #if(CXSC_INDEX_CHECK)
653 {
return _vmassign<intvector,intmatrix,int>(*
this,m); }
655 #if(CXSC_INDEX_CHECK)
660 {
return _vmassign<intvector,intmatrix,int>(*
this,
intmatrix(m)); }
662 #if(CXSC_INDEX_CHECK)
667 {
return _vsvassign(*
this,
intvector(m)); }
669 #if(CXSC_INDEX_CHECK)
676 #if(CXSC_INDEX_CHECK)
681 {
return _mvvassign(*
this,
intvector(m)); }
683 #if(CXSC_INDEX_CHECK)
693 #if(CXSC_INDEX_CHECK)
698 {
return _mmplus<intmatrix,intmatrix,intmatrix>(m1,m2); }
700 #if(CXSC_INDEX_CHECK)
705 {
return _mmsplus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
707 #if(CXSC_INDEX_CHECK)
712 {
return _mmsplus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
714 #if(CXSC_INDEX_CHECK)
719 {
return _msmsplus<intmatrix_slice,intmatrix_slice,intmatrix>(m1,m2); }
721 #if(CXSC_INDEX_CHECK)
726 {
return _mmplusassign(m1,m2); }
728 #if(CXSC_INDEX_CHECK)
733 {
return _mmsplusassign(m1,ms); }
737 #if(CXSC_INDEX_CHECK)
742 {
return _mmminus<intmatrix,intmatrix,intmatrix>(m1,m2); }
744 #if(CXSC_INDEX_CHECK)
749 {
return _mmsminus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
751 #if(CXSC_INDEX_CHECK)
756 {
return _msmminus<intmatrix_slice,intmatrix,intmatrix>(ms,m); }
758 #if(CXSC_INDEX_CHECK)
763 {
return _msmsminus<intmatrix_slice,intmatrix_slice,intmatrix>(ms1,ms2); }
765 #if(CXSC_INDEX_CHECK)
770 {
return _mmminusassign(m1,m2); }
772 #if(CXSC_INDEX_CHECK)
777 {
return _mmsminusassign(m1,ms); }
796 INLINE
bool operator !(
const intmatrix &ms) noexcept {
return _mnot(ms); }
798 INLINE std::ostream &operator <<(std::ostream &s,
const intmatrix &r) noexcept {
return _mout(s,r); }
799 INLINE std::ostream &operator <<(std::ostream &s,
const intmatrix_slice &r) noexcept {
return _msout(s,r); }
800 INLINE std::istream &operator >>(std::istream &s,
intmatrix &r) noexcept {
return _min(s,r); }
801 INLINE std::istream &operator >>(std::istream &s,
intmatrix_slice &r) noexcept {
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) {
The Data Type dotprecision.
The Data Type intmatrix_slice.
intmatrix_slice & operator-=(const intmatrix &m1) noexcept
Implementation of subtraction and allocation operation.
intmatrix_slice & operator=(const intmatrix &m) noexcept
Implementation of standard assigning operator.
intmatrix_slice & operator*=(const int &c) noexcept
Implementation of multiplication and allocation operation.
intmatrix_slice & operator+=(const intmatrix &m1) noexcept
Implementation of addition and allocation operation.
intmatrix_slice & operator/=(const int &c) noexcept
Implementation of division and allocation operation.
intmatrix_subv operator[](const int &i) noexcept
Operator for accessing a single row of the matrix.
intmatrix_slice & operator()() noexcept
Operator for accessing the whole matrix.
The Data Type intmatrix_subv.
int & operator[](const int &i) const noexcept
Operator for accessing the single elements of the vector.
intmatrix_subv & operator/=(const int &c) noexcept
Implementation of division and allocation operation.
intmatrix_subv & operator()() noexcept
Operator for accessing the whole vector.
intmatrix_subv & operator=(const intmatrix_subv &rv) noexcept
Implementation of standard assigning operator.
intmatrix_subv & operator+=(const int &c) noexcept
Implementation of addition and allocation operation.
intmatrix_subv & operator-=(const int &c) noexcept
Implementation of subtraction and allocation operation.
intmatrix_subv & operator*=(const int &c) noexcept
Implementation of multiplication and allocation operation.
intmatrix & operator=(const int &r) noexcept
Implementation of standard assigning operator.
intmatrix & operator()() noexcept
Operator for accessing the whole matrix.
intmatrix() noexcept
Constructor of class intmatrix.
intmatrix_subv operator[](const int &i) const noexcept
Operator for accessing a single row of the matrix.
The Data Type intvector_slice.
intvector_slice & operator=(const intvector_slice &sl) noexcept
Constructor of class intvector_slice.
intvector() noexcept
Constructor of class intvector.
intvector & operator=(const intvector &rv) noexcept
Implementation of standard assigning operator.
The namespace cxsc, providing all functionality of the class library C-XSC.
cimatrix_subv Col(cimatrix &m, const int &i) noexcept
Returns one column of the matrix as a vector.
int VecLen(const scimatrix_subv &S)
Returns the length of the subvector.
int ColLen(const cimatrix &)
Returns the column dimension.
civector operator/(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of division operation.
cimatrix transp(const cimatrix &A)
Returns the transposed matrix.
cimatrix_subv Row(cimatrix &m, const int &i) noexcept
Returns one row of the matrix as a vector.
int Ub(const cimatrix &rm, const int &i) noexcept
Returns the upper bound index.
cimatrix & SetLb(cimatrix &m, const int &i, const int &j) noexcept
Sets the lower bound index.
intmatrix _intmatrix(const intmatrix &rm) noexcept
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
int RowLen(const cimatrix &)
Returns the row dimension.
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc) noexcept
Implementation of standard algebraic addition and allocation operation.
cimatrix & operator*=(cimatrix &m, const cinterval &c) noexcept
Implementation of multiplication and allocation operation.
ivector abs(const cimatrix_subv &mv) noexcept
Returns the absolute value of the matrix.
civector operator*(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of multiplication operation.
void Resize(cimatrix &A) noexcept
Resizes the matrix.
cimatrix & SetUb(cimatrix &m, const int &i, const int &j) noexcept
Sets the upper bound index.
int Lb(const cimatrix &rm, const int &i) noexcept
Returns the lower bound index.
cimatrix & operator/=(cimatrix &m, const cinterval &c) noexcept
Implementation of division and allocation operation.