19.2 Elements of free modules

Module: sage.modules.free_module_element

Module-level Functions

Vector( R, elts)

Return a vector over R with given entries.

INPUT:
    R -- ring
    elts -- entries of a vector
OUTPUT:
    An element of the free module over R of rank len(elts).

sage: v = Vector(Rationals(), [1,1]); v
(1, 1)

_sparse_dot_product( v, w)

v and w are dictionaries with integer keys.

is_FreeModuleElement( x)

Class: FreeModuleElement

class FreeModuleElement
An element of a generic free module.
FreeModuleElement( self, parent)

Functions: additive_order,$  $ change_ring,$  $ copy,$  $ degree,$  $ denominator,$  $ dict,$  $ dot_product,$  $ element,$  $ entries,$  $ get,$  $ inner_product,$  $ is_dense,$  $ is_sparse,$  $ is_vector,$  $ lift,$  $ list,$  $ Mod,$  $ nonzero_positions,$  $ set,$  $ support

dot_product( self, right)

Return the dot product of self and right, which is the sum of the product of the corresponding entries.

INPUT:
    right -- vector of the same degree as self.  it need not
             be in the same vector space as self, as long as
             the coefficients can be multiplied.

sage: V = FreeModule(ZZ, 3)
sage: v = V([1,2,3])
sage: w = V([4,5,6])
sage: v.dot_product(w)
32

sage: W = VectorSpace(GF(3),3)
sage: w = W([0,1,2])
sage: w.dot_product(v)
2
sage: w.dot_product(v).parent()
Finite Field of size 3

Implicit coercion is well defined (irregardless of order), so we get 2 even if we do the dot product in the other order.

sage: v.dot_product(w)  
2

get( self, i)

get is meant to be more efficient than getitem, because it does not do any error checking.

inner_product( self, right)

Returns the inner product of self and other, with respect to the inner product defined on the parent of self.

todo

lift( self)

sage: V = Vector(ZZ/7, [5, 9, 13, 15]) ; V
(5, 2, 6, 1)
sage: V.lift()
(5, 2, 6, 1)
sage: parent(V.lift())
Ambient free module of rank 4 over the principal ideal domain Integer Ring

Mod( self, p)

sage: V = Vector(ZZ, [5, 9, 13, 15])
sage: V.Mod(7)
(5, 2, 6, 1)
sage: parent(V.Mod(7))
Vector space of dimension 4 over Ring of integers modulo 7

nonzero_positions( self)

Return the sorted list of integers i such that self[i] != 0.

set( self, i, x)

set is meant to be more efficient than setitem, because it does not do any error checking or coercion. Use with care.

support( self)

Return the sorted list of integers i such that self[i] != 0.

Special Functions: __abs__,$  $ __add__,$  $ __cmp__,$  $ __div__,$  $ __getitem__,$  $ __invert__,$  $ __len__,$  $ __mod__,$  $ __mul__,$  $ __neg__,$  $ __pos__,$  $ __pow__,$  $ __setitem__,$  $ __sub__,$  $ _latex_,$  $ _matrix_multiply,$  $ _repr_,$  $ _scalar_multiply,$  $ _vector_

__add__( self, right)

sage: V = Q^5
sage: W = V.span([V.1, V.2])
sage: W.0 + V.0
(1, 1, 0, 0, 0)
sage: V.0 + W.0
(1, 1, 0, 0, 0)

__mod__( self, p)

sage: V = Vector(ZZ, [5, 9, 13, 15])
sage: V % 7
(5, 2, 6, 1)
sage: parent(V % 7)
Ambient free module of rank 4 over the principal ideal domain Integer Ring

__neg__( self)

sage: V = QQ^3
sage: v = V([1,2,3])
sage: v.__neg__()
(-1, -2, -3)

_latex_( self)

Return a latex representation of self. For example, if self is the free module element (1,2,3,4), then following latex is generated: "(1,2,3,4)" (without the quotes).

_matrix_multiply( self, A)

Return the product self*A.

sage: MS = MatrixSpace(QQ,3)
sage: A = MS([0,1,0,1,0,0,0,0,1])
sage: V = QQ^3
sage: v = V([1,2,3])
sage: v._matrix_multiply(A)
(2, 1, 3)

The multiplication operator also just calls _matrix_multiply:

sage: v*A
(2, 1, 3)

_scalar_multiply( self, s)

return the product s*self.

Class: FreeModuleElement_generic_dense

class FreeModuleElement_generic_dense
FreeModuleElement_generic_dense( self, parent, entries, [coerce_entries=True], [copy=True])

Functions: entries,$  $ list

Special Functions: __getitem__,$  $ __setitem__

__getitem__( self, i)

__setitem__( self, i, value)

Set entry i of self to value.

Class: FreeModuleElement_generic_sparse

class FreeModuleElement_generic_sparse
A generic_sparse is a dictionary with keys ints i and entries in the base ring.
FreeModuleElement_generic_sparse( self, parent, [entries=True], [coerce_entries=True], [copy=0])

Functions: denominator,$  $ dict,$  $ entries,$  $ get,$  $ nonzero_positions,$  $ set

get( self, i)

Like __getitem__ but with no type or bounds checking. Returns 0 if access is out of bounds.

nonzero_positions( self)

Returns the set of pairs (i,j) such that self[i,j] != 0.

set( self, i, x)

Like __setitem__ but with no type or bounds checking.

Special Functions: __getitem__,$  $ __setitem__

__setitem__( self, i, value)

See About this document... for information on suggesting changes.