Function: nfsnf
Section: number_fields
C-Name: nfsnf0
Prototype: GGD0,L,
Help: nfsnf(nf,x,{flag=0}): if x=[A,I,J], outputs D=[d_1,...d_n] Smith normal
form of x. If flag is non-zero return [D,U,V], where UAV = Id.
Doc: given a torsion $\Z_K$-module $x$ attached to the square integral
invertible pseudo-matrix $(A,I,J)$, returns an ideal list
$D=[d_1,\dots,d_n]$ which is the \idx{Smith normal form} of $x$. In other
words, $x$ is isomorphic to $\Z_K/d_1\oplus\cdots\oplus\Z_K/d_n$ and $d_i$
divides $d_{i-1}$ for $i\ge2$. If $\fl$ is non-zero return $[D,U,V]$, where
$UAV$ is the identity.
See \secref{se:ZKmodules} for the definition of integral pseudo-matrix;
briefly, it is input as a 3-component row vector $[A,I,J]$ where
$I = [b_1,\dots,b_n]$ and $J = [a_1,\dots,a_n]$ are two ideal lists,
and $A$ is a square $n\times n$ matrix with columns $(A_1,\dots,A_n)$,
seen as elements in $K^n$ (with canonical basis $(e_1,\dots,e_n)$).
This data defines the $\Z_K$ module $x$ given by
$$ (b_1e_1\oplus\cdots\oplus b_ne_n) / (a_1A_1\oplus\cdots\oplus a_nA_n)
\enspace, $$
The integrality condition is $a_{i,j} \in b_i a_j^{-1}$ for all $i,j$. If it
is not satisfied, then the $d_i$ will not be integral. Note that every
finitely generated torsion module is isomorphic to a module of this form and
even with $b_i=Z_K$ for all $i$.
Variant: Also available:
\fun{GEN}{nfsnf}{GEN nf, GEN x} ($\fl = 0$).