Mojo struct
ComplexSIMD
@register_passable(trivial)
struct ComplexSIMD[type: DType, size: Int]
Represents a complex SIMD value.
The class provides basic methods for manipulating complex values.
Parameters
- type (
DType
): DType of the value. - size (
Int
): SIMD width of the value.
Fields
- re (
SIMD[type, size]
): The real part of the complex SIMD value. - im (
SIMD[type, size]
): The imaginary part of the complex SIMD value.
Implemented traits
AnyType
,
Copyable
,
ExplicitlyCopyable
,
Movable
,
Stringable
,
UnknownDestructibility
,
Writable
Methods
__neg__
__neg__(self) -> Self
Negates the complex value.
Returns:
The negative of the complex value.
__add__
__add__(self, rhs: Self) -> Self
Adds two complex values.
Args:
- rhs (
Self
): Complex value to add.
Returns:
A sum of this and RHS complex values.
__mul__
__mul__(self, rhs: Self) -> Self
Multiplies two complex values.
Args:
- rhs (
Self
): Complex value to multiply with.
Returns:
A product of this and RHS complex values.
__str__
__str__(self) -> String
Get the complex as a string.
Returns:
A string representation.
write_to
write_to[W: Writer](self, mut writer: W)
Formats this complex value to the provided Writer.
Parameters:
- W (
Writer
): A type conforming to the Writable trait.
Args:
- writer (
W
): The object to write to.
__abs__
__abs__(self) -> SIMD[type, size]
Returns the magnitude of the complex value.
Returns:
Value of sqrt(re*re + im*im)
.
norm
norm(self) -> SIMD[type, size]
Returns the magnitude of the complex value.
Returns:
Value of sqrt(re*re + im*im)
.
squared_norm
squared_norm(self) -> SIMD[type, size]
Returns the squared magnitude of the complex value.
Returns:
Value of re*re + im*im
.
fma
fma(self, b: Self, c: Self) -> Self
Computes FMA operation.
Compute fused multiple-add with two other complex values:
result = self * b + c
Args:
- b (
Self
): Multiplier complex value. - c (
Self
): Complex value to add.
Returns:
Computed Self * B + C
complex value.
squared_add
squared_add(self, c: Self) -> Self
Computes Square-Add operation.
Compute Self * Self + C
.
Args:
- c (
Self
): Complex value to add.
Returns:
Computed Self * Self + C
complex value.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!