• Home
  • Raw
  • Download

Lines Matching refs:qp

411 	__isl_take isl_qpolynomial *qp, __isl_take isl_space *space)  in isl_qpolynomial_reset_domain_space()  argument
413 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_reset_domain_space()
414 if (!qp || !space) in isl_qpolynomial_reset_domain_space()
417 isl_space_free(qp->dim); in isl_qpolynomial_reset_domain_space()
418 qp->dim = space; in isl_qpolynomial_reset_domain_space()
420 return qp; in isl_qpolynomial_reset_domain_space()
422 isl_qpolynomial_free(qp); in isl_qpolynomial_reset_domain_space()
432 __isl_take isl_qpolynomial *qp, __isl_take isl_space *space, in isl_qpolynomial_reset_space_and_domain() argument
436 return isl_qpolynomial_reset_domain_space(qp, domain); in isl_qpolynomial_reset_space_and_domain()
439 isl_ctx *isl_qpolynomial_get_ctx(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_get_ctx() argument
441 return qp ? qp->dim->ctx : NULL; in isl_qpolynomial_get_ctx()
447 __isl_keep isl_qpolynomial *qp) in isl_qpolynomial_peek_domain_space() argument
449 return qp ? qp->dim : NULL; in isl_qpolynomial_peek_domain_space()
455 __isl_keep isl_qpolynomial *qp) in isl_qpolynomial_get_domain_space() argument
457 return isl_space_copy(isl_qpolynomial_peek_domain_space(qp)); in isl_qpolynomial_get_domain_space()
475 __isl_keep isl_qpolynomial *qp) in isl_qpolynomial_get_domain_local_space() argument
479 if (!qp) in isl_qpolynomial_get_domain_local_space()
482 space = isl_qpolynomial_get_domain_space(qp); in isl_qpolynomial_get_domain_local_space()
483 return isl_local_space_alloc_div(space, isl_mat_copy(qp->div)); in isl_qpolynomial_get_domain_local_space()
486 __isl_give isl_space *isl_qpolynomial_get_space(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_get_space() argument
489 if (!qp) in isl_qpolynomial_get_space()
491 space = isl_space_copy(qp->dim); in isl_qpolynomial_get_space()
499 isl_size isl_qpolynomial_domain_dim(__isl_keep isl_qpolynomial *qp, in isl_qpolynomial_domain_dim() argument
505 space = isl_qpolynomial_peek_domain_space(qp); in isl_qpolynomial_domain_dim()
510 return qp->div->n_row; in isl_qpolynomial_domain_dim()
517 n_div = isl_qpolynomial_domain_dim(qp, isl_dim_div); in isl_qpolynomial_domain_dim()
538 isl_size isl_qpolynomial_dim(__isl_keep isl_qpolynomial *qp, in isl_qpolynomial_dim() argument
541 if (!qp) in isl_qpolynomial_dim()
546 return isl_qpolynomial_domain_dim(qp, type); in isl_qpolynomial_dim()
553 __isl_keep isl_qpolynomial *qp, enum isl_dim_type type) in isl_qpolynomial_domain_var_offset() argument
557 space = isl_qpolynomial_peek_domain_space(qp); in isl_qpolynomial_domain_var_offset()
567 isl_die(isl_qpolynomial_get_ctx(qp), isl_error_invalid, in isl_qpolynomial_domain_var_offset()
575 unsigned isl_qpolynomial_domain_offset(__isl_keep isl_qpolynomial *qp, in isl_qpolynomial_domain_offset() argument
584 return 1 + isl_qpolynomial_domain_var_offset(qp, type); in isl_qpolynomial_domain_offset()
590 isl_bool isl_qpolynomial_is_zero(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_is_zero() argument
592 return qp ? isl_poly_is_zero(qp->poly) : isl_bool_error; in isl_qpolynomial_is_zero()
595 isl_bool isl_qpolynomial_is_one(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_is_one() argument
597 return qp ? isl_poly_is_one(qp->poly) : isl_bool_error; in isl_qpolynomial_is_one()
600 isl_bool isl_qpolynomial_is_nan(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_is_nan() argument
602 return qp ? isl_poly_is_nan(qp->poly) : isl_bool_error; in isl_qpolynomial_is_nan()
605 isl_bool isl_qpolynomial_is_infty(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_is_infty() argument
607 return qp ? isl_poly_is_infty(qp->poly) : isl_bool_error; in isl_qpolynomial_is_infty()
610 isl_bool isl_qpolynomial_is_neginfty(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_is_neginfty() argument
612 return qp ? isl_poly_is_neginfty(qp->poly) : isl_bool_error; in isl_qpolynomial_is_neginfty()
615 int isl_qpolynomial_sgn(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_sgn() argument
617 return qp ? isl_poly_sgn(qp->poly) : 0; in isl_qpolynomial_sgn()
1285 struct isl_qpolynomial *qp = NULL; in isl_qpolynomial_alloc() local
1296 qp = isl_calloc_type(space->ctx, struct isl_qpolynomial); in isl_qpolynomial_alloc()
1297 if (!qp) in isl_qpolynomial_alloc()
1300 qp->ref = 1; in isl_qpolynomial_alloc()
1301 qp->div = isl_mat_alloc(space->ctx, n_div, 1 + 1 + total + n_div); in isl_qpolynomial_alloc()
1302 if (!qp->div) in isl_qpolynomial_alloc()
1305 qp->dim = space; in isl_qpolynomial_alloc()
1306 qp->poly = poly; in isl_qpolynomial_alloc()
1308 return qp; in isl_qpolynomial_alloc()
1312 isl_qpolynomial_free(qp); in isl_qpolynomial_alloc()
1316 __isl_give isl_qpolynomial *isl_qpolynomial_copy(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_copy() argument
1318 if (!qp) in isl_qpolynomial_copy()
1321 qp->ref++; in isl_qpolynomial_copy()
1322 return qp; in isl_qpolynomial_copy()
1325 __isl_give isl_qpolynomial *isl_qpolynomial_dup(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_dup() argument
1329 if (!qp) in isl_qpolynomial_dup()
1332 dup = isl_qpolynomial_alloc(isl_space_copy(qp->dim), qp->div->n_row, in isl_qpolynomial_dup()
1333 isl_poly_copy(qp->poly)); in isl_qpolynomial_dup()
1337 dup->div = isl_mat_copy(qp->div); in isl_qpolynomial_dup()
1347 __isl_give isl_qpolynomial *isl_qpolynomial_cow(__isl_take isl_qpolynomial *qp) in isl_qpolynomial_cow() argument
1349 if (!qp) in isl_qpolynomial_cow()
1352 if (qp->ref == 1) in isl_qpolynomial_cow()
1353 return qp; in isl_qpolynomial_cow()
1354 qp->ref--; in isl_qpolynomial_cow()
1355 return isl_qpolynomial_dup(qp); in isl_qpolynomial_cow()
1359 __isl_take isl_qpolynomial *qp) in isl_qpolynomial_free() argument
1361 if (!qp) in isl_qpolynomial_free()
1364 if (--qp->ref > 0) in isl_qpolynomial_free()
1367 isl_space_free(qp->dim); in isl_qpolynomial_free()
1368 isl_mat_free(qp->div); in isl_qpolynomial_free()
1369 isl_poly_free(qp->poly); in isl_qpolynomial_free()
1371 free(qp); in isl_qpolynomial_free()
1493 static __isl_give isl_qpolynomial *sort_divs(__isl_take isl_qpolynomial *qp) in sort_divs() argument
1503 if (!qp) in sort_divs()
1505 if (qp->div->n_row <= 1) in sort_divs()
1506 return qp; in sort_divs()
1508 div_pos = isl_qpolynomial_domain_var_offset(qp, isl_dim_div); in sort_divs()
1510 return isl_qpolynomial_free(qp); in sort_divs()
1512 array = isl_alloc_array(qp->div->ctx, struct isl_div_sort_info, in sort_divs()
1513 qp->div->n_row); in sort_divs()
1514 pos = isl_alloc_array(qp->div->ctx, int, qp->div->n_row); in sort_divs()
1515 at = isl_alloc_array(qp->div->ctx, int, qp->div->n_row); in sort_divs()
1516 len = qp->div->n_col - 2; in sort_divs()
1517 reordering = isl_alloc_array(qp->div->ctx, int, len); in sort_divs()
1521 for (i = 0; i < qp->div->n_row; ++i) { in sort_divs()
1522 array[i].div = qp->div; in sort_divs()
1528 qsort(array, qp->div->n_row, sizeof(struct isl_div_sort_info), in sort_divs()
1534 for (i = 0; i < qp->div->n_row; ++i) { in sort_divs()
1537 qp->div = isl_mat_swap_rows(qp->div, i, pos[array[i].row]); in sort_divs()
1547 isl_seq_eq(qp->div->row[i - skip - 1], in sort_divs()
1548 qp->div->row[i - skip], qp->div->n_col)) { in sort_divs()
1549 qp->div = isl_mat_drop_rows(qp->div, i - skip, 1); in sort_divs()
1550 isl_mat_col_add(qp->div, 2 + div_pos + i - skip - 1, in sort_divs()
1552 qp->div = isl_mat_drop_cols(qp->div, in sort_divs()
1559 qp->poly = reorder(qp->poly, reordering); in sort_divs()
1561 if (!qp->poly || !qp->div) in sort_divs()
1569 return qp; in sort_divs()
1575 isl_qpolynomial_free(qp); in sort_divs()
1724 __isl_take isl_qpolynomial *qp, isl_int v) in isl_qpolynomial_add_isl_int() argument
1727 return qp; in isl_qpolynomial_add_isl_int()
1729 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_add_isl_int()
1730 if (!qp) in isl_qpolynomial_add_isl_int()
1733 qp->poly = isl_poly_add_isl_int(qp->poly, v); in isl_qpolynomial_add_isl_int()
1734 if (!qp->poly) in isl_qpolynomial_add_isl_int()
1737 return qp; in isl_qpolynomial_add_isl_int()
1739 isl_qpolynomial_free(qp); in isl_qpolynomial_add_isl_int()
1744 __isl_give isl_qpolynomial *isl_qpolynomial_neg(__isl_take isl_qpolynomial *qp) in isl_qpolynomial_neg() argument
1746 if (!qp) in isl_qpolynomial_neg()
1749 return isl_qpolynomial_mul_isl_int(qp, qp->dim->ctx->negone); in isl_qpolynomial_neg()
1753 __isl_take isl_qpolynomial *qp, isl_int v) in isl_qpolynomial_mul_isl_int() argument
1756 return qp; in isl_qpolynomial_mul_isl_int()
1758 if (qp && isl_int_is_zero(v)) { in isl_qpolynomial_mul_isl_int()
1760 zero = isl_qpolynomial_zero_on_domain(isl_space_copy(qp->dim)); in isl_qpolynomial_mul_isl_int()
1761 isl_qpolynomial_free(qp); in isl_qpolynomial_mul_isl_int()
1765 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_mul_isl_int()
1766 if (!qp) in isl_qpolynomial_mul_isl_int()
1769 qp->poly = isl_poly_mul_isl_int(qp->poly, v); in isl_qpolynomial_mul_isl_int()
1770 if (!qp->poly) in isl_qpolynomial_mul_isl_int()
1773 return qp; in isl_qpolynomial_mul_isl_int()
1775 isl_qpolynomial_free(qp); in isl_qpolynomial_mul_isl_int()
1780 __isl_take isl_qpolynomial *qp, isl_int v) in isl_qpolynomial_scale() argument
1782 return isl_qpolynomial_mul_isl_int(qp, v); in isl_qpolynomial_scale()
1788 __isl_take isl_qpolynomial *qp, __isl_take isl_val *v) in isl_qpolynomial_scale_val() argument
1790 if (!qp || !v) in isl_qpolynomial_scale_val()
1794 isl_die(isl_qpolynomial_get_ctx(qp), isl_error_invalid, in isl_qpolynomial_scale_val()
1799 return qp; in isl_qpolynomial_scale_val()
1805 space = isl_qpolynomial_get_domain_space(qp); in isl_qpolynomial_scale_val()
1806 isl_qpolynomial_free(qp); in isl_qpolynomial_scale_val()
1811 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_scale_val()
1812 if (!qp) in isl_qpolynomial_scale_val()
1815 qp->poly = isl_poly_scale_val(qp->poly, v); in isl_qpolynomial_scale_val()
1816 if (!qp->poly) in isl_qpolynomial_scale_val()
1817 qp = isl_qpolynomial_free(qp); in isl_qpolynomial_scale_val()
1820 return qp; in isl_qpolynomial_scale_val()
1823 isl_qpolynomial_free(qp); in isl_qpolynomial_scale_val()
1830 __isl_take isl_qpolynomial *qp, __isl_take isl_val *v) in isl_qpolynomial_scale_down_val() argument
1832 if (!qp || !v) in isl_qpolynomial_scale_down_val()
1836 isl_die(isl_qpolynomial_get_ctx(qp), isl_error_invalid, in isl_qpolynomial_scale_down_val()
1842 return isl_qpolynomial_scale_val(qp, isl_val_inv(v)); in isl_qpolynomial_scale_down_val()
1845 isl_qpolynomial_free(qp); in isl_qpolynomial_scale_down_val()
1881 __isl_give isl_qpolynomial *isl_qpolynomial_pow(__isl_take isl_qpolynomial *qp, in isl_qpolynomial_pow() argument
1884 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_pow()
1886 if (!qp) in isl_qpolynomial_pow()
1889 qp->poly = isl_poly_pow(qp->poly, power); in isl_qpolynomial_pow()
1890 if (!qp->poly) in isl_qpolynomial_pow()
1893 return qp; in isl_qpolynomial_pow()
1895 isl_qpolynomial_free(qp); in isl_qpolynomial_pow()
1912 pwqp->p[i].qp = isl_qpolynomial_pow(pwqp->p[i].qp, power); in isl_pw_qpolynomial_pow()
1913 if (!pwqp->p[i].qp) in isl_pw_qpolynomial_pow()
1964 struct isl_qpolynomial *qp; in isl_qpolynomial_cst_on_domain() local
1967 qp = isl_qpolynomial_zero_on_domain(domain); in isl_qpolynomial_cst_on_domain()
1968 if (!qp) in isl_qpolynomial_cst_on_domain()
1971 cst = isl_poly_as_cst(qp->poly); in isl_qpolynomial_cst_on_domain()
1974 return qp; in isl_qpolynomial_cst_on_domain()
1977 isl_bool isl_qpolynomial_is_cst(__isl_keep isl_qpolynomial *qp, in isl_qpolynomial_is_cst() argument
1983 if (!qp) in isl_qpolynomial_is_cst()
1986 is_cst = isl_poly_is_cst(qp->poly); in isl_qpolynomial_is_cst()
1990 cst = isl_poly_as_cst(qp->poly); in isl_qpolynomial_is_cst()
2032 __isl_keep isl_qpolynomial *qp) in isl_qpolynomial_get_constant_val() argument
2034 if (!qp) in isl_qpolynomial_get_constant_val()
2037 return isl_poly_get_constant_val(qp->poly); in isl_qpolynomial_get_constant_val()
2067 isl_bool isl_qpolynomial_is_affine(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_is_affine() argument
2069 if (!qp) in isl_qpolynomial_is_affine()
2072 if (qp->div->n_row > 0) in isl_qpolynomial_is_affine()
2075 return isl_poly_is_affine(qp->poly); in isl_qpolynomial_is_affine()
2130 __isl_keep isl_qpolynomial *qp) in isl_qpolynomial_extract_affine() argument
2135 d = isl_qpolynomial_domain_dim(qp, isl_dim_all); in isl_qpolynomial_extract_affine()
2139 aff = isl_vec_alloc(qp->div->ctx, 2 + d); in isl_qpolynomial_extract_affine()
2146 if (isl_poly_update_affine(qp->poly, aff) < 0) in isl_qpolynomial_extract_affine()
2237 __isl_give isl_val *isl_qpolynomial_get_den(__isl_keep isl_qpolynomial *qp) in isl_qpolynomial_get_den() argument
2241 if (!qp) in isl_qpolynomial_get_den()
2243 d = isl_val_one(isl_qpolynomial_get_ctx(qp)); in isl_qpolynomial_get_den()
2246 if (poly_update_den(qp->poly, &d->n) < 0) in isl_qpolynomial_get_den()
2353 static void normalize_div(__isl_keep isl_qpolynomial *qp, int div) in normalize_div() argument
2355 isl_ctx *ctx = qp->div->ctx; in normalize_div()
2356 unsigned total = qp->div->n_col - 2; in normalize_div()
2358 isl_seq_gcd(qp->div->row[div] + 2, total, &ctx->normalize_gcd); in normalize_div()
2360 ctx->normalize_gcd, qp->div->row[div][0]); in normalize_div()
2364 isl_seq_scale_down(qp->div->row[div] + 2, qp->div->row[div] + 2, in normalize_div()
2366 isl_int_divexact(qp->div->row[div][0], qp->div->row[div][0], in normalize_div()
2368 isl_int_fdiv_q(qp->div->row[div][1], qp->div->row[div][1], in normalize_div()
2377 __isl_take isl_qpolynomial *qp, int div, __isl_take isl_poly *s) in substitute_div() argument
2384 if (!qp || !s) in substitute_div()
2387 qp = isl_qpolynomial_cow(qp); in substitute_div()
2388 if (!qp) in substitute_div()
2391 div_pos = isl_qpolynomial_domain_var_offset(qp, isl_dim_div); in substitute_div()
2394 qp->poly = isl_poly_subs(qp->poly, div_pos + div, 1, &s); in substitute_div()
2395 if (!qp->poly) in substitute_div()
2398 ctx = isl_qpolynomial_get_ctx(qp); in substitute_div()
2399 reordering = isl_alloc_array(ctx, int, div_pos + qp->div->n_row); in substitute_div()
2404 for (i = div_pos + div + 1; i < div_pos + qp->div->n_row; ++i) in substitute_div()
2406 qp->div = isl_mat_drop_rows(qp->div, div, 1); in substitute_div()
2407 qp->div = isl_mat_drop_cols(qp->div, 2 + div_pos + div, 1); in substitute_div()
2408 qp->poly = reorder(qp->poly, reordering); in substitute_div()
2411 if (!qp->poly || !qp->div) in substitute_div()
2415 return qp; in substitute_div()
2417 isl_qpolynomial_free(qp); in substitute_div()
2426 __isl_take isl_qpolynomial *qp) in substitute_non_divs() argument
2432 div_pos = isl_qpolynomial_domain_var_offset(qp, isl_dim_div); in substitute_non_divs()
2434 return isl_qpolynomial_free(qp); in substitute_non_divs()
2436 for (i = 0; qp && i < qp->div->n_row; ++i) { in substitute_non_divs()
2437 if (!isl_int_is_one(qp->div->row[i][0])) in substitute_non_divs()
2439 for (j = i + 1; j < qp->div->n_row; ++j) { in substitute_non_divs()
2440 if (isl_int_is_zero(qp->div->row[j][2 + div_pos + i])) in substitute_non_divs()
2442 isl_seq_combine(qp->div->row[j] + 1, in substitute_non_divs()
2443 qp->div->ctx->one, qp->div->row[j] + 1, in substitute_non_divs()
2444 qp->div->row[j][2 + div_pos + i], in substitute_non_divs()
2445 qp->div->row[i] + 1, 1 + div_pos + i); in substitute_non_divs()
2446 isl_int_set_si(qp->div->row[j][2 + div_pos + i], 0); in substitute_non_divs()
2447 normalize_div(qp, j); in substitute_non_divs()
2449 s = isl_poly_from_affine(qp->dim->ctx, qp->div->row[i] + 1, in substitute_non_divs()
2450 qp->div->row[i][0], qp->div->n_col - 1); in substitute_non_divs()
2451 qp = substitute_div(qp, i, s); in substitute_non_divs()
2455 return qp; in substitute_non_divs()
2467 static void reduce_div(__isl_keep isl_qpolynomial *qp, int div, in reduce_div() argument
2472 unsigned total = qp->div->n_col - qp->div->n_row - 2; in reduce_div()
2476 if (isl_int_is_nonneg(qp->div->row[div][1 + i]) && in reduce_div()
2477 isl_int_lt(qp->div->row[div][1 + i], qp->div->row[div][0])) in reduce_div()
2479 isl_int_fdiv_q(v, qp->div->row[div][1 + i], qp->div->row[div][0]); in reduce_div()
2480 isl_int_fdiv_r(qp->div->row[div][1 + i], in reduce_div()
2481 qp->div->row[div][1 + i], qp->div->row[div][0]); in reduce_div()
2483 for (j = div + 1; j < qp->div->n_row; ++j) { in reduce_div()
2484 if (isl_int_is_zero(qp->div->row[j][2 + total + div])) in reduce_div()
2486 isl_int_addmul(qp->div->row[j][1 + i], in reduce_div()
2487 v, qp->div->row[j][2 + total + div]); in reduce_div()
2525 static void invert_div(__isl_keep isl_qpolynomial *qp, int div, in invert_div() argument
2528 unsigned total = qp->div->n_col - qp->div->n_row - 2; in invert_div()
2530 isl_seq_neg(qp->div->row[div] + 1, in invert_div()
2531 qp->div->row[div] + 1, qp->div->n_col - 1); in invert_div()
2532 isl_int_sub_ui(qp->div->row[div][1], qp->div->row[div][1], 1); in invert_div()
2533 isl_int_add(qp->div->row[div][1], in invert_div()
2534 qp->div->row[div][1], qp->div->row[div][0]); in invert_div()
2536 isl_mat_col_mul(qp->div, 2 + total + div, in invert_div()
2537 qp->div->ctx->negone, 2 + total + div); in invert_div()
2554 static __isl_give isl_qpolynomial *reduce_divs(__isl_take isl_qpolynomial *qp) in reduce_divs() argument
2563 total = isl_qpolynomial_domain_dim(qp, isl_dim_all); in reduce_divs()
2564 n_div = isl_qpolynomial_domain_dim(qp, isl_dim_div); in reduce_divs()
2565 o_div = isl_qpolynomial_domain_offset(qp, isl_dim_div); in reduce_divs()
2567 return isl_qpolynomial_free(qp); in reduce_divs()
2568 ctx = isl_qpolynomial_get_ctx(qp); in reduce_divs()
2574 for (i = 0; i < qp->div->n_row; ++i) { in reduce_divs()
2575 normalize_div(qp, i); in reduce_divs()
2576 reduce_div(qp, i, &mat); in reduce_divs()
2577 if (needs_invert(qp->div, i)) { in reduce_divs()
2578 invert_div(qp, i, &mat); in reduce_divs()
2579 reduce_div(qp, i, &mat); in reduce_divs()
2591 qp->poly = isl_poly_subs(qp->poly, o_div - 1, n_div, s); in reduce_divs()
2595 if (!qp->poly) in reduce_divs()
2600 qp = substitute_non_divs(qp); in reduce_divs()
2601 qp = sort_divs(qp); in reduce_divs()
2602 new_n_div = isl_qpolynomial_domain_dim(qp, isl_dim_div); in reduce_divs()
2604 return isl_qpolynomial_free(qp); in reduce_divs()
2606 return reduce_divs(qp); in reduce_divs()
2608 return qp; in reduce_divs()
2610 isl_qpolynomial_free(qp); in reduce_divs()
2618 struct isl_qpolynomial *qp; in isl_qpolynomial_rat_cst_on_domain() local
2621 qp = isl_qpolynomial_zero_on_domain(domain); in isl_qpolynomial_rat_cst_on_domain()
2622 if (!qp) in isl_qpolynomial_rat_cst_on_domain()
2625 cst = isl_poly_as_cst(qp->poly); in isl_qpolynomial_rat_cst_on_domain()
2629 return qp; in isl_qpolynomial_rat_cst_on_domain()
2637 isl_qpolynomial *qp; in isl_qpolynomial_val_on_domain() local
2640 qp = isl_qpolynomial_zero_on_domain(domain); in isl_qpolynomial_val_on_domain()
2641 if (!qp || !val) in isl_qpolynomial_val_on_domain()
2644 cst = isl_poly_as_cst(qp->poly); in isl_qpolynomial_val_on_domain()
2649 return qp; in isl_qpolynomial_val_on_domain()
2652 isl_qpolynomial_free(qp); in isl_qpolynomial_val_on_domain()
2679 static isl_stat set_active(__isl_keep isl_qpolynomial *qp, int *active) in set_active() argument
2685 space = isl_qpolynomial_peek_domain_space(qp); in set_active()
2691 for (j = 0; j < qp->div->n_row; ++j) { in set_active()
2692 if (isl_int_is_zero(qp->div->row[j][2 + i])) in set_active()
2698 return poly_set_active(qp->poly, active, d); in set_active()
2706 isl_bool isl_qpolynomial_involves_dims(__isl_keep isl_qpolynomial *qp, in isl_qpolynomial_involves_dims() argument
2716 if (!qp) in isl_qpolynomial_involves_dims()
2721 if (isl_qpolynomial_check_range(qp, type, first, n) < 0) in isl_qpolynomial_involves_dims()
2723 isl_assert(qp->dim->ctx, type == isl_dim_param || in isl_qpolynomial_involves_dims()
2726 space = isl_qpolynomial_peek_domain_space(qp); in isl_qpolynomial_involves_dims()
2730 active = isl_calloc_array(qp->dim->ctx, int, d); in isl_qpolynomial_involves_dims()
2731 if (set_active(qp, active) < 0) in isl_qpolynomial_involves_dims()
2734 offset = isl_qpolynomial_domain_var_offset(qp, domain_type(type)); in isl_qpolynomial_involves_dims()
2756 __isl_take isl_qpolynomial *qp) in remove_redundant_divs() argument
2768 if (!qp) in remove_redundant_divs()
2770 if (qp->div->n_row == 0) in remove_redundant_divs()
2771 return qp; in remove_redundant_divs()
2773 div_pos = isl_qpolynomial_domain_var_offset(qp, isl_dim_div); in remove_redundant_divs()
2775 return isl_qpolynomial_free(qp); in remove_redundant_divs()
2776 len = qp->div->n_col - 2; in remove_redundant_divs()
2777 ctx = isl_qpolynomial_get_ctx(qp); in remove_redundant_divs()
2782 if (poly_set_active(qp->poly, active, len) < 0) in remove_redundant_divs()
2785 for (i = qp->div->n_row - 1; i >= 0; --i) { in remove_redundant_divs()
2791 if (isl_int_is_zero(qp->div->row[i][2 + div_pos + j])) in remove_redundant_divs()
2800 return qp; in remove_redundant_divs()
2803 reordering = isl_alloc_array(qp->div->ctx, int, len); in remove_redundant_divs()
2811 n_div = qp->div->n_row; in remove_redundant_divs()
2814 qp->div = isl_mat_drop_rows(qp->div, i - skip, 1); in remove_redundant_divs()
2815 qp->div = isl_mat_drop_cols(qp->div, in remove_redundant_divs()
2822 qp->poly = reorder(qp->poly, reordering); in remove_redundant_divs()
2824 if (!qp->poly || !qp->div) in remove_redundant_divs()
2830 return qp; in remove_redundant_divs()
2834 isl_qpolynomial_free(qp); in remove_redundant_divs()
2873 __isl_take isl_qpolynomial *qp, in isl_qpolynomial_set_dim_name() argument
2876 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_set_dim_name()
2877 if (!qp) in isl_qpolynomial_set_dim_name()
2880 isl_die(isl_qpolynomial_get_ctx(qp), isl_error_invalid, in isl_qpolynomial_set_dim_name()
2882 return isl_qpolynomial_free(qp)); in isl_qpolynomial_set_dim_name()
2884 qp->dim = isl_space_set_dim_name(qp->dim, type, pos, s); in isl_qpolynomial_set_dim_name()
2885 if (!qp->dim) in isl_qpolynomial_set_dim_name()
2887 return qp; in isl_qpolynomial_set_dim_name()
2889 isl_qpolynomial_free(qp); in isl_qpolynomial_set_dim_name()
2894 __isl_take isl_qpolynomial *qp, in isl_qpolynomial_drop_dims() argument
2899 if (!qp) in isl_qpolynomial_drop_dims()
2902 isl_die(qp->dim->ctx, isl_error_invalid, in isl_qpolynomial_drop_dims()
2905 if (isl_qpolynomial_check_range(qp, type, first, n) < 0) in isl_qpolynomial_drop_dims()
2906 return isl_qpolynomial_free(qp); in isl_qpolynomial_drop_dims()
2908 if (n == 0 && !isl_space_is_named_or_nested(qp->dim, type)) in isl_qpolynomial_drop_dims()
2909 return qp; in isl_qpolynomial_drop_dims()
2911 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_drop_dims()
2912 if (!qp) in isl_qpolynomial_drop_dims()
2915 isl_assert(qp->dim->ctx, type == isl_dim_param || in isl_qpolynomial_drop_dims()
2918 qp->dim = isl_space_drop_dims(qp->dim, type, first, n); in isl_qpolynomial_drop_dims()
2919 if (!qp->dim) in isl_qpolynomial_drop_dims()
2922 offset = isl_qpolynomial_domain_var_offset(qp, type); in isl_qpolynomial_drop_dims()
2927 qp->div = isl_mat_drop_cols(qp->div, 2 + first, n); in isl_qpolynomial_drop_dims()
2928 if (!qp->div) in isl_qpolynomial_drop_dims()
2931 qp->poly = isl_poly_drop(qp->poly, first, n); in isl_qpolynomial_drop_dims()
2932 if (!qp->poly) in isl_qpolynomial_drop_dims()
2935 return qp; in isl_qpolynomial_drop_dims()
2937 isl_qpolynomial_free(qp); in isl_qpolynomial_drop_dims()
2945 __isl_take isl_qpolynomial *qp) in isl_qpolynomial_project_domain_on_params() argument
2951 n = isl_qpolynomial_dim(qp, isl_dim_in); in isl_qpolynomial_project_domain_on_params()
2953 return isl_qpolynomial_free(qp); in isl_qpolynomial_project_domain_on_params()
2954 involves = isl_qpolynomial_involves_dims(qp, isl_dim_in, 0, n); in isl_qpolynomial_project_domain_on_params()
2956 return isl_qpolynomial_free(qp); in isl_qpolynomial_project_domain_on_params()
2958 isl_die(isl_qpolynomial_get_ctx(qp), isl_error_invalid, in isl_qpolynomial_project_domain_on_params()
2960 return isl_qpolynomial_free(qp)); in isl_qpolynomial_project_domain_on_params()
2961 qp = isl_qpolynomial_drop_dims(qp, isl_dim_in, 0, n); in isl_qpolynomial_project_domain_on_params()
2962 space = isl_qpolynomial_get_domain_space(qp); in isl_qpolynomial_project_domain_on_params()
2964 qp = isl_qpolynomial_reset_domain_space(qp, space); in isl_qpolynomial_project_domain_on_params()
2965 return qp; in isl_qpolynomial_project_domain_on_params()
2969 __isl_take isl_qpolynomial *qp, __isl_take isl_basic_set *eq) in isl_qpolynomial_substitute_equalities_lifted() argument
2981 return qp; in isl_qpolynomial_substitute_equalities_lifted()
2984 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_substitute_equalities_lifted()
2985 if (!qp) in isl_qpolynomial_substitute_equalities_lifted()
2987 qp->div = isl_mat_cow(qp->div); in isl_qpolynomial_substitute_equalities_lifted()
2988 if (!qp->div) in isl_qpolynomial_substitute_equalities_lifted()
2999 for (k = 0; k < qp->div->n_row; ++k) { in isl_qpolynomial_substitute_equalities_lifted()
3000 if (isl_int_is_zero(qp->div->row[k][1 + j])) in isl_qpolynomial_substitute_equalities_lifted()
3002 isl_seq_elim(qp->div->row[k] + 1, eq->eq[i], j, total, in isl_qpolynomial_substitute_equalities_lifted()
3003 &qp->div->row[k][0]); in isl_qpolynomial_substitute_equalities_lifted()
3004 normalize_div(qp, k); in isl_qpolynomial_substitute_equalities_lifted()
3012 poly = isl_poly_from_affine(qp->dim->ctx, in isl_qpolynomial_substitute_equalities_lifted()
3014 qp->poly = isl_poly_subs(qp->poly, j - 1, 1, &poly); in isl_qpolynomial_substitute_equalities_lifted()
3019 if (!qp->poly) in isl_qpolynomial_substitute_equalities_lifted()
3024 qp = substitute_non_divs(qp); in isl_qpolynomial_substitute_equalities_lifted()
3025 qp = sort_divs(qp); in isl_qpolynomial_substitute_equalities_lifted()
3027 return qp; in isl_qpolynomial_substitute_equalities_lifted()
3030 isl_qpolynomial_free(qp); in isl_qpolynomial_substitute_equalities_lifted()
3037 __isl_take isl_qpolynomial *qp, __isl_take isl_basic_set *eq) in isl_qpolynomial_substitute_equalities() argument
3039 if (!qp || !eq) in isl_qpolynomial_substitute_equalities()
3041 if (qp->div->n_row > 0) in isl_qpolynomial_substitute_equalities()
3042 eq = isl_basic_set_add_dims(eq, isl_dim_set, qp->div->n_row); in isl_qpolynomial_substitute_equalities()
3043 return isl_qpolynomial_substitute_equalities_lifted(qp, eq); in isl_qpolynomial_substitute_equalities()
3046 isl_qpolynomial_free(qp); in isl_qpolynomial_substitute_equalities()
3056 __isl_take isl_qpolynomial *qp, __isl_take isl_set *context) in isl_qpolynomial_gist() argument
3061 ls = isl_qpolynomial_get_domain_local_space(qp); in isl_qpolynomial_gist()
3065 return isl_qpolynomial_substitute_equalities_lifted(qp, aff); in isl_qpolynomial_gist()
3069 __isl_take isl_qpolynomial *qp, __isl_take isl_set *context) in isl_qpolynomial_gist_params() argument
3071 isl_space *space = isl_qpolynomial_get_domain_space(qp); in isl_qpolynomial_gist_params()
3074 return isl_qpolynomial_gist(qp, dom_context); in isl_qpolynomial_gist_params()
3101 #define FIELD qp
3133 return isl_qpolynomial_is_one(pwqp->p[0].qp); in isl_pw_qpolynomial_is_one()
3191 isl_qpolynomial_copy(pwqp1->p[i].qp), in isl_pw_qpolynomial_mul()
3192 isl_qpolynomial_copy(pwqp2->p[j].qp)); in isl_pw_qpolynomial_mul()
3258 static __isl_give isl_val *eval_void(__isl_take isl_qpolynomial *qp, in eval_void() argument
3264 isl_qpolynomial_free(qp); in eval_void()
3269 __isl_give isl_val *isl_qpolynomial_eval(__isl_take isl_qpolynomial *qp, in isl_qpolynomial_eval() argument
3276 if (!qp || !pnt) in isl_qpolynomial_eval()
3278 isl_assert(pnt->dim->ctx, isl_space_is_equal(pnt->dim, qp->dim), goto error); in isl_qpolynomial_eval()
3283 return eval_void(qp, pnt); in isl_qpolynomial_eval()
3285 ext = isl_local_extend_point_vec(qp->div, isl_vec_copy(pnt->vec)); in isl_qpolynomial_eval()
3287 v = isl_poly_eval(isl_poly_copy(qp->poly), ext); in isl_qpolynomial_eval()
3289 isl_qpolynomial_free(qp); in isl_qpolynomial_eval()
3294 isl_qpolynomial_free(qp); in isl_qpolynomial_eval()
3312 __isl_take isl_qpolynomial *qp, enum isl_dim_type type, in isl_qpolynomial_insert_dims() argument
3319 if (!qp) in isl_qpolynomial_insert_dims()
3322 isl_die(qp->div->ctx, isl_error_invalid, in isl_qpolynomial_insert_dims()
3325 if (isl_qpolynomial_check_range(qp, type, first, 0) < 0) in isl_qpolynomial_insert_dims()
3326 return isl_qpolynomial_free(qp); in isl_qpolynomial_insert_dims()
3328 if (n == 0 && !isl_space_is_named_or_nested(qp->dim, type)) in isl_qpolynomial_insert_dims()
3329 return qp; in isl_qpolynomial_insert_dims()
3331 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_insert_dims()
3332 if (!qp) in isl_qpolynomial_insert_dims()
3335 g_pos = pos(qp->dim, type) + first; in isl_qpolynomial_insert_dims()
3337 qp->div = isl_mat_insert_zero_cols(qp->div, 2 + g_pos, n); in isl_qpolynomial_insert_dims()
3338 if (!qp->div) in isl_qpolynomial_insert_dims()
3341 total = qp->div->n_col - 2; in isl_qpolynomial_insert_dims()
3344 exp = isl_alloc_array(qp->div->ctx, int, total - g_pos); in isl_qpolynomial_insert_dims()
3349 qp->poly = expand(qp->poly, exp, g_pos); in isl_qpolynomial_insert_dims()
3351 if (!qp->poly) in isl_qpolynomial_insert_dims()
3355 qp->dim = isl_space_insert_dims(qp->dim, type, first, n); in isl_qpolynomial_insert_dims()
3356 if (!qp->dim) in isl_qpolynomial_insert_dims()
3359 return qp; in isl_qpolynomial_insert_dims()
3361 isl_qpolynomial_free(qp); in isl_qpolynomial_insert_dims()
3366 __isl_take isl_qpolynomial *qp, enum isl_dim_type type, unsigned n) in isl_qpolynomial_add_dims() argument
3370 pos = isl_qpolynomial_dim(qp, type); in isl_qpolynomial_add_dims()
3372 return isl_qpolynomial_free(qp); in isl_qpolynomial_add_dims()
3374 return isl_qpolynomial_insert_dims(qp, type, pos, n); in isl_qpolynomial_add_dims()
3411 __isl_take isl_qpolynomial *qp, in isl_qpolynomial_move_dims() argument
3419 if (!qp) in isl_qpolynomial_move_dims()
3423 isl_die(qp->dim->ctx, isl_error_invalid, in isl_qpolynomial_move_dims()
3426 if (isl_qpolynomial_check_range(qp, src_type, src_pos, n) < 0) in isl_qpolynomial_move_dims()
3427 return isl_qpolynomial_free(qp); in isl_qpolynomial_move_dims()
3434 !isl_space_is_named_or_nested(qp->dim, src_type) && in isl_qpolynomial_move_dims()
3435 !isl_space_is_named_or_nested(qp->dim, dst_type)) in isl_qpolynomial_move_dims()
3436 return qp; in isl_qpolynomial_move_dims()
3438 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_move_dims()
3439 if (!qp) in isl_qpolynomial_move_dims()
3442 g_dst_pos = pos(qp->dim, dst_type) + dst_pos; in isl_qpolynomial_move_dims()
3443 g_src_pos = pos(qp->dim, src_type) + src_pos; in isl_qpolynomial_move_dims()
3447 qp->div = isl_mat_move_cols(qp->div, 2 + g_dst_pos, 2 + g_src_pos, n); in isl_qpolynomial_move_dims()
3448 if (!qp->div) in isl_qpolynomial_move_dims()
3450 qp = sort_divs(qp); in isl_qpolynomial_move_dims()
3451 if (!qp) in isl_qpolynomial_move_dims()
3454 reordering = reordering_move(qp->dim->ctx, in isl_qpolynomial_move_dims()
3455 qp->div->n_col - 2, g_dst_pos, g_src_pos, n); in isl_qpolynomial_move_dims()
3459 qp->poly = reorder(qp->poly, reordering); in isl_qpolynomial_move_dims()
3461 if (!qp->poly) in isl_qpolynomial_move_dims()
3464 qp->dim = isl_space_move_dims(qp->dim, dst_type, dst_pos, src_type, src_pos, n); in isl_qpolynomial_move_dims()
3465 if (!qp->dim) in isl_qpolynomial_move_dims()
3468 return qp; in isl_qpolynomial_move_dims()
3470 isl_qpolynomial_free(qp); in isl_qpolynomial_move_dims()
3494 isl_qpolynomial *qp; in isl_qpolynomial_from_aff() local
3503 qp = isl_qpolynomial_alloc(isl_aff_get_domain_space(aff), in isl_qpolynomial_from_aff()
3505 if (!qp) in isl_qpolynomial_from_aff()
3508 isl_mat_free(qp->div); in isl_qpolynomial_from_aff()
3509 qp->div = isl_mat_copy(aff->ls->div); in isl_qpolynomial_from_aff()
3510 qp->div = isl_mat_cow(qp->div); in isl_qpolynomial_from_aff()
3511 if (!qp->div) in isl_qpolynomial_from_aff()
3515 qp = reduce_divs(qp); in isl_qpolynomial_from_aff()
3516 qp = remove_redundant_divs(qp); in isl_qpolynomial_from_aff()
3517 return qp; in isl_qpolynomial_from_aff()
3520 return isl_qpolynomial_free(qp); in isl_qpolynomial_from_aff()
3537 isl_qpolynomial *qp; in isl_pw_qpolynomial_from_pw_aff() local
3540 qp = isl_qpolynomial_from_aff(isl_aff_copy(pwaff->p[i].aff)); in isl_pw_qpolynomial_from_pw_aff()
3541 pwqp = isl_pw_qpolynomial_add_piece(pwqp, dom, qp); in isl_pw_qpolynomial_from_pw_aff()
3562 __isl_take isl_qpolynomial *qp, in isl_qpolynomial_substitute() argument
3570 return qp; in isl_qpolynomial_substitute()
3572 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_substitute()
3573 if (!qp) in isl_qpolynomial_substitute()
3577 isl_die(qp->dim->ctx, isl_error_invalid, in isl_qpolynomial_substitute()
3580 if (isl_qpolynomial_check_range(qp, type, first, n) < 0) in isl_qpolynomial_substitute()
3581 return isl_qpolynomial_free(qp); in isl_qpolynomial_substitute()
3589 if (isl_qpolynomial_check_equal_space(qp, subs[i]) < 0) in isl_qpolynomial_substitute()
3592 isl_assert(qp->dim->ctx, qp->div->n_row == 0, goto error); in isl_qpolynomial_substitute()
3594 isl_assert(qp->dim->ctx, subs[i]->div->n_row == 0, goto error); in isl_qpolynomial_substitute()
3596 first += pos(qp->dim, type); in isl_qpolynomial_substitute()
3598 polys = isl_alloc_array(qp->dim->ctx, struct isl_poly *, n); in isl_qpolynomial_substitute()
3604 qp->poly = isl_poly_subs(qp->poly, first, n, polys); in isl_qpolynomial_substitute()
3608 if (!qp->poly) in isl_qpolynomial_substitute()
3611 return qp; in isl_qpolynomial_substitute()
3613 isl_qpolynomial_free(qp); in isl_qpolynomial_substitute()
3622 isl_stat isl_qpolynomial_as_polynomial_on_domain(__isl_keep isl_qpolynomial *qp, in isl_qpolynomial_as_polynomial_on_domain() argument
3631 if (!qp || !bset) in isl_qpolynomial_as_polynomial_on_domain()
3633 if (qp->div->n_row == 0) in isl_qpolynomial_as_polynomial_on_domain()
3634 return fn(isl_basic_set_copy(bset), isl_qpolynomial_copy(qp), in isl_qpolynomial_as_polynomial_on_domain()
3637 space = isl_space_copy(qp->dim); in isl_qpolynomial_as_polynomial_on_domain()
3638 space = isl_space_add_dims(space, isl_dim_set, qp->div->n_row); in isl_qpolynomial_as_polynomial_on_domain()
3639 poly = isl_qpolynomial_alloc(space, 0, isl_poly_copy(qp->poly)); in isl_qpolynomial_as_polynomial_on_domain()
3641 ls = isl_qpolynomial_get_domain_local_space(qp); in isl_qpolynomial_as_polynomial_on_domain()
3758 __isl_keep isl_qpolynomial *qp, in isl_qpolynomial_coeff() argument
3765 if (!qp) in isl_qpolynomial_coeff()
3769 isl_die(qp->div->ctx, isl_error_invalid, in isl_qpolynomial_coeff()
3772 if (isl_qpolynomial_check_range(qp, type, t_pos, 1) < 0) in isl_qpolynomial_coeff()
3776 g_pos = pos(qp->dim, type) + t_pos; in isl_qpolynomial_coeff()
3777 poly = isl_poly_coeff(qp->poly, g_pos, deg); in isl_qpolynomial_coeff()
3779 c = isl_qpolynomial_alloc(isl_space_copy(qp->dim), in isl_qpolynomial_coeff()
3780 qp->div->n_row, poly); in isl_qpolynomial_coeff()
3784 c->div = isl_mat_copy(qp->div); in isl_qpolynomial_coeff()
4152 isl_stat isl_qpolynomial_foreach_term(__isl_keep isl_qpolynomial *qp, in isl_qpolynomial_foreach_term() argument
4157 if (!qp) in isl_qpolynomial_foreach_term()
4160 term = isl_term_alloc(isl_space_copy(qp->dim), isl_mat_copy(qp->div)); in isl_qpolynomial_foreach_term()
4164 term = isl_poly_foreach_term(qp->poly, fn, term, user); in isl_qpolynomial_foreach_term()
4174 isl_qpolynomial *qp; in isl_qpolynomial_from_term() local
4192 qp = isl_qpolynomial_alloc(isl_space_copy(term->dim), in isl_qpolynomial_from_term()
4194 if (!qp) in isl_qpolynomial_from_term()
4196 isl_mat_free(qp->div); in isl_qpolynomial_from_term()
4197 qp->div = isl_mat_copy(term->div); in isl_qpolynomial_from_term()
4198 if (!qp->div) in isl_qpolynomial_from_term()
4202 return qp; in isl_qpolynomial_from_term()
4204 isl_qpolynomial_free(qp); in isl_qpolynomial_from_term()
4209 __isl_give isl_qpolynomial *isl_qpolynomial_lift(__isl_take isl_qpolynomial *qp, in isl_qpolynomial_lift() argument
4216 if (!qp || !space) in isl_qpolynomial_lift()
4219 if (isl_space_is_equal(qp->dim, space)) { in isl_qpolynomial_lift()
4221 return qp; in isl_qpolynomial_lift()
4224 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_lift()
4225 if (!qp) in isl_qpolynomial_lift()
4229 d_qp = isl_qpolynomial_domain_dim(qp, isl_dim_set); in isl_qpolynomial_lift()
4231 total = isl_space_dim(qp->dim, isl_dim_all); in isl_qpolynomial_lift()
4234 if (qp->div->n_row) { in isl_qpolynomial_lift()
4237 exp = isl_alloc_array(qp->div->ctx, int, qp->div->n_row); in isl_qpolynomial_lift()
4240 for (i = 0; i < qp->div->n_row; ++i) in isl_qpolynomial_lift()
4242 qp->poly = expand(qp->poly, exp, total); in isl_qpolynomial_lift()
4244 if (!qp->poly) in isl_qpolynomial_lift()
4247 qp->div = isl_mat_insert_cols(qp->div, 2 + total, extra); in isl_qpolynomial_lift()
4248 if (!qp->div) in isl_qpolynomial_lift()
4250 for (i = 0; i < qp->div->n_row; ++i) in isl_qpolynomial_lift()
4251 isl_seq_clr(qp->div->row[i] + 2 + total, extra); in isl_qpolynomial_lift()
4253 isl_space_free(qp->dim); in isl_qpolynomial_lift()
4254 qp->dim = space; in isl_qpolynomial_lift()
4256 return qp; in isl_qpolynomial_lift()
4259 isl_qpolynomial_free(qp); in isl_qpolynomial_lift()
4267 __isl_keep isl_qpolynomial *qp) in fix_inactive() argument
4276 if (d < 0 || !qp) in fix_inactive()
4280 if (set_active(qp, active) < 0) in fix_inactive()
4319 isl_qpolynomial *qp; member
4330 val = isl_qpolynomial_eval(isl_qpolynomial_copy(data->qp), pnt); in opt_fn()
4344 __isl_take isl_qpolynomial *qp, __isl_take isl_set *set, int max) in isl_qpolynomial_opt_on_domain() argument
4349 if (!set || !qp) in isl_qpolynomial_opt_on_domain()
4352 is_cst = isl_poly_is_cst(qp->poly); in isl_qpolynomial_opt_on_domain()
4357 data.opt = isl_qpolynomial_get_constant_val(qp); in isl_qpolynomial_opt_on_domain()
4358 isl_qpolynomial_free(qp); in isl_qpolynomial_opt_on_domain()
4362 set = fix_inactive(set, qp); in isl_qpolynomial_opt_on_domain()
4364 data.qp = qp; in isl_qpolynomial_opt_on_domain()
4372 isl_qpolynomial_free(qp); in isl_qpolynomial_opt_on_domain()
4376 isl_qpolynomial_free(qp); in isl_qpolynomial_opt_on_domain()
4382 __isl_take isl_qpolynomial *qp, __isl_take isl_morph *morph) in isl_qpolynomial_morph_domain() argument
4390 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_morph_domain()
4391 if (!qp || !morph) in isl_qpolynomial_morph_domain()
4394 ctx = qp->dim->ctx; in isl_qpolynomial_morph_domain()
4395 isl_assert(ctx, isl_space_is_equal(qp->dim, morph->dom->dim), goto error); in isl_qpolynomial_morph_domain()
4399 n_sub += qp->div->n_row; in isl_qpolynomial_morph_domain()
4408 for (i = 0; i < qp->div->n_row; ++i) in isl_qpolynomial_morph_domain()
4412 qp->poly = isl_poly_subs(qp->poly, 0, n_sub, subs); in isl_qpolynomial_morph_domain()
4420 diag = isl_mat_diag(ctx, qp->div->n_row, morph->inv->row[0][0]); in isl_qpolynomial_morph_domain()
4422 qp->div = isl_mat_product(qp->div, mat); in isl_qpolynomial_morph_domain()
4423 isl_space_free(qp->dim); in isl_qpolynomial_morph_domain()
4424 qp->dim = isl_space_copy(morph->ran->dim); in isl_qpolynomial_morph_domain()
4426 if (!qp->poly || !qp->div || !qp->dim) in isl_qpolynomial_morph_domain()
4431 return qp; in isl_qpolynomial_morph_domain()
4433 isl_qpolynomial_free(qp); in isl_qpolynomial_morph_domain()
4449 __isl_take isl_qpolynomial *qp, __isl_take isl_reordering *r) in isl_qpolynomial_realign_domain() argument
4453 qp = isl_qpolynomial_cow(qp); in isl_qpolynomial_realign_domain()
4454 if (!qp) in isl_qpolynomial_realign_domain()
4457 r = isl_reordering_extend(r, qp->div->n_row); in isl_qpolynomial_realign_domain()
4461 qp->div = isl_local_reorder(qp->div, isl_reordering_copy(r)); in isl_qpolynomial_realign_domain()
4462 if (!qp->div) in isl_qpolynomial_realign_domain()
4465 qp->poly = reorder(qp->poly, r->pos); in isl_qpolynomial_realign_domain()
4466 if (!qp->poly) in isl_qpolynomial_realign_domain()
4470 qp = isl_qpolynomial_reset_domain_space(qp, space); in isl_qpolynomial_realign_domain()
4473 return qp; in isl_qpolynomial_realign_domain()
4475 isl_qpolynomial_free(qp); in isl_qpolynomial_realign_domain()
4481 __isl_take isl_qpolynomial *qp, __isl_take isl_space *model) in isl_qpolynomial_align_params() argument
4485 if (!qp || !model) in isl_qpolynomial_align_params()
4488 equal_params = isl_space_has_equal_params(qp->dim, model); in isl_qpolynomial_align_params()
4494 exp = isl_parameter_alignment_reordering(qp->dim, model); in isl_qpolynomial_align_params()
4496 isl_qpolynomial_get_domain_space(qp)); in isl_qpolynomial_align_params()
4497 qp = isl_qpolynomial_realign_domain(qp, exp); in isl_qpolynomial_align_params()
4501 return qp; in isl_qpolynomial_align_params()
4504 isl_qpolynomial_free(qp); in isl_qpolynomial_align_params()
4524 __isl_keep isl_qpolynomial *qp, int div, isl_int v) in set_div_slice() argument
4531 if (total < 0 || !qp) in set_div_slice()
4539 isl_seq_cpy(bset->ineq[k], qp->div->row[div] + 1, 1 + total); in set_div_slice()
4540 isl_int_submul(bset->ineq[k][0], v, qp->div->row[div][0]); in set_div_slice()
4545 isl_seq_neg(bset->ineq[k], qp->div->row[div] + 1, 1 + total); in set_div_slice()
4546 isl_int_addmul(bset->ineq[k][0], v, qp->div->row[div][0]); in set_div_slice()
4547 isl_int_add(bset->ineq[k][0], bset->ineq[k][0], qp->div->row[div][0]); in set_div_slice()
4559 __isl_take isl_qpolynomial *qp, void *user);
4566 __isl_take isl_qpolynomial *qp, int div, isl_int v, in set_div() argument
4574 slice = set_div_slice(isl_set_get_space(set), qp, div, v); in set_div()
4577 div_pos = isl_qpolynomial_domain_var_offset(qp, isl_dim_div); in set_div()
4581 for (i = div + 1; i < qp->div->n_row; ++i) { in set_div()
4582 if (isl_int_is_zero(qp->div->row[i][2 + div_pos + div])) in set_div()
4584 isl_int_addmul(qp->div->row[i][1], in set_div()
4585 qp->div->row[i][2 + div_pos + div], v); in set_div()
4586 isl_int_set_si(qp->div->row[i][2 + div_pos + div], 0); in set_div()
4589 cst = isl_poly_rat_cst(qp->dim->ctx, v, qp->dim->ctx->one); in set_div()
4590 qp = substitute_div(qp, div, cst); in set_div()
4592 return split_periods(set, qp, data); in set_div()
4595 isl_qpolynomial_free(qp); in set_div()
4604 __isl_take isl_qpolynomial *qp, int div, isl_int min, isl_int max, in split_div() argument
4609 isl_qpolynomial *qp_i = isl_qpolynomial_copy(qp); in split_div()
4615 isl_qpolynomial_free(qp); in split_div()
4619 isl_qpolynomial_free(qp); in split_div()
4630 __isl_take isl_qpolynomial *qp, void *user) in split_periods() argument
4641 if (!set || !qp) in split_periods()
4644 if (qp->div->n_row == 0) { in split_periods()
4645 pwqp = isl_pw_qpolynomial_alloc(set, qp); in split_periods()
4650 div_pos = isl_qpolynomial_domain_var_offset(qp, isl_dim_div); in split_periods()
4656 for (i = 0; i < qp->div->n_row; ++i) { in split_periods()
4659 if (isl_seq_first_non_zero(qp->div->row[i] + 2 + div_pos, in split_periods()
4660 qp->div->n_row) != -1) in split_periods()
4663 lp_res = isl_set_solve_lp(set, 0, qp->div->row[i] + 1, in split_periods()
4669 isl_int_fdiv_q(min, min, qp->div->row[i][0]); in split_periods()
4671 lp_res = isl_set_solve_lp(set, 1, qp->div->row[i] + 1, in split_periods()
4677 isl_int_fdiv_q(max, max, qp->div->row[i][0]); in split_periods()
4686 if (i < qp->div->n_row) { in split_periods()
4687 r = split_div(set, qp, i, min, max, data); in split_periods()
4689 pwqp = isl_pw_qpolynomial_alloc(set, qp); in split_periods()
4702 isl_qpolynomial_free(qp); in split_periods()
4743 isl_qpolynomial *qp; in constant_on_domain() local
4753 qp = isl_qpolynomial_infty_on_domain(space); in constant_on_domain()
4755 qp = isl_qpolynomial_zero_on_domain(space); in constant_on_domain()
4757 qp = isl_qpolynomial_one_on_domain(space); in constant_on_domain()
4758 return isl_pw_qpolynomial_alloc(isl_set_from_basic_set(bset), qp); in constant_on_domain()
4801 isl_qpolynomial *qp; in compressed_multiplicative_call() local
4815 qp = isl_qpolynomial_one_on_domain(space); in compressed_multiplicative_call()
4816 data.pwqp = isl_pw_qpolynomial_alloc(set, qp); in compressed_multiplicative_call()
4892 __isl_take isl_qpolynomial *qp, int down) in qp_drop_floors() argument
4897 if (!qp) in qp_drop_floors()
4899 if (qp->div->n_row == 0) in qp_drop_floors()
4900 return qp; in qp_drop_floors()
4902 qp = isl_qpolynomial_cow(qp); in qp_drop_floors()
4903 if (!qp) in qp_drop_floors()
4906 for (i = qp->div->n_row - 1; i >= 0; --i) { in qp_drop_floors()
4908 isl_int_sub(qp->div->row[i][1], in qp_drop_floors()
4909 qp->div->row[i][1], qp->div->row[i][0]); in qp_drop_floors()
4910 isl_int_add_ui(qp->div->row[i][1], in qp_drop_floors()
4911 qp->div->row[i][1], 1); in qp_drop_floors()
4913 s = isl_poly_from_affine(qp->dim->ctx, qp->div->row[i] + 1, in qp_drop_floors()
4914 qp->div->row[i][0], qp->div->n_col - 1); in qp_drop_floors()
4915 qp = substitute_div(qp, i, s); in qp_drop_floors()
4916 if (!qp) in qp_drop_floors()
4920 return qp; in qp_drop_floors()
4942 pwqp->p[i].qp = qp_drop_floors(pwqp->p[i].qp, 0); in pwqp_drop_floors()
4943 if (!pwqp->p[i].qp) in pwqp_drop_floors()
4968 static __isl_give isl_qpolynomial *make_divs_pos(__isl_take isl_qpolynomial *qp, in make_divs_pos() argument
4976 qp = isl_qpolynomial_cow(qp); in make_divs_pos()
4977 div_pos = isl_qpolynomial_domain_var_offset(qp, isl_dim_div); in make_divs_pos()
4979 return isl_qpolynomial_free(qp); in make_divs_pos()
4980 qp->div = isl_mat_cow(qp->div); in make_divs_pos()
4981 if (!qp->div) in make_divs_pos()
4984 v = isl_vec_alloc(qp->div->ctx, qp->div->n_col - 1); in make_divs_pos()
4986 for (i = 0; i < qp->div->n_row; ++i) { in make_divs_pos()
4987 isl_int *row = qp->div->row[i]; in make_divs_pos()
5013 for (j = i + 1; j < qp->div->n_row; ++j) { in make_divs_pos()
5014 if (isl_int_is_zero(qp->div->row[j][2 + div_pos + i])) in make_divs_pos()
5016 isl_seq_combine(qp->div->row[j] + 1, in make_divs_pos()
5017 qp->div->ctx->one, qp->div->row[j] + 1, in make_divs_pos()
5018 qp->div->row[j][2 + div_pos + i], v->el, in make_divs_pos()
5022 s = isl_poly_from_affine(qp->dim->ctx, v->el, in make_divs_pos()
5023 qp->div->ctx->one, v->size); in make_divs_pos()
5024 qp->poly = isl_poly_subs(qp->poly, div_pos + i, 1, &s); in make_divs_pos()
5026 if (!qp->poly) in make_divs_pos()
5031 return qp; in make_divs_pos()
5034 isl_qpolynomial_free(qp); in make_divs_pos()
5041 isl_qpolynomial *qp; member
5057 isl_qpolynomial *qp, *up, *down; in to_polynomial_on_orthant() local
5059 qp = isl_qpolynomial_copy(data->qp); in to_polynomial_on_orthant()
5060 qp = make_divs_pos(qp, signs); in to_polynomial_on_orthant()
5062 up = isl_qpolynomial_terms_of_sign(qp, signs, data->sign); in to_polynomial_on_orthant()
5064 down = isl_qpolynomial_terms_of_sign(qp, signs, -data->sign); in to_polynomial_on_orthant()
5067 isl_qpolynomial_free(qp); in to_polynomial_on_orthant()
5068 qp = isl_qpolynomial_add(up, down); in to_polynomial_on_orthant()
5070 t = isl_pw_qpolynomial_alloc(orthant, qp); in to_polynomial_on_orthant()
5104 if (pwqp->p[i].qp->div->n_row == 0) { in isl_pw_qpolynomial_to_polynomial()
5108 isl_qpolynomial_copy(pwqp->p[i].qp)); in isl_pw_qpolynomial_to_polynomial()
5112 data.qp = pwqp->p[i].qp; in isl_pw_qpolynomial_to_polynomial()
5143 __isl_take isl_qpolynomial *qp) in isl_basic_map_from_qpolynomial() argument
5153 if (!qp) in isl_basic_map_from_qpolynomial()
5155 is_affine = isl_poly_is_affine(qp->poly); in isl_basic_map_from_qpolynomial()
5159 isl_die(qp->dim->ctx, isl_error_invalid, in isl_basic_map_from_qpolynomial()
5161 aff = isl_qpolynomial_extract_affine(qp); in isl_basic_map_from_qpolynomial()
5164 space = isl_qpolynomial_get_space(qp); in isl_basic_map_from_qpolynomial()
5166 n_div = qp->div->n_row; in isl_basic_map_from_qpolynomial()
5173 isl_seq_cpy(bmap->div[k], qp->div->row[i], qp->div->n_col); in isl_basic_map_from_qpolynomial()
5174 isl_int_set_si(bmap->div[k][qp->div->n_col], 0); in isl_basic_map_from_qpolynomial()
5185 isl_qpolynomial_free(qp); in isl_basic_map_from_qpolynomial()
5190 isl_qpolynomial_free(qp); in isl_basic_map_from_qpolynomial()