# Sign of a linear combination of roots of unity

Is there a way to access the sign of an integer, self conjugate, linear combination of roots of 1?

More precisely, is there an algorithm (fast is preferred :-) that, given rationals $$q_1,q_2,\ldots,q_n$$ and integers $$a_1,a_2,\ldots,a_n$$ returns the sign of $${\Large\sum}_j a_j(e^{2\pi i q_j}+e^{-2\pi i q_j})\qquad?$$ Of course, this is just the sign of $$\sum_j a_jcos(2\pi q_j)$$.

Deciding 0 can be done working in a cyclotomic field, so the actual question is to decide whether the sum is positive.

If such an algorithm is known, I would appreciate pointers to actual implementations, if extant.