mir_slice.opBinary

Element-wise operator overloading for scalars.

  1. auto opBinary(T value)
    struct mir_slice(Iterator_, size_t N_ = 1, SliceKind kind_ = Contiguous, Labels_...)
    scope return
    @optmath
    opBinary
    (
    string op
    T
    )
    (
    scope return T value
    )
    if ()
    if (
    0 < N_ &&
    N_ < 255
    &&
    !(
    kind_ == Canonical &&
    N_ == 1
    )
    &&
    Labels_.length <= N_
    &&
    isIterator!Iterator_
    )
  2. auto opBinary(Slice!(RIterator, RN, rkind) rhs)
  3. auto opBinaryRight(T value)

Parameters

value T

a scalar

Return Value

Type: auto

lazy slice of the same kind and the same structure Note: Does not allocate neither new slice nor a closure.

Examples

import mir.ndslice.topology;

// 0 1 2 3
auto s = iota([4]);
// 0 1 2 0
assert(s % 3 == iota([4]).map!"a % 3");
// 0 2 4 6
assert(2 * s == iota([4], 0, 2));
import mir.ndslice.topology;

// 0 1 2 3
auto s = iota([4]);
// 0 1 4 9
assert(s ^^ 2.0 == iota([4]).map!"a ^^ 2.0");

Meta