Manipulation API Reference
The manipulation module provides functions for changing array shapes and content.
Shape Manipulation
ravel
Return a contiguous flattened array.
pub fn ravel(allocator: Allocator, comptime T: type, arr: NDArray(T)) !NDArray(T)moveaxis
Move axes of an array to new positions.
pub fn moveaxis(allocator: Allocator, comptime T: type, arr: NDArray(T), source: []const usize, destination: []const usize) !NDArray(T)swapaxes
Interchange two axes of an array.
pub fn swapaxes(allocator: Allocator, comptime T: type, arr: NDArray(T), axis1: usize, axis2: usize) !NDArray(T)flip
Reverse the order of elements in an array along the given axis.
pub fn flip(allocator: Allocator, comptime T: type, arr: NDArray(T), axis: usize) !NDArray(T)roll
Roll array elements along a given axis.
pub fn roll(allocator: Allocator, comptime T: type, arr: NDArray(T), shift: isize, axis: usize) !NDArray(T)Joining Arrays
vstack
Stack arrays in sequence vertically (row wise).
pub fn vstack(allocator: Allocator, comptime T: type, arrays: []const NDArray(T)) !NDArray(T)hstack
Stack arrays in sequence horizontally (column wise).
pub fn hstack(allocator: Allocator, comptime T: type, arrays: []const NDArray(T)) !NDArray(T)dstack
Stack arrays in sequence depth wise (along third axis).
pub fn dstack(allocator: Allocator, comptime T: type, arrays: []const NDArray(T)) !NDArray(T)Tiling and Repeating
tile
Construct an array by repeating A the number of times given by reps.
pub fn tile(allocator: Allocator, comptime T: type, arr: NDArray(T), reps: []const usize) !NDArray(T)repeat
Repeat elements of an array.
pub fn repeat(allocator: Allocator, comptime T: type, arr: NDArray(T), repeats: usize, axis: ?usize) !NDArray(T)Search and Replace
find
Find indices where a predicate is true.
pub fn find(allocator: Allocator, comptime T: type, a: *const NDArray(T), predicate: anytype) !NDArray(usize)replace
Replace all occurrences of a value.
pub fn replace(allocator: Allocator, comptime T: type, a: *const NDArray(T), old_val: T, new_val: T) !NDArray(T)replaceWhere
Replace values where a predicate is true.
pub fn replaceWhere(allocator: Allocator, comptime T: type, a: *const NDArray(T), predicate: anytype, value: T) !NDArray(T)replaceFirst
Replace the first occurrence of a value.
pub fn replaceFirst(allocator: Allocator, comptime T: type, a: *const NDArray(T), old_val: T, new_val: T) !NDArray(T)replaceLast
Replace the last occurrence of a value.
pub fn replaceLast(allocator: Allocator, comptime T: type, a: *const NDArray(T), old_val: T, new_val: T) !NDArray(T)delete
Return a new array with sub-arrays along an axis deleted.
pub fn delete(allocator: Allocator, comptime T: type, a: *const NDArray(T), indices: []const usize) !NDArray(T)