adder

二つの信号を足します。 2つ目の信号は、演算により生成された理想信号でなければいけません。

adder
(
Sg1
Sg2
)
(
Sg1 sg1
,
Sg2 sg2
)
if (
isInfinite!Sg2
)

Examples

scope(failure) {writefln("Unittest failure :%s(%s)", __FILE__, __LINE__); stdout.flush();}
scope(success) {writefln("Unittest success :%s(%s)", __FILE__, __LINE__); stdout.flush();}

auto arr1 = [0, 1, 0, 1, 0, 1, 0, 1].repeatStream;
auto arr2 = [0, 0, 1, 1, 0, 0, 1, 1].repeatStream;
auto mx1 = arr1.adder(arr2);
static assert(isInfinite!(typeof(mx1)));
static assert(isInputStream!(typeof(mx1)));

int[] buf1 = new int[16];
assert(mx1.read(buf1) == [0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2]);
scope(failure) {writefln("Unittest failure :%s(%s)", __FILE__, __LINE__); stdout.flush();}
scope(success) {writefln("Unittest success :%s(%s)", __FILE__, __LINE__); stdout.flush();}

auto arr1 = [0, 1, 0, 1, 0, 1, 0, 1].repeatStream;
auto buf1 = arr1.adder(arr1).adder(arr1).read(new int[16]);
auto buf2 = arr1.amplifier(3).read(new int[16]);

assert(buf1 == buf2);

Meta