|
5 | 5 | #ifndef INTARRAY_H |
6 | 6 | #define INTARRAY_H |
7 | 7 |
|
8 | | -#include <iostream> |
| 8 | +#include <cassert> |
9 | 9 | #include <fstream> |
10 | 10 | #include <iomanip> |
11 | | -#include <cassert> |
| 11 | +#include <iostream> |
12 | 12 |
|
13 | 13 | #ifdef _MCD_CHECK |
14 | 14 | //#include "./src_parallel/mcd.h" |
15 | 15 | #endif |
16 | 16 |
|
17 | 17 | namespace ModuleBase |
18 | 18 | { |
19 | | - |
| 19 | +/** |
| 20 | + * @brief Integer array |
| 21 | + * |
| 22 | + */ |
20 | 23 | class IntArray |
21 | 24 | { |
22 | | -public: |
23 | | - int *ptr; |
24 | | - |
25 | | - // Constructors for different dimesnions |
26 | | - IntArray(const int d1 = 1, const int d2 = 1); |
27 | | - IntArray(const int d1, const int d2,const int d3); |
28 | | - IntArray(const int d1, const int d2,const int d3,const int d4); |
29 | | - IntArray(const int d1, const int d2,const int d3,const int d4,const int d5); |
30 | | - IntArray(const int d1, const int d2,const int d3,const int d4,const int d5,const int d6); |
31 | | - |
32 | | - ~IntArray(); |
33 | | - |
34 | | - void create(const int d1, const int d2); |
35 | | - void create(const int d1, const int d2, const int d3); |
36 | | - void create(const int d1, const int d2, const int d3, const int d4); |
37 | | - void create(const int d1, const int d2, const int d3, const int d4, const int d5); |
38 | | - void create(const int d1, const int d2, const int d3, const int d4, const int d5, const int d6); |
39 | | - |
40 | | - const IntArray &operator=(const IntArray &right); |
41 | | - const IntArray &operator=(const int &right); |
42 | | - |
43 | | - int &operator()(const int d1, const int d2); |
44 | | - int &operator()(const int d1, const int d2, const int d3); |
45 | | - int &operator()(const int d1, const int d2, const int d3,const int d4); |
46 | | - int &operator()(const int d1, const int d2, const int d3, const int d4, const int d5); |
47 | | - int &operator()(const int d1, const int d2, const int d3, const int d4, const int d5, const int d6); |
48 | | - |
49 | | - const int &operator()(const int d1,const int d2)const; |
50 | | - const int &operator()(const int d1,const int d2,const int d3)const; |
51 | | - const int &operator()(const int d1,const int d2,const int d3,const int d4)const; |
52 | | - const int &operator()(const int d1,const int d2,const int d3,const int d4, const int d5)const; |
53 | | - const int &operator()(const int d1,const int d2,const int d3,const int d4, const int d5, const int d6)const; |
54 | | - |
55 | | - void zero_out(void); |
56 | | - |
57 | | - int getSize() const{ return size;} |
58 | | - int getDim() const{ return dim;} |
59 | | - int getBound1() const{ return bound1;} |
60 | | - int getBound2() const{ return bound2;} |
61 | | - int getBound3() const{ return bound3;} |
62 | | - int getBound4() const { return bound4;} |
63 | | - int getBound5() const { return bound5;} |
64 | | - int getBound6() const { return bound6;} |
65 | | - |
66 | | - static int getArrayCount(void) |
67 | | - { return arrayCount;} |
68 | | - |
69 | | -private: |
70 | | - int size; |
71 | | - int dim; |
72 | | - int bound1, bound2, bound3, bound4, bound5, bound6; |
73 | | - static int arrayCount; |
74 | | - void freemem(); |
| 25 | + public: |
| 26 | + int *ptr; |
| 27 | + |
| 28 | + /** |
| 29 | + * @brief Construct a new Int Array object |
| 30 | + * |
| 31 | + * @param d1 The first dimension size |
| 32 | + * @param d2 The second dimension size |
| 33 | + */ |
| 34 | + IntArray(const int d1 = 1, const int d2 = 1); |
| 35 | + IntArray(const int d1, const int d2, const int d3); |
| 36 | + IntArray(const int d1, const int d2, const int d3, const int d4); |
| 37 | + IntArray(const int d1, const int d2, const int d3, const int d4, const int d5); |
| 38 | + IntArray(const int d1, const int d2, const int d3, const int d4, const int d5, const int d6); |
| 39 | + |
| 40 | + ~IntArray(); |
| 41 | + |
| 42 | + /** |
| 43 | + * @brief Create integer arrays |
| 44 | + * |
| 45 | + * @param[in] d1 |
| 46 | + * @param[in] d2 |
| 47 | + */ |
| 48 | + void create(const int d1, const int d2); |
| 49 | + void create(const int d1, const int d2, const int d3); |
| 50 | + void create(const int d1, const int d2, const int d3, const int d4); |
| 51 | + void create(const int d1, const int d2, const int d3, const int d4, const int d5); |
| 52 | + void create(const int d1, const int d2, const int d3, const int d4, const int d5, const int d6); |
| 53 | + |
| 54 | + /** |
| 55 | + * @brief Equal an IntArray to another one |
| 56 | + * |
| 57 | + * @param right |
| 58 | + * @return const IntArray& |
| 59 | + */ |
| 60 | + const IntArray &operator=(const IntArray &right); |
| 61 | + |
| 62 | + /** |
| 63 | + * @brief Equal all elements of an IntArray to an |
| 64 | + * integer |
| 65 | + * |
| 66 | + * @param right |
| 67 | + * @return const IntArray& |
| 68 | + */ |
| 69 | + const IntArray &operator=(const int &right); |
| 70 | + |
| 71 | + /** |
| 72 | + * @brief Access elements by using operator "()" |
| 73 | + * |
| 74 | + * @param d1 |
| 75 | + * @param d2 |
| 76 | + * @return int& |
| 77 | + */ |
| 78 | + int &operator()(const int d1, const int d2); |
| 79 | + int &operator()(const int d1, const int d2, const int d3); |
| 80 | + int &operator()(const int d1, const int d2, const int d3, const int d4); |
| 81 | + int &operator()(const int d1, const int d2, const int d3, const int d4, const int d5); |
| 82 | + int &operator()(const int d1, const int d2, const int d3, const int d4, const int d5, const int d6); |
| 83 | + |
| 84 | + /** |
| 85 | + * @brief Access elements by using "()" through pointer |
| 86 | + * without changing its elements |
| 87 | + * |
| 88 | + * @param d1 |
| 89 | + * @param d2 |
| 90 | + * @return const int& |
| 91 | + */ |
| 92 | + const int &operator()(const int d1, const int d2) const; |
| 93 | + const int &operator()(const int d1, const int d2, const int d3) const; |
| 94 | + const int &operator()(const int d1, const int d2, const int d3, const int d4) const; |
| 95 | + const int &operator()(const int d1, const int d2, const int d3, const int d4, const int d5) const; |
| 96 | + const int &operator()(const int d1, const int d2, const int d3, const int d4, const int d5, const int d6) const; |
| 97 | + |
| 98 | + /** |
| 99 | + * @brief Set all elements of an IntArray to zero |
| 100 | + * |
| 101 | + */ |
| 102 | + void zero_out(void); |
| 103 | + |
| 104 | + int getSize() const |
| 105 | + { |
| 106 | + return size; |
| 107 | + } |
| 108 | + int getDim() const |
| 109 | + { |
| 110 | + return dim; |
| 111 | + } |
| 112 | + int getBound1() const |
| 113 | + { |
| 114 | + return bound1; |
| 115 | + } |
| 116 | + int getBound2() const |
| 117 | + { |
| 118 | + return bound2; |
| 119 | + } |
| 120 | + int getBound3() const |
| 121 | + { |
| 122 | + return bound3; |
| 123 | + } |
| 124 | + int getBound4() const |
| 125 | + { |
| 126 | + return bound4; |
| 127 | + } |
| 128 | + int getBound5() const |
| 129 | + { |
| 130 | + return bound5; |
| 131 | + } |
| 132 | + int getBound6() const |
| 133 | + { |
| 134 | + return bound6; |
| 135 | + } |
| 136 | + |
| 137 | + /** |
| 138 | + * @brief Get the Array Count object |
| 139 | + * |
| 140 | + * @return int |
| 141 | + */ |
| 142 | + static int getArrayCount(void) |
| 143 | + { |
| 144 | + return arrayCount; |
| 145 | + } |
| 146 | + |
| 147 | + private: |
| 148 | + int size; |
| 149 | + int dim; |
| 150 | + int bound1, bound2, bound3, bound4, bound5, bound6; |
| 151 | + static int arrayCount; |
| 152 | + void freemem(); |
75 | 153 | }; |
76 | | -} |
| 154 | +} // namespace ModuleBase |
77 | 155 |
|
78 | | -#endif // IntArray class |
| 156 | +#endif // IntArray class |
0 commit comments