Function safe_arch::sign_apply_i8_m256i

source ยท
pub fn sign_apply_i8_m256i(a: m256i, b: m256i) -> m256i
Available with target feature avx2 only.
Expand description

Lanewise a * signum(b) with lanes as i8

  • If b is positive, the output is a.
  • If b is zero, the output is 0.
  • If b is negative, the output is -a.
let a = m256i::from([
  3_i8, 11, 2, 13, 4, 15, 6, 17, 8, 19, 20, 21, 22, 23, 24, 127, 7, 11, 2, 13, 4, 15, 6, 17, 8,
  19, 20, 21, 22, 23, 24, 127,
]);
let b = m256i::from([
  -1_i8, -1, 0, 2, 2, 3, 0, 5, 6, 6, -7, 8, 8, 0, 0, 10, 10, -11, 11, 12, 12, 13, 13, 12, 11,
  -10, 9, 8, 7, 6, 5, -4,
]);
let c: [i8; 32] = sign_apply_i8_m256i(a, b).into();
assert_eq!(
  c,
  [
    -3, -11, 0, 13, 4, 15, 0, 17, 8, 19, -20, 21, 22, 0, 0, 127, 7, -11, 2, 13, 4, 15, 6, 17, 8,
    -19, 20, 21, 22, 23, 24, -127
  ]
);