Complex class

A high-performance equivalent to C++ <complex>.

Represents a complex number with a real and an imaginary part, providing operations for complex arithmetic and magnitude extraction.

Constructors

Complex(num real, [num imag = 0.0])
Creates a standard complex number. If the imaginary part is not provided, it defaults to 0.0.
const
Complex.polar(num rho, num theta)
Creates a complex number from polar coordinates. rho is the magnitude, and theta is the phase angle in radians.
factory

Properties

hashCode int
Returns a hash code based on both the real and imaginary parts.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

abs() double
Computes the magnitude (absolute value) of the complex number.
arg() double
Computes the phase angle (argument) of the complex number in radians.
conj() Complex
Returns the complex conjugate of the number (real - imag * i).
imag() double
Returns the imaginary component of the complex number.
norm() double
Computes the squared magnitude of the complex number.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
real() double
Returns the real component of the complex number.
toString() String
Returns a human-readable string in the form a + bi or a - bi.
override

Operators

operator *(Complex other) Complex
Multiplies two complex numbers using the standard complex multiplication rule.
operator +(Complex other) Complex
Adds two complex numbers component-wise.
operator -(Complex other) Complex
Subtracts other from this complex number component-wise.
operator /(Complex other) Complex
Divides this complex number by other.
operator ==(Object other) bool
Returns true if both the real and imaginary parts are equal.
override