Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!apple!agate!shelby!unix!garth!smryan From: smryan@garth.UUCP (Steven Ryan) Newsgroups: comp.lang.fortran Subject: Re: strength reduction of array address calculations Message-ID: <4@garth.UUCP> Date: 3 Dec 90 20:21:33 GMT References: <17680:Nov2806:04:1090@kramden.acf.nyu.edu> <1990Nov28.065242.10154@murdoch.acc.Virginia.EDU> <1990Nov28.213735.25563@murdoch.acc.Virginia.EDU> Reply-To: smryan@garth.UUCP (Steven Ryan) Organization: INTERGRAPH (APD) -- Palo Alto, CA Lines: 35 >... I was responding (somewhat tongue in cheek, though hoping I'd >actually get an incredibly insightful answer) to someone who had said one can >strength-reduce the multiplies away in loops in response to yet another person >who clearly had been talking about, yes, RANDOM references. Given something like real a(0:9,0:9),b(0:9,0:9) integer e,f,g,h do j=0,9 do i=0,9 a(e(i),f(j)) = b(g(i),h(j)) enddo enddo end you can get rid of the multiplication by using real a(0:99),b(0:99) integer e,f,g,h integer m(0:9) data m/0,10,20,30,40,50,60,70,80,90/ do j=0,9 do i=0,9 a(m(e(i))+f(j)) = b(m(g(i))+h(j)) enddo which the compiler can do for you. Even when the multiplier is unknown, as with adjustable arrays, the multiplier vector can be filled in with a loop using only adds. enddo end -- ...!uunet!ingr!apd!smryan Steven Ryan ...!{apple|pyramid}!garth!smryan 2400 Geng Road, Palo Alto, CA Brought to you by Super Global Mega Corp .com