floor_simd

Function floor_simd 

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

Compute the floor (round down) of each element (SIMD-accelerated).

Computes the largest integer less than or equal to x for each element.

§Arguments

  • x - Input 1D array

§Returns

Array1<F> with the same length as input, where each element is rounded down to the nearest integer.

§Performance

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

§Mathematical Properties

  • For any x: floor(x) <= x
  • floor(x) is the largest integer <= x
  • floor(-x) = -ceil(x)
  • floor(x) = x if x is already an integer

§Examples

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

let x = array![1.2, 2.7, -1.3, -2.9, 3.0];
let result = floor_simd(&x.view());
// Result: [1.0, 2.0, -2.0, -3.0, 3.0]

§Applications

  • Binning: Discretizing continuous values into bins
  • Indexing: Converting continuous coordinates to discrete indices
  • Quantization: Reducing precision for data compression
  • Digital Signal Processing: Sample rate conversion, downsampling
  • Computer Graphics: Pixel coordinate calculations
  • Financial: Rounding down monetary amounts

§See Also