1 #include <isl_val_private.h>
3 #define xFN(TYPE,NAME) TYPE ## _ ## NAME
4 #define FN(TYPE,NAME) xFN(TYPE,NAME)
6 /* Compute the given non-zero power of "map" and return the result.
7 * If the exponent "exp" is negative, then the -exp th power of the inverse
8 * relation is computed.
10 __isl_give TYPE
*FN(TYPE
,fixed_power
)(__isl_take TYPE
*map
, isl_int exp
)
19 ctx
= FN(TYPE
,get_ctx
)(map
);
20 if (isl_int_is_zero(exp
))
21 isl_die(ctx
, isl_error_invalid
,
22 "expecting non-zero exponent", goto error
);
24 if (isl_int_is_neg(exp
)) {
25 isl_int_neg(exp
, exp
);
26 map
= FN(TYPE
,reverse
)(map
);
27 return FN(TYPE
,fixed_power
)(map
, exp
);
32 isl_int_fdiv_r(r
, exp
, ctx
->two
);
34 if (!isl_int_is_zero(r
)) {
36 res
= FN(TYPE
,copy
)(map
);
38 res
= FN(TYPE
,apply_range
)(res
,
40 res
= FN(TYPE
,coalesce
)(res
);
46 isl_int_fdiv_q(exp
, exp
, ctx
->two
);
47 if (isl_int_is_zero(exp
))
50 map
= FN(TYPE
,apply_range
)(map
, FN(TYPE
,copy
)(map
));
51 map
= FN(TYPE
,coalesce
)(map
);
62 /* Compute the given non-zero power of "map" and return the result.
63 * If the exponent "exp" is negative, then the -exp th power of the inverse
64 * relation is computed.
66 __isl_give TYPE
*FN(TYPE
,fixed_power_val
)(__isl_take TYPE
*map
,
67 __isl_take isl_val
*exp
)
71 if (!isl_val_is_int(exp
))
72 isl_die(FN(TYPE
,get_ctx
)(map
), isl_error_invalid
,
73 "expecting integer exponent", goto error
);
74 map
= FN(TYPE
,fixed_power
)(map
, exp
->n
);