The OpenD Programming Language

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, sizediff_t axis)
    Slice!(Iterator, N + 1, kind)
    unsqueeze
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) slice
    ,
    sizediff_t axis
    )
  2. template unsqueeze(sizediff_t axis = 0)

Parameters

slice Slice!(Iterator, N, kind)

n-dimensional slice

axis sizediff_t

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

Return Value

Type: Slice!(Iterator, N + 1, kind)

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