{"id":51494969,"url":"https://github.com/coderonion/zigen","last_synced_at":"2026-07-07T14:02:04.553Z","repository":{"id":364209089,"uuid":"1157642576","full_name":"coderonion/zigen","owner":"coderonion","description":"Zigen: High-performance linear algebra library for Zig — pure Zig implementation with Eigen-compatible naming, zero dependencies, and zero-allocation APIs for performance-critical code.","archived":false,"fork":false,"pushed_at":"2026-02-14T04:39:28.000Z","size":165,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-12T05:30:23.061Z","etag":null,"topics":["armadillo","cpp","eigen","hpc","linear-algebra","math","matrix","numpy","tensor","vector","zig","zigen","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderonion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-14T04:33:34.000Z","updated_at":"2026-06-09T00:20:45.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/coderonion/zigen","commit_stats":null,"previous_names":["coderonion/zigen"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/coderonion/zigen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderonion%2Fzigen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderonion%2Fzigen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderonion%2Fzigen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderonion%2Fzigen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderonion","download_url":"https://codeload.github.com/coderonion/zigen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderonion%2Fzigen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35230519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-07T02:00:07.222Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["armadillo","cpp","eigen","hpc","linear-algebra","math","matrix","numpy","tensor","vector","zig","zigen","ziglang"],"created_at":"2026-07-07T14:02:03.399Z","updated_at":"2026-07-07T14:02:04.526Z","avatar_url":"https://github.com/coderonion.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zigen\n\nZigen: High-performance linear algebra library for Zig — pure Zig implementation with Eigen-compatible naming, zero dependencies, and zero-allocation APIs for performance-critical code.\n\n## Overview\n\n| Metric             | Value                     |\n| ------------------ | ------------------------- |\n| **Version**        | 0.1.0                     |\n| **Zig**            | 0.16.0-dev.2510+bcb5218a2 |\n| **Dependencies**   | None (pure Zig)           |\n| **Decompositions** | 20+                       |\n| **Tests**          | All passing ✅             |\n| **Examples**       | 9                         |\n| **Benchmarks**     | 28 (vs Eigen 5.0)         |\n\n## Features\n\n- ✅ **Zero Dependencies** — Pure Zig, no BLAS/LAPACK required\n- ✅ **Fixed + Dynamic Size** — Compile-time and runtime-sized matrices/vectors\n- ✅ **20+ Decompositions** — LU, QR, Cholesky, SVD, Eigensolvers, Schur, and more\n- ✅ **Sparse Matrices** — CSR/COO formats, SparseLU/Cholesky/QR solvers\n- ✅ **Iterative Solvers** — CG, BiCGSTAB, GMRES, MINRES with preconditioners\n- ✅ **Geometry** — Quaternions, transforms, rotations, SLERP, Euler angles\n- ✅ **Zero-Allocation APIs** — Workspace-reuse pattern for hot paths\n- ✅ **I/O** — NumPy `.npy` and MatrixMarket format support\n- ✅ **Eigen-Compatible Naming** — Easy migration from Eigen C++\n\n## Quick Start\n\n### Prerequisites\n\n- **Zig** 0.16.0-dev.2510+bcb5218a2\n\nNo other dependencies required — Zigen is pure Zig.\n\n### Build \u0026 Test\n\n```bash\ngit clone https://github.com/coderonion/zigen\ncd zigen\n\nzig build                           # Build library\nzig build test                      # Run all tests\nzig build unit-test                 # Unit tests only\nzig build integration-test          # Integration tests only\nzig build run-basic_matrix          # Run a specific example\n```\n\n### Basic Usage\n\n```zig\nconst Zigen = @import(\"zigen\");\n\n// Fixed-size matrix operations\nconst A = Zigen.Matrix3f.fromArray([3][3]f32{\n    .{ 2, -1, 0 },\n    .{ -1, 2, -1 },\n    .{ 0, -1, 2 },\n});\nconst b = Zigen.Vector3f.fromArray(.{ 1, 0, 1 });\n\n// Solve Ax = b via LU decomposition\nconst lu = try Zigen.LU(f32, 3).compute(A);\nconst x = lu.solve(b);\n\n// Quaternion rotation\nconst axis = Zigen.Vector3f.fromArray(.{ 0, 0, 1 });\nconst q = Zigen.Quaternionf.fromAxisAngle(axis, std.math.pi / 2.0);\nconst rotated = q.rotate(b);\n```\n\n## 📦 Use as Zig Package\n\nAdd Zigen as a dependency in your project — **pure Zig, no linking needed**.\n\n### Step 1: Add dependency to `build.zig.zon`\n\n**Local path (for development):**\n\n```zig\n.dependencies = .{\n    .zigen = .{\n        .path = \"../zigen\",\n    },\n},\n```\n\n**Git URL (for release):**\n\n```zig\n.dependencies = .{\n    .zigen = .{\n        .url = \"https://github.com/coderonion/zigen/archive/v0.1.0.tar.gz\",\n        .hash = \"HASH_VALUE\",\n    },\n},\n```\n\n\u003e [!TIP]\n\u003e **How to get the hash:** First, add the `.url` field **without** `.hash`, then run `zig build`. Zig will download the package, compute the hash, and display the correct `.hash = \"...\"` value in the error output. Copy that value into your `build.zig.zon`.\n\n### Step 2: Import in `build.zig`\n\n```zig\n// Get zigen dependency — pure Zig, no linking needed\nconst zigen = b.dependency(\"zigen\", .{}).module(\"zigen\");\n\n// Just one line to import\nexe.root_module.addImport(\"zigen\", zigen);\n```\n\n### Step 3: Use in your code\n\n```zig\nconst Zigen = @import(\"zigen\");\n\npub fn main() !void {\n    const m = Zigen.Matrix3f.identity();\n    const det = m.determinant();\n    // ...\n}\n```\n\n## Modules\n\n| Module                | Features                                                         | Status |\n| --------------------- | ---------------------------------------------------------------- | ------ |\n| **Core**              | Matrix/vector ops, transpose, inverse, determinant, trace, norms | ✅      |\n| **Decompositions**    | LU, QR, Cholesky, LDLT, SVD, JacobiSVD, BDCSVD                   | ✅      |\n| **Eigensolvers**      | SelfAdjointEigenSolver, EigenSolver, GeneralizedEigenSolver      | ✅      |\n| **Advanced Decomp**   | Tridiagonalization, Hessenberg, RealSchur, ComplexSchur, RealQZ  | ✅      |\n| **Sparse**            | CSR, COO, SparseLU, SparseCholesky, SparseQR, SimplicialLDLT/LLT | ✅      |\n| **Iterative Solvers** | CG, BiCGSTAB, GMRES, MINRES, LSCG                                | ✅      |\n| **Preconditioners**   | Diagonal, IncompleteLUT, IdentityPreconditioner                  | ✅      |\n| **Geometry**          | Quaternions, transforms, AngleAxis, Rotation2D, Euler angles     | ✅      |\n| **I/O**               | NumPy .npy, MatrixMarket                                         | ✅      |\n| **Matrix Functions**  | matExp, matPow, matSqrt, matLog, Kronecker product               | ✅      |\n| **Zero-Alloc APIs**   | Workspace reuse, `*Into()` variants, `computeFrom()`             | ✅      |\n\n### Zero-Allocation Pattern\n\nFor performance-critical loops, use workspace-reuse APIs to eliminate per-iteration allocations:\n\n```zig\n// Allocate once\nvar lu = try Zigen.LUDynamic(f64).init(allocator, n);\ndefer lu.deinit();\n\n// Reuse in hot loop — zero allocation per iteration\nfor (matrices) |A| {\n    lu.computeFrom(A);\n    lu.solveInto(b, x_buf, pb_buf, y_buf);\n}\n```\n\n### Eigen Compatibility\n\n| Operation      | Eigen C++               | Zigen                   |\n| -------------- | ----------------------- | ----------------------- |\n| Zero/Identity  | `.Zero()` `.Identity()` | `.zero()` `.identity()` |\n| Transpose      | `.transpose()`          | `.transpose()`          |\n| Multiply       | `A * B`                 | `A.mul(cols, B)`        |\n| Element access | `m(i,j)`                | `m.at(i,j)`             |\n| LU solve       | `lu.solve(b)`           | `lu.solve(b)`           |\n\n\u003e **Key difference**: Zig has no operator overloading, so `*` becomes `.mul()`.\n\u003e\n\u003e See [Eigen Migration Guide](docs/eigen-migration.md) for details.\n\n## Examples\n\n9 working examples in the [`examples/`](examples/) directory. See [examples/README.md](examples/README.md) for the full categorized index.\n\n```bash\nzig build run-basic_matrix             # Matrix basics\nzig build run-linear_algebra           # Decompositions, solve\nzig build run-geometry                 # Quaternions, rotations\nzig build run-sparse_systems           # Sparse matrices, SparseLU\nzig build run-iterative_solvers        # CG, BiCGSTAB\nzig build run-dynamic_decompositions   # Workspace-reuse pattern\n```\n\n### Example Categories\n\n| Category               | Examples                                            |\n| ---------------------- | --------------------------------------------------- |\n| **Getting Started**    | basic_matrix, matrix_operations                     |\n| **Linear Algebra**     | linear_algebra, dynamic_decompositions              |\n| **Sparse \u0026 Iterative** | sparse_systems, iterative_solvers                   |\n| **Geometry**           | geometry                                            |\n| **Applications**       | data_analysis (PCA), image_processing (convolution) |\n\n## Documentation\n\nComprehensive documentation is available in the [`docs/`](docs/) directory:\n\n- **[Documentation Index](docs/README.md)** — Full navigation guide\n- **[API Reference](docs/api.md)** — Complete API listing with Eigen comparison\n- **[Eigen Migration](docs/eigen-migration.md)** — Step-by-step migration from Eigen C++\n- **[Module Docs](docs/modules/)** — Per-module detailed reference (core, decompositions, sparse, solvers, geometry, io)\n\nSee also [STRUCTURE.md](STRUCTURE.md) for project layout details.\n\n## Testing\n\n```bash\nzig build test                      # All tests (src + unit + integration)\nzig build unit-test                 # Unit tests only\nzig build integration-test          # Integration tests only\n```\n\nTest coverage includes:\n- **Unit tests** — Each module's core functionality, error handling, edge cases\n- **Integration tests** — Cross-module workflows combining decompositions, sparse, geometry\n- **Inline tests** — Source-level tests embedded in library code\n\n## Benchmarks\n\nCompare Zigen vs Eigen 5.0 performance across 28 tests:\n\n```bash\ncd bench\n./run_benchmark.sh              # dim 64, f64\n./run_benchmark.sh --dim 128    # Custom dimension\n./run_benchmark.sh --all        # Full sweep (64,256,1024 × f32,f64)\n```\n\nSee [bench/README.md](bench/README.md) for details.\n\n## Architecture\n\n```\nzigen/\n├── src/                    # Pure Zig library\n│   ├── zigen.zig          # Root module — re-exports all types\n│   ├── core/              # Matrix, Vector, Array, Map, Kronecker (8 files)\n│   ├── decompositions/    # LU, QR, Cholesky, SVD, Eigen, Schur (13 files)\n│   ├── sparse/            # CSR, COO, SparseLU/Cholesky/QR (6 files)\n│   ├── solvers/           # CG, BiCGSTAB, GMRES, preconditioners (3 files)\n│   ├── geometry/          # Quaternion, Transform, AngleAxis\n│   └── io/                # NumPy .npy I/O\n├── test/                  # Tests\n│   ├── unit/              # 8 unit test files\n│   └── integration/       # Integration tests\n├── examples/              # 9 working examples\n├── bench/                 # Benchmark system (vs Eigen 5.0)\n├── docs/                  # Comprehensive API documentation\n├── build.zig              # Build configuration\n└── build.zig.zon          # Package manifest\n```\n\n## Contributing\n\n1. ⭐ Star and Fork this repository\n2. Create a feature branch (`git checkout -b feature/new-module`)\n3. Implement your changes in `src/`\n4. Add unit tests in `test/unit/` and integration tests in `test/integration/`\n5. Create an example in `examples/`\n6. Update documentation in `docs/`\n7. Submit a Pull Request\n\n## License\n\nMIT License\n\n## Acknowledgments\n\nBuilt with gratitude on the shoulders of giants:\n\n- **[Eigen](https://eigen.tuxfamily.org/)** — The C++ linear algebra library that inspired Zigen's API design and naming conventions.\n- **[Zig](https://ziglang.org/)** — A modern systems programming language focused on safety, performance, and simplicity, created by Andrew Kelley and the Zig Software Foundation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderonion%2Fzigen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderonion%2Fzigen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderonion%2Fzigen/lists"}