add isl_set_preimage_multi_aff
[platform/upstream/isl.git] / isl_polynomial.c
index 132986e..f026763 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2010      INRIA Saclay
  *
- * 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, INRIA Saclay - Ile-de-France,
  * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
@@ -3482,7 +3482,7 @@ __isl_give isl_term *isl_term_dup(__isl_keep isl_term *term)
        isl_term *dup;
        unsigned total;
 
-       if (term)
+       if (!term)
                return NULL;
 
        total = isl_space_dim(term->dim, isl_dim_all) + term->div->n_row;
@@ -3581,7 +3581,6 @@ __isl_give isl_aff *isl_term_get_div(__isl_keep isl_term *term, unsigned pos)
 {
        isl_local_space *ls;
        isl_aff *aff;
-       unsigned total;
 
        if (!term)
                return NULL;
@@ -3589,13 +3588,6 @@ __isl_give isl_aff *isl_term_get_div(__isl_keep isl_term *term, unsigned pos)
        isl_assert(term->dim->ctx, pos < isl_term_dim(term, isl_dim_div),
                        return NULL);
 
-       total = term->div->n_col - term->div->n_row - 2;
-       /* No nested divs for now */
-       isl_assert(term->dim->ctx,
-               isl_seq_first_non_zero(term->div->row[pos] + 2 + total,
-                                       term->div->n_row) == -1,
-               return NULL);
-
        ls = isl_local_space_alloc_div(isl_space_copy(term->dim),
                                        isl_mat_copy(term->div));
        aff = isl_aff_alloc(ls);
@@ -3604,6 +3596,8 @@ __isl_give isl_aff *isl_term_get_div(__isl_keep isl_term *term, unsigned pos)
 
        isl_seq_cpy(aff->v->el, term->div->row[pos], aff->v->size);
 
+       aff = isl_aff_normalize(aff);
+
        return aff;
 }
 
@@ -3968,44 +3962,11 @@ __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub(
                                        isl_union_pw_qpolynomial_neg(upwqp2));
 }
 
-static int mul_entry(void **entry, void *user)
-{
-       struct isl_union_pw_qpolynomial_match_bin_data *data = user;
-       uint32_t hash;
-       struct isl_hash_table_entry *entry2;
-       isl_pw_qpolynomial *pwpq = *entry;
-       int empty;
-
-       hash = isl_space_get_hash(pwpq->dim);
-       entry2 = isl_hash_table_find(data->u2->dim->ctx, &data->u2->table,
-                                    hash, &has_dim, pwpq->dim, 0);
-       if (!entry2)
-               return 0;
-
-       pwpq = isl_pw_qpolynomial_copy(pwpq);
-       pwpq = isl_pw_qpolynomial_mul(pwpq,
-                                     isl_pw_qpolynomial_copy(entry2->data));
-
-       empty = isl_pw_qpolynomial_is_zero(pwpq);
-       if (empty < 0) {
-               isl_pw_qpolynomial_free(pwpq);
-               return -1;
-       }
-       if (empty) {
-               isl_pw_qpolynomial_free(pwpq);
-               return 0;
-       }
-
-       data->res = isl_union_pw_qpolynomial_add_pw_qpolynomial(data->res, pwpq);
-
-       return 0;
-}
-
 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul(
        __isl_take isl_union_pw_qpolynomial *upwqp1,
        __isl_take isl_union_pw_qpolynomial *upwqp2)
 {
-       return match_bin_op(upwqp1, upwqp2, &mul_entry);
+       return match_bin_op(upwqp1, upwqp2, &isl_pw_qpolynomial_mul);
 }
 
 /* Reorder the columns of the given div definitions according to the