__init__.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. """
  2. Linear Solvers
  3. ==============
  4. The default solver is SuperLU (included in the scipy distribution),
  5. which can solve real or complex linear systems in both single and
  6. double precisions. It is automatically replaced by UMFPACK, if
  7. available. Note that UMFPACK works in double precision only, so
  8. switch it off by::
  9. >>> use_solver(useUmfpack=False)
  10. to solve in the single precision. See also use_solver documentation.
  11. Example session::
  12. >>> from scipy.sparse import csc_matrix, spdiags
  13. >>> from numpy import array
  14. >>> from scipy.sparse.linalg import spsolve, use_solver
  15. >>>
  16. >>> print("Inverting a sparse linear system:")
  17. >>> print("The sparse matrix (constructed from diagonals):")
  18. >>> a = spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]], [0, 1], 5, 5)
  19. >>> b = array([1, 2, 3, 4, 5])
  20. >>> print("Solve: single precision complex:")
  21. >>> use_solver( useUmfpack = False )
  22. >>> a = a.astype('F')
  23. >>> x = spsolve(a, b)
  24. >>> print(x)
  25. >>> print("Error: ", a*x-b)
  26. >>>
  27. >>> print("Solve: double precision complex:")
  28. >>> use_solver( useUmfpack = True )
  29. >>> a = a.astype('D')
  30. >>> x = spsolve(a, b)
  31. >>> print(x)
  32. >>> print("Error: ", a*x-b)
  33. >>>
  34. >>> print("Solve: double precision:")
  35. >>> a = a.astype('d')
  36. >>> x = spsolve(a, b)
  37. >>> print(x)
  38. >>> print("Error: ", a*x-b)
  39. >>>
  40. >>> print("Solve: single precision:")
  41. >>> use_solver( useUmfpack = False )
  42. >>> a = a.astype('f')
  43. >>> x = spsolve(a, b.astype('f'))
  44. >>> print(x)
  45. >>> print("Error: ", a*x-b)
  46. """
  47. from __future__ import division, print_function, absolute_import
  48. #import umfpack
  49. #__doc__ = '\n\n'.join( (__doc__, umfpack.__doc__) )
  50. #del umfpack
  51. from .linsolve import *
  52. from ._superlu import SuperLU
  53. from . import _add_newdocs
  54. __all__ = [s for s in dir() if not s.startswith('_')]
  55. from scipy._lib._testutils import PytestTester
  56. test = PytestTester(__name__)
  57. del PytestTester