Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uflorida!ukma!rutgers!uwvax!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.fortran Subject: Re: Fortran versus C for numerical analysis Message-ID: <13543@mimsy.UUCP> Date: 14 Sep 88 01:35:17 GMT References: <1484@ficc.uu.net> <3502@lanl.gov> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 34 >In article <1484@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: >>You mean dynamically sized arrays. Dynamically allocated but statically >>sized arrays are implemented like any other array. In article <3502@lanl.gov>, jlg@lanl.gov (Jim Giles) writes: >No, I've never seen a C dynamically allocated multidimensional array >that wasn't implemented as an array of pointers. For a two dimensional >array, each pointer in the array of pointers points to a row of the array. >Higher dimensions are implementes as pointers_to_pointers_to_.... >the number of indirect levels is one less than the number of dimensions. > >- This is _NOT_ 'like any other array'. You seem to have conveniently forgotten the material I posted here not long ago. Here is a dynamic (fixed size) array that is not an array of pointers: extern char *malloc(); f() { double (*arr)[64]; int n_rows = 16, i, j; arr = (double (*)[64])malloc(n_rows * sizeof(*arr)); if (arr == NULL) ... do something for (i = 0; i < n_rows; i++) for (j = 0; j < 64; j++) /* work on arr[i][j] */; } -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris