Subview

Classes

class  subview< eT >
 Class for storing data required to construct or apply operations to a submatrix (i.e. where the submatrix starts and ends as well as a reference/pointer to the original matrix),. More...
class  subview_col< eT >
class  subview_row< eT >

Functions

 subview::~subview ()
arma_inline subview::subview (const Mat< eT > &in_m, const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2)
arma_inline subview::subview (Mat< eT > &in_m, const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2)
void subview::fill (const eT val)
void subview::operator+= (const eT val)
void subview::operator-= (const eT val)
void subview::operator*= (const eT val)
void subview::operator/= (const eT val)
template<typename T1 >
void subview::operator_equ_mat (const Base< eT, T1 > &x)
template<typename T1 >
void subview::operator_equ_proxy (const Base< eT, T1 > &x)
template<typename T1 >
void subview::operator= (const Base< eT, T1 > &x)
template<typename T1 >
void subview::operator+= (const Base< eT, T1 > &x)
template<typename T1 >
void subview::operator-= (const Base< eT, T1 > &x)
template<typename T1 >
void subview::operator%= (const Base< eT, T1 > &x)
template<typename T1 >
void subview::operator/= (const Base< eT, T1 > &x)
void subview::operator= (const subview &x)
 x.submat(...) = y.submat(...)
void subview::operator+= (const subview &x)
void subview::operator-= (const subview &x)
void subview::operator%= (const subview &x)
void subview::operator/= (const subview &x)
void subview::zeros ()
arma_inline eT & subview::operator[] (const u32 i)
arma_inline eT subview::operator[] (const u32 i) const
arma_inline eT & subview::operator() (const u32 i)
arma_inline eT subview::operator() (const u32 i) const
arma_inline eT & subview::operator() (const u32 in_row, const u32 in_col)
arma_inline eT subview::operator() (const u32 in_row, const u32 in_col) const
arma_inline eT & subview::at (const u32 in_row, const u32 in_col)
arma_inline eT subview::at (const u32 in_row, const u32 in_col) const
arma_inline eT * subview::colptr (const u32 in_col)
arma_inline const eT * subview::colptr (const u32 in_col) const
bool subview::check_overlap (const subview &x) const
bool subview::is_vec () const
static void subview::extract (Mat< eT > &out, const subview &in)
 X = Y.submat(...).
static void subview::plus_inplace (Mat< eT > &out, const subview &in)
 X += Y.submat(...).
static void subview::minus_inplace (Mat< eT > &out, const subview &in)
 X -= Y.submat(...).
static void subview::schur_inplace (Mat< eT > &out, const subview &in)
 X = Y.submat(...).
static void subview::div_inplace (Mat< eT > &out, const subview &in)
 X /= Y.submat(...).
arma_inline subview_col::subview_col (const Mat< eT > &in_m, const u32 in_col)
arma_inline subview_col::subview_col (Mat< eT > &in_m, const u32 in_col)
arma_inline subview_col::subview_col (const Mat< eT > &in_m, const u32 in_col, const u32 in_row1, const u32 in_row2)
arma_inline subview_col::subview_col (Mat< eT > &in_m, const u32 in_col, const u32 in_row1, const u32 in_row2)
void subview_col::operator= (const subview< eT > &x)
void subview_col::operator= (const subview_col &x)
 x.submat(...) = y.submat(...)
template<typename T1 >
void subview_col::operator= (const Base< eT, T1 > &x)
arma_inline subview_row::subview_row (const Mat< eT > &in_m, const u32 in_row)
arma_inline subview_row::subview_row (Mat< eT > &in_m, const u32 in_row)
arma_inline subview_row::subview_row (const Mat< eT > &in_m, const u32 in_row, const u32 in_col1, const u32 in_col2)
arma_inline subview_row::subview_row (Mat< eT > &in_m, const u32 in_row, const u32 in_col1, const u32 in_col2)
void subview_row::operator= (const subview< eT > &x)
void subview_row::operator= (const subview_row &x)
 x.submat(...) = y.submat(...)
template<typename T1 >
void subview_row::operator= (const Base< eT, T1 > &x)

Function Documentation

template<typename eT >
subview< eT >::~subview (  )  [inline, inherited]

Definition at line 23 of file subview_meat.hpp.

00024   {
00025   arma_extra_debug_sigprint();
00026   }

template<typename eT >
arma_inline subview< eT >::subview ( const Mat< eT > &  in_m,
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_meat.hpp.

00032   : m(in_m)
00033   , m_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   }

template<typename eT >
arma_inline subview< eT >::subview ( Mat< eT > &  in_m,
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_meat.hpp.

00050   : m(in_m)
00051   , m_ptr(&in_m)
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   }

template<typename eT >
void subview< eT >::fill ( const eT  val  )  [inline, inherited]

Definition at line 68 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), subview< eT >::n_cols, subview< eT >::n_rows, and field< oT >::row().

00069   {
00070   arma_extra_debug_sigprint();
00071   
00072   for(u32 col = 0; col<n_cols; ++col)
00073     {
00074     eT* coldata = colptr(col);
00075     
00076     for(u32 row = 0; row<n_rows; ++row)
00077       {
00078       coldata[row] = val;
00079       }
00080     }
00081   
00082   
00083   }

template<typename eT >
void subview< eT >::operator+= ( const eT  val  )  [inline, inherited]

Definition at line 90 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), subview< eT >::n_cols, subview< eT >::n_rows, and field< oT >::row().

00091   {
00092   arma_extra_debug_sigprint();
00093   
00094   for(u32 col = 0; col<n_cols; ++col)
00095     {
00096     eT* coldata = colptr(col);
00097     
00098     for(u32 row = 0; row<n_rows; ++row)
00099       {
00100       coldata[row] += val;
00101       }
00102     
00103     }
00104   
00105   }

template<typename eT >
void subview< eT >::operator-= ( const eT  val  )  [inline, inherited]

Definition at line 112 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), subview< eT >::n_cols, subview< eT >::n_rows, and field< oT >::row().

00113   {
00114   arma_extra_debug_sigprint();
00115   
00116   for(u32 col = 0; col<n_cols; ++col)
00117     {
00118     eT* coldata = colptr(col);
00119     
00120     for(u32 row = 0; row<n_rows; ++row)
00121       {
00122       coldata[row] -= val;
00123       }
00124     
00125     }
00126   
00127   }

template<typename eT >
void subview< eT >::operator*= ( const eT  val  )  [inline, inherited]

Definition at line 134 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), subview< eT >::n_cols, subview< eT >::n_rows, and field< oT >::row().

00135   {
00136   arma_extra_debug_sigprint();
00137   
00138   for(u32 col = 0; col<n_cols; ++col)
00139     {
00140     eT* coldata = colptr(col);
00141     
00142     for(u32 row = 0; row<n_rows; ++row)
00143       {
00144       coldata[row] *= val;
00145       }
00146     
00147     }
00148   
00149   }

template<typename eT >
void subview< eT >::operator/= ( const eT  val  )  [inline, inherited]

Definition at line 156 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), subview< eT >::n_cols, subview< eT >::n_rows, and field< oT >::row().

00157   {
00158   arma_extra_debug_sigprint();
00159   
00160   for(u32 col = 0; col<n_cols; ++col)
00161     {
00162     eT* coldata = colptr(col);
00163     
00164     for(u32 row = 0; row<n_rows; ++row)
00165       {
00166       coldata[row] /= val;
00167       }
00168     
00169     }
00170   
00171   }

template<typename eT >
template<typename T1 >
void subview< eT >::operator_equ_mat ( const Base< eT, T1 > &  x  )  [inline, inherited]

Definition at line 179 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), syslib::copy_elem(), Base< elem_type, derived >::get_ref(), subview< eT >::n_cols, and subview< eT >::n_rows.

Referenced by subview< eT >::operator=().

00180   {
00181   arma_extra_debug_sigprint();
00182   
00183   const unwrap<T1>   tmp(in.get_ref());
00184   const Mat<eT>& x = tmp.M;
00185   
00186   subview<eT>& t = *this;
00187   
00188   arma_debug_assert_same_size(t, x, "insert into submatrix");
00189   
00190   const u32 t_n_cols = t.n_cols;
00191   const u32 t_n_rows = t.n_rows;
00192   
00193   for(u32 col=0; col<t_n_cols; ++col)
00194     {
00195     syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
00196     }
00197   }

template<typename eT >
template<typename T1 >
void subview< eT >::operator_equ_proxy ( const Base< eT, T1 > &  x  )  [inline, inherited]

Definition at line 205 of file subview_meat.hpp.

References field< oT >::col(), Base< elem_type, derived >::get_ref(), and field< oT >::row().

Referenced by subview< eT >::operator=().

00206   {
00207   arma_extra_debug_sigprint();
00208   
00209   const Proxy<T1> x(in.get_ref());
00210   
00211   subview<eT>& t = *this;
00212   
00213   arma_debug_assert_same_size(t, x, "insert into submatrix");
00214   
00215   const u32 t_n_cols = t.n_cols;
00216   const u32 t_n_rows = t.n_rows;
00217   
00218   for(u32 col = 0; col<t_n_cols; ++col)
00219     {
00220     eT* t_coldata = t.colptr(col);
00221     
00222     for(u32 row = 0; row<t_n_rows; ++row)
00223       {
00224       t_coldata[row] = x.at(row,col);
00225       }
00226     }
00227   
00228   }

template<typename eT >
template<typename T1 >
arma_inline void subview< eT >::operator= ( const Base< eT, T1 > &  x  )  [inline, inherited]

Reimplemented in subview_col< eT >, and subview_row< eT >.

Definition at line 236 of file subview_meat.hpp.

