00001
00003 inline zgematrix& zgematrix::operator=(const zgbmatrix& mat)
00004 {
00005 #ifdef CPPL_VERBOSE
00006 std::cerr << "# [MARK] zgematrix::operator=(const zgbmatrix&)"
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 zgematrix& zgematrix::operator+=(const zgbmatrix& mat)
00028 {
00029 #ifdef CPPL_VERBOSE
00030 std::cerr << "# [MARK] zgematrix::operator+=(const zgbmatrix&)"
00031 << std::endl;
00032 #endif//CPPL_VERBOSE
00033
00034 #ifdef CPPL_DEBUG
00035 if(N!=mat.N || M!=mat.M){
00036 std::cerr << "[ERROR] zgematrix::operator+=(const zgbmatrix&)" << 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 zgematrix& zgematrix::operator-=(const zgbmatrix& mat)
00056 {
00057 #ifdef CPPL_VERBOSE
00058 std::cerr << "# [MARK] zgematrix::operator-=(const zgbmatrix&)"
00059 << std::endl;
00060 #endif//CPPL_VERBOSE
00061
00062 #ifdef CPPL_DEBUG
00063 if(N!=mat.N || M!=mat.M){
00064 std::cerr << "[ERROR] zgematrix::operator-=(const zgbmatrix&)" << 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
00082 inline zgematrix& zgematrix::operator*=(const zgbmatrix& mat)
00083 {
00084 #ifdef CPPL_VERBOSE
00085 std::cerr << "# [MARK] zgematrix::operator*=(const zgbmatrix&)"
00086 << std::endl;
00087 #endif//CPPL_VERBOSE
00088
00089 #ifdef CPPL_DEBUG
00090 if(N!=mat.M){
00091 std::cerr << "[ERROR] zgematrix::operator*=(const zgbmatrix&)" << std::endl
00092 << "These two matrises can not make a product." << std::endl
00093 << "Your input was (" << M << "x" << N << ") *= ("
00094 << mat.M << "x" << mat.N << ")." << std::endl;
00095 exit(1);
00096 }
00097 #endif//CPPL_DEBUG
00098 zgematrix newmat(M,mat.N);
00099 newmat.zero();
00100
00101 for(long i=0; i<newmat.m; i++){ for(long j=0; j<newmat.n; j++){
00102 for(long k=max(0,j-mat.KU); k<min(mat.M,j+mat.KL+1); k++){
00103 newmat(i,j)+=operator()(i,k)*mat(k,j);
00104 }
00105 }}
00106
00107 swap(*this,newmat);
00108 return *this;
00109 }
00110
00114
00115
00117 inline _zgematrix operator+(const zgematrix& matA, const zgbmatrix& matB)
00118 {
00119 #ifdef CPPL_VERBOSE
00120 std::cerr << "# [MARK] operator+(const zgematrix&, const zgbmatrix&)"
00121 << std::endl;
00122 #endif//CPPL_VERBOSE
00123
00124 #ifdef CPPL_DEBUG
00125 if(matA.N!=matB.N || matA.M!=matB.M){
00126 std::cerr << "[ERROR] operator+(zgematrix&, zgbmatrix&)" << std::endl
00127 << "These two matrises can not make a summation." << std::endl
00128 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00129 << matB.M << "x" << matB.N << ")." << std::endl;
00130 exit(1);
00131 }
00132 #endif//CPPL_DEBUG
00133
00134 zgematrix newmat(matA);
00135
00136 for(long i=0; i<matB.M; i++){
00137 for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
00138 newmat(i,j)+=matB(i,j);
00139 }
00140 }
00141
00142 return _(newmat);
00143 }
00144
00145
00147 inline _zgematrix operator-(const zgematrix& matA, const zgbmatrix& matB)
00148 {
00149 #ifdef CPPL_VERBOSE
00150 std::cerr << "# [MARK] operator-(const zgematrix&, const zgbmatrix&)"
00151 << std::endl;
00152 #endif//CPPL_VERBOSE
00153
00154 #ifdef CPPL_DEBUG
00155 if(matA.N!=matB.N || matA.M!=matB.M){
00156 std::cerr << "[ERROR] operator+(zgematrix&, zgbmatrix&)" << std::endl
00157 << "These two matrises can not make a summation." << std::endl
00158 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00159 << matB.M << "x" << matB.N << ")." << std::endl;
00160 exit(1);
00161 }
00162 #endif//CPPL_DEBUG
00163
00164 zgematrix newmat(matA);
00165
00166 for(long i=0; i<matB.M; i++){
00167 for(long j=max(0,i-matB.KL); j<min(matB.N,i+matB.KU+1); j++){
00168 newmat(i,j)-=matB(i,j);
00169 }
00170 }
00171
00172 return _(newmat);
00173 }
00174
00175
00177 inline _zgematrix operator*(const zgematrix& matA, const zgbmatrix& matB)
00178 {
00179 #ifdef CPPL_VERBOSE
00180 std::cerr << "# [MARK] operator*(const zgematrix&, const zgbmatrix&)"
00181 << std::endl;
00182 #endif//CPPL_VERBOSE
00183
00184 #ifdef CPPL_DEBUG
00185 if(matA.N!=matB.M){
00186 std::cerr << "[ERROR] operator*(zgematrix&, zgbmatrix&)" << std::endl
00187 << "These two matrises can not make a product." << std::endl
00188 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00189 << matB.M << "x" << matB.N << ")." << std::endl;
00190 exit(1);
00191 }
00192 #endif//CPPL_DEBUG
00193
00194 zgematrix newmat( matA.M, matB.N );
00195 newmat.zero();
00196
00197 long i, j, k;
00198 #pragma omp parallel for private(j,k)
00199 for(i=0; i<newmat.m; i++){
00200 for(j=0; j<newmat.n; j++){
00201 for(k=max(0,j-matB.KU); k<min(matB.M,j+matB.KL+1); k++){
00202 newmat(i,j)+=matA(i,k)*matB(k,j);
00203 }
00204 }
00205 }
00206
00207 return _(newmat);
00208 }