numpoly.remove_redundant_coefficients#

numpoly.remove_redundant_coefficients(exponents: ArrayLike, coefficients: Sequence[ArrayLike]) Tuple[ndarray, List[ndarray]][source]#

Remove coefficients if they are redundant to the polynomial representation.

Will always keep at least one coefficient.

Args:
exponents:

The exponents in an integer array with shape (N, D), where N is the number of terms in the polynomial sum and D is the number of dimensions.

coefficients:

The polynomial coefficients. Must correspond to exponents by having the same length N.

Return:

Same as inputs, but with redundant exponent rows and coefficients removed. This corresponds to N being lowered.

Example:
>>> exponents, coefficients = remove_redundant_coefficients(
...     [[0, 0], [0, 1]], [1, 2])
>>> exponents
array([[0, 0],
       [0, 1]])
>>> coefficients
[array(1), array(2)]
>>> remove_redundant_coefficients(
...     [[0, 0], [0, 1]], [1, 0])
(array([[0, 0]]), [array(1)])
>>> remove_redundant_coefficients([[0]], [[]])
(array([[0]]), [array([], dtype=float64)])