using System; namespace Science.Mathematics.LinearAlgebra { public class FactorizationAeqQH { private Matrix Q; private Matrix H; private Matrix a; public FactorizationAeqQH(Matrix A) { a = A; Q = new Matrix(A.SizeOfRow,A.SizeOfColumn); H = new Matrix(A.SizeOfColumn, A.SizeOfColumn); } public void Compute() { FactorizationAeqUSVt obj = new FactorizationAeqUSVt(a); obj.Compute(); Matrix UVt = obj.ColumnOrthogonal * obj.Orthogonal.Transpose; Matrix VSVt = obj.Orthogonal * obj.Diagonal * obj.Orthogonal.Transpose; for (int i = 0; i < a.SizeOfRow; i++) { for (int j = 0; j < a.SizeOfColumn; j++) { Q[i, j] = UVt[i, j]; } } for (int i = 0; i < a.SizeOfColumn; i++) { for (int j = 0; j < a.SizeOfColumn; j++) { H[i, j] = VSVt[i, j]; } } } public Matrix Orthogonal { get { return Q; } } public Matrix PositiveSemidefinite { get { return H; } } } }