Home | History | Annotate | Line # | Download | only in dist
      1 /*
      2  * Copyright 2010      INRIA Saclay
      3  *
      4  * Use of this software is governed by the MIT license
      5  *
      6  * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
      7  * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
      8  * 91893 Orsay, France
      9  */
     10 
     11 __isl_give PW *FN(PW,morph_domain)(__isl_take PW *pw,
     12 	__isl_take isl_morph *morph)
     13 {
     14 	int i;
     15 	isl_size n;
     16 	isl_ctx *ctx;
     17 	isl_space *space;
     18 
     19 	n = FN(PW,n_piece)(pw);
     20 	if (n < 0 || !morph)
     21 		goto error;
     22 
     23 	ctx = isl_space_get_ctx(pw->dim);
     24 	isl_assert(ctx, isl_space_is_domain_internal(morph->dom->dim, pw->dim),
     25 		goto error);
     26 
     27 	space = FN(PW,take_space)(pw);
     28 	space = isl_space_extend_domain_with_range(
     29 			isl_space_copy(morph->ran->dim), space);
     30 	pw = FN(PW,restore_space)(pw, space);
     31 
     32 	for (i = 0; i < n; ++i) {
     33 		isl_set *domain;
     34 		EL *el;
     35 
     36 		domain = FN(PW,take_domain_at)(pw, i);
     37 		domain = isl_morph_set(isl_morph_copy(morph), domain);
     38 		pw = FN(PW,restore_domain_at)(pw, i, domain);
     39 		el = FN(PW,take_base_at)(pw, i);
     40 		el = FN(EL,morph_domain)(el, isl_morph_copy(morph));
     41 		pw = FN(PW,restore_base_at)(pw, i, el);
     42 	}
     43 
     44 	isl_morph_free(morph);
     45 
     46 	return pw;
     47 error:
     48 	FN(PW,free)(pw);
     49 	isl_morph_free(morph);
     50 	return NULL;
     51 }
     52