Skip to content

Latest commit

 

History

History
203 lines (163 loc) · 11.7 KB

File metadata and controls

203 lines (163 loc) · 11.7 KB

Zigen API Reference

Complete API listing for all public types and functions. For detailed per-module documentation, see the module reference.

Tip: Migrating from Eigen? See the Eigen Migration Guide.


Public Exports Summary

All types are accessed via const Zigen = @import("zigen");.

Core Types

Type Generic Form Aliases
Fixed Matrix Matrix(T, rows, cols) Matrix2f/3f/4f, Matrix2d/3d/4d
Fixed Vector Vector(T, n) Vector2f/3f/4f, Vector2d/3d/4d
Dynamic Matrix MatrixDynamic(T) MatrixXf, MatrixXd
Dynamic Vector VectorDynamic(T) VectorXf, VectorXd
RowVector RowVector(T, n) RowVector2f/3f/4f, RowVector2d/3d/4d
Array (element-wise) Array(T, n)
Dynamic Array ArrayDynamic(T)
Complex Complex(T) Complexf, Complexd

Decompositions — Fixed Size

Type Description
LU(T, n) LU with partial pivoting
QR(T, rows, cols) Householder QR
Cholesky(T, n) Cholesky LLᵀ (SPD matrices)
LDLT(T, n) LDLᵀ (symmetric matrices)
SVD(T, rows, cols) Singular Value Decomposition
SelfAdjointEigenSolver(T, n) Symmetric eigenvalue solver
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) Complete orthogonal decomposition
EigenSolver(T, n) Non-symmetric eigenvalue solver
GeneralizedEigenSolver(T, n) Generalized eigenvalue solver
Tridiagonalization(T, n) Tridiagonal reduction
HessenbergDecomp(T, n) Hessenberg form
RealSchur(T, n) Real Schur decomposition
RealQZ(T, n) Generalized Schur (QZ)
ComplexSchur(T, n) Complex Schur decomposition

Decompositions — Dynamic Size

Type Description
LUDynamic(T) Dynamic LU with init() + computeFrom() + solveInto()
QRDynamic(T) Dynamic QR with workspace reuse
CholeskyDynamic(T) Dynamic Cholesky with workspace reuse
SVDDynamic(T) Dynamic SVD with workspace reuse
SelfAdjointEigenSolverDynamic(T) Dynamic eigenvalue solver with workspace reuse

Sparse

Type Description
SparseMatrix(T) CSR sparse matrix with mulVec(), mulVecInto()
SparseMatrixCOO(T) COO (coordinate) format
SparseLU(T) Sparse LU solver with init() + computeFrom() + solveInto()
SparseCholesky(T) Sparse Cholesky with workspace reuse
SparseQR(T) Sparse QR decomposition
SimplicialLDLT(T) Simplicial LDLᵀ for sparse SPD systems
SimplicialLLT(T) Simplicial LLᵀ for sparse SPD systems
Triplet(T) COO triplet entry

Iterative Solvers

Type Description
ConjugateGradient(T) CG for SPD systems
BiCGSTAB(T) BiCGSTAB for non-symmetric systems
GMRES(T) Generalized Minimal Residual
MINRES(T) Minimal Residual for symmetric systems
LeastSquaresConjugateGradient(T) LSCG for least-squares problems

Preconditioners

Type Description
DiagonalPreconditioner(T) Jacobi (diagonal) preconditioner
IdentityPreconditioner(T) No-op preconditioner
LeastSquareDiagonalPreconditioner(T) Diagonal preconditioner for least-squares
IncompleteLUT(T) Incomplete LU with thresholding

Geometry

