/*
* Copyright 2008-2009 Katholieke Universiteit Leuven
*
- * Use of this software is governed by the GNU LGPLv2.1 license
+ * Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege, K.U.Leuven, Departement
* Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
*
* x2' = Q2 x
*/
-struct isl_mat *isl_mat_variable_compression(struct isl_mat *B,
- struct isl_mat **T2)
+__isl_give isl_mat *isl_mat_variable_compression(__isl_take isl_mat *B,
+ __isl_give isl_mat **T2)
{
int i;
struct isl_mat *H = NULL, *C = NULL, *H1, *U = NULL, *U1, *U2, *TC;
isl_int_init(r);
for (i = 1; i < set->n; ++i) {
- if (isl_basic_set_dim_residue_class(set->p[0], pos, &m, &r) < 0)
+ if (isl_basic_set_dim_residue_class(set->p[i], pos, &m, &r) < 0)
goto error;
isl_int_gcd(*modulo, *modulo, m);
+ isl_int_sub(m, *residue, r);
+ isl_int_gcd(*modulo, *modulo, m);
if (!isl_int_is_zero(*modulo))
isl_int_fdiv_r(*residue, *residue, *modulo);
if (isl_int_is_one(*modulo))
break;
- if (!isl_int_is_zero(*modulo))
- isl_int_fdiv_r(r, r, *modulo);
- if (isl_int_ne(*residue, r)) {
- isl_int_set_si(*modulo, 1);
- isl_int_set_si(*residue, 0);
- break;
- }
}
isl_int_clear(m);