www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/12/20/04:24:30

From: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
To: DJGPP AT sun DOT soe DOT clarkson DOT edu
Date: Wed, 20 Dec 1995 08:59:26 GMT
Subject: dynamic parametric arrays (was: Re: array arg funny (2))

  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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019