using System; namespace Science.Mathematics.LinearAlgebra { public class Subspace : VectorSpace { public Subspace(int dimension) : base(dimension) { } public Subspace(Vector[] basis) : base(basis) { this.Basis = basis; this.Dimension = basis.Length; } public Subspace(Matrix basis) { Vector[] v = new Vector[basis.SizeOfColumn]; for (int i = 0; i < v.Length; i++) { v[i] = new Vector(basis.SizeOfRow); for (int j = 0; j < basis.SizeOfRow; j++) v[i][j] = basis[j, i]; } this.Basis = v; this.Dimension = v.Length; } public bool IsInSpaceQ(Vector v) { Projection obj = new Projection(this, v); if (obj.Error.Norm < 1.0E-12) return true; else return false; } } }