Good day. I am honestly a newbie of std::vector and I would like to know how can I convert my previous program into a new one? My old program looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
float matA2[1000][1000];
int a = 0;
for (int x = 0; x < count_g_polCoeffGerald; x++) {
int b = 0;
for (int y = 0; y < count_g_polCoeffGerald; y++) {
x0 = values [a]; //x component
y0 = values [a + 1]; //y component
x1 = values [b] //x component of the next coordinate
y1 = values [b + 1]; //y component of the next coordinate
matA2[x][y] = LeastSquareDistance(x0,y0,x1,y1); //function computation
b+=2; //go to next coordinate
}
a+=2; //go to next coordinate to be compared with all coordinates
}
However, I am trying to incorporate the same algorithm to the code that I have right now, but I am having trouble with how can I can call the x,y,z values of indCell. I know that the code "glm::ivec3 indCell = it->first;" iterates to all the values of g_polCoeff and "indCell.x", "indCell.y" correspond to "x values" and "y values" of indCell, however, I was wondering how can I call the next x,y values of the next coordinate if I have the kind of syntax code below considering the iterator "it" I have below?
std::unordered_map<glm::ivec3, float>::iterator it;
constint count_g_polCoeff = g_polCoeff.size();
for (it = g_polCoeff.begin(); it != g_polCoeff.end(); it++) {
glm::ivec3 indCell = it->first;
std::vector<float> matA2;
matA2.reserve(count_g_polCoeff * count_g_polCoeff);
int a = 0;
for (int x = 0; x < count_g_polCoeffGerald; x++) {
int b = 0;
for (int y = 0; y < count_g_polCoeffGerald; y++) {
x0 = ?
y0 = ?
x1 = ?
y1 = ?
matA2[ ] = LeastSquareDistance(x0,y0,x1,y1);
b+=2; //go to next coordinate
}
a+=2; //go to next coordinate to be compared with all coordinates
}
}
Up to this moment I am still guessing how to correspondingly translate my old program to the new one and it's still question mark for me. Thank you very much for your inputs in advance!