bundles / scipy 1.17.1 / scipy / linalg / _basic / solve_triangular
function
scipy.linalg._basic:solve_triangular
source: /scipy/linalg/_basic.py :650
Signature
def solve_triangular ( a , b , trans = 0 , lower = False , unit_diagonal = False , overwrite_b = False , check_finite = True ) Summary
Solve the equation a @ x = b for x, where a is a triangular matrix.
Extended Summary
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: (M, M) array_likeA triangular matrix
b: (M,) or (M, N) array_likeRight-hand side matrix in
a x = blower: bool, optionalUse only data contained in the lower triangle of
a. Default is to use upper triangle.trans: {0, 1, 2, 'N', 'T', 'C'}, optionalType of system to solve:
======== ========= trans system ======== ========= 0 or 'N' a x = b 1 or 'T' a^T x = b 2 or 'C' a^H x = b ======== =========
unit_diagonal: bool, optionalIf True, diagonal elements of
aare assumed to be 1 and will not be referenced.overwrite_b: bool, optionalAllow overwriting data in
b(may enhance performance)check_finite: bool, optionalWhether 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.
Returns
x: (M,) or (M, N) ndarraySolution to the system
a x = b. Shape of return matchesb.
Raises
: LinAlgErrorIf
ais singular
Notes
Examples
Solve the lower triangular system a x = b, where:: [3 0 0 0] [4] a = [2 1 0 0] b = [2] [1 0 1 0] [4] [1 1 1 1] [2]import numpy as np from scipy.linalg import solve_triangular a = np.array([[3, 0, 0, 0], [2, 1, 0, 0], [1, 0, 1, 0], [1, 1, 1, 1]]) b = np.array([4, 2, 4, 2]) x = solve_triangular(a, b, lower=True)✓
x a.dot(x) # Check the result✗
Aliases
-
scipy.linalg.solve_triangular