Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Added are_linearly_dependent.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Scrimshaw committed Feb 16, 2014
1 parent 6452f9d commit c3e7244
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/sage/modules/free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,35 @@ def zero(self):
res.set_immutable()
return res

def are_linearly_dependent(self, vecs):
"""
Return ``True`` if the vectors ``vecs`` are linearly dependent and
``False`` otherwise.
EXAMPLES::
sage: M = QQ^3
sage: vecs = [M([1,2,3]), M([4,5,6])]
sage: M.are_linearly_dependent(vecs)
False
sage: vecs.append(M([3,3,3]))
sage: M.are_linearly_dependent(vecs)
True
sage: R.<x> = QQ[]
sage: M = FreeModule(R, 2)
sage: vecs = [M([x^2+1, x+1]), M([x+2, 2*x+1])]
sage: M.are_linearly_dependent(vecs)
False
sage: vecs.append(M([-2*x+1, -2*x^2+1]))
sage: M.are_linearly_dependent(vecs)
True
"""
from sage.matrix.constructor import matrix
A = matrix(vecs)
A.echelonize()
return any(row.is_zero() for row in A.rows())

def _magma_init_(self, magma):
"""
EXAMPLES::
Expand Down

0 comments on commit c3e7244

Please sign in to comment.