One way (using j601, also works in j504 but with different tacit result) -

   pad =: 13 : '(2# >./ $y.){. y.'
   pad
] {.~ 2 # [: >./ $

   q
0 1
2 3
4 5
6 7
   pad q
0 1 0 0
2 3 0 0
4 5 0 0
6 7 0 0
   pad |: q
0 2 4 6
1 3 5 7
0 0 0 0
0 0 0 0

- joey


At 09:44  -0400 2006/04/05, John Randall wrote:
Suppose I have a numeric matrix.  How can I add rows or columns of zeros
if necessary to make it square?

I have some code that will do this, but I am embarrassed to post it.
There must be a slick way.

Thanks.

Best wishes,

John

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to