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#include <isl_pw_macro.h>
12
13__isl_give PW *FN(PW,scale)(__isl_take PW *pw, isl_int v)
14{
15 int i;
16 isl_size n;
17
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;
26 }
27 if (isl_int_is_neg(v))
28 pw = FN(PW,negate_type)(pw);
29
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;
35
36 el = FN(PW,take_base_at)(pw, pos: i);
37 el = FN(EL,scale)(aff: el, f: v);
38 pw = FN(PW,restore_base_at)(pw, pos: i, el);
39 }
40
41 return pw;
42}
43

source code of polly/lib/External/isl/isl_pw_scale_templ.c