Tpsa
Real truncated power series objects.
Tpsa stores real coefficients in a Descriptor-defined
algebraic space. It provides arithmetic, calculus, and elementary functions on
truncated multivariate power series.
- class madng_tpsa.tpsa.Tpsa(descriptor, order=None)
A truncated power series in the algebraic space defined by a descriptor.
Create a zero series on
descriptor.- classmethod from_ptr(ptr, descriptor=None, *, owns=False)
Return the interned
Tpsafor a raw C pointer.If a live
Tpsaalready 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 TPSA pointer.
descriptor (Descriptor | None) – Descriptor that owns this TPSA. When omitted it is inferred from the pointer via
mad_tpsa_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:
- property ptr: Any
Low-level TPSA pointer for consumers marshalling across an ABI.
- property descriptor: Descriptor
Descriptor that defines this series’ variables, parameters, and order.
- 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: float
Constant coefficient of the series.
- get(monomial)
Return the coefficient for
monomial.- Return type:
float
- set_const_part(value)
Set the constant coefficient.
- set(monomial, value)
Set the coefficient for
monomial.
- monomial_coeffs(tol=1e-14)
Return stored coefficients larger than
tolin absolute value.Keys are full monomial tuples with one entry per variable and parameter.
- Return type:
dict[tuple[int, …], float]
- 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[float]
- param_grad()
First-order coefficients for the descriptor parameters.
- Return type:
list[float]
- integrate(variable)
Return the formal integral with respect to
variable.
- derivative(variable)
Return a partial derivative with respect to
variable.
- poisson_bracket(other, num_pairs='all')
Return the Poisson bracket with
otherover canonical variable pairs.- Return type:
- format(style='code')
Format this series as code, LaTeX math, or a rich table.
- Parameters:
style (FormatStyle) – Output style. See
madng_tpsa.formatting.FormatStyle.- Return type:
object
- equals(other, tol=0.0)
Return whether this series and
otherhave matching coefficients.- Return type:
bool
- norm()
Return the sum of absolute values of the stored coefficients.
- Return type:
float
- sincosq()
Return \((\operatorname{sinc}(\sqrt{x}), \cos(\sqrt{x}))\) for this series.
- sincosmq()
Return two related trigonometric series.
\(((\operatorname{sinc}(\sqrt{x}) - 1) / x, (\cos(\sqrt{x}) - 1) / x)\).
- sincoshq()
Return \((\operatorname{sinhc}(\sqrt{x}), \cosh(\sqrt{x}))\) for this series.
- sincoshmq()
Return two related hyperbolic series.
\(((\operatorname{sinhc}(\sqrt{x}) - 1) / x, (\cosh(\sqrt{x}) - 1) / x)\).
- wofz()
Return the complex-valued Faddeeva function for this series.
- Return type:
- wofz_real()
Return the real-valued Faddeeva function for this series (MAD-NG’s
wf).For complex output use
scipy.special.wofzof manually promote the TPSA to complex with (ComplexTpsa.from_tpsa) and then call itswofz.- Return type: