numpoly.cross_truncate#

numpoly.cross_truncate(indices: ArrayLike, bound: ArrayLike, norm: float) 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.

Return:

Boolean indices to indices with True for each index where the truncation criteria holds.

Example:
>>> 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]])