Given a field K and a non-negative integer n, create the n-dimensional vector space V = K(n), consisting of all n-tuples over K. The vector space is created with respect to the standard basis, e1, ..., en, where ei (i = 1, ..., n) is the vector containing a 1 in the i-th position and zeros elsewhere.Use of the functions VectorSpace and KSpace ensures that subspaces of V will be presented in embedded form.
Given a field K and a non-negative integer n, create the n-dimensional vector space V = K(n), consisting of all n-tuples over K. The vector space is created with respect to the standard basis, e1, ..., en, where ei (i = 1, ..., n) is the vector containing a 1 in the i-th position and zeros elsewhere.Use of the function KModule ensures that subspaces of V will be presented in reduced form. In all other respects, a vector space created by this function is identical to one created by KSpace.
Given a field K and integers m and n greater than one, create the vector space K(m x n), consisting of all m x n matrices over K. The vector space is created with the standard basis, {Eij | i = 1 ..., m, j = 1 ..., n}, where Eij is the matrix having a 1 in the (i, j)-th position and zeros elsewhere.Note that for a matrix space, subspaces will always be presented in embedded form, i.e. there is no reduced mode available for matrix spaces.
If V is the vector space K(m) and W is the vector space K(n), create the matrix space HomK(V, W) as the vector space K(m x n), represented as the set of all m x n matrices over K. The vector space is created with the standard basis, {Eij | i = 1 ..., m, j = 1 ..., n}, where Eij is the matrix having a 1 in the (i, j)-th position and zeros elsewhere.
> Q := RationalField(); > V := VectorSpace(Q, 6); > V; Vector space of dimension 6 over Rational Field
> K<w> := QuadraticField(5); > V := KMatrixSpace(K, 3, 5); > V; Full Vector Space of 3 by 5 matrices over Quadratic Field Q(w)
Given a field K, a non-negative integer n and a square n x n symmetric matrix F, create the n-dimensional vector space V = K(n) (in embedded form), with inner product matrix F. This is the same as VectorSpace(K, n), except that the functions Norm and InnerProduct (see below) will be with respect to the inner product matrix F.
- (1)
- Suppose V is a subspace of the vector space K(n). Given elements a1, ..., an belonging to K, construct the vector v = (a1, ..., an) as a vector of V. Note that if v is not an element of V, an error will result.
- (2)
- Suppose V is a subspace of the matrix space K(m x n). Given elements a1, ..., amn belonging to K, construct the matrix m = (a1, ..., amn) as an element of V. Note that if m is not an element of V, an error will result.
- (1)
- Suppose V is a subspace of the vector space K(n). Given elements a1, ..., an belonging to K, construct the vector v = (a1, ..., an) as a vector of V. Note that if v is not an element of V, an error will result.
- (2)
- Suppose V is a subspace of the matrix space K(m x n). Given elements a1, ..., amn belonging to K, construct the matrix m = (a1, ..., amn) as an element of V. Note that if m is not an element of V, an error will result.
Given a subspace V of the vector space K(n) together with a set S of integers lying in the interval [1, n], return the characteristic number of S as a vector of V.
The zero element for the vector space V.
Given a vector space V defined over a finite field, return a random vector.
> K<w> := GaloisField(4); > V := VectorSpace(K, 5); > u := V ! [1, w, 1+w, 0, 0]; > u; (1 w w + 1 0 0) > zero := V ! 0; > zero; (0 0 0 0 0) r := Random(V); (1 0 w 1 w + 1)
> R<x> := PolynomialRing(RationalField()); > L<w> := NumberField(x^7 - 7*x + 3); > L34 := KMatrixSpace(L, 3, 4); > a := L34 ! [ 1, w, 0, -w, 0, 1+w, 2, -w^3, w-w^3, 2*w, 1/3, 1 ]; > a; [1 w 0 -1 * w] [0 w + 1 2 -1 * w^3] [-1 * w^3 + w 2 * w 1/3 1]
Given an element u belonging to the K-vector space V, return u in the form of a sequence Q of elements of V. Thus, if u is an element of K(n), then Q[i] = u[i], 1 ≤i ≤n.
For the following operations the vectors u and v must belong to the same vector space i.e. the same tuple space K(n) or the same matrix space K(m x n). The scalar a must belong to the field K.
Sum of the vectors u and v, where u and v lie in the same vector space.
Additive inverse of the vector u.
Difference of the vectors u and v, where u and v lie in the same vector space.
The scalar product of the vector u belonging to the K-vector space and the field element x belonging to K.
The scalar product of the vector u belonging to the K-vector space and the field element 1/x belonging to K where x is non-zero.
The number of columns in the vector u.
The index of the first non-zero entry of the vector u (0 if none such).
Return the inner product of the vectors u and v with respect to the inner product defined on the space. If an inner product matrix F is given when the space is created, then this is defined to be u.F.vtr. Otherwise, this is simply u.vtr.
Returns true iff the vector u belonging to a vector space is the zero element.
Return the norm product of the vector u with respect to the inner product defined on the space. If an inner product matrix F is given when the space is created, then this is defined to be u.F.utr. Otherwise, this is simply u.utr.
Given an element u, not the zero element, belonging to the K-vector space V, return (1/a) * u, where a is the first non-zero component of u. If u is the zero vector, it is returned. The net effect is that Normalize(u) always returns a vector v in the subspace generated by u, such that the first non-zero component of v (if existent) is K!1.
Given a vector u, return the vector obtained from u by rotating by k coordinate positions.
Given a vector u, destructively rotate u by k coordinate positions.
The number of rows in the vector u (1 of course; included for completeness).
A set of integers giving the positions of the non-zero components of the vector u.
The tensor (Kronecker) product of the vectors u and v. The resulting vector has degree equal to the product of the degrees of u and v.
Given a vector belonging to the space K(n), and a subfield F of K, return the vector obtained by replacing each component of u by its trace over the subfield F. If F is the prime field of K, it may be omitted.
The number of non-zero components of the vector u.
> K<w> := CyclotomicField(8); > V := VectorSpace(K, 4); > x := V ! [ w, w^2, w^4, 0]; > y := V ! [1, w, w^2, w^4]; > x + y; ( w + 1 w^2 + w w^2 - 1 -1) > -x; ( -w -w^2 1 0) > x - y; ( w - 1 w^2 - w -w^2 - 1 1) > w * x; (w^2 w^3 -w 0) > y * w^ -4; ( -1 -w -w^2 1) > Normalize(x); ( 1 w w^3 0) > InnerProduct(x, y); w^2 + 2*w > z := V ! [1, 0, w, 0 ]; > z; (1 0 w 0) > Support(z); { 1, 3 }
> Q := RationalField(); > F := SymmetricMatrix(Q, [1, 0,2, 0,0,3, 1,2,3,4]); > F; [1 0 0 1] [0 2 0 2] [0 0 3 3] [1 2 3 4] > V := VectorSpace(Q, 4, F); > V; Full Vector space of degree 4 over Rational Field Inner Product Matrix: [1 0 0 1] [0 2 0 2] [0 0 3 3] [1 2 3 4] > v := V![1,0,0,0]; > Norm(v); 1 > w := V![0,1,0,0]; > Norm(w); 2 > InnerProduct(v, w); 0 > z := V![0,0,0,1]; > Norm(z); 4 > InnerProduct(v, z); 1 > InnerProduct(w, z); 2
The indexing operations have a different meaning depending upon whether they are applied to a tuple space or a matrix space.
Given a vector u belonging to a K-vector space V, the result of this operation depends upon whether V is a tuple or matrix space.If V is a subspace of K(n), and i, 1 ≤i≤n, is a positive integer, the i-th component of the vector u is returned (as an element of the field K).
If V is a subspace of K(m x n), and i, 1 ≤i≤m, is a positive integer, u[i] will return the i-th row of the matrix u (as an element of the vector space K(n)). Similarly, if i and j, 1 ≤i≤m, 1 ≤j≤n, are positive integers, u[i, j] will return the (i, j)-th component of the matrix u (as an element of K).
Given a vector u belonging to a K-vector space V, and an element x of K, the result of this operation depends upon whether V is a tuple or matrix space.If V is a subspace of K(n), and i, 1 ≤i≤n, is a positive integer, the i-th component of the vector u is redefined to be x.
If V is a subspace of K(m x n) and 1 ≤i≤m is a positive integer and x is an element of K(n), u[i] := x will redefine the i-th row of the matrix u to be the vector x, where x must be an element of K(n). Similarly, if 1 ≤i≤m, 1 ≤j≤n, are positive integers, u[i, j] := x will redefine the (i, j)-th component of the matrix u to be x, where x must be an element of K.
> K<w> := CyclotomicField(8); > V := VectorSpace(K, 3); > u := V ! [ 1 + w, w^ 2, w^ 4]; > u; ((1 + w) (w^2) -1) > u[3]; -1 > u[3] := 1 + w - w^7; > u; ((1 + w) (w^2) (1 + w + w^3)) > // We now demonstrate indexing a matrix space > W := KMatrixSpace(K, 2, 3); > l := W ! [ 1 - w, 1 + w, 1 + w + w^2, 0, 1 - w^7, 1 - w^3 + w^6 ]; > l; [(1 - w) (1 + w) (1 + w + w^2)] [0 (1 + w^3) (1 - w^2 - w^3)] > l[2]; (0 (1 + w^3) (1 - w^2 - w^3)) > l[2,2]; (1 + w^3) > m := l[2]; > m; (0 (1 + w^3) (1 - w^2 - w^3)) > l[2] := u; > l; [(1 - w) (1 + w) (1 + w + w^2)] [(1 + w) (w^2) -1] > l[2, 3] := 1 + w - w^7; > l; [(1 - w) (1 + w) (1 + w + w^2)] [(1 + w) (w^2) (1 + w + w^3)]