Re: Challenge 4 (matrix diagonal)
From: Dave Thompson (david.thompson1_at_worldnet.att.net)
Date: 12/28/03
- Previous message: Richard Maine: "Re: Symmetric Integer Ranges"
- Next in thread: David Frank: "Re: Challenge 4 (matrix diagonal)"
- Reply: David Frank: "Re: Challenge 4 (matrix diagonal)"
- Reply: *** Hendrickson: "Re: Challenge 4 (matrix diagonal)"
- Maybe reply: robin: "Re: Challenge 4 (matrix diagonal)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 28 Dec 2003 01:49:05 GMT
On Sun, 21 Dec 2003 02:15:36 GMT, john <john@nospam.com> wrote, in
comp.lang.pl1 as part of a (the?) long-running David Frank flamefest;
comp.lang.fortran added with some trepidation:
> 4. Fortran CAN'T equivalence a vector with the diagonal of a matrix.
>
> dcl a(10,10) float, diag(10) defined (1sub, 1sub);
> put (d); prints the diagonal elements of array a.
For the specific case of diagonal, I *think* this will work:
REAL/whatever Matrix (1:N, 1:N)
TYPE EveryNPlus1; SEQUENCE
REAL/whatever Take, Skip (1:N)
END TYPE EveryNPlus1
TYPE(EveryNPlus1) Overlay (1:N)
EQUIVALENCE (Matrix, Overlay)
and now you can use Overlay%Take as a vector, or I'm pretty sure even
set an "assumed-shape" dummy or POINTER to it (F9x array POINTERs are
full dope vectors). Overlay(N) runs off the end of the last column of
Matrix (Fortran arrays are column-major) though Overlay%Take(N) aka
Overlay(N)%Take doesn't, so I'm not sure this is technically legal.
Similarly for the antidiagonal, and hyper versions; but not more
general isub cases, which you have under a different item number.
With F2k03? "type kind parameters" you might be able to improve the
syntax some, but I haven't looked at it in enough detail to be sure,
and anyway that is neither official nor implemented yet.
- David.Thompson1 at worldnet.att.net
- Previous message: Richard Maine: "Re: Symmetric Integer Ranges"
- Next in thread: David Frank: "Re: Challenge 4 (matrix diagonal)"
- Reply: David Frank: "Re: Challenge 4 (matrix diagonal)"
- Reply: *** Hendrickson: "Re: Challenge 4 (matrix diagonal)"
- Maybe reply: robin: "Re: Challenge 4 (matrix diagonal)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]