[SciPy-user] More problems with Sparse

Nils Wagner nwagner at mecha.uni-stuttgart.de
Wed Oct 27 02:30:12 CDT 2004


Robert Kern wrote:

> Nils Wagner wrote:
>
>> Hi Travis,
>>
>> A few days ago I have reported on the following bug in sparse. 
>> (recent Bug tracker entries)
>> It would be nice if this problem could be fixed.
>> Thanks in advance.
>>
>> Nils
>>
>>>>> from scipy import *
>>>>> A = sparse.dok_matrix()
>>>>> A[0,0] = 1j
>>>>> A.todense()
>>>>
>>
>> Traceback (most recent call last):
>>  File "<stdin>", line 1, in ?
>>  File "/usr/lib/python2.3/site-packages/scipy/sparse/Sparse.py", line 
>> 1326, in todense
>>    new[ikey0,ikey1] = self[key]
>> TypeError: can't convert complex to float; use abs(z)
>
>
> It's difficult to determine beforehand if a matrix needs to be complex 
> or not. The default typecode for the dense array is 'd' (double 
> precision real). Use the typecode keyword argument to todense() to 
> choose something else.
>
> E.g.
>
>   A.todense(Complex)
>
> I found this out in 30 seconds by looking at the source code.
>
Thank you.  A tutorial illustrating all these features would be very 
valuable.

Again, I have some trouble with complex matrices and iterative solvers.

 File "sparse_it.py", line 38, in ?
    sol0,info0  = linalg.gmres(A,r)
  File "/usr/lib/python2.3/site-packages/scipy/linalg/iterative.py", 
line 499, in gmres
    work[slice2] += sclr1*matvec(work[slice1])
TypeError: return array has incorrect type

How can I resolve this problem ?

Nils

 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: sparse_it.py
Type: text/x-python
Size: 1303 bytes
Desc: not available
Url : http://www.scipy.net/pipermail/scipy-user/attachments/20041027/19472cd5/sparse_it.py


More information about the SciPy-user mailing list