I have an arbitrary matrix >:5 5 $ i.100 and want to insert a row and column
of zeros between the 4th row and column respectively. So, the matrix 

 

1  2  3  4  5

 6  7  8  9 10

11 12 13 14 15

16 17 18 19 20

21 22 23 24 25

 

becomes 

 

1   2   3   4   0   5

6   7   8   9   0   10

11 12 13 14 0   15

16 17 18 19 0   20

0    0    0   0 0     0

21 22 13 24 0   25

 

I have been trying the spread verb #^:_1 but this appears only to work on
lists. I could loop through the matrix but there must be a straightforward
way in J to do this. The insertions ultimately will be fairly irregular
(i.e. requiring insertions of 1, 2, 3 etc rows and columns between various
rows and columns.

 

Any help on this would be greatly appreciated

 

Thanks

 

Bob

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

Reply via email to