Nimony

The road to Nim 3

complex

nimony/lib/std/complex.nim

This module implements complex numbers and basic mathematical operations on them.

A complex number is a number of the form a + b*i, where a is the real part and b is the imaginary part (and i is the imaginary unit with the property i*i == -1).

Complex[T] is generic over the floating-point component type T. Following the modelling of std/math, each operation depends precisely on the concepts it needs: the arithmetic operators come from Arithmetic, and the transcendental functions add HasSqrt, HasExp, HasLn, HasSin, HasCos and HasArctan2. So Complex[float32] and Complex[float64] both work, and a user float type satisfying the relevant concepts works too.