using System; using System.Collections.Generic; using System.Linq; using System.Text; using L = Science.Mathematics.LinearAlgebra; namespace Strang3Ed.Chapter04.Section2 { public class ExampleB { public ExampleB() { } private string result; public string Result { get { return result; } } public void Compute() { double[,] x = { {1.0}, {1.0}, {1.0}}; L.Matrix A = new L.Matrix(x); L.Matrix AtA = A.Transpose * A; L.Vector b = new L.Vector(3); b[0] = 70.0; b[1] = 80.0; b[2] = 120.0; L.Vector Atb = A.Transpose * b; L.LinearEquation eq = new L.LinearEquation(AtA, Atb); eq.Solve(); result += eq.Solution[0].ToString() + "\r\n"; } } } /* 3 4.8 2.4 4.44089209850063E-16 -0.8 1.6 1 0 0 0 0.8 0.4 0 0.4 0.2 */