smith normal form almost working. missing:
- beta and psi functions
- row8 in pseudocode, page5.