References subview< eT >::operator_equ_mat(), and subview< eT >::operator_equ_proxy().

00237   {
00238   arma_extra_debug_sigprint();
00239   
00240   (is_Mat<T1>::value == true) ? operator_equ_mat(in) : operator_equ_proxy(in);
00241   }

template<typename eT >
template<typename T1 >
void subview< eT >::operator+= ( const Base< eT, T1 > &  x  )  [inline, inherited]

Definition at line 249 of file subview_meat.hpp.

References field< oT >::col(), Base< elem_type, derived >::get_ref(), and field< oT >::row().

00250   {
00251   arma_extra_debug_sigprint();
00252   
00253   const Proxy<T1> x(in.get_ref());
00254   
00255   subview<eT>& t = *this;
00256   
00257   arma_debug_assert_same_size(t, x, "matrix addition");
00258   
00259   
00260   for(u32 col = 0; col<t.n_cols; ++col)
00261     {
00262     eT* t_coldata = t.colptr(col);
00263     
00264     for(u32 row = 0; row<t.n_rows; ++row)
00265       {
00266       t_coldata[row] += x.at(row,col);
00267       }
00268     }
00269   
00270   }

template<typename eT >
template<typename T1 >
void subview< eT >::operator-= ( const Base< eT, T1 > &  x  )  [inline, inherited]

Definition at line 278 of file subview_meat.hpp.

References field< oT >::col(), Base< elem_type, derived >::get_ref(), and field< oT >::row().

00279   {
00280   arma_extra_debug_sigprint();
00281   
00282   const Proxy<T1> x(in.get_ref());
00283   
00284   subview<eT>& t = *this;
00285   
00286   arma_debug_assert_same_size(t, x, "matrix subtraction");
00287   
00288   
00289   for(u32 col = 0; col<t.n_cols; ++col)
00290     {
00291      eT* t_coldata = t.colptr(col);
00292     
00293     for(u32 row = 0; row<t.n_rows; ++row)
00294       {
00295       t_coldata[row] -= x.at(row,col);
00296       }
00297     }
00298   
00299   }

template<typename eT >
template<typename T1 >
void subview< eT >::operator%= ( const Base< eT, T1 > &  x  )  [inline, inherited]

Definition at line 307 of file subview_meat.hpp.

References field< oT >::col(), Base< elem_type, derived >::get_ref(), and field< oT >::row().

00308   {
00309   arma_extra_debug_sigprint();
00310   
00311   const Proxy<T1> x(in.get_ref());
00312   
00313   subview<eT>& t = *this;
00314   
00315   arma_debug_assert_same_size(t, x, "matrix schur product");
00316   
00317   
00318   for(u32 col = 0; col<t.n_cols; ++col)
00319     {
00320     eT* t_coldata = t.colptr(col);
00321     
00322     for(u32 row = 0; row<t.n_rows; ++row)
00323       {
00324       t_coldata[row] *= x.at(row,col);
00325       }
00326     }
00327   
00328   }

template<typename eT >
template<typename T1 >
void subview< eT >::operator/= ( const Base< eT, T1 > &  x  )  [inline, inherited]

Definition at line 336 of file subview_meat.hpp.

References field< oT >::col(), Base< elem_type, derived >::get_ref(), and field< oT >::row().

00337   {
00338   arma_extra_debug_sigprint();
00339   
00340   const Proxy<T1> x(in.get_ref());
00341   
00342   subview<eT>& t = *this;
00343   
00344   arma_debug_assert_same_size(t, x, "element-wise matrix division");
00345   
00346   
00347   for(u32 col = 0; col<t.n_cols; ++col)
00348     {
00349     eT* t_coldata = t.colptr(col);
00350     
00351     for(u32 row = 0; row<t.n_rows; ++row)
00352       {
00353       t_coldata[row] /= x.at(row,col);
00354       }
00355     }
00356   
00357   }

template<typename eT >
void subview< eT >::operator= ( const subview< eT > &  x  )  [inline, inherited]

x.submat(...) = y.submat(...)

Reimplemented in subview_col< eT >, and subview_row< eT >.

Definition at line 365 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_col2, subview< eT >::aux_row1, subview< eT >::aux_row2, subview< eT >::check_overlap(), field< oT >::col(), subview< eT >::colptr(), syslib::copy_elem(), subview< eT >::m, subview< eT >::n_cols, and subview< eT >::n_rows.

00366   {
00367   arma_extra_debug_sigprint();
00368   
00369   const bool overlap = check_overlap(x_in);
00370   
00371         Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
00372   const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
00373   const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
00374   
00375   subview<eT>& t = *this;
00376   
00377   arma_debug_assert_same_size(t, x, "insert into submatrix");
00378   
00379   const u32 t_n_cols = t.n_cols;
00380   const u32 t_n_rows = t.n_rows;
00381   
00382   for(u32 col = 0; col<t_n_cols; ++col)
00383     {
00384     syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
00385     }
00386   
00387   if(overlap)
00388     {
00389     delete tmp_subview;
00390     delete tmp_mat;
00391     }
00392   
00393   }

