[Numpy-discussion] how to create a block diagonal matrix by repeating the block?

Jose Borreguero borreguero@gmail....
Thu Aug 11 18:43:12 CDT 2011


Dear numpy users,

I have a 3x3 matrix which I want to repeat 50 times along a diagonal, thus
creating a 150x150 block diagonal matrix.

I know of a method usin scipy.linalg.block_diag, but I don't know if this is
the best one:
a = random.randn(3,3)
b = a.reshape(1,3,3).repeat(50,axis=0)
scipy.linalg.block_diag( *b )

Jose
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110811/b59221c8/attachment.html 


More information about the NumPy-Discussion mailing list