[SciPy-User] need assistance

josef.pktd at gmail.com josef.pktd at gmail.com
Sat Sep 25 14:35:32 EDT 2010


On Sun, Sep 12, 2010 at 9:09 PM, AHILAN KANAGASUNDARAM
<ahilan.kanagasundaram at student.qut.edu.au> wrote:
> Hi,
>
> I’m working on python and scipy.  I need to create block diagonal matrix,
> When I tried to use below function,  it says that there is not block module
>
>
>
>>>> a=numpy.ones([2,2])
>
>>>> b=numpy.random.rand(3,3)
>
>>>> import block
>
>>>> c=block.block_diag(a,b)
>
>>>> print c


In case you still need it, I don't know why the message shows up today,

block_diag is in a recent scipy


>>> from scipy.linalg import block_diag
>>> block_diag(np.random.randint(1,4,size=(3,3)), np.random.randint(1,2,size=(2,4)))
array([[2, 2, 1, 0, 0, 0, 0],
       [2, 1, 1, 0, 0, 0, 0],
       [1, 2, 1, 0, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1],
       [0, 0, 0, 1, 1, 1, 1]])

Josef

>
>
>
>
> How can I fix this problem. Is there any alternative way to create block
> diagonal matrix.
>
>
>
> I look forward to hearing from you.
>
>
>
>
>
> Thanks
>
>
>
>
>
> K.Ahilan
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>



More information about the SciPy-User mailing list