コード例 #1
0
        public void TestDivideScalar()
        {
            var          array1   = new[] { 1.2, 2.3, 3.4, 4.5 };
            const double scalar   = 1.1;
            var          expected = new[] { 1.09090909, 2.09090909, 3.09090909, 4.09090909 };

            Assert.IsTrue(TestUtils.SequenceEquals(expected, WaveMath.Divide(array1, scalar)));

            expected = new[] { 0.0, 0.0, 0.0, 0.0 };
            Assert.IsTrue(TestUtils.SequenceEquals(expected, WaveMath.Divide(array1, 0)));
        }
コード例 #2
0
        public void TestDivideArrays()
        {
            var array1    = new[] { 2, 4, 0, 12.0 };
            var array2    = new[] { 1, 0, 3, 8.0 };
            var expected1 = new[] { 2, 0, 0, 1.5 };
            var expected2 = new[] { 0.5, 0, 0, 0.6666667 };
            var expected3 = new[] { 2, 0, 0, 12.0 };
            var expected4 = new[] { 0.5, 0, 0, 8 };

            Assert.IsTrue(TestUtils.SequenceEquals(expected1, WaveMath.GetOperationFunction(WaveMath.OperationEnum.Divide)(array1, array2)));
            Assert.IsTrue(TestUtils.SequenceEquals(expected2, WaveMath.Divide(array2, array1)));
            Assert.IsTrue(TestUtils.SequenceEquals(expected3, WaveMath.Divide(array1, array2.SubArray(3))));
            Assert.IsTrue(TestUtils.SequenceEquals(expected4, WaveMath.Divide(array1.SubArray(3), array2)));
        }