1Function: matsnf 2Section: linear_algebra 3C-Name: matsnf0 4Prototype: GD0,L, 5Help: matsnf(X,{flag=0}): Smith normal form (i.e. elementary divisors) of 6 the matrix X, expressed as a vector d; X must have integer or polynomial 7 entries. Binary digits of flag mean 1: returns 8 [u,v,d] where d=u*X*v, otherwise only the diagonal d is returned, 9 4: removes all information corresponding to entries equal to 1 in d. 10Doc: if $X$ is a (singular or nonsingular) matrix outputs the vector of 11 \idx{elementary divisors} of $X$, i.e.~the diagonal of the 12 \idx{Smith normal form} of $X$, normalized so that $d_n \mid d_{n-1} \mid 13 \ldots \mid d_1$. $X$ must have integer or polynomial entries; in the latter 14 case, $X$ must be a square matrix. 15 16 The binary digits of \fl\ mean: 17 18 1 (complete output): if set, outputs $[U,V,D]$, where $U$ and $V$ are two 19 unimodular matrices such that $UXV$ is the diagonal matrix $D$. Otherwise 20 output only the diagonal of $D$. If $X$ is not a square matrix, then $D$ 21 will be a square diagonal matrix padded with zeros on the left or the top. 22 23 4 (cleanup): if set, cleans up the output. This means that elementary 24 divisors equal to $1$ will be deleted, i.e.~outputs a shortened vector $D'$ 25 instead of $D$. If complete output was required, returns $[U',V',D']$ so 26 that $U'XV' = D'$ holds. If this flag is set, $X$ is allowed to be of the 27 form `vector of elementary divisors' or $[U,V,D]$ as would normally be 28 output with the cleanup flag unset. 29