padEdge

Pads with the edge values of slice.

  1. auto padEdge(Slice!(Iterator, N, kind) s, size_t[N] lengths)
    @optmath
    padEdge
    (
    string direction = "both"
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) s
    ,
    size_t[N] lengths...
    )
  2. template padEdge(size_t[] dimensions, string[] directions)

Parameters

direction

padding direction. Direction can be one of the following values: "both", "pre", and "post".

s Slice!(Iterator, N, kind)
lengths size_t[N]

list of lengths for each dimension.

Return Value

Type: auto

Examples

import mir.ndslice.allocation: slice;
import mir.ndslice.topology: iota;

auto pad = iota([3], 1)
    .padEdge([2])
    .slice;

assert(pad == [1, 1,  1, 2, 3,  3, 3]);
import mir.ndslice.allocation: slice;
import mir.ndslice.topology: iota;

auto pad = iota([2, 2], 1)
    .padEdge([2, 1])
    .slice;

assert(pad == [
    [1,  1, 2,  2],
    [1,  1, 2,  2],

    [1,  1, 2,  2],
    [3,  3, 4,  4],

    [3,  3, 4,  4],
    [3,  3, 4,  4]]);

See Also

._concatenation examples.

Meta