The OpenD Programming Language

padWrap

Pads with the wrap of the slice along the axis. The first values are used to pad the end and the end values are used to pad the beginning.

  1. auto padWrap(Slice!(Iterator, N, kind) s, size_t[N] lengths)
    padWrap
    (
    string direction = "both"
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) s
    ,
    size_t[N] lengths...
    )
  2. template padWrap(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. Each length must be less or equal to the corresponding slice length.

Return Value

Type: auto

Examples

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

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

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

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

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

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

    [2,  1, 2,  1],
    [4,  3, 4,  3]]);

See Also

._concatenation examples.

Meta