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

Fernando Perez fperez.net@gmail....
Thu Aug 11 19:15:21 CDT 2011


On Thu, Aug 11, 2011 at 4:43 PM, Jose Borreguero <borreguero@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