Skip to main content

encode_binary

Function encode_binary 

Source
pub fn encode_binary(values: &[f32], threshold: f32) -> PackedBinary
Expand description

Encode f32 slice as packed binary.

Values above threshold become 1, others become 0.

use innr::binary::encode_binary;

let v = [0.5_f32, -0.1, 0.9, 0.0];
let packed = encode_binary(&v, 0.0);
assert!(packed.get(0));   // 0.5 > 0.0
assert!(!packed.get(1));  // -0.1 <= 0.0
assert!(packed.get(2));   // 0.9 > 0.0