Module complex

This module implements complex numbers.

Types

Complex = tuple[re, im: float]
a complex number, consisting of a real and an imaginary part   Source

Procs

proc toComplex[SomeInteger](x: SomeInteger): Complex
Convert some integer x to a complex number.   Source
proc `==`(x, y: Complex): bool {.raises: [], tags: [].}
Compare two complex numbers x and y for equality.   Source
proc `=~`(x, y: Complex): bool {.raises: [], tags: [].}
Compare two complex numbers x and y approximately.   Source
proc `+`(x, y: Complex): Complex {.raises: [], tags: [].}
Add two complex numbers.   Source
proc `+`(x: Complex; y: float): Complex {.raises: [], tags: [].}
Add complex x to float y.   Source
proc `+`(x: float; y: Complex): Complex {.raises: [], tags: [].}
Add float x to complex y.   Source
proc `-`(z: Complex): Complex {.raises: [], tags: [].}
Unary minus for complex numbers.   Source
proc `-`(x, y: Complex): Complex {.raises: [], tags: [].}
Subtract two complex numbers.   Source
proc `-`(x: Complex; y: float): Complex {.raises: [], tags: [].}
Subtracts float y from complex x.   Source
proc `-`(x: float; y: Complex): Complex {.raises: [], tags: [].}
Subtracts complex y from float x.   Source
proc `/`(x, y: Complex): Complex {.raises: [], tags: [].}
Divide x by y.   Source
proc `/`(x: Complex; y: float): Complex {.raises: [], tags: [].}
Divide complex x by float y.   Source
proc `/`(x: float; y: Complex): Complex {.raises: [], tags: [].}
Divide float x by complex y.   Source
proc `*`(x, y: Complex): Complex {.raises: [], tags: [].}
Multiply x with y.   Source
proc `*`(x: float; y: Complex): Complex {.raises: [], tags: [].}
Multiply float x with complex y.   Source
proc `*`(x: Complex; y: float): Complex {.raises: [], tags: [].}
Multiply complex x with float y.   Source
proc `+=`(x: var Complex; y: Complex) {.raises: [], tags: [].}
Add y to x.   Source
proc `+=`(x: var Complex; y: float) {.raises: [], tags: [].}
Add y to the complex number x.   Source
proc `-=`(x: var Complex; y: Complex) {.raises: [], tags: [].}
Subtract y from x.   Source
proc `-=`(x: var Complex; y: float) {.raises: [], tags: [].}
Subtract y from the complex number x.   Source
proc `*=`(x: var Complex; y: Complex) {.raises: [], tags: [].}
Multiply y to x.   Source
proc `*=`(x: var Complex; y: float) {.raises: [], tags: [].}
Multiply y to the complex number x.   Source
proc `/=`(x: var Complex; y: Complex) {.raises: [], tags: [].}
Divide x by y in place.   Source
proc `/=`(x: var Complex; y: float) {.raises: [], tags: [].}
Divide complex x by float y in place.   Source
proc abs(z: Complex): float {.raises: [], tags: [].}
Return the distance from (0,0) to z.   Source
proc conjugate(z: Complex): Complex {.raises: [], tags: [].}
Conjugate of complex number z.   Source
proc sqrt(z: Complex): Complex {.raises: [], tags: [].}
Square root for a complex number z.   Source
proc exp(z: Complex): Complex {.raises: [], tags: [].}
e raised to the power z.   Source
proc ln(z: Complex): Complex {.raises: [], tags: [].}
Returns the natural log of z.   Source
proc log10(z: Complex): Complex {.raises: [], tags: [].}
Returns the log base 10 of z.   Source
proc log2(z: Complex): Complex {.raises: [], tags: [].}
Returns the log base 2 of z.   Source
proc pow(x, y: Complex): Complex {.raises: [], tags: [].}
x raised to the power y.   Source
proc sin(z: Complex): Complex {.raises: [], tags: [].}
Returns the sine of z.   Source
proc arcsin(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse sine of z.   Source
proc cos(z: Complex): Complex {.raises: [], tags: [].}
Returns the cosine of z.   Source
proc arccos(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse cosine of z.   Source
proc tan(z: Complex): Complex {.raises: [], tags: [].}
Returns the tangent of z.   Source
proc arctan(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse tangent of z.   Source
proc cot(z: Complex): Complex {.raises: [], tags: [].}
Returns the cotangent of z.   Source
proc arccot(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse cotangent of z.   Source
proc sec(z: Complex): Complex {.raises: [], tags: [].}
Returns the secant of z.   Source
proc arcsec(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse secant of z.   Source
proc csc(z: Complex): Complex {.raises: [], tags: [].}
Returns the cosecant of z.   Source
proc arccsc(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse cosecant of z.   Source
proc sinh(z: Complex): Complex {.raises: [], tags: [].}
Returns the hyperbolic sine of z.   Source
proc arcsinh(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse hyperbolic sine of z.   Source
proc cosh(z: Complex): Complex {.raises: [], tags: [].}
Returns the hyperbolic cosine of z.   Source
proc arccosh(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse hyperbolic cosine of z.   Source
proc tanh(z: Complex): Complex {.raises: [], tags: [].}
Returns the hyperbolic tangent of z.   Source
proc arctanh(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse hyperbolic tangent of z.   Source
proc sech(z: Complex): Complex {.raises: [], tags: [].}
Returns the hyperbolic secant of z.   Source
proc arcsech(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse hyperbolic secant of z.   Source
proc csch(z: Complex): Complex {.raises: [], tags: [].}
Returns the hyperbolic cosecant of z.   Source
proc arccsch(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse hyperbolic cosecant of z.   Source
proc coth(z: Complex): Complex {.raises: [], tags: [].}
Returns the hyperbolic cotangent of z.   Source
proc arccoth(z: Complex): Complex {.raises: [], tags: [].}
Returns the inverse hyperbolic cotangent of z.   Source
proc phase(z: Complex): float {.raises: [], tags: [].}
Returns the phase of z.   Source
proc polar(z: Complex): tuple[r, phi: float] {.raises: [], tags: [].}
Returns z in polar coordinates.   Source
proc rect(r: float; phi: float): Complex {.raises: [], tags: [].}
Returns the complex number with polar coordinates r and phi.   Source
proc `$`(z: Complex): string {.raises: [], tags: [].}
Returns z's string representation as "(re, im)".   Source