using System; namespace Science.Mathematics.LinearAlgebra { public class LeftNullspace : VectorSpace { public LeftNullspace(Matrix A) { if (A.SizeOfRow == A.Rank) { Vector[] n = new Vector[1]; n[0] = new Vector(A.SizeOfRow); this.Basis = n; this.Dimension = 0; } else { this.Dimension = A.SizeOfRow - A.Rank; Vector[] n = new Vector[this.Dimension]; Nullspace NAt = new Nullspace(A.Transpose); for (int i = 0; i < n.Length; i++) { n[i] = new Vector(A.SizeOfRow); for (int j = 0; j < A.SizeOfRow ; j++) { n[i][j] = NAt.NullspaceMatrix[j,i]; } } this.Basis = n; } } public Vector LinearCombination(double[] x) { Vector xx = new Vector(this.Basis[0].Size); for (int i = 0; i < x.Length; i++) xx += x[i] * this.Basis[i]; return xx; } } }