Diagview


Classes

class  diagview< eT >
 Class for storing data required to extract and set the diagonals of a matrix. More...

Functions

 diagview::~diagview ()
arma_inline diagview::diagview (const Mat< eT > &in_m, const u32 in_row_offset, const u32 in_col_offset, const u32 len)
arma_inline diagview::diagview (Mat< eT > &in_m, const u32 in_row_offset, const u32 in_col_offset, const u32 len)
template<typename T1 >
void diagview::operator= (const Base< eT, T1 > &x)
 set a diagonal of our matrix using data from a foreign object
void diagview::operator= (const diagview &x)
 set a diagonal of our matrix using a diagonal from a foreign matrix
static void diagview::extract (Mat< eT > &out, const diagview &in)
 extract a diagonal and store it as a column vector
arma_inline eT & diagview::operator[] (const u32 i)
arma_inline eT diagview::operator[] (const u32 i) const
arma_inline eT & diagview::operator() (const u32 i)
arma_inline eT diagview::operator() (const u32 i) const
void diagview::fill (const eT val)
void diagview::zeros ()

Function Documentation

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

Definition at line 22 of file diagview_meat.hpp.

00023   {
00024   arma_extra_debug_sigprint();
00025   }

template<typename eT >
arma_inline diagview< eT >::diagview ( const Mat< eT > &  in_m,
const u32  in_row_offset,
const u32  in_col_offset,
const u32  len 
) [inline, protected, inherited]

Definition at line 30 of file diagview_meat.hpp.

00031   : m(in_m)
00032   , m_ptr(0)
00033   , row_offset(in_row_offset)
00034   , col_offset(in_col_offset)
00035   , n_elem(in_len)
00036   {
00037   arma_extra_debug_sigprint();
00038   }

template<typename eT >
arma_inline diagview< eT >::diagview ( Mat< eT > &  in_m,
const u32  in_row_offset,
const u32  in_col_offset,
const u32  len 
) [inline, protected, inherited]

Definition at line 44 of file diagview_meat.hpp.

00045   : m(in_m)
00046   , m_ptr(&in_m)
00047   , row_offset(in_row_offset)
00048   , col_offset(in_col_offset)
00049   , n_elem(in_len)
00050   {
00051   arma_extra_debug_sigprint();
00052   }

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

set a diagonal of our matrix using data from a foreign object

Definition at line 61 of file diagview_meat.hpp.

References arma_check(), Mat< eT >::at(), diagview< eT >::col_offset, Base< elem_type, derived >::get_ref(), diagview< eT >::m_ptr, diagview< eT >::n_elem, and diagview< eT >::row_offset.

00062   {
00063   arma_extra_debug_sigprint();
00064   arma_check( (m_ptr == 0), "diagview::operator=(): matrix is read only");
00065   
00066   const unwrap<T1> tmp(o.get_ref());
00067   const Mat<eT>& x = tmp.M;
00068   
00069   diagview& t = *this;
00070   
00071   arma_debug_check( !x.is_vec(), "diagview::operator=(): need a vector");
00072   arma_debug_check( (t.n_elem != x.n_elem), "diagview::operator=(): diagonal and given vector have incompatible lengths");
00073   
00074   Mat<eT>& t_m = *(t.m_ptr);
00075   
00076   for(u32 i=0; i<n_elem; ++i)
00077     {
00078     t_m.at(i+row_offset, i+col_offset) = x.mem[i];
00079     }
00080   
00081   }

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

set a diagonal of our matrix using a diagonal from a foreign matrix

Definition at line 89 of file diagview_meat.hpp.

References arma_check(), Mat< eT >::at(), diagview< eT >::col_offset, diagview< eT >::m, diagview< eT >::m_ptr, diagview< eT >::n_elem, and diagview< eT >::row_offset.

00090   {
00091   arma_extra_debug_sigprint();
00092   arma_check( (m_ptr == 0), "diagview::operator=(): matrix is read only");
00093   
00094   diagview<eT>& t = *this;
00095   
00096   arma_debug_check( (t.n_elem != x.n_elem), "diagview::operator=(): diagonals have incompatible lengths");
00097   
00098         Mat<eT>& t_m = *(t.m_ptr);
00099   const Mat<eT>& x_m = x.m;
00100   
00101   for(u32 i=0; i<n_elem; ++i)
00102     {
00103     t_m.at(i+t.row_offset, i+t.col_offset) = x_m.at(i+x.row_offset, i+x.col_offset);
00104     }
00105     
00106   }

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

extract a diagonal and store it as a column vector

Definition at line 115 of file diagview_meat.hpp.

References Mat< eT >::at(), diagview< eT >::col_offset, diagview< eT >::m, Mat< eT >::memptr(), diagview< eT >::n_elem, diagview< eT >::row_offset, and Mat< eT >::set_size().

00116   {
00117   arma_extra_debug_sigprint();
00118   
00119   const Mat<eT>& in_m = in.m;
00120   const bool alias = (&actual_out == &in_m);
00121   
00122   Mat<eT>* tmp = (alias) ? new Mat<eT> : 0;
00123   Mat<eT>& out = (alias) ? (*tmp)            : actual_out;
00124   
00125   const u32 in_n_elem     = in.n_elem;
00126   const u32 in_row_offset = in.row_offset;
00127   const u32 in_col_offset = in.col_offset;
00128   
00129   out.set_size(in_n_elem,1);
00130   eT* out_mem = out.memptr();
00131   
00132   for(u32 i=0; i<in_n_elem; ++i)
00133     {
00134     out_mem[i] = in_m.at(i+in_row_offset, i+in_col_offset);
00135     }
00136   
00137   
00138   if(alias)
00139     {
00140     actual_out = out;
00141     delete tmp;
00142     }
00143   
00144   }

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

Definition at line 151 of file diagview_meat.hpp.

References diagview< eT >::col_offset, and diagview< eT >::row_offset.

00152   {
00153   return (*m_ptr).at(i+row_offset, i+col_offset);
00154   }

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

Definition at line 161 of file diagview_meat.hpp.

References diagview< eT >::col_offset, diagview< eT >::m, and diagview< eT >::row_offset.

00162   {
00163   return m.at(i+row_offset, i+col_offset);
00164   }

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

Definition at line 171 of file diagview_meat.hpp.

References arma_check(), diagview< eT >::col_offset, diagview< eT >::m_ptr, diagview< eT >::n_elem, and diagview< eT >::row_offset.

00172   {
00173   arma_check( (m_ptr == 0), "diagview::operator(): matrix is read only");
00174   arma_debug_check( (i > n_elem), "diagview::operator(): index out of bounds" );
00175   
00176   return (*m_ptr).at(i+row_offset, i+col_offset);
00177   }

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

Definition at line 184 of file diagview_meat.hpp.

References diagview< eT >::col_offset, diagview< eT >::m, diagview< eT >::n_elem, and diagview< eT >::row_offset.

00185   {
00186   arma_debug_check( (i > n_elem), "diagview::operator(): index out of bounds" );
00187   
00188   return m.at(i+row_offset, i+col_offset);
00189   }

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

Definition at line 196 of file diagview_meat.hpp.

References arma_check(), Mat< eT >::at(), diagview< eT >::col_offset, diagview< eT >::m_ptr, diagview< eT >::n_elem, and diagview< eT >::row_offset.

00197   {
00198   arma_extra_debug_sigprint();
00199   arma_check( (m_ptr == 0), "diagview::operator(): matrix is read only");
00200   
00201   Mat<eT>& x = (*m_ptr);
00202   
00203   for(u32 i=0; i<n_elem; ++i)
00204     {
00205     x.at(i+row_offset, i+col_offset) = val;
00206     }
00207   }

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

Definition at line 214 of file diagview_meat.hpp.

References arma_check(), Mat< eT >::at(), diagview< eT >::col_offset, diagview< eT >::m_ptr, diagview< eT >::n_elem, and diagview< eT >::row_offset.

00215   {
00216   arma_extra_debug_sigprint();
00217   arma_check( (m_ptr == 0), "diagview::operator(): matrix is read only");
00218   
00219   Mat<eT>& x = (*m_ptr);
00220   
00221   for(u32 i=0; i<n_elem; ++i)
00222     {
00223     x.at(i+row_offset, i+col_offset) = eT(0);
00224     }
00225   }