adder

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

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

Examples

1 scope(failure) {writefln("Unittest failure :%s(%s)", __FILE__, __LINE__); stdout.flush();}
2 scope(success) {writefln("Unittest success :%s(%s)", __FILE__, __LINE__); stdout.flush();}
3 
4 auto arr1 = [0, 1, 0, 1, 0, 1, 0, 1].repeatStream;
5 auto arr2 = [0, 0, 1, 1, 0, 0, 1, 1].repeatStream;
6 auto mx1 = arr1.adder(arr2);
7 static assert(isInfinite!(typeof(mx1)));
8 static assert(isInputStream!(typeof(mx1)));
9 
10 int[] buf1 = new int[16];
11 assert(mx1.read(buf1) == [0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2]);
1 scope(failure) {writefln("Unittest failure :%s(%s)", __FILE__, __LINE__); stdout.flush();}
2 scope(success) {writefln("Unittest success :%s(%s)", __FILE__, __LINE__); stdout.flush();}
3 
4 auto arr1 = [0, 1, 0, 1, 0, 1, 0, 1].repeatStream;
5 auto buf1 = arr1.adder(arr1).adder(arr1).read(new int[16]);
6 auto buf2 = arr1.amplifier(3).read(new int[16]);
7 
8 assert(buf1 == buf2);

Meta