# The Construction of Extensions and their Elements

## The Construction of Direct Sums and Tensor Products

### `DirectSum(R, T): AlgMat, AlgMat -> AlgMat`

Given two matrix algebras $R$ and $T$, where $R$ and $T$ have the same coefficient ring $S$, return the direct sum $D$ of $R$ and $T$ (with the action given by the direct sum of the action of $R$ and the action of $T$).

### `TensorProduct(A, B): AlgMat, AlgMat -> AlgMat`

Given two unital matrix algebras $A$ and $B$, where $A$ and $B$ have the same coefficient ring $S$, construct the tensor product of $A$ and $B$.

### `Example: Products (ex-548c90)`

We construct the direct product and tensor product of the matrix algebra $A$ (defined above) with itself.

```magma
> Q := RationalField();
> A := MatrixAlgebra< Q, 3 | [ 1/3,0,0, 3/2,3,0, -1/2,4,3],
>        [ 3,0,0, 1/2,-5,0, 8,-1/2,4] >;
> AplusA := DirectSum(A, A);
> AplusA: Maximal;
Matrix Algebra of degree 6 with 4 generators over
    Rational Field
Generators:
[ 1/3    0    0    0    0    0]
[ 3/2    3    0    0    0    0]
[-1/2    4    3    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]

[   3    0    0    0    0    0]
[ 1/2   -5    0    0    0    0]
[   8 -1/2    4    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]

[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0  1/3    0    0]
[   0    0    0  3/2    3    0]
[   0    0    0 -1/2    4    3]

[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    3    0    0]
[   0    0    0  1/2   -5    0]
[   0    0    0    8 -1/2    4]
> AtimesA := TensorProduct(A, A);
> AtimesA: Maximal;
Matrix Algebra of degree 9 with 4 generators over
    Rational Field
Generators:
[ 1/3    0    0    0    0    0    0    0    0]
[   0  1/3    0    0    0    0    0    0    0]
[   0    0  1/3    0    0    0    0    0    0]
[ 3/2    0    0    3    0    0    0    0    0]
[   0  3/2    0    0    3    0    0    0    0]
[   0    0  3/2    0    0    3    0    0    0]
[-1/2    0    0    4    0    0    3    0    0]
[   0 -1/2    0    0    4    0    0    3    0]
[   0    0 -1/2    0    0    4    0    0    3]

[   3    0    0    0    0    0    0    0    0]
[   0    3    0    0    0    0    0    0    0]
[   0    0    3    0    0    0    0    0    0]
[ 1/2    0    0   -5    0    0    0    0    0]
[   0  1/2    0    0   -5    0    0    0    0]
[   0    0  1/2    0    0   -5    0    0    0]
[   8    0    0 -1/2    0    0    4    0    0]
[   0    8    0    0 -1/2    0    0    4    0]
[   0    0    8    0    0 -1/2    0    0    4]

[ 1/3    0    0    0    0    0    0    0    0]
[ 3/2    3    0    0    0    0    0    0    0]
[-1/2    4    3    0    0    0    0    0    0]
[   0    0    0  1/3    0    0    0    0    0]
[   0    0    0  3/2    3    0    0    0    0]
[   0    0    0 -1/2    4    3    0    0    0]
[   0    0    0    0    0    0  1/3    0    0]
[   0    0    0    0    0    0  3/2    3    0]
[   0    0    0    0    0    0 -1/2    4    3]

[   3    0    0    0    0    0    0    0    0]
[ 1/2   -5    0    0    0    0    0    0    0]
[   8 -1/2    4    0    0    0    0    0    0]
[   0    0    0    3    0    0    0    0    0]
[   0    0    0  1/2   -5    0    0    0    0]
[   0    0    0    8 -1/2    4    0    0    0]
[   0    0    0    0    0    0    3    0    0]
[   0    0    0    0    0    0  1/2   -5    0]
[   0    0    0    0    0    0    8 -1/2    4]

```

## Construction of Direct Sums and Tensor Products of Elements

### `DirectSum(a, b): AlgMatElt, AlgMatElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $Q$ and an element $b$ of the matrix algebra $R$, form the direct sum of matrices $a$ and $b$. The square is returned as an element of the matrix algebra $T$, which must be the direct sum of the parent of $a$ and the parent of $b$.

### `ExteriorSquare(a): AlgMatElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $M_n(S)$, form the exterior square of $a$ as an element of $M_m(S)$, where $m = n(n-1)/2$.

### `ExteriorPower(a, r): AlgMat, RngIntElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $M_n(S)$, form the $r$th exterior power of $a$ as an element of $M_m(S)$, where $m = n\choose r$.

### `SymmetricSquare(a): AlgMatElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $M_n(S)$, form the symmetric square of $a$ as an element of $M_m(S)$, where $m = n(n+1)/2$.

### `SymmetricPower(a, r): AlgMatElt, RngIntElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $M_n(S)$, form the $r$th symmetric power of $a$ as an element of $M_m(S)$, for the appropriate $m$.

### `TensorProduct(a, b): AlgMatElt, AlgMatElt -> AlgMatElt`

Given an element $a$ belonging to a subalgebra of $M_{n_1}(S)$ and an element $b$ belonging to a subalgebra of $M_{n_2}(S)$, construct the tensor product of $a$ and $b$ as an element of the matrix algebra $M_n(S)$, where $n = n_1 * n_2$.
