[SciPy-User] Gmres preconditionner

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[SciPy-User] Gmres preconditionner

Puiseux

Hello,

i try to solve a linear sparse system using scipy.sparse.linalg.gmres.
>>> w, v = gmres(A, b)

It works fine.
Now i’m trying to improve the iterations, using scipy.sparse.linalg.spilu preconditionner :

>>> invA = spilu(A)
>>> w,v = gmres(A, b, M=invA)

  File "<string>", line 2, in gmres
  File "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/iterative.py", line 85, in non_reentrant
    return func(*a, **kw)
  File "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/iterative.py", line 422, in gmres
    A,M,x,b,postprocess = make_system(A,M,x0,b,xtype)
  File "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/utils.py", line 131, in make_system
    M = aslinearoperator(M)
  File "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py", line 682, in aslinearoperator
    raise TypeError('type not understood')
TypeError: type not understood

Do i mistake somewhere ?

Thanks for your answer.

Pierre Puiseux



_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: Gmres preconditionner

Eric S. Carlson
A little tougher to track down than I thought, but you are missing a
couple of steps:


P = scipy.sparse.linalg.spilu(matrix, fill_factor=int(math.sqrt(m)))
M_x = lambda x: P.solve(x)
M = scipy.sparse.linalg.LinearOperator((n * m, n * m), M_x)
#(n*m,n*m)==matrix shape
result = scipy.sparse.linalg.lgmres(matrix, b, tol=1e-5, M=M)


On 11/20/2015 2:37 AM, Puiseux Pierre wrote:

>
> Hello,
>
>
> i try to solve a linear sparse system using scipy.sparse.linalg.gmres.
>
>  >>> w, v = gmres(A, b)
>
>
> It works fine.
>
> Now i’m trying to improve the iterations, using
> scipy.sparse.linalg.spilu preconditionner :
>
>
>  >>> invA = spilu(A)
>
>  >>> w,v = gmres(A, b, M=invA)
>
>
>    File "<string>", line 2, in gmres
> File
> "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/iterative.py",
> line 85, in non_reentrant
>      return func(*a, **kw)
> File
> "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/iterative.py",
> line 422, in gmres
>      A,M,x,b,postprocess = make_system(A,M,x0,b,xtype)
> File
> "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/utils.py",
> line 131, in make_system
>      M = aslinearoperator(M)
> File
> "/usr/local/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py",
> line 682, in aslinearoperator
>      raise TypeError('type not understood')
> TypeError: type not understood
>
> Do i mistake somewhere ?
>
> Thanks for your answer.
>
> Pierre Puiseux
>
>
>
>
> _______________________________________________
> SciPy-User mailing list
> [hidden email]
> https://mail.scipy.org/mailman/listinfo/scipy-user
>


_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.scipy.org/mailman/listinfo/scipy-user