3 void isl_seq_clr(isl_int *p, unsigned len)
6 for (i = 0; i < len; ++i)
7 isl_int_set_si(p[i], 0);
10 void isl_seq_neg(isl_int *dst, isl_int *src, unsigned len)
13 for (i = 0; i < len; ++i)
14 isl_int_neg(dst[i], src[i]);
17 void isl_seq_cpy(isl_int *dst, isl_int *src, unsigned len)
20 for (i = 0; i < len; ++i)
21 isl_int_set(dst[i], src[i]);
24 void isl_seq_scale(isl_int *dst, isl_int *src, isl_int m, unsigned len)
27 for (i = 0; i < len; ++i)
28 isl_int_mul(dst[i], src[i], m);
31 void isl_seq_scale_down(isl_int *dst, isl_int *src, isl_int m, unsigned len)
34 for (i = 0; i < len; ++i)
35 isl_int_divexact(dst[i], src[i], m);
38 void isl_seq_combine(isl_int *dst, isl_int m1, isl_int *src1,
39 isl_int m2, isl_int *src2, unsigned len)
45 for (i = 0; i < len; ++i) {
46 isl_int_mul(tmp, m1, src1[i]);
47 isl_int_addmul(tmp, m2, src2[i]);
48 isl_int_set(dst[i], tmp);
54 * Let d = dst[pos] and s = src[pos]
55 * dst is replaced by |s| dst - sgn(s)d src
57 void isl_seq_elim(isl_int *dst, isl_int *src, unsigned pos, unsigned len,
63 if (isl_int_is_zero(dst[pos]))
69 isl_int_gcd(a, src[pos], dst[pos]);
70 isl_int_divexact(b, dst[pos], a);
71 if (isl_int_is_pos(src[pos]))
73 isl_int_divexact(a, src[pos], a);
75 isl_seq_combine(dst, a, dst, b, src, len);
78 isl_int_mul(*m, *m, a);
84 int isl_seq_eq(isl_int *p1, isl_int *p2, unsigned len)
87 for (i = 0; i < len; ++i)
88 if (isl_int_ne(p1[i], p2[i]))
93 int isl_seq_first_non_zero(isl_int *p, unsigned len)
97 for (i = 0; i < len; ++i)
98 if (!isl_int_is_zero(p[i]))
103 int isl_seq_abs_min_non_zero(isl_int *p, unsigned len)
105 int i, min = isl_seq_first_non_zero(p, len);
108 for (i = min + 1; i < len; ++i) {
109 if (isl_int_is_zero(p[i]))
111 if (isl_int_abs_lt(p[i], p[min]))
117 void isl_seq_gcd(isl_int *p, unsigned len, isl_int *gcd)
119 int i, min = isl_seq_abs_min_non_zero(p, len);
122 isl_int_set_si(*gcd, 0);
125 isl_int_abs(*gcd, p[min]);
126 for (i = 0; isl_int_cmp_si(*gcd, 1) > 0 && i < len; ++i) {
129 if (isl_int_is_zero(p[i]))
131 isl_int_gcd(*gcd, *gcd, p[i]);
135 u_int32_t isl_seq_hash(isl_int *p, unsigned len, unsigned bits)
138 u_int32_t hash = 2166136261u;
140 for (i = 0; i < len; ++i) {
141 if (isl_int_is_zero(p[i]))
145 hash = isl_int_hash(p[i], hash);
150 return (hash >> bits) ^ (hash & (((u_int32_t)1 << bits) - 1));
151 return ((hash >> bits) ^ hash) & (((u_int32_t)1 << bits) - 1);