ReferenceNu STD
cmath
Nu surface for Python's `complex` builtin and its `cmath` companion.
Module nustd.cmath.
Nu surface for Python's complex builtin and its cmath companion.
A hybrid surface: complex is a builtin with no module of its own, and
cmath is its set of companion functions, so the two co-locate here. The
surface mirrors both 1-1:
- the
complexvalue type is a Form (complex.of(real, imag),.real/.imag,conjugate(), arithmetic,eq/ne). - the
cmathfree functions (sqrt,exp,phase,polar, ...) and constants (pi,e,tau,inf,nan,infj,nanj).
Three layers behind it: forms (the complex type), functions (the
cmath wrappers and constants), and interactions (the atoms each builds).
Import it the way you would the stdlib:
from nustd.cmath import complex, sqrt, phase, pi
import nustd.cmath as cmath # then cmath.sqrt(...), cmath.phase(...)forms
Module nustd.cmath.forms.
The builtin complex as a Form - the value type behind nustd.cmath.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| complex | scalar_query | complex() | builtins.complex as a Form - a complex number. |
functions
Module nustd.cmath.functions.
Module-level functions and constants for nustd.cmath.
| Name | Call | Meaning |
|---|---|---|
| acos | cmath.acos(x) | The arc cosine of x: mirrors cmath.acos(). |
| asin | cmath.asin(x) | The arc sine of x: mirrors cmath.asin(). |
| atan | cmath.atan(x) | The arc tangent of x: mirrors cmath.atan(). |
| cos | cmath.cos(x) | The cosine of x: mirrors cmath.cos(). |
| cosh | cmath.cosh(x) | The hyperbolic cosine of x: mirrors cmath.cosh(). |
| exp | cmath.exp(x) | e raised to x: mirrors cmath.exp(). |
| isclose | cmath.isclose(a, b) | Whether a and b are close: mirrors cmath.isclose(). |
| isfinite | cmath.isfinite(x) | Whether both components of x are finite: mirrors cmath.isfinite(). |
| isinf | cmath.isinf(x) | Whether x has an infinite component: mirrors cmath.isinf(). |
| isnan | cmath.isnan(x) | Whether x has a NaN component: mirrors cmath.isnan(). |
| log | cmath.log(x, base=None) | The logarithm of x (natural, or to base): mirrors cmath.log(). |
| log10 | cmath.log10(x) | The base-10 logarithm of x: mirrors cmath.log10(). |
| phase | cmath.phase(x) | The phase angle of x, in radians: mirrors cmath.phase(). |
| polar | cmath.polar(x) | x as the polar pair (r, phi): mirrors cmath.polar(). |
| rect | cmath.rect(r, phi) | The complex number with modulus r and phase phi: mirrors cmath.rect(). |
| sin | cmath.sin(x) | The sine of x: mirrors cmath.sin(). |
| sinh | cmath.sinh(x) | The hyperbolic sine of x: mirrors cmath.sinh(). |
| sqrt | cmath.sqrt(x) | The square root of x: mirrors cmath.sqrt(). |
| tan | cmath.tan(x) | The tangent of x: mirrors cmath.tan(). |
| tanh | cmath.tanh(x) | The hyperbolic tangent of x: mirrors cmath.tanh(). |