00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SELDON_FILE_SUBMATRIX_BASE_CXX
00021
00022
00023 #include "SubMatrix_Base.hxx"
00024
00025
00026 namespace Seldon
00027 {
00028
00029
00031
00033
00034
00035
00036
00037
00038
00039
00041 template <class T, class Prop, class M, class Allocator>
00042 inline SubMatrix_Base<T, Prop, M, Allocator>
00043 ::SubMatrix_Base(M& A, Vector<int>& row_list, Vector<int>& column_list):
00044 Matrix_Base<T, Allocator>(row_list.GetLength(), column_list.GetLength()),
00045 matrix_(&A), row_list_(row_list), column_list_(column_list)
00046 {
00047 }
00048
00049
00050
00051
00052
00053
00054
00056 template <class T, class Prop, class M, class Allocator>
00057 inline SubMatrix_Base<T, Prop, M, Allocator>::~SubMatrix_Base()
00058 {
00059 }
00060
00061
00062
00063
00064
00065
00066
00068
00074 template <class T, class Prop, class M, class Allocator>
00075 inline typename SubMatrix_Base<T, Prop, M, Allocator>::access_type
00076 SubMatrix_Base<T, Prop, M, Allocator>::operator() (int i, int j)
00077 {
00078 return (*this->matrix_)(this->row_list_(i), this->column_list_(j));
00079 }
00080
00081
00083
00089 template <class T, class Prop, class M, class Allocator>
00090 inline typename SubMatrix_Base<T, Prop, M, Allocator>::const_access_type
00091 SubMatrix_Base<T, Prop, M, Allocator>::operator() (int i, int j) const
00092 {
00093 return (*this->matrix_)(this->row_list_(i), this->column_list_(j));
00094 }
00095
00096
00098
00104 template <class T, class Prop, class M, class Allocator>
00105 inline typename SubMatrix_Base<T, Prop, M, Allocator>::entry_type&
00106 SubMatrix_Base<T, Prop, M, Allocator>::Val(int i, int j)
00107 {
00108 return this->matrix_->Val(this->row_list_(i), this->column_list_(j));
00109 }
00110
00111
00113
00119 template <class T, class Prop, class M, class Allocator>
00120 inline const typename SubMatrix_Base<T, Prop, M, Allocator>::entry_type&
00121 SubMatrix_Base<T, Prop, M, Allocator>::Val(int i, int j) const
00122 {
00123 return this->matrix_->Val(this->row_list_(i), this->column_list_(j));
00124 }
00125
00126
00127
00128
00129
00130
00131
00133
00136 template <class T, class Prop, class M, class Allocator>
00137 inline int SubMatrix_Base<T, Prop, M, Allocator>::GetM() const
00138 {
00139 return row_list_.GetLength();
00140 }
00141
00142
00144
00147 template <class T, class Prop, class M, class Allocator>
00148 inline int SubMatrix_Base<T, Prop, M, Allocator>::GetN() const
00149 {
00150 return column_list_.GetLength();
00151 }
00152
00153
00155
00159 template <class T, class Prop, class M, class Allocator>
00160 inline int SubMatrix_Base<T, Prop, M, Allocator>
00161 ::GetM(const SeldonTranspose& status) const
00162 {
00163 if (status.NoTrans())
00164 return row_list_.GetLength();
00165 else
00166 return column_list_.GetLength();
00167 }
00168
00169
00171
00175 template <class T, class Prop, class M, class Allocator>
00176 inline int SubMatrix_Base<T, Prop, M, Allocator>
00177 ::GetN(const SeldonTranspose& status) const
00178 {
00179 if (status.NoTrans())
00180 return column_list_.GetLength();
00181 else
00182 return row_list_.GetLength();
00183 }
00184
00185
00187
00191 template <class T, class Prop, class M, class Allocator>
00192 void SubMatrix_Base<T, Prop, M, Allocator>::Print() const
00193 {
00194 for (int i = 0; i < this->GetM(); i++)
00195 {
00196 for (int j = 0; j < this->GetN(); j++)
00197 cout << (*this)(i, j) << "\t";
00198 cout << endl;
00199 }
00200 }
00201
00202
00203 }
00204
00205
00206 #define SELDON_FILE_SUBMATRIX_BASE_CXX
00207 #endif