isl_tab_basic_map_partial_lexopt: copy integer divisions to context
[isl.git] / isl_pw_scale_templ.c
blob81c8495e9cb7e6942bba7deabe91d849573a8b25
1 /*
2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the MIT license
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 */
11 #include <isl_pw_macro.h>
13 __isl_give PW *FN(PW,scale)(__isl_take PW *pw, isl_int v)
15 int i;
16 isl_size n;
18 if (isl_int_is_one(v))
19 return pw;
20 if (pw && DEFAULT_IS_ZERO && isl_int_is_zero(v)) {
21 PW *zero;
22 isl_space *space = FN(PW,get_space)(pw);
23 zero = FN(PW,ZERO)(space OPT_TYPE_ARG(pw->));
24 FN(PW,free)(pw);
25 return zero;
27 if (isl_int_is_neg(v))
28 pw = FN(PW,negate_type)(pw);
30 n = FN(PW,n_piece)(pw);
31 if (n < 0)
32 return FN(PW,free)(pw);
33 for (i = 0; i < n; ++i) {
34 EL *el;
36 el = FN(PW,take_base_at)(pw, i);
37 el = FN(EL,scale)(el, v);
38 pw = FN(PW,restore_base_at)(pw, i, el);
41 return pw;