I am using a boost mutli array for 2D as follows,
typedef boost::multi_array<double, 2> array_type;
typedef array_type::index index;
// initialize array
array_type U(boost::extents[N][3]);
for(index i = 0; i != N; ++i) {
for(index j = 0; j != 3; ++j){
U[i][j] = 0;
}
}
double * pU = U.data();
double (*arrayU)[3] = (double (*)[3])pU;
Now I am trying to implement it but for 3D, so far I have written the following,
typedef boost::multi_array<double, 3> array_type;
typedef array_type::index index;
// initialize array
array_type U(boost::extents[M][N][4]);
for(index i = 0; i != M; ++i) {
for(index j = 0; j != N; ++j){
for(index k = 0; k != 4; ++k){
U[i][j][k] = 0;
}
}
}
But the following part is still confusing for me, can you please tell me how to do it and explain it a little bit?
double * pU = U.data();
double (*arrayU)[3] = (double (*)[3])pU;
Thanks!