numpoly.cross_truncate¶
- numpoly.cross_truncate(indices: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray], bound: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray], norm: float) → numpy.ndarray[source]¶
Truncate of indices using L_p norm.
where \(b_i\) are bounds that each \(x_i\) should follow.
- Args:
- indices:
Indices to be truncated.
- bound:
The bound function for witch the indices can not be larger than.
- norm:
The p in the L_p-norm. Support includes both L_0 and L_inf.
- Returns:
Boolean indices to
indiceswith True for each index where the truncation criteria holds.- Examples:
>>> indices = numpy.array(numpy.mgrid[:10, :10]).reshape(2, -1).T >>> indices[cross_truncate(indices, 2, norm=0.)].T array([[0, 0, 0, 1, 2], [0, 1, 2, 0, 0]]) >>> indices[cross_truncate(indices, 2, norm=1.)].T array([[0, 0, 0, 1, 1, 2], [0, 1, 2, 0, 1, 0]]) >>> indices[cross_truncate(indices, [0, 1], norm=1.)].T array([[0, 0], [0, 1]])