]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
Use built-in Gram-Schmidt to make things a little better.
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 6 Jun 2015 03:40:29 +0000 (23:40 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 6 Jun 2015 03:40:29 +0000 (23:40 -0400)
mjo/cone/cone.py

index 6fb15ae21e242085b223eac729c857b8d04b8189..f2e8b2e9ee104e6cbd216e7473fd65dd76947d98 100644 (file)
@@ -8,26 +8,6 @@ addsitedir(abspath('../../'))
 from sage.all import *
 
 
-def drop_dependent(vs):
-    r"""
-    Return the largest linearly-independent subset of ``vs``.
-    """
-    if len(vs) == 0:
-        # ...for lazy enough definitions of linearly-independent
-        return vs
-
-    result = []
-    old_V = VectorSpace(vs[0].parent().base_field(), 0)
-
-    for v in vs:
-        new_V = span(result + [v])
-        if new_V.dimension() > old_V.dimension():
-            result.append(v)
-            old_V = new_V
-
-    return result
-
-
 def iso_space(K):
     r"""
     Construct the space `W \times W^{\perp}` isomorphic to the ambient space
@@ -36,7 +16,10 @@ def iso_space(K):
     V = K.lattice().vector_space()
 
     # Create the space W \times W^{\perp} isomorphic to V.
-    W_basis = drop_dependent(K.rays())
+    # First we get an orthogonal (but not normal) basis...
+    M = matrix(V.base_field(), K.rays())
+    W_basis,_ = M.gram_schmidt()
+
     W = V.subspace_with_basis(W_basis)
     W_perp = W.complement()