{"id":46650692,"url":"https://github.com/yusa-imit/zuda","last_synced_at":"2026-04-13T13:00:48.764Z","repository":{"id":342837146,"uuid":"1175174253","full_name":"yusa-imit/zuda","owner":"yusa-imit","description":"Zig Universal DataSstructures and Algorithms","archived":false,"fork":false,"pushed_at":"2026-04-10T19:04:50.000Z","size":11005,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-10T21:07:57.030Z","etag":null,"topics":["data-structures","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yusa-imit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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-03-07T10:36:27.000Z","updated_at":"2026-04-10T19:04:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yusa-imit/zuda","commit_stats":null,"previous_names":["yusa-imit/zuda"],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/yusa-imit/zuda","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusa-imit%2Fzuda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusa-imit%2Fzuda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusa-imit%2Fzuda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusa-imit%2Fzuda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusa-imit","download_url":"https://codeload.github.com/yusa-imit/zuda/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusa-imit%2Fzuda/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31753550,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["data-structures","zig"],"created_at":"2026-03-08T06:06:39.543Z","updated_at":"2026-04-13T13:00:48.725Z","avatar_url":"https://github.com/yusa-imit.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zuda\n\n\u003e **Z**ig **U**niversal **D**atastructures and **A**lgorithms\n\nA comprehensive, production-ready library of data structures, algorithms, and scientific computing for Zig 0.15+. The Zig-native alternative to NumPy/SciPy.\n\n[![CI](https://github.com/yusa-imit/zuda/actions/workflows/ci.yml/badge.svg)](https://github.com/yusa-imit/zuda/actions)\n[![Zig](https://img.shields.io/badge/zig-0.15.x-orange)](https://ziglang.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\n---\n\n## Features\n\n### v2.0 — Scientific Computing Platform (Stable) 🚀\n- **NDArray**: N-dimensional arrays with broadcasting, slicing, SIMD acceleration (4-8× speedup)\n- **Linear Algebra**: BLAS Level 1-3 with SIMD, decompositions (LU/QR/SVD/Cholesky/Eigen), solvers (solve/lstsq/inv/pinv)\n- **Statistics**: Descriptive stats, 8 probability distributions (PDF/CDF/sampling), hypothesis testing, regression\n- **Signal Processing**: FFT/IFFT with real FFT optimization, windowing, convolution, filtering, spectral analysis\n- **Numerical Methods**: Integration (trapezoidal/Simpson/Romberg), root finding (bisection/Newton/Brent), interpolation, ODE solvers\n- **Optimization**: Unconstrained (gradient descent/BFGS/L-BFGS/Nelder-Mead), constrained (penalty/Lagrangian/QP), LP (simplex/interior-point), auto-diff\n- **4600+ Tests**: 100% passing with comprehensive coverage including cross-module integration\n- **Comprehensive Documentation**: 7 tutorial guides (3385 lines, 100+ examples), NumPy compatibility guide\n\n### v1.x — Data Structures \u0026 Algorithms (Stable)\n- **100+ Data Structures**: Lists, trees, graphs, heaps, spatial indexes, probabilistic structures\n- **80+ Algorithms**: Sorting, graph algorithms, string matching, dynamic programming, geometry, math\n- **746 Tests**: Comprehensive test coverage including property-based and fuzz testing\n\n### Core Design\n- **Allocator-First**: Every container accepts `std.mem.Allocator` for full control\n- **Comptime-Optimized**: Parameterize behavior at compile time for zero-overhead abstractions\n- **C FFI**: Export to C, Python, Node.js, and other languages\n- **Complete Documentation**: API reference, algorithm explainers, decision guides\n\n---\n\n## Quick Start\n\n### Installation\n\nAdd to your `build.zig.zon`:\n\n```zig\n.{\n    .name = \"my-project\",\n    .version = \"0.1.0\",\n    .dependencies = .{\n        .zuda = .{\n            .url = \"https://github.com/yusa-imit/zuda/archive/refs/tags/v2.0.0.tar.gz\",\n            .hash = \"1220...\", // Get via `zig fetch \u003curl\u003e`\n        },\n    },\n}\n```\n\nUpdate `build.zig`:\n\n```zig\nconst zuda = b.dependency(\"zuda\", .{ .target = target, .optimize = optimize });\nexe.root_module.addImport(\"zuda\", zuda.module(\"zuda\"));\n```\n\n### Example\n\n```zig\nconst std = @import(\"std\");\nconst zuda = @import(\"zuda\");\n\npub fn main() !void {\n    const allocator = std.heap.page_allocator;\n\n    // Use a Red-Black Tree for ordered map\n    const RBTree = zuda.containers.trees.RedBlackTree;\n    fn cmp(_: void, a: i32, b: i32) std.math.Order {\n        return std.math.order(a, b);\n    }\n\n    var map = RBTree(i32, []const u8, void, cmp).init(allocator);\n    defer map.deinit();\n\n    try map.insert(42, \"answer\");\n    try map.insert(7, \"lucky\");\n\n    // Iterate in sorted order\n    var it = map.iterator();\n    while (it.next()) |entry| {\n        std.debug.print(\"{}: {s}\\n\", .{ entry.key, entry.value });\n    }\n}\n```\n\n**Output**:\n```\n7: lucky\n42: answer\n```\n\n---\n\n## v2.0 — Scientific Computing\n\nzuda v2.0 transforms the library into a comprehensive scientific computing platform — the Zig-native alternative to NumPy/SciPy:\n\n```zig\nconst std = @import(\"std\");\nconst zuda = @import(\"zuda\");\nconst NDArray = zuda.ndarray.NDArray;\nconst linalg = zuda.linalg;\nconst stats = zuda.stats;\n\npub fn main() !void {\n    const alloc = std.heap.page_allocator;\n\n    // Create matrices\n    var A = try NDArray(f64, 2).fromSlice(alloc, \u0026.{ 3, 3 }, \u0026.{\n        1, 2, 3,\n        4, 5, 6,\n        7, 8, 10,\n    });\n    defer A.deinit();\n\n    var b = try NDArray(f64, 1).fromSlice(alloc, \u0026.{3}, \u0026.{ 1, 2, 3 });\n    defer b.deinit();\n\n    // Solve Ax = b\n    var x = try linalg.solve(alloc, A, b);\n    defer x.deinit();\n\n    // SVD decomposition\n    var result = try linalg.svd(alloc, A);\n    defer result.deinit();\n\n    // Statistics\n    const data = try NDArray(f64, 1).arange(alloc, 0, 1000, 1);\n    defer data.deinit();\n    const mu = stats.mean(data);\n    const sigma = stats.std(data);\n}\n```\n\n### NumPy vs zuda Comparison\n\n| NumPy (Python) | zuda (Zig) |\n|----------------|------------|\n| `np.array([[1,2],[3,4]])` | `NDArray(f64, 2).fromSlice(alloc, \u0026.{2,2}, \u0026.{1,2,3,4})` |\n| `np.zeros((3, 3))` | `NDArray(f64, 2).zeros(alloc, \u0026.{3, 3})` |\n| `A @ B` | `linalg.matmul(alloc, A, B)` |\n| `np.linalg.solve(A, b)` | `linalg.solve(alloc, A, b)` |\n| `np.fft.fft(x)` | `signal.fft(alloc, x)` |\n| `np.mean(x)` | `stats.mean(x)` |\n| `scipy.optimize.minimize(f, x0)` | `optimize.minimize(alloc, f, x0, .{})` |\n\n**Why zuda over NumPy?**\n- No GIL — true parallelism without workarounds\n- No garbage collector — predictable latency\n- Comptime generics — zero-overhead abstractions\n- Single binary — no Python runtime dependency\n- Explicit memory — allocator-first design, no hidden allocations\n- C ABI — easy integration with any language\n\n---\n\n## What's Inside\n\n### 📦 Containers\n\n| Category | Structures |\n|----------|------------|\n| **Lists \u0026 Queues** | `SkipList`, `XorLinkedList`, `UnrolledLinkedList`, `Deque`, `LockFreeQueue`, `LockFreeStack`, `WorkStealingDeque` |\n| **Hash Tables** | `CuckooHashMap`, `RobinHoodHashMap`, `SwissTable`, `ConsistentHashRing`, `PersistentHashMap` (HAMT) |\n| **Heaps** | `FibonacciHeap`, `BinomialHeap`, `PairingHeap`, `DaryHeap`, `VanEmdeBoasTree` |\n| **Trees** | `RedBlackTree`, `AVLTree`, `SplayTree`, `AATree`, `ScapegoatTree`, `BTree`, `Trie`, `RadixTree`, `SegmentTree`, `LazySegmentTree`, `FenwickTree`, `SparseTable`, `IntervalTree` |\n| **Graphs** | `AdjacencyList`, `AdjacencyMatrix`, `CompressedSparseRow`, `EdgeList` |\n| **Spatial** | `KDTree`, `RTree`, `QuadTree`, `OctTree` |\n| **Strings** | `SuffixArray`, `SuffixTree`, `Rope`, `BKTree` |\n| **Caches** | `LRUCache`, `LFUCache`, `ARCCache` |\n| **Probabilistic** | `BloomFilter`, `CuckooFilter`, `CountMinSketch`, `HyperLogLog`, `MinHash` |\n| **Persistent** | `PersistentArray`, `PersistentHashMap`, `PersistentRBTree` |\n| **Specialized** | `DisjointSet`, `DancingLinks`, `ConcurrentSkipList` |\n\n### 🧮 Algorithms\n\n| Category | Algorithms |\n|----------|------------|\n| **Sorting** | TimSort, IntroSort, RadixSort, CountingSort, MergeSort (3 variants), BlockSort |\n| **Graph** | BFS, DFS, Dijkstra, Bellman-Ford, A*, Floyd-Warshall, Johnson, Kruskal, Prim, Borůvka, Tarjan SCC, Kosaraju SCC, Bridges, Articulation Points, Topological Sort, Edmonds-Karp, Dinic, Push-Relabel, Hopcroft-Karp, Hungarian |\n| **String** | KMP, Boyer-Moore, Rabin-Karp, Aho-Corasick, Z-algorithm |\n| **DP** | LIS, LCS, Edit Distance, Knapsack, Binary Search variants |\n| **Geometry** | Convex Hull (Graham, Jarvis), Closest Pair, Haversine, Geohash |\n| **Math** | GCD/LCM, ModExp, Miller-Rabin, Sieve of Eratosthenes, CRT, NTT |\n\n---\n\n## Documentation\n\n| Document | Description |\n|----------|-------------|\n| **[Getting Started](docs/GETTING_STARTED.md)** | Installation, examples, common patterns |\n| **[API Reference](docs/API.md)** | Complete API documentation for v1.x structures and algorithms |\n| **[Scientific Computing Guides](docs/guides/README.md)** | Comprehensive tutorials for v2.0 modules (NDArray, linalg, stats, signal, numeric, optimize) |\n| **[NumPy Compatibility](docs/NUMPY_COMPATIBILITY.md)** | NumPy → zuda migration guide (70+ function mappings) |\n| **[Algorithm Explainers](docs/ALGORITHMS.md)** | Conceptual guides for how algorithms work |\n| **[Changelog](CHANGELOG.md)** | Detailed release history and migration notes |\n| **[Decision Guide](docs/GUIDE.md)** | Choose the right data structure for your use case |\n| **[PRD](docs/PRD.md)** | Product requirements and development roadmap |\n\n---\n\n## Real-World Usage\n\nzuda is designed to replace hand-rolled data structures in real projects:\n\n| Project | Current Implementation | zuda Replacement | Status |\n|---------|------------------------|------------------|--------|\n| **[zr](https://github.com/yusa-imit/zr)** (task runner) | Custom DAG + topological sort (323 LOC) | `AdjacencyList` + `TopologicalSort` | Phase 3 ✅ |\n| **[silica](https://github.com/yusa-imit/silica)** (RDBMS) | Custom B+Tree (4300 LOC), LRU cache (1237 LOC) | `BTree`, `LRUCache` | Phase 2/4 ✅ |\n| **[zoltraak](https://github.com/yusa-imit/zoltraak)** (Redis-compatible server) | Custom sorted set, HyperLogLog | `SkipList`, `HyperLogLog`, `Geohash` | Phase 1/4 ✅ |\n\nSee [CLAUDE.md](CLAUDE.md#consumer-use-case-registry) for complete consumer registry.\n\n---\n\n## Performance\n\nSelected benchmarks (see [API.md](docs/API.md#performance-targets-v050) for full targets):\n\n| Operation | Target | Status |\n|-----------|--------|--------|\n| RedBlackTree insert (1M keys) | ≤ 200 ns/op | ✅ |\n| RedBlackTree lookup (1M keys) | ≤ 150 ns/op | ✅ |\n| FibonacciHeap decrease-key | ≤ 50 ns amortized | ✅ |\n| BloomFilter lookup | ≥ 100M ops/sec | ✅ |\n\n---\n\n## Testing\n\n```bash\n# Run all 701 tests\nzig build test\n\n# Cross-compile for 6 targets\nzig build -Dtarget=x86_64-linux-gnu\nzig build -Dtarget=aarch64-linux-gnu\nzig build -Dtarget=x86_64-macos\nzig build -Dtarget=aarch64-macos\nzig build -Dtarget=x86_64-windows\nzig build -Dtarget=wasm32-wasi\n```\n\n---\n\n## C FFI\n\nBuild shared library with C headers:\n\n```bash\nzig build -Dshared=true\n```\n\nOutput:\n- `zig-out/lib/libzuda.a`\n- `zig-out/include/zuda.h`\n\n**C Example**:\n```c\n#include \u003czuda.h\u003e\n\nZudaHashMap* map = zuda_hash_map_create();\nzuda_hash_map_put(map, \"key\", \"value\");\nconst char* val = zuda_hash_map_get(map, \"key\");\nzuda_hash_map_destroy(map);\n```\n\n**Python Example**:\n```python\nfrom zuda import HashMap\nhm = HashMap()\nhm.put(\"key\", \"value\")\nprint(hm.get(\"key\"))  # \"value\"\n```\n\nSee [examples/FFI_README.md](examples/FFI_README.md) for Python, Node.js, and other language bindings.\n\n---\n\n## Roadmap\n\n### v1.x — Data Structures \u0026 Algorithms (Complete)\n- [x] **Phase 1**: Lists, queues, heaps, hash tables\n- [x] **Phase 2**: Trees, spatial structures, strings\n- [x] **Phase 3**: Graph algorithms\n- [x] **Phase 4**: Sorting, string algorithms, probabilistic, caches, geometry, math, DP\n- [x] **Phase 5**: Concurrent, persistent, exotic, C API, FFI\n- [x] **v1.0**: Documentation, decision guides, consumer migration support\n\n### v2.0 — Scientific Computing (In Progress)\n- [ ] **Phase 6**: NDArray foundation (multi-dimensional array, broadcasting, element-wise ops)\n- [ ] **Phase 7**: Linear algebra (BLAS, decompositions, solvers, sparse matrices)\n- [ ] **Phase 8**: Statistics \u0026 random (distributions, hypothesis testing, regression)\n- [ ] **Phase 9**: Transforms \u0026 signal processing (FFT, convolution, filtering)\n- [ ] **Phase 10**: Numerical methods (integration, interpolation, ODE solvers, root finding)\n- [ ] **Phase 11**: Optimization (gradient descent, L-BFGS, linear programming, auto-diff)\n- [ ] **Phase 12**: v2.0 integration, SIMD acceleration, NumPy compatibility guide\n\nSee [PRD.md](docs/PRD.md) for detailed roadmap and [milestones.md](docs/milestones.md) for progress tracking.\n\n---\n\n## Contributing\n\nContributions welcome! Please:\n\n1. Check existing issues or create a new one\n2. Fork and create a feature branch\n3. Follow Zig coding conventions (see [CLAUDE.md](CLAUDE.md#coding-standards))\n4. Add tests for new functionality\n5. Ensure `zig build test` passes\n6. Submit a pull request\n\n**Bug Reports**: https://github.com/yusa-imit/zuda/issues\n\n---\n\n## Design Principles\n\n1. **Allocator-First**: Every container accepts `std.mem.Allocator` - never hardcode allocator\n2. **Comptime Configuration**: Parameterize behavior at compile time (comparators, hash functions, branching factors)\n3. **Iterator Protocol**: All iterable containers expose `next() -\u003e ?T`\n4. **Complexity Contracts**: Every public function documents Big-O in doc comments\n5. **Invariant Validation**: Every container provides `validate()` method\n6. **No Panics**: Library code returns errors, caller decides\n7. **Memory Safety**: Leak-free (verified with `std.testing.allocator`)\n\nSee [CLAUDE.md](CLAUDE.md#coding-standards) for complete coding standards.\n\n---\n\n## Version History\n\n- **v1.14.0** (2026-03-20): Ergonomic enhancements — reverse iterators, convenience constructors, 112 new tests\n- **v1.0.0** (2026-03-14): Stable release — 100+ data structures, 80+ algorithms, C FFI, 746 tests\n- **v0.5.0** (2026-03-13): Phase 5 complete — C API, FFI bindings, persistent structures, exotic containers\n- **v0.4.0**: Phase 4 complete — Probabilistic structures, caches, geometry, math, DP utilities\n- **v0.3.0**: Phase 3 complete — Graph algorithms (shortest paths, MST, flow, matching)\n- **v0.2.0**: Phase 2 complete — Trees, spatial structures, suffix arrays/trees\n- **v0.1.0**: Phase 1 complete — Foundations (lists, queues, heaps, hash tables)\n\n**Next**: v2.0.0 — Scientific computing platform (NDArray, linear algebra, statistics, FFT, numerical methods, optimization)\n\n---\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n---\n\n## Acknowledgments\n\nInspired by:\n- **Zig Standard Library**: `std.ArrayList`, `std.HashMap`, `std.PriorityQueue`\n- **Boost C++ Libraries**: Comprehensive STL-style containers\n- **NumPy / SciPy**: NDArray design, scientific computing API surface\n- **Eigen**: Template-based linear algebra design patterns\n- **LAPACK / OpenBLAS / FFTW**: Performance reference implementations\n- **CLRS**: *Introduction to Algorithms* (3rd edition)\n- **Sedgewick**: *Algorithms* (4th edition)\n- **Knuth**: *The Art of Computer Programming*\n- **Google Abseil**: SwissTable implementation\n- **Clojure**: Persistent data structures (HAMT)\n\nDeveloped with **[Claude Code](https://github.com/anthropics/claude-code)** - autonomous AI development.\n\n---\n\n**Ready to build?** → [Getting Started](docs/GETTING_STARTED.md) | [API Reference](docs/API.md) | [Choose a Data Structure](docs/GUIDE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusa-imit%2Fzuda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusa-imit%2Fzuda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusa-imit%2Fzuda/lists"}