mlx_rs

Struct Array

Source
pub struct Array { /* private fields */ }
Expand description

An n-dimensional array.

Implementations§

Source§

impl Array

Source

pub unsafe fn from_ptr(c_array: mlx_array) -> Array

Create a new array from an existing mlx_array pointer.

§Safety

The caller must ensure the reference count of the array is properly incremented with mlx_sys::mlx_retain.

Source

pub fn as_ptr(&self) -> mlx_array

Get the underlying mlx_array pointer.

Source

pub fn from_bool(val: bool) -> Array

New array from a bool scalar.

Source

pub fn from_int(val: i32) -> Array

New array from an int scalar.

Source

pub fn from_float(val: f32) -> Array

New array from a float scalar.

Source

pub fn from_complex(val: complex64) -> Array

New array from a complex scalar.

Source

pub fn from_slice<T: ArrayElement>(data: &[T], shape: &[i32]) -> Self

New array from existing buffer.

§Parameters
  • data: A buffer which will be copied.
  • shape: Shape of the array.
§Panic
  • Panics if the product of the shape is not equal to the length of the data.
  • Panics if the shape is too large.
Source

pub unsafe fn from_raw_data( data: *const c_void, shape: &[i32], dtype: Dtype, ) -> Self

Create a new array from raw data buffer.

This is a convenience wrapper around [mlx_sy::mlx_array_new_data].

§Safety

This is unsafe because the caller must ensure that the data buffer is valid and that the shape is correct.

Source

pub fn from_iter<I: IntoIterator<Item = T>, T: ArrayElement>( iter: I, shape: &[i32], ) -> Self

New array from an iterator.

This is a convenience method that is equivalent to

let data: Vec<T> = iter.collect();
Array::from_slice(&data, shape)
§Example
use mlx_rs::Array;

let data = vec![1i32, 2, 3, 4, 5];
let mut array = Array::from_iter(data.clone(), &[5]);
assert_eq!(array.as_slice::<i32>(), &data[..]);
Source

pub fn item_size(&self) -> usize

The size of the array’s datatype in bytes.

Source

pub fn size(&self) -> usize

Number of elements in the array.

Source

pub fn strides(&self) -> &[usize]

The strides of the array.

Source

pub fn nbytes(&self) -> usize

The number of bytes in the array.

Source

pub fn ndim(&self) -> usize

The array’s dimension.

Source

pub fn shape(&self) -> &[i32]

The shape of the array.

Returns: a pointer to the sizes of each dimension.

Source

pub fn dim(&self, dim: i32) -> i32

The shape of the array in a particular dimension.

§Panic
  • Panics if the array is scalar.
  • Panics if dim is negative and dim + ndim overflows
  • Panics if the dimension is out of bounds.
Source

pub fn dtype(&self) -> Dtype

The array element type.

Source

pub fn eval(&self) -> Result<()>

Evaluate the array.

Source

pub fn item<T: ArrayElement>(&self) -> T

Access the value of a scalar array. If T does not match the array’s dtype this will convert the type first.

Note: This will evaluate the array.

Source

pub fn try_item<T: ArrayElement>(&self) -> Result<T>

Access the value of a scalar array returning an error if the array is not a scalar. If T does not match the array’s dtype this will convert the type first.

Note: This will evaluate the array.

Source

pub unsafe fn as_slice_unchecked<T: ArrayElement>(&self) -> &[T]

Returns a slice of the array data without validating the dtype.

§Safety

This is unsafe because the underlying data ptr is not checked for null or if the desired dtype matches the actual dtype of the array.

§Example
use mlx_rs::Array;

let data = [1i32, 2, 3, 4, 5];
let mut array = Array::from_slice(&data[..], &[5]);

unsafe {
   let slice = array.as_slice_unchecked::<i32>();
   assert_eq!(slice, &[1, 2, 3, 4, 5]);
}
Source

pub fn try_as_slice<T: ArrayElement>(&self) -> Result<&[T], AsSliceError>

Returns a slice of the array data returning an error if the dtype does not match the actual dtype.

§Example
use mlx_rs::Array;

let data = [1i32, 2, 3, 4, 5];
let mut array = Array::from_slice(&data[..], &[5]);

let slice = array.try_as_slice::<i32>();
assert_eq!(slice, Ok(&data[..]));
Source

pub fn as_slice<T: ArrayElement>(&self) -> &[T]

Returns a slice of the array data. This method requires a mutable reference (&self) because it evaluates the array.

§Panics

Panics if the array is not evaluated or if the desired dtype does not match the actual dtype

§Example
use mlx_rs::Array;

let data = [1i32, 2, 3, 4, 5];
let mut array = Array::from_slice(&data[..], &[5]);

let slice = array.as_slice::<i32>();
assert_eq!(slice, &data[..]);
Source

pub fn deep_clone(&self) -> Self

Clone the array by copying the data.

This is named deep_clone to avoid confusion with the Clone trait.

Source§

impl Array

Source

pub fn abs_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise absolute value.

§Example
use mlx_rs::Array;
let array = Array::from_slice(&[1i32, 2, -3, -4, -5], &[5]);
let mut result = array.abs().unwrap();

let data: &[i32] = result.as_slice();
// data == [1, 2, 3, 4, 5]
Source

pub fn abs(&self) -> Result<Array>

Element-wise absolute value.

§Example
use mlx_rs::Array;
let array = Array::from_slice(&[1i32, 2, -3, -4, -5], &[5]);
let mut result = array.abs().unwrap();

let data: &[i32] = result.as_slice();
// data == [1, 2, 3, 4, 5]
Source

pub fn add_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise addition returning an error if arrays are not broadcastable.

Add two arrays with broadcasting.

§Params
  • other: array to add
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[4.0, 5.0, 6.0], &[3]);
let mut c = a.add(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [5.0, 7.0, 9.0]
Source

pub fn add(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise addition returning an error if arrays are not broadcastable.

Add two arrays with broadcasting.

§Params
  • other: array to add
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[4.0, 5.0, 6.0], &[3]);
let mut c = a.add(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [5.0, 7.0, 9.0]
Source

pub fn subtract_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise subtraction returning an error if arrays are not broadcastable.

Subtract two arrays with broadcasting.

§Params
  • other: array to subtract
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[4.0, 5.0, 6.0], &[3]);
let mut c = a.subtract(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [-3.0, -3.0, -3.0]
Source

pub fn subtract(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise subtraction returning an error if arrays are not broadcastable.

Subtract two arrays with broadcasting.

§Params
  • other: array to subtract
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[4.0, 5.0, 6.0], &[3]);
let mut c = a.subtract(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [-3.0, -3.0, -3.0]
Source

pub fn negative_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Unary element-wise negation. Returns an error if the array is of type bool.

Negate the values in the array.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let mut b = a.negative().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [-1.0, -2.0, -3.0]
Source

pub fn negative(&self) -> Result<Array>

Unary element-wise negation. Returns an error if the array is of type bool.

Negate the values in the array.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let mut b = a.negative().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [-1.0, -2.0, -3.0]
Source

pub fn multiply_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise multiplication returning an error if arrays are not broadcastable.

Multiply two arrays with broadcasting.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[4.0, 5.0, 6.0], &[3]);
let mut c = a.multiply(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [4.0, 10.0, 18.0]
Source

pub fn multiply(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise multiplication returning an error if arrays are not broadcastable.

Multiply two arrays with broadcasting.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[4.0, 5.0, 6.0], &[3]);
let mut c = a.multiply(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [4.0, 10.0, 18.0]
Source

pub fn nan_to_num_device( &self, nan: impl IntoOption<f32>, pos_inf: impl IntoOption<f32>, neg_inf: impl IntoOption<f32>, stream: impl AsRef<Stream>, ) -> Result<Array>

Replace NaN and Inf values with finite numbers.

§Params
  • nan: value to replace NaN with
  • posInf: value to replace positive inifinites with. If not specified will use the largest finite value for the given dtype.
  • negInf: value to replace negative inifinites with. If not specified will use the negative of the largest finite value for the given dtype.
  • stream: stream or device to evaluate on
Source

pub fn nan_to_num( &self, nan: impl IntoOption<f32>, pos_inf: impl IntoOption<f32>, neg_inf: impl IntoOption<f32>, ) -> Result<Array>

Replace NaN and Inf values with finite numbers.

§Params
  • nan: value to replace NaN with
  • posInf: value to replace positive inifinites with. If not specified will use the largest finite value for the given dtype.
  • negInf: value to replace negative inifinites with. If not specified will use the negative of the largest finite value for the given dtype.
  • stream: stream or device to evaluate on
Source

pub fn divide_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise division returning an error if arrays are not broadcastable.

Divide two arrays with broadcasting.

§Params
  • other: array to divide
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[4.0, 5.0, 6.0], &[3]);
let mut c = a.divide(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [0.25, 0.4, 0.5]
Source

pub fn divide(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise division returning an error if arrays are not broadcastable.

Divide two arrays with broadcasting.

§Params
  • other: array to divide
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[4.0, 5.0, 6.0], &[3]);
let mut c = a.divide(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [0.25, 0.4, 0.5]
Source

pub fn power_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise power operation returning an error if arrays are not broadcastable if they have different shapes.

Raise the elements of the array to the power of the elements of another array.

§Params
  • other: array to raise to the power of
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[2.0, 3.0, 4.0], &[3]);
let mut c = a.power(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [1.0, 8.0, 81.0]
Source

pub fn power(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise power operation returning an error if arrays are not broadcastable if they have different shapes.

Raise the elements of the array to the power of the elements of another array.

§Params
  • other: array to raise to the power of
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[2.0, 3.0, 4.0], &[3]);
let mut c = a.power(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [1.0, 8.0, 81.0]
Source

pub fn remainder_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise remainder of division returning an error if arrays are not broadcastable.

Computes the remainder of dividing lhs with rhs with broadcasting.

§Params
  • other: array to divide
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[10.0, 11.0, 12.0], &[3]);
let b = Array::from_slice(&[3.0, 4.0, 5.0], &[3]);
let mut c = a.remainder(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [1.0, 3.0, 2.0]
Source

pub fn remainder(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise remainder of division returning an error if arrays are not broadcastable.

Computes the remainder of dividing lhs with rhs with broadcasting.

§Params
  • other: array to divide
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[10.0, 11.0, 12.0], &[3]);
let b = Array::from_slice(&[3.0, 4.0, 5.0], &[3]);
let mut c = a.remainder(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [1.0, 3.0, 2.0]
Source

pub fn sqrt_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise square root

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 4.0, 9.0], &[3]);
let mut b = a.sqrt().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [1.0, 2.0, 3.0]
Source

pub fn sqrt(&self) -> Result<Array>

Element-wise square root

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 4.0, 9.0], &[3]);
let mut b = a.sqrt().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [1.0, 2.0, 3.0]
Source

pub fn cos_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise cosine

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[0.0, 1.0, 2.0], &[3]);
let mut b = a.cos().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [1.0, 0.54030234, -0.41614687]
Source

pub fn cos(&self) -> Result<Array>

Element-wise cosine

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[0.0, 1.0, 2.0], &[3]);
let mut b = a.cos().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [1.0, 0.54030234, -0.41614687]
Source

pub fn exp_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise exponential.

§Example
use mlx_rs::Array;

let a = Array::from_slice(&[0.0, 1.0, 2.0], &[3]);
let a = Array::from_slice(&[0.0, 1.0, 2.0], &[3]);
let mut b = a.exp().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [1.0, 2.7182817, 7.389056]
Source

pub fn exp(&self) -> Result<Array>

Element-wise exponential.

§Example
use mlx_rs::Array;

let a = Array::from_slice(&[0.0, 1.0, 2.0], &[3]);
let a = Array::from_slice(&[0.0, 1.0, 2.0], &[3]);
let mut b = a.exp().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [1.0, 2.7182817, 7.389056]
Source

pub fn floor_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise floor returning an error if the array is of type complex64.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[0.1, 1.9, 2.5], &[3]);
let mut b = a.floor().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [0.0, 1.0, 2.0]
Source

