public void Gradient()
        {
            var f = new PolynomialFunction <double>();

            var grad = f.Gradient(new Vector <double>(new[] { 2d }),
                                  new Vector <double>(new[] { 3d })).ToArray();

            Assert.Single(grad);

            Assert.True(1e-14 > Math.Abs(1 - grad[0]));

            grad = f.Gradient(new Vector <double>(new[] { 2d, 1d }),
                              new Vector <double>(new[] { 2d })).ToArray();

            Assert.True(grad.Length == 2);
            Assert.True(1e-14 > Math.Abs(2 - grad[0]));
            Assert.True(1e-14 > Math.Abs(1 - grad[1]));

            grad = f.Gradient(new Vector <double>(new[] { 2d, 3d, 1d }),
                              new Vector <double>(new[] { 2d })).ToArray();

            Assert.True(grad.Length == 3);
            Assert.True(1e-14 > Math.Abs(4 - grad[0]));
            Assert.True(1e-14 > Math.Abs(2 - grad[1]));
            Assert.True(1e-14 > Math.Abs(1 - grad[2]));
        }
        public void Value()
        {
            var f = new PolynomialFunction <double>();

            Assert.True(1e-14 > Math.Abs(2 - f.Value(new Vector <double>(new[] { 2d }),
                                                     new Vector <double>(new[] { 2d }))));

            Assert.True(1e-14 > Math.Abs(3 - f.Value(new Vector <double>(new[] { 3d }),
                                                     new Vector <double>(new[] { 2d }))));

            Assert.True(1e-14 > Math.Abs(7 - f.Value(new Vector <double>(new[] { 3d, 1d }),
                                                     new Vector <double>(new[] { 2d }))));

            Assert.True(1e-14 > Math.Abs(34 - f.Value(new Vector <double>(new[] { 3d, 2d, 1d }),
                                                      new Vector <double>(new[] { 3d }))));
        }