pub fn cosh_simd<F>(x: &ArrayView1<'_, F>) -> Array1<F>where
F: Float + SimdUnifiedOps,Expand description
Compute the hyperbolic cosine of each element (SIMD-accelerated).
Computes cosh(x) for each element in the array.
§Arguments
x- Input 1D array
§Returns
Array1<F> with the same length as input, with hyperbolic cosine values.
§Performance
- Auto-vectorization: Compiler optimizations provide excellent performance
- Speedup: 2-4x on large arrays via auto-vectorization
§Mathematical Definition
cosh(x) = (e^x + e^(-x)) / 2
Range: [1, ∞) (always >= 1)§Examples
use scirs2_core::ndarray::array;
use scirs2_core::ndarray_ext::elementwise::cosh_simd;
let x = array![0.0_f64, 1.0, -1.0];
let result = cosh_simd(&x.view());
// cosh(0) = 1, cosh(1) ≈ 1.543, cosh(-1) ≈ 1.543
assert!((result[0] - 1.0).abs() < 1e-10);
assert!((result[1] - 1.5430806348).abs() < 1e-9);
assert!((result[2] - 1.5430806348).abs() < 1e-9);§Edge Cases
- Empty array: Returns empty array
- Zero: cosh(0) = 1
- Symmetric: cosh(-x) = cosh(x)
- Large values: May overflow to infinity
- NaN: Returns NaN (preserves NaN)
§Applications
- Neural Networks: Activation functions, normalization
- Physics: Wave propagation, special relativity
- Engineering: Cable suspension, arch design
- Mathematics: Hyperbolic identities (cosh² - sinh² = 1)
- Numerical Methods: Stability analysis