# Ticket #10791: trac-10791-gram-schmidt-doctests-v2.patch

File trac-10791-gram-schmidt-doctests-v2.patch, 2.6 KB (added by mraum, 10 years ago)

A copy of trac_10791-gram-schmidt-doctests-v2.patch

• ## sage/matrix/matrix2.pyx

```# HG changeset patch
# User Rob Beezer <beezer@ups.edu>
# Date 1301203798 25200
# Node ID 1f2f69aed28b5eac302b6bcf790b3948a4e34b3a
# Parent  9bf40613dbca3acfc33762f3c01774df48f4f9f4
10791: doctest edits for Gram-Schmidt routines

diff -r 9bf40613dbca -r 1f2f69aed28b sage/matrix/matrix2.pyx```
 a to arrive at an orthonormal set, it must be possible to construct square roots of the elements of the base field.  In Sage, your best option is the field of algebraic numbers, ``QQbar``, which properly contain the rationals and number fields. properly contains the rationals and number fields. If you have an approximate numerical matrix, then this routine requires that your base field be the real and complex attempt is made to recognize linear dependence with approximate calculations. EXAMPLES:: EXAMPLES: Inexact Rings, Numerical Matrices: To scale a vector to unit length requires taking a square root, which often takes us outside the base ring. For the integers,  and rationals the field of algebraic numbers, ``QQbar``, is big enough to contain what we need, but the price For the integers and the rationals, the field of algebraic numbers (``QQbar``) is big enough to contain what we need, but the price is that the computations are very slow, hence mostly of value for small cases or instruction. Now we need to use the ``orthonormal`` keyword.  :: Use the ``orthonormal=False`` keyword (or assume it as the default). Note that now the orthogonality check creates a diagonal matrix whose diagonal entries are the squares of the lengths of the vectors. :: vectors. First, in the rationals, without involving ``QQbar``.  ::
• ## sage/modules/misc.py

`diff -r 9bf40613dbca -r 1f2f69aed28b sage/modules/misc.py`
 a 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 """ import sage.modules.free_module_element if len(B) == 0 or len(B) == 0: