unsqueeze

Constructs a view of an n-dimensional slice with a dimension added at axis. Used to unsqueeze a squeezed slice.

  1. Slice!(Iterator, N + 1, kind) unsqueeze(Slice!(Iterator, N, kind) slice)
    template unsqueeze(sizediff_t axis = 0)
    @optmath
    Slice!(Iterator, N + 1, kind)
    unsqueeze
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) slice
    )
  2. Slice!(Iterator, N + 1, kind) unsqueeze(Slice!(Iterator, N, kind) slice, sizediff_t axis)

Members

Functions

unsqueeze
Slice!(Iterator, N + 1, kind) unsqueeze(Slice!(Iterator, N, kind) slice)
Undocumented in source.

Parameters

slice

n-dimensional slice

axis

dimension to be unsqueezed (add new dimension), default values is 0, the first dimension

Return Value

unsqueezed n+1-dimensional slice of the same slice kind

Examples

// [0, 1, 2] -> [[0, 1, 2]]
assert([3].iota.unsqueeze == [1, 3].iota);

assert([3].iota.universal.unsqueeze == [1, 3].iota);
assert([3, 4].iota.unsqueeze == [1, 3, 4].iota);
assert([3, 4].iota.canonical.unsqueeze == [1, 3, 4].iota);
assert([3, 4].iota.universal.unsqueeze == [1, 3, 4].iota);

// [0, 1, 2] -> [[0], [1], [2]]
assert([3].iota.unsqueeze(-1) == [3, 1].iota);
assert([3].iota.unsqueeze!(-1) == [3, 1].iota);

assert([3].iota.universal.unsqueeze(-1) == [3, 1].iota);
assert([3].iota.universal.unsqueeze!(-1) == [3, 1].iota);
assert([3, 4].iota.unsqueeze(-1) == [3, 4, 1].iota);
assert([3, 4].iota.unsqueeze!(-1) == [3, 4, 1].iota);
assert([3, 4].iota.canonical.unsqueeze(-1) == [3, 4, 1].iota);
assert([3, 4].iota.canonical.unsqueeze!(-1) == [3, 4, 1].iota);
assert([3, 4].iota.universal.unsqueeze(-1) == [3, 4, 1].iota);
assert([3, 4].iota.universal.unsqueeze!(-1) == [3, 4, 1].iota);

See Also

Meta