Add imaginary unit. (#7922)
This commit is contained in:
parent
3027ca292c
commit
3acedd4cd9
1 changed files with 4 additions and 0 deletions
|
|
@ -25,6 +25,10 @@ type
|
||||||
Complex* = tuple[re, im: float]
|
Complex* = tuple[re, im: float]
|
||||||
## a complex number, consisting of a real and an imaginary part
|
## 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 =
|
proc toComplex*(x: SomeInteger): Complex =
|
||||||
## Convert some integer ``x`` to a complex number.
|
## Convert some integer ``x`` to a complex number.
|
||||||
result.re = x
|
result.re = x
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue