Ask Your Question

Revision history [back]

Use in to check membership.

The check will work if the vector is constructed with vector, not if it is a list or tuple.

Below are some examples.

sage: from sage.modules.free_module_integer import IntegerLattice
sage: v1 = vector((3, 4))
sage: v2 = vector((4, 5))
sage: M = [v1, v2]
sage: L = IntegerLattice(M)

sage: L
Free module of degree 2 and rank 2 over Integer Ring
User basis matrix:
[-1  0]
[ 0  1]

sage: v1 in L
True
sage: v2 in L
True
sage: vector((0, 0)) in L
True
sage: vector((1, 0)) in L
True
sage: vector((0, 1)) in L
True
sage: vector((1, 1)) in L
True
sage: vector((2, 0)) in L
True
sage: vector((1/2, 1)) in L
False