# Elementary Arithmetic

## `A + B: Mtrx, Mtrx -> Mtrx`

Given $m \times n$ matrices $A$ and $B$ over a ring $R$, return $A+B$.

## `A - B: Mtrx, Mtrx -> Mtrx`

Given $m \times n$ matrices $A$ and $B$ over a ring $R$, return $A-B$.

## `A * B: Mtrx, Mtrx -> Mtrx`

Given an $m \times n$ matrix $A$ over a ring $R$ and an $n \times p$ matrix $B$ over $R$, return the $m \times p$ matrix $A\cdot B$ over $R$. This function attempts to preserve the maximal amount of information in the choice of parent for the product. For example, if $A$ and $B$ are both square and have the same matrix algebra $M$ as parent, then the product will also have $M$ as parent. Similarly, if the parents of $A$ and $B$ are $R$-matrix spaces such that the codomain of $B$ equals the domain $A$, then the product will have domain equal to that of $A$ and codomain equal to that of $B$.

## `x * A: RngElt, Mtrx -> Mtrx`

## `A * x: Mtrx, RngElt -> Mtrx`

Given an $m \times n$ matrix $A$ over a ring $R$ and a ring element $x$ coercible into $R$, return the scalar product $x\cdot A$.

Note that if $x$ is not coercible into the ring $R$ then $A$ may be automatically coerced into the ring of $x$. On the other hand, one particular common case is that multiplying an integral matrix by the real number 1.0 will **not** coerce the matrix into the reals, as the scalar is coercible into the ring $R$ (the integers) in that case.

## `- A: Mtrx -> Mtrx`

Given a matrix $A$, return $-A$.

## `A ^ -1: Mtrx, RngIntElt -> Mtrx`

Given a invertible square matrix $A$ over a ring $R$, return the inverse $B$ of $A$ so that $A\cdot B = B\cdot A = 1$. The coefficient ring $R$ must be either a field, a Euclidean domain, or a ring with an exact division algorithm and having characteristic equal to zero or greater than $m$ (this includes most commutative rings).

## `A ^ n: Mtrx, RngIntElt -> Mtrx`

Given a square matrix $A$ over a ring $R$ and an integer $n$, return the matrix power $A^n$. $A^0$ is defined to be the identity matrix for any square matrix $A$ (even if $A$ is zero). If $n$ is negative, $A$ must be invertible (see the previous function), and the result is $(A^{-1})^{-n}$.

## `Transpose(A): Mtrx -> Mtrx`

Given an $m \times n$ matrix $A$ over a ring $R$, return the transpose of $A$, which is simply the $n \times m$ matrix over $R$ whose $(i,j)$-th entry is the $(j,i)$-th entry of $A$.

## `AddScaledMatrix(A, s, B): Mtrx, RngElt, Mtrx -> Mtrx`

Given a matrix $A$ over a ring $R$, a scalar $s$ coercible into $R$, and a matrix $B$ over $R$ with the same shape as $A$, return $A + s\cdot B$. This is generally quicker than the call `A + s*B`.

## `AddScaledMatrix(~A, s, B): Mtrx, RngElt, Mtrx`

Given a matrix $A$ over a ring $R$, a scalar $s$ coercible into $R$, and a matrix $B$ over $R$ with the same shape as $A$, set $A$ to $A+ s\cdot B$. This is generally quicker than the statement `A := A + s*B;`.
