예제 #1
0
        public void ForwardTest3()
        {
            var topology = new Forward(states: 3, deepness: 2);

            double[,] actualA;
            double[] actualPi;

            double[,] expectedA;
            double[] expectedPi;

            int actualStates   = topology.Create(true, out actualA, out actualPi);
            int expectedStates = topology.Create(false, out expectedA, out expectedPi);

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Assert.AreEqual(actualA[i, j], System.Math.Log(expectedA[i, j]));
                }
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Assert.AreEqual(actualPi[i], System.Math.Log(expectedPi[i]));
                }
            }

            Assert.AreEqual(actualStates, expectedStates);
            Assert.AreEqual(actualStates, 3);
        }
예제 #2
0
        public void ForwardTest2()
        {
            var topology = new Forward(3, 2);

            Assert.AreEqual(topology.States, 3);
            Assert.AreEqual(topology.Deepness, 2);

            double[,] actual;
            double[] pi;
            int      states   = topology.Create(false, out actual, out pi);
            var      expected = new double[, ]
            {
                { 0.50, 0.50, 0.00 },
                { 0.00, 0.50, 0.50 },
                { 0.00, 0.00, 1.00 },
            };

            Assert.IsTrue(actual.IsEqual(expected, 0.01));
            Assert.AreEqual(states, 3);
        }