Classes | Functions

Subview

//! More...

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)
 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)

Detailed Description

//!


Function Documentation

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

Definition at line 23 of file subview_meat.hpp.

  {
  arma_extra_debug_sigprint();
  }

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 
) [protected, inherited]

Definition at line 31 of file subview_meat.hpp.

  : m(in_m)
  , m_ptr(0)
  , aux_row1(in_row1)
  , aux_col1(in_col1)
  , aux_row2(in_row2)
  , aux_col2(in_col2)
  , n_rows(1 + in_row2 - in_row1)
  , n_cols(1 + in_col2 - in_col1)
  , n_elem(n_rows*n_cols)
  {
  arma_extra_debug_sigprint();
  }

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 
) [protected, inherited]

Definition at line 49 of file subview_meat.hpp.

  : m(in_m)
  , m_ptr(&in_m)
  , aux_row1(in_row1)
  , aux_col1(in_col1)
  , aux_row2(in_row2)
  , aux_col2(in_col2)
  , n_rows(1 + in_row2 - in_row1)
  , n_cols(1 + in_col2 - in_col1)
  , n_elem(n_rows*n_cols)
  {
  arma_extra_debug_sigprint();
  }

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().

  {
  arma_extra_debug_sigprint();
  
  for(u32 col = 0; col<n_cols; ++col)
    {
    eT* coldata = colptr(col);
    
    for(u32 row = 0; row<n_rows; ++row)
      {
      coldata[row] = val;
      }
    }
  
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  for(u32 col = 0; col<n_cols; ++col)
    {
    eT* coldata = colptr(col);
    
    for(u32 row = 0; row<n_rows; ++row)
      {
      coldata[row] += val;
      }
    
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  for(u32 col = 0; col<n_cols; ++col)
    {
    eT* coldata = colptr(col);
    
    for(u32 row = 0; row<n_rows; ++row)
      {
      coldata[row] -= val;
      }
    
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  for(u32 col = 0; col<n_cols; ++col)
    {
    eT* coldata = colptr(col);
    
    for(u32 row = 0; row<n_rows; ++row)
      {
      coldata[row] *= val;
      }
    
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  for(u32 col = 0; col<n_cols; ++col)
    {
    eT* coldata = colptr(col);
    
    for(u32 row = 0; row<n_rows; ++row)
      {
      coldata[row] /= val;
      }
    
    }
  
  }

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=().

  {
  arma_extra_debug_sigprint();
  
  const unwrap<T1>   tmp(in.get_ref());
  const Mat<eT>& x = tmp.M;
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "insert into submatrix");
  
  const u32 t_n_cols = t.n_cols;
  const u32 t_n_rows = t.n_rows;
  
  for(u32 col=0; col<t_n_cols; ++col)
    {
    syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
    }
  }

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=().

  {
  arma_extra_debug_sigprint();
  
  const Proxy<T1> x(in.get_ref());
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "insert into submatrix");
  
  const u32 t_n_cols = t.n_cols;
  const u32 t_n_rows = t.n_rows;
  
  for(u32 col = 0; col<t_n_cols; ++col)
    {
    eT* t_coldata = t.colptr(col);
    
    for(u32 row = 0; row<t_n_rows; ++row)
      {
      t_coldata[row] = x.at(row,col);
      }
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  (is_Mat<T1>::value == true) ? operator_equ_mat(in) : operator_equ_proxy(in);
  }

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().

  {
  arma_extra_debug_sigprint();
  
  const Proxy<T1> x(in.get_ref());
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "matrix addition");
  
  
  for(u32 col = 0; col<t.n_cols; ++col)
    {
    eT* t_coldata = t.colptr(col);
    
    for(u32 row = 0; row<t.n_rows; ++row)
      {
      t_coldata[row] += x.at(row,col);
      }
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  const Proxy<T1> x(in.get_ref());
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "matrix subtraction");
  
  
  for(u32 col = 0; col<t.n_cols; ++col)
    {
     eT* t_coldata = t.colptr(col);
    
    for(u32 row = 0; row<t.n_rows; ++row)
      {
      t_coldata[row] -= x.at(row,col);
      }
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  const Proxy<T1> x(in.get_ref());
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "matrix schur product");
  
  
  for(u32 col = 0; col<t.n_cols; ++col)
    {
    eT* t_coldata = t.colptr(col);
    
    for(u32 row = 0; row<t.n_rows; ++row)
      {
      t_coldata[row] *= x.at(row,col);
      }
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  const Proxy<T1> x(in.get_ref());
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "element-wise matrix division");
  
  
  for(u32 col = 0; col<t.n_cols; ++col)
    {
    eT* t_coldata = t.colptr(col);
    
    for(u32 row = 0; row<t.n_rows; ++row)
      {
      t_coldata[row] /= x.at(row,col);
      }
    }
  
  }

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.

  {
  arma_extra_debug_sigprint();
  
  const bool overlap = check_overlap(x_in);
  
        Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
  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;
  const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "insert into submatrix");
  
  const u32 t_n_cols = t.n_cols;
  const u32 t_n_rows = t.n_rows;
  
  for(u32 col = 0; col<t_n_cols; ++col)
    {
    syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
    }
  
  if(overlap)
    {
    delete tmp_subview;
    delete tmp_mat;
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  const bool overlap = check_overlap(x_in);
  
        Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
  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;
  const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
  
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "matrix addition");
  
  
  for(u32 col = 0; col<t.n_cols; ++col)
    {
          eT* t_coldata = t.colptr(col);
    const eT* x_coldata = x.colptr(col);
    
    for(u32 row = 0; row<t.n_rows; ++row)
      {
      t_coldata[row] += x_coldata[row];
      }
    
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  const bool overlap = check_overlap(x_in);
  
        Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
  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;
  const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "matrix subtraction");
  
  
  for(u32 col = 0; col<t.n_cols; ++col)
    {
          eT* t_coldata = t.colptr(col);
    const eT* x_coldata = x.colptr(col);
    
    for(u32 row = 0; row<t.n_rows; ++row)
      {
      t_coldata[row] -= x_coldata[row];
      }
    }
    
  if(overlap)
    {
    delete tmp_subview;
    delete tmp_mat;
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  const bool overlap = check_overlap(x_in);
  
        Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
  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;
  const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "matrix schur product");
  
  
  for(u32 col = 0; col<t.n_cols; ++col)
    {
          eT* t_coldata = t.colptr(col);
    const eT* x_coldata = x.colptr(col);
    
    for(u32 row = 0; row<t.n_rows; ++row)
      {
      t_coldata[row] *= x_coldata[row];
      }
    }
  
  if(overlap)
    {
    delete tmp_subview;
    delete tmp_mat;
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  const bool overlap = check_overlap(x_in);
  
        Mat<eT>*     tmp_mat     = overlap ? new Mat<eT>(x_in.m) : 0;
  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;
  const subview<eT>&           x = overlap ? (*tmp_subview) : x_in;
  
  subview<eT>& t = *this;
  
  arma_debug_assert_same_size(t, x, "element-wise matrix division");
  
  
  for(u32 col = 0; col<t.n_cols; ++col)
    {
          eT* t_coldata = t.colptr(col);
    const eT* x_coldata = x.colptr(col);
    
    for(u32 row = 0; row<t.n_rows; ++row)
      {
      t_coldata[row] /= x_coldata[row];
      }
    }
    
  if(overlap)
    {
    delete tmp_subview;
    delete tmp_mat;
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  subview<eT>& t = *this;
  
  for(u32 col = 0; col<t.n_cols; ++col)
    {
    eT* t_coldata = t.colptr(col);
    
    for(u32 row = 0; row<t.n_rows; ++row)
      {
      t_coldata[row] = eT(0);
      }
    
    }
  
  }

template<typename eT >
arma_inline eT & subview< eT >::operator[] ( const u32  i  )  [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().

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

template<typename eT >
arma_inline eT subview< eT >::operator[] ( const u32  i  )  const [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.

  {
  const u32 in_col = i / n_rows;
  const u32 in_row = i % n_rows;
  
  const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
  return m.mem[index];
  }

template<typename eT >
arma_inline eT & subview< eT >::operator() ( const u32  i  )  [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().

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

template<typename eT >
arma_inline eT subview< eT >::operator() ( const u32  i  )  const [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.

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

template<typename eT >
arma_inline eT & subview< eT >::operator() ( const u32  in_row,
const u32  in_col 
) [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().

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

template<typename eT >
arma_inline eT subview< eT >::operator() ( const u32  in_row,
const u32  in_col 
) const [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.

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

template<typename eT >
arma_inline eT & subview< eT >::at ( const u32  in_row,
const u32  in_col 
) [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().

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

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

Definition at line 679 of file subview_meat.hpp.

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

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

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

Definition at line 702 of file subview_meat.hpp.

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

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

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=().

  {
  const subview<eT>& t = *this;
  
  if(&t.m != &x.m)
    {
    return false;
    }
  else
    {
    const bool row_overlap =
      (
      ( (x.aux_row1 >= t.aux_row1) && (x.aux_row1 <= t.aux_row2) )
      || 
      ( (x.aux_row2 >= t.aux_row1) && (x.aux_row2 <= t.aux_row2) )
      );
    
    const bool col_overlap =
      (
      ( (x.aux_col1 >= t.aux_col1) && (x.aux_col1 <= t.aux_col2) )
      || 
      ( (x.aux_col2 >= t.aux_col1) && (x.aux_col2 <= t.aux_col2) )
      );
    
    
    return (row_overlap & col_overlap);
    }
  }

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().

  {
  return ( (n_rows == 1) || (n_cols == 1) );
  }

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().

  {
  arma_extra_debug_sigprint();
  
  //
  const bool alias = (&actual_out == &in.m);
  
  Mat<eT>* tmp = (alias) ? new Mat<eT> : 0;
  Mat<eT>& out = (alias) ? (*tmp)      : actual_out;
  
  //
  
  const u32 n_rows = in.n_rows;  // number of rows in the subview
  const u32 n_cols = in.n_cols;  // number of columns in the subview
  
  out.set_size(n_rows, n_cols);
  
  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 );
  

  if(in.is_vec() == true)
    {
    if(n_cols == 1)   // a column vector
      {
      arma_extra_debug_print("subview::extract(): copying col (going across rows)");
      
            eT* out_mem    = out.memptr();
      const eT* in_coldata = in.colptr(0);  // the first column of the subview, taking into account any row offset
      
      for(u32 row=0; row<n_rows; ++row)
        {
        out_mem[row] = in_coldata[row];
        }
      }
    else   // a row vector
      {
      arma_extra_debug_print("subview::extract(): copying row (going across columns)");
      
      const Mat<eT>& X = in.m;
      
            eT* out_mem   = out.memptr();
      const u32 row       = in.aux_row1;
      const u32 start_col = in.aux_col1;
      
      for(u32 i=0; i<n_cols; ++i)
        {
        out_mem[i] = X.at(row, i+start_col);
        }
      }
    }
  else   // general submatrix
    {
    arma_extra_debug_print("subview::extract(): general submatrix");
    
    for(u32 col = 0; col<n_cols; ++col)   
      {
      syslib::copy_elem( out.colptr(col), in.colptr(col), n_rows );
      }
    }
  
  
  if(alias)
    {
    actual_out = out;
    delete tmp;
    }
  
  }

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().

  {
  arma_extra_debug_sigprint();
  
  arma_debug_assert_same_size(out, in, "matrix addition");
  
  const u32 n_rows = out.n_rows;
  const u32 n_cols = out.n_cols;
  
  for(u32 col = 0; col<n_cols; ++col)
    {
          eT* out_coldata = out.colptr(col);
    const eT*  in_coldata =  in.colptr(col);
    
    for(u32 row = 0; row<n_rows; ++row)
      {
      out_coldata[row] += in_coldata[row];
      }
    }
  }

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().

  {
  arma_extra_debug_sigprint();
  
  arma_debug_assert_same_size(out, in, "matrix subtraction");
  
  const u32 n_rows = out.n_rows;
  const u32 n_cols = out.n_cols;
  
  for(u32 col = 0; col<n_cols; ++col)
    {
          eT* out_coldata = out.colptr(col);
    const eT*  in_coldata =  in.colptr(col);
    
    for(u32 row = 0; row<n_rows; ++row)
      {
      out_coldata[row] -= in_coldata[row];
      }
    }
  }

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().

  {
  arma_extra_debug_sigprint();
  
  arma_debug_assert_same_size(out, in, "matrix schur product");
  
  const u32 n_rows = out.n_rows;
  const u32 n_cols = out.n_cols;
  
  for(u32 col = 0; col<n_cols; ++col)
    {
          eT* out_coldata = out.colptr(col);
    const eT*  in_coldata =  in.colptr(col);
    
    for(u32 row = 0; row<n_rows; ++row)
      {
      out_coldata[row] *= in_coldata[row];
      }
    }
  }

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().

  {
  arma_extra_debug_sigprint();
  
  arma_debug_assert_same_size(out, in, "element-wise matrix division");
  
  const u32 n_rows = out.n_rows;
  const u32 n_cols = out.n_cols;
  
  for(u32 col = 0; col<n_cols; ++col)
    {
          eT* out_coldata = out.colptr(col);
    const eT*  in_coldata =  in.colptr(col);
    
    for(u32 row = 0; row<n_rows; ++row)
      {
      out_coldata[row] /= in_coldata[row];
      }
    }
  }

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

Definition at line 944 of file subview_meat.hpp.

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

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

Definition at line 954 of file subview_meat.hpp.

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

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 
) [protected, inherited]

Definition at line 964 of file subview_meat.hpp.

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

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 
) [protected, inherited]

Definition at line 974 of file subview_meat.hpp.

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

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

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

  {
  arma_extra_debug_sigprint();
  
  subview<eT>::operator=(X);
  arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
  }

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

Definition at line 998 of file subview_meat.hpp.

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

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

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=().

  {
  arma_extra_debug_sigprint();
  
  subview<eT>::operator=(X);
  arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
  }

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

Definition at line 1031 of file subview_meat.hpp.

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

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

Definition at line 1041 of file subview_meat.hpp.

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

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 
) [protected, inherited]

Definition at line 1051 of file subview_meat.hpp.

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

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 
) [protected, inherited]

Definition at line 1061 of file subview_meat.hpp.

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

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

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

  {
  arma_extra_debug_sigprint();
  
  subview<eT>::operator=(X);
  arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
  }

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

Definition at line 1085 of file subview_meat.hpp.

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

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

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=().

  {
  arma_extra_debug_sigprint();
  
  subview<eT>::operator=(X);
  arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
  }