5.2.1.1 Vector Objects

class Vector
Vector( parent)

Instances of class Vector have the following functions (in addition to inherited functions and special functions):

base_field,$  $ base_ring,$  $ copy,$  $ degree,$  $ denominator,$  $ dict,$  $ dot_product,$  $ entries,$  $ get,$  $ height,$  $ is_dense,$  $ is_sparse,$  $ is_vector,$  $ list,$  $ nonzero_positions,$  $ parent,$  $ rational_reconstruction,$  $ set,$  $ str_latex

Further documentation:

dot_product( 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 = VectorSpace(RationalField(),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

Note that in SAGE implicit coercions, when defined, coerce the element on the right into the parent of the element on the left. Thus the dot product in the other order results in the rational number $ 8$ , since the finite field elements are lifted up to the rationals.

sage: v.dot_product(w)  
8

get( i)

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

nonzero_positions( )

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

set( i, x)

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

str_latex( )

Print a latex representation of self. For example, if self is [1,2,3,4], the following latex is generated: (1,2,3,4)

Instances of class Vector also have the following special functions:

__abs__,$  $ __add__,$  $ __cmp__,$  $ __getitem__,$  $ __invert__,$  $ __len__,$  $ __mod__,$  $ __mul__,$  $ __neg__,$  $ __pos__,$  $ __pow__,$  $ __rmul__,$  $ __setitem__,$  $ __str__,$  $ __sub__

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