26#ifndef _CXSC_RMATRIX_INL_INCLUDED
27#define _CXSC_RMATRIX_INL_INCLUDED
29#include "intmatrix.hpp"
33INLINE
rmatrix::rmatrix() noexcept:dat(NULL),lb1(1),ub1(0),lb2(1),ub2(0),xsize(0),ysize(0)
43INLINE
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];
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)];
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)];
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);
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);
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)"));
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)"));
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);
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);
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)"));
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)"));
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);
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);
330 {
return _mvvassign(*
this,v); }
337 {
return _mvvassign(*
this,
rvector(v)); }
342 INLINE rmatrix::operator
void*()
noexcept {
return _mvoid(*
this); }
349 {
return _msmassign(*
this,m); }
356 {
return _msmsassign(*
this,ms); }
364 {
return _msmassign(*
this,
rmatrix(v)); }
385 {
return _msmplusassign(*
this,m1); }
392 {
return _msmsplusassign(*
this,ms2); }
399 {
return _msmminusassign(*
this,m1); }
406 {
return _msmsminusassign(*
this,ms2); }
413 {
return (*
this=*
this*m); }
420 {
return (*
this=*
this*m); }
423 INLINE rmatrix_slice::operator
void*()
noexcept {
return _msvoid(*
this); }
442 {
return _mvmvmult<rmatrix_subv,rmatrix_subv,real>(rv1,rv2); }
449 {
return _vmvmult<rvector,rmatrix_subv,real>(rv1,rv2); }
456 {
return _vmvmult<rvector,rmatrix_subv,real>(rv2,rv1); }
463 {
return _vmvmult<rvector,rmatrix_subv,real>(
rvector(sl),sv); }
470 {
return _vmvmult<rvector,rmatrix_subv,real>(
rvector(vs),mv); }
477 {
return _mvmvplus<rmatrix_subv,rmatrix_subv,rvector>(rv1,rv2); }
484 {
return _mvvplus<rmatrix_subv,rvector,rvector>(rv1,rv2); }
491 {
return _mvvplus<rmatrix_subv,rvector,rvector>(rv2,rv1); }
498 {
return _mvvplus<rmatrix_subv,rvector,rvector>(mv,
rvector(sl)); }
505 {
return _mvvplus<rmatrix_subv,rvector,rvector>(mv,
rvector(sl)); }
512 {
return _mvvplusassign(*
this,rv); }
519 {
return _mvvplusassign(*
this,
rvector(rv)); }
526 {
return _mvmvminus<rmatrix_subv,rmatrix_subv,rvector>(rv1,rv2); }
533 {
return _vmvminus<rvector,rmatrix_subv,rvector>(rv1,rv2); }
540 {
return _mvvminus<rmatrix_subv,rvector,rvector>(rv1,rv2); }
547 {
return _vmvminus<rvector,rmatrix_subv,rvector>(
rvector(sl),mv); }
554 {
return _mvvminus<rmatrix_subv,rvector,rvector>(mv,
rvector(sl)); }
561 {
return _mvvminusassign(*
this,rv); }
568 {
return _mvvminusassign(*
this,
rvector(rv)); }
600 {
return _mlb(rm,i); }
607 {
return _mub(rm,i); }
614 {
return _mslb(rm,i); }
621 {
return _msub(rm,i); }
628 {
return _msetlb(m,i,j); }
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; }
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)
664 { _mresize<rmatrix,real>(A,m1,m2,n1,n2); }
673 { _smconstr(*
this,m); }
689 { _vmconstr<rvector,rmatrix,real>(*
this,sl); }
696 { _vmsconstr<rvector,rmatrix_slice,real>(*
this,sl); }
703 {
return _vmassign<rvector,rmatrix,real>(*
this,m); }
710 {
return _vmassign<rvector,rmatrix,real>(*
this,
rmatrix(m)); }
717 {
return _vsvassign(*
this,
rvector(m)); }
731 {
return _mvvassign(*
this,
rvector(m)); }
745 {
return _mvmult<rmatrix,rvector,rvector>(m,v); };
752 {
return _msvmult<rmatrix_slice,rvector,rvector>(ms,v); }
759 {
return _vmmult<rvector,rmatrix,rvector>(v,m); }
766 {
return _vmsmult<rvector,rmatrix_slice,rvector>(v,ms); }
773 {
return _vmmultassign<rvector,rmatrix,real>(v,m); }
780 {
return _vmsmultassign<rvector,rmatrix_slice,real>(v,ms); }
787 {
return _vsmmultassign<rvector_slice,rmatrix,real>(*
this,m); }
794 {
return _vmmult<rvector,rmatrix,rvector>(
rvector(v),m); }
804 {
return _mmplus<rmatrix,rmatrix,rmatrix>(m1,m2); }
811 {
return _mmsplus<rmatrix,rmatrix_slice,rmatrix>(m,ms); }
818 {
return _mmsplus<rmatrix,rmatrix_slice,rmatrix>(m,ms); }
825 {
return _msmsplus<rmatrix_slice,rmatrix_slice,rmatrix>(m1,m2); }
832 {
return _mmplusassign(m1,m2); }
839 {
return _mmsplusassign(m1,ms); }
848 {
return _mmminus<rmatrix,rmatrix,rmatrix>(m1,m2); }
855 {
return _mmsminus<rmatrix,rmatrix_slice,rmatrix>(m,ms); }
862 {
return _msmminus<rmatrix_slice,rmatrix,rmatrix>(ms,m); }
869 {
return _msmsminus<rmatrix_slice,rmatrix_slice,rmatrix>(ms1,ms2); }
876 {
return _mmminusassign(m1,m2); }
883 {
return _mmsminusassign(m1,ms); }
890 {
return _mmmult<rmatrix,rmatrix,rmatrix>(m1,m2); }
897 {
return _mmsmult<rmatrix,rmatrix_slice,rmatrix>(m1,ms); }
904 {
return _msmmult<rmatrix_slice,rmatrix,rmatrix>(ms,m1); }
911 {
return _msmsmult<rmatrix_slice,rmatrix_slice,rmatrix>(ms1,ms2); }
918 {
return _mmmultassign<rmatrix,rmatrix,real>(m1,m2); }
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.
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.
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.
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.
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.