Releases: jailop/ndarray-c
Releases · jailop/ndarray-c
Version 0.4.0
- includes support for functions some functions defined in the c math
header: exp, log, sqrt, sin, cos, tan, sinh, cosh, tanh, asin, acos,
atan, and pow - new example added: Geometric Brownian Motion Paths, to simulate stock
price evalotion.
Version 0.3.0
- zig: all functions that creates a new NDArray are prefixed with init,
ex. initArange(...). In that way, it is easy to remember that it
requires a deinit and also that they can not be chained. - ndaray_logical... functions have been renamed to
ndarray_new_logical... Also ndarray_where has been renamed to
ndarray_new_where to be clear that they are allocating memory that
must be deallocated. - Comments in code improved to include examples.
- Site documentation improved
Version 0.2.3
- const qualitifiers
- CMakefileLists.txt updated
- zig aditional dynamic memory allocations removed
- zig tests extended
- README divided in multiple files
- README - new section on nesting functions
- Tests for nested functions added
- License added: BSD 3-clause
- Support for compiling in Windows added via CMakefile
- new function:
ndarray_scalar_aggr
Version 0.2.2
Zig build/importing reviewed/improved
Version 0.2.1
Random number generation improved.
Improved zig compatibility
Version 0.2.0
Major Feature Release: Conditional Operations, Comparison Logic, and Slice Access
This release expands the ndarray library's capabilities
adding conditional operations, comparison logic, and efficient slice
access helpers. This is a fully backward-compatible release. All
existing APIs remain unchanged.
New Conditional Operations
Essential for constraints, activation functions, and data validation:
ndarray_clip_min(A, 0.0); // Non-negativity constraints, ReLU
ndarray_clip_max(A, 100.0); // Saturation, prevent overflow
ndarray_clip(A, 0.0, 1.0); // Normalize to [0, 1] range
ndarray_abs(A); // Distance calculations, L1 norm
ndarray_sign(A); // Direction indicators (-1, 0, +1)New Comparison Operations
Element-wise comparisons returning boolean masks (1.0 for true, 0.0 for false):
// Array vs Array
NDArray eq = ndarray_new_equal(A, B); // A == B
NDArray lt = ndarray_new_less(A, B); // A < B
NDArray gt = ndarray_new_greater(A, B); // A > B
// Array vs Scalar
NDArray positive = ndarray_new_greater_scalar(A, 0.0);
NDArray zeros = ndarray_new_equal_scalar(A, 0.0);
NDArray outliers = ndarray_new_greater_scalar(A, 100.0);New Logical Operations
Boolean algebra on arrays for complex conditions:
// Combine multiple conditions
NDArray mask1 = ndarray_new_greater_scalar(A, 10.0);
NDArray mask2 = ndarray_new_less_scalar(A, 90.0);
NDArray combined = ndarray_logical_and(mask1, mask2); // 10 < A < 90
// Boolean logic
ndarray_logical_or(mask1, mask2); // At least one true
ndarray_logical_not(mask1); // Invert condition
// NumPy-style where (ternary operator)
NDArray result = ndarray_where(condition, x, y); // condition ? x : yNew Slice Access Helpers
Ergonomic access to array slices:
// Direct pointer access (advanced users)
double* row = ndarray_get_slice_ptr(matrix, 0, 2); // Row 2
// Safe slice copying
ndarray_copy_slice(src, 0, 1, dst, 0, 3); // Copy row 1 to row 3
// Query slice dimensions
size_t row_size = ndarray_get_slice_size(matrix, 0); // Elements per rowSupported Build Systems
Three build systems:
- Makefile: Traditional GNU Make (verified in Linux)
- CMake: Cross-platform builds (verified in MacOS and Linux)
- Zig: Native Zig integration (verified in MacOS and Linux)