Crates.io | argmm |
lib.rs | argmm |
version | 0.1.2 |
source | src |
created_at | 2020-02-08 11:50:32.438631 |
updated_at | 2020-07-29 12:19:01.116446 |
description | Argmin and argmax with SIMD support for u8, u16, i16, i32 and f32 |
homepage | |
repository | https://github.com/minimalrust/argmm.git |
max_upload_size | |
id | 206344 |
size | 61,400 |
Argmin/max with SIMD support for u8, i16, u16, i32 and f32 arrays and vectors.
Add the following to your Cargo.toml
argmm = "0.1.2"
You can use the extention trait which will take advantage of SIMD if available
use argmm::ArgMinMax;
fn main() {
let v = vec![1., 3., -20., 50., -82., 9., -53., 60., 0.];
let min_index = v.argmin();
let max_index = v.argmax();
assert_eq!(min_index, Some(4));
assert_eq!(max_index, Some(7));
}
Alternatively, the generic function can be used if you require non-SIMD support for other types
use argmm::generic::{simple_argmin, simple_argmax};
fn main() {
let v = vec![1u64, 3, 20, 50, 82, 9, 53, 60, 0];
let min_index = simple_argmin(&v);
let max_index = simple_argmax(&v);
assert_eq!(min_index, 8);
assert_eq!(max_index, 4);
}
Using a MacBook Pro (Retina, 13-inch, Early 2015) Processor 2.7 GHz Dual-Core Intel Core i5 with an array size of 512.
See /benches/results
.
NAN values are not supported.
Licensed under either of