00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 namespace CIMPL
00059 {
00060
00061
00062 template< class T >
00063 SubMatrix<T>::SubMatrix(void)
00064 {
00065 xDim = 0;
00066 yDim = 0;
00067 columns = 0;
00068 clean = 0;
00069 }
00070
00071
00072 template< class T >
00073 SubMatrix<T>::SubMatrix(SubMatrix<T> &m)
00074 {
00075 xDim = m.xDim;
00076 yDim = m.yDim;
00077 columns = m.columns;
00078 clean = new (std::nothrow) Cleaner<T>(columns);
00079 Utility::CheckPointer(clean);
00080
00081 }
00082
00083
00084
00085
00086 template< class T >
00087 SubMatrix<T>::~SubMatrix(void)
00088 {
00089
00090 if(clean != 0)
00091 {
00092 delete clean;
00093 }
00094
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 template< class T >
00106 inline const int SubMatrix<T>::Columns() const
00107 {
00108 return xDim;
00109 }
00110
00111 template< class T >
00112 inline const int SubMatrix<T>::Rows() const
00113 {
00114 return yDim;
00115 }
00116
00117
00118 template< class T >
00119 inline const int SubMatrix<T>::XDim() const
00120 {
00121 return xDim;
00122 }
00123
00124 template< class T >
00125 inline const int SubMatrix<T>::YDim() const
00126 {
00127 return yDim;
00128 }
00129
00130
00131
00132 template< class T >
00133 SubMatrix<T>& SubMatrix<T>::operator= (SubMatrix<T>& m)
00134 {
00135 if(xDim != m.xDim || yDim != m.yDim)
00136 {
00137 cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00138 Utility::RunTimeError("(Sub)Matrices must be same size for the assignment!");
00139 }
00140 for(int i=0;i<m.xDim;i++)
00141 {
00142 for(int j=0;j<m.yDim;j++)
00143 {
00144 columns[i][j] = m.columns[i][j];
00145 }
00146 }
00147
00148 return *this;
00149 }
00150
00151 template< class T >
00152 SubMatrix<T>& SubMatrix<T>::operator= (Matrix<T>& m)
00153 {
00154 if(xDim != m.xDim || yDim != m.yDim)
00155 {
00156 cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00157 Utility::RunTimeError("(Sub)Matrices must be same size for the assignment!");
00158 }
00159 for(int i=0;i<m.xDim;i++)
00160 {
00161 for(int j=0;j<m.yDim;j++)
00162 {
00163 columns[i][j] = m.ElemNC(j,i);
00164 }
00165 }
00166
00167
00168 return *this;
00169 }
00170
00171
00172
00173 template< class T >
00174 inline T& SubMatrix<T>::operator() (const int j, const int i)
00175 {
00176 if(i<0 || i>=xDim || j<0 || j>=yDim)
00177 {
00178 cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
00179 Utility::RunTimeError("Index outside bounds!");
00180 }
00181
00182 return columns[i][j];
00183
00184 }
00185
00186 template< class T >
00187 inline Vector<T>& SubMatrix<T>::operator[] (const int i)
00188 {
00189 return columns[i];
00190 }
00191
00192
00193
00194
00195
00196
00197 };
00198
00199
00200
00201
00202