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= (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)
 x.submat(...) = y.submat(...)
void subview_col::operator= (const subview_col &x)
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)
 x.submat(...) = y.submat(...)
void subview_row::operator= (const subview_row &x)
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= ( const Base< eT, T1 > &  x  )  [inline, inherited]

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

Definition at line 179 of file subview_meat.hpp.

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

00180   {
00181   arma_extra_debug_sigprint();
00182   
00183   const Proxy<T1> x(in.get_ref());
00184   
00185   subview<eT>& t = *this;
00186   
00187   arma_debug_assert_same_size(t, x, "insert into submatrix");
00188   
00189   
00190   for(u32 col = 0; col<t.n_cols; ++col)
00191     {
00192     eT* t_coldata = t.colptr(col);
00193     
00194     for(u32 row = 0; row<t.n_rows; ++row)
00195       {
00196       t_coldata[row] = x.at(row,col);
00197       }
00198       
00199     }
00200   }

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

Definition at line 208 of file subview_meat.hpp.

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

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

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

Definition at line 237 of file subview_meat.hpp.

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

00238   {
00239   arma_extra_debug_sigprint();
00240   
00241   const Proxy<T1> x(in.get_ref());
00242   
00243   subview<eT>& t = *this;
00244   
00245   arma_debug_assert_same_size(t, x, "matrix subtraction");
00246   
00247   
00248   for(u32 col = 0; col<t.n_cols; ++col)
00249     {
00250      eT* t_coldata = t.colptr(col);
00251     
00252     for(u32 row = 0; row<t.n_rows; ++row)
00253       {
00254       t_coldata[row] -= x.at(row,col);
00255       }
00256     }
00257   
00258   }

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

Definition at line 266 of file subview_meat.hpp.

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

00267   {
00268   arma_extra_debug_sigprint();
00269   
00270   const Proxy<T1> x(in.get_ref());
00271   
00272   subview<eT>& t = *this;
00273   
00274   arma_debug_assert_same_size(t, x, "matrix schur product");
00275   
00276   
00277   for(u32 col = 0; col<t.n_cols; ++col)
00278     {
00279     eT* t_coldata = t.colptr(col);
00280     
00281     for(u32 row = 0; row<t.n_rows; ++row)
00282       {
00283       t_coldata[row] *= x.at(row,col);
00284       }
00285     }
00286   
00287   }

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

Definition at line 295 of file subview_meat.hpp.

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

00296   {
00297   arma_extra_debug_sigprint();
00298   
00299   const Proxy<T1> x(in.get_ref());
00300   
00301   subview<eT>& t = *this;
00302   
00303   arma_debug_assert_same_size(t, x, "element-wise matrix division");
00304   
00305   
00306   for(u32 col = 0; col<t.n_cols; ++col)
00307     {
00308     eT* t_coldata = t.colptr(col);
00309     
00310     for(u32 row = 0; row<t.n_rows; ++row)
00311       {
00312       t_coldata[row] /= x.at(row,col);
00313       }
00314     }
00315   
00316   }

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 324 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, and field< oT >::row().

00325   {
00326   arma_extra_debug_sigprint();
00327   
00328   const bool overlap = check_overlap(x_in);
00329   
00330         Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
00331   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;
00332   const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
00333   
00334   subview<eT>& t = *this;
00335   
00336   arma_debug_assert_same_size(t, x, "insert into submatrix");
00337   
00338   
00339   for(u32 col = 0; col<t.n_cols; ++col)
00340     {
00341           eT* t_coldata = t.colptr(col);
00342     const eT* x_coldata = x.colptr(col);
00343     
00344     for(u32 row = 0; row<t.n_rows; ++row)
00345       {
00346       t_coldata[row] = x_coldata[row];
00347       }
00348     
00349     }
00350     
00351   if(overlap)
00352     {
00353     delete tmp_subview;
00354     delete tmp_mat;
00355     }
00356   
00357   }

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

Definition at line 364 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().

