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

Fernando Perez fperez.net at gmail.com
Thu Aug 11 20:15:21 EDT 2011


On Thu, Aug 11, 2011 at 4:43 PM, Jose Borreguero <borreguero at gmail.com> wrote:
> a = random.randn(3,3)
> b = a.reshape(1,3,3).repeat(50,axis=0)
> scipy.linalg.block_diag( *b )
>

slightly simpler, but equivalent, code:

b = [a]*50
scipy.linalg.block_diag( *b)

Cheers,

f



More information about the NumPy-Discussion mailing list