Beispiel #1
0
        public void ConstructMatrixTest()
        {
            // Arrange
            var a = 3;
            var b = 2;
            Func<double, double> f = t => 6 * t * t * t + 25 * t * t + 12 * t - 2;

            var solver = new DiffEqSolver(x => 1, x => a, x => b, f, 0, 0);

            int n = 3;
            double[] nodes = { 0, 0.5, 1 };

            double[,] A;
            double[] B;

            // Act
            solver.ConstructMatrix(nodes, n, out A, out B);

            // Assert
            Assert.AreEqual(nodes.Length, A.GetLength(0));
            Assert.AreEqual(n, A.GetLength(1));
            Assert.AreEqual(nodes.Length, B.Length);

            Assert.AreEqual(new[] { f(0), f(0.5), f(1) }, B);
        }
Beispiel #2
0
        public void Init()
        {
            Func<double, double> a2, a1, a0, f, exactSolution;
            double y0, y1;
            Example3(out a2, out a1, out a0, out f, out exactSolution, out y0, out y1);

            plotExact.DiscreteFunction = new DiscreteFunction2D(exactSolution, SegmentStart, SegmentEnd, 1000);
            plotExact.Refresh();
            solver = new DiffEqSolver(a2, a1, a0, f, 0, 0);
        }