00365   {
00366   arma_extra_debug_sigprint();
00367   
00368   const bool overlap = check_overlap(x_in);
00369   
00370         Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
00371   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;
00372   const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
00373   
00374   
00375   subview<eT>& t = *this;
00376   
00377   arma_debug_assert_same_size(t, x, "matrix addition");
00378   
00379   
00380   for(u32 col = 0; col<t.n_cols; ++col)
00381     {
00382           eT* t_coldata = t.colptr(col);
00383     const eT* x_coldata = x.colptr(col);
00384     
00385     for(u32 row = 0; row<t.n_rows; ++row)
00386       {
00387       t_coldata[row] += x_coldata[row];
00388       }
00389     
00390     }
00391   
00392   }

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

Definition at line 399 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().

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

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

Definition at line 438 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().

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

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

Definition at line 477 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().

00478   {
00479   arma_extra_debug_sigprint();
00480   
00481   const bool overlap = check_overlap(x_in);
00482   
00483         Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
00484   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;
00485   const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
00486   
00487   subview<eT>& t = *this;
00488   
00489   arma_debug_assert_same_size(t, x, "element-wise matrix division");
00490   
00491   
00492   for(u32 col = 0; col<t.n_cols; ++col)
00493     {
00494           eT* t_coldata = t.colptr(col);
00495     const eT* x_coldata = x.colptr(col);
00496     
00497     for(u32 row = 0; row<t.n_rows; ++row)
00498       {
00499       t_coldata[row] /= x_coldata[row];
00500       }
00501     }
00502     
00503   if(overlap)
00504     {
00505     delete tmp_subview;
00506     delete tmp_mat;
00507     }
00508   
00509   }

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

Definition at line 516 of file subview_meat.hpp.

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

00517   {
00518   arma_extra_debug_sigprint();
00519   
00520   subview<eT>& t = *this;
00521   
00522   for(u32 col = 0; col<t.n_cols; ++col)
00523     {
00524     eT* t_coldata = t.colptr(col);
00525     
00526     for(u32 row = 0; row<t.n_rows; ++row)
00527       {
00528       t_coldata[row] = eT(0);
00529       }
00530     
00531     }
00532   
00533   }

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

Definition at line 540 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().

00541   {
00542   arma_check( (m_ptr == 0), "subview::operator[]: matrix is read-only");
00543   
00544   const u32 in_col = i / n_rows;
00545   const u32 in_row = i % n_rows;
00546     
00547   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00548   return access::rw( (*m_ptr).mem[index] );
00549   }

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

Definition at line 556 of file subview_meat.hpp.

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

00557   {
00558   const u32 in_col = i / n_rows;
00559   const u32 in_row = i % n_rows;
00560   
00561   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00562   return m.mem[index];
00563   }

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

Definition at line 570 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().

00571   {
00572   arma_check( (m_ptr == 0), "subview::operator(): matrix is read-only");
00573   arma_debug_check( (i >= n_elem), "subview::operator(): index out of bounds");
00574     
00575   const u32 in_col = i / n_rows;
00576   const u32 in_row = i % n_rows;
00577   
00578   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00579   return access::rw( (*m_ptr).mem[index] );
00580   }

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

Definition at line 587 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.

00588   {
00589   arma_debug_check( (i >= n_elem), "subview::operator(): index out of bounds");
00590   
00591   const u32 in_col = i / n_rows;
00592   const u32 in_row = i % n_rows;
00593   
00594   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00595   return m.mem[index];
00596   }

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

Definition at line 603 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().

00604   {
00605   arma_check( (m_ptr == 0), "subview::operator(): matrix is read-only");
00606   arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::operator(): index out of bounds");
00607   
00608   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00609   return access::rw( (*m_ptr).mem[index] );
00610   }

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

Definition at line 617 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.

00618   {
00619   arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::operator(): index out of bounds");
00620   
00621   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00622   return m.mem[index];
00623   }

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

Definition at line 630 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().

