Podarray

Classes

class  podarray< eT >
 A lightweight array for POD types. If the amount of memory requested is small, the stack is used. More...

Functions

 podarray::~podarray ()
 podarray::podarray ()
 podarray::podarray (const podarray &x)
const podarraypodarray::operator= (const podarray &x)
arma_inline podarray::podarray (const u32 new_N)
arma_inline podarray::podarray (const eT *X, const u32 new_N)
arma_inline eT podarray::operator[] (const u32 i) const
arma_inline eT & podarray::operator[] (const u32 i)
arma_inline eT podarray::operator() (const u32 i) const
arma_inline eT & podarray::operator() (const u32 i)
void podarray::set_size (const u32 new_n_elem)
void podarray::fill (const eT val)
void podarray::zeros ()
void podarray::zeros (const u32 new_n_elem)
arma_inline eT * podarray::memptr ()
arma_inline const eT * podarray::memptr () const
void podarray::init (const u32 new_n_elem)

Function Documentation

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

Definition at line 23 of file podarray_meat.hpp.

References arma_config::debug, podarray< eT >::mem, podarray< eT >::mem_local, podarray< eT >::n_elem, and access::rw().

00024   {
00025   arma_extra_debug_sigprint_this(this);
00026   
00027   if(n_elem > sizeof(mem_local)/sizeof(eT) )
00028     {
00029     delete [] mem;
00030     }
00031   
00032   if(arma_config::debug == true)
00033     {
00034     access::rw(n_elem) = 0;
00035     access::rw(mem)    = 0;
00036     }
00037   }

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

Definition at line 43 of file podarray_meat.hpp.

00044   : n_elem(0)
00045   , mem   (0)
00046   {
00047   arma_extra_debug_sigprint_this(this);
00048   }

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

Definition at line 54 of file podarray_meat.hpp.

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

00055   : n_elem(0)
00056   , mem   (0)
00057   {
00058   arma_extra_debug_sigprint();
00059   
00060   this->operator=(x);
00061   }

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

Definition at line 68 of file podarray_meat.hpp.

References syslib::copy_elem(), podarray< eT >::init(), podarray< eT >::memptr(), and podarray< eT >::n_elem.

Referenced by podarray< eT >::podarray().

00069   {
00070   arma_extra_debug_sigprint();
00071   
00072   if(this != &x)
00073     {
00074     init(x.n_elem);
00075     
00076     syslib::copy_elem( memptr(), x.memptr(), n_elem );
00077     }
00078   
00079   return *this;
00080   }

template<typename eT >
arma_inline podarray< eT >::podarray ( const u32  new_N  )  [inline, explicit, inherited]

Definition at line 86 of file podarray_meat.hpp.

References podarray< eT >::init().

00087   : n_elem(0)
00088   , mem   (0)
00089   {
00090   arma_extra_debug_sigprint_this(this);
00091   
00092   init(new_n_elem);
00093   }

template<typename eT >
arma_inline podarray< eT >::podarray ( const eT *  X,
const u32  new_N 
) [inline, explicit, inherited]

Definition at line 99 of file podarray_meat.hpp.

References syslib::copy_elem(), podarray< eT >::init(), and podarray< eT >::memptr().

00100   : n_elem(0)
00101   , mem   (0)
00102   {
00103   arma_extra_debug_sigprint_this(this);
00104   
00105   init(new_n_elem);
00106   
00107   syslib::copy_elem( memptr(), X, new_n_elem );
00108   }

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

Definition at line 115 of file podarray_meat.hpp.

References podarray< eT >::mem.

00116   {
00117   return mem[i];
00118   }

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

Definition at line 125 of file podarray_meat.hpp.

References podarray< eT >::mem, and access::rw().

00126   {
00127   return access::rw(mem[i]);
00128   }

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

Definition at line 135 of file podarray_meat.hpp.

References podarray< eT >::mem, and podarray< eT >::n_elem.

00136   {
00137   arma_debug_check( (i >= n_elem), "podarray::operator(): index out of bounds");
00138   return mem[i];
00139   }

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

Definition at line 146 of file podarray_meat.hpp.

References podarray< eT >::mem, podarray< eT >::n_elem, and access::rw().

00147   {
00148   arma_debug_check( (i >= n_elem), "podarray::operator(): index out of bounds");
00149   return access::rw(mem[i]);
00150   }

template<typename eT >
void podarray< eT >::set_size ( const u32  new_n_elem  )  [inline, inherited]

Definition at line 157 of file podarray_meat.hpp.

References podarray< eT >::init().

Referenced by auxlib::inv_inplace(), auxlib::inv_noalias(), auxlib::lu(), auxlib::qr(), and auxlib::svd().

00158   {
00159   arma_extra_debug_sigprint();
00160   
00161   init(new_n_elem);
00162   }

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

Definition at line 169 of file podarray_meat.hpp.

References podarray< eT >::mem, podarray< eT >::n_elem, and access::rw().

Referenced by podarray< eT >::zeros().

00170   {
00171   arma_extra_debug_sigprint();
00172   
00173   for(u32 i=0; i<n_elem; ++i)
00174     {
00175     access::rw(mem[i]) = val;
00176     }
00177   }

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

Definition at line 184 of file podarray_meat.hpp.

References podarray< eT >::fill().

00185   {
00186   arma_extra_debug_sigprint();
00187   
00188   fill(eT(0));
00189   }

template<typename eT >
void podarray< eT >::zeros ( const u32  new_n_elem  )  [inline, inherited]

Definition at line 196 of file podarray_meat.hpp.

References podarray< eT >::fill(), and podarray< eT >::init().

00197   {
00198   arma_extra_debug_sigprint();
00199   
00200   init(new_n_elem);
00201   fill(0);
00202   }

template<typename eT >
arma_inline eT * podarray< eT >::memptr (  )  [inline, inherited]
template<typename eT >
arma_inline const eT * podarray< eT >::memptr (  )  const [inline, inherited]

Definition at line 219 of file podarray_meat.hpp.

References podarray< eT >::mem.

00220   {
00221   return mem;
00222   }

template<typename eT >
void podarray< eT >::init ( const u32  new_n_elem  )  [inline, protected, inherited]

Definition at line 229 of file podarray_meat.hpp.

References podarray< eT >::mem, podarray< eT >::mem_local, podarray< eT >::n_elem, and access::rw().

Referenced by podarray< eT >::operator=(), podarray< eT >::podarray(), podarray< eT >::set_size(), and podarray< eT >::zeros().

00230   {
00231   arma_extra_debug_sigprint();
00232   
00233   if(n_elem == new_n_elem)
00234     {
00235     return;
00236     }
00237     
00238   if(n_elem > sizeof(mem_local)/sizeof(eT) )
00239     {
00240     delete [] mem;
00241     }
00242   
00243   if(new_n_elem <= sizeof(mem_local)/sizeof(eT) )
00244     {
00245     access::rw(mem) = mem_local;
00246     }
00247   else
00248     {
00249     access::rw(mem) = new eT[new_n_elem];
00250     }
00251   
00252   access::rw(n_elem) = new_n_elem;
00253   }