Re: Extract any diagonal from a square matrix...
- To: mathgroup at smc.vnet.net
- Subject: [mg66531] Re: Extract any diagonal from a square matrix...
- From: "J Siehler" <jsiehler at gmail.com>
- Date: Fri, 19 May 2006 03:39:27 -0400 (EDT)
- References: <e3js8r$8kh$1@smc.vnet.net><e3uofj$ial$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I'm sure everyone's past caring, but here's a solution that avoids separate definitions for super- and subdiagonals, and behaves well with nonsquare matrices: diag[t_, d_] := Extract[t, Cases[Position[t, _, {2}, Heads -> False], {x_, y_} /; y == x + d]]