Skip to main content

take

Function take 

Source
pub fn take<B: Backend, T: Element, I: Int>(
    x: &Array<B, T>,
    indices: &Array<B, I>,
    axis: i64,
) -> Array<B, T>
Expand description

The elements of x at indices along axis (jnp.take(x, indices, axis, mode="clip"), which is JAX’s indexing x[..., indices, ...]): the result has the shape of x with dimension axis replaced by the shape of indices. Negative indices count from the end, and indices out of bounds are clamped.

§Examples

use ruxla_core::{Array, Native, jnp};

let x = Array::<Native, i32>::from_slice(&[10, 11, 12, 13, 14, 15], [3, 2]);
let i = Array::<Native, i32>::from_slice(&[2, -3], [2]);
assert_eq!(jnp::take(&x, &i, 0).to_vec(), [14, 15, 10, 11]);

§Panics

Panics if axis is out of range.