00001
00003 inline _dgematrix operator+(const dgbmatrix& matA, const _dgematrix& matB)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] operator+(const dgbmatrix&, const _dgematrix&)"
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+(dgbmatrix&, _dgematrix&)" << 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<matA.M; i++){
00021 for(long j=max(0,i-matA.KL); j<min(matA.N,i+matA.KU+1); j++){
00022 matB(i,j)+=matA(i,j);
00023 }
00024 }
00025
00026 return matB;
00027 }
00028
00029
00031 inline _dgematrix operator-(const dgbmatrix& matA, const _dgematrix& matB)
00032 {
00033 #ifdef CPPL_VERBOSE
00034 std::cerr << "# [MARK] operator-(const dgbmatrix&, const _dgematrix&)"
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+(dgbmatrix&, _dgematrix&)" << 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
00049 for(long i=0; i<matB.M*matB.N; i++){
00050 matB.Array[i]=-matB.Array[i];
00051 }
00052
00054 for(long i=0; i<matA.M; i++){
00055 for(long j=max(0,i-matA.KL); j<min(matA.N,i+matA.KU+1); j++){
00056 matB(i,j) +=matA(i,j);
00057 }
00058 }
00059
00060 return matB;
00061 }
00062
00063
00065 inline _dgematrix operator*(const dgbmatrix& matA, const _dgematrix& matB)
00066 {
00067 #ifdef CPPL_VERBOSE
00068 std::cerr << "# [MARK] operator*(const dgbmatrix&, const _dgematrix&)"
00069 << std::endl;
00070 #endif//CPPL_VERBOSE
00071
00072 #ifdef CPPL_DEBUG
00073 if(matA.N!=matB.M){
00074 std::cerr << "[ERROR] operator*(dgbmatrix&, _dgematrix&)" << std::endl
00075 << "These two matrises can not make a product." << std::endl
00076 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00077 << matB.M << "x" << matB.N << ")." << std::endl;
00078 exit(1);
00079 }
00080 #endif//CPPL_DEBUG
00081
00082 dgematrix newmat( matA.M, matB.N );
00083 newmat.zero();
00084
00085 long i, j, k;
00086 #pragma omp parallel for private(j,k)
00087 for(i=0; i<newmat.m; i++){
00088 for(j=0; j<newmat.n; j++){
00089 for(k=max(0,i-matA.KL); k<min(matA.N,i+matA.KU+1); k++){
00090 newmat(i,j)+=matA(i,k)*matB(k,j);
00091 }
00092 }
00093 }
00094
00095 matB.destroy();
00096 return _(newmat);
00097 }