From 3acedd4cd95e75f04714590f5dbd5876e3a936e8 Mon Sep 17 00:00:00 2001 From: Koki Fushimi Date: Sat, 2 Jun 2018 00:20:28 +0900 Subject: [PATCH] Add imaginary unit. (#7922) --- lib/pure/complex.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pure/complex.nim b/lib/pure/complex.nim index 98cab1a5ae..ba5c571ce1 100644 --- a/lib/pure/complex.nim +++ b/lib/pure/complex.nim @@ -25,6 +25,10 @@ type Complex* = tuple[re, im: float] ## a complex number, consisting of a real and an imaginary part +const + im*: Complex = (re: 0.0, im: 1.0) + ## The imaginary unit. √-1. + proc toComplex*(x: SomeInteger): Complex = ## Convert some integer ``x`` to a complex number. result.re = x