#include <MagMat.h>
Public Member Functions | |
MagMat (int N, int M) | |
MagMat () | |
MagMat (const MagMat &m) | |
~MagMat () | |
MagMat_row | operator[] (int) |
MagMat_row_const | operator[] (int) const |
MagMat & | operator= (const MagMat &m) |
MagMat | operator+ (const MagMat &m) |
MagMat | operator+ (const MagMat &m) const |
MagMat & | operator+= (const MagMat &m) |
MagMat | operator- (const MagMat &m) |
MagMat | operator- (const MagMat &m) const |
MagMat & | operator-= (const MagMat &m) |
MagMat | operator * (const MagMat &m) |
MagMat | operator * (const MagMat &m) const |
MagMat & | operator *= (const double &d) |
MagMat | T () const |
int | nrow () const |
int | ncol () const |
void | reSize (int Nnew, int Mnew) |
Private Member Functions | |
void | copy (const MagMat &m) |
Private Attributes | |
int | Ncol |
int | Nrow |
int | Nele |
double * | ptr_data |
Friends | |
class | MagMat_row |
class | MagMat_row_const |
Classes | |
class | MagMat_row |
class | MagMat_row_const |
Definition at line 10 of file MagMat.h.
MagMat::MagMat | ( | int | N, | |
int | M | |||
) |
MagMat::MagMat | ( | ) |
MagMat::MagMat | ( | const MagMat & | m | ) |
MagMat::~MagMat | ( | ) |
MagMat::MagMat_row MagMat::operator[] | ( | int | ) | [inline] |
MagMat::MagMat_row_const MagMat::operator[] | ( | int | ) | const [inline] |
Definition at line 99 of file MagMat.h.
00101 { 00102 const MagMat_row_const b(*this,r); 00103 00104 return b; 00105 }
Definition at line 58 of file MagMat.cpp.
00058 { 00059 00060 if(( Nrow!=0 || Ncol!=0) && (Nrow != m.Nrow || Ncol != m.Ncol )) 00061 { std::cerr << "MagMat MagMat Assignment: size do not match!" << std::endl; return *this; } 00062 00063 if ( ptr_data != m.ptr_data ) { 00064 reSize(m.Nrow, m.Ncol); 00065 copy(m); 00066 }; 00067 return (*this); 00068 00069 }
Definition at line 73 of file MagMat.cpp.
00073 { 00074 00075 if( Nrow != m.Nrow || Ncol != m.Ncol ) 00076 { std::cerr << "operator+: size do not match!" << std::endl; return *this; } 00077 00078 MagMat b( Nrow, Ncol ); 00079 00080 for( int i=0; i<Nrow; i++ ) { 00081 for( int j=0; j<Ncol; j++ ) { 00082 00083 *(b.ptr_data+i*b.Ncol+j) = *(ptr_data+i*Ncol+j)+m[i][j]; 00084 00085 } 00086 } 00087 00088 return b; 00089 }
Definition at line 91 of file MagMat.cpp.
00091 { 00092 00093 if( Nrow != m.Nrow || Ncol != m.Ncol ) 00094 { std::cerr << "operator+: size do not match!" << std::endl; return *this; } 00095 00096 MagMat b( Nrow, Ncol ); 00097 00098 for( int i=0; i<Nrow; i++ ) { 00099 for( int j=0; j<Ncol; j++ ) { 00100 00101 *(b.ptr_data+i*b.Ncol+j) = *(ptr_data+i*Ncol+j)+m[i][j]; 00102 00103 } 00104 } 00105 00106 return b; 00107 }
Definition at line 109 of file MagMat.cpp.
00109 { 00110 00111 if( Nrow != m.Nrow || Ncol != m.Ncol ) 00112 { std::cerr << "operator+=: size do not match!" << std::endl; return *this; } 00113 00114 for( int i=0; i<Nrow; i++ ) { 00115 for( int j=0; j<Ncol; j++ ) { 00116 00117 *(ptr_data+i*Ncol+j) += *(m.ptr_data+i*m.Ncol+j); 00118 00119 }; 00120 }; 00121 00122 return *this; 00123 }
Definition at line 125 of file MagMat.cpp.
00125 { 00126 if( Nrow != m.Nrow || Ncol != m.Ncol ) 00127 { std::cerr << "operator-: size do not match!" << std::endl; return *this; } 00128 00129 MagMat b( Nrow, Ncol ); 00130 00131 for( int i=0; i<Nrow; i++ ) { 00132 for( int j=0; j<Ncol; j++ ) { 00133 00134 *(b.ptr_data+i*b.Ncol+j) = *(ptr_data+i*Ncol+j)-m[i][j]; 00135 00136 } 00137 } 00138 00139 return b; 00140 }
Definition at line 142 of file MagMat.cpp.
00142 { 00143 if( Nrow != m.Nrow || Ncol != m.Ncol ) 00144 { std::cerr << "operator-: size do not match!" << std::endl; return *this; } 00145 00146 MagMat b( Nrow, Ncol ); 00147 00148 for( int i=0; i<Nrow; i++ ) { 00149 for( int j=0; j<Ncol; j++ ) { 00150 00151 *(b.ptr_data+i*b.Ncol+j) = *(ptr_data+i*Ncol+j)-m[i][j]; 00152 00153 } 00154 } 00155 00156 return b; 00157 }
Definition at line 159 of file MagMat.cpp.
00159 { 00160 00161 if( Nrow != m.Nrow || Ncol != m.Ncol ) 00162 { std::cerr << "operator-=: size do not match!" << std::endl; return *this; } 00163 00164 for( int i=0; i<Nrow; i++ ) { 00165 for( int j=0; j<Ncol; j++ ) { 00166 00167 *(ptr_data+i*Ncol+j) -= *(m.ptr_data+i*m.Ncol+j); 00168 00169 }; 00170 }; 00171 00172 return *this; 00173 }
Definition at line 175 of file MagMat.cpp.
00175 { 00176 00177 if( Ncol != m.Nrow ) { std::cerr << "operator*: size do not match!" << std::endl; 00178 return m; } 00179 00180 MagMat b( Nrow, m.Ncol); 00181 00182 00183 for( int i=0; i<Nrow; i++ ) { 00184 for( int j=0; j<m.Ncol; j++ ) { 00185 for( int k=0; k<m.Nrow; k++) b[i][j]+= *(ptr_data+i*Ncol+k)*(m[k][j]); 00186 } 00187 } 00188 00189 return b; 00190 00191 }
Definition at line 193 of file MagMat.cpp.
00193 { 00194 00195 if( Ncol != m.Nrow ) { std::cerr << "operator*: size do not match!" << std::endl; 00196 return m; } 00197 00198 MagMat b( Nrow, m.Ncol); 00199 00200 00201 for( int i=0; i<Nrow; i++ ) { 00202 for( int j=0; j<m.Ncol; j++ ) { 00203 for( int k=0; k<m.Nrow; k++) b[i][j]+= *(ptr_data+i*Ncol+k)*(m[k][j]); 00204 } 00205 } 00206 00207 return b; 00208 00209 }
MagMat & MagMat::operator *= | ( | const double & | d | ) |
MagMat MagMat::T | ( | ) | const |
int MagMat::nrow | ( | ) | const |
int MagMat::ncol | ( | ) | const |
void MagMat::reSize | ( | int | Nnew, | |
int | Mnew | |||
) |
Definition at line 245 of file MagMat.cpp.
00245 { 00246 00247 00248 if ( Nnew != Nrow || Mnew != Ncol ) { 00249 00250 double* p = ptr_data; 00251 Nele = Nnew*Mnew; 00252 ptr_data = new double[Nele]; 00253 int Nrow_old = Nrow; 00254 int Ncol_old = Ncol; 00255 00256 Nrow = Nnew; 00257 Ncol = Mnew; 00258 int k = Nrow <= Nrow_old ? Nrow : Nrow_old; 00259 int l = Ncol <= Ncol_old ? Ncol : Ncol_old; 00260 00261 for( int i=0; i<k; i++ ) { 00262 for( int j=0; j<l; j++ ) { 00263 *(ptr_data+i*Ncol+j) = *(p+i*Ncol_old+j); 00264 } 00265 } 00266 00267 00268 delete [] p; 00269 } 00270 00271 00272 00273 }
void MagMat::copy | ( | const MagMat & | m | ) | [private] |
Definition at line 40 of file MagMat.cpp.
00040 { 00041 00042 int n = Nrow <= m.Nrow ? Nrow : m.Nrow; 00043 int l = Ncol <= m.Ncol ? Ncol : m.Ncol; 00044 00045 for( int i=0; i<n; i++ ) { 00046 for( int j=0; j<l; j++ ) { 00047 00048 *(ptr_data+i*Ncol+j) = *(m.ptr_data+i*m.Ncol+j); 00049 00050 } 00051 } 00052 00053 }
friend class MagMat_row [friend] |
friend class MagMat_row_const [friend] |
int MagMat::Ncol [private] |
int MagMat::Nrow [private] |
int MagMat::Nele [private] |
double* MagMat::ptr_data [private] |