Skip to main content

flatnonzero

Function flatnonzero 

Source
pub fn flatnonzero<T>(array: &Array<T>) -> Result<Array<usize>>
where T: Clone + Zero + PartialEq,
Expand description

Return indices that are non-zero in the flattened version of the input array

§Parameters

  • array - Input array

§Returns

Array of indices in the flattened array

§Examples

use numrs2::prelude::*;

let a = Array::from_vec(vec![0, 1, 0, 3, 0, 5]);
let indices = flatnonzero(&a).expect("flatnonzero should succeed");
assert_eq!(indices.to_vec(), vec![1, 3, 5]);