# linalg::smithForm

Smith canonical form of a matrix

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```linalg::smithForm(`A`)
```

## Description

`linalg::smithForm(A)` computes the Smith canonical form of the n-dimensional square matrix A, i.e., an n×n diagonal matrix S such that Si - 1, i - 1 divides Si, i for i = 2, …, n.

The Smith canonical form of a matrix `A` is unique.

The component ring of `A` must be a Euclidean ring, i.e., a domain of category `Cat::EuclideanDomain`.

## Examples

### Example 1

We define a matrix over the integers:

```MatZ := Dom::Matrix(Dom::Integer): A := MatZ([[9, -36, 30], [-36, 192, -180], [30, -180, 180]])```

The Smith canonical form of `A` is then given by:

`linalg::smithForm(A)`

### Example 2

We compute the Smith canonical form of a matrix over a ring of polynomials:

```MatPoly := Dom::Matrix(Dom::DistributedPolynomial([x], Dom::Rational)): B := MatPoly( [[-(x - 3)^2*(x - 2),(x - 3)*(x - 2)*(x - 4)], [(x - 3)*(x - 2)*(x - 4),-(x - 3)^2*(x - 4)] ])```

The Smith canonical form of the matrix `B` is the following matrix:

`linalg::smithForm(B)`

## Parameters

 `A` A square matrix of a domain of category `Cat::Matrix`

## Return Values

Matrix of the same domain type as `A`.

## Algorithms

An n×n matrix S = (sij) with coefficients in a Euclidean ring is said to be in Smith canonical form if S is a diagonal matrix (with nonnegative coefficients in case of the ring ) such that si, i divides si + 1, i + 1 for all i < n.