Classes | |
class | subview_field< oT > |
Class for storing data required to construct or apply operations to a subfield (i.e. where the subfield starts and ends as well as a reference/pointer to the original field),. More... | |
Functions | |
subview_field::~subview_field () | |
arma_inline | subview_field::subview_field (const field< oT > &in_f, const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2) |
arma_inline | subview_field::subview_field (field< oT > &in_f, const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2) |
void | subview_field::operator= (const field< oT > &x) |
void | subview_field::operator= (const subview_field &x) |
x.subfield(...) = y.subfield(...) | |
arma_inline oT & | subview_field::operator[] (const u32 i) |
arma_inline const oT & | subview_field::operator[] (const u32 i) const |
arma_inline oT & | subview_field::operator() (const u32 i) |
arma_inline const oT & | subview_field::operator() (const u32 i) const |
arma_inline oT & | subview_field::operator() (const u32 row, const u32 col) |
arma_inline const oT & | subview_field::operator() (const u32 row, const u32 col) const |
arma_inline oT & | subview_field::at (const u32 row, const u32 col) |
arma_inline const oT & | subview_field::at (const u32 row, const u32 col) const |
bool | subview_field::check_overlap (const subview_field &x) const |
static void | subview_field::extract (field< oT > &out, const subview_field &in) |
X = Y.subfield(...). |
subview_field< oT >::~subview_field | ( | ) | [inline, inherited] |
arma_inline subview_field< oT >::subview_field | ( | const field< oT > & | in_f, | |
const u32 | in_row1, | |||
const u32 | in_col1, | |||
const u32 | in_row2, | |||
const u32 | in_col2 | |||
) | [inline, protected, inherited] |
Definition at line 31 of file subview_field_meat.hpp.
00032 : f(in_f) 00033 , f_ptr(0) 00034 , aux_row1(in_row1) 00035 , aux_col1(in_col1) 00036 , aux_row2(in_row2) 00037 , aux_col2(in_col2) 00038 , n_rows(1 + in_row2 - in_row1) 00039 , n_cols(1 + in_col2 - in_col1) 00040 , n_elem(n_rows*n_cols) 00041 { 00042 arma_extra_debug_sigprint(); 00043 }
arma_inline subview_field< oT >::subview_field | ( | field< oT > & | in_f, | |
const u32 | in_row1, | |||
const u32 | in_col1, | |||
const u32 | in_row2, | |||
const u32 | in_col2 | |||
) | [inline, protected, inherited] |
Definition at line 49 of file subview_field_meat.hpp.
00050 : f(in_f) 00051 , f_ptr(&in_f) 00052 , aux_row1(in_row1) 00053 , aux_col1(in_col1) 00054 , aux_row2(in_row2) 00055 , aux_col2(in_col2) 00056 , n_rows(1 + in_row2 - in_row1) 00057 , n_cols(1 + in_col2 - in_col1) 00058 , n_elem(n_rows*n_cols) 00059 { 00060 arma_extra_debug_sigprint(); 00061 }
void subview_field< oT >::operator= | ( | const field< oT > & | x | ) | [inline, inherited] |
Definition at line 68 of file subview_field_meat.hpp.
References field< oT >::at(), subview_field< oT >::at(), field< oT >::n_cols, subview_field< oT >::n_cols, field< oT >::n_rows, and subview_field< oT >::n_rows.
00069 { 00070 arma_extra_debug_sigprint(); 00071 00072 subview_field<oT>& t = *this; 00073 00074 arma_debug_check( (t.n_rows != x.n_rows) || (t.n_cols != x.n_cols), "incompatible field dimensions"); 00075 00076 for(u32 col=0; col<t.n_cols; ++col) 00077 { 00078 for(u32 row=0; row<t.n_rows; ++row) 00079 { 00080 t.at(row,col) = x.at(row,col); 00081 } 00082 } 00083 }
void subview_field< oT >::operator= | ( | const subview_field< oT > & | x | ) | [inline, inherited] |
x.subfield(...) = y.subfield(...)
Definition at line 91 of file subview_field_meat.hpp.
References subview_field< oT >::at(), subview_field< oT >::aux_col1, subview_field< oT >::aux_col2, subview_field< oT >::aux_row1, subview_field< oT >::aux_row2, subview_field< oT >::check_overlap(), subview_field< oT >::f, subview_field< oT >::n_cols, and subview_field< oT >::n_rows.
00092 { 00093 arma_extra_debug_sigprint(); 00094 00095 const bool overlap = check_overlap(x_in); 00096 00097 field<oT>* tmp_field = overlap ? new field<oT>(x_in.f) : 0; 00098 const subview_field<oT>* tmp_subview = overlap ? new subview_field<oT>(*tmp_field, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0; 00099 const subview_field<oT>& x = overlap ? (*tmp_subview) : x_in; 00100 00101 subview_field<oT>& t = *this; 00102 00103 arma_debug_check( (t.n_rows != x.n_rows) || (t.n_cols != x.n_cols), "incompatible field dimensions"); 00104 00105 for(u32 col=0; col<t.n_cols; ++col) 00106 { 00107 for(u32 row=0; row<t.n_rows; ++row) 00108 { 00109 t.at(row,col) = x.at(row,col); 00110 } 00111 } 00112 00113 if(overlap) 00114 { 00115 delete tmp_subview; 00116 delete tmp_field; 00117 } 00118 }
arma_inline oT & subview_field< oT >::operator[] | ( | const u32 | i | ) | [inline, inherited] |
Definition at line 125 of file subview_field_meat.hpp.
References arma_check(), subview_field< oT >::aux_col1, subview_field< oT >::aux_row1, subview_field< oT >::f, subview_field< oT >::f_ptr, and subview_field< oT >::n_rows.
00126 { 00127 arma_check( (f_ptr == 0), "subview_field::operator[]: field is read-only"); 00128 00129 const u32 in_col = i / n_rows; 00130 const u32 in_row = i % n_rows; 00131 00132 const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; 00133 00134 return *((*f_ptr).mem[index]); 00135 }
arma_inline const oT & subview_field< oT >::operator[] | ( | const u32 | i | ) | const [inline, inherited] |
Definition at line 142 of file subview_field_meat.hpp.
References subview_field< oT >::aux_col1, subview_field< oT >::aux_row1, subview_field< oT >::f, and subview_field< oT >::n_rows.
00143 { 00144 const u32 in_col = i / n_rows; 00145 const u32 in_row = i % n_rows; 00146 00147 const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; 00148 00149 return *(f.mem[index]); 00150 }
arma_inline oT & subview_field< oT >::operator() | ( | const u32 | i | ) | [inline, inherited] |
Definition at line 157 of file subview_field_meat.hpp.
References arma_check(), subview_field< oT >::aux_col1, subview_field< oT >::aux_row1, subview_field< oT >::f, subview_field< oT >::f_ptr, subview_field< oT >::n_elem, and subview_field< oT >::n_rows.
00158 { 00159 arma_check( (f_ptr == 0), "subview_field::operator(): field is read-only"); 00160 arma_debug_check( (i >= n_elem), "subview_field::operator(): index out of bounds"); 00161 00162 const u32 in_col = i / n_rows; 00163 const u32 in_row = i % n_rows; 00164 00165 const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; 00166 00167 return *((*f_ptr).mem[index]); 00168 }
arma_inline const oT & subview_field< oT >::operator() | ( | const u32 | i | ) | const [inline, inherited] |
Definition at line 175 of file subview_field_meat.hpp.
References subview_field< oT >::aux_col1, subview_field< oT >::aux_row1, subview_field< oT >::f, subview_field< oT >::n_elem, and subview_field< oT >::n_rows.
00176 { 00177 arma_debug_check( (i >= n_elem), "subview_field::operator(): index out of bounds"); 00178 00179 const u32 in_col = i / n_rows; 00180 const u32 in_row = i % n_rows; 00181 00182 const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; 00183 00184 return *(f.mem[index]); 00185 }
arma_inline oT & subview_field< oT >::operator() | ( | const u32 | row, | |
const u32 | col | |||
) | [inline, inherited] |
Definition at line 192 of file subview_field_meat.hpp.
References arma_check(), subview_field< oT >::aux_col1, subview_field< oT >::aux_row1, subview_field< oT >::f, subview_field< oT >::f_ptr, subview_field< oT >::n_cols, and subview_field< oT >::n_rows.
00193 { 00194 arma_check( (f_ptr == 0), "subview_field::operator(): field is read-only"); 00195 arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_field::operator(): index out of bounds"); 00196 00197 const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; 00198 00199 return *((*f_ptr).mem[index]); 00200 }
arma_inline const oT & subview_field< oT >::operator() | ( | const u32 | row, | |
const u32 | col | |||
) | const [inline, inherited] |
Definition at line 207 of file subview_field_meat.hpp.
References subview_field< oT >::aux_col1, subview_field< oT >::aux_row1, subview_field< oT >::f, subview_field< oT >::n_cols, and subview_field< oT >::n_rows.
00208 { 00209 arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_field::operator(): index out of bounds"); 00210 00211 const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; 00212 00213 return *(f.mem[index]); 00214 }
arma_inline oT & subview_field< oT >::at | ( | const u32 | row, | |
const u32 | col | |||
) | [inline, inherited] |
Definition at line 221 of file subview_field_meat.hpp.
References arma_check(), subview_field< oT >::aux_col1, subview_field< oT >::aux_row1, subview_field< oT >::f, and subview_field< oT >::f_ptr.
Referenced by subview_field< oT >::extract(), and subview_field< oT >::operator=().
00222 { 00223 //arma_extra_debug_sigprint(); 00224 00225 arma_check( (f_ptr == 0), "subview_field::at(): field is read-only"); 00226 00227 const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; 00228 00229 return *((*f_ptr).mem[index]); 00230 }
arma_inline const oT & subview_field< oT >::at | ( | const u32 | row, | |
const u32 | col | |||
) | const [inline, inherited] |
Definition at line 237 of file subview_field_meat.hpp.
References subview_field< oT >::aux_col1, subview_field< oT >::aux_row1, and subview_field< oT >::f.
00238 { 00239 //arma_extra_debug_sigprint(); 00240 00241 const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; 00242 00243 return *(f.mem[index]); 00244 }
bool subview_field< oT >::check_overlap | ( | const subview_field< oT > & | x | ) | const [inline, inherited] |
Definition at line 251 of file subview_field_meat.hpp.
References subview_field< oT >::aux_col1, subview_field< oT >::aux_col2, subview_field< oT >::aux_row1, subview_field< oT >::aux_row2, and subview_field< oT >::f.
Referenced by subview_field< oT >::operator=().
00252 { 00253 const subview_field<oT>& t = *this; 00254 00255 if(&t.f != &x.f) 00256 { 00257 return false; 00258 } 00259 else 00260 { 00261 const bool row_overlap = 00262 ( 00263 ( (x.aux_row1 >= t.aux_row1) && (x.aux_row1 <= t.aux_row2) ) 00264 || 00265 ( (x.aux_row2 >= t.aux_row1) && (x.aux_row2 <= t.aux_row2) ) 00266 ); 00267 00268 const bool col_overlap = 00269 ( 00270 ( (x.aux_col1 >= t.aux_col1) && (x.aux_col1 <= t.aux_col2) ) 00271 || 00272 ( (x.aux_col2 >= t.aux_col1) && (x.aux_col2 <= t.aux_col2) ) 00273 ); 00274 00275 00276 return (row_overlap & col_overlap); 00277 } 00278 }
void subview_field< oT >::extract | ( | field< oT > & | out, | |
const subview_field< oT > & | in | |||
) | [inline, static, inherited] |
X = Y.subfield(...).
Definition at line 286 of file subview_field_meat.hpp.
References subview_field< oT >::at(), field< oT >::at(), subview_field< oT >::f, field< oT >::n_cols, subview_field< oT >::n_cols, field< oT >::n_rows, subview_field< oT >::n_rows, and field< oT >::set_size().
00287 { 00288 arma_extra_debug_sigprint(); 00289 00290 // 00291 const bool alias = (&actual_out == &in.f); 00292 00293 field<oT>* tmp = (alias) ? new field<oT> : 0; 00294 field<oT>& out = (alias) ? (*tmp) : actual_out; 00295 00296 // 00297 00298 const u32 n_rows = in.n_rows; 00299 const u32 n_cols = in.n_cols; 00300 00301 out.set_size(n_rows, n_cols); 00302 00303 arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d in.m.n_rows = %d in.m.n_cols = %d") % out.n_rows % out.n_cols % in.f.n_rows % in.f.n_cols ); 00304 00305 for(u32 col = 0; col<n_cols; ++col) 00306 { 00307 for(u32 row = 0; row<n_rows; ++row) 00308 { 00309 out.at(row,col) = in.at(row,col); 00310 } 00311 } 00312 00313 00314 if(alias) 00315 { 00316 actual_out = out; 00317 delete tmp; 00318 } 00319 00320 }