absAll method

Float64List absAll()

Computes the element-wise absolute value (magnitude) of each complex number. Returns a new Float64List containing the magnitudes.

Implementation

Float64List absAll() {
  final result = Float64List(length);
  for (int i = 0; i < length; i++) {
    final z = _data[i];
    result[i] = (z * z).x + (z * z).y; // x² + y²
    result[i] = result[i] > 0 ? result[i] : 0; // Ensure non-negative for sqrt
  }
  // Apply sqrt
  for (int i = 0; i < length; i++) {
    result[i] = result[i] != 0 ? Float64x2.splat(result[i]).sqrt().x : 0;
  }
  return result;
}