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