scipy.linalg.
solve#Solves the linear equation set a @ x == b
for the unknown x
for square a matrix.
If the data matrix is known to be a particular type then supplying the corresponding string to assume_a
key chooses the dedicated solver. The available options are
diagonal
âdiagonalâ
tridiagonal
âtridiagonalâ
banded
âbandedâ
upper triangular
âupper triangularâ
lower triangular
âlower triangularâ
symmetric
âsymmetricâ (or âsymâ)
hermitian
âhermitianâ (or âherâ)
positive definite
âpositive definiteâ (or âposâ)
general
âgeneralâ (or âgenâ)
Square input data
Input data for the right hand side.
Ignored unless assume_a
is one of 'sym'
, 'her'
, or 'pos'
. If True, the calculation uses only the data in the lower triangle of a; entries above the diagonal are ignored. If False (default), the calculation uses only the data in the upper triangle of a; entries below the diagonal are ignored.
Allow overwriting data in a (may enhance performance).
Allow overwriting data in b (may enhance performance).
Whether to check that the input matrices contain only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs.
Valid entries are described above. If omitted or None
, checks are performed to identify structure so the appropriate solver can be called.
If True, solve a.T @ x == b
. Raises NotImplementedError for complex a.
The solution array.
If size mismatches detected or input a is not square.
If the matrix is singular.
If an ill-conditioned input a is detected.
If transposed is True and input a is a complex matrix.
Notes
If the input b matrix is a 1-D array with N elements, when supplied together with an NxN input a, it is assumed as a valid column vector despite the apparent size mismatch. This is compatible with the numpy.dot() behavior and the returned result is still 1-D array.
The general, symmetric, Hermitian and positive definite solutions are obtained via calling ?GESV, ?SYSV, ?HESV, and ?POSV routines of LAPACK respectively.
The datatype of the arrays define which solver is called regardless of the values. In other words, even when the complex array entries have precisely zero imaginary parts, the complex solver will be called based on the data type of the array.
Examples
Given a and b, solve for x:
>>> import numpy as np >>> a = np.array([[3, 2, 0], [1, -1, 0], [0, 5, 1]]) >>> b = np.array([2, 4, -1]) >>> from scipy import linalg >>> x = linalg.solve(a, b) >>> x array([ 2., -2., 9.]) >>> np.dot(a, x) == b array([ True, True, True], dtype=bool)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3