{"id":51002605,"url":"https://github.com/muhammad-fiaz/num.zig","last_synced_at":"2026-06-20T16:32:40.148Z","repository":{"id":332271278,"uuid":"1111581329","full_name":"muhammad-fiaz/num.zig","owner":"muhammad-fiaz","description":"A production-grade, high-performance numerical computing library for Zig, designed with a clean, intuitive, and developer-friendly API similar to NumPy.","archived":false,"fork":false,"pushed_at":"2025-12-08T08:20:57.000Z","size":278,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-22T15:40:32.346Z","etag":null,"topics":["num-zig","num-zig-package","numzig","numzig-library","package","zig","zig-lang","zig-library","zig-package"],"latest_commit_sha":null,"homepage":"https://muhammad-fiaz.github.io/num.zig/","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muhammad-fiaz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["muhammad-fiaz"],"ko_fi":"muhammadfiaz"}},"created_at":"2025-12-07T08:25:40.000Z","updated_at":"2026-03-25T19:21:36.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/muhammad-fiaz/num.zig","commit_stats":null,"previous_names":["muhammad-fiaz/num.zig"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/muhammad-fiaz/num.zig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammad-fiaz%2Fnum.zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammad-fiaz%2Fnum.zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammad-fiaz%2Fnum.zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammad-fiaz%2Fnum.zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muhammad-fiaz","download_url":"https://codeload.github.com/muhammad-fiaz/num.zig/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammad-fiaz%2Fnum.zig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34578089,"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-06-20T02:00:06.407Z","response_time":98,"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":["num-zig","num-zig-package","numzig","numzig-library","package","zig","zig-lang","zig-library","zig-package"],"created_at":"2026-06-20T16:32:39.030Z","updated_at":"2026-06-20T16:32:40.131Z","avatar_url":"https://github.com/muhammad-fiaz.png","language":"Zig","funding_links":["https://github.com/sponsors/muhammad-fiaz","https://ko-fi.com/muhammadfiaz"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg alt=\"Logo\" src=\"https://github.com/user-attachments/assets/a6e08aa0-61ac-4246-b574-af6097ae1b81\" /\u003e\n\n\n\u003ca href=\"https://muhammad-fiaz.github.io/num.zig/\"\u003e\u003cimg src=\"https://img.shields.io/badge/docs-muhammad--fiaz.github.io-blue\" alt=\"Documentation\"\u003e\u003c/a\u003e\n\u003ca href=\"https://ziglang.org/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Zig-0.15.1-orange.svg?logo=zig\" alt=\"Zig Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/muhammad-fiaz/num.zig\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/muhammad-fiaz/num.zig\" alt=\"GitHub stars\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/muhammad-fiaz/num.zig/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/muhammad-fiaz/num.zig\" alt=\"GitHub issues\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/muhammad-fiaz/num.zig/pulls\"\u003e\u003cimg src=\"https://img.shields.io/github/issues-pr/muhammad-fiaz/num.zig\" alt=\"GitHub pull requests\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/muhammad-fiaz/num.zig\"\u003e\u003cimg src=\"https://img.shields.io/github/last-commit/muhammad-fiaz/num.zig\" alt=\"GitHub last commit\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/muhammad-fiaz/num.zig\"\u003e\u003cimg src=\"https://img.shields.io/github/license/muhammad-fiaz/num.zig\" alt=\"License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/muhammad-fiaz/num.zig/actions/workflows/deploy.yml\"\u003e\u003cimg src=\"https://github.com/muhammad-fiaz/num.zig/actions/workflows/deploy.yml/badge.svg\" alt=\"Deploy VitePress site to Pages\" /\u003e\u003c/a\u003e\n\u003cimg src=\"https://img.shields.io/badge/platforms-linux%20%7C%20windows%20%7C%20macos-blue\" alt=\"Supported Platforms\"\u003e\n\u003ca href=\"https://github.com/muhammad-fiaz/num.zig/actions/workflows/github-code-scanning/codeql\"\u003e\u003cimg src=\"https://github.com/muhammad-fiaz/num.zig/actions/workflows/github-code-scanning/codeql/badge.svg\" alt=\"CodeQL\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/muhammad-fiaz/num.zig/actions/workflows/release.yml\"\u003e\u003cimg src=\"https://github.com/muhammad-fiaz/num.zig/actions/workflows/release.yml/badge.svg\" alt=\"Release\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/muhammad-fiaz/num.zig/releases/latest\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/muhammad-fiaz/num.zig?label=Latest%20Release\u0026style=flat-square\" alt=\"Latest Release\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pay.muhammadfiaz.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/Sponsor-pay.muhammadfiaz.com-ff69b4?style=flat\u0026logo=heart\" alt=\"Sponsor\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/sponsors/muhammad-fiaz\"\u003e\u003cimg src=\"https://img.shields.io/badge/Sponsor-💖-pink?style=social\u0026logo=github\" alt=\"GitHub Sponsors\"\u003e\u003c/a\u003e\n\u003ca href=\"https://hits.sh/muhammad-fiaz/num.zig/\"\u003e\u003cimg src=\"https://hits.sh/muhammad-fiaz/num.zig.svg?label=Visitors\u0026extraCount=0\u0026color=green\" alt=\"Repo Visitors\"\u003e\u003c/a\u003e\n\n\u003cp\u003e\u003cem\u003eA fast, high-performance, memory-safe numerical computing and machine learning library for Zig.\u003c/em\u003e\u003c/p\u003e\n\n\u003cb\u003e📚 \u003ca href=\"https://muhammad-fiaz.github.io/num.zig/\"\u003eDocumentation\u003c/a\u003e |\n\u003ca href=\"https://muhammad-fiaz.github.io/num.zig/api/overview\"\u003eAPI Reference\u003c/a\u003e |\n\u003ca href=\"https://muhammad-fiaz.github.io/num.zig/guide/quick-start\"\u003eQuick Start\u003c/a\u003e |\n\u003ca href=\"CONTRIBUTING.md\"\u003eContributing\u003c/a\u003e\u003c/b\u003e\n\n\u003c/div\u003e\n\nA production-grade, high-performance numerical computing library for Zig, designed with a clean, intuitive, and developer-friendly API similar to NumPy.\n\n\u003e Note: Num.zig is currently under active development. GPU acceleration is not yet supported, but it is planned for future releases. If you are interested, contributions are welcome! ⭐ If you love Num.zig, please consider starring the repository.\n\n---\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e✨ Features of Num.Zig\u003c/strong\u003e (click to expand)\u003c/summary\u003e\n\n| Feature | Description |\n|---------|-------------|\n| ✨ **NDArray** | N-dimensional array implementation with efficient memory management |\n| 🎯 **Broadcasting** | NumPy-style broadcasting for arithmetic operations |\n| 🚀 **Linear Algebra** | Matrix multiplication, dot products, QR/Cholesky/Eig decompositions, solvers |\n| 📁 **Statistics** | Reductions (sum, mean, min, max, std, var, median) |\n| 🔍 **Indexing** | Advanced slicing, boolean masking, take, where, nonzero |\n| 📡 **Signal Processing** | Convolution, correlation, filtering modes (full, valid, same) |\n| 📈 **Polynomials** | Evaluation, arithmetic, roots, derivatives, integrals |\n| 🔢 **Calculus** | Finite differences, gradients |\n| 🛠️ **Element-wise** | Clip, Round, Floor, Ceil, Abs, Sign, Min/Max, Trig, Log, Exp |\n| 🔄 **Random** | Random number generation with various distributions |\n| ⚡ **FFT** | N-dimensional Fast Fourier Transform |\n| ℂ **Complex Numbers** | Complex number support and operations |\n| 💾 **IO** | Binary save/load, Memory Mapping (mmap) |\n| 🎨 **Machine Learning** | Sequential Models, Dense/Dropout/Softmax Layers, Training Loop, Save/Load |\n| 📊 **Memory Safe** | Built with Zig's safety features and explicit allocator control |\n| 📝 **Cross-Platform** | Supports Windows, Linux, macOS, and bare metal |\n| 🔗 **Zero Dependencies** | Pure Zig implementation with no external dependencies |\n| ⚡ **Performance** | Optimized algorithms including tiled matrix multiplication |\n| 🧮 **Autograd** | Automatic differentiation for gradient-based optimization |\n| 📊 **DataFrame** | Tabular data structures similar to pandas (DataFrame, Series) |\n| 🧩 **Modular Design** | Organized into modules for easy use and extension |\n| 🛠️ **Builtin Collections** | Efficient data structures like basic ML Algorithms, HashSet, etc. |\n| 📚 **Comprehensive Documentation** | Detailed guides and API reference for easy adoption |\n\n\u003c/details\u003e\n\n----\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e📌 Prerequisites \u0026 Supported Platforms\u003c/strong\u003e (click to expand)\u003c/summary\u003e\n\n\u003cbr\u003e\n\n## Prerequisites\n\nBefore installing Num.Zig, ensure you have the following:\n\n| Requirement | Version | Notes |\n|-------------|---------|-------|\n| **Zig** | 0.15.0+ | Download from [ziglang.org](https://ziglang.org/download/) |\n| **Operating System** | Windows 10+, Linux, macOS | Cross-platform support |\n\n\u003e **Tip:** Verify your Zig installation by running `zig version` in your terminal.\n\n---\n\n## Supported Platforms\n\nNum.Zig supports a wide range of platforms and architectures:\n\n| Platform | Architectures | Status |\n|----------|---------------|--------|\n| **Windows** | x86_64, x86 | ✅ Full support |\n| **Linux** | x86_64, x86, aarch64 | ✅ Full support |\n| **macOS** | x86_64, aarch64 (Apple Silicon) | ✅ Full support |\n| **Bare Metal / Freestanding** | x86_64, aarch64, arm, riscv64 | ✅ Full support |\n\n\u003c/details\u003e\n\n---\n\n## Installation\n\n### Method 1: Starter Project (Recommended)\n\nDownload the starter project to get up and running quickly:\n\n[**⬇️ Download Starter Project**](https://github.com/muhammad-fiaz/num.zig/releases/latest/download/project-starter-example.zip)\n\n### Method 2: Zig Fetch\n\nThe easiest way to add Num.Zig to your existing project:\n\n```bash\nzig fetch --save https://github.com/muhammad-fiaz/num.zig/archive/refs/heads/main.tar.gz\n```\n\nThis automatically adds the dependency with the correct hash to your `build.zig.zon`.\n\n### Method 3: Manual Configuration\n\nAdd to your `build.zig.zon`:\n\n```zig\n.dependencies = .{\n    .num = .{\n        .url = \"https://github.com/muhammad-fiaz/num.zig/archive/refs/heads/main.tar.gz\",\n        // .hash = \"...\", // Run zig build to get the hash\n    },\n},\n```\n\nThen in your `build.zig`:\n\n```zig\nconst num = b.dependency(\"num\", .{\n    .target = target,\n    .optimize = optimize,\n});\nexe.root_module.addImport(\"num\", num.module(\"num\"));\n```\n\n## Quick Start\n\n```zig\nconst std = @import(\"std\");\nconst num = @import(\"num\");\nconst NDArray = num.NDArray;\n\npub fn main() !void {\n    var gpa = std.heap.GeneralPurposeAllocator(.{}){};\n    defer _ = gpa.deinit();\n    const allocator = gpa.allocator();\n\n    // Create a 2x3 matrix using arange (0, 1, 2, 3, 4, 5)\n    var a = try NDArray(f32).arange(allocator, 0.0, 6.0, 1.0);\n    defer a.deinit();\n    try a.reshape(\u0026.{ 2, 3 });\n\n    // Create another matrix of ones\n    var b = try NDArray(f32).ones(allocator, \u0026.{ 2, 3 });\n    defer b.deinit();\n\n    // Add them together\n    var c = try num.ops.add(f32, allocator, \u0026a, \u0026b);\n    defer c.deinit();\n\n    // Print result\n    const val = try c.get(\u0026.{ 0, 0 }); // 0.0 + 1.0 = 1.0\n    std.debug.print(\"Result at [0,0]: {d}\\n\", .{val});\n}\n```\n\n## Running Examples\n\nThis repository includes several runnable examples covering different aspects of the library:\n\n- `zig build run-basics`: Basic array creation, I/O, and indexing.\n- `zig build run-manipulation`: Reshaping, transposing, and flattening arrays.\n- `zig build run-math`: Arithmetic operations, broadcasting, and statistics.\n- `zig build run-linalg`: Linear algebra operations (matmul, solve).\n- `zig build run-random`: Random number generation distributions.\n- `zig build run-ml`: Machine learning components (Dense layer, ReLU, MSE).\n- `zig build run-ml_sample`: Full Neural Network training (XOR) using Sequential API.\n- `zig build run-fft`: Fast Fourier Transform.\n- `zig build run-indexing`: Advanced indexing (slicing, take).\n- `zig build run-signal_poly`: Signal processing and polynomials.\n- `zig build run-setops`: Set operations.\n\nTo run an example:\n```bash\nzig build run-basics\n```\n\n## Usage Examples\n\n### Linear Algebra\n\n```zig\nconst allocator = std.heap.page_allocator;\n\n// Matrix Multiplication\nvar a = try NDArray(f32).init(allocator, \u0026.{ 2, 3 });\n// ... fill a ...\nvar b = try NDArray(f32).init(allocator, \u0026.{ 3, 2 });\n// ... fill b ...\n\nvar c = try num.linalg.matmul(f32, allocator, \u0026a, \u0026b);\ndefer c.deinit();\n```\n\n### Machine Learning (Sequential API)\n\n```zig\nconst allocator = std.heap.page_allocator;\nconst Sequential = num.ml.models.Sequential;\nconst Layer = num.ml.layers.Layer;\nconst Dense = num.ml.layers.Dense;\n\n// Define Model\nvar model = Sequential.init(allocator);\ndefer model.deinit(allocator);\n\n// Add Layers\ntry model.add(allocator, Layer{ .Dense = try Dense.init(allocator, 10, 32, .XavierUniform) });\ntry model.add(allocator, Layer{ .ReLU = {} });\ntry model.add(allocator, Layer{ .Dense = try Dense.init(allocator, 32, 1, .XavierUniform) });\ntry model.add(allocator, Layer{ .Sigmoid = {} });\n\n// Train (assuming x_train, y_train, optimizer, loss_fn are defined)\n// try model.fit(allocator, x_train, y_train, optimizer, loss_fn, 100);\n\n// Save \u0026 Load\ntry model.save(allocator, \"model.bin\");\nvar loaded = try Sequential.load(allocator, \"model.bin\");\ndefer loaded.deinit(allocator);\n```\n\n## Performance\n\nNum.Zig is designed for high performance. It uses tiled algorithms for matrix multiplication to optimize cache usage and minimize memory bandwidth bottlenecks.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nApache 2.0 License - see [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhammad-fiaz%2Fnum.zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuhammad-fiaz%2Fnum.zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhammad-fiaz%2Fnum.zig/lists"}