public void TestAbs() { var input = new [] { 2.1, 3.2, -1, -1.3, -100, 145, -2 }; var expected = new [] { 2.1, 3.2, 1, 1.3, 100, 145, 2 }; Assert.IsTrue(TestUtils.SequenceEquals(expected, WaveMath.Abs(input))); var signal = new Signal(input); WaveMath.Abs(ref signal, input); Assert.IsTrue(TestUtils.SequenceEquals(expected, signal.Samples)); input = new double[] { }; expected = new double[] { }; Assert.IsTrue(TestUtils.SequenceEquals(expected, WaveMath.Abs(input))); }
public void TestAbsFromComplex() { var input = new[] { 2.1, 3.2, 1, -1.3, -100, 145, -2 }; var expected = new[] { 3.8275318418009276, 1.6401219466856727, 176.13914953808538, 2 }; Assert.IsTrue(TestUtils.SequenceEquals(expected, WaveMath.AbsFromComplex(input))); var signal = new Signal(input) { IsComplex = true }; WaveMath.Abs(ref signal, input); Assert.IsTrue(TestUtils.SequenceEquals(expected, signal.Samples)); input = new double[] { }; expected = new double[] { }; Assert.IsTrue(TestUtils.SequenceEquals(expected, WaveMath.AbsFromComplex(input))); }
/// <summary> /// Executes the block /// </summary> public override void Execute() { var inputNode = InputNodes[0].ConnectingNode as BlockOutputNode; if (inputNode == null || inputNode.Object == null) { return; } OutputNodes[0].Object.Clear(); foreach (var signal in inputNode.Object) { var output = signal.Copy(); WaveMath.Abs(ref output, signal.Samples); OutputNodes[0].Object.Add(output); } if (Cascade && OutputNodes[0].ConnectingNode != null) { OutputNodes[0].ConnectingNode.Root.Execute(); } }