lu
result = lu(A)
Input: A · Output: result
What it is
LU decomposition with partial pivoting of a square n×n Mat A, P·A = L·U.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = lu(A) | A Matnot documented yet | Model —kind "lu"l Matn×n lower-triangular Mat, unit diagonalu Matn×n upper-triangular Matp Matn×n permutation Mat | Returns a Model (kind "lu") with fields l (n×n lower-triangular Mat, unit diagonal), u (n×n upper-triangular Mat), and p (n×n permutation Mat). |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
s = svd([1, 2; 3, 4; 5, 6])
S = [s.s[0], 0; 0, s.s[1]]
print("U*S*Vt reconstructs A: {s.u * S * s.vt}")
r = qr([1, 2; 3, 4; 5, 6])
print("Q*R == A: {r.q * r.r}")
f = lu([2, 1, 1; 4, 3, 3; 8, 7, 9])
print("P*A == L*U: {f.p * [2,1,1;4,3,3;8,7,9]} vs {f.l * f.u}")
output
U*S*Vt reconstructs A: [1, 2; 3, 4; 5, 6] Q*R == A: [1, 2; 3, 4; 5, 6] P*A == L*U: [8, 7, 9; 2, 1, 1; 4, 3, 3] vs [8, 7, 9; 2, 1, 1; 4, 3, 3]
from numerics-dsp
How it works
lu(A) — LU decomposition with partial pivoting, P * A = L * U. Model kind "lu", fields l/u/p.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.