예제 #1
0
        public void DivideSingleValues()
        {
            INode <double> left  = Flow.Constant(10.0);
            INode <double> right = Flow.Constant(4.0);

            var divide = new DivideDoubleOperation(left, right);

            Assert.AreEqual(left.Rank, divide.Rank);
            Assert.IsTrue(left.Shape.SequenceEqual(right.Shape));

            var result = divide.Evaluate();

            Assert.IsNotNull(result);
            Assert.AreEqual(left.Rank, result.Rank);
            Assert.IsTrue(left.Shape.SequenceEqual(result.Shape));
            Assert.AreEqual(2.5, result.GetValue());
        }
예제 #2
0
        public void DivideVectors()
        {
            INode <double> left  = Flow.Constant(new double[] { 4, 5, 6 });
            INode <double> right = Flow.Constant(new double[] { 1, 2, 3 });

            var divide = new DivideDoubleOperation(left, right);

            Assert.AreEqual(left.Rank, divide.Rank);
            Assert.IsTrue(left.Shape.SequenceEqual(right.Shape));

            var result = divide.Evaluate();

            Assert.IsNotNull(result);
            Assert.AreEqual(left.Rank, result.Rank);
            Assert.IsTrue(left.Shape.SequenceEqual(result.Shape));
            Assert.AreEqual(4.0, result.GetValue(0));
            Assert.AreEqual(2.5, result.GetValue(1));
            Assert.AreEqual(2.0, result.GetValue(2));
        }
예제 #3
0
        public void DivideMatrices()
        {
            INode <double> left  = Flow.Constant(new double[][] { new double[] { 10, 20, 30 }, new double[] { 40, 50, 60 } });
            INode <double> right = Flow.Constant(new double[][] { new double[] { 1, 2, 3 }, new double[] { 4, 5, 6 } });

            var divide = new DivideDoubleOperation(left, right);

            Assert.AreEqual(left.Rank, divide.Rank);
            Assert.IsTrue(left.Shape.SequenceEqual(right.Shape));

            var result = divide.Evaluate();

            Assert.IsNotNull(result);
            Assert.AreEqual(left.Rank, result.Rank);
            Assert.IsTrue(left.Shape.SequenceEqual(result.Shape));

            Assert.AreEqual(10, result.GetValue(0, 0));
            Assert.AreEqual(10, result.GetValue(0, 1));
            Assert.AreEqual(10, result.GetValue(0, 2));

            Assert.AreEqual(10, result.GetValue(1, 0));
            Assert.AreEqual(10, result.GetValue(1, 1));
            Assert.AreEqual(10, result.GetValue(1, 2));
        }