pub fn floor(&self) -> Result<Array>

Element-wise floor returning an error if the array is of type complex64.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[0.1, 1.9, 2.5], &[3]);
let mut b = a.floor().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [0.0, 1.0, 2.0]
Source

pub fn floor_divide_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise integer division returning an error if arrays are not broadcastable.

Divide two arrays with broadcasting.

If either array is a floating point type then it is equivalent to calling Array::floor() after /.

§Params
  • other: array to divide
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[4.0, 5.0, 6.0], &[3]);
let mut c = a.floor_divide(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [0.25, 0.4, 0.5]
Source

pub fn floor_divide(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise integer division returning an error if arrays are not broadcastable.

Divide two arrays with broadcasting.

If either array is a floating point type then it is equivalent to calling Array::floor() after /.

§Params
  • other: array to divide
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let b = Array::from_slice(&[4.0, 5.0, 6.0], &[3]);
let mut c = a.floor_divide(&b).unwrap();

let c_data: &[f32] = c.as_slice();
// c_data == [0.25, 0.4, 0.5]
Source

pub fn is_nan_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Return a boolean array indicating which elements are NaN.

§Params
  • stream: stream or device to evaluate on
Source

pub fn is_nan(&self) -> Result<Array>

Return a boolean array indicating which elements are NaN.

§Params
  • stream: stream or device to evaluate on
Source

pub fn is_inf_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Return a boolean array indicating which elements are infinity.

§Params
  • stream: stream or device to evaluate on
Source

pub fn is_inf(&self) -> Result<Array>

Return a boolean array indicating which elements are infinity.

§Params
  • stream: stream or device to evaluate on
Source

pub fn is_finite_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Return a boolean array indicating which elements are finite.

§Params
  • stream: stream or device to evaluate on
Source

pub fn is_finite(&self) -> Result<Array>

Return a boolean array indicating which elements are finite.

§Params
  • stream: stream or device to evaluate on
Source

pub fn is_neg_inf_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Return a boolean array indicating which elements are negative infinity.

§Params
  • stream: stream or device to evaluate on
Source

pub fn is_neg_inf(&self) -> Result<Array>

Return a boolean array indicating which elements are negative infinity.

§Params
  • stream: stream or device to evaluate on
Source

pub fn is_pos_inf_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Return a boolean array indicating which elements are positive infinity.

§Params
  • stream: stream or device to evaluate on
Source

pub fn is_pos_inf(&self) -> Result<Array>

Return a boolean array indicating which elements are positive infinity.

§Params
  • stream: stream or device to evaluate on
Source

pub fn log_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise natural logarithm.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let mut b = a.log().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [0.0, 0.6931472, 1.0986123]
Source

pub fn log(&self) -> Result<Array>

Element-wise natural logarithm.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let mut b = a.log().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [0.0, 0.6931472, 1.0986123]
Source

pub fn log2_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise base-2 logarithm.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 4.0, 8.0], &[4]);
let mut b = a.log2().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [0.0, 1.0, 2.0, 3.0]
Source

pub fn log2(&self) -> Result<Array>

Element-wise base-2 logarithm.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 4.0, 8.0], &[4]);
let mut b = a.log2().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [0.0, 1.0, 2.0, 3.0]
Source

pub fn log10_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise base-10 logarithm.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 10.0, 100.0], &[3]);
let mut b = a.log10().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [0.0, 1.0, 2.0]
Source

pub fn log10(&self) -> Result<Array>

Element-wise base-10 logarithm.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 10.0, 100.0], &[3]);
let mut b = a.log10().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [0.0, 1.0, 2.0]
Source

pub fn log1p_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise natural log of one plus the array.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let mut b = a.log1p().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [0.6931472, 1.0986123, 1.3862944]
Source

pub fn log1p(&self) -> Result<Array>

Element-wise natural log of one plus the array.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 3.0], &[3]);
let mut b = a.log1p().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [0.6931472, 1.0986123, 1.3862944]
Source

pub fn matmul_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Matrix multiplication returning an error if inputs are not valid.

Perform the (possibly batched) matrix multiplication of two arrays. This function supports broadcasting for arrays with more than two dimensions.

  • If the first array is 1-D then a 1 is prepended to its shape to make it a matrix. Similarly, if the second array is 1-D then a 1 is appended to its shape to make it a matrix. In either case the singleton dimension is removed from the result.
  • A batched matrix multiplication is performed if the arrays have more than 2 dimensions. The matrix dimensions for the matrix product are the last two dimensions of each input.
  • All but the last two dimensions of each input are broadcast with one another using standard broadcasting.
§Params
  • other: array to multiply
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3, 4], &[2, 2]);
let b = Array::from_slice(&[-5.0, 37.5, 4., 7., 1., 0.], &[2, 3]);

// produces a [2, 3] result
let mut c = a.matmul(&b);
Source

pub fn matmul(&self, other: impl AsRef<Array>) -> Result<Array>

Matrix multiplication returning an error if inputs are not valid.

Perform the (possibly batched) matrix multiplication of two arrays. This function supports broadcasting for arrays with more than two dimensions.

  • If the first array is 1-D then a 1 is prepended to its shape to make it a matrix. Similarly, if the second array is 1-D then a 1 is appended to its shape to make it a matrix. In either case the singleton dimension is removed from the result.
  • A batched matrix multiplication is performed if the arrays have more than 2 dimensions. The matrix dimensions for the matrix product are the last two dimensions of each input.
  • All but the last two dimensions of each input are broadcast with one another using standard broadcasting.
§Params
  • other: array to multiply
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3, 4], &[2, 2]);
let b = Array::from_slice(&[-5.0, 37.5, 4., 7., 1., 0.], &[2, 3]);

// produces a [2, 3] result
let mut c = a.matmul(&b);
Source

pub fn reciprocal_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise reciprocal.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 4.0], &[3]);
let mut b = a.reciprocal().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [1.0, 0.5, 0.25]
Source

pub fn reciprocal(&self) -> Result<Array>

Element-wise reciprocal.

§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1.0, 2.0, 4.0], &[3]);
let mut b = a.reciprocal().unwrap();

let b_data: &[f32] = b.as_slice();
// b_data == [1.0, 0.5, 0.25]
Source

