# Singular          #### D.11.3.1 smith

Procedure from library `jacobson.lib` (see jacobson_lib).

Usage:
smith(M[, eng1, eng2]); M matrix, eng1 and eng2 are optional integers

Return:
matrix or list of matrices, depending on arguments

Assume:
Basering is a commutative polynomial ring in one variable

Purpose:
compute the Smith Normal Form of M with (optionally) transformation matrices

Theory:
Groebner bases are used for the Smith form like in  and .

Note:
By default, just the Smith normal form of M is returned.
If the optional integer `eng1` is non-zero, the list {U,D,V} is returned
where U*M*V = D and the diagonal field entries of D are not normalized.
The normalization of the latter can be done with the 'divideUnits' procedure.
U and V above are square unimodular (invertible) matrices.
Note, that the procedure works for a rectangular matrix M.

The optional integer `eng2` determines the Groebner basis engine:
0 (default) ensures the use of 'slimgb' , otherwise 'std' is used.

Display:
If `printlevel`=1, progress debug messages will be printed,
if `printlevel`>=2, all the debug messages will be printed.

Example:
 ```LIB "jacobson.lib"; ring r = 0,x,Dp; matrix m=x, x^4+x^2+21, x^4+x^2+x, x^3+x, 4*x^2+x, x; list s=smith(m,1); print(s); // non-normalized Smith form of m ==> 21,0, ==> 0, x, ==> 0, 0 print(s*m*s - s); // check U*M*V = D ==> 0,0, ==> 0,0, ==> 0,0 list t = divideUnits(s); print(t); // the Smith form of m ==> 1,0, ==> 0,x, ==> 0,0 ``` 