return NULL;
}
+__isl_give isl_qpolynomial *isl_qpolynomial_gist_params(
+ __isl_take isl_qpolynomial *qp, __isl_take isl_set *context)
+{
+ isl_space *space = isl_qpolynomial_get_domain_space(qp);
+ isl_set *dom_context = isl_set_universe(space);
+ dom_context = isl_set_intersect_params(dom_context, context);
+ return isl_qpolynomial_gist(qp, dom_context);
+}
+
__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_qpolynomial(
__isl_take isl_qpolynomial *qp)
{
#define IS_ZERO is_zero
#undef FIELD
#define FIELD qp
+#undef DEFAULT_IS_ZERO
+#define DEFAULT_IS_ZERO 1
#include <isl_pw_templ.c>
return isl_qpolynomial_is_one(pwqp->p[0].qp);
}
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
+ __isl_take isl_pw_qpolynomial *pwqp1,
+ __isl_take isl_pw_qpolynomial *pwqp2)
+{
+ return isl_pw_qpolynomial_union_add_(pwqp1, pwqp2);
+}
+
__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
__isl_take isl_pw_qpolynomial *pwqp1,
__isl_take isl_pw_qpolynomial *pwqp2)
isl_term *dup;
unsigned total;
- if (term)
+ if (!term)
return NULL;
total = isl_space_dim(term->dim, isl_dim_all) + term->div->n_row;
{
isl_local_space *ls;
isl_aff *aff;
- unsigned total;
if (!term)
return NULL;
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);
isl_seq_cpy(aff->v->el, term->div->row[pos], aff->v->size);
+ aff = isl_aff_normalize(aff);
+
return aff;
}
int n_sub;
isl_ctx *ctx;
struct isl_upoly **subs;
- isl_mat *mat;
+ isl_mat *mat, *diag;
qp = isl_qpolynomial_cow(qp);
if (!qp || !morph)
isl_upoly_free(subs[i]);
free(subs);
- mat = isl_mat_diagonal(isl_mat_identity(ctx, 1), isl_mat_copy(morph->inv));
- mat = isl_mat_diagonal(mat, isl_mat_identity(ctx, qp->div->n_row));
+ diag = isl_mat_diag(ctx, 1, morph->inv->row[0][0]);
+ mat = isl_mat_diagonal(diag, isl_mat_copy(morph->inv));
+ diag = isl_mat_diag(ctx, qp->div->n_row, morph->inv->row[0][0]);
+ mat = isl_mat_diagonal(mat, diag);
qp->div = isl_mat_product(qp->div, mat);
isl_space_free(qp->dim);
qp->dim = isl_space_copy(morph->ran->dim);
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