Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!rutgers!mcnc!uvaarpa!murdoch!astsun.astro.Virginia.EDU!gl8f From: gl8f@astsun.astro.Virginia.EDU (Greg Lindahl) Newsgroups: comp.lang.fortran Subject: Re: Fortran vs. C for numerical work (SUMMARY) Message-ID: <1990Nov28.065242.10154@murdoch.acc.Virginia.EDU> Date: 28 Nov 90 06:52:42 GMT References: <9458:Nov2721:51:5590@kramden.acf.nyu.edu> <7097@lanl.gov> <17680:Nov2806:04:1090@kramden.acf.nyu.edu> Sender: news@murdoch.acc.Virginia.EDU Organization: Department of Astronomy, University of Virginia Lines: 18 In article <17680:Nov2806:04:1090@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: >Huh? A double-pointer array, as we were discussing, is a >single-dimensional array of pointers to single-dimensional arrays. To >access a random element of the array takes two additions and two memory >references. In contrast, to access a random element of a flat array >takes two additions, a multiplication, and a memory reference. On most >widely used machines, a multiplication is quite a bit slower than a >memory reference, particularly a cached memory reference. That's why >double-pointer arrays are better than flat arrays for so many >applications. Except that inside loops, the multiplication is strength-reduced to an addition. That's why flat arrays are faster than double-pointer arrays for so many applications. The totally flexible language would hide this little detail from the programmer and would pick the right one. If I have to choose, I'd use flat arrays in my numerical programs. If I have to use C, a few macros give me what I really want.