Y
Yos P.
I'm using a 3D matrix, which is actually a three 2D arrays, in a
dinamic programing that runs many times. The 2D arrays are being filled
and sometimes deallocated in each run.
I need to optimize the accessing (filling up the 2D array) part, making
it as fast as possible, while allocating is less important since it is
done less often.
Any suggestion of the fastest way to do so are welcomed.
Here is the naive approach:
F = new int**[3];
for(int i=0; i<3; ++i) {
F = new int*[Rows];
for(int j=0; j < Rows; ++j) {
F[j]= new int[Cols];
}
}
for (int i = 1; i < Rows; ++i) {
for (int j = 1; j < Cols; ++j) {
F[0][j] = .... F[0][i-1][j] ....
F[1][j]...
...
Thanks.
dinamic programing that runs many times. The 2D arrays are being filled
and sometimes deallocated in each run.
I need to optimize the accessing (filling up the 2D array) part, making
it as fast as possible, while allocating is less important since it is
done less often.
Any suggestion of the fastest way to do so are welcomed.
Here is the naive approach:
F = new int**[3];
for(int i=0; i<3; ++i) {
F = new int*[Rows];
for(int j=0; j < Rows; ++j) {
F[j]= new int[Cols];
}
}
for (int i = 1; i < Rows; ++i) {
for (int j = 1; j < Cols; ++j) {
F[0][j] = .... F[0][i-1][j] ....
F[1][j]...
...
Thanks.