biz.source_code.dsp.math

## Class PolynomialUtils

• ```public class PolynomialUtils
extends Object```
Plynomial utility routines.

In this module, polynomial coefficients are stored in arrays ordered in descending powers. When an awway a[] contains the coefficients, the polynomial has the following form:
` a * x^n + a * x^(n-1) + ... a[n-1] * x + a[n] `

• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
`static class ` `PolynomialUtils.RationalFraction`
Structure for the coefficients of a rational fraction (a fraction of two polynomials) with real coefficients.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static Complex[]` ```deflate(Complex[] a, Complex z, double eps)```
Forward deflation of a polynomial with a known zero.
`static Complex` ```evaluate(double[] a, Complex x)```
Computes the value of a polynomial with real coefficients.
`static Complex` ```evaluate(PolynomialUtils.RationalFraction f, Complex x)```
Computes the value of a rational fraction.
`static Complex[]` `expand(Complex[] zeros)`
Computes the coefficients of a polynomial from it's complex zeros.
`static Complex[]` ```multiply(Complex[] a1, Complex[] a2)```
Multiplies two polynomials with complex coefficients.
`static double[]` ```multiply(double[] a1, double[] a2)```
Multiplies two polynomials with real coefficients.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Method Detail

• #### evaluate

```public static Complex evaluate(double[] a,
Complex x)```
Computes the value of a polynomial with real coefficients.
Parameters:
`a` - The coefficients of the polynomial, ordered in descending powers.
`x` - The x value for which the polynomial is to be evaluated.
Returns:
The result.
• #### evaluate

```public static Complex evaluate(PolynomialUtils.RationalFraction f,
Complex x)```
Computes the value of a rational fraction. Returns `evaluate(f.top, x) / evaluate(f.bottom, x)`.
• #### multiply

```public static double[] multiply(double[] a1,
double[] a2)```
Multiplies two polynomials with real coefficients.
• #### multiply

```public static Complex[] multiply(Complex[] a1,
Complex[] a2)```
Multiplies two polynomials with complex coefficients.
• #### deflate

```public static Complex[] deflate(Complex[] a,
Complex z,
double eps)```
Forward deflation of a polynomial with a known zero. Divides the polynomial with coefficients `a[]` by `(x - z)`, where `z` is a zero of the polynomial.
Parameters:
`a` - Coefficients of the polynomial.
`z` - A known zero of the polynomial
`eps` - The maximum value allowed for the absolute real and imaginary parts of the remainder, or 0 to ignore the reminder.
Returns:
The coefficients of the resulting polynomial.
• #### expand

`public static Complex[] expand(Complex[] zeros)`
Computes the coefficients of a polynomial from it's complex zeros.
Parameters:
`zeros` - The zeros of the polynomial. The polynomial formula is: ` (x - zero) * (x - zero) * ... (x - zero[n - 1]) `
Returns:
The coefficients of the expanded polynomial, ordered in descending powers.