5.1.1.3 VectorSpace_generic Objects

class VectorSpace_generic
The VectorSpace_generic class derives from VectorSpace, and defines functionality for generic vector spaces over an arbitrary base field. (One never instantiates objects of this class.)
VectorSpace_generic( base_field, degree, [sparse=False])

Create the space of all vectors of given degree over base_field.

INPUT:
    base_field -- a field
    degree -- int >= 0, the degree of the vector space 
              (number of components of vectors).
    sparse -- whether or not matrices are given a sparse
representation 
              (default to False)

Instances of class VectorSpace_generic have the following methods (in addition to inherited methods and special methods):

coordinates,$  $ random,$  $ random_element,$  $ subspace,$  $ subspace_with_basis

These methods are defined as follows:

coordinates( v)

Write v in terms of the basis for self.

Returns a list c such that if B is the basis for self, then sum c[i] B[i] = v If v is not in self, raises an ArithmeticError exception.

random( [X=True], [prob=1.0], [coerce=[-2, -1, 1, 2]])

Returns a random element of self.

random_element( [X=True], [prob=1.0], [coerce=[-2, -1, 1, 2]])

Returns a random element of self.

subspace( gens)

Create a subspace of self.

INPUT:
    gens -- a list of vector in self
OUTPUT:
    VectorSpace -- the subspace spanned by the vectors in the
list gens.
    The basis for the subspace is always put in reduced row
echelon form.

sage: import sage.rings.rings as rings
sage: V = VectorSpace(rings.RationalField(), 3)
sage: B = V.basis()
sage: W = V.subspace([B[0]+B[1], 2*B[1]-B[2]])
sage: W
Vector space of degree 3, dimension 2 over Rational Field
Basis matrix:
[   1    0  1/2]
[   0    1 -1/2]

subspace_with_basis( basis)

Create a subspace of self with given basis.

INPUT:
    basis -- a list of linearly independent vectors

OUTPUT:
    VectorSpace_subspace_with_basis -- the subspace with given
basis.
    The basis for the subspace is always put in reduced row
echelon form.

sage: import sage.rings.rings as rings
sage: V = VectorSpace(rings.RationalField(), 3)
sage: B = V.basis()
sage: W = V.subspace_with_basis([B[0]+B[1], 2*B[1]-B[2]])
sage: W
Vector space of degree 3, dimension 2 over Rational Field
User basis matrix:
[ 1  1  0]
[ 0  2 -1]

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