Expand description
Indexing module for NumRS2 arrays
This module provides comprehensive indexing capabilities for arrays, including:
- Basic indexing with integer indices
- Slicing with ranges and steps
- Boolean (mask) indexing
- Fancy indexing with index arrays
- NewAxis and Ellipsis support
§Examples
use numrs2::prelude::*;
// Create a 2D array
let arr = Array::from_vec(vec![1, 2, 3, 4, 5, 6]).reshape(&[2, 3]);
// Basic indexing
let elem = arr.get(&[0, 1]).expect("valid index should succeed");
assert_eq!(elem, 2);
// Slicing
let slice = arr.index(&[IndexSpec::All, IndexSpec::Slice(0, Some(2), None)])
.expect("valid slice should succeed");
assert_eq!(slice.shape(), vec![2, 2]);Enums§
- Index
Spec - Represents an index specification for a single dimension
Functions§
- diag_
indices - Return the indices to access the main diagonal of an n-dimensional array.
- diag_
indices_ from - Return the indices to access the main diagonal of an array.
- extract
- Return the elements of an array that satisfy some condition
- indices_
grid - Create index arrays for the nth dimension in an n-dimensional grid from shape
- ix_
- Generate index arrays for fancy indexing
- mask_
indices - Return the indices to access array elements that satisfy the given condition
- put
- Set array values using indices
- put_
along_ axis - Put values into array by matching 1D indices along axis
- putmask
- Set array elements using a mask array
- ravel_
multi_ index - Converts a tuple of index arrays into an array of flat indices
- take
- Take elements from array along axis using indices
- take_
along_ axis - Take values from array by matching 1D indices along axis
- tril_
indices - Return the indices for the lower-triangle of an array.
- tril_
indices_ from - Return the indices for the lower-triangle of an array from an existing array.
- triu_
indices - Return the indices for the upper-triangle of an array.
- triu_
indices_ from - Return the indices for the upper-triangle of an array from an existing array.
- unravel_
index - Converts a flat index or array of flat indices into a tuple of coordinate arrays