26 #ifndef _CXSC_RMATRIX_INL_INCLUDED
27 #define _CXSC_RMATRIX_INL_INCLUDED
29 #include "intmatrix.hpp"
33 INLINE
rmatrix::rmatrix() noexcept:dat(NULL),lb1(1),ub1(0),lb2(1),ub2(0),xsize(0),ysize(0)
43 INLINE
rmatrix::rmatrix(
const rmatrix &rm) noexcept:lb1(rm.lb1),ub1(rm.ub1),lb2(rm.lb2),ub2(rm.ub2),xsize(rm.xsize),ysize(rm.ysize)
45 dat=
new real[xsize*ysize];
46 for(
int i=0;i<xsize*ysize;i++)
52 :lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m)
54 noexcept:lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m)
58 if((n<0)||(m<0)) cxscthrow(ERROR_RMATRIX_WRONG_BOUNDARIES(
"rmatrix::rmatrix(const int &m, const int &n)"));
65 :lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1)
67 noexcept:lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1)
71 if((m2<m1)||(n2<n1)) cxscthrow(ERROR_RMATRIX_WRONG_BOUNDARIES(
"rmatrix::rmatrix(const int &m1, const int &n1, const int &m2, const int &n2)"));
73 dat=
new real[xsize*ysize];
79 for (
int i=0, j=v.start;i<v.size;i++,j+=v.offset)
86 for(
int i=0;i<v.size;i++)
93 for(
int i=0,j=v.start-v.l;i<v.size;i++,j++)
102 dat=
new real[xsize*ysize];
103 for (i=0;i<ysize;i++)
107 dat[i*xsize+j]=sl.dat[(sl.offset1+i)*sl.mxsize+sl.offset2+j];
113 dat=
new real[xsize*ysize];
114 for(
int i=0 ; i<ysize ; i++)
115 for(
int j=0 ; j<xsize ; j++)
116 dat[i*xsize+j] = I[i+lb1][j+lb2];
120 #if(CXSC_INDEX_CHECK)
131 #if(CXSC_INDEX_CHECK)
141 #if(CXSC_INDEX_CHECK)
152 #if(CXSC_INDEX_CHECK)
163 #if(CXSC_INDEX_CHECK)
169 #if(CXSC_INDEX_CHECK)
170 if((i<lb)||(i>ub)) cxscthrow(ERROR_RVECTOR_ELEMENT_NOT_IN_VEC(
"real &rmatrix_subv::operator [](const int &i) const"));
172 return dat[start+((i-lb)*offset)];
176 #if(CXSC_INDEX_CHECK)
182 #if(CXSC_INDEX_CHECK)
183 if((i<lb)||(i>ub)) cxscthrow(ERROR_RVECTOR_ELEMENT_NOT_IN_VEC(
"real &rmatrix_subv::operator [](const int &i)"));
185 return dat[start+((i-lb)*offset)];
191 #if(CXSC_INDEX_CHECK)
197 #if(CXSC_INDEX_CHECK)
198 if((i<lb1)||(i>ub1)) cxscthrow(ERROR_RMATRIX_ROW_OR_COL_NOT_IN_MAT(
"rmatrix_subv rmatrix::operator [](const int &i)"));
200 return rmatrix_subv(dat, lb2, ub2, xsize, xsize*(i-lb1),1);
204 #if(CXSC_INDEX_CHECK)
210 #if(CXSC_INDEX_CHECK)
211 if((i.col()<lb2)||(i.col()>ub2)) cxscthrow(ERROR_RMATRIX_ROW_OR_COL_NOT_IN_MAT(
"rmatrix_subv rmatrix::operator [](const cxscmatrix_column &i)"));
213 return rmatrix_subv(dat, lb1, ub1, ysize, i.col()-lb2, xsize);
217 #if(CXSC_INDEX_CHECK)
223 #if(CXSC_INDEX_CHECK)
224 if((m<1)||(n<1)||(m<lb1)||(n<lb2)||(m>ub1)||(n>ub2)) cxscthrow(ERROR_RMATRIX_SUB_ARRAY_TOO_BIG(
"rmatrix_slice rmatrix::operator ()(const int &m, const int &n)"));
230 #if(CXSC_INDEX_CHECK)
236 #if(CXSC_INDEX_CHECK)
237 if((m1<lb1)||(n1<lb2)||(m2>ub1)||(n2>ub2)) cxscthrow(ERROR_RMATRIX_SUB_ARRAY_TOO_BIG(
"rmatrix_slice rmatrix::operator ()(const int &m1, const int &n1, const int &m2, const int &n2)"));
243 #if(CXSC_INDEX_CHECK)
249 #if(CXSC_INDEX_CHECK)
250 if((i<start1)||(i>end1)) cxscthrow(ERROR_RMATRIX_ROW_OR_COL_NOT_IN_MAT(
"rmatrix_subv rmatrix_slice::operator [](const int &i)"));
252 return rmatrix_subv(dat, start2, end2, sxsize, mxsize*(i-start1+offset1)+offset2,1);
256 #if(CXSC_INDEX_CHECK)
262 #if(CXSC_INDEX_CHECK)
263 if((i.col()<start2)||(i.col()>end2)) cxscthrow(ERROR_RMATRIX_ROW_OR_COL_NOT_IN_MAT(
"rmatrix_subv rmatrix_slice::operator [](const cxscmatrix_column &i)"));
265 return rmatrix_subv(dat, start1, end1, sysize, offset1*mxsize+i.col()-start2+offset2, mxsize);
269 #if(CXSC_INDEX_CHECK)
275 #if(CXSC_INDEX_CHECK)
276 if((m<1)||(n<1)||(m<start1)||(n<start2)||(m>end1)||(n>end2)) cxscthrow(ERROR_RMATRIX_SUB_ARRAY_TOO_BIG(
"rmatrix_slice rmatrix_slice::operator ()(const int &m, const int &n)"));
282 #if(CXSC_INDEX_CHECK)
288 #if(CXSC_INDEX_CHECK)
289 if((m1<start1)||(n1<start2)||(m2>end1)||(n2>end2)) cxscthrow(ERROR_RMATRIX_SUB_ARRAY_TOO_BIG(
"rmatrix_slice rmatrix_slice::operator ()(const int &m1, const int &m2, const int &n1, const int &n2)"));
295 #if(CXSC_INDEX_CHECK)
301 #if(CXSC_INDEX_CHECK)
302 if(1<lb||i>ub) cxscthrow(ERROR_RVECTOR_SUB_ARRAY_TOO_BIG(
"rmatrix_subv rmatrix_subv::operator ()(const int &i)"));
304 return rmatrix_subv(dat,1,i,i,start+(1-lb)*offset,offset);
308 #if(CXSC_INDEX_CHECK)
314 #if(CXSC_INDEX_CHECK)
315 if(i1<lb||i2>ub) cxscthrow(ERROR_RVECTOR_SUB_ARRAY_TOO_BIG(
"rmatrix_subv rmatrix_subv::operator ()(const int &i1,const int &i2)"));
317 return rmatrix_subv(dat,i1,i2,i2-i1+1,start+(i1-lb)*offset,offset);
325 #if(CXSC_INDEX_CHECK)
330 {
return _mvvassign(*
this,v); }
332 #if(CXSC_INDEX_CHECK)
337 {
return _mvvassign(*
this,
rvector(v)); }
342 INLINE rmatrix::operator
void*() noexcept {
return _mvoid(*
this); }
344 #if(CXSC_INDEX_CHECK)
349 {
return _msmassign(*
this,m); }
351 #if(CXSC_INDEX_CHECK)
356 {
return _msmsassign(*
this,ms); }
359 #if(CXSC_INDEX_CHECK)
364 {
return _msmassign(*
this,
rmatrix(v)); }
366 #if(CXSC_INDEX_CHECK)
373 #if(CXSC_INDEX_CHECK)
380 #if(CXSC_INDEX_CHECK)
385 {
return _msmplusassign(*
this,m1); }
387 #if(CXSC_INDEX_CHECK)
392 {
return _msmsplusassign(*
this,ms2); }
394 #if(CXSC_INDEX_CHECK)
399 {
return _msmminusassign(*
this,m1); }
401 #if(CXSC_INDEX_CHECK)
406 {
return _msmsminusassign(*
this,ms2); }
408 #if(CXSC_INDEX_CHECK)
413 {
return (*
this=*
this*m); }
415 #if(CXSC_INDEX_CHECK)
420 {
return (*
this=*
this*m); }
423 INLINE rmatrix_slice::operator
void*() noexcept {
return _msvoid(*
this); }
437 #if(CXSC_INDEX_CHECK)
442 {
return _mvmvmult<rmatrix_subv,rmatrix_subv,real>(rv1,rv2); }
444 #if(CXSC_INDEX_CHECK)
449 {
return _vmvmult<rvector,rmatrix_subv,real>(rv1,rv2); }
451 #if(CXSC_INDEX_CHECK)
456 {
return _vmvmult<rvector,rmatrix_subv,real>(rv2,rv1); }
458 #if(CXSC_INDEX_CHECK)
463 {
return _vmvmult<rvector,rmatrix_subv,real>(
rvector(sl),sv); }
465 #if(CXSC_INDEX_CHECK)
470 {
return _vmvmult<rvector,rmatrix_subv,real>(
rvector(vs),mv); }
472 #if(CXSC_INDEX_CHECK)
477 {
return _mvmvplus<rmatrix_subv,rmatrix_subv,rvector>(rv1,rv2); }
479 #if(CXSC_INDEX_CHECK)
484 {
return _mvvplus<rmatrix_subv,rvector,rvector>(rv1,rv2); }
486 #if(CXSC_INDEX_CHECK)
491 {
return _mvvplus<rmatrix_subv,rvector,rvector>(rv2,rv1); }
493 #if(CXSC_INDEX_CHECK)
498 {
return _mvvplus<rmatrix_subv,rvector,rvector>(mv,
rvector(sl)); }
500 #if(CXSC_INDEX_CHECK)
505 {
return _mvvplus<rmatrix_subv,rvector,rvector>(mv,
rvector(sl)); }
507 #if(CXSC_INDEX_CHECK)
512 {
return _mvvplusassign(*
this,rv); }
514 #if(CXSC_INDEX_CHECK)
519 {
return _mvvplusassign(*
this,
rvector(rv)); }
521 #if(CXSC_INDEX_CHECK)
526 {
return _mvmvminus<rmatrix_subv,rmatrix_subv,rvector>(rv1,rv2); }
528 #if(CXSC_INDEX_CHECK)
533 {
return _vmvminus<rvector,rmatrix_subv,rvector>(rv1,rv2); }
535 #if(CXSC_INDEX_CHECK)
540 {
return _mvvminus<rmatrix_subv,rvector,rvector>(rv1,rv2); }
542 #if(CXSC_INDEX_CHECK)
547 {
return _vmvminus<rvector,rmatrix_subv,rvector>(
rvector(sl),mv); }
549 #if(CXSC_INDEX_CHECK)
554 {
return _mvvminus<rmatrix_subv,rvector,rvector>(mv,
rvector(sl)); }
556 #if(CXSC_INDEX_CHECK)
561 {
return _mvvminusassign(*
this,rv); }
563 #if(CXSC_INDEX_CHECK)
568 {
return _mvvminusassign(*
this,
rvector(rv)); }
595 #if(CXSC_INDEX_CHECK)
600 {
return _mlb(rm,i); }
602 #if(CXSC_INDEX_CHECK)
607 {
return _mub(rm,i); }
609 #if(CXSC_INDEX_CHECK)
614 {
return _mslb(rm,i); }
616 #if(CXSC_INDEX_CHECK)
621 {
return _msub(rm,i); }
623 #if(CXSC_INDEX_CHECK)
628 {
return _msetlb(m,i,j); }
630 #if(CXSC_INDEX_CHECK)
635 {
return _msetub(m,i,j); }
639 {
return Ub(A,2)-
Lb(A,2)+1; }
642 {
return Ub(A,1)-
Lb(A,1)+1; }
645 {
return Ub(A,2)-
Lb(A,2)+1; }
648 {
return Ub(A,1)-
Lb(A,1)+1; }
652 #if(CXSC_INDEX_CHECK)
657 { _mresize<rmatrix,real>(A,m,n); }
658 INLINE
void Resize(
rmatrix &A,
const int &m1,
const int &m2,
const int &n1,
const int &n2)
659 #if(CXSC_INDEX_CHECK)
664 { _mresize<rmatrix,real>(A,m1,m2,n1,n2); }
668 #if(CXSC_INDEX_CHECK)
673 { _smconstr(*
this,m); }
684 #if(CXSC_INDEX_CHECK)
689 { _vmconstr<rvector,rmatrix,real>(*
this,sl); }
691 #if(CXSC_INDEX_CHECK)
696 { _vmsconstr<rvector,rmatrix_slice,real>(*
this,sl); }
698 #if(CXSC_INDEX_CHECK)
703 {
return _vmassign<rvector,rmatrix,real>(*
this,m); }
705 #if(CXSC_INDEX_CHECK)
710 {
return _vmassign<rvector,rmatrix,real>(*
this,
rmatrix(m)); }
712 #if(CXSC_INDEX_CHECK)
717 {
return _vsvassign(*
this,
rvector(m)); }
719 #if(CXSC_INDEX_CHECK)
726 #if(CXSC_INDEX_CHECK)
731 {
return _mvvassign(*
this,
rvector(m)); }
733 #if(CXSC_INDEX_CHECK)
740 #if(CXSC_INDEX_CHECK)
745 {
return _mvmult<rmatrix,rvector,rvector>(m,v); };
747 #if(CXSC_INDEX_CHECK)
752 {
return _msvmult<rmatrix_slice,rvector,rvector>(ms,v); }
754 #if(CXSC_INDEX_CHECK)
759 {
return _vmmult<rvector,rmatrix,rvector>(v,m); }
761 #if(CXSC_INDEX_CHECK)
766 {
return _vmsmult<rvector,rmatrix_slice,rvector>(v,ms); }
768 #if(CXSC_INDEX_CHECK)
773 {
return _vmmultassign<rvector,rmatrix,real>(v,m); }
775 #if(CXSC_INDEX_CHECK)
780 {
return _vmsmultassign<rvector,rmatrix_slice,real>(v,ms); }
782 #if(CXSC_INDEX_CHECK)
787 {
return _vsmmultassign<rvector_slice,rmatrix,real>(*
this,m); }
789 #if(CXSC_INDEX_CHECK)
794 {
return _vmmult<rvector,rmatrix,rvector>(
rvector(v),m); }
799 #if(CXSC_INDEX_CHECK)
804 {
return _mmplus<rmatrix,rmatrix,rmatrix>(m1,m2); }
806 #if(CXSC_INDEX_CHECK)
811 {
return _mmsplus<rmatrix,rmatrix_slice,rmatrix>(m,ms); }
813 #if(CXSC_INDEX_CHECK)
818 {
return _mmsplus<rmatrix,rmatrix_slice,rmatrix>(m,ms); }
820 #if(CXSC_INDEX_CHECK)
825 {
return _msmsplus<rmatrix_slice,rmatrix_slice,rmatrix>(m1,m2); }
827 #if(CXSC_INDEX_CHECK)
832 {
return _mmplusassign(m1,m2); }
834 #if(CXSC_INDEX_CHECK)
839 {
return _mmsplusassign(m1,ms); }
843 #if(CXSC_INDEX_CHECK)
848 {
return _mmminus<rmatrix,rmatrix,rmatrix>(m1,m2); }
850 #if(CXSC_INDEX_CHECK)
855 {
return _mmsminus<rmatrix,rmatrix_slice,rmatrix>(m,ms); }
857 #if(CXSC_INDEX_CHECK)
862 {
return _msmminus<rmatrix_slice,rmatrix,rmatrix>(ms,m); }
864 #if(CXSC_INDEX_CHECK)
869 {
return _msmsminus<rmatrix_slice,rmatrix_slice,rmatrix>(ms1,ms2); }
871 #if(CXSC_INDEX_CHECK)
876 {
return _mmminusassign(m1,m2); }
878 #if(CXSC_INDEX_CHECK)
883 {
return _mmsminusassign(m1,ms); }
885 #if(CXSC_INDEX_CHECK)
890 {
return _mmmult<rmatrix,rmatrix,rmatrix>(m1,m2); }
892 #if(CXSC_INDEX_CHECK)
897 {
return _mmsmult<rmatrix,rmatrix_slice,rmatrix>(m1,ms); }
899 #if(CXSC_INDEX_CHECK)
904 {
return _msmmult<rmatrix_slice,rmatrix,rmatrix>(ms,m1); }
906 #if(CXSC_INDEX_CHECK)
911 {
return _msmsmult<rmatrix_slice,rmatrix_slice,rmatrix>(ms1,ms2); }
913 #if(CXSC_INDEX_CHECK)
918 {
return _mmmultassign<rmatrix,rmatrix,real>(m1,m2); }
920 #if(CXSC_INDEX_CHECK)
925 {
return _mmsmultassign<rmatrix,rmatrix_slice,real>(m1,ms); }
926 INLINE
bool operator ==(
const rmatrix &m1,
const rmatrix &m2) noexcept {
return _mmeq(m1,m2); }
927 INLINE
bool operator !=(
const rmatrix &m1,
const rmatrix &m2) noexcept {
return _mmneq(m1,m2); }
928 INLINE
bool operator <(
const rmatrix &m1,
const rmatrix &m2) noexcept {
return _mmless(m1,m2); }
929 INLINE
bool operator <=(
const rmatrix &m1,
const rmatrix &m2) noexcept {
return _mmleq(m1,m2); }
930 INLINE
bool operator >(
const rmatrix &m1,
const rmatrix &m2) noexcept {
return _mmless(m2,m1); }
931 INLINE
bool operator >=(
const rmatrix &m1,
const rmatrix &m2) noexcept {
return _mmleq(m2,m1); }
944 INLINE
bool operator !(
const rmatrix &ms) noexcept {
return _mnot(ms); }
945 INLINE
bool operator !(
const rmatrix_slice &ms) noexcept {
return _msnot(ms); }
946 INLINE std::ostream &operator <<(std::ostream &s,
const rmatrix &r) noexcept {
return _mout(s,r); }
947 INLINE std::ostream &operator <<(std::ostream &s,
const rmatrix_slice &r) noexcept {
return _msout(s,r); }
948 INLINE std::istream &operator >>(std::istream &s,
rmatrix &r) noexcept {
return _min(s,r); }
949 INLINE std::istream &operator >>(std::istream &s,
rmatrix_slice &r) noexcept {
return _msin(s,r); }
954 for(
int i=0 ; i<
ColLen(A) ; i++)
955 for(
int j=0 ; j<
RowLen(A) ; j++)
956 A[i+
Lb(A,1)][j+
Lb(A,2)] = (*this)[p[i+
Lb(p)]+
Lb(A,1)][q[j+
Lb(q)]+
Lb(A,2)];
963 for(
int i=0 ; i<
ColLen(A) ; i++)
964 A[i+
Lb(A,1)] = (*this)[p[i+
Lb(p)]+
Lb(A,1)];
real(void) noexcept
Constructor of class real.
The Data Type rmatrix_slice.
rmatrix_slice & operator=(const srmatrix &m)
Implementation of standard assigning operator.
rmatrix_subv operator[](const int &i) const noexcept
Operator for accessing a single row of the matrix.
rmatrix_slice & operator-=(const srmatrix &m)
Implementation of multiplication and allocation operation.
rmatrix_slice & operator*=(const srmatrix &m)
Implementation of multiplication and allocation operation.
rmatrix_slice & operator+=(const srmatrix &m)
Implementation of multiplication and allocation operation.
rmatrix_slice & operator/=(const real &c) noexcept
Implementation of division and allocation operation.
rmatrix_slice & operator()() noexcept
Operator for accessing the whole matrix.
The Data Type rmatrix_subv.
rmatrix_subv & operator()() noexcept
Operator for accessing the whole vector.
rmatrix_subv & operator+=(const real &c) noexcept
Implementation of addition and allocation operation.
rmatrix_subv & operator=(const rmatrix_subv &rv) noexcept
Implementation of standard assigning operator.
rmatrix_subv & operator/=(const real &c) noexcept
Implementation of division and allocation operation.
rmatrix_subv & operator*=(const real &c) noexcept
Implementation of multiplication and allocation operation.
real & operator[](const int &i) const noexcept
Operator for accessing the single elements of the vector (read-only)
rmatrix_subv & operator-=(const real &c) noexcept
Implementation of subtraction and allocation operation.
rmatrix_subv operator[](const int &i) const noexcept
Operator for accessing a single row of the matrix.
rmatrix & operator=(const real &r) noexcept
Implementation of standard assigning operator.
rmatrix() noexcept
Constructor of class rmatrix.
rmatrix & operator()() noexcept
Operator for accessing the whole matrix.
The Data Type rvector_slice.
rvector_slice & operator=(const rvector_slice &sl) noexcept
Implementation of standard assigning operator.
rvector_slice & operator*=(const real &r) noexcept
Implementation of multiplication and allocation operation.
rvector & operator=(const rvector &rv) noexcept
Implementation of standard assigning operator.
rvector & operator()() noexcept
Operator for accessing the whole vector.
rvector() noexcept
Constructor of class rvector.
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 ColLen(const cimatrix &)
Returns the column dimension.
rmatrix _rmatrix(const rmatrix &rm) noexcept
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
civector operator/(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of division operation.
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.
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.