Linear algebra decompositions for both fixed-size and dynamic-size matrices.
LU(T, n) — LU factorization with partial pivoting.
const lu = try Zigen.LU(f64, 3).compute(A);
lu.L // Lower triangular
lu.U // Upper triangular
lu.P // Permutation matrix
lu.determinant() // det(A)
lu.solve(b) // Solve Ax = bQR(T, rows, cols) — Householder QR.
const qr = Zigen.QR(f64, 3, 3).compute(A);
qr.Q // Orthogonal matrix
qr.R // Upper triangular
qr.solve(b) // Solve via QRCholesky(T, n) — LLᵀ for symmetric positive definite matrices.
const chol = try Zigen.Cholesky(f64, 3).compute(A);
chol.L // Lower Cholesky factor
chol.solve(b) // Solve Ax = bSVD(T, rows, cols) — Singular Value Decomposition.
const svd = Zigen.SVD(f64, 3, 3).compute(A);
svd.U // Left singular vectors
svd.S // Singular values (vector)
svd.V // Right singular vectors| Type | Description |
|---|---|
LDLT(T, n) |
LDLᵀ for symmetric matrices |
FullPivLU(T, rows, cols) |
Full-pivoting LU |
JacobiSVD(T, rows, cols) |
Jacobi SVD |
BDCSVD(T, rows, cols) |
Bidiagonal Divide & Conquer SVD |
ColPivHouseholderQR(T, rows, cols) |
Column-pivoting QR |
CompleteOrthogonalDecomp(T, rows, cols) |
Rank-revealing decomposition |
SelfAdjointEigenSolver(T, n) |
Symmetric eigenvalue solver |
EigenSolver(T, n) |
Non-symmetric eigenvalue solver |
GeneralizedEigenSolver(T, n) |
Generalized eigenvalue solver |
Tridiagonalization(T, n) |
Tridiagonal reduction |
HessenbergDecomp(T, n) |
Upper Hessenberg form |
RealSchur(T, n) |
Real Schur decomposition |
RealQZ(T, n) |
Generalized Schur (QZ) |
ComplexSchur(T, n) |
Complex Schur decomposition |
All dynamic decompositions support two usage patterns:
var lu = try Zigen.LUDynamic(f64).compute(allocator, A);
defer lu.deinit();
var x = try lu.solve(b);
defer x.deinit();// Allocate once
var lu = try Zigen.LUDynamic(f64).init(allocator, n);
defer lu.deinit();
// Reuse many times — zero allocation in the loop
for (matrices) |A| {
lu.computeFrom(A); // Reuse workspace
lu.solveInto(b, x_buf, pb_buf, y_buf); // Write into buffers
}| Method | Description |
|---|---|
compute(allocator, A) |
One-shot decompose (allocating) |
init(allocator, n) |
Allocate workspace |
computeFrom(A) |
Decompose into existing workspace |
solve(b) |
Solve, returning new vector |
solveInto(b, x_buf, pb_buf, y_buf) |
Solve into pre-allocated buffers |
inverse() |
Compute inverse (allocating) |
inverseInto(result, e_buf, x_buf, pb_buf, y_buf) |
Inverse into buffers |
determinant() |
Compute determinant |
| Method | Description |
|---|---|
compute(allocator, A) |
One-shot (allocating) |
init(allocator, n) |
Allocate workspace |
computeFrom(A) |
Decompose into workspace |
solve(b) |
Solve (allocating) |
solveInto(b, x_buf, y_buf) |
Solve into buffers |
| Method | Description |
|---|---|
compute(allocator, A) |
One-shot (allocating) |
init(allocator, m, n) |
Allocate workspace |
computeFrom(A) |
Decompose into workspace |
solve(b) |
Solve (allocating) |
solveInto(b, x_buf, qtb_buf) |
Solve into buffers |
| Method | Description |
|---|---|
compute(allocator, A) |
One-shot (allocating) |
init(allocator, m, n) |
Allocate workspace |
computeFrom(A) |
Decompose into workspace |
| Method | Description |
|---|---|
compute(allocator, A) |
One-shot (allocating) |
init(allocator, n) |
Allocate workspace |
computeFrom(A) |
Decompose into workspace |