Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!mach1!torn!howland.reston.ans.net!gatech!udel!bogus.sura.net!news-feed-1.peachnet.edu!umn.edu!csus.edu!sfsuvax1.sfsu.edu!vpcsc4
From: vpcsc4@sfsuvax1.sfsu.edu (Emmett McLean)
Subject: Re: Question: Tri-diagonal matrices in APL
Message-ID: <1993Apr27.210112.2780@csus.edu>
Sender: news@csus.edu
Organization: San Francisco State University
References: <27APR93.10680596.0076@UNBVM1.CSD.UNB.CA>
Date: Tue, 27 Apr 1993 21:01:12 GMT
Lines: 41


   
   NB.  A more interesting question might be : What is the APL code for the
   NB.  multiplicative inverse of the tridiagonal?
   
   b =. 5 5 $ 2 _1 0 0 0 _1
   b
 2 _1  0  0  0
_1  2 _1  0  0
 0 _1  2 _1  0
 0  0 _1  2 _1
 0  0  0 _1  2

   %. b
0.833333 0.666667 0.5 0.333333 0.166667
0.666667  1.33333   1 0.666667 0.333333
     0.5        1 1.5        1      0.5
0.333333 0.666667   1  1.33333 0.666667
0.166667 0.333333 0.5 0.666667 0.833333

NB.  Here is the J code for the inverse:
   l =. >:/~@>:@i. * |.@(*/~)@>:@i.
   inverse =. >: %~ (] + |:"2@(] - (<0 1)&|: * =/~@i.@#))@l
   
   inverse 5
0.833333 0.666667 0.5 0.333333 0.166667
0.666667  1.33333   1 0.666667 0.333333
     0.5        1 1.5        1      0.5
0.333333 0.666667   1  1.33333 0.666667
0.166667 0.333333 0.5 0.666667 0.833333
  
NB. Easier to see the pattern this way. 
   6 * inverse 5   
5 4 3 2 1
4 8 6 4 2
3 6 9 6 3
2 4 6 8 4
1 2 3 4 5

  
Emmett 
