complex arithmetic in C

Dik T. Winter dik at cwi.nl
Tue Mar 28 09:35:21 AEST 1989


In article <9933 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
 > In article <54901 at yale-celray.yale.UUCP> ashcraft at yale.UUCP (Cleve Ashcraft) writes:
 > >dealing with struct's may be easy, but will it later have to be
 > >hardcoded into two arrays for efficiency?
 > 
 > Two arrays of what?
 > 
The question was: should an array of complex be stored as such or as two
arrays of reals, real and imaginary parts.  It is difficult to say which
is more efficient, it is very machine dependent, although on most machines
storing as two arrays will be slightly more efficient (it gives a slightly
better locality of reference, and hence a slightly better cache hit ratio).
However, on vector machines storing as two arrays is in general a big win,
especially if the vector instructions do not allow strides (CDC, ETA).
But do not worry, C does not support vector machines very well.
-- 
dik t. winter, cwi, amsterdam, nederland
INTERNET   : dik at cwi.nl
BITNET/EARN: dik at mcvax



More information about the Comp.lang.c mailing list