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
ComplexTpsafor a raw C pointer.If a live
ComplexTpsaalready wrapsptrit 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 ifownsis False.owns (bool) – Set it to
Trueonly whenptrpoints 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 defaultFalsetreats an unknown pointer as a bug and will raise.
- Return type:
- classmethod from_tpsa(real, imag=None)
Promote real and optional imaginary TPSAs to a complex TPSA.
- Return type:
- 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:
- 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:
- 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:
- poisson_bracket(other, num_pairs='all')
Return the Poisson bracket with
otherover canonical variable pairs.- Return type:
- equals(other, tol=0.0)
Return whether this and
otherhave matching coefficients.- Return type:
bool
- conjugate()
Return the complex conjugate of this series.
- Return type:
- 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:
- sqrt()
Return the square root of this series.
- Return type:
- exp()
Return the exponential of this series.
- Return type:
- log()
Return the natural logarithm of this series.
- Return type:
- sin()
Return the sine of this series.
- Return type:
- cos()
Return the cosine of this series.
- Return type:
- tan()
Return the tangent of this series.
- Return type:
- sinh()
Return the hyperbolic sine of this series.
- Return type:
- cosh()
Return the hyperbolic cosine of this series.
- Return type:
- tanh()
Return the hyperbolic tangent of this series.
- Return type:
- asin()
Return the inverse sine of this series.
- Return type:
- acos()
Return the inverse cosine of this series.
- Return type:
- atan()
Return the inverse tangent of this series.
- Return type:
- asinh()
Return the inverse hyperbolic sine of this series.
- Return type:
- acosh()
Return the inverse hyperbolic cosine of this series.
- Return type:
- atanh()
Return the inverse hyperbolic tangent of this series.
- Return type:
- erf()
Return the error function of this series.
- Return type:
- erfc()
Return the complementary error function of this series.
- Return type:
- erfcx()
Return the scaled complementary error function of this series.
- Return type:
- erfi()
Return the imaginary error function of this series.
- Return type:
- wofz()
Return the Faddeeva function of this series.
- Return type: