Chris@49: // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) Chris@49: // Copyright (C) 2008-2012 Conrad Sanderson Chris@49: // Chris@49: // This Source Code Form is subject to the terms of the Mozilla Public Chris@49: // License, v. 2.0. If a copy of the MPL was not distributed with this Chris@49: // file, You can obtain one at http://mozilla.org/MPL/2.0/. Chris@49: Chris@49: Chris@49: //! \addtogroup podarray Chris@49: //! @{ Chris@49: Chris@49: Chris@49: Chris@49: struct podarray_prealloc_n_elem Chris@49: { Chris@49: static const uword val = 16; Chris@49: }; Chris@49: Chris@49: Chris@49: Chris@49: //! A lightweight array for POD types. For internal use only! Chris@49: template Chris@49: class podarray Chris@49: { Chris@49: public: Chris@49: Chris@49: arma_aligned const uword n_elem; //!< number of elements held Chris@49: arma_aligned eT* mem; //!< pointer to memory used by the object Chris@49: Chris@49: Chris@49: protected: Chris@49: //! internal memory, to avoid calling the 'new' operator for small amounts of memory. Chris@49: arma_align_mem eT mem_local[ podarray_prealloc_n_elem::val ]; Chris@49: Chris@49: Chris@49: public: Chris@49: Chris@49: inline ~podarray(); Chris@49: inline podarray(); Chris@49: Chris@49: inline podarray (const podarray& x); Chris@49: inline const podarray& operator=(const podarray& x); Chris@49: Chris@49: arma_inline explicit podarray(const uword new_N); Chris@49: Chris@49: arma_inline explicit podarray(const eT* X, const uword new_N); Chris@49: Chris@49: template Chris@49: inline explicit podarray(const Proxy& P); Chris@49: Chris@49: arma_inline eT& operator[] (const uword i); Chris@49: arma_inline eT operator[] (const uword i) const; Chris@49: Chris@49: arma_inline eT& operator() (const uword i); Chris@49: arma_inline eT operator() (const uword i) const; Chris@49: Chris@49: inline void set_min_size(const uword min_n_elem); Chris@49: Chris@49: inline void set_size(const uword new_n_elem); Chris@49: inline void reset(); Chris@49: Chris@49: Chris@49: inline void fill(const eT val); Chris@49: Chris@49: inline void zeros(); Chris@49: inline void zeros(const uword new_n_elem); Chris@49: Chris@49: arma_inline eT* memptr(); Chris@49: arma_inline const eT* memptr() const; Chris@49: Chris@49: arma_hot inline void copy_row(const Mat& A, const uword row); Chris@49: Chris@49: Chris@49: protected: Chris@49: Chris@49: inline void init_cold(const uword new_n_elem); Chris@49: inline void init_warm(const uword new_n_elem); Chris@49: }; Chris@49: Chris@49: Chris@49: Chris@49: //! @}