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