I was trying to create some vector with negative index but just learnt that it was not allowed in C++. Is there any alternative or better way to do it?
for example I want to create a 3D vector named Wt:
in VBA context array was like built like this: easy and nice
Redim Wt(0 to k_max,-i_max to i_max,-j_max to j_max)
' and use it like below for example:
Wt(3, -100, -105) = .....
in C++ context it was unfriendly and inconvenient:
// resizing the vector:
Wt.resize(k_max + 1);
for (int k = 0; k < k_max + 1; k++) {
Wt[k].resize(2 * i_max + 1);
for (int i = 0; i < 2 * i_max + 1; i++) {
Wt[k][i].resize(2 * j_max + 1);
}
}
// when using the vector:
for (int k = 0; k <= k_max; k++) {
for (int i = -i_max; i <= i_max; i++) {
for (int j = -j_max; j <= j_max; j++) {
Wt[k][i + i_max][j + j_max] = ...
}
}
}