repeat - multiple declarations

Function repeat

Repeats the output of an operation along each axis the given number of times.

Operation repeat (
  Operation input,
  ulong[] repetitions,
  string mod = __MODULE__,
  ulong line = cast(ulong)__LINE__
);

Parameters

NameDescription
input The operation to have its output repeated.
repetitions The number of repetitions to perform along each axis.

Return

The new Operation.

Example

import dopt.core : evaluate;

auto r1 = float32([1, 1], [3.0f]).repeat([2, 3]);
auto r2 = float32([2, 2], [1.0f, 2.0f, 3.0f, 4.0f]).repeat([3, 2]);

assert(r1.evaluate().as!float == [
    3.0f, 3.0f, 3.0f,
    3.0f, 3.0f, 3.0f
]);

assert(r2.evaluate().as!float == [
    1.0f, 2.0f, 1.0f, 2.0f,
    3.0f, 4.0f, 3.0f, 4.0f,
    1.0f, 2.0f, 1.0f, 2.0f,
    3.0f, 4.0f, 3.0f, 4.0f,
    1.0f, 2.0f, 1.0f, 2.0f,
    3.0f, 4.0f, 3.0f, 4.0f
]);

Function repeat

Repeats the output of an operation the given number of times.

Operation repeat (
  Operation input,
  ulong repetitions,
  string mod = __MODULE__,
  ulong line = cast(ulong)__LINE__
);

A new dimension is added, allowing one to index each of these repetitions.

Parameters

NameDescription
input The operation to have its output repeated.
repetitions The number of repetitions to perform.

Return

The new Operation.

Example

import dopt.core : evaluate;

auto r1 = float32([2], [1.0f, 2.0f]).repeat(3);

assert(r1.evaluate().as!float == [
    1.0f, 2.0f,
    1.0f, 2.0f,
    1.0f, 2.0f
]);