00001
00003 inline _zgematrix operator+(const _zgematrix& matA, const zgbmatrix& matB)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] operator+(const _zgematrix&, const zgbmatrix&)"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 #ifdef CPPL_DEBUG
00011 if(matA.N!=matB.N || matA.M!=matB.M){
00012 std::cerr << "[ERROR] operator+(_zgematrix&, zgbmatrix&)" << std::endl
00013 << "These two matrises can not make a summation." << std::endl
00014 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00015 << matB.M << "x" << matB.N << ")." << std::endl;
00016 exit(1);
00017 }
00018 #endif//CPPL_DEBUG
00019
00020 for(long i=0; i<matB.M; i++){
00021 for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
00022 matA(i,j)+=matB(i,j);
00023 }
00024 }
00025
00026 return matA;
00027 }
00028
00029
00031 inline _zgematrix operator-(const _zgematrix& matA, const zgbmatrix& matB)
00032 {
00033 #ifdef CPPL_VERBOSE
00034 std::cerr << "# [MARK] operator-(const _zgematrix&, const zgbmatrix&)"
00035 << std::endl;
00036 #endif//CPPL_VERBOSE
00037
00038 #ifdef CPPL_DEBUG
00039 if(matA.N!=matB.N || matA.M!=matB.M){
00040 std::cerr << "[ERROR] operator+(_zgematrix&, zgbmatrix&)" << std::endl
00041 << "These two matrises can not make a summation." << std::endl
00042 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00043 << matB.M << "x" << matB.N << ")." << std::endl;
00044 exit(1);
00045 }
00046 #endif//CPPL_DEBUG
00047
00048 for(long i=0; i<matB.M; i++){
00049 for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
00050 matA(i,j)-=matB(i,j);
00051 }
00052 }
00053
00054 return matA;
00055 }
00056
00057
00059 inline _zgematrix operator*(const _zgematrix& matA, const zgbmatrix& matB)
00060 {
00061 #ifdef CPPL_VERBOSE
00062 std::cerr << "# [MARK] operator*(const _zgematrix&, const zgbmatrix&)"
00063 << std::endl;
00064 #endif//CPPL_VERBOSE
00065
00066 #ifdef CPPL_DEBUG
00067 if(matA.N!=matB.M){
00068 std::cerr << "[ERROR] operator*(_zgematrix&, zgbmatrix&)" << std::endl
00069 << "These two matrises can not make a product." << std::endl
00070 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00071 << matB.M << "x" << matB.N << ")." << std::endl;
00072 exit(1);
00073 }
00074 #endif//CPPL_DEBUG
00075
00076 zgematrix newmat( matA.M, matB.N );
00077 newmat.zero();
00078
00079 long i, j, k;
00080 #pragma omp parallel for private(j,k)
00081 for(i=0; i<newmat.m; i++){
00082 for(j=0; j<newmat.n; j++){
00083 for(k=max(0,j-matB.KU); k<min(matB.M,j+matB.KL+1); k++){
00084 newmat(i,j)+=matA(i,k)*matB(k,j);
00085 }
00086 }
00087 }
00088
00089 matA.destroy();
00090 return _(newmat);
00091 }