template<typename eT >
void subview< eT >::operator+= ( const subview< eT > &  x  )  [inline, inherited]

Definition at line 400 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_col2, subview< eT >::aux_row1, subview< eT >::aux_row2, subview< eT >::check_overlap(), field< oT >::col(), subview< eT >::colptr(), subview< eT >::m, subview< eT >::n_cols, subview< eT >::n_rows, field< oT >::row(), and subview< eT >::subview().

00401   {
00402   arma_extra_debug_sigprint();
00403   
00404   const bool overlap = check_overlap(x_in);
00405   
00406         Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
00407   const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
00408   const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
00409   
00410   
00411   subview<eT>& t = *this;
00412   
00413   arma_debug_assert_same_size(t, x, "matrix addition");
00414   
00415   
00416   for(u32 col = 0; col<t.n_cols; ++col)
00417     {
00418           eT* t_coldata = t.colptr(col);
00419     const eT* x_coldata = x.colptr(col);
00420     
00421     for(u32 row = 0; row<t.n_rows; ++row)
00422       {
00423       t_coldata[row] += x_coldata[row];
00424       }
00425     
00426     }
00427   
00428   }

template<typename eT >
void subview< eT >::operator-= ( const subview< eT > &  x  )  [inline, inherited]

Definition at line 435 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_col2, subview< eT >::aux_row1, subview< eT >::aux_row2, subview< eT >::check_overlap(), field< oT >::col(), subview< eT >::colptr(), subview< eT >::m, subview< eT >::n_cols, subview< eT >::n_rows, field< oT >::row(), and subview< eT >::subview().

00436   {
00437   arma_extra_debug_sigprint();
00438   
00439   const bool overlap = check_overlap(x_in);
00440   
00441         Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
00442   const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
00443   const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
00444   
00445   subview<eT>& t = *this;
00446   
00447   arma_debug_assert_same_size(t, x, "matrix subtraction");
00448   
00449   
00450   for(u32 col = 0; col<t.n_cols; ++col)
00451     {
00452           eT* t_coldata = t.colptr(col);
00453     const eT* x_coldata = x.colptr(col);
00454     
00455     for(u32 row = 0; row<t.n_rows; ++row)
00456       {
00457       t_coldata[row] -= x_coldata[row];
00458       }
00459     }
00460     
00461   if(overlap)
00462     {
00463     delete tmp_subview;
00464     delete tmp_mat;
00465     }
00466   
00467   }

template<typename eT >
void subview< eT >::operator%= ( const subview< eT > &  x  )  [inline, inherited]

Definition at line 474 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_col2, subview< eT >::aux_row1, subview< eT >::aux_row2, subview< eT >::check_overlap(), field< oT >::col(), subview< eT >::colptr(), subview< eT >::m, subview< eT >::n_cols, subview< eT >::n_rows, field< oT >::row(), and subview< eT >::subview().

00475   {
00476   arma_extra_debug_sigprint();
00477   
00478   const bool overlap = check_overlap(x_in);
00479   
00480         Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
00481   const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
00482   const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
00483   
00484   subview<eT>& t = *this;
00485   
00486   arma_debug_assert_same_size(t, x, "matrix schur product");
00487   
00488   
00489   for(u32 col = 0; col<t.n_cols; ++col)
00490     {
00491           eT* t_coldata = t.colptr(col);
00492     const eT* x_coldata = x.colptr(col);
00493     
00494     for(u32 row = 0; row<t.n_rows; ++row)
00495       {
00496       t_coldata[row] *= x_coldata[row];
00497       }
00498     }
00499   
00500   if(overlap)
00501     {
00502     delete tmp_subview;
00503     delete tmp_mat;
00504     }
00505   
00506   }

template<typename eT >
void subview< eT >::operator/= ( const subview< eT > &  x  )  [inline, inherited]

Definition at line 513 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_col2, subview< eT >::aux_row1, subview< eT >::aux_row2, subview< eT >::check_overlap(), field< oT >::col(), subview< eT >::colptr(), subview< eT >::m, subview< eT >::n_cols, subview< eT >::n_rows, field< oT >::row(), and subview< eT >::subview().

00514   {
00515   arma_extra_debug_sigprint();
00516   
00517   const bool overlap = check_overlap(x_in);
00518   
00519         Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
00520   const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
00521   const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
00522   
00523   subview<eT>& t = *this;
00524   
00525   arma_debug_assert_same_size(t, x, "element-wise matrix division");
00526   
00527   
00528   for(u32 col = 0; col<t.n_cols; ++col)
00529     {
00530           eT* t_coldata = t.colptr(col);
00531     const eT* x_coldata = x.colptr(col);
00532     
00533     for(u32 row = 0; row<t.n_rows; ++row)
00534       {
00535       t_coldata[row] /= x_coldata[row];
00536       }
00537     }
00538     
00539   if(overlap)
00540     {
00541     delete tmp_subview;
00542     delete tmp_mat;
00543     }
00544   
00545   }

