Chris@49
|
1 // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
|
Chris@49
|
2 // Copyright (C) 2008-2012 Conrad Sanderson
|
Chris@49
|
3 //
|
Chris@49
|
4 // This Source Code Form is subject to the terms of the Mozilla Public
|
Chris@49
|
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
|
Chris@49
|
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
Chris@49
|
7
|
Chris@49
|
8
|
Chris@49
|
9 //! \addtogroup podarray
|
Chris@49
|
10 //! @{
|
Chris@49
|
11
|
Chris@49
|
12
|
Chris@49
|
13
|
Chris@49
|
14 struct podarray_prealloc_n_elem
|
Chris@49
|
15 {
|
Chris@49
|
16 static const uword val = 16;
|
Chris@49
|
17 };
|
Chris@49
|
18
|
Chris@49
|
19
|
Chris@49
|
20
|
Chris@49
|
21 //! A lightweight array for POD types. For internal use only!
|
Chris@49
|
22 template<typename eT>
|
Chris@49
|
23 class podarray
|
Chris@49
|
24 {
|
Chris@49
|
25 public:
|
Chris@49
|
26
|
Chris@49
|
27 arma_aligned const uword n_elem; //!< number of elements held
|
Chris@49
|
28 arma_aligned eT* mem; //!< pointer to memory used by the object
|
Chris@49
|
29
|
Chris@49
|
30
|
Chris@49
|
31 protected:
|
Chris@49
|
32 //! internal memory, to avoid calling the 'new' operator for small amounts of memory.
|
Chris@49
|
33 arma_align_mem eT mem_local[ podarray_prealloc_n_elem::val ];
|
Chris@49
|
34
|
Chris@49
|
35
|
Chris@49
|
36 public:
|
Chris@49
|
37
|
Chris@49
|
38 inline ~podarray();
|
Chris@49
|
39 inline podarray();
|
Chris@49
|
40
|
Chris@49
|
41 inline podarray (const podarray& x);
|
Chris@49
|
42 inline const podarray& operator=(const podarray& x);
|
Chris@49
|
43
|
Chris@49
|
44 arma_inline explicit podarray(const uword new_N);
|
Chris@49
|
45
|
Chris@49
|
46 arma_inline explicit podarray(const eT* X, const uword new_N);
|
Chris@49
|
47
|
Chris@49
|
48 template<typename T1>
|
Chris@49
|
49 inline explicit podarray(const Proxy<T1>& P);
|
Chris@49
|
50
|
Chris@49
|
51 arma_inline eT& operator[] (const uword i);
|
Chris@49
|
52 arma_inline eT operator[] (const uword i) const;
|
Chris@49
|
53
|
Chris@49
|
54 arma_inline eT& operator() (const uword i);
|
Chris@49
|
55 arma_inline eT operator() (const uword i) const;
|
Chris@49
|
56
|
Chris@49
|
57 inline void set_min_size(const uword min_n_elem);
|
Chris@49
|
58
|
Chris@49
|
59 inline void set_size(const uword new_n_elem);
|
Chris@49
|
60 inline void reset();
|
Chris@49
|
61
|
Chris@49
|
62
|
Chris@49
|
63 inline void fill(const eT val);
|
Chris@49
|
64
|
Chris@49
|
65 inline void zeros();
|
Chris@49
|
66 inline void zeros(const uword new_n_elem);
|
Chris@49
|
67
|
Chris@49
|
68 arma_inline eT* memptr();
|
Chris@49
|
69 arma_inline const eT* memptr() const;
|
Chris@49
|
70
|
Chris@49
|
71 arma_hot inline void copy_row(const Mat<eT>& A, const uword row);
|
Chris@49
|
72
|
Chris@49
|
73
|
Chris@49
|
74 protected:
|
Chris@49
|
75
|
Chris@49
|
76 inline void init_cold(const uword new_n_elem);
|
Chris@49
|
77 inline void init_warm(const uword new_n_elem);
|
Chris@49
|
78 };
|
Chris@49
|
79
|
Chris@49
|
80
|
Chris@49
|
81
|
Chris@49
|
82 //! @}
|