Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-2.4.4/include/armadillo_bits/podarray_bones.hpp @ 0:8b6102e2a9b0
Armadillo Library
author | maxzanoni76 <max.zanoni@eecs.qmul.ac.uk> |
---|---|
date | Wed, 11 Apr 2012 09:27:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8b6102e2a9b0 |
---|---|
1 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2008-2010 Conrad Sanderson | |
3 // | |
4 // This file is part of the Armadillo C++ library. | |
5 // It is provided without any warranty of fitness | |
6 // for any purpose. You can redistribute this file | |
7 // and/or modify it under the terms of the GNU | |
8 // Lesser General Public License (LGPL) as published | |
9 // by the Free Software Foundation, either version 3 | |
10 // of the License or (at your option) any later version. | |
11 // (see http://www.opensource.org/licenses for more info) | |
12 | |
13 | |
14 //! \addtogroup podarray | |
15 //! @{ | |
16 | |
17 | |
18 | |
19 struct podarray_prealloc_n_elem | |
20 { | |
21 static const uword val = 16; | |
22 }; | |
23 | |
24 | |
25 | |
26 //! A lightweight array for POD types. If the amount of memory requested is small, the stack is used. | |
27 | |
28 template<typename eT> | |
29 class podarray | |
30 { | |
31 public: | |
32 | |
33 arma_aligned const uword n_elem; //!< number of elements held | |
34 arma_aligned const eT* const mem; //!< pointer to memory used by the object | |
35 | |
36 | |
37 protected: | |
38 //! Internal memory, to avoid calling the 'new' operator for small amounts of memory. | |
39 arma_aligned eT mem_local[ podarray_prealloc_n_elem::val ]; | |
40 | |
41 | |
42 public: | |
43 | |
44 inline ~podarray(); | |
45 inline podarray(); | |
46 | |
47 inline podarray (const podarray& x); | |
48 inline const podarray& operator=(const podarray& x); | |
49 | |
50 arma_inline explicit podarray(const uword new_N); | |
51 | |
52 arma_inline explicit podarray(const eT* X, const uword new_N); | |
53 | |
54 arma_inline eT& operator[] (const uword i); | |
55 arma_inline eT operator[] (const uword i) const; | |
56 | |
57 arma_inline eT& operator() (const uword i); | |
58 arma_inline eT operator() (const uword i) const; | |
59 | |
60 inline void set_size(const uword new_n_elem); | |
61 inline void reset(); | |
62 | |
63 inline void fill(const eT val); | |
64 | |
65 inline void zeros(); | |
66 inline void zeros(const uword new_n_elem); | |
67 | |
68 arma_inline eT* memptr(); | |
69 arma_inline const eT* memptr() const; | |
70 | |
71 arma_hot inline void copy_row(const Mat<eT>& A, const uword row); | |
72 | |
73 protected: | |
74 | |
75 inline void init(const uword new_n_elem); | |
76 | |
77 }; | |
78 | |
79 | |
80 | |
81 //! @} |