pub struct Array { /* private fields */ }
Expand description
An n-dimensional array.
Implementations§
Source§impl Array
impl Array
Sourcepub unsafe fn from_ptr(c_array: mlx_array) -> Array
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
.
Sourcepub fn from_float(val: f32) -> Array
pub fn from_float(val: f32) -> Array
New array from a float scalar.
Sourcepub fn from_complex(val: complex64) -> Array
pub fn from_complex(val: complex64) -> Array
New array from a complex scalar.
Sourcepub fn from_slice<T: ArrayElement>(data: &[T], shape: &[i32]) -> Self
pub fn from_slice<T: ArrayElement>(data: &[T], shape: &[i32]) -> Self
Sourcepub unsafe fn from_raw_data(
data: *const c_void,
shape: &[i32],
dtype: Dtype,
) -> Self
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.
Sourcepub fn from_iter<I: IntoIterator<Item = T>, T: ArrayElement>(
iter: I,
shape: &[i32],
) -> Self
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[..]);
Sourcepub fn shape(&self) -> &[i32]
pub fn shape(&self) -> &[i32]
The shape of the array.
Returns: a pointer to the sizes of each dimension.
Sourcepub fn dim(&self, dim: i32) -> i32
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 anddim + ndim
overflows - Panics if the dimension is out of bounds.
Sourcepub fn item<T: ArrayElement>(&self) -> T
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.
Sourcepub fn try_item<T: ArrayElement>(&self) -> Result<T>
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.
Sourcepub unsafe fn as_slice_unchecked<T: ArrayElement>(&self) -> &[T]
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]);
}
Sourcepub fn try_as_slice<T: ArrayElement>(&self) -> Result<&[T], AsSliceError>
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[..]));
Sourcepub fn as_slice<T: ArrayElement>(&self) -> &[T]
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[..]);
Sourcepub fn deep_clone(&self) -> Self
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
impl Array
Sourcepub fn abs_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn abs(&self) -> Result<Array>
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]
Sourcepub fn add_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn add(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn subtract_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn subtract(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn negative_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn negative(&self) -> Result<Array>
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]
Sourcepub fn multiply_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn multiply(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub 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>
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
Sourcepub fn nan_to_num(
&self,
nan: impl IntoOption<f32>,
pos_inf: impl IntoOption<f32>,
neg_inf: impl IntoOption<f32>,
) -> Result<Array>
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
Sourcepub fn divide_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn divide(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn power_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn power(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn remainder_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn remainder(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn sqrt_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn sqrt(&self) -> Result<Array>
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]
Sourcepub fn cos_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn cos(&self) -> Result<Array>
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]
Sourcepub fn exp_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn exp(&self) -> Result<Array>
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]
Sourcepub fn floor_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn floor(&self) -> Result<Array>
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]
Sourcepub fn floor_divide_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn floor_divide(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn is_nan_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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
Sourcepub fn is_nan(&self) -> Result<Array>
pub fn is_nan(&self) -> Result<Array>
Return a boolean array indicating which elements are NaN.
§Params
- stream: stream or device to evaluate on
Sourcepub fn is_inf_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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
Sourcepub fn is_inf(&self) -> Result<Array>
pub fn is_inf(&self) -> Result<Array>
Return a boolean array indicating which elements are infinity.
§Params
- stream: stream or device to evaluate on
Sourcepub fn is_finite_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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
Sourcepub fn is_finite(&self) -> Result<Array>
pub fn is_finite(&self) -> Result<Array>
Return a boolean array indicating which elements are finite.
§Params
- stream: stream or device to evaluate on
Sourcepub fn is_neg_inf_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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
Sourcepub fn is_neg_inf(&self) -> Result<Array>
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
Sourcepub fn is_pos_inf_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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
Sourcepub fn is_pos_inf(&self) -> Result<Array>
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
Sourcepub fn log_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn log(&self) -> Result<Array>
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]
Sourcepub fn log2_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn log2(&self) -> Result<Array>
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]
Sourcepub fn log10_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn log10(&self) -> Result<Array>
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]
Sourcepub fn log1p_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn log1p(&self) -> Result<Array>
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]
Sourcepub fn matmul_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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);
Sourcepub fn matmul(&self, other: impl AsRef<Array>) -> Result<Array>
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);
Sourcepub fn reciprocal_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn reciprocal(&self) -> Result<Array>
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]
Sourcepub fn round_device(
&self,
decimals: impl Into<Option<i32>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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
Sourcepub fn round(&self, decimals: impl Into<Option<i32>>) -> Result<Array>
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§impl Array
impl Array
Sourcepub fn as_type_device<T: ArrayElement>(
&self,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]);
Sourcepub fn as_type<T: ArrayElement>(&self) -> Result<Array>
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]);
Sourcepub fn as_dtype_device(
&self,
dtype: Dtype,
stream: impl AsRef<Stream>,
) -> Result<Array>
pub fn as_dtype_device( &self, dtype: Dtype, stream: impl AsRef<Stream>, ) -> Result<Array>
Same as as_type
but with a Dtype
argument.
Sourcepub fn as_dtype(&self, dtype: Dtype) -> Result<Array>
pub fn as_dtype(&self, dtype: Dtype) -> Result<Array>
Same as as_type
but with a Dtype
argument.
Sourcepub fn view_device<T: ArrayElement>(
&self,
stream: impl AsRef<Stream>,
) -> Result<Array>
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.
Sourcepub fn view<T: ArrayElement>(&self) -> Result<Array>
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§impl Array
impl Array
Sourcepub 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>
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();
Sourcepub fn cummax(
&self,
axis: impl Into<Option<i32>>,
reverse: impl Into<Option<bool>>,
inclusive: impl Into<Option<bool>>,
) -> Result<Array>
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();
Sourcepub 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>
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();
Sourcepub fn cummin(
&self,
axis: impl Into<Option<i32>>,
reverse: impl Into<Option<bool>>,
inclusive: impl Into<Option<bool>>,
) -> Result<Array>
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();
Sourcepub 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>
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();
Sourcepub fn cumprod(
&self,
axis: impl Into<Option<i32>>,
reverse: impl Into<Option<bool>>,
inclusive: impl Into<Option<bool>>,
) -> Result<Array>
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();
Sourcepub 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>
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();
Sourcepub fn cumsum(
&self,
axis: impl Into<Option<i32>>,
reverse: impl Into<Option<bool>>,
inclusive: impl Into<Option<bool>>,
) -> Result<Array>
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
impl Array
Sourcepub fn zeros_device<T: ArrayElement>(
shape: &[i32],
stream: impl AsRef<Stream>,
) -> Result<Array>
pub fn zeros_device<T: ArrayElement>( shape: &[i32], stream: impl AsRef<Stream>, ) -> Result<Array>
Sourcepub fn ones_device<T: ArrayElement>(
shape: &[i32],
stream: impl AsRef<Stream>,
) -> Result<Array>
pub fn ones_device<T: ArrayElement>( shape: &[i32], stream: impl AsRef<Stream>, ) -> Result<Array>
Sourcepub fn eye_device<T: ArrayElement>(
n: i32,
m: Option<i32>,
k: Option<i32>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn eye<T: ArrayElement>(
n: i32,
m: Option<i32>,
k: Option<i32>,
) -> Result<Array>
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();
Sourcepub fn full_device<T: ArrayElement>(
shape: &[i32],
values: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn full<T: ArrayElement>(
shape: &[i32],
values: impl AsRef<Array>,
) -> Result<Array>
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();
Sourcepub fn identity_device<T: ArrayElement>(
n: i32,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn identity<T: ArrayElement>(n: i32) -> Result<Array>
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();
Sourcepub 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,
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 to0
.stop
: Stopping value.step
: Increment which defaults to1
.
§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);
Sourcepub fn arange<U, T>(
start: impl Into<Option<U>>,
stop: U,
step: impl Into<Option<U>>,
) -> Result<Array>where
U: NumCast,
T: ArrayElement,
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 to0
.stop
: Stopping value.step
: Increment which defaults to1
.
§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);
Sourcepub 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,
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();
Sourcepub fn linspace<U, T>(
start: U,
stop: U,
count: impl Into<Option<i32>>,
) -> Result<Array>where
U: NumCast,
T: ArrayElement,
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();
Sourcepub fn repeat_device<T: ArrayElement>(
array: Array,
count: i32,
axis: i32,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn repeat<T: ArrayElement>(
array: Array,
count: i32,
axis: i32,
) -> Result<Array>
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();
Sourcepub fn repeat_all_device<T: ArrayElement>(
array: Array,
count: i32,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn repeat_all<T: ArrayElement>(array: Array, count: i32) -> Result<Array>
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();
Sourcepub fn tri_device<T: ArrayElement>(
n: i32,
m: Option<i32>,
k: Option<i32>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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());
Sourcepub fn tri<T: ArrayElement>(
n: i32,
m: Option<i32>,
k: Option<i32>,
) -> Result<Array>
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
impl Array
Sourcepub fn load_numpy_device(
path: impl AsRef<Path>,
stream: impl AsRef<Stream>,
) -> Result<Array, IoError>
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
Sourcepub fn load_numpy(path: impl AsRef<Path>) -> Result<Array, IoError>
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
Sourcepub fn load_safetensors_device(
path: impl AsRef<Path>,
stream: impl AsRef<Stream>,
) -> Result<HashMap<String, Array>, IoError>
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
Sourcepub fn load_safetensors(
path: impl AsRef<Path>,
) -> Result<HashMap<String, Array>, IoError>
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
Sourcepub fn load_safetensors_with_metadata_device(
path: impl AsRef<Path>,
stream: impl AsRef<Stream>,
) -> Result<(HashMap<String, Array>, HashMap<String, String>), IoError>
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
Sourcepub fn load_safetensors_with_metadata(
path: impl AsRef<Path>,
) -> Result<(HashMap<String, Array>, HashMap<String, String>), IoError>
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
Sourcepub fn save_safetensors<'a, I, S, V>(
arrays: I,
metadata: impl Into<Option<&'a HashMap<String, String>>>,
path: impl AsRef<Path>,
) -> Result<(), IoError>
pub fn save_safetensors<'a, I, S, V>( arrays: I, metadata: impl Into<Option<&'a HashMap<String, String>>>, path: impl AsRef<Path>, ) -> Result<(), IoError>
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
impl Array
Sourcepub fn eq_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn eq(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn le_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn le(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn ge_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn ge(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn ne_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn ne(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn lt_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn lt(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn gt_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn gt(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn logical_and_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn logical_and(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn logical_or_device(
&self,
other: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn logical_or(&self, other: impl AsRef<Array>) -> Result<Array>
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]
Sourcepub fn logical_not_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
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]
Sourcepub fn logical_not(&self) -> Result<Array>
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]
Sourcepub 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>
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]
Sourcepub 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>
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]
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub fn array_eq_device(
&self,
other: impl AsRef<Array>,
equal_nan: impl Into<Option<bool>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn array_eq(
&self,
other: impl AsRef<Array>,
equal_nan: impl Into<Option<bool>>,
) -> Result<Array>
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]
Sourcepub fn any_device<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn any<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
) -> Result<Array>
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
impl Array
Sourcepub fn diag_device(
&self,
k: impl Into<Option<i32>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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 constructstream
: stream or device to evaluate on
Sourcepub fn diag(&self, k: impl Into<Option<i32>>) -> Result<Array>
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 constructstream
: stream or device to evaluate on
Sourcepub 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>
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 negativeaxis1
: first axis of the 2-D sub-array from which the diagonals should be takenaxis2
: second axis of the 2-D sub-array from which the diagonals should be takenstream
: stream or device to evaluate on
Sourcepub fn diagonal(
&self,
offset: impl Into<Option<i32>>,
axis1: impl Into<Option<i32>>,
axis2: impl Into<Option<i32>>,
) -> Result<Array>
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 negativeaxis1
: first axis of the 2-D sub-array from which the diagonals should be takenaxis2
: second axis of the 2-D sub-array from which the diagonals should be takenstream
: stream or device to evaluate on
Sourcepub fn hadamard_transform_device(
&self,
scale: impl Into<Option<f32>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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.
Sourcepub fn hadamard_transform(&self, scale: impl Into<Option<f32>>) -> Result<Array>
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
impl Array
Sourcepub fn all_device<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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]
Sourcepub fn all<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
) -> Result<Array>
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]
Sourcepub fn prod_device<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn prod<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
) -> Result<Array>
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();
Sourcepub fn max_device<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn max<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
) -> Result<Array>
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();
Sourcepub fn sum_device<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn sum<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
) -> Result<Array>
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();
Sourcepub fn mean_device<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn mean<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
) -> Result<Array>
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();
Sourcepub fn min_device<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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();
Sourcepub fn min<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
) -> Result<Array>
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();
Sourcepub 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>
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
Sourcepub fn variance<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
ddof: impl Into<Option<i32>>,
) -> Result<Array>
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
Sourcepub fn log_sum_exp_device<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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
Sourcepub fn log_sum_exp<'a>(
&self,
axes: impl IntoOption<&'a [i32]>,
keep_dims: impl Into<Option<bool>>,
) -> Result<Array>
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
impl Array
Sourcepub fn expand_dims_device(
&self,
axes: &[i32],
stream: impl AsRef<Stream>,
) -> Result<Array>
pub fn expand_dims_device( &self, axes: &[i32], stream: impl AsRef<Stream>, ) -> Result<Array>
See expand_dims
.
Sourcepub fn expand_dims(&self, axes: &[i32]) -> Result<Array>
pub fn expand_dims(&self, axes: &[i32]) -> Result<Array>
See expand_dims
.
Sourcepub fn flatten_device(
&self,
start_axis: impl Into<Option<i32>>,
end_axis: impl Into<Option<i32>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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
.
Sourcepub fn flatten(
&self,
start_axis: impl Into<Option<i32>>,
end_axis: impl Into<Option<i32>>,
) -> Result<Array>
pub fn flatten( &self, start_axis: impl Into<Option<i32>>, end_axis: impl Into<Option<i32>>, ) -> Result<Array>
See flatten
.
Sourcepub fn reshape_device(
&self,
shape: &[i32],
stream: impl AsRef<Stream>,
) -> Result<Array>
pub fn reshape_device( &self, shape: &[i32], stream: impl AsRef<Stream>, ) -> Result<Array>
See reshape
.
Sourcepub fn squeeze_device<'a>(
&'a self,
axes: impl IntoOption<&'a [i32]>,
stream: impl AsRef<Stream>,
) -> Result<Array>
pub fn squeeze_device<'a>( &'a self, axes: impl IntoOption<&'a [i32]>, stream: impl AsRef<Stream>, ) -> Result<Array>
See squeeze
.
Sourcepub 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>
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>
See as_strided
Sourcepub fn as_strided<'a>(
&'a self,
shape: impl IntoOption<&'a [i32]>,
strides: impl IntoOption<&'a [usize]>,
offset: impl Into<Option<usize>>,
) -> Result<Array>
pub fn as_strided<'a>( &'a self, shape: impl IntoOption<&'a [i32]>, strides: impl IntoOption<&'a [usize]>, offset: impl Into<Option<usize>>, ) -> Result<Array>
See as_strided
Sourcepub fn at_least_1d_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
pub fn at_least_1d_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
See at_least_1d
Sourcepub fn at_least_1d(&self) -> Result<Array>
pub fn at_least_1d(&self) -> Result<Array>
See at_least_1d
Sourcepub fn at_least_2d_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
pub fn at_least_2d_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
See at_least_2d
Sourcepub fn at_least_2d(&self) -> Result<Array>
pub fn at_least_2d(&self) -> Result<Array>
See at_least_2d
Sourcepub fn at_least_3d_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
pub fn at_least_3d_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
See at_least_3d
Sourcepub fn at_least_3d(&self) -> Result<Array>
pub fn at_least_3d(&self) -> Result<Array>
See at_least_3d
Sourcepub fn move_axis_device(
&self,
src: i32,
dst: i32,
stream: impl AsRef<Stream>,
) -> Result<Array>
pub fn move_axis_device( &self, src: i32, dst: i32, stream: impl AsRef<Stream>, ) -> Result<Array>
See move_axis
Sourcepub fn split_device(
&self,
indices: &[i32],
axis: impl Into<Option<i32>>,
stream: impl AsRef<Stream>,
) -> Result<Vec<Array>>
pub fn split_device( &self, indices: &[i32], axis: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Vec<Array>>
See split
Sourcepub fn split(
&self,
indices: &[i32],
axis: impl Into<Option<i32>>,
) -> Result<Vec<Array>>
pub fn split( &self, indices: &[i32], axis: impl Into<Option<i32>>, ) -> Result<Vec<Array>>
See split
Sourcepub fn split_equal_device(
&self,
num_parts: i32,
axis: impl Into<Option<i32>>,
stream: impl AsRef<Stream>,
) -> Result<Vec<Array>>
pub fn split_equal_device( &self, num_parts: i32, axis: impl Into<Option<i32>>, stream: impl AsRef<Stream>, ) -> Result<Vec<Array>>
See split_equal
Sourcepub fn split_equal(
&self,
num_parts: i32,
axis: impl Into<Option<i32>>,
) -> Result<Vec<Array>>
pub fn split_equal( &self, num_parts: i32, axis: impl Into<Option<i32>>, ) -> Result<Vec<Array>>
See split_equal
Sourcepub fn swap_axes_device(
&self,
axis1: i32,
axis2: i32,
stream: impl AsRef<Stream>,
) -> Result<Array>
pub fn swap_axes_device( &self, axis1: i32, axis2: i32, stream: impl AsRef<Stream>, ) -> Result<Array>
See swap_axes
Sourcepub fn transpose_device(
&self,
axes: &[i32],
stream: impl AsRef<Stream>,
) -> Result<Array>
pub fn transpose_device( &self, axes: &[i32], stream: impl AsRef<Stream>, ) -> Result<Array>
See transpose
Sourcepub fn transpose_all_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
pub fn transpose_all_device(&self, stream: impl AsRef<Stream>) -> Result<Array>
See transpose_all
Sourcepub fn transpose_all(&self) -> Result<Array>
pub fn transpose_all(&self) -> Result<Array>
See transpose_all
Source§impl Array
impl Array
Sourcepub fn take_device(
&self,
indices: impl AsRef<Array>,
axis: i32,
stream: impl AsRef<Stream>,
) -> Result<Array>
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.
Sourcepub fn take(&self, indices: impl AsRef<Array>, axis: i32) -> Result<Array>
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.
Sourcepub fn take_all_device(
&self,
indices: impl AsRef<Array>,
stream: impl AsRef<Stream>,
) -> Result<Array>
pub fn take_all_device( &self, indices: impl AsRef<Array>, stream: impl AsRef<Stream>, ) -> Result<Array>
Sourcepub fn take_along_axis_device(
&self,
indices: impl AsRef<Array>,
axis: impl Into<Option<i32>>,
stream: impl AsRef<Stream>,
) -> Result<Array>
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.
Sourcepub fn take_along_axis(
&self,
indices: impl AsRef<Array>,
axis: impl Into<Option<i32>>,
) -> Result<Array>
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.
Sourcepub 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>
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.
Sourcepub fn put_along_axis(
&self,
indices: impl AsRef<Array>,
values: impl AsRef<Array>,
axis: impl Into<Option<i32>>,
) -> Result<Array>
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 Arraywhere
T: ScalarOrArray<'t>,
impl<'a, 't: 'a, T> Add<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
Source§impl<'a, T> Add<T> for Arraywhere
T: ScalarOrArray<'a>,
impl<'a, T> Add<T> for Arraywhere
T: ScalarOrArray<'a>,
Source§impl AddAssign<&Array> for Array
impl AddAssign<&Array> for Array
Source§fn add_assign(&mut self, rhs: &Self)
fn add_assign(&mut self, rhs: &Self)
+=
operation. Read moreSource§impl<T: Into<Array>> AddAssign<T> for Array
impl<T: Into<Array>> AddAssign<T> for Array
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
+=
operation. Read moreSource§impl<'a> ArrayIndex<'a> for &'a Array
impl<'a> ArrayIndex<'a> for &'a Array
Source§fn index_op(self) -> ArrayIndexOp<'a>
fn index_op(self) -> ArrayIndexOp<'a>
mlx
allows out of bounds indexing.Source§impl<'a> ArrayIndex<'a> for Array
impl<'a> ArrayIndex<'a> for Array
Source§fn index_op(self) -> ArrayIndexOp<'a>
fn index_op(self) -> ArrayIndexOp<'a>
mlx
allows out of bounds indexing.Source§impl<'a, F, G> CallMut<(&'a Array, &'a Array, &'a Array), Array, Exception> for Compiled<F, G>
impl<'a, F, G> CallMut<(&'a Array, &'a Array, &'a Array), Array, Exception> for Compiled<F, G>
Source§impl<U, F, G> CallMutWithState<U, (&Array, &Array, &Array), Array, Exception> for Compiled<F, G>
impl<U, F, G> CallMutWithState<U, (&Array, &Array, &Array), Array, Exception> for Compiled<F, G>
Source§impl<'a, 't: 'a, T> Div<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
impl<'a, 't: 'a, T> Div<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
Source§impl<'a, T> Div<T> for Arraywhere
T: ScalarOrArray<'a>,
impl<'a, T> Div<T> for Arraywhere
T: ScalarOrArray<'a>,
Source§impl DivAssign<&Array> for Array
impl DivAssign<&Array> for Array
Source§fn div_assign(&mut self, rhs: &Self)
fn div_assign(&mut self, rhs: &Self)
/=
operation. Read moreSource§impl<T: Into<Array>> DivAssign<T> for Array
impl<T: Into<Array>> DivAssign<T> for Array
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
/=
operation. Read moreSource§impl<'a> From<&'a Array> for AlibiInput<'a>
impl<'a> From<&'a Array> for AlibiInput<'a>
Source§impl<T: ArrayElement + Copy> FromNested<&[&[&[T]]]> for Array
impl<T: ArrayElement + Copy> FromNested<&[&[&[T]]]> for Array
Source§fn from_nested(data: &[&[&[T]]]) -> Self
fn from_nested(data: &[&[&[T]]]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[&[&[T; N]; M]; O]> for Array
impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[&[&[T; N]; M]; O]> for Array
Source§impl<T: ArrayElement + Copy, const N: usize> FromNested<&[&[[T; N]]]> for Array
impl<T: ArrayElement + Copy, const N: usize> FromNested<&[&[[T; N]]]> for Array
Source§fn from_nested(data: &[&[[T; N]]]) -> Self
fn from_nested(data: &[&[[T; N]]]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<&[&[[T; N]]; M]> for Array
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
fn from_nested(data: &[&[[T; N]]; M]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[&[[T; N]; M]; O]> for Array
impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[&[[T; N]; M]; O]> for Array
Source§impl<T: ArrayElement + Copy> FromNested<&[&[T]]> for Array
impl<T: ArrayElement + Copy> FromNested<&[&[T]]> for Array
Source§fn from_nested(data: &[&[T]]) -> Self
fn from_nested(data: &[&[T]]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize> FromNested<&[&[T; N]]> for Array
impl<T: ArrayElement + Copy, const N: usize> FromNested<&[&[T; N]]> for Array
Source§fn from_nested(data: &[&[T; N]]) -> Self
fn from_nested(data: &[&[T; N]]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<&[&[T; N]; M]> for Array
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
fn from_nested(data: &[&[T; N]; M]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize> FromNested<&[[&[T]; N]]> for Array
impl<T: ArrayElement + Copy, const N: usize> FromNested<&[[&[T]; N]]> for Array
Source§fn from_nested(data: &[[&[T]; N]]) -> Self
fn from_nested(data: &[[&[T]; N]]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<&[[&[T]; N]; M]> for Array
impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<&[[&[T]; N]; M]> for Array
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[[&[T; N]; M]; O]> for Array
impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[[&[T; N]; M]; O]> for Array
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[[[T; N]; M]; O]> for Array
impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<&[[[T; N]; M]; O]> for Array
Source§impl<T: ArrayElement + Copy, const N: usize> FromNested<&[[T; N]]> for Array
impl<T: ArrayElement + Copy, const N: usize> FromNested<&[[T; N]]> for Array
Source§fn from_nested(data: &[[T; N]]) -> Self
fn from_nested(data: &[[T; N]]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<&[[T; N]; M]> for Array
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
fn from_nested(data: &[[T; N]; M]) -> Self
Source§impl<T: ArrayElement> FromNested<&[T]> for Array
impl<T: ArrayElement> FromNested<&[T]> for Array
Source§fn from_nested(data: &[T]) -> Self
fn from_nested(data: &[T]) -> Self
Source§impl<T: ArrayElement, const N: usize> FromNested<&[T; N]> for Array
impl<T: ArrayElement, const N: usize> FromNested<&[T; N]> for Array
Source§fn from_nested(data: &[T; N]) -> Self
fn from_nested(data: &[T; N]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize> FromNested<[&[&[T]]; N]> for Array
impl<T: ArrayElement + Copy, const N: usize> FromNested<[&[&[T]]; N]> for Array
Source§fn from_nested(data: [&[&[T]]; N]) -> Self
fn from_nested(data: [&[&[T]]; N]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize> FromNested<[&[T]; N]> for Array
impl<T: ArrayElement + Copy, const N: usize> FromNested<[&[T]; N]> for Array
Source§fn from_nested(data: [&[T]; N]) -> Self
fn from_nested(data: [&[T]; N]) -> Self
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<[[&[T]; N]; M]> for Array
impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<[[&[T]; N]; M]> for Array
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<[[[T; N]; M]; O]> for Array
impl<T: ArrayElement + Copy, const N: usize, const M: usize, const O: usize> FromNested<[[[T; N]; M]; O]> for Array
Source§impl<T: ArrayElement + Copy, const N: usize, const M: usize> FromNested<[[T; N]; M]> for Array
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
fn from_nested(data: [[T; N]; M]) -> Self
Source§impl<T: ArrayElement, const N: usize> FromNested<[T; N]> for Array
impl<T: ArrayElement, const N: usize> FromNested<[T; N]> for Array
Source§fn from_nested(data: [T; N]) -> Self
fn from_nested(data: [T; N]) -> Self
Source§impl FromScalar<Complex<f32>> for Array
impl FromScalar<Complex<f32>> for Array
Source§fn from_scalar(val: complex64) -> Array
fn from_scalar(val: complex64) -> Array
Source§impl FromScalar<bool> for Array
impl FromScalar<bool> for Array
Source§fn from_scalar(val: bool) -> Array
fn from_scalar(val: bool) -> Array
Source§impl FromScalar<f32> for Array
impl FromScalar<f32> for Array
Source§fn from_scalar(val: f32) -> Array
fn from_scalar(val: f32) -> Array
Source§impl FromScalar<i32> for Array
impl FromScalar<i32> for Array
Source§fn from_scalar(val: i32) -> Array
fn from_scalar(val: i32) -> Array
Source§impl<'a, F, M, Args> IntoModuleValueAndGrad<'a, M, Args, Array, ()> for F
impl<'a, F, M, Args> IntoModuleValueAndGrad<'a, M, Args, Array, ()> for F
Source§fn into_module_value_and_grad(
self,
) -> impl FnMut(&mut M, Args) -> Result<(Array, FlattenedModuleParam), Exception> + 'a
fn into_module_value_and_grad( self, ) -> impl FnMut(&mut M, Args) -> Result<(Array, FlattenedModuleParam), Exception> + 'a
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
impl<'a, F, M, Args> IntoModuleValueAndGrad<'a, M, Args, Array, Exception> for F
Source§fn into_module_value_and_grad(
self,
) -> impl FnMut(&mut M, Args) -> Result<(Array, FlattenedModuleParam), Exception> + 'a
fn into_module_value_and_grad( self, ) -> impl FnMut(&mut M, Args) -> Result<(Array, FlattenedModuleParam), Exception> + 'a
f(model, args)
with regard to the
model’s trainable parameters.Source§impl Module<&Array> for AvgPool1d
impl Module<&Array> for AvgPool1d
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for AvgPool2d
impl Module<&Array> for AvgPool2d
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for BatchNorm
impl Module<&Array> for BatchNorm
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for ConvTranspose1d
impl Module<&Array> for ConvTranspose1d
Source§impl Module<&Array> for ConvTranspose2d
impl Module<&Array> for ConvTranspose2d
Source§impl Module<&Array> for ConvTranspose3d
impl Module<&Array> for ConvTranspose3d
Source§impl Module<&Array> for Dropout
impl Module<&Array> for Dropout
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for Dropout2d
impl Module<&Array> for Dropout2d
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for Dropout3d
impl Module<&Array> for Dropout3d
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for Embedding
impl Module<&Array> for Embedding
Source§fn training_mode(&mut self, _mode: bool)
fn training_mode(&mut self, _mode: bool)
Source§impl Module<&Array> for GroupNorm
impl Module<&Array> for GroupNorm
Source§fn training_mode(&mut self, _mode: bool)
fn training_mode(&mut self, _mode: bool)
Source§impl Module<&Array> for InstanceNorm
impl Module<&Array> for InstanceNorm
Source§fn training_mode(&mut self, _mode: bool)
fn training_mode(&mut self, _mode: bool)
Source§impl Module<&Array> for LayerNorm
impl Module<&Array> for LayerNorm
Source§fn training_mode(&mut self, _mode: bool)
fn training_mode(&mut self, _mode: bool)
Source§impl Module<&Array> for LogSigmoid
impl Module<&Array> for LogSigmoid
Source§impl Module<&Array> for LogSoftmax
impl Module<&Array> for LogSoftmax
Source§impl Module<&Array> for MaxPool1d
impl Module<&Array> for MaxPool1d
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for MaxPool2d
impl Module<&Array> for MaxPool2d
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for Pool
impl Module<&Array> for Pool
Source§fn training_mode(&mut self, _mode: bool)
fn training_mode(&mut self, _mode: bool)
Source§impl Module<&Array> for QuantizedEmbedding
impl Module<&Array> for QuantizedEmbedding
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for QuantizedLinear
impl Module<&Array> for QuantizedLinear
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for RmsNorm
impl Module<&Array> for RmsNorm
Source§fn training_mode(&mut self, _mode: bool)
fn training_mode(&mut self, _mode: bool)
Source§impl Module<&Array> for Sequential
impl Module<&Array> for Sequential
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl Module<&Array> for Sinpe
impl Module<&Array> for Sinpe
Source§impl Module<&Array> for Upsample
impl Module<&Array> for Upsample
Source§impl<'a, 't: 'a, T> Mul<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
impl<'a, 't: 'a, T> Mul<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
Source§impl<'a, T> Mul<T> for Arraywhere
T: ScalarOrArray<'a>,
impl<'a, T> Mul<T> for Arraywhere
T: ScalarOrArray<'a>,
Source§impl MulAssign<&Array> for Array
impl MulAssign<&Array> for Array
Source§fn mul_assign(&mut self, rhs: &Self)
fn mul_assign(&mut self, rhs: &Self)
*=
operation. Read moreSource§impl<T: Into<Array>> MulAssign<T> for Array
impl<T: Into<Array>> MulAssign<T> for Array
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*=
operation. Read moreSource§impl PartialEq for Array
impl PartialEq for Array
Source§fn eq(&self, other: &Self) -> bool
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.
Source§impl<'a, 't: 'a, T> Pow<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
impl<'a, 't: 'a, T> Pow<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
Source§impl<'a, T> Pow<T> for Arraywhere
T: ScalarOrArray<'a>,
impl<'a, T> Pow<T> for Arraywhere
T: ScalarOrArray<'a>,
Source§impl<'a, 't: 'a, T> Rem<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
impl<'a, 't: 'a, T> Rem<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
Source§impl<'a, T> Rem<T> for Arraywhere
T: ScalarOrArray<'a>,
impl<'a, T> Rem<T> for Arraywhere
T: ScalarOrArray<'a>,
Source§impl RemAssign<&Array> for Array
impl RemAssign<&Array> for Array
Source§fn rem_assign(&mut self, rhs: &Self)
fn rem_assign(&mut self, rhs: &Self)
%=
operation. Read moreSource§impl<T: Into<Array>> RemAssign<T> for Array
impl<T: Into<Array>> RemAssign<T> for Array
Source§fn rem_assign(&mut self, rhs: T)
fn rem_assign(&mut self, rhs: T)
%=
operation. Read moreSource§impl ScalarOrArray<'_> for Array
impl ScalarOrArray<'_> for Array
Source§impl<'a> ScalarOrArray<'a> for &'a Array
impl<'a> ScalarOrArray<'a> for &'a Array
Source§impl<'a, 't: 'a, T> Sub<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
impl<'a, 't: 'a, T> Sub<T> for &'a Arraywhere
T: ScalarOrArray<'t>,
Source§impl<'a, T> Sub<T> for Arraywhere
T: ScalarOrArray<'a>,
impl<'a, T> Sub<T> for Arraywhere
T: ScalarOrArray<'a>,
Source§impl SubAssign<&Array> for Array
impl SubAssign<&Array> for Array
Source§fn sub_assign(&mut self, rhs: &Self)
fn sub_assign(&mut self, rhs: &Self)
-=
operation. Read moreSource§impl<T: Into<Array>> SubAssign<T> for Array
impl<T: Into<Array>> SubAssign<T> for Array
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
-=
operation. Read moreSource§impl<'a, Val> TryIndexMutOp<&'a [ArrayIndexOp<'a>], Val> for Array
impl<'a, Val> TryIndexMutOp<&'a [ArrayIndexOp<'a>], Val> for Array
Source§fn try_index_mut_device(
&mut self,
i: &'a [ArrayIndexOp<'a>],
val: Val,
stream: impl AsRef<Stream>,
) -> Result<()>
fn try_index_mut_device( &mut self, i: &'a [ArrayIndexOp<'a>], val: Val, stream: impl AsRef<Stream>, ) -> Result<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
Source§impl<'a, A, Val> TryIndexMutOp<(A,), Val> for Array
impl<'a, A, Val> TryIndexMutOp<(A,), Val> for Array
Source§impl<'a, 'b, A, B, Val> TryIndexMutOp<(A, B), Val> for Array
impl<'a, 'b, A, B, Val> TryIndexMutOp<(A, B), Val> for Array
Source§impl<'a, 'b, 'c, A, B, C, Val> TryIndexMutOp<(A, B, C), Val> for Array
impl<'a, 'b, 'c, A, B, C, Val> TryIndexMutOp<(A, B, C), Val> for Array
Source§fn try_index_mut_device(
&mut self,
i: (A, B, C),
val: Val,
stream: impl AsRef<Stream>,
) -> Result<()>
fn try_index_mut_device( &mut self, i: (A, B, C), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
Source§impl<'a, 'b, 'c, 'd, A, B, C, D, Val> TryIndexMutOp<(A, B, C, D), Val> for Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
Val: AsRef<Array>,
impl<'a, 'b, 'c, 'd, A, B, C, D, Val> TryIndexMutOp<(A, B, C, D), Val> for Arraywhere
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<()>
fn try_index_mut_device( &mut self, i: (A, B, C, D), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
Source§impl<'a, 'b, 'c, 'd, 'e, A, B, C, D, E, Val> TryIndexMutOp<(A, B, C, D, E), Val> for Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
E: ArrayIndex<'e>,
Val: AsRef<Array>,
impl<'a, 'b, 'c, 'd, 'e, A, B, C, D, E, Val> TryIndexMutOp<(A, B, C, D, E), Val> for Arraywhere
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<()>
fn try_index_mut_device( &mut self, i: (A, B, C, D, E), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
Source§impl<'a, 'b, 'c, 'd, 'e, 'f, A, B, C, D, E, F, Val> TryIndexMutOp<(A, B, C, D, E, F), Val> for Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
E: ArrayIndex<'e>,
F: ArrayIndex<'f>,
Val: AsRef<Array>,
impl<'a, 'b, 'c, 'd, 'e, 'f, A, B, C, D, E, F, Val> TryIndexMutOp<(A, B, C, D, E, F), Val> for Arraywhere
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<()>
fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
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 Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
E: ArrayIndex<'e>,
F: ArrayIndex<'f>,
G: ArrayIndex<'g>,
Val: AsRef<Array>,
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 Arraywhere
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<()>
fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
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 Arraywhere
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>,
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 Arraywhere
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<()>
fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
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 Arraywhere
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>,
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 Arraywhere
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<()>
fn try_index_mut_device( &mut self, i: (A, B, C, D, E, F, G, H, I), val: Val, stream: impl AsRef<Stream>, ) -> Result<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
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 Arraywhere
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>,
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 Arraywhere
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<()>
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<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
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 Arraywhere
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>,
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 Arraywhere
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<()>
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<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
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 Arraywhere
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>,
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 Arraywhere
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<()>
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<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
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 Arraywhere
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>,
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 Arraywhere
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<()>
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<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
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 Arraywhere
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>,
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 Arraywhere
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<()>
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<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
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 Arraywhere
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>,
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 Arraywhere
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<()>
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<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
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 Arraywhere
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>,
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 Arraywhere
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<()>
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<()>
Source§fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
fn try_index_mut(&mut self, i: Idx, val: Val) -> Result<()>
Source§impl<A, Val> TryIndexMutOp<A, Val> for Array
impl<A, Val> TryIndexMutOp<A, Val> for Array
Source§impl<'a> TryIndexOp<&'a [ArrayIndexOp<'a>]> for Array
impl<'a> TryIndexOp<&'a [ArrayIndexOp<'a>]> for Array
Source§impl<'a, A> TryIndexOp<(A,)> for Arraywhere
A: ArrayIndex<'a>,
impl<'a, A> TryIndexOp<(A,)> for Arraywhere
A: ArrayIndex<'a>,
Source§impl<'a, 'b, A, B> TryIndexOp<(A, B)> for Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
impl<'a, 'b, A, B> TryIndexOp<(A, B)> for Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
Source§impl<'a, 'b, 'c, A, B, C> TryIndexOp<(A, B, C)> for Array
impl<'a, 'b, 'c, A, B, C> TryIndexOp<(A, B, C)> for Array
Source§impl<'a, 'b, 'c, 'd, A, B, C, D> TryIndexOp<(A, B, C, D)> for Array
impl<'a, 'b, 'c, 'd, A, B, C, D> TryIndexOp<(A, B, C, D)> for Array
Source§impl<'a, 'b, 'c, 'd, 'e, A, B, C, D, E> TryIndexOp<(A, B, C, D, E)> for Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
E: ArrayIndex<'e>,
impl<'a, 'b, 'c, 'd, 'e, A, B, C, D, E> TryIndexOp<(A, B, C, D, E)> for Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
E: ArrayIndex<'e>,
Source§impl<'a, 'b, 'c, 'd, 'e, 'f, A, B, C, D, E, F> TryIndexOp<(A, B, C, D, E, F)> for Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
E: ArrayIndex<'e>,
F: ArrayIndex<'f>,
impl<'a, 'b, 'c, 'd, 'e, 'f, A, B, C, D, E, F> TryIndexOp<(A, B, C, D, E, F)> for Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
E: ArrayIndex<'e>,
F: ArrayIndex<'f>,
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 Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
E: ArrayIndex<'e>,
F: ArrayIndex<'f>,
G: ArrayIndex<'g>,
impl<'a, 'b, 'c, 'd, 'e, 'f, 'g, A, B, C, D, E, F, G> TryIndexOp<(A, B, C, D, E, F, G)> for Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
E: ArrayIndex<'e>,
F: ArrayIndex<'f>,
G: ArrayIndex<'g>,
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 Arraywhere
A: ArrayIndex<'a>,
B: ArrayIndex<'b>,
C: ArrayIndex<'c>,
D: ArrayIndex<'d>,
E: ArrayIndex<'e>,
F: ArrayIndex<'f>,
G: ArrayIndex<'g>,
H: ArrayIndex<'h>,
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 Arraywhere
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§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 Arraywhere
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>,
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 Arraywhere
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§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 Arraywhere
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>,
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 Arraywhere
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§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 Arraywhere
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>,
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 Arraywhere
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§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 Arraywhere
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>,
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 Arraywhere
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§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 Arraywhere
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>,
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 Arraywhere
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§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 Arraywhere
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>,
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 Arraywhere
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§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 Arraywhere
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>,
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 Arraywhere
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§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 Arraywhere
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>,
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 Arraywhere
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§impl<'a, T> TryIndexOp<T> for Arraywhere
T: ArrayIndex<'a>,
impl<'a, T> TryIndexOp<T> for Arraywhere
T: ArrayIndex<'a>,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, Idx, Val> IndexMutOp<Idx, Val> for Twhere
T: TryIndexMutOp<Idx, Val>,
impl<T, Idx, Val> IndexMutOp<Idx, Val> for Twhere
T: TryIndexMutOp<Idx, Val>,
Source§impl<T, Idx> IndexOp<Idx> for Twhere
T: TryIndexOp<Idx>,
impl<T, Idx> IndexOp<Idx> for Twhere
T: TryIndexOp<Idx>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Option
.