---
title: "Construction of Structure Constant Algebras and Elements"
canonical: "https://docs.magma-maths.org/v2.30-1/Algebras/StructureConstantAlgebras/creation.html"
source: "https://docs.magma-maths.org/v2.30-1/Algebras/StructureConstantAlgebras/creation.md"
part: "Algebras"
chapter: "Structure Constant Algebras"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/index-algebras.md"}
  - {"title": "Structure Constant Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/StructureConstantAlgebras/index-structure-constant-algebras.md"}
prev: {"title": "Introduction", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/StructureConstantAlgebras/introduction.md"}
next: {"title": "Operations on Structure Constant Algebras and Elements", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/StructureConstantAlgebras/creation-2.md"}
intrinsics:
  - {"name": "Algebra", "signature": "Algebra< R, n | Q : parameters >: Rng, RngIntElt, SeqEnum -> AlgGen"}
  - {"name": "Algebra", "signature": "Algebra< M | Q : parameters >: ModTupRng, SeqEnum -> AlgGen"}
  - {"name": "Algebra", "signature": "Algebra< R, n | T : parameters >: Rng, RngIntElt, SeqEnum -> AlgGen"}
  - {"name": "ChangeBasis", "signature": "ChangeBasis(A, B): AlgGen, {[AlgGenElt]} -> AlgGen"}
  - {"name": "ChangeBasis", "signature": "ChangeBasis(A, B): AlgGen, {[ModTupFldElt]} -> AlgGen"}
  - {"name": "ChangeBasis", "signature": "ChangeBasis(A, B): AlgGen, Mtrx -> AlgGen"}
  - {"name": "elt", "signature": "elt< A | r₁, r₂, ..., rₙ >: AlgGen, RngElt, RngElt, ..., RngElt -> AlgGenElt"}
  - {"name": "!", "signature": "A ! Q: AlgGen, SeqEnum[RngElt] -> AlgGenElt"}
  - {"name": "BasisProduct", "signature": "BasisProduct(A, i, j): AlgGen, RngIntElt, RngIntElt -> AlgGenElt"}
  - {"name": "BasisProducts", "signature": "BasisProducts(A): AlgGen -> SeqEnum"}
---

# Construction of Structure Constant Algebras and Elements

## Construction of a Structure Constant Algebra

There are three ways in Magma to specify the structure constants for a structure constant algebra $A$ of dimension $n$. The first is to give $n^3$ ring elements, the second to identify $A$ with the module $M = R^n$ and give the products $e_i * e_j$ as elements of $M$ and the third to specify only the non-zero structure constants.

<a id="constructor-constructor-algebra-rng-rngintelt-seqenum-alggen"></a>
### `Algebra< R, n | Q : parameters >: Rng, RngIntElt, SeqEnum -> AlgGen`

<a id="constructor-constructor-algebra-modtuprng-seqenum-alggen"></a>
### `Algebra< M | Q : parameters >: ModTupRng, SeqEnum -> AlgGen`

```magma
Rep: MonStgElt                    Default: "Dense"
```

This function creates the structure constant algebra $A$ over the free module $M = R^n$, with standard basis ${e_1, e_2, \ldots, e_n}$, and with the structure constants $a_{ij}^k$ being given by the sequence $Q$. The sequence $Q$ can be of any of the following three forms. Note that in all cases the actual ordering of the structure constants is the same: it is only their division that varies.

**(i)**
A sequence of $n$ sequences of $n$ sequences of length $n$. The $j$-th element of the $i$-th sequence is the sequence $[ a_{ij}^1, \ldots, a_{ij}^n ]$, or the element $(a_{ij}^1, \ldots, a_{ij}^n)$ of $M$, giving the coefficients of the product $e_i * e_j$.

**(ii)**
A sequence of $n^2$ sequences of length $n$, or $n^2$ elements of $M$. Here the coefficients of $e_i * e_j$ are given by position $(i - 1)*n + j$ of $Q$.

**(iii)**
A sequence of $n^3$ elements of the ring $R$. Here the sequence elements are the structure constants themselves, with the ordering $a_{11}^1, a_{11}^2, \ldots, a_{11}^n, a_{12}^1, a_{12}^2, \ldots, a_{nn}^n$. So $a_{ij}^k$ lies in position $(i - 1)*n^2 + (j - 1)*n + k$ of $Q$.

The optional parameter `Rep` can be used to select the internal representation of the structure constants. The possible values for `Rep` are `"Dense"`, `"Sparse"`, and `"Partial"`, with the default being `"Dense"`. In the dense format, the $n^3$ structure constants are stored as $n^2$ vectors of length $n$, similarly to (ii) above. This is the best representation if most of the structure constants are non-zero. The sparse format, intended for use when most structure constants are zero, stores the positions and values of the non-zero structure constants. The partial format stores the vectors, but records for efficiency the positions of the non-zero structure constants.

<a id="constructor-constructor-algebra-rng-rngintelt-seqenum-alggen-2"></a>
### `Algebra< R, n | T : parameters >: Rng, RngIntElt, SeqEnum -> AlgGen`

```magma
Rep: MonStgElt                    Default: "Sparse"
```

This function creates the structure constant algebra $A$ with standard basis ${e_1, e_2, \ldots, e_n}$ over $R$. The sequence $T$ contains quadruples $< i, j, k, a_{ij}^k>$ giving the non-zero structure constants. All other structure constants are defined to be 0.

As above, the optional parameter `Rep` can be used to select the internal representation of the structure constants.

<a id="function-changebasis-alggen-alggenelt"></a>
### `ChangeBasis(A, B): AlgGen, {[AlgGenElt]} -> AlgGen`

<a id="function-changebasis-alggen-modtupfldelt"></a>
### `ChangeBasis(A, B): AlgGen, {[ModTupFldElt]} -> AlgGen`

<a id="function-changebasis-alggen-mtrx"></a>
### `ChangeBasis(A, B): AlgGen, Mtrx -> AlgGen`

```magma
Rep: MonStgElt                    Default: "Dense"
```

Create a new structure constant algebra $A'$, isomorphic to $A$, by recomputing the structure constants with respect to the basis $B$. The basis $B$ can be specified as a set or sequence of elements of $A$, a set or sequence of vectors, or a matrix. The second returned value is the isomorphism from $A$ to $A'$.

As above, the optional parameter `Rep` can be used to select the internal representation of the structure constants. Note that the default is dense representation, regardless of the representation used by $A$.

## Construction of Elements of a Structure Constant Algebra

<a id="constructor-constructor-elt-alggen-rngelt-rngelt-rngelt-alggenelt"></a>
### `elt< A | r₁, r₂, ..., rₙ >: AlgGen, RngElt, RngElt, ..., RngElt -> AlgGenElt`

Given a structure constant algebra $A$ of dimension $n$ over a ring $R$, and ring elements $r_1, r_2, \ldots, r_n \in R$ construct the element $r_1 * e_1 + r_2 * e_2 + \ldots + r_n * e_n$ of $A$.

<a id="operation-op-alggen-seqenum-rngelt"></a>
### `A ! Q: AlgGen, SeqEnum[RngElt] -> AlgGenElt`

Given a structure constant algebra $A$ of dimension $n$ and a sequence $Q = [r_1, r_2, \ldots, r_n]$ of elements of the base ring $R$ of $A$, construct the element $r_1 * e_1 + r_2 * e_2 + \ldots + r_n * e_n$ of $A$.

<a id="function-basisproduct-alggen-rngintelt-rngintelt"></a>
### `BasisProduct(A, i, j): AlgGen, RngIntElt, RngIntElt -> AlgGenElt`

Return the product of the $i$-th and $j$-th basis element of the algebra $A$.

<a id="function-basisproducts-alggen"></a>
### `BasisProducts(A): AlgGen -> SeqEnum`

```magma
Rep: MonStgElt                    Default: "Dense"
```

Return the products of all basis elements of the algebra $A$.

The optional parameter `Rep` may be used to specify the format of the result. If `Rep` is set to “Dense”, the products are returned as a sequence $Q$ of $n$ sequences of $n$ elements of $A$, where $n$ is the dimension of $A$. The element $Q[i][j]$ is the product of the $i$-th and $j$-th basis elements.

If `Rep` is set to “Sparse”, the products are returned as a sequence $Q$ containing quadruples $(i,j,k,a_{ijk})$ signifying that the product of the $i$-th and $j$-th basis elements is $\sum_{k=1}^n a_{ijk} b_k$, where $b_k$ is the $k$-th basis element and $n =$ dim($A$).
