# Bases

This section is concerned with the construction of bases for vector spaces.

## `VectorSpaceWithBasis(Q): [ModTupFldElt] -> ModTupFld`

## `VectorSpaceWithBasis(a): AlgMatElt -> ModTupFld`

## `VectorSpaceWithBasis(a): ModMatFldElt -> ModTupFld`

## `KSpaceWithBasis(Q): [ModTupFldElt] -> ModTupFld`

## `KSpaceWithBasis(a): AlgMatElt -> ModTupFld`

## `KSpaceWithBasis(a): ModMatFldElt -> ModTupFld`

## `KModuleWithBasis(Q): [ModTupFldElt] -> ModTupFld`

Create a vector space having as basis the terms of $B$ (rows of $a$).

## `Basis(V): ModTupFld -> [ModTupFldElt]`

The current basis for the vector space $V$, returned as a sequence of vectors.

## `BasisElement(V, i): ModTupFld, RngIntElt -> ModTupFldElt`

The $i$-th basis element for the vector space $V$.

## `BasisMatrix(V): ModTupFld -> ModMatElt`

The current basis for the vector space $V$, returned as the rows of a matrix belonging to the matrix space $K^{(m \times n)}$, where $m$ is the dimension of $V$ and $n$ is the over-dimension of $V$.

## `Coordinates(V, v): ModTupFld, ModTupFldElt -> [FldElt]`

Given a vector $v$ belonging to the $r$-dimensional $K$-vector space $V$, with basis $v_1, \ldots, v_r$, return a sequence $[a_1, \ldots, a_r]$ of elements of $K$ giving the coordinates of $v$ relative to the $V$-basis: $v = a_1*v_1 + \cdots +a_r*v_r$.

## `Dimension(V): ModTupFld -> RngIntElt`

The dimension of the vector space $V$.

## `ExtendBasis(Q, U): [ModTupFldElt], ModTupFld -> [ModTupFldElt]`

Given a sequence $Q$ containing $r$ linearly independent vectors belonging to the vector space $U$, extend the vectors of $Q$ to a basis for $U$. The basis is returned in the form of a sequence $T$ such that $T[i] = Q[i], i = 1, \ldots r$.

## `ExtendBasis(U, V): ModTupFld, ModTupFld -> [ModTupFldElt]`

Given an $r$-dimensional subspace $U$ of the vector space $V$, return a basis for $V$ in the form of a sequence $T$ of elements such that the first $r$ elements correspond to the given basis vectors for $U$.

## `IsIndependent(S): { ModTupFldElt} -> BoolElt`

Given a set $S$ of elements belonging to the vector space $V$, return `true` if the elements of $S$ are linearly independent.

## `IsIndependent(Q): [ ModTupFldElt ] -> BoolElt`

Given a sequence $Q$ of elements belonging to the vector space $V$, return `true` if the terms of $Q$ are linearly independent.

## `Example: Basis (ex-a4fb0c)`

These operations will be illustrated in the context of the subspace $G3$ of the $11$-dimensional vector space over ${\bf F}_{3}$ defining the ternary Golay code.

```magma
> V11 := VectorSpace(FiniteField(3), 11);
> G3  := sub< V11 |  [1,0,0,0,0,0,1,1,1,1,1], [0,1,0,0,0,0,0,1,2,2,1],
>                    [0,0,1,0,0,0,1,0,1,2,2], [0,0,0,1,0,0,2,1,0,1,2],
>                    [0,0,0,0,1,0,2,2,1,0,1], [0,0,0,0,0,1,1,2,2,1,0] >;
> Dimension(G3);
    6
> Basis(G3);
[
    (1 0 0 0 0 0 1 1 1 1 1),
    (0 1 0 0 0 0 0 1 2 2 1),
    (0 0 1 0 0 0 1 0 1 2 2),
    (0 0 0 1 0 0 2 1 0 1 2),
    (0 0 0 0 1 0 2 2 1 0 1),
    (0 0 0 0 0 1 1 2 2 1 0)
]
> S := ExtendBasis(G3, V11);
> S;
[
    (1 0 0 0 0 0 1 1 1 1 1),
    (0 1 0 0 0 0 0 1 2 2 1),
    (0 0 1 0 0 0 1 0 1 2 2),
    (0 0 0 1 0 0 2 1 0 1 2),
    (0 0 0 0 1 0 2 2 1 0 1),
    (0 0 0 0 0 1 1 2 2 1 0),
    (0 0 0 0 0 0 1 0 0 0 0),
    (0 0 0 0 0 0 0 1 0 0 0),
    (0 0 0 0 0 0 0 0 1 0 0),
    (0 0 0 0 0 0 0 0 0 1 0),
    (0 0 0 0 0 0 0 0 0 0 1)
]
> C3:= Complement(V11, G3);
> C3;
Vector space of degree 11, dimension 5 over GF(3)
Echelonized basis:
(0 0 0 0 0 0 1 0 0 0 0)
(0 0 0 0 0 0 0 1 0 0 0)
(0 0 0 0 0 0 0 0 1 0 0)
(0 0 0 0 0 0 0 0 0 1 0)
(0 0 0 0 0 0 0 0 0 0 1)
> G3 + C3;
Full Vector space of degree 11 over GF(3)
> G3 meet C3;
Vector space of degree 11, dimension 0 over GF(3)
> x := Random(G3);
> x;
(1 1 2 0 0 1 1 1 1 2 0)
> c := Coordinates(G3, x);
> c;
[ 1, 1, 2, 0, 0, 1 ]
> G3 ! &+[ c[i] * G3.i : i in [1 .. Dimension(G3)]];
(1 1 2 0 0 1 1 1 1 2 0)

```
