home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!convex!convex!dodson
- From: dodson@convex.COM (Dave Dodson)
- Newsgroups: comp.programming
- Subject: Re: Fast array rotation
- Message-ID: <1992Dec22.154338.15357@news.eng.convex.com>
- Date: 22 Dec 92 15:43:38 GMT
- References: <u895027.724990251@tasman>
- Sender: usenet@news.eng.convex.com (news access account)
- Reply-To: dodson@convex.COM (Dave Dodson)
- Organization: Engineering, CONVEX Computer Corp., Richardson, Tx., USA
- Lines: 30
- Originator: dodson@bach.convex.com
- Nntp-Posting-Host: bach.convex.com
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
-
- In article <u895027.724990251@tasman> u895027@tasman.cc.utas.edu.au (Mark Mackey) writes:
- >
- > I am currently writing a terrain display routine which utilises
- >a fast surface display algorithm based on scan-line processing. As
- >part of the algorith I need to rotate the raw data array. I have an
- >algorithm to do this using two 1d transforms, but in between these
- >transforms the data array needs to be transposed.
- > Does anyone out there have any code for fast array transposition
- >on disk, minimising disk access time? Alternatively, if anyone out there
- >has ideas on how to rotate a large array (512*512 reals) efficiently
- >I would be most grateful.
-
- I assume you have the array stored on disk in row- or column-major order.
- There is a way to transpose the array by reading and writing the matrix
- twice. For simplicity, assume you have row-major order, 4 byte reals,
- and a scratch array of length 64K bytes. Read 65536/4/512 = 16 rows into
- the scratch array. Write 16 x 16 square blocks onto a scratch file. There
- will be 512/16 = 32 of them for every 16 rows. Repeat for all rows of the
- matrix. Now randomly read blocks 1, 33, 65, ... . Transpose each 16 x 16
- block in memory, and write out the first 16 rows of the transposed matrix.
- Repeat with blocks 2, 34, 66, ... , 3, 35, 67, ... .
-
- Alternatively, you might consider storing your 512 x 512 matrix in those
- 16 x 16 blocks as your standard storage format. Then you can easily read
- or write it in either normal or transposed form using that 64K scratch array.
-
- ----------------------------------------------------------------------
-
- Dave Dodson dodson@convex.COM
- Convex Computer Corporation Richardson, Texas (214) 497-4234
-