using System; using System.Collections.Generic; using System.Linq; using System.Text; using L = Science.Mathematics.LinearAlgebra; namespace Strang3Ed.Chapter04.Section4 { public class Example05 { public Example05() { } private string result; public string Result { get { return result; } } public void Compute() { L.Vector[] a = new L.Vector[3]; a[0] = new L.Vector(3); a[0][0] = 1.0; a[0][1] = -1.0; a[0][2] = 0.0; a[1] = new L.Vector(3); a[1][0] = 2.0; a[1][1] = 0.0; a[1][2] = -2.0; a[2] = new L.Vector(3); a[2][0] = 3.0; a[2][1] = -3.0; a[2][2] = 3.0; L.Matrix A = new L.Matrix(a); L.FactorizationAeqQR obj = new L.FactorizationAeqQR(A); obj.Compute(); result += obj.Orthonormal.ToString() + "\r\n"; L.Vector[] q = new L.Vector[3]; q[0] = new L.Vector(3); q[0][0] = 1.0/Math.Sqrt(2.0); q[0][1] = -1.0 / Math.Sqrt(2.0); q[0][2] = 0.0; q[1] = new L.Vector(3); q[1][0] = 1.0 / Math.Sqrt(6.0); q[1][1] = 1.0 / Math.Sqrt(6.0); q[1][2] = -2.0 / Math.Sqrt(6.0); q[2] = new L.Vector(3); q[2][0] = 1.0 / Math.Sqrt(3.0); q[2][1] = 1.0 / Math.Sqrt(3.0); q[2][2] = 1.0 / Math.Sqrt(3.0); L.Matrix Q = new L.Matrix(q); result += Q.ToString() + "\r\n"; } } } /* -0.707106781186547 -0.408248290463863 0.577350269189626 0.707106781186547 -0.408248290463863 0.577350269189626 0 0.816496580927726 0.577350269189626 0.707106781186547 0.408248290463863 0.577350269189626 -0.707106781186547 0.408248290463863 0.577350269189626 0 -0.816496580927726 0.577350269189626 */