|
5 | 5 | #include <iostream> |
6 | 6 | #include <fstream> |
7 | 7 | #include <iomanip> |
| 8 | +#include <cassert> |
8 | 9 |
|
9 | 10 | namespace ModuleBase |
10 | 11 | { |
@@ -58,11 +59,27 @@ class ComplexArray |
58 | 59 |
|
59 | 60 | /// overloaded subscript operator for non-const std::complex Array const reference return creates an lvakue |
60 | 61 | std::complex <double> &operator() |
61 | | - (const int ind1=0, const int ind2=0, const int ind3=0, const int ind4=0); |
| 62 | + (const int ind1=0, const int ind2=0, const int ind3=0, const int ind4=0) |
| 63 | + { |
| 64 | + assert(ind1>=0); assert(ind1<bound1); |
| 65 | + assert(ind2>=0); assert(ind2<bound2); |
| 66 | + assert(ind3>=0); assert(ind3<bound3); |
| 67 | + assert(ind4>=0); assert(ind4<bound4); |
| 68 | + const int ind = ((ind1 * bound2 + ind2) * bound3 + ind3) * bound4 + ind4; |
| 69 | + return ptr[ind]; |
| 70 | + }; |
62 | 71 | // std::complex < double> &operator()(int, int, int, int, int); |
63 | 72 | /// overloaded subscript operator for const std::complex Array const reference return creates an cvakue |
64 | 73 | const std::complex <double> &operator() |
65 | | - (const int ind1=0, const int ind2=0, const int ind3=0, const int ind4=0)const; |
| 74 | + (const int ind1=0, const int ind2=0, const int ind3=0, const int ind4=0) const |
| 75 | + { |
| 76 | + assert(ind1>=0); assert(ind1<bound1); |
| 77 | + assert(ind2>=0); assert(ind2<bound2); |
| 78 | + assert(ind3>=0); assert(ind3<bound3); |
| 79 | + assert(ind4>=0); assert(ind4<bound4); |
| 80 | + const int ind = ((ind1 * bound2 + ind2) * bound3 + ind3) * bound4 + ind4; |
| 81 | + return ptr[ind]; |
| 82 | + }; |
66 | 83 | // const std::complex < double> &operator()(int, int, int, int, int)const; |
67 | 84 |
|
68 | 85 | /**************************************************** |
|
0 commit comments