update .gitignore
[platform/upstream/isl.git] / isl_fold.c
index e7c9dfb..3286bd7 100644 (file)
@@ -43,6 +43,22 @@ error:
        return NULL;
 }
 
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_reset_dim(
+       __isl_take isl_qpolynomial_fold *fold, __isl_take isl_dim *dim)
+{
+       if (!fold || !dim)
+               goto error;
+
+       isl_dim_free(fold->dim);
+       fold->dim = dim;
+
+       return fold;
+error:
+       isl_qpolynomial_fold_free(fold);
+       isl_dim_free(dim);
+       return NULL;
+}
+
 int isl_qpolynomial_fold_involves_dims(__isl_keep isl_qpolynomial_fold *fold,
        enum isl_dim_type type, unsigned first, unsigned n)
 {
@@ -334,6 +350,33 @@ error:
        return NULL;
 }
 
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_substitute_equalities(
+       __isl_take isl_qpolynomial_fold *fold, __isl_take isl_basic_set *eq)
+{
+       int i;
+
+       if (!fold || !eq)
+               goto error;
+
+       fold = isl_qpolynomial_fold_cow(fold);
+       if (!fold)
+               return NULL;
+
+       for (i = 0; i < fold->n; ++i) {
+               fold->qp[i] = isl_qpolynomial_substitute_equalities(fold->qp[i],
+                                                       isl_basic_set_copy(eq));
+               if (!fold->qp[i])
+                       goto error;
+       }
+
+       isl_basic_set_free(eq);
+       return fold;
+error:
+       isl_basic_set_free(eq);
+       isl_qpolynomial_fold_free(fold);
+       return NULL;
+}
+
 #undef PW
 #define PW isl_pw_qpolynomial_fold
 #undef EL
@@ -860,3 +903,33 @@ error:
        isl_qpolynomial_fold_free(fold);
        return NULL;
 }
+
+/* For each 0 <= i < "n", replace variable "first" + i of type "type"
+ * in fold->qp[k] by subs[i].
+ */
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_substitute(
+       __isl_take isl_qpolynomial_fold *fold,
+       enum isl_dim_type type, unsigned first, unsigned n,
+       __isl_keep isl_qpolynomial **subs)
+{
+       int i;
+
+       if (n == 0)
+               return fold;
+
+       fold = isl_qpolynomial_fold_cow(fold);
+       if (!fold)
+               return NULL;
+
+       for (i = 0; i < fold->n; ++i) {
+               fold->qp[i] = isl_qpolynomial_substitute(fold->qp[i],
+                               type, first, n, subs);
+               if (!fold->qp[i])
+                       goto error;
+       }
+
+       return fold;
+error:
+       isl_qpolynomial_fold_free(fold);
+       return NULL;
+}