Shape, Indexing & Set Ops
Stack 1D arrays as columns into a 2D array.
Concatenate tensors along an existing axis.
Delete elements from a tensor along an axis.
Return the indices of the bins to which each value in the input array belongs.
Element-wise greatest common divisor.
Return the numerical gradient of a 1D array using central finite differences.
Stack tensors horizontally (column-wise).
Insert values into a tensor along an axis before given indices.
One-dimensional linear interpolation.
Compute the sorted, unique intersection of two 1D tensors.
Element-wise least common multiple.
Repeat elements of a tensor along an axis.
Compute the sorted set difference of two 1D tensors.
Split tensor into multiple sub-tensors along an axis.
Stack tensors along a new axis.
Repeat tensor along axes by tiling.
Integrate along the given axis using the composite trapezoidal rule.
Compute the sorted, unique union of two 1D tensors.
Stack tensors vertically (row-wise).
Flatten to 1D.
Gather values along an axis specified by indices.
Change shape (view) without copying.
Slice a tensor.
Transpose tensor dimensions.
Remove single-dimensional entries from the shape.
Expand the shape by inserting a new axis.
import { concatenate, delete_, hstack, insert, meshgrid, repeat, reshape, slice, split, stack, tensor, tile, union1d,} from "deepbox/ndarray";const x = tensor([[1, 2, 3], [4, 5, 6]]);console.log(slice(x, { start: 0, end: 2 }, { start: 1, end: 3 }).toString());console.log(reshape(x, [3, 2]).toString());console.log(stack([tensor([1, 2]), tensor([3, 4])]).toString());console.log(concatenate([tensor([1, 2]), tensor([3, 4])]).toString());console.log(split(tensor([1, 2, 3, 4]), 2).map((t) => t.toString()));console.log(repeat(tensor([1, 2]), 2).toString());console.log(tile(tensor([[1, 2]]), [2, 1]).toString());console.log(insert(tensor([1, 3, 4]), 1, tensor([2])).toString());console.log(delete_(tensor([1, 2, 3, 4]), 2).toString());console.log(hstack([tensor([[1], [2]]), tensor([[3], [4]])]).toString());console.log(meshgrid(tensor([0, 1]), tensor([10, 20])).map((t) => t.toString()));console.log(union1d(tensor([1, 2, 3]), tensor([3, 4, 5])).toString());