pol_root#

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

This is the opposite module to PolynomialToRoots().

Parameters:
orderint >= 1

The order of the polynomial.

epsfloat >= 0 or None

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

in_format[‘rectangular’, ‘polar’]

The input format.

forward(x: Tensor) Tensor[source]#

Convert roots to polynomial coefficients.

Parameters:
xTensor [shape=(…, M)]

The roots, can be complex.

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

The polynomial coefficients.

Examples

>>> x = torch.tensor([3, 4, -1])
>>> pol_root = diffsptk.RootsToPolynomial(x.size(-1))
>>> a = pol_root(x)
>>> a
tensor([ 1, -6,  5, 12])
diffsptk.functional.pol_root(x: Tensor, *, eps: float | None = None, in_format: str = 'rectangular') Tensor[source]#

Convert roots to polynomial coefficients.

Parameters:
xTensor [shape=(…, M)]

The roots, can be complex.

epsfloat >= 0 or None

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

in_format[‘rectangular’, ‘polar’]

The input format.

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

The polynomial coefficients.

See also

root_pol