This module implements complex numbers. Complex numbers are currently implemented as generic on a 64-bit or 32-bit float.
プロシージャ
proc complex[T: SomeFloat](re: T; im: T = 0.0): Complex[T]
- ソース 編集
proc complex32(re: float32; im: float32 = 0.0): Complex[float32] {...}{.raises: [], tags: [].}
- ソース 編集
proc complex64(re: float64; im: float64 = 0.0): Complex[float64] {...}{.raises: [], tags: [].}
- ソース 編集
proc abs[T](z: Complex[T]): T
- Return the distance from (0,0) to z. ソース 編集
proc abs2[T](z: Complex[T]): T
- Return the squared distance from (0,0) to z. ソース 編集
proc conjugate[T](z: Complex[T]): Complex[T]
- Conjugate of complex number z. ソース 編集
proc inv[T](z: Complex[T]): Complex[T]
- Multiplicative inverse of complex number z. ソース 編集
proc `==`[T](x, y: Complex[T]): bool
- Compare two complex numbers x and y for equality. ソース 編集
proc `+`[T](x: T; y: Complex[T]): Complex[T]
- Add a real number to a complex number. ソース 編集
proc `+`[T](x: Complex[T]; y: T): Complex[T]
- Add a complex number to a real number. ソース 編集
proc `+`[T](x, y: Complex[T]): Complex[T]
- Add two complex numbers. ソース 編集
proc `-`[T](z: Complex[T]): Complex[T]
- Unary minus for complex numbers. ソース 編集
proc `-`[T](x: T; y: Complex[T]): Complex[T]
- Subtract a complex number from a real number. ソース 編集
proc `-`[T](x: Complex[T]; y: T): Complex[T]
- Subtract a real number from a complex number. ソース 編集
proc `-`[T](x, y: Complex[T]): Complex[T]
- Subtract two complex numbers. ソース 編集
proc `/`[T](x: Complex[T]; y: T): Complex[T]
- Divide complex number x by real number y. ソース 編集
proc `/`[T](x: T; y: Complex[T]): Complex[T]
- Divide real number x by complex number y. ソース 編集
proc `/`[T](x, y: Complex[T]): Complex[T]
- Divide x by y. ソース 編集
proc `*`[T](x: T; y: Complex[T]): Complex[T]
- Multiply a real number and a complex number. ソース 編集
proc `*`[T](x: Complex[T]; y: T): Complex[T]
- Multiply a complex number with a real number. ソース 編集
proc `*`[T](x, y: Complex[T]): Complex[T]
- Multiply x with y. ソース 編集
proc `+=`[T](x: var Complex[T]; y: Complex[T])
- Add y to x. ソース 編集
proc `-=`[T](x: var Complex[T]; y: Complex[T])
- Subtract y from x. ソース 編集
proc `*=`[T](x: var Complex[T]; y: Complex[T])
- Multiply y to x. ソース 編集
proc `/=`[T](x: var Complex[T]; y: Complex[T])
- Divide x by y in place. ソース 編集
proc sqrt[T](z: Complex[T]): Complex[T]
- Square root for a complex number z. ソース 編集
proc exp[T](z: Complex[T]): Complex[T]
- e raised to the power z. ソース 編集
proc ln[T](z: Complex[T]): Complex[T]
- Returns the natural log of z. ソース 編集
proc log10[T](z: Complex[T]): Complex[T]
- Returns the log base 10 of z. ソース 編集
proc log2[T](z: Complex[T]): Complex[T]
- Returns the log base 2 of z. ソース 編集
proc pow[T](x, y: Complex[T]): Complex[T]
- x raised to the power y. ソース 編集
proc pow[T](x: Complex[T]; y: T): Complex[T]
- Complex number x raised to the power y. ソース 編集
proc sin[T](z: Complex[T]): Complex[T]
- Returns the sine of z. ソース 編集
proc arcsin[T](z: Complex[T]): Complex[T]
- Returns the inverse sine of z. ソース 編集
proc cos[T](z: Complex[T]): Complex[T]
- Returns the cosine of z. ソース 編集
proc arccos[T](z: Complex[T]): Complex[T]
- Returns the inverse cosine of z. ソース 編集
proc tan[T](z: Complex[T]): Complex[T]
- Returns the tangent of z. ソース 編集
proc arctan[T](z: Complex[T]): Complex[T]
- Returns the inverse tangent of z. ソース 編集
proc cot[T](z: Complex[T]): Complex[T]
- Returns the cotangent of z. ソース 編集
proc arccot[T](z: Complex[T]): Complex[T]
- Returns the inverse cotangent of z. ソース 編集
proc sec[T](z: Complex[T]): Complex[T]
- Returns the secant of z. ソース 編集
proc arcsec[T](z: Complex[T]): Complex[T]
- Returns the inverse secant of z. ソース 編集
proc csc[T](z: Complex[T]): Complex[T]
- Returns the cosecant of z. ソース 編集
proc arccsc[T](z: Complex[T]): Complex[T]
- Returns the inverse cosecant of z. ソース 編集
proc sinh[T](z: Complex[T]): Complex[T]
- Returns the hyperbolic sine of z. ソース 編集
proc arcsinh[T](z: Complex[T]): Complex[T]
- Returns the inverse hyperbolic sine of z. ソース 編集
proc cosh[T](z: Complex[T]): Complex[T]
- Returns the hyperbolic cosine of z. ソース 編集
proc arccosh[T](z: Complex[T]): Complex[T]
- Returns the inverse hyperbolic cosine of z. ソース 編集
proc tanh[T](z: Complex[T]): Complex[T]
- Returns the hyperbolic tangent of z. ソース 編集
proc arctanh[T](z: Complex[T]): Complex[T]
- Returns the inverse hyperbolic tangent of z. ソース 編集
proc sech[T](z: Complex[T]): Complex[T]
- Returns the hyperbolic secant of z. ソース 編集
proc arcsech[T](z: Complex[T]): Complex[T]
- Returns the inverse hyperbolic secant of z. ソース 編集
proc csch[T](z: Complex[T]): Complex[T]
- Returns the hyperbolic cosecant of z. ソース 編集
proc arccsch[T](z: Complex[T]): Complex[T]
- Returns the inverse hyperbolic cosecant of z. ソース 編集
proc coth[T](z: Complex[T]): Complex[T]
- Returns the hyperbolic cotangent of z. ソース 編集
proc arccoth[T](z: Complex[T]): Complex[T]
- Returns the inverse hyperbolic cotangent of z. ソース 編集
proc phase[T](z: Complex[T]): T
- Returns the phase of z. ソース 編集
proc polar[T](z: Complex[T]): tuple[r, phi: T]
- Returns z in polar coordinates. ソース 編集
proc rect[T](r, phi: T): Complex[T]
-
Returns the complex number with polar coordinates r and phi.
result.re = r * cos(phi)
ソース 編集
result.im = r * sin(phi) proc `$`(z: Complex): string
- Returns z's string representation as "(re, im)". ソース 編集