Hi, I've been using (bad) codes a lot for years, and I want to update them using latest/most optimized c++ tools now. I feel like I just need a little better understanding to get going.
I want to start using range-based for loops or for_each, and I'm kinda of blocked with this type of arrays:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
double interpolation_term_tab[8][8];
for (int n = 0 ; n < 8 ; n++)
for (int i = 0 ; i < 8 ; i++) {
interpolation_term_tab[n][i] = 0.0;
}
for (int n = 0 ; n < 8 ; n++)
for (int i = 0 ; i < n ; i++) {
constint i_plus_one = i + 1;
double interpolation_term = 1.0;
for (int ii = 0 ; ii < n ; ii++) {
if (i != ii) interpolation_term *= i_plus_one/static_cast<double> (i - ii);
}
interpolation_term_tab[n][i] = interpolation_term;
}
Is there a way of constructing such a (nested) array in a simpler way, as in with no raw loops. I don't even mind to use standard C++ algorithms. I just don't know where to start.