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