# Introduction

This chapter discusses Magma operations with multilinear algebra. The notation follows [[First *et al.*, 2019](../../references.md#cite-fmw-densors)] closely and can be viewed as companion literature. Wherever possible we follow the conventions in use in physics [[Weyl, 1950](../../references.md#cite-weyl), Chapter V], differential geometry [[Lee, 2013](../../references.md#cite-lee-geom), Chapter 10], and algebra [[Landsberg, 2012](../../references.md#cite-landsberg-tensors)]. Necessary categorical formalism is drawn largely from [[Wilson, 2013](../../references.md#cite-wilson-division)]. The package covers:

**(1)**
Tensors and multilinear functions and their associated groups and algebras.

**(2)**
Spaces of tensors.

**(3)**
Categories of tensors and tensor spaces.

**(4)**
Linear invariants of tensors.

## Overview

We set up some notation used throughout. Define $K$ to be a commutative ring (typically a field), $\nu$ to be a nonnegative integer, and a sequence of right $K$-modules $U_0,\dots,U_{\nu}$. Set $[\nu]=\{0,\dots,\nu\}$, and for a subset $A\subset[\nu]$, let $\bar{A}=[\nu]-A$. Let $\oslash_{a\in[\nu]} U_a$ denote the set of multilinear maps $U_{\nu}\times\cdots U_1\rightarrowtail U_0$. Here, we use $\rightarrowtail$ exclusively for multilinear maps.

A *tensor space* $T$ is a $K$-module equipped with a monomorphism

$$
\langle \cdot | : T \hookrightarrow \oslash_{a\in[\nu]}U_a.
$$

*Tensors* are elements of $T$, $(U_{\nu},\dots,U_0)$ is the *frame*, and $\nu+1$ is the valence. In Dirac styled $\langle t|$ “bra t” and $|u\rangle$ “ket u” notation, we evaluate $\langle t | \in\oslash_{a\in[\nu]}U_a$ on inputs $|u\rangle=|u_{\nu},\dots, u_1\rangle\in U_{\nu}\times\cdots\times U_1$ denote $\langle t | u\rangle$ or $\langle t | u_{\nu},\dots,u_1\rangle$.

The module $U_0$ is reserved for the codomain which in turn makes reverse indexing the simplest notation. Every tensor in Magma is treated as an element of a tensor space which is, by default, a universal tensor space:

$$
\oslash_{a\in[\nu]} U_a = \hom_K(U_{\nu},\dots,\hom_K(U_1,U_0)\cdots).
$$

In Magma, the tensor space determines the associated multilinear function of a given tensor $T$. Evaluation of $T$ mimics the application of a map $U_v\times \cdots \times U_1\to U_0$, for instance,

```
> <u_v, ..., u_1> @ T;

```

Special attention is given to bilinear maps $*:U_2\times U_1\rightarrowtail U_0$ including the ability to use infix notation `u\_2 * u\_1`. Tensor spaces have type `TenSpc` and behave like modules in that they have subspaces and quotient spaces. Tensors have type `TenSpcElt` and behave in a similar way to Magma matrices.

A library of commonly used exceptional tensors is provided. These include octonion algebras and exceptional Jordan algebras.

Tensor categories, type `TenCat`, provide Magma with the information needed to interpret the contents of a tensor space. For example, one tensor category may treat a $(d\times d)$-matrix $F$ over a field $K$ as a linear map $K^d\to K^d$, while another assigns the same matrix to a bilinear form $K^d\times K^d\rightarrowtail K$. Functors are provided to change tensor categories and to define standard categories.

## Verbose Printing

The string `"TensorSpace"` and an integer, either $0$ or $1$, is now acceptable input to `SetVerbose`. Level $0$ turns off printing, and level $1$ turns it on.

### `Example: Verbose Printing (ex-18db1e)`

We demonstrate the verbose printing. Currently, we only have verbose printing when we solve linear systems. To turn on all the printing statements, set `"TensorSpace"` to $1$.

```magma
> SetVerbose("TensorSpace", 1);
>
> t := RandomTensor(GF(2), [32, 32, 32]);
> D := DerivationAlgebra(t);
Construting a 3072 by 32768 matrix over Finite field of size 2.
Adding in possible fusion data.
Computing the nullspace of a 3072 by 32768 matrix.

```

### `T : Magma;`

### `S : Magma;`

### `C : Magma;`

Prints strings that can be executed in Magma to construct the given object. If $T$ is a black-box tensor where structure constants cannot be computed, then the printed string is the same as `print T`, which cannot be executed to construct $T$.

### `Example: Print To String (ex-525a77)`

We first construct a tensor category, tensor space, and a tensor contained in the tensor space.

```magma
> C := TensorCategory([1, 1, 0], {{0}, {1,2}});
> C;
Tensor category of valence 3 (->,->,==) ({ 0 },{ 1, 2 })
>
> T := KTensorSpace(GF(2), [10, 10, 2], C);
> T;
Tensor space of dimension 200 over GF(2) with valence 3
U2 : Full Vector space of degree 10 over GF(2)
U1 : Full Vector space of degree 10 over GF(2)
U0 : Full Vector space of degree 2 over GF(2)
>
> t := T![1..200];
> t;
Tensor of valence 3, U2 x U1 >-> U0
U2 : Full Vector space of degree 10 over GF(2)
U1 : Full Vector space of degree 10 over GF(2)
U0 : Full Vector space of degree 2 over GF(2)

```

Now we will print at “Magma” level each of the objects we created.

```magma
> C:Magma;
TensorCategory([ 1, 1, 0 ], { PowerSet(IntegerRing()) |
{ IntegerRing() | 0 },
{ IntegerRing() | 1, 2 }
})
>
> T:Magma;
TensorSpace([*VectorSpace(GF(2), 10), VectorSpace(GF(2), 10),
VectorSpace(GF(2),2)*], TensorCategory([ 1, 1, 0 ], {
PowerSet(IntegerRing()) |
{ IntegerRing() | 0 },
{ IntegerRing() | 1, 2 }
}))
>
> t:Magma;
Tensor(GF(2), [ 10, 10, 2 ], [ GF(2) | 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0 ], TensorCategory([ 1, 1, 0 ], { PowerSet(IntegerRing()) |
{ IntegerRing() | 0 },
{ IntegerRing() | 1, 2 }
}))

```
