Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Modules
Light Logo Dark Logo
Version 10.6 Reference Manual
  • Home - Modules
  • Tutorial: Using free modules and vector spaces
  • Abstract base class for modules
  • Free modules
  • Elements of free modules
  • Submodules and subquotients of free modules
  • Quotients of free modules
  • Concrete classes related to modules with a distinguished basis
  • Cell modules
  • An element in an indexed free module
  • Invariant modules
  • Morphisms of modules with a basis
  • Quotients of modules with basis
  • Representations of a semigroup
  • Finitely generated modules over a PID
  • Elements of finitely generated modules over a PID
  • Morphisms between finitely generated modules over a PID
  • Finitely generated free graded left modules over connected graded algebras
  • Elements of finitely generated free graded left modules
  • Homomorphisms of finitely generated free graded left modules
  • Homsets of finitely generated free graded left modules
  • Finitely presented graded modules
  • Elements of finitely presented graded modules
  • Homomorphisms of finitely presented graded modules
  • Homsets of finitely presented graded modules
  • Finitely presented graded modules over the Steenrod algebra
  • Homomorphisms of finitely presented modules over the Steenrod algebra
  • Discrete subgroups of \(\ZZ^n\)
  • Free quadratic modules
  • Integral lattices
  • Finite \(\ZZ\)-modules with bilinear and quadratic forms
  • \(\ZZ\)-filtered vector spaces
  • Multiple \(\ZZ\)-graded filtrations of a single vector space
  • Space of morphisms of vector spaces (linear transformations)
  • Morphisms of vector spaces (linear transformations)
  • Homspaces between free modules
  • Morphisms of free modules
  • Morphisms defined by a matrix
  • Space of pseudomorphisms of free modules
  • Pseudomorphisms of free modules
  • Vectors with integer entries
  • File: sage/modules/vector_integer_sparse.pyx (starting at line 1)
  • Vectors with elements in \(\GF{2}\)
  • Vectors with integer mod \(n\) entries, with small \(n\)
  • File: sage/modules/vector_modn_sparse.pyx (starting at line 1)
  • Vectors with rational entries
  • File: sage/modules/vector_rational_sparse.pyx (starting at line 1)
  • Dense vectors over the symbolic ring
  • Sparse vectors over the symbolic ring
  • Vectors over callable symbolic rings
  • Dense vectors using a NumPy backend
  • Dense real double vectors using a NumPy backend
  • Dense vectors using a NumPy backend.
  • Dense integer vectors using a NumPy backend.
  • Dense complex double vectors using a NumPy backend
  • Pickling for the old CDF vector class
  • Pickling for the old RDF vector class
  • Diamond cutting implementation
  • Helper classes to implement tensor operations
  • Iterators over finite submodules of a \(\ZZ\)-module
  • Miscellaneous module-related functions
Back to top
View this page
Edit this page

Miscellaneous module-related functions¶

AUTHORS:

  • William Stein (2007-11-18)

sage.modules.misc.gram_schmidt(B)[source]¶

Return the Gram-Schmidt orthogonalization of the entries in the list B of vectors, along with the matrix mu of Gram-Schmidt coefficients.

Note that the output vectors need not have unit length. We do this to avoid having to extract square roots.

Note

Use of this function is discouraged. It fails on linearly dependent input and its output format is not as natural as it could be. Instead, see sage.matrix.matrix2.Matrix2.gram_schmidt() which is safer and more general-purpose.

EXAMPLES:

sage: B = [vector([1,2,1/5]), vector([1,2,3]), vector([-1,0,0])]
sage: from sage.modules.misc import gram_schmidt
sage: G, mu = gram_schmidt(B)
sage: G
[(1, 2, 1/5), (-1/9, -2/9, 25/9), (-4/5, 2/5, 0)]
sage: G[0] * G[1]
0
sage: G[0] * G[2]
0
sage: G[1] * G[2]
0
sage: mu
[      0       0       0]
[   10/9       0       0]
[-25/126    1/70       0]
sage: a = matrix([])
sage: a.gram_schmidt()
([], [])
sage: a = matrix([[],[],[],[]])
sage: a.gram_schmidt()
 ([], [])
>>> from sage.all import *
>>> B = [vector([Integer(1),Integer(2),Integer(1)/Integer(5)]), vector([Integer(1),Integer(2),Integer(3)]), vector([-Integer(1),Integer(0),Integer(0)])]
>>> from sage.modules.misc import gram_schmidt
>>> G, mu = gram_schmidt(B)
>>> G
[(1, 2, 1/5), (-1/9, -2/9, 25/9), (-4/5, 2/5, 0)]
>>> G[Integer(0)] * G[Integer(1)]
0
>>> G[Integer(0)] * G[Integer(2)]
0
>>> G[Integer(1)] * G[Integer(2)]
0
>>> mu
[      0       0       0]
[   10/9       0       0]
[-25/126    1/70       0]
>>> a = matrix([])
>>> a.gram_schmidt()
([], [])
>>> a = matrix([[],[],[],[]])
>>> a.gram_schmidt()
 ([], [])

Linearly dependent input leads to a zero dot product in a denominator. This shows that Issue #10791 is fixed.

sage: from sage.modules.misc import gram_schmidt
sage: V = [vector(ZZ,[1,1]), vector(ZZ,[2,2]), vector(ZZ,[1,2])]
sage: gram_schmidt(V)
Traceback (most recent call last):
...
ValueError: linearly dependent input for module version of Gram-Schmidt
>>> from sage.all import *
>>> from sage.modules.misc import gram_schmidt
>>> V = [vector(ZZ,[Integer(1),Integer(1)]), vector(ZZ,[Integer(2),Integer(2)]), vector(ZZ,[Integer(1),Integer(2)])]
>>> gram_schmidt(V)
Traceback (most recent call last):
...
ValueError: linearly dependent input for module version of Gram-Schmidt
Previous
Iterators over finite submodules of a \(\ZZ\)-module
Copyright © 2005--2025, The Sage Development Team
Made with Sphinx and @pradyunsg's Furo
On this page
  • Miscellaneous module-related functions
    • gram_schmidt()