pub fn round_device( &self, decimals: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Round to the given number of decimals.

§Params
  • decimals: number of decimals to round to - default is 0 if not provided
Source

pub fn round(&self, decimals: impl Into<Option<i32>>) -> Result<Array>

Round to the given number of decimals.

§Params
  • decimals: number of decimals to round to - default is 0 if not provided
Source

pub fn rsqrt_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise reciprocal and square root.

Source

pub fn rsqrt(&self) -> Result<Array>

Element-wise reciprocal and square root.

Source

pub fn sin_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise sine.

Source

pub fn sin(&self) -> Result<Array>

Element-wise sine.

Source

pub fn square_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Element-wise square.

Source

pub fn square(&self) -> Result<Array>

Element-wise square.

Source§

impl Array

Source

pub fn as_type_device<T: ArrayElement>( &self, stream: impl AsRef<Stream>, ) -> Result<Array>

Create a new array with the contents converted to the given ArrayElement type.

§Example
use mlx_rs::{Array, Dtype};

let array = Array::from_slice(&[1i16,2,3], &[3]);
let mut new_array = array.as_type::<f32>().unwrap();

assert_eq!(new_array.dtype(), Dtype::Float32);
assert_eq!(new_array.shape(), &[3]);
assert_eq!(new_array.item_size(), 4);
assert_eq!(new_array.as_slice::<f32>(), &[1.0,2.0,3.0]);
Source

pub fn as_type<T: ArrayElement>(&self) -> Result<Array>

Create a new array with the contents converted to the given ArrayElement type.

§Example
use mlx_rs::{Array, Dtype};

let array = Array::from_slice(&[1i16,2,3], &[3]);
let mut new_array = array.as_type::<f32>().unwrap();

assert_eq!(new_array.dtype(), Dtype::Float32);
assert_eq!(new_array.shape(), &[3]);
assert_eq!(new_array.item_size(), 4);
assert_eq!(new_array.as_slice::<f32>(), &[1.0,2.0,3.0]);
Source

pub fn as_dtype_device( &self, dtype: Dtype, stream: impl AsRef<Stream>, ) -> Result<Array>

Same as as_type but with a Dtype argument.

Source

pub fn as_dtype(&self, dtype: Dtype) -> Result<Array>

Same as as_type but with a Dtype argument.

Source

pub fn view_device<T: ArrayElement>( &self, stream: impl AsRef<Stream>, ) -> Result<Array>

View the array as a different type.

The output array will change along the last axis if the input array’s type and the output array’s type do not have the same size.

Note: the view op does not imply that the input and output arrays share their underlying data. The view only guarantees that the binary representation of each element (or group of elements) is the same.

Source

pub fn view<T: ArrayElement>(&self) -> Result<Array>

View the array as a different type.

The output array will change along the last axis if the input array’s type and the output array’s type do not have the same size.

Note: the view op does not imply that the input and output arrays share their underlying data. The view only guarantees that the binary representation of each element (or group of elements) is the same.

Source

pub fn view_dtype_device( &self, dtype: Dtype, stream: impl AsRef<Stream>, ) -> Result<Array>

Same as view but with a Dtype argument.

Source

pub fn view_dtype(&self, dtype: Dtype) -> Result<Array>

Same as view but with a Dtype argument.

Source§

impl Array

Source

pub fn cummax_device( &self, axis: impl Into<Option<i32>>, reverse: impl Into<Option<bool>>, inclusive: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Return the cumulative maximum of the elements along the given axis returning an error if the inputs are invalid.

§Params
  • axis: Optional axis to compute the cumulative maximum over. If unspecified the cumulative maximum of the flattened array is returned.
  • reverse: If true, the cumulative maximum is computed in reverse - defaults to false if unspecified.
  • inclusive: If true, the i-th element of the output includes the i-th element of the input - defaults to true if unspecified.
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [[5, 8], [5, 9]] -- cumulative max along the columns
let result = array.cummax(0, None, None).unwrap();
Source

pub fn cummax( &self, axis: impl Into<Option<i32>>, reverse: impl Into<Option<bool>>, inclusive: impl Into<Option<bool>>, ) -> Result<Array>

Return the cumulative maximum of the elements along the given axis returning an error if the inputs are invalid.

§Params
  • axis: Optional axis to compute the cumulative maximum over. If unspecified the cumulative maximum of the flattened array is returned.
  • reverse: If true, the cumulative maximum is computed in reverse - defaults to false if unspecified.
  • inclusive: If true, the i-th element of the output includes the i-th element of the input - defaults to true if unspecified.
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [[5, 8], [5, 9]] -- cumulative max along the columns
let result = array.cummax(0, None, None).unwrap();
Source

pub fn cummin_device( &self, axis: impl Into<Option<i32>>, reverse: impl Into<Option<bool>>, inclusive: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Return the cumulative minimum of the elements along the given axis returning an error if the inputs are invalid.

§Params
  • axis: Optional axis to compute the cumulative minimum over. If unspecified the cumulative maximum of the flattened array is returned.
  • reverse: If true, the cumulative minimum is computed in reverse - defaults to false if unspecified.
  • inclusive: If true, the i-th element of the output includes the i-th element of the input - defaults to true if unspecified.
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [[5, 8], [4, 8]] -- cumulative min along the columns
let result = array.cummin(0, None, None).unwrap();
Source

pub fn cummin( &self, axis: impl Into<Option<i32>>, reverse: impl Into<Option<bool>>, inclusive: impl Into<Option<bool>>, ) -> Result<Array>

Return the cumulative minimum of the elements along the given axis returning an error if the inputs are invalid.

§Params
  • axis: Optional axis to compute the cumulative minimum over. If unspecified the cumulative maximum of the flattened array is returned.
  • reverse: If true, the cumulative minimum is computed in reverse - defaults to false if unspecified.
  • inclusive: If true, the i-th element of the output includes the i-th element of the input - defaults to true if unspecified.
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [[5, 8], [4, 8]] -- cumulative min along the columns
let result = array.cummin(0, None, None).unwrap();
Source

pub fn cumprod_device( &self, axis: impl Into<Option<i32>>, reverse: impl Into<Option<bool>>, inclusive: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Return the cumulative product of the elements along the given axis returning an error if the inputs are invalid.

§Params
  • axis: Optional axis to compute the cumulative product over. If unspecified the cumulative maximum of the flattened array is returned.
  • reverse: If true, the cumulative product is computed in reverse - defaults to false if unspecified.
  • inclusive: If true, the i-th element of the output includes the i-th element of the input - defaults to true if unspecified.
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [[5, 8], [20, 72]] -- cumulative min along the columns
let result = array.cumprod(0, None, None).unwrap();
Source

pub fn cumprod( &self, axis: impl Into<Option<i32>>, reverse: impl Into<Option<bool>>, inclusive: impl Into<Option<bool>>, ) -> Result<Array>

Return the cumulative product of the elements along the given axis returning an error if the inputs are invalid.

§Params
  • axis: Optional axis to compute the cumulative product over. If unspecified the cumulative maximum of the flattened array is returned.
  • reverse: If true, the cumulative product is computed in reverse - defaults to false if unspecified.
  • inclusive: If true, the i-th element of the output includes the i-th element of the input - defaults to true if unspecified.
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [[5, 8], [20, 72]] -- cumulative min along the columns
let result = array.cumprod(0, None, None).unwrap();
Source

pub fn cumsum_device( &self, axis: impl Into<Option<i32>>, reverse: impl Into<Option<bool>>, inclusive: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Return the cumulative sum of the elements along the given axis returning an error if the inputs are invalid.

§Params
  • axis: Optional axis to compute the cumulative sum over. If unspecified the cumulative maximum of the flattened array is returned.
  • reverse: If true, the cumulative sum is computed in reverse - defaults to false if unspecified.
  • inclusive: If true, the i-th element of the output includes the i-th element of the input - defaults to true if unspecified.
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [[5, 8], [9, 17]] -- cumulative min along the columns
let result = array.cumsum(0, None, None).unwrap();
Source

pub fn cumsum( &self, axis: impl Into<Option<i32>>, reverse: impl Into<Option<bool>>, inclusive: impl Into<Option<bool>>, ) -> Result<Array>

Return the cumulative sum of the elements along the given axis returning an error if the inputs are invalid.

§Params
  • axis: Optional axis to compute the cumulative sum over. If unspecified the cumulative maximum of the flattened array is returned.
  • reverse: If true, the cumulative sum is computed in reverse - defaults to false if unspecified.
  • inclusive: If true, the i-th element of the output includes the i-th element of the input - defaults to true if unspecified.
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [[5, 8], [9, 17]] -- cumulative min along the columns
let result = array.cumsum(0, None, None).unwrap();
Source§

impl Array

Source

pub fn zeros_device<T: ArrayElement>( shape: &[i32], stream: impl AsRef<Stream>, ) -> Result<Array>

Construct an array of zeros returning an error if shape is invalid.

§Params
  • shape: Desired shape
§Example
use mlx_rs::{Array, StreamOrDevice};
Array::zeros_device::<f32>(&[5, 10], StreamOrDevice::default()).unwrap();
Source

pub fn zeros<T: ArrayElement>(shape: &[i32]) -> Result<Array>

Construct an array of zeros returning an error if shape is invalid.

§Params
  • shape: Desired shape
§Example
use mlx_rs::{Array, StreamOrDevice};
Array::zeros_device::<f32>(&[5, 10], StreamOrDevice::default()).unwrap();
Source

pub fn ones_device<T: ArrayElement>( shape: &[i32], stream: impl AsRef<Stream>, ) -> Result<Array>

Construct an array of ones returning an error if shape is invalid.

§Params
  • shape: Desired shape
§Example
use mlx_rs::{Array, StreamOrDevice};
Array::ones_device::<f32>(&[5, 10], StreamOrDevice::default()).unwrap();
Source

pub fn ones<T: ArrayElement>(shape: &[i32]) -> Result<Array>

Construct an array of ones returning an error if shape is invalid.

§Params
  • shape: Desired shape
§Example
use mlx_rs::{Array, StreamOrDevice};
Array::ones_device::<f32>(&[5, 10], StreamOrDevice::default()).unwrap();
Source

pub fn eye_device<T: ArrayElement>( n: i32, m: Option<i32>, k: Option<i32>, stream: impl AsRef<Stream>, ) -> Result<Array>

Create an identity matrix or a general diagonal matrix returning an error if params are invalid.

§Params
  • n: number of rows in the output
  • m: number of columns in the output – equal to n if not specified
  • k: index of the diagonal - defaults to 0 if not specified
§Example
use mlx_rs::{Array, StreamOrDevice};
//  create [10, 10] array with 1's on the diagonal.
let r = Array::eye_device::<f32>(10, None, None, StreamOrDevice::default()).unwrap();
Source

pub fn eye<T: ArrayElement>( n: i32, m: Option<i32>, k: Option<i32>, ) -> Result<Array>

Create an identity matrix or a general diagonal matrix returning an error if params are invalid.

§Params
  • n: number of rows in the output
  • m: number of columns in the output – equal to n if not specified
  • k: index of the diagonal - defaults to 0 if not specified
§Example
use mlx_rs::{Array, StreamOrDevice};
//  create [10, 10] array with 1's on the diagonal.
let r = Array::eye_device::<f32>(10, None, None, StreamOrDevice::default()).unwrap();
Source

pub fn full_device<T: ArrayElement>( shape: &[i32], values: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Construct an array with the given value returning an error if shape is invalid.

Constructs an array of size shape filled with values. If values is an Array it must be broadcasting to the given shape.

§Params
  • shape: shape of the output array
  • values: values to be broadcast into the array
§Example
use mlx_rs::{Array, StreamOrDevice, array};
//  create [5, 4] array filled with 7
let r = Array::full_device::<f32>(&[5, 4], array!(7.0f32), StreamOrDevice::default()).unwrap();
Source

pub fn full<T: ArrayElement>( shape: &[i32], values: impl AsRef<Array>, ) -> Result<Array>

Construct an array with the given value returning an error if shape is invalid.

Constructs an array of size shape filled with values. If values is an Array it must be broadcasting to the given shape.

§Params
  • shape: shape of the output array
  • values: values to be broadcast into the array
§Example
use mlx_rs::{Array, StreamOrDevice, array};
//  create [5, 4] array filled with 7
let r = Array::full_device::<f32>(&[5, 4], array!(7.0f32), StreamOrDevice::default()).unwrap();
Source

pub fn identity_device<T: ArrayElement>( n: i32, stream: impl AsRef<Stream>, ) -> Result<Array>

Create a square identity matrix returning an error if params are invalid.

§Params
  • n: number of rows and columns in the output
§Example
use mlx_rs::{Array, StreamOrDevice};
//  create [10, 10] array with 1's on the diagonal.
let r = Array::identity_device::<f32>(10, StreamOrDevice::default()).unwrap();
Source

pub fn identity<T: ArrayElement>(n: i32) -> Result<Array>

Create a square identity matrix returning an error if params are invalid.

§Params
  • n: number of rows and columns in the output
§Example
use mlx_rs::{Array, StreamOrDevice};
//  create [10, 10] array with 1's on the diagonal.
let r = Array::identity_device::<f32>(10, StreamOrDevice::default()).unwrap();
Source

pub fn arange_device<U, T>( start: impl Into<Option<U>>, stop: U, step: impl Into<Option<U>>, stream: impl AsRef<Stream>, ) -> Result<Array>
where U: NumCast, T: ArrayElement,

Generates ranges of numbers.

Generate numbers in the half-open interval [start, stop) in increments of step.

§Params
  • start: Starting value which defaults to 0.
  • stop: Stopping value.
  • step: Increment which defaults to 1.
§Example
use mlx_rs::{Array, StreamOrDevice};

// Create a 1-D array with values from 0 to 50
let r = Array::arange::<_, f32>(None, 50, None);
Source

pub fn arange<U, T>( start: impl Into<Option<U>>, stop: U, step: impl Into<Option<U>>, ) -> Result<Array>
where U: NumCast, T: ArrayElement,

Generates ranges of numbers.

Generate numbers in the half-open interval [start, stop) in increments of step.

§Params
  • start: Starting value which defaults to 0.
  • stop: Stopping value.
  • step: Increment which defaults to 1.
§Example
use mlx_rs::{Array, StreamOrDevice};

// Create a 1-D array with values from 0 to 50
let r = Array::arange::<_, f32>(None, 50, None);
Source

pub fn linspace_device<U, T>( start: U, stop: U, count: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Array>
where U: NumCast, T: ArrayElement,

Generate num evenly spaced numbers over interval [start, stop] returning an error if params are invalid.

§Params
  • start: start value
  • stop: stop value
  • count: number of samples – defaults to 50 if not specified
§Example
use mlx_rs::{Array, StreamOrDevice};
// Create a 50 element 1-D array with values from 0 to 50
let r = Array::linspace_device::<_, f32>(0, 50, None, StreamOrDevice::default()).unwrap();
Source

pub fn linspace<U, T>( start: U, stop: U, count: impl Into<Option<i32>>, ) -> Result<Array>
where U: NumCast, T: ArrayElement,

Generate num evenly spaced numbers over interval [start, stop] returning an error if params are invalid.

§Params
  • start: start value
  • stop: stop value
  • count: number of samples – defaults to 50 if not specified
§Example
use mlx_rs::{Array, StreamOrDevice};
// Create a 50 element 1-D array with values from 0 to 50
let r = Array::linspace_device::<_, f32>(0, 50, None, StreamOrDevice::default()).unwrap();
Source

pub fn repeat_device<T: ArrayElement>( array: Array, count: i32, axis: i32, stream: impl AsRef<Stream>, ) -> Result<Array>

Repeat an array along a specified axis returning an error if params are invalid.

§Params
  • array: array to repeat
  • count: number of times to repeat
  • axis: axis to repeat along
§Example
use mlx_rs::{Array, StreamOrDevice};
// repeat a [2, 2] array 4 times along axis 1
let source = Array::from_slice(&[0, 1, 2, 3], &[2, 2]);
let r = Array::repeat_device::<i32>(source, 4, 1, StreamOrDevice::default()).unwrap();
Source

pub fn repeat<T: ArrayElement>( array: Array, count: i32, axis: i32, ) -> Result<Array>

Repeat an array along a specified axis returning an error if params are invalid.

§Params
  • array: array to repeat
  • count: number of times to repeat
  • axis: axis to repeat along
§Example
use mlx_rs::{Array, StreamOrDevice};
// repeat a [2, 2] array 4 times along axis 1
let source = Array::from_slice(&[0, 1, 2, 3], &[2, 2]);
let r = Array::repeat_device::<i32>(source, 4, 1, StreamOrDevice::default()).unwrap();
Source

pub fn repeat_all_device<T: ArrayElement>( array: Array, count: i32, stream: impl AsRef<Stream>, ) -> Result<Array>

Repeat a flattened array along axis 0 returning an error if params are invalid.

§Params
  • array: array to repeat
  • count: number of times to repeat
§Example
use mlx_rs::{Array, StreamOrDevice};
// repeat a 4 element array 4 times along axis 0
let source = Array::from_slice(&[0, 1, 2, 3], &[2, 2]);
let r = Array::repeat_all_device::<i32>(source, 4, StreamOrDevice::default()).unwrap();
Source

pub fn repeat_all<T: ArrayElement>(array: Array, count: i32) -> Result<Array>

Repeat a flattened array along axis 0 returning an error if params are invalid.

§Params
  • array: array to repeat
  • count: number of times to repeat
§Example
use mlx_rs::{Array, StreamOrDevice};
// repeat a 4 element array 4 times along axis 0
let source = Array::from_slice(&[0, 1, 2, 3], &[2, 2]);
let r = Array::repeat_all_device::<i32>(source, 4, StreamOrDevice::default()).unwrap();
Source

pub fn tri_device<T: ArrayElement>( n: i32, m: Option<i32>, k: Option<i32>, stream: impl AsRef<Stream>, ) -> Result<Array>

An array with ones at and below the given diagonal and zeros elsewhere.

§Params
  • n: number of rows in the output
  • m: number of columns in the output – equal to n if not specified
  • k: index of the diagonal – defaults to 0 if not specified
§Example
use mlx_rs::{Array, StreamOrDevice};
// [5, 5] array with the lower triangle filled with 1s
let r = Array::tri_device::<f32>(5, None, None, StreamOrDevice::default());
Source

pub fn tri<T: ArrayElement>( n: i32, m: Option<i32>, k: Option<i32>, ) -> Result<Array>

An array with ones at and below the given diagonal and zeros elsewhere.

§Params
  • n: number of rows in the output
  • m: number of columns in the output – equal to n if not specified
  • k: index of the diagonal – defaults to 0 if not specified
§Example
use mlx_rs::{Array, StreamOrDevice};
// [5, 5] array with the lower triangle filled with 1s
let r = Array::tri_device::<f32>(5, None, None, StreamOrDevice::default());
Source§

impl Array

Source

pub fn load_numpy_device( path: impl AsRef<Path>, stream: impl AsRef<Stream>, ) -> Result<Array, IoError>

Load array from a binary file in .npy format.

§Params
  • path: path of file to load
  • stream: stream or device to evaluate on
Source

pub fn load_numpy(path: impl AsRef<Path>) -> Result<Array, IoError>

Load array from a binary file in .npy format.

§Params
  • path: path of file to load
  • stream: stream or device to evaluate on
Source

pub fn load_safetensors_device( path: impl AsRef<Path>, stream: impl AsRef<Stream>, ) -> Result<HashMap<String, Array>, IoError>

Load dictionary of MLXArray from a safetensors file.

§Params
  • path: path of file to load
  • stream: stream or device to evaluate on
Source

pub fn load_safetensors( path: impl AsRef<Path>, ) -> Result<HashMap<String, Array>, IoError>

Load dictionary of MLXArray from a safetensors file.

§Params
  • path: path of file to load
  • stream: stream or device to evaluate on
Source

pub fn load_safetensors_with_metadata_device( path: impl AsRef<Path>, stream: impl AsRef<Stream>, ) -> Result<(HashMap<String, Array>, HashMap<String, String>), IoError>

Load dictionary of MLXArray and metadata [String:String] from a safetensors file.

§Params
  • path: path of file to load
  • stream: stream or device to evaluate on
Source

pub fn load_safetensors_with_metadata( path: impl AsRef<Path>, ) -> Result<(HashMap<String, Array>, HashMap<String, String>), IoError>

Load dictionary of MLXArray and metadata [String:String] from a safetensors file.

§Params
  • path: path of file to load
  • stream: stream or device to evaluate on
Source

pub fn save_numpy(&self, path: impl AsRef<Path>) -> Result<(), IoError>

Save array to a binary file in .npyformat.

§Params
  • array: array to save
  • url: URL of file to load
Source

pub fn save_safetensors<'a, I, S, V>( arrays: I, metadata: impl Into<Option<&'a HashMap<String, String>>>, path: impl AsRef<Path>, ) -> Result<(), IoError>
where I: IntoIterator<Item = (S, V)>, S: AsRef<str>, V: AsRef<Array>,

Save dictionary of arrays in safetensors format.

§Params
  • arrays: arrays to save
  • metadata: metadata to save
  • path: path of file to save
  • stream: stream or device to evaluate on
Source§

impl Array

Source

pub fn eq_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise equality returning an error if the arrays are not broadcastable.

Equality comparison on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.eq(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true, true, true]
Source

pub fn eq(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise equality returning an error if the arrays are not broadcastable.

Equality comparison on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.eq(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true, true, true]
Source

pub fn le_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise less than or equal returning an error if the arrays are not broadcastable.

Less than or equal on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.le(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true, true, true]
Source

pub fn le(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise less than or equal returning an error if the arrays are not broadcastable.

Less than or equal on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.le(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true, true, true]
Source

pub fn ge_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise greater than or equal returning an error if the arrays are not broadcastable.

Greater than or equal on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.ge(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true, true, true]
Source

pub fn ge(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise greater than or equal returning an error if the arrays are not broadcastable.

Greater than or equal on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.ge(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true, true, true]
Source

pub fn ne_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise not equal returning an error if the arrays are not broadcastable.

Not equal on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.ne(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [false, false, false]
Source

pub fn ne(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise not equal returning an error if the arrays are not broadcastable.

Not equal on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.ne(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [false, false, false]
Source

pub fn lt_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise less than returning an error if the arrays are not broadcastable.

Less than on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.lt(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [false, false, false]
Source

pub fn lt(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise less than returning an error if the arrays are not broadcastable.

Less than on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.lt(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [false, false, false]
Source

pub fn gt_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise greater than returning an error if the arrays are not broadcastable.

Greater than on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.gt(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [false, false, false]
Source

pub fn gt(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise greater than returning an error if the arrays are not broadcastable.

Greater than on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[1, 2, 3], &[3]);
let b = Array::from_slice(&[1, 2, 3], &[3]);
let mut c = a.gt(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [false, false, false]
Source

pub fn logical_and_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise logical and returning an error if the arrays are not broadcastable.

Logical and on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[true, false, true], &[3]);
let b = Array::from_slice(&[true, true, false], &[3]);
let mut c = a.logical_and(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true, false, false]
Source

pub fn logical_and(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise logical and returning an error if the arrays are not broadcastable.

Logical and on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[true, false, true], &[3]);
let b = Array::from_slice(&[true, true, false], &[3]);
let mut c = a.logical_and(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true, false, false]
Source

pub fn logical_or_device( &self, other: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Element-wise logical or returning an error if the arrays are not broadcastable.

Logical or on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[true, false, true], &[3]);
let b = Array::from_slice(&[true, true, false], &[3]);
let mut c = a.logical_or(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true, true, true]
Source

pub fn logical_or(&self, other: impl AsRef<Array>) -> Result<Array>

Element-wise logical or returning an error if the arrays are not broadcastable.

Logical or on two arrays with broadcasting.

§Params
  • other: array to compare
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[true, false, true], &[3]);
let b = Array::from_slice(&[true, true, false], &[3]);
let mut c = a.logical_or(&b).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true, true, true]
Source

pub fn logical_not_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Unary element-wise logical not.

§Example
use mlx_rs::{Array, StreamOrDevice};
let a: Array = false.into();
let mut b = a.logical_not_device(StreamOrDevice::default()).unwrap();

let b_data: &[bool] = b.as_slice();
// b_data == [true]
Source

pub fn logical_not(&self) -> Result<Array>

Unary element-wise logical not.

§Example
use mlx_rs::{Array, StreamOrDevice};
let a: Array = false.into();
let mut b = a.logical_not_device(StreamOrDevice::default()).unwrap();

let b_data: &[bool] = b.as_slice();
// b_data == [true]
Source

pub fn all_close_device( &self, other: impl AsRef<Array>, rtol: impl Into<Option<f64>>, atol: impl Into<Option<f64>>, equal_nan: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Approximate comparison of two arrays returning an error if the inputs aren’t valid.

The arrays are considered equal if:

all(abs(a - b) <= (atol + rtol * abs(b)))
§Params
  • other: array to compare
  • rtol: relative tolerance = defaults to 1e-5 when None
  • atol: absolute tolerance - defaults to 1e-8 when None
  • equal_nan: whether to consider NaNs equal – default is false when None
§Example
use num_traits::Pow;
use mlx_rs::array;
let a = array!([0., 1., 2., 3.]).sqrt().unwrap();
let b = array!([0., 1., 2., 3.]).power(array!(0.5)).unwrap();
let mut c = a.all_close(&b, None, None, None).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true]
Source

pub fn all_close( &self, other: impl AsRef<Array>, rtol: impl Into<Option<f64>>, atol: impl Into<Option<f64>>, equal_nan: impl Into<Option<bool>>, ) -> Result<Array>

Approximate comparison of two arrays returning an error if the inputs aren’t valid.

The arrays are considered equal if:

all(abs(a - b) <= (atol + rtol * abs(b)))
§Params
  • other: array to compare
  • rtol: relative tolerance = defaults to 1e-5 when None
  • atol: absolute tolerance - defaults to 1e-8 when None
  • equal_nan: whether to consider NaNs equal – default is false when None
§Example
use num_traits::Pow;
use mlx_rs::array;
let a = array!([0., 1., 2., 3.]).sqrt().unwrap();
let b = array!([0., 1., 2., 3.]).power(array!(0.5)).unwrap();
let mut c = a.all_close(&b, None, None, None).unwrap();

let c_data: &[bool] = c.as_slice();
// c_data == [true]
Source

pub fn is_close_device( &self, other: impl AsRef<Array>, rtol: impl Into<Option<f64>>, atol: impl Into<Option<f64>>, equal_nan: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Returns a boolean array where two arrays are element-wise equal within a tolerance returning an error if the arrays are not broadcastable.

Infinite values are considered equal if they have the same sign, NaN values are not equal unless equalNAN is true.

Two values are considered close if:

abs(a - b) <= (atol + rtol * abs(b))

Unlike [self.array_eq] this function supports broadcasting.

Source

pub fn is_close( &self, other: impl AsRef<Array>, rtol: impl Into<Option<f64>>, atol: impl Into<Option<f64>>, equal_nan: impl Into<Option<bool>>, ) -> Result<Array>

Returns a boolean array where two arrays are element-wise equal within a tolerance returning an error if the arrays are not broadcastable.

Infinite values are considered equal if they have the same sign, NaN values are not equal unless equalNAN is true.

Two values are considered close if:

abs(a - b) <= (atol + rtol * abs(b))

Unlike [self.array_eq] this function supports broadcasting.

Source

pub fn array_eq_device( &self, other: impl AsRef<Array>, equal_nan: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Array equality check.

Compare two arrays for equality. Returns true iff the arrays have the same shape and their values are equal. The arrays need not have the same type to be considered equal.

§Params
  • other: array to compare
  • equal_nan: whether to consider NaNs equal – default is false when None
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[0, 1, 2, 3], &[4]);
let b = Array::from_slice(&[0., 1., 2., 3.], &[4]);

let c = a.array_eq(&b, None);
// c == [true]
Source

pub fn array_eq( &self, other: impl AsRef<Array>, equal_nan: impl Into<Option<bool>>, ) -> Result<Array>

Array equality check.

Compare two arrays for equality. Returns true iff the arrays have the same shape and their values are equal. The arrays need not have the same type to be considered equal.

§Params
  • other: array to compare
  • equal_nan: whether to consider NaNs equal – default is false when None
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[0, 1, 2, 3], &[4]);
let b = Array::from_slice(&[0., 1., 2., 3.], &[4]);

let c = a.array_eq(&b, None);
// c == [true]
Source

pub fn any_device<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

An or reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over – defaults to all axes if not provided
  • keep_dims: if true keep reduced axis as singleton dimension – defaults to false if not provided
§Example
use mlx_rs::Array;

let array = Array::from_slice(&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], &[3, 4]);

// will produce a scalar Array with true -- some of the values are non-zero
let all = array.any(None, None).unwrap();

// produces an Array([true, true, true, true]) -- all rows have non-zeros
let all_rows = array.any(&[0], None).unwrap();
Source

pub fn any<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, ) -> Result<Array>

An or reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over – defaults to all axes if not provided
  • keep_dims: if true keep reduced axis as singleton dimension – defaults to false if not provided
§Example
use mlx_rs::Array;

let array = Array::from_slice(&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], &[3, 4]);

// will produce a scalar Array with true -- some of the values are non-zero
let all = array.any(None, None).unwrap();

// produces an Array([true, true, true, true]) -- all rows have non-zeros
let all_rows = array.any(&[0], None).unwrap();
Source§

impl Array

Source

pub fn diag_device( &self, k: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Extract a diagonal or construct a diagonal matrix.

If self is 1-D then a diagonal matrix is constructed with self on the k-th diagonal. If self is 2-D then the k-th diagonal is returned.

§Params:
  • k: the diagonal to extract or construct
  • stream: stream or device to evaluate on
Source

pub fn diag(&self, k: impl Into<Option<i32>>) -> Result<Array>

Extract a diagonal or construct a diagonal matrix.

If self is 1-D then a diagonal matrix is constructed with self on the k-th diagonal. If self is 2-D then the k-th diagonal is returned.

§Params:
  • k: the diagonal to extract or construct
  • stream: stream or device to evaluate on
Source

pub fn diagonal_device( &self, offset: impl Into<Option<i32>>, axis1: impl Into<Option<i32>>, axis2: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Return specified diagonals.

If self is 2-D, then a 1-D array containing the diagonal at the given offset is returned.

If self has more than two dimensions, then axis1 and axis2 determine the 2D subarrays from which diagonals are extracted. The new shape is the original shape with axis1 and axis2 removed and a new dimension inserted at the end corresponding to the diagonal.

§Params:
  • offset: offset of the diagonal. Can be positive or negative
  • axis1: first axis of the 2-D sub-array from which the diagonals should be taken
  • axis2: second axis of the 2-D sub-array from which the diagonals should be taken
  • stream: stream or device to evaluate on
Source

pub fn diagonal( &self, offset: impl Into<Option<i32>>, axis1: impl Into<Option<i32>>, axis2: impl Into<Option<i32>>, ) -> Result<Array>

Return specified diagonals.

If self is 2-D, then a 1-D array containing the diagonal at the given offset is returned.

If self has more than two dimensions, then axis1 and axis2 determine the 2D subarrays from which diagonals are extracted. The new shape is the original shape with axis1 and axis2 removed and a new dimension inserted at the end corresponding to the diagonal.

§Params:
  • offset: offset of the diagonal. Can be positive or negative
  • axis1: first axis of the 2-D sub-array from which the diagonals should be taken
  • axis2: second axis of the 2-D sub-array from which the diagonals should be taken
  • stream: stream or device to evaluate on
Source

pub fn hadamard_transform_device( &self, scale: impl Into<Option<f32>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Perform the Walsh-Hadamard transform along the final axis.

Supports sizes n = m*2^k for m in (1, 12, 20, 28) and 2^k <= 8192 for DType/float32 and 2^k <= 16384 for DType/float16 and DType/bfloat16.

§Params
  • scale: scale the output by this factor – default is 1.0/sqrt(array.dim(-1))
  • stream: stream to evaluate on.
Source

pub fn hadamard_transform(&self, scale: impl Into<Option<f32>>) -> Result<Array>

Perform the Walsh-Hadamard transform along the final axis.

Supports sizes n = m*2^k for m in (1, 12, 20, 28) and 2^k <= 8192 for DType/float32 and 2^k <= 16384 for DType/float16 and DType/bfloat16.

§Params
  • scale: scale the output by this factor – default is 1.0/sqrt(array.dim(-1))
  • stream: stream to evaluate on.
Source§

impl Array

Source

pub fn all_device<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

An and reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: The axes to reduce over – defaults to all axes if not provided
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], &[3, 4]);
let mut b = a.all(&[0], None).unwrap();

let results: &[bool] = b.as_slice();
// results == [false, true, true, true]
Source

pub fn all<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, ) -> Result<Array>

An and reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: The axes to reduce over – defaults to all axes if not provided
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
§Example
use mlx_rs::Array;
let a = Array::from_slice(&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], &[3, 4]);
let mut b = a.all(&[0], None).unwrap();

let results: &[bool] = b.as_slice();
// results == [false, true, true, true]
Source

pub fn prod_device<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

A product reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [20, 72]
let result = array.prod(&[0], None).unwrap();
Source

pub fn prod<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, ) -> Result<Array>

A product reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [20, 72]
let result = array.prod(&[0], None).unwrap();
Source

pub fn max_device<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

A max reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [5, 9]
let result = array.max(&[0], None).unwrap();
Source

pub fn max<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, ) -> Result<Array>

A max reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [5, 9]
let result = array.max(&[0], None).unwrap();
Source

pub fn sum_device<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Sum reduce the array over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: if true, keep the reduces axes as singleton dimensions
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [9, 17]
let result = array.sum(&[0], None).unwrap();
Source

pub fn sum<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, ) -> Result<Array>

Sum reduce the array over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: if true, keep the reduces axes as singleton dimensions
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [9, 17]
let result = array.sum(&[0], None).unwrap();
Source

pub fn mean_device<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

A mean reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [4.5, 8.5]
let result = array.mean(&[0], None).unwrap();
Source

pub fn mean<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, ) -> Result<Array>

A mean reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [4.5, 8.5]
let result = array.mean(&[0], None).unwrap();
Source

pub fn min_device<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

A min reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [4, 8]
let result = array.min(&[0], None).unwrap();
Source

pub fn min<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, ) -> Result<Array>

A min reduction over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
§Example
use mlx_rs::Array;
let array = Array::from_slice(&[5, 8, 4, 9], &[2, 2]);

// result is [4, 8]
let result = array.min(&[0], None).unwrap();
Source

pub fn variance_device<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, ddof: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Compute the variance(s) over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: if true, keep the reduces axes as singleton dimensions
  • ddof: the divisor to compute the variance is N - ddof
Source

pub fn variance<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, ddof: impl Into<Option<i32>>, ) -> Result<Array>

Compute the variance(s) over the given axes returning an error if the axes are invalid.

§Params
  • axes: axes to reduce over
  • keep_dims: if true, keep the reduces axes as singleton dimensions
  • ddof: the divisor to compute the variance is N - ddof
Source

pub fn log_sum_exp_device<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, stream: impl AsRef<Stream>, ) -> Result<Array>

A log-sum-exp reduction over the given axes returning an error if the axes are invalid.

The log-sum-exp reduction is a numerically stable version of using the individual operations.

§Params
  • axes: axes to reduce over
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
Source

pub fn log_sum_exp<'a>( &self, axes: impl IntoOption<&'a [i32]>, keep_dims: impl Into<Option<bool>>, ) -> Result<Array>

A log-sum-exp reduction over the given axes returning an error if the axes are invalid.

The log-sum-exp reduction is a numerically stable version of using the individual operations.

§Params
  • axes: axes to reduce over
  • keep_dims: Whether to keep the reduced dimensions – defaults to false if not provided
Source§

impl Array

Source

pub fn expand_dims_device( &self, axes: &[i32], stream: impl AsRef<Stream>, ) -> Result<Array>

Source

pub fn expand_dims(&self, axes: &[i32]) -> Result<Array>

Source

pub fn flatten_device( &self, start_axis: impl Into<Option<i32>>, end_axis: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Array>

See flatten.

Source

pub fn flatten( &self, start_axis: impl Into<Option<i32>>, end_axis: impl Into<Option<i32>>, ) -> Result<Array>

See flatten.

Source

pub fn reshape_device( &self, shape: &[i32], stream: impl AsRef<Stream>, ) -> Result<Array>

See reshape.

Source

pub fn reshape(&self, shape: &[i32]) -> Result<Array>

See reshape.

Source

pub fn squeeze_device<'a>( &'a self, axes: impl IntoOption<&'a [i32]>, stream: impl AsRef<Stream>, ) -> Result<Array>

See squeeze.

Source

pub fn squeeze<'a>(&'a self, axes: impl IntoOption<&'a [i32]>) -> Result<Array>

See squeeze.

Source

pub fn as_strided_device<'a>( &'a self, shape: impl IntoOption<&'a [i32]>, strides: impl IntoOption<&'a [usize]>, offset: impl Into<Option<usize>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Source

pub fn as_strided<'a>( &'a self, shape: impl IntoOption<&'a [i32]>, strides: impl IntoOption<&'a [usize]>, offset: impl Into<Option<usize>>, ) -> Result<Array>

Source

pub fn at_least_1d_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Source

pub fn at_least_1d(&self) -> Result<Array>

Source

pub fn at_least_2d_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Source

pub fn at_least_2d(&self) -> Result<Array>

Source

pub fn at_least_3d_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Source

pub fn at_least_3d(&self) -> Result<Array>

Source

pub fn move_axis_device( &self, src: i32, dst: i32, stream: impl AsRef<Stream>, ) -> Result<Array>

Source

pub fn move_axis(&self, src: i32, dst: i32) -> Result<Array>

Source

pub fn split_device( &self, indices: &[i32], axis: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Vec<Array>>

See split

Source

pub fn split( &self, indices: &[i32], axis: impl Into<Option<i32>>, ) -> Result<Vec<Array>>

See split

Source

pub fn split_equal_device( &self, num_parts: i32, axis: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Vec<Array>>

Source

pub fn split_equal( &self, num_parts: i32, axis: impl Into<Option<i32>>, ) -> Result<Vec<Array>>

Source

pub fn swap_axes_device( &self, axis1: i32, axis2: i32, stream: impl AsRef<Stream>, ) -> Result<Array>

Source

pub fn swap_axes(&self, axis1: i32, axis2: i32) -> Result<Array>

Source

pub fn transpose_device( &self, axes: &[i32], stream: impl AsRef<Stream>, ) -> Result<Array>

Source

pub fn transpose(&self, axes: &[i32]) -> Result<Array>

Source

pub fn transpose_all_device(&self, stream: impl AsRef<Stream>) -> Result<Array>

Source

pub fn transpose_all(&self) -> Result<Array>

Source

pub fn t(&self) -> Array

transpose and unwrap the result.

Source§

impl Array

Source

pub fn take_device( &self, indices: impl AsRef<Array>, axis: i32, stream: impl AsRef<Stream>, ) -> Result<Array>

Take elements along an axis.

The elements are taken from indices along the specified axis. If the axis is not specified the array is treated as a flattened 1-D array prior to performing the take.

See Array::take_all for the flattened array.

§Params
  • indices: The indices to take from the array.
  • axis: The axis along which to take the elements.
Source

pub fn take(&self, indices: impl AsRef<Array>, axis: i32) -> Result<Array>

Take elements along an axis.

The elements are taken from indices along the specified axis. If the axis is not specified the array is treated as a flattened 1-D array prior to performing the take.

See Array::take_all for the flattened array.

§Params
  • indices: The indices to take from the array.
  • axis: The axis along which to take the elements.
Source

pub fn take_all_device( &self, indices: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>

Take elements from flattened 1-D array.

§Params
  • indices: The indices to take from the array.
Source

pub fn take_all(&self, indices: impl AsRef<Array>) -> Result<Array>

Take elements from flattened 1-D array.

§Params
  • indices: The indices to take from the array.
Source

pub fn take_along_axis_device( &self, indices: impl AsRef<Array>, axis: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Take values along an axis at the specified indices.

If no axis is specified, the array is flattened to 1D prior to the indexing operation.

§Params
  • indices: The indices to take from the array.
  • axis: Axis in the input to take the values from.
Source

pub fn take_along_axis( &self, indices: impl AsRef<Array>, axis: impl Into<Option<i32>>, ) -> Result<Array>

Take values along an axis at the specified indices.

If no axis is specified, the array is flattened to 1D prior to the indexing operation.

§Params
  • indices: The indices to take from the array.
  • axis: Axis in the input to take the values from.
Source

pub fn put_along_axis_device( &self, indices: impl AsRef<Array>, values: impl AsRef<Array>, axis: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Array>

Put values along an axis at the specified indices.

If no axis is specified, the array is flattened to 1D prior to the indexing operation.

§Params
  • indices: Indices array. These should be broadcastable with the input array excluding the axis dimension.
  • values: Values array. These should be broadcastable with the indices.
  • axis: Axis in the destination to put the values to.
  • stream: stream or device to evaluate on.
Source

pub fn put_along_axis( &self, indices: impl AsRef<Array>, values: impl AsRef<Array>, axis: impl Into<Option<i32>>, ) -> Result<Array>

Put values along an axis at the specified indices.

If no axis is specified, the array is flattened to 1D prior to the indexing operation.

§Params
  • indices: Indices array. These should be broadcastable with the input array excluding the axis dimension.
  • values: Values array. These should be broadcastable with the indices.
  • axis: Axis in the destination to put the values to.
  • stream: stream or device to evaluate on.

Trait Implementations§

Source§

impl<'a, 't: 'a, T> Add<T> for &'a Array
where T: ScalarOrArray<'t>,

Source§

type Output = Array

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, T> Add<T> for Array
where T: ScalarOrArray<'a>,

Source§

type Output = Array

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<&Array> for Array

Source§

fn add_assign(&mut self, rhs: &Self)

Performs the += operation. Read more
Source§

impl<T: Into<Array>> AddAssign<T> for Array

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl<'a> ArrayIndex<'a> for &'a Array

Source§

fn index_op(self) -> ArrayIndexOp<'a>

mlx allows out of bounds indexing.
Source§

impl<'a> ArrayIndex<'a> for Array

Source§

fn index_op(self) -> ArrayIndexOp<'a>

mlx allows out of bounds indexing.
Source§

impl AsRef<Array> for Array

Source§

fn as_ref(&self) -> &Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a, F, G> CallMut<&'a Array, Array, ()> for Compiled<F, G>
where F: FnMut(&Array) -> Array + 'a, G: FnMut(&[Array]) -> Vec<Array> + 'a,

Source§

fn call_mut(&mut self, args: &Array) -> Result<Array, Exception>

Calls the compiled function with the given arguments.
Source§

impl<'a, F, G> CallMut<&'a Array, Array, Exception> for Compiled<F, G>
where F: FnMut(&Array) -> Result<Array, Exception> + 'a, G: FnMut(&[Array]) -> Result<Vec<Array>, Exception> + 'a,

Source§

fn call_mut(&mut self, args: &Array) -> Result<Array, Exception>

Calls the compiled function with the given arguments.
Source§

impl<'a, F, G> CallMut<(&'a Array, &'a Array), Array, ()> for Compiled<F, G>
where F: FnMut((&Array, &Array)) -> Array + 'a, G: FnMut(&[Array]) -> Vec<Array> + 'a,

Source§

fn call_mut(&mut self, args: (&Array, &Array)) -> Result<Array, Exception>

Calls the compiled function with the given arguments.
Source§

impl<'a, F, G> CallMut<(&'a Array, &'a Array), Array, Exception> for Compiled<F, G>
where F: FnMut((&Array, &Array)) -> Result<Array, Exception> + 'a, G: FnMut(&[Array]) -> Result<Vec<Array>, Exception> + 'a,

Source§

fn call_mut(&mut self, args: (&Array, &Array)) -> Result<Array, Exception>

Calls the compiled function with the given arguments.
Source§

impl<'a, F, G> CallMut<(&'a Array, &'a Array, &'a Array), Array, ()> for Compiled<F, G>
where F: FnMut((&Array, &Array, &Array)) -> Array + 'a, G: FnMut(&[Array]) -> Vec<Array> + 'a,

Source§

fn call_mut( &mut self, args: (&Array, &Array, &Array), ) -> Result<Array, Exception>

Calls the compiled function with the given arguments.
Source§

impl<'a, F, G> CallMut<(&'a Array, &'a Array, &'a Array), Array, Exception> for Compiled<F, G>
where F: FnMut((&Array, &Array, &Array)) -> Result<Array, Exception> + 'a, G: FnMut(&[Array]) -> Result<Vec<Array>, Exception> + 'a,

Source§

fn call_mut( &mut self, args: (&Array, &Array, &Array), ) -> Result<Array, Exception>

Calls the compiled function with the given arguments.
Source§

impl<U, F, G> CallMutWithState<U, &Array, Array, ()> for Compiled<F, G>
where F: FnMut(&mut U, &Array) -> Array, G: FnMut(&mut U, &[Array]) -> Vec<Array>, U: Updatable,

Source§

fn call_mut(&mut self, state: &mut U, args: &Array) -> Result<Array, Exception>

Call the function with the given state and arguments.
Source§

impl<U, F, G> CallMutWithState<U, &Array, Array, Exception> for Compiled<F, G>

Source§

fn call_mut(&mut self, state: &mut U, args: &Array) -> Result<Array, Exception>

Call the function with the given state and arguments.
Source§

impl<U, F, G> CallMutWithState<U, (&Array, &Array), Array, ()> for Compiled<F, G>
where F: FnMut(&mut U, (&Array, &Array)) -> Array, G: FnMut(&mut U, &[Array]) -> Vec<Array>, U: Updatable,

Source§

fn call_mut( &mut self, state: &mut U, args: (&Array, &Array), ) -> Result<Array, Exception>

Call the function with the given state and arguments.
Source§

impl<U, F, G> CallMutWithState<U, (&Array, &Array), Array, Exception> for Compiled<F, G>

Source§

fn call_mut( &mut self, state: &mut U, args: (&Array, &Array), ) -> Result<Array, Exception>

Call the function with the given state and arguments.
Source§

impl<U, F, G> CallMutWithState<U, (&Array, &Array, &Array), Array, ()> for Compiled<F, G>
where F: FnMut(&mut U, (&Array, &Array, &Array)) -> Array, G: FnMut(&mut U, &[Array]) -> Vec<Array>, U: Updatable,

Source§

fn call_mut( &mut self, state: &mut U, args: (&Array, &Array, &Array), ) -> Result<Array, Exception>

Call the function with the given state and arguments.
Source§

impl<U, F, G> CallMutWithState<U, (&Array, &Array, &Array), Array, Exception> for Compiled<F, G>

Source§

fn call_mut( &mut self, state: &mut U, args: (&Array, &Array, &Array), ) -> Result<Array, Exception>

Call the function with the given state and arguments.
Source§

impl Clone for Array

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F> Compile<&Array, Array, ()> for F
where F: FnMut(&Array) -> Array + 'static,

Source§

type Args<'a> = &'a Array

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMut<Self::Args<'args>, Array, ()>

Compiles the function.
Source§

impl<F> Compile<&Array, Array, Exception> for F
where F: FnMut(&Array) -> Result<Array, Exception> + 'static,

Source§

type Args<'a> = &'a Array

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMut<Self::Args<'args>, Array, Exception>

Compiles the function.
Source§

impl<F> Compile<(&Array, &Array), Array, ()> for F
where F: FnMut((&Array, &Array)) -> Array + 'static,

Source§

type Args<'a> = (&'a Array, &'a Array)

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMut<Self::Args<'args>, Array, ()>

Compiles the function.
Source§

impl<F> Compile<(&Array, &Array), Array, Exception> for F
where F: FnMut((&Array, &Array)) -> Result<Array, Exception> + 'static,

Source§

type Args<'a> = (&'a Array, &'a Array)

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMut<Self::Args<'args>, Array, Exception>

Compiles the function.
Source§

impl<F> Compile<(&Array, &Array, &Array), Array, ()> for F
where F: FnMut((&Array, &Array, &Array)) -> Array + 'static,

Source§

type Args<'a> = (&'a Array, &'a Array, &'a Array)

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMut<Self::Args<'args>, Array, ()>

Compiles the function.
Source§

impl<F> Compile<(&Array, &Array, &Array), Array, Exception> for F
where F: FnMut((&Array, &Array, &Array)) -> Result<Array, Exception> + 'static,

Source§

type Args<'a> = (&'a Array, &'a Array, &'a Array)

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMut<Self::Args<'args>, Array, Exception>

Compiles the function.
Source§

impl<F, U> CompileWithState<U, &Array, Array, ()> for F
where F: FnMut(&mut U, &Array) -> Array + 'static, U: Updatable,

Source§

type Args<'a> = &'a Array

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMutWithState<U, Self::Args<'args>, Array, ()>

Compile the function.
Source§

impl<F, U> CompileWithState<U, &Array, Array, Exception> for F
where F: FnMut(&mut U, &Array) -> Result<Array, Exception> + 'static, U: Updatable,

Source§

type Args<'a> = &'a Array

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMutWithState<U, Self::Args<'args>, Array, Exception>

Compile the function.
Source§

impl<F, U> CompileWithState<U, (&Array, &Array), Array, ()> for F
where F: FnMut(&mut U, (&Array, &Array)) -> Array + 'static, U: Updatable,

Source§

type Args<'a> = (&'a Array, &'a Array)

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMutWithState<U, Self::Args<'args>, Array, ()>

Compile the function.
Source§

impl<F, U> CompileWithState<U, (&Array, &Array), Array, Exception> for F
where F: FnMut(&mut U, (&Array, &Array)) -> Result<Array, Exception> + 'static, U: Updatable,

Source§

type Args<'a> = (&'a Array, &'a Array)

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMutWithState<U, Self::Args<'args>, Array, Exception>

Compile the function.
Source§

impl<F, U> CompileWithState<U, (&Array, &Array, &Array), Array, ()> for F
where F: FnMut(&mut U, (&Array, &Array, &Array)) -> Array + 'static, U: Updatable,

Source§

type Args<'a> = (&'a Array, &'a Array, &'a Array)

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMutWithState<U, Self::Args<'args>, Array, ()>

Compile the function.
Source§

impl<F, U> CompileWithState<U, (&Array, &Array, &Array), Array, Exception> for F
where F: FnMut(&mut U, (&Array, &Array, &Array)) -> Result<Array, Exception> + 'static, U: Updatable,

Source§

type Args<'a> = (&'a Array, &'a Array, &'a Array)

The type of the arguments that the returned closure takes. Read more
Source§

fn compile<'args>( self, shapeless: bool, ) -> impl CallMutWithState<U, Self::Args<'args>, Array, Exception>

Compile the function.
Source§

impl Debug for Array

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Array

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, 't: 'a, T> Div<T> for &'a Array
where T: ScalarOrArray<'t>,

Source§

type Output = Array

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, T> Div<T> for Array
where T: ScalarOrArray<'a>,

Source§

type Output = Array

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign<&Array> for Array

Source§

fn div_assign(&mut self, rhs: &Self)

Performs the /= operation. Read more
Source§

impl<T: Into<Array>> DivAssign<T> for Array

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl Drop for Array

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a> From<&'a Array> for AlibiInput<'a>

Source§

fn from(attention_scores: &'a Array) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Array> for LstmInput<'a>

Source§

fn from(x: &'a Array) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Array> for RnnInput<'a>

Source§

fn from(x: &'a Array) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Array> for RopeInput<'a>

Source§

fn from(x: &'a Array) -> Self

Converts to this type from the input type.
Source§

impl From<Complex<f32>> for Array

Source§

fn from(value: complex64) -> Self

Converts to this type from the input type.
Source§

impl<T> From<T> for Array
where Array: FromNested<T>,

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Array

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Array

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Array

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl<T: ArrayElement + Copy> FromNested<&[&[&[T]]]> for Array

Source§

fn from_nested(data: &[&[&[T]]]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[&[&[T; N]; M]; O]> for Array

Source§

fn from_nested(data: &[&[&[T; N]; M]; O]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize> FromNested<&[&[[T; N]]]> for Array

Source§

fn from_nested(data: &[&[[T; N]]]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<&[&[[T; N]]; M]> for Array

Source§

fn from_nested(data: &[&[[T; N]]; M]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[&[[T; N]; M]; O]> for Array

Source§

fn from_nested(data: &[&[[T; N]; M]; O]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy> FromNested<&[&[T]]> for Array

Source§

fn from_nested(data: &[&[T]]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize> FromNested<&[&[T; N]]> for Array

Source§

fn from_nested(data: &[&[T; N]]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<&[&[T; N]; M]> for Array

Source§

fn from_nested(data: &[&[T; N]; M]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize> FromNested<&[[&[T]; N]]> for Array

Source§

fn from_nested(data: &[[&[T]; N]]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<&[[&[T]; N]; M]> for Array

Source§

fn from_nested(data: &[[&[T]; N]; M]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[[&[T; N]; M]; O]> for Array

Source§

fn from_nested(data: &[[&[T; N]; M]; O]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[[[T; N]; M]; O]> for Array

Source§

fn from_nested(data: &[[[T; N]; M]; O]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize> FromNested<&[[T; N]]> for Array

Source§

fn from_nested(data: &[[T; N]]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<&[[T; N]; M]> for Array

Source§

fn from_nested(data: &[[T; N]; M]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement> FromNested<&[T]> for Array

Source§

fn from_nested(data: &[T]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement, const N: usize> FromNested<&[T; N]> for Array

Source§

fn from_nested(data: &[T; N]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize> FromNested<[&[&[T]]; N]> for Array

Source§

fn from_nested(data: [&[&[T]]; N]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize> FromNested<[&[T]; N]> for Array

Source§

fn from_nested(data: [&[T]; N]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<[[&[T]; N]; M]> for Array

Source§

fn from_nested(data: [[&[T]; N]; M]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<[[[T; N]; M]; O]> for Array

Source§

fn from_nested(data: [[[T; N]; M]; O]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<[[T; N]; M]> for Array

Source§

fn from_nested(data: [[T; N]; M]) -> Self

Create an array from nested arrays or slices.
Source§

impl<T: ArrayElement, const N: usize> FromNested<[T; N]> for Array

Source§

fn from_nested(data: [T; N]) -> Self

Create an array from nested arrays or slices.
Source§

impl FromScalar<Complex<f32>> for Array

Source§

fn from_scalar(val: complex64) -> Array

Create an array from a scalar value.
Source§

impl FromScalar<bool> for Array

Source§

fn from_scalar(val: bool) -> Array

Create an array from a scalar value.
Source§

impl FromScalar<f32> for Array

Source§

fn from_scalar(val: f32) -> Array

Create an array from a scalar value.
Source§

impl FromScalar<i32> for Array

Source§

fn from_scalar(val: i32) -> Array

Create an array from a scalar value.
Source§

impl<'a, F> IntoGrad<'a, &[Array], Array, ()> for F
where F: FnMut(&[Array]) -> Array + 'a,

Source§

fn into_grad( self, argument_numbers: impl IntoOption<&'a [i32]>, ) -> impl FnMut(&[Array]) -> Result<Array> + 'a

Convert the function/closure into a closure that computes the gradient.
Source§

impl<'a, F> IntoGrad<'a, &[Array], Array, Exception> for F
where F: FnMut(&[Array]) -> Result<Array> + 'a,

Source§

fn into_grad( self, argument_numbers: impl IntoOption<&'a [i32]>, ) -> impl FnMut(&[Array]) -> Result<Array> + 'a

Convert the function/closure into a closure that computes the gradient.
Source§

impl<'a, F> IntoGrad<'a, &Array, Array, ()> for F
where F: FnMut(&Array) -> Array + 'a,

Source§

fn into_grad( self, argument_numbers: impl IntoOption<&'a [i32]>, ) -> impl FnMut(&Array) -> Result<Array> + 'a

Convert the function/closure into a closure that computes the gradient.
Source§

impl<'a, F> IntoGrad<'a, &Array, Array, Exception> for F
where F: FnMut(&Array) -> Result<Array> + 'a,

Source§

fn into_grad( self, argument_numbers: impl IntoOption<&'a [i32]>, ) -> impl FnMut(&Array) -> Result<Array> + 'a

Convert the function/closure into a closure that computes the gradient.
Source§

impl<'a, F> IntoGrad<'a, &Array, Vec<Array>, ()> for F
where F: FnMut(&Array) -> Vec<Array> + 'a,

Source§

fn into_grad( self, argument_numbers: impl IntoOption<&'a [i32]>, ) -> impl FnMut(&Array) -> Result<Vec<Array>> + 'a

Convert the function/closure into a closure that computes the gradient.
Source§

impl<'a, F> IntoGrad<'a, &Array, Vec<Array>, Exception> for F
where F: FnMut(&Array) -> Result<Vec<Array>> + 'a,

Source§

fn into_grad( self, argument_numbers: impl IntoOption<&'a [i32]>, ) -> impl FnMut(&Array) -> Result<Vec<Array>> + 'a

Convert the function/closure into a closure that computes the gradient.
Source§

impl<'a, F, M, Args> IntoModuleValueAndGrad<'a, M, Args, Array, ()> for F
where M: ModuleParameters + 'a, F: FnMut(&mut M, Args) -> Array + 'a, Args: Clone,

Source§

fn into_module_value_and_grad( self, ) -> impl FnMut(&mut M, Args) -> Result<(Array, FlattenedModuleParam), Exception> + 'a

Computes the valud and gradient of the passed function f(model, args) with regard to the model’s trainable parameters.
Source§

impl<'a, F, M, Args> IntoModuleValueAndGrad<'a, M, Args, Array, Exception> for F
where M: ModuleParameters + 'a, F: FnMut(&mut M, Args) -> Result<Array, Exception> + 'a, Args: Clone,

Source§

fn into_module_value_and_grad( self, ) -> impl FnMut(&mut M, Args) -> Result<(Array, FlattenedModuleParam), Exception> + 'a

Computes the valud and gradient of the passed function f(model, args) with regard to the model’s trainable parameters.
Source§

impl Module<&Array> for AvgPool1d

Source§

type Output = Array

Output type of the module.
Source§

type Error = Exception

Error type for the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for AvgPool2d

Source§

type Output = Array

Output type of the module.
Source§

type Error = Exception

Error type for the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for BatchNorm

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Bilinear

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Celu

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Conv1d

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Conv2d

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Conv3d

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for ConvTranspose1d

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for ConvTranspose2d

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for ConvTranspose3d

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Dropout

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Dropout2d

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Dropout3d

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Embedding

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Gelu

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Glu

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for GroupNorm

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for HardSwish

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for InstanceNorm

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for LayerNorm

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for LeakyRelu

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Linear

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for LogSigmoid

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for LogSoftmax

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for MaxPool1d

Source§

type Output = Array

Output type of the module.
Source§

type Error = Exception

Error type for the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for MaxPool2d

Source§

type Output = Array

Output type of the module.
Source§

type Error = Exception

Error type for the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Mish

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Pool

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Prelu

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for QuantizedEmbedding

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for QuantizedLinear

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Relu

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Relu6

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for RmsNorm

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Selu

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Sequential

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Sigmoid

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Silu

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Sinpe

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Self::Output, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _mode: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Softmax

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Softplus

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Softsign

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Step

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Tanh

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Array>

Forward pass of the module.
Source§

fn training_mode(&mut self, _: bool)

Set whether the module is in training mode. Read more
Source§

impl Module<&Array> for Upsample

Source§

type Error = Exception

Error type for the module.
Source§

type Output = Array

Output type of the module.
Source§

fn forward(&mut self, x: &Array) -> Result<Self::Output, Self::Error>

Forward pass of the module.
Source§

fn training_mode(&mut self, _mode: bool)

Set whether the module is in training mode. Read more
Source§

impl<'a, 't: 'a, T> Mul<T> for &'a Array
where T: ScalarOrArray<'t>,

Source§

type Output = Array

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<T> for Array
where T: ScalarOrArray<'a>,

Source§

type Output = Array

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<&Array> for Array

Source§

fn mul_assign(&mut self, rhs: &Self)

Performs the *= operation. Read more
Source§

impl<T: Into<Array>> MulAssign<T> for Array

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl Neg for &Array

Source§

type Output = Array

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Neg for Array

Source§

type Output = Array

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Not for &Array

Source§

type Output = Array

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Not for Array

Source§

type Output = Array

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl PartialEq for Array

Source§

fn eq(&self, other: &Self) -> bool

Array equality check.

Compare two arrays for equality. Returns true iff the arrays have the same shape and their values are equal. The arrays need not have the same type to be considered equal.

If you’re looking for element-wise equality, use the Array::eq() method.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 't: 'a, T> Pow<T> for &'a Array
where T: ScalarOrArray<'t>,

Source§

type Output = Array

The result after applying the operator.
Source§

fn pow(self, rhs: T) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<'a, T> Pow<T> for Array
where T: ScalarOrArray<'a>,

Source§

type Output = Array

The result after applying the operator.
Source§

fn pow(self, rhs: T) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<'a> Product<&'a Array> for Array

Source§

fn product<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl Product for Array

Source§

fn product<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<'a, 't: 'a, T> Rem<T> for &'a Array
where T: ScalarOrArray<'t>,

Source§

type Output = Array

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a, T> Rem<T> for Array
where T: ScalarOrArray<'a>,

Source§

type Output = Array

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> Self::Output

Performs the % operation. Read more
Source§

impl RemAssign<&Array> for Array

Source§

fn rem_assign(&mut self, rhs: &Self)

Performs the %= operation. Read more
Source§

impl<T: Into<Array>> RemAssign<T> for Array

Source§

fn rem_assign(&mut self, rhs: T)

Performs the %= operation. Read more
Source§

impl ScalarOrArray<'_> for Array

Source§

type Array = Array

The reference type of the array.
Source§

fn into_owned_or_ref_array(self) -> Array

Convert to an owned or reference array.
Source§

impl<'a> ScalarOrArray<'a> for &'a Array

Source§

type Array = &'a Array

The reference type of the array.
Source§

fn into_owned_or_ref_array(self) -> &'a Array

Convert to an owned or reference array.
Source§

impl<'a, 't: 'a, T> Sub<T> for &'a Array
where T: ScalarOrArray<'t>,

Source§

type Output = Array

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, T> Sub<T> for Array
where T: ScalarOrArray<'a>,

Source§

type Output = Array

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<&Array> for Array

Source§

fn sub_assign(&mut self, rhs: &Self)

Performs the -= operation. Read more
Source§

impl<T: Into<Array>> SubAssign<T> for Array

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl Sum for Array

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<'a, Val> TryIndexMutOp<&'a [ArrayIndexOp<'a>], Val> for Array
where Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: &'a [ArrayIndexOp<'a>], val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, A, Val> TryIndexMutOp<(A,), Val> for Array
where A: ArrayIndex<'a>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, (i): (A,), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, A, B, Val> TryIndexMutOp<(A, B), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, A, B, C, Val> TryIndexMutOp<(A, B, C), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, A, B, C, D, Val> TryIndexMutOp<(A, B, C, D), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, A, B, C, D, E, Val> TryIndexMutOp<(A, B, C, D, E), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, A, B, C, D, E, F, Val> TryIndexMutOp<(A, B, C, D, E, F), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, A, B, C, D, E, F, G, Val> TryIndexMutOp<(A, B, C, D, E, F, G), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, A, B, C, D, E, F, G, H, Val> TryIndexMutOp<(A, B, C, D, E, F, G, H), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, A, B, C, D, E, F, G, H, I, Val> TryIndexMutOp<(A, B, C, D, E, F, G, H, I), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H, I), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, A, B, C, D, E, F, G, H, I, J, Val> TryIndexMutOp<(A, B, C, D, E, F, G, H, I, J), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H, I, J), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, A, B, C, D, E, F, G, H, I, J, K, Val> TryIndexMutOp<(A, B, C, D, E, F, G, H, I, J, K), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H, I, J, K), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, A, B, C, D, E, F, G, H, I, J, K, L, Val> TryIndexMutOp<(A, B, C, D, E, F, G, H, I, J, K, L), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, L: ArrayIndex<'l>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H, I, J, K, L), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, A, B, C, D, E, F, G, H, I, J, K, L, M, Val> TryIndexMutOp<(A, B, C, D, E, F, G, H, I, J, K, L, M), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, L: ArrayIndex<'l>, M: ArrayIndex<'m>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H, I, J, K, L, M), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, A, B, C, D, E, F, G, H, I, J, K, L, M, N, Val> TryIndexMutOp<(A, B, C, D, E, F, G, H, I, J, K, L, M, N), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, L: ArrayIndex<'l>, M: ArrayIndex<'m>, N: ArrayIndex<'n>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H, I, J, K, L, M, N), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, Val> TryIndexMutOp<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, L: ArrayIndex<'l>, M: ArrayIndex<'m>, N: ArrayIndex<'n>, O: ArrayIndex<'o>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Val> TryIndexMutOp<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P), Val> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, L: ArrayIndex<'l>, M: ArrayIndex<'m>, N: ArrayIndex<'n>, O: ArrayIndex<'o>, P: ArrayIndex<'p>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<A, Val> TryIndexMutOp<A, Val> for Array
where for<'a> A: ArrayIndex<'a>, Val: AsRef<Array>,

Source§

fn try_index_mut_device( &mut self, i: A, val: Val, stream: impl AsRef<Stream>, ) -> Result<()>

Try to index the array with the given index and set the value.
Source§

fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>

Try to index the array with the given index and set the value.
Source§

impl<'a> TryIndexOp<&'a [ArrayIndexOp<'a>]> for Array

Source§

fn try_index_device( &self, i: &'a [ArrayIndexOp<'a>], stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, A> TryIndexOp<(A,)> for Array
where A: ArrayIndex<'a>,

Source§

fn try_index_device(&self, i: (A,), stream: impl AsRef<Stream>) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, A, B> TryIndexOp<(A, B)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>,

Source§

fn try_index_device( &self, i: (A, B), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, A, B, C> TryIndexOp<(A, B, C)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>,

Source§

fn try_index_device( &self, i: (A, B, C), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, A, B, C, D> TryIndexOp<(A, B, C, D)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>,

Source§

fn try_index_device( &self, i: (A, B, C, D), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, A, B, C, D, E> TryIndexOp<(A, B, C, D, E)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, A, B, C, D, E, F> TryIndexOp<(A, B, C, D, E, F)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, A, B, C, D, E, F, G> TryIndexOp<(A, B, C, D, E, F, G)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F, G), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, A, B, C, D, E, F, G, H> TryIndexOp<(A, B, C, D, E, F, G, H)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F, G, H), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, A, B, C, D, E, F, G, H, I> TryIndexOp<(A, B, C, D, E, F, G, H, I)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F, G, H, I), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, A, B, C, D, E, F, G, H, I, J> TryIndexOp<(A, B, C, D, E, F, G, H, I, J)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F, G, H, I, J), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, A, B, C, D, E, F, G, H, I, J, K> TryIndexOp<(A, B, C, D, E, F, G, H, I, J, K)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F, G, H, I, J, K), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, A, B, C, D, E, F, G, H, I, J, K, L> TryIndexOp<(A, B, C, D, E, F, G, H, I, J, K, L)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, L: ArrayIndex<'l>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F, G, H, I, J, K, L), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, A, B, C, D, E, F, G, H, I, J, K, L, M> TryIndexOp<(A, B, C, D, E, F, G, H, I, J, K, L, M)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, L: ArrayIndex<'l>, M: ArrayIndex<'m>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F, G, H, I, J, K, L, M), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, A, B, C, D, E, F, G, H, I, J, K, L, M, N> TryIndexOp<(A, B, C, D, E, F, G, H, I, J, K, L, M, N)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, L: ArrayIndex<'l>, M: ArrayIndex<'m>, N: ArrayIndex<'n>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F, G, H, I, J, K, L, M, N), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> TryIndexOp<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, L: ArrayIndex<'l>, M: ArrayIndex<'m>, N: ArrayIndex<'n>, O: ArrayIndex<'o>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> TryIndexOp<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)> for Array
where A: ArrayIndex<'a>, B: ArrayIndex<'b>, C: ArrayIndex<'c>, D: ArrayIndex<'d>, E: ArrayIndex<'e>, F: ArrayIndex<'f>, G: ArrayIndex<'g>, H: ArrayIndex<'h>, I: ArrayIndex<'i>, J: ArrayIndex<'j>, K: ArrayIndex<'k>, L: ArrayIndex<'l>, M: ArrayIndex<'m>, N: ArrayIndex<'n>, O: ArrayIndex<'o>, P: ArrayIndex<'p>,

Source§

fn try_index_device( &self, i: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P), stream: impl AsRef<Stream>, ) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl<'a, T> TryIndexOp<T> for Array
where T: ArrayIndex<'a>,

Source§

fn try_index_device(&self, i: T, stream: impl AsRef<Stream>) -> Result<Array>

Try to index the array with the given index.
Source§

fn try_index(&self, i: Idx) -> Result<Array>

Try to index the array with the given index.
Source§

impl Send for Array

Auto Trait Implementations§

§

impl Freeze for Array

§

impl RefUnwindSafe for Array

§

impl !Sync for Array

§

impl Unpin for Array

§

impl UnwindSafe for Array

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, Idx, Val> IndexMutOp<Idx, Val> for T
where T: TryIndexMutOp<Idx, Val>,

Source§

fn index_mut_device(&mut self, i: Idx, val: Val, stream: impl AsRef<Stream>)

Index the array with the given index and set the value.
Source§

fn index_mut(&mut self, i: Idx, val: Val)

Index the array with the given index and set the value.
Source§

impl<T, Idx> IndexOp<Idx> for T
where T: TryIndexOp<Idx>,

Source§

fn index_device(&self, i: Idx, stream: impl AsRef<Stream>) -> Array

Index the array with the given index.
Source§

fn index(&self, i: Idx) -> Array

Index the array with the given index.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoOption<T> for T

Source§

fn into_option(self) -> Option<T>

Convert into an Option.
Source§

impl<T> IntoStrideBy for T

Source§

fn stride_by(self, stride: i32) -> StrideBy<T>

Create a stride indexing operation.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,