00001
00003 inline dgematrix& dgematrix::operator=(const dgbmatrix& mat)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] dgematrix::operator=(const dgbmatrix&)"
00007 << std::endl;
00008 #endif//CPPL_VERBOSE
00009
00010 resize(mat.M, mat.N);
00011 zero();
00012 for(long i=0; i<mat.M; i++){
00013 for(long j=max(0,i-mat.KL); j<min(N,i+mat.KU+1); j++){
00014 operator()(i,j)=mat(i,j);
00015 }
00016 }
00017
00018 return *this;
00019 }
00020
00024
00025
00027 inline dgematrix& dgematrix::operator+=(const dgbmatrix& mat)
00028 {
00029 #ifdef CPPL_VERBOSE
00030 std::cerr << "# [MARK] dgematrix::operator+=(const dgbmatrix&)"
00031 << std::endl;
00032 #endif//CPPL_VERBOSE
00033
00034 #ifdef CPPL_DEBUG
00035 if(N!=mat.N || M!=mat.M){
00036 std::cerr << "[ERROR] dgematrix::operator+=(const dgbmatrix&)" << std::endl
00037 << "These two matrises can not make a summation." << std::endl
00038 << "Your input was (" << M << "x" << N << ") += ("
00039 << mat.M << "x" << mat.N << ")." << std::endl;
00040 exit(1);
00041 }
00042 #endif//CPPL_DEBUG
00043
00044 for(long i=0; i<mat.M; i++){
00045 for(long j=max(0,i-mat.KL); j<min(N,i+mat.KU+1); j++){
00046 operator()(i,j)+=mat(i,j);
00047 }
00048 }
00049
00050 return *this;
00051 }
00052
00053
00055 inline dgematrix& dgematrix::operator-=(const dgbmatrix& mat)
00056 {
00057 #ifdef CPPL_VERBOSE
00058 std::cerr << "# [MARK] dgematrix::operator-=(const dgbmatrix&)"
00059 << std::endl;
00060 #endif//CPPL_VERBOSE
00061
00062 #ifdef CPPL_DEBUG
00063 if(N!=mat.N || M!=mat.M){
00064 std::cerr << "[ERROR] dgematrix::operator-=(const dgbmatrix&)" << std::endl
00065 << "These two matrises can not make a subtraction." << std::endl
00066 << "Your input was (" << M << "x" << N << ") -= ("
00067 << mat.M << "x" << mat.N << ")." << std::endl;
00068 exit(1);
00069 }
00070 #endif//CPPL_DEBUG
00071
00072 for(long i=0; i<mat.M; i++){
00073 for(long j=max(0,i-mat.KL); j<min(N,i+mat.KU+1); j++){
00074 operator()(i,j)-=mat(i,j);
00075 }
00076 }
00077
00078 return *this;
00079 }
00080
00081
00083 inline dgematrix& dgematrix::operator*=(const dgbmatrix& mat)
00084 {
00085 #ifdef CPPL_VERBOSE
00086 std::cerr << "# [MARK] dgematrix::operator*=(const dgbmatrix&)"
00087 << std::endl;
00088 #endif//CPPL_VERBOSE
00089
00090 #ifdef CPPL_DEBUG
00091 if(N!=mat.M){
00092 std::cerr << "[ERROR] dgematrix::operator*=(const dgbmatrix&)" << std::endl
00093 << "These two matrises can not make a product." << std::endl
00094 << "Your input was (" << M << "x" << N << ") *= ("
00095 << mat.M << "x" << mat.N << ")." << std::endl;
00096 exit(1);
00097 }
00098 #endif//CPPL_DEBUG
00099 dgematrix newmat(M,mat.N);
00100 newmat.zero();
00101
00102 for(long i=0; i<newmat.M; i++){ for(long j=0; j<newmat.N; j++){
00103 for(long k=max(0,j-mat.KU); k<min(mat.M,j+mat.KL+1); k++){
00104 newmat(i,j)+=operator()(i,k)*mat(k,j);
00105 }
00106 }}
00107
00108 swap(*this,newmat);
00109 return *this;
00110 }
00111
00115
00116
00118 inline _dgematrix operator+(const dgematrix& matA, const dgbmatrix& matB)
00119 {
00120 #ifdef CPPL_VERBOSE
00121 std::cerr << "# [MARK] operator+(const dgematrix&, const dgbmatrix&)"
00122 << std::endl;
00123 #endif//CPPL_VERBOSE
00124
00125 #ifdef CPPL_DEBUG
00126 if(matA.N!=matB.N || matA.M!=matB.M){
00127 std::cerr << "[ERROR] operator+(dgematrix&, dgbmatrix&)" << std::endl
00128 << "These two matrises can not make a summation." << std::endl
00129 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00130 << matB.M << "x" << matB.N << ")." << std::endl;
00131 exit(1);
00132 }
00133 #endif//CPPL_DEBUG
00134
00135 dgematrix newmat(matA);
00136
00137 for(long i=0; i<matB.M; i++){
00138 for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
00139 newmat(i,j)+=matB(i,j);
00140 }
00141 }
00142
00143 return _(newmat);
00144 }
00145
00146
00148 inline _dgematrix operator-(const dgematrix& matA, const dgbmatrix& matB)
00149 {
00150 #ifdef CPPL_VERBOSE
00151 std::cerr << "# [MARK] operator-(const dgematrix&, const dgbmatrix&)"
00152 << std::endl;
00153 #endif//CPPL_VERBOSE
00154
00155 #ifdef CPPL_DEBUG
00156 if(matA.N!=matB.N || matA.M!=matB.M){
00157 std::cerr << "[ERROR] operator+(dgematrix&, dgbmatrix&)" << std::endl
00158 << "These two matrises can not make a summation." << std::endl
00159 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00160 << matB.M << "x" << matB.N << ")." << std::endl;
00161 exit(1);
00162 }
00163 #endif//CPPL_DEBUG
00164
00165 dgematrix newmat(matA);
00166
00167 for(long i=0; i<matB.M; i++){
00168 for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
00169 newmat(i,j)-=matB(i,j);
00170 }
00171 }
00172
00173 return _(newmat);
00174 }
00175
00176
00178 inline _dgematrix operator*(const dgematrix& matA, const dgbmatrix& matB)
00179 {
00180 #ifdef CPPL_VERBOSE
00181 std::cerr << "# [MARK] operator*(const dgematrix&, const dgbmatrix&)"
00182 << std::endl;
00183 #endif//CPPL_VERBOSE
00184
00185 #ifdef CPPL_DEBUG
00186 if(matA.N!=matB.M){
00187 std::cerr << "[ERROR] operator*(dgematrix&, dgbmatrix&)" << std::endl
00188 << "These two matrises can not make a product." << std::endl
00189 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00190 << matB.M << "x" << matB.N << ")." << std::endl;
00191 exit(1);
00192 }
00193 #endif//CPPL_DEBUG
00194
00195 dgematrix newmat( matA.M, matB.N );
00196 newmat.zero();
00197
00198 long i, j, k;
00199 #pragma omp parallel for private(j,k)
00200 for(i=0; i<newmat.M; i++){
00201 for(j=0; j<newmat.N; j++){
00202 for(k=max(0,j-matB.KU); k<min(matB.M,j+matB.KL+1); k++){
00203 newmat(i,j)+=matA(i,k)*matB(k,j);
00204 }
00205 }
00206 }
00207
00208 return _(newmat);
00209 }