public void Negate() { // arrange var input = NdArray <bool> .Zeros(HostDevice.Instance, new int[] { 10 }); // action var output = LogicalFunction <bool> .Negate(input); // assert Assert.IsTrue(NdArray <bool> .All(output)); }
public void Any() { // arrange var input = NdArray <bool> .Zeros(HostDevice.Instance, new int[] { 2, 4 }); input[new[] { 0, 1 }] = true; // action var output = LogicalFunction <bool> .Any(input); // assert Assert.AreEqual(true, output); }
public void All() { // arrange var input = NdArray <bool> .Ones(HostDevice.Instance, new int[] { 2, 4 }); input[new[] { 0, 1 }] = false; // action var output = LogicalFunction <bool> .All(input); // assert Assert.AreEqual(false, output); }
void InitFunction() { if (_fns == null) { _fns = new Dictionary <string, FunctionDefinition>(StringComparer.InvariantCultureIgnoreCase); LogicalFunction.Register(this); MathFunction.Register(this); TextFunction.Register(this); StatisticalFunction.Register(this); (new CollectionFunction(this)).Register(); } }
public void CountTrue() { // arrange var input = NdArray <bool> .Ones(HostDevice.Instance, new int[] { 2, 4 }); input[new[] { 0, 1 }] = false; input[new[] { 1, 0 }] = false; input[new[] { 1, 3 }] = false; // action var output = LogicalFunction <bool> .CountTrue(input); // assert Assert.AreEqual(5, output); }
public void Xor() { // arrange var input1 = NdArray <bool> .Zeros(HostDevice.Instance, new int[] { 2 }); var input2 = NdArray <bool> .Ones(HostDevice.Instance, new int[] { 2 }); input2[0].Value = false; // action var output = LogicalFunction <bool> .Xor(input1, input2); // assert Assert.AreEqual(false, output[0].Value); Assert.AreEqual(true, output[1].Value); }
public void AnyAxis() { // arrange var input = NdArray <bool> .Zeros(HostDevice.Instance, new int[] { 2, 4 }); input[new[] { 0, 1 }] = true; // action var output0 = LogicalFunction <bool> .AnyAxis(0, input); var output1 = LogicalFunction <bool> .AnyAxis(1, input); // assert Assert.AreEqual(true, output0[1].Value); Assert.AreEqual(false, output1[1].Value); }
public void Or() { // arrange var input1 = NdArray <bool> .Zeros(HostDevice.Instance, new int[] { 4 }); var input2 = NdArray <bool> .Ones(HostDevice.Instance, new int[] { 4 }); // action var output = LogicalFunction <bool> .Or(input1, input2); // assert var expected = NdArray <bool> .Ones(HostDevice.Instance, new int[] { 4 }); var result = expected == output; Assert.IsTrue(NdArray <bool> .All(result)); }
public void CountTrueAxis() { // arrange var input = NdArray <bool> .Ones(HostDevice.Instance, new int[] { 2, 4 }); input[new[] { 0, 1 }] = false; input[new[] { 1, 0 }] = false; input[new[] { 1, 3 }] = false; // action var output0 = LogicalFunction <bool> .CountTrueAxis(0, input); var output1 = LogicalFunction <bool> .CountTrueAxis(1, input); // assert Assert.AreEqual(1, output0[0].Value); Assert.AreEqual(2, output1[1].Value); }
public void IfThenElse() { // arrange var condition = NdArray <bool> .Ones(HostDevice.Instance, new int[] { 4 }); var ifTrue = NdArray <int> .Ones(HostDevice.Instance, new int[] { 4 }); var ifFalse = NdArray <int> .Zeros(HostDevice.Instance, new int[] { 4 }); condition[new[] { 0 }] = false; condition[new[] { 2 }] = false; // action var output = LogicalFunction <int> .IfThenElse(condition, ifTrue, ifFalse); // assert Assert.AreEqual(0, output[0].Value); Assert.AreEqual(1, output[1].Value); Assert.AreEqual(0, output[2].Value); Assert.AreEqual(1, output[3].Value); }