Trait arr_rs::core::operations::search::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§
sourcefn argmax(
&self,
axis: Option<isize>,
keepdims: Option<bool>
) -> Result<Array<usize>, ArrayError>
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 flattenedkeepdims- if true, the result will broadcast correctly against the input
Examples
use arr_rs::prelude::*;
let arr: Result<Array<i32>, ArrayError> = array!([[10, 11, 12], [13, 14, 15]]);
assert_eq!(array!([5]), arr.argmax(None, None));
let arr: Result<Array<f64>, ArrayError> = array!([[f64::NAN, 4.], [2., 3.]]);
assert_eq!(array!([0]), arr.argmax(None, None));sourcefn argmin(
&self,
axis: Option<isize>,
keepdims: Option<bool>
) -> Result<Array<usize>, ArrayError>
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 flattenedkeepdims- if true, the result will broadcast correctly against the input
Examples
use arr_rs::prelude::*;
let arr: Result<Array<i32>, ArrayError> = array!([[10, 11, 12], [13, 14, 15]]);
assert_eq!(array!([0]), arr.argmin(None, None));
assert_eq!(array!([0, 0, 0]), arr.argmin(Some(0), None));
assert_eq!(array!([0, 0]), arr.argmin(Some(1), None));
let arr: Result<Array<f64>, ArrayError> = array!([[f64::NAN, 4.], [2., 3.]]);
assert_eq!(array!([0]), arr.argmin(None, None));
assert_eq!(array!([0, 1]), arr.argmin(Some(0), None));
assert_eq!(array!([0, 0]), arr.argmin(Some(1), None));