chaospy.nonzero

chaospy.nonzero(x: 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]], numpoly.baseclass.ndpoly], **kwargs: Any) Tuple[numpy.ndarray, ...][source]

Return the indices of the elements that are non-zero.

Args:
x:

Input array.

Return:

Indices of elements that are non-zero.

Example:
>>> q0, q1 = numpoly.variable(2)
>>> poly = numpoly.polynomial([[3*q0, 0, 0],
...                            [0, 4*q1, 0],
...                            [5*q0+q1, 6*q0, 0]])
>>> poly
polynomial([[3*q0, 0, 0],
            [0, 4*q1, 0],
            [q1+5*q0, 6*q0, 0]])
>>> numpoly.nonzero(poly)
(array([0, 1, 2, 2]), array([0, 1, 0, 1]))
>>> poly[numpoly.nonzero(poly)]
polynomial([3*q0, 4*q1, q1+5*q0, 6*q0])