Mail Archives: djgpp/1995/12/20/04:24:30
Felaco <bcf AT ssd DOT ray DOT com> wrote to me:-
> ... Passing 2 dimensional arrays as parameters is a pain, especially when
> the bounds are dynamic. You might end up doing your index arithmetic
> yourself.
Try accessing matrixes via `Iliffe vectors' like in Atlas Autocode (a subset
of Algol60 but it had type complex, on our mainframes in the 1960's):-
Instead of e.g. `double x[p][q];' write:-
double x$[p][q],*x[p]; for(i=0;i<p;i++) x[i]=x$[i];
and e.g. x[5][7] accesses the same element as x$[5][7].
Likewise, instead of e.g. `double y[p][q][r];' write:-
double y$$[p][q][r],*y$[p][q],**y[p];
for(i=0;i<p;i++) {y[i]=y$[i]; for(j=0;j<q;j++) y$[i][j]=y$$[i][j];}
and e.g. y[5][7][6] accesses the same element as y$$[5][7][6].
(as macros if called several times)
and in args pass matrixes as **type and 3D arrays as ***type.
- Raw text -