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