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