# Elementary question about linear algebra on a circle

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.

I believe the magic words are "Smith Normal Form" (of the matrix $A.$)