minmaxIndex

Finds a backward indices such that slice[indices[0]] is minimal and slice[indices[1]] is maximal elements in the slice.

  1. size_t[N][2] minmaxIndex(Slice!(Iterator, N, kind) slice)
    template minmaxIndex(alias pred = "a < b")
    @optmath
    static if(__traits(isSame, naryFun!pred, pred))
    @optmath
    size_t[N][2]
    minmaxIndex
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) slice
    )
  2. alias minmaxIndex = .minmaxIndex!(naryFun!pred)

Members

Aliases

minmaxIndex
alias minmaxIndex = .minmaxIndex!(naryFun!pred)
Undocumented in source.

Functions

minmaxIndex
size_t[N][2] minmaxIndex(Slice!(Iterator, N, kind) slice)

Parameters

pred

A predicate.

Examples

import mir.ndslice.slice: sliced;
auto s = [
    2, 6, 4, -3,
    0, -4, -3, 3,
    -3, -2, 7, 8,
    ].sliced(3, 4);

auto indices = s.minmaxIndex;

assert(indices == [[1, 1], [2, 3]]);
assert(s[indices[0]] == -4);
assert(s[indices[1]] ==  8);

See Also

Meta