Scipy LinearOperator dtype unspecified
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Meadow
--
Chapters
00:00 Question
02:18 Accepted answer (Score 4)
02:59 Thank you
--
Full question
https://stackoverflow.com/questions/2025...
Question links:
[LinearOperator with Two Inputs]: https://stackoverflow.com/questions/2024...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpy #matrix #scipy
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Meadow
--
Chapters
00:00 Question
02:18 Accepted answer (Score 4)
02:59 Thank you
--
Full question
https://stackoverflow.com/questions/2025...
Question links:
[LinearOperator with Two Inputs]: https://stackoverflow.com/questions/2024...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpy #matrix #scipy
#avk47
ACCEPTED ANSWER
Score 4
(This is more of an extended comment than an answer.)
What version of scipy are you using? I'm using scipy 0.13.0. If I don't specify the dtype when I create the LinearOperator, I get the dtype error that you get. But specifying dtype='float64' works for me:
In [1]: import numpy as np
In [2]: from scipy.sparse.linalg import LinearOperator, gmres
In [3]: def mymatvec(v):
...: a = np.array([[4,2,1],[2,2,1],[1,1,1]])
...: return a.dot(v)
...:
In [4]: A = LinearOperator((3,3), mymatvec, dtype='float64')
In [5]: b = np.array([1,2,3])
In [6]: gmres(A, b)
Out[6]: (array([-0.5, -0.5, 4. ]), 0)