harold.haroldlcm¶

harold.haroldlcm(*args, compute_multipliers=True, cleanup_threshold=1e-09)

Takes n-many 1D numpy arrays and computes the numerical least common multiple polynomial. The polynomials are assumed to be in decreasing powers, e.g. s^2 + 5 should be given as [1,0,5]

Returns a numpy array holding the polynomial coefficients of LCM and a list, of which entries are the polynomial multipliers to arrive at the LCM of each input element.

For the multiplier computation, a variant of [1] is used.

Parameters: args (iterable) – Input arrays. 1-D arrays or array_like sequences of polynomial coefficients compute_multipliers (bool, optional) – After the computation of the LCM, this switch decides whether the multipliers of the given arguments should be computed or skipped. A multiplier in this context is [1,3] for the argument [1,2] if the LCM turns out to be [1,5,6]. cleanup_threshold (float) – The computed polynomials might contain some numerical noise and after finishing everything this value is used to clean up the tiny entries. Set this value to zero to turn off this behavior. The default value is $$10^{-9}$$. lcmpoly (ndarray) – Resulting 1D polynomial coefficient array for the LCM. mults (list) – The multipliers given as a list of 1D arrays, for each given argument.

Notes

If complex-valued arrays are given, only real parts are taken into account.

Examples

>>> a , b = haroldlcm([1,3,0,-4], [1,-4,-3,18], [1,-4,3], [1,-2,-8])
>>> a
array([   1.,   -7.,    3.,   59.,  -68., -132.,  144.]
>>> b
[array([  1., -10.,  33., -36.]),
array([  1.,  -3.,  -6.,   8.]),
array([  1.,  -3., -12.,  20.,  48.]),
array([  1.,  -5.,   1.,  21., -18.])]
>>> np.convolve([1, 3, 0, -4], b[0]) # or haroldpolymul() for poly mult
(array([   1.,   -7.,    3.,   59.,  -68., -132.,  144.]),


References

 [1] Karcanias, Mitrouli, “System theoretic based characterisation and computation of the least common multiple of a set of polynomials”, 2004, DOI:10.1016/j.laa.2003.11.009