File: isl_multi_pw_aff_pullback_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 (73 lines) | stat: -rw-r--r-- 1,746 bytes parent folder | download | duplicates (14)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Copyright 2013      Ecole Normale Superieure
 *
 * Use of this software is governed by the MIT license
 *
 * Written by Sven Verdoolaege,
 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
 */

#define xCAT(A,B) A ## B
#define CAT(A,B) xCAT(A,B)
#undef TYPE
#define TYPE CAT(isl_,BASE)
#define xFN(TYPE,NAME) TYPE ## _ ## NAME
#define FN(TYPE,NAME) xFN(TYPE,NAME)

#undef SUFFIX
#define SUFFIX	BASE
#undef ARG1
#define ARG1	isl_multi_pw_aff
#undef ARG2
#define ARG2	TYPE

static
#include "isl_align_params_templ.c"

/* Compute the pullback of "mpa" by the function represented by "fn".
 * In other words, plug in "fn" in "mpa".
 *
 * If "mpa" has an explicit domain, then it is this domain
 * that needs to undergo a pullback, i.e., a preimage.
 */
__isl_give isl_multi_pw_aff *FN(isl_multi_pw_aff_pullback,BASE)(
	__isl_take isl_multi_pw_aff *mpa, __isl_take TYPE *fn)
{
	int i;
	isl_size n;
	isl_space *space = NULL;

	FN(isl_multi_pw_aff_align_params,BASE)(&mpa, &fn);
	mpa = isl_multi_pw_aff_cow(mpa);
	n = isl_multi_pw_aff_size(mpa);
	if (n < 0 || !fn)
		goto error;

	space = isl_space_join(FN(TYPE,get_space)(fn),
				isl_multi_pw_aff_get_space(mpa));

	for (i = 0; i < n; ++i) {
		isl_pw_aff *pa;

		pa = isl_multi_pw_aff_take_at(mpa, i);
		pa = FN(isl_pw_aff_pullback,BASE)(pa, FN(TYPE,copy)(fn));
		mpa = isl_multi_pw_aff_restore_at(mpa, i, pa);
		if (!mpa)
			goto error;
	}
	if (isl_multi_pw_aff_has_explicit_domain(mpa)) {
		mpa->u.dom = FN(isl_set_preimage,BASE)(mpa->u.dom,
							FN(TYPE,copy)(fn));
		if (!mpa->u.dom)
			goto error;
	}

	FN(TYPE,free)(fn);
	isl_multi_pw_aff_restore_space(mpa, space);
	return mpa;
error:
	isl_space_free(space);
	isl_multi_pw_aff_free(mpa);
	FN(TYPE,free)(fn);
	return NULL;
}