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));
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));

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§