00631   {
00632   arma_check( (m_ptr == 0), "subview::at(): matrix is read-only");
00633   
00634   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00635   return access::rw( (*m_ptr).mem[index] );
00636   }

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

Definition at line 643 of file subview_meat.hpp.

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

00644   {
00645   const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00646   return m.mem[index];
00647   }

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 666 of file subview_meat.hpp.

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

00667   {
00668   return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ];
00669   }

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

Definition at line 676 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=().

00677   {
00678   const subview<eT>& t = *this;
00679   
00680   if(&t.m != &x.m)
00681     {
00682     return false;
00683     }
00684   else
00685     {
00686     const bool row_overlap =
00687       (
00688       ( (x.aux_row1 >= t.aux_row1) && (x.aux_row1 <= t.aux_row2) )
00689       || 
00690       ( (x.aux_row2 >= t.aux_row1) && (x.aux_row2 <= t.aux_row2) )
00691       );
00692     
00693     const bool col_overlap =
00694       (
00695       ( (x.aux_col1 >= t.aux_col1) && (x.aux_col1 <= t.aux_col2) )
00696       || 
00697       ( (x.aux_col2 >= t.aux_col1) && (x.aux_col2 <= t.aux_col2) )
00698       );
00699     
00700     
00701     return (row_overlap & col_overlap);
00702     }
00703   }

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

Definition at line 710 of file subview_meat.hpp.

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

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

00711   {
00712   return ( (n_rows == 1) || (n_cols == 1) );
00713   }

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

X = Y.submat(...).

Definition at line 721 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(), 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().

00722   {
00723   arma_extra_debug_sigprint();
00724   
00725   //
00726   const bool alias = (&actual_out == &in.m);
00727   
00728   Mat<eT>* tmp = (alias) ? new Mat<eT> : 0;
00729   Mat<eT>& out = (alias) ? (*tmp)      : actual_out;
00730   
00731   //
00732   
00733   const u32 n_rows = in.n_rows;  // number of rows in the subview
00734   const u32 n_cols = in.n_cols;  // number of columns in the subview
00735   
00736   out.set_size(n_rows, n_cols);
00737   
00738   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 );
00739   
00740 
00741   if(in.is_vec() == true)
00742     {
00743     if(n_cols == 1)   // a column vector
00744       {
00745       arma_extra_debug_print("subview::extract(): copying col (going across rows)");
00746       
00747             eT* out_mem    = out.memptr();
00748       const eT* in_coldata = in.colptr(0);  // the first column of the subview, taking into account any row offset
00749       
00750       for(u32 row=0; row<n_rows; ++row)
00751         {
00752         out_mem[row] = in_coldata[row];
00753         }
00754       }
00755     else   // a row vector
00756       {
00757       arma_extra_debug_print("subview::extract(): copying row (going across columns)");
00758       
00759       const Mat<eT>& X = in.m;
00760       
00761             eT* out_mem   = out.memptr();
00762       const u32 row       = in.aux_row1;
00763       const u32 start_col = in.aux_col1;
00764       
00765       for(u32 i=0; i<n_cols; ++i)
00766         {
00767         out_mem[i] = X.at(row, i+start_col);
00768         }
00769       }
00770     }
00771   else   // general submatrix
00772     {
00773     arma_extra_debug_print("subview::extract(): general submatrix");
00774     
00775     for(u32 col = 0; col<n_cols; ++col)   
00776       {
00777             eT* out_coldata = out.colptr(col);
00778       const eT*  in_coldata =  in.colptr(col);
00779       
00780       for(u32 row = 0; row<n_rows; ++row)
00781         {
00782         out_coldata[row] = in_coldata[row];
00783         }
00784       }
00785     }
00786   
00787   
00788   if(alias)
00789     {
00790     actual_out = out;
00791     delete tmp;
00792     }
00793   
00794   }

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

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

Definition at line 802 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().

