harold.haroldgcd

harold.haroldgcd(*args)

Takes 1D numpy arrays and computes the numerical greatest common divisor polynomial. The polynomials are assumed to be in decreasing powers, e.g. \(s^2 + 5\) should be given as numpy.array([1,0,5]).

Returns a numpy array holding the polynomial coefficients of GCD. The GCD does not cancel scalars but returns only monic roots. In other words, the GCD of polynomials \(2\) and \(2s+4\) is still computed as \(1\).

Parameters:args (iterable) – A collection of 1D array_likes.
Returns:gcdpoly (ndarray) – Computed GCD of args.

Examples

>>> a = haroldgcd(*map(haroldpoly,([-1,-1,-2,-1j,1j],
                                   [-2,-3,-4,-5],
                                   [-2]*10)))
>>> a
array([ 1.,  2.])

Warning

It uses the LU factorization of the Sylvester matrix. Use responsibly. It does not check any certificate of success by any means (maybe it will in the future). I have played around with ERES method but probably due to my implementation, couldn’t get satisfactory results. I am still interested in better methods.