# 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.

### `Dimension(R): AlgMatV -> RngIntElt`

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

### `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$.

### `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$.

### `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

### `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.

### `x in R: AlgMatElt, AlgMat -> BoolElt`

### `X subset R: { AlgMatElt}, AlgMat -> BoolElt`

### `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.

### `x notin R: AlgMatElt, AlgMat -> BoolElt`

### `X notsubset R: { AlgMatElt}, AlgMat -> BoolElt`

### `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.

### `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.

### `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.
