pub fn powf_simd<F>(base: &ArrayView1<'_, F>, exp: F) -> Array1<F>where
F: Float + SimdUnifiedOps,Expand description
Compute the power of each element with a scalar exponent (SIMD-accelerated).
Computes base^exp for each element in the base array.
§Arguments
base- Input 1D array of base valuesexp- Scalar exponent value
§Returns
Array1<F> with the same length as input, with power values.
§Performance
- Auto-vectorization: Compiler optimizations provide excellent performance
- Speedup: 2-4x on large arrays via auto-vectorization
§Mathematical Definition
powf(base, exp) = base^exp§Examples
use scirs2_core::ndarray::array;
use scirs2_core::ndarray_ext::elementwise::powf_simd;
let base = array![2.0_f64, 3.0, 4.0, 5.0];
let result = powf_simd(&base.view(), 2.0);
// [4.0, 9.0, 16.0, 25.0]§Edge Cases
- Empty array: Returns empty array
- x^0: Returns 1 for any x (including 0^0 = 1 by convention)
- x^1: Returns x
- 0^negative: Returns infinity
- negative^non-integer: Returns NaN
- NaN: Returns NaN (preserves NaN)
§Applications
- Statistics: Variance, standard deviation, moment calculations
- Machine Learning: Polynomial features, L2 regularization
- Signal Processing: Power spectral density, energy calculations
- Physics: Kinetic energy, gravitational potential
- Finance: Compound interest, exponential growth models