Type Description
Quaternion(T) Unit quaternion (Quaternionf, Quaterniond)
Transform(T) Rigid body transform (rotation + translation)
AngleAxis(T) Axis-angle representation
Rotation2D(T) 2D rotation
Isometry(T) Isometric transform
Affine(T) Affine transform
Projective(T) Projective transform
Hyperplane(T, n) Hyperplane in N dimensions
AlignedBox(T, n) Axis-aligned bounding box
ParametrizedLine(T, n) Parametric line
Scaling(T, n) Non-uniform scaling
UniformScaling(T) Uniform scaling
Translation(T, n) Translation transform
EulerAxis Euler angle axis enum

Geometry Functions

Function Description
eulerToRotationMatrix(T, axes, angles) Convert Euler angles to rotation matrix
umeyama(T, n, src, dst) Umeyama alignment (SVD-based point set registration)

Matrix Functions

Function Description
matExp(T, n, A) Matrix exponential
matPow(T, n, A, p) Matrix power (integer)
matSqrt(T, n, A) Matrix square root
matLog(T, n, A) Matrix logarithm
kronecker(T, m, n, p, q, A, B) Kronecker product (fixed)
kroneckerDynamic(T, A, B) Kronecker product (dynamic)

I/O

Function Description
loadNpy(T, allocator, path) Load matrix from .npy file
loadNpyVector(T, allocator, path) Load vector from .npy file
saveNpy(T, matrix, path) Save matrix to .npy file
saveNpyVector(T, vector, path) Save vector to .npy file
loadMatrixMarket(T, allocator, data) Load sparse matrix from MatrixMarket string
saveMatrixMarket(T, allocator, matrix) Save sparse matrix to MatrixMarket string

Triangular Utilities

Function Description
solveLowerTriangular(T, n, L, b) Solve Lx = b (fixed)
solveUpperTriangular(T, n, U, b) Solve Ux = b (fixed)
solveLowerTriangularDynamic(T, L, b) Solve Lx = b (dynamic)
solveUpperTriangularDynamic(T, U, b) Solve Ux = b (dynamic)
lowerTriangular(T, n, M) Extract lower triangular
upperTriangular(T, n, M) Extract upper triangular
conditionNumber(T, n, M) Estimate condition number
DiagonalMatrix(T, n) Diagonal matrix type
MapMatrix(T, rows, cols) Memory-mapped matrix view
MapVector(T, n) Memory-mapped vector view
PermutationMatrix(T, n) Permutation matrix

Eigen Compatibility Quick Reference

Operation Eigen C++ Zigen
Zero/Identity MatrixXd::Zero(n,n) MatrixXd.zero(alloc, n, n)
Element access m(i,j) m.at(i,j)
Set element m(i,j) = v m.set(i,j, v)
Multiply A * B A.mul(cols, B) or A.mulInto(B, &result)
Transpose A.transpose() A.transpose() or A.transposeInto(&result)
LU decompose lu.compute(A) lu = LU.compute(A) or lu.computeFrom(A)
Solve lu.solve(b) lu.solve(b) or lu.solveInto(b, x, work...)
Inverse A.inverse() A.inverse() or A.inverseDynamicInto(&result, work)
SpMV sp * v sp.mulVec(x) or sp.mulVecInto(x, y)

See Eigen Migration Guide for comprehensive migration details.


Zero-Allocation APIs

For performance-critical code, use the *Into() and workspace-reuse variants:

// Workspace reuse pattern (allocate once, compute many times)
var lu = try LUDynamic(f64).init(allocator, n);
defer lu.deinit();

for (matrices) |A| {
    lu.computeFrom(A);       // No allocation
    lu.solveInto(b, x, pb, y); // No allocation
}

// In-place operations
A.addInto(B, &result);   // result = A + B, no allocation
A.mulInto(B, &result);   // result = A * B, no allocation
A.inverseDynamicInto(&result, work); // No allocation
sp.mulVecInto(x, y);     // y = sp * x, no allocation

Available workspace-reuse types: LUDynamic, QRDynamic, CholeskyDynamic, SVDDynamic, SelfAdjointEigenSolverDynamic, SparseLU, SparseCholesky.


Related Documentation: