Go to the documentation of this file.00001
00002
00003 inline zgsmatrix& zgsmatrix::operator=(const zgsmatrix& mat)
00004 {VERBOSE_REPORT;
00005 if(&data!=&mat.data){
00006 copy(mat);
00007 }
00008 return *this;
00009 }
00010
00011
00012
00013
00014
00015
00016
00017 inline zgsmatrix& zgsmatrix::operator+=(const zgsmatrix& mat)
00018 {VERBOSE_REPORT;
00019 #ifdef CPPL_DEBUG
00020 if(n!=mat.n || m!=mat.m){
00021 ERROR_REPORT;
00022 std::cerr << "These two matrises can not make a summation." << std::endl
00023 << "Your input was (" << m << "x" << n << ") += (" << mat.m << "x" << mat.n << ")." << std::endl;
00024 exit(1);
00025 }
00026 #endif//CPPL_DEBUG
00027
00028 for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00029 (*this)(it->i,it->j) +=it->v;
00030 }
00031 return *this;
00032 }
00033
00034
00035
00036 inline zgsmatrix& zgsmatrix::operator-=(const zgsmatrix& mat)
00037 {VERBOSE_REPORT;
00038 #ifdef CPPL_DEBUG
00039 if(n!=mat.n || m!=mat.m){
00040 ERROR_REPORT;
00041 std::cerr << "These two matrises can not make a sutraction." << std::endl
00042 << "Your input was (" << m << "x" << n << ") -= (" << mat.m << "x" << mat.n << ")." << std::endl;
00043 exit(1);
00044 }
00045 #endif//CPPL_DEBUG
00046
00047 for(std::vector<zcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00048 (*this)(it->i,it->j) -=it->v;
00049 }
00050 return *this;
00051 }
00052
00053
00054
00055 inline zgsmatrix& zgsmatrix::operator*=(const zgsmatrix& mat)
00056 {VERBOSE_REPORT;
00057 #ifdef CPPL_DEBUG
00058 if(n!=mat.m){
00059 ERROR_REPORT;
00060 std::cerr << "These two matrises can not make a product." << std::endl
00061 << "Your input was (" << m << "x" << n << ") *= (" << mat.m << "x" << mat.n << ")." << std::endl;
00062 exit(1);
00063 }
00064 #endif//CPPL_DEBUG
00065
00066 zgsmatrix newmat(m, mat.n);
00067
00068 for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data.end(); it++){
00069 long k(it->j);
00070 std::vector<uint32_t>::const_iterator p;
00071 for(p=mat.rows[k].begin(); p!=mat.rows[k].end(); p++){
00072 newmat(it->i,mat.data[*p].j) +=it->v*mat.data[*p].v;
00073 }
00074 }
00075
00076 swap(*this,newmat);
00077 return *this;
00078 }
00079
00080
00081
00082
00083
00084
00085
00086 inline _zgsmatrix operator+(const zgsmatrix& matA, const zgsmatrix& matB)
00087 {VERBOSE_REPORT;
00088 #ifdef CPPL_DEBUG
00089 if(matA.n!=matB.n || matA.m!=matB.m){
00090 ERROR_REPORT;
00091 std::cerr << "These two matrises can not make a summation." << std::endl
00092 << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
00093 exit(1);
00094 }
00095 #endif//CPPL_DEBUG
00096
00097 zgsmatrix newmat(matA);
00098 for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00099 newmat(it->i, it->j) +=it->v;
00100 }
00101 return _(newmat);
00102 }
00103
00104
00105
00106 inline _zgsmatrix operator-(const zgsmatrix& matA, const zgsmatrix& matB)
00107 {VERBOSE_REPORT;
00108 #ifdef CPPL_DEBUG
00109 if(matA.n!=matB.n || matA.m!=matB.m){
00110 ERROR_REPORT;
00111 std::cerr << "These two matrises can not make a subtraction." << std::endl
00112 << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.m << "x" << matB.n << ")." << std::endl;
00113 exit(1);
00114 }
00115 #endif//CPPL_DEBUG
00116
00117 zgsmatrix newmat(matA);
00118 for(std::vector<zcomponent>::const_iterator it=matB.data.begin(); it!=matB.data.end(); it++){
00119 newmat(it->i, it->j) -=it->v;
00120 }
00121 return _(newmat);
00122 }
00123
00124
00125
00126 inline _zgsmatrix operator*(const zgsmatrix& matA, const zgsmatrix& matB)
00127 {VERBOSE_REPORT;
00128 #ifdef CPPL_DEBUG
00129 if(matA.n!=matB.m){
00130 ERROR_REPORT;
00131 std::cerr << "These two matrises can not make a product." << std::endl
00132 << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.m << "x" << matB.n << ")." << std::endl;
00133 exit(1);
00134 }
00135 #endif//CPPL_DEBUG
00136
00137 zgsmatrix newmat(matA.m, matB.n);
00138
00139 for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA.data.end(); it++){
00140 long k(it->j);
00141 std::vector<uint32_t>::const_iterator p;
00142 for(p=matB.rows[k].begin(); p!=matB.rows[k].end(); p++){
00143 newmat(it->i,matB.data[*p].j) +=it->v*matB.data[*p].v;
00144 }
00145 }
00146
00147 return _(newmat);
00148 }