using System; using System.Collections.Generic; using System.Linq; using System.Text; using L = Science.Mathematics.LinearAlgebra; namespace Strang3Ed.Chapter04.Section3 { public class ExampleB { public ExampleB() { } private string result; public string Result { get { return result; } } public void Compute() { double[,] x = {{1.0, -2.0, 4.0}, {1.0, -1.0, 1.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 1.0}, {1.0, 2.0, 4.0}}; L.Matrix A = new L.Matrix(x); L.Vector b = new L.Vector(5); b[0] = 0.0; b[1] = 0.0; b[2] = 1.0; b[3] = 0.0; b[4] = 0.0; L.LeastSquareApproximation obj = new L.LeastSquareApproximation(A, b); foreach (double k in obj.Solution) result += k.ToString() + "\r\n"; result += (17.0/35.0).ToString() + "\r\n"; result += (0.0).ToString() + "\r\n"; result += (-1.0/7.0).ToString() + "\r\n"; } } } /* 0.485714285714286 0 -0.142857142857143 0.485714285714286 0 -0.142857142857143 */