~ubuntu-branches/ubuntu/trusty/cloog/trusty

« back to all changes in this revision

Viewing changes to isl/isl_morph.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-12-15 18:39:17 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20111215183917-uqggmujou8wna9js
Tags: 0.17.0-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#include <isl_morph.h>
13
13
#include <isl/seq.h>
14
14
#include <isl_mat_private.h>
15
 
#include <isl_dim_private.h>
 
15
#include <isl_space_private.h>
16
16
#include <isl_equalities.h>
17
17
 
18
18
__isl_give isl_morph *isl_morph_alloc(
88
88
        free(morph);
89
89
}
90
90
 
91
 
__isl_give isl_dim *isl_morph_get_ran_dim(__isl_keep isl_morph *morph)
 
91
__isl_give isl_space *isl_morph_get_ran_space(__isl_keep isl_morph *morph)
92
92
{
93
93
        if (!morph)
94
94
                return NULL;
95
95
        
96
 
        return isl_dim_copy(morph->ran->dim);
 
96
        return isl_space_copy(morph->ran->dim);
97
97
}
98
98
 
99
99
unsigned isl_morph_dom_dim(__isl_keep isl_morph *morph, enum isl_dim_type type)
124
124
        if (!morph)
125
125
                return NULL;
126
126
 
127
 
        dom_offset = 1 + isl_dim_offset(morph->dom->dim, type);
 
127
        dom_offset = 1 + isl_space_offset(morph->dom->dim, type);
128
128
 
129
129
        morph->dom = isl_basic_set_remove_dims(morph->dom, type, first, n);
130
130
 
151
151
        if (!morph)
152
152
                return NULL;
153
153
 
154
 
        ran_offset = 1 + isl_dim_offset(morph->ran->dim, type);
 
154
        ran_offset = 1 + isl_space_offset(morph->ran->dim, type);
155
155
 
156
156
        morph->ran = isl_basic_set_remove_dims(morph->ran, type, first, n);
157
157
 
166
166
        return NULL;
167
167
}
168
168
 
 
169
/* Project domain of morph onto its parameter domain.
 
170
 */
 
171
__isl_give isl_morph *isl_morph_dom_params(__isl_take isl_morph *morph)
 
172
{
 
173
        unsigned n;
 
174
 
 
175
        if (!morph)
 
176
                return NULL;
 
177
        n = isl_basic_set_dim(morph->dom, isl_dim_set);
 
178
        morph = isl_morph_remove_dom_dims(morph, isl_dim_set, 0, n);
 
179
        if (!morph)
 
180
                return NULL;
 
181
        morph->dom = isl_basic_set_params(morph->dom);
 
182
        if (morph->dom)
 
183
                return morph;
 
184
 
 
185
        isl_morph_free(morph);
 
186
        return NULL;
 
187
}
 
188
 
 
189
/* Project range of morph onto its parameter domain.
 
190
 */
 
191
__isl_give isl_morph *isl_morph_ran_params(__isl_take isl_morph *morph)
 
192
{
 
193
        unsigned n;
 
194
 
 
195
        if (!morph)
 
196
                return NULL;
 
197
        n = isl_basic_set_dim(morph->ran, isl_dim_set);
 
198
        morph = isl_morph_remove_ran_dims(morph, isl_dim_set, 0, n);
 
199
        if (!morph)
 
200
                return NULL;
 
201
        morph->ran = isl_basic_set_params(morph->ran);
 
202
        if (morph->ran)
 
203
                return morph;
 
204
 
 
205
        isl_morph_free(morph);
 
206
        return NULL;
 
207
}
 
208
 
