home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / sci / math / numanal / 3601 < prev    next >
Encoding:
Internet Message Format  |  1992-12-16  |  2.7 KB

  1. Path: sparky!uunet!cs.utexas.edu!natinst.com!news.dell.com!swrinde!network.ucsd.edu!sdcc12!xm9
  2. From: xm9@sdcc12.ucsd.edu (richard g. adair)
  3. Newsgroups: sci.math.num-analysis
  4. Subject: Re: Band Matrix Multiplication
  5. Keywords: Matrix Vector
  6. Message-ID: <42615@sdcc12.ucsd.edu>
  7. Date: 16 Dec 92 06:24:00 GMT
  8. References: <1992Dec15.145457@is.morgan.com>
  9. Sender: news@sdcc12.ucsd.edu
  10. Organization: University of California, San Diego
  11. Lines: 49
  12. Nntp-Posting-Host: sdcc12.ucsd.edu
  13.  
  14. In article <1992Dec15.145457@is.morgan.com> robt@is.morgan.com (Rob Torop) writes:
  15. >
  16. >I have some code, the core of which is a loop that computes the transformation of a
  17. >vector by a band matrix multiple times:
  18. >
  19. >    x <-- Bx    where  B  =    b c 0 . . . 0
  20. >                       a b c . . . 0
  21. >                   . . .
  22. >                           0 0 0 . a b c
  23. >
  24. >Right now, I'm basically doing the obvious thing, looping over the vector.  I have this nagging feeling that there is something brilliant and very different that can be done.  I'm running on Sun Sparcs (2 and 10), in case that makes a difference.  Any advice?
  25. >
  26. >
  27. >-- Rob Torop
  28.  
  29. Yes, you're right about there being other ways to do this.  Your
  30. banded matrix has special structure - it is a Toeplitz matrix, that
  31. is, the diagonals have constant entries.  Multiplication of a vector
  32. by a Toeplitz matrix can be done by convolution - consult Numerical
  33. Recipes, for example, for an explanation of convolution.    However,
  34. there is an even easier way in the case of your compact, tridiagonal
  35. matrix.
  36.  
  37. Think of your matrix B as the sum aI(-) + bI + cI(+), where I is the
  38. identity matrix, I(-) is a matrix of all ones along the first
  39. sub-diagonal, and I(+) is all ones along the first super-diagonal.
  40. The effect of multiplication by I(-) is to shift a vector forward by
  41. one entry, with the first entry replaced by zero.  Thus,
  42. I(-)*[1,2,3] = [0,1,2]; I intend my vector notation to denote a
  43. column vector.  
  44.  
  45. Similarly, multiplication by I(+) shifts
  46. the entries back one, replacing the last entry by zero: 
  47. I(+)*[1,2,3]=[2,3,0].  I, of course, simply returns the orginal
  48. vector.
  49.  
  50. If you put this all together, our example would be
  51.     Bx = a*[0,1,2] + b*[1,2,3] + c*[2,3,0] 
  52.  
  53. The generalization to your problem is straightforward.  This is done
  54. in 3*(n-1) + 1 flops, whereas general matrix-vector multiplication
  55. requries n^2 flops, where n is the length of the vector. If your
  56. matrix is Toeplitz, but more of the diagonals are filled out, you
  57. can use Fast Fourier transforms to do the equivalent convolutions,
  58. which could be done in order n*log2(n) operations.  In practice, the
  59. speed of the FFT approach depends a lot on implementation details,
  60. and so your effort wouldn't be repayed except at large n (~ 512 or
  61. greater, in my experience).
  62. intermdediate to . 
  63.