center

Lazily centers a slice.

  1. auto center(S slice)
    template center(sumTemplateArgs...)
    nothrow @nogc deprecated nothrow pure @nogc
    center
    (
    S
    )
    ()
    if (
    isSlice!S
    )
  2. auto center(S slice, Seed seed)

Members

Functions

center
deprecated auto center(S slice)
center
deprecated auto center(S slice, Seed seed)
Undocumented in source. Be warned that the author may not have intended to support it.

Parameters

sumTemplateArgs

template arguments to pass to mir.math.sum (to compute the mean of the slice)

Examples

Center vector

import mir.ndslice.slice : sliced;

static immutable x = [0.0, 1.0, 1.5, 2.0, 3.5, 4.25,
                      2.0, 7.5, 5.0, 1.0, 1.5, 0.0];
static immutable result = [-2.4375, -1.4375, -0.9375, -0.4375,  1.0625,  1.8125,
                           -0.4375,  5.0625,  2.5625, -1.4375, -0.9375, -2.4375];
assert(x.sliced.center == result.sliced);

Center matrix

import mir.ndslice.slice : sliced;

static immutable x = [0.0, 1.0, 1.5, 2.0, 3.5, 4.25,
                      2.0, 7.5, 5.0, 1.0, 1.5, 0.0];
static immutable result = [-2.4375, -1.4375, -0.9375, -0.4375,  1.0625,  1.8125,
                           -0.4375,  5.0625,  2.5625, -1.4375, -0.9375, -2.4375];
assert(x.sliced(2, 6).center == result.sliced(2, 6));

See Also

$(MATHREF sum, sum)

Meta