Re: [R] Summing up diagonals w/o for-loop

2008-02-26 Thread Marc Schwartz
Camarda, Carlo Giovanni wrote: > Dear R-users, > > is there any way to sum up the elements of the "diagonals" of a matrix > without using a for-loop? While there is a simple way over rows and > columns, I don't see a straightforward multiplication for the diagonals, > am I too demanding? Or, more l

Re: [R] Summing up diagonals w/o for-loop

2008-02-26 Thread Greg Snow
gt; [mailto:[EMAIL PROTECTED] On Behalf Of Camarda, > Carlo Giovanni > Sent: Tuesday, February 26, 2008 1:32 PM > To: [EMAIL PROTECTED] > Subject: [R] Summing up diagonals w/o for-loop > > Dear R-users, > > is there any way to sum up the elements of the "diagonals" of

[R] Summing up diagonals w/o for-loop

2008-02-26 Thread Camarda, Carlo Giovanni
Dear R-users, is there any way to sum up the elements of the "diagonals" of a matrix without using a for-loop? While there is a simple way over rows and columns, I don't see a straightforward multiplication for the diagonals, am I too demanding? Or, more likely, I'm lack some algebra trick? Is the