atan_simd

Function atan_simd 

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

Compute the arctangent of each element (SIMD-accelerated).

Computes atan(x) for each element, returning values in the range (-π/2, π/2).

§Arguments

  • x - Input 1D array

§Returns

Array1<F> with the same length as input, where each element is the arctangent in radians.

§Performance

  • SIMD: Automatically used for large arrays (1000+ elements)
  • Scalar: Used for small arrays or when SIMD is unavailable

§Mathematical Properties

  • Range: (-π/2, π/2) for all finite x
  • atan(0) = 0
  • atan(-x) = -atan(x) (odd function)
  • atan(∞) = π/2, atan(-∞) = -π/2
  • atan(tan(x)) = x for x ∈ (-π/2, π/2)

§Examples

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

let x = array![0.0_f64, 1.0, -1.0, f64::INFINITY];
let result = atan_simd(&x.view());
// Result: [0.0, π/4, -π/4, π/2]

§Applications

  • Geometry: Calculating angles from slopes
  • Robotics: Inverse kinematics for joint angles
  • Computer Vision: Feature detection, edge orientation
  • Signal Processing: Phase unwrapping, frequency analysis
  • Physics: Trajectory analysis, projectile motion

§See Also