Vectors with elements in \(\GF{2}\)#
AUTHOR:
Martin Albrecht (2009-12): initial implementation
Thomas Feulner (2012-11): added
Vector_mod2_dense.hamming_weight()
EXAMPLES:
sage: VS = GF(2)^3
sage: e = VS.random_element()
sage: e.parent() is VS
True
sage: S = set(vector(v, immutable=True) for v in VS)
sage: S1 = set()
sage: while S != S1:
....: S1.add(vector(VS.random_element(), immutable=True))
- class sage.modules.vector_mod2_dense.Vector_mod2_dense#
Bases:
sage.modules.free_module_element.FreeModuleElement
EXAMPLES:
sage: VS = VectorSpace(GF(2),3) sage: VS((0,0,1/3)) (0, 0, 1) sage: type(_) <class 'sage.modules.vector_mod2_dense.Vector_mod2_dense'> sage: VS((0,0,int(3))) (0, 0, 1) sage: VS((0,0,3)) (0, 0, 1) sage: VS((0,0,GF(2)(1))) (0, 0, 1)
- hamming_weight()#
Return the number of positions
i
such thatself[i] != 0
.EXAMPLES:
sage: vector(GF(2), [1,1,0]).hamming_weight() 2
- list(copy=True)#
Return a list of entries in
self
.INPUT:
copy
- alwaysTrue
EXAMPLES:
sage: VS = VectorSpace(GF(2), 10) sage: entries = [GF(2).random_element() for _ in range(10)] sage: e = VS(entries) sage: e.list() == entries True
- sage.modules.vector_mod2_dense.unpickle_v0(parent, entries, degree, is_immutable)#
EXAMPLES:
sage: from sage.modules.vector_mod2_dense import unpickle_v0 sage: VS = VectorSpace(GF(2),10) sage: unpickle_v0(VS, [0,1,2,3,4,5,6,7,8,9], 10, 0) (0, 1, 0, 1, 0, 1, 0, 1, 0, 1)