ComplexArraySimd class

SIMD-optimized array for efficient bulk complex number operations.

Uses Float64x2List where each Float64x2 stores one complex number:

  • x lane: real part
  • y lane: imaginary part

This provides 150%+ speedup for bulk operations on native platforms.

Note: SIMD is only available on native platforms (iOS, Android, macOS, Windows, Linux). For web, use ComplexArray instead.

Example:

final a = ComplexArraySimd.from([Complex(1, 2), Complex(3, 4)]);
final b = ComplexArraySimd.from([Complex(5, 6), Complex(7, 8)]);
a.addInPlace(b);
print(a[0]); // 6 + 8i

Constructors

ComplexArraySimd(int length)
Creates a ComplexArraySimd with the given length.
ComplexArraySimd.from(List<Complex> list)
Creates a ComplexArraySimd from a list of Complex numbers.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
length → int
The number of complex numbers in the array.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

absAll() → Float64List
Computes the element-wise absolute value (magnitude) of each complex number. Returns a new Float64List containing the magnitudes.
add(ComplexArraySimd other) → ComplexArraySimd
Returns a new array with element-wise addition.
addInPlace(ComplexArraySimd other) → void
Adds another array element-wise to this array, in-place (SIMD accelerated).
addScalarInPlace(double scalar) → void
Adds a scalar (real number) to all elements in-place.
circularShift(int n) → ComplexArraySimd
Circularly shifts the array by n positions.
conjugateInPlace() → void
Conjugates all elements in-place (negates imaginary parts).
copy() → ComplexArraySimd
Returns a copy of this array.
divideInPlace(ComplexArraySimd other) → void
Divides this array by another array element-wise, in-place.
dot(ComplexArraySimd other) → Complex
Computes the dot product: Σ(thisi * conj(otheri)).
expInPlace() → void
Applies e^z to each element in-place.
fft() → ComplexArraySimd
Computes the Fast Fourier Transform. Delegates to ComplexArray for simplicity.
ifft() → ComplexArraySimd
Computes the Inverse Fast Fourier Transform.
logInPlace() → void
Applies log(z) to each element in-place.
mean() → Complex
Returns the mean (average) of all complex numbers.
multiply(ComplexArraySimd other) → ComplexArraySimd
Returns a new array with element-wise multiplication.
multiplyInPlace(ComplexArraySimd other) → void
Multiplies this array by another array element-wise, in-place. (a + bi)(c + di) = (ac - bd) + i(ad + bc)
negateInPlace() → void
Negates all elements in-place (SIMD accelerated).
normSquared() → double
Returns the sum of squared magnitudes: Σ|zi|².
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
powInPlace(num n) → void
Applies z^n to each element in-place.
scaleInPlace(double factor) → void
Multiplies this array by a scalar (real number), in-place (SIMD accelerated).
sqrtInPlace() → void
Applies √z to each element in-place.
subtractInPlace(ComplexArraySimd other) → void
Subtracts another array element-wise from this array, in-place (SIMD accelerated).
sum() → Complex
Returns the sum of all complex numbers.
toComplexArray() → ComplexArray
Converts this SIMD array to a regular ComplexArray.
toList() → List<Complex>
Returns a new List<Complex> containing the elements of this array.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited
operator [](int i) → Complex
Gets the Complex number at index i.
operator []=(int i, Complex z) → void
Sets the Complex number at index i.