Re: fast bit rotation
- Posted by "Lucius L. Hilley III" <L3Euphoria at bellsouth.net> Dec 31, 2003
- 452 views
Using a precomputed table is 2 of my examples. One arrangement of 7x256 another of 256x7. Except for the precomputed tables, any of my examples could be modified for 32-bit integers and extended to work on sequences to rotate all of the values within. Making the assumption that all values within the sequence are not floats. Lucius L. Hilley III ----- Original Message ----- From: "Pete Lomax" <petelomax at blueyonder.co.uk> To: <EUforum at topica.com> Sent: Wednesday, December 31, 2003 10:59 AM Subject: Re: fast bit rotation > > > Another thing you could try is to build tables of pre-computed shifts, > eg: > > sequence shl, shr > shl=repeat(0,256) > shr=repeat(0,256) > for i = 0 to 255 do > if i<=127 then > shl[i+1]=i*2 > else > shl[i+1]=and_bits(i,#7F)*2+1 > end if > shr[shl[i+1]+1]=i > end for > > Use k=shl[k+1] when k is 0..255, to avoid zero index problems. > > You can do your own test/timings, though I got 3.9 million/sec on a > 233MHz PII with 48Mb ram, sorry Tommy, CNR ) > > Pete > PS No warranty on the above code, btw. >