template<typename eT >
void subview< eT >::zeros (  )  [inline, inherited]

Definition at line 552 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), subview< eT >::n_cols, subview< eT >::n_rows, and field< oT >::row().

00553   {
00554   arma_extra_debug_sigprint();
00555   
00556   subview<eT>& t = *this;
00557   
00558   for(u32 col = 0; col<t.n_cols; ++col)
00559     {
00560     eT* t_coldata = t.colptr(col);
00561     
00562     for(u32 row = 0; row<t.n_rows; ++row)
00563       {
00564       t_coldata[row] = eT(0);
00565       }
00566     
00567     }
00568   
00569   }

template<typename eT >
arma_inline eT & subview< eT >::operator[] ( const u32  i  )  [inline, inherited]

Definition at line 576 of file subview_meat.hpp.

References arma_check(), subview< eT >::aux_col1, subview< eT >::aux_row1, subview< eT >::m, subview< eT >::m_ptr, subview< eT >::n_rows, and access::rw().

00577   {
00578   arma_check( (m_ptr == 0), "subview::operator[]: matrix is read-only");
00579   
00580   const u32 in_col = i / n_rows;
00581   const u32 in_row = i % n_rows;
00582     
00583   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00584   return access::rw( (*m_ptr).mem[index] );
00585   }

template<typename eT >
arma_inline eT subview< eT >::operator[] ( const u32  i  )  const [inline, inherited]

Definition at line 592 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_row1, subview< eT >::m, and subview< eT >::n_rows.

00593   {
00594   const u32 in_col = i / n_rows;
00595   const u32 in_row = i % n_rows;
00596   
00597   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00598   return m.mem[index];
00599   }

template<typename eT >
arma_inline eT & subview< eT >::operator() ( const u32  i  )  [inline, inherited]

Definition at line 606 of file subview_meat.hpp.

References arma_check(), subview< eT >::aux_col1, subview< eT >::aux_row1, subview< eT >::m, subview< eT >::m_ptr, subview< eT >::n_elem, subview< eT >::n_rows, and access::rw().

00607   {
00608   arma_check( (m_ptr == 0), "subview::operator(): matrix is read-only");
00609   arma_debug_check( (i >= n_elem), "subview::operator(): index out of bounds");
00610     
00611   const u32 in_col = i / n_rows;
00612   const u32 in_row = i % n_rows;
00613   
00614   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00615   return access::rw( (*m_ptr).mem[index] );
00616   }

template<typename eT >
arma_inline eT subview< eT >::operator() ( const u32  i  )  const [inline, inherited]

Definition at line 623 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_row1, subview< eT >::m, subview< eT >::n_elem, and subview< eT >::n_rows.

00624   {
00625   arma_debug_check( (i >= n_elem), "subview::operator(): index out of bounds");
00626   
00627   const u32 in_col = i / n_rows;
00628   const u32 in_row = i % n_rows;
00629   
00630   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00631   return m.mem[index];
00632   }

template<typename eT >
arma_inline eT & subview< eT >::operator() ( const u32  in_row,
const u32  in_col 
) [inline, inherited]

Definition at line 639 of file subview_meat.hpp.

References arma_check(), subview< eT >::aux_col1, subview< eT >::aux_row1, subview< eT >::m, subview< eT >::m_ptr, subview< eT >::n_cols, subview< eT >::n_rows, and access::rw().

00640   {
00641   arma_check( (m_ptr == 0), "subview::operator(): matrix is read-only");
00642   arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::operator(): index out of bounds");
00643   
00644   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00645   return access::rw( (*m_ptr).mem[index] );
00646   }

template<typename eT >
arma_inline eT subview< eT >::operator() ( const u32  in_row,
const u32  in_col 
) const [inline, inherited]

Definition at line 653 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_row1, subview< eT >::m, subview< eT >::n_cols, and subview< eT >::n_rows.

00654   {
00655   arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::operator(): index out of bounds");
00656   
00657   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00658   return m.mem[index];
00659   }

template<typename eT >
arma_inline eT & subview< eT >::at ( const u32  in_row,
const u32  in_col 
) [inline, inherited]

Definition at line 666 of file subview_meat.hpp.

References arma_check(), subview< eT >::aux_col1, subview< eT >::aux_row1, subview< eT >::m, subview< eT >::m_ptr, and access::rw().

00667   {
00668   arma_check( (m_ptr == 0), "subview::at(): matrix is read-only");
00669   
00670   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00671   return access::rw( (*m_ptr).mem[index] );
00672   }

template<typename eT >
arma_inline eT subview< eT >::at ( const u32  in_row,
const u32  in_col 
) const [inline, inherited]

Definition at line 679 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_row1, and subview< eT >::m.

00680   {
00681   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00682   return m.mem[index];
00683   }

