-
-
Notifications
You must be signed in to change notification settings - Fork 1
Home
rizkirakasiwi edited this page Mar 14, 2026
·
3 revisions
numc is a high-performance N-dimensional tensor library written in pure C23. It provides NumPy-like array operations with zero external dependencies, targeting scientific computing, machine learning, and high-frequency data processing.
- Pure C, zero dependencies -- no BLAS, Fortran, or Python required. Just a C23 compiler.
-
10 numeric types --
int8throughuint64,float32,float64. Every operation works on all types. - Arena memory management -- all arrays are owned by a context. Free the context, free everything. No leaks.
- SIMD-accelerated -- AVX2, AVX-512, NEON, SVE/SVE2, and RISC-V Vector with automatic dispatch.
- NumPy-compatible broadcasting -- binary operations broadcast shapes just like NumPy.
- Cross-platform -- compiles on GCC, Clang, and MSVC. Runs on x86, ARM, and RISC-V.
#include <numc/numc.h>
#include <stdio.h>
int main() {
// Create a context -- all arrays live here
NumcCtx *ctx = numc_ctx_create();
// Create a 3x3 matrix filled with 2.0
size_t shape[] = {3, 3};
NumcArray *a = numc_array_fill(ctx, shape, 2, NUMC_DTYPE_FLOAT32,
&(float){2.0f});
// Create a random 3x3 matrix
NumcArray *b = numc_array_rand(ctx, shape, 2, NUMC_DTYPE_FLOAT32);
// Element-wise addition
NumcArray *sum = numc_array_create(ctx, shape, 2, NUMC_DTYPE_FLOAT32);
numc_add(a, b, sum);
// Matrix multiplication
NumcArray *prod = numc_array_create(ctx, shape, 2, NUMC_DTYPE_FLOAT32);
numc_matmul(a, b, prod);
printf("a + b:\n");
numc_array_print(sum);
printf("\na @ b:\n");
numc_array_print(prod);
// Free everything at once
numc_ctx_free(ctx);
return 0;
}- Get Started -- Installation, building, and your first program.
-
Building and Linking -- CMake integration with
find_packageandFetchContent.
- Context and Lifecycle -- How arena-based memory management works.
-
Array Creation -- Creating arrays:
zeros,fill,rand,copy,write. - Data Types -- The 10 supported numeric types and how to choose.
- Math Operations -- Arithmetic, unary, comparisons, reductions, matmul.
- Broadcasting -- How shape broadcasting works with examples.
- Shape Manipulation -- Reshape, transpose, slice, and contiguous layouts.
- Random Initialization -- PRNG seeding, uniform/normal, He/Xavier.
- Error Handling -- Error codes, checking, and reporting.
- Architecture Overview -- How numc works under the hood.
- Performance Tips -- Getting the best performance from numc.