ComplexTpsa

Complex truncated power series objects.

ComplexTpsa stores complex coefficients in a Descriptor-defined algebraic space. It mirrors the real TPSA API where operations are defined for complex series.

class madng_tpsa.complex_tpsa.ComplexTpsa(descriptor, order=None)

A complex truncated power series on a Descriptor.

Create a zero complex series on descriptor.

classmethod from_ptr(ptr, descriptor=None, *, owns=False)

Return the interned ComplexTpsa for a raw C pointer.

If a live ComplexTpsa already wraps ptr it is returned directly, so that at most one Python object exists per C allocation, preventing a use-after-free if two owners existed for the same pointer.

Parameters:
  • ptr (Any) – Raw CFFI complex TPSA pointer.

  • descriptor (Descriptor | None) – Descriptor that owns this TPSA. When omitted it is inferred from the pointer via mad_ctpsa_desc. Required if owns is False.

  • owns (bool) – Set it to True only when ptr points to a freshly allocated C object that has no Python wrapper yet, i.e. the call site created the allocation and is handing ownership. The default False treats an unknown pointer as a bug and will raise.

Return type:

ComplexTpsa

classmethod from_tpsa(real, imag=None)

Promote real and optional imaginary TPSAs to a complex TPSA.

Return type:

ComplexTpsa

property ptr: Any

Low-level CTPSA pointer for consumers marshalling across an ABI.

property descriptor: Descriptor

Descriptor that defines this series’ algebraic space.

property order: int

Maximum order stored by this series.

property max_nonzero_order: int

Highest order currently containing a non-zero coefficient.

property const_part: complex

Constant coefficient of the series.

get(monomial)

Return the coefficient for monomial.

Return type:

complex

set_const_part(value)

Set the constant coefficient.

set(monomial, value)

Set the coefficient for monomial.

monomial_coeffs(tol=1e-14)

Return stored coefficients with magnitude greater than tol.

Return type:

dict[tuple[int, …], complex]

is_zero()

Return whether this series has no non-zero coefficients.

Return type:

bool

is_constant()

Return whether this series has no non-constant coefficients.

Return type:

bool

clear()

Set all coefficients to zero in place.

grad()

First-order coefficients for the descriptor variables.

Return type:

list[complex]

param_grad()

First-order coefficients for the descriptor parameters.

Return type:

list[complex]

copy()

Return an independent copy of this series.

Return type:

ComplexTpsa

real()

Return the real part as a real TPSA.

Return type:

Tpsa

imag()

Return the imaginary part as a real TPSA.

Return type:

Tpsa

integrate(variable)

Return the formal integral with respect to variable.

Parameters:

variable (int | str | Tpsa) – May be a label, a 1-based variable/parameter index, or a TPSA identity variable with exactly one first-order monomial of coefficient 1. See _resolve_single_monomial() for accepted inputs.

Return type:

ComplexTpsa

derivative(variable)

Return a partial derivative with respect to variable.

Parameters:

variable (int | str | tuple[int, ...] | Tpsa) – May be a label, a 1-based variable/parameter index, a monomial tuple, or a TPSA with exactly one non-constant coefficient equal to one. See _resolve_single_monomial() for accepted inputs.

Return type:

ComplexTpsa

poisson_bracket(other, num_pairs='all')

Return the Poisson bracket with other over canonical variable pairs.

Return type:

ComplexTpsa

equals(other, tol=0.0)

Return whether this and other have matching coefficients.

Return type:

bool

conjugate()

Return the complex conjugate of this series.

Return type:

ComplexTpsa

norm()

Return the sum of magnitudes of the stored coefficients.

Return type:

float

unit()

Return this series normalised by the magnitude of its constant part.

Return type:

ComplexTpsa

sqrt()

Return the square root of this series.

Return type:

ComplexTpsa

exp()

Return the exponential of this series.

Return type:

ComplexTpsa

log()

Return the natural logarithm of this series.

Return type:

ComplexTpsa

sin()

Return the sine of this series.

Return type:

ComplexTpsa

cos()

Return the cosine of this series.

Return type:

ComplexTpsa

tan()

Return the tangent of this series.

Return type:

ComplexTpsa

sinh()

Return the hyperbolic sine of this series.

Return type:

ComplexTpsa

cosh()

Return the hyperbolic cosine of this series.

Return type:

ComplexTpsa

tanh()

Return the hyperbolic tangent of this series.

Return type:

ComplexTpsa

asin()

Return the inverse sine of this series.

Return type:

ComplexTpsa

acos()

Return the inverse cosine of this series.

Return type:

ComplexTpsa

atan()

Return the inverse tangent of this series.

Return type:

ComplexTpsa

asinh()

Return the inverse hyperbolic sine of this series.

Return type:

ComplexTpsa

acosh()

Return the inverse hyperbolic cosine of this series.

Return type:

ComplexTpsa

atanh()

Return the inverse hyperbolic tangent of this series.

Return type:

ComplexTpsa

erf()

Return the error function of this series.

Return type:

ComplexTpsa

erfc()

Return the complementary error function of this series.

Return type:

ComplexTpsa

erfcx()

Return the scaled complementary error function of this series.

Return type:

ComplexTpsa

erfi()

Return the imaginary error function of this series.

Return type:

ComplexTpsa

wofz()

Return the Faddeeva function of this series.

Return type:

ComplexTpsa