template<typename eT >
arma_inline eT * subview< eT >::colptr ( const u32  in_col  )  [inline, inherited]
template<typename eT >
arma_inline const eT * subview< eT >::colptr ( const u32  in_col  )  const [inline, inherited]

Definition at line 702 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_row1, and subview< eT >::m.

00703   {
00704   return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ];
00705   }

template<typename eT >
bool subview< eT >::check_overlap ( const subview< eT > &  x  )  const [inline, inherited]

Definition at line 712 of file subview_meat.hpp.

References subview< eT >::aux_col1, subview< eT >::aux_col2, subview< eT >::aux_row1, subview< eT >::aux_row2, and subview< eT >::m.

Referenced by subview< eT >::operator%=(), subview< eT >::operator+=(), subview< eT >::operator-=(), subview< eT >::operator/=(), and subview< eT >::operator=().

00713   {
00714   const subview<eT>& t = *this;
00715   
00716   if(&t.m != &x.m)
00717     {
00718     return false;
00719     }
00720   else
00721     {
00722     const bool row_overlap =
00723       (
00724       ( (x.aux_row1 >= t.aux_row1) && (x.aux_row1 <= t.aux_row2) )
00725       || 
00726       ( (x.aux_row2 >= t.aux_row1) && (x.aux_row2 <= t.aux_row2) )
00727       );
00728     
00729     const bool col_overlap =
00730       (
00731       ( (x.aux_col1 >= t.aux_col1) && (x.aux_col1 <= t.aux_col2) )
00732       || 
00733       ( (x.aux_col2 >= t.aux_col1) && (x.aux_col2 <= t.aux_col2) )
00734       );
00735     
00736     
00737     return (row_overlap & col_overlap);
00738     }
00739   }

template<typename eT >
bool subview< eT >::is_vec (  )  const [inline, inherited]

Definition at line 746 of file subview_meat.hpp.

References subview< eT >::n_cols, and subview< eT >::n_rows.

Referenced by subview< eT >::extract().

00747   {
00748   return ( (n_rows == 1) || (n_cols == 1) );
00749   }

template<typename eT >
void subview< eT >::extract ( Mat< eT > &  out,
const subview< eT > &  in 
) [inline, static, inherited]

X = Y.submat(...).

Definition at line 757 of file subview_meat.hpp.

References Mat< eT >::at(), subview< eT >::aux_col1, subview< eT >::aux_row1, field< oT >::col(), Mat< eT >::colptr(), subview< eT >::colptr(), syslib::copy_elem(), subview< eT >::is_vec(), subview< eT >::m, Mat< eT >::memptr(), Mat< eT >::n_cols, subview< eT >::n_cols, Mat< eT >::n_rows, subview< eT >::n_rows, field< oT >::row(), and Mat< eT >::set_size().

00758   {
00759   arma_extra_debug_sigprint();
00760   
00761   //
00762   const bool alias = (&actual_out == &in.m);
00763   
00764   Mat<eT>* tmp = (alias) ? new Mat<eT> : 0;
00765   Mat<eT>& out = (alias) ? (*tmp)      : actual_out;
00766   
00767   //
00768   
00769   const u32 n_rows = in.n_rows;  // number of rows in the subview
00770   const u32 n_cols = in.n_cols;  // number of columns in the subview
00771   
00772   out.set_size(n_rows, n_cols);
00773   
00774   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.m.n_rows % in.m.n_cols );
00775   
00776 
00777   if(in.is_vec() == true)
00778     {
00779     if(n_cols == 1)   // a column vector
00780       {
00781       arma_extra_debug_print("subview::extract(): copying col (going across rows)");
00782       
00783             eT* out_mem    = out.memptr();
00784       const eT* in_coldata = in.colptr(0);  // the first column of the subview, taking into account any row offset
00785       
00786       for(u32 row=0; row<n_rows; ++row)
00787         {
00788         out_mem[row] = in_coldata[row];
00789         }
00790       }
00791     else   // a row vector
00792       {
00793       arma_extra_debug_print("subview::extract(): copying row (going across columns)");
00794       
00795       const Mat<eT>& X = in.m;
00796       
00797             eT* out_mem   = out.memptr();
00798       const u32 row       = in.aux_row1;
00799       const u32 start_col = in.aux_col1;
00800       
00801       for(u32 i=0; i<n_cols; ++i)
00802         {
00803         out_mem[i] = X.at(row, i+start_col);
00804         }
00805       }
00806     }
00807   else   // general submatrix
00808     {
00809     arma_extra_debug_print("subview::extract(): general submatrix");
00810     
00811     for(u32 col = 0; col<n_cols; ++col)   
00812       {
00813       syslib::copy_elem( out.colptr(col), in.colptr(col), n_rows );
00814       }
00815     }
00816   
00817   
00818   if(alias)
00819     {
00820     actual_out = out;
00821     delete tmp;
00822     }
00823   
00824   }

