antidiagonal

Returns a 1-dimensional slice over the main antidiagonal of an 2D-dimensional slice. antidiagonal can be generalized with other selectors such as blocks (diagonal blocks) and windows (multi-diagonal slice).

It runs from the top right corner to the bottom left corner.

More...
@optmath
Slice!(Iterator, 1, Universal)
antidiagonal
(
Iterator
size_t N
SliceKind kind
)
(
Slice!(Iterator, N, kind) slice
)
if (
N == 2
)

Parameters

slice Slice!(Iterator, N, kind)

input slice

Return Value

Type: Slice!(Iterator, 1, Universal)

1-dimensional slice composed of antidiagonal elements.

Detailed Description

Pseudo code

auto antidiagonal = slice.dropToHypercube.reversed!1.diagonal;

Examples

//  -----
// | 0 1 |
// | 2 3 |
//  -----
//->
// | 1 2 |
static immutable c = [1, 2];
import std.stdio;
assert(iota(2, 2).antidiagonal == c);
//  -------
// | 0 1 2 |
// | 3 4 5 |
//  -------
//->
// | 1 3 |
static immutable d = [1, 3];
assert(iota(2, 3).antidiagonal == d);

See Also

Meta