---
title: "Elementary Operations on Subalgebras and Ideals"
canonical: "https://docs.magma-maths.org/v2.30-1/Algebras/MatrixAlgebras/subalgebra-ideal.html"
source: "https://docs.magma-maths.org/v2.30-1/Algebras/MatrixAlgebras/subalgebra-ideal.md"
part: "Algebras"
chapter: "Matrix 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": "Matrix Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/MatrixAlgebras/index-matrix-algebras.md"}
prev: {"title": "Elements of $M_n$ as Homomorphisms", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/MatrixAlgebras/homomorphism-element.md"}
next: {"title": "Accessing and Modifying a Matrix", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/MatrixAlgebras/operation-element.md"}
intrinsics:
  - {"name": "Dimension", "signature": "Dimension(R): AlgMatV -> RngIntElt"}
  - {"name": "Basis", "signature": "Basis(R): AlgMatV -> [ AlgMatElt ]"}
  - {"name": "BasisElement", "signature": "BasisElement(R, i): AlgMatV, RngIntElt -> AlgMatElt"}
  - {"name": "Coordinates", "signature": "Coordinates(R, X): AlgMatV, AlgMatVElt -> [ RngElt ]"}
  - {"name": "meet", "signature": "R meet T: AlgMat, AlgMat -> AlgMat"}
  - {"name": "in", "signature": "x in R: AlgMatElt, AlgMat -> BoolElt"}
  - {"name": "subset", "signature": "X subset R: { AlgMatElt}, AlgMat -> BoolElt"}
  - {"name": "subset", "signature": "T subset R: AlgMat, AlgMat -> BoolElt"}
  - {"name": "notin", "signature": "x notin R: AlgMatElt, AlgMat -> BoolElt"}
  - {"name": "notsubset", "signature": "X notsubset R: { AlgMatElt}, AlgMat -> BoolElt"}
  - {"name": "notsubset", "signature": "T notsubset R: AlgMat, AlgMat -> BoolElt"}
  - {"name": "eq", "signature": "R eq T: AlgMat, AlgMat -> BoolElt"}
  - {"name": "ne", "signature": "R ne T: AlgMat, AlgMat -> BoolElt"}
---

# Elementary Operations on Subalgebras and Ideals

## Bases

The functions described here assume that the matrix algebra $R$ is defined over a ring $S$ with a matrix echelonization algorithm. Magma computes a basis for $R$ considered as a $S$-module when necessary so then operations like membership testing can be performed. The following functions allow one to access this basis.

<a id="function-dimension-algmatv"></a>
### `Dimension(R): AlgMatV -> RngIntElt`

Assuming that $R$ is a subalgebra of $M_n(S)$, return the dimension of $R$, considered as a $S$-module.

<a id="function-basis-algmatv"></a>
### `Basis(R): AlgMatV -> [ AlgMatElt ]`

Assuming that $R$ is a subalgebra of $M_n(S)$, return the $S$-basis of $R$, considered as a $S$-module. The basis is returned as a sequence of matrices of $R$.

<a id="function-basiselement-algmatv-rngintelt"></a>
### `BasisElement(R, i): AlgMatV, RngIntElt -> AlgMatElt`

Given $R$ a subalgebra of $M_n(S)$, return the $i$-th element of the $S$-basis of $R$, where $i$ must be between 1 and the dimension of $R$.

<a id="function-coordinates-algmatv-algmatvelt"></a>
### `Coordinates(R, X): AlgMatV, AlgMatVElt -> [ RngElt ]`

Assuming that $R$ is a subalgebra of $M_n(S)$, and given an element $X$ of $R$, return the coordinates of $X$ with respect to the basis of $R$. If $R$ has dimension $k$ over its coefficient ring $S$, and $R$ has basis $U_1, \ldots, U_k$, the coordinates are returned as the unique sequence $[a_1, \ldots, a_k]$ of elements of $S$ such that $X = a_1 U_1 + \ldots + a_r U_r$.

## Intersection of Subalgebras

<a id="operation-op-meet-algmat-algmat"></a>
### `R meet T: AlgMat, AlgMat -> AlgMat`

Given algebras $R$ and $S$ that are subalgebras of the same complete algebra $M_n(S)$, where $S$ is a PIR, this operator constructs their intersection.

## Membership and Equality

The operations described here assume that the matrix algebra is defined over a principal ideal ring.

<a id="operation-op-in-algmatelt-algmat"></a>
### `x in R: AlgMatElt, AlgMat -> BoolElt`

<a id="operation-op-subset-algmatelt-algmat"></a>
### `X subset R: { AlgMatElt}, AlgMat -> BoolElt`

<a id="operation-op-subset-algmat-algmat"></a>
### `T subset R: AlgMat, AlgMat -> BoolElt`

Given a matrix $x$ (set of matrices $X$, matrix algebra $T$) and a matrix algebra $R$ all belonging to a common matrix algebra defined over a PIR, return `true` if $x$ ($X$, $T$, respectively) is contained in $R$, `false` otherwise.

<a id="operation-op-notin-algmatelt-algmat"></a>
### `x notin R: AlgMatElt, AlgMat -> BoolElt`

<a id="operation-operation-notsubset-algmatelt-algmat-boolelt"></a>
### `X notsubset R: { AlgMatElt}, AlgMat -> BoolElt`

<a id="operation-operation-notsubset-algmat-algmat-boolelt"></a>
### `T notsubset R: AlgMat, AlgMat -> BoolElt`

Given a matrix $x$ (set of matrices $X$, matrix algebra $T$) and a matrix algebra $R$ all belonging to a common matrix algebra defined over a PIR, return `true` if $x$ ($X$, $T$, respectively) is not contained in $R$, `false` otherwise.

<a id="operation-op-eq-algmat-algmat"></a>
### `R eq T: AlgMat, AlgMat -> BoolElt`

Given a matrix algebra $R$, and a matrix algebra $T$, return `true` if $R$ is equal to $T$, `false` otherwise.

<a id="operation-op-ne-algmat-algmat"></a>
### `R ne T: AlgMat, AlgMat -> BoolElt`

Given a matrix algebra $R$ and a matrix algebra $T$, return `true` if $R$ is not equal to $T$, `false` otherwise.
