numpoly.remove_redundant_coefficients¶
- numpoly.remove_redundant_coefficients(exponents: Union[numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], coefficients: Sequence[Union[numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]]) → Tuple[numpy.ndarray, List[numpy.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)
, whereN
is the number of terms in the polynomial sum andD
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)])