00803   {
00804   arma_extra_debug_sigprint();
00805   
00806   arma_debug_assert_same_size(out, in, "matrix addition");
00807   
00808   const u32 n_rows = out.n_rows;
00809   const u32 n_cols = out.n_cols;
00810   
00811   for(u32 col = 0; col<n_cols; ++col)
00812     {
00813           eT* out_coldata = out.colptr(col);
00814     const eT*  in_coldata =  in.colptr(col);
00815     
00816     for(u32 row = 0; row<n_rows; ++row)
00817       {
00818       out_coldata[row] += in_coldata[row];
00819       }
00820     }
00821   }

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

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

Definition at line 829 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().

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

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

X = Y.submat(...).

Definition at line 856 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().

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

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

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

Definition at line 883 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().

00884   {
00885   arma_extra_debug_sigprint();
00886   
00887   arma_debug_assert_same_size(out, in, "element-wise matrix division");
00888   
00889   const u32 n_rows = out.n_rows;
00890   const u32 n_cols = out.n_cols;
00891   
00892   for(u32 col = 0; col<n_cols; ++col)
00893     {
00894           eT* out_coldata = out.colptr(col);
00895     const eT*  in_coldata =  in.colptr(col);
00896     
00897     for(u32 row = 0; row<n_rows; ++row)
00898       {
00899       out_coldata[row] /= in_coldata[row];
00900       }
00901     }
00902   }

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 914 of file subview_meat.hpp.

00915   : subview<eT>(in_m, 0, in_col, in_m.n_rows-1, in_col)
00916   {
00917   arma_extra_debug_sigprint();
00918   }

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

Definition at line 924 of file subview_meat.hpp.

00925   : subview<eT>(in_m, 0, in_col, in_m.n_rows-1, in_col)
00926   {
00927   arma_extra_debug_sigprint();
00928   }

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 934 of file subview_meat.hpp.

00935   : subview<eT>(in_m, in_row1, in_col, in_row2, in_col)
00936   {
00937   arma_extra_debug_sigprint();
00938   }

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 944 of file subview_meat.hpp.

00945   : subview<eT>(in_m, in_row1, in_col, in_row2, in_col)
00946   {
00947   arma_extra_debug_sigprint();
00948   }

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

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

Reimplemented from subview< eT >.

Definition at line 955 of file subview_meat.hpp.

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

00956   {
00957   arma_extra_debug_sigprint();
00958   
00959   subview<eT>::operator=(X);
00960   arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
00961   }

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

Definition at line 968 of file subview_meat.hpp.

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

00969   {
00970   arma_extra_debug_sigprint();
00971   
00972   subview<eT>::operator=(X); // interprets 'subview_col' as 'subview'
00973   arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
00974   }

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 982 of file subview_meat.hpp.

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

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

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 1001 of file subview_meat.hpp.

01002   : subview<eT>(in_m, in_row, 0, in_row, in_m.n_cols-1)
01003   {
01004   arma_extra_debug_sigprint();
01005   }

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

Definition at line 1011 of file subview_meat.hpp.

01012   : subview<eT>(in_m, in_row, 0, in_row, in_m.n_cols-1)
01013   {
01014   arma_extra_debug_sigprint();
01015   }

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 1021 of file subview_meat.hpp.

01022   : subview<eT>(in_m, in_row, in_col1, in_row, in_col2)
01023   {
01024   arma_extra_debug_sigprint();
01025   }

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 1031 of file subview_meat.hpp.

01032   : subview<eT>(in_m, in_row, in_col1, in_row, in_col2)
01033   {
01034   arma_extra_debug_sigprint();
01035   }

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

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

Reimplemented from subview< eT >.

Definition at line 1042 of file subview_meat.hpp.

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

01043   {
01044   arma_extra_debug_sigprint();
01045   
01046   subview<eT>::operator=(X);
01047   arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
01048   }

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

Definition at line 1055 of file subview_meat.hpp.

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

01056   {
01057   arma_extra_debug_sigprint();
01058   
01059   subview<eT>::operator=(X); // interprets 'subview_row' as 'subview'
01060   arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
01061   }

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 1069 of file subview_meat.hpp.

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

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