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++)
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];
174 if((i<lb1)||(i>ub1)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT(
"intmatrix_subv intmatrix::operator [](const int &i)"));
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)"));
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)"));
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)"));
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);
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);
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)"));
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)"));
278 if(1<lb||i>ub) cxscthrow(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG(
"intmatrix_subv intmatrix_subv::operator ()(const int &i)"));
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);
304 {
return _mvvassign(*
this,v); }
311 {
return _mvvassign(*
this,
intvector(v)); }
316 INLINE intmatrix::operator
void*()
noexcept {
return _mvoid(*
this); }
323 {
return _msmassign(*
this,m); }
330 {
return _msmsassign(*
this,ms); }
338 {
return _msmassign(*
this,
intmatrix(v)); }
359 {
return _msmplusassign(*
this,m1); }
366 {
return _msmsplusassign(*
this,ms2); }
373 {
return _msmminusassign(*
this,m1); }
380 {
return _msmsminusassign(*
this,ms2); }
383 INLINE intmatrix_slice::operator
void*()
noexcept {
return _msvoid(*
this); }
401 { _mvmvaccu(dp,rv1,rv2); }
408 { _vmvaccu(dp,rv1,rv2); }
415 { _vmvaccu(dp,rv2,rv1); }
436 {
return _mvmvplus<intmatrix_subv,intmatrix_subv,intvector>(rv1,rv2); }
443 {
return _mvvplus<intmatrix_subv,intvector,intvector>(rv1,rv2); }
450 {
return _mvvplus<intmatrix_subv,intvector,intvector>(rv2,rv1); }
457 {
return _mvvplus<intmatrix_subv,intvector,intvector>(mv,
intvector(sl)); }
464 {
return _mvvplus<intmatrix_subv,intvector,intvector>(mv,
intvector(sl)); }
471 {
return _mvvplusassign(*
this,rv); }
478 {
return _mvvplusassign(*
this,
intvector(rv)); }
485 {
return _mvmvminus<intmatrix_subv,intmatrix_subv,intvector>(rv1,rv2); }
492 {
return _vmvminus<intvector,intmatrix_subv,intvector>(rv1,rv2); }
499 {
return _mvvminus<intmatrix_subv,intvector,intvector>(rv1,rv2); }
506 {
return _vmvminus<intvector,intmatrix_subv,intvector>(
intvector(sl),mv); }
513 {
return _mvvminus<intmatrix_subv,intvector,intvector>(mv,
intvector(sl)); }
520 {
return _mvvminusassign(*
this,rv); }
527 {
return _mvvminusassign(*
this,
intvector(rv)); }
559 {
return _mlb(rm,i); }
566 {
return _mub(rm,i); }
573 {
return _mslb(rm,i); }
580 {
return _msub(rm,i); }
587 {
return _msetlb(m,i,j); }
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; }
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)
622 { _mresize<intmatrix,int>(A,m1,m2,n1,n2); }
639 { _vmconstr<intvector,intmatrix,int>(*
this,sl); }
646 { _vmsconstr<intvector,intmatrix_slice,int>(*
this,sl); }
653 {
return _vmassign<intvector,intmatrix,int>(*
this,m); }
660 {
return _vmassign<intvector,intmatrix,int>(*
this,
intmatrix(m)); }
667 {
return _vsvassign(*
this,
intvector(m)); }
681 {
return _mvvassign(*
this,
intvector(m)); }
698 {
return _mmplus<intmatrix,intmatrix,intmatrix>(m1,m2); }
705 {
return _mmsplus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
712 {
return _mmsplus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
719 {
return _msmsplus<intmatrix_slice,intmatrix_slice,intmatrix>(m1,m2); }
726 {
return _mmplusassign(m1,m2); }
733 {
return _mmsplusassign(m1,ms); }
742 {
return _mmminus<intmatrix,intmatrix,intmatrix>(m1,m2); }
749 {
return _mmsminus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
756 {
return _msmminus<intmatrix_slice,intmatrix,intmatrix>(ms,m); }
763 {
return _msmsminus<intmatrix_slice,intmatrix_slice,intmatrix>(ms1,ms2); }
770 {
return _mmminusassign(m1,m2); }
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_slice & operator()() noexcept
Operator for accessing the whole matrix.
intmatrix_subv operator[](const int &i) noexcept
Operator for accessing a single row of the 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=(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()() noexcept
Operator for accessing the whole vector.
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()() noexcept
Operator for accessing the whole matrix.
intmatrix & operator=(const int &r) noexcept
Implementation of standard assigning operator.
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.
int VecLen(const scimatrix_subv &S)
Returns the length of the subvector.
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc) noexcept
Implementation of standard algebraic addition and allocation operation.
cimatrix_subv Col(cimatrix &m, const int &i) noexcept
Returns one column of the matrix as a vector.
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.
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.
cimatrix_subv Row(cimatrix &m, const int &i) noexcept
Returns one row of the matrix as a vector.
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.