Complex numbers
Overview
Multik supports complex-valued data through two element types:
ComplexFloat— single-precision complex numbersComplexDouble— double-precision complex numbers
These types behave like regular numeric values with re (real) and im (imaginary) parts, and they can be stored in ndarrays just like other primitive numeric types.
Creating complex values
ComplexFloat and ComplexDouble provide useful helpers:
Creating complex ndarrays
You can build complex arrays using literals or dedicated complex array builders.
From complex primitive arrays:
You can also generate complex grids with index-based factories:
Arithmetic with complex arrays
Complex ndarrays support the usual element-wise operations:
When adding or multiplying by scalars, use complex scalars:
Math functions
Many math functions work with complex arrays. For example:
Converting between real and complex types
You can cast a real array to a complex type with toType, which sets the imaginary part to zero: