The following solution is far from simple.
($$ (+/"1)@(#: [:i. */)@$ ({:/: /:@{.)@([,&; ([:< +/\.)/.) ,) x
0 5 15 18
4 13 15 7
8 9 0 1
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:programming-
> [EMAIL PROTECTED] Namens Robert O'Boyle
> Verzonden: zondag 25 november 2007 16:13
> Aan: [email protected]
> Onderwerp: [Jprogramming] Oblique function
>
> I have an arbitrary matrix, x
>
>
>
> 0 1 2 3
>
> 4 5 6 7
>
> 8 9 0 1
>
>
>
> and wish to apply verbs along the diagonals. The oblique verb, /. , allows
> me to do this and with the suffix. \., I can keep the intermediate results
>
>
>
> So,
>
>
>
> +/\./. x produces matrix
>
>
>
> 0 0 0
>
> 5 4 0
>
> 15 13 8
>
> 18 15 9
>
> 7 0 0
>
> 1 0 0
>
>
>
> which is almost what I want but what I would really like are the
> cumulative
> results along the diagonals but in the shape of the original matrix. Thus
> summing the original matrix x above would produce
>
>
>
> 0 5 15 18
>
> 4 13 15 7
>
> 8 9 0 1
>
>
>
> I looked in the forum archive and couldn't find anything on this.
>
>
>
> Is there a simple way of producing my desired matrix from the original?
>
>
>
> Bob
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm