sinh_simd

Function sinh_simd 

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

Compute the hyperbolic sine of each element (SIMD-accelerated).

Computes sinh(x) for each element in the array.

§Arguments

  • x - Input 1D array

§Returns

Array1<F> with the same length as input, with hyperbolic sine values.

§Performance

  • Auto-vectorization: Compiler optimizations provide excellent performance
  • Speedup: 2-4x on large arrays via auto-vectorization

§Mathematical Definition

sinh(x) = (e^x - e^(-x)) / 2
Range: (-∞, ∞)

§Examples

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

let x = array![0.0_f64, 1.0, -1.0];
let result = sinh_simd(&x.view());

// sinh(0) = 0, sinh(1) ≈ 1.175, sinh(-1) ≈ -1.175
assert!((result[0] - 0.0).abs() < 1e-10);
assert!((result[1] - 1.1752011936).abs() < 1e-9);
assert!((result[2] + 1.1752011936).abs() < 1e-9);

§Edge Cases

  • Empty array: Returns empty array
  • Zero: sinh(0) = 0
  • Large positive: May overflow to infinity
  • Large negative: May overflow to negative infinity
  • NaN: Returns NaN (preserves NaN)

§Applications

  • Neural Networks: Tanh activation (related via tanh = sinh/cosh)
  • Numerical Integration: Tanh-sinh quadrature
  • Physics: Catenary curves, special relativity
  • Engineering: Transmission line theory, heat transfer
  • Mathematics: Hyperbolic geometry, complex analysis