Algorithm to check if first-order polynomial has any roots in region of the integers

49 Views Asked by At

I'm trying to implement a C++ function to check if an object that refers to a tensor has the so-called problem of aliasing. This seems to lead to the following mathematical problem:

Assume you are given natural numbers $a_1,..., a_n > 0$ and $s_1,..., s_n > 1$. Do there exist integers $\gamma_1,...,\gamma_n \in \mathbb{Z}$ not all equal to zero such that

$$\gamma_1 a_1 \; + \; ... \; + \; \gamma_n a_n = 0$$

and $-s_i < \gamma_i < s_i$ for all $i = 1,...n$.

I would need an efficient algorithm to check whether such $\gamma_i$'s exist or not. As $n$ refers to the dimension of a tensor, it is usually not too big but the $a_i, s_i$ can be big. So by efficient I mean that the algorithm should not just simply try all combinations.

For $n = 1$ it is of course trivial, and I think I also figured it out for $n = 2$, but $n > 2$ is giving me a bit of a headache.

I thought maybe this is a well-known mathematical problem with a well-known solution? Any hints, suggestions?