Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/scipy/sparse/linalg/dsolve/__init__.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Linear Solvers
3==============
5The default solver is SuperLU (included in the scipy distribution),
6which can solve real or complex linear systems in both single and
7double precisions. It is automatically replaced by UMFPACK, if
8available. Note that UMFPACK works in double precision only, so
9switch it off by::
11 >>> use_solver(useUmfpack=False)
13to solve in the single precision. See also use_solver documentation.
15Example session::
17 >>> from scipy.sparse import csc_matrix, spdiags
18 >>> from numpy import array
19 >>> from scipy.sparse.linalg import spsolve, use_solver
20 >>>
21 >>> print("Inverting a sparse linear system:")
22 >>> print("The sparse matrix (constructed from diagonals):")
23 >>> a = spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]], [0, 1], 5, 5)
24 >>> b = array([1, 2, 3, 4, 5])
25 >>> print("Solve: single precision complex:")
26 >>> use_solver( useUmfpack = False )
27 >>> a = a.astype('F')
28 >>> x = spsolve(a, b)
29 >>> print(x)
30 >>> print("Error: ", a*x-b)
31 >>>
32 >>> print("Solve: double precision complex:")
33 >>> use_solver( useUmfpack = True )
34 >>> a = a.astype('D')
35 >>> x = spsolve(a, b)
36 >>> print(x)
37 >>> print("Error: ", a*x-b)
38 >>>
39 >>> print("Solve: double precision:")
40 >>> a = a.astype('d')
41 >>> x = spsolve(a, b)
42 >>> print(x)
43 >>> print("Error: ", a*x-b)
44 >>>
45 >>> print("Solve: single precision:")
46 >>> use_solver( useUmfpack = False )
47 >>> a = a.astype('f')
48 >>> x = spsolve(a, b.astype('f'))
49 >>> print(x)
50 >>> print("Error: ", a*x-b)
52"""
54#import umfpack
55#__doc__ = '\n\n'.join( (__doc__, umfpack.__doc__) )
56#del umfpack
58from .linsolve import *
59from ._superlu import SuperLU
60from . import _add_newdocs
62__all__ = [s for s in dir() if not s.startswith('_')]
64from scipy._lib._testutils import PytestTester
65test = PytestTester(__name__)
66del PytestTester