qr_solve
qr_solve(a, b)Solve a linear system by QR decomposition.
Mirrors the C# QRDecomposition.Solve overloads (vector and matrix right-hand sides). a need not be square: an overdetermined system is solved in the least-squares sense; an underdetermined system leaves the trailing a.shape[1] - min(a.shape) unknowns at zero (matching QRDecomposition.Solve’s own truncated back-substitution, which only ever fills indices below min(m, n)).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| a | array_like | A 2D array, M x N. | required |
| b | array_like | A 1D array of length M, or a 2D array with M rows. | required |
Returns
| Name | Type | Description |
|---|---|---|
| numpy.ndarray | A 1D array of length N when b is 1D, or an N x b.shape[1] array when b is 2D. |
Examples
>>> from corehydropy import qr_solve
>>> a = [[1, 2, 3], [0, 1, 4], [5, 6, 0]]
>>> qr_solve(a, [1, 2, 3])
array([27., -22., 6.])