bundles / scipy 1.17.1 / scipy / linalg / _basic / solve0
function
scipy.linalg._basic:solve0
source: /scipy/linalg/_basic.py :307
Signature
def solve0 ( a , b , lower = False , overwrite_a = False , overwrite_b = False , check_finite = True , assume_a = None , transposed = False ) Summary
Solve the equation a @ x = b for x, where a is a square matrix.
Extended Summary
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') symmetric positive definite 'positive definite' (or 'pos') general 'general' (or 'gen') ============================= ================================
The documentation is written assuming array arguments are of specified "core" shapes. However, array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details. Note that calls with zero-size batches are unsupported and will raise a ValueError.
Parameters
a: (N, N) array_likeSquare input data
b: (N, NRHS) array_likeInput data for the right hand side.
lower: bool, default: FalseIgnored unless
assume_ais one of'sym','her', or'pos'. If True, the calculation uses only the data in the lower triangle ofa; entries above the diagonal are ignored. If False (default), the calculation uses only the data in the upper triangle ofa; entries below the diagonal are ignored.overwrite_a: bool, default: FalseAllow overwriting data in
a(may enhance performance).overwrite_b: bool, default: FalseAllow overwriting data in
b(may enhance performance).check_finite: bool, default: TrueWhether 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.
assume_a: str, optionalValid entries are described above. If omitted or
None, checks are performed to identify structure so the appropriate solver can be called.transposed: bool, default: FalseIf True, solve
a.T @ x == b. RaisesNotImplementedErrorfor complexa.
Returns
x: (N, NRHS) ndarrayThe solution array.
Raises
: ValueErrorIf size mismatches detected or input a is not square.
: LinAlgErrorIf the computation fails because of matrix singularity.
: LinAlgWarningIf an ill-conditioned input a is detected.
: NotImplementedErrorIf 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✓
np.dot(a, x) == b
✗Aliases
-
scipy.linalg._basic.solve0