Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/scipy/sparse/linalg/_dsolve/__init__.py: 100%
8 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-12 06:31 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-12 06:31 +0000
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
61from . import linsolve
63__all__ = [
64 'MatrixRankWarning', 'SuperLU', 'factorized',
65 'spilu', 'splu', 'spsolve',
66 'spsolve_triangular', 'use_solver'
67]
69from scipy._lib._testutils import PytestTester
70test = PytestTester(__name__)
71del PytestTester