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_swp_or_cpy(isl_int *dst, isl_int *src, unsigned len)
27 for (i = 0; i < len; ++i)
28 isl_int_swap_or_set(dst[i], src[i]);
31 void isl_seq_scale(isl_int *dst, isl_int *src, isl_int m, unsigned len)
34 for (i = 0; i < len; ++i)
35 isl_int_mul(dst[i], src[i], m);
38 void isl_seq_scale_down(isl_int *dst, isl_int *src, isl_int m, unsigned len)
41 for (i = 0; i < len; ++i)
42 isl_int_divexact(dst[i], src[i], m);
45 void isl_seq_combine(isl_int *dst, isl_int m1, isl_int *src1,
46 isl_int m2, isl_int *src2, unsigned len)
52 for (i = 0; i < len; ++i) {
53 isl_int_mul(tmp, m1, src1[i]);
54 isl_int_addmul(tmp, m2, src2[i]);
55 isl_int_set(dst[i], tmp);
61 * Let d = dst[pos] and s = src[pos]
62 * dst is replaced by |s| dst - sgn(s)d src
64 void isl_seq_elim(isl_int *dst, isl_int *src, unsigned pos, unsigned len,
70 if (isl_int_is_zero(dst[pos]))
76 isl_int_gcd(a, src[pos], dst[pos]);
77 isl_int_divexact(b, dst[pos], a);
78 if (isl_int_is_pos(src[pos]))
80 isl_int_divexact(a, src[pos], a);
82 isl_seq_combine(dst, a, dst, b, src, len);
85 isl_int_mul(*m, *m, a);
91 int isl_seq_eq(isl_int *p1, isl_int *p2, unsigned len)
94 for (i = 0; i < len; ++i)
95 if (isl_int_ne(p1[i], p2[i]))
100 int isl_seq_is_neg(isl_int *p1, isl_int *p2, unsigned len)
104 for (i = 0; i < len; ++i) {
105 if (isl_int_abs_ne(p1[i], p2[i]))
107 if (isl_int_is_zero(p1[i]))
109 if (isl_int_eq(p1[i], p2[i]))
115 int isl_seq_first_non_zero(isl_int *p, unsigned len)
119 for (i = 0; i < len; ++i)
120 if (!isl_int_is_zero(p[i]))
125 int isl_seq_abs_min_non_zero(isl_int *p, unsigned len)
127 int i, min = isl_seq_first_non_zero(p, len);
130 for (i = min + 1; i < len; ++i) {
131 if (isl_int_is_zero(p[i]))
133 if (isl_int_abs_lt(p[i], p[min]))
139 void isl_seq_gcd(isl_int *p, unsigned len, isl_int *gcd)
141 int i, min = isl_seq_abs_min_non_zero(p, len);
144 isl_int_set_si(*gcd, 0);
147 isl_int_abs(*gcd, p[min]);
148 for (i = 0; isl_int_cmp_si(*gcd, 1) > 0 && i < len; ++i) {
151 if (isl_int_is_zero(p[i]))
153 isl_int_gcd(*gcd, *gcd, p[i]);
157 void isl_seq_inner_product(isl_int *p1, isl_int *p2, unsigned len,
162 isl_int_set_si(*prod, 0);
165 isl_int_mul(*prod, p1[0], p2[0]);
166 for (i = 1; i < len; ++i)
167 isl_int_addmul(*prod, p1[i], p2[i]);
170 u_int32_t isl_seq_hash(isl_int *p, unsigned len, unsigned bits)
173 u_int32_t hash = 2166136261u;
175 for (i = 0; i < len; ++i) {
176 if (isl_int_is_zero(p[i]))
180 hash = isl_int_hash(p[i], hash);
185 return (hash >> bits) ^ (hash & (((u_int32_t)1 << bits) - 1));
186 return ((hash >> bits) ^ hash) & (((u_int32_t)1 << bits) - 1);