root_pol#

class diffsptk.PolynomialToRoots(order: int, *, eps: float | None = None, out_format: str | int = 'rectangular')[source]#

See this page for details.

Parameters:
orderint >= 1

The order of the polynomial.

epsfloat >= 0 or None

If the absolute values of the imaginary parts of the roots are all less than this value, they are considered as real roots.

out_format[‘rectangular’, ‘polar’]

The output format.

forward(a: Tensor) Tensor[source]#

Find the roots of the input polynomial.

Parameters:
aTensor [shape=(…, M+1)]

The polynomial coefficients.

Returns:
outTensor [shape=(…, M)]

The roots.

Examples

>>> a = torch.tensor([3, 4, 5])
>>> root_pol = diffsptk.PolynomialToRoots(a.size(-1) - 1)
>>> x = root_pol(a)
>>> x
tensor([[-0.6667+1.1055j, -0.6667-1.1055j]])
diffsptk.functional.root_pol(a: Tensor, *, eps: float | None = None, out_format: str = 'rectangular') Tensor[source]#

Compute roots of polynomial.

Parameters:
aTensor [shape=(…, M+1)]

The polynomial coefficients.

epsfloat >= 0 or None

If the absolute values of the imaginary parts of the roots are all less than this value, they are considered as real roots.

out_format[‘rectangular’, ‘polar’]

Output format.

Returns:
outTensor [shape=(…, M)]

The roots.

See also

pol_root