3
votes

I have 3 matrices A,B,C. I wish to create a larger matrix of the form

D = | 0 A |
    | B C |

How to do this in Numpy ?

1

1 Answers

5
votes

This:

numpy.bmat([[numpy.zeros(appropriate_shape), A], [B, C]])

works, but I'm not sure how to avoid the creation of that big, useless array of zeros. Also, it returns a matrix instead of an array, so make sure to call asarray on it if you want an array.