template<typename eT >
void subview< eT >::plus_inplace ( Mat< eT > &  out,
const subview< eT > &  in 
) [inline, static, inherited]

X += Y.submat(...).

Definition at line 832 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), Mat< eT >::colptr(), Mat< eT >::n_cols, subview< eT >::n_cols, Mat< eT >::n_rows, subview< eT >::n_rows, and field< oT >::row().

00833   {
00834   arma_extra_debug_sigprint();
00835   
00836   arma_debug_assert_same_size(out, in, "matrix addition");
00837   
00838   const u32 n_rows = out.n_rows;
00839   const u32 n_cols = out.n_cols;
00840   
00841   for(u32 col = 0; col<n_cols; ++col)
00842     {
00843           eT* out_coldata = out.colptr(col);
00844     const eT*  in_coldata =  in.colptr(col);
00845     
00846     for(u32 row = 0; row<n_rows; ++row)
00847       {
00848       out_coldata[row] += in_coldata[row];
00849       }
00850     }
00851   }

template<typename eT >
void subview< eT >::minus_inplace ( Mat< eT > &  out,
const subview< eT > &  in 
) [inline, static, inherited]

X -= Y.submat(...).

Definition at line 859 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), Mat< eT >::colptr(), Mat< eT >::n_cols, subview< eT >::n_cols, Mat< eT >::n_rows, subview< eT >::n_rows, and field< oT >::row().

00860   {
00861   arma_extra_debug_sigprint();
00862   
00863   arma_debug_assert_same_size(out, in, "matrix subtraction");
00864   
00865   const u32 n_rows = out.n_rows;
00866   const u32 n_cols = out.n_cols;
00867   
00868   for(u32 col = 0; col<n_cols; ++col)
00869     {
00870           eT* out_coldata = out.colptr(col);
00871     const eT*  in_coldata =  in.colptr(col);
00872     
00873     for(u32 row = 0; row<n_rows; ++row)
00874       {
00875       out_coldata[row] -= in_coldata[row];
00876       }
00877     }
00878   }

template<typename eT >
void subview< eT >::schur_inplace ( Mat< eT > &  out,
const subview< eT > &  in 
) [inline, static, inherited]

X = Y.submat(...).

Definition at line 886 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), Mat< eT >::colptr(), Mat< eT >::n_cols, subview< eT >::n_cols, Mat< eT >::n_rows, subview< eT >::n_rows, and field< oT >::row().

00887   {
00888   arma_extra_debug_sigprint();
00889   
00890   arma_debug_assert_same_size(out, in, "matrix schur product");
00891   
00892   const u32 n_rows = out.n_rows;
00893   const u32 n_cols = out.n_cols;
00894   
00895   for(u32 col = 0; col<n_cols; ++col)
00896     {
00897           eT* out_coldata = out.colptr(col);
00898     const eT*  in_coldata =  in.colptr(col);
00899     
00900     for(u32 row = 0; row<n_rows; ++row)
00901       {
00902       out_coldata[row] *= in_coldata[row];
00903       }
00904     }
00905   }

template<typename eT >
void subview< eT >::div_inplace ( Mat< eT > &  out,
const subview< eT > &  in 
) [inline, static, inherited]

X /= Y.submat(...).

Definition at line 913 of file subview_meat.hpp.

References field< oT >::col(), subview< eT >::colptr(), Mat< eT >::colptr(), Mat< eT >::n_cols, subview< eT >::n_cols, Mat< eT >::n_rows, subview< eT >::n_rows, and field< oT >::row().

00914   {
00915   arma_extra_debug_sigprint();
00916   
00917   arma_debug_assert_same_size(out, in, "element-wise matrix division");
00918   
00919   const u32 n_rows = out.n_rows;
00920   const u32 n_cols = out.n_cols;
00921   
00922   for(u32 col = 0; col<n_cols; ++col)
00923     {
00924           eT* out_coldata = out.colptr(col);
00925     const eT*  in_coldata =  in.colptr(col);
00926     
00927     for(u32 row = 0; row<n_rows; ++row)
00928       {
00929       out_coldata[row] /= in_coldata[row];
00930       }
00931     }
00932   }

template<typename eT >
arma_inline subview_col< eT >::subview_col ( const Mat< eT > &  in_m,
const u32  in_col 
) [inline, protected, inherited]

Definition at line 944 of file subview_meat.hpp.

00945   : subview<eT>(in_m, 0, in_col, in_m.n_rows-1, in_col)
00946   {
00947   arma_extra_debug_sigprint();
00948   }

template<typename eT >
arma_inline subview_col< eT >::subview_col ( Mat< eT > &  in_m,
const u32  in_col 
) [inline, protected, inherited]

Definition at line 954 of file subview_meat.hpp.

00955   : subview<eT>(in_m, 0, in_col, in_m.n_rows-1, in_col)
00956   {
00957   arma_extra_debug_sigprint();
00958   }

template<typename eT >
arma_inline subview_col< eT >::subview_col ( const Mat< eT > &  in_m,
const u32  in_col,
const u32  in_row1,
const u32  in_row2 
) [inline, protected, inherited]

Definition at line 964 of file subview_meat.hpp.

00965   : subview<eT>(in_m, in_row1, in_col, in_row2, in_col)
00966   {
00967   arma_extra_debug_sigprint();
00968   }

template<typename eT >
arma_inline subview_col< eT >::subview_col ( Mat< eT > &  in_m,
const u32  in_col,
const u32  in_row1,
const u32  in_row2 
) [inline, protected, inherited]

Definition at line 974 of file subview_meat.hpp.

00975   : subview<eT>(in_m, in_row1, in_col, in_row2, in_col)
00976   {
00977   arma_extra_debug_sigprint();
00978   }

template<typename eT >
void subview_col< eT >::operator= ( const subview< eT > &  x  )  [inline, inherited]

Definition at line 985 of file subview_meat.hpp.

Referenced by subview_col< eT >::operator=().

00986   {
00987   arma_extra_debug_sigprint();
00988   
00989   subview<eT>::operator=(X);
00990   arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
00991   }

template<typename eT >
void subview_col< eT >::operator= ( const subview_col< eT > &  x  )  [inline, inherited]

x.submat(...) = y.submat(...)

Reimplemented from subview< eT >.

Definition at line 998 of file subview_meat.hpp.

References subview_col< eT >::operator=().

00999   {
01000   arma_extra_debug_sigprint();
01001   
01002   subview<eT>::operator=(X); // interprets 'subview_col' as 'subview'
01003   arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
01004   }

template<typename eT >
template<typename T1 >
void subview_col< eT >::operator= ( const Base< eT, T1 > &  x  )  [inline, inherited]

Reimplemented from subview< eT >.

Definition at line 1012 of file subview_meat.hpp.

References subview_col< eT >::operator=().

01013   {
01014   arma_extra_debug_sigprint();
01015   
01016   subview<eT>::operator=(X);
01017   arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
01018   }

template<typename eT >
arma_inline subview_row< eT >::subview_row ( const Mat< eT > &  in_m,
const u32  in_row 
) [inline, protected, inherited]

Definition at line 1031 of file subview_meat.hpp.

01032   : subview<eT>(in_m, in_row, 0, in_row, in_m.n_cols-1)
01033   {
01034   arma_extra_debug_sigprint();
01035   }

template<typename eT >
arma_inline subview_row< eT >::subview_row ( Mat< eT > &  in_m,
const u32  in_row 
) [inline, protected, inherited]

Definition at line 1041 of file subview_meat.hpp.

01042   : subview<eT>(in_m, in_row, 0, in_row, in_m.n_cols-1)
01043   {
01044   arma_extra_debug_sigprint();
01045   }

template<typename eT >
arma_inline subview_row< eT >::subview_row ( const Mat< eT > &  in_m,
const u32  in_row,
const u32  in_col1,
const u32  in_col2 
) [inline, protected, inherited]

Definition at line 1051 of file subview_meat.hpp.

01052   : subview<eT>(in_m, in_row, in_col1, in_row, in_col2)
01053   {
01054   arma_extra_debug_sigprint();
01055   }

template<typename eT >
arma_inline subview_row< eT >::subview_row ( Mat< eT > &  in_m,
const u32  in_row,
const u32  in_col1,
const u32  in_col2 
) [inline, protected, inherited]

Definition at line 1061 of file subview_meat.hpp.

01062   : subview<eT>(in_m, in_row, in_col1, in_row, in_col2)
01063   {
01064   arma_extra_debug_sigprint();
01065   }

template<typename eT >
void subview_row< eT >::operator= ( const subview< eT > &  x  )  [inline, inherited]

Definition at line 1072 of file subview_meat.hpp.

Referenced by subview_row< eT >::operator=().

01073   {
01074   arma_extra_debug_sigprint();
01075   
01076   subview<eT>::operator=(X);
01077   arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
01078   }

template<typename eT >
void subview_row< eT >::operator= ( const subview_row< eT > &  x  )  [inline, inherited]

x.submat(...) = y.submat(...)

Reimplemented from subview< eT >.

Definition at line 1085 of file subview_meat.hpp.

References subview_row< eT >::operator=().

01086   {
01087   arma_extra_debug_sigprint();
01088   
01089   subview<eT>::operator=(X); // interprets 'subview_row' as 'subview'
01090   arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
01091   }

template<typename eT >
template<typename T1 >
void subview_row< eT >::operator= ( const Base< eT, T1 > &  x  )  [inline, inherited]

Reimplemented from subview< eT >.

Definition at line 1099 of file subview_meat.hpp.

References subview_row< eT >::operator=().

01100   {
01101   arma_extra_debug_sigprint();
01102   
01103   subview<eT>::operator=(X);
01104   arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
01105   }