return NULL;
}
+static __isl_give PW *FN(PW,align_params_pw_pw_multi_aff_and)(__isl_take PW *pw,
+ __isl_take isl_pw_multi_aff *pma,
+ __isl_give PW *(*fn)(__isl_take PW *pw,
+ __isl_take isl_pw_multi_aff *ma))
+{
+ isl_ctx *ctx;
+ isl_space *pma_space;
+
+ pma_space = isl_pw_multi_aff_get_space(pma);
+ if (!pw || !pma || !pma_space)
+ goto error;
+ if (isl_space_match(pw->dim, isl_dim_param, pma_space, isl_dim_param)) {
+ isl_space_free(pma_space);
+ return fn(pw, pma);
+ }
+ ctx = FN(PW,get_ctx)(pw);
+ if (!isl_space_has_named_params(pw->dim) ||
+ !isl_space_has_named_params(pma_space))
+ isl_die(ctx, isl_error_invalid,
+ "unaligned unnamed parameters", goto error);
+ pw = FN(PW,align_params)(pw, pma_space);
+ pma = isl_pw_multi_aff_align_params(pma, FN(PW,get_space)(pw));
+ return fn(pw, pma);
+error:
+ isl_space_free(pma_space);
+ FN(PW,free)(pw);
+ isl_pw_multi_aff_free(pma);
+ return NULL;
+}
+
/* Compute the pullback of "pw" by the function represented by "ma".
* In other words, plug in "ma" in "pw".
*/
return FN(PW,align_params_pw_multi_aff_and)(pw, ma,
&FN(PW,pullback_multi_aff_aligned));
}
+
+/* Compute the pullback of "pw" by the function represented by "pma".
+ * In other words, plug in "pma" in "pw".
+ */
+static __isl_give PW *FN(PW,pullback_pw_multi_aff_aligned)(__isl_take PW *pw,
+ __isl_take isl_pw_multi_aff *pma)
+{
+ int i;
+ PW *res;
+
+ if (!pma)
+ goto error;
+
+ if (pma->n == 0) {
+ isl_pw_multi_aff_free(pma);
+ res = FN(PW,empty)(FN(PW,get_space)(pw));
+ FN(PW,free)(pw);
+ return res;
+ }
+
+ res = FN(PW,pullback_multi_aff)(FN(PW,copy)(pw),
+ isl_multi_aff_copy(pma->p[0].maff));
+ res = FN(PW,intersect_domain)(res, isl_set_copy(pma->p[0].set));
+
+ for (i = 1; i < pma->n; ++i) {
+ PW *res_i;
+
+ res_i = FN(PW,pullback_multi_aff)(FN(PW,copy)(pw),
+ isl_multi_aff_copy(pma->p[i].maff));
+ res_i = FN(PW,intersect_domain)(res_i,
+ isl_set_copy(pma->p[i].set));
+ res = FN(PW,add_disjoint)(res, res_i);
+ }
+
+ isl_pw_multi_aff_free(pma);
+ FN(PW,free)(pw);
+ return res;
+error:
+ isl_pw_multi_aff_free(pma);
+ FN(PW,free)(pw);
+ return NULL;
+}
+
+__isl_give PW *FN(PW,pullback_pw_multi_aff)(__isl_take PW *pw,
+ __isl_take isl_pw_multi_aff *pma)
+{
+ return FN(PW,align_params_pw_pw_multi_aff_and)(pw, pma,
+ &FN(PW,pullback_pw_multi_aff_aligned));
+}
#endif