Trait ArraySearch

Source
pub trait ArraySearch<T: ArrayElement>
where Self: Sized + Clone,
{ // Required methods fn argmax( &self, axis: Option<isize>, keepdims: Option<bool>, ) -> Result<Array<usize>, ArrayError>; fn argmin( &self, axis: Option<isize>, keepdims: Option<bool>, ) -> Result<Array<usize>, ArrayError>; }
Expand description

ArrayTrait - Array Search functions

Required Methods§

Source

fn argmax( &self, axis: Option<isize>, keepdims: Option<bool>, ) -> Result<Array<usize>, ArrayError>

Returns the indices of the maximum values along an axis.

§Arguments
  • axis - axis along which to search. if None, array is flattened
  • keepdims - if true, the result will broadcast correctly against the input
§Examples
use arr_rs::prelude::*;

let arr = array!(i32, [[10, 11, 12], [13, 14, 15]]);
assert_eq!(array!(usize, [5]), arr.argmax(None, None));
let arr = array!(f64, [[f64::NAN, 4.], [2., 3.]]);
assert_eq!(array!(usize, [0]), arr.argmax(None, None));
§Errors

may returns ArrayError

Source

fn argmin( &self, axis: Option<isize>, keepdims: Option<bool>, ) -> Result<Array<usize>, ArrayError>

Returns the indices of the minimum values along an axis.

§Arguments
  • axis - axis along which to search. if None, array is flattened
  • keepdims - if true, the result will broadcast correctly against the input
§Examples
use arr_rs::prelude::*;

let arr = array!(i32, [[10, 11, 12], [13, 14, 15]]);
assert_eq!(array!(usize, [0]), arr.argmin(None, None));
assert_eq!(array!(usize, [0, 0, 0]), arr.argmin(Some(0), None));
assert_eq!(array!(usize, [0, 0]), arr.argmin(Some(1), None));
let arr = array!(f64, [[f64::NAN, 4.], [2., 3.]]);
assert_eq!(array!(usize, [0]), arr.argmin(None, None));
assert_eq!(array!(usize, [0, 1]), arr.argmin(Some(0), None));
assert_eq!(array!(usize, [0, 0]), arr.argmin(Some(1), None));
§Errors

may returns ArrayError

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: ArrayElement> ArraySearch<T> for Result<Array<T>, ArrayError>

Source§

fn argmax( &self, axis: Option<isize>, keepdims: Option<bool>, ) -> Result<Array<usize>, ArrayError>

Source§

fn argmin( &self, axis: Option<isize>, keepdims: Option<bool>, ) -> Result<Array<usize>, ArrayError>

Implementors§