Go to the documentation of this file.00001
00002
00003 inline _zgematrix operator+(const _zgsmatrix& matA, const _zhematrix& matB)
00004 {VERBOSE_REPORT;
00005 #ifdef CPPL_DEBUG
00006 if(matA.m!=matB.n || matA.n!=matB.n){
00007 ERROR_REPORT;
00008 std::cerr << "These two matrises can not make a summation." << std::endl
00009 << "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.n << "x" << matB.n << ")." << std::endl;
00010 exit(1);
00011 }
00012 #endif//CPPL_DEBUG
00013
00014 zgematrix newmat( matB.to_zgematrix() );
00015
00016 for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA.data.end(); it++){
00017 newmat(it->i,it->j) += it->v;
00018 }
00019
00020 matA.destroy();
00021 matB.destroy();
00022 return _(newmat);
00023 }
00024
00025
00026
00027 inline _zgematrix operator-(const _zgsmatrix& matA, const _zhematrix& matB)
00028 {VERBOSE_REPORT;
00029 #ifdef CPPL_DEBUG
00030 if(matA.m!=matB.n || matA.n!=matB.n){
00031 ERROR_REPORT;
00032 std::cerr << "These two matrises can not make a subtraction." << std::endl
00033 << "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
00034 exit(1);
00035 }
00036 #endif//CPPL_DEBUG
00037
00038
00039 zgematrix newmat( (-matB).to_zgematrix() );
00040
00041 for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA.data.end(); it++){
00042 newmat(it->i,it->j) += it->v;
00043 }
00044
00045 matA.destroy();
00046 matB.destroy();
00047 return _(newmat);
00048 }
00049
00050
00051
00052 inline _zgematrix operator*(const _zgsmatrix& matA, const _zhematrix& matB)
00053 {VERBOSE_REPORT;
00054 #ifdef CPPL_DEBUG
00055 if(matA.n!=matB.n){
00056 ERROR_REPORT;
00057 std::cerr << "These two matrises can not make a product." << std::endl
00058 << "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
00059 exit(1);
00060 }
00061 #endif//CPPL_DEBUG
00062
00063 zgematrix newmat(matA.m, matB.n);
00064 newmat.zero();
00065
00066 for(std::vector<zcomponent>::const_iterator it=matA.data.begin(); it!=matA.data.end(); it++){
00067 for(long i=0; i<matB.n; i++){
00068 newmat(it->i,i) += it->v*matB(it->j,i);
00069 }
00070 }
00071
00072 matA.destroy();
00073 matB.destroy();
00074 return _(newmat);
00075 }