change isl_mat_sub_alloc prototype
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 6 Apr 2011 12:09:00 +0000 (14:09 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 21 Apr 2011 11:13:11 +0000 (13:13 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
basis_reduction_templ.c
isl_affine_hull.c
isl_convex_hull.c
isl_equalities.c
isl_map.c
isl_map_simplify.c
isl_mat.c
isl_mat_private.h
isl_morph.c
isl_sample.c

index dd90a15..2e4034f 100644 (file)
@@ -337,7 +337,7 @@ struct isl_mat *isl_basic_set_reduced_basis(struct isl_basic_set *bset)
        else {
                isl_mat *eq;
                unsigned nvar = isl_basic_set_total_dim(bset);
-               eq = isl_mat_sub_alloc(bset->ctx, bset->eq, 0, bset->n_eq,
+               eq = isl_mat_sub_alloc6(bset->ctx, bset->eq, 0, bset->n_eq,
                                        1, nvar);
                eq = isl_mat_left_hermite(eq, 0, NULL, &tab->basis);
                tab->basis = isl_mat_lin_to_aff(tab->basis);
index 396b56c..99a35a1 100644 (file)
@@ -697,7 +697,7 @@ static struct isl_basic_set *affine_hull_with_cone(struct isl_basic_set *bset,
        total = isl_basic_set_total_dim(cone);
        cone_dim = total - cone->n_eq;
 
-       M = isl_mat_sub_alloc(bset->ctx, cone->eq, 0, cone->n_eq, 1, total);
+       M = isl_mat_sub_alloc6(bset->ctx, cone->eq, 0, cone->n_eq, 1, total);
        M = isl_mat_left_hermite(M, 0, &U, &Q);
        if (!M)
                goto error;
index b0e3ed9..8c04265 100644 (file)
@@ -1039,7 +1039,7 @@ static struct isl_basic_set *modulo_lineality(struct isl_set *set,
        if (!set || !lin)
                goto error;
        lin_dim = total - lin->n_eq;
-       M = isl_mat_sub_alloc(set->ctx, lin->eq, 0, lin->n_eq, 1, total);
+       M = isl_mat_sub_alloc6(set->ctx, lin->eq, 0, lin->n_eq, 1, total);
        M = isl_mat_left_hermite(M, 0, &U, &Q);
        if (!M)
                goto error;
@@ -1672,7 +1672,7 @@ static struct isl_basic_set *common_constraints(struct isl_basic_set *hull,
 
        total = isl_dim_total(set->dim);
        for (i = 0; i < set->p[best]->n_ineq; ++i) {
-               constraints[i].c = isl_mat_sub_alloc(hull->ctx,
+               constraints[i].c = isl_mat_sub_alloc6(hull->ctx,
                        set->p[best]->ineq + i, 0, 1, 0, 1 + total);
                if (!constraints[i].c)
                        goto error;
index 31e3b9c..fa8ee58 100644 (file)
@@ -85,7 +85,7 @@ static struct isl_mat *particular_solution(struct isl_mat *B, struct isl_vec *d)
        M = isl_mat_left_hermite(M, 0, &U, NULL);
        if (!M || !U)
                goto error;
-       H = isl_mat_sub_alloc(B->ctx, M->row, 0, B->n_row, 0, B->n_row);
+       H = isl_mat_sub_alloc(M, 0, B->n_row, 0, B->n_row);
        H = isl_mat_lin_to_aff(H);
        C = isl_mat_inverse_product(H, C);
        if (!C)
@@ -98,8 +98,8 @@ static struct isl_mat *particular_solution(struct isl_mat *B, struct isl_vec *d)
        if (i < B->n_row)
                cst = isl_mat_alloc(B->ctx, B->n_row, 0);
        else
-               cst = isl_mat_sub_alloc(C->ctx, C->row, 1, B->n_row, 0, 1);
-       T = isl_mat_sub_alloc(U->ctx, U->row, B->n_row, B->n_col - 1, 0, B->n_row);
+               cst = isl_mat_sub_alloc(C, 1, B->n_row, 0, 1);
+       T = isl_mat_sub_alloc(U, B->n_row, B->n_col - 1, 0, B->n_row);
        cst = isl_mat_product(T, cst);
        isl_mat_free(M);
        isl_mat_free(C);
@@ -184,7 +184,7 @@ static struct isl_mat *parameter_compression_multi(
                                                D, U->row[j][k]);
        }
        A = isl_mat_left_hermite(A, 0, NULL, NULL);
-       T = isl_mat_sub_alloc(A->ctx, A->row, 0, A->n_row, 0, A->n_row);
+       T = isl_mat_sub_alloc(A, 0, A->n_row, 0, A->n_row);
        T = isl_mat_lin_to_aff(T);
        if (!T)
                goto error;
@@ -426,7 +426,7 @@ struct isl_mat *isl_mat_variable_compression(struct isl_mat *B,
                goto error;
 
        dim = B->n_col - 1;
-       H = isl_mat_sub_alloc(B->ctx, B->row, 0, B->n_row, 1, dim);
+       H = isl_mat_sub_alloc(B, 0, B->n_row, 1, dim);
        H = isl_mat_left_hermite(H, 0, &U, T2);
        if (!H || !U || (T2 && !*T2))
                goto error;
@@ -441,7 +441,7 @@ struct isl_mat *isl_mat_variable_compression(struct isl_mat *B,
                goto error;
        isl_int_set_si(C->row[0][0], 1);
        isl_mat_sub_neg(C->ctx, C->row+1, B->row, B->n_row, 0, 0, 1);
-       H1 = isl_mat_sub_alloc(H->ctx, H->row, 0, H->n_row, 0, H->n_row);
+       H1 = isl_mat_sub_alloc(H, 0, H->n_row, 0, H->n_row);
        H1 = isl_mat_lin_to_aff(H1);
        TC = isl_mat_inverse_product(H1, C);
        if (!TC)
@@ -464,10 +464,9 @@ struct isl_mat *isl_mat_variable_compression(struct isl_mat *B,
                }
                isl_int_set_si(TC->row[0][0], 1);
        }
-       U1 = isl_mat_sub_alloc(U->ctx, U->row, 0, U->n_row, 0, B->n_row);
+       U1 = isl_mat_sub_alloc(U, 0, U->n_row, 0, B->n_row);
        U1 = isl_mat_lin_to_aff(U1);
-       U2 = isl_mat_sub_alloc(U->ctx, U->row, 0, U->n_row,
-                               B->n_row, U->n_row - B->n_row);
+       U2 = isl_mat_sub_alloc(U, 0, U->n_row, B->n_row, U->n_row - B->n_row);
        U2 = isl_mat_lin_to_aff(U2);
        isl_mat_free(U);
        TC = isl_mat_product(U1, TC);
@@ -513,7 +512,7 @@ static struct isl_basic_set *compress_variables(
        if (bset->n_eq == 0)
                return bset;
 
-       B = isl_mat_sub_alloc(bset->ctx, bset->eq, 0, bset->n_eq, 0, 1 + dim);
+       B = isl_mat_sub_alloc6(bset->ctx, bset->eq, 0, bset->n_eq, 0, 1 + dim);
        TC = isl_mat_variable_compression(B, T2);
        if (!TC)
                goto error;
@@ -584,7 +583,7 @@ int isl_basic_set_dim_residue_class(struct isl_basic_set *bset,
        ctx = bset->ctx;
        total = isl_basic_set_total_dim(bset);
        nparam = isl_basic_set_n_param(bset);
-       H = isl_mat_sub_alloc(bset->ctx, bset->eq, 0, bset->n_eq, 1, total);
+       H = isl_mat_sub_alloc6(bset->ctx, bset->eq, 0, bset->n_eq, 1, total);
        H = isl_mat_left_hermite(H, 0, &U, NULL);
        if (!H)
                return -1;
@@ -605,11 +604,11 @@ int isl_basic_set_dim_residue_class(struct isl_basic_set *bset,
                goto error;
        isl_int_set_si(C->row[0][0], 1);
        isl_mat_sub_neg(C->ctx, C->row+1, bset->eq, bset->n_eq, 0, 0, 1);
-       H1 = isl_mat_sub_alloc(H->ctx, H->row, 0, H->n_row, 0, H->n_row);
+       H1 = isl_mat_sub_alloc(H, 0, H->n_row, 0, H->n_row);
        H1 = isl_mat_lin_to_aff(H1);
        C = isl_mat_inverse_product(H1, C);
        isl_mat_free(H);
-       U1 = isl_mat_sub_alloc(U->ctx, U->row, nparam+pos, 1, 0, bset->n_eq);
+       U1 = isl_mat_sub_alloc(U, nparam+pos, 1, 0, bset->n_eq);
        U1 = isl_mat_lin_to_aff(U1);
        isl_mat_free(U);
        C = isl_mat_product(U1, C);
index 9b9d54b..b5eafbc 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -5066,7 +5066,7 @@ static struct isl_set *parameter_compute_divs(struct isl_basic_set *bset)
        if (i == bset->n_eq)
                return isl_basic_set_lexmin(bset);
 
-       eq = isl_mat_sub_alloc(bset->ctx, bset->eq, i, bset->n_eq - i,
+       eq = isl_mat_sub_alloc6(bset->ctx, bset->eq, i, bset->n_eq - i,
                0, 1 + nparam);
        eq = isl_mat_cow(eq);
        T = isl_mat_variable_compression(isl_mat_copy(eq), &T2);
index 157d6b7..e733cbd 100644 (file)
@@ -813,7 +813,7 @@ static struct isl_basic_map *normalize_divs(
                return bmap;
 
        if (div_eq < bmap->n_eq) {
-               B = isl_mat_sub_alloc(bmap->ctx, bmap->eq, div_eq,
+               B = isl_mat_sub_alloc6(bmap->ctx, bmap->eq, div_eq,
                                        bmap->n_eq - div_eq, 0, 1 + total);
                C = isl_mat_variable_compression(B, &C2);
                if (!C || !C2)
@@ -834,7 +834,7 @@ static struct isl_basic_map *normalize_divs(
                        --j;
                isl_int_set(d->block.data[i], bmap->eq[i][1 + total + j]);
        }
-       B = isl_mat_sub_alloc(bmap->ctx, bmap->eq, 0, div_eq, 0, 1 + total);
+       B = isl_mat_sub_alloc6(bmap->ctx, bmap->eq, 0, div_eq, 0, 1 + total);
 
        if (C) {
                B = isl_mat_product(B, C);
@@ -1559,7 +1559,7 @@ static struct isl_basic_set *normalize_constraints_in_compressed_space(
                return NULL;
 
        total = isl_basic_set_total_dim(bset);
-       B = isl_mat_sub_alloc(bset->ctx, bset->eq, 0, bset->n_eq, 0, 1 + total);
+       B = isl_mat_sub_alloc6(bset->ctx, bset->eq, 0, bset->n_eq, 0, 1 + total);
        C = isl_mat_variable_compression(B, NULL);
        if (!C)
                return bset;
@@ -1567,7 +1567,7 @@ static struct isl_basic_set *normalize_constraints_in_compressed_space(
                isl_mat_free(C);
                return isl_basic_set_set_to_empty(bset);
        }
-       B = isl_mat_sub_alloc(bset->ctx, bset->ineq,
+       B = isl_mat_sub_alloc6(bset->ctx, bset->ineq,
                                                0, bset->n_ineq, 0, 1 + total);
        C = isl_mat_product(B, C);
        if (!C)
@@ -1742,7 +1742,7 @@ static __isl_give isl_basic_set *uset_gist(__isl_take isl_basic_set *bset,
                return uset_gist_full(bset, context);
        }
        total = isl_basic_set_total_dim(bset);
-       eq = isl_mat_sub_alloc(bset->ctx, aff->eq, 0, aff->n_eq, 0, 1 + total);
+       eq = isl_mat_sub_alloc6(bset->ctx, aff->eq, 0, aff->n_eq, 0, 1 + total);
        eq = isl_mat_cow(eq);
        T = isl_mat_variable_compression(eq, &T2);
        if (T && T->n_col == 0) {
index 9a8a558..0f053a5 100644 (file)
--- a/isl_mat.c
+++ b/isl_mat.c
@@ -107,7 +107,7 @@ error:
        return NULL;
 }
 
-struct isl_mat *isl_mat_sub_alloc(struct isl_ctx *ctx, isl_int **row,
+__isl_give isl_mat *isl_mat_sub_alloc6(isl_ctx *ctx, isl_int **row,
        unsigned first_row, unsigned n_row, unsigned first_col, unsigned n_col)
 {
        int i;
@@ -134,6 +134,15 @@ error:
        return NULL;
 }
 
+__isl_give isl_mat *isl_mat_sub_alloc(__isl_keep isl_mat *mat,
+       unsigned first_row, unsigned n_row, unsigned first_col, unsigned n_col)
+{
+       if (!mat)
+               return NULL;
+       return isl_mat_sub_alloc6(mat->ctx, mat->row, first_row, n_row,
+                                 first_col, n_col);
+}
+
 void isl_mat_sub_copy(struct isl_ctx *ctx, isl_int **dst, isl_int **src,
        unsigned n_row, unsigned dst_col, unsigned src_col, unsigned n_col)
 {
@@ -1004,7 +1013,7 @@ static int preimage(struct isl_ctx *ctx, isl_int **q, unsigned n,
        if (has_div)
                for (i = 0; i < n; ++i)
                        isl_int_mul(q[i][0], q[i][0], mat->row[0][0]);
-       t = isl_mat_sub_alloc(mat->ctx, q, 0, n, has_div, mat->n_row);
+       t = isl_mat_sub_alloc6(mat->ctx, q, 0, n, has_div, mat->n_row);
        t = isl_mat_product(t, mat);
        if (!t)
                return -1;
index 95b41d1..5ba4990 100644 (file)
@@ -19,7 +19,9 @@ struct isl_mat {
        struct isl_blk block;
 };
 
-struct isl_mat *isl_mat_sub_alloc(struct isl_ctx *ctx, isl_int **row,
+__isl_give isl_mat *isl_mat_sub_alloc(__isl_keep isl_mat *mat,
+       unsigned first_row, unsigned n_row, unsigned first_col, unsigned n_col);
+__isl_give isl_mat *isl_mat_sub_alloc6(isl_ctx *ctx, isl_int **row,
        unsigned first_row, unsigned n_row, unsigned first_col, unsigned n_col);
 void isl_mat_sub_copy(struct isl_ctx *ctx, isl_int **dst, isl_int **src,
        unsigned n_row, unsigned dst_col, unsigned src_col, unsigned n_col);
index 8a526e7..e0c58d8 100644 (file)
@@ -354,7 +354,7 @@ __isl_give isl_morph *isl_basic_set_variable_compression(
        if (n_eq == 0)
                return isl_morph_identity(bset);
 
-       H = isl_mat_sub_alloc(bset->ctx, bset->eq, f_eq, n_eq, otype, ntype);
+       H = isl_mat_sub_alloc6(bset->ctx, bset->eq, f_eq, n_eq, otype, ntype);
        H = isl_mat_left_hermite(H, 0, &U, &Q);
        if (!H || !U || !Q)
                goto error;
@@ -367,7 +367,7 @@ __isl_give isl_morph *isl_basic_set_variable_compression(
        isl_int_set_si(C->row[0][0], 1);
        isl_seq_clr(C->row[0] + 1, otype - 1);
        isl_mat_sub_neg(C->ctx, C->row + 1, bset->eq + f_eq, n_eq, 0, 0, otype);
-       H1 = isl_mat_sub_alloc(H->ctx, H->row, 0, H->n_row, 0, H->n_row);
+       H1 = isl_mat_sub_alloc(H, 0, H->n_row, 0, H->n_row);
        H1 = isl_mat_lin_to_aff(H1);
        C = isl_mat_inverse_product(H1, C);
        if (!C)
@@ -397,9 +397,9 @@ __isl_give isl_morph *isl_basic_set_variable_compression(
                C = isl_mat_normalize(C);
        }
 
-       U1 = isl_mat_sub_alloc(U->ctx, U->row, 0, U->n_row, 0, n_eq);
+       U1 = isl_mat_sub_alloc(U, 0, U->n_row, 0, n_eq);
        U1 = isl_mat_lin_to_aff(U1);
-       U2 = isl_mat_sub_alloc(U->ctx, U->row, 0, U->n_row, n_eq, U->n_row - n_eq);
+       U2 = isl_mat_sub_alloc(U, 0, U->n_row, n_eq, U->n_row - n_eq);
        U2 = isl_mat_lin_to_aff(U2);
        isl_mat_free(U);
 
@@ -466,8 +466,8 @@ __isl_give isl_morph *isl_basic_set_parameter_compression(
        isl_assert(bset->ctx, n_eq <= nvar, return NULL);
 
        d = isl_vec_alloc(bset->ctx, n_eq);
-       B = isl_mat_sub_alloc(bset->ctx, bset->eq, 0, n_eq, 0, 1 + nparam);
-       H = isl_mat_sub_alloc(bset->ctx, bset->eq, 0, n_eq, 1 + nparam, nvar);
+       B = isl_mat_sub_alloc6(bset->ctx, bset->eq, 0, n_eq, 0, 1 + nparam);
+       H = isl_mat_sub_alloc6(bset->ctx, bset->eq, 0, n_eq, 1 + nparam, nvar);
        H = isl_mat_left_hermite(H, 0, NULL, NULL);
        H = isl_mat_drop_cols(H, n_eq, nvar - n_eq);
        H = isl_mat_lin_to_aff(H);
@@ -583,7 +583,7 @@ __isl_give isl_basic_set *isl_morph_basic_set(__isl_take isl_morph *morph,
                if (isl_basic_set_alloc_div(res) < 0)
                        goto error;
 
-       mat = isl_mat_sub_alloc(bset->ctx, bset->eq, 0, bset->n_eq,
+       mat = isl_mat_sub_alloc6(bset->ctx, bset->eq, 0, bset->n_eq,
                                        0, morph->inv->n_row);
        mat = isl_mat_product(mat, isl_mat_copy(morph->inv));
        if (!mat)
@@ -598,7 +598,7 @@ __isl_give isl_basic_set *isl_morph_basic_set(__isl_take isl_morph *morph,
        }
        isl_mat_free(mat);
 
-       mat = isl_mat_sub_alloc(bset->ctx, bset->ineq, 0, bset->n_ineq,
+       mat = isl_mat_sub_alloc6(bset->ctx, bset->ineq, 0, bset->n_ineq,
                                        0, morph->inv->n_row);
        mat = isl_mat_product(mat, isl_mat_copy(morph->inv));
        if (!mat)
@@ -614,7 +614,7 @@ __isl_give isl_basic_set *isl_morph_basic_set(__isl_take isl_morph *morph,
        }
        isl_mat_free(mat);
 
-       mat = isl_mat_sub_alloc(bset->ctx, bset->div, 0, bset->n_div,
+       mat = isl_mat_sub_alloc6(bset->ctx, bset->div, 0, bset->n_div,
                                        1, morph->inv->n_row);
        mat = isl_mat_product(mat, isl_mat_copy(morph->inv));
        if (!mat)
index fd01261..80b0031 100644 (file)
@@ -963,7 +963,7 @@ __isl_give isl_vec *isl_basic_set_sample_with_cone(
        total = isl_basic_set_total_dim(cone);
        cone_dim = total - cone->n_eq;
 
-       M = isl_mat_sub_alloc(bset->ctx, cone->eq, 0, cone->n_eq, 1, total);
+       M = isl_mat_sub_alloc6(bset->ctx, cone->eq, 0, cone->n_eq, 1, total);
        M = isl_mat_left_hermite(M, 0, &U, NULL);
        if (!M)
                goto error;