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 if(Array!=mat.Array){
00011 copy(mat);
00012 }
00013 return *this;
00014 }
00015
00019
00020
00022 inline dssmatrix& dssmatrix::operator+=(const dssmatrix& mat)
00023 {
00024 #ifdef CPPL_VERBOSE
00025 std::cerr << "# [MARK] dssmatrix::operator+=(const dssmatrix&)"
00026 << std::endl;
00027 #endif//CPPL_VERBOSE
00028
00029 #ifdef CPPL_DEBUG
00030 if(N!=mat.N || M!=mat.M){
00031 std::cerr << "[ERROR] dssmatrix::operator+=(const dssmatrix&)"
00032 << std::endl
00033 << "These two matrises can not make a summation." << std::endl
00034 << "Your input was (" << M << "x" << N << ") += ("
00035 << mat.M << "x" << mat.N << ")." << std::endl;
00036 exit(1);
00037 }
00038 #endif//CPPL_DEBUG
00039
00040 for(long c=0; c<mat.VOL; c++){
00041 add(mat.Indx[c],mat.Jndx[c], mat.Array[c]);
00042 }
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 return *this;
00070 }
00071
00072
00074 inline dssmatrix& dssmatrix::operator*=(const dssmatrix& mat)
00075 {
00076 #ifdef CPPL_VERBOSE
00077 std::cerr << "# [MARK] dssmatrix::operator*=(const dssmatrix&)"
00078 << std::endl;
00079 #endif//CPPL_VERBOSE
00080
00081 #ifdef CPPL_DEBUG
00082 if(N!=mat.M){
00083 std::cerr << "[ERROR] dssmatrix::operator*=(const dssmatrix&)"
00084 << std::endl
00085 << "These two matrises can not make a product." << std::endl
00086 << "Your input was (" << M << "x" << N << ") *= ("
00087 << mat.M << "x" << mat.N << ")." << std::endl;
00088 exit(1);
00089 }
00090 #endif//CPPL_DEBUG
00091
00092 dssmatrix newmat( M, mat.N, 0 );
00093
00094 for(long c=0; c<VOL; c++){
00095 for(long d=0; d<mat.VOL; d++){
00096 if(Jndx[c]==mat.Indx[d]){
00097 newmat.add(Indx[c], mat.Jndx[d], Array[c]*mat.Array[d]);
00098 }
00099 }
00100 }
00101
00102 swap(*this,newmat);
00103 return *this;
00104 }
00105
00109
00110
00112 inline _dssmatrix operator+(const dssmatrix& matA, const dssmatrix& matB)
00113 {
00114 #ifdef CPPL_VERBOSE
00115 std::cerr << "# [MARK] operator+(const dssmatrix&, const dssmatrix&)"
00116 << std::endl;
00117 #endif//CPPL_VERBOSE
00118
00119 #ifdef CPPL_DEBUG
00120 if(matA.N!=matB.N || matA.M!=matB.M){
00121 std::cerr << "[ERROR] operator+(dssmatrix&, dssmatrix&)" << std::endl
00122 << "These two matrises can not make a summation." << std::endl
00123 << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00124 << matB.M << "x" << matB.N << ")." << std::endl;
00125 exit(1);
00126 }
00127 #endif//CPPL_DEBUG
00128
00129 dssmatrix newmat(matA);
00130
00131 for(long c=0; c<matB.VOL; c++){
00132 newmat.add(matB.Indx[c], matB.Jndx[c], matB.Array[c]);
00133 }
00134
00135 return _(newmat);
00136 }
00137
00138
00140 inline _dssmatrix operator-(const dssmatrix& matA, const dssmatrix& matB)
00141 {
00142 #ifdef CPPL_VERBOSE
00143 std::cerr << "# [MARK] operator-(const dssmatrix&, const dssmatrix&)"
00144 << std::endl;
00145 #endif//CPPL_VERBOSE
00146
00147 #ifdef CPPL_DEBUG
00148 if(matA.N!=matB.N || matA.M!=matB.M){
00149 std::cerr << "[ERROR] operator-(dssmatrix&, dssmatrix&)" << std::endl
00150 << "These two matrises can not make a subtraction." << std::endl
00151 << "Your input was (" << matA.M << "x" << matA.N << ") - ("
00152 << matB.M << "x" << matB.N << ")." << std::endl;
00153 exit(1);
00154 }
00155 #endif//CPPL_DEBUG
00156
00157 dssmatrix newmat(matA);
00158
00159 for(long c=0; c<matB.VOL; c++){
00160 newmat.sub(matB.Indx[c], matB.Jndx[c], matB.Array[c]);
00161 }
00162
00163 return _(newmat);
00164 }
00165
00166
00168 inline _dssmatrix operator*(const dssmatrix& matA, const dssmatrix& matB)
00169 {
00170 #ifdef CPPL_VERBOSE
00171 std::cerr << "# [MARK] operator*(const dssmatrix&, const dssmatrix&)"
00172 << std::endl;
00173 #endif//CPPL_VERBOSE
00174
00175 #ifdef CPPL_DEBUG
00176 if(matA.N!=matB.M){
00177 std::cerr << "[ERROR] operator*(dssmatrix&, dssmatrix&)" << std::endl
00178 << "These two matrises can not make a product." << std::endl
00179 << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00180 << matB.M << "x" << matB.N << ")." << std::endl;
00181 exit(1);
00182 }
00183 #endif//CPPL_DEBUG
00184
00185 dssmatrix newmat( matA.M, matB.N, 0 );
00186
00187 for(long c=0; c<matA.VOL; c++){
00188 for(long d=0; d<matB.VOL; d++){
00189 if(matA.Jndx[c]==matB.Indx[d]){
00190 newmat.add(matA.Indx[c], matB.Jndx[d], matA.Array[c]*matB.Array[d]);
00191 }
00192 }
00193 }
00194
00195 return _(newmat);
00196 }