(Fwd) (Fwd) Re: Band Matrices 
Author Message
 (Fwd) (Fwd) Re: Band Matrices


10:24:04 PM
-------------------
Quote:

>   NB. I would like to see the posting of more
>   NB. well-defined problems (such as the diag-
>   NB. onal and band matrices posted by Faust),
>   NB. together with executable treatments of
>   NB. them in any or all dialects of APL. Here
>   NB. is a treatment of band matrices in J:



>     sh=. |. !. 0  NB. Shift in zeroes

>   NB. Try:
>   diag 2 3 5 7
>2 0 0 0
>0 3 0 0
>0 0 5 0
>0 0 0 7
>   0 band 2 3 5 7
>2 0 0 0
>0 3 0 0
>0 0 5 0
>0 0 0 7
>   1 band 3 5 7
>0 3 0 0
>0 0 5 0
>0 0 0 7
>0 0 0 0
>   _1 band 3 5 7
>0 0 0 0
>3 0 0 0
>0 5 0 0
>0 0 7 0
>. . . .

In reply to KEI here is further discussion on
banded matrices, including APL listings
to band a matrix super or sub-diagonal.
The four APL2 and ISI/APLIWIN functions
are short, but in my opinion, rely a bit too
much on overtake tricks and implicit
premultiplication of a boolean matrix by a
diagonal matrix (last line of the each function.)

Some limitations are also apparent.  Thus
only one diagonal is banded with each
execution.  Several bands -  matrices such
as bidiagonal or tridiagonal forms -are
usually what's needed.  To achieve that
result with these functions requires multiple
execution.  This forces one extra copy of the
matrix into the workspace, not a good thing
if the matrix is big.  A minor limitation is that
the resulting matrix is square.

The functions are listed as APL transliterated
to ASCII.  APL2 function names are in upper case,
ISI/APLIWIN function names are in lower case.
BANDHI and bandhi put their right vector
(or scalar) argument R into a super-diagonal,
BANDLO and bandlo put their right argument
into a sub-diagonal.  The left argument, scalar L,
sets the dimensions of the resulting square matrix.
The length of the right argument ({shape},R)
determines which diagonal will be used to contain
R.  The length must not be zero or exceed L.

Transliteration is via use of J. Weigang's A2A
workspace (beta version).  A2A inverse trans-
literation to APL functions should work for the APL2
listings.  It may fail for the ISI/APLIWIN functions
because of the symbol {rank}, which is ISI/APLIWIN's
'Rank Conjunction'.  See page 6-19 of the Iverson APL
Reference Manual (1993).  It is {quad}AV[164] when
{quad}io is 0.

Usage;  In APL2, 5 BANDHI 1 2 3 makes a 5 by 5 matrix
of all zeros except at positions [1;3], [2;4] and [3;5],
a super-diagonal of length three, in which vector 1 2 3
resides, in upper left to lower right order.  5 bandhi 1 2 3
does the same thing in ISI/APLIWIN, but uses the rank
conjunction in place of the axes brackets of APL2.

5 BANDHI 0 0 0 is a 5 by 5 matrix of all zeros.
5 BANDHI 0 1 0 is a 5 by 5 all zero matrix except with 1
stored in [2;4],  which is on the super-diagonal of length 3.
5 bandhi 1 is a 5 by 5 all zero matrix except 1 is stored
in [1;5], the shortest and highest super-diagonal.
(5 bandhi 1 2 3 4 5) + 5 bandhi 6 7 8 9 is an upper
bidiagonal matrix, etc.

Function Listings;
[0]   R{is}M BANDHI V;N;B
[1]   B{is}(N{is}M+#IO{is}1){reshape}0
[2]   B[N-{shape},V]{is}1
[3]   R{is}(M{take}V){times}[1](M,M){reshape}N{take}B

[0]   R{is}M BANDLO V;N;B
[1]   B{is}(N{is}M+#IO{is}1){reshape}0
[2]   B[N-{shape},V]{is}1
[3]
R{is}(M{take}V){times}[2]{transpose}(M,M){reshape}N{take}B

[0]   r{is}m bandhi v;n;b
[1]   b{is}(n{is}m+#io{is}1){reshape}0
[2]   b[n-{shape},v]{is}1
[3]   r{is}(m{take}v){times}{rank}0 1(m,m){reshape}n{take}b

[0]   r{is}m bandlo v;n;b
[1]   b{is}(n{is}m+#io{is}1){reshape}0
[2]   b[n-{shape},v]{is}1
[3]
r{is}({transpose}(m,m){reshape}n{take}b){times}{rank}1(m{take}v)



Sat, 22 Mar 1997 07:00:21 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. painting cells [Fwd: Re: Rubber Band]

2. (Fwd) MESSAGE ON PHONE SCAM (fwd)

3. [Fwd: envienla (fwd)]

4. Fwd: [LogoForum] Re: (Fwd) [apcs] Karel Goes Fishing!

5. Fwd: NetRexx language now available (fwd)

6. [Fwd: Re: RubyInline 1.0.4 Released! (fwd)]

7. Ruby Impressions (fwd) (fwd)

8. There's got to be an easy way to do this (fwd) (fwd)

9. utility to display the contents of a pickle (fwd) (fwd)

10. get-a-cup-of-coffee slow (fwd) (fwd)

11. Announcing DOS port availability (fwd) (Was: Announcing DOS port availability (fwd))

12. LOGO-L> (Fwd) Fwd: (fwd) Computers and education

 

 
Powered by phpBB® Forum Software