169
209
void isl_morph_dump(__isl_take isl_morph *morph, FILE *out)
170
210
{
171
211
        if (!morph)
188
228
 
189
229
        total = isl_basic_set_total_dim(bset);
190
230
        id = isl_mat_identity(bset->ctx, 1 + total);
191
 
        universe = isl_basic_set_universe(isl_dim_copy(bset->dim));
 
231
        universe = isl_basic_set_universe(isl_space_copy(bset->dim));
192
232
 
193
233
        return isl_morph_alloc(universe, isl_basic_set_copy(universe),
194
234
                id, isl_mat_copy(id));
208
248
 
209
249
        total = isl_basic_set_total_dim(bset);
210
250
        id = isl_mat_identity(bset->ctx, 1 + total);
211
 
        empty = isl_basic_set_empty(isl_dim_copy(bset->dim));
 
251
        empty = isl_basic_set_empty(isl_space_copy(bset->dim));
212
252
 
213
253
        return isl_morph_alloc(empty, isl_basic_set_copy(empty),
214
254
                id, isl_mat_copy(id));
253
293
        isl_assert(bset->ctx, bset->n_div == 0, return NULL);
254
294
 
255
295
        total = isl_basic_set_total_dim(bset);
256
 
        eq = isl_basic_set_alloc_dim(isl_dim_copy(bset->dim), 0, n, 0);
 
296
        eq = isl_basic_set_alloc_space(isl_space_copy(bset->dim), 0, n, 0);
257
297
        if (!eq)
258
298
                return NULL;
259
299
        for (i = 0; i < n; ++i) {
327
367
        unsigned orest;
328
368
        unsigned nrest;
329
369
        int f_eq, n_eq;
330
 
        isl_dim *dim;
 
370
        isl_space *dim;
331
371
        isl_mat *H, *U, *Q, *C = NULL, *H1, *U1, *U2;
332
372
        isl_basic_set *dom, *ran;
333
373
 
339
379
 
340
380
        isl_assert(bset->ctx, bset->n_div == 0, return NULL);
341
381
 
342
 
        otype = 1 + isl_dim_offset(bset->dim, type);
 
382
        otype = 1 + isl_space_offset(bset->dim, type);
343
383
        ntype = isl_basic_set_dim(bset, type);
344
384
        orest = otype + ntype;
345
385
        nrest = isl_basic_set_total_dim(bset) - (orest - 1);
407
447
        C = insert_parameter_rows(C, otype - 1);
408
448
        C = isl_mat_diagonal(C, isl_mat_identity(bset->ctx, nrest));
409
449
 
410
 
        dim = isl_dim_copy(bset->dim);
411
 
        dim = isl_dim_drop(dim, type, 0, ntype);
412
 
        dim = isl_dim_add(dim, type, ntype - n_eq);
 
450
        dim = isl_space_copy(bset->dim);
 
451
        dim = isl_space_drop_dims(dim, type, 0, ntype);
 
452
        dim = isl_space_add_dims(dim, type, ntype - n_eq);
413
453
        ran = isl_basic_set_universe(dim);
414
454
        dom = copy_equalities(bset, f_eq, n_eq);
415
455
 
481
521
        inv = isl_mat_diagonal(inv, isl_mat_identity(bset->ctx, nvar));
482
522
        map = isl_mat_right_inverse(isl_mat_copy(inv));
483
523
 
484
 
        dom = isl_basic_set_universe(isl_dim_copy(bset->dim));
485
 
        ran = isl_basic_set_universe(isl_dim_copy(bset->dim));
 
524
        dom = isl_basic_set_universe(isl_space_copy(bset->dim));
 
525
        ran = isl_basic_set_universe(isl_space_copy(bset->dim));
486
526
 
487
527
        return isl_morph_alloc(dom, ran, map, inv);
488
528
error:
569
609
        if (!morph || !bset)
570
610
                goto error;
571
611
 
572
 
        isl_assert(bset->ctx, isl_dim_equal(bset->dim, morph->dom->dim),
 
612
        isl_assert(bset->ctx, isl_space_is_equal(bset->dim, morph->dom->dim),
573
613
                    goto error);
574
614
 
575
615
        max_stride = morph->inv->n_row - 1;
576
616
        if (isl_int_is_one(morph->inv->row[0][0]))
577
617
                max_stride = 0;
578
 
        res = isl_basic_set_alloc_dim(isl_dim_copy(morph->ran->dim),
 
618
        res = isl_basic_set_alloc_space(isl_space_copy(morph->ran->dim),
579
619
                bset->n_div + max_stride, bset->n_eq + max_stride, bset->n_ineq);
580
620
 
581
621
        for (i = 0; i < bset->n_div; ++i)
659
699
        if (!morph || !set)
660
700
                goto error;
661
701
 
662
 
        isl_assert(set->ctx, isl_dim_equal(set->dim, morph->dom->dim), goto error);
 
702
        isl_assert(set->ctx, isl_space_is_equal(set->dim, morph->dom->dim), goto error);
663
703
 
664
704
        set = isl_set_cow(set);
665
705
        if (!set)
666
706
                goto error;
667
707
 
668
 
        isl_dim_free(set->dim);
669
 
        set->dim = isl_dim_copy(morph->ran->dim);
 
708
        isl_space_free(set->dim);
 
709
        set->dim = isl_space_copy(morph->ran->dim);
670
710
        if (!set->dim)
671
711
                goto error;
672
712