polyc

Variants: poly, polyc, polycf, polyf

Public Functions

double complex polyc_val(double complex * _p, unsigned int _k, double complex _x)
int polyc_fit(double complex * _x, double complex * _y, unsigned int _n, double complex * _p, unsigned int _k)
int polyc_fit_lagrange(double complex * _x, double complex * _y, unsigned int _n, double complex * _p)
double complex polyc_interp_lagrange(double complex * _x, double complex * _y, unsigned int _n, double complex _x0)
int polyc_fit_lagrange_barycentric(double complex * _x, unsigned int _n, double complex * _w)
double complex polyc_val_lagrange_barycentric(double complex * _x, double complex * _y, double complex * _w, double complex _x0, unsigned int _n)
int polyc_expandbinomial(unsigned int _n, double complex * _p)
int polyc_expandbinomial_pm(unsigned int _m, unsigned int _k, double complex * _p)
int polyc_expandroots(double complex * _r, unsigned int _n, double complex * _p)
int polyc_expandroots2(double complex * _a, double complex * _b, unsigned int _n, double complex * _p)
int polyc_findroots(double complex * _poly, unsigned int _n, double complex * _roots)
int polyc_findroots_durandkerner(double complex * _p, unsigned int _k, double complex * _roots)
int polyc_findroots_bairstow(double complex * _p, unsigned int _k, double complex * _roots)
int polyc_mul(double complex * _a, unsigned int _order_a, double complex * _b, unsigned int _order_b, double complex * _c)

Interfaces

double complex polyc_val(double complex * _p, unsigned int _k, double complex _x)

Evaluate polynomial _p at value _x

  • _p : polynomial coefficients, shape: (_k, 1)
  • _k : polynomial coefficients length
  • _x : input to evaluate polynomial

int polyc_fit(double complex * _x, double complex * _y, unsigned int _n, double complex * _p, unsigned int _k)

Perform least-squares polynomial fit on data set

  • _x : x-value sample set, shape: (_n, 1)
  • _y : y-value sample set, shape: (_n, 1)
  • _n : number of samples in _x and _y
  • _p : polynomial coefficients output, shape: (_k, 1)
  • _k : polynomial coefficients length

int polyc_fit_lagrange(double complex * _x, double complex * _y, unsigned int _n, double complex * _p)

Perform Lagrange polynomial exact fit on data set

  • _x : x-value sample set, size [_n x 1]
  • _y : y-value sample set, size [_n x 1]
  • _n : number of samples in _x and _y
  • _p : polynomial coefficients output, shape: (_n, 1)

double complex polyc_interp_lagrange(double complex * _x, double complex * _y, unsigned int _n, double complex _x0)

Perform Lagrange polynomial interpolation on data set without computing coefficients as an intermediate step.

  • _x : x-value sample set, shape: (_n, 1)
  • _y : y-value sample set, shape: (_n, 1)
  • _n : number of samples in _x and _y
  • _x0 : x-value to evaluate and compute interpolant

int polyc_fit_lagrange_barycentric(double complex * _x, unsigned int _n, double complex * _w)

Compute Lagrange polynomial fit in the barycentric form.

  • _x : x-value sample set, size [_n x 1]
  • _n : number of samples in _x
  • _w : barycentric weights normalized so _w [0]=1, size [_n x 1]

double complex polyc_val_lagrange_barycentric(double complex * _x, double complex * _y, double complex * _w, double complex _x0, unsigned int _n)

Perform Lagrange polynomial interpolation using the barycentric form of the weights.

  • _x : x-value sample set, shape: (_n, 1)
  • _y : y-value sample set, shape: (_n, 1)
  • _w : barycentric weights, shape: (_n, 1)
  • _x0 : x-value to evaluate and compute interpolant
  • _n : number of samples in _x, _y, and _w

int polyc_expandbinomial(unsigned int _n, double complex * _p)

Perform binomial expansion on the polynomial \( P_n(x) = (1+x)^n \) as \( P_n(x) = p[0] + p[1]x + p[2]x^2 + ... + p[n]x^n \) NOTE: _p has order n (coefficients has length n+1)

  • _n : polynomial order
  • _p : polynomial coefficients, shape: (_n+1, 1)

int polyc_expandbinomial_pm(unsigned int _m, unsigned int _k, double complex * _p)

Perform positive/negative binomial expansion on the polynomial \( P_n(x) = (1+x)^m (1-x)^k \) as \( P_n(x) = p[0] + p[1]x + p[2]x^2 + ... + p[n]x^n \) NOTE: _p has order n=m+k (array is length n+1)

  • _m : number of '1+x' terms
  • _k : number of '1-x' terms
  • _p : polynomial coefficients, shape: (_m+_k+1, 1)

int polyc_expandroots(double complex * _r, unsigned int _n, double complex * _p)

Perform root expansion on the polynomial \( P_n(x) = (x-r[0]) (x-r[1]) ... (x-r[n-1]) \) as \( P_n(x) = p[0] + p[1]x + ... + p[n]x^n \) where \( r[0],r[1],...,r[n-1]\) are the roots of \( P_n(x) \). NOTE: _p has order _n (array is length _n+1)

  • _r : roots of polynomial, shape: (_n, 1)
  • _n : number of roots in polynomial
  • _p : polynomial coefficients, shape: (_n+1, 1)

int polyc_expandroots2(double complex * _a, double complex * _b, unsigned int _n, double complex * _p)

Perform root expansion on the polynomial \( P_n(x) = (xb[0]-a[0]) (xb[1]-a[1])...(xb[n-1]-a[n-1]) \) as \( P_n(x) = p[0] + p[1]x + ... + p[n]x^n \) NOTE: _p has order _n (array is length _n+1)

  • _a : subtractant of polynomial rotos, shape: (_n, 1)
  • _b : multiplicant of polynomial roots, shape: (_n, 1)
  • _n : number of roots in polynomial
  • _p : polynomial coefficients, shape: (_n+1, 1)

int polyc_findroots(double complex * _poly, unsigned int _n, double complex * _roots)

Find the complex roots of a polynomial.

  • _poly :
  • _n :
  • _roots : resulting complex roots, shape: (_k-1, 1)

int polyc_findroots_durandkerner(double complex * _p, unsigned int _k, double complex * _roots)

Find the complex roots of the polynomial using the Durand-Kerner method

  • _p : polynomial coefficients, shape: (_n, 1)
  • _k : polynomial length
  • _roots : resulting complex roots, shape: (_k-1, 1)

int polyc_findroots_bairstow(double complex * _p, unsigned int _k, double complex * _roots)

Find the complex roots of the polynomial using Bairstow's method.

  • _p : polynomial coefficients, shape: (_n, 1)
  • _k : polynomial length
  • _roots : resulting complex roots, shape: (_k-1, 1)

int polyc_mul(double complex * _a, unsigned int _order_a, double complex * _b, unsigned int _order_b, double complex * _c)

Expand the multiplication of two polynomials \( ( a[0] + a[1]x + a[2]x^2 + ...) (b[0] + b[1]x + b[]x^2 + ...) \) as \( c[0] + c[1]x + c[2]x^2 + ... + c[n]x^n \) where order(c) = order(a) + order(b) + 1 and therefore length(c) = length(a) + length(b) - 1

  • _a : 1st polynomial coefficients (length is _order_a+1)
  • _order_a : 1st polynomial order
  • _b : 2nd polynomial coefficients (length is _order_b+1)
  • _order_b : 2nd polynomial order
  • _c : output polynomial, shape: (_order_a+_order_b+1, 1)