Skip to main content

ClikaRT::ops::searchsorted

function

searchsorted()

Tensor searchsorted(
    Tensor sorted_sequence,
    Tensor values,
    bool out_int32 = false,
    bool right = false,
    std::optional<bool> side = std::nullopt,
    OptionalTensor sorter = {}
)

Insertion points of values into a sorted sequence.

For each value, the index in sorted_sequence's last axis where it would insert to keep the order: right == false gives the leftmost admissible slot, true the rightmost. side, when present, must AGREE with right (it is the same switch under its string-API name); sorter supplies indices that sort an unsorted sequence.

Parameters

  • sorted_sequence: the sorted haystack (last-axis sorted).
  • values: the needles; output mirrors this shape.
  • out_int32: emit Int32 indices instead of Int64.
  • right: insertion side for ties; default false (left).
  • side: optional string-API twin of right; a present value that contradicts right is an error.
  • sorter: optional Int64/Int32 indices sorting the sequence.

Returns: integer insertion indices, shaped like values.

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when side contradicts right or the operand shapes are incompatible.

Declared in ClikaRT/compute/ops.h, line 4618