Re: Filling a matrix with values
- From: Phil Last <phil.last@xxxxxxxxxxxx>
- Date: Mon, 24 Dec 2007 07:53:14 -0800 (PST)
On Dec 24, 3:13 pm, Lance <Lanc...@xxxxxxxxx> wrote:
On Dec 24, 6:19 am, Jimmy Miller <CaptainThun...@xxxxxxxxx> wrote:
I'm a complete beginner to APL, and I had the following question:
Suppose I have a 16x16 matrix of values. How would I set each value
in the matrix (starting in the second row) equal to the sum of the
matrix element directly above it, and the element to the top-left of
it? Essentially,
m[x;y]=m[x;y-1]+m[x-1;y-1]
But I'm not sure how to express that in APL. I've tried entering just
that in APL (with proper symbols, of course), but it doesn't work
because x and y are arrays, and I need to access only two single
elements of the matrix.
I'm a little confused. You state 'matrix element directly above it',
which to me would be m[x-1,y]. Also, it isn't completely clear to me
the meaning of 'the element to the top-left of it'.
Lance
(1 0↓m)←2+/0,¯1 0↓m ⍝ should do what you asked but the first row and
column might not be what you want.
.
- References:
- Filling a matrix with values
- From: Jimmy Miller
- Re: Filling a matrix with values
- From: Lance
- Filling a matrix with values
- Prev by Date: Re: Filling a matrix with values
- Next by Date: Re: Filling a matrix with values
- Previous by thread: Re: Filling a matrix with values
- Next by thread: Re: Filling a matrix with values
- Index(es):
Relevant Pages
|
Loading