File: polyhedron_8c_source.html

package info (click to toggle)
polylib 5.22.5-3%2Bdfsg
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 14,444 kB
  • ctags: 52,958
  • sloc: ansic: 16,342; sh: 10,134; makefile: 560
file content (4751 lines) | stat: -rw-r--r-- 566,519 bytes parent folder | download | duplicates (4)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>polylib: polyhedron.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>polyhedron.c</h1><a href="polyhedron_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">    This file is part of PolyLib.</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">    PolyLib is free software: you can redistribute it and/or modify</span>
<a name="l00005"></a>00005 <span class="comment">    it under the terms of the GNU General Public License as published by</span>
<a name="l00006"></a>00006 <span class="comment">    the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00007"></a>00007 <span class="comment">    (at your option) any later version.</span>
<a name="l00008"></a>00008 <span class="comment"></span>
<a name="l00009"></a>00009 <span class="comment">    PolyLib is distributed in the hope that it will be useful,</span>
<a name="l00010"></a>00010 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00011"></a>00011 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00012"></a>00012 <span class="comment">    GNU General Public License for more details.</span>
<a name="l00013"></a>00013 <span class="comment"></span>
<a name="l00014"></a>00014 <span class="comment">    You should have received a copy of the GNU General Public License</span>
<a name="l00015"></a>00015 <span class="comment">    along with PolyLib.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<a name="l00016"></a>00016 <span class="comment">*/</span>
<a name="l00017"></a>00017 
<a name="l00018"></a>00018 <span class="comment">/* polyhedron.c</span>
<a name="l00019"></a>00019 <span class="comment">     COPYRIGHT</span>
<a name="l00020"></a>00020 <span class="comment">          Both this software and its documentation are</span>
<a name="l00021"></a>00021 <span class="comment"></span>
<a name="l00022"></a>00022 <span class="comment">              Copyright 1993 by IRISA /Universite de Rennes I - France,</span>
<a name="l00023"></a>00023 <span class="comment">              Copyright 1995,1996 by BYU, Provo, Utah</span>
<a name="l00024"></a>00024 <span class="comment">                         all rights reserved.</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">          Permission is granted to copy, use, and distribute</span>
<a name="l00027"></a>00027 <span class="comment">          for any commercial or noncommercial purpose under the terms</span>
<a name="l00028"></a>00028 <span class="comment">          of the GNU General Public license, version 2, June 1991</span>
<a name="l00029"></a>00029 <span class="comment">          (see file : LICENSING).</span>
<a name="l00030"></a>00030 <span class="comment">*/</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="comment">/*</span>
<a name="l00033"></a>00033 <span class="comment"></span>
<a name="l00034"></a>00034 <span class="comment">1997/12/02 - Olivier Albiez</span>
<a name="l00035"></a>00035 <span class="comment">  Ce fichier contient les fonctions de la polylib de l&apos;IRISA,</span>
<a name="l00036"></a>00036 <span class="comment">  passees en 64bits.</span>
<a name="l00037"></a>00037 <span class="comment">  La structure de la polylib a donc ete modifie pour permettre </span>
<a name="l00038"></a>00038 <span class="comment">  le passage aux Value. La fonction Chernikova a ete reecrite.</span>
<a name="l00039"></a>00039 <span class="comment"></span>
<a name="l00040"></a>00040 <span class="comment">*/</span>
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="comment">/*</span>
<a name="l00043"></a>00043 <span class="comment"></span>
<a name="l00044"></a>00044 <span class="comment">1998/26/02 - Vincent Loechner</span>
<a name="l00045"></a>00045 <span class="comment">  Ajout de nombreuses fonctions, a la fin de ce fichier,</span>
<a name="l00046"></a>00046 <span class="comment">  pour les polyedres parametres 64 bits.</span>
<a name="l00047"></a>00047 <span class="comment">1998/16/03</span>
<a name="l00048"></a>00048 <span class="comment">  #define DEBUG  printf</span>
<a name="l00049"></a>00049 <span class="comment">  tests out of memory</span>
<a name="l00050"></a>00050 <span class="comment">  compatibilite avec la version de doran</span>
<a name="l00051"></a>00051 <span class="comment"></span>
<a name="l00052"></a>00052 <span class="comment">*/</span>
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="preprocessor">#undef POLY_DEBUG               </span><span class="comment">/* debug printf: general functions */</span>
<a name="l00055"></a>00055 <span class="preprocessor">#undef POLY_RR_DEBUG            </span><span class="comment">/* debug printf: Remove Redundants */</span>
<a name="l00056"></a>00056 <span class="preprocessor">#undef POLY_CH_DEBUG            </span><span class="comment">/* debug printf: Chernikova */</span>
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00059"></a>00059 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00060"></a>00060 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00061"></a>00061 <span class="preprocessor">#include &lt;<a class="code" href="assert_8h.html">assert.h</a>&gt;</span>
<a name="l00062"></a>00062 <span class="preprocessor">#include &lt;<a class="code" href="polylib_8h.html">polylib/polylib.h</a>&gt;</span>
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 <span class="preprocessor">#ifdef MAC_OS</span>
<a name="l00065"></a>00065 <span class="preprocessor"></span><span class="preprocessor">  #define abs __abs</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00067"></a>00067 <span class="preprocessor"></span>
<a name="l00068"></a>00068 <span class="comment">/* WSIZE is the number of bits in a word or int type */</span> 
<a name="l00069"></a><a class="code" href="polyhedron_8c.html#a7edb6b8a8c89cb564d6e1b85ed80e7db">00069</a> <span class="preprocessor">#define WSIZE (8*sizeof(int)) </span>
<a name="l00070"></a>00070 <span class="preprocessor"></span>
<a name="l00071"></a><a class="code" href="polyhedron_8c.html#ab15f1c639db2248c48f7a822c0d51665">00071</a> <span class="preprocessor">#define bexchange(a, b, l)\</span>
<a name="l00072"></a>00072 <span class="preprocessor">{\</span>
<a name="l00073"></a>00073 <span class="preprocessor">  char *t = (char *)malloc(l*sizeof(char));\</span>
<a name="l00074"></a>00074 <span class="preprocessor">  memcpy((t), (char *)(a), (int)(l));\</span>
<a name="l00075"></a>00075 <span class="preprocessor">  memcpy((char *)(a), (char *)(b), (int)(l));\</span>
<a name="l00076"></a>00076 <span class="preprocessor">  memcpy((char *)(b), (t), (int)(l));\</span>
<a name="l00077"></a>00077 <span class="preprocessor">  free(t); \</span>
<a name="l00078"></a>00078 <span class="preprocessor">}</span>
<a name="l00079"></a>00079 <span class="preprocessor"></span>
<a name="l00080"></a><a class="code" href="polyhedron_8c.html#a8294d94a99fcebc56913f5eff14807e2">00080</a> <span class="preprocessor">#define exchange(a, b, t)\</span>
<a name="l00081"></a>00081 <span class="preprocessor">{ (t)=(a); (a)=(b); (b)=(t); }</span>
<a name="l00082"></a>00082 <span class="preprocessor"></span>
<a name="l00083"></a>00083 <span class="comment">/*  errormsg1 is an external function which is usually supplied by the</span>
<a name="l00084"></a>00084 <span class="comment">    calling program (e.g. Domlib.c, ReadAlpha, etc...).</span>
<a name="l00085"></a>00085 <span class="comment">    See errormsg.c for an example of such a function.  */</span>
<a name="l00086"></a>00086 
<a name="l00087"></a>00087 <span class="keywordtype">void</span> <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *f, <span class="keyword">const</span> <span class="keywordtype">char</span> *msgname, <span class="keyword">const</span> <span class="keywordtype">char</span> *msg);
<a name="l00088"></a>00088 
<a name="l00089"></a><a class="code" href="types_8h.html#aa587bf4e8c763fa5e95542df7eb070b7">00089</a> <span class="keywordtype">int</span> <a class="code" href="errormsg_8c.html#aa587bf4e8c763fa5e95542df7eb070b7">Pol_status</a>;                    <span class="comment">/* error status after operations */</span>
<a name="l00090"></a>00090 
<a name="l00091"></a>00091 <span class="comment">/*</span>
<a name="l00092"></a>00092 <span class="comment"> * The Saturation matrix is defined to be an integer (int type) matrix.</span>
<a name="l00093"></a>00093 <span class="comment"> * It is a boolean matrix which has a row for every constraint and a column</span>
<a name="l00094"></a>00094 <span class="comment"> * for every line or ray. The bits in the binary format of each integer in </span>
<a name="l00095"></a>00095 <span class="comment"> * the stauration matrix stores the information whether the corresponding</span>
<a name="l00096"></a>00096 <span class="comment"> * constraint is saturated by ray(line) or not.   </span>
<a name="l00097"></a>00097 <span class="comment"> */</span>
<a name="l00098"></a>00098 
<a name="l00099"></a><a class="code" href="structSatMatrix.html">00099</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00100"></a><a class="code" href="structSatMatrix.html#a08d0db0d2eda3b8bdcc316eabadaca09">00100</a>   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> NbRows;
<a name="l00101"></a><a class="code" href="structSatMatrix.html#a20a0299b3d86f4c26a22faed4aaea6fd">00101</a>   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> NbColumns;
<a name="l00102"></a><a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">00102</a>   <span class="keywordtype">int</span> **<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a>;
<a name="l00103"></a><a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">00103</a>   <span class="keywordtype">int</span> *p_init;
<a name="l00104"></a>00104 } <a class="code" href="structSatMatrix.html">SatMatrix</a>;
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 <span class="comment">/*</span>
<a name="l00107"></a>00107 <span class="comment"> * Allocate memory space for a saturation matrix. </span>
<a name="l00108"></a>00108 <span class="comment"> */</span>
<a name="l00109"></a><a class="code" href="polyhedron_8c.html#a010deaa3d3f81aaa979f67bb0012d109">00109</a> <span class="keyword">static</span> <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyhedron_8c.html#a010deaa3d3f81aaa979f67bb0012d109">SMAlloc</a>(<span class="keywordtype">int</span> rows,<span class="keywordtype">int</span> cols) {
<a name="l00110"></a>00110   
<a name="l00111"></a>00111   <span class="keywordtype">int</span> **q, *<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a>, i;
<a name="l00112"></a>00112   <a class="code" href="structSatMatrix.html">SatMatrix</a> *result;
<a name="l00113"></a>00113   
<a name="l00114"></a>00114   result = (<a class="code" href="structSatMatrix.html">SatMatrix</a> *) malloc (<span class="keyword">sizeof</span>(<a class="code" href="structSatMatrix.html">SatMatrix</a>));
<a name="l00115"></a>00115   <span class="keywordflow">if</span>(!result) { 
<a name="l00116"></a>00116     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;SMAlloc&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l00117"></a>00117     <span class="keywordflow">return</span> 0;
<a name="l00118"></a>00118   }
<a name="l00119"></a>00119   result-&gt;<a class="code" href="structSatMatrix.html#a08d0db0d2eda3b8bdcc316eabadaca09">NbRows</a> = rows;
<a name="l00120"></a>00120   result-&gt;<a class="code" href="structSatMatrix.html#a20a0299b3d86f4c26a22faed4aaea6fd">NbColumns</a> = cols;
<a name="l00121"></a>00121   <span class="keywordflow">if</span>(rows == 0 || cols == 0) {
<a name="l00122"></a>00122     result-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a> = NULL;
<a name="l00123"></a>00123     <span class="keywordflow">return</span> result;
<a name="l00124"></a>00124   }
<a name="l00125"></a>00125   result-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a> = q = (<span class="keywordtype">int</span> **)malloc(rows * <span class="keyword">sizeof</span>(<span class="keywordtype">int</span> *));
<a name="l00126"></a>00126   <span class="keywordflow">if</span>(!result-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>) {
<a name="l00127"></a>00127     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;SMAlloc&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l00128"></a>00128     <span class="keywordflow">return</span> 0;
<a name="l00129"></a>00129   }
<a name="l00130"></a>00130   result-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a> = p = (<span class="keywordtype">int</span> *)malloc (rows * cols * <span class="keyword">sizeof</span> (<span class="keywordtype">int</span>));
<a name="l00131"></a>00131   <span class="keywordflow">if</span>(!result-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a>) {
<a name="l00132"></a>00132     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;SMAlloc&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l00133"></a>00133     <span class="keywordflow">return</span> 0;
<a name="l00134"></a>00134   }
<a name="l00135"></a>00135   <span class="keywordflow">for</span> (i=0; i&lt;rows; i++) {
<a name="l00136"></a>00136     *q++ = p;
<a name="l00137"></a>00137     p += cols;
<a name="l00138"></a>00138   }
<a name="l00139"></a>00139   <span class="keywordflow">return</span> result;
<a name="l00140"></a>00140 } <span class="comment">/* SMAlloc */</span>
<a name="l00141"></a>00141 
<a name="l00142"></a>00142 <span class="comment">/* </span>
<a name="l00143"></a>00143 <span class="comment"> * Free the memory space occupied by saturation matrix. </span>
<a name="l00144"></a>00144 <span class="comment"> */</span> 
<a name="l00145"></a><a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">00145</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a> (<a class="code" href="structSatMatrix.html">SatMatrix</a> **<a class="code" href="structmatrix.html">matrix</a>) {
<a name="l00146"></a>00146   <a class="code" href="structSatMatrix.html">SatMatrix</a> *SM = *matrix;
<a name="l00147"></a>00147 
<a name="l00148"></a>00148   <span class="keywordflow">if</span> (SM) { 
<a name="l00149"></a>00149     <span class="keywordflow">if</span> (SM-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>) {
<a name="l00150"></a>00150       free ((<span class="keywordtype">char</span> *) SM-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a>);
<a name="l00151"></a>00151       free ((<span class="keywordtype">char</span> *) SM-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>);
<a name="l00152"></a>00152     }
<a name="l00153"></a>00153     free ((<span class="keywordtype">char</span> *) SM);
<a name="l00154"></a>00154     *matrix = NULL;
<a name="l00155"></a>00155   }
<a name="l00156"></a>00156 } <span class="comment">/* SMFree */</span>
<a name="l00157"></a>00157 
<a name="l00158"></a>00158 <span class="comment">/*</span>
<a name="l00159"></a>00159 <span class="comment"> * Print the contents of a saturation matrix.</span>
<a name="l00160"></a>00160 <span class="comment"> * This function is defined only for debugging purpose. </span>
<a name="l00161"></a>00161 <span class="comment"> */</span>
<a name="l00162"></a><a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">00162</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a> (<a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="structmatrix.html">matrix</a>) {
<a name="l00163"></a>00163   
<a name="l00164"></a>00164   <span class="keywordtype">int</span> *<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a>;
<a name="l00165"></a>00165   <span class="keywordtype">int</span> i, j;
<a name="l00166"></a>00166   <span class="keywordtype">unsigned</span> NbRows, NbColumns;
<a name="l00167"></a>00167   
<a name="l00168"></a>00168   fprintf(stderr,<span class="stringliteral">&quot;%d %d\n&quot;</span>,NbRows=matrix-&gt;<a class="code" href="structSatMatrix.html#a08d0db0d2eda3b8bdcc316eabadaca09">NbRows</a>, NbColumns=matrix-&gt;<a class="code" href="structSatMatrix.html#a20a0299b3d86f4c26a22faed4aaea6fd">NbColumns</a>);
<a name="l00169"></a>00169   <span class="keywordflow">for</span> (i=0;i&lt;NbRows;i++) {
<a name="l00170"></a>00170     p = *(matrix-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>+i);
<a name="l00171"></a>00171     <span class="keywordflow">for</span> (j=0;j&lt;NbColumns;j++)
<a name="l00172"></a>00172       fprintf(stderr, <span class="stringliteral">&quot; %10X &quot;</span>, *p++);
<a name="l00173"></a>00173     fprintf(stderr, <span class="stringliteral">&quot;\n&quot;</span>);
<a name="l00174"></a>00174   }  
<a name="l00175"></a>00175 } <span class="comment">/* SMPrint */</span>
<a name="l00176"></a>00176 
<a name="l00177"></a>00177 <span class="comment">/* </span>
<a name="l00178"></a>00178 <span class="comment"> * Compute the bitwise OR of two saturation matrices.</span>
<a name="l00179"></a>00179 <span class="comment"> */</span>
<a name="l00180"></a><a class="code" href="polyhedron_8c.html#ab878a4f79f7c6fa2c95321aa905a101e">00180</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#ab878a4f79f7c6fa2c95321aa905a101e">SatVector_OR</a>(<span class="keywordtype">int</span> *p1,<span class="keywordtype">int</span> *p2,<span class="keywordtype">int</span> *p3,<span class="keywordtype">unsigned</span> length) {
<a name="l00181"></a>00181   
<a name="l00182"></a>00182   <span class="keywordtype">int</span> *cp1, *cp2, *cp3;
<a name="l00183"></a>00183   <span class="keywordtype">int</span> i;
<a name="l00184"></a>00184   
<a name="l00185"></a>00185   cp1=p1;
<a name="l00186"></a>00186   cp2=p2;
<a name="l00187"></a>00187   cp3=p3;
<a name="l00188"></a>00188   <span class="keywordflow">for</span> (i=0;i&lt;length;i++) {
<a name="l00189"></a>00189     *cp3 = *cp1 | *cp2;
<a name="l00190"></a>00190     cp3++;
<a name="l00191"></a>00191     cp1++;
<a name="l00192"></a>00192     cp2++;
<a name="l00193"></a>00193   }
<a name="l00194"></a>00194 } <span class="comment">/* SatVector_OR */</span>
<a name="l00195"></a>00195 
<a name="l00196"></a>00196 <span class="comment">/* </span>
<a name="l00197"></a>00197 <span class="comment"> * Copy a saturation matrix to another (macro definition). </span>
<a name="l00198"></a>00198 <span class="comment"> */</span>
<a name="l00199"></a><a class="code" href="polyhedron_8c.html#a224c6af52361d50af23a236949251a70">00199</a> <span class="preprocessor">#define SMVector_Copy(p1, p2, length) \</span>
<a name="l00200"></a>00200 <span class="preprocessor">  memcpy((char *)(p2), (char *)(p1), (int)((length)*sizeof(int)))</span>
<a name="l00201"></a>00201 <span class="preprocessor"></span>
<a name="l00202"></a>00202 <span class="comment">/*</span>
<a name="l00203"></a>00203 <span class="comment"> * Initialize a saturation matrix with zeros (macro definition) </span>
<a name="l00204"></a>00204 <span class="comment"> */</span>
<a name="l00205"></a><a class="code" href="polyhedron_8c.html#a3351961690e2b071105b7bb4be0b7127">00205</a> <span class="preprocessor">#define SMVector_Init(p1, length) \</span>
<a name="l00206"></a>00206 <span class="preprocessor">  memset((char *)(p1), 0, (int)((length)*sizeof(int)))</span>
<a name="l00207"></a>00207 <span class="preprocessor"></span>
<a name="l00208"></a>00208 <span class="comment">/*</span>
<a name="l00209"></a>00209 <span class="comment"> * Defining operations on polyhedron --</span>
<a name="l00210"></a>00210 <span class="comment"> */</span>
<a name="l00211"></a>00211 
<a name="l00212"></a>00212 <span class="comment">/* </span>
<a name="l00213"></a>00213 <span class="comment"> * Vector p3 is a linear combination of two vectors (p1 and p2) such that </span>
<a name="l00214"></a>00214 <span class="comment"> * p3[pos] is zero. First element of each vector (p1,p2,p3) is a status </span>
<a name="l00215"></a>00215 <span class="comment"> * element and is not changed in p3. The value of &apos;pos&apos; may be 0 however.</span>
<a name="l00216"></a>00216 <span class="comment"> * The parameter &apos;length&apos; does not include status element one. </span>
<a name="l00217"></a>00217 <span class="comment"> */</span>
<a name="l00218"></a><a class="code" href="polyhedron_8c.html#af4f5e2e459098eddbfbb7236162de68c">00218</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#af4f5e2e459098eddbfbb7236162de68c">Combine</a>(Value *p1, Value *p2, Value *p3, <span class="keywordtype">int</span> pos, <span class="keywordtype">unsigned</span> length) { 
<a name="l00219"></a>00219 
<a name="l00220"></a>00220   Value a1, a2, gcd;
<a name="l00221"></a>00221   Value abs_a1,abs_a2,neg_a1;
<a name="l00222"></a>00222 
<a name="l00223"></a>00223   <span class="comment">/* Initialize all the &apos;Value&apos; variables */</span>
<a name="l00224"></a>00224   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(a1); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(a2); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(gcd);
<a name="l00225"></a>00225   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(abs_a1); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(abs_a2); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(neg_a1);
<a name="l00226"></a>00226   
<a name="l00227"></a>00227   <span class="comment">/* a1 = p1[pos] */</span>
<a name="l00228"></a>00228   <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(a1,p1[pos]); 
<a name="l00229"></a>00229 
<a name="l00230"></a>00230   <span class="comment">/* a2 = p2[pos] */</span>
<a name="l00231"></a>00231   <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(a2,p2[pos]); 
<a name="l00232"></a>00232 
<a name="l00233"></a>00233   <span class="comment">/* a1_abs = |a1| */</span>
<a name="l00234"></a>00234   <a class="code" href="source_2arith_2arithmetique_8h.html#a6eee595d027bdf64a6c529b5f138720f">value_absolute</a>(abs_a1,a1);
<a name="l00235"></a>00235   
<a name="l00236"></a>00236   <span class="comment">/* a2_abs = |a2| */</span>
<a name="l00237"></a>00237   <a class="code" href="source_2arith_2arithmetique_8h.html#a6eee595d027bdf64a6c529b5f138720f">value_absolute</a>(abs_a2,a2);
<a name="l00238"></a>00238 
<a name="l00239"></a>00239   <span class="comment">/* gcd  = Gcd(abs(a1), abs(a2)) */</span>
<a name="l00240"></a>00240   <a class="code" href="source_2arith_2arithmetique_8h.html#a50a34e78517e58cd1c2494a99be1e62b">value_gcd</a>(gcd, abs_a1, abs_a2);
<a name="l00241"></a>00241 
<a name="l00242"></a>00242   <span class="comment">/* a1 = a1/gcd */</span>
<a name="l00243"></a>00243   <a class="code" href="source_2arith_2arithmetique_8h.html#a4b01d50506e0c7691b69d57a87280f5d">value_divexact</a>(a1, a1, gcd);
<a name="l00244"></a>00244 
<a name="l00245"></a>00245   <span class="comment">/* a2 = a2/gcd */</span>
<a name="l00246"></a>00246   <a class="code" href="source_2arith_2arithmetique_8h.html#a4b01d50506e0c7691b69d57a87280f5d">value_divexact</a>(a2, a2, gcd);
<a name="l00247"></a>00247 
<a name="l00248"></a>00248   <span class="comment">/* neg_a1 = -(a1) */</span>
<a name="l00249"></a>00249   <a class="code" href="source_2arith_2arithmetique_8h.html#a0daf9a8ecdc14e7a274832b0d2add830">value_oppose</a>(neg_a1,a1);
<a name="l00250"></a>00250 
<a name="l00251"></a>00251   <a class="code" href="vector_8c.html#a4700bd41bb9179b23deb7ab9d80a463d">Vector_Combine</a>(p1+1,p2+1,p3+1,a2,neg_a1,length);
<a name="l00252"></a>00252   <a class="code" href="vector_8c.html#a9e3e9df020a7c7b0ad95baffed7ed5c9">Vector_Normalize</a>(p3+1,length);
<a name="l00253"></a>00253 
<a name="l00254"></a>00254   <span class="comment">/* Clear all the &apos;Value&apos; variables */</span>
<a name="l00255"></a>00255   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(a1); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(a2); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(gcd);
<a name="l00256"></a>00256   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(abs_a1); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(abs_a2); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(neg_a1);    
<a name="l00257"></a>00257   
<a name="l00258"></a>00258   <span class="keywordflow">return</span>;
<a name="l00259"></a>00259 } <span class="comment">/* Combine */</span>
<a name="l00260"></a>00260 
<a name="l00261"></a>00261 <span class="comment">/* </span>
<a name="l00262"></a>00262 <span class="comment"> * Return the transpose of the saturation matrix &apos;Sat&apos;. &apos;Mat&apos; is a matrix</span>
<a name="l00263"></a>00263 <span class="comment"> * of constraints and &apos;Ray&apos; is a matrix of ray vectors and &apos;Sat&apos; is the </span>
<a name="l00264"></a>00264 <span class="comment"> * corresponding saturation matrix. </span>
<a name="l00265"></a>00265 <span class="comment"> */</span>
<a name="l00266"></a><a class="code" href="polyhedron_8c.html#ae90f313a0b016d966ced7e9bf09bc4f1">00266</a> <span class="keyword">static</span> <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyhedron_8c.html#ae90f313a0b016d966ced7e9bf09bc4f1">TransformSat</a>(<a class="code" href="structmatrix.html">Matrix</a> *Mat, <a class="code" href="structmatrix.html">Matrix</a> *Ray, <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a>) { 
<a name="l00267"></a>00267   
<a name="l00268"></a>00268   <span class="keywordtype">int</span> i, j, sat_nbcolumns;
<a name="l00269"></a>00269   <span class="keywordtype">unsigned</span> jx1, jx2, bx1, bx2;
<a name="l00270"></a>00270   <a class="code" href="structSatMatrix.html">SatMatrix</a> *result;
<a name="l00271"></a>00271 
<a name="l00272"></a>00272   <span class="keywordflow">if</span> (Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> != 0) 
<a name="l00273"></a>00273     sat_nbcolumns = (Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>-1) /(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>)*8) + 1;
<a name="l00274"></a>00274   <span class="keywordflow">else</span>                  
<a name="l00275"></a>00275     sat_nbcolumns = 0;
<a name="l00276"></a>00276 
<a name="l00277"></a>00277   result = <a class="code" href="polyhedron_8c.html#a010deaa3d3f81aaa979f67bb0012d109">SMAlloc</a>(Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>, sat_nbcolumns);
<a name="l00278"></a>00278   <a class="code" href="polyhedron_8c.html#a3351961690e2b071105b7bb4be0b7127">SMVector_Init</a>(result-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a>, Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> * sat_nbcolumns);
<a name="l00279"></a>00279 
<a name="l00280"></a>00280   <span class="keywordflow">for</span>(i=0,jx1=0,bx1=<a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>; i&lt;Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) { 
<a name="l00281"></a>00281     <span class="keywordflow">for</span>(j=0,jx2=0,bx2=<a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>; j&lt;Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>; j++) { 
<a name="l00282"></a>00282       <span class="keywordflow">if</span> (Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[j][jx1] &amp; bx1) 
<a name="l00283"></a>00283         result-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][jx2] |= bx2;
<a name="l00284"></a>00284       <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(jx2,bx2);
<a name="l00285"></a>00285     }
<a name="l00286"></a>00286     <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(jx1, bx1);
<a name="l00287"></a>00287   }
<a name="l00288"></a>00288   <span class="keywordflow">return</span> result;
<a name="l00289"></a>00289 } <span class="comment">/* TransformSat */</span>
<a name="l00290"></a>00290 
<a name="l00291"></a>00291 <span class="comment">/* </span>
<a name="l00292"></a>00292 <span class="comment"> * Sort the rays (Ray, Sat) into three tiers as used in &apos;Chernikova&apos; function:</span>
<a name="l00293"></a>00293 <span class="comment"> * NbBid         &lt;= i &lt;  equal_bound    : saturates the constraint</span>
<a name="l00294"></a>00294 <span class="comment"> * equal_bound   &lt;= i &lt;  sup_bound      : verifies the constraint</span>
<a name="l00295"></a>00295 <span class="comment"> * sup_bound     &lt;= i &lt;  NbRay          : does not verify </span>
<a name="l00296"></a>00296 <span class="comment"> *</span>
<a name="l00297"></a>00297 <span class="comment"> * &apos;Ray&apos; is the matrix of rays and &apos;Sat&apos; is the corresponding saturation </span>
<a name="l00298"></a>00298 <span class="comment"> * matrix. (jx,bx) pair specify the constraint in the saturation matrix. The</span>
<a name="l00299"></a>00299 <span class="comment"> * status element of the &apos;Ray&apos; matrix holds the saturation value w.r.t the </span>
<a name="l00300"></a>00300 <span class="comment"> * constraint specified by (jx,bx). Thus</span>
<a name="l00301"></a>00301 <span class="comment"> * Ray-&gt;p[i][0]  = 0 -&gt; ray(i) saturates the constraint</span>
<a name="l00302"></a>00302 <span class="comment"> * Ray-&gt;p[i][0]  &gt; 0 -&gt; ray(i) verifies  the constraint</span>
<a name="l00303"></a>00303 <span class="comment"> * Ray-&gt;p[i][0]  &lt; 0 -&gt; ray(i) doesn&apos;t verify the constraint  </span>
<a name="l00304"></a>00304 <span class="comment"> */</span>  
<a name="l00305"></a><a class="code" href="polyhedron_8c.html#af5d9c54095ce4ad550db5d9f0686233f">00305</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#af5d9c54095ce4ad550db5d9f0686233f">RaySort</a>(<a class="code" href="structmatrix.html">Matrix</a> *Ray,<a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a>,<span class="keywordtype">int</span> NbBid,<span class="keywordtype">int</span> NbRay,<span class="keywordtype">int</span> *equal_bound,<span class="keywordtype">int</span> *sup_bound,<span class="keywordtype">unsigned</span> RowSize1, <span class="keywordtype">unsigned</span> RowSize2, <span class="keywordtype">unsigned</span> bx, <span class="keywordtype">unsigned</span> jx) {                     
<a name="l00306"></a>00306 
<a name="l00307"></a>00307   <span class="keywordtype">int</span> inf_bound;
<a name="l00308"></a>00308   Value **uni_eq, **uni_sup, **uni_inf;
<a name="l00309"></a>00309   <span class="keywordtype">int</span> **inc_eq, **inc_sup, **inc_inf;
<a name="l00310"></a>00310 
<a name="l00311"></a>00311   <span class="comment">/* &apos;uni_eq&apos; points to the first ray in the ray matrix which verifies a</span>
<a name="l00312"></a>00312 <span class="comment">   * constraint, &apos;inc_eq&apos; is the corresponding pointer in saturation </span>
<a name="l00313"></a>00313 <span class="comment">   * matrix. &apos;uni_inf&apos; points to the first ray (from top) which doesn&apos;t </span>
<a name="l00314"></a>00314 <span class="comment">   * verify a constraint, &apos;inc_inf&apos; is the corresponding pointer in </span>
<a name="l00315"></a>00315 <span class="comment">   * saturation matrix. &apos;uni_sup&apos; scans the ray matrix and &apos;inc_sup&apos; is </span>
<a name="l00316"></a>00316 <span class="comment">   * the corresponding pointer in saturation matrix. &apos;inf_bound&apos; holds the </span>
<a name="l00317"></a>00317 <span class="comment">   * number of the first ray which does not verify the constraints. </span>
<a name="l00318"></a>00318 <span class="comment">   */</span>
<a name="l00319"></a>00319 
<a name="l00320"></a>00320   *sup_bound = *equal_bound = NbBid;
<a name="l00321"></a>00321   uni_sup = uni_eq = Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>+NbBid;
<a name="l00322"></a>00322   inc_sup = inc_eq = Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>+NbBid;
<a name="l00323"></a>00323   inf_bound = NbRay;
<a name="l00324"></a>00324   uni_inf = Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>+NbRay;
<a name="l00325"></a>00325   inc_inf = Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>+NbRay;
<a name="l00326"></a>00326   
<a name="l00327"></a>00327   <span class="keywordflow">while</span> (inf_bound&gt;*sup_bound) {
<a name="l00328"></a>00328     <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(**uni_sup)) {               <span class="comment">/* status = satisfy */</span>
<a name="l00329"></a>00329       <span class="keywordflow">if</span> (inc_eq != inc_sup) {
<a name="l00330"></a>00330         <a class="code" href="vector_8c.html#a88f4d69371f16d6d28e8a87c496b0730">Vector_Exchange</a>(*uni_eq,*uni_sup,RowSize1);
<a name="l00331"></a>00331         <a class="code" href="polyhedron_8c.html#ab15f1c639db2248c48f7a822c0d51665">bexchange</a>(*inc_eq,*inc_sup,RowSize2);
<a name="l00332"></a>00332       }
<a name="l00333"></a>00333       (*equal_bound)++; uni_eq++; inc_eq++;
<a name="l00334"></a>00334       (*sup_bound)++; uni_sup++; inc_sup++;
<a name="l00335"></a>00335     }
<a name="l00336"></a>00336     <span class="keywordflow">else</span> {
<a name="l00337"></a>00337       *((*inc_sup)+jx)|=bx;
<a name="l00338"></a>00338       
<a name="l00339"></a>00339       <span class="comment">/* if (**uni_sup&lt;0) */</span>
<a name="l00340"></a>00340       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#af031da52c8a160fd1ee6e4c793f8c78a">value_neg_p</a>(**uni_sup)) {             <span class="comment">/* Status != verify  */</span>
<a name="l00341"></a>00341         inf_bound--; uni_inf--; inc_inf--;
<a name="l00342"></a>00342         <span class="keywordflow">if</span> (inc_inf != inc_sup) {
<a name="l00343"></a>00343           <a class="code" href="vector_8c.html#a88f4d69371f16d6d28e8a87c496b0730">Vector_Exchange</a>(*uni_inf,*uni_sup,RowSize1);
<a name="l00344"></a>00344           <a class="code" href="polyhedron_8c.html#ab15f1c639db2248c48f7a822c0d51665">bexchange</a>(*inc_inf,*inc_sup,RowSize2);
<a name="l00345"></a>00345         }
<a name="l00346"></a>00346       }
<a name="l00347"></a>00347       <span class="keywordflow">else</span> {                                     <span class="comment">/* status == verify */</span>
<a name="l00348"></a>00348          (*sup_bound)++; uni_sup++; inc_sup++;
<a name="l00349"></a>00349       } 
<a name="l00350"></a>00350     }
<a name="l00351"></a>00351   }
<a name="l00352"></a>00352 } <span class="comment">/* RaySort */</span> 
<a name="l00353"></a>00353 
<a name="l00354"></a><a class="code" href="polyhedron_8c.html#a5ac9c35c3c66e939e06110aca9a66590">00354</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#a5ac9c35c3c66e939e06110aca9a66590">SatMatrix_Extend</a>(<a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a>, <a class="code" href="structmatrix.html">Matrix</a>* Mat, <span class="keywordtype">unsigned</span> rows)
<a name="l00355"></a>00355 {
<a name="l00356"></a>00356   <span class="keywordtype">int</span> i;
<a name="l00357"></a>00357   <span class="keywordtype">unsigned</span> cols;
<a name="l00358"></a>00358   cols = (Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> - 1)/(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>)*8) + 1;
<a name="l00359"></a>00359 
<a name="l00360"></a>00360   Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a> = (<span class="keywordtype">int</span> **)realloc(Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>, rows * <span class="keyword">sizeof</span>(<span class="keywordtype">int</span> *));
<a name="l00361"></a>00361   <span class="keywordflow">if</span>(!Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>) {
<a name="l00362"></a>00362     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;SatMatrix_Extend&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l00363"></a>00363     <span class="keywordflow">return</span>;
<a name="l00364"></a>00364   }
<a name="l00365"></a>00365   Sat-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a> = (<span class="keywordtype">int</span> *)realloc(Sat-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a>, rows * cols * sizeof (<span class="keywordtype">int</span>));
<a name="l00366"></a>00366   <span class="keywordflow">if</span>(!Sat-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a>) {
<a name="l00367"></a>00367     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;SatMatrix_Extend&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l00368"></a>00368     <span class="keywordflow">return</span>;
<a name="l00369"></a>00369   }
<a name="l00370"></a>00370   <span class="keywordflow">for</span> (i = 0; i &lt; rows; ++i)
<a name="l00371"></a>00371     Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i] = Sat-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a> + (i * cols);
<a name="l00372"></a>00372   Sat-&gt;<a class="code" href="structSatMatrix.html#a08d0db0d2eda3b8bdcc316eabadaca09">NbRows</a> = rows;
<a name="l00373"></a>00373 }
<a name="l00374"></a>00374 
<a name="l00375"></a>00375 <span class="comment">/* </span>
<a name="l00376"></a>00376 <span class="comment"> * Compute the dual of matrix &apos;Mat&apos; and place it in matrix &apos;Ray&apos;.&apos;Mat&apos; </span>
<a name="l00377"></a>00377 <span class="comment"> * contains the constraints (equalities and inequalities) in rows and &apos;Ray&apos; </span>
<a name="l00378"></a>00378 <span class="comment"> * contains the ray space (lines and rays) in its rows. &apos;Sat&apos; is a boolean </span>
<a name="l00379"></a>00379 <span class="comment"> * saturation matrix defined as Sat(i,j)=0 if ray(i) saturates constraint(j),</span>
<a name="l00380"></a>00380 <span class="comment"> *  otherwise 1. The constraints in the &apos;Mat&apos; matrix are processed starting at</span>
<a name="l00381"></a>00381 <span class="comment"> * &apos;FirstConstraint&apos;, &apos;Ray&apos; and &apos;Sat&apos; matrices are changed accordingly.&apos;NbBid&apos;</span>
<a name="l00382"></a>00382 <span class="comment"> * is the number of lines in the ray matrix and &apos;NbMaxRays&apos; is the maximum </span>
<a name="l00383"></a>00383 <span class="comment"> * number of rows (rays) permissible in the &apos;Ray&apos; and &apos;Sat&apos; matrix. Return 0 </span>
<a name="l00384"></a>00384 <span class="comment"> * if successful, otherwise return 1.  </span>
<a name="l00385"></a>00385 <span class="comment"> */</span>     
<a name="l00386"></a><a class="code" href="polyhedron_8c.html#a6138e0e907fa19ecc60710b1ab1868c1">00386</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="polyhedron_8c.html#a6138e0e907fa19ecc60710b1ab1868c1">Chernikova</a> (<a class="code" href="structmatrix.html">Matrix</a> *Mat,<a class="code" href="structmatrix.html">Matrix</a> *Ray,<a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a>, <span class="keywordtype">unsigned</span> NbBid, <span class="keywordtype">unsigned</span> NbMaxRays, <span class="keywordtype">unsigned</span> FirstConstraint,<span class="keywordtype">unsigned</span> dual) {
<a name="l00387"></a>00387 
<a name="l00388"></a>00388   <span class="keywordtype">unsigned</span> NbRay, Dimension, NbConstraints, RowSize1, RowSize2, sat_nbcolumns;
<a name="l00389"></a>00389   <span class="keywordtype">int</span> sup_bound, equal_bound, index_non_zero, bound;
<a name="l00390"></a>00390   <span class="keywordtype">int</span> i, j, k, l, redundant, rayonly, nbcommonconstraints;
<a name="l00391"></a>00391   <span class="keywordtype">int</span> *Temp, aux;
<a name="l00392"></a>00392   <span class="keywordtype">int</span> *ip1, *ip2;
<a name="l00393"></a>00393   <span class="keywordtype">unsigned</span> bx, <a class="code" href="polyparam_8c.html#a742204794ea328ba293fe59cec79b990">m</a>, jx;
<a name="l00394"></a>00394   Value *p1, *p2, *p3;
<a name="l00395"></a>00395 
<a name="l00396"></a>00396 <span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00397"></a>00397 <span class="preprocessor"></span>  fprintf(stderr, <span class="stringliteral">&quot;[Chernikova: Input]\nRay = &quot;</span>);
<a name="l00398"></a>00398   <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l00399"></a>00399   fprintf(stderr, <span class="stringliteral">&quot;\nConstraints = &quot;</span>);
<a name="l00400"></a>00400   <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00401"></a>00401   fprintf(stderr, <span class="stringliteral">&quot;\nSat = &quot;</span>);
<a name="l00402"></a>00402   <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a>(Sat);
<a name="l00403"></a>00403 <span class="preprocessor">#endif</span>
<a name="l00404"></a>00404 <span class="preprocessor"></span>  
<a name="l00405"></a>00405   NbConstraints=Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l00406"></a>00406   NbRay = Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l00407"></a>00407   Dimension = Mat-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1;         <span class="comment">/* Homogeneous Dimension */</span>
<a name="l00408"></a>00408   sat_nbcolumns=Sat-&gt;<a class="code" href="structSatMatrix.html#a20a0299b3d86f4c26a22faed4aaea6fd">NbColumns</a>;
<a name="l00409"></a>00409   
<a name="l00410"></a>00410   RowSize1=(Dimension+1);
<a name="l00411"></a>00411   RowSize2=sat_nbcolumns * <span class="keyword">sizeof</span>(int);
<a name="l00412"></a>00412 
<a name="l00413"></a>00413   Temp=(<span class="keywordtype">int</span> *)malloc(RowSize2);
<a name="l00414"></a>00414   <span class="keywordflow">if</span>(!Temp) {   
<a name="l00415"></a>00415     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Chernikova&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l00416"></a>00416     <span class="keywordflow">return</span> 0;
<a name="l00417"></a>00417   }
<a name="l00418"></a>00418   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l00419"></a>00419 
<a name="l00420"></a>00420   <span class="comment">/* </span>
<a name="l00421"></a>00421 <span class="comment">   * In case of overflow, free the allocated memory!</span>
<a name="l00422"></a>00422 <span class="comment">   * Rethrow upwards the stack to forward the exception.</span>
<a name="l00423"></a>00423 <span class="comment">   */</span>
<a name="l00424"></a>00424     free(Temp);
<a name="l00425"></a>00425     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l00426"></a>00426   }
<a name="l00427"></a>00427   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l00428"></a>00428     jx = FirstConstraint/<a class="code" href="polyhedron_8c.html#a7edb6b8a8c89cb564d6e1b85ed80e7db">WSIZE</a>;    
<a name="l00429"></a>00429     bx = <a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>; bx &gt;&gt;= FirstConstraint%<a class="code" href="polyhedron_8c.html#a7edb6b8a8c89cb564d6e1b85ed80e7db">WSIZE</a>;
<a name="l00430"></a>00430     <span class="keywordflow">for</span> (k=FirstConstraint; k&lt;NbConstraints; k++) {
<a name="l00431"></a>00431       
<a name="l00432"></a>00432       <span class="comment">/* Set the status word of each ray[i] to ray[i] dot constraint[k] */</span>
<a name="l00433"></a>00433       <span class="comment">/* This is equivalent to evaluating each ray by the constraint[k] */</span>
<a name="l00434"></a>00434       <span class="comment">/* &apos;index_non_zero&apos; is assigned the smallest ray index which does */</span>
<a name="l00435"></a>00435       <span class="comment">/* not saturate the constraint.                                   */</span>
<a name="l00436"></a>00436       
<a name="l00437"></a>00437       index_non_zero = NbRay;
<a name="l00438"></a>00438       <span class="keywordflow">for</span> (i=0; i&lt;NbRay; i++) { 
<a name="l00439"></a>00439         p1 = Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i]+1;
<a name="l00440"></a>00440         p2 = Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k]+1;
<a name="l00441"></a>00441         p3 = Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i];
<a name="l00442"></a>00442         
<a name="l00443"></a>00443         <span class="comment">/* *p3 = *p1 * *p2 */</span>     
<a name="l00444"></a>00444         <a class="code" href="source_2arith_2arithmetique_8h.html#ac9986d34264874727344f666079e2294">value_multiply</a>(*p3,*p1,*p2);
<a name="l00445"></a>00445         p1++; p2++;
<a name="l00446"></a>00446         <span class="keywordflow">for</span> (j=1; j&lt;Dimension; j++) {   
<a name="l00447"></a>00447           
<a name="l00448"></a>00448           <span class="comment">/* *p3 +=  *p1 * *p2 */</span>
<a name="l00449"></a>00449           <a class="code" href="source_2arith_2arithmetique_8h.html#a9900fbd029b36f5887e587642a064a52">value_addmul</a>(*p3, *p1, *p2);
<a name="l00450"></a>00450           p1++; p2++;
<a name="l00451"></a>00451         }
<a name="l00452"></a>00452         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(*p3) &amp;&amp; (i&lt;index_non_zero)) 
<a name="l00453"></a>00453           index_non_zero=i;
<a name="l00454"></a>00454       }
<a name="l00455"></a>00455       
<a name="l00456"></a>00456 <span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00457"></a>00457 <span class="preprocessor"></span>      fprintf(stderr, <span class="stringliteral">&quot;[Chernikova: A]\nRay = &quot;</span>);
<a name="l00458"></a>00458       <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l00459"></a>00459       fprintf(stderr, <span class="stringliteral">&quot;\nConstraints = &quot;</span>);
<a name="l00460"></a>00460       <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00461"></a>00461       fprintf(stderr, <span class="stringliteral">&quot;\nSat = &quot;</span>);
<a name="l00462"></a>00462       <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a> (Sat);
<a name="l00463"></a>00463 <span class="preprocessor">#endif</span>
<a name="l00464"></a>00464 <span class="preprocessor"></span>      
<a name="l00465"></a>00465       <span class="comment">/* Find a bidirectional ray z such that cz &lt;&gt; 0 */</span>  
<a name="l00466"></a>00466       <span class="keywordflow">if</span> (index_non_zero&lt;NbBid) {
<a name="l00467"></a>00467         
<a name="l00468"></a>00468         <span class="comment">/* Discard index_non_zero bidirectional ray */</span>    
<a name="l00469"></a>00469         NbBid--;
<a name="l00470"></a>00470         <span class="keywordflow">if</span> (NbBid!=index_non_zero) 
<a name="l00471"></a>00471           <a class="code" href="vector_8c.html#a88f4d69371f16d6d28e8a87c496b0730">Vector_Exchange</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[index_non_zero],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbBid],RowSize1);       
<a name="l00472"></a>00472 
<a name="l00473"></a>00473 <span class="preprocessor">#ifdef POLY_CH_DEBUG    </span>
<a name="l00474"></a>00474 <span class="preprocessor"></span>        fprintf(stderr,<span class="stringliteral">&quot;************\n&quot;</span>);
<a name="l00475"></a>00475         <span class="keywordflow">for</span>(i=0;i&lt;RowSize1;i++) {
<a name="l00476"></a>00476           <a class="code" href="source_2arith_2arithmetique_8h.html#ad34605b56b571830b928b50a74d618b7">value_print</a>(stderr,<a class="code" href="types_8h.html#ae6f16bcd4a42ba51cbb003e3d1e1cde6">P_VALUE_FMT</a>,Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[index_non_zero][i]);
<a name="l00477"></a>00477         }  
<a name="l00478"></a>00478         fprintf(stderr,<span class="stringliteral">&quot;\n******\n&quot;</span>);
<a name="l00479"></a>00479         <span class="keywordflow">for</span>(i=0;i&lt;RowSize1;i++) {
<a name="l00480"></a>00480           <a class="code" href="source_2arith_2arithmetique_8h.html#ad34605b56b571830b928b50a74d618b7">value_print</a>(stderr,<a class="code" href="types_8h.html#ae6f16bcd4a42ba51cbb003e3d1e1cde6">P_VALUE_FMT</a>,Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbBid][i]);
<a name="l00481"></a>00481         }
<a name="l00482"></a>00482         fprintf(stderr,<span class="stringliteral">&quot;\n*******\n&quot;</span>);
<a name="l00483"></a>00483 <span class="preprocessor">#endif</span>
<a name="l00484"></a>00484 <span class="preprocessor"></span>
<a name="l00485"></a>00485         <span class="comment">/* Compute the new lineality space */</span>    
<a name="l00486"></a>00486         <span class="keywordflow">for</span> (i=0; i&lt;NbBid; i++)
<a name="l00487"></a>00487           <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0]))
<a name="l00488"></a>00488             <a class="code" href="polyhedron_8c.html#af4f5e2e459098eddbfbb7236162de68c">Combine</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbBid],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i],0,Dimension);
<a name="l00489"></a>00489 
<a name="l00490"></a>00490         <span class="comment">/* Add the positive part of index_non_zero bidirectional ray to  */</span>
<a name="l00491"></a>00491         <span class="comment">/* the set of unidirectional rays                                */</span>
<a name="l00492"></a>00492         
<a name="l00493"></a>00493         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#af031da52c8a160fd1ee6e4c793f8c78a">value_neg_p</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbBid][0])) {
<a name="l00494"></a>00494           p1=Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbBid]; 
<a name="l00495"></a>00495           <span class="keywordflow">for</span> (j=0;j&lt;Dimension+1; j++) { 
<a name="l00496"></a>00496             
<a name="l00497"></a>00497             <span class="comment">/* *p1 = - *p1 */</span>   
<a name="l00498"></a>00498             <a class="code" href="source_2arith_2arithmetique_8h.html#a0daf9a8ecdc14e7a274832b0d2add830">value_oppose</a>(*p1,*p1);
<a name="l00499"></a>00499             p1++; 
<a name="l00500"></a>00500           }
<a name="l00501"></a>00501         }
<a name="l00502"></a>00502         
<a name="l00503"></a>00503 <span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00504"></a>00504 <span class="preprocessor"></span>        fprintf(stderr, <span class="stringliteral">&quot;[Chernikova: B]\nRay = &quot;</span>);
<a name="l00505"></a>00505         Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>=NbRay;
<a name="l00506"></a>00506         <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l00507"></a>00507         fprintf(stderr, <span class="stringliteral">&quot;\nConstraints = &quot;</span>);
<a name="l00508"></a>00508         <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00509"></a>00509         fprintf(stderr, <span class="stringliteral">&quot;\nSat = &quot;</span>);
<a name="l00510"></a>00510         <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a>(Sat);
<a name="l00511"></a>00511 <span class="preprocessor">#endif</span>
<a name="l00512"></a>00512 <span class="preprocessor"></span>        
<a name="l00513"></a>00513         <span class="comment">/* Compute the new pointed cone */</span>
<a name="l00514"></a>00514         <span class="keywordflow">for</span> (i=NbBid+1; i&lt;NbRay; i++)
<a name="l00515"></a>00515           <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0]))
<a name="l00516"></a>00516             <a class="code" href="polyhedron_8c.html#af4f5e2e459098eddbfbb7236162de68c">Combine</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbBid],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i],0,Dimension);
<a name="l00517"></a>00517         
<a name="l00518"></a>00518         <span class="comment">/* Add the new ray */</span>
<a name="l00519"></a>00519         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][0])) { <span class="comment">/* Constraint is an inequality */</span> 
<a name="l00520"></a>00520           <span class="keywordflow">for</span> (j=0;j&lt;sat_nbcolumns;j++) {
<a name="l00521"></a>00521             Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[NbBid][j] = 0;     <span class="comment">/* Saturation vec for new ray */</span>
<a name="l00522"></a>00522           }
<a name="l00523"></a>00523           <span class="comment">/* The new ray saturates everything except last inequality */</span>
<a name="l00524"></a>00524           Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[NbBid][jx] |= bx;
<a name="l00525"></a>00525         }
<a name="l00526"></a>00526         <span class="keywordflow">else</span> {                        <span class="comment">/* Constraint is an equality */</span>
<a name="l00527"></a>00527           <span class="keywordflow">if</span> (--NbRay != NbBid) {
<a name="l00528"></a>00528             <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbRay],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbBid],Dimension+1);
<a name="l00529"></a>00529             <a class="code" href="polyhedron_8c.html#a224c6af52361d50af23a236949251a70">SMVector_Copy</a>(Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[NbRay],Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[NbBid],sat_nbcolumns);
<a name="l00530"></a>00530           }
<a name="l00531"></a>00531         }
<a name="l00532"></a>00532 
<a name="l00533"></a>00533 <span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00534"></a>00534 <span class="preprocessor"></span>        fprintf(stderr, <span class="stringliteral">&quot;[Chernikova: C]\nRay = &quot;</span>);
<a name="l00535"></a>00535         Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>=NbRay;
<a name="l00536"></a>00536         <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l00537"></a>00537         fprintf(stderr, <span class="stringliteral">&quot;\nConstraints = &quot;</span>);
<a name="l00538"></a>00538         <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00539"></a>00539         fprintf(stderr, <span class="stringliteral">&quot;\nSat = &quot;</span>);
<a name="l00540"></a>00540         <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a> (Sat);
<a name="l00541"></a>00541 <span class="preprocessor">#endif</span>
<a name="l00542"></a>00542 <span class="preprocessor"></span>
<a name="l00543"></a>00543       } 
<a name="l00544"></a>00544       <span class="keywordflow">else</span> {  <span class="comment">/* If the new constraint satisfies all the rays */</span>
<a name="l00545"></a>00545         <a class="code" href="polyhedron_8c.html#af5d9c54095ce4ad550db5d9f0686233f">RaySort</a>(Ray, Sat, NbBid, NbRay, &amp;equal_bound, &amp;sup_bound,
<a name="l00546"></a>00546                 RowSize1, RowSize2,bx,jx);
<a name="l00547"></a>00547         
<a name="l00548"></a>00548         <span class="comment">/* Sort the unidirectional rays into R0, R+, R- */</span>
<a name="l00549"></a>00549         <span class="comment">/* Ray </span>
<a name="l00550"></a>00550 <span class="comment">           NbRay-&gt; bound-&gt; ________</span>
<a name="l00551"></a>00551 <span class="comment">                           |  R-  |    R- ==&gt; ray.eq &lt; 0  (outside domain)</span>
<a name="l00552"></a>00552 <span class="comment">                     sup-&gt; |------|</span>
<a name="l00553"></a>00553 <span class="comment">                           |  R+  |    R+ ==&gt; ray.eq &gt; 0  (inside domain)</span>
<a name="l00554"></a>00554 <span class="comment">                   equal-&gt; |------|</span>
<a name="l00555"></a>00555 <span class="comment">                           |  R0  |    R0 ==&gt; ray.eq = 0  (on face of domain)</span>
<a name="l00556"></a>00556 <span class="comment">                   NbBid-&gt; |______|</span>
<a name="l00557"></a>00557 <span class="comment">        */</span>
<a name="l00558"></a>00558 
<a name="l00559"></a>00559 <span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00560"></a>00560 <span class="preprocessor"></span>        fprintf(stderr, <span class="stringliteral">&quot;[Chernikova: D]\nRay = &quot;</span>);
<a name="l00561"></a>00561         Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>=NbRay;
<a name="l00562"></a>00562         <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l00563"></a>00563         fprintf(stderr, <span class="stringliteral">&quot;\nConstraints = &quot;</span>);
<a name="l00564"></a>00564         <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00565"></a>00565         fprintf(stderr, <span class="stringliteral">&quot;\nSat = &quot;</span>);
<a name="l00566"></a>00566         <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a> (Sat);
<a name="l00567"></a>00567 <span class="preprocessor">#endif</span>
<a name="l00568"></a>00568 <span class="preprocessor"></span>
<a name="l00569"></a>00569         <span class="comment">/* Compute only the new pointed cone */</span>
<a name="l00570"></a>00570         bound=NbRay;
<a name="l00571"></a>00571         <span class="keywordflow">for</span> (i=equal_bound; i&lt;sup_bound; i++) <span class="comment">/* for all pairs of R- and R+ */</span>
<a name="l00572"></a>00572           <span class="keywordflow">for</span>(j=sup_bound; j&lt;bound; j++) {    
<a name="l00573"></a>00573             
<a name="l00574"></a>00574           <span class="comment">/*--------------------------------------------------------------*/</span>
<a name="l00575"></a>00575           <span class="comment">/* Count the set of constraints saturated by R+ and R- */</span>
<a name="l00576"></a>00576           <span class="comment">/* Includes equalities, inequalities and the positivity constraint */</span>
<a name="l00577"></a>00577           <span class="comment">/*-----------------------------------------------------------------*/</span>
<a name="l00578"></a>00578             
<a name="l00579"></a>00579             nbcommonconstraints = 0;
<a name="l00580"></a>00580             <span class="keywordflow">for</span> (l=0; l&lt;jx; l++) {
<a name="l00581"></a>00581               aux = Temp[l] = Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][l] | Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[j][l];
<a name="l00582"></a>00582               <span class="keywordflow">for</span> (m=<a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>; m!=0; m&gt;&gt;=1) 
<a name="l00583"></a>00583                 <span class="keywordflow">if</span> (!(aux&amp;m)) 
<a name="l00584"></a>00584                   nbcommonconstraints++;
<a name="l00585"></a>00585             }
<a name="l00586"></a>00586             aux = Temp[jx] =  Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][jx] | Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[j][jx];
<a name="l00587"></a>00587             <span class="keywordflow">for</span> (m=<a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>; m!=bx; m&gt;&gt;=1) 
<a name="l00588"></a>00588               <span class="keywordflow">if</span> (!(aux&amp;m)) 
<a name="l00589"></a>00589                 nbcommonconstraints++;      
<a name="l00590"></a>00590             rayonly = (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][Dimension])  &amp;&amp; 
<a name="l00591"></a>00591                        <a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][Dimension]) &amp;&amp; 
<a name="l00592"></a>00592                        (dual == 0));                
<a name="l00593"></a>00593             <span class="keywordflow">if</span>(rayonly)
<a name="l00594"></a>00594               nbcommonconstraints++;      <span class="comment">/* account for pos constr */</span>
<a name="l00595"></a>00595 
<a name="l00596"></a>00596           <span class="comment">/*-----------------------------------------------------------------*/</span>
<a name="l00597"></a>00597           <span class="comment">/* Adjacency Test : is combination [R-,R+] a non redundant ray?    */</span>
<a name="l00598"></a>00598           <span class="comment">/*-----------------------------------------------------------------*/</span>
<a name="l00599"></a>00599           
<a name="l00600"></a>00600             <span class="keywordflow">if</span> (nbcommonconstraints+NbBid&gt;=Dimension-2) { <span class="comment">/* Dimensionality check*/</span>
<a name="l00601"></a>00601               <span class="comment">/* Check whether a ray m saturates the same set of constraints */</span>
<a name="l00602"></a>00602               redundant=0;
<a name="l00603"></a>00603               <span class="keywordflow">for</span> (m=NbBid; m&lt;bound; m++) 
<a name="l00604"></a>00604                 <span class="keywordflow">if</span> ((m!=i)&amp;&amp;(m!=j)) {
<a name="l00605"></a>00605                   
<a name="l00606"></a>00606                   <span class="comment">/* Two rays (r+ r-) are never made redundant by a vertex */</span>
<a name="l00607"></a>00607                   <span class="comment">/* because the positivity constraint saturates both rays */</span>
<a name="l00608"></a>00608                   <span class="comment">/* but not the vertex                                    */</span>
<a name="l00609"></a>00609                   
<a name="l00610"></a>00610                   <span class="keywordflow">if</span> (rayonly &amp;&amp; <a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[m][Dimension]))
<a name="l00611"></a>00611                     <span class="keywordflow">continue</span>;
<a name="l00612"></a>00612 
<a name="l00613"></a>00613                   <span class="comment">/* (r+ r-) is redundant if there doesn&apos;t exist an equation */</span>
<a name="l00614"></a>00614                   <span class="comment">/* which saturates both r+ and r- but not rm.              */</span>
<a name="l00615"></a>00615                   
<a name="l00616"></a>00616                   ip1 = Temp;
<a name="l00617"></a>00617                   ip2 = Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[m];
<a name="l00618"></a>00618                   <span class="keywordflow">for</span> (l=0; l&lt;=jx; l++,ip2++,ip1++)
<a name="l00619"></a>00619                     <span class="keywordflow">if</span> (*ip2 &amp; ~*ip1) 
<a name="l00620"></a>00620                       <span class="keywordflow">break</span>;
<a name="l00621"></a>00621                   <span class="keywordflow">if</span> (l&gt;jx) { 
<a name="l00622"></a>00622                     redundant=1;
<a name="l00623"></a>00623                     <span class="keywordflow">break</span>;
<a name="l00624"></a>00624                   }
<a name="l00625"></a>00625                 }
<a name="l00626"></a>00626 
<a name="l00627"></a>00627 <span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00628"></a>00628 <span class="preprocessor"></span>              fprintf(stderr, <span class="stringliteral">&quot;[Chernikova: E]\nRay = &quot;</span>);
<a name="l00629"></a>00629               Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>=NbRay;
<a name="l00630"></a>00630               <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l00631"></a>00631               fprintf(stderr, <span class="stringliteral">&quot;\nConstraints = &quot;</span>);
<a name="l00632"></a>00632               <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00633"></a>00633               fprintf(stderr, <span class="stringliteral">&quot;\nSat = &quot;</span>);
<a name="l00634"></a>00634               <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a> (Sat);
<a name="l00635"></a>00635 <span class="preprocessor">#endif</span>
<a name="l00636"></a>00636 <span class="preprocessor"></span>              
<a name="l00637"></a>00637               <span class="comment">/*------------------------------------------------------------*/</span>
<a name="l00638"></a>00638               <span class="comment">/* Add new ray generated by [R+,R-]                           */</span>
<a name="l00639"></a>00639               <span class="comment">/*------------------------------------------------------------*/</span>
<a name="l00640"></a>00640             
<a name="l00641"></a>00641               <span class="keywordflow">if</span> (!redundant) {
<a name="l00642"></a>00642                 <span class="keywordflow">if</span> (NbRay==NbMaxRays) {
<a name="l00643"></a>00643                   NbMaxRays *= 2;
<a name="l00644"></a>00644                   Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> = NbRay;
<a name="l00645"></a>00645                   <a class="code" href="matrix_8c.html#a22b92aad923f05a327d06d761f0396e0">Matrix_Extend</a>(Ray, NbMaxRays);
<a name="l00646"></a>00646                   <a class="code" href="polyhedron_8c.html#a5ac9c35c3c66e939e06110aca9a66590">SatMatrix_Extend</a>(Sat, Mat, NbMaxRays);
<a name="l00647"></a>00647                 }
<a name="l00648"></a>00648                 
<a name="l00649"></a>00649                 <span class="comment">/* Compute the new ray */</span>
<a name="l00650"></a>00650                 <a class="code" href="polyhedron_8c.html#af4f5e2e459098eddbfbb7236162de68c">Combine</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbRay],0,Dimension);
<a name="l00651"></a>00651                 <a class="code" href="polyhedron_8c.html#ab878a4f79f7c6fa2c95321aa905a101e">SatVector_OR</a>(Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[j],Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i],Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[NbRay],sat_nbcolumns);
<a name="l00652"></a>00652                 Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[NbRay][jx] &amp;= ~bx;
<a name="l00653"></a>00653                 NbRay++;
<a name="l00654"></a>00654               }
<a name="l00655"></a>00655             }
<a name="l00656"></a>00656           }
<a name="l00657"></a>00657 
<a name="l00658"></a>00658 <span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00659"></a>00659 <span class="preprocessor"></span>        fprintf(stderr, 
<a name="l00660"></a>00660                 <span class="stringliteral">&quot;[Chernikova: F]\n&quot;</span>
<a name="l00661"></a>00661                 <span class="stringliteral">&quot;sup_bound=%d\n&quot;</span>
<a name="l00662"></a>00662                 <span class="stringliteral">&quot;equal_bound=%d\n&quot;</span>
<a name="l00663"></a>00663                 <span class="stringliteral">&quot;bound=%d\n&quot;</span>
<a name="l00664"></a>00664                 <span class="stringliteral">&quot;NbRay=%d\n&quot;</span>
<a name="l00665"></a>00665                 <span class="stringliteral">&quot;Dimension = %d\n&quot;</span>
<a name="l00666"></a>00666                 <span class="stringliteral">&quot;Ray = &quot;</span>,sup_bound,equal_bound,bound,NbRay,Dimension);
<a name="l00667"></a>00667 <span class="preprocessor">#endif</span>
<a name="l00668"></a>00668 <span class="preprocessor"></span><span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00669"></a>00669 <span class="preprocessor"></span>        Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>=NbRay;
<a name="l00670"></a>00670         fprintf(stderr, <span class="stringliteral">&quot;[Chernikova: F]:\nRay = &quot;</span>);
<a name="l00671"></a>00671         <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l00672"></a>00672 <span class="preprocessor">#endif</span>
<a name="l00673"></a>00673 <span class="preprocessor"></span>        
<a name="l00674"></a>00674         <span class="comment">/* Eliminates all non extremal rays */</span>
<a name="l00675"></a>00675         <span class="comment">/* j = (Mat-&gt;p[k][0]) ? */</span>
<a name="l00676"></a>00676         
<a name="l00677"></a>00677         j = (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][0])) ? 
<a name="l00678"></a>00678           sup_bound : equal_bound;
<a name="l00679"></a>00679         
<a name="l00680"></a>00680         i = NbRay;
<a name="l00681"></a>00681 <span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00682"></a>00682 <span class="preprocessor"></span>        fprintf(stderr, <span class="stringliteral">&quot;i = %d\nj = %d \n&quot;</span>, i, j);
<a name="l00683"></a>00683 <span class="preprocessor">#endif</span>
<a name="l00684"></a>00684 <span class="preprocessor"></span>        <span class="keywordflow">while</span> ((j&lt;bound)&amp;&amp;(i&gt;bound)) {
<a name="l00685"></a>00685           i--;
<a name="l00686"></a>00686           <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j],Dimension+1);
<a name="l00687"></a>00687           <a class="code" href="polyhedron_8c.html#a224c6af52361d50af23a236949251a70">SMVector_Copy</a>(Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i],Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[j],sat_nbcolumns);
<a name="l00688"></a>00688           j++;
<a name="l00689"></a>00689         }
<a name="l00690"></a>00690 
<a name="l00691"></a>00691 <span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00692"></a>00692 <span class="preprocessor"></span>        fprintf(stderr, <span class="stringliteral">&quot;i = %d\nj = %d \n&quot;</span>, i, j);
<a name="l00693"></a>00693         fprintf(stderr, 
<a name="l00694"></a>00694                 <span class="stringliteral">&quot;[Chernikova: F]\n&quot;</span>
<a name="l00695"></a>00695                 <span class="stringliteral">&quot;sup_bound=%d\n&quot;</span>
<a name="l00696"></a>00696                 <span class="stringliteral">&quot;equal_bound=%d\n&quot;</span>
<a name="l00697"></a>00697                 <span class="stringliteral">&quot;bound=%d\n&quot;</span>
<a name="l00698"></a>00698                 <span class="stringliteral">&quot;NbRay=%d\n&quot;</span>
<a name="l00699"></a>00699                 <span class="stringliteral">&quot;Dimension = %d\n&quot;</span>
<a name="l00700"></a>00700                 <span class="stringliteral">&quot;Ray = &quot;</span>,sup_bound,equal_bound,bound,NbRay, Dimension);
<a name="l00701"></a>00701 <span class="preprocessor">#endif</span>
<a name="l00702"></a>00702 <span class="preprocessor"></span><span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00703"></a>00703 <span class="preprocessor"></span>        Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>=NbRay;
<a name="l00704"></a>00704         fprintf(stderr, <span class="stringliteral">&quot;[Chernikova: G]\nRay = &quot;</span>); 
<a name="l00705"></a>00705         <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l00706"></a>00706 <span class="preprocessor">#endif  </span>
<a name="l00707"></a>00707 <span class="preprocessor"></span>        <span class="keywordflow">if</span> (j==bound) 
<a name="l00708"></a>00708           NbRay=i;
<a name="l00709"></a>00709         <span class="keywordflow">else</span> 
<a name="l00710"></a>00710           NbRay=j;
<a name="l00711"></a>00711       }
<a name="l00712"></a>00712       <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(jx,bx);
<a name="l00713"></a>00713     }    
<a name="l00714"></a>00714     Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>=NbRay;
<a name="l00715"></a>00715     Sat-&gt;<a class="code" href="structSatMatrix.html#a08d0db0d2eda3b8bdcc316eabadaca09">NbRows</a>=NbRay;
<a name="l00716"></a>00716     
<a name="l00717"></a>00717   } <span class="comment">/* End of TRY */</span>
<a name="l00718"></a>00718 
<a name="l00719"></a>00719   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l00720"></a>00720   free(Temp);
<a name="l00721"></a>00721   
<a name="l00722"></a>00722 <span class="preprocessor">#ifdef POLY_CH_DEBUG</span>
<a name="l00723"></a>00723 <span class="preprocessor"></span>  fprintf(stderr, <span class="stringliteral">&quot;[Chernikova: Output]\nRay = &quot;</span>);
<a name="l00724"></a>00724   <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l00725"></a>00725   fprintf(stderr, <span class="stringliteral">&quot;\nConstraints = &quot;</span>);
<a name="l00726"></a>00726   <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00727"></a>00727   fprintf(stderr, <span class="stringliteral">&quot;\nSat = &quot;</span>);
<a name="l00728"></a>00728   <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a> (Sat);
<a name="l00729"></a>00729 <span class="preprocessor">#endif</span>
<a name="l00730"></a>00730 <span class="preprocessor"></span>  
<a name="l00731"></a>00731   <span class="keywordflow">return</span> 0;
<a name="l00732"></a>00732 } <span class="comment">/* Chernikova */</span>
<a name="l00733"></a>00733 
<a name="l00734"></a><a class="code" href="polyhedron_8c.html#a20c6f331a707d14f3bfb3f6920b3221e">00734</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="polyhedron_8c.html#a20c6f331a707d14f3bfb3f6920b3221e">Gauss4</a>(Value **<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a>, <span class="keywordtype">int</span> NbEq, <span class="keywordtype">int</span> NbRows, <span class="keywordtype">int</span> Dimension)
<a name="l00735"></a>00735 {
<a name="l00736"></a>00736   <span class="keywordtype">int</span> i, j, k, pivot, Rank;
<a name="l00737"></a>00737   <span class="keywordtype">int</span> *column_index = NULL;
<a name="l00738"></a>00738   Value gcd;
<a name="l00739"></a>00739 
<a name="l00740"></a>00740   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(gcd);
<a name="l00741"></a>00741   column_index=(<span class="keywordtype">int</span> *)malloc(Dimension * <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));
<a name="l00742"></a>00742   <span class="keywordflow">if</span>(!column_index) {   
<a name="l00743"></a>00743     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Gauss&quot;</span>,<span class="stringliteral">&quot;outofmem&quot;</span>,<span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l00744"></a>00744     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(gcd);
<a name="l00745"></a>00745     <span class="keywordflow">return</span> 0;
<a name="l00746"></a>00746   }
<a name="l00747"></a>00747   Rank=0;
<a name="l00748"></a>00748   
<a name="l00749"></a>00749   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l00750"></a>00750     <span class="keywordflow">if</span> (column_index)
<a name="l00751"></a>00751       free(column_index);
<a name="l00752"></a>00752     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(gcd);
<a name="l00753"></a>00753     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l00754"></a>00754   }
<a name="l00755"></a>00755   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l00756"></a>00756     
<a name="l00757"></a>00757     <span class="keywordflow">for</span> (j=1; j&lt;=Dimension; j++) {   <span class="comment">/* for each column (except status) */</span>  
<a name="l00758"></a>00758       <span class="keywordflow">for</span> (i=Rank; i&lt;NbEq; i++)      <span class="comment">/* starting at diagonal, look down */</span>
<a name="l00759"></a>00759         
<a name="l00760"></a>00760         <span class="comment">/* if (Mat-&gt;p[i][j] != 0) */</span>
<a name="l00761"></a>00761         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(p[i][j])) 
<a name="l00762"></a>00762           <span class="keywordflow">break</span>;                    <span class="comment">/* Find the first non zero element  */</span>    
<a name="l00763"></a>00763       <span class="keywordflow">if</span> (i!=NbEq) {                <span class="comment">/* If a non-zero element is found?  */</span>
<a name="l00764"></a>00764         <span class="keywordflow">if</span> (i!=Rank)                <span class="comment">/* If it is found below the diagonal*/</span>
<a name="l00765"></a>00765           <a class="code" href="vector_8c.html#a88f4d69371f16d6d28e8a87c496b0730">Vector_Exchange</a>(p[Rank]+1,p[i]+1,Dimension);
<a name="l00766"></a>00766         
<a name="l00767"></a>00767         <span class="comment">/* Normalize the pivot row by dividing it by the gcd */</span>      
<a name="l00768"></a>00768         <span class="comment">/* gcd = Vector_Gcd(p[Rank]+1,Dimension) */</span>
<a name="l00769"></a>00769         <a class="code" href="vector_8c.html#a801486b45cadc8b9d22d99a79af91fa1">Vector_Gcd</a>(p[Rank]+1,Dimension,&amp;gcd);
<a name="l00770"></a>00770         
<a name="l00771"></a>00771         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#afee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(gcd, 2) &gt;= 0)
<a name="l00772"></a>00772           <a class="code" href="vector_8c.html#a95d6452a07b82054af71a14c686e66a8">Vector_AntiScale</a>(p[Rank]+1, p[Rank]+1, gcd, Dimension);
<a name="l00773"></a>00773         
<a name="l00774"></a>00774         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#af031da52c8a160fd1ee6e4c793f8c78a">value_neg_p</a>(p[Rank][j]))
<a name="l00775"></a>00775           <a class="code" href="vector_8c.html#ae572a02f9c8cd14b0ca8771c40dcaf75">Vector_Oppose</a>(p[Rank]+1, p[Rank]+1, Dimension);
<a name="l00776"></a>00776         
<a name="l00777"></a>00777         pivot=i;
<a name="l00778"></a>00778         <span class="keywordflow">for</span> (i=pivot+1; i&lt;NbEq; i++) {  <span class="comment">/* Zero out the rest of the column */</span>
<a name="l00779"></a>00779           
<a name="l00780"></a>00780           <span class="comment">/* if (Mat-&gt;p[i][j] != 0) */</span>
<a name="l00781"></a>00781           <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(p[i][j]))
<a name="l00782"></a>00782             <a class="code" href="polyhedron_8c.html#af4f5e2e459098eddbfbb7236162de68c">Combine</a>(p[i],p[Rank],p[i],j,Dimension);
<a name="l00783"></a>00783         }
<a name="l00784"></a>00784         
<a name="l00785"></a>00785         <span class="comment">/* For each row with non-zero entry Mat-&gt;p[Rank], store the column */</span>
<a name="l00786"></a>00786         <span class="comment">/* number &apos;j&apos; in &apos;column_index[Rank]&apos;. This information will be    */</span>
<a name="l00787"></a>00787         <span class="comment">/* useful in performing Gaussian elimination backward step.        */</span>
<a name="l00788"></a>00788         
<a name="l00789"></a>00789         column_index[Rank]=j;
<a name="l00790"></a>00790         Rank++;
<a name="l00791"></a>00791       }
<a name="l00792"></a>00792     } <span class="comment">/* end of Gaussian elimination forward step */</span>
<a name="l00793"></a>00793     
<a name="l00794"></a>00794     <span class="comment">/* Back Substitution -- normalize the system of equations */</span>
<a name="l00795"></a>00795     <span class="keywordflow">for</span> (k=Rank-1; k&gt;=0; k--) { 
<a name="l00796"></a>00796       j = column_index[k];
<a name="l00797"></a>00797 
<a name="l00798"></a>00798       <span class="comment">/* Normalize the equations */</span>
<a name="l00799"></a>00799       <span class="keywordflow">for</span> (i=0; i&lt;k; i++) { 
<a name="l00800"></a>00800         
<a name="l00801"></a>00801         <span class="comment">/* if (Mat-&gt;p[i][j] != 0) */</span>
<a name="l00802"></a>00802         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(p[i][j]))
<a name="l00803"></a>00803           <a class="code" href="polyhedron_8c.html#af4f5e2e459098eddbfbb7236162de68c">Combine</a>(p[i],p[k],p[i],j,Dimension);
<a name="l00804"></a>00804       }
<a name="l00805"></a>00805       
<a name="l00806"></a>00806       <span class="comment">/* Normalize the inequalities */</span>
<a name="l00807"></a>00807       <span class="keywordflow">for</span> (i=NbEq;i&lt;NbRows;i++) { 
<a name="l00808"></a>00808         
<a name="l00809"></a>00809         <span class="comment">/* if (Mat-&gt;p[i][j] != 0) */</span>
<a name="l00810"></a>00810         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(p[i][j]))
<a name="l00811"></a>00811           <a class="code" href="polyhedron_8c.html#af4f5e2e459098eddbfbb7236162de68c">Combine</a>(p[i],p[k],p[i],j,Dimension);
<a name="l00812"></a>00812       }
<a name="l00813"></a>00813     }
<a name="l00814"></a>00814   } <span class="comment">/* end of TRY */</span>
<a name="l00815"></a>00815   
<a name="l00816"></a>00816   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l00817"></a>00817   free(column_index), column_index = NULL;
<a name="l00818"></a>00818   
<a name="l00819"></a>00819   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(gcd);
<a name="l00820"></a>00820   <span class="keywordflow">return</span> Rank;
<a name="l00821"></a>00821 } <span class="comment">/* Gauss */</span>
<a name="l00822"></a>00822 
<a name="l00823"></a>00823 <span class="comment">/*  </span>
<a name="l00824"></a>00824 <span class="comment"> * Compute a minimal system of equations using Gausian elimination method.</span>
<a name="l00825"></a>00825 <span class="comment"> * &apos;Mat&apos; is a matrix of constraints in which the first &apos;Nbeq&apos; constraints</span>
<a name="l00826"></a>00826 <span class="comment"> * are equations. The dimension of the homogenous system is &apos;Dimension&apos;. </span>
<a name="l00827"></a>00827 <span class="comment"> * The function returns the rank of the matrix &apos;Mat&apos;. </span>
<a name="l00828"></a>00828 <span class="comment"> */</span>
<a name="l00829"></a><a class="code" href="polyhedron_8h.html#a671d2a19d0c376dec383521e78faa70a">00829</a> <span class="keywordtype">int</span> <a class="code" href="polyhedron_8c.html#a671d2a19d0c376dec383521e78faa70a">Gauss</a>(<a class="code" href="structmatrix.html">Matrix</a> *Mat, <span class="keywordtype">int</span> NbEq, <span class="keywordtype">int</span> Dimension)
<a name="l00830"></a>00830 {
<a name="l00831"></a>00831   <span class="keywordtype">int</span> Rank;
<a name="l00832"></a>00832 
<a name="l00833"></a>00833 <span class="preprocessor">#ifdef POLY_DEBUG</span>
<a name="l00834"></a>00834 <span class="preprocessor"></span>  fprintf(stderr, <span class="stringliteral">&quot;[Gauss : Input]\nRay =&quot;</span>);
<a name="l00835"></a>00835   <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00836"></a>00836 <span class="preprocessor">#endif</span>
<a name="l00837"></a>00837 <span class="preprocessor"></span>
<a name="l00838"></a>00838   Rank = <a class="code" href="polyhedron_8c.html#a20c6f331a707d14f3bfb3f6920b3221e">Gauss4</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>, NbEq, Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>, Dimension);
<a name="l00839"></a>00839 
<a name="l00840"></a>00840 <span class="preprocessor">#ifdef POLY_DEBUG</span>
<a name="l00841"></a>00841 <span class="preprocessor"></span>  fprintf(stderr, <span class="stringliteral">&quot;[Gauss : Output]\nRay =&quot;</span>);
<a name="l00842"></a>00842   <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00843"></a>00843 <span class="preprocessor">#endif</span>
<a name="l00844"></a>00844 <span class="preprocessor"></span>
<a name="l00845"></a>00845   <span class="keywordflow">return</span> Rank;
<a name="l00846"></a>00846 }
<a name="l00847"></a>00847 
<a name="l00848"></a>00848 <span class="comment">/*</span>
<a name="l00849"></a>00849 <span class="comment"> * Given &apos;Mat&apos; - a matrix of equations and inequalities, &apos;Ray&apos; - a matrix of </span>
<a name="l00850"></a>00850 <span class="comment"> * lines and rays, &apos;Sat&apos; - the corresponding saturation matrix, and &apos;Filter&apos;</span>
<a name="l00851"></a>00851 <span class="comment"> * - an array to mark (with 1) the non-redundant equalities and inequalities, </span>
<a name="l00852"></a>00852 <span class="comment"> * compute a polyhedron composed of &apos;Mat&apos; as constraint matrix and &apos;Ray&apos; as </span>
<a name="l00853"></a>00853 <span class="comment"> * ray matrix after reductions. This function is usually called as a follow</span>
<a name="l00854"></a>00854 <span class="comment"> * up to &apos;Chernikova&apos; to remove redundant constraints or rays.</span>
<a name="l00855"></a>00855 <span class="comment"> * Note: (1) &apos;Chernikova&apos; ensures that there are no redundant lines and rays. </span>
<a name="l00856"></a>00856 <span class="comment"> *       (2) The same function can be used with constraint and ray matrix used</span>
<a name="l00857"></a>00857 <span class="comment">  interchangbly.</span>
<a name="l00858"></a>00858 <span class="comment"> */</span> 
<a name="l00859"></a><a class="code" href="polyhedron_8c.html#a1288eb192e28147e2572f35ed3a82de3">00859</a> <span class="keyword">static</span> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a1288eb192e28147e2572f35ed3a82de3">Remove_Redundants</a>(<a class="code" href="structmatrix.html">Matrix</a> *Mat,<a class="code" href="structmatrix.html">Matrix</a> *Ray,<a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a>,<span class="keywordtype">unsigned</span> *Filter) { 
<a name="l00860"></a>00860   
<a name="l00861"></a>00861   <span class="keywordtype">int</span> i, j, k;
<a name="l00862"></a>00862   <span class="keywordtype">unsigned</span> Dimension, sat_nbcolumns, NbRay, NbConstraints, RowSize2,
<a name="l00863"></a>00863            *Trace = NULL, *bx = NULL, *jx = NULL, Dim_RaySpace, b;
<a name="l00864"></a>00864   <span class="keywordtype">unsigned</span> NbBid, NbUni, NbEq, NbIneq;
<a name="l00865"></a>00865   <span class="keywordtype">unsigned</span> NbBid2, NbUni2, NbEq2, NbIneq2;
<a name="l00866"></a>00866   <span class="keywordtype">int</span> Redundant;
<a name="l00867"></a>00867   <span class="keywordtype">int</span> aux, *temp2 = NULL;
<a name="l00868"></a>00868   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol = NULL;
<a name="l00869"></a>00869   <a class="code" href="structVector.html">Vector</a> *temp1 = NULL;
<a name="l00870"></a>00870   <span class="keywordtype">unsigned</span> Status;
<a name="l00871"></a>00871   
<a name="l00872"></a>00872   Dimension = Mat-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1;     <span class="comment">/* Homogeneous Dimension */</span>
<a name="l00873"></a>00873   NbRay = Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l00874"></a>00874   sat_nbcolumns = Sat-&gt;<a class="code" href="structSatMatrix.html#a20a0299b3d86f4c26a22faed4aaea6fd">NbColumns</a>;
<a name="l00875"></a>00875   NbConstraints = Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l00876"></a>00876   RowSize2=sat_nbcolumns * <span class="keyword">sizeof</span>(int);
<a name="l00877"></a>00877   
<a name="l00878"></a>00878   temp1 = <a class="code" href="vector_8c.html#a358c545236f58b1001479e4a69d318aa">Vector_Alloc</a>(Dimension+1);
<a name="l00879"></a>00879   <span class="keywordflow">if</span> (!temp1) {
<a name="l00880"></a>00880     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Remove_Redundants&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l00881"></a>00881     <span class="keywordflow">return</span> 0;
<a name="l00882"></a>00882   }
<a name="l00883"></a>00883 
<a name="l00884"></a>00884   <span class="keywordflow">if</span> (Filter) {
<a name="l00885"></a>00885     temp2 = (<span class="keywordtype">int</span> *)calloc(sat_nbcolumns, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));
<a name="l00886"></a>00886     <span class="keywordflow">if</span> (!temp2)
<a name="l00887"></a>00887       <span class="keywordflow">goto</span> oom;
<a name="l00888"></a>00888   }
<a name="l00889"></a>00889   
<a name="l00890"></a>00890   <span class="comment">/* Introduce indirections into saturation matrix &apos;Sat&apos; to simplify */</span>
<a name="l00891"></a>00891   <span class="comment">/* processing with &apos;Sat&apos; and allow easy exchanges of columns.      */</span>
<a name="l00892"></a>00892   bx = (<span class="keywordtype">unsigned</span> *)malloc(NbConstraints * <span class="keyword">sizeof</span>(<span class="keywordtype">unsigned</span>));
<a name="l00893"></a>00893   <span class="keywordflow">if</span> (!bx)
<a name="l00894"></a>00894     <span class="keywordflow">goto</span> oom;
<a name="l00895"></a>00895   jx = (<span class="keywordtype">unsigned</span> *)malloc(NbConstraints * <span class="keyword">sizeof</span>(<span class="keywordtype">unsigned</span>));
<a name="l00896"></a>00896   <span class="keywordflow">if</span> (!jx)
<a name="l00897"></a>00897     <span class="keywordflow">goto</span> oom;
<a name="l00898"></a>00898   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {  
<a name="l00899"></a>00899     
<a name="l00900"></a>00900     <a class="code" href="vector_8c.html#a055608d1a3726b7cb26e3e8074764ba0">Vector_Free</a>(temp1);
<a name="l00901"></a>00901     <span class="keywordflow">if</span> (temp2) free(temp2);
<a name="l00902"></a>00902     <span class="keywordflow">if</span> (bx) free(bx);
<a name="l00903"></a>00903     <span class="keywordflow">if</span> (jx) free(jx);
<a name="l00904"></a>00904     <span class="keywordflow">if</span> (Trace) free(Trace);
<a name="l00905"></a>00905     <span class="keywordflow">if</span> (Pol) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol);
<a name="l00906"></a>00906 
<a name="l00907"></a>00907     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l00908"></a>00908   }
<a name="l00909"></a>00909   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l00910"></a>00910     
<a name="l00911"></a>00911     <span class="comment">/* For each constraint &apos;j&apos; following mapping is defined to facilitate  */</span>
<a name="l00912"></a>00912     <span class="comment">/* data access from saturation matrix &apos;Sat&apos; :-                         */</span>
<a name="l00913"></a>00913     <span class="comment">/* (1) jx[j] -&gt; floor[j/(8*sizeof(int))]                               */</span>
<a name="l00914"></a>00914     <span class="comment">/* (2) bx[j] -&gt; bin(00..10..0) where position of 1 = j%(8*sizeof(int)) */</span>
<a name="l00915"></a>00915     
<a name="l00916"></a>00916     i = 0;
<a name="l00917"></a>00917     b = <a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>;
<a name="l00918"></a>00918     <span class="keywordflow">for</span> (j=0; j&lt;NbConstraints; j++) { 
<a name="l00919"></a>00919       jx[j] = i;
<a name="l00920"></a>00920       bx[j] = b;
<a name="l00921"></a>00921       <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(i,b);
<a name="l00922"></a>00922     }
<a name="l00923"></a>00923     
<a name="l00924"></a>00924     <span class="comment">/* </span>
<a name="l00925"></a>00925 <span class="comment">     * STEP(0): Count the number of vertices among the rays while initializing</span>
<a name="l00926"></a>00926 <span class="comment">     * the ray status count to 0. If no vertices are found, quit the procedure</span>
<a name="l00927"></a>00927 <span class="comment">     * and return an empty polyhedron as the result. </span>
<a name="l00928"></a>00928 <span class="comment">     */</span>            
<a name="l00929"></a>00929     
<a name="l00930"></a>00930     <span class="comment">/* Reset the status element of each ray to zero. Store the number of  */</span>
<a name="l00931"></a>00931     <span class="comment">/* vertices in &apos;aux&apos;.                                                 */</span>
<a name="l00932"></a>00932     aux = 0;
<a name="l00933"></a>00933     <span class="keywordflow">for</span> (i=0; i&lt;NbRay; i++) {  
<a name="l00934"></a>00934       
<a name="l00935"></a>00935       <span class="comment">/* Ray-&gt;p[i][0] = 0 */</span>
<a name="l00936"></a>00936       <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0],0);
<a name="l00937"></a>00937       
<a name="l00938"></a>00938       <span class="comment">/* If ray(i) is a vertex of the Inhomogenous system */</span>
<a name="l00939"></a>00939       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][Dimension]))
<a name="l00940"></a>00940         aux++;              
<a name="l00941"></a>00941     }
<a name="l00942"></a>00942     
<a name="l00943"></a>00943     <span class="comment">/* If no vertices, return an empty polyhedron. */</span>
<a name="l00944"></a>00944     <span class="keywordflow">if</span> (!aux)
<a name="l00945"></a>00945       <span class="keywordflow">goto</span> empty;
<a name="l00946"></a>00946     
<a name="l00947"></a>00947 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l00948"></a>00948 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : Init]\nConstraints =&quot;</span>);
<a name="l00949"></a>00949     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00950"></a>00950     fprintf(stderr, <span class="stringliteral">&quot;\nRays =&quot;</span>);
<a name="l00951"></a>00951     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l00952"></a>00952 <span class="preprocessor">#endif</span>
<a name="l00953"></a>00953 <span class="preprocessor"></span>    
<a name="l00954"></a>00954     <span class="comment">/* </span>
<a name="l00955"></a>00955 <span class="comment">     * STEP(1): Compute status counts for both rays and inequalities. For each</span>
<a name="l00956"></a>00956 <span class="comment">     * constraint, count the number of vertices/rays saturated by that </span>
<a name="l00957"></a>00957 <span class="comment">     * constraint, and put the result in the status words. At the same time, </span>
<a name="l00958"></a>00958 <span class="comment">     * for each vertex/ray, count the number of constraints saturated by it.</span>
<a name="l00959"></a>00959 <span class="comment">     * Delete any positivity constraints, but give rays credit in their status</span>
<a name="l00960"></a>00960 <span class="comment">     * counts for saturating the positivity constraint.</span>
<a name="l00961"></a>00961 <span class="comment">     */</span>
<a name="l00962"></a>00962     
<a name="l00963"></a>00963     NbEq=0;
<a name="l00964"></a>00964     
<a name="l00965"></a>00965 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l00966"></a>00966 <span class="preprocessor"></span>    fprintf (stderr, <span class="stringliteral">&quot; j = &quot;</span>);
<a name="l00967"></a>00967 <span class="preprocessor">#endif</span>
<a name="l00968"></a>00968 <span class="preprocessor"></span>    
<a name="l00969"></a>00969     <span class="keywordflow">for</span> (j=0; j&lt;NbConstraints; j++) {
<a name="l00970"></a>00970       
<a name="l00971"></a>00971 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l00972"></a>00972 <span class="preprocessor"></span>      fprintf (stderr, <span class="stringliteral">&quot; %i &quot;</span>, j);
<a name="l00973"></a>00973       fflush (stderr);
<a name="l00974"></a>00974 <span class="preprocessor">#endif</span>
<a name="l00975"></a>00975 <span class="preprocessor"></span>      
<a name="l00976"></a>00976       <span class="comment">/* If constraint(j) is an equality, mark &apos;1&apos; in array &apos;temp2&apos; */</span>
<a name="l00977"></a>00977       <span class="keywordflow">if</span> (Filter &amp;&amp; <a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0]))  
<a name="l00978"></a>00978         temp2[jx[j]] |= bx[j]; 
<a name="l00979"></a>00979       <span class="comment">/* Reset the status element of each constraint to zero */</span>
<a name="l00980"></a>00980       <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0],0);
<a name="l00981"></a>00981       
<a name="l00982"></a>00982       <span class="comment">/* Identify and remove the positivity constraint 1&gt;=0 */</span>
<a name="l00983"></a>00983       i = <a class="code" href="vector_8c.html#ab719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j]+1, Dimension-1);
<a name="l00984"></a>00984       
<a name="l00985"></a>00985 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l00986"></a>00986 <span class="preprocessor"></span>      fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : IntoStep1]\nConstraints =&quot;</span>);
<a name="l00987"></a>00987       <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l00988"></a>00988       fprintf (stderr, <span class="stringliteral">&quot; j = %i \n&quot;</span>, j);
<a name="l00989"></a>00989 <span class="preprocessor">#endif</span>
<a name="l00990"></a>00990 <span class="preprocessor"></span>      
<a name="l00991"></a>00991       <span class="comment">/* Check if constraint(j) is a positivity constraint, 1 &gt;= 0, or if it */</span>
<a name="l00992"></a>00992       <span class="comment">/* is 1==0. If constraint(j) saturates all the rays of the matrix &apos;Ray&apos;*/</span>
<a name="l00993"></a>00993       <span class="comment">/* then it is an equality. in this case, return an empty polyhedron.   */</span>
<a name="l00994"></a>00994       
<a name="l00995"></a>00995       <span class="keywordflow">if</span> (i == -1) {
<a name="l00996"></a>00996         <span class="keywordflow">for</span> (i=0; i&lt;NbRay; i++)
<a name="l00997"></a>00997           <span class="keywordflow">if</span> (!(Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][jx[j]]&amp;bx[j])) {
<a name="l00998"></a>00998             
<a name="l00999"></a>00999             <span class="comment">/* Mat-&gt;p[j][0]++ */</span>
<a name="l01000"></a>01000             <a class="code" href="source_2arith_2arithmetique_8h.html#a88693f35dd41deddc6ac0700073fc8db">value_increment</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0],Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0]);
<a name="l01001"></a>01001           }
<a name="l01002"></a>01002         
<a name="l01003"></a>01003         <span class="comment">/* if ((Mat-&gt;p[j][0] == NbRay) &amp;&amp;   : it is an equality</span>
<a name="l01004"></a>01004 <span class="comment">           (Mat-&gt;p[j][Dimension] != 0)) : and its not 0=0 */</span>
<a name="l01005"></a>01005         <span class="keywordflow">if</span> ((<a class="code" href="source_2arith_2arithmetique_8h.html#afee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0], NbRay) == 0) &amp;&amp;
<a name="l01006"></a>01006             (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][Dimension])))
<a name="l01007"></a>01007           <span class="keywordflow">goto</span> empty;
<a name="l01008"></a>01008         
<a name="l01009"></a>01009         <span class="comment">/* Delete the positivity constraint */</span>
<a name="l01010"></a>01010         NbConstraints--;
<a name="l01011"></a>01011         <span class="keywordflow">if</span> (j==NbConstraints) <span class="keywordflow">continue</span>;
<a name="l01012"></a>01012         <a class="code" href="vector_8c.html#a88f4d69371f16d6d28e8a87c496b0730">Vector_Exchange</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j], Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbConstraints], temp1-&gt;Size);
<a name="l01013"></a>01013         <a class="code" href="polyhedron_8c.html#a8294d94a99fcebc56913f5eff14807e2">exchange</a>(jx[j], jx[NbConstraints], aux);
<a name="l01014"></a>01014         <a class="code" href="polyhedron_8c.html#a8294d94a99fcebc56913f5eff14807e2">exchange</a>(bx[j], bx[NbConstraints], aux);
<a name="l01015"></a>01015         j--; <span class="keywordflow">continue</span>;
<a name="l01016"></a>01016       }
<a name="l01017"></a>01017       
<a name="l01018"></a>01018       <span class="comment">/* Count the number of vertices/rays saturated by each constraint. At  */</span>
<a name="l01019"></a>01019       <span class="comment">/* the same time, count the number of constraints saturated by each ray*/</span>
<a name="l01020"></a>01020       <span class="keywordflow">for</span> (i=0; i&lt;NbRay; i++) 
<a name="l01021"></a>01021         <span class="keywordflow">if</span> (!(Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][jx[j]]&amp;bx[j])) {  
<a name="l01022"></a>01022           
<a name="l01023"></a>01023           <span class="comment">/* Mat-&gt;p[j][0]++ */</span>
<a name="l01024"></a>01024           <a class="code" href="source_2arith_2arithmetique_8h.html#a88693f35dd41deddc6ac0700073fc8db">value_increment</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0],Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0]);
<a name="l01025"></a>01025           
<a name="l01026"></a>01026           <span class="comment">/* Ray-&gt;p[i][0]++ */</span>
<a name="l01027"></a>01027           <a class="code" href="source_2arith_2arithmetique_8h.html#a88693f35dd41deddc6ac0700073fc8db">value_increment</a> (Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0]);
<a name="l01028"></a>01028         }
<a name="l01029"></a>01029       
<a name="l01030"></a>01030       <span class="comment">/* if (Mat-&gt;p[j][0]==NbRay) then increment the number of eq. count */</span>
<a name="l01031"></a>01031       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#afee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0], NbRay) == 0)
<a name="l01032"></a>01032         NbEq++;    <span class="comment">/* all vertices/rays are saturated */</span>
<a name="l01033"></a>01033     }
<a name="l01034"></a>01034     Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> = NbConstraints;
<a name="l01035"></a>01035     
<a name="l01036"></a>01036     NbBid=0;
<a name="l01037"></a>01037     <span class="keywordflow">for</span> (i=0; i&lt;NbRay; i++) {
<a name="l01038"></a>01038       
<a name="l01039"></a>01039       <span class="comment">/* Give rays credit for saturating the positivity constraint */</span>
<a name="l01040"></a>01040       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][Dimension]))   
<a name="l01041"></a>01041         
<a name="l01042"></a>01042         <span class="comment">/* Ray-&gt;p[i][0]++ */</span>
<a name="l01043"></a>01043         <a class="code" href="source_2arith_2arithmetique_8h.html#a88693f35dd41deddc6ac0700073fc8db">value_increment</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0],Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0]);
<a name="l01044"></a>01044       
<a name="l01045"></a>01045       <span class="comment">/* If ray(i) saturates all the constraints including positivity  */</span>
<a name="l01046"></a>01046       <span class="comment">/* constraint then it is a bi-directional ray or line. Increment */</span>
<a name="l01047"></a>01047       <span class="comment">/* &apos;NbBid&apos; by one.                                               */</span>
<a name="l01048"></a>01048       
<a name="l01049"></a>01049       <span class="comment">/* if (Ray-&gt;p[i][0]==NbConstraints+1) */</span>
<a name="l01050"></a>01050       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#afee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], NbConstraints+1) == 0)
<a name="l01051"></a>01051         NbBid++;
<a name="l01052"></a>01052     }
<a name="l01053"></a>01053     
<a name="l01054"></a>01054 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l01055"></a>01055 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : Step1]\nConstraints =&quot;</span>);
<a name="l01056"></a>01056     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l01057"></a>01057     fprintf(stderr, <span class="stringliteral">&quot;\nRay =&quot;</span>);
<a name="l01058"></a>01058     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l01059"></a>01059 <span class="preprocessor">#endif</span>
<a name="l01060"></a>01060 <span class="preprocessor"></span>    
<a name="l01061"></a>01061     <span class="comment">/* </span>
<a name="l01062"></a>01062 <span class="comment">     * STEP(2): Sort equalities to the top of constraint matrix &apos;Mat&apos;. Detect</span>
<a name="l01063"></a>01063 <span class="comment">     * implicit equations such as y&gt;=3; y&lt;=3. Keep Inequalities in same </span>
<a name="l01064"></a>01064 <span class="comment">     * relative order. (Note: Equalities are constraints which saturate all of</span>
<a name="l01065"></a>01065 <span class="comment">     * the rays)              </span>
<a name="l01066"></a>01066 <span class="comment">     */</span>
<a name="l01067"></a>01067     
<a name="l01068"></a>01068     <span class="keywordflow">for</span> (i=0; i&lt;NbEq; i++) {
<a name="l01069"></a>01069       
<a name="l01070"></a>01070       <span class="comment">/* If constraint(i) doesn&apos;t saturate some ray, then it is an inequality*/</span>
<a name="l01071"></a>01071       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#afee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], NbRay) != 0) {
<a name="l01072"></a>01072         
<a name="l01073"></a>01073         <span class="comment">/* Skip over inequalities and find an equality */</span>
<a name="l01074"></a>01074         <span class="keywordflow">for</span> (k=i+1; <a class="code" href="source_2arith_2arithmetique_8h.html#afee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][0], NbRay) != 0 &amp;&amp; k &lt; NbConstraints; k++)
<a name="l01075"></a>01075           ;
<a name="l01076"></a>01076         <span class="keywordflow">if</span> (k==NbConstraints) <span class="comment">/* If none found then error */</span> <span class="keywordflow">break</span>;
<a name="l01077"></a>01077         
<a name="l01078"></a>01078         <span class="comment">/* Slide inequalities down the array &apos;Mat&apos; and move equality up to */</span>
<a name="l01079"></a>01079         <span class="comment">/* position &apos;i&apos;.                                                   */</span>
<a name="l01080"></a>01080         <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k], temp1-&gt;p, temp1-&gt;Size);
<a name="l01081"></a>01081         aux = jx[k];
<a name="l01082"></a>01082         j   = bx[k];
<a name="l01083"></a>01083         <span class="keywordflow">for</span> (;k&gt;i;k--) {  
<a name="l01084"></a>01084           <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k-1], Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k], temp1-&gt;Size);
<a name="l01085"></a>01085           jx[k] = jx[k-1];
<a name="l01086"></a>01086           bx[k] = bx[k-1];
<a name="l01087"></a>01087         }
<a name="l01088"></a>01088         <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(temp1-&gt;p, Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], temp1-&gt;Size);
<a name="l01089"></a>01089         jx[i] = aux;
<a name="l01090"></a>01090         bx[i] = j;
<a name="l01091"></a>01091       }
<a name="l01092"></a>01092     }
<a name="l01093"></a>01093 
<a name="l01094"></a>01094     <span class="comment">/* for SIMPLIFY */</span>
<a name="l01095"></a>01095     <span class="keywordflow">if</span> (Filter) {
<a name="l01096"></a>01096       Value mone;
<a name="l01097"></a>01097       <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(mone);
<a name="l01098"></a>01098       <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(mone, -1);
<a name="l01099"></a>01099       <span class="comment">/* Normalize equalities to have lexpositive coefficients to</span>
<a name="l01100"></a>01100 <span class="comment">       * be able to detect identical equalities.</span>
<a name="l01101"></a>01101 <span class="comment">       */</span>
<a name="l01102"></a>01102       <span class="keywordflow">for</span> (i = 0; i &lt; NbEq; i++) {
<a name="l01103"></a>01103         <span class="keywordtype">int</span> pos = <a class="code" href="vector_8c.html#ab719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i]+1, Dimension);
<a name="l01104"></a>01104         <span class="keywordflow">if</span> (pos == -1)
<a name="l01105"></a>01105           <span class="keywordflow">continue</span>;
<a name="l01106"></a>01106         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#af031da52c8a160fd1ee6e4c793f8c78a">value_neg_p</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][1+pos]))
<a name="l01107"></a>01107           <a class="code" href="vector_8c.html#a14c75456dab7e1b9296fb4ec7b6ad3a5">Vector_Scale</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i]+1, Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i]+1, mone, Dimension);
<a name="l01108"></a>01108       }
<a name="l01109"></a>01109       <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(mone);
<a name="l01110"></a>01110       <span class="keywordflow">for</span> (i=0; i&lt;NbEq; i++) {
<a name="l01111"></a>01111         
<a name="l01112"></a>01112         <span class="comment">/* Detect implicit constraints such as y&gt;=3 and y&lt;=3 */</span>
<a name="l01113"></a>01113         Redundant = 0;
<a name="l01114"></a>01114         <span class="keywordflow">for</span> (j=i+1; j&lt;NbEq; j++) {
<a name="l01115"></a>01115           <span class="comment">/* Only check equalities, i.e., &apos;temp2&apos; has entry 1             */</span>
<a name="l01116"></a>01116           <span class="keywordflow">if</span> (!(temp2[jx[j]] &amp; bx[j]))
<a name="l01117"></a>01117             <span class="keywordflow">continue</span>;
<a name="l01118"></a>01118           <span class="comment">/* Redundant if both are same `and&apos; constraint(j) was equality. */</span>
<a name="l01119"></a>01119           <span class="keywordflow">if</span> (<a class="code" href="vector_8c.html#a29ed40e88da2f079a8fcd2b7b4c4dbeb">Vector_Equal</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i]+1, Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j]+1, Dimension)) {
<a name="l01120"></a>01120             Redundant=1; 
<a name="l01121"></a>01121             <span class="keywordflow">break</span>;
<a name="l01122"></a>01122           }
<a name="l01123"></a>01123         }
<a name="l01124"></a>01124         
<a name="l01125"></a>01125         <span class="comment">/* Set &apos;Filter&apos; entry to 1 corresponding to the irredundant equality*/</span>
<a name="l01126"></a>01126         <span class="keywordflow">if</span> (!Redundant) Filter[jx[i]] |= bx[i];  <span class="comment">/* set flag */</span>
<a name="l01127"></a>01127       }
<a name="l01128"></a>01128     }
<a name="l01129"></a>01129 
<a name="l01130"></a>01130 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l01131"></a>01131 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : Step2]\nConstraints =&quot;</span>);
<a name="l01132"></a>01132     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l01133"></a>01133     fprintf(stderr, <span class="stringliteral">&quot;\nRay =&quot;</span>);
<a name="l01134"></a>01134     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l01135"></a>01135 <span class="preprocessor">#endif</span>
<a name="l01136"></a>01136 <span class="preprocessor"></span>    
<a name="l01137"></a>01137     <span class="comment">/* </span>
<a name="l01138"></a>01138 <span class="comment">     * STEP(3): Perform Gaussian elimiation on the list of equalities. Obtain</span>
<a name="l01139"></a>01139 <span class="comment">     * a minimal basis by solving for as many variables as possible. Use this </span>
<a name="l01140"></a>01140 <span class="comment">     * solution to reduce the inequalities by eliminating as many variables as</span>
<a name="l01141"></a>01141 <span class="comment">     * possible. Set NbEq2 to the rank of the system of equalities.</span>
<a name="l01142"></a>01142 <span class="comment">     */</span>
<a name="l01143"></a>01143     
<a name="l01144"></a>01144     NbEq2 = <a class="code" href="polyhedron_8c.html#a671d2a19d0c376dec383521e78faa70a">Gauss</a>(Mat,NbEq,Dimension);
<a name="l01145"></a>01145     
<a name="l01146"></a>01146     <span class="comment">/* If number of equalities is not less then the homogenous dimension, */</span>
<a name="l01147"></a>01147     <span class="comment">/* return an empty polyhedron.                                        */</span>
<a name="l01148"></a>01148     
<a name="l01149"></a>01149     <span class="keywordflow">if</span> (NbEq2 &gt;= Dimension)
<a name="l01150"></a>01150       <span class="keywordflow">goto</span> empty;
<a name="l01151"></a>01151     
<a name="l01152"></a>01152 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l01153"></a>01153 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : Step3]\nConstraints =&quot;</span>);
<a name="l01154"></a>01154     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l01155"></a>01155     fprintf(stderr, <span class="stringliteral">&quot;\nRay =&quot;</span>);
<a name="l01156"></a>01156     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l01157"></a>01157 <span class="preprocessor">#endif</span>
<a name="l01158"></a>01158 <span class="preprocessor"></span>    
<a name="l01159"></a>01159     <span class="comment">/*</span>
<a name="l01160"></a>01160 <span class="comment">     * STEP(4): Sort lines to the top of ray matrix &apos;Ray&apos;, leaving rays</span>
<a name="l01161"></a>01161 <span class="comment">     * afterwards. Detect implicit lines such as ray(1,2) and ray(-1,-2). </span>
<a name="l01162"></a>01162 <span class="comment">     * (Note: Lines are rays which saturate all of the constraints including</span>
<a name="l01163"></a>01163 <span class="comment">     * the positivity constraint 1&gt;=0. </span>
<a name="l01164"></a>01164 <span class="comment">     */</span>
<a name="l01165"></a>01165     
<a name="l01166"></a>01166     
<a name="l01167"></a>01167     <span class="keywordflow">for</span> (i=0, k=NbRay; i&lt;NbBid &amp;&amp; k&gt;i; i++) {
<a name="l01168"></a>01168       <span class="comment">/* If ray(i) doesn&apos;t saturate some constraint then it is not a line */</span>
<a name="l01169"></a>01169       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#afee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], NbConstraints+1) != 0) {
<a name="l01170"></a>01170         
<a name="l01171"></a>01171         <span class="comment">/* Skip over rays and vertices and find a line (bi-directional rays) */</span>
<a name="l01172"></a>01172         <span class="keywordflow">while</span> (--k &gt; i &amp;&amp; <a class="code" href="source_2arith_2arithmetique_8h.html#afee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][0], NbConstraints+1) != 0)
<a name="l01173"></a>01173           ;
<a name="l01174"></a>01174         
<a name="l01175"></a>01175         <span class="comment">/* Exchange positions of ray(i) and line(k), thus sorting lines to */</span>
<a name="l01176"></a>01176         <span class="comment">/* the top of matrix &apos;Ray&apos;.                                        */</span>
<a name="l01177"></a>01177         <a class="code" href="vector_8c.html#a88f4d69371f16d6d28e8a87c496b0730">Vector_Exchange</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k], temp1-&gt;Size);
<a name="l01178"></a>01178         <a class="code" href="polyhedron_8c.html#ab15f1c639db2248c48f7a822c0d51665">bexchange</a>(Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i], Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[k], RowSize2);
<a name="l01179"></a>01179       }     
<a name="l01180"></a>01180     }   
<a name="l01181"></a>01181 
<a name="l01182"></a>01182 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l01183"></a>01183 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : Step4]\nConstraints =&quot;</span>);
<a name="l01184"></a>01184     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l01185"></a>01185     fprintf(stderr, <span class="stringliteral">&quot;\nRay =&quot;</span>);
<a name="l01186"></a>01186     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l01187"></a>01187 <span class="preprocessor">#endif</span>
<a name="l01188"></a>01188 <span class="preprocessor"></span>    
<a name="l01189"></a>01189     <span class="comment">/* </span>
<a name="l01190"></a>01190 <span class="comment">     * STEP(5): Perform Gaussian elimination on the lineality space to obtain</span>
<a name="l01191"></a>01191 <span class="comment">     * a minimal basis of lines. Use this basis to reduce the representation</span>
<a name="l01192"></a>01192 <span class="comment">     * of the uniderectional rays. Set &apos;NbBid2&apos; to the rank of the system of </span>
<a name="l01193"></a>01193 <span class="comment">     * lines. </span>
<a name="l01194"></a>01194 <span class="comment">     */</span>
<a name="l01195"></a>01195     
<a name="l01196"></a>01196     NbBid2 = <a class="code" href="polyhedron_8c.html#a671d2a19d0c376dec383521e78faa70a">Gauss</a>(Ray, NbBid, Dimension);
<a name="l01197"></a>01197     
<a name="l01198"></a>01198 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l01199"></a>01199 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : After Gauss]\nRay =&quot;</span>);
<a name="l01200"></a>01200     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l01201"></a>01201 <span class="preprocessor">#endif</span>
<a name="l01202"></a>01202 <span class="preprocessor"></span>    
<a name="l01203"></a>01203     <span class="comment">/* If number of lines is not less then the homogenous dimension, return */</span>
<a name="l01204"></a>01204     <span class="comment">/* an empty polyhedron.                                                 */</span>
<a name="l01205"></a>01205     <span class="keywordflow">if</span> (NbBid2&gt;=Dimension) {
<a name="l01206"></a>01206       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;RemoveRedundants&quot;</span>, <span class="stringliteral">&quot;rmrdt&quot;</span>, <span class="stringliteral">&quot;dimension error&quot;</span>);
<a name="l01207"></a>01207       <span class="keywordflow">goto</span> empty;
<a name="l01208"></a>01208     }
<a name="l01209"></a>01209     
<a name="l01210"></a>01210     <span class="comment">/* Compute dimension of non-homogenous ray space */</span>
<a name="l01211"></a>01211     Dim_RaySpace = Dimension-1-NbEq2-NbBid2;  
<a name="l01212"></a>01212     
<a name="l01213"></a>01213 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l01214"></a>01214 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : Step5]\nConstraints =&quot;</span>);
<a name="l01215"></a>01215     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l01216"></a>01216     fprintf(stderr, <span class="stringliteral">&quot;\nRay =&quot;</span>);
<a name="l01217"></a>01217     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l01218"></a>01218 <span class="preprocessor">#endif</span>
<a name="l01219"></a>01219 <span class="preprocessor"></span>    
<a name="l01220"></a>01220     <span class="comment">/* </span>
<a name="l01221"></a>01221 <span class="comment">     * STEP(6): Do a first pass filter of inequalities and equality identifi-</span>
<a name="l01222"></a>01222 <span class="comment">     * cation. New positivity constraints may have been created by step(3). </span>
<a name="l01223"></a>01223 <span class="comment">     * Check for and eliminate them. Count the irredundant inequalities and </span>
<a name="l01224"></a>01224 <span class="comment">     * store count in &apos;NbIneq&apos;.  </span>
<a name="l01225"></a>01225 <span class="comment">     */</span>
<a name="l01226"></a>01226  
<a name="l01227"></a>01227     NbIneq=0;
<a name="l01228"></a>01228     <span class="keywordflow">for</span> (j=0; j&lt;NbConstraints; j++) {
<a name="l01229"></a>01229       
<a name="l01230"></a>01230       <span class="comment">/* Identify and remove the positivity constraint 1&gt;=0 */</span>
<a name="l01231"></a>01231       i = <a class="code" href="vector_8c.html#ab719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j]+1, Dimension-1);
<a name="l01232"></a>01232       
<a name="l01233"></a>01233       <span class="comment">/* Check if constraint(j) is a positivity constraint, 1&gt;= 0, or if it */</span>
<a name="l01234"></a>01234       <span class="comment">/* is 1==0.                                                           */</span>
<a name="l01235"></a>01235       <span class="keywordflow">if</span> (i == -1) {
<a name="l01236"></a>01236         <span class="comment">/* if ((Mat-&gt;p[j][0]==NbRay) &amp;&amp;   : it is an equality </span>
<a name="l01237"></a>01237 <span class="comment">           (Mat-&gt;p[j][Dimension]!=0))    : and its not 0=0 */</span>
<a name="l01238"></a>01238         <span class="keywordflow">if</span> ((<a class="code" href="source_2arith_2arithmetique_8h.html#afee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0], NbRay) == 0) &amp;&amp;
<a name="l01239"></a>01239             (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][Dimension])))
<a name="l01240"></a>01240           <span class="keywordflow">goto</span> empty;
<a name="l01241"></a>01241         
<a name="l01242"></a>01242         <span class="comment">/* Set the positivity constraint redundant by setting status element */</span>
<a name="l01243"></a>01243         <span class="comment">/* equal to 2.                                                       */</span>
<a name="l01244"></a>01244         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0],2);
<a name="l01245"></a>01245         <span class="keywordflow">continue</span>;
<a name="l01246"></a>01246       }
<a name="l01247"></a>01247       
<a name="l01248"></a>01248       Status = VALUE_TO_INT(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0]);
<a name="l01249"></a>01249       
<a name="l01250"></a>01250       <span class="keywordflow">if</span> (Status == 0)  
<a name="l01251"></a>01251         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0], 2);  <span class="comment">/* constraint is redundant */</span>
<a name="l01252"></a>01252       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (Status &lt; Dim_RaySpace)   
<a name="l01253"></a>01253         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0], 2);  <span class="comment">/* constraint is redundant */</span>
<a name="l01254"></a>01254       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (Status == NbRay)         
<a name="l01255"></a>01255         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0], 0);  <span class="comment">/* constraint is an equality */</span>
<a name="l01256"></a>01256       <span class="keywordflow">else</span> { 
<a name="l01257"></a>01257         NbIneq++;                       <span class="comment">/* constraint is an irredundant inequality */</span> 
<a name="l01258"></a>01258         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0], 1);  <span class="comment">/* inequality */</span>
<a name="l01259"></a>01259       }
<a name="l01260"></a>01260     }
<a name="l01261"></a>01261     
<a name="l01262"></a>01262 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l01263"></a>01263 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : Step6]\nConstraints =&quot;</span>);
<a name="l01264"></a>01264     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l01265"></a>01265     fprintf(stderr, <span class="stringliteral">&quot;\nRay =&quot;</span>);
<a name="l01266"></a>01266     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l01267"></a>01267 <span class="preprocessor">#endif</span>
<a name="l01268"></a>01268 <span class="preprocessor"></span>    
<a name="l01269"></a>01269     <span class="comment">/* </span>
<a name="l01270"></a>01270 <span class="comment">     * STEP(7): Do a first pass filter of rays and identification of lines.</span>
<a name="l01271"></a>01271 <span class="comment">     * Count the irredundant Rays and store count in &apos;NbUni&apos;. </span>
<a name="l01272"></a>01272 <span class="comment">     */</span>
<a name="l01273"></a>01273     
<a name="l01274"></a>01274     NbUni=0;
<a name="l01275"></a>01275     <span class="keywordflow">for</span> (j=0; j&lt;NbRay; j++) { 
<a name="l01276"></a>01276       Status = VALUE_TO_INT(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0]);
<a name="l01277"></a>01277       
<a name="l01278"></a>01278       <span class="keywordflow">if</span> (Status &lt; Dim_RaySpace)        
<a name="l01279"></a>01279         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0], 2);  <span class="comment">/* ray is redundant */</span>
<a name="l01280"></a>01280       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (Status == NbConstraints+1) 
<a name="l01281"></a>01281         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0], 0);  <span class="comment">/* ray is a line */</span>
<a name="l01282"></a>01282       <span class="keywordflow">else</span> {
<a name="l01283"></a>01283         NbUni++;                        <span class="comment">/* an irredundant unidirectional ray. */</span>
<a name="l01284"></a>01284         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0], 1);  <span class="comment">/* ray */</span>
<a name="l01285"></a>01285       }
<a name="l01286"></a>01286     }
<a name="l01287"></a>01287     
<a name="l01288"></a>01288     <span class="comment">/*</span>
<a name="l01289"></a>01289 <span class="comment">     * STEP(8): Create the polyhedron (using approximate sizes).</span>
<a name="l01290"></a>01290 <span class="comment">     * Number of constraints = NbIneq + NbEq2 + 1</span>
<a name="l01291"></a>01291 <span class="comment">     * Number of rays = NbUni + NbBid2 </span>
<a name="l01292"></a>01292 <span class="comment">     * Partially fill the polyhedron structure with the lines computed in step</span>
<a name="l01293"></a>01293 <span class="comment">     * 3 and the equalities computed in step 5. </span>
<a name="l01294"></a>01294 <span class="comment">     */</span>
<a name="l01295"></a>01295     
<a name="l01296"></a>01296     Pol = <a class="code" href="polyhedron_8c.html#aa308ade6448cc5544e21d59e86a53ddf">Polyhedron_Alloc</a>(Dimension-1, NbIneq+NbEq2+1, NbUni+NbBid2);
<a name="l01297"></a>01297     <span class="keywordflow">if</span> (!Pol) {
<a name="l01298"></a>01298       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l01299"></a>01299       <span class="keywordflow">goto</span> oom;
<a name="l01300"></a>01300     }
<a name="l01301"></a>01301     Pol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a> = NbBid2;
<a name="l01302"></a>01302     Pol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>  = NbEq2;
<a name="l01303"></a>01303     
<a name="l01304"></a>01304     <span class="comment">/* Partially fill the polyhedron structure */</span>
<a name="l01305"></a>01305     <span class="keywordflow">if</span> (NbBid2) <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[0], Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[0], (Dimension+1)*NbBid2);
<a name="l01306"></a>01306     <span class="keywordflow">if</span> (NbEq2)  <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[0], Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], (Dimension+1)*NbEq2);
<a name="l01307"></a>01307     
<a name="l01308"></a>01308 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l01309"></a>01309 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : Step7]\nConstraints =&quot;</span>);
<a name="l01310"></a>01310     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l01311"></a>01311     fprintf(stderr, <span class="stringliteral">&quot;\nRay =&quot;</span>);
<a name="l01312"></a>01312     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l01313"></a>01313 <span class="preprocessor">#endif</span>
<a name="l01314"></a>01314 <span class="preprocessor"></span>    
<a name="l01315"></a>01315     <span class="comment">/* </span>
<a name="l01316"></a>01316 <span class="comment">     * STEP(9): Final Pass filter of inequalities and detection of redundant</span>
<a name="l01317"></a>01317 <span class="comment">     * inequalities. Redundant inequalities include: </span>
<a name="l01318"></a>01318 <span class="comment">     * (1) Inequalities which are always true, such as 1&gt;=0, </span>
<a name="l01319"></a>01319 <span class="comment">     * (2) Redundant inequalities such as y&gt;=4 given y&gt;=3, or x&gt;=1 given x=2. </span>
<a name="l01320"></a>01320 <span class="comment">     * (3) Redundant inequalities such as x+y&gt;=5 given x&gt;=3 and y&gt;=2.</span>
<a name="l01321"></a>01321 <span class="comment">     * Every &apos;good&apos; inequality must saturate at least &apos;Dimension&apos; rays and be </span>
<a name="l01322"></a>01322 <span class="comment">     * unique.</span>
<a name="l01323"></a>01323 <span class="comment">     */</span>
<a name="l01324"></a>01324     
<a name="l01325"></a>01325     <span class="comment">/* &apos;Trace&apos; is a (1 X sat_nbcolumns) row matrix to hold the union of all */</span>
<a name="l01326"></a>01326     <span class="comment">/* rows (corresponding to irredundant rays) of saturation matrix &apos;Sat&apos;  */</span>
<a name="l01327"></a>01327     <span class="comment">/* which saturate some constraint &apos;j&apos;. See figure below:-               */</span>
<a name="l01328"></a>01328     Trace=(<span class="keywordtype">unsigned</span> *)malloc(sat_nbcolumns * <span class="keyword">sizeof</span>(<span class="keywordtype">unsigned</span>));
<a name="l01329"></a>01329     <span class="keywordflow">if</span>(!Trace) {
<a name="l01330"></a>01330       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l01331"></a>01331       <span class="keywordflow">goto</span> oom;
<a name="l01332"></a>01332     }
<a name="l01333"></a>01333     
<a name="l01334"></a>01334     <span class="comment">/*                         NbEq      NbConstraints</span>
<a name="l01335"></a>01335 <span class="comment">                               |-----------&gt;</span>
<a name="l01336"></a>01336 <span class="comment">                                ___________j____</span>
<a name="l01337"></a>01337 <span class="comment">                               |           |   |</span>
<a name="l01338"></a>01338 <span class="comment">                               |      Mat  |   |</span>
<a name="l01339"></a>01339 <span class="comment">                               |___________|___|</span>
<a name="l01340"></a>01340 <span class="comment">                                           |                  </span>
<a name="l01341"></a>01341 <span class="comment">     NbRay  ^ ________         ____________|____</span>
<a name="l01342"></a>01342 <span class="comment">            | |-------|--------|-----------0---|t1</span>
<a name="l01343"></a>01343 <span class="comment">            |i|-------|--------|-----------0---|t2</span>
<a name="l01344"></a>01344 <span class="comment">            | | Ray   |        |    Sat        |</span>
<a name="l01345"></a>01345 <span class="comment">     NbBid  - |-------|--------|-----------0---|tk</span>
<a name="l01346"></a>01346 <span class="comment">              |_______|        |_______________|</span>
<a name="l01347"></a>01347 <span class="comment">                                           |</span>
<a name="l01348"></a>01348 <span class="comment">                                           |</span>
<a name="l01349"></a>01349 <span class="comment">                                      -OR- (of rows t1,t2,...,tk)</span>
<a name="l01350"></a>01350 <span class="comment">                               ________|___|____</span>
<a name="l01351"></a>01351 <span class="comment">                               |_____Trace_0___|</span>
<a name="l01352"></a>01352 <span class="comment">                               </span>
<a name="l01353"></a>01353 <span class="comment">    */</span>
<a name="l01354"></a>01354     
<a name="l01355"></a>01355     NbIneq2 = 0;
<a name="l01356"></a>01356     <span class="keywordflow">for</span> (j=NbEq; j&lt;NbConstraints; j++) {
<a name="l01357"></a>01357       
<a name="l01358"></a>01358       <span class="comment">/* if (Mat-&gt;p[j][0]==1) : non-redundant inequality */</span>
<a name="l01359"></a>01359       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a61db0ba9ba925615ec70eb92e40b9ef4">value_one_p</a> (Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0])) { 
<a name="l01360"></a>01360         <span class="keywordflow">for</span> (k=0; k&lt;sat_nbcolumns; k++) Trace[k]=0;  <span class="comment">/* init Trace */</span>
<a name="l01361"></a>01361         
<a name="l01362"></a>01362         <span class="comment">/* Compute Trace: the union of all rows of Sat where constraint(j) */</span>
<a name="l01363"></a>01363         <span class="comment">/* is saturated.                                                   */</span>
<a name="l01364"></a>01364         <span class="keywordflow">for</span> (i=NbBid; i&lt;NbRay; i++) 
<a name="l01365"></a>01365           
<a name="l01366"></a>01366           <span class="comment">/* if (Ray-&gt;p[i][0]==1) */</span>
<a name="l01367"></a>01367           <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a61db0ba9ba925615ec70eb92e40b9ef4">value_one_p</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0])) { 
<a name="l01368"></a>01368             <span class="keywordflow">if</span> (!(Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][jx[j]]&amp;bx[j])) 
<a name="l01369"></a>01369               <span class="keywordflow">for</span> (k=0; k&lt;sat_nbcolumns; k++) Trace[k] |= Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][k];
<a name="l01370"></a>01370           }
<a name="l01371"></a>01371         
<a name="l01372"></a>01372         <span class="comment">/* Only constraint(j) should saturate this set of vertices/rays. */</span>
<a name="l01373"></a>01373         <span class="comment">/* If another non-redundant constraint also saturates this set,  */</span>
<a name="l01374"></a>01374         <span class="comment">/* then constraint(j) is redundant                               */</span>
<a name="l01375"></a>01375         Redundant=0;
<a name="l01376"></a>01376         <span class="keywordflow">for</span> (i=NbEq; i&lt;NbConstraints; i++) {
<a name="l01377"></a>01377           
<a name="l01378"></a>01378           <span class="comment">/* if ((Mat-&gt;p[i][0] ==1) &amp;&amp; (i!=j) &amp;&amp; !(Trace[jx[i]] &amp; bx[i]) ) */</span>
<a name="l01379"></a>01379           <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a61db0ba9ba925615ec70eb92e40b9ef4">value_one_p</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0]) &amp;&amp; (i!=j) &amp;&amp; !(Trace[jx[i]] &amp; bx[i])) {
<a name="l01380"></a>01380             Redundant=1;
<a name="l01381"></a>01381             <span class="keywordflow">break</span>;
<a name="l01382"></a>01382           }
<a name="l01383"></a>01383         }
<a name="l01384"></a>01384         <span class="keywordflow">if</span> (Redundant) {
<a name="l01385"></a>01385           <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0],2);
<a name="l01386"></a>01386         }       
<a name="l01387"></a>01387         <span class="keywordflow">else</span> {
<a name="l01388"></a>01388           <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j], Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[NbEq2+NbIneq2], Dimension+1);
<a name="l01389"></a>01389           <span class="keywordflow">if</span> (Filter) Filter[jx[j]] |= bx[j];           <span class="comment">/* for SIMPLIFY */</span>
<a name="l01390"></a>01390           NbIneq2++;
<a name="l01391"></a>01391         }
<a name="l01392"></a>01392       }
<a name="l01393"></a>01393     }
<a name="l01394"></a>01394     free(Trace), Trace = NULL;
<a name="l01395"></a>01395     
<a name="l01396"></a>01396 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l01397"></a>01397 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : Step8]\nConstraints =&quot;</span>);
<a name="l01398"></a>01398     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l01399"></a>01399     fprintf(stderr, <span class="stringliteral">&quot;\nRay =&quot;</span>);
<a name="l01400"></a>01400     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l01401"></a>01401 <span class="preprocessor">#endif</span>
<a name="l01402"></a>01402 <span class="preprocessor"></span>    
<a name="l01403"></a>01403     <span class="comment">/* </span>
<a name="l01404"></a>01404 <span class="comment">     * Step(10): Final pass filter of rays and detection of redundant rays.</span>
<a name="l01405"></a>01405 <span class="comment">     * The final list of rays is written to polyhedron.                     </span>
<a name="l01406"></a>01406 <span class="comment">     */</span>
<a name="l01407"></a>01407     
<a name="l01408"></a>01408     <span class="comment">/* Trace is a (NbRay x 1) column matrix to hold the union of all columns */</span>
<a name="l01409"></a>01409     <span class="comment">/* (corresponding to irredundant inequalities) of saturation matrix &apos;Sat&apos;*/</span>
<a name="l01410"></a>01410     <span class="comment">/* which saturate some ray &apos;i&apos;. See figure below:-                       */</span>
<a name="l01411"></a>01411     
<a name="l01412"></a>01412     Trace=(<span class="keywordtype">unsigned</span> *)malloc(NbRay * <span class="keyword">sizeof</span>(<span class="keywordtype">unsigned</span>));
<a name="l01413"></a>01413     <span class="keywordflow">if</span>(!Trace) {
<a name="l01414"></a>01414       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l01415"></a>01415       <span class="keywordflow">goto</span> oom;
<a name="l01416"></a>01416     }
<a name="l01417"></a>01417     
<a name="l01418"></a>01418     <span class="comment">/*                     NbEq     NbConstraints</span>
<a name="l01419"></a>01419 <span class="comment">                             |----------&gt;</span>
<a name="l01420"></a>01420 <span class="comment">                        ___________j_____</span>
<a name="l01421"></a>01421 <span class="comment">                        |      | |   |  |</span>
<a name="l01422"></a>01422 <span class="comment">                        |      Mat   |  |</span>
<a name="l01423"></a>01423 <span class="comment">                        |______|_|___|__|</span>
<a name="l01424"></a>01424 <span class="comment">                               | |   |</span>
<a name="l01425"></a>01425 <span class="comment">NbRay ^ _________       _______|_|___|__   ___</span>
<a name="l01426"></a>01426 <span class="comment">      | |       |       |      | |   |  |  |T|</span>
<a name="l01427"></a>01427 <span class="comment">      | |  Ray  |       |   Sat| |   |  |  |r|</span>
<a name="l01428"></a>01428 <span class="comment">      | |       |       |      | |   |  |  |a|  Trace = Union[col(t1,t2,..,tk)]</span>
<a name="l01429"></a>01429 <span class="comment">      |i|-------|------&gt;i      0 0   0  |  |c|</span>
<a name="l01430"></a>01430 <span class="comment">NbBid - |       |       |      | |   |  |  |e|</span>
<a name="l01431"></a>01431 <span class="comment">        |_______|       |______|_|___|__|  |_|</span>
<a name="l01432"></a>01432 <span class="comment">                              t1 t2  tk</span>
<a name="l01433"></a>01433 <span class="comment">    */</span>    
<a name="l01434"></a>01434   
<a name="l01435"></a>01435     NbUni2 = 0;
<a name="l01436"></a>01436     
<a name="l01437"></a>01437     <span class="comment">/* Let &apos;aux&apos; be the number of rays not vertices */</span> 
<a name="l01438"></a>01438     aux = 0;     
<a name="l01439"></a>01439     <span class="keywordflow">for</span> (i=NbBid; i&lt;NbRay; i++) {
<a name="l01440"></a>01440       
<a name="l01441"></a>01441       <span class="comment">/* if (Ray-&gt;p[i][0]==1) */</span>
<a name="l01442"></a>01442       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a61db0ba9ba925615ec70eb92e40b9ef4">value_one_p</a> (Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0])) { 
<a name="l01443"></a>01443         
<a name="l01444"></a>01444         <span class="comment">/* if (Ray-&gt;p[i][Dimension]!=0) : vertex */</span>
<a name="l01445"></a>01445         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a> (Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][Dimension]))
<a name="l01446"></a>01446           <span class="keywordflow">for</span> (k=NbBid; k&lt;NbRay; k++) Trace[k]=0;         <span class="comment">/* init Trace */</span>
<a name="l01447"></a>01447         <span class="keywordflow">else</span> <span class="comment">/* for ray */</span>
<a name="l01448"></a>01448           
<a name="l01449"></a>01449           <span class="comment">/* Include the positivity constraint incidences for rays. The */</span>
<a name="l01450"></a>01450           <span class="comment">/* positivity constraint saturates all rays and no vertices   */</span>
<a name="l01451"></a>01451           
<a name="l01452"></a>01452           <span class="keywordflow">for</span> (k=NbBid; k&lt;NbRay; k++)
<a name="l01453"></a>01453             
<a name="l01454"></a>01454             <span class="comment">/* Trace[k]=(Ray-&gt;p[k][Dimension]!=0); */</span>
<a name="l01455"></a>01455             Trace[k] = (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a> (Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][Dimension]));
<a name="l01456"></a>01456         
<a name="l01457"></a>01457         <span class="comment">/* Compute Trace: the union of all columns of Sat where ray(i) is  */</span>
<a name="l01458"></a>01458         <span class="comment">/* saturated.                                                      */</span>
<a name="l01459"></a>01459         <span class="keywordflow">for</span> (j=NbEq; j&lt;NbConstraints; j++)
<a name="l01460"></a>01460           
<a name="l01461"></a>01461           <span class="comment">/* if (Mat-&gt;p[j][0]==1) : inequality */</span>
<a name="l01462"></a>01462           <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a61db0ba9ba925615ec70eb92e40b9ef4">value_one_p</a> (Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0])) { 
<a name="l01463"></a>01463             <span class="keywordflow">if</span> (!(Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][jx[j]]&amp;bx[j]))
<a name="l01464"></a>01464               <span class="keywordflow">for</span> (k=NbBid; k&lt;NbRay; k++) Trace[k] |= Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[k][jx[j]]&amp;bx[j];
<a name="l01465"></a>01465           }
<a name="l01466"></a>01466         
<a name="l01467"></a>01467         <span class="comment">/* If ray i does not saturate any inequalities (other than the   */</span>
<a name="l01468"></a>01468         <span class="comment">/* the positivity constraint, then it is the case that there is  */</span>
<a name="l01469"></a>01469         <span class="comment">/* only one inequality and that ray is its orthogonal            */</span>
<a name="l01470"></a>01470         
<a name="l01471"></a>01471         <span class="comment">/* only ray(i) should saturate this set of inequalities. If      */</span>
<a name="l01472"></a>01472         <span class="comment">/* another non-redundant ray also saturates this set, then ray(i)*/</span>
<a name="l01473"></a>01473         <span class="comment">/* is redundant                                                  */</span>
<a name="l01474"></a>01474         
<a name="l01475"></a>01475         Redundant = 0;
<a name="l01476"></a>01476         <span class="keywordflow">for</span> (j=NbBid; j&lt;NbRay; j++) { 
<a name="l01477"></a>01477           
<a name="l01478"></a>01478           <span class="comment">/* if ( (Ray-&gt;p[j][0]==1) &amp;&amp; (i!=j) &amp;&amp; !Trace[j] ) */</span>
<a name="l01479"></a>01479           <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a61db0ba9ba925615ec70eb92e40b9ef4">value_one_p</a> (Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0]) &amp;&amp; (i!=j) &amp;&amp; !Trace[j]) { 
<a name="l01480"></a>01480             Redundant=1;
<a name="l01481"></a>01481             <span class="keywordflow">break</span>;
<a name="l01482"></a>01482           }
<a name="l01483"></a>01483         }
<a name="l01484"></a>01484         <span class="keywordflow">if</span> (Redundant) 
<a name="l01485"></a>01485           <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0],2); 
<a name="l01486"></a>01486         <span class="keywordflow">else</span> {
<a name="l01487"></a>01487           <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[NbBid2+NbUni2], Dimension+1);
<a name="l01488"></a>01488           NbUni2++;  <span class="comment">/* Increment number of uni-directional rays */</span>
<a name="l01489"></a>01489           
<a name="l01490"></a>01490           <span class="comment">/* if (Ray-&gt;p[i][Dimension]==0) */</span> 
<a name="l01491"></a>01491           <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a> (Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][Dimension]))
<a name="l01492"></a>01492             aux++; <span class="comment">/* Increment number of rays which are not vertices */</span>
<a name="l01493"></a>01493         }
<a name="l01494"></a>01494       }
<a name="l01495"></a>01495     }
<a name="l01496"></a>01496     
<a name="l01497"></a>01497     <span class="comment">/* Include the positivity constraint */</span>
<a name="l01498"></a>01498     <span class="keywordflow">if</span> (aux&gt;=Dim_RaySpace) {
<a name="l01499"></a>01499       <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[NbEq2+NbIneq2],0,Dimension+1);
<a name="l01500"></a>01500       <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[NbEq2+NbIneq2][0],1);
<a name="l01501"></a>01501       <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[NbEq2+NbIneq2][Dimension],1);
<a name="l01502"></a>01502       NbIneq2++;
<a name="l01503"></a>01503     }   
<a name="l01504"></a>01504   } <span class="comment">/* end of TRY */</span>
<a name="l01505"></a>01505   
<a name="l01506"></a>01506   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l01507"></a>01507   
<a name="l01508"></a>01508 <span class="preprocessor">#ifdef POLY_RR_DEBUG</span>
<a name="l01509"></a>01509 <span class="preprocessor"></span>  fprintf(stderr, <span class="stringliteral">&quot;[Remove_redundants : Step9]\nConstraints =&quot;</span>);
<a name="l01510"></a>01510   <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l01511"></a>01511   fprintf(stderr, <span class="stringliteral">&quot;\nRay =&quot;</span>);
<a name="l01512"></a>01512   <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l01513"></a>01513 <span class="preprocessor">#endif</span>
<a name="l01514"></a>01514 <span class="preprocessor"></span>  
<a name="l01515"></a>01515   free(Trace);
<a name="l01516"></a>01516   free(bx);
<a name="l01517"></a>01517   free(jx);
<a name="l01518"></a>01518   <span class="keywordflow">if</span> (temp2)
<a name="l01519"></a>01519     free(temp2);
<a name="l01520"></a>01520   
<a name="l01521"></a>01521   Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> = NbEq2 + NbIneq2;
<a name="l01522"></a>01522   Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a> = NbBid2 + NbUni2;
<a name="l01523"></a>01523   
<a name="l01524"></a>01524   <a class="code" href="vector_8c.html#a055608d1a3726b7cb26e3e8074764ba0">Vector_Free</a>(temp1);
<a name="l01525"></a>01525   <a class="code" href="types_8h.html#ab04b7b56e2789336fbc544896cb477f9">F_SET</a>(Pol, 
<a name="l01526"></a>01526         <a class="code" href="types_8h.html#a2ac4c28a3acbe4578e03ad20db7939cc">POL_VALID</a> | <a class="code" href="types_8h.html#a1869e11b8e9a1e9e89e8145c242e0eea">POL_INEQUALITIES</a> | <a class="code" href="types_8h.html#adef192e3530c5e1fcb2c44858a78f703">POL_FACETS</a> | <a class="code" href="types_8h.html#aacccb2db7ed6cb45d5e324216aa5ea3f">POL_POINTS</a> | <a class="code" href="types_8h.html#a18cb4aab2aec424306ea8f67f6dfc9b0">POL_VERTICES</a>);
<a name="l01527"></a>01527   <span class="keywordflow">return</span> Pol;
<a name="l01528"></a>01528 
<a name="l01529"></a>01529 oom:
<a name="l01530"></a>01530   <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Remove_Redundants&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l01531"></a>01531 
<a name="l01532"></a>01532   <a class="code" href="vector_8c.html#a055608d1a3726b7cb26e3e8074764ba0">Vector_Free</a>(temp1);
<a name="l01533"></a>01533   <span class="keywordflow">if</span> (temp2)
<a name="l01534"></a>01534     free(temp2);
<a name="l01535"></a>01535   <span class="keywordflow">if</span> (bx)
<a name="l01536"></a>01536     free(bx);
<a name="l01537"></a>01537   <span class="keywordflow">if</span> (jx)
<a name="l01538"></a>01538     free(jx);
<a name="l01539"></a>01539   <span class="keywordflow">return</span> NULL;
<a name="l01540"></a>01540 
<a name="l01541"></a>01541 empty:
<a name="l01542"></a>01542   <a class="code" href="vector_8c.html#a055608d1a3726b7cb26e3e8074764ba0">Vector_Free</a>(temp1);
<a name="l01543"></a>01543   <span class="keywordflow">if</span> (temp2)
<a name="l01544"></a>01544     free(temp2);
<a name="l01545"></a>01545   <span class="keywordflow">if</span> (bx)
<a name="l01546"></a>01546     free(bx);
<a name="l01547"></a>01547   <span class="keywordflow">if</span> (jx)
<a name="l01548"></a>01548     free(jx);
<a name="l01549"></a>01549   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l01550"></a>01550   <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Dimension-1);
<a name="l01551"></a>01551 } <span class="comment">/* Remove_Redundants */</span>
<a name="l01552"></a>01552 
<a name="l01553"></a>01553 <span class="comment">/*</span>
<a name="l01554"></a>01554 <span class="comment"> * Allocate memory space for polyhedron. </span>
<a name="l01555"></a>01555 <span class="comment"> */</span>
<a name="l01556"></a><a class="code" href="polyhedron_8h.html#aa308ade6448cc5544e21d59e86a53ddf">01556</a> <a class="code" href="structpolyhedron.html">Polyhedron</a>* <a class="code" href="polyhedron_8c.html#aa308ade6448cc5544e21d59e86a53ddf">Polyhedron_Alloc</a>(<span class="keywordtype">unsigned</span> Dimension,<span class="keywordtype">unsigned</span> NbConstraints,<span class="keywordtype">unsigned</span> NbRays) { 
<a name="l01557"></a>01557   
<a name="l01558"></a>01558   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol;
<a name="l01559"></a>01559   <span class="keywordtype">unsigned</span> NbRows,NbColumns;
<a name="l01560"></a>01560   <span class="keywordtype">int</span> i,j;
<a name="l01561"></a>01561   Value *<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a>, **q; 
<a name="l01562"></a>01562 
<a name="l01563"></a>01563   Pol=(<a class="code" href="structpolyhedron.html">Polyhedron</a> *)malloc(<span class="keyword">sizeof</span>(<a class="code" href="structpolyhedron.html">Polyhedron</a>));
<a name="l01564"></a>01564   <span class="keywordflow">if</span>(!Pol) {
<a name="l01565"></a>01565     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Alloc&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l01566"></a>01566     <span class="keywordflow">return</span> 0;
<a name="l01567"></a>01567   }
<a name="l01568"></a>01568   
<a name="l01569"></a>01569   Pol-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>          = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l01570"></a>01570   Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>     = Dimension;
<a name="l01571"></a>01571   Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> = NbConstraints;
<a name="l01572"></a>01572   Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>        = NbRays;
<a name="l01573"></a>01573   Pol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>          = 0;
<a name="l01574"></a>01574   Pol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a>         = 0;
<a name="l01575"></a>01575   Pol-&gt;<a class="code" href="structpolyhedron.html#ac1fb864c352ef93ef3030c35e98c2aed">flags</a>         = 0;
<a name="l01576"></a>01576   NbRows             = NbConstraints + NbRays;
<a name="l01577"></a>01577   NbColumns          = Dimension + 2;
<a name="l01578"></a>01578   
<a name="l01579"></a>01579   q = (Value **)malloc(NbRows * <span class="keyword">sizeof</span>(Value *));
<a name="l01580"></a>01580   <span class="keywordflow">if</span>(!q) {
<a name="l01581"></a>01581     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Alloc&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l01582"></a>01582     <span class="keywordflow">return</span> 0;
<a name="l01583"></a>01583   }
<a name="l01584"></a>01584   p = <a class="code" href="vector_8c.html#ae8b0745702c689f66f3d12bc17f93f58">value_alloc</a>(NbRows*NbColumns, &amp;Pol-&gt;<a class="code" href="structpolyhedron.html#ac2aa52aede2212101bd130ba7a67663a">p_Init_size</a>);
<a name="l01585"></a>01585   <span class="keywordflow">if</span>(!p) {
<a name="l01586"></a>01586     free(q);
<a name="l01587"></a>01587     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Alloc&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l01588"></a>01588     <span class="keywordflow">return</span> 0;
<a name="l01589"></a>01589   }
<a name="l01590"></a>01590   Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>    = q;
<a name="l01591"></a>01591   Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>           = q + NbConstraints;
<a name="l01592"></a>01592   Pol-&gt;<a class="code" href="structpolyhedron.html#a3681618067c7bf2a0bd5e805871283f5">p_Init</a>        = p;
<a name="l01593"></a>01593   <span class="keywordflow">for</span> (i=0;i&lt;NbRows;i++) {
<a name="l01594"></a>01594     *q++ = p;
<a name="l01595"></a>01595     p += NbColumns;
<a name="l01596"></a>01596   }
<a name="l01597"></a>01597   <span class="keywordflow">return</span> Pol;
<a name="l01598"></a>01598 } <span class="comment">/* Polyhedron_Alloc */</span>
<a name="l01599"></a>01599 
<a name="l01600"></a>01600 <span class="comment">/*    </span>
<a name="l01601"></a>01601 <span class="comment"> * Free the memory space occupied by the single polyhedron.</span>
<a name="l01602"></a>01602 <span class="comment"> */</span>
<a name="l01603"></a><a class="code" href="polyhedron_8h.html#a4ae97b9794e3a616f1d38c68e6515cc3">01603</a> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol)
<a name="l01604"></a>01604 {
<a name="l01605"></a>01605   <span class="keywordflow">if</span>(!Pol)
<a name="l01606"></a>01606     <span class="keywordflow">return</span>;
<a name="l01607"></a>01607   <a class="code" href="vector_8c.html#a3e050c3a0fbb40af2a15f874835e34a4">value_free</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a3681618067c7bf2a0bd5e805871283f5">p_Init</a>, Pol-&gt;<a class="code" href="structpolyhedron.html#ac2aa52aede2212101bd130ba7a67663a">p_Init_size</a>);
<a name="l01608"></a>01608   free(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>);
<a name="l01609"></a>01609   free(Pol);
<a name="l01610"></a>01610   <span class="keywordflow">return</span>;
<a name="l01611"></a>01611 } <span class="comment">/* Polyhedron_Free */</span>
<a name="l01612"></a>01612 
<a name="l01613"></a>01613 <span class="comment">/*</span>
<a name="l01614"></a>01614 <span class="comment"> * Free the memory space occupied by the domain. </span>
<a name="l01615"></a>01615 <span class="comment"> */</span>
<a name="l01616"></a><a class="code" href="polyhedron_8h.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">01616</a> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol)
<a name="l01617"></a>01617 {
<a name="l01618"></a>01618   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Next;
<a name="l01619"></a>01619   
<a name="l01620"></a>01620   <span class="keywordflow">for</span> (; Pol; Pol = Next) {
<a name="l01621"></a>01621     Next = Pol-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l01622"></a>01622     <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol);
<a name="l01623"></a>01623   }
<a name="l01624"></a>01624   <span class="keywordflow">return</span>;
<a name="l01625"></a>01625 } <span class="comment">/* Domain_Free */</span>
<a name="l01626"></a>01626 
<a name="l01627"></a>01627 <span class="comment">/*</span>
<a name="l01628"></a>01628 <span class="comment"> * Print the contents of a polyhedron. </span>
<a name="l01629"></a>01629 <span class="comment"> */</span>
<a name="l01630"></a><a class="code" href="polyhedron_8h.html#ad87595bd01c5cdd0f3933824943db496">01630</a> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#ad87595bd01c5cdd0f3933824943db496">Polyhedron_Print</a>(FILE *Dst, <span class="keyword">const</span> <span class="keywordtype">char</span> *Format, <span class="keyword">const</span> <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol)
<a name="l01631"></a>01631 {
<a name="l01632"></a>01632   <span class="keywordtype">unsigned</span> Dimension, NbConstraints, NbRays;
<a name="l01633"></a>01633   <span class="keywordtype">int</span>      i, j;
<a name="l01634"></a>01634   Value    *<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a>;
<a name="l01635"></a>01635   
<a name="l01636"></a>01636   <span class="keywordflow">if</span> (!Pol) { 
<a name="l01637"></a>01637     fprintf(Dst, <span class="stringliteral">&quot;&lt;null polyhedron&gt;\n&quot;</span>);
<a name="l01638"></a>01638     <span class="keywordflow">return</span>;
<a name="l01639"></a>01639   }
<a name="l01640"></a>01640   
<a name="l01641"></a>01641   Dimension     = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> + 2;  <span class="comment">/* Homogenous Dimension + status */</span>
<a name="l01642"></a>01642   NbConstraints = Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l01643"></a>01643   NbRays        = Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>;
<a name="l01644"></a>01644   fprintf(Dst, <span class="stringliteral">&quot;POLYHEDRON Dimension:%d\n&quot;</span>, Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>);
<a name="l01645"></a>01645   fprintf(Dst,<span class="stringliteral">&quot;           Constraints:%d  Equations:%d  Rays:%d  Lines:%d\n&quot;</span>,
<a name="l01646"></a>01646           Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>, Pol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>, Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>, Pol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a>);
<a name="l01647"></a>01647   fprintf(Dst,<span class="stringliteral">&quot;Constraints %d %d\n&quot;</span>, NbConstraints, Dimension);
<a name="l01648"></a>01648   
<a name="l01649"></a>01649   <span class="keywordflow">for</span> (i=0;i&lt;NbConstraints;i++) {
<a name="l01650"></a>01650     p=Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i];
<a name="l01651"></a>01651     
<a name="l01652"></a>01652     <span class="comment">/* if (*p) */</span>
<a name="l01653"></a>01653     <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a> (*p))
<a name="l01654"></a>01654       fprintf(Dst,<span class="stringliteral">&quot;Inequality: [&quot;</span>);
<a name="l01655"></a>01655     <span class="keywordflow">else</span>      
<a name="l01656"></a>01656       fprintf(Dst,<span class="stringliteral">&quot;Equality:   [&quot;</span>);
<a name="l01657"></a>01657     p++;
<a name="l01658"></a>01658     <span class="keywordflow">for</span> (j=1;j&lt;Dimension;j++) {
<a name="l01659"></a>01659       <a class="code" href="source_2arith_2arithmetique_8h.html#ad34605b56b571830b928b50a74d618b7">value_print</a>(Dst,Format,*p++);
<a name="l01660"></a>01660     }  
<a name="l01661"></a>01661     (void)fprintf(Dst,<span class="stringliteral">&quot; ]\n&quot;</span>);
<a name="l01662"></a>01662   }
<a name="l01663"></a>01663 
<a name="l01664"></a>01664   (void)fprintf(Dst, <span class="stringliteral">&quot;Rays %d %d\n&quot;</span>, NbRays, Dimension);
<a name="l01665"></a>01665   <span class="keywordflow">for</span> (i=0;i&lt;NbRays;i++) {
<a name="l01666"></a>01666     p=Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[i];
<a name="l01667"></a>01667     
<a name="l01668"></a>01668     <span class="comment">/* if (*p) */</span>
<a name="l01669"></a>01669     <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a> (*p)) {   
<a name="l01670"></a>01670       p++;
<a name="l01671"></a>01671       
<a name="l01672"></a>01672       <span class="comment">/* if ( p[Dimension-2] ) */</span>
<a name="l01673"></a>01673       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a> (p[Dimension-2]))
<a name="l01674"></a>01674         fprintf(Dst, <span class="stringliteral">&quot;Vertex: [&quot;</span>);
<a name="l01675"></a>01675       <span class="keywordflow">else</span>                  
<a name="l01676"></a>01676         fprintf(Dst, <span class="stringliteral">&quot;Ray:    [&quot;</span>);
<a name="l01677"></a>01677     }
<a name="l01678"></a>01678     <span class="keywordflow">else</span> {
<a name="l01679"></a>01679       p++;
<a name="l01680"></a>01680       fprintf(Dst, <span class="stringliteral">&quot;Line:   [&quot;</span>);
<a name="l01681"></a>01681     }
<a name="l01682"></a>01682     <span class="keywordflow">for</span> (j=1; j &lt; Dimension-1; j++) {
<a name="l01683"></a>01683       <a class="code" href="source_2arith_2arithmetique_8h.html#ad34605b56b571830b928b50a74d618b7">value_print</a>(Dst,Format,*p++);  
<a name="l01684"></a>01684     }  
<a name="l01685"></a>01685     
<a name="l01686"></a>01686     <span class="comment">/* if (*p) */</span>
<a name="l01687"></a>01687     <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a> (*p)) {
<a name="l01688"></a>01688       fprintf( Dst, <span class="stringliteral">&quot; ]/&quot;</span> );
<a name="l01689"></a>01689       <a class="code" href="source_2arith_2arithmetique_8h.html#ad34605b56b571830b928b50a74d618b7">value_print</a>(Dst,VALUE_FMT,*p);
<a name="l01690"></a>01690       fprintf( Dst, <span class="stringliteral">&quot;\n&quot;</span> );
<a name="l01691"></a>01691     }
<a name="l01692"></a>01692     <span class="keywordflow">else</span>    
<a name="l01693"></a>01693       fprintf(Dst, <span class="stringliteral">&quot; ]\n&quot;</span>);
<a name="l01694"></a>01694   }
<a name="l01695"></a>01695   <span class="keywordflow">if</span> (Pol-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {  
<a name="l01696"></a>01696     fprintf(Dst, <span class="stringliteral">&quot;UNION &quot;</span>);
<a name="l01697"></a>01697     <a class="code" href="polyhedron_8c.html#ad87595bd01c5cdd0f3933824943db496">Polyhedron_Print</a>(Dst,Format,Pol-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>);
<a name="l01698"></a>01698   }
<a name="l01699"></a>01699 } <span class="comment">/* Polyhedron_Print */</span>
<a name="l01700"></a>01700 
<a name="l01701"></a>01701 <span class="comment">/* </span>
<a name="l01702"></a>01702 <span class="comment"> * Print the contents of a polyhedron &apos;Pol&apos; (used for debugging purpose).</span>
<a name="l01703"></a>01703 <span class="comment"> */</span>
<a name="l01704"></a><a class="code" href="polyhedron_8h.html#a09e380e70f4f88c4a646b4795f9c9626">01704</a> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#a09e380e70f4f88c4a646b4795f9c9626">PolyPrint</a> (<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol) {
<a name="l01705"></a>01705   <a class="code" href="polyhedron_8c.html#ad87595bd01c5cdd0f3933824943db496">Polyhedron_Print</a>(stderr,<span class="stringliteral">&quot;%4d&quot;</span>,Pol);
<a name="l01706"></a>01706 } <span class="comment">/* PolyPrint */</span>
<a name="l01707"></a>01707 
<a name="l01708"></a>01708 <span class="comment">/* </span>
<a name="l01709"></a>01709 <span class="comment"> * Create and return an empty polyhedron of non-homogenous dimension </span>
<a name="l01710"></a>01710 <span class="comment"> * &apos;Dimension&apos;. An empty polyhedron is characterized by :-</span>
<a name="l01711"></a>01711 <span class="comment"> *  (a) The dimension of the ray-space is -1.  </span>
<a name="l01712"></a>01712 <span class="comment"> *  (b) There is an over-constrained system of equations given by:</span>
<a name="l01713"></a>01713 <span class="comment"> *      x=0, y=0, ...... z=0, 1=0</span>
<a name="l01714"></a>01714 <span class="comment"> */</span>
<a name="l01715"></a><a class="code" href="polyhedron_8h.html#a37f19f6863a633aa08657cadf564d3d6">01715</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(<span class="keywordtype">unsigned</span> Dimension) {
<a name="l01716"></a>01716 
<a name="l01717"></a>01717   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol;
<a name="l01718"></a>01718   <span class="keywordtype">int</span> i;
<a name="l01719"></a>01719 
<a name="l01720"></a>01720   Pol = <a class="code" href="polyhedron_8c.html#aa308ade6448cc5544e21d59e86a53ddf">Polyhedron_Alloc</a>(Dimension, Dimension+1, 0);
<a name="l01721"></a>01721   <span class="keywordflow">if</span> (!Pol) {
<a name="l01722"></a>01722     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Empty_Polyhedron&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l01723"></a>01723     <span class="keywordflow">return</span> 0;
<a name="l01724"></a>01724   }
<a name="l01725"></a>01725   <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0],0,(Dimension+1)*(Dimension+2));
<a name="l01726"></a>01726   <span class="keywordflow">for</span> (i=0; i&lt;=Dimension; i++) {
<a name="l01727"></a>01727     
<a name="l01728"></a>01728     <span class="comment">/* Pol-&gt;Constraint[i][i+1]=1 */</span>
<a name="l01729"></a>01729     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][i+1],1);
<a name="l01730"></a>01730   }
<a name="l01731"></a>01731   Pol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a> = Dimension+1;
<a name="l01732"></a>01732   Pol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a> = 0;
<a name="l01733"></a>01733   <a class="code" href="types_8h.html#ab04b7b56e2789336fbc544896cb477f9">F_SET</a>(Pol, 
<a name="l01734"></a>01734         <a class="code" href="types_8h.html#a2ac4c28a3acbe4578e03ad20db7939cc">POL_VALID</a> | <a class="code" href="types_8h.html#a1869e11b8e9a1e9e89e8145c242e0eea">POL_INEQUALITIES</a> | <a class="code" href="types_8h.html#adef192e3530c5e1fcb2c44858a78f703">POL_FACETS</a> | <a class="code" href="types_8h.html#aacccb2db7ed6cb45d5e324216aa5ea3f">POL_POINTS</a> | <a class="code" href="types_8h.html#a18cb4aab2aec424306ea8f67f6dfc9b0">POL_VERTICES</a>);
<a name="l01735"></a>01735   <span class="keywordflow">return</span> Pol;
<a name="l01736"></a>01736 } <span class="comment">/* Empty_Polyhedron */</span>
<a name="l01737"></a>01737 
<a name="l01738"></a>01738 <span class="comment">/* </span>
<a name="l01739"></a>01739 <span class="comment"> * Create and return a universe polyhedron of non-homogenous dimension</span>
<a name="l01740"></a>01740 <span class="comment"> * &apos;Dimension&apos;. A universe polyhedron is characterized by :-</span>
<a name="l01741"></a>01741 <span class="comment"> * (a) The dimension of rayspace is zero. </span>
<a name="l01742"></a>01742 <span class="comment"> * (b) The dimension of lineality space is the dimension of the polyhedron.</span>
<a name="l01743"></a>01743 <span class="comment"> * (c) There is only one constraint (positivity constraint) in the constraint</span>
<a name="l01744"></a>01744 <span class="comment"> *     set given by : 1 &gt;= 0. </span>
<a name="l01745"></a>01745 <span class="comment"> * (d) The bi-directional ray set is the canonical set of vectors. </span>
<a name="l01746"></a>01746 <span class="comment"> * (e) The only vertex is the origin (0,0,0,....0).  </span>
<a name="l01747"></a>01747 <span class="comment"> */</span>
<a name="l01748"></a><a class="code" href="polyhedron_8h.html#a832c074e0ce9da3df126dc7d51248276">01748</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a832c074e0ce9da3df126dc7d51248276">Universe_Polyhedron</a>(<span class="keywordtype">unsigned</span> Dimension) { 
<a name="l01749"></a>01749   
<a name="l01750"></a>01750   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol;
<a name="l01751"></a>01751   <span class="keywordtype">int</span> i;
<a name="l01752"></a>01752   
<a name="l01753"></a>01753   Pol = <a class="code" href="polyhedron_8c.html#aa308ade6448cc5544e21d59e86a53ddf">Polyhedron_Alloc</a>(Dimension,1,Dimension+1);
<a name="l01754"></a>01754   <span class="keywordflow">if</span> (!Pol) {
<a name="l01755"></a>01755     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Universe_Polyhedron&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l01756"></a>01756     <span class="keywordflow">return</span> 0;
<a name="l01757"></a>01757   }
<a name="l01758"></a>01758   <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0],0,(Dimension+2));
<a name="l01759"></a>01759   
<a name="l01760"></a>01760   <span class="comment">/* Pol-&gt;Constraint[0][0] = 1 */</span>
<a name="l01761"></a>01761   <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0][0],1);
<a name="l01762"></a>01762   
<a name="l01763"></a>01763   <span class="comment">/* Pol-&gt;Constraint[0][Dimension+1] = 1 */</span>
<a name="l01764"></a>01764   <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0][Dimension+1],1);
<a name="l01765"></a>01765   <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[0],0,(Dimension+1)*(Dimension+2));
<a name="l01766"></a>01766   <span class="keywordflow">for</span> (i=0;i&lt;=Dimension;i++) {
<a name="l01767"></a>01767     
<a name="l01768"></a>01768     <span class="comment">/* Pol-&gt;Ray[i][i+1]=1 */</span>
<a name="l01769"></a>01769     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[i][i+1],1);
<a name="l01770"></a>01770   }  
<a name="l01771"></a>01771   
<a name="l01772"></a>01772   <span class="comment">/* Pol-&gt;Ray[Dimension][0] = 1 :  vertex status */</span>
<a name="l01773"></a>01773   <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[Dimension][0],1);
<a name="l01774"></a>01774   Pol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a> = 0;
<a name="l01775"></a>01775   Pol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a> = Dimension;
<a name="l01776"></a>01776   <a class="code" href="types_8h.html#ab04b7b56e2789336fbc544896cb477f9">F_SET</a>(Pol, 
<a name="l01777"></a>01777         <a class="code" href="types_8h.html#a2ac4c28a3acbe4578e03ad20db7939cc">POL_VALID</a> | <a class="code" href="types_8h.html#a1869e11b8e9a1e9e89e8145c242e0eea">POL_INEQUALITIES</a> | <a class="code" href="types_8h.html#adef192e3530c5e1fcb2c44858a78f703">POL_FACETS</a> | <a class="code" href="types_8h.html#aacccb2db7ed6cb45d5e324216aa5ea3f">POL_POINTS</a> | <a class="code" href="types_8h.html#a18cb4aab2aec424306ea8f67f6dfc9b0">POL_VERTICES</a>);
<a name="l01778"></a>01778   <span class="keywordflow">return</span> Pol;
<a name="l01779"></a>01779 } <span class="comment">/* Universe_Polyhedron */</span>
<a name="l01780"></a>01780 
<a name="l01781"></a>01781 <span class="comment">/*</span>
<a name="l01782"></a>01782 <span class="comment"></span>
<a name="l01783"></a>01783 <span class="comment">Sort constraints and remove trivially redundant constraints.</span>
<a name="l01784"></a>01784 <span class="comment"></span>
<a name="l01785"></a>01785 <span class="comment">*/</span>
<a name="l01786"></a><a class="code" href="polyhedron_8c.html#a0e3d47f133646ddcbb799914ac84dbcd">01786</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#a0e3d47f133646ddcbb799914ac84dbcd">SortConstraints</a>(<a class="code" href="structmatrix.html">Matrix</a> *Constraints, <span class="keywordtype">unsigned</span> NbEq)
<a name="l01787"></a>01787 {
<a name="l01788"></a>01788     <span class="keywordtype">int</span> i, j, k;
<a name="l01789"></a>01789     <span class="keywordflow">for</span> (i = NbEq; i &lt; Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>; ++i) {
<a name="l01790"></a>01790         <span class="keywordtype">int</span> <a class="code" href="verif__ehrhart_8c.html#a76af106aaa860ca001b28491fa8e046c">max</a> = i;
<a name="l01791"></a>01791         <span class="keywordflow">for</span> (k = i+1; k &lt; Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>; ++k) {
<a name="l01792"></a>01792             <span class="keywordflow">for</span> (j = 1; j &lt; Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1; ++j) {
<a name="l01793"></a>01793                 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#aaac63aa93e7c9fa23ebcde2dc80a12b9">value_eq</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][j],
<a name="l01794"></a>01794                              Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[max][j]))
<a name="l01795"></a>01795                     <span class="keywordflow">continue</span>;
<a name="l01796"></a>01796                 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a7eae65fd61df2cb8af2b9c11c586e029">value_abs_lt</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][j],
<a name="l01797"></a>01797                                  Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[max][j]))
<a name="l01798"></a>01798                     <span class="keywordflow">break</span>;
<a name="l01799"></a>01799                 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a22b43fb8cc50260d0bb946b88ade67a6">value_abs_eq</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][j],
<a name="l01800"></a>01800                                  Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[max][j]) &amp;&amp;
<a name="l01801"></a>01801                     <a class="code" href="source_2arith_2arithmetique_8h.html#a01904c8c75c10d407a24c55f16ec27c7">value_pos_p</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[max][j]))
<a name="l01802"></a>01802                         <span class="keywordflow">break</span>;
<a name="l01803"></a>01803                 max = k;
<a name="l01804"></a>01804                 <span class="keywordflow">break</span>;
<a name="l01805"></a>01805             }
<a name="l01806"></a>01806             <span class="comment">/* equal, except for possibly the constant</span>
<a name="l01807"></a>01807 <span class="comment">             * =&gt; remove constraint with biggest constant</span>
<a name="l01808"></a>01808 <span class="comment">             */</span>
<a name="l01809"></a>01809             <span class="keywordflow">if</span> (j == Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1) {
<a name="l01810"></a>01810                 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#ad87a1fcce82a9885ffd8518f4fba2c0e">value_lt</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][j], Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[max][j]))
<a name="l01811"></a>01811                     <a class="code" href="vector_8c.html#a88f4d69371f16d6d28e8a87c496b0730">Vector_Exchange</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k], 
<a name="l01812"></a>01812                                     Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[max], 
<a name="l01813"></a>01813                                     Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l01814"></a>01814                 Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>--;
<a name="l01815"></a>01815                 <span class="keywordflow">if</span> (k &lt; Constraints-&gt;NbRows)
<a name="l01816"></a>01816                     <a class="code" href="vector_8c.html#a88f4d69371f16d6d28e8a87c496b0730">Vector_Exchange</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k], 
<a name="l01817"></a>01817                                     Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>], 
<a name="l01818"></a>01818                                     Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l01819"></a>01819                 k--;
<a name="l01820"></a>01820             }
<a name="l01821"></a>01821         }
<a name="l01822"></a>01822         <span class="keywordflow">if</span> (max != i)
<a name="l01823"></a>01823             <a class="code" href="vector_8c.html#a88f4d69371f16d6d28e8a87c496b0730">Vector_Exchange</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[max], Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], 
<a name="l01824"></a>01824                             Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l01825"></a>01825     }
<a name="l01826"></a>01826 }
<a name="l01827"></a>01827 
<a name="l01828"></a>01828 <span class="comment">/*</span>
<a name="l01829"></a>01829 <span class="comment"></span>
<a name="l01830"></a>01830 <span class="comment">Search for trivial implicit equalities,</span>
<a name="l01831"></a>01831 <span class="comment">assuming the constraints have been sorted.</span>
<a name="l01832"></a>01832 <span class="comment"></span>
<a name="l01833"></a>01833 <span class="comment">*/</span>
<a name="l01834"></a>01834 
<a name="l01835"></a><a class="code" href="polyhedron_8c.html#af5a2e545702901c2deb13234096810c2">01835</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="polyhedron_8c.html#af5a2e545702901c2deb13234096810c2">ImplicitEqualities</a>(<a class="code" href="structmatrix.html">Matrix</a> *Constraints, <span class="keywordtype">unsigned</span> NbEq)
<a name="l01836"></a>01836 {
<a name="l01837"></a>01837     <span class="keywordtype">int</span> row, nrow, k;
<a name="l01838"></a>01838     <span class="keywordtype">int</span> found = 0;
<a name="l01839"></a>01839     Value tmp;
<a name="l01840"></a>01840     <span class="keywordflow">for</span> (row = NbEq; row &lt; Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>; ++row) {
<a name="l01841"></a>01841         <span class="keywordtype">int</span> d = <a class="code" href="vector_8c.html#ab719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row]+1, Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2);
<a name="l01842"></a>01842         <span class="keywordflow">if</span> (d == -1) {
<a name="l01843"></a>01843             <span class="comment">/* -n &gt;= 0 */</span>
<a name="l01844"></a>01844             <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#af031da52c8a160fd1ee6e4c793f8c78a">value_neg_p</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row][Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1])) {
<a name="l01845"></a>01845                 <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row][0], 0);
<a name="l01846"></a>01846                 found = 1;
<a name="l01847"></a>01847             }
<a name="l01848"></a>01848             <span class="keywordflow">break</span>;
<a name="l01849"></a>01849         }
<a name="l01850"></a>01850         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#af031da52c8a160fd1ee6e4c793f8c78a">value_neg_p</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row][1+d]))
<a name="l01851"></a>01851             <span class="keywordflow">continue</span>;
<a name="l01852"></a>01852         <span class="keywordflow">for</span> (nrow = row+1; nrow &lt; Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>; ++nrow) {
<a name="l01853"></a>01853             <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[nrow][1+d]))
<a name="l01854"></a>01854                 <span class="keywordflow">break</span>;
<a name="l01855"></a>01855             <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a01904c8c75c10d407a24c55f16ec27c7">value_pos_p</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[nrow][1+d]))
<a name="l01856"></a>01856                 <span class="keywordflow">continue</span>;
<a name="l01857"></a>01857             <span class="keywordflow">for</span> (k = d; k &lt; Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1; ++k) {
<a name="l01858"></a>01858                 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a669046111316f58e17c7ed91e9c01bd6">value_abs_ne</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row][1+k], 
<a name="l01859"></a>01859                                  Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[nrow][1+k]))
<a name="l01860"></a>01860                     <span class="keywordflow">break</span>;
<a name="l01861"></a>01861                 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row][1+k]))
<a name="l01862"></a>01862                     <span class="keywordflow">continue</span>;
<a name="l01863"></a>01863                 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#aaac63aa93e7c9fa23ebcde2dc80a12b9">value_eq</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row][1+k], Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[nrow][1+k]))
<a name="l01864"></a>01864                     <span class="keywordflow">break</span>;
<a name="l01865"></a>01865             }
<a name="l01866"></a>01866             <span class="keywordflow">if</span> (k == Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1) {
<a name="l01867"></a>01867                 <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row][0], 0);
<a name="l01868"></a>01868                 <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[nrow][0], 0);
<a name="l01869"></a>01869                 found = 1;
<a name="l01870"></a>01870                 <span class="keywordflow">break</span>;
<a name="l01871"></a>01871             }
<a name="l01872"></a>01872             <span class="keywordflow">if</span> (k != Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2)
<a name="l01873"></a>01873                 <span class="keywordflow">continue</span>;
<a name="l01874"></a>01874             <span class="comment">/* if the constants are such that </span>
<a name="l01875"></a>01875 <span class="comment">             * the sum c1+c2 is negative then the constraints conflict</span>
<a name="l01876"></a>01876 <span class="comment">             */</span>
<a name="l01877"></a>01877             <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmp);
<a name="l01878"></a>01878             <a class="code" href="source_2arith_2arithmetique_8h.html#aea216a0e750144f0e6eb9b0a82583739">value_addto</a>(tmp, Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row][1+k], 
<a name="l01879"></a>01879                              Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[nrow][1+k]);
<a name="l01880"></a>01880             <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a0b5c341e5cae69bf0078a74dbbbaead0">value_sign</a>(tmp) &lt; 0) {
<a name="l01881"></a>01881                 <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row], 0, Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1);
<a name="l01882"></a>01882                 <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[nrow], 0, Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1);
<a name="l01883"></a>01883                 <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[row][1+k], 1);
<a name="l01884"></a>01884                 <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[nrow][1+k], 1);
<a name="l01885"></a>01885                 found = 1;
<a name="l01886"></a>01886             }
<a name="l01887"></a>01887             <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l01888"></a>01888             <span class="keywordflow">if</span> (found)
<a name="l01889"></a>01889                 <span class="keywordflow">break</span>;
<a name="l01890"></a>01890         }
<a name="l01891"></a>01891     }
<a name="l01892"></a>01892     <span class="keywordflow">return</span> found;
<a name="l01893"></a>01893 }
<a name="l01894"></a>01894 <span class="comment"></span>
<a name="l01895"></a>01895 <span class="comment">/**</span>
<a name="l01896"></a>01896 <span class="comment"></span>
<a name="l01897"></a>01897 <span class="comment">Given a matrix of constraints (&apos;Constraints&apos;), construct and return a </span>
<a name="l01898"></a>01898 <span class="comment">polyhedron.</span>
<a name="l01899"></a>01899 <span class="comment"></span>
<a name="l01900"></a>01900 <span class="comment">@param Constraints Constraints (may be modified!)</span>
<a name="l01901"></a>01901 <span class="comment">@param NbMaxRays Estimated number of rays in the ray matrix of the</span>
<a name="l01902"></a>01902 <span class="comment">polyhedron.</span>
<a name="l01903"></a>01903 <span class="comment">@return newly allocated Polyhedron</span>
<a name="l01904"></a>01904 <span class="comment"></span>
<a name="l01905"></a>01905 <span class="comment">*/</span> 
<a name="l01906"></a><a class="code" href="polyhedron_8h.html#aefb77665a187d751bdd44f106b12465e">01906</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#aefb77665a187d751bdd44f106b12465e" title="Given a matrix of constraints (&amp;#39;Constraints&amp;#39;), construct and return a polyhedron...">Constraints2Polyhedron</a>(<a class="code" href="structmatrix.html">Matrix</a> *Constraints,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l01907"></a>01907   
<a name="l01908"></a>01908   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol = NULL;
<a name="l01909"></a>01909   <a class="code" href="structmatrix.html">Matrix</a> *Ray = NULL;
<a name="l01910"></a>01910   <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a> = NULL;
<a name="l01911"></a>01911   <span class="keywordtype">unsigned</span> Dimension, nbcolumns;
<a name="l01912"></a>01912   <span class="keywordtype">int</span> i;
<a name="l01913"></a>01913 
<a name="l01914"></a>01914   Dimension = Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a> - 1;  <span class="comment">/* Homogeneous Dimension */</span>
<a name="l01915"></a>01915   <span class="keywordflow">if</span> (Dimension &lt; 1) {
<a name="l01916"></a>01916     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Constraints2Polyhedron&quot;</span>,<span class="stringliteral">&quot;invalidpoly&quot;</span>,<span class="stringliteral">&quot;invalid polyhedron dimension&quot;</span>);
<a name="l01917"></a>01917     <span class="keywordflow">return</span> 0;
<a name="l01918"></a>01918   }
<a name="l01919"></a>01919   
<a name="l01920"></a>01920   <span class="comment">/* If there is no constraint in the constraint matrix, return universe */</span>
<a name="l01921"></a>01921   <span class="comment">/* polyhderon.                                                         */</span>
<a name="l01922"></a>01922   <span class="keywordflow">if</span> (Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>==0) {  
<a name="l01923"></a>01923     Pol = <a class="code" href="polyhedron_8c.html#a832c074e0ce9da3df126dc7d51248276">Universe_Polyhedron</a>(Dimension-1);
<a name="l01924"></a>01924     <span class="keywordflow">return</span> Pol;
<a name="l01925"></a>01925   }
<a name="l01926"></a>01926 
<a name="l01927"></a>01927   <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxRays, <a class="code" href="types_8h.html#a754586a0aee88f21ad4c98b1cddee1be">POL_NO_DUAL</a>)) {
<a name="l01928"></a>01928     <span class="keywordtype">unsigned</span> NbEq;
<a name="l01929"></a>01929     <span class="keywordtype">unsigned</span> Rank;
<a name="l01930"></a>01930     Value tmp;
<a name="l01931"></a>01931     <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxRays, <a class="code" href="types_8h.html#ad8b11210e90424f4d7be767b93ae2f72">POL_INTEGER</a>))
<a name="l01932"></a>01932       <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmp);
<a name="l01933"></a>01933     <span class="keywordflow">do</span> {
<a name="l01934"></a>01934       NbEq = 0;
<a name="l01935"></a>01935       <span class="comment">/* Move equalities up */</span>
<a name="l01936"></a>01936       <span class="keywordflow">for</span> (i = 0; i &lt; Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>; ++i)
<a name="l01937"></a>01937         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0])) {
<a name="l01938"></a>01938           <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxRays, <a class="code" href="types_8h.html#ad8b11210e90424f4d7be767b93ae2f72">POL_INTEGER</a>) &amp;&amp;
<a name="l01939"></a>01939             <a class="code" href="vector_8c.html#ae6b570a9b1d0273b6cad4dab66fd9c71">ConstraintSimplify</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], 
<a name="l01940"></a>01940                                Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], Dimension+1, &amp;tmp)) {
<a name="l01941"></a>01941             <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l01942"></a>01942             <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Dimension-1);
<a name="l01943"></a>01943           }
<a name="l01944"></a>01944           <span class="comment">/* detect 1 == 0, possibly created by ImplicitEqualities */</span>
<a name="l01945"></a>01945           <span class="keywordflow">if</span> (<a class="code" href="vector_8c.html#ab719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i]+1, Dimension-1) == -1 &amp;&amp;
<a name="l01946"></a>01946               <a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][Dimension])) {
<a name="l01947"></a>01947             <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxRays, <a class="code" href="types_8h.html#ad8b11210e90424f4d7be767b93ae2f72">POL_INTEGER</a>))
<a name="l01948"></a>01948               <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l01949"></a>01949             <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Dimension-1);
<a name="l01950"></a>01950           }
<a name="l01951"></a>01951           <span class="keywordflow">if</span> (i != NbEq)
<a name="l01952"></a>01952             <a class="code" href="Matop_8c.html#acf8ce28d22ae1fabdf97ac6c4e86341a">ExchangeRows</a>(Constraints, i, NbEq);
<a name="l01953"></a>01953           ++NbEq;
<a name="l01954"></a>01954         }
<a name="l01955"></a>01955       Rank = <a class="code" href="polyhedron_8c.html#a671d2a19d0c376dec383521e78faa70a">Gauss</a>(Constraints, NbEq, Dimension);
<a name="l01956"></a>01956       <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxRays, <a class="code" href="types_8h.html#ad8b11210e90424f4d7be767b93ae2f72">POL_INTEGER</a>))
<a name="l01957"></a>01957         <span class="keywordflow">for</span> (i = NbEq; i &lt; Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>; ++i)
<a name="l01958"></a>01958           <a class="code" href="vector_8c.html#ae6b570a9b1d0273b6cad4dab66fd9c71">ConstraintSimplify</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], 
<a name="l01959"></a>01959                              Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], Dimension+1, &amp;tmp);
<a name="l01960"></a>01960       <a class="code" href="polyhedron_8c.html#a0e3d47f133646ddcbb799914ac84dbcd">SortConstraints</a>(Constraints, NbEq);
<a name="l01961"></a>01961     } <span class="keywordflow">while</span> (<a class="code" href="polyhedron_8c.html#af5a2e545702901c2deb13234096810c2">ImplicitEqualities</a>(Constraints, NbEq));
<a name="l01962"></a>01962     <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxRays, <a class="code" href="types_8h.html#ad8b11210e90424f4d7be767b93ae2f72">POL_INTEGER</a>))
<a name="l01963"></a>01963       <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l01964"></a>01964     Pol = <a class="code" href="polyhedron_8c.html#aa308ade6448cc5544e21d59e86a53ddf">Polyhedron_Alloc</a>(Dimension-1, Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> - (NbEq-Rank), 0);
<a name="l01965"></a>01965     <span class="keywordflow">if</span> (Rank &gt; 0)
<a name="l01966"></a>01966         <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[0], Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], 
<a name="l01967"></a>01967                     Rank * Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l01968"></a>01968     <span class="keywordflow">if</span> (Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> &gt; NbEq)
<a name="l01969"></a>01969         <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbEq], Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[Rank], 
<a name="l01970"></a>01970                     (Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> - NbEq) * Constraints-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l01971"></a>01971     Pol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a> = Rank;
<a name="l01972"></a>01972     <span class="comment">/* Make sure nobody accesses the rays by accident */</span>
<a name="l01973"></a>01973     Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a> = 0;
<a name="l01974"></a>01974     <a class="code" href="types_8h.html#ab04b7b56e2789336fbc544896cb477f9">F_SET</a>(Pol, <a class="code" href="types_8h.html#a2ac4c28a3acbe4578e03ad20db7939cc">POL_VALID</a> | <a class="code" href="types_8h.html#a1869e11b8e9a1e9e89e8145c242e0eea">POL_INEQUALITIES</a>);
<a name="l01975"></a>01975     <span class="keywordflow">return</span> Pol;
<a name="l01976"></a>01976   }
<a name="l01977"></a>01977 
<a name="l01978"></a>01978   <span class="keywordflow">if</span> (Dimension &gt; NbMaxRays)
<a name="l01979"></a>01979     NbMaxRays = Dimension;
<a name="l01980"></a>01980     
<a name="l01981"></a>01981   <span class="comment">/*</span>
<a name="l01982"></a>01982 <span class="comment">   * Rather than adding a &apos;positivity constraint&apos;, it is better to</span>
<a name="l01983"></a>01983 <span class="comment">   * initialize the lineality space with line in each of the index</span>
<a name="l01984"></a>01984 <span class="comment">   * dimensions, but no line in the lambda dimension. Then initialize</span>
<a name="l01985"></a>01985 <span class="comment">   * the ray space with an origin at 0.  This is what you get anyway,</span>
<a name="l01986"></a>01986 <span class="comment">   * after the positivity constraint has been processed by Chernikova</span>
<a name="l01987"></a>01987 <span class="comment">   * function.</span>
<a name="l01988"></a>01988 <span class="comment">   */</span>
<a name="l01989"></a>01989 
<a name="l01990"></a>01990   <span class="comment">/* Allocate and initialize the Ray Space */</span>
<a name="l01991"></a>01991   Ray = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbMaxRays, Dimension+1);
<a name="l01992"></a>01992   <span class="keywordflow">if</span>(!Ray) {
<a name="l01993"></a>01993     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Constraints2Polyhedron&quot;</span>,<span class="stringliteral">&quot;outofmem&quot;</span>,<span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l01994"></a>01994     <span class="keywordflow">return</span> 0;
<a name="l01995"></a>01995   }
<a name="l01996"></a>01996   <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(Ray-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>,0, NbMaxRays * (Dimension+1));
<a name="l01997"></a>01997   <span class="keywordflow">for</span> (i=0; i&lt;Dimension; i++) {    
<a name="l01998"></a>01998     
<a name="l01999"></a>01999     <span class="comment">/* Ray-&gt;p[i][i+1] = 1 */</span>
<a name="l02000"></a>02000     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][i+1],1);
<a name="l02001"></a>02001   }
<a name="l02002"></a>02002 
<a name="l02003"></a>02003   <span class="comment">/* Ray-&gt;p[Dimension-1][0] = 1 : mark for ray */</span>
<a name="l02004"></a>02004   <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[Dimension-1][0],1);
<a name="l02005"></a>02005   Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> = Dimension; 
<a name="l02006"></a>02006 
<a name="l02007"></a>02007   <span class="comment">/* Initialize the Sat Matrix */</span>
<a name="l02008"></a>02008   nbcolumns = (Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> - 1)/(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>)*8) + 1;
<a name="l02009"></a>02009   Sat = <a class="code" href="polyhedron_8c.html#a010deaa3d3f81aaa979f67bb0012d109">SMAlloc</a>(NbMaxRays, nbcolumns);
<a name="l02010"></a>02010   <a class="code" href="polyhedron_8c.html#a3351961690e2b071105b7bb4be0b7127">SMVector_Init</a>(Sat-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a>,Dimension*nbcolumns);
<a name="l02011"></a>02011   Sat-&gt;<a class="code" href="structSatMatrix.html#a08d0db0d2eda3b8bdcc316eabadaca09">NbRows</a> = Dimension;
<a name="l02012"></a>02012 
<a name="l02013"></a>02013   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l02014"></a>02014 
<a name="l02015"></a>02015     <span class="comment">/* In case of overflow, free the allocated memory and forward. */</span>    
<a name="l02016"></a>02016     <span class="keywordflow">if</span> (Sat) <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l02017"></a>02017     <span class="keywordflow">if</span> (Ray) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ray);
<a name="l02018"></a>02018     <span class="keywordflow">if</span> (Pol) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol);
<a name="l02019"></a>02019     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l02020"></a>02020   }
<a name="l02021"></a>02021   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l02022"></a>02022 
<a name="l02023"></a>02023     <span class="comment">/* Create ray matrix &apos;Ray&apos; from constraint matrix &apos;Constraints&apos; */</span>
<a name="l02024"></a>02024     <a class="code" href="polyhedron_8c.html#a6138e0e907fa19ecc60710b1ab1868c1">Chernikova</a>(Constraints,Ray,Sat,Dimension-1,NbMaxRays,0,0);
<a name="l02025"></a>02025 
<a name="l02026"></a>02026 <span class="preprocessor">#ifdef POLY_DEBUG</span>
<a name="l02027"></a>02027 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[constraints2polyhedron]\nConstraints = &quot;</span>);
<a name="l02028"></a>02028     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Constraints);
<a name="l02029"></a>02029     fprintf(stderr, <span class="stringliteral">&quot;\nRay = &quot;</span>);
<a name="l02030"></a>02030     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l02031"></a>02031     fprintf(stderr, <span class="stringliteral">&quot;\nSat = &quot;</span>);
<a name="l02032"></a>02032     <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a>(Sat);
<a name="l02033"></a>02033 <span class="preprocessor">#endif</span>
<a name="l02034"></a>02034 <span class="preprocessor"></span>    
<a name="l02035"></a>02035     <span class="comment">/* Remove the redundant constraints and create the polyhedron */</span>
<a name="l02036"></a>02036     Pol = <a class="code" href="polyhedron_8c.html#a1288eb192e28147e2572f35ed3a82de3">Remove_Redundants</a>(Constraints,Ray,Sat,0);
<a name="l02037"></a>02037   } <span class="comment">/* end of TRY */</span>
<a name="l02038"></a>02038 
<a name="l02039"></a>02039   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02040"></a>02040   
<a name="l02041"></a>02041 <span class="preprocessor">#ifdef POLY_DEBUG</span>
<a name="l02042"></a>02042 <span class="preprocessor"></span>  fprintf(stderr, <span class="stringliteral">&quot;\nPol = &quot;</span>);
<a name="l02043"></a>02043   <a class="code" href="polyhedron_8c.html#ad87595bd01c5cdd0f3933824943db496">Polyhedron_Print</a>(stderr,<span class="stringliteral">&quot;%4d&quot;</span>,Pol);
<a name="l02044"></a>02044 <span class="preprocessor">#endif</span>
<a name="l02045"></a>02045 <span class="preprocessor"></span>  
<a name="l02046"></a>02046   <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat), Sat = NULL;
<a name="l02047"></a>02047   <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ray), Ray = NULL; 
<a name="l02048"></a>02048   <span class="keywordflow">return</span> Pol;
<a name="l02049"></a>02049 } <span class="comment">/* Constraints2Polyhedron */</span>
<a name="l02050"></a>02050 
<a name="l02051"></a>02051 <span class="preprocessor">#undef POLY_DEBUG</span>
<a name="l02052"></a>02052 <span class="preprocessor"></span>
<a name="l02053"></a>02053 <span class="comment">/* </span>
<a name="l02054"></a>02054 <span class="comment"> * Given a polyhedron &apos;Pol&apos;, return a matrix of constraints. </span>
<a name="l02055"></a>02055 <span class="comment"> */</span>
<a name="l02056"></a><a class="code" href="polyhedron_8h.html#a69417a994cd682d0c391ecff6d223cd2">02056</a> <a class="code" href="structmatrix.html">Matrix</a> *<a class="code" href="polyhedron_8c.html#a69417a994cd682d0c391ecff6d223cd2">Polyhedron2Constraints</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol) {
<a name="l02057"></a>02057   
<a name="l02058"></a>02058   <a class="code" href="structmatrix.html">Matrix</a>     *Mat;
<a name="l02059"></a>02059   <span class="keywordtype">unsigned</span> NbConstraints,Dimension;
<a name="l02060"></a>02060 
<a name="l02061"></a>02061   <a class="code" href="polyhedron_8h.html#a54a764faf683e794f4db092c8d050104">POL_ENSURE_INEQUALITIES</a>(Pol);
<a name="l02062"></a>02062   
<a name="l02063"></a>02063   NbConstraints = Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l02064"></a>02064   Dimension     = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;
<a name="l02065"></a>02065   Mat = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbConstraints,Dimension);
<a name="l02066"></a>02066   <span class="keywordflow">if</span>(!Mat) {
<a name="l02067"></a>02067     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron2Constraints&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02068"></a>02068     <span class="keywordflow">return</span> 0;
<a name="l02069"></a>02069   }
<a name="l02070"></a>02070   <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0],Mat-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>,NbConstraints * Dimension);
<a name="l02071"></a>02071   <span class="keywordflow">return</span> Mat;
<a name="l02072"></a>02072 } <span class="comment">/* Polyhedron2Constraints */</span>
<a name="l02073"></a>02073 <span class="comment"></span>
<a name="l02074"></a>02074 <span class="comment">/** </span>
<a name="l02075"></a>02075 <span class="comment"></span>
<a name="l02076"></a>02076 <span class="comment">Given a matrix of rays &apos;Ray&apos;, create and return a polyhedron. </span>
<a name="l02077"></a>02077 <span class="comment"></span>
<a name="l02078"></a>02078 <span class="comment">@param Ray Rays (may be modified!)</span>
<a name="l02079"></a>02079 <span class="comment">@param NbMaxConstrs Estimated number of constraints in the polyhedron.</span>
<a name="l02080"></a>02080 <span class="comment">@return newly allocated Polyhedron</span>
<a name="l02081"></a>02081 <span class="comment"></span>
<a name="l02082"></a>02082 <span class="comment">*/</span> 
<a name="l02083"></a><a class="code" href="polyhedron_8h.html#a3d5b12b71133d329c88db195b56d9feb">02083</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a3d5b12b71133d329c88db195b56d9feb" title="Given a matrix of rays &amp;#39;Ray&amp;#39;, create and return a polyhedron.">Rays2Polyhedron</a>(<a class="code" href="structmatrix.html">Matrix</a> *Ray,<span class="keywordtype">unsigned</span> NbMaxConstrs) {
<a name="l02084"></a>02084   
<a name="l02085"></a>02085   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol = NULL;
<a name="l02086"></a>02086   <a class="code" href="structmatrix.html">Matrix</a> *Mat = NULL;
<a name="l02087"></a>02087   <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a> = NULL, *SatTranspose = NULL;
<a name="l02088"></a>02088   <span class="keywordtype">unsigned</span> Dimension, nbcolumns;
<a name="l02089"></a>02089   <span class="keywordtype">int</span> i;
<a name="l02090"></a>02090   
<a name="l02091"></a>02091   Dimension = Ray-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1;        <span class="comment">/* Homogeneous Dimension */</span>
<a name="l02092"></a>02092   Sat = NULL;
<a name="l02093"></a>02093   SatTranspose = NULL;
<a name="l02094"></a>02094   Mat = NULL;
<a name="l02095"></a>02095   
<a name="l02096"></a>02096   <span class="keywordflow">if</span> (Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>==0) {  
<a name="l02097"></a>02097     
<a name="l02098"></a>02098     <span class="comment">/* If there is no ray in the matrix &apos;Ray&apos;, return an empty polyhedron */</span>
<a name="l02099"></a>02099     Pol = <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Dimension-1);
<a name="l02100"></a>02100     <span class="keywordflow">return</span>(Pol);
<a name="l02101"></a>02101   }
<a name="l02102"></a>02102 
<a name="l02103"></a>02103   <span class="comment">/* Ignore for now */</span>
<a name="l02104"></a>02104   <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxConstrs, <a class="code" href="types_8h.html#a754586a0aee88f21ad4c98b1cddee1be">POL_NO_DUAL</a>))
<a name="l02105"></a>02105     NbMaxConstrs = 0;
<a name="l02106"></a>02106 
<a name="l02107"></a>02107   <span class="keywordflow">if</span> (Dimension &gt; NbMaxConstrs)
<a name="l02108"></a>02108     NbMaxConstrs = Dimension;
<a name="l02109"></a>02109   
<a name="l02110"></a>02110   <span class="comment">/* Allocate space for constraint matrix &apos;Mat&apos; */</span>
<a name="l02111"></a>02111   Mat = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbMaxConstrs,Dimension+1);
<a name="l02112"></a>02112   <span class="keywordflow">if</span>(!Mat) {
<a name="l02113"></a>02113     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Rays2Polyhedron&quot;</span>,<span class="stringliteral">&quot;outofmem&quot;</span>,<span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02114"></a>02114     <span class="keywordflow">return</span> 0;
<a name="l02115"></a>02115   }
<a name="l02116"></a>02116   
<a name="l02117"></a>02117   <span class="comment">/* Initialize the constraint matrix &apos;Mat&apos; */</span>
<a name="l02118"></a>02118   <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(Mat-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>,0,NbMaxConstrs * (Dimension+1));
<a name="l02119"></a>02119   <span class="keywordflow">for</span> (i=0; i&lt;Dimension; i++) {
<a name="l02120"></a>02120     
<a name="l02121"></a>02121     <span class="comment">/* Mat-&gt;p[i][i+1]=1 */</span>
<a name="l02122"></a>02122     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][i+1],1);
<a name="l02123"></a>02123   }
<a name="l02124"></a>02124   
<a name="l02125"></a>02125   <span class="comment">/* Allocate and assign the saturation matrix. Remember we are using a */</span>
<a name="l02126"></a>02126   <span class="comment">/* transposed saturation matrix referenced by (constraint,ray) pair.  */</span>
<a name="l02127"></a>02127   Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> = Dimension;
<a name="l02128"></a>02128   nbcolumns = (Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> -1)/(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>)*8) + 1;
<a name="l02129"></a>02129   SatTranspose = <a class="code" href="polyhedron_8c.html#a010deaa3d3f81aaa979f67bb0012d109">SMAlloc</a>(NbMaxConstrs,nbcolumns);
<a name="l02130"></a>02130   <a class="code" href="polyhedron_8c.html#a3351961690e2b071105b7bb4be0b7127">SMVector_Init</a>(SatTranspose-&gt;p[0],Dimension * nbcolumns);
<a name="l02131"></a>02131   SatTranspose-&gt;NbRows = Dimension;
<a name="l02132"></a>02132   
<a name="l02133"></a>02133 <span class="preprocessor">#ifdef POLY_DEBUG</span>
<a name="l02134"></a>02134 <span class="preprocessor"></span>  fprintf(stderr, <span class="stringliteral">&quot;[ray2polyhedron: Before]\nRay = &quot;</span>);
<a name="l02135"></a>02135   <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l02136"></a>02136   fprintf(stderr, <span class="stringliteral">&quot;\nConstraints = &quot;</span>);
<a name="l02137"></a>02137   <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l02138"></a>02138   fprintf(stderr, <span class="stringliteral">&quot;\nSatTranspose = &quot;</span>);
<a name="l02139"></a>02139   <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a> (SatTranspose);
<a name="l02140"></a>02140 <span class="preprocessor">#endif</span>
<a name="l02141"></a>02141 <span class="preprocessor"></span>  
<a name="l02142"></a>02142   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l02143"></a>02143     
<a name="l02144"></a>02144     <span class="comment">/* In case of overflow, free the allocated memory before forwarding</span>
<a name="l02145"></a>02145 <span class="comment">     * the exception. </span>
<a name="l02146"></a>02146 <span class="comment">     */</span>
<a name="l02147"></a>02147     <span class="keywordflow">if</span> (SatTranspose) <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;SatTranspose);
<a name="l02148"></a>02148     <span class="keywordflow">if</span> (Sat) <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l02149"></a>02149     <span class="keywordflow">if</span> (Mat) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);
<a name="l02150"></a>02150     <span class="keywordflow">if</span> (Pol) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol);
<a name="l02151"></a>02151     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l02152"></a>02152   }
<a name="l02153"></a>02153   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l02154"></a>02154     
<a name="l02155"></a>02155     <span class="comment">/* Create constraint matrix &apos;Mat&apos; from ray matrix &apos;Ray&apos; */</span> 
<a name="l02156"></a>02156     <a class="code" href="polyhedron_8c.html#a6138e0e907fa19ecc60710b1ab1868c1">Chernikova</a>(Ray,Mat,SatTranspose,Dimension,NbMaxConstrs,0,1);
<a name="l02157"></a>02157     
<a name="l02158"></a>02158 <span class="preprocessor">#ifdef POLY_DEBUG</span>
<a name="l02159"></a>02159 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;[ray2polyhedron: After]\nRay = &quot;</span>);
<a name="l02160"></a>02160     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Ray);
<a name="l02161"></a>02161     fprintf(stderr, <span class="stringliteral">&quot;\nConstraints = &quot;</span>);
<a name="l02162"></a>02162     <a class="code" href="matrix_8c.html#ad4c3c350dba633f72bbcf3609b6b67d7">Matrix_Print</a>(stderr,0,Mat);
<a name="l02163"></a>02163     fprintf(stderr, <span class="stringliteral">&quot;\nSatTranspose = &quot;</span>);
<a name="l02164"></a>02164     <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a> (SatTranspose);
<a name="l02165"></a>02165 <span class="preprocessor">#endif</span>
<a name="l02166"></a>02166 <span class="preprocessor"></span>    
<a name="l02167"></a>02167     <span class="comment">/* Transform the saturation matrix &apos;SatTranspose&apos; in the standard  */</span>
<a name="l02168"></a>02168     <span class="comment">/* format, that is, ray X constraint format.                       */</span>
<a name="l02169"></a>02169     Sat = <a class="code" href="polyhedron_8c.html#ae90f313a0b016d966ced7e9bf09bc4f1">TransformSat</a>(Mat,Ray,SatTranspose);
<a name="l02170"></a>02170     
<a name="l02171"></a>02171 <span class="preprocessor">#ifdef POLY_DEBUG</span>
<a name="l02172"></a>02172 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;\nSat =&quot;</span>);
<a name="l02173"></a>02173     <a class="code" href="polyhedron_8c.html#ae7ab7efd2892ac6c61e2acc8f1142f1c">SMPrint</a>(Sat);
<a name="l02174"></a>02174 <span class="preprocessor">#endif</span>
<a name="l02175"></a>02175 <span class="preprocessor"></span>    
<a name="l02176"></a>02176     <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;SatTranspose), SatTranspose = NULL;
<a name="l02177"></a>02177     
<a name="l02178"></a>02178     <span class="comment">/* Remove redundant rays from the ray matrix &apos;Ray&apos; */</span>
<a name="l02179"></a>02179     Pol = <a class="code" href="polyhedron_8c.html#a1288eb192e28147e2572f35ed3a82de3">Remove_Redundants</a>(Mat,Ray,Sat,0);
<a name="l02180"></a>02180   } <span class="comment">/* of TRY */</span>
<a name="l02181"></a>02181   
<a name="l02182"></a>02182   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02183"></a>02183   
<a name="l02184"></a>02184 <span class="preprocessor">#ifdef POLY_DEBUG</span>
<a name="l02185"></a>02185 <span class="preprocessor"></span>  fprintf(stderr, <span class="stringliteral">&quot;\nPol = &quot;</span>);
<a name="l02186"></a>02186   <a class="code" href="polyhedron_8c.html#ad87595bd01c5cdd0f3933824943db496">Polyhedron_Print</a>(stderr,<span class="stringliteral">&quot;%4d&quot;</span>,Pol);
<a name="l02187"></a>02187 <span class="preprocessor">#endif</span>
<a name="l02188"></a>02188 <span class="preprocessor"></span>  
<a name="l02189"></a>02189   <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l02190"></a>02190   <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);
<a name="l02191"></a>02191   <span class="keywordflow">return</span> Pol;
<a name="l02192"></a>02192 } <span class="comment">/* Rays2Polyhedron */</span>
<a name="l02193"></a>02193 
<a name="l02194"></a>02194 <span class="comment">/*</span>
<a name="l02195"></a>02195 <span class="comment"> * Compute the dual representation if P only contains one representation.</span>
<a name="l02196"></a>02196 <span class="comment"> * Currently only handles the case where only the equalities are known.</span>
<a name="l02197"></a>02197 <span class="comment"> */</span>
<a name="l02198"></a><a class="code" href="polyhedron_8h.html#a4e3db79bcd2da3284175f960012af17a">02198</a> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#a4e3db79bcd2da3284175f960012af17a">Polyhedron_Compute_Dual</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *P)
<a name="l02199"></a>02199 {
<a name="l02200"></a>02200   <span class="keywordflow">if</span> (!<a class="code" href="types_8h.html#a19f1ae711bb0e3063ba1962cb8a898a0">F_ISSET</a>(P, <a class="code" href="types_8h.html#a2ac4c28a3acbe4578e03ad20db7939cc">POL_VALID</a>))
<a name="l02201"></a>02201     <span class="keywordflow">return</span>;
<a name="l02202"></a>02202 
<a name="l02203"></a>02203   <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a19f1ae711bb0e3063ba1962cb8a898a0">F_ISSET</a>(P, <a class="code" href="types_8h.html#adef192e3530c5e1fcb2c44858a78f703">POL_FACETS</a> | <a class="code" href="types_8h.html#a18cb4aab2aec424306ea8f67f6dfc9b0">POL_VERTICES</a>))
<a name="l02204"></a>02204     <span class="keywordflow">return</span>;
<a name="l02205"></a>02205 
<a name="l02206"></a>02206   <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a19f1ae711bb0e3063ba1962cb8a898a0">F_ISSET</a>(P, <a class="code" href="types_8h.html#a1869e11b8e9a1e9e89e8145c242e0eea">POL_INEQUALITIES</a>)) {
<a name="l02207"></a>02207     <a class="code" href="structmatrix.html">Matrix</a> M;
<a name="l02208"></a>02208     <a class="code" href="structpolyhedron.html">Polyhedron</a> tmp, *Q;
<a name="l02209"></a>02209     <span class="comment">/* Pretend P is a Matrix for a second */</span>
<a name="l02210"></a>02210     M.<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> = P-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l02211"></a>02211     M.<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a> = P-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;
<a name="l02212"></a>02212     M.<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a> = P-&gt;<a class="code" href="structpolyhedron.html#a3681618067c7bf2a0bd5e805871283f5">p_Init</a>;
<a name="l02213"></a>02213     M.<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a> = P-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>;
<a name="l02214"></a>02214     Q = <a class="code" href="polyhedron_8c.html#aefb77665a187d751bdd44f106b12465e" title="Given a matrix of constraints (&amp;#39;Constraints&amp;#39;), construct and return a polyhedron...">Constraints2Polyhedron</a>(&amp;M, 0);
<a name="l02215"></a>02215 
<a name="l02216"></a>02216     <span class="comment">/* Switch contents of P and Q ... */</span>
<a name="l02217"></a>02217     tmp = *Q;
<a name="l02218"></a>02218     *Q = *P;
<a name="l02219"></a>02219     *P = tmp;
<a name="l02220"></a>02220     <span class="comment">/* ... but keep the next pointer */</span>
<a name="l02221"></a>02221     P-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = Q-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l02222"></a>02222     <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Q);
<a name="l02223"></a>02223     <span class="keywordflow">return</span>;
<a name="l02224"></a>02224   }
<a name="l02225"></a>02225 
<a name="l02226"></a>02226   <span class="comment">/* other cases not handled yet */</span>
<a name="l02227"></a>02227   <a class="code" href="assert_8h.html#a07d17d6d5d1074c0969bc5d3c3d1d84a">assert</a>(0);
<a name="l02228"></a>02228 }
<a name="l02229"></a>02229 
<a name="l02230"></a>02230 <span class="comment">/*   </span>
<a name="l02231"></a>02231 <span class="comment"> * Build a saturation matrix from constraint matrix &apos;Mat&apos; and ray matrix </span>
<a name="l02232"></a>02232 <span class="comment"> * &apos;Ray&apos;. Only &apos;NbConstraints&apos; constraint of matrix &apos;Mat&apos; are considered </span>
<a name="l02233"></a>02233 <span class="comment"> * in creating the saturation matrix. &apos;NbMaxRays&apos; is the maximum number </span>
<a name="l02234"></a>02234 <span class="comment"> * of rows (rays) allowed in the saturation matrix.</span>
<a name="l02235"></a>02235 <span class="comment"> * Vin100&apos;s stuff, for the polyparam vertices to work.</span>
<a name="l02236"></a>02236 <span class="comment"> */</span>
<a name="l02237"></a><a class="code" href="polyhedron_8c.html#a542ec91dd2ace5b3faab3f02511d26bd">02237</a> <span class="keyword">static</span> <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyhedron_8c.html#a542ec91dd2ace5b3faab3f02511d26bd">BuildSat</a>(<a class="code" href="structmatrix.html">Matrix</a> *Mat,<a class="code" href="structmatrix.html">Matrix</a> *Ray,<span class="keywordtype">unsigned</span> NbConstraints,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l02238"></a>02238   
<a name="l02239"></a>02239   <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a> = NULL;
<a name="l02240"></a>02240   <span class="keywordtype">int</span> i, j, k, jx;
<a name="l02241"></a>02241   Value *p1, *p2, *p3;
<a name="l02242"></a>02242   <span class="keywordtype">unsigned</span> Dimension, NbRay, bx, nbcolumns;
<a name="l02243"></a>02243   
<a name="l02244"></a>02244   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l02245"></a>02245     <span class="keywordflow">if</span> (Sat) 
<a name="l02246"></a>02246       <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l02247"></a>02247     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l02248"></a>02248   }
<a name="l02249"></a>02249   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l02250"></a>02250     NbRay = Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l02251"></a>02251     Dimension = Mat-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1;   <span class="comment">/* Homogeneous Dimension */</span>
<a name="l02252"></a>02252     
<a name="l02253"></a>02253     <span class="comment">/* Build the Sat matrix */</span>
<a name="l02254"></a>02254     nbcolumns = (Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> - 1)/(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>)*8) + 1;
<a name="l02255"></a>02255     Sat = <a class="code" href="polyhedron_8c.html#a010deaa3d3f81aaa979f67bb0012d109">SMAlloc</a>(NbMaxRays,nbcolumns);
<a name="l02256"></a>02256     Sat-&gt;<a class="code" href="structSatMatrix.html#a08d0db0d2eda3b8bdcc316eabadaca09">NbRows</a> = NbRay;
<a name="l02257"></a>02257     <a class="code" href="polyhedron_8c.html#a3351961690e2b071105b7bb4be0b7127">SMVector_Init</a>(Sat-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a>, nbcolumns * NbRay);
<a name="l02258"></a>02258     jx=0; bx=<a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>;
<a name="l02259"></a>02259     <span class="keywordflow">for</span> (k=0; k&lt;NbConstraints; k++) {
<a name="l02260"></a>02260       <span class="keywordflow">for</span> (i=0; i&lt;NbRay; i++) {
<a name="l02261"></a>02261         
<a name="l02262"></a>02262         <span class="comment">/* Compute the dot product of ray(i) and constraint(k) and */</span>
<a name="l02263"></a>02263         <span class="comment">/* store in the status element of ray(i).                  */</span>
<a name="l02264"></a>02264         p1 = Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i]+1;
<a name="l02265"></a>02265         p2 = Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k]+1;
<a name="l02266"></a>02266         p3 = Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i];
<a name="l02267"></a>02267         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(*p3,0);
<a name="l02268"></a>02268         <span class="keywordflow">for</span> (j=0; j&lt;Dimension; j++) {
<a name="l02269"></a>02269           <a class="code" href="source_2arith_2arithmetique_8h.html#a9900fbd029b36f5887e587642a064a52">value_addmul</a>(*p3, *p1, *p2);
<a name="l02270"></a>02270           p1++; p2++;
<a name="l02271"></a>02271         }
<a name="l02272"></a>02272       }
<a name="l02273"></a>02273       <span class="keywordflow">for</span> (j=0; j&lt;NbRay; j++) {
<a name="l02274"></a>02274         
<a name="l02275"></a>02275         <span class="comment">/* Set 1 in the saturation matrix if the ray doesn&apos;t saturate */</span>
<a name="l02276"></a>02276         <span class="comment">/* the constraint, otherwise the entry is 0.                  */</span>
<a name="l02277"></a>02277         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][0]))
<a name="l02278"></a>02278           Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[j][jx]|=bx;
<a name="l02279"></a>02279       }
<a name="l02280"></a>02280       <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(jx, bx);
<a name="l02281"></a>02281     }
<a name="l02282"></a>02282   } <span class="comment">/* end of TRY */</span>
<a name="l02283"></a>02283   
<a name="l02284"></a>02284   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02285"></a>02285   <span class="keywordflow">return</span> Sat;
<a name="l02286"></a>02286 } <span class="comment">/* BuildSat */</span>
<a name="l02287"></a>02287 
<a name="l02288"></a>02288 <span class="comment">/* </span>
<a name="l02289"></a>02289 <span class="comment"> * Add &apos;Nbconstraints&apos; new constraints to polyhedron &apos;Pol&apos;. Constraints are </span>
<a name="l02290"></a>02290 <span class="comment"> * pointed by &apos;Con&apos; and the maximum allowed rays in the new polyhedron is</span>
<a name="l02291"></a>02291 <span class="comment"> * &apos;NbMaxRays&apos;.   </span>
<a name="l02292"></a>02292 <span class="comment"> */</span>
<a name="l02293"></a><a class="code" href="polyhedron_8h.html#a9690baafb863abbd2e8d5c4da2995416">02293</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a9690baafb863abbd2e8d5c4da2995416">AddConstraints</a>(Value *Con,<span class="keywordtype">unsigned</span> NbConstraints,<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l02294"></a>02294 
<a name="l02295"></a>02295   <a class="code" href="structpolyhedron.html">Polyhedron</a> *NewPol = NULL;
<a name="l02296"></a>02296   <a class="code" href="structmatrix.html">Matrix</a>   *Mat = NULL, *Ray = NULL;
<a name="l02297"></a>02297   <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a> = NULL;
<a name="l02298"></a>02298   <span class="keywordtype">unsigned</span> NbRay, NbCon, Dimension;
<a name="l02299"></a>02299 
<a name="l02300"></a>02300   <span class="keywordflow">if</span> (NbConstraints == 0)
<a name="l02301"></a>02301     <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(Pol);
<a name="l02302"></a>02302   
<a name="l02303"></a>02303   <a class="code" href="polyhedron_8h.html#a54a764faf683e794f4db092c8d050104">POL_ENSURE_INEQUALITIES</a>(Pol);
<a name="l02304"></a>02304   Dimension     = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> + 2;   <span class="comment">/* Homogeneous Dimension + Status */</span>
<a name="l02305"></a>02305 
<a name="l02306"></a>02306   <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxRays, <a class="code" href="types_8h.html#a754586a0aee88f21ad4c98b1cddee1be">POL_NO_DUAL</a>)) {
<a name="l02307"></a>02307     NbCon       = Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> + NbConstraints;
<a name="l02308"></a>02308     
<a name="l02309"></a>02309     Mat = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbCon, Dimension);
<a name="l02310"></a>02310     <span class="keywordflow">if</span> (!Mat) {
<a name="l02311"></a>02311       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;AddConstraints&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02312"></a>02312       <span class="keywordflow">return</span> NULL;
<a name="l02313"></a>02313     }
<a name="l02314"></a>02314     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[0], Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> * Dimension);
<a name="l02315"></a>02315     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Con, Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>], NbConstraints * Dimension);  
<a name="l02316"></a>02316     NewPol = <a class="code" href="polyhedron_8c.html#aefb77665a187d751bdd44f106b12465e" title="Given a matrix of constraints (&amp;#39;Constraints&amp;#39;), construct and return a polyhedron...">Constraints2Polyhedron</a>(Mat, NbMaxRays);
<a name="l02317"></a>02317     <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);  
<a name="l02318"></a>02318     <span class="keywordflow">return</span> NewPol;
<a name="l02319"></a>02319   }
<a name="l02320"></a>02320 
<a name="l02321"></a>02321   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol);
<a name="l02322"></a>02322 
<a name="l02323"></a>02323   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l02324"></a>02324     <span class="keywordflow">if</span> (NewPol) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(NewPol);
<a name="l02325"></a>02325     <span class="keywordflow">if</span> (Mat) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);
<a name="l02326"></a>02326     <span class="keywordflow">if</span> (Ray) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ray);
<a name="l02327"></a>02327     <span class="keywordflow">if</span> (Sat) <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l02328"></a>02328     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l02329"></a>02329   }
<a name="l02330"></a>02330   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l02331"></a>02331     NbRay       = Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>;
<a name="l02332"></a>02332     NbCon       = Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> + NbConstraints;
<a name="l02333"></a>02333 
<a name="l02334"></a>02334     <span class="keywordflow">if</span> (NbRay &gt; NbMaxRays)
<a name="l02335"></a>02335       NbMaxRays = NbRay;
<a name="l02336"></a>02336     
<a name="l02337"></a>02337     Mat = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbCon, Dimension);
<a name="l02338"></a>02338     <span class="keywordflow">if</span>(!Mat) {
<a name="l02339"></a>02339       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;AddConstraints&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02340"></a>02340       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02341"></a>02341       <span class="keywordflow">return</span> 0;
<a name="l02342"></a>02342     }
<a name="l02343"></a>02343     
<a name="l02344"></a>02344     <span class="comment">/* Copy constraints of polyhedron &apos;Pol&apos; to matrix &apos;Mat&apos; */</span>
<a name="l02345"></a>02345     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[0], Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> * Dimension);
<a name="l02346"></a>02346     
<a name="l02347"></a>02347     <span class="comment">/* Add the new constraints pointed by &apos;Con&apos; to matrix &apos;Mat&apos; */</span>
<a name="l02348"></a>02348     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Con, Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>], NbConstraints * Dimension);  
<a name="l02349"></a>02349     
<a name="l02350"></a>02350     <span class="comment">/* Allocate space for ray matrix &apos;Ray&apos; */</span>
<a name="l02351"></a>02351     Ray = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbMaxRays, Dimension);
<a name="l02352"></a>02352     <span class="keywordflow">if</span>(!Ray) {
<a name="l02353"></a>02353       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;AddConstraints&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02354"></a>02354       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02355"></a>02355       <span class="keywordflow">return</span> 0;
<a name="l02356"></a>02356     }
<a name="l02357"></a>02357     Ray-&gt;NbRows = NbRay;
<a name="l02358"></a>02358 
<a name="l02359"></a>02359     <span class="comment">/* Copy rays of polyhedron &apos;Pol&apos; to matrix &apos;Ray&apos; */</span>
<a name="l02360"></a>02360     <span class="keywordflow">if</span> (NbRay)
<a name="l02361"></a>02361         <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[0], Ray-&gt;p[0], NbRay * Dimension);  
<a name="l02362"></a>02362     
<a name="l02363"></a>02363     <span class="comment">/* Create the saturation matrix &apos;Sat&apos; from constraint matrix &apos;Mat&apos; and */</span>
<a name="l02364"></a>02364     <span class="comment">/* ray matrix &apos;Ray&apos; .                                                  */</span> 
<a name="l02365"></a>02365     Sat = <a class="code" href="polyhedron_8c.html#a542ec91dd2ace5b3faab3f02511d26bd">BuildSat</a>(Mat, Ray, Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>, NbMaxRays);
<a name="l02366"></a>02366     
<a name="l02367"></a>02367     <span class="comment">/* Create the ray matrix &apos;Ray&apos; from the constraint matrix &apos;Mat&apos; */</span>
<a name="l02368"></a>02368     <a class="code" href="errormsg_8c.html#aa587bf4e8c763fa5e95542df7eb070b7">Pol_status</a> = <a class="code" href="polyhedron_8c.html#a6138e0e907fa19ecc60710b1ab1868c1">Chernikova</a>(Mat, Ray, Sat, Pol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a>, NbMaxRays, Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>,0);
<a name="l02369"></a>02369     
<a name="l02370"></a>02370     <span class="comment">/* Remove redundant constraints from matrix &apos;Mat&apos; */</span>
<a name="l02371"></a>02371     NewPol = <a class="code" href="polyhedron_8c.html#a1288eb192e28147e2572f35ed3a82de3">Remove_Redundants</a>(Mat, Ray, Sat, 0);
<a name="l02372"></a>02372     
<a name="l02373"></a>02373   } <span class="comment">/* end of TRY */</span>
<a name="l02374"></a>02374   
<a name="l02375"></a>02375   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);  
<a name="l02376"></a>02376   <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l02377"></a>02377   <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ray);
<a name="l02378"></a>02378   <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);  
<a name="l02379"></a>02379   <span class="keywordflow">return</span> NewPol;
<a name="l02380"></a>02380 } <span class="comment">/* AddConstraints */</span>
<a name="l02381"></a>02381 
<a name="l02382"></a>02382 <span class="comment">/* </span>
<a name="l02383"></a>02383 <span class="comment"> * Return 1 if &apos;Pol1&apos; includes (covers) &apos;Pol2&apos;, 0 otherwise. </span>
<a name="l02384"></a>02384 <span class="comment"> * Polyhedron &apos;A&apos; includes polyhedron &apos;B&apos; if the rays of &apos;B&apos; saturate</span>
<a name="l02385"></a>02385 <span class="comment"> * the equalities and verify the inequalities of &apos;A&apos;. Both &apos;Pol1&apos; and </span>
<a name="l02386"></a>02386 <span class="comment"> * &apos;Pol2&apos; have same dimensions. </span>
<a name="l02387"></a>02387 <span class="comment"> */</span>
<a name="l02388"></a><a class="code" href="polyhedron_8h.html#a107a96d44465428ffcd25f1ab3d67b43">02388</a> <span class="keywordtype">int</span> <a class="code" href="polyhedron_8c.html#a107a96d44465428ffcd25f1ab3d67b43">PolyhedronIncludes</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol1,<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol2) {
<a name="l02389"></a>02389         
<a name="l02390"></a>02390   <span class="keywordtype">int</span> Dimension = Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> + 1;   <span class="comment">/* Homogenous Dimension */</span>
<a name="l02391"></a>02391   <span class="keywordtype">int</span> i, j, k;
<a name="l02392"></a>02392   Value *p1, *p2, p3;
<a name="l02393"></a>02393   
<a name="l02394"></a>02394   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(Pol1);
<a name="l02395"></a>02395   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol1);
<a name="l02396"></a>02396   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(Pol2);
<a name="l02397"></a>02397   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol2);
<a name="l02398"></a>02398 
<a name="l02399"></a>02399   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(p3); 
<a name="l02400"></a>02400   <span class="keywordflow">for</span> (k=0; k&lt;Pol1-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>; k++) {
<a name="l02401"></a>02401     <span class="keywordflow">for</span> (i=0;i&lt;Pol2-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>;i++) {
<a name="l02402"></a>02402       
<a name="l02403"></a>02403       <span class="comment">/* Compute the dot product of ray(i) and constraint(k) and store in p3 */</span>
<a name="l02404"></a>02404       p1 = Pol2-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[i]+1;
<a name="l02405"></a>02405       p2 = Pol1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[k]+1;
<a name="l02406"></a>02406       <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(p3,0);
<a name="l02407"></a>02407       <span class="keywordflow">for</span>(j=0;j&lt;Dimension;j++) {
<a name="l02408"></a>02408         <a class="code" href="source_2arith_2arithmetique_8h.html#a9900fbd029b36f5887e587642a064a52">value_addmul</a>(p3, *p1,*p2);
<a name="l02409"></a>02409         p1++; p2++;
<a name="l02410"></a>02410       }
<a name="l02411"></a>02411      
<a name="l02412"></a>02412       <span class="comment">/* If (p3 &lt; 0) or (p3 &gt; 0 and (constraint(k) is equality</span>
<a name="l02413"></a>02413 <span class="comment">                                     or ray(i) is a line)), return 0 */</span>
<a name="l02414"></a>02414       <span class="keywordflow">if</span>(<a class="code" href="source_2arith_2arithmetique_8h.html#af031da52c8a160fd1ee6e4c793f8c78a">value_neg_p</a>(p3) ||
<a name="l02415"></a>02415           (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(p3)
<a name="l02416"></a>02416              &amp;&amp; (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Pol1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[k][0]) || (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Pol2-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[i][0]))   ) )) {
<a name="l02417"></a>02417         <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); 
<a name="l02418"></a>02418         <span class="keywordflow">return</span> 0;
<a name="l02419"></a>02419       }
<a name="l02420"></a>02420     }
<a name="l02421"></a>02421   } 
<a name="l02422"></a>02422   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); 
<a name="l02423"></a>02423   <span class="keywordflow">return</span> 1;
<a name="l02424"></a>02424 } <span class="comment">/* PolyhedronIncludes */</span>
<a name="l02425"></a>02425 
<a name="l02426"></a>02426 <span class="comment">/*</span>
<a name="l02427"></a>02427 <span class="comment"> * Add Polyhedron &apos;Pol&apos; to polhedral domain &apos;PolDomain&apos;. If &apos;Pol&apos; covers</span>
<a name="l02428"></a>02428 <span class="comment"> * some polyhedron in the domain &apos;PolDomain&apos;, it is removed from the list.</span>
<a name="l02429"></a>02429 <span class="comment"> * On the other hand if some polyhedron in the domain covers polyhedron </span>
<a name="l02430"></a>02430 <span class="comment"> * &apos;Pol&apos; then &apos;Pol&apos; is not included in the domain.   </span>
<a name="l02431"></a>02431 <span class="comment"> */</span>
<a name="l02432"></a><a class="code" href="polyhedron_8h.html#a965fd466bed4b1dd143c426e51ac16c5">02432</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<a class="code" href="structpolyhedron.html">Polyhedron</a> *PolDomain) {
<a name="l02433"></a>02433   
<a name="l02434"></a>02434   <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a>, *pnext, *p_domain_end = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *) 0;
<a name="l02435"></a>02435   <span class="keywordtype">int</span> Redundant;
<a name="l02436"></a>02436   
<a name="l02437"></a>02437   <span class="keywordflow">if</span> (!Pol) 
<a name="l02438"></a>02438     <span class="keywordflow">return</span> PolDomain;
<a name="l02439"></a>02439   <span class="keywordflow">if</span> (!PolDomain)       
<a name="l02440"></a>02440     <span class="keywordflow">return</span> Pol;
<a name="l02441"></a>02441 
<a name="l02442"></a>02442   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(Pol);
<a name="l02443"></a>02443   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol);
<a name="l02444"></a>02444   
<a name="l02445"></a>02445   <span class="comment">/* Check for emptiness of polyhedron &apos;Pol&apos; */</span>
<a name="l02446"></a>02446   <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(Pol)) {
<a name="l02447"></a>02447     <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol);
<a name="l02448"></a>02448     <span class="keywordflow">return</span> PolDomain;
<a name="l02449"></a>02449   }
<a name="l02450"></a>02450   
<a name="l02451"></a>02451   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(PolDomain);
<a name="l02452"></a>02452   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(PolDomain);
<a name="l02453"></a>02453 
<a name="l02454"></a>02454   <span class="comment">/* Check for emptiness of polyhedral domain &apos;PolDomain&apos; */</span>
<a name="l02455"></a>02455   <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(PolDomain)) {
<a name="l02456"></a>02456     <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(PolDomain);
<a name="l02457"></a>02457     <span class="keywordflow">return</span> Pol;
<a name="l02458"></a>02458   }
<a name="l02459"></a>02459   
<a name="l02460"></a>02460   <span class="comment">/* Test &apos;Pol&apos; against the domain &apos;PolDomain&apos; */</span>
<a name="l02461"></a>02461   Redundant = 0;
<a name="l02462"></a>02462   <span class="keywordflow">for</span> (p=PolDomain,PolDomain=(<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0; p; p=pnext) {
<a name="l02463"></a>02463     
<a name="l02464"></a>02464     <span class="comment">/* If &apos;Pol&apos; covers &apos;p&apos; */</span>    
<a name="l02465"></a>02465     <span class="keywordflow">if</span> (<a class="code" href="polyhedron_8c.html#a107a96d44465428ffcd25f1ab3d67b43">PolyhedronIncludes</a>(Pol, p))
<a name="l02466"></a>02466     {
<a name="l02467"></a>02467        <span class="comment">/* free p */</span>
<a name="l02468"></a>02468                  pnext = p-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l02469"></a>02469        <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>( p );
<a name="l02470"></a>02470        <span class="keywordflow">continue</span>;
<a name="l02471"></a>02471     }
<a name="l02472"></a>02472 
<a name="l02473"></a>02473     <span class="comment">/* Add polyhedron p to the new domain list */</span>
<a name="l02474"></a>02474     <span class="keywordflow">if</span> (!PolDomain) PolDomain = p; <span class="keywordflow">else</span> p_domain_end-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = p;
<a name="l02475"></a>02475     p_domain_end = p;
<a name="l02476"></a>02476     
<a name="l02477"></a>02477     <span class="comment">/* If p covers Pol */</span>
<a name="l02478"></a>02478     <span class="keywordflow">if</span> (<a class="code" href="polyhedron_8c.html#a107a96d44465428ffcd25f1ab3d67b43">PolyhedronIncludes</a>(p,Pol)) {
<a name="l02479"></a>02479       Redundant = 1;
<a name="l02480"></a>02480       <span class="keywordflow">break</span>;
<a name="l02481"></a>02481     }
<a name="l02482"></a>02482     pnext = p-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l02483"></a>02483   }
<a name="l02484"></a>02484   <span class="keywordflow">if</span> (!Redundant) {  
<a name="l02485"></a>02485     
<a name="l02486"></a>02486     <span class="comment">/* The whole list has been checked. Add new polyhedron &apos;Pol&apos; to the */</span>
<a name="l02487"></a>02487     <span class="comment">/* new domain list.                                                 */</span> 
<a name="l02488"></a>02488     <span class="keywordflow">if</span> (!PolDomain) PolDomain = Pol; <span class="keywordflow">else</span> p_domain_end-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = Pol;
<a name="l02489"></a>02489   }
<a name="l02490"></a>02490   <span class="keywordflow">else</span> {
<a name="l02491"></a>02491     
<a name="l02492"></a>02492     <span class="comment">/* The rest of the list is just inherited from p */</span>
<a name="l02493"></a>02493     <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol);
<a name="l02494"></a>02494   }
<a name="l02495"></a>02495   <span class="keywordflow">return</span> PolDomain;
<a name="l02496"></a>02496 } <span class="comment">/* AddPolyToDomain */</span>
<a name="l02497"></a>02497 
<a name="l02498"></a>02498 <span class="comment">/* </span>
<a name="l02499"></a>02499 <span class="comment"> * Given a polyhedra &apos;Pol&apos; and a single constraint &apos;Con&apos; and an integer &apos;Pass&apos; </span>
<a name="l02500"></a>02500 <span class="comment"> * whose value ranges from 0 to 3, add the inverse of constraint &apos;Con&apos; to the </span>
<a name="l02501"></a>02501 <span class="comment"> * constraint set of &apos;Pol&apos; and return the new polyhedron. &apos;NbMaxRays&apos; is the </span>
<a name="l02502"></a>02502 <span class="comment"> * maximum allowed rays in the new generated polyhedron. </span>
<a name="l02503"></a>02503 <span class="comment"> * If Pass == 0, add ( -constraint -1) &gt;= 0</span>
<a name="l02504"></a>02504 <span class="comment"> * If Pass == 1, add ( +constraint -1) &gt;= 0</span>
<a name="l02505"></a>02505 <span class="comment"> * If Pass == 2, add ( -constraint   ) &gt;= 0</span>
<a name="l02506"></a>02506 <span class="comment"> * If Pass == 3, add ( +constraint   ) &gt;= 0</span>
<a name="l02507"></a>02507 <span class="comment"> */</span>
<a name="l02508"></a><a class="code" href="polyhedron_8h.html#a1a9b9a572ee65d1c15aea3f9885dde7a">02508</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a1a9b9a572ee65d1c15aea3f9885dde7a">SubConstraint</a>(Value *Con,<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<span class="keywordtype">unsigned</span> NbMaxRays,<span class="keywordtype">int</span> Pass) {
<a name="l02509"></a>02509   
<a name="l02510"></a>02510   <a class="code" href="structpolyhedron.html">Polyhedron</a> *NewPol = NULL;
<a name="l02511"></a>02511   <a class="code" href="structmatrix.html">Matrix</a>   *Mat = NULL, *Ray = NULL;
<a name="l02512"></a>02512   <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a> = NULL;
<a name="l02513"></a>02513   <span class="keywordtype">unsigned</span> NbRay, NbCon, NbEle1, Dimension;
<a name="l02514"></a>02514   <span class="keywordtype">int</span> i;
<a name="l02515"></a>02515 
<a name="l02516"></a>02516   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(Pol);
<a name="l02517"></a>02517   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol);
<a name="l02518"></a>02518   
<a name="l02519"></a>02519   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l02520"></a>02520     <span class="keywordflow">if</span> (NewPol) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(NewPol);
<a name="l02521"></a>02521     <span class="keywordflow">if</span> (Mat) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);
<a name="l02522"></a>02522     <span class="keywordflow">if</span> (Ray) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ray);
<a name="l02523"></a>02523     <span class="keywordflow">if</span> (Sat) <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l02524"></a>02524     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l02525"></a>02525   }
<a name="l02526"></a>02526   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l02527"></a>02527     
<a name="l02528"></a>02528     <span class="comment">/* If &apos;Con&apos; is the positivity constraint, return Null */</span>
<a name="l02529"></a>02529     Dimension  = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1;      <span class="comment">/* Homogeneous Dimension */</span>
<a name="l02530"></a>02530     <span class="keywordflow">for</span> (i=1; i&lt;Dimension; i++)
<a name="l02531"></a>02531       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Con[i])) <span class="keywordflow">break</span>;
<a name="l02532"></a>02532     <span class="keywordflow">if</span> (i==Dimension) {
<a name="l02533"></a>02533       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02534"></a>02534       <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a> *) 0;
<a name="l02535"></a>02535     }
<a name="l02536"></a>02536     
<a name="l02537"></a>02537     NbRay     = Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>;
<a name="l02538"></a>02538     NbCon     = Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l02539"></a>02539     Dimension = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;       <span class="comment">/* Homogeneous Dimension + Status */</span>
<a name="l02540"></a>02540     NbEle1    = NbCon * Dimension;
<a name="l02541"></a>02541     
<a name="l02542"></a>02542     <span class="comment">/* Ignore for now */</span>
<a name="l02543"></a>02543     <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxRays, <a class="code" href="types_8h.html#a754586a0aee88f21ad4c98b1cddee1be">POL_NO_DUAL</a>))
<a name="l02544"></a>02544       NbMaxRays = 0;
<a name="l02545"></a>02545 
<a name="l02546"></a>02546     <span class="keywordflow">if</span> (NbRay &gt; NbMaxRays)
<a name="l02547"></a>02547       NbMaxRays = NbRay;
<a name="l02548"></a>02548     
<a name="l02549"></a>02549     Mat = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbCon + 1, Dimension);
<a name="l02550"></a>02550     <span class="keywordflow">if</span>(!Mat) {
<a name="l02551"></a>02551       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;SubConstraint&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02552"></a>02552       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02553"></a>02553       <span class="keywordflow">return</span> 0;
<a name="l02554"></a>02554     }
<a name="l02555"></a>02555     
<a name="l02556"></a>02556     <span class="comment">/* Set the constraints of Pol */</span>
<a name="l02557"></a>02557     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[0], NbEle1);
<a name="l02558"></a>02558     
<a name="l02559"></a>02559     <span class="comment">/* Add the new constraint */</span>
<a name="l02560"></a>02560     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbCon][0],1);
<a name="l02561"></a>02561     <span class="keywordflow">if</span> (!(Pass&amp;1))
<a name="l02562"></a>02562       <span class="keywordflow">for</span>(i=1; i&lt;Dimension; i++) 
<a name="l02563"></a>02563         <a class="code" href="source_2arith_2arithmetique_8h.html#a0daf9a8ecdc14e7a274832b0d2add830">value_oppose</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbCon][i],Con[i]);
<a name="l02564"></a>02564     <span class="keywordflow">else</span>
<a name="l02565"></a>02565       <span class="keywordflow">for</span>(i=1; i&lt;Dimension; i++)
<a name="l02566"></a>02566         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbCon][i],Con[i]);
<a name="l02567"></a>02567     <span class="keywordflow">if</span> (!(Pass&amp;2))
<a name="l02568"></a>02568       <a class="code" href="source_2arith_2arithmetique_8h.html#a7e293e9652086118cc5b660e6022767c">value_decrement</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbCon][Dimension-1],Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[NbCon][Dimension-1]);
<a name="l02569"></a>02569    
<a name="l02570"></a>02570     <span class="comment">/* Allocate the ray matrix. */</span>
<a name="l02571"></a>02571     Ray = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbMaxRays, Dimension);
<a name="l02572"></a>02572     <span class="keywordflow">if</span>(!Ray) {
<a name="l02573"></a>02573       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;SubConstraint&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02574"></a>02574       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02575"></a>02575       <span class="keywordflow">return</span> 0;
<a name="l02576"></a>02576     }
<a name="l02577"></a>02577     
<a name="l02578"></a>02578     <span class="comment">/* Initialize the ray matrix with the rays of polyhedron &apos;Pol&apos; */</span>
<a name="l02579"></a>02579     Ray-&gt;NbRows = NbRay;
<a name="l02580"></a>02580     <span class="keywordflow">if</span> (NbRay)
<a name="l02581"></a>02581         <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[0], Ray-&gt;p[0], NbRay * Dimension);   
<a name="l02582"></a>02582     
<a name="l02583"></a>02583     <span class="comment">/* Create the saturation matrix from the constraint matrix &apos;mat&apos; and */</span>
<a name="l02584"></a>02584     <span class="comment">/* ray matrix &apos;Ray&apos;.                                                 */</span>
<a name="l02585"></a>02585     Sat = <a class="code" href="polyhedron_8c.html#a542ec91dd2ace5b3faab3f02511d26bd">BuildSat</a>(Mat, Ray, NbCon, NbMaxRays);
<a name="l02586"></a>02586     
<a name="l02587"></a>02587     <span class="comment">/* Create the ray matrix &apos;Ray&apos; from consraint matrix &apos;Mat&apos;           */</span>
<a name="l02588"></a>02588     <a class="code" href="errormsg_8c.html#aa587bf4e8c763fa5e95542df7eb070b7">Pol_status</a> = <a class="code" href="polyhedron_8c.html#a6138e0e907fa19ecc60710b1ab1868c1">Chernikova</a>(Mat, Ray, Sat, Pol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a>, NbMaxRays, NbCon,0);
<a name="l02589"></a>02589     
<a name="l02590"></a>02590     <span class="comment">/* Remove redundant constraints from matrix &apos;Mat&apos; */</span> 
<a name="l02591"></a>02591     NewPol = <a class="code" href="polyhedron_8c.html#a1288eb192e28147e2572f35ed3a82de3">Remove_Redundants</a>(Mat, Ray, Sat, 0);
<a name="l02592"></a>02592     
<a name="l02593"></a>02593   } <span class="comment">/* end of TRY */</span>
<a name="l02594"></a>02594   
<a name="l02595"></a>02595   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02596"></a>02596   
<a name="l02597"></a>02597   <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l02598"></a>02598   <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ray);
<a name="l02599"></a>02599   <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);
<a name="l02600"></a>02600   <span class="keywordflow">return</span> NewPol;
<a name="l02601"></a>02601 } <span class="comment">/* SubConstraint */</span>
<a name="l02602"></a>02602 
<a name="l02603"></a>02603 <span class="comment">/*</span>
<a name="l02604"></a>02604 <span class="comment"> * Return the intersection of two polyhedral domains &apos;Pol1&apos; and &apos;Pol2&apos;. </span>
<a name="l02605"></a>02605 <span class="comment"> * The maximum allowed rays in the new polyhedron generated is &apos;NbMaxRays&apos;. </span>
<a name="l02606"></a>02606 <span class="comment"> */</span>
<a name="l02607"></a><a class="code" href="polyhedron_8h.html#ac5a1a2751f0b833183560af25b18033b">02607</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#ac5a1a2751f0b833183560af25b18033b">DomainIntersection</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol1,<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol2,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l02608"></a>02608   
<a name="l02609"></a>02609   <a class="code" href="structpolyhedron.html">Polyhedron</a> *p1, *p2, *p3, *d;
<a name="l02610"></a>02610   
<a name="l02611"></a>02611   <span class="keywordflow">if</span> (!Pol1 || !Pol2) <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l02612"></a>02612   <span class="keywordflow">if</span> (Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> != Pol2-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>) {
<a name="l02613"></a>02613     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>( <span class="stringliteral">&quot;DomainIntersection&quot;</span>, <span class="stringliteral">&quot;diffdim&quot;</span>,
<a name="l02614"></a>02614                <span class="stringliteral">&quot;operation on different dimensions&quot;</span>);
<a name="l02615"></a>02615     <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l02616"></a>02616   }
<a name="l02617"></a>02617   
<a name="l02618"></a>02618   <span class="comment">/* For every polyhedron pair (p1,p2) where p1 belongs to domain Pol1 and */</span>
<a name="l02619"></a>02619   <span class="comment">/* p2 belongs to domain Pol2, compute the intersection and add it to the */</span>
<a name="l02620"></a>02620   <span class="comment">/* new domain &apos;d&apos;.                                                       */</span>
<a name="l02621"></a>02621   d = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l02622"></a>02622   <span class="keywordflow">for</span> (p1=Pol1; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l02623"></a>02623     <span class="keywordflow">for</span> (p2=Pol2; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l02624"></a>02624       p3 = <a class="code" href="polyhedron_8c.html#a9690baafb863abbd2e8d5c4da2995416">AddConstraints</a>(p2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0],
<a name="l02625"></a>02625                           p2-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>, p1, NbMaxRays);      
<a name="l02626"></a>02626       d = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a>(p3,d);
<a name="l02627"></a>02627     }
<a name="l02628"></a>02628   }
<a name="l02629"></a>02629   <span class="keywordflow">if</span> (!d)
<a name="l02630"></a>02630     <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>);
<a name="l02631"></a>02631   <span class="keywordflow">else</span>
<a name="l02632"></a>02632     <span class="keywordflow">return</span> d;
<a name="l02633"></a>02633   
<a name="l02634"></a>02634 } <span class="comment">/* DomainIntersection */</span>
<a name="l02635"></a>02635 
<a name="l02636"></a>02636 <span class="comment">/*</span>
<a name="l02637"></a>02637 <span class="comment"> * Given a polyhedron &apos;Pol&apos;, return a matrix of rays. </span>
<a name="l02638"></a>02638 <span class="comment"> */</span>
<a name="l02639"></a><a class="code" href="polyhedron_8h.html#a4163ba86faa8741d9215ff038a791bda">02639</a> <a class="code" href="structmatrix.html">Matrix</a> *<a class="code" href="polyhedron_8c.html#a4163ba86faa8741d9215ff038a791bda">Polyhedron2Rays</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol) {
<a name="l02640"></a>02640   
<a name="l02641"></a>02641   <a class="code" href="structmatrix.html">Matrix</a>     *Ray;
<a name="l02642"></a>02642   <span class="keywordtype">unsigned</span> NbRays, Dimension;
<a name="l02643"></a>02643 
<a name="l02644"></a>02644   <a class="code" href="polyhedron_8h.html#a6dd85019d042c483105a927e7babfdfa">POL_ENSURE_POINTS</a>(Pol);
<a name="l02645"></a>02645   
<a name="l02646"></a>02646   NbRays    = Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>;
<a name="l02647"></a>02647   Dimension = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;         <span class="comment">/* Homogeneous Dimension + Status */</span>
<a name="l02648"></a>02648   Ray = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbRays, Dimension);
<a name="l02649"></a>02649   <span class="keywordflow">if</span>(!Ray) {
<a name="l02650"></a>02650     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron2Rays&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02651"></a>02651     <span class="keywordflow">return</span> 0;
<a name="l02652"></a>02652   }
<a name="l02653"></a>02653   <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[0], Ray-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>, NbRays*Dimension);
<a name="l02654"></a>02654   <span class="keywordflow">return</span> Ray;
<a name="l02655"></a>02655 } <span class="comment">/* Polyhedron2Rays */</span>
<a name="l02656"></a>02656 
<a name="l02657"></a>02657 <span class="comment">/*</span>
<a name="l02658"></a>02658 <span class="comment"> * Add &apos;NbAddedRays&apos; rays to polyhedron &apos;Pol&apos;. Rays are pointed by &apos;AddedRays&apos;</span>
<a name="l02659"></a>02659 <span class="comment"> * and the maximum allowed constraints in the new polyhedron is &apos;NbMaxConstrs&apos;.</span>
<a name="l02660"></a>02660 <span class="comment"> */</span> 
<a name="l02661"></a><a class="code" href="polyhedron_8h.html#a6c3e0559da6a19b6d6aa1dedfc44162f">02661</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a964e678fe2d07dd6162a7f1c429d38ba">AddRays</a>(Value *AddedRays,<span class="keywordtype">unsigned</span> NbAddedRays,<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<span class="keywordtype">unsigned</span> NbMaxConstrs) {
<a name="l02662"></a>02662 
<a name="l02663"></a>02663   <a class="code" href="structpolyhedron.html">Polyhedron</a> *NewPol = NULL;
<a name="l02664"></a>02664   <a class="code" href="structmatrix.html">Matrix</a>   *Mat = NULL, *Ray = NULL;
<a name="l02665"></a>02665   <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a> = NULL, *SatTranspose = NULL;
<a name="l02666"></a>02666   <span class="keywordtype">unsigned</span> NbCon, NbRay,NbEle1, Dimension;
<a name="l02667"></a>02667   
<a name="l02668"></a>02668   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(Pol);
<a name="l02669"></a>02669   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol);
<a name="l02670"></a>02670 
<a name="l02671"></a>02671   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l02672"></a>02672     <span class="keywordflow">if</span> (NewPol) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(NewPol);
<a name="l02673"></a>02673     <span class="keywordflow">if</span> (Mat) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);
<a name="l02674"></a>02674     <span class="keywordflow">if</span> (Ray) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ray);
<a name="l02675"></a>02675     <span class="keywordflow">if</span> (Sat) <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l02676"></a>02676     <span class="keywordflow">if</span> (SatTranspose) <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;SatTranspose);
<a name="l02677"></a>02677     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l02678"></a>02678   }
<a name="l02679"></a>02679   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l02680"></a>02680     
<a name="l02681"></a>02681     NbCon      = Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l02682"></a>02682     NbRay      = Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>;
<a name="l02683"></a>02683     Dimension  = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> + 2;    <span class="comment">/* Homogeneous Dimension + Status */</span>
<a name="l02684"></a>02684     NbEle1     = NbRay * Dimension;
<a name="l02685"></a>02685     
<a name="l02686"></a>02686     Ray = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbAddedRays + NbRay, Dimension);
<a name="l02687"></a>02687     <span class="keywordflow">if</span>(!Ray) {
<a name="l02688"></a>02688       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;AddRays&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02689"></a>02689       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02690"></a>02690       <span class="keywordflow">return</span> 0;
<a name="l02691"></a>02691     }
<a name="l02692"></a>02692     
<a name="l02693"></a>02693     <span class="comment">/* Copy rays of polyhedron &apos;Pol&apos; to matrix &apos;Ray&apos; */</span>
<a name="l02694"></a>02694     <span class="keywordflow">if</span> (NbRay)
<a name="l02695"></a>02695       <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[0], Ray-&gt;p_Init, NbEle1);
<a name="l02696"></a>02696     
<a name="l02697"></a>02697     <span class="comment">/* Add the new rays pointed by &apos;AddedRays&apos; to matrix &apos;Ray&apos; */</span>
<a name="l02698"></a>02698     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(AddedRays, Ray-&gt;p_Init+NbEle1, NbAddedRays * Dimension);
<a name="l02699"></a>02699     
<a name="l02700"></a>02700     <span class="comment">/* Ignore for now */</span>
<a name="l02701"></a>02701     <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxConstrs, <a class="code" href="types_8h.html#a754586a0aee88f21ad4c98b1cddee1be">POL_NO_DUAL</a>))
<a name="l02702"></a>02702       NbMaxConstrs = 0;
<a name="l02703"></a>02703 
<a name="l02704"></a>02704     <span class="comment">/* We need at least NbCon rows */</span>
<a name="l02705"></a>02705     <span class="keywordflow">if</span> (NbMaxConstrs &lt; NbCon)
<a name="l02706"></a>02706         NbMaxConstrs = NbCon;
<a name="l02707"></a>02707 
<a name="l02708"></a>02708     <span class="comment">/* Allocate space for constraint matrix &apos;Mat&apos; */</span>
<a name="l02709"></a>02709     Mat = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbMaxConstrs, Dimension);
<a name="l02710"></a>02710     <span class="keywordflow">if</span>(!Mat) {
<a name="l02711"></a>02711       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;AddRays&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02712"></a>02712       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02713"></a>02713       <span class="keywordflow">return</span> 0;
<a name="l02714"></a>02714     }
<a name="l02715"></a>02715     Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> = NbCon;
<a name="l02716"></a>02716     
<a name="l02717"></a>02717     <span class="comment">/* Copy constraints of polyhedron &apos;Pol&apos; to matrix &apos;Mat&apos; */</span>
<a name="l02718"></a>02718     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], Mat-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>, NbCon*Dimension);
<a name="l02719"></a>02719 
<a name="l02720"></a>02720     <span class="comment">/* Create the saturation matrix &apos;SatTranspose&apos; from constraint matrix */</span>
<a name="l02721"></a>02721     <span class="comment">/* &apos;Mat&apos; and ray matrix &apos;Ray&apos;. Remember the saturation matrix is      */</span>
<a name="l02722"></a>02722     <span class="comment">/* referenced by (constraint,ray) pair                                */</span> 
<a name="l02723"></a>02723     SatTranspose = <a class="code" href="polyhedron_8c.html#a542ec91dd2ace5b3faab3f02511d26bd">BuildSat</a>(Ray, Mat, NbRay, NbMaxConstrs);
<a name="l02724"></a>02724     
<a name="l02725"></a>02725     <span class="comment">/* Create the constraint matrix &apos;Mat&apos; from the ray matrix &apos;Ray&apos; */</span>
<a name="l02726"></a>02726     <a class="code" href="errormsg_8c.html#aa587bf4e8c763fa5e95542df7eb070b7">Pol_status</a> = <a class="code" href="polyhedron_8c.html#a6138e0e907fa19ecc60710b1ab1868c1">Chernikova</a>(Ray, Mat, SatTranspose, Pol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>, NbMaxConstrs, NbRay,1);
<a name="l02727"></a>02727     
<a name="l02728"></a>02728     <span class="comment">/* Transform the saturation matrix &apos;SatTranspose&apos; in the standard format */</span>
<a name="l02729"></a>02729     <span class="comment">/* , that is, (ray X constraint) format.                                 */</span>
<a name="l02730"></a>02730     Sat = <a class="code" href="polyhedron_8c.html#ae90f313a0b016d966ced7e9bf09bc4f1">TransformSat</a>(Mat, Ray, SatTranspose);
<a name="l02731"></a>02731     <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;SatTranspose), SatTranspose = NULL;
<a name="l02732"></a>02732     
<a name="l02733"></a>02733     <span class="comment">/* Remove redundant rays from the ray matrix &apos;Ray&apos; */</span>
<a name="l02734"></a>02734     NewPol = <a class="code" href="polyhedron_8c.html#a1288eb192e28147e2572f35ed3a82de3">Remove_Redundants</a>(Mat, Ray, Sat, 0);
<a name="l02735"></a>02735     
<a name="l02736"></a>02736     <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat), Sat = NULL;
<a name="l02737"></a>02737     <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat), Mat = NULL;
<a name="l02738"></a>02738     <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ray), Ray = NULL;  
<a name="l02739"></a>02739   } <span class="comment">/* end of TRY */</span>
<a name="l02740"></a>02740   
<a name="l02741"></a>02741   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);  
<a name="l02742"></a>02742   <span class="keywordflow">return</span> NewPol;
<a name="l02743"></a>02743 } <span class="comment">/* AddRays */</span>
<a name="l02744"></a>02744 
<a name="l02745"></a>02745 <span class="comment">/* </span>
<a name="l02746"></a>02746 <span class="comment"> * Add rays pointed by &apos;Ray&apos; to each and every polyhedron in the polyhedral </span>
<a name="l02747"></a>02747 <span class="comment"> * domain &apos;Pol&apos;. &apos;NbMaxConstrs&apos; is maximum allowed constraints in the </span>
<a name="l02748"></a>02748 <span class="comment"> * constraint set of a polyhedron.                         </span>
<a name="l02749"></a>02749 <span class="comment"> */</span> 
<a name="l02750"></a><a class="code" href="polyhedron_8h.html#a5ac0337f8a955ee77d5414761f3d41bb">02750</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a5ac0337f8a955ee77d5414761f3d41bb">DomainAddRays</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<a class="code" href="structmatrix.html">Matrix</a> *Ray,<span class="keywordtype">unsigned</span> NbMaxConstrs) {
<a name="l02751"></a>02751   
<a name="l02752"></a>02752   <a class="code" href="structpolyhedron.html">Polyhedron</a> *PolA, *PolEndA, *p1, *p2, *p3;
<a name="l02753"></a>02753   <span class="keywordtype">int</span> Redundant;
<a name="l02754"></a>02754   
<a name="l02755"></a>02755   <span class="keywordflow">if</span> (!Pol) <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l02756"></a>02756   <span class="keywordflow">if</span> (!Ray || Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> == 0)
<a name="l02757"></a>02757     <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#ad57e191f32f3c9022ec00747f4908b3f">Domain_Copy</a>(Pol);
<a name="l02758"></a>02758   <span class="keywordflow">if</span> (Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> != Ray-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2) {
<a name="l02759"></a>02759     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(
<a name="l02760"></a>02760               <span class="stringliteral">&quot;DomainAddRays&quot;</span>, <span class="stringliteral">&quot;diffdim&quot;</span>, <span class="stringliteral">&quot;operation on different dimensions&quot;</span>);
<a name="l02761"></a>02761     <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l02762"></a>02762   }
<a name="l02763"></a>02763   
<a name="l02764"></a>02764   <span class="comment">/* Copy Pol to PolA */</span>
<a name="l02765"></a>02765   PolA = PolEndA = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l02766"></a>02766   <span class="keywordflow">for</span> (p1=Pol; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l02767"></a>02767     p3 = <a class="code" href="polyhedron_8c.html#a964e678fe2d07dd6162a7f1c429d38ba">AddRays</a>(Ray-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[0], Ray-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>, p1, NbMaxConstrs);
<a name="l02768"></a>02768     
<a name="l02769"></a>02769     <span class="comment">/* Does any component of PolA cover &apos;p3&apos; ? */</span>
<a name="l02770"></a>02770     Redundant = 0;
<a name="l02771"></a>02771     <span class="keywordflow">for</span> (p2=PolA; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l02772"></a>02772       <span class="keywordflow">if</span> (<a class="code" href="polyhedron_8c.html#a107a96d44465428ffcd25f1ab3d67b43">PolyhedronIncludes</a>(p2, p3)) { <span class="comment">/* If p2 covers p3 */</span>
<a name="l02773"></a>02773         Redundant = 1;
<a name="l02774"></a>02774         <span class="keywordflow">break</span>;
<a name="l02775"></a>02775       }
<a name="l02776"></a>02776     }
<a name="l02777"></a>02777     
<a name="l02778"></a>02778     <span class="comment">/* If the new polyheron is not redundant, add it (&apos;p3&apos;) to the list */</span>
<a name="l02779"></a>02779     <span class="keywordflow">if</span> (Redundant)
<a name="l02780"></a>02780       <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(p3);
<a name="l02781"></a>02781     <span class="keywordflow">else</span> { 
<a name="l02782"></a>02782       <span class="keywordflow">if</span> (!PolEndA)
<a name="l02783"></a>02783         PolEndA = PolA = p3;
<a name="l02784"></a>02784       <span class="keywordflow">else</span> {
<a name="l02785"></a>02785         PolEndA-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = p3;
<a name="l02786"></a>02786         PolEndA = PolEndA-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l02787"></a>02787       }
<a name="l02788"></a>02788     }
<a name="l02789"></a>02789   }
<a name="l02790"></a>02790   <span class="keywordflow">return</span> PolA;
<a name="l02791"></a>02791 } <span class="comment">/* DomainAddRays */</span>
<a name="l02792"></a>02792 
<a name="l02793"></a>02793 <span class="comment">/*</span>
<a name="l02794"></a>02794 <span class="comment"> * Create a copy of the polyhedron &apos;Pol&apos; </span>
<a name="l02795"></a>02795 <span class="comment"> */</span>
<a name="l02796"></a><a class="code" href="polyhedron_8h.html#ab0f89a51f01cea6b93b8fb3ab43feca3">02796</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol) {
<a name="l02797"></a>02797   
<a name="l02798"></a>02798   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol1;
<a name="l02799"></a>02799   
<a name="l02800"></a>02800   <span class="keywordflow">if</span> (!Pol) <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l02801"></a>02801   
<a name="l02802"></a>02802   <span class="comment">/* Allocate space for the new polyhedron */</span>
<a name="l02803"></a>02803   Pol1 = <a class="code" href="polyhedron_8c.html#aa308ade6448cc5544e21d59e86a53ddf">Polyhedron_Alloc</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>, Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>, Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>);
<a name="l02804"></a>02804   <span class="keywordflow">if</span> (!Pol1) {
<a name="l02805"></a>02805     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Copy&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02806"></a>02806     <span class="keywordflow">return</span> 0;
<a name="l02807"></a>02807   }
<a name="l02808"></a>02808   <span class="keywordflow">if</span>( Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> )
<a name="l02809"></a>02809     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], Pol1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0],
<a name="l02810"></a>02810               Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>*(Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2));
<a name="l02811"></a>02811   <span class="keywordflow">if</span>( Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a> )
<a name="l02812"></a>02812     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[0], Pol1-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[0],
<a name="l02813"></a>02813               Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>*(Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2));
<a name="l02814"></a>02814   Pol1-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a> = Pol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a>;
<a name="l02815"></a>02815   Pol1-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a> = Pol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>;
<a name="l02816"></a>02816   Pol1-&gt;<a class="code" href="structpolyhedron.html#ac1fb864c352ef93ef3030c35e98c2aed">flags</a> = Pol-&gt;<a class="code" href="structpolyhedron.html#ac1fb864c352ef93ef3030c35e98c2aed">flags</a>;
<a name="l02817"></a>02817   <span class="keywordflow">return</span> Pol1;
<a name="l02818"></a>02818 } <span class="comment">/* Polyhedron_Copy */</span>
<a name="l02819"></a>02819 
<a name="l02820"></a>02820 <span class="comment">/* </span>
<a name="l02821"></a>02821 <span class="comment"> * Create a copy of a polyhedral domain. </span>
<a name="l02822"></a>02822 <span class="comment"> */</span>
<a name="l02823"></a><a class="code" href="polyhedron_8h.html#ad57e191f32f3c9022ec00747f4908b3f">02823</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#ad57e191f32f3c9022ec00747f4908b3f">Domain_Copy</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol) {
<a name="l02824"></a>02824   
<a name="l02825"></a>02825   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol1;
<a name="l02826"></a>02826   
<a name="l02827"></a>02827   <span class="keywordflow">if</span> (!Pol) <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a> *) 0;
<a name="l02828"></a>02828   Pol1 = <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(Pol);
<a name="l02829"></a>02829   <span class="keywordflow">if</span> (Pol-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) Pol1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = <a class="code" href="polyhedron_8c.html#ad57e191f32f3c9022ec00747f4908b3f">Domain_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>);
<a name="l02830"></a>02830   <span class="keywordflow">return</span> Pol1;
<a name="l02831"></a>02831 } <span class="comment">/* Domain_Copy */</span>
<a name="l02832"></a>02832 
<a name="l02833"></a>02833 <span class="comment">/*</span>
<a name="l02834"></a>02834 <span class="comment"> * Given constraint number &apos;k&apos; of a polyhedron, and an array &apos;Filter&apos; to store</span>
<a name="l02835"></a>02835 <span class="comment"> * the non-redundant constraints of the polyhedron in bit-wise notation, and</span>
<a name="l02836"></a>02836 <span class="comment"> * a Matrix &apos;Sat&apos;, add the constraint &apos;k&apos; in &apos;Filter&apos; array. tmpR[i] stores the</span>
<a name="l02837"></a>02837 <span class="comment"> * number of constraints, other than those in &apos;Filter&apos;, which ray(i) saturates </span>
<a name="l02838"></a>02838 <span class="comment"> * or verifies. In case, ray(i) does not saturate or verify a constraint in</span>
<a name="l02839"></a>02839 <span class="comment"> * array &apos;Filter&apos;, it is assigned to -1. Similarly, tmpC[j] stores the number</span>
<a name="l02840"></a>02840 <span class="comment"> * of rays which constraint(j), if it doesn&apos;t belong to Filter, saturates or </span>
<a name="l02841"></a>02841 <span class="comment"> * verifies. If constraint(j) belongs to &apos;Filter&apos;, then tmpC[j] is assigned to</span>
<a name="l02842"></a>02842 <span class="comment"> * -1. &apos;NbConstraints&apos; is the number of constraints in the constraint matrix of</span>
<a name="l02843"></a>02843 <span class="comment"> * the polyhedron. </span>
<a name="l02844"></a>02844 <span class="comment"> * NOTE: (1) &apos;Sat&apos; is not the saturation matrix of the polyhedron. In fact, </span>
<a name="l02845"></a>02845 <span class="comment"> *           entry in &apos;Sat&apos; is set to 1 if ray(i) of polyhedron1 verifies or </span>
<a name="l02846"></a>02846 <span class="comment"> *           saturates the constraint(j) of polyhedron2 and otherwise it is set</span>
<a name="l02847"></a>02847 <span class="comment"> *           to 0. So here the difference with saturation matrix is in terms </span>
<a name="l02848"></a>02848 <span class="comment"> *           definition and entries(1&lt;-&gt;0) of the matrix &apos;Sat&apos;.    </span>
<a name="l02849"></a>02849 <span class="comment"> *       </span>
<a name="l02850"></a>02850 <span class="comment"> * ALGORITHM:-&gt;</span>
<a name="l02851"></a>02851 <span class="comment"> * (1) Include constraint(k) in array &apos;Filter&apos;. </span>
<a name="l02852"></a>02852 <span class="comment"> * (2) Set tmpC[k] to -1.</span>
<a name="l02853"></a>02853 <span class="comment"> * (3) For all ray(i) {</span>
<a name="l02854"></a>02854 <span class="comment"> *        If ray(i) saturates or verifies constraint(k) then --(tmpR[i])</span>
<a name="l02855"></a>02855 <span class="comment"> *        Else {</span>
<a name="l02856"></a>02856 <span class="comment"> *           Discard ray(i) by assigning tmpR[i] = -1</span>
<a name="l02857"></a>02857 <span class="comment"> *           Decrement tmpC[j] for all constraint(j) not in array &apos;Filter&apos;.</span>
<a name="l02858"></a>02858 <span class="comment"> *        }</span>
<a name="l02859"></a>02859 <span class="comment"> *     }</span>
<a name="l02860"></a>02860 <span class="comment"> */</span>
<a name="l02861"></a><a class="code" href="polyhedron_8c.html#af08de0a78a3c54f1b6c8a554cf68656c">02861</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#af08de0a78a3c54f1b6c8a554cf68656c">addToFilter</a>(<span class="keywordtype">int</span> k, <span class="keywordtype">unsigned</span> *Filter, <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a>,Value *tmpR,Value *tmpC,<span class="keywordtype">int</span> NbRays,<span class="keywordtype">int</span> NbConstraints) {
<a name="l02862"></a>02862   
<a name="l02863"></a>02863   <span class="keywordtype">int</span> kj, i,j, jx;
<a name="l02864"></a>02864   <span class="keywordtype">unsigned</span> kb, bx;
<a name="l02865"></a>02865   
<a name="l02866"></a>02866   <span class="comment">/* Remove constraint k */</span>
<a name="l02867"></a>02867   kj =   k/<a class="code" href="polyhedron_8c.html#a7edb6b8a8c89cb564d6e1b85ed80e7db">WSIZE</a>; kb = <a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>; kb &gt;&gt;= k%<a class="code" href="polyhedron_8c.html#a7edb6b8a8c89cb564d6e1b85ed80e7db">WSIZE</a>;
<a name="l02868"></a>02868   Filter[kj]|=kb;
<a name="l02869"></a>02869   <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(tmpC[k],-1);
<a name="l02870"></a>02870   
<a name="l02871"></a>02871   <span class="comment">/* Remove rays excluded by constraint k */</span>
<a name="l02872"></a>02872   <span class="keywordflow">for</span>(i=0; i&lt;NbRays; i++)
<a name="l02873"></a>02873     <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#afef45b8b369740e71140484a097b6ab4">value_posz_p</a>(tmpR[i])) {
<a name="l02874"></a>02874       <span class="keywordflow">if</span> (Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][kj]&amp;kb)
<a name="l02875"></a>02875         <a class="code" href="source_2arith_2arithmetique_8h.html#a7e293e9652086118cc5b660e6022767c">value_decrement</a>(tmpR[i],tmpR[i]);  <span class="comment">/* adjust included ray */</span>
<a name="l02876"></a>02876       <span class="keywordflow">else</span> {
<a name="l02877"></a>02877         
<a name="l02878"></a>02878         <span class="comment">/* Constraint k excludes ray i -- delete ray i */</span>
<a name="l02879"></a>02879         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(tmpR[i],-1);
<a name="l02880"></a>02880         
<a name="l02881"></a>02881         <span class="comment">/* Adjust non-deleted constraints */</span>
<a name="l02882"></a>02882         jx=0; bx=<a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>;
<a name="l02883"></a>02883         <span class="keywordflow">for</span>(j=0; j&lt;NbConstraints; j++) {
<a name="l02884"></a>02884           <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#afef45b8b369740e71140484a097b6ab4">value_posz_p</a>(tmpC[j]) &amp;&amp; (Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][jx]&amp;bx) )
<a name="l02885"></a>02885             <a class="code" href="source_2arith_2arithmetique_8h.html#a7e293e9652086118cc5b660e6022767c">value_decrement</a>(tmpC[j],tmpC[j]);
<a name="l02886"></a>02886           <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(jx,bx);
<a name="l02887"></a>02887         }
<a name="l02888"></a>02888       }
<a name="l02889"></a>02889     } 
<a name="l02890"></a>02890 } <span class="comment">/* addToFilter */</span>
<a name="l02891"></a>02891 
<a name="l02892"></a>02892 <span class="comment">/*</span>
<a name="l02893"></a>02893 <span class="comment"> * Given polyhedra &apos;P1&apos; and &apos;P2&apos; such that their intersection is an empty</span>
<a name="l02894"></a>02894 <span class="comment"> * polyhedron, find the minimal set of constraints of &apos;P1&apos; which contradict</span>
<a name="l02895"></a>02895 <span class="comment"> * all of the constraints of &apos;P2&apos;. This is believed to be an NP-hard problem</span>
<a name="l02896"></a>02896 <span class="comment"> * and so a heuristic is employed to solve it in worst case. The heuristic is </span>
<a name="l02897"></a>02897 <span class="comment"> * to select in every turn that constraint of &apos;P1&apos; which excludes most rays of</span>
<a name="l02898"></a>02898 <span class="comment"> * &apos;P2&apos;. A bit in the binary format of an element of array &apos;Filter&apos; is set to</span>
<a name="l02899"></a>02899 <span class="comment"> * 1 if the corresponding constraint is to be included in the minimal set of </span>
<a name="l02900"></a>02900 <span class="comment"> * constraints otherwise it is set to 0.</span>
<a name="l02901"></a>02901 <span class="comment"> */</span>
<a name="l02902"></a><a class="code" href="polyhedron_8c.html#a8f3a2040fba83bdd5e328b42c7aed63c">02902</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#a8f3a2040fba83bdd5e328b42c7aed63c">FindSimple</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *P1,<a class="code" href="structpolyhedron.html">Polyhedron</a> *P2,<span class="keywordtype">unsigned</span> *Filter,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l02903"></a>02903   
<a name="l02904"></a>02904   <a class="code" href="structmatrix.html">Matrix</a> *Mat = NULL;
<a name="l02905"></a>02905   <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a> = NULL;
<a name="l02906"></a>02906   <span class="keywordtype">int</span> i, j, k, jx, found;
<a name="l02907"></a>02907   Value *p1, *p2, p3;
<a name="l02908"></a>02908   <span class="keywordtype">unsigned</span> Dimension, NbRays, NbConstraints, bx, nc;
<a name="l02909"></a>02909   Value NbConstraintsLeft, tmp;
<a name="l02910"></a>02910   Value *tmpC = NULL, *tmpR = NULL;
<a name="l02911"></a>02911   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol = NULL, *Pol2 = NULL;
<a name="l02912"></a>02912   
<a name="l02913"></a>02913   <span class="comment">/* Initialize all the &apos;Value&apos; variables */</span>
<a name="l02914"></a>02914   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(NbConstraintsLeft);
<a name="l02915"></a>02915   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmp);
<a name="l02916"></a>02916  
<a name="l02917"></a>02917   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l02918"></a>02918     <span class="keywordflow">if</span> (tmpC) free(tmpC);
<a name="l02919"></a>02919     <span class="keywordflow">if</span> (tmpR) free(tmpR);
<a name="l02920"></a>02920     <span class="keywordflow">if</span> (Mat) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);
<a name="l02921"></a>02921     <span class="keywordflow">if</span> (Sat) <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l02922"></a>02922     <span class="keywordflow">if</span> (Pol2 &amp;&amp; Pol2!=P2) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol2);
<a name="l02923"></a>02923     <span class="keywordflow">if</span> (Pol &amp;&amp; Pol!=Pol2 &amp;&amp; Pol!=P2) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol);
<a name="l02924"></a>02924     
<a name="l02925"></a>02925     <span class="comment">/* Clear all the &apos;Value&apos; variables */</span>
<a name="l02926"></a>02926     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(NbConstraintsLeft);
<a name="l02927"></a>02927     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l02928"></a>02928     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l02929"></a>02929   }
<a name="l02930"></a>02930   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l02931"></a>02931     
<a name="l02932"></a>02932     Dimension = P1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;       <span class="comment">/* status + homogeneous Dimension */</span>
<a name="l02933"></a>02933     Mat = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(P1-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>, Dimension);
<a name="l02934"></a>02934     <span class="keywordflow">if</span>(!Mat) {
<a name="l02935"></a>02935       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;FindSimple&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02936"></a>02936       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02937"></a>02937       
<a name="l02938"></a>02938       <span class="comment">/* Clear all the &apos;Value&apos; variables */</span>
<a name="l02939"></a>02939       <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(NbConstraintsLeft); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);  
<a name="l02940"></a>02940       <span class="keywordflow">return</span>;
<a name="l02941"></a>02941     }
<a name="l02942"></a>02942     
<a name="l02943"></a>02943     <span class="comment">/* Post constraints in P1 already included by Filter */</span>
<a name="l02944"></a>02944     jx = 0; bx = <a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>; Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>=0;
<a name="l02945"></a>02945     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(NbConstraintsLeft,0);
<a name="l02946"></a>02946     <span class="keywordflow">for</span> (k=0; k&lt;P1-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>; k++) {
<a name="l02947"></a>02947       <span class="keywordflow">if</span> (Filter[jx]&amp;bx) {
<a name="l02948"></a>02948         <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(P1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[k], Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>], Dimension);
<a name="l02949"></a>02949         Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>++;
<a name="l02950"></a>02950       }
<a name="l02951"></a>02951       <span class="keywordflow">else</span>
<a name="l02952"></a>02952         <a class="code" href="source_2arith_2arithmetique_8h.html#a88693f35dd41deddc6ac0700073fc8db">value_increment</a>(NbConstraintsLeft,NbConstraintsLeft);
<a name="l02953"></a>02953       <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(jx,bx);
<a name="l02954"></a>02954     }
<a name="l02955"></a>02955     Pol2 = P2;
<a name="l02956"></a>02956     
<a name="l02957"></a>02957     <span class="keywordflow">for</span> (;;) {
<a name="l02958"></a>02958       <span class="keywordflow">if</span> (Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>==0)
<a name="l02959"></a>02959         Pol = <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(Pol2);
<a name="l02960"></a>02960       <span class="keywordflow">else</span> {
<a name="l02961"></a>02961         Pol = <a class="code" href="polyhedron_8c.html#a9690baafb863abbd2e8d5c4da2995416">AddConstraints</a>(Mat-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>, Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>, Pol2, NbMaxRays);
<a name="l02962"></a>02962         <span class="keywordflow">if</span> (Pol2 != P2) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol2), Pol2 = NULL;
<a name="l02963"></a>02963       }
<a name="l02964"></a>02964       <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(Pol)) {
<a name="l02965"></a>02965         <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat), Mat = NULL;
<a name="l02966"></a>02966         <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol), Pol = NULL;
<a name="l02967"></a>02967         <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02968"></a>02968         
<a name="l02969"></a>02969         <span class="comment">/* Clear all the &apos;Value&apos; variables */</span>
<a name="l02970"></a>02970         <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(NbConstraintsLeft); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l02971"></a>02971         <span class="keywordflow">return</span>;
<a name="l02972"></a>02972       }
<a name="l02973"></a>02973       Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> = 0;        <span class="comment">/* Reset Mat */</span>
<a name="l02974"></a>02974       Pol2 = Pol;
<a name="l02975"></a>02975       
<a name="l02976"></a>02976       <span class="comment">/* Its not enough-- find some more constraints */</span>
<a name="l02977"></a>02977       Dimension         = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1;       <span class="comment">/* homogeneous Dimension */</span>
<a name="l02978"></a>02978       NbRays            = Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>;
<a name="l02979"></a>02979       NbConstraints     = P1-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l02980"></a>02980       tmpR = (Value *)malloc(NbRays*<span class="keyword">sizeof</span>(Value));
<a name="l02981"></a>02981       <span class="keywordflow">if</span>(!tmpR) {
<a name="l02982"></a>02982         <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;FindSimple&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02983"></a>02983         <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02984"></a>02984         
<a name="l02985"></a>02985         <span class="comment">/* Clear all the &apos;Value&apos; variables */</span>
<a name="l02986"></a>02986         <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(NbConstraintsLeft); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);  
<a name="l02987"></a>02987         <span class="keywordflow">return</span>;
<a name="l02988"></a>02988       }
<a name="l02989"></a>02989       <span class="keywordflow">for</span>(i=0;i&lt;NbRays;i++)
<a name="l02990"></a>02990         <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmpR[i]);
<a name="l02991"></a>02991       tmpC = (Value *)malloc(NbConstraints*<span class="keyword">sizeof</span>(Value));
<a name="l02992"></a>02992       <span class="keywordflow">if</span>(!tmpC) {
<a name="l02993"></a>02993         <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;FindSimple&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l02994"></a>02994         <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l02995"></a>02995         
<a name="l02996"></a>02996         <span class="comment">/* Clear all the &apos;Value&apos; variables */</span>
<a name="l02997"></a>02997         <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(NbConstraintsLeft);
<a name="l02998"></a>02998         <span class="keywordflow">for</span>(i=0;i&lt;NbRays;i++)
<a name="l02999"></a>02999           <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmpR[i]);
<a name="l03000"></a>03000         free(tmpR);
<a name="l03001"></a>03001         <span class="keywordflow">return</span>;
<a name="l03002"></a>03002       }
<a name="l03003"></a>03003       <span class="keywordflow">for</span>(i=0;i&lt;NbConstraints;i++)
<a name="l03004"></a>03004         <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmpC[i]);
<a name="l03005"></a>03005       <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(tmpR,0,NbRays);
<a name="l03006"></a>03006       <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(tmpC,0,NbConstraints);
<a name="l03007"></a>03007       
<a name="l03008"></a>03008       <span class="comment">/* Build the Sat matrix */</span>
<a name="l03009"></a>03009       nc      = (NbConstraints - 1) / (<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>)*8) + 1;
<a name="l03010"></a>03010       Sat     = <a class="code" href="polyhedron_8c.html#a010deaa3d3f81aaa979f67bb0012d109">SMAlloc</a>(NbRays, nc);
<a name="l03011"></a>03011       Sat-&gt;<a class="code" href="structSatMatrix.html#a08d0db0d2eda3b8bdcc316eabadaca09">NbRows</a> = NbRays;
<a name="l03012"></a>03012       <a class="code" href="polyhedron_8c.html#a3351961690e2b071105b7bb4be0b7127">SMVector_Init</a>(Sat-&gt;<a class="code" href="structSatMatrix.html#ade050f206fbbc64a84bcaaec6f8c260e">p_init</a>, nc*NbRays);
<a name="l03013"></a>03013       
<a name="l03014"></a>03014       jx=0; bx=<a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>;
<a name="l03015"></a>03015       <span class="keywordflow">for</span> (k=0; k&lt;NbConstraints; k++) {
<a name="l03016"></a>03016         <span class="keywordflow">if</span> (Filter[jx]&amp;bx)
<a name="l03017"></a>03017           <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(tmpC[k],-1);
<a name="l03018"></a>03018         <span class="keywordflow">else</span>
<a name="l03019"></a>03019           <span class="keywordflow">for</span> (i=0; i&lt;NbRays; i++) {
<a name="l03020"></a>03020             p1 = Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[i]+1;
<a name="l03021"></a>03021             p2 = P1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[k]+1;
<a name="l03022"></a>03022             <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(p3,0);
<a name="l03023"></a>03023             <span class="keywordflow">for</span> (j=0; j&lt;Dimension; j++) {
<a name="l03024"></a>03024               <a class="code" href="source_2arith_2arithmetique_8h.html#a9900fbd029b36f5887e587642a064a52">value_addmul</a>(p3, *p1, *p2);
<a name="l03025"></a>03025               p1++; p2++;
<a name="l03026"></a>03026             }
<a name="l03027"></a>03027             <span class="keywordflow">if</span>(<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(p3) ||
<a name="l03028"></a>03028                (<a class="code" href="source_2arith_2arithmetique_8h.html#a01904c8c75c10d407a24c55f16ec27c7">value_pos_p</a>(p3) &amp;&amp; <a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(P1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[k][0]))) {
<a name="l03029"></a>03029               Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][jx]|=bx;  <span class="comment">/* constraint includes ray, set flag */</span>
<a name="l03030"></a>03030               <a class="code" href="source_2arith_2arithmetique_8h.html#a88693f35dd41deddc6ac0700073fc8db">value_increment</a>(tmpR[i],tmpR[i]);
<a name="l03031"></a>03031               <a class="code" href="source_2arith_2arithmetique_8h.html#a88693f35dd41deddc6ac0700073fc8db">value_increment</a>(tmpC[k],tmpC[k]);
<a name="l03032"></a>03032             }
<a name="l03033"></a>03033           }
<a name="l03034"></a>03034         <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(jx, bx);
<a name="l03035"></a>03035       }
<a name="l03036"></a>03036       
<a name="l03037"></a>03037       <span class="keywordflow">do</span> { <span class="comment">/* find all of the essential constraints */</span>
<a name="l03038"></a>03038         found = 0;
<a name="l03039"></a>03039         <span class="keywordflow">for</span>(i=0; i&lt;NbRays; i++)
<a name="l03040"></a>03040           <span class="keywordflow">if</span>(<a class="code" href="source_2arith_2arithmetique_8h.html#afef45b8b369740e71140484a097b6ab4">value_posz_p</a>(tmpR[i])) {
<a name="l03041"></a>03041             <a class="code" href="source_2arith_2arithmetique_8h.html#a73e7093353d4108ea8f63898e868ed5f">value_add_int</a>(tmp,tmpR[i],1);
<a name="l03042"></a>03042             <span class="keywordflow">if</span>(<a class="code" href="source_2arith_2arithmetique_8h.html#aaac63aa93e7c9fa23ebcde2dc80a12b9">value_eq</a>(tmp,NbConstraintsLeft)) {
<a name="l03043"></a>03043               
<a name="l03044"></a>03044               <span class="comment">/* Ray i is excluded by only one constraint... find it */</span>
<a name="l03045"></a>03045               jx = 0; bx = <a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>;
<a name="l03046"></a>03046               <span class="keywordflow">for</span>(k=0; k&lt;NbConstraints; k++) {
<a name="l03047"></a>03047                 <span class="keywordflow">if</span>(<a class="code" href="source_2arith_2arithmetique_8h.html#afef45b8b369740e71140484a097b6ab4">value_posz_p</a>(tmpC[k]) &amp;&amp; ((Sat-&gt;<a class="code" href="structSatMatrix.html#a1035c79878e19d97de2ba62fc38456aa">p</a>[i][jx]&amp;bx)==0)) {
<a name="l03048"></a>03048                   <a class="code" href="polyhedron_8c.html#af08de0a78a3c54f1b6c8a554cf68656c">addToFilter</a>(k, Filter, Sat, tmpR, tmpC,
<a name="l03049"></a>03049                               NbRays, NbConstraints);
<a name="l03050"></a>03050                   <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(P1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[k],
<a name="l03051"></a>03051                               Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>],Dimension+1);
<a name="l03052"></a>03052                   Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>++;
<a name="l03053"></a>03053                   <a class="code" href="source_2arith_2arithmetique_8h.html#a7e293e9652086118cc5b660e6022767c">value_decrement</a>(NbConstraintsLeft,NbConstraintsLeft);
<a name="l03054"></a>03054                   found=1;
<a name="l03055"></a>03055                   <span class="keywordflow">break</span>;
<a name="l03056"></a>03056                 }
<a name="l03057"></a>03057                 <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(jx,bx);
<a name="l03058"></a>03058               }
<a name="l03059"></a>03059               <span class="keywordflow">break</span>;
<a name="l03060"></a>03060             }
<a name="l03061"></a>03061           }
<a name="l03062"></a>03062       }
<a name="l03063"></a>03063       <span class="keywordflow">while</span> (found);
<a name="l03064"></a>03064      
<a name="l03065"></a>03065       <span class="keywordflow">if</span> (!Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>) { <span class="comment">/* Well then, just use a stupid heuristic */</span>
<a name="l03066"></a>03066         <span class="comment">/* find the constraint which excludes the most */</span>
<a name="l03067"></a>03067         Value cmax;
<a name="l03068"></a>03068         <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(cmax);
<a name="l03069"></a>03069         
<a name="l03070"></a>03070 <span class="preprocessor">#ifndef LINEAR_VALUE_IS_CHARS</span>
<a name="l03071"></a>03071 <span class="preprocessor"></span>        <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(cmax,(NbRays * NbConstraints+1));
<a name="l03072"></a>03072 <span class="preprocessor">#else</span>
<a name="l03073"></a>03073 <span class="preprocessor"></span>        <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(cmax,1);
<a name="l03074"></a>03074 <span class="preprocessor">#endif</span>
<a name="l03075"></a>03075 <span class="preprocessor"></span>        
<a name="l03076"></a>03076         j = -1;
<a name="l03077"></a>03077         <span class="keywordflow">for</span>(k=0; k&lt;NbConstraints; k++)
<a name="l03078"></a>03078           <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#afef45b8b369740e71140484a097b6ab4">value_posz_p</a>(tmpC[k])) {
<a name="l03079"></a>03079             <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a15b0362ff15576108c69c31e5ed0cfeb">value_gt</a>(cmax,tmpC[k])) {
<a name="l03080"></a>03080               <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(cmax,tmpC[k]);
<a name="l03081"></a>03081               j = k;
<a name="l03082"></a>03082             }
<a name="l03083"></a>03083           }
<a name="l03084"></a>03084         <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(cmax);
<a name="l03085"></a>03085         <span class="keywordflow">if</span> (j&lt;0) {
<a name="l03086"></a>03086           <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomSimplify&quot;</span>,<span class="stringliteral">&quot;logerror&quot;</span>,<span class="stringliteral">&quot;logic error&quot;</span>);
<a name="l03087"></a>03087         }
<a name="l03088"></a>03088         <span class="keywordflow">else</span> {
<a name="l03089"></a>03089           <a class="code" href="polyhedron_8c.html#af08de0a78a3c54f1b6c8a554cf68656c">addToFilter</a>(j, Filter, Sat, tmpR, tmpC, NbRays, NbConstraints);
<a name="l03090"></a>03090           <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(P1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[j],Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>],Dimension+1);
<a name="l03091"></a>03091           Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>++;
<a name="l03092"></a>03092           <a class="code" href="source_2arith_2arithmetique_8h.html#a7e293e9652086118cc5b660e6022767c">value_decrement</a>(NbConstraintsLeft,NbConstraintsLeft);
<a name="l03093"></a>03093         }
<a name="l03094"></a>03094       }
<a name="l03095"></a>03095       <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat), Sat = NULL;
<a name="l03096"></a>03096       free(tmpC), tmpC = NULL;
<a name="l03097"></a>03097       free(tmpR), tmpR = NULL;
<a name="l03098"></a>03098     }   
<a name="l03099"></a>03099   } <span class="comment">/* end of TRY */</span>
<a name="l03100"></a>03100   
<a name="l03101"></a>03101   <span class="comment">/* Clear all the &apos;Value&apos; variables */</span>
<a name="l03102"></a>03102   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(NbConstraintsLeft);
<a name="l03103"></a>03103   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l03104"></a>03104   <span class="keywordflow">for</span>(i=0;i&lt;NbRays;i++)
<a name="l03105"></a>03105     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmpR[i]);
<a name="l03106"></a>03106   <span class="keywordflow">for</span>(i=0;i&lt;NbRays;i++)
<a name="l03107"></a>03107     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmpC[i]);
<a name="l03108"></a>03108   
<a name="l03109"></a>03109   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03110"></a>03110 } <span class="comment">/* FindSimple */</span>
<a name="l03111"></a>03111 
<a name="l03112"></a>03112 <span class="comment">/* </span>
<a name="l03113"></a>03113 <span class="comment"> * Return 0 if the intersection of Pol1 and Pol2 is empty, otherwise return 1.</span>
<a name="l03114"></a>03114 <span class="comment"> * If the intersection is non-empty, store the non-redundant constraints in </span>
<a name="l03115"></a>03115 <span class="comment"> * &apos;Filter&apos; array. If the intersection is empty then store the smallest set of</span>
<a name="l03116"></a>03116 <span class="comment"> * constraints of &apos;Pol1&apos; which on intersection with &apos;Pol2&apos; gives empty set, in</span>
<a name="l03117"></a>03117 <span class="comment"> * &apos;Filter&apos; array. &apos;NbMaxRays&apos; is the maximum allowed rays in the intersection</span>
<a name="l03118"></a>03118 <span class="comment"> *  of &apos;Pol1&apos; and &apos;Pol2&apos;.   </span>
<a name="l03119"></a>03119 <span class="comment"> */</span>
<a name="l03120"></a><a class="code" href="polyhedron_8c.html#a967a5dd2175dd962c94c1d7ef0e9047b">03120</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="polyhedron_8c.html#a967a5dd2175dd962c94c1d7ef0e9047b">SimplifyConstraints</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol1,<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol2,<span class="keywordtype">unsigned</span> *Filter,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l03121"></a>03121   
<a name="l03122"></a>03122   <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol = NULL;
<a name="l03123"></a>03123   <a class="code" href="structmatrix.html">Matrix</a>   *Mat = NULL, *Ray = NULL;
<a name="l03124"></a>03124   <a class="code" href="structSatMatrix.html">SatMatrix</a> *<a class="code" href="polyparam_8c.html#a41ad9a1ceff17c92987e3d80dfbaccf4">Sat</a> = NULL;
<a name="l03125"></a>03125   <span class="keywordtype">unsigned</span> NbRay, NbCon, NbCon1, NbCon2, NbEle1, Dimension, notempty;
<a name="l03126"></a>03126 
<a name="l03127"></a>03127   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l03128"></a>03128     <span class="keywordflow">if</span> (Pol) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol);
<a name="l03129"></a>03129     <span class="keywordflow">if</span> (Mat) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);
<a name="l03130"></a>03130     <span class="keywordflow">if</span> (Ray) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ray);
<a name="l03131"></a>03131     <span class="keywordflow">if</span> (Sat) <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat);
<a name="l03132"></a>03132     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l03133"></a>03133   }
<a name="l03134"></a>03134   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l03135"></a>03135 
<a name="l03136"></a>03136     NbRay         = Pol1-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>;
<a name="l03137"></a>03137     NbCon1        = Pol1-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l03138"></a>03138     NbCon2        = Pol2-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l03139"></a>03139     NbCon         = NbCon1 + NbCon2;
<a name="l03140"></a>03140     Dimension     = Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;    <span class="comment">/* Homogeneous Dimension + Status */</span>
<a name="l03141"></a>03141     NbEle1        = NbCon1*Dimension;
<a name="l03142"></a>03142     
<a name="l03143"></a>03143     <span class="comment">/* Ignore for now */</span>
<a name="l03144"></a>03144     <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(NbMaxRays, <a class="code" href="types_8h.html#a754586a0aee88f21ad4c98b1cddee1be">POL_NO_DUAL</a>))
<a name="l03145"></a>03145       NbMaxRays = 0;
<a name="l03146"></a>03146 
<a name="l03147"></a>03147     <span class="keywordflow">if</span> (NbRay &gt; NbMaxRays)
<a name="l03148"></a>03148       NbMaxRays = NbRay;
<a name="l03149"></a>03149 
<a name="l03150"></a>03150     <span class="comment">/* Allocate space for constraint matrix &apos;Mat&apos; */</span>
<a name="l03151"></a>03151     Mat = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbCon, Dimension);
<a name="l03152"></a>03152     <span class="keywordflow">if</span>(!Mat) {
<a name="l03153"></a>03153       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;SimplifyConstraints&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l03154"></a>03154       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03155"></a>03155       <span class="keywordflow">return</span> 0;
<a name="l03156"></a>03156     }
<a name="l03157"></a>03157 
<a name="l03158"></a>03158     <span class="comment">/* Copy constraints of &apos;Pol1&apos; to matrix &apos;Mat&apos; */</span>
<a name="l03159"></a>03159     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], Mat-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>, NbEle1);
<a name="l03160"></a>03160     
<a name="l03161"></a>03161     <span class="comment">/* Add constraints of &apos;Pol2&apos; to matrix &apos;Mat&apos;*/</span>
<a name="l03162"></a>03162     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], Mat-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>+NbEle1, NbCon2*Dimension);
<a name="l03163"></a>03163 
<a name="l03164"></a>03164     <span class="comment">/* Allocate space for ray matrix &apos;Ray&apos; */</span>
<a name="l03165"></a>03165     Ray = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbMaxRays, Dimension);
<a name="l03166"></a>03166     <span class="keywordflow">if</span>(!Ray) {
<a name="l03167"></a>03167       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;SimplifyConstraints&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l03168"></a>03168       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03169"></a>03169       <span class="keywordflow">return</span> 0;
<a name="l03170"></a>03170     }
<a name="l03171"></a>03171     Ray-&gt;NbRows = NbRay;
<a name="l03172"></a>03172         
<a name="l03173"></a>03173     <span class="comment">/* Copy rays of polyhedron &apos;Pol1&apos; to matrix &apos;Ray&apos; */</span>
<a name="l03174"></a>03174     <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol1-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[0], Ray-&gt;p_Init, NbRay*Dimension);
<a name="l03175"></a>03175 
<a name="l03176"></a>03176     <span class="comment">/* Create saturation matrix from constraint matrix &apos;Mat&apos; and ray matrix */</span>
<a name="l03177"></a>03177     <span class="comment">/* &apos;Ray&apos;.                                                               */</span>
<a name="l03178"></a>03178     Sat = <a class="code" href="polyhedron_8c.html#a542ec91dd2ace5b3faab3f02511d26bd">BuildSat</a>(Mat, Ray, NbCon1, NbMaxRays);
<a name="l03179"></a>03179 
<a name="l03180"></a>03180     <span class="comment">/* Create the ray matrix &apos;Ray&apos; from the constraint matrix &apos;Mat&apos; */</span>
<a name="l03181"></a>03181     <a class="code" href="errormsg_8c.html#aa587bf4e8c763fa5e95542df7eb070b7">Pol_status</a> = <a class="code" href="polyhedron_8c.html#a6138e0e907fa19ecc60710b1ab1868c1">Chernikova</a>(Mat, Ray, Sat, Pol1-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a>, NbMaxRays, NbCon1,0);
<a name="l03182"></a>03182 
<a name="l03183"></a>03183     <span class="comment">/* Remove redundant constraints from the constraint matrix &apos;Mat&apos; */</span>
<a name="l03184"></a>03184     Pol = <a class="code" href="polyhedron_8c.html#a1288eb192e28147e2572f35ed3a82de3">Remove_Redundants</a>(Mat, Ray, Sat, Filter);
<a name="l03185"></a>03185     notempty = 1;
<a name="l03186"></a>03186     <span class="keywordflow">if</span> (Filter &amp;&amp; <a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(Pol)) {
<a name="l03187"></a>03187       notempty = 0;
<a name="l03188"></a>03188       <a class="code" href="polyhedron_8c.html#a8f3a2040fba83bdd5e328b42c7aed63c">FindSimple</a>(Pol1, Pol2, Filter, NbMaxRays);
<a name="l03189"></a>03189     }
<a name="l03190"></a>03190     <span class="comment">/* Polyhedron_Print(stderr,&quot;%4d&quot;,Pol1); */</span>
<a name="l03191"></a>03191 
<a name="l03192"></a>03192     <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(Pol), Pol = NULL;
<a name="l03193"></a>03193     <a class="code" href="polyhedron_8c.html#a367ed1d639627aa759b98db73cdfc4ef">SMFree</a>(&amp;Sat), Sat = NULL;
<a name="l03194"></a>03194     <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ray), Ray = NULL;
<a name="l03195"></a>03195     <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat), Mat = NULL;
<a name="l03196"></a>03196     
<a name="l03197"></a>03197   } <span class="comment">/* end of TRY */</span>
<a name="l03198"></a>03198 
<a name="l03199"></a>03199   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);  
<a name="l03200"></a>03200   <span class="keywordflow">return</span> notempty;
<a name="l03201"></a>03201 } <span class="comment">/* SimplifyConstraints */</span>
<a name="l03202"></a>03202 
<a name="l03203"></a>03203 <span class="comment">/* </span>
<a name="l03204"></a>03204 <span class="comment"> * Eliminate equations of Pol1 using equations of Pol2. Mark as needed, </span>
<a name="l03205"></a>03205 <span class="comment"> * equations of Pol1 that are not eliminated. Or info into Filter vector. </span>
<a name="l03206"></a>03206 <span class="comment"> */</span>
<a name="l03207"></a><a class="code" href="polyhedron_8c.html#ae8a1aa65cd8281406d143e51a2be7563">03207</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#ae8a1aa65cd8281406d143e51a2be7563">SimplifyEqualities</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol1, <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol2, <span class="keywordtype">unsigned</span> *Filter) {
<a name="l03208"></a>03208 
<a name="l03209"></a>03209   <span class="keywordtype">int</span> i,j;
<a name="l03210"></a>03210   <span class="keywordtype">unsigned</span> ix, bx, NbEqn, NbEqn1, NbEqn2, NbEle2, Dimension;
<a name="l03211"></a>03211   <a class="code" href="structmatrix.html">Matrix</a>   *Mat;
<a name="l03212"></a>03212 
<a name="l03213"></a>03213   NbEqn1        = Pol1-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>;
<a name="l03214"></a>03214   NbEqn2        = Pol2-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>;
<a name="l03215"></a>03215   NbEqn         = NbEqn1 + NbEqn2;
<a name="l03216"></a>03216   Dimension     = Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;    <span class="comment">/* Homogeneous Dimension + Status */</span>
<a name="l03217"></a>03217   NbEle2        = NbEqn2*Dimension;
<a name="l03218"></a>03218 
<a name="l03219"></a>03219   Mat = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbEqn, Dimension);
<a name="l03220"></a>03220   <span class="keywordflow">if</span> (!Mat) {
<a name="l03221"></a>03221     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;SimplifyEqualities&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l03222"></a>03222     <a class="code" href="errormsg_8c.html#aa587bf4e8c763fa5e95542df7eb070b7">Pol_status</a> = 1;
<a name="l03223"></a>03223     <span class="keywordflow">return</span>;
<a name="l03224"></a>03224   }
<a name="l03225"></a>03225 
<a name="l03226"></a>03226   <span class="comment">/* Set the equalities of Pol2 */</span>
<a name="l03227"></a>03227   <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], Mat-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>, NbEle2);
<a name="l03228"></a>03228 
<a name="l03229"></a>03229   <span class="comment">/* Add the equalities of Pol1 */</span>
<a name="l03230"></a>03230   <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], Mat-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>+NbEle2, NbEqn1*Dimension);
<a name="l03231"></a>03231 
<a name="l03232"></a>03232   <a class="code" href="polyhedron_8c.html#a671d2a19d0c376dec383521e78faa70a">Gauss</a>(Mat, NbEqn2, Dimension-1);
<a name="l03233"></a>03233 
<a name="l03234"></a>03234   ix = 0;
<a name="l03235"></a>03235   bx = <a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>;
<a name="l03236"></a>03236   <span class="keywordflow">for</span> (i=NbEqn2; i&lt;NbEqn; i++) {
<a name="l03237"></a>03237     <span class="keywordflow">for</span> (j=1; j&lt;Dimension; j++) {
<a name="l03238"></a>03238       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j])) { 
<a name="l03239"></a>03239         <span class="comment">/* If any coefficient of the equation is non-zero */</span>    
<a name="l03240"></a>03240         <span class="comment">/* Set the filter bit for the equation */</span>
<a name="l03241"></a>03241         
<a name="l03242"></a>03242         Filter[ix] |= bx;
<a name="l03243"></a>03243         <span class="keywordflow">break</span>;
<a name="l03244"></a>03244       }
<a name="l03245"></a>03245     }
<a name="l03246"></a>03246     <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(ix,bx);
<a name="l03247"></a>03247   }
<a name="l03248"></a>03248   <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);
<a name="l03249"></a>03249   <span class="keywordflow">return</span>;
<a name="l03250"></a>03250 } <span class="comment">/* SimplifyEqualities */</span>
<a name="l03251"></a>03251 
<a name="l03252"></a>03252  
<a name="l03253"></a>03253 <span class="comment">/* </span>
<a name="l03254"></a>03254 <span class="comment"> * Given two polyhedral domains &apos;Pol1&apos; and &apos;Pol2&apos;, find the largest domain</span>
<a name="l03255"></a>03255 <span class="comment"> * set (or the smallest list of non-redundant constraints), that when </span>
<a name="l03256"></a>03256 <span class="comment"> * intersected with polyhedral domain &apos;Pol2&apos; equals (Pol1)intersect(Pol2).</span>
<a name="l03257"></a>03257 <span class="comment"> * The output is a polyhedral domain with the &quot;redundant&quot; constraints removed.</span>
<a name="l03258"></a>03258 <span class="comment"> * &apos;NbMaxRays&apos; is the maximium allowed rays in the new polyhedra. </span>
<a name="l03259"></a>03259 <span class="comment"> */</span>
<a name="l03260"></a><a class="code" href="polyhedron_8h.html#a5fe8c61eb1dddc73783aad88c76ce758">03260</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a5fe8c61eb1dddc73783aad88c76ce758">DomainSimplify</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol1, <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol2, <span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l03261"></a>03261   
<a name="l03262"></a>03262   <a class="code" href="structpolyhedron.html">Polyhedron</a> *p1, *p2, *p3, *d;
<a name="l03263"></a>03263   <span class="keywordtype">unsigned</span> k, jx, bx, nbentries, NbConstraints, Dimension, NbCon, empty;
<a name="l03264"></a>03264   <span class="keywordtype">unsigned</span> *Filter;
<a name="l03265"></a>03265   <a class="code" href="structmatrix.html">Matrix</a> *Constraints;
<a name="l03266"></a>03266   
<a name="l03267"></a>03267 
<a name="l03268"></a>03268   <span class="keywordflow">if</span> (!Pol1 || !Pol2) <span class="keywordflow">return</span> Pol1;
<a name="l03269"></a>03269   <span class="keywordflow">if</span> (Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> != Pol2-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>) {
<a name="l03270"></a>03270     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomSimplify&quot;</span>,<span class="stringliteral">&quot;diffdim&quot;</span>,<span class="stringliteral">&quot;operation on different dimensions&quot;</span>);
<a name="l03271"></a>03271     <a class="code" href="errormsg_8c.html#aa587bf4e8c763fa5e95542df7eb070b7">Pol_status</a> = 1;
<a name="l03272"></a>03272     <span class="keywordflow">return</span> 0;
<a name="l03273"></a>03273   }
<a name="l03274"></a>03274   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol1);
<a name="l03275"></a>03275   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol2);
<a name="l03276"></a>03276   <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(Pol1)||<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(Pol2)) 
<a name="l03277"></a>03277     <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>);
<a name="l03278"></a>03278 
<a name="l03279"></a>03279   <span class="comment">/* Find the maximum number of constraints over all polyhedron in the  */</span>
<a name="l03280"></a>03280   <span class="comment">/* polyhedral domain &apos;Pol2&apos; and store in &apos;NbCon&apos;.                     */</span>
<a name="l03281"></a>03281   NbCon = 0;
<a name="l03282"></a>03282   <span class="keywordflow">for</span> (p2=Pol2; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>)
<a name="l03283"></a>03283     <span class="keywordflow">if</span> (p2-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> &gt; NbCon) 
<a name="l03284"></a>03284       NbCon = p2-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l03285"></a>03285   
<a name="l03286"></a>03286   Dimension = Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;     <span class="comment">/* Homogenous Dimension + Status  */</span>
<a name="l03287"></a>03287   d = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l03288"></a>03288   <span class="keywordflow">for</span> (p1=Pol1; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) { 
<a name="l03289"></a>03289 
<a name="l03290"></a>03290     <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(p1);
<a name="l03291"></a>03291 
<a name="l03292"></a>03292     <span class="comment">/* Filter is an array of integers, each bit in an element of Filter */</span>
<a name="l03293"></a>03293     <span class="comment">/* array corresponds to a constraint. The bit is marked 1 if the    */</span>
<a name="l03294"></a>03294     <span class="comment">/* corresponding constraint is non-redundant and is 0 if it is      */</span>
<a name="l03295"></a>03295     <span class="comment">/* redundant.                                                       */</span>
<a name="l03296"></a>03296     
<a name="l03297"></a>03297     NbConstraints = p1-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l03298"></a>03298     nbentries = (NbConstraints + NbCon - 1) / (<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>)*8) + 1;
<a name="l03299"></a>03299 
<a name="l03300"></a>03300     <span class="comment">/* Allocate space for array &apos;Filter&apos; */</span>
<a name="l03301"></a>03301     Filter  = (<span class="keywordtype">unsigned</span> *)malloc(nbentries * <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));
<a name="l03302"></a>03302     <span class="keywordflow">if</span> (!Filter) {
<a name="l03303"></a>03303       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomSimplify&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space\n&quot;</span>);
<a name="l03304"></a>03304       <a class="code" href="errormsg_8c.html#aa587bf4e8c763fa5e95542df7eb070b7">Pol_status</a> = 1;
<a name="l03305"></a>03305       <span class="keywordflow">return</span> 0;
<a name="l03306"></a>03306     } 
<a name="l03307"></a>03307     
<a name="l03308"></a>03308     <span class="comment">/* Initialize &apos;Filter&apos; with zeros */</span>
<a name="l03309"></a>03309     <a class="code" href="polyhedron_8c.html#a3351961690e2b071105b7bb4be0b7127">SMVector_Init</a>(Filter, nbentries);
<a name="l03310"></a>03310     
<a name="l03311"></a>03311     <span class="comment">/* Filter the constraints of p1 in context of polyhedra p2(s) */</span>
<a name="l03312"></a>03312     empty = 1;
<a name="l03313"></a>03313     <span class="keywordflow">for</span> (p2=Pol2; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l03314"></a>03314 
<a name="l03315"></a>03315       <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(p2);
<a name="l03316"></a>03316       
<a name="l03317"></a>03317       <span class="comment">/* Store the non-redundant constraints in array &apos;Filter&apos;. With    */</span>
<a name="l03318"></a>03318       <span class="comment">/* successive loops, the array &apos;Filter&apos; holds the union of all    */</span>
<a name="l03319"></a>03319       <span class="comment">/* non-redundant constraints. &apos;empty&apos; is set to zero if the       */</span>
<a name="l03320"></a>03320       <span class="comment">/* intersection of two polyhedra is non-empty and Filter is !Null */</span>
<a name="l03321"></a>03321       
<a name="l03322"></a>03322       <a class="code" href="polyhedron_8c.html#ae8a1aa65cd8281406d143e51a2be7563">SimplifyEqualities</a>(p1, p2, Filter);
<a name="l03323"></a>03323       <span class="keywordflow">if</span> (<a class="code" href="polyhedron_8c.html#a967a5dd2175dd962c94c1d7ef0e9047b">SimplifyConstraints</a>(p1, p2, Filter, NbMaxRays)) 
<a name="l03324"></a>03324         empty=0;      
<a name="l03325"></a>03325             
<a name="l03326"></a>03326       <span class="comment">/* takes the union of all non redundant constraints */</span>
<a name="l03327"></a>03327     }
<a name="l03328"></a>03328 
<a name="l03329"></a>03329     <span class="keywordflow">if</span> (!empty) {
<a name="l03330"></a>03330       
<a name="l03331"></a>03331       <span class="comment">/* Copy all non-redundant constraints to matrix &apos;Constraints&apos; */</span>
<a name="l03332"></a>03332       Constraints = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbConstraints, Dimension);
<a name="l03333"></a>03333       <span class="keywordflow">if</span> (!Constraints) {
<a name="l03334"></a>03334         <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomSimplify&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space\n&quot;</span>);
<a name="l03335"></a>03335         <a class="code" href="errormsg_8c.html#aa587bf4e8c763fa5e95542df7eb070b7">Pol_status</a> = 1;
<a name="l03336"></a>03336         <span class="keywordflow">return</span> 0;
<a name="l03337"></a>03337       }
<a name="l03338"></a>03338       Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> = 0;
<a name="l03339"></a>03339       <span class="keywordflow">for</span> (k=0, jx=0, bx=<a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>; k&lt;NbConstraints; k++) {
<a name="l03340"></a>03340 
<a name="l03341"></a>03341         <span class="comment">/* If a bit entry in Filter[jx] is marked 1, copy the correspond- */</span>
<a name="l03342"></a>03342         <span class="comment">/* ing constraint in matrix &apos;Constraints&apos;.                        */</span>
<a name="l03343"></a>03343         <span class="keywordflow">if</span> (Filter[jx]&amp;bx) { 
<a name="l03344"></a>03344           <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(p1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[k],
<a name="l03345"></a>03345                       Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>],
<a name="l03346"></a>03346                       Dimension);
<a name="l03347"></a>03347           Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>++;
<a name="l03348"></a>03348         }
<a name="l03349"></a>03349         <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(jx,bx);
<a name="l03350"></a>03350       }
<a name="l03351"></a>03351       
<a name="l03352"></a>03352       <span class="comment">/* Create the polyhedron &apos;p3&apos; corresponding to the constraints in   */</span>
<a name="l03353"></a>03353       <span class="comment">/* matrix &apos;Constraints&apos;.                                            */</span>
<a name="l03354"></a>03354       p3 = <a class="code" href="polyhedron_8c.html#aefb77665a187d751bdd44f106b12465e" title="Given a matrix of constraints (&amp;#39;Constraints&amp;#39;), construct and return a polyhedron...">Constraints2Polyhedron</a>(Constraints,NbMaxRays);
<a name="l03355"></a>03355       <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Constraints);
<a name="l03356"></a>03356       
<a name="l03357"></a>03357       <span class="comment">/* Add polyhedron &apos;p3&apos; in the domain &apos;d&apos;. */</span>
<a name="l03358"></a>03358       d = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a> (p3, d);
<a name="l03359"></a>03359       p3 = NULL;
<a name="l03360"></a>03360     }
<a name="l03361"></a>03361     free(Filter);
<a name="l03362"></a>03362   }
<a name="l03363"></a>03363   <span class="keywordflow">if</span> (!d) 
<a name="l03364"></a>03364     <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>); 
<a name="l03365"></a>03365   <span class="keywordflow">else</span> <span class="keywordflow">return</span> d;
<a name="l03366"></a>03366 
<a name="l03367"></a>03367 } <span class="comment">/* DomainSimplify */</span>
<a name="l03368"></a>03368 
<a name="l03369"></a>03369 <span class="comment">/*</span>
<a name="l03370"></a>03370 <span class="comment"> * Domain Simplify as defined in Strasborg Polylib version. </span>
<a name="l03371"></a>03371 <span class="comment"> */</span>
<a name="l03372"></a><a class="code" href="polyhedron_8h.html#a95a584b74e1fa94e39740fc4c4cf1bdb">03372</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a95a584b74e1fa94e39740fc4c4cf1bdb">Stras_DomainSimplify</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol1,<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol2,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l03373"></a>03373 
<a name="l03374"></a>03374   <a class="code" href="structpolyhedron.html">Polyhedron</a> *p1, *p2, *p3 = NULL, *d = NULL;
<a name="l03375"></a>03375   <span class="keywordtype">unsigned</span> k, jx, bx, nbentries, NbConstraints, Dimension, NbCon, empty;
<a name="l03376"></a>03376   <span class="keywordtype">unsigned</span>  *Filter = NULL;
<a name="l03377"></a>03377   <a class="code" href="structmatrix.html">Matrix</a> *Constraints = NULL;
<a name="l03378"></a>03378   
<a name="l03379"></a>03379   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l03380"></a>03380     <span class="keywordflow">if</span> (Constraints) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Constraints);
<a name="l03381"></a>03381     <span class="keywordflow">if</span> (Filter) free(Filter);
<a name="l03382"></a>03382     <span class="keywordflow">if</span> (d) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(d);
<a name="l03383"></a>03383     <span class="keywordflow">if</span> (p2) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(p3);
<a name="l03384"></a>03384     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l03385"></a>03385   }
<a name="l03386"></a>03386   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l03387"></a>03387     <span class="keywordflow">if</span> (!Pol1 || !Pol2) {
<a name="l03388"></a>03388       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03389"></a>03389       <span class="keywordflow">return</span> Pol1;
<a name="l03390"></a>03390     }
<a name="l03391"></a>03391     <span class="keywordflow">if</span> (Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> != Pol2-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>) {
<a name="l03392"></a>03392       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomainSimplify&quot;</span>,<span class="stringliteral">&quot;diffdim&quot;</span>,<span class="stringliteral">&quot;operation on different dimensions&quot;</span>);
<a name="l03393"></a>03393       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03394"></a>03394       <span class="keywordflow">return</span> 0;
<a name="l03395"></a>03395     }
<a name="l03396"></a>03396     <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol1);
<a name="l03397"></a>03397     <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol2);
<a name="l03398"></a>03398     <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(Pol1)||<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(Pol2)) {
<a name="l03399"></a>03399       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03400"></a>03400       <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>);
<a name="l03401"></a>03401     }
<a name="l03402"></a>03402     
<a name="l03403"></a>03403     <span class="comment">/* Find the maximum number of constraints over all polyhedron in the  */</span>
<a name="l03404"></a>03404     <span class="comment">/* polyhedral domain &apos;Pol2&apos; and store in &apos;NbCon&apos;.                     */</span>
<a name="l03405"></a>03405     NbCon = 0;
<a name="l03406"></a>03406     <span class="keywordflow">for</span> (p2=Pol2; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>)
<a name="l03407"></a>03407       <span class="keywordflow">if</span> (p2-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> &gt; NbCon)
<a name="l03408"></a>03408         NbCon = p2-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l03409"></a>03409     
<a name="l03410"></a>03410     Dimension = Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;      <span class="comment">/* Homogenous Dimension + Status  */</span>
<a name="l03411"></a>03411     d = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l03412"></a>03412     <span class="keywordflow">for</span> (p1=Pol1; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) { 
<a name="l03413"></a>03413 
<a name="l03414"></a>03414       <span class="comment">/* Filter is an array of integers, each bit in an element of Filter */</span>
<a name="l03415"></a>03415       <span class="comment">/* array corresponds to a constraint. The bit is marked 1 if the    */</span>
<a name="l03416"></a>03416       <span class="comment">/* corresponding constraint is non-redundant and is 0 if it is      */</span>
<a name="l03417"></a>03417       <span class="comment">/* redundant.                                                       */</span>
<a name="l03418"></a>03418       
<a name="l03419"></a>03419       NbConstraints = p1-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l03420"></a>03420       nbentries = (NbConstraints + NbCon - 1)/(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>)*8) + 1;
<a name="l03421"></a>03421       
<a name="l03422"></a>03422       <span class="comment">/* Allocate space for array &apos;Filter&apos; */</span>
<a name="l03423"></a>03423       Filter  = (<span class="keywordtype">unsigned</span> *)malloc(nbentries * <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));
<a name="l03424"></a>03424       <span class="keywordflow">if</span>(!Filter) {
<a name="l03425"></a>03425         <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomainSimplify&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l03426"></a>03426         <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03427"></a>03427         <span class="keywordflow">return</span> 0;
<a name="l03428"></a>03428       }
<a name="l03429"></a>03429       
<a name="l03430"></a>03430       <span class="comment">/* Initialize &apos;Filter&apos; with zeros */</span>
<a name="l03431"></a>03431       <a class="code" href="polyhedron_8c.html#a3351961690e2b071105b7bb4be0b7127">SMVector_Init</a>(Filter, nbentries);
<a name="l03432"></a>03432       
<a name="l03433"></a>03433       <span class="comment">/* Filter the constraints of p1 in context to the polyhedra p2(s)   */</span>
<a name="l03434"></a>03434       empty = 1;
<a name="l03435"></a>03435       <span class="keywordflow">for</span> (p2=Pol2; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l03436"></a>03436         
<a name="l03437"></a>03437         <span class="comment">/* Store the non-redundant constraints in array &apos;Filter&apos;. With    */</span>
<a name="l03438"></a>03438         <span class="comment">/* successive loops, the array &apos;Filter&apos; holds the union of all    */</span>
<a name="l03439"></a>03439         <span class="comment">/* non-redundant constraints. &apos;empty&apos; is set to zero if the       */</span>
<a name="l03440"></a>03440         <span class="comment">/* intersection of two polyhedra is non-empty and Filter is !Null */</span>
<a name="l03441"></a>03441    
<a name="l03442"></a>03442         <span class="keywordflow">if</span> (<a class="code" href="polyhedron_8c.html#a967a5dd2175dd962c94c1d7ef0e9047b">SimplifyConstraints</a>(p1, p2, Filter, NbMaxRays))
<a name="l03443"></a>03443           empty=0;
<a name="l03444"></a>03444       }
<a name="l03445"></a>03445       
<a name="l03446"></a>03446       <span class="keywordflow">if</span> (!empty) {
<a name="l03447"></a>03447         
<a name="l03448"></a>03448         <span class="comment">/* Copy all non-redundant constraints to matrix &apos;Constraints&apos; */</span>
<a name="l03449"></a>03449         Constraints = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbConstraints,Dimension);
<a name="l03450"></a>03450         <span class="keywordflow">if</span>(!Constraints) {
<a name="l03451"></a>03451           <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomainSimplify&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l03452"></a>03452           <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03453"></a>03453           <span class="keywordflow">return</span> 0;
<a name="l03454"></a>03454         }
<a name="l03455"></a>03455         Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> = 0;
<a name="l03456"></a>03456         <span class="keywordflow">for</span> (k=0, jx=0, bx=<a class="code" href="types_8h.html#a11f27b3b63dfc15c4b4fbb665a3ce3fe">MSB</a>; k&lt;NbConstraints; k++) {
<a name="l03457"></a>03457           
<a name="l03458"></a>03458           <span class="comment">/* If a bit entry in Filter[jx] is marked 1, copy the correspond- */</span>
<a name="l03459"></a>03459           <span class="comment">/* ing constraint in matrix &apos;Constraints&apos;.                        */</span>
<a name="l03460"></a>03460           <span class="keywordflow">if</span> (Filter[jx]&amp;bx) { 
<a name="l03461"></a>03461             <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(p1-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[k],
<a name="l03462"></a>03462                         Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>],
<a name="l03463"></a>03463                         Dimension);
<a name="l03464"></a>03464             Constraints-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>++;
<a name="l03465"></a>03465           }
<a name="l03466"></a>03466           <a class="code" href="types_8h.html#a3dd66db5db700555d4e24314974a2ea1">NEXT</a>(jx,bx);
<a name="l03467"></a>03467         }
<a name="l03468"></a>03468         
<a name="l03469"></a>03469         <span class="comment">/* Create the polyhedron &apos;p3&apos; corresponding to the constraints in   */</span>
<a name="l03470"></a>03470         <span class="comment">/* matrix &apos;Constraints&apos;.                                            */</span>
<a name="l03471"></a>03471         p3 = <a class="code" href="polyhedron_8c.html#aefb77665a187d751bdd44f106b12465e" title="Given a matrix of constraints (&amp;#39;Constraints&amp;#39;), construct and return a polyhedron...">Constraints2Polyhedron</a>(Constraints,NbMaxRays);
<a name="l03472"></a>03472         <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Constraints), Constraints = NULL;
<a name="l03473"></a>03473         
<a name="l03474"></a>03474         <span class="comment">/* Add polyhedron &apos;p3&apos; in the domain &apos;d&apos;. */</span>
<a name="l03475"></a>03475         d = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a> (p3, d);
<a name="l03476"></a>03476         p3 = NULL;
<a name="l03477"></a>03477       }
<a name="l03478"></a>03478       free(Filter), Filter = NULL;
<a name="l03479"></a>03479     }
<a name="l03480"></a>03480   } <span class="comment">/* end of TRY */</span>
<a name="l03481"></a>03481         
<a name="l03482"></a>03482   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);  
<a name="l03483"></a>03483   <span class="keywordflow">if</span> (!d)
<a name="l03484"></a>03484     <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>);
<a name="l03485"></a>03485   <span class="keywordflow">else</span>
<a name="l03486"></a>03486     <span class="keywordflow">return</span> d;
<a name="l03487"></a>03487 } <span class="comment">/* DomainSimplify */</span>
<a name="l03488"></a>03488 
<a name="l03489"></a>03489 <span class="comment">/*</span>
<a name="l03490"></a>03490 <span class="comment"> * Return the Union of two polyhedral domains &apos;Pol1&apos; and Pol2&apos;. The result is</span>
<a name="l03491"></a>03491 <span class="comment"> * a new polyhedral domain.</span>
<a name="l03492"></a>03492 <span class="comment"> */</span>
<a name="l03493"></a><a class="code" href="polyhedron_8h.html#a6e402792ade8ef5e83a87d623f03c5cb">03493</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a6e402792ade8ef5e83a87d623f03c5cb">DomainUnion</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol1,<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol2,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l03494"></a>03494 
<a name="l03495"></a>03495   <a class="code" href="structpolyhedron.html">Polyhedron</a> *PolA, *PolEndA, *PolB, *PolEndB, *p1, *p2;
<a name="l03496"></a>03496   <span class="keywordtype">int</span> Redundant;
<a name="l03497"></a>03497   
<a name="l03498"></a>03498   <span class="keywordflow">if</span> (!Pol1 || !Pol2) <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a> *) 0;
<a name="l03499"></a>03499   <span class="keywordflow">if</span> (Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> != Pol2-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>) {
<a name="l03500"></a>03500     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomainUnion&quot;</span>,<span class="stringliteral">&quot;diffdim&quot;</span>,<span class="stringliteral">&quot;operation on different dimensions&quot;</span>);
<a name="l03501"></a>03501     <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l03502"></a>03502   }
<a name="l03503"></a>03503 
<a name="l03504"></a>03504 
<a name="l03505"></a>03505 
<a name="l03506"></a>03506 
<a name="l03507"></a>03507 
<a name="l03508"></a>03508 
<a name="l03509"></a>03509   <span class="comment">/* Copy &apos;Pol1&apos; to &apos;PolA&apos; */</span>
<a name="l03510"></a>03510   PolA = PolEndA = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l03511"></a>03511   <span class="keywordflow">for</span> (p1=Pol1; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l03512"></a>03512     
<a name="l03513"></a>03513     <span class="comment">/* Does any component of &apos;Pol2&apos; cover &apos;p1&apos; ? */</span>
<a name="l03514"></a>03514     Redundant = 0;
<a name="l03515"></a>03515     <span class="keywordflow">for</span> (p2=Pol2; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l03516"></a>03516       <span class="keywordflow">if</span> (<a class="code" href="polyhedron_8c.html#a107a96d44465428ffcd25f1ab3d67b43">PolyhedronIncludes</a>(p2, p1) ) { <span class="comment">/* p2 covers p1 */</span> 
<a name="l03517"></a>03517         Redundant = 1;
<a name="l03518"></a>03518         
<a name="l03519"></a>03519 
<a name="l03520"></a>03520         <span class="keywordflow">break</span>;
<a name="l03521"></a>03521 
<a name="l03522"></a>03522       }
<a name="l03523"></a>03523     }
<a name="l03524"></a>03524     <span class="keywordflow">if</span> (!Redundant) {
<a name="l03525"></a>03525       
<a name="l03526"></a>03526       <span class="comment">/* Add &apos;p1&apos; to &apos;PolA&apos; */</span>
<a name="l03527"></a>03527       <span class="keywordflow">if</span> (!PolEndA)
<a name="l03528"></a>03528         PolEndA = PolA = <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(p1);
<a name="l03529"></a>03529       <span class="keywordflow">else</span> {
<a name="l03530"></a>03530         PolEndA-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(p1);
<a name="l03531"></a>03531         PolEndA = PolEndA-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l03532"></a>03532       }
<a name="l03533"></a>03533 
<a name="l03534"></a>03534     }
<a name="l03535"></a>03535   }
<a name="l03536"></a>03536 
<a name="l03537"></a>03537   <span class="comment">/* Copy &apos;Pol2&apos; to PolB */</span>
<a name="l03538"></a>03538   PolB = PolEndB = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l03539"></a>03539   <span class="keywordflow">for</span> (p2=Pol2; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l03540"></a>03540 
<a name="l03541"></a>03541     <span class="comment">/* Does any component of PolA cover &apos;p2&apos; ? */</span>
<a name="l03542"></a>03542     Redundant = 0;
<a name="l03543"></a>03543     <span class="keywordflow">for</span> (p1=PolA; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l03544"></a>03544       <span class="keywordflow">if</span> (<a class="code" href="polyhedron_8c.html#a107a96d44465428ffcd25f1ab3d67b43">PolyhedronIncludes</a>(p1, p2)) { <span class="comment">/* p1 covers p2 */</span>
<a name="l03545"></a>03545         Redundant = 1;
<a name="l03546"></a>03546         <span class="keywordflow">break</span>;
<a name="l03547"></a>03547       }
<a name="l03548"></a>03548     }
<a name="l03549"></a>03549     <span class="keywordflow">if</span> (!Redundant) {
<a name="l03550"></a>03550       
<a name="l03551"></a>03551       <span class="comment">/* Add &apos;p2&apos; to &apos;PolB&apos; */</span>
<a name="l03552"></a>03552       <span class="keywordflow">if</span> (!PolEndB)
<a name="l03553"></a>03553         PolEndB = PolB = <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(p2);
<a name="l03554"></a>03554       <span class="keywordflow">else</span> {
<a name="l03555"></a>03555         PolEndB-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(p2);
<a name="l03556"></a>03556         PolEndB = PolEndB-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l03557"></a>03557       }
<a name="l03558"></a>03558 
<a name="l03559"></a>03559 
<a name="l03560"></a>03560     }
<a name="l03561"></a>03561   }
<a name="l03562"></a>03562 
<a name="l03563"></a>03563   <span class="keywordflow">if</span> (!PolA) <span class="keywordflow">return</span> PolB;
<a name="l03564"></a>03564   PolEndA-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = PolB;
<a name="l03565"></a>03565   <span class="keywordflow">return</span> PolA;
<a name="l03566"></a>03566 } <span class="comment">/* DomainUnion */</span>
<a name="l03567"></a>03567 
<a name="l03568"></a>03568 <span class="comment">/* </span>
<a name="l03569"></a>03569 <span class="comment"> * Given a polyhedral domain &apos;Pol&apos;, concatenate the lists of rays and lines </span>
<a name="l03570"></a>03570 <span class="comment"> * of the two (or more) polyhedra in the domain into one combined list, and </span>
<a name="l03571"></a>03571 <span class="comment"> * find the set of constraints which tightly bound all of those objects. </span>
<a name="l03572"></a>03572 <span class="comment"> * &apos;NbMaxConstrs&apos; is the maximum allowed constraints in the new polyhedron. </span>
<a name="l03573"></a>03573 <span class="comment"> */</span> 
<a name="l03574"></a><a class="code" href="polyhedron_8h.html#a53b04dfca9570691fbe42574118215ab">03574</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a53b04dfca9570691fbe42574118215ab">DomainConvex</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<span class="keywordtype">unsigned</span> NbMaxConstrs) {
<a name="l03575"></a>03575   
<a name="l03576"></a>03576   <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a>, *q, *NewPol = NULL;
<a name="l03577"></a>03577   
<a name="l03578"></a>03578   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l03579"></a>03579     <span class="keywordflow">if</span> (NewPol) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(NewPol);
<a name="l03580"></a>03580     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l03581"></a>03581   }
<a name="l03582"></a>03582   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l03583"></a>03583     
<a name="l03584"></a>03584     <span class="keywordflow">if</span> (!Pol) {
<a name="l03585"></a>03585       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03586"></a>03586       <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l03587"></a>03587     }
<a name="l03588"></a>03588     
<a name="l03589"></a>03589     <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol);
<a name="l03590"></a>03590     NewPol = <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(Pol);
<a name="l03591"></a>03591     <span class="keywordflow">for</span> (p=Pol-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>; p; p=p-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l03592"></a>03592       <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(p);
<a name="l03593"></a>03593       q = <a class="code" href="polyhedron_8c.html#a964e678fe2d07dd6162a7f1c429d38ba">AddRays</a>(p-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[0], p-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>, NewPol, NbMaxConstrs);
<a name="l03594"></a>03594       <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(NewPol);
<a name="l03595"></a>03595       NewPol = q;
<a name="l03596"></a>03596     }
<a name="l03597"></a>03597   } <span class="comment">/* end of TRY */</span>
<a name="l03598"></a>03598   
<a name="l03599"></a>03599   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03600"></a>03600   
<a name="l03601"></a>03601   <span class="keywordflow">return</span> NewPol;
<a name="l03602"></a>03602 } <span class="comment">/* DomainConvex */</span>
<a name="l03603"></a>03603 
<a name="l03604"></a>03604 <span class="comment">/*</span>
<a name="l03605"></a>03605 <span class="comment"> * Given polyhedral domains &apos;Pol1&apos; and &apos;Pol2&apos;, create a new polyhedral </span>
<a name="l03606"></a>03606 <span class="comment"> * domain which is mathematically the differnce of the two domains. </span>
<a name="l03607"></a>03607 <span class="comment"> */</span>
<a name="l03608"></a><a class="code" href="polyhedron_8h.html#aaaefa8685a2b2819b9863f2e4ff427f5">03608</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#aaaefa8685a2b2819b9863f2e4ff427f5">DomainDifference</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol1,<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol2,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l03609"></a>03609 
<a name="l03610"></a>03610   <a class="code" href="structpolyhedron.html">Polyhedron</a> *p1, *p2, *p3, *d;
<a name="l03611"></a>03611   <span class="keywordtype">int</span> i;
<a name="l03612"></a>03612   
<a name="l03613"></a>03613   <span class="keywordflow">if</span> (!Pol1 || !Pol2) <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l03614"></a>03614   <span class="keywordflow">if</span> (Pol1-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> != Pol2-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>) {
<a name="l03615"></a>03615     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomainDifference&quot;</span>, 
<a name="l03616"></a>03616               <span class="stringliteral">&quot;diffdim&quot;</span>, <span class="stringliteral">&quot;operation on different dimensions&quot;</span>);
<a name="l03617"></a>03617     <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l03618"></a>03618   }
<a name="l03619"></a>03619   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(Pol1);
<a name="l03620"></a>03620   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol1);
<a name="l03621"></a>03621   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(Pol2);
<a name="l03622"></a>03622   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol2);
<a name="l03623"></a>03623   <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(Pol1) || <a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(Pol2))
<a name="l03624"></a>03624     <span class="keywordflow">return</span> (<a class="code" href="polyhedron_8c.html#ad57e191f32f3c9022ec00747f4908b3f">Domain_Copy</a>(Pol1));
<a name="l03625"></a>03625   d = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l03626"></a>03626   <span class="keywordflow">for</span> (p2=Pol2; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l03627"></a>03627     <span class="keywordflow">for</span> (p1=Pol1; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l03628"></a>03628       <span class="keywordflow">for</span> (i=0; i&lt;p2-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>; i++) {
<a name="l03629"></a>03629         
<a name="l03630"></a>03630         <span class="comment">/* Add the constraint ( -p2-&gt;constraint[i] -1) &gt;= 0 in &apos;p1&apos; */</span>
<a name="l03631"></a>03631         <span class="comment">/* and create the new polyhedron &apos;p3&apos;.                      */</span>
<a name="l03632"></a>03632         p3 = <a class="code" href="polyhedron_8c.html#a1a9b9a572ee65d1c15aea3f9885dde7a">SubConstraint</a>(p2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i], p1, NbMaxRays,0);
<a name="l03633"></a>03633         
<a name="l03634"></a>03634         <span class="comment">/* Add &apos;p3&apos; in the new domain &apos;d&apos; */</span>
<a name="l03635"></a>03635         d = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a> (p3, d);
<a name="l03636"></a>03636         
<a name="l03637"></a>03637         <span class="comment">/* If the constraint p2-&gt;constraint[i][0] is an equality, then  */</span>
<a name="l03638"></a>03638         <span class="comment">/* add the constraint ( +p2-&gt;constraint[i] -1) &gt;= 0  in &apos;p1&apos; and*/</span>
<a name="l03639"></a>03639         <span class="comment">/* create the new polyhedron &apos;p3&apos;.                              */</span>
<a name="l03640"></a>03640         
<a name="l03641"></a>03641         <span class="keywordflow">if</span>( <a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(p2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][0]) ) <span class="comment">/* Inequality */</span>
<a name="l03642"></a>03642           <span class="keywordflow">continue</span>;  
<a name="l03643"></a>03643         p3 = <a class="code" href="polyhedron_8c.html#a1a9b9a572ee65d1c15aea3f9885dde7a">SubConstraint</a>(p2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i], p1, NbMaxRays,1);
<a name="l03644"></a>03644         
<a name="l03645"></a>03645         <span class="comment">/* Add &apos;p3&apos; in the new domain &apos;d&apos; */</span>
<a name="l03646"></a>03646         d = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a> (p3, d);
<a name="l03647"></a>03647       }
<a name="l03648"></a>03648     }
<a name="l03649"></a>03649     <span class="keywordflow">if</span> (p2 != Pol2)
<a name="l03650"></a>03650         <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>(Pol1);
<a name="l03651"></a>03651     Pol1 = d;
<a name="l03652"></a>03652     d = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l03653"></a>03653   }
<a name="l03654"></a>03654   <span class="keywordflow">if</span> (!Pol1)
<a name="l03655"></a>03655     <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Pol2-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>);
<a name="l03656"></a>03656   <span class="keywordflow">else</span>
<a name="l03657"></a>03657     <span class="keywordflow">return</span> Pol1;
<a name="l03658"></a>03658 } <span class="comment">/* DomainDifference */</span>
<a name="l03659"></a>03659 
<a name="l03660"></a>03660 <span class="comment">/*</span>
<a name="l03661"></a>03661 <span class="comment"> * Given a polyhedral domain &apos;Pol&apos;, convert it to a new polyhedral domain </span>
<a name="l03662"></a>03662 <span class="comment"> * with dimension expanded to &apos;align_dimension&apos;. &apos;NbMaxRays&apos; is the maximum</span>
<a name="l03663"></a>03663 <span class="comment"> * allowed rays in the new polyhedra.</span>
<a name="l03664"></a>03664 <span class="comment"> */</span>
<a name="l03665"></a><a class="code" href="polyhedron_8h.html#affd77db2a2f748d557ab6be0fcede209">03665</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#affd77db2a2f748d557ab6be0fcede209">align_context</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<span class="keywordtype">int</span> align_dimension,<span class="keywordtype">int</span> NbMaxRays) {
<a name="l03666"></a>03666   
<a name="l03667"></a>03667   <span class="keywordtype">int</span> i, j, k;
<a name="l03668"></a>03668   <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a> = NULL, **next, *result = NULL;
<a name="l03669"></a>03669   <span class="keywordtype">unsigned</span> dim;
<a name="l03670"></a>03670 
<a name="l03671"></a>03671   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l03672"></a>03672     <span class="keywordflow">if</span> (result) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(result);
<a name="l03673"></a>03673     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l03674"></a>03674   }
<a name="l03675"></a>03675   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l03676"></a>03676     
<a name="l03677"></a>03677     <span class="keywordflow">if</span> (!Pol) <span class="keywordflow">return</span> Pol;
<a name="l03678"></a>03678     dim = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>;
<a name="l03679"></a>03679     <span class="keywordflow">if</span> (align_dimension &lt; Pol-&gt;Dimension) {
<a name="l03680"></a>03680       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;align_context&quot;</span>, <span class="stringliteral">&quot;diffdim&quot;</span>, <span class="stringliteral">&quot;context dimension exceeds data&quot;</span>);
<a name="l03681"></a>03681       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03682"></a>03682       <span class="keywordflow">return</span> NULL;
<a name="l03683"></a>03683     }
<a name="l03684"></a>03684     <span class="keywordflow">if</span> (align_dimension == Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>) {
<a name="l03685"></a>03685       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03686"></a>03686       <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#ad57e191f32f3c9022ec00747f4908b3f">Domain_Copy</a>(Pol);
<a name="l03687"></a>03687     }
<a name="l03688"></a>03688 
<a name="l03689"></a>03689     <span class="comment">/* &apos;k&apos; is the dimension increment */</span>
<a name="l03690"></a>03690     k = align_dimension - Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>;
<a name="l03691"></a>03691     next = &amp;result;
<a name="l03692"></a>03692 
<a name="l03693"></a>03693     <span class="comment">/* Expand the dimension of all polyhedra in the polyhedral domain &apos;Pol&apos; */</span>
<a name="l03694"></a>03694     <span class="keywordflow">for</span> (; Pol; Pol=Pol-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l03695"></a>03695       <span class="keywordtype">int</span> have_cons = !<a class="code" href="types_8h.html#a19f1ae711bb0e3063ba1962cb8a898a0">F_ISSET</a>(Pol, <a class="code" href="types_8h.html#a2ac4c28a3acbe4578e03ad20db7939cc">POL_VALID</a>) || <a class="code" href="types_8h.html#a19f1ae711bb0e3063ba1962cb8a898a0">F_ISSET</a>(Pol, <a class="code" href="types_8h.html#a1869e11b8e9a1e9e89e8145c242e0eea">POL_INEQUALITIES</a>);
<a name="l03696"></a>03696       <span class="keywordtype">int</span> have_rays = !<a class="code" href="types_8h.html#a19f1ae711bb0e3063ba1962cb8a898a0">F_ISSET</a>(Pol, <a class="code" href="types_8h.html#a2ac4c28a3acbe4578e03ad20db7939cc">POL_VALID</a>) || <a class="code" href="types_8h.html#a19f1ae711bb0e3063ba1962cb8a898a0">F_ISSET</a>(Pol, <a class="code" href="types_8h.html#aacccb2db7ed6cb45d5e324216aa5ea3f">POL_POINTS</a>);
<a name="l03697"></a>03697       <span class="keywordtype">unsigned</span> NbCons = have_cons ? Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> : 0;
<a name="l03698"></a>03698       <span class="keywordtype">unsigned</span> NbRays = have_rays ? Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a> + k : 0;
<a name="l03699"></a>03699 
<a name="l03700"></a>03700       <span class="keywordflow">if</span> (Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> != dim) {
<a name="l03701"></a>03701         <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>(result);
<a name="l03702"></a>03702         <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;align_context&quot;</span>, <span class="stringliteral">&quot;diffdim&quot;</span>, <span class="stringliteral">&quot;context not of uniform dimension&quot;</span>);
<a name="l03703"></a>03703         <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03704"></a>03704         <span class="keywordflow">return</span> NULL;
<a name="l03705"></a>03705       }
<a name="l03706"></a>03706 
<a name="l03707"></a>03707       p = <a class="code" href="polyhedron_8c.html#aa308ade6448cc5544e21d59e86a53ddf">Polyhedron_Alloc</a>(align_dimension, NbCons, NbRays);
<a name="l03708"></a>03708       <span class="keywordflow">if</span> (have_cons) {
<a name="l03709"></a>03709         <span class="keywordflow">for</span> (i = 0; i &lt; NbCons; ++i) {
<a name="l03710"></a>03710           <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(p-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][0], Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][0]);  <span class="comment">/* Status bit */</span>
<a name="l03711"></a>03711           <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i]+1, p-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i]+k+1, Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1);
<a name="l03712"></a>03712         }
<a name="l03713"></a>03713         p-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a> = Pol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>;
<a name="l03714"></a>03714       }
<a name="l03715"></a>03715 
<a name="l03716"></a>03716       <span class="keywordflow">if</span> (have_rays) {
<a name="l03717"></a>03717         <span class="keywordflow">for</span> (i = 0; i &lt; k; ++i)
<a name="l03718"></a>03718           <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(p-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[i][1+i], 1);                          <span class="comment">/* A line */</span>
<a name="l03719"></a>03719         <span class="keywordflow">for</span> (i = 0; i &lt; Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>; ++i) {
<a name="l03720"></a>03720           <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(p-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[k+i][0], Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[i][0]);             <span class="comment">/* Status bit */</span>
<a name="l03721"></a>03721           <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[i]+1, p-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>[i+k]+k+1, Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1);
<a name="l03722"></a>03722         }
<a name="l03723"></a>03723         p-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a> = Pol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a> + k;
<a name="l03724"></a>03724       }
<a name="l03725"></a>03725       p-&gt;<a class="code" href="structpolyhedron.html#ac1fb864c352ef93ef3030c35e98c2aed">flags</a> = Pol-&gt;<a class="code" href="structpolyhedron.html#ac1fb864c352ef93ef3030c35e98c2aed">flags</a>;
<a name="l03726"></a>03726       
<a name="l03727"></a>03727       *next = p;
<a name="l03728"></a>03728       next = &amp;p-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l03729"></a>03729     }
<a name="l03730"></a>03730   } <span class="comment">/* end of TRY */</span>
<a name="l03731"></a>03731   
<a name="l03732"></a>03732   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>); 
<a name="l03733"></a>03733   <span class="keywordflow">return</span> result;
<a name="l03734"></a>03734 } <span class="comment">/* align_context */</span>
<a name="l03735"></a>03735 
<a name="l03736"></a>03736 <span class="comment">/*----------------------------------------------------------------------*/</span>
<a name="l03737"></a>03737 <span class="comment">/* Polyhedron *Polyhedron_Scan(D, C, NbMaxRays)                         */</span>
<a name="l03738"></a>03738 <span class="comment">/*       D : Domain to be scanned (single polyhedron only)              */</span>
<a name="l03739"></a>03739 <span class="comment">/*       C : Context domain                                             */</span>
<a name="l03740"></a>03740 <span class="comment">/*       NbMaxRays : Workspace size                                     */</span>
<a name="l03741"></a>03741 <span class="comment">/* Returns a linked list of scan domains, outer loop first              */</span>
<a name="l03742"></a>03742 <span class="comment">/*----------------------------------------------------------------------*/</span>
<a name="l03743"></a><a class="code" href="polyhedron_8h.html#a9ff332ec08a9a3ccf95c6b1e2a784a68">03743</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a7e6c09758e3d3063be1386c7026b38ba">Polyhedron_Scan</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *D, <a class="code" href="structpolyhedron.html">Polyhedron</a> *C,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l03744"></a>03744   
<a name="l03745"></a>03745   <span class="keywordtype">int</span> i, j, dim ;
<a name="l03746"></a>03746   <a class="code" href="structmatrix.html">Matrix</a> *Mat;
<a name="l03747"></a>03747   <a class="code" href="structpolyhedron.html">Polyhedron</a> *C1, *C2, *D1, *D2;
<a name="l03748"></a>03748   <a class="code" href="structpolyhedron.html">Polyhedron</a> *res, *last, *tmp;
<a name="l03749"></a>03749   
<a name="l03750"></a>03750   dim = D-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> - C-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>;
<a name="l03751"></a>03751   res = last = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *) 0;
<a name="l03752"></a>03752   <span class="keywordflow">if</span> (dim==0) <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l03753"></a>03753 
<a name="l03754"></a>03754   <a class="code" href="assert_8h.html#a07d17d6d5d1074c0969bc5d3c3d1d84a">assert</a>(!D-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>);
<a name="l03755"></a>03755 
<a name="l03756"></a>03756   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(D);
<a name="l03757"></a>03757   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(D);
<a name="l03758"></a>03758   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(C);
<a name="l03759"></a>03759   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(C);
<a name="l03760"></a>03760 
<a name="l03761"></a>03761   <span class="comment">/* Allocate space for constraint matrix. */</span>
<a name="l03762"></a>03762   Mat   = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(D-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>, D-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2);
<a name="l03763"></a>03763   <span class="keywordflow">if</span>(!Mat) {
<a name="l03764"></a>03764     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Scan&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space&quot;</span>);
<a name="l03765"></a>03765     <span class="keywordflow">return</span> 0;
<a name="l03766"></a>03766   }
<a name="l03767"></a>03767   C1  = <a class="code" href="polyhedron_8c.html#affd77db2a2f748d557ab6be0fcede209">align_context</a>(C,D-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>,NbMaxRays);
<a name="l03768"></a>03768   <span class="keywordflow">if</span>(!C1) {
<a name="l03769"></a>03769     <span class="keywordflow">return</span> 0;
<a name="l03770"></a>03770   }
<a name="l03771"></a>03771   <span class="comment">/* Vin100, aug 16, 2001:  The context is intersected with D */</span>
<a name="l03772"></a>03772   D2 = <a class="code" href="polyhedron_8c.html#ac5a1a2751f0b833183560af25b18033b">DomainIntersection</a>( C1, D, NbMaxRays);
<a name="l03773"></a>03773 
<a name="l03774"></a>03774   <span class="keywordflow">for</span> (i=0; i&lt;dim; i++)
<a name="l03775"></a>03775   {
<a name="l03776"></a>03776     <a class="code" href="vector_8c.html#a27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>(Mat-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>,0,D2-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>*(D2-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> + 2));
<a name="l03777"></a>03777     <span class="keywordflow">for</span> (j=i+1; j&lt;dim; j++) {
<a name="l03778"></a>03778       <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Mat-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j-i-1][j+1],1);
<a name="l03779"></a>03779     }
<a name="l03780"></a>03780     Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> = dim-i-1;
<a name="l03781"></a>03781     D1 = Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a> ? <a class="code" href="polyhedron_8c.html#a5ac0337f8a955ee77d5414761f3d41bb">DomainAddRays</a>(D2, Mat, NbMaxRays) : D2;
<a name="l03782"></a>03782     tmp = <a class="code" href="polyhedron_8c.html#a5fe8c61eb1dddc73783aad88c76ce758">DomainSimplify</a>(D1, C1, NbMaxRays);
<a name="l03783"></a>03783     <span class="keywordflow">if</span> (!last) res = last = tmp;
<a name="l03784"></a>03784     <span class="keywordflow">else</span> { last-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = tmp; last = tmp; }
<a name="l03785"></a>03785     C2 = <a class="code" href="polyhedron_8c.html#ac5a1a2751f0b833183560af25b18033b">DomainIntersection</a>(C1, D1, NbMaxRays);
<a name="l03786"></a>03786     <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>(C1);
<a name="l03787"></a>03787     C1 = C2;
<a name="l03788"></a>03788     <span class="keywordflow">if</span> (Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>) <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>(D1);
<a name="l03789"></a>03789   }
<a name="l03790"></a>03790   <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>(D2);
<a name="l03791"></a>03791   <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>(C1);
<a name="l03792"></a>03792   <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Mat);
<a name="l03793"></a>03793   <span class="keywordflow">return</span> res;
<a name="l03794"></a>03794 } <span class="comment">/* Polyhedron_Scan */</span>
<a name="l03795"></a>03795 
<a name="l03796"></a>03796 <span class="comment">/*---------------------------------------------------------------------*/</span>
<a name="l03797"></a>03797 <span class="comment">/* int lower_upper_bounds(pos,P,context,LBp,UBp)                       */</span>
<a name="l03798"></a>03798 <span class="comment">/*    pos : index position of current loop index (1..hdim-1)           */</span>
<a name="l03799"></a>03799 <span class="comment">/*    P: loop domain                                                   */</span>
<a name="l03800"></a>03800 <span class="comment">/*    context : context values for fixed indices                       */</span>
<a name="l03801"></a>03801 <span class="comment">/*              notice that context[hdim] must be 1                    */</span>
<a name="l03802"></a>03802 <span class="comment">/*    LBp, UBp : pointers to resulting bounds                          */</span>
<a name="l03803"></a>03803 <span class="comment">/* returns the flag = (UB_INFINITY, LB_INFINITY)                       */</span>
<a name="l03804"></a>03804 <span class="comment">/*---------------------------------------------------------------------*/</span>
<a name="l03805"></a><a class="code" href="polyhedron_8h.html#aa8c3f429dd74c5ec2087f97d702cdc66">03805</a> <span class="keywordtype">int</span> <a class="code" href="polyhedron_8c.html#aa8c3f429dd74c5ec2087f97d702cdc66">lower_upper_bounds</a>(<span class="keywordtype">int</span> pos,<a class="code" href="structpolyhedron.html">Polyhedron</a> *P,Value *context,Value *LBp,Value *UBp) {
<a name="l03806"></a>03806   
<a name="l03807"></a>03807   Value LB, UB;
<a name="l03808"></a>03808   <span class="keywordtype">int</span> flag, i;
<a name="l03809"></a>03809   Value <a class="code" href="polyparam_8c.html#a76f11d9a0a47b94f72c2d0e77fb32240">n</a>, n1, d, tmp;
<a name="l03810"></a>03810   
<a name="l03811"></a>03811   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(P);
<a name="l03812"></a>03812   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(P);
<a name="l03813"></a>03813 
<a name="l03814"></a>03814   <span class="comment">/* Initialize all the &apos;Value&apos; variables */</span>
<a name="l03815"></a>03815   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(LB); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(UB); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmp);
<a name="l03816"></a>03816   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(n); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(n1); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(d);
<a name="l03817"></a>03817   
<a name="l03818"></a>03818   <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(LB,0);
<a name="l03819"></a>03819   <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(UB,0);
<a name="l03820"></a>03820   
<a name="l03821"></a>03821   <span class="comment">/* Compute Upper Bound and Lower Bound for current loop */</span>
<a name="l03822"></a>03822   flag = <a class="code" href="types_8h.html#ab3e4132829e88232125e7bf259520a18">LB_INFINITY</a> | <a class="code" href="types_8h.html#a629bf0301263815e35636f493380b9dd">UB_INFINITY</a>;
<a name="l03823"></a>03823   <span class="keywordflow">for</span> (i=0; i&lt;P-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>; i++) {
<a name="l03824"></a>03824     <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(d,P-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][pos]);
<a name="l03825"></a>03825     <a class="code" href="vector_8c.html#a29ab9dcdb0a2666d54c5698d5e3a802f">Inner_Product</a>(&amp;context[1],&amp;(P-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][1]),P-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1,&amp;n);
<a name="l03826"></a>03826     <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(d)) {
<a name="l03827"></a>03827       <span class="comment">/* If context doesn&apos;t satisfy constraints, return empty loop. */</span>
<a name="l03828"></a>03828       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#af031da52c8a160fd1ee6e4c793f8c78a">value_neg_p</a>(n) ||
<a name="l03829"></a>03829           (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(P-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][0]) &amp;&amp; <a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(n)))
<a name="l03830"></a>03830         <span class="keywordflow">goto</span> empty_loop;
<a name="l03831"></a>03831       <span class="keywordflow">continue</span>;
<a name="l03832"></a>03832     }
<a name="l03833"></a>03833     <a class="code" href="source_2arith_2arithmetique_8h.html#a0daf9a8ecdc14e7a274832b0d2add830">value_oppose</a>(n,n);
<a name="l03834"></a>03834     
<a name="l03835"></a>03835     <span class="comment">/*---------------------------------------------------*/</span>
<a name="l03836"></a>03836     <span class="comment">/* Compute n/d        n/d&lt;0              n/d&gt;0       */</span>
<a name="l03837"></a>03837     <span class="comment">/*---------------------------------------------------*/</span>
<a name="l03838"></a>03838     <span class="comment">/*  n%d == 0    floor   = n/d      floor   = n/d     */</span>
<a name="l03839"></a>03839     <span class="comment">/*              ceiling = n/d      ceiling = n/d     */</span>
<a name="l03840"></a>03840     <span class="comment">/*---------------------------------------------------*/</span>
<a name="l03841"></a>03841     <span class="comment">/*  n%d != 0    floor   = n/d - 1  floor   = n/d     */</span>
<a name="l03842"></a>03842     <span class="comment">/*              ceiling = n/d      ceiling = n/d + 1 */</span>
<a name="l03843"></a>03843     <span class="comment">/*---------------------------------------------------*/</span>
<a name="l03844"></a>03844 
<a name="l03845"></a>03845     <span class="comment">/* Check to see if constraint is inequality */</span>
<a name="l03846"></a>03846     <span class="comment">/* if constraint is equality, both upper and lower bounds are fixed */</span>
<a name="l03847"></a>03847     <span class="keywordflow">if</span>(<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(P-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][0])) {     <span class="comment">/* Equality */</span>
<a name="l03848"></a>03848       <a class="code" href="source_2arith_2arithmetique_8h.html#ae77f928488d756f77270649775dbdc1d">value_modulus</a>(tmp,n,d);
<a name="l03849"></a>03849       
<a name="l03850"></a>03850       <span class="comment">/* if not integer, return 0; */</span>
<a name="l03851"></a>03851       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(tmp))
<a name="l03852"></a>03852         <span class="keywordflow">goto</span> empty_loop;
<a name="l03853"></a>03853 
<a name="l03854"></a>03854       <a class="code" href="source_2arith_2arithmetique_8h.html#ac633e4bcd9ed1d8412c67cda6d8ddb11">value_division</a>(n1,n,d);
<a name="l03855"></a>03855       
<a name="l03856"></a>03856       <span class="comment">/* Upper and Lower bounds found */</span>
<a name="l03857"></a>03857       <span class="keywordflow">if</span>((flag&amp;<a class="code" href="types_8h.html#ab3e4132829e88232125e7bf259520a18">LB_INFINITY</a>) || <a class="code" href="source_2arith_2arithmetique_8h.html#a15b0362ff15576108c69c31e5ed0cfeb">value_gt</a>(n1,LB))
<a name="l03858"></a>03858         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(LB,n1);
<a name="l03859"></a>03859       <span class="keywordflow">if</span>((flag&amp;<a class="code" href="types_8h.html#a629bf0301263815e35636f493380b9dd">UB_INFINITY</a>) || <a class="code" href="source_2arith_2arithmetique_8h.html#ad87a1fcce82a9885ffd8518f4fba2c0e">value_lt</a>(n1,UB))
<a name="l03860"></a>03860         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(UB,n1);
<a name="l03861"></a>03861       flag = 0;
<a name="l03862"></a>03862     }
<a name="l03863"></a>03863     
<a name="l03864"></a>03864     <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a01904c8c75c10d407a24c55f16ec27c7">value_pos_p</a>(d)) {  <span class="comment">/* Lower Bound */</span>
<a name="l03865"></a>03865       <a class="code" href="source_2arith_2arithmetique_8h.html#ae77f928488d756f77270649775dbdc1d">value_modulus</a>(tmp,n,d);
<a name="l03866"></a>03866       
<a name="l03867"></a>03867       <span class="comment">/* n1 = ceiling(n/d) */</span>
<a name="l03868"></a>03868       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a01904c8c75c10d407a24c55f16ec27c7">value_pos_p</a>(n) &amp;&amp; <a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(tmp)) {
<a name="l03869"></a>03869         <a class="code" href="source_2arith_2arithmetique_8h.html#ac633e4bcd9ed1d8412c67cda6d8ddb11">value_division</a>(n1,n,d);
<a name="l03870"></a>03870         <a class="code" href="source_2arith_2arithmetique_8h.html#a73e7093353d4108ea8f63898e868ed5f">value_add_int</a>(n1,n1,1);
<a name="l03871"></a>03871       }
<a name="l03872"></a>03872       <span class="keywordflow">else</span>
<a name="l03873"></a>03873         <a class="code" href="source_2arith_2arithmetique_8h.html#ac633e4bcd9ed1d8412c67cda6d8ddb11">value_division</a>(n1,n,d);
<a name="l03874"></a>03874       <span class="keywordflow">if</span> (flag&amp;<a class="code" href="types_8h.html#ab3e4132829e88232125e7bf259520a18">LB_INFINITY</a>) {
<a name="l03875"></a>03875         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(LB,n1); 
<a name="l03876"></a>03876         flag^=LB_INFINITY; 
<a name="l03877"></a>03877       }
<a name="l03878"></a>03878       <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="source_2arith_2arithmetique_8h.html#a15b0362ff15576108c69c31e5ed0cfeb">value_gt</a>(n1,LB))
<a name="l03879"></a>03879         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(LB,n1);
<a name="l03880"></a>03880     }
<a name="l03881"></a>03881     
<a name="l03882"></a>03882     <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#af031da52c8a160fd1ee6e4c793f8c78a">value_neg_p</a>(d)) {   <span class="comment">/* Upper Bound */</span>
<a name="l03883"></a>03883       <a class="code" href="source_2arith_2arithmetique_8h.html#ae77f928488d756f77270649775dbdc1d">value_modulus</a>(tmp,n,d);
<a name="l03884"></a>03884       
<a name="l03885"></a>03885       <span class="comment">/* n1 = floor(n/d) */</span>
<a name="l03886"></a>03886       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a01904c8c75c10d407a24c55f16ec27c7">value_pos_p</a>(n) &amp;&amp; <a class="code" href="source_2arith_2arithmetique_8h.html#a47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(tmp)) {
<a name="l03887"></a>03887         <a class="code" href="source_2arith_2arithmetique_8h.html#ac633e4bcd9ed1d8412c67cda6d8ddb11">value_division</a>(n1,n,d);
<a name="l03888"></a>03888         <a class="code" href="source_2arith_2arithmetique_8h.html#a11f18b25f757ecabd62ef14833909101">value_sub_int</a>(n1,n1,1);
<a name="l03889"></a>03889       }
<a name="l03890"></a>03890       <span class="keywordflow">else</span>
<a name="l03891"></a>03891         <a class="code" href="source_2arith_2arithmetique_8h.html#ac633e4bcd9ed1d8412c67cda6d8ddb11">value_division</a>(n1,n,d);
<a name="l03892"></a>03892       
<a name="l03893"></a>03893       <span class="keywordflow">if</span> (flag&amp;<a class="code" href="types_8h.html#a629bf0301263815e35636f493380b9dd">UB_INFINITY</a>) {
<a name="l03894"></a>03894         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(UB,n1); 
<a name="l03895"></a>03895         flag^=UB_INFINITY; 
<a name="l03896"></a>03896       }
<a name="l03897"></a>03897       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#ad87a1fcce82a9885ffd8518f4fba2c0e">value_lt</a>(n1,UB))
<a name="l03898"></a>03898         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(UB, n1);
<a name="l03899"></a>03899     }
<a name="l03900"></a>03900   }
<a name="l03901"></a>03901   <span class="keywordflow">if</span> ((flag &amp; <a class="code" href="types_8h.html#ab3e4132829e88232125e7bf259520a18">LB_INFINITY</a>)==0) <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(*LBp,LB);
<a name="l03902"></a>03902   <span class="keywordflow">if</span> ((flag &amp; <a class="code" href="types_8h.html#a629bf0301263815e35636f493380b9dd">UB_INFINITY</a>)==0) <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(*UBp,UB);
<a name="l03903"></a>03903 
<a name="l03904"></a>03904   <span class="keywordflow">if</span> (0) {
<a name="l03905"></a>03905 empty_loop:
<a name="l03906"></a>03906     flag = 0;
<a name="l03907"></a>03907     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(*LBp, 1);
<a name="l03908"></a>03908     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(*UBp, 0);      <span class="comment">/* empty loop */</span>
<a name="l03909"></a>03909   }
<a name="l03910"></a>03910   
<a name="l03911"></a>03911   <span class="comment">/* Clear all the &apos;Value&apos; variables */</span>
<a name="l03912"></a>03912   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(LB); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(UB); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l03913"></a>03913   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(n); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(n1); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(d);
<a name="l03914"></a>03914   <span class="keywordflow">return</span> flag;
<a name="l03915"></a>03915 } <span class="comment">/* lower_upper_bounds */</span>
<a name="l03916"></a>03916 
<a name="l03917"></a>03917 <span class="comment">/*</span>
<a name="l03918"></a>03918 <span class="comment"> *  C = A x B</span>
<a name="l03919"></a>03919 <span class="comment"> */</span>
<a name="l03920"></a><a class="code" href="polyhedron_8c.html#a322c84e876179e263891de1c3d705230">03920</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#a322c84e876179e263891de1c3d705230">Rays_Mult</a>(Value **A, <a class="code" href="structmatrix.html">Matrix</a> *B, Value **C, <span class="keywordtype">unsigned</span> NbRays)
<a name="l03921"></a>03921 {
<a name="l03922"></a>03922   <span class="keywordtype">int</span> i, j, k;
<a name="l03923"></a>03923   <span class="keywordtype">unsigned</span> Dimension1, Dimension2;
<a name="l03924"></a>03924   Value Sum, tmp;
<a name="l03925"></a>03925 
<a name="l03926"></a>03926   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(Sum); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmp);
<a name="l03927"></a>03927 
<a name="l03928"></a>03928   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l03929"></a>03929     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(Sum); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l03930"></a>03930     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l03931"></a>03931   }
<a name="l03932"></a>03932   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l03933"></a>03933     Dimension1 = B-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l03934"></a>03934     Dimension2 = B-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>;
<a name="l03935"></a>03935 
<a name="l03936"></a>03936     <span class="keywordflow">for</span> (i=0; i&lt;NbRays; i++) {
<a name="l03937"></a>03937       <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(C[i][0],A[i][0]);
<a name="l03938"></a>03938       <span class="keywordflow">for</span> (j=0; j&lt;Dimension2; j++) {
<a name="l03939"></a>03939         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Sum,0);
<a name="l03940"></a>03940         <span class="keywordflow">for</span> (k=0; k&lt;Dimension1; k++) {
<a name="l03941"></a>03941           
<a name="l03942"></a>03942           <span class="comment">/* Sum+=A[i][k+1] * B-&gt;p[k][j]; */</span>
<a name="l03943"></a>03943           <a class="code" href="source_2arith_2arithmetique_8h.html#a9900fbd029b36f5887e587642a064a52">value_addmul</a>(Sum, A[i][k+1], B-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][j]);
<a name="l03944"></a>03944         }
<a name="l03945"></a>03945         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(C[i][j+1],Sum);
<a name="l03946"></a>03946       }
<a name="l03947"></a>03947       <a class="code" href="vector_8c.html#a801486b45cadc8b9d22d99a79af91fa1">Vector_Gcd</a>(C[i]+1, Dimension2, &amp;tmp);
<a name="l03948"></a>03948       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a5f258141f9e07b66da01ff7f4fe3d56d">value_notone_p</a>(tmp))
<a name="l03949"></a>03949           <a class="code" href="vector_8c.html#a95d6452a07b82054af71a14c686e66a8">Vector_AntiScale</a>(C[i]+1, C[i]+1, tmp, Dimension2);
<a name="l03950"></a>03950     }
<a name="l03951"></a>03951   }
<a name="l03952"></a>03952   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03953"></a>03953   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(Sum); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l03954"></a>03954 }
<a name="l03955"></a>03955 
<a name="l03956"></a>03956 <span class="comment">/*</span>
<a name="l03957"></a>03957 <span class="comment"> *  C = A x B^T</span>
<a name="l03958"></a>03958 <span class="comment"> */</span>
<a name="l03959"></a><a class="code" href="polyhedron_8c.html#adf74947c39b4b8eb27cfc81b85abd0ff">03959</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#adf74947c39b4b8eb27cfc81b85abd0ff">Rays_Mult_Transpose</a>(Value **A, <a class="code" href="structmatrix.html">Matrix</a> *B, Value **C, 
<a name="l03960"></a>03960                                 <span class="keywordtype">unsigned</span> NbRays)
<a name="l03961"></a>03961 {
<a name="l03962"></a>03962   <span class="keywordtype">int</span> i, j, k;
<a name="l03963"></a>03963   <span class="keywordtype">unsigned</span> Dimension1, Dimension2;
<a name="l03964"></a>03964   Value Sum, tmp;
<a name="l03965"></a>03965 
<a name="l03966"></a>03966   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(Sum); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmp);
<a name="l03967"></a>03967 
<a name="l03968"></a>03968   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l03969"></a>03969     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(Sum); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l03970"></a>03970     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l03971"></a>03971   }
<a name="l03972"></a>03972   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l03973"></a>03973     Dimension1 = B-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>;
<a name="l03974"></a>03974     Dimension2 = B-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l03975"></a>03975 
<a name="l03976"></a>03976     <span class="keywordflow">for</span> (i=0; i&lt;NbRays; i++) {
<a name="l03977"></a>03977       <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(C[i][0],A[i][0]);
<a name="l03978"></a>03978       <span class="keywordflow">for</span> (j=0; j&lt;Dimension2; j++) {
<a name="l03979"></a>03979         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Sum,0);
<a name="l03980"></a>03980         <span class="keywordflow">for</span> (k=0; k&lt;Dimension1; k++) {
<a name="l03981"></a>03981           
<a name="l03982"></a>03982           <span class="comment">/* Sum+=A[i][k+1] * B-&gt;p[j][k]; */</span>
<a name="l03983"></a>03983           <a class="code" href="source_2arith_2arithmetique_8h.html#a9900fbd029b36f5887e587642a064a52">value_addmul</a>(Sum, A[i][k+1], B-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[j][k]);
<a name="l03984"></a>03984         }
<a name="l03985"></a>03985         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(C[i][j+1],Sum);
<a name="l03986"></a>03986       }
<a name="l03987"></a>03987       <a class="code" href="vector_8c.html#a801486b45cadc8b9d22d99a79af91fa1">Vector_Gcd</a>(C[i]+1, Dimension2, &amp;tmp);
<a name="l03988"></a>03988       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a5f258141f9e07b66da01ff7f4fe3d56d">value_notone_p</a>(tmp))
<a name="l03989"></a>03989           <a class="code" href="vector_8c.html#a95d6452a07b82054af71a14c686e66a8">Vector_AntiScale</a>(C[i]+1, C[i]+1, tmp, Dimension2);
<a name="l03990"></a>03990     }
<a name="l03991"></a>03991   }
<a name="l03992"></a>03992   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l03993"></a>03993   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(Sum); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l03994"></a>03994 }
<a name="l03995"></a>03995 
<a name="l03996"></a>03996 <span class="comment">/*</span>
<a name="l03997"></a>03997 <span class="comment"> * Given a polyhedron &apos;Pol&apos; and a transformation matrix &apos;Func&apos;, return the </span>
<a name="l03998"></a>03998 <span class="comment"> * polyhedron which when transformed by mapping function &apos;Func&apos; gives &apos;Pol&apos;. </span>
<a name="l03999"></a>03999 <span class="comment"> * &apos;NbMaxRays&apos; is the maximum number of rays that can be in the ray matrix </span>
<a name="l04000"></a>04000 <span class="comment"> * of the resulting polyhedron.</span>
<a name="l04001"></a>04001 <span class="comment"> */</span>
<a name="l04002"></a><a class="code" href="polyhedron_8h.html#a53d52d5d1befc1d1446e0920556c3d24">04002</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a53d52d5d1befc1d1446e0920556c3d24">Polyhedron_Preimage</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<a class="code" href="structmatrix.html">Matrix</a> *Func,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l04003"></a>04003 
<a name="l04004"></a>04004   <a class="code" href="structmatrix.html">Matrix</a> *Constraints = NULL;
<a name="l04005"></a>04005   <a class="code" href="structpolyhedron.html">Polyhedron</a> *NewPol = NULL;
<a name="l04006"></a>04006   <span class="keywordtype">unsigned</span> NbConstraints, Dimension1, Dimension2;
<a name="l04007"></a>04007 
<a name="l04008"></a>04008   <a class="code" href="polyhedron_8h.html#a54a764faf683e794f4db092c8d050104">POL_ENSURE_INEQUALITIES</a>(Pol);
<a name="l04009"></a>04009 
<a name="l04010"></a>04010   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l04011"></a>04011     <span class="keywordflow">if</span> (Constraints) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Constraints);
<a name="l04012"></a>04012     <span class="keywordflow">if</span> (NewPol) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(NewPol);
<a name="l04013"></a>04013     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l04014"></a>04014   }
<a name="l04015"></a>04015   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l04016"></a>04016     
<a name="l04017"></a>04017     NbConstraints = Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l04018"></a>04018     Dimension1    = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1;   <span class="comment">/* Homogeneous Dimension */</span>
<a name="l04019"></a>04019     Dimension2    = Func-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>;    <span class="comment">/* Homogeneous Dimension */</span>
<a name="l04020"></a>04020     <span class="keywordflow">if</span> (Dimension1!=(Func-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>)) {
<a name="l04021"></a>04021       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Preimage&quot;</span>, <span class="stringliteral">&quot;dimincomp&quot;</span>, <span class="stringliteral">&quot;incompatable dimensions&quot;</span>);
<a name="l04022"></a>04022       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04023"></a>04023       <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Dimension2-1);
<a name="l04024"></a>04024     }
<a name="l04025"></a>04025     
<a name="l04026"></a>04026     <span class="comment">/*            Dim1           Dim2            Dim2</span>
<a name="l04027"></a>04027 <span class="comment">                  __k__          __j__           __j__  </span>
<a name="l04028"></a>04028 <span class="comment">            NbCon |   |  X   Dim1|   |  =  NbCon |   |</span>
<a name="l04029"></a>04029 <span class="comment">              i   |___|       k  |___|       i   |___|</span>
<a name="l04030"></a>04030 <span class="comment">            Pol-&gt;Constraints Function        Constraints</span>
<a name="l04031"></a>04031 <span class="comment">    */</span>
<a name="l04032"></a>04032   
<a name="l04033"></a>04033     <span class="comment">/* Allocate space for the resulting constraint matrix */</span>
<a name="l04034"></a>04034     Constraints = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbConstraints, Dimension2+1);
<a name="l04035"></a>04035     <span class="keywordflow">if</span> (!Constraints) { 
<a name="l04036"></a>04036       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Preimage&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space\n&quot;</span>);
<a name="l04037"></a>04037       <a class="code" href="errormsg_8c.html#aa587bf4e8c763fa5e95542df7eb070b7">Pol_status</a> = 1;
<a name="l04038"></a>04038       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04039"></a>04039       <span class="keywordflow">return</span> 0;
<a name="l04040"></a>04040     }
<a name="l04041"></a>04041     
<a name="l04042"></a>04042     <span class="comment">/* The new constraint matrix is the product of constraint matrix of the */</span>
<a name="l04043"></a>04043     <span class="comment">/* polyhedron and the function matrix.                                  */</span>
<a name="l04044"></a>04044     <a class="code" href="polyhedron_8c.html#a322c84e876179e263891de1c3d705230">Rays_Mult</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>, Func, Constraints-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>, NbConstraints);
<a name="l04045"></a>04045     NewPol = <a class="code" href="polyhedron_8c.html#aefb77665a187d751bdd44f106b12465e" title="Given a matrix of constraints (&amp;#39;Constraints&amp;#39;), construct and return a polyhedron...">Constraints2Polyhedron</a>(Constraints, NbMaxRays);
<a name="l04046"></a>04046     <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Constraints), Constraints = NULL;
<a name="l04047"></a>04047     
<a name="l04048"></a>04048   } <span class="comment">/* end of TRY */</span>
<a name="l04049"></a>04049   
<a name="l04050"></a>04050   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04051"></a>04051   
<a name="l04052"></a>04052   <span class="keywordflow">return</span> NewPol;
<a name="l04053"></a>04053 } <span class="comment">/* Polyhedron_Preimage */</span>
<a name="l04054"></a>04054 
<a name="l04055"></a>04055 <span class="comment">/*</span>
<a name="l04056"></a>04056 <span class="comment"> * Given a polyhedral domain &apos;Pol&apos; and a transformation matrix &apos;Func&apos;, return </span>
<a name="l04057"></a>04057 <span class="comment"> * the polyhedral domain which when transformed by mapping function &apos;Func&apos; </span>
<a name="l04058"></a>04058 <span class="comment"> * gives &apos;Pol&apos;. &apos;NbMaxRays&apos; is the maximum number of rays that can be in the </span>
<a name="l04059"></a>04059 <span class="comment"> * ray matrix of the resulting domain.</span>
<a name="l04060"></a>04060 <span class="comment"> */</span>
<a name="l04061"></a><a class="code" href="polyhedron_8h.html#a494ede0f23752164d1c839085a0e3be2">04061</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a494ede0f23752164d1c839085a0e3be2">DomainPreimage</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<a class="code" href="structmatrix.html">Matrix</a> *Func,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l04062"></a>04062   
<a name="l04063"></a>04063   <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a>, *q, *d = NULL;
<a name="l04064"></a>04064   
<a name="l04065"></a>04065   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l04066"></a>04066     <span class="keywordflow">if</span> (d) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(d);
<a name="l04067"></a>04067     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l04068"></a>04068   }
<a name="l04069"></a>04069   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l04070"></a>04070     <span class="keywordflow">if</span> (!Pol || !Func) {
<a name="l04071"></a>04071       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04072"></a>04072       <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a> *) 0;
<a name="l04073"></a>04073     }
<a name="l04074"></a>04074     d = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *) 0;
<a name="l04075"></a>04075     <span class="keywordflow">for</span> (p=Pol; p; p=p-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l04076"></a>04076       q = <a class="code" href="polyhedron_8c.html#a53d52d5d1befc1d1446e0920556c3d24">Polyhedron_Preimage</a>(p, Func, NbMaxRays);
<a name="l04077"></a>04077       d = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a> (q, d);
<a name="l04078"></a>04078     } 
<a name="l04079"></a>04079   } <span class="comment">/* end of TRY */</span>
<a name="l04080"></a>04080   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04081"></a>04081   <span class="keywordflow">return</span> d;
<a name="l04082"></a>04082 } <span class="comment">/* DomainPreimage */</span>
<a name="l04083"></a>04083 
<a name="l04084"></a>04084 <span class="comment">/*</span>
<a name="l04085"></a>04085 <span class="comment"> * Transform a polyhedron &apos;Pol&apos; into another polyhedron according to a given</span>
<a name="l04086"></a>04086 <span class="comment"> * affine mapping function &apos;Func&apos;. &apos;NbMaxConstrs&apos; is the maximum number of </span>
<a name="l04087"></a>04087 <span class="comment"> * constraints that can be in the constraint matrix of the new polyhedron. </span>
<a name="l04088"></a>04088 <span class="comment"> */</span>
<a name="l04089"></a><a class="code" href="polyhedron_8h.html#a0b1d25597364fcc0847e8de25d9454c4">04089</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a0b1d25597364fcc0847e8de25d9454c4">Polyhedron_Image</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol, <a class="code" href="structmatrix.html">Matrix</a> *Func,<span class="keywordtype">unsigned</span> NbMaxConstrs) {
<a name="l04090"></a>04090   
<a name="l04091"></a>04091   <a class="code" href="structmatrix.html">Matrix</a> *Rays = NULL;
<a name="l04092"></a>04092   <a class="code" href="structpolyhedron.html">Polyhedron</a> *NewPol = NULL;
<a name="l04093"></a>04093   <span class="keywordtype">unsigned</span> NbRays, Dimension1, Dimension2;
<a name="l04094"></a>04094   
<a name="l04095"></a>04095   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(Pol);
<a name="l04096"></a>04096   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol);
<a name="l04097"></a>04097 
<a name="l04098"></a>04098   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l04099"></a>04099     <span class="keywordflow">if</span> (Rays) <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Rays);
<a name="l04100"></a>04100     <span class="keywordflow">if</span> (NewPol) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(NewPol);
<a name="l04101"></a>04101     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l04102"></a>04102   }
<a name="l04103"></a>04103   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l04104"></a>04104   
<a name="l04105"></a>04105     NbRays     = Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>;
<a name="l04106"></a>04106     Dimension1 = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1;      <span class="comment">/* Homogeneous Dimension */</span>
<a name="l04107"></a>04107     Dimension2 = Func-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>;          <span class="comment">/* Homogeneous Dimension */</span>
<a name="l04108"></a>04108     <span class="keywordflow">if</span> (Dimension1!=Func-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>) {
<a name="l04109"></a>04109       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Image&quot;</span>, <span class="stringliteral">&quot;dimincomp&quot;</span>, <span class="stringliteral">&quot;incompatible dimensions&quot;</span>);
<a name="l04110"></a>04110       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04111"></a>04111       <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(Dimension2-1);
<a name="l04112"></a>04112     }
<a name="l04113"></a>04113     
<a name="l04114"></a>04114     <span class="comment">/*   </span>
<a name="l04115"></a>04115 <span class="comment">        Dim1     /      Dim1  \Transpose      Dim2</span>
<a name="l04116"></a>04116 <span class="comment">        __k__    |      __k__ |              __j__</span>
<a name="l04117"></a>04117 <span class="comment">  NbRays|   |  X | Dim2 |   | |     =  NbRays|   |</span>
<a name="l04118"></a>04118 <span class="comment">    i   |___|    |   j  |___| |          i   |___|</span>
<a name="l04119"></a>04119 <span class="comment">     Pol-&gt;Rays  \       Func /               Rays</span>
<a name="l04120"></a>04120 <span class="comment"></span>
<a name="l04121"></a>04121 <span class="comment">    */</span>
<a name="l04122"></a>04122 
<a name="l04123"></a>04123     <span class="keywordflow">if</span> (Dimension1 == Dimension2) {
<a name="l04124"></a>04124         <a class="code" href="structmatrix.html">Matrix</a> *M, *M2;
<a name="l04125"></a>04125         <span class="keywordtype">int</span> ok;
<a name="l04126"></a>04126         M = <a class="code" href="Matop_8c.html#a9d027e9fc6b85e6fa37fc284bf1b5e06">Matrix_Copy</a>(Func);
<a name="l04127"></a>04127         M2 = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(Dimension2, Dimension1);
<a name="l04128"></a>04128         <span class="keywordflow">if</span> (!M2) {
<a name="l04129"></a>04129           <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Image&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space\n&quot;</span>);
<a name="l04130"></a>04130           <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04131"></a>04131           <span class="keywordflow">return</span> 0;
<a name="l04132"></a>04132         }
<a name="l04133"></a>04133 
<a name="l04134"></a>04134         ok = <a class="code" href="matrix_8c.html#a97aa755c011357ce2146d71ddb88ded6">Matrix_Inverse</a>(M, M2);
<a name="l04135"></a>04135         <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(M);
<a name="l04136"></a>04136         <span class="keywordflow">if</span> (ok) {
<a name="l04137"></a>04137             NewPol = <a class="code" href="polyhedron_8c.html#aa308ade6448cc5544e21d59e86a53ddf">Polyhedron_Alloc</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>, Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>,
<a name="l04138"></a>04138                                       Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>);
<a name="l04139"></a>04139             <span class="keywordflow">if</span> (!NewPol) {
<a name="l04140"></a>04140               <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Image&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, 
<a name="l04141"></a>04141                         <span class="stringliteral">&quot;out of memory space\n&quot;</span>);
<a name="l04142"></a>04142               <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04143"></a>04143               <span class="keywordflow">return</span> 0;
<a name="l04144"></a>04144             }
<a name="l04145"></a>04145             <a class="code" href="polyhedron_8c.html#adf74947c39b4b8eb27cfc81b85abd0ff">Rays_Mult_Transpose</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>, Func, NewPol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>, NbRays);
<a name="l04146"></a>04146             <a class="code" href="polyhedron_8c.html#a322c84e876179e263891de1c3d705230">Rays_Mult</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>, M2, NewPol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>, 
<a name="l04147"></a>04147                       Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>);
<a name="l04148"></a>04148             NewPol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a> = Pol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>;
<a name="l04149"></a>04149             NewPol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a> = Pol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a>;
<a name="l04150"></a>04150             <span class="keywordflow">if</span> (NewPol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>)
<a name="l04151"></a>04151               <a class="code" href="polyhedron_8c.html#a20c6f331a707d14f3bfb3f6920b3221e">Gauss4</a>(NewPol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>, NewPol-&gt;<a class="code" href="structpolyhedron.html#af316f6440017b2e02fa3a387b2818cc9">NbEq</a>, NewPol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>,
<a name="l04152"></a>04152                      NewPol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1);
<a name="l04153"></a>04153             <span class="keywordflow">if</span> (NewPol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a>)
<a name="l04154"></a>04154               <a class="code" href="polyhedron_8c.html#a20c6f331a707d14f3bfb3f6920b3221e">Gauss4</a>(NewPol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>, NewPol-&gt;<a class="code" href="structpolyhedron.html#a9e7c80deeddf472a57bd54217f75c717">NbBid</a>, NewPol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>,
<a name="l04155"></a>04155                      NewPol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1);
<a name="l04156"></a>04156         }
<a name="l04157"></a>04157         <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(M2);
<a name="l04158"></a>04158     }
<a name="l04159"></a>04159     
<a name="l04160"></a>04160     <span class="keywordflow">if</span> (!NewPol) {
<a name="l04161"></a>04161         <span class="comment">/* Allocate space for the resulting ray matrix */</span>
<a name="l04162"></a>04162         Rays = <a class="code" href="matrix_8c.html#ac0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(NbRays, Dimension2+1);
<a name="l04163"></a>04163         <span class="keywordflow">if</span> (!Rays) {
<a name="l04164"></a>04164           <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Polyhedron_Image&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space\n&quot;</span>);
<a name="l04165"></a>04165           <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04166"></a>04166           <span class="keywordflow">return</span> 0;
<a name="l04167"></a>04167         }
<a name="l04168"></a>04168         
<a name="l04169"></a>04169         <span class="comment">/* The new ray space is the product of ray matrix of the polyhedron and */</span>
<a name="l04170"></a>04170         <span class="comment">/* the transpose matrix of the mapping function.                        */</span>
<a name="l04171"></a>04171         <a class="code" href="polyhedron_8c.html#adf74947c39b4b8eb27cfc81b85abd0ff">Rays_Mult_Transpose</a>(Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>, Func, Rays-&gt;<a class="code" href="structmatrix.html#a2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>, NbRays);
<a name="l04172"></a>04172         NewPol = <a class="code" href="polyhedron_8c.html#a3d5b12b71133d329c88db195b56d9feb" title="Given a matrix of rays &amp;#39;Ray&amp;#39;, create and return a polyhedron.">Rays2Polyhedron</a>(Rays, NbMaxConstrs);
<a name="l04173"></a>04173         <a class="code" href="matrix_8c.html#afcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Rays), Rays = NULL;
<a name="l04174"></a>04174     }
<a name="l04175"></a>04175     
<a name="l04176"></a>04176   } <span class="comment">/* end of TRY */</span>
<a name="l04177"></a>04177 
<a name="l04178"></a>04178   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04179"></a>04179   <span class="keywordflow">return</span> NewPol;
<a name="l04180"></a>04180 } <span class="comment">/* Polyhedron_Image */</span>
<a name="l04181"></a>04181 
<a name="l04182"></a>04182 <span class="comment">/* </span>
<a name="l04183"></a>04183 <span class="comment"> *Transform a polyhedral domain &apos;Pol&apos; into another domain according to a given</span>
<a name="l04184"></a>04184 <span class="comment"> * affine mapping function &apos;Func&apos;. &apos;NbMaxConstrs&apos; is the maximum number of </span>
<a name="l04185"></a>04185 <span class="comment"> * constraints that can be in the constraint matrix of the resulting domain. </span>
<a name="l04186"></a>04186 <span class="comment"> */</span>
<a name="l04187"></a><a class="code" href="polyhedron_8h.html#a8b92d94a0a1cbd47b98e9f72f34c43eb">04187</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a8b92d94a0a1cbd47b98e9f72f34c43eb">DomainImage</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<a class="code" href="structmatrix.html">Matrix</a> *Func,<span class="keywordtype">unsigned</span> NbMaxConstrs) {
<a name="l04188"></a>04188 
<a name="l04189"></a>04189   <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="vector_8c.html#aa45b2e3dcf291527c5aedc420819adfc">p</a>, *q, *d = NULL;
<a name="l04190"></a>04190 
<a name="l04191"></a>04191   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l04192"></a>04192     <span class="keywordflow">if</span> (d) <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(d);
<a name="l04193"></a>04193     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l04194"></a>04194   }
<a name="l04195"></a>04195   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l04196"></a>04196     
<a name="l04197"></a>04197     <span class="keywordflow">if</span> (!Pol || !Func) {
<a name="l04198"></a>04198       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04199"></a>04199       <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a> *) 0;
<a name="l04200"></a>04200     }
<a name="l04201"></a>04201     d = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *) 0;
<a name="l04202"></a>04202     <span class="keywordflow">for</span> (p=Pol; p; p=p-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) { 
<a name="l04203"></a>04203       q = <a class="code" href="polyhedron_8c.html#a0b1d25597364fcc0847e8de25d9454c4">Polyhedron_Image</a>(p, Func, NbMaxConstrs);
<a name="l04204"></a>04204       d = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a> (q, d);
<a name="l04205"></a>04205     }
<a name="l04206"></a>04206   } <span class="comment">/* end of TRY */</span>
<a name="l04207"></a>04207   
<a name="l04208"></a>04208   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04209"></a>04209   
<a name="l04210"></a>04210   <span class="keywordflow">return</span> d;
<a name="l04211"></a>04211 } <span class="comment">/* DomainImage */</span>
<a name="l04212"></a>04212 
<a name="l04213"></a>04213 <span class="comment">/* </span>
<a name="l04214"></a>04214 <span class="comment"> * Given a polyhedron &apos;Pol&apos; and an affine cost function &apos;Cost&apos;, compute the </span>
<a name="l04215"></a>04215 <span class="comment"> * maximum and minimum value of the function over set of points representing</span>
<a name="l04216"></a>04216 <span class="comment"> * polyhedron. </span>
<a name="l04217"></a>04217 <span class="comment"> * Note: If Polyhedron &apos;Pol&apos; is empty, then there is no feasible solution. </span>
<a name="l04218"></a>04218 <span class="comment"> * Otherwise, if there is a bidirectional ray with Sum[cost(i)*ray(i)] != 0 or</span>
<a name="l04219"></a>04219 <span class="comment"> * a unidirectional ray with Sum[cost(i)*ray(i)] &gt;0, then the maximum is un-</span>
<a name="l04220"></a>04220 <span class="comment"> * bounded else the finite optimal solution occurs at one of the vertices of</span>
<a name="l04221"></a>04221 <span class="comment"> * the polyhderon. </span>
<a name="l04222"></a>04222 <span class="comment"> */</span>
<a name="l04223"></a><a class="code" href="polyhedron_8h.html#a99cc84955162014f9ca1805281bc8c04">04223</a> <a class="code" href="structinterval.html">Interval</a> *<a class="code" href="polyhedron_8c.html#a99cc84955162014f9ca1805281bc8c04">DomainCost</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,Value *Cost) {
<a name="l04224"></a>04224   
<a name="l04225"></a>04225   <span class="keywordtype">int</span> i, j, NbRay, Dim;
<a name="l04226"></a>04226   Value *p1, *p2, p3, d, status;
<a name="l04227"></a>04227   Value tmp1, tmp2, tmp3;
<a name="l04228"></a>04228   Value **Ray;
<a name="l04229"></a>04229   <a class="code" href="structinterval.html">Interval</a> *I = NULL;
<a name="l04230"></a>04230 
<a name="l04231"></a>04231   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(d); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(status);
<a name="l04232"></a>04232   <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmp1); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmp2); <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmp3);
<a name="l04233"></a>04233 
<a name="l04234"></a>04234   <a class="code" href="polyhedron_8h.html#a729f721c450a034c1219447745c6b123">POL_ENSURE_FACETS</a>(Pol);
<a name="l04235"></a>04235   <a class="code" href="polyhedron_8h.html#a317e5eb888f5c14e1229742f31169378">POL_ENSURE_VERTICES</a>(Pol);
<a name="l04236"></a>04236 
<a name="l04237"></a>04237   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a221261b286628ee622df9588446d503e">CATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>) {
<a name="l04238"></a>04238     <span class="keywordflow">if</span> (I) free(I);
<a name="l04239"></a>04239     <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ac8d720dd87a0d11d335c873336c65cee">RETHROW</a>();
<a name="l04240"></a>04240     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(d); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(status);
<a name="l04241"></a>04241     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp1); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp2); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp3);
<a name="l04242"></a>04242   }
<a name="l04243"></a>04243   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a> {
<a name="l04244"></a>04244     
<a name="l04245"></a>04245     Ray = Pol-&gt;<a class="code" href="structpolyhedron.html#a1332db86327e189effc8798ab230f36a">Ray</a>;
<a name="l04246"></a>04246     NbRay = Pol-&gt;<a class="code" href="structpolyhedron.html#a74cba037f5ac1c7182bf960d79d3f124">NbRays</a>;
<a name="l04247"></a>04247     Dim = Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1;             <span class="comment">/* Homogenous Dimension */</span>
<a name="l04248"></a>04248     I = (<a class="code" href="structinterval.html">Interval</a> *) malloc (<span class="keyword">sizeof</span>(<a class="code" href="structinterval.html">Interval</a>));
<a name="l04249"></a>04249     <span class="keywordflow">if</span> (!I) {
<a name="l04250"></a>04250       <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomainCost&quot;</span>, <span class="stringliteral">&quot;outofmem&quot;</span>, <span class="stringliteral">&quot;out of memory space\n&quot;</span>);
<a name="l04251"></a>04251       <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04252"></a>04252       <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(d); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(status);
<a name="l04253"></a>04253       <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp1); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp2); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp3);
<a name="l04254"></a>04254       <span class="keywordflow">return</span> 0;
<a name="l04255"></a>04255     }
<a name="l04256"></a>04256     
<a name="l04257"></a>04257     <span class="comment">/* The maximum and minimum values of the cost function over polyhedral  */</span>
<a name="l04258"></a>04258     <span class="comment">/* domain is stored in &apos;I&apos;. I-&gt;MaxN and I-&gt;MaxD store the numerator and */</span>
<a name="l04259"></a>04259     <span class="comment">/* denominator of the maximum value. Likewise,I-&gt;MinN and I-&gt;MinD store */</span>
<a name="l04260"></a>04260     <span class="comment">/* the numerator and denominator of the minimum value. I-&gt;MaxI and      */</span>
<a name="l04261"></a>04261     <span class="comment">/* I-&gt;MinI store the ray indices corresponding to the max and min values*/</span>
<a name="l04262"></a>04262     <span class="comment">/* of the function.                                                     */</span>
<a name="l04263"></a>04263     
<a name="l04264"></a>04264     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(I-&gt;<a class="code" href="structinterval.html#a3af72063ac42a7959562dd87586acb70">MaxN</a>,-1);
<a name="l04265"></a>04265     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(I-&gt;<a class="code" href="structinterval.html#aec5d91911af4c48d899c363c1637b6fe">MaxD</a>,0);          <span class="comment">/* Actual cost is MaxN/MaxD */</span>
<a name="l04266"></a>04266     I-&gt;<a class="code" href="structinterval.html#a0bcde6d5bb239a8786de8401adf60489">MaxI</a> = -1;
<a name="l04267"></a>04267     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(I-&gt;<a class="code" href="structinterval.html#a671bae1e764608a6f6da4449f8158098">MinN</a>,1);
<a name="l04268"></a>04268     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(I-&gt;<a class="code" href="structinterval.html#a0470f7cbd4da9aa8b77a579af53c65a3">MinD</a>,0);
<a name="l04269"></a>04269     I-&gt;<a class="code" href="structinterval.html#a4a85bcb34b14c468511a4a783673bfcb">MinI</a> = -1;
<a name="l04270"></a>04270     
<a name="l04271"></a>04271     <span class="comment">/* Compute the cost of each ray[i] */</span>
<a name="l04272"></a>04272     <span class="keywordflow">for</span> (i=0; i&lt;NbRay; i++) {
<a name="l04273"></a>04273       p1 = Ray[i];
<a name="l04274"></a>04274       <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(status, *p1);
<a name="l04275"></a>04275       p1++;
<a name="l04276"></a>04276       p2 = Cost;
<a name="l04277"></a>04277       
<a name="l04278"></a>04278       <span class="comment">/* p3 = *p1++ * *p2++; */</span>
<a name="l04279"></a>04279       <a class="code" href="source_2arith_2arithmetique_8h.html#ac9986d34264874727344f666079e2294">value_multiply</a>(p3,*p1,*p2);
<a name="l04280"></a>04280       p1++; p2++;
<a name="l04281"></a>04281       <span class="keywordflow">for</span> (j=1; j&lt;Dim; j++) {
<a name="l04282"></a>04282         <a class="code" href="source_2arith_2arithmetique_8h.html#ac9986d34264874727344f666079e2294">value_multiply</a>(tmp1,*p1,*p2);
<a name="l04283"></a>04283         
<a name="l04284"></a>04284         <span class="comment">/* p3 += *p1++ * *p2++; */</span>
<a name="l04285"></a>04285         <a class="code" href="source_2arith_2arithmetique_8h.html#aea216a0e750144f0e6eb9b0a82583739">value_addto</a>(p3,p3,tmp1);
<a name="l04286"></a>04286         p1++; p2++;
<a name="l04287"></a>04287       }
<a name="l04288"></a>04288       
<a name="l04289"></a>04289       <span class="comment">/* d = *--p1; */</span>
<a name="l04290"></a>04290       p1--;
<a name="l04291"></a>04291       <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(d,*p1); <span class="comment">/* d == 0 for lines and ray, non-zero for vertex */</span>
<a name="l04292"></a>04292       <a class="code" href="source_2arith_2arithmetique_8h.html#ac9986d34264874727344f666079e2294">value_multiply</a>(tmp1,p3,I-&gt;<a class="code" href="structinterval.html#aec5d91911af4c48d899c363c1637b6fe">MaxD</a>); 
<a name="l04293"></a>04293       <a class="code" href="source_2arith_2arithmetique_8h.html#ac9986d34264874727344f666079e2294">value_multiply</a>(tmp2,I-&gt;<a class="code" href="structinterval.html#a3af72063ac42a7959562dd87586acb70">MaxN</a>,d);
<a name="l04294"></a>04294       <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(tmp3,1);
<a name="l04295"></a>04295       
<a name="l04296"></a>04296       <span class="comment">/* Compare p3/d with MaxN/MaxD to assign new maximum cost value */</span>
<a name="l04297"></a>04297       <span class="keywordflow">if</span> (I-&gt;<a class="code" href="structinterval.html#a0bcde6d5bb239a8786de8401adf60489">MaxI</a>==-1 ||
<a name="l04298"></a>04298           <a class="code" href="source_2arith_2arithmetique_8h.html#a15b0362ff15576108c69c31e5ed0cfeb">value_gt</a>(tmp1,tmp2) ||
<a name="l04299"></a>04299           (<a class="code" href="source_2arith_2arithmetique_8h.html#aaac63aa93e7c9fa23ebcde2dc80a12b9">value_eq</a>(tmp1,tmp2) &amp;&amp;
<a name="l04300"></a>04300            <a class="code" href="source_2arith_2arithmetique_8h.html#aaac63aa93e7c9fa23ebcde2dc80a12b9">value_eq</a>(d,tmp3) &amp;&amp; <a class="code" href="source_2arith_2arithmetique_8h.html#a8092395b58522bbac9f2c8a1ee14c10c">value_ne</a>(I-&gt;<a class="code" href="structinterval.html#aec5d91911af4c48d899c363c1637b6fe">MaxD</a>,tmp3))) {
<a name="l04301"></a>04301         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(I-&gt;<a class="code" href="structinterval.html#a3af72063ac42a7959562dd87586acb70">MaxN</a>,p3);
<a name="l04302"></a>04302         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(I-&gt;<a class="code" href="structinterval.html#aec5d91911af4c48d899c363c1637b6fe">MaxD</a>,d);
<a name="l04303"></a>04303         I-&gt;<a class="code" href="structinterval.html#a0bcde6d5bb239a8786de8401adf60489">MaxI</a> = i;
<a name="l04304"></a>04304       }
<a name="l04305"></a>04305       <a class="code" href="source_2arith_2arithmetique_8h.html#ac9986d34264874727344f666079e2294">value_multiply</a>(tmp1,p3,I-&gt;<a class="code" href="structinterval.html#a0470f7cbd4da9aa8b77a579af53c65a3">MinD</a>);
<a name="l04306"></a>04306       <a class="code" href="source_2arith_2arithmetique_8h.html#ac9986d34264874727344f666079e2294">value_multiply</a>(tmp2,I-&gt;<a class="code" href="structinterval.html#a671bae1e764608a6f6da4449f8158098">MinN</a>,d);
<a name="l04307"></a>04307       <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(tmp3,1);
<a name="l04308"></a>04308       
<a name="l04309"></a>04309       <span class="comment">/* Compare p3/d with MinN/MinD to assign new minimum cost value */</span>
<a name="l04310"></a>04310       <span class="keywordflow">if</span> (I-&gt;<a class="code" href="structinterval.html#a4a85bcb34b14c468511a4a783673bfcb">MinI</a>==-1 ||
<a name="l04311"></a>04311           <a class="code" href="source_2arith_2arithmetique_8h.html#ad87a1fcce82a9885ffd8518f4fba2c0e">value_lt</a>(tmp1,tmp2) ||
<a name="l04312"></a>04312           (<a class="code" href="source_2arith_2arithmetique_8h.html#aaac63aa93e7c9fa23ebcde2dc80a12b9">value_eq</a>(tmp1,tmp2) &amp;&amp;
<a name="l04313"></a>04313            <a class="code" href="source_2arith_2arithmetique_8h.html#aaac63aa93e7c9fa23ebcde2dc80a12b9">value_eq</a>(d,tmp3) &amp;&amp; <a class="code" href="source_2arith_2arithmetique_8h.html#a8092395b58522bbac9f2c8a1ee14c10c">value_ne</a>(I-&gt;<a class="code" href="structinterval.html#a0470f7cbd4da9aa8b77a579af53c65a3">MinD</a>,tmp3))) {
<a name="l04314"></a>04314         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(I-&gt;<a class="code" href="structinterval.html#a671bae1e764608a6f6da4449f8158098">MinN</a>, p3);
<a name="l04315"></a>04315         <a class="code" href="source_2arith_2arithmetique_8h.html#a864613888dc46f15679aa4f63e468f89">value_assign</a>(I-&gt;<a class="code" href="structinterval.html#a0470f7cbd4da9aa8b77a579af53c65a3">MinD</a>, d);
<a name="l04316"></a>04316         I-&gt;<a class="code" href="structinterval.html#a4a85bcb34b14c468511a4a783673bfcb">MinI</a> = i;
<a name="l04317"></a>04317       }
<a name="l04318"></a>04318       <a class="code" href="source_2arith_2arithmetique_8h.html#ac9986d34264874727344f666079e2294">value_multiply</a>(tmp1,p3,I-&gt;<a class="code" href="structinterval.html#aec5d91911af4c48d899c363c1637b6fe">MaxD</a>);
<a name="l04319"></a>04319       <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(tmp2,0);
<a name="l04320"></a>04320       
<a name="l04321"></a>04321       <span class="comment">/* If there is a line, assign max to +infinity and min to -infinity */</span>
<a name="l04322"></a>04322       <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(status)) { <span class="comment">/* line , d is 0 */</span>
<a name="l04323"></a>04323         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#ad87a1fcce82a9885ffd8518f4fba2c0e">value_lt</a>(tmp1,tmp2)) {
<a name="l04324"></a>04324           <a class="code" href="source_2arith_2arithmetique_8h.html#a0daf9a8ecdc14e7a274832b0d2add830">value_oppose</a>(I-&gt;<a class="code" href="structinterval.html#a3af72063ac42a7959562dd87586acb70">MaxN</a>,p3);
<a name="l04325"></a>04325           <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(I-&gt;<a class="code" href="structinterval.html#aec5d91911af4c48d899c363c1637b6fe">MaxD</a>,0);
<a name="l04326"></a>04326           I-&gt;<a class="code" href="structinterval.html#a0bcde6d5bb239a8786de8401adf60489">MaxI</a> = i;
<a name="l04327"></a>04327         }
<a name="l04328"></a>04328         <a class="code" href="source_2arith_2arithmetique_8h.html#ac9986d34264874727344f666079e2294">value_multiply</a>(tmp1,p3,I-&gt;<a class="code" href="structinterval.html#a0470f7cbd4da9aa8b77a579af53c65a3">MinD</a>);
<a name="l04329"></a>04329         <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(tmp2,0);
<a name="l04330"></a>04330 
<a name="l04331"></a>04331         <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a15b0362ff15576108c69c31e5ed0cfeb">value_gt</a>(tmp1,tmp2)) {
<a name="l04332"></a>04332           <a class="code" href="source_2arith_2arithmetique_8h.html#a0daf9a8ecdc14e7a274832b0d2add830">value_oppose</a>(I-&gt;<a class="code" href="structinterval.html#a671bae1e764608a6f6da4449f8158098">MinN</a>,p3);
<a name="l04333"></a>04333           <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(I-&gt;<a class="code" href="structinterval.html#a0470f7cbd4da9aa8b77a579af53c65a3">MinD</a>,0);
<a name="l04334"></a>04334           I-&gt;<a class="code" href="structinterval.html#a4a85bcb34b14c468511a4a783673bfcb">MinI</a> = i;
<a name="l04335"></a>04335         }
<a name="l04336"></a>04336       }
<a name="l04337"></a>04337     }
<a name="l04338"></a>04338   } <span class="comment">/* end of TRY */</span>
<a name="l04339"></a>04339   
<a name="l04340"></a>04340   <a class="code" href="source_2arith_2arithmetic__errors_8h.html#a8211465bb59b0e6b8c374b440965dbb4">UNCATCH</a>(<a class="code" href="source_2arith_2arithmetique_8h.html#a3fbedc713824754a33dd94278851fe70">any_exception_error</a>);
<a name="l04341"></a>04341   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(p3); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(d); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(status);
<a name="l04342"></a>04342   <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp1); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp2); <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(tmp3);
<a name="l04343"></a>04343   <span class="keywordflow">return</span> I;
<a name="l04344"></a>04344 } <span class="comment">/* DomainCost */</span>
<a name="l04345"></a>04345 
<a name="l04346"></a>04346 <span class="comment">/* </span>
<a name="l04347"></a>04347 <span class="comment"> * Add constraints pointed by &apos;Mat&apos; to each and every polyhedron in the </span>
<a name="l04348"></a>04348 <span class="comment"> * polyhedral domain &apos;Pol&apos;. &apos;NbMaxRays&apos; is maximum allowed rays in the ray </span>
<a name="l04349"></a>04349 <span class="comment"> * matrix of a polyhedron.</span>
<a name="l04350"></a>04350 <span class="comment"> */</span>
<a name="l04351"></a><a class="code" href="polyhedron_8h.html#afa3e85ca5d8849370db166c2ea6851c6">04351</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#afa3e85ca5d8849370db166c2ea6851c6">DomainAddConstraints</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol,<a class="code" href="structmatrix.html">Matrix</a> *Mat,<span class="keywordtype">unsigned</span> NbMaxRays) {
<a name="l04352"></a>04352 
<a name="l04353"></a>04353   <a class="code" href="structpolyhedron.html">Polyhedron</a> *PolA, *PolEndA, *p1, *p2, *p3;
<a name="l04354"></a>04354   <span class="keywordtype">int</span> Redundant;
<a name="l04355"></a>04355   
<a name="l04356"></a>04356   <span class="keywordflow">if</span> (!Pol) <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l04357"></a>04357   <span class="keywordflow">if</span> (!Mat) <span class="keywordflow">return</span> Pol;
<a name="l04358"></a>04358   <span class="keywordflow">if</span> (Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a> != Mat-&gt;<a class="code" href="structmatrix.html#a68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2) {
<a name="l04359"></a>04359     <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;DomainAddConstraints&quot;</span>,
<a name="l04360"></a>04360               <span class="stringliteral">&quot;diffdim&quot;</span>, <span class="stringliteral">&quot;operation on different dimensions&quot;</span>);
<a name="l04361"></a>04361     <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l04362"></a>04362   }
<a name="l04363"></a>04363   
<a name="l04364"></a>04364   <span class="comment">/* Copy &apos;Pol&apos; to &apos;PolA&apos; */</span>
<a name="l04365"></a>04365   PolA = PolEndA = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l04366"></a>04366   <span class="keywordflow">for</span> (p1=Pol; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l04367"></a>04367     p3 = <a class="code" href="polyhedron_8c.html#a9690baafb863abbd2e8d5c4da2995416">AddConstraints</a>(Mat-&gt;<a class="code" href="structmatrix.html#a9c294a3fd4d273963e27a0c8cd819bd5">p_Init</a>, Mat-&gt;<a class="code" href="structmatrix.html#a16ad614d15c6e81c0041e877b623c72d">NbRows</a>, p1, NbMaxRays);
<a name="l04368"></a>04368     
<a name="l04369"></a>04369     <span class="comment">/* Does any component of &apos;PolA&apos; cover &apos;p3&apos; */</span>
<a name="l04370"></a>04370     Redundant = 0;
<a name="l04371"></a>04371     <span class="keywordflow">for</span> (p2=PolA; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) {
<a name="l04372"></a>04372       <span class="keywordflow">if</span> (<a class="code" href="polyhedron_8c.html#a107a96d44465428ffcd25f1ab3d67b43">PolyhedronIncludes</a>(p2, p3)) { <span class="comment">/* &apos;p2&apos; covers &apos;p3&apos; */</span>
<a name="l04373"></a>04373         Redundant = 1;
<a name="l04374"></a>04374         <span class="keywordflow">break</span>;
<a name="l04375"></a>04375       }
<a name="l04376"></a>04376     }
<a name="l04377"></a>04377     
<a name="l04378"></a>04378     <span class="comment">/* If the new polyhedron &apos;p3&apos; is not redundant, add it to the domain */</span>
<a name="l04379"></a>04379     <span class="keywordflow">if</span> (Redundant)
<a name="l04380"></a>04380       <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(p3);
<a name="l04381"></a>04381     <span class="keywordflow">else</span> { 
<a name="l04382"></a>04382       <span class="keywordflow">if</span> (!PolEndA)
<a name="l04383"></a>04383         PolEndA = PolA = p3;
<a name="l04384"></a>04384       <span class="keywordflow">else</span> {
<a name="l04385"></a>04385         PolEndA-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = p3;
<a name="l04386"></a>04386         PolEndA = PolEndA-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l04387"></a>04387       }
<a name="l04388"></a>04388     }
<a name="l04389"></a>04389   }
<a name="l04390"></a>04390   <span class="keywordflow">return</span> PolA;
<a name="l04391"></a>04391 } <span class="comment">/* DomainAddConstraints */</span>
<a name="l04392"></a>04392 
<a name="l04393"></a>04393 
<a name="l04394"></a>04394 <span class="comment">/* </span>
<a name="l04395"></a>04395 <span class="comment"> * Computes the disjoint union of a union of polyhedra.</span>
<a name="l04396"></a>04396 <span class="comment"> * If flag = 0 the result is such that there are no intersections</span>
<a name="l04397"></a>04397 <span class="comment"> *                   between the resulting polyhedra,</span>
<a name="l04398"></a>04398 <span class="comment"> * if flag = 1 it computes a joint union, the resulting polyhedra are</span>
<a name="l04399"></a>04399 <span class="comment"> *                   adjacent (they have their facets in common).</span>
<a name="l04400"></a>04400 <span class="comment"> *</span>
<a name="l04401"></a>04401 <span class="comment"> * WARNING: if all polyhedra are not of same geometrical dimension</span>
<a name="l04402"></a>04402 <span class="comment"> *          duplicates may appear.</span>
<a name="l04403"></a>04403 <span class="comment"> */</span>
<a name="l04404"></a><a class="code" href="polyhedron_8h.html#a42ffb06d7be94fa6edf3247c519f6b30">04404</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#aa2db71a574d8c1b1c3d90df140f1e5fd">Disjoint_Domain</a>( <a class="code" href="structpolyhedron.html">Polyhedron</a> *P, <span class="keywordtype">int</span> flag, <span class="keywordtype">unsigned</span> NbMaxRays )
<a name="l04405"></a>04405 {
<a name="l04406"></a>04406         <a class="code" href="structpolyhedron.html">Polyhedron</a> *lP, *tmp, *Result, *lR, *prec, *reste;
<a name="l04407"></a>04407         <a class="code" href="structpolyhedron.html">Polyhedron</a> *p1, *p2, *p3, *Pol1, *dx, *d1, *d2, *pi, *newpi;
<a name="l04408"></a>04408         <span class="keywordtype">int</span> i;
<a name="l04409"></a>04409 
<a name="l04410"></a>04410         <span class="keywordflow">if</span>( flag!=0 &amp;&amp; flag!=1 )
<a name="l04411"></a>04411         {
<a name="l04412"></a>04412                 <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>(<span class="stringliteral">&quot;Disjoint_Domain&quot;</span>,
<a name="l04413"></a>04413                         <span class="stringliteral">&quot;invalidarg&quot;</span>, <span class="stringliteral">&quot;flag should be equal to 0 or 1&quot;</span>);
<a name="l04414"></a>04414                 <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l04415"></a>04415         }
<a name="l04416"></a>04416         <span class="keywordflow">if</span>(!P) <span class="keywordflow">return</span> (<a class="code" href="structpolyhedron.html">Polyhedron</a>*) 0;
<a name="l04417"></a>04417         <span class="keywordflow">if</span>(!P-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>) <span class="keywordflow">return</span> <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(P);
<a name="l04418"></a>04418 
<a name="l04419"></a>04419         Result = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l04420"></a>04420 
<a name="l04421"></a>04421         <span class="keywordflow">for</span>(lP=P;lP;lP=lP-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>)
<a name="l04422"></a>04422         {
<a name="l04423"></a>04423                 reste = <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(lP);
<a name="l04424"></a>04424                 prec = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0; <span class="comment">/* preceeding lR */</span>
<a name="l04425"></a>04425                 <span class="comment">/* Intersection with each polyhedron of the current Result */</span>
<a name="l04426"></a>04426                 lR=Result;
<a name="l04427"></a>04427                 <span class="keywordflow">while</span>( lR &amp;&amp; reste )
<a name="l04428"></a>04428                 {
<a name="l04429"></a>04429                         <span class="comment">/* dx = DomainIntersection(reste,lR-&gt;P,WS); */</span>
<a name="l04430"></a>04430                         dx = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l04431"></a>04431                         <span class="keywordflow">for</span>( p1=reste; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> )
<a name="l04432"></a>04432                         {
<a name="l04433"></a>04433                                 p3 = <a class="code" href="polyhedron_8c.html#a9690baafb863abbd2e8d5c4da2995416">AddConstraints</a>(lR-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[0], lR-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>, p1,
<a name="l04434"></a>04434                                                 NbMaxRays);
<a name="l04435"></a>04435                                 dx = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a>(p3,dx);
<a name="l04436"></a>04436                         }
<a name="l04437"></a>04437 
<a name="l04438"></a>04438                         <span class="comment">/* if empty intersection, continue */</span>
<a name="l04439"></a>04439                         <span class="keywordflow">if</span>(!dx)
<a name="l04440"></a>04440                         {       prec = lR;
<a name="l04441"></a>04441                                 lR=lR-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l04442"></a>04442                                 <span class="keywordflow">continue</span>;
<a name="l04443"></a>04443                         }
<a name="l04444"></a>04444                         <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(dx)) {       
<a name="l04445"></a>04445                                 <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>(dx);
<a name="l04446"></a>04446                                 prec = lR;
<a name="l04447"></a>04447                                 lR=lR-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l04448"></a>04448                                 <span class="keywordflow">continue</span>;
<a name="l04449"></a>04449                 }
<a name="l04450"></a>04450 
<a name="l04451"></a>04451                         <span class="comment">/* intersection is not empty, we need to compute the differences */</span>
<a name="l04452"></a>04452                         <span class="comment">/* between the intersection and the two polyhedra, such that the */</span>
<a name="l04453"></a>04453                         <span class="comment">/* results are disjoint unions (according to flag)               */</span>
<a name="l04454"></a>04454                         <span class="comment">/* d1 = reste \ P = DomainDifference(reste,lR-&gt;P,WS);   */</span>
<a name="l04455"></a>04455                         <span class="comment">/* d2 = P \ reste = DomainDifference(lR-&gt;P,reste,WS); */</span>
<a name="l04456"></a>04456 
<a name="l04457"></a>04457                         <span class="comment">/* compute d1 */</span>
<a name="l04458"></a>04458                         d1 = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l04459"></a>04459                         <span class="keywordflow">for</span> (p1=reste; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>)
<a name="l04460"></a>04460                         {
<a name="l04461"></a>04461                                 pi = p1;
<a name="l04462"></a>04462                                 <span class="keywordflow">for</span> (i=0; i&lt;P-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> &amp;&amp; pi ; i++)
<a name="l04463"></a>04463                                 {
<a name="l04464"></a>04464 
<a name="l04465"></a>04465                                         <span class="comment">/* Add the constraint ( -P-&gt;constraint[i] [-1 if flag=0]) &gt;= 0 in &apos;p1&apos; */</span>
<a name="l04466"></a>04466                                         <span class="comment">/* and create the new polyhedron &apos;p3&apos;.                      */</span>
<a name="l04467"></a>04467                                         p3 = <a class="code" href="polyhedron_8c.html#a1a9b9a572ee65d1c15aea3f9885dde7a">SubConstraint</a>(P-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i], pi, NbMaxRays,2*flag);
<a name="l04468"></a>04468                                         <span class="comment">/* Add &apos;p3&apos; in the new domain &apos;d1&apos; */</span>
<a name="l04469"></a>04469                                         d1 = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a> (p3, d1);
<a name="l04470"></a>04470 
<a name="l04471"></a>04471                                         <span class="comment">/* If the constraint P-&gt;constraint[i][0] is an equality, then add   */</span>
<a name="l04472"></a>04472                                         <span class="comment">/* the constraint ( +P-&gt;constraint[i] [-1 if flag=0]) &gt;= 0  in &apos;pi&apos; */</span>
<a name="l04473"></a>04473                                         <span class="comment">/* and create the new polyhedron &apos;p3&apos;.                              */</span>
<a name="l04474"></a>04474                                         <span class="keywordflow">if</span>( <a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(P-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][0]) ) <span class="comment">/* Inequality */</span>
<a name="l04475"></a>04475                                         {
<a name="l04476"></a>04476                                                 p3 = <a class="code" href="polyhedron_8c.html#a1a9b9a572ee65d1c15aea3f9885dde7a">SubConstraint</a>(P-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i], pi, NbMaxRays,1+2*flag);
<a name="l04477"></a>04477                                                 <span class="comment">/* Add &apos;p3&apos; in the new domain &apos;d1&apos; */</span>
<a name="l04478"></a>04478                                                 d1 = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a> (p3, d1);
<a name="l04479"></a>04479 
<a name="l04480"></a>04480                                                 <span class="comment">/* newpi : add constraint P-&gt;constraint[i]==0 to pi */</span>
<a name="l04481"></a>04481                                                 newpi = <a class="code" href="polyhedron_8c.html#a9690baafb863abbd2e8d5c4da2995416">AddConstraints</a>( P-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i], 1, pi, NbMaxRays);
<a name="l04482"></a>04482                                         }
<a name="l04483"></a>04483                                         <span class="keywordflow">else</span>
<a name="l04484"></a>04484                                         {
<a name="l04485"></a>04485                                                 <span class="comment">/* newpi : add constraint +P-&gt;constraint[i] &gt;= 0 in pi */</span>
<a name="l04486"></a>04486                                                 newpi = <a class="code" href="polyhedron_8c.html#a1a9b9a572ee65d1c15aea3f9885dde7a">SubConstraint</a>(P-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i], pi, NbMaxRays,3);
<a name="l04487"></a>04487                                         }
<a name="l04488"></a>04488                                         <span class="keywordflow">if</span>( newpi &amp;&amp; <a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>( newpi ) )
<a name="l04489"></a>04489                                         {
<a name="l04490"></a>04490                                                 <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( newpi );
<a name="l04491"></a>04491                                                 newpi = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l04492"></a>04492                                         }
<a name="l04493"></a>04493                                         <span class="keywordflow">if</span>( pi != p1 )
<a name="l04494"></a>04494                                                 <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( pi );
<a name="l04495"></a>04495                                         pi = newpi;
<a name="l04496"></a>04496                                 }
<a name="l04497"></a>04497                                 <span class="keywordflow">if</span>( pi != p1 )
<a name="l04498"></a>04498                                         <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( pi );
<a name="l04499"></a>04499                         }
<a name="l04500"></a>04500 
<a name="l04501"></a>04501                         <span class="comment">/* and now d2 */</span>
<a name="l04502"></a>04502                         Pol1 = <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>( lR );
<a name="l04503"></a>04503                         <span class="keywordflow">for</span> (p2=reste; p2; p2=p2-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>)
<a name="l04504"></a>04504                         {
<a name="l04505"></a>04505                                 d2 = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l04506"></a>04506                                 <span class="keywordflow">for</span> (p1=Pol1; p1; p1=p1-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>)
<a name="l04507"></a>04507                                 {
<a name="l04508"></a>04508                                         pi = p1;
<a name="l04509"></a>04509                                         <span class="keywordflow">for</span> (i=0; i&lt;p2-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> &amp;&amp; pi ; i++)
<a name="l04510"></a>04510                                         {
<a name="l04511"></a>04511 
<a name="l04512"></a>04512                                                 <span class="comment">/* Add the constraint ( -p2-&gt;constraint[i] [-1 if flag=0]) &gt;= 0 in &apos;pi&apos; */</span>
<a name="l04513"></a>04513                                                 <span class="comment">/* and create the new polyhedron &apos;p3&apos;.                      */</span>
<a name="l04514"></a>04514                                                 p3 = <a class="code" href="polyhedron_8c.html#a1a9b9a572ee65d1c15aea3f9885dde7a">SubConstraint</a>(p2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i], pi, NbMaxRays,2*flag);
<a name="l04515"></a>04515                                                 <span class="comment">/* Add &apos;p3&apos; in the new domain &apos;d2&apos; */</span>
<a name="l04516"></a>04516                                                 d2 = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a> (p3, d2);
<a name="l04517"></a>04517 
<a name="l04518"></a>04518                                                 <span class="comment">/* If the constraint p2-&gt;constraint[i][0] is an equality, then add   */</span>
<a name="l04519"></a>04519                                                 <span class="comment">/* the constraint ( +p2-&gt;constraint[i] [-1 if flag=0]) &gt;= 0  in &apos;pi&apos; */</span>
<a name="l04520"></a>04520                                                 <span class="comment">/* and create the new polyhedron &apos;p3&apos;.                              */</span>
<a name="l04521"></a>04521                                                 <span class="keywordflow">if</span>( <a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(p2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][0]) ) <span class="comment">/* Inequality */</span>
<a name="l04522"></a>04522                                                 {
<a name="l04523"></a>04523                                                         p3 = <a class="code" href="polyhedron_8c.html#a1a9b9a572ee65d1c15aea3f9885dde7a">SubConstraint</a>(p2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i], pi, NbMaxRays,1+2*flag);
<a name="l04524"></a>04524                                                         <span class="comment">/* Add &apos;p3&apos; in the new domain &apos;d2&apos; */</span>
<a name="l04525"></a>04525                                                         d2 = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a> (p3, d2);
<a name="l04526"></a>04526 
<a name="l04527"></a>04527                                                         <span class="comment">/* newpi : add constraint p2-&gt;constraint[i]==0 to pi */</span>
<a name="l04528"></a>04528                                                         newpi = <a class="code" href="polyhedron_8c.html#a9690baafb863abbd2e8d5c4da2995416">AddConstraints</a>( p2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i], 1, pi, NbMaxRays);
<a name="l04529"></a>04529                                                 }
<a name="l04530"></a>04530                                                 <span class="keywordflow">else</span>
<a name="l04531"></a>04531                                                 {
<a name="l04532"></a>04532                                                         <span class="comment">/* newpi : add constraint +p2-&gt;constraint[i] &gt;= 0 in pi */</span>
<a name="l04533"></a>04533                                                         newpi = <a class="code" href="polyhedron_8c.html#a1a9b9a572ee65d1c15aea3f9885dde7a">SubConstraint</a>(p2-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i], pi, NbMaxRays,3);
<a name="l04534"></a>04534                                                 }
<a name="l04535"></a>04535                                                 <span class="keywordflow">if</span>( newpi &amp;&amp; <a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>( newpi ) )
<a name="l04536"></a>04536                                                 {
<a name="l04537"></a>04537                                                         <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( newpi );
<a name="l04538"></a>04538                                                         newpi = (<a class="code" href="structpolyhedron.html">Polyhedron</a> *)0;
<a name="l04539"></a>04539                                                 }
<a name="l04540"></a>04540                                                 <span class="keywordflow">if</span>( pi != p1 )
<a name="l04541"></a>04541                                                         <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( pi );
<a name="l04542"></a>04542                                                 pi = newpi;
<a name="l04543"></a>04543                                         }
<a name="l04544"></a>04544                                         <span class="keywordflow">if</span>( pi &amp;&amp; pi!=p1 )
<a name="l04545"></a>04545                                                 <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( pi );
<a name="l04546"></a>04546                                 }
<a name="l04547"></a>04547                                 <span class="keywordflow">if</span>( Pol1 )
<a name="l04548"></a>04548                                         <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( Pol1 );
<a name="l04549"></a>04549                                 Pol1 = d2;
<a name="l04550"></a>04550                         }
<a name="l04551"></a>04551                         <span class="comment">/* ok, d1 and d2 are computed */</span>
<a name="l04552"></a>04552 
<a name="l04553"></a>04553                         <span class="comment">/* now, replace lR by d2+dx (at least dx is nonempty) and set reste to d1 */</span>
<a name="l04554"></a>04554                         <span class="keywordflow">if</span>( d1 &amp;&amp; <a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(d1) )
<a name="l04555"></a>04555                         {
<a name="l04556"></a>04556                                 <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( d1 );
<a name="l04557"></a>04557                                 d1 = NULL;
<a name="l04558"></a>04558                         }
<a name="l04559"></a>04559                         <span class="keywordflow">if</span>( d2 &amp;&amp; <a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(d2) )
<a name="l04560"></a>04560                         {
<a name="l04561"></a>04561                                 <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( d2 );
<a name="l04562"></a>04562                                 d2 = NULL;
<a name="l04563"></a>04563                         }
<a name="l04564"></a>04564 
<a name="l04565"></a>04565                         <span class="comment">/* set reste */</span>
<a name="l04566"></a>04566                         <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( reste );
<a name="l04567"></a>04567                         reste = d1;
<a name="l04568"></a>04568 
<a name="l04569"></a>04569                         <span class="comment">/* add d2 at beginning of Result */</span>
<a name="l04570"></a>04570                         <span class="keywordflow">if</span>( d2 )
<a name="l04571"></a>04571                         {
<a name="l04572"></a>04572                                 <span class="keywordflow">for</span>( tmp=d2 ; tmp-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> ; tmp=tmp-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> )
<a name="l04573"></a>04573                                                 ;
<a name="l04574"></a>04574                                 tmp-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = Result;
<a name="l04575"></a>04575                                 Result = d2;
<a name="l04576"></a>04576                                 <span class="keywordflow">if</span>( !prec )
<a name="l04577"></a>04577                                         prec = tmp;
<a name="l04578"></a>04578                         }
<a name="l04579"></a>04579 
<a name="l04580"></a>04580                         <span class="comment">/* add dx at beginning of Result */</span>
<a name="l04581"></a>04581                         <span class="keywordflow">for</span>( tmp=dx ; tmp-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> ; tmp=tmp-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> )
<a name="l04582"></a>04582                                 ;
<a name="l04583"></a>04583                         tmp-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = Result;
<a name="l04584"></a>04584                         Result = dx;
<a name="l04585"></a>04585                         <span class="keywordflow">if</span>( !prec )
<a name="l04586"></a>04586                                 prec = tmp;
<a name="l04587"></a>04587 
<a name="l04588"></a>04588                         <span class="comment">/* suppress current lR */</span>
<a name="l04589"></a>04589                         <span class="keywordflow">if</span>( !prec )
<a name="l04590"></a>04590                                 <a class="code" href="errormsg_8c.html#a1ac398d9106568a1991a001172e0e00b">errormsg1</a>( <span class="stringliteral">&quot;Disjoint_Domain&quot;</span>,<span class="stringliteral">&quot;internalerror&quot;</span>,<span class="stringliteral">&quot;internal error&quot;</span>);
<a name="l04591"></a>04591                         prec-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = lR-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l04592"></a>04592                         <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>( lR );
<a name="l04593"></a>04593                         lR = prec-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l04594"></a>04594                 } <span class="comment">/* end for result */</span>
<a name="l04595"></a>04595 
<a name="l04596"></a>04596                   <span class="comment">/* if there is something left, add it to Result : */</span>
<a name="l04597"></a>04597                 <span class="keywordflow">if</span>(reste)
<a name="l04598"></a>04598                 {
<a name="l04599"></a>04599                         <span class="keywordflow">if</span>(<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(reste))
<a name="l04600"></a>04600                         {
<a name="l04601"></a>04601                                 <a class="code" href="polyhedron_8c.html#ae6d0a7daf8e801a777fc8e93d8cfe43a">Domain_Free</a>( reste );
<a name="l04602"></a>04602                                 reste = NULL;
<a name="l04603"></a>04603                         }
<a name="l04604"></a>04604                         <span class="keywordflow">else</span>
<a name="l04605"></a>04605                         {
<a name="l04606"></a>04606                                 <a class="code" href="structpolyhedron.html">Polyhedron</a> *tnext;
<a name="l04607"></a>04607                                 <span class="keywordflow">for</span>( tmp=reste ; tmp ; tmp=tnext )
<a name="l04608"></a>04608                                 {
<a name="l04609"></a>04609                                         tnext = tmp-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l04610"></a>04610                                         tmp-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = NULL;
<a name="l04611"></a>04611                                         Result = <a class="code" href="polyhedron_8c.html#a965fd466bed4b1dd143c426e51ac16c5">AddPolyToDomain</a>(tmp, Result);
<a name="l04612"></a>04612                                 }
<a name="l04613"></a>04613                 }
<a name="l04614"></a>04614                 }
<a name="l04615"></a>04615         }
<a name="l04616"></a>04616 
<a name="l04617"></a>04617         <span class="keywordflow">return</span>( Result );
<a name="l04618"></a>04618 }
<a name="l04619"></a>04619 
<a name="l04620"></a>04620 
<a name="l04621"></a>04621 
<a name="l04622"></a>04622 <span class="comment">/* Procedure to print constraint matrix of a polyhedron */</span>
<a name="l04623"></a><a class="code" href="polyhedron_8h.html#a2303f014f8cd948a950c920085135081">04623</a> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#a2303f014f8cd948a950c920085135081">Polyhedron_PrintConstraints</a>(FILE *Dst, <span class="keyword">const</span> <span class="keywordtype">char</span> *Format, <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol)
<a name="l04624"></a>04624 {
<a name="l04625"></a>04625         <span class="keywordtype">int</span> i,j;
<a name="l04626"></a>04626 
<a name="l04627"></a>04627         fprintf( Dst, <span class="stringliteral">&quot;%d %d\n&quot;</span>, Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>, Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2 );
<a name="l04628"></a>04628         <span class="keywordflow">for</span>( i=0 ; i&lt;Pol-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a> ; i++ )
<a name="l04629"></a>04629         {
<a name="l04630"></a>04630                 <span class="keywordflow">for</span>( j=0 ; j&lt;Pol-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2 ; j++ )
<a name="l04631"></a>04631                         <a class="code" href="source_2arith_2arithmetique_8h.html#ad34605b56b571830b928b50a74d618b7">value_print</a>( Dst, Format, Pol-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[i][j] );
<a name="l04632"></a>04632                 fprintf( Dst, <span class="stringliteral">&quot;\n&quot;</span> );
<a name="l04633"></a>04633         }
<a name="l04634"></a>04634 
<a name="l04635"></a>04635 }
<a name="l04636"></a>04636 
<a name="l04637"></a>04637 <span class="comment">/* Procedure to print constraint matrix of a domain */</span>
<a name="l04638"></a><a class="code" href="polyhedron_8h.html#a1d8ad597537b66ac5c09e3c231002a7c">04638</a> <span class="keywordtype">void</span> <a class="code" href="polyhedron_8c.html#a1d8ad597537b66ac5c09e3c231002a7c">Domain_PrintConstraints</a>(FILE *Dst, <span class="keyword">const</span> <span class="keywordtype">char</span> *Format, <a class="code" href="structpolyhedron.html">Polyhedron</a> *Pol)
<a name="l04639"></a>04639 {
<a name="l04640"></a>04640     <a class="code" href="structpolyhedron.html">Polyhedron</a> *Q;
<a name="l04641"></a>04641     <span class="keywordflow">for</span> (Q = Pol; Q; Q = Q-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>)
<a name="l04642"></a>04642         <a class="code" href="polyhedron_8c.html#a2303f014f8cd948a950c920085135081">Polyhedron_PrintConstraints</a>(Dst, Format, Q);
<a name="l04643"></a>04643 }
<a name="l04644"></a>04644 
<a name="l04645"></a><a class="code" href="polyhedron_8c.html#a3b9cc3c5f8bf8df8d05855ba7a31d6ea">04645</a> <span class="keyword">static</span> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a3b9cc3c5f8bf8df8d05855ba7a31d6ea">p_simplify_constraints</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *P, <a class="code" href="structVector.html">Vector</a> *row,
<a name="l04646"></a>04646                                           Value *g, <span class="keywordtype">unsigned</span> MaxRays)
<a name="l04647"></a>04647 {
<a name="l04648"></a>04648     <a class="code" href="structpolyhedron.html">Polyhedron</a> *T, *R = P;
<a name="l04649"></a>04649     <span class="keywordtype">int</span> len = P-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;
<a name="l04650"></a>04650     <span class="keywordtype">int</span> r;
<a name="l04651"></a>04651 
<a name="l04652"></a>04652     <span class="comment">/* Also look at equalities.</span>
<a name="l04653"></a>04653 <span class="comment">     * If an equality can be &quot;simplified&quot; then there</span>
<a name="l04654"></a>04654 <span class="comment">     * are no integer solutions and we return an empty polyhedron</span>
<a name="l04655"></a>04655 <span class="comment">     */</span>
<a name="l04656"></a>04656     <span class="keywordflow">for</span> (r = 0; r &lt; R-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>; ++r) {
<a name="l04657"></a>04657         <span class="keywordflow">if</span> (<a class="code" href="vector_8c.html#ae6b570a9b1d0273b6cad4dab66fd9c71">ConstraintSimplify</a>(R-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[r], row-&gt;<a class="code" href="structVector.html#aecf9fddd3ad47d143da2e041fdff37cc">p</a>, len, g)) {
<a name="l04658"></a>04658             T = R;
<a name="l04659"></a>04659             <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#a827532f2140ae2aa96e46baebae09723">value_zero_p</a>(R-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[r][0])) {
<a name="l04660"></a>04660                 R = <a class="code" href="polyhedron_8c.html#a37f19f6863a633aa08657cadf564d3d6">Empty_Polyhedron</a>(R-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>);
<a name="l04661"></a>04661                 r = R-&gt;<a class="code" href="structpolyhedron.html#a2db05293e731089b9198d45cf027bd1c">NbConstraints</a>;
<a name="l04662"></a>04662             } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a223261a4719dd67ef2048c192bb34099">POL_ISSET</a>(MaxRays, <a class="code" href="types_8h.html#a754586a0aee88f21ad4c98b1cddee1be">POL_NO_DUAL</a>)) {
<a name="l04663"></a>04663                 R = <a class="code" href="polyhedron_8c.html#ab0f89a51f01cea6b93b8fb3ab43feca3">Polyhedron_Copy</a>(R);
<a name="l04664"></a>04664                 <a class="code" href="types_8h.html#abf7ccc8dc487c568afdb1efd664d1e61">F_CLR</a>(R, <a class="code" href="types_8h.html#adef192e3530c5e1fcb2c44858a78f703">POL_FACETS</a> | <a class="code" href="types_8h.html#a18cb4aab2aec424306ea8f67f6dfc9b0">POL_VERTICES</a> | <a class="code" href="types_8h.html#aacccb2db7ed6cb45d5e324216aa5ea3f">POL_POINTS</a>);
<a name="l04665"></a>04665                 <a class="code" href="vector_8c.html#ab6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(row-&gt;<a class="code" href="structVector.html#aecf9fddd3ad47d143da2e041fdff37cc">p</a>+1, R-&gt;<a class="code" href="structpolyhedron.html#ab2691b8eb5d2dc43a509ac2094d2bc73">Constraint</a>[r]+1, R-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+1);
<a name="l04666"></a>04666             } <span class="keywordflow">else</span> {
<a name="l04667"></a>04667                 R = <a class="code" href="polyhedron_8c.html#a9690baafb863abbd2e8d5c4da2995416">AddConstraints</a>(row-&gt;<a class="code" href="structVector.html#aecf9fddd3ad47d143da2e041fdff37cc">p</a>, 1, R, MaxRays);
<a name="l04668"></a>04668                 r = -1;
<a name="l04669"></a>04669             }
<a name="l04670"></a>04670             <span class="keywordflow">if</span> (T != P)
<a name="l04671"></a>04671                 <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(T);
<a name="l04672"></a>04672         }
<a name="l04673"></a>04673     }
<a name="l04674"></a>04674     <span class="keywordflow">if</span> (R != P)
<a name="l04675"></a>04675         <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(P);
<a name="l04676"></a>04676     <span class="keywordflow">return</span> R;
<a name="l04677"></a>04677 }
<a name="l04678"></a>04678 
<a name="l04679"></a>04679 <span class="comment">/*</span>
<a name="l04680"></a>04680 <span class="comment"> * Replaces constraint a x &gt;= c by x &gt;= ceil(c/a)</span>
<a name="l04681"></a>04681 <span class="comment"> * where &quot;a&quot; is a common factor in the coefficients</span>
<a name="l04682"></a>04682 <span class="comment"> * Destroys P and returns a newly allocated Polyhedron</span>
<a name="l04683"></a>04683 <span class="comment"> * or just returns P in case no changes were made</span>
<a name="l04684"></a>04684 <span class="comment"> */</span>
<a name="l04685"></a><a class="code" href="polyhedron_8h.html#a5ec487b5417647317b8e71f93b09c59e">04685</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> *<a class="code" href="polyhedron_8c.html#a5ec487b5417647317b8e71f93b09c59e">DomainConstraintSimplify</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> *P, <span class="keywordtype">unsigned</span> MaxRays)
<a name="l04686"></a>04686 {
<a name="l04687"></a>04687     <a class="code" href="structpolyhedron.html">Polyhedron</a> **prev;
<a name="l04688"></a>04688     <span class="keywordtype">int</span> len = P-&gt;<a class="code" href="structpolyhedron.html#a2a02cea8b7ba3dde415041b8b2373bc8">Dimension</a>+2;
<a name="l04689"></a>04689     <a class="code" href="structVector.html">Vector</a> *row = <a class="code" href="vector_8c.html#a358c545236f58b1001479e4a69d318aa">Vector_Alloc</a>(len);
<a name="l04690"></a>04690     Value g;
<a name="l04691"></a>04691     <a class="code" href="structpolyhedron.html">Polyhedron</a> *R = P, *N;
<a name="l04692"></a>04692     <a class="code" href="source_2arith_2arithmetique_8h.html#a8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(row-&gt;<a class="code" href="structVector.html#aecf9fddd3ad47d143da2e041fdff37cc">p</a>[0], 1);
<a name="l04693"></a>04693     <a class="code" href="source_2arith_2arithmetique_8h.html#af71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(g);
<a name="l04694"></a>04694 
<a name="l04695"></a>04695     <span class="keywordflow">for</span> (prev = &amp;R; P; P = N) {
<a name="l04696"></a>04696         <a class="code" href="structpolyhedron.html">Polyhedron</a> *T;
<a name="l04697"></a>04697         N = P-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l04698"></a>04698         T = <a class="code" href="polyhedron_8c.html#a3b9cc3c5f8bf8df8d05855ba7a31d6ea">p_simplify_constraints</a>(P, row, &amp;g, MaxRays);
<a name="l04699"></a>04699 
<a name="l04700"></a>04700         <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(T) &amp;&amp; prev != &amp;R) {
<a name="l04701"></a>04701             <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(T);
<a name="l04702"></a>04702             *prev = NULL;
<a name="l04703"></a>04703             <span class="keywordflow">continue</span>;
<a name="l04704"></a>04704         }
<a name="l04705"></a>04705 
<a name="l04706"></a>04706         <span class="keywordflow">if</span> (T != P)
<a name="l04707"></a>04707             T-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> = N;
<a name="l04708"></a>04708         *prev = T;
<a name="l04709"></a>04709         prev = &amp;T-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l04710"></a>04710     }
<a name="l04711"></a>04711 
<a name="l04712"></a>04712     <span class="keywordflow">if</span> (R-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a> &amp;&amp; <a class="code" href="types_8h.html#a156641ae25106f9a6ac5c5c2a624c168">emptyQ</a>(R)) {
<a name="l04713"></a>04713         N = R-&gt;<a class="code" href="structpolyhedron.html#aab97126cb9e56431d40eaf4e68b3953d">next</a>;
<a name="l04714"></a>04714         <a class="code" href="polyhedron_8c.html#a4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(R);
<a name="l04715"></a>04715         R = N;
<a name="l04716"></a>04716     }
<a name="l04717"></a>04717 
<a name="l04718"></a>04718     <a class="code" href="source_2arith_2arithmetique_8h.html#ab9b282921e85a0527d462d331533d619">value_clear</a>(g);
<a name="l04719"></a>04719     <a class="code" href="vector_8c.html#a055608d1a3726b7cb26e3e8074764ba0">Vector_Free</a>(row);
<a name="l04720"></a>04720     <span class="keywordflow">return</span> R;
<a name="l04721"></a>04721 }
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Wed Nov 25 17:45:26 2009 for polylib by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>