File: isl_ilp_opt_val_templ.c

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (42 lines) | stat: -rw-r--r-- 1,062 bytes parent folder | download | duplicates (24)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright 2017      Sven Verdoolaege
 *
 * Use of this software is governed by the MIT license
 *
 * Written by Sven Verdoolaege
 */

#define xCAT(A,B) A ## B
#define CAT(A,B) xCAT(A,B)
#undef TYPE
#define TYPE CAT(isl_,BASE)
#define xBFN(BASE,NAME) isl_ ## BASE ## _ ## NAME
#define BFN(BASE,NAME) xBFN(BASE,NAME)

/* Return the minimal (maximal if "max" is set) value attained
 * by the given set dimension,
 * independently of the parameter values and of any other dimensions.
 *
 * Return infinity or negative infinity if the optimal value is unbounded and
 * NaN if "set" is empty.
 */
static __isl_give isl_val *BFN(BASE,dim_opt_val)(__isl_take TYPE *set, int max,
	int pos)
{
	isl_local_space *ls;
	isl_aff *obj;
	isl_val *v;

	if (BFN(BASE,check_range)(set, isl_dim_set, pos, 1) < 0)
		goto error;
	ls = isl_local_space_from_space(BFN(BASE,get_space)(set));
	obj = isl_aff_var_on_domain(ls, isl_dim_set, pos);
	v = BFN(BASE,opt_val)(set, max, obj);
	isl_aff_free(obj);
	BFN(BASE,free)(set);

	return v;
error:
	BFN(BASE,free)(set);
	return NULL;
}