max_simd

Function max_simd 

Source
pub fn max_simd<F>(a: &ArrayView1<'_, F>, b: &ArrayView1<'_, F>) -> Array1<F>
where F: Float + SimdUnifiedOps,
Expand description

SIMD-accelerated element-wise maximum

Computes max(a, b) element-wise.

§Arguments

  • a - First array
  • b - Second array

§Returns

Element-wise maximum

§Examples

use scirs2_core::ndarray::array;
use scirs2_core::ndarray_ext::elementwise::max_simd;

let a = array![1.0_f64, 5.0, 3.0];
let b = array![4.0_f64, 2.0, 6.0];
let c = max_simd::<f64>(&a.view(), &b.view());
assert!((c[0] - 4.0_f64).abs() < 1e-14);
assert!((c[1] - 5.0_f64).abs() < 1e-14);
assert!((c[2] - 6.0_f64).abs() < 1e-14);

§Use Cases

  • ReLU activation: max(0, x)
  • Soft clipping
  • Envelope detection
  • Upper bound enforcement