Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!dik From: dik@cwi.nl (Dik T. Winter) Newsgroups: comp.lang.c Subject: Re: complex arithmetic in C Keywords: complex arithmetic, C Message-ID: <7976@boring.cwi.nl> Date: 27 Mar 89 23:35:21 GMT References: <54901@yale-celray.yale.UUCP> <9933@smoke.BRL.MIL> Organization: CWI, Amsterdam Lines: 19 In article <9933@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: > In article <54901@yale-celray.yale.UUCP> ashcraft@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@cwi.nl BITNET/EARN: dik@mcvax