Let $T = {\mathbb R}/{\mathbb Z}$ be the $1$-torus. Let $a\_{ij}$ be integer numbers, $1 \leq i \leq m$, $1 \leq j \leq n$ and $A$ the $m \times n$ matrix whose $(i,j)$ entry is $a\_{ij}$. Consider the following system of $m$ linear equations:


$$\left\{\begin{array}{rl}
a\_{11}x\_1 + a\_{12}x\_2 + \cdots + a\_{1n}x\_n & = \overline{0}\\
a\_{21}x\_1 + a\_{22}x\_2 + \cdots + a\_{2n}x\_n & = \overline{0}\\
\vdots &\\
a\_{m1}x\_1 + a\_{m2}x\_2 + \cdots + a\_{mn}x\_n & = \overline{0}
\end{array}\right.$$


where $x\_1,x\_2,...,x\_n \in T$. The set of solutions $S$ is obviously a subgroup of $T^n$. Let $S\_0$ be the connected component containing the trivial solution $(0,0,...,0)$. 


I would like to understand the quotient group $S/S\_0$. By "understand" I mean compute it an algorithmic way — something which can be implemented on a computer. What is the right way to think about something like this? Thank you.


Remark: For instance, if $m=n$ and $A$ is invertible, then it is fairly easy to show that $S/S\_0$ has order $|\det A|$. (One way to do it is geometric, taking the cup product of the (Poincare duals) of the codimension 1 submanifolds corresponding to solutions of individual equations). Of course, this doesn't come close to answering the question.


P.S. My motivation for asking this question comes from algebraic geometry.



Elementary question about linear algebra on a circle
I believe the magic words are ["Smith Normal Form"](https://www.wikiwand.com/en/Smith_normal_form) (of the matrix $A.$)


