2 * Copyright 2010 INRIA Saclay
3 * Copyright 2013 Ecole Normale Superieure
5 * Use of this software is governed by the MIT license
7 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
8 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
10 * and Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
14 #include <isl_space_private.h>
15 #include <isl_point_private.h>
17 #include <isl_pw_macro.h>
24 #define ARG2 isl_point
27 #include "isl_align_params_templ.c"
29 /* Evaluate "pw" in the void point "pnt".
30 * In particular, return the value NaN.
32 static __isl_give isl_val
*FN(PW
,eval_void
)(__isl_take PW
*pw
,
33 __isl_take isl_point
*pnt
)
37 ctx
= isl_point_get_ctx(pnt
);
40 return isl_val_nan(ctx
);
43 /* Evaluate the piecewise function "pw" in "pnt".
44 * If the point is void, then return NaN.
45 * If the point lies outside the domain of "pw", then return 0 or NaN
46 * depending on whether 0 is the default value for this type of function.
48 * Align the parameters if needed, but "pnt" should specify a value
49 * for all parameters in "pw".
51 __isl_give isl_val
*FN(PW
,eval
)(__isl_take PW
*pw
, __isl_take isl_point
*pnt
)
58 isl_space
*pnt_space
, *pw_space
;
61 FN(PW
,align_params_point
)(&pw
, &pnt
);
63 pnt_space
= isl_point_peek_space(pnt
);
64 pw_space
= FN(PW
,peek_space
)(pw
);
65 ok
= isl_space_is_domain_internal(pnt_space
, pw_space
);
68 ctx
= isl_point_get_ctx(pnt
);
70 isl_die(ctx
, isl_error_invalid
,
71 "incompatible spaces", goto error
);
72 is_void
= isl_point_is_void(pnt
);
76 return FN(PW
,eval_void
)(pw
, pnt
);
78 found
= isl_bool_false
;
79 for (i
= 0; i
< pw
->n
; ++i
) {
80 found
= isl_set_contains_point(pw
->p
[i
].set
, pnt
);
87 v
= FN(EL
,eval
)(FN(EL
,copy
)(pw
->p
[i
].FIELD
),
89 } else if (DEFAULT_IS_ZERO
) {
90 v
= isl_val_zero(ctx
);