nustack
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 complex value type is a Form (complex.of(real, imag), .real / .imag, conjugate(), arithmetic, eq / ne).
  • the cmath free 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.

Full entries

NameSortCallMeaning
complexscalar_querycomplex()builtins.complex as a Form - a complex number.

functions

Module nustd.cmath.functions.

Module-level functions and constants for nustd.cmath.

Full entries

NameCallMeaning
acoscmath.acos(x)The arc cosine of x: mirrors cmath.acos().
asincmath.asin(x)The arc sine of x: mirrors cmath.asin().
atancmath.atan(x)The arc tangent of x: mirrors cmath.atan().
coscmath.cos(x)The cosine of x: mirrors cmath.cos().
coshcmath.cosh(x)The hyperbolic cosine of x: mirrors cmath.cosh().
expcmath.exp(x)e raised to x: mirrors cmath.exp().
isclosecmath.isclose(a, b)Whether a and b are close: mirrors cmath.isclose().
isfinitecmath.isfinite(x)Whether both components of x are finite: mirrors cmath.isfinite().
isinfcmath.isinf(x)Whether x has an infinite component: mirrors cmath.isinf().
isnancmath.isnan(x)Whether x has a NaN component: mirrors cmath.isnan().
logcmath.log(x, base=None)The logarithm of x (natural, or to base): mirrors cmath.log().
log10cmath.log10(x)The base-10 logarithm of x: mirrors cmath.log10().
phasecmath.phase(x)The phase angle of x, in radians: mirrors cmath.phase().
polarcmath.polar(x)x as the polar pair (r, phi): mirrors cmath.polar().
rectcmath.rect(r, phi)The complex number with modulus r and phase phi: mirrors cmath.rect().
sincmath.sin(x)The sine of x: mirrors cmath.sin().
sinhcmath.sinh(x)The hyperbolic sine of x: mirrors cmath.sinh().
sqrtcmath.sqrt(x)The square root of x: mirrors cmath.sqrt().
tancmath.tan(x)The tangent of x: mirrors cmath.tan().
tanhcmath.tanh(x)The hyperbolic tangent of x: mirrors cmath.tanh().

On this page