[SciPy-user] ValueError: invalid return array shape

Nils Wagner nwagner at mecha.uni-stuttgart.de
Fri Mar 17 01:27:21 CST 2006


Ed Schofield wrote:
> On 16/03/2006, at 12:56 PM, Nils Wagner wrote:
>
>   
>> If I use a lowercase dtype name
>> A_csc = s.csc_matrix((3,3),complex128)
>> for i in arange(0,3):
>>
>>     A_csr[i,i] = 1.0+2j
>>     A_csc[i,i] = 1.0+2j
>>
>>     
>>>>> A_csc
>>>>>           
>> <3x3 sparse matrix of type '<type 'float64scalar'>'
>>         with 3 stored elements (space for 100)
>>         in Compressed Sparse Column format>
>>
>> Note that the imaginary part is missing !
>>
>>     
>>>>> print A_csc
>>>>>           
>>   (0, 0)        1.0
>>   (1, 1)        1.0
>>   (2, 2)        1.0
>>     
>
> Try again using:
>  >>> A_csc = csc_matrix((3,3), dtype=complex128)
>
> The dtype keyword is necessary explicitly.  I've closed the bug  
> report for now.  Could you please submit your user name with future  
> bug reports on Trac?  Thanks :)
>
> -- Ed
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>   

Hi Ed,

I have added the dtype keyword - it works but the iterative solvers get
into trouble if the input is a dense matrix.
For what reason ? Should I submit another bug report w.r.t. this issue ?

       cg         --- Conjugate gradient (symmetric systems only)
       cgs        --- Conjugate gradient squared
       qmr        --- Quasi-minimal residual
       gmres      --- Generalized minimal residual
       bicg       --- Bi-conjugate gradient
       bicgstab   --- Bi-conjugate gradient stabilized

    x1,info3 = linalg.gmres(A_csc_dense,b) # ValueError: invalid return
array shape
  File "/usr/lib64/python2.4/site-packages/scipy/linalg/iterative.py",
line 615, in gmres
    work[slice2] += sclr1*matvec(work[slice1])
ValueError: invalid return array shape
>>> A_csc_dense
matrix([[ 1.+2.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j,  1.+2.j,  0.+0.j],
       [ 0.+0.j,  0.+0.j,  1.+2.j]])
>>> b
array([ 0.99145813+0.30371645j,  0.36026628+0.88278217j,
        0.65509504+0.08744001j])

Nils



More information about the SciPy-user mailing list