max@0: // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) max@0: // Copyright (C) 2008-2010 Conrad Sanderson max@0: // max@0: // This file is part of the Armadillo C++ library. max@0: // It is provided without any warranty of fitness max@0: // for any purpose. You can redistribute this file max@0: // and/or modify it under the terms of the GNU max@0: // Lesser General Public License (LGPL) as published max@0: // by the Free Software Foundation, either version 3 max@0: // of the License or (at your option) any later version. max@0: // (see http://www.opensource.org/licenses for more info) max@0: max@0: max@0: //! \addtogroup podarray max@0: //! @{ max@0: max@0: max@0: max@0: struct podarray_prealloc_n_elem max@0: { max@0: static const uword val = 16; max@0: }; max@0: max@0: max@0: max@0: //! A lightweight array for POD types. If the amount of memory requested is small, the stack is used. max@0: max@0: template max@0: class podarray max@0: { max@0: public: max@0: max@0: arma_aligned const uword n_elem; //!< number of elements held max@0: arma_aligned const eT* const mem; //!< pointer to memory used by the object max@0: max@0: max@0: protected: max@0: //! Internal memory, to avoid calling the 'new' operator for small amounts of memory. max@0: arma_aligned eT mem_local[ podarray_prealloc_n_elem::val ]; max@0: max@0: max@0: public: max@0: max@0: inline ~podarray(); max@0: inline podarray(); max@0: max@0: inline podarray (const podarray& x); max@0: inline const podarray& operator=(const podarray& x); max@0: max@0: arma_inline explicit podarray(const uword new_N); max@0: max@0: arma_inline explicit podarray(const eT* X, const uword new_N); max@0: max@0: arma_inline eT& operator[] (const uword i); max@0: arma_inline eT operator[] (const uword i) const; max@0: max@0: arma_inline eT& operator() (const uword i); max@0: arma_inline eT operator() (const uword i) const; max@0: max@0: inline void set_size(const uword new_n_elem); max@0: inline void reset(); max@0: max@0: inline void fill(const eT val); max@0: max@0: inline void zeros(); max@0: inline void zeros(const uword new_n_elem); max@0: max@0: arma_inline eT* memptr(); max@0: arma_inline const eT* memptr() const; max@0: max@0: arma_hot inline void copy_row(const Mat& A, const uword row); max@0: max@0: protected: max@0: max@0: inline void init(const uword new_n_elem); max@0: max@0: }; max@0: max@0: max@0: max@0: //! @}