gauss_jordan
gauss_jordan(a, b=None)Gauss-Jordan elimination.
Mirrors the C# GaussJordanElimination.Solve(ref Matrix A, ref Matrix B): one full-pivot Gauss-Jordan reduction that produces a’s inverse and, when b is supplied, the solution set of a @ x = b. Unlike the C# ref, ref in-place API, a and b are never mutated in Python – both results come back as new arrays.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| a | array_like | A square 2D array, N x N. | required |
| b | array_like | A 1D array of length N, or a 2D array with N rows (the right-hand sides). Omit for the inverse alone, in which case solution is an N x 0 array. |
None |
Returns
| Name | Type | Description |
|---|---|---|
| dict | {"inverse": ndarray (N, N), "solution": ndarray (N, b.shape[1])}. |
Examples
>>> from corehydropy import gauss_jordan
>>> a = [[1, 3, 3], [1, 4, 3], [1, 3, 4]]
>>> gauss_jordan(a)["inverse"]
array([[ 7., -3., -3.],
[-1., 1., 0.],
[-1., 0., 1.]])