kthvalue(input: Tensor, k: _int, dim: _int = ..., keepdim: _bool = ...)Implementing kernel
C++ engine symbols that back this Python API.Return the k-th smallest value along dim and its index.
Indices are 1-based: k=1 is the minimum, k=size(dim) is the
maximum. Equivalent to sort followed by an index along
dim but typically faster (O(n) via quickselect).
Parameters
inputTensorSource tensor.
kintRank of the desired order statistic (1-based).
dimint= -1Reduction axis.
keepdimbool= FalseRetain reduced dim with size 1.
Returns
Notes
Ties are broken by the order in which they appear in input.
Behaviour is undefined if k is outside [1, size(dim)].
Examples
>>> import lucid
>>> x = lucid.tensor([5.0, 1.0, 4.0, 2.0, 3.0])
>>> lucid.kthvalue(x, k=2, dim=0)
(Tensor(2.), Tensor(3))