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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>polylib: compress_parms.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main 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>
<h1>compress_parms.c</h1><a href="compress__parms_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"> * $Id: compress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * The integer points in a parametric linear subspace of Q^n are generally</span>
<a name="l00005"></a>00005 <span class="comment"> * lying on a sub-lattice of Z^n. </span>
<a name="l00006"></a>00006 <span class="comment"> * Functions here use and compute validity lattices, i.e. lattices induced on a</span>
<a name="l00007"></a>00007 <span class="comment"> * set of variables by such equalities involving another set of integer</span>
<a name="l00008"></a>00008 <span class="comment"> * variables.</span>
<a name="l00009"></a>00009 <span class="comment"> * @author B. Meister 12/2003-2006 meister@icps.u-strasbg.fr</span>
<a name="l00010"></a>00010 <span class="comment"> * LSIIT -ICPS </span>
<a name="l00011"></a>00011 <span class="comment"> * UMR 7005 CNRS</span>
<a name="l00012"></a>00012 <span class="comment"> * Louis Pasteur University (ULP), Strasbourg, France </span>
<a name="l00013"></a>00013 <span class="comment">*/</span>
<a name="l00014"></a>00014
<a name="l00015"></a>00015 <span class="preprocessor">#include <stdlib.h></span>
<a name="l00016"></a>00016 <span class="preprocessor">#include <<a class="code" href="polylib_8h.html">polylib/polylib.h</a>></span>
<a name="l00017"></a>00017 <span class="comment"></span>
<a name="l00018"></a>00018 <span class="comment">/** </span>
<a name="l00019"></a>00019 <span class="comment"> * debug flags (2 levels)</span>
<a name="l00020"></a>00020 <span class="comment"> */</span>
<a name="l00021"></a><a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70">00021</a> <span class="preprocessor">#define dbgCompParm 0</span>
<a name="l00022"></a><a class="code" href="compress__parms_8c.html#964f66a0f36b5e1d0dea475066c53ca0">00022</a> <span class="preprocessor"></span><span class="preprocessor">#define dbgCompParmMore 0</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span>
<a name="l00024"></a><a class="code" href="compress__parms_8c.html#4df7b5873f125cf5c2976bbd4dcfe168">00024</a> <span class="preprocessor">#define dbgStart(a) if (dbgCompParmMore) { printf(" -- begin "); \</span>
<a name="l00025"></a>00025 <span class="preprocessor"> printf(#a); \</span>
<a name="l00026"></a>00026 <span class="preprocessor"> printf(" --\n"); } \</span>
<a name="l00027"></a>00027 <span class="preprocessor"> while(0)</span>
<a name="l00028"></a><a class="code" href="compress__parms_8c.html#49fcecacd32fa2357935cb5a4f542e0c">00028</a> <span class="preprocessor"></span><span class="preprocessor">#define dbgEnd(a) if (dbgCompParmMore) { printf(" -- end "); \</span>
<a name="l00029"></a>00029 <span class="preprocessor"> printf(#a); \</span>
<a name="l00030"></a>00030 <span class="preprocessor"> printf(" --\n"); } \</span>
<a name="l00031"></a>00031 <span class="preprocessor"> while(0)</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span>
<a name="l00033"></a>00033 <span class="comment"></span>
<a name="l00034"></a>00034 <span class="comment">/** </span>
<a name="l00035"></a>00035 <span class="comment"> * Given a full-row-rank nxm matrix M made of m row-vectors), computes the</span>
<a name="l00036"></a>00036 <span class="comment"> * basis K (made of n-m column-vectors) of the integer kernel of the rows of M</span>
<a name="l00037"></a>00037 <span class="comment"> * so we have: M.K = 0</span>
<a name="l00038"></a>00038 <span class="comment">*/</span>
<a name="l00039"></a><a class="code" href="compress__parms_8h.html#d66769b920ca4596c9fe5b76d38d0b3b">00039</a> <a class="code" href="structmatrix.html">Matrix</a> * <a class="code" href="compress__parms_8c.html#d66769b920ca4596c9fe5b76d38d0b3b" title="Given a full-row-rank nxm matrix M made of m row-vectors), computes the basis K (made...">int_ker</a>(<a class="code" href="structmatrix.html">Matrix</a> * M) {
<a name="l00040"></a>00040 <a class="code" href="structmatrix.html">Matrix</a> *U, *Q, *H, *H2, *K=NULL;
<a name="l00041"></a>00041 <span class="keywordtype">int</span> i, j, rk;
<a name="l00042"></a>00042
<a name="l00043"></a>00043 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>)
<a name="l00044"></a>00044 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(M);
<a name="l00045"></a>00045 <span class="comment">/* eliminate redundant rows : UM = H*/</span>
<a name="l00046"></a>00046 <a class="code" href="matrix_8c.html#9d112ac078583626580f848b51a515f3">right_hermite</a>(M, &H, &Q, &U);
<a name="l00047"></a>00047 <span class="keywordflow">for</span> (rk=H-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>-1; (rk>=0) && <a class="code" href="vector_8c.html#4f5f43ecdfb5c63f8c3ecbf875887869">Vector_IsZero</a>(H-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[rk], H-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>); rk--);
<a name="l00048"></a>00048 rk++;
<a name="l00049"></a>00049 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#964f66a0f36b5e1d0dea475066c53ca0">dbgCompParmMore</a>) {
<a name="l00050"></a>00050 printf(<span class="stringliteral">"rank = %d\n"</span>, rk);
<a name="l00051"></a>00051 }
<a name="l00052"></a>00052
<a name="l00053"></a>00053 <span class="comment">/* there is a non-null kernel if and only if the dimension m of </span>
<a name="l00054"></a>00054 <span class="comment"> the space spanned by the rows </span>
<a name="l00055"></a>00055 <span class="comment"> is inferior to the number n of variables */</span>
<a name="l00056"></a>00056 <span class="keywordflow">if</span> (M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a> <= rk) {
<a name="l00057"></a>00057 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(H);
<a name="l00058"></a>00058 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Q);
<a name="l00059"></a>00059 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(U);
<a name="l00060"></a>00060 K = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>, 0);
<a name="l00061"></a>00061 <span class="keywordflow">return</span> K;
<a name="l00062"></a>00062 }
<a name="l00063"></a>00063 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(U);
<a name="l00064"></a>00064 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Q);
<a name="l00065"></a>00065 <span class="comment">/* fool left_hermite by giving NbRows =rank of M*/</span>
<a name="l00066"></a>00066 H-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>=rk;
<a name="l00067"></a>00067 <span class="comment">/* computes MU = [H 0] */</span>
<a name="l00068"></a>00068 <a class="code" href="matrix_8c.html#dcbe5ee3f0c28fb35aed49f4e1f40f5b">left_hermite</a>(H, &H2, &Q, &U);
<a name="l00069"></a>00069 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#964f66a0f36b5e1d0dea475066c53ca0">dbgCompParmMore</a>) {
<a name="l00070"></a>00070 printf(<span class="stringliteral">"-- Int. Kernel -- \n"</span>);
<a name="l00071"></a>00071 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(M);
<a name="l00072"></a>00072 printf(<span class="stringliteral">" = \n"</span>);
<a name="l00073"></a>00073 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(H2);
<a name="l00074"></a>00074 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(U);
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076 H-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>==M-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l00077"></a>00077 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(H);
<a name="l00078"></a>00078 <span class="comment">/* the Integer Kernel is made of the last n-rk columns of U */</span>
<a name="l00079"></a>00079 <a class="code" href="matrix__addon_8c.html#33fec91bb879b7b4dda814ad9d33f41b" title="returns a contiguous submatrix of a matrix.">Matrix_subMatrix</a>(U, 0, rk, U-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>, U-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>, &K);
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="comment">/* clean up */</span>
<a name="l00082"></a>00082 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(H2);
<a name="l00083"></a>00083 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(U);
<a name="l00084"></a>00084 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Q);
<a name="l00085"></a>00085 <span class="keywordflow">return</span> K;
<a name="l00086"></a>00086 } <span class="comment">/* int_ker */</span>
<a name="l00087"></a>00087
<a name="l00088"></a>00088 <span class="comment"></span>
<a name="l00089"></a>00089 <span class="comment">/** </span>
<a name="l00090"></a>00090 <span class="comment"> * Computes the intersection of two linear lattices, whose base vectors are</span>
<a name="l00091"></a>00091 <span class="comment"> * respectively represented in A and B.</span>
<a name="l00092"></a>00092 <span class="comment"> * If I and/or Lb is set to NULL, then the matrix is allocated. </span>
<a name="l00093"></a>00093 <span class="comment"> * Else, the matrix is assumed to be allocated already. </span>
<a name="l00094"></a>00094 <span class="comment"> * I and Lb are rk x rk, where rk is the rank of A (or B).</span>
<a name="l00095"></a>00095 <span class="comment"> * @param A the full-row rank matrix whose column-vectors are the basis for the</span>
<a name="l00096"></a>00096 <span class="comment"> * first linear lattice.</span>
<a name="l00097"></a>00097 <span class="comment"> * @param B the matrix whose column-vectors are the basis for the second linear</span>
<a name="l00098"></a>00098 <span class="comment"> * lattice.</span>
<a name="l00099"></a>00099 <span class="comment"> * @param Lb the matrix such that B.Lb = I, where I is the intersection.</span>
<a name="l00100"></a>00100 <span class="comment"> * @return their intersection.</span>
<a name="l00101"></a>00101 <span class="comment"> */</span>
<a name="l00102"></a><a class="code" href="compress__parms_8c.html#8b044a0b5721eb247eb671644b80df9d">00102</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="compress__parms_8c.html#8b044a0b5721eb247eb671644b80df9d" title="Computes the intersection of two linear lattices, whose base vectors are respectively...">linearInter</a>(<a class="code" href="structmatrix.html">Matrix</a> * A, <a class="code" href="structmatrix.html">Matrix</a> * B, <a class="code" href="structmatrix.html">Matrix</a> ** I, <a class="code" href="structmatrix.html">Matrix</a> **Lb) {
<a name="l00103"></a>00103 <a class="code" href="structmatrix.html">Matrix</a> * AB=NULL;
<a name="l00104"></a>00104 <span class="keywordtype">int</span> rk = A-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l00105"></a>00105 <span class="keywordtype">int</span> a = A-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>;
<a name="l00106"></a>00106 <span class="keywordtype">int</span> b = B-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>;
<a name="l00107"></a>00107 <span class="keywordtype">int</span> i,j, z=0;
<a name="l00108"></a>00108
<a name="l00109"></a>00109 <a class="code" href="structmatrix.html">Matrix</a> * H, *U, *Q;
<a name="l00110"></a>00110 <span class="comment">/* ensure that the spanning vectors are in the same space */</span>
<a name="l00111"></a>00111 <a class="code" href="assert_8h.html#07d17d6d5d1074c0969bc5d3c3d1d84a">assert</a>(B-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>==rk);
<a name="l00112"></a>00112 <span class="comment">/* 1- build the matrix </span>
<a name="l00113"></a>00113 <span class="comment"> * (A 0 1)</span>
<a name="l00114"></a>00114 <span class="comment"> * (0 B 1)</span>
<a name="l00115"></a>00115 <span class="comment"> */</span>
<a name="l00116"></a>00116 AB = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(2*rk, a+b+rk);
<a name="l00117"></a>00117 <a class="code" href="matrix__addon_8c.html#cb90cceb8e7a674a3d5796a1402f0c9e" title="Copies a contiguous submatrix of M1 into M2, at the indicated position.">Matrix_copySubMatrix</a>(A, 0, 0, rk, a, AB, 0, 0);
<a name="l00118"></a>00118 <a class="code" href="matrix__addon_8c.html#cb90cceb8e7a674a3d5796a1402f0c9e" title="Copies a contiguous submatrix of M1 into M2, at the indicated position.">Matrix_copySubMatrix</a>(B, 0, 0, rk, b, AB, rk, a);
<a name="l00119"></a>00119 <span class="keywordflow">for</span> (i=0; i< rk; i++) {
<a name="l00120"></a>00120 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(AB-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][a+b+i], 1);
<a name="l00121"></a>00121 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(AB-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i+rk][a+b+i], 1);
<a name="l00122"></a>00122 }
<a name="l00123"></a>00123 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00124"></a>00124 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(AB);
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126
<a name="l00127"></a>00127 <span class="comment">/* 2- Compute its left Hermite normal form. AB.U = [H 0] */</span>
<a name="l00128"></a>00128 <a class="code" href="matrix_8c.html#dcbe5ee3f0c28fb35aed49f4e1f40f5b">left_hermite</a>(AB, &H, &Q, &U);
<a name="l00129"></a>00129 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(AB);
<a name="l00130"></a>00130 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Q);
<a name="l00131"></a>00131 <span class="comment">/* count the number of non-zero colums in H */</span>
<a name="l00132"></a>00132 <span class="keywordflow">for</span> (z=H-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1; <a class="code" href="source_2arith_2arithmetique_8h.html#827532f2140ae2aa96e46baebae09723">value_zero_p</a>(H-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[H-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>-1][z]); z--);
<a name="l00133"></a>00133 z++;
<a name="l00134"></a>00134 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00135"></a>00135 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(H);
<a name="l00136"></a>00136 printf(<span class="stringliteral">"z=%d\n"</span>, z);
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(H);
<a name="l00139"></a>00139 <span class="comment">/* if you split U in 9 submatrices, you have: </span>
<a name="l00140"></a>00140 <span class="comment"> * A.U_13 = -U_33</span>
<a name="l00141"></a>00141 <span class="comment"> * B.U_23 = -U_33,</span>
<a name="l00142"></a>00142 <span class="comment"> * where the nb of cols of U_{*3} equals the nb of zero-cols of H</span>
<a name="l00143"></a>00143 <span class="comment"> * U_33 is a (the smallest) combination of col-vectors of A and B at the same</span>
<a name="l00144"></a>00144 <span class="comment"> * time: their intersection.</span>
<a name="l00145"></a>00145 <span class="comment"> */</span>
<a name="l00146"></a>00146 <a class="code" href="matrix__addon_8c.html#33fec91bb879b7b4dda814ad9d33f41b" title="returns a contiguous submatrix of a matrix.">Matrix_subMatrix</a>(U, a+b, z, U-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>, U-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>, I);
<a name="l00147"></a>00147 <a class="code" href="matrix__addon_8c.html#33fec91bb879b7b4dda814ad9d33f41b" title="returns a contiguous submatrix of a matrix.">Matrix_subMatrix</a>(U, a, z, a+b, U-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>, Lb);
<a name="l00148"></a>00148 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00149"></a>00149 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(U);
<a name="l00150"></a>00150 }
<a name="l00151"></a>00151 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(U);
<a name="l00152"></a>00152 } <span class="comment">/* linearInter */</span>
<a name="l00153"></a>00153
<a name="l00154"></a>00154 <span class="comment"></span>
<a name="l00155"></a>00155 <span class="comment">/** </span>
<a name="l00156"></a>00156 <span class="comment"> * Given a system of equalities, looks if it has an integer solution in the</span>
<a name="l00157"></a>00157 <span class="comment"> * combined space, and if yes, returns one solution.</span>
<a name="l00158"></a>00158 <span class="comment"> * <p>pre-condition: the equalities are full-row rank (without the constant</span>
<a name="l00159"></a>00159 <span class="comment"> * part)</p></span>
<a name="l00160"></a>00160 <span class="comment"> * @param Eqs the system of equations (as constraints)</span>
<a name="l00161"></a>00161 <span class="comment"> * @param I a feasible integer solution if it exists, else NULL. Allocated if</span>
<a name="l00162"></a>00162 <span class="comment"> * initially set to NULL, else reused.</span>
<a name="l00163"></a>00163 <span class="comment"> */</span>
<a name="l00164"></a><a class="code" href="compress__parms_8h.html#70ce0c696b3509b89996e7bd8baf6b66">00164</a> <span class="keywordtype">void</span> <a class="code" href="compress__parms_8c.html#0395c4623907612a51219536d4d258e6" title="Given a system of equalities, looks if it has an integer solution in the combined...">Equalities_integerSolution</a>(<a class="code" href="structmatrix.html">Matrix</a> * Eqs, <a class="code" href="structmatrix.html">Matrix</a> **I) {
<a name="l00165"></a>00165 <a class="code" href="structmatrix.html">Matrix</a> * Hm, *H=NULL, *U, *Q, *M=NULL, *C=NULL, *Hi;
<a name="l00166"></a>00166 <a class="code" href="structmatrix.html">Matrix</a> *Ip;
<a name="l00167"></a>00167 <span class="keywordtype">int</span> i;
<a name="l00168"></a>00168 Value mod;
<a name="l00169"></a>00169 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> rk;
<a name="l00170"></a>00170 <span class="keywordflow">if</span> (Eqs==NULL){
<a name="l00171"></a>00171 <span class="keywordflow">if</span> ((*I)!=NULL) <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(*I);
<a name="l00172"></a>00172 I = NULL;
<a name="l00173"></a>00173 <span class="keywordflow">return</span>;
<a name="l00174"></a>00174 }
<a name="l00175"></a>00175 <span class="comment">/* we use: AI = C = (Ha 0).Q.I = (Ha 0)(I' 0)^T */</span>
<a name="l00176"></a>00176 <span class="comment">/* with I = Qinv.I' = U.I'*/</span>
<a name="l00177"></a>00177 <span class="comment">/* 1- compute I' = Hainv.(-C) */</span>
<a name="l00178"></a>00178 <span class="comment">/* HYP: the equalities are full-row rank */</span>
<a name="l00179"></a>00179 rk = Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l00180"></a>00180 <a class="code" href="matrix__addon_8c.html#33fec91bb879b7b4dda814ad9d33f41b" title="returns a contiguous submatrix of a matrix.">Matrix_subMatrix</a>(Eqs, 0, 1, rk, Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1, &M);
<a name="l00181"></a>00181 <a class="code" href="matrix_8c.html#dcbe5ee3f0c28fb35aed49f4e1f40f5b">left_hermite</a>(M, &Hm, &Q, &U);
<a name="l00182"></a>00182 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(M);
<a name="l00183"></a>00183 <a class="code" href="matrix__addon_8c.html#33fec91bb879b7b4dda814ad9d33f41b" title="returns a contiguous submatrix of a matrix.">Matrix_subMatrix</a>(Hm, 0, 0, rk, rk, &H);
<a name="l00184"></a>00184 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#964f66a0f36b5e1d0dea475066c53ca0">dbgCompParmMore</a>) {
<a name="l00185"></a>00185 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(Hm);
<a name="l00186"></a>00186 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(H);
<a name="l00187"></a>00187 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(U);
<a name="l00188"></a>00188 }
<a name="l00189"></a>00189 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Q);
<a name="l00190"></a>00190 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Hm);
<a name="l00191"></a>00191 <a class="code" href="matrix__addon_8c.html#33fec91bb879b7b4dda814ad9d33f41b" title="returns a contiguous submatrix of a matrix.">Matrix_subMatrix</a>(Eqs, 0, Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1, rk, Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>, &C);
<a name="l00192"></a>00192 <a class="code" href="matrix__addon_8c.html#cbbded0c02e89b1a7b6b08ee3f396986" title="transforms a matrix M into -M">Matrix_oppose</a>(C);
<a name="l00193"></a>00193 Hi = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(rk, rk+1);
<a name="l00194"></a>00194 <a class="code" href="matrix_8c.html#e2b2f031eb75c5011091536d7ef4befc">MatInverse</a>(H, Hi);
<a name="l00195"></a>00195 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#964f66a0f36b5e1d0dea475066c53ca0">dbgCompParmMore</a>) {
<a name="l00196"></a>00196 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(C);
<a name="l00197"></a>00197 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(Hi);
<a name="l00198"></a>00198 }
<a name="l00199"></a>00199 <span class="comment">/* put the numerator of Hinv back into H */</span>
<a name="l00200"></a>00200 <a class="code" href="matrix__addon_8c.html#33fec91bb879b7b4dda814ad9d33f41b" title="returns a contiguous submatrix of a matrix.">Matrix_subMatrix</a>(Hi, 0, 0, rk, rk, &H);
<a name="l00201"></a>00201 Ip = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2, 1);
<a name="l00202"></a>00202 <span class="comment">/* fool Matrix_Product on the size of Ip */</span>
<a name="l00203"></a>00203 Ip-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a> = rk;
<a name="l00204"></a>00204 <a class="code" href="matrix_8c.html#1e967c74adaa2eec868fd737a55b6624">Matrix_Product</a>(H, C, Ip);
<a name="l00205"></a>00205 Ip-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a> = Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2;
<a name="l00206"></a>00206 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(H);
<a name="l00207"></a>00207 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(C);
<a name="l00208"></a>00208 <a class="code" href="source_2arith_2arithmetique_8h.html#f71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(mod);
<a name="l00209"></a>00209 <span class="keywordflow">for</span> (i=0; i< rk; i++) {
<a name="l00210"></a>00210 <span class="comment">/* if Hinv.C is not integer, return NULL (no solution) */</span>
<a name="l00211"></a>00211 <a class="code" href="source_2arith_2arithmetique_8h.html#60a1720f53f9951170f929062609ddcf">value_pmodulus</a>(mod, Ip-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], Hi->p[i][rk]);
<a name="l00212"></a>00212 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(mod)) {
<a name="l00213"></a>00213 <span class="keywordflow">if</span> ((*I)!=NULL) <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(*I);
<a name="l00214"></a>00214 <a class="code" href="source_2arith_2arithmetique_8h.html#b9b282921e85a0527d462d331533d619">value_clear</a>(mod);
<a name="l00215"></a>00215 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(U);
<a name="l00216"></a>00216 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ip);
<a name="l00217"></a>00217 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Hi);
<a name="l00218"></a>00218 I = NULL;
<a name="l00219"></a>00219 <span class="keywordflow">return</span>;
<a name="l00220"></a>00220 }
<a name="l00221"></a>00221 <span class="keywordflow">else</span> {
<a name="l00222"></a>00222 <a class="code" href="source_2arith_2arithmetique_8h.html#1d5fd16549d53f259c2e7699a22045cb">value_pdivision</a>(Ip-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], Ip-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], Hi->p[i][rk]);
<a name="l00223"></a>00223 }
<a name="l00224"></a>00224 }
<a name="l00225"></a>00225 <span class="comment">/* fill the rest of I' with zeros */</span>
<a name="l00226"></a>00226 <span class="keywordflow">for</span> (i=rk; i< Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2; i++) {
<a name="l00227"></a>00227 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Ip-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], 0);
<a name="l00228"></a>00228 }
<a name="l00229"></a>00229 <a class="code" href="source_2arith_2arithmetique_8h.html#b9b282921e85a0527d462d331533d619">value_clear</a>(mod);
<a name="l00230"></a>00230 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Hi);
<a name="l00231"></a>00231 <span class="comment">/* 2 - Compute the particular solution I = U.(I' 0) */</span>
<a name="l00232"></a>00232 <a class="code" href="matrix__addon_8h.html#4f34dad95751e0142b7b9404fc44d0f0" title="Allocates a matrix if it is null, or else asserts that it has at least a certain...">ensureMatrix</a>((*I), Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2, 1);
<a name="l00233"></a>00233 <a class="code" href="matrix_8c.html#1e967c74adaa2eec868fd737a55b6624">Matrix_Product</a>(U, Ip, (*I));
<a name="l00234"></a>00234 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(U);
<a name="l00235"></a>00235 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ip);
<a name="l00236"></a>00236 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00237"></a>00237 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(*I);
<a name="l00238"></a>00238 }
<a name="l00239"></a>00239 }
<a name="l00240"></a>00240
<a name="l00241"></a>00241 <span class="comment"></span>
<a name="l00242"></a>00242 <span class="comment">/** </span>
<a name="l00243"></a>00243 <span class="comment"> * Computes the validity lattice of a set of equalities. I.e., the lattice</span>
<a name="l00244"></a>00244 <span class="comment"> * induced on the last <tt>b</tt> variables by the equalities involving the</span>
<a name="l00245"></a>00245 <span class="comment"> * first <tt>a</tt> integer existential variables. The submatrix of Eqs that</span>
<a name="l00246"></a>00246 <span class="comment"> * concerns only the existential variables (so the first a columns) is assumed</span>
<a name="l00247"></a>00247 <span class="comment"> * to be full-row rank.</span>
<a name="l00248"></a>00248 <span class="comment"> * @param Eqs the equalities</span>
<a name="l00249"></a>00249 <span class="comment"> * @param a the number of existential integer variables, placed as first</span>
<a name="l00250"></a>00250 <span class="comment"> * variables</span>
<a name="l00251"></a>00251 <span class="comment"> * @param vl the (returned) validity lattice, in homogeneous form. It is</span>
<a name="l00252"></a>00252 <span class="comment"> * allocated if initially set to null, or reused if already allocated.</span>
<a name="l00253"></a>00253 <span class="comment"> */</span>
<a name="l00254"></a><a class="code" href="compress__parms_8h.html#e018fc28835ce2d99a74dba09055acc0">00254</a> <span class="keywordtype">void</span> <a class="code" href="compress__parms_8c.html#e018fc28835ce2d99a74dba09055acc0" title="Computes the validity lattice of a set of equalities.">Equalities_validityLattice</a>(<a class="code" href="structmatrix.html">Matrix</a> * Eqs, <span class="keywordtype">int</span> a, <a class="code" href="structmatrix.html">Matrix</a>** vl) {
<a name="l00255"></a>00255 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> b = Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2-a;
<a name="l00256"></a>00256 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> r = Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l00257"></a>00257 <a class="code" href="structmatrix.html">Matrix</a> * A=NULL, * B=NULL, *I = NULL, *Lb=NULL, *sol=NULL;
<a name="l00258"></a>00258 <a class="code" href="structmatrix.html">Matrix</a> *H, *U, *Q;
<a name="l00259"></a>00259 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00260"></a>00260
<a name="l00261"></a>00261 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00262"></a>00262 printf(<span class="stringliteral">"Computing validity lattice induced by the %d first variables of:"</span>
<a name="l00263"></a>00263 ,a);
<a name="l00264"></a>00264 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(Eqs);
<a name="l00265"></a>00265 }
<a name="l00266"></a>00266 <span class="keywordflow">if</span> (b==0) {
<a name="l00267"></a>00267 <a class="code" href="matrix__addon_8h.html#4f34dad95751e0142b7b9404fc44d0f0" title="Allocates a matrix if it is null, or else asserts that it has at least a certain...">ensureMatrix</a>((*vl), 1, 1);
<a name="l00268"></a>00268 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>((*vl)->p[0][0], 1);
<a name="l00269"></a>00269 <span class="keywordflow">return</span>;
<a name="l00270"></a>00270 }
<a name="l00271"></a>00271
<a name="l00272"></a>00272 <span class="comment">/* 1- check that there is an integer solution to the equalities */</span>
<a name="l00273"></a>00273 <span class="comment">/* OPT: could change integerSolution's profile to allocate or not*/</span>
<a name="l00274"></a>00274 <a class="code" href="compress__parms_8c.html#0395c4623907612a51219536d4d258e6" title="Given a system of equalities, looks if it has an integer solution in the combined...">Equalities_integerSolution</a>(Eqs, &sol);
<a name="l00275"></a>00275 <span class="comment">/* if there is no integer solution, there is no validity lattice */</span>
<a name="l00276"></a>00276 <span class="keywordflow">if</span> (sol==NULL) {
<a name="l00277"></a>00277 <span class="keywordflow">if</span> ((*vl)!=NULL) <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(*vl);
<a name="l00278"></a>00278 <span class="keywordflow">return</span>;
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280 <a class="code" href="matrix__addon_8c.html#33fec91bb879b7b4dda814ad9d33f41b" title="returns a contiguous submatrix of a matrix.">Matrix_subMatrix</a>(Eqs, 0, 1, r, 1+a, &A);
<a name="l00281"></a>00281 <a class="code" href="matrix__addon_8c.html#33fec91bb879b7b4dda814ad9d33f41b" title="returns a contiguous submatrix of a matrix.">Matrix_subMatrix</a>(Eqs, 0, 1+a, r, 1+a+b, &B);
<a name="l00282"></a>00282 <a class="code" href="compress__parms_8c.html#8b044a0b5721eb247eb671644b80df9d" title="Computes the intersection of two linear lattices, whose base vectors are respectively...">linearInter</a>(A, B, &I, &Lb);
<a name="l00283"></a>00283 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(A);
<a name="l00284"></a>00284 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(B);
<a name="l00285"></a>00285 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(I);
<a name="l00286"></a>00286 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00287"></a>00287 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(Lb);
<a name="l00288"></a>00288 }
<a name="l00289"></a>00289
<a name="l00290"></a>00290 <span class="comment">/* 2- The linear part of the validity lattice is the left HNF of Lb */</span>
<a name="l00291"></a>00291 <a class="code" href="matrix_8c.html#dcbe5ee3f0c28fb35aed49f4e1f40f5b">left_hermite</a>(Lb, &H, &Q, &U);
<a name="l00292"></a>00292 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Lb);
<a name="l00293"></a>00293 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Q);
<a name="l00294"></a>00294 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(U);
<a name="l00295"></a>00295
<a name="l00296"></a>00296 <span class="comment">/* 3- build the validity lattice */</span>
<a name="l00297"></a>00297 <a class="code" href="matrix__addon_8h.html#4f34dad95751e0142b7b9404fc44d0f0" title="Allocates a matrix if it is null, or else asserts that it has at least a certain...">ensureMatrix</a>((*vl), b+1, b+1);
<a name="l00298"></a>00298 <a class="code" href="matrix__addon_8c.html#cb90cceb8e7a674a3d5796a1402f0c9e" title="Copies a contiguous submatrix of M1 into M2, at the indicated position.">Matrix_copySubMatrix</a>(H, 0, 0, b, b, (*vl), 0,0);
<a name="l00299"></a>00299 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(H);
<a name="l00300"></a>00300 <span class="keywordflow">for</span> (i=0; i< b; i++) {
<a name="l00301"></a>00301 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>((*vl)->p[i][b], sol->p[0][a+i]);
<a name="l00302"></a>00302 }
<a name="l00303"></a>00303 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(sol);
<a name="l00304"></a>00304 <a class="code" href="vector_8c.html#27ccb3ea01f3a496bb799fb99e9e3075">Vector_Set</a>((*vl)->p[b],0, b);
<a name="l00305"></a>00305 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>((*vl)->p[b][b], 1);
<a name="l00306"></a>00306
<a name="l00307"></a>00307 } <span class="comment">/* validityLattice */</span>
<a name="l00308"></a>00308
<a name="l00309"></a>00309 <span class="comment"></span>
<a name="l00310"></a>00310 <span class="comment">/**</span>
<a name="l00311"></a>00311 <span class="comment"> * Eliminate the columns corresponding to a list of eliminated parameters.</span>
<a name="l00312"></a>00312 <span class="comment"> * @param M the constraints matrix whose columns are to be removed</span>
<a name="l00313"></a>00313 <span class="comment"> * @param nbVars an offset to be added to the ranks of the variables to be</span>
<a name="l00314"></a>00314 <span class="comment"> * removed</span>
<a name="l00315"></a>00315 <span class="comment"> * @param elimParms the list of ranks of the variables to be removed</span>
<a name="l00316"></a>00316 <span class="comment"> * @param newM (output) the matrix without the removed columns</span>
<a name="l00317"></a>00317 <span class="comment"> */</span>
<a name="l00318"></a><a class="code" href="compress__parms_8h.html#3efbee2cc61c1cfb2e0b05f3320a2e83">00318</a> <span class="keywordtype">void</span> <a class="code" href="compress__parms_8c.html#3efbee2cc61c1cfb2e0b05f3320a2e83" title="Eliminate the columns corresponding to a list of eliminated parameters.">Constraints_removeElimCols</a>(<a class="code" href="structmatrix.html">Matrix</a> * M, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nbVars,
<a name="l00319"></a>00319 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *elimParms, <a class="code" href="structmatrix.html">Matrix</a> ** newM) {
<a name="l00320"></a>00320 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i, j, k;
<a name="l00321"></a>00321 <span class="keywordflow">if</span> (elimParms[0]==0) {
<a name="l00322"></a>00322 <a class="code" href="matrix__addon_8c.html#8269bc80b6beba6d58a4c5b029f04bbf" title="Cloning function.">Matrix_clone</a>(M, newM);
<a name="l00323"></a>00323 <span class="keywordflow">return</span>;
<a name="l00324"></a>00324 }
<a name="l00325"></a>00325 <span class="keywordflow">if</span> ((*newM)==NULL) {
<a name="l00326"></a>00326 (*newM) = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(M-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>, M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a> - elimParms[0]);
<a name="l00327"></a>00327 }
<a name="l00328"></a>00328 <span class="keywordflow">else</span> {
<a name="l00329"></a>00329 <a class="code" href="assert_8h.html#07d17d6d5d1074c0969bc5d3c3d1d84a">assert</a> ((*newM)->NbColumns==M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a> - elimParms[0]);
<a name="l00330"></a>00330 }
<a name="l00331"></a>00331 <span class="keywordflow">for</span> (i=0; i< M-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00332"></a>00332 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>((*newM)->p[i][0], M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0]); <span class="comment">/* kind of cstr */</span>
<a name="l00333"></a>00333 k=0;
<a name="l00334"></a>00334 <a class="code" href="vector_8c.html#b6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(&(M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][1]), &((*newM)->p[i][1]), nbVars);
<a name="l00335"></a>00335 <span class="keywordflow">for</span> (j=0; j< M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2-nbVars; j++) {
<a name="l00336"></a>00336 <span class="keywordflow">if</span> (j!=elimParms[k+1]) {
<a name="l00337"></a>00337 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>((*newM)->p[i][j-k+nbVars+1], M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j+nbVars+1]);
<a name="l00338"></a>00338 }
<a name="l00339"></a>00339 <span class="keywordflow">else</span> {
<a name="l00340"></a>00340 k++;
<a name="l00341"></a>00341 }
<a name="l00342"></a>00342 }
<a name="l00343"></a>00343 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>((*newM)->p[i][(*newM)->NbColumns-1],
<a name="l00344"></a>00344 M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1]); <span class="comment">/* cst part */</span>
<a name="l00345"></a>00345 }
<a name="l00346"></a>00346 } <span class="comment">/* Constraints_removeElimCols */</span>
<a name="l00347"></a>00347
<a name="l00348"></a>00348 <span class="comment"></span>
<a name="l00349"></a>00349 <span class="comment">/**</span>
<a name="l00350"></a>00350 <span class="comment"> * Eliminates all the equalities in a set of constraints and returns the set of</span>
<a name="l00351"></a>00351 <span class="comment"> * constraints defining a full-dimensional polyhedron, such that there is a</span>
<a name="l00352"></a>00352 <span class="comment"> * bijection between integer points of the original polyhedron and these of the</span>
<a name="l00353"></a>00353 <span class="comment"> * resulting (projected) polyhedron).</span>
<a name="l00354"></a>00354 <span class="comment"> * If VL is set to NULL, this funciton allocates it. Else, it assumes that</span>
<a name="l00355"></a>00355 <span class="comment"> * (*VL) points to a matrix of the right size.</span>
<a name="l00356"></a>00356 <span class="comment"> * <p> The following things are done: </span>
<a name="l00357"></a>00357 <span class="comment"> * <ol></span>
<a name="l00358"></a>00358 <span class="comment"> * <li> remove equalities involving only parameters, and remove as many</span>
<a name="l00359"></a>00359 <span class="comment"> * parameters as there are such equalities. From that, the list of</span>
<a name="l00360"></a>00360 <span class="comment"> * eliminated parameters <i>elimParms</i> is built.</span>
<a name="l00361"></a>00361 <span class="comment"> * <li> remove equalities that involve variables. This requires a compression</span>
<a name="l00362"></a>00362 <span class="comment"> * of the parameters and of the other variables that are not eliminated.</span>
<a name="l00363"></a>00363 <span class="comment"> * The affine compresson is represented by matrix VL (for <i>validity</span>
<a name="l00364"></a>00364 <span class="comment"> * lattice</i>) and is such that (N I 1)^T = VL.(N' I' 1), where N', I'</span>
<a name="l00365"></a>00365 <span class="comment"> * are integer (they are the parameters and variables after compression).</span>
<a name="l00366"></a>00366 <span class="comment"> *</ol></span>
<a name="l00367"></a>00367 <span class="comment"> *</p></span>
<a name="l00368"></a>00368 <span class="comment"> */</span>
<a name="l00369"></a><a class="code" href="compress__parms_8h.html#1a9cd66aec30116cfd3b07c2e38c73c8">00369</a> <span class="keywordtype">void</span> <a class="code" href="compress__parms_8c.html#1a9cd66aec30116cfd3b07c2e38c73c8" title="Eliminates all the equalities in a set of constraints and returns the set of constraints...">Constraints_fullDimensionize</a>(<a class="code" href="structmatrix.html">Matrix</a> ** M, <a class="code" href="structmatrix.html">Matrix</a> ** C, <a class="code" href="structmatrix.html">Matrix</a> ** VL,
<a name="l00370"></a>00370 <a class="code" href="structmatrix.html">Matrix</a> ** Eqs, <a class="code" href="structmatrix.html">Matrix</a> ** ParmEqs,
<a name="l00371"></a>00371 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ** elimVars,
<a name="l00372"></a>00372 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ** elimParms,
<a name="l00373"></a>00373 <span class="keywordtype">int</span> <a class="code" href="testCompressParms_8c.html#508eb31b6faa4939e1c32adaef41b8c8">maxRays</a>) {
<a name="l00374"></a>00374 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i, j;
<a name="l00375"></a>00375 <a class="code" href="structmatrix.html">Matrix</a> * A=NULL, *B=NULL;
<a name="l00376"></a>00376 <a class="code" href="structmatrix.html">Matrix</a> * Ineqs=NULL;
<a name="l00377"></a>00377 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nbVars = (*M)->NbColumns - (*C)->NbColumns;
<a name="l00378"></a>00378 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nbParms;
<a name="l00379"></a>00379 <span class="keywordtype">int</span> nbElimVars;
<a name="l00380"></a>00380 <a class="code" href="structmatrix.html">Matrix</a> * fullDim = NULL;
<a name="l00381"></a>00381
<a name="l00382"></a>00382 <span class="comment">/* variables for permutations */</span>
<a name="l00383"></a>00383 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> * permutation;
<a name="l00384"></a>00384 <a class="code" href="structmatrix.html">Matrix</a> * permutedEqs=NULL, * permutedIneqs=NULL;
<a name="l00385"></a>00385
<a name="l00386"></a>00386 <span class="comment">/* 1- Eliminate the equalities involving only parameters. */</span>
<a name="l00387"></a>00387 (*ParmEqs) = <a class="code" href="compress__parms_8h.html#374fb10257b4bbe7a650cff3945e338f">Constraints_removeParmEqs</a>(M, C, 0, elimParms);
<a name="l00388"></a>00388 <span class="comment">/* if the polyehdron is empty, return now. */</span>
<a name="l00389"></a>00389 <span class="keywordflow">if</span> ((*M)->NbColumns==0) <span class="keywordflow">return</span>;
<a name="l00390"></a>00390 <span class="comment">/* eliminate the columns corresponding to the eliminated parameters */</span>
<a name="l00391"></a>00391 <span class="keywordflow">if</span> (elimParms[0]!=0) {
<a name="l00392"></a>00392 <a class="code" href="compress__parms_8c.html#3efbee2cc61c1cfb2e0b05f3320a2e83" title="Eliminate the columns corresponding to a list of eliminated parameters.">Constraints_removeElimCols</a>(*M, nbVars, (*elimParms), &A);
<a name="l00393"></a>00393 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(*M);
<a name="l00394"></a>00394 (*M) = A;
<a name="l00395"></a>00395 <a class="code" href="compress__parms_8c.html#3efbee2cc61c1cfb2e0b05f3320a2e83" title="Eliminate the columns corresponding to a list of eliminated parameters.">Constraints_removeElimCols</a>(*C, 0, (*elimParms), &B);
<a name="l00396"></a>00396 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(*C);
<a name="l00397"></a>00397 (*C) = B;
<a name="l00398"></a>00398 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00399"></a>00399 printf(<span class="stringliteral">"After false parameter elimination: \n"</span>);
<a name="l00400"></a>00400 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(*M);
<a name="l00401"></a>00401 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(*C);
<a name="l00402"></a>00402 }
<a name="l00403"></a>00403 }
<a name="l00404"></a>00404 nbParms = (*C)->NbColumns-2;
<a name="l00405"></a>00405
<a name="l00406"></a>00406 <span class="comment">/* 2- Eliminate the equalities involving variables */</span>
<a name="l00407"></a>00407 <span class="comment">/* a- extract the (remaining) equalities from the poyhedron */</span>
<a name="l00408"></a>00408 <a class="code" href="matrix__addon_8c.html#288db1ffeb5425aada82cabf5c824bc4" title="splits a matrix of constraints M into a matrix of equalities Eqs and a matrix of...">split_constraints</a>((*M), Eqs, &Ineqs);
<a name="l00409"></a>00409 nbElimVars = (*Eqs)->NbRows;
<a name="l00410"></a>00410 <span class="comment">/* if the polyhedron is already full-dimensional, return */</span>
<a name="l00411"></a>00411 <span class="keywordflow">if</span> ((*Eqs)->NbRows==0) {
<a name="l00412"></a>00412 <a class="code" href="matrix__addon_8c.html#db1631ef2ddb3b386742b881b30f8ce6" title="returns the dim-dimensional identity matrix.">Matrix_identity</a>(nbParms+1, VL);
<a name="l00413"></a>00413 <span class="keywordflow">return</span>;
<a name="l00414"></a>00414 }
<a name="l00415"></a>00415 <span class="comment">/* b- choose variables to be eliminated */</span>
<a name="l00416"></a>00416 permutation = <a class="code" href="matrix__permutations_8c.html#f43c186b57b2df6caa02a812c175a4d1" title="finds a valid permutation : for a set of m equations, find m variables that will...">find_a_permutation</a>((*Eqs), nbParms);
<a name="l00417"></a>00417
<a name="l00418"></a>00418 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00419"></a>00419 printf(<span class="stringliteral">"Permuting the vars/parms this way: [ "</span>);
<a name="l00420"></a>00420 <span class="keywordflow">for</span> (i=0; i< (*Eqs)->NbColumns-2; i++) {
<a name="l00421"></a>00421 printf(<span class="stringliteral">"%d "</span>, permutation[i]);
<a name="l00422"></a>00422 }
<a name="l00423"></a>00423 printf(<span class="stringliteral">"]\n"</span>);
<a name="l00424"></a>00424 }
<a name="l00425"></a>00425
<a name="l00426"></a>00426 <a class="code" href="matrix__permutations_8c.html#1714c230c3b1785a1da3c38bcbf7e661" title="permutes the variables of the constraints of a polyhedron">Constraints_permute</a>((*Eqs), permutation, &permutedEqs);
<a name="l00427"></a>00427 <a class="code" href="compress__parms_8c.html#e018fc28835ce2d99a74dba09055acc0" title="Computes the validity lattice of a set of equalities.">Equalities_validityLattice</a>(permutedEqs, (*Eqs)-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>, VL);
<a name="l00428"></a>00428
<a name="l00429"></a>00429 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00430"></a>00430 printf(<span class="stringliteral">"Validity lattice: "</span>);
<a name="l00431"></a>00431 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(*VL);
<a name="l00432"></a>00432 }
<a name="l00433"></a>00433 <a class="code" href="matrix__addon_8h.html#9af03fc1d2667573752d7e593d8a50c3">Constraints_compressLastVars</a>(permutedEqs, (*VL));
<a name="l00434"></a>00434 <a class="code" href="matrix__permutations_8c.html#1714c230c3b1785a1da3c38bcbf7e661" title="permutes the variables of the constraints of a polyhedron">Constraints_permute</a>(Ineqs, permutation, &permutedIneqs);
<a name="l00435"></a>00435 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#964f66a0f36b5e1d0dea475066c53ca0">dbgCompParmMore</a>) {
<a name="l00436"></a>00436 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(permutedIneqs);
<a name="l00437"></a>00437 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(permutedEqs);
<a name="l00438"></a>00438 }
<a name="l00439"></a>00439 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(*Eqs);
<a name="l00440"></a>00440 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ineqs);
<a name="l00441"></a>00441 <a class="code" href="matrix__addon_8h.html#9af03fc1d2667573752d7e593d8a50c3">Constraints_compressLastVars</a>(permutedIneqs, (*VL));
<a name="l00442"></a>00442 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00443"></a>00443 printf(<span class="stringliteral">"After compression: "</span>);
<a name="l00444"></a>00444 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(permutedIneqs);
<a name="l00445"></a>00445 }
<a name="l00446"></a>00446 <span class="comment">/* c- eliminate the first variables */</span>
<a name="l00447"></a>00447 <a class="code" href="assert_8h.html#07d17d6d5d1074c0969bc5d3c3d1d84a">assert</a>(<a class="code" href="matrix__addon_8h.html#f4e227a2b50484a6befcc1e33933eb3a">Constraints_eliminateFirstVars</a>(permutedEqs, permutedIneqs));
<a name="l00448"></a>00448 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#964f66a0f36b5e1d0dea475066c53ca0">dbgCompParmMore</a>) {
<a name="l00449"></a>00449 printf(<span class="stringliteral">"After elimination of the variables: "</span>);
<a name="l00450"></a>00450 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(permutedIneqs);
<a name="l00451"></a>00451 }
<a name="l00452"></a>00452
<a name="l00453"></a>00453 <span class="comment">/* d- get rid of the first (zero) columns, </span>
<a name="l00454"></a>00454 <span class="comment"> which are now useless, and put the parameters back at the end */</span>
<a name="l00455"></a>00455 fullDim = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(permutedIneqs->NbRows,
<a name="l00456"></a>00456 permutedIneqs->NbColumns-nbElimVars);
<a name="l00457"></a>00457 <span class="keywordflow">for</span> (i=0; i< permutedIneqs->NbRows; i++) {
<a name="l00458"></a>00458 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(fullDim-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], 1);
<a name="l00459"></a>00459 <span class="keywordflow">for</span> (j=0; j< nbParms; j++) {
<a name="l00460"></a>00460 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>(fullDim-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j+fullDim-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-nbParms-1],
<a name="l00461"></a>00461 permutedIneqs->p[i][j+nbElimVars+1]);
<a name="l00462"></a>00462 }
<a name="l00463"></a>00463 <span class="keywordflow">for</span> (j=0; j< permutedIneqs->NbColumns-nbParms-2-nbElimVars; j++) {
<a name="l00464"></a>00464 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>(fullDim-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j+1],
<a name="l00465"></a>00465 permutedIneqs->p[i][nbElimVars+nbParms+j+1]);
<a name="l00466"></a>00466 }
<a name="l00467"></a>00467 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>(fullDim-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][fullDim-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1],
<a name="l00468"></a>00468 permutedIneqs->p[i][permutedIneqs->NbColumns-1]);
<a name="l00469"></a>00469 }
<a name="l00470"></a>00470 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(permutedIneqs);
<a name="l00471"></a>00471
<a name="l00472"></a>00472 } <span class="comment">/* Constraints_fullDimensionize */</span>
<a name="l00473"></a>00473
<a name="l00474"></a>00474 <span class="comment"></span>
<a name="l00475"></a>00475 <span class="comment">/**</span>
<a name="l00476"></a>00476 <span class="comment"> * Given a matrix that defines a full-dimensional affine lattice, returns the </span>
<a name="l00477"></a>00477 <span class="comment"> * affine sub-lattice spanned in the k first dimensions.</span>
<a name="l00478"></a>00478 <span class="comment"> * Useful for instance when you only look for the parameters' validity lattice.</span>
<a name="l00479"></a>00479 <span class="comment"> * @param lat the original full-dimensional lattice</span>
<a name="l00480"></a>00480 <span class="comment"> * @param subLat the sublattice</span>
<a name="l00481"></a>00481 <span class="comment"> */</span>
<a name="l00482"></a><a class="code" href="compress__parms_8h.html#9a39676ea22cef575c08911c95badba2">00482</a> <span class="keywordtype">void</span> <a class="code" href="compress__parms_8c.html#9a39676ea22cef575c08911c95badba2" title="Given a matrix that defines a full-dimensional affine lattice, returns the affine...">Lattice_extractSubLattice</a>(<a class="code" href="structmatrix.html">Matrix</a> * lat, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> k, <a class="code" href="structmatrix.html">Matrix</a> ** subLat) {
<a name="l00483"></a>00483 <a class="code" href="structmatrix.html">Matrix</a> * H, *Q, *U, *linLat = NULL;
<a name="l00484"></a>00484 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00485"></a>00485 <a class="code" href="compress__parms_8c.html#4df7b5873f125cf5c2976bbd4dcfe168">dbgStart</a>(<a class="code" href="compress__parms_8c.html#9a39676ea22cef575c08911c95badba2" title="Given a matrix that defines a full-dimensional affine lattice, returns the affine...">Lattice_extractSubLattice</a>);
<a name="l00486"></a>00486 <span class="comment">/* if the dimension is already good, just copy the initial lattice */</span>
<a name="l00487"></a>00487 <span class="keywordflow">if</span> (k==lat-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>-1) {
<a name="l00488"></a>00488 <span class="keywordflow">if</span> (*subLat==NULL) {
<a name="l00489"></a>00489 (*subLat) = <a class="code" href="Matop_8c.html#9d027e9fc6b85e6fa37fc284bf1b5e06">Matrix_Copy</a>(lat);
<a name="l00490"></a>00490 }
<a name="l00491"></a>00491 <span class="keywordflow">else</span> {
<a name="l00492"></a>00492 <a class="code" href="matrix__addon_8c.html#cb90cceb8e7a674a3d5796a1402f0c9e" title="Copies a contiguous submatrix of M1 into M2, at the indicated position.">Matrix_copySubMatrix</a>(lat, 0, 0, lat-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>, lat-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>, (*subLat), 0, 0);
<a name="l00493"></a>00493 }
<a name="l00494"></a>00494 <span class="keywordflow">return</span>;
<a name="l00495"></a>00495 }
<a name="l00496"></a>00496 <a class="code" href="assert_8h.html#07d17d6d5d1074c0969bc5d3c3d1d84a">assert</a>(k<lat->NbRows-1);
<a name="l00497"></a>00497 <span class="comment">/* 1- Make the linear part of the lattice triangular to eliminate terms from </span>
<a name="l00498"></a>00498 <span class="comment"> other dimensions */</span>
<a name="l00499"></a>00499 <a class="code" href="matrix__addon_8c.html#33fec91bb879b7b4dda814ad9d33f41b" title="returns a contiguous submatrix of a matrix.">Matrix_subMatrix</a>(lat, 0, 0, lat-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>, lat-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1, &linLat);
<a name="l00500"></a>00500 <span class="comment">/* OPT: any integer column-vector elimination is ok indeed. */</span>
<a name="l00501"></a>00501 <span class="comment">/* OPT: could test if the lattice is already in triangular form. */</span>
<a name="l00502"></a>00502 <a class="code" href="matrix_8c.html#dcbe5ee3f0c28fb35aed49f4e1f40f5b">left_hermite</a>(linLat, &H, &Q, &U);
<a name="l00503"></a>00503 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#964f66a0f36b5e1d0dea475066c53ca0">dbgCompParmMore</a>) {
<a name="l00504"></a>00504 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(H);
<a name="l00505"></a>00505 }
<a name="l00506"></a>00506 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Q);
<a name="l00507"></a>00507 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(U);
<a name="l00508"></a>00508 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(linLat);
<a name="l00509"></a>00509 <span class="comment">/* if not allocated yet, allocate it */</span>
<a name="l00510"></a>00510 <span class="keywordflow">if</span> (*subLat==NULL) {
<a name="l00511"></a>00511 (*subLat) = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(k+1, k+1);
<a name="l00512"></a>00512 }
<a name="l00513"></a>00513 <a class="code" href="matrix__addon_8c.html#cb90cceb8e7a674a3d5796a1402f0c9e" title="Copies a contiguous submatrix of M1 into M2, at the indicated position.">Matrix_copySubMatrix</a>(H, 0, 0, k, k, (*subLat), 0, 0);
<a name="l00514"></a>00514 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(H);
<a name="l00515"></a>00515 <a class="code" href="matrix__addon_8c.html#cb90cceb8e7a674a3d5796a1402f0c9e" title="Copies a contiguous submatrix of M1 into M2, at the indicated position.">Matrix_copySubMatrix</a>(lat, 0, lat-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1, k, 1, (*subLat), 0, k);
<a name="l00516"></a>00516 <span class="keywordflow">for</span> (i=0; i<k; i++) {
<a name="l00517"></a>00517 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>((*subLat)->p[k][i], 0);
<a name="l00518"></a>00518 }
<a name="l00519"></a>00519 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>((*subLat)->p[k][k], 1);
<a name="l00520"></a>00520 <a class="code" href="compress__parms_8c.html#49fcecacd32fa2357935cb5a4f542e0c">dbgEnd</a>(<a class="code" href="compress__parms_8c.html#9a39676ea22cef575c08911c95badba2" title="Given a matrix that defines a full-dimensional affine lattice, returns the affine...">Lattice_extractSubLattice</a>);
<a name="l00521"></a>00521 } <span class="comment">/* Lattice_extractSubLattice */</span>
<a name="l00522"></a>00522
<a name="l00523"></a>00523 <span class="comment"></span>
<a name="l00524"></a>00524 <span class="comment">/** </span>
<a name="l00525"></a>00525 <span class="comment"> * Computes the overall period of the variables I for (MI) mod |d|, where M is</span>
<a name="l00526"></a>00526 <span class="comment"> * a matrix and |d| a vector. Produce a diagonal matrix S = (s_k) where s_k is</span>
<a name="l00527"></a>00527 <span class="comment"> * the overall period of i_k </span>
<a name="l00528"></a>00528 <span class="comment"> * @param M the set of affine functions of I (row-vectors)</span>
<a name="l00529"></a>00529 <span class="comment"> * @param d the column-vector representing the modulos</span>
<a name="l00530"></a>00530 <span class="comment">*/</span>
<a name="l00531"></a><a class="code" href="compress__parms_8h.html#bfe5775031fc1fc8b783ef3a248a18b0">00531</a> <a class="code" href="structmatrix.html">Matrix</a> * <a class="code" href="compress__parms_8c.html#bfe5775031fc1fc8b783ef3a248a18b0" title="Computes the overall period of the variables I for (MI) mod |d|, where M is a matrix...">affine_periods</a>(<a class="code" href="structmatrix.html">Matrix</a> * M, <a class="code" href="structmatrix.html">Matrix</a> * d) {
<a name="l00532"></a>00532 <a class="code" href="structmatrix.html">Matrix</a> * S;
<a name="l00533"></a>00533 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i,j;
<a name="l00534"></a>00534 Value tmp;
<a name="l00535"></a>00535 Value * periods = (Value *)malloc(<span class="keyword">sizeof</span>(Value) * M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00536"></a>00536 <a class="code" href="source_2arith_2arithmetique_8h.html#f71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(tmp);
<a name="l00537"></a>00537 <span class="keywordflow">for</span>(i=0; i< M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>; i++) {
<a name="l00538"></a>00538 <a class="code" href="source_2arith_2arithmetique_8h.html#f71a2ca0294a19cff0cdcbdcc052ee27">value_init</a>(periods[i]);
<a name="l00539"></a>00539 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(periods[i], 1);
<a name="l00540"></a>00540 }
<a name="l00541"></a>00541 <span class="keywordflow">for</span> (i=0; i<M-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00542"></a>00542 <span class="keywordflow">for</span> (j=0; j< M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>; j++) {
<a name="l00543"></a>00543 <a class="code" href="source_2arith_2arithmetique_8h.html#50a34e78517e58cd1c2494a99be1e62b">value_gcd</a>(tmp, d-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j]);
<a name="l00544"></a>00544 <a class="code" href="source_2arith_2arithmetique_8h.html#4b01d50506e0c7691b69d57a87280f5d">value_divexact</a>(tmp, d-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], tmp);
<a name="l00545"></a>00545 <a class="code" href="source_2arith_2arithmetique_8h.html#6da13dbfdd065b7609591ff6b3aee310">value_lcm</a>(periods[j], periods[j], tmp);
<a name="l00546"></a>00546 }
<a name="l00547"></a>00547 }
<a name="l00548"></a>00548 <a class="code" href="source_2arith_2arithmetique_8h.html#b9b282921e85a0527d462d331533d619">value_clear</a>(tmp);
<a name="l00549"></a>00549
<a name="l00550"></a>00550 <span class="comment">/* 2- build S */</span>
<a name="l00551"></a>00551 S = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>, M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00552"></a>00552 <span class="keywordflow">for</span> (i=0; i< M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>; i++)
<a name="l00553"></a>00553 <span class="keywordflow">for</span> (j=0; j< M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>; j++)
<a name="l00554"></a>00554 <span class="keywordflow">if</span> (i==j) <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>(S-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j],periods[j]);
<a name="l00555"></a>00555 <span class="keywordflow">else</span> <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(S-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j], 0);
<a name="l00556"></a>00556
<a name="l00557"></a>00557 <span class="comment">/* 3- clean up */</span>
<a name="l00558"></a>00558 <span class="keywordflow">for</span>(i=0; i< M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>; i++) <a class="code" href="source_2arith_2arithmetique_8h.html#b9b282921e85a0527d462d331533d619">value_clear</a>(periods[i]);
<a name="l00559"></a>00559 free(periods);
<a name="l00560"></a>00560 <span class="keywordflow">return</span> S;
<a name="l00561"></a>00561 } <span class="comment">/* affine_periods */</span>
<a name="l00562"></a>00562
<a name="l00563"></a>00563 <span class="comment"></span>
<a name="l00564"></a>00564 <span class="comment">/** </span>
<a name="l00565"></a>00565 <span class="comment"> * Given an integer matrix B with m rows and integer m-vectors C and d,</span>
<a name="l00566"></a>00566 <span class="comment"> * computes the basis of the integer solutions to (BN+C) mod d = 0 (1).</span>
<a name="l00567"></a>00567 <span class="comment"> * This is an affine lattice (G): (N 1)^T= G(N' 1)^T, forall N' in Z^b.</span>
<a name="l00568"></a>00568 <span class="comment"> * If there is no solution, returns NULL.</span>
<a name="l00569"></a>00569 <span class="comment"> * @param B B, a (m x b) matrix</span>
<a name="l00570"></a>00570 <span class="comment"> * @param C C, a (m x 1) integer matrix</span>
<a name="l00571"></a>00571 <span class="comment"> * @param d d, a (1 x m) integer matrix</span>
<a name="l00572"></a>00572 <span class="comment"> * @param imb the affine (b+1)x(b+1) basis of solutions, in the homogeneous</span>
<a name="l00573"></a>00573 <span class="comment"> * form. Allocated if initially set to NULL, reused if not.</span>
<a name="l00574"></a>00574 <span class="comment">*/</span>
<a name="l00575"></a><a class="code" href="compress__parms_8h.html#12b7b863af43c3d85682b9df2385938c">00575</a> <span class="keywordtype">void</span> <a class="code" href="compress__parms_8c.html#12b7b863af43c3d85682b9df2385938c" title="Given an integer matrix B with m rows and integer m-vectors C and d, computes the...">Equalities_intModBasis</a>(<a class="code" href="structmatrix.html">Matrix</a> * B, <a class="code" href="structmatrix.html">Matrix</a> * C, <a class="code" href="structmatrix.html">Matrix</a> * d, <a class="code" href="structmatrix.html">Matrix</a> ** imb) {
<a name="l00576"></a>00576 <span class="keywordtype">int</span> b = B-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>;
<a name="l00577"></a>00577 <span class="comment">/* FIXME: treat the case d=0 as a regular equality B_kN+C_k = 0: */</span>
<a name="l00578"></a>00578 <span class="comment">/* OPT: could keep only equalities for which d>1 */</span>
<a name="l00579"></a>00579 <span class="keywordtype">int</span> nbEqs = B-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l00580"></a>00580 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00581"></a>00581
<a name="l00582"></a>00582 <span class="comment">/* 1- buid the problem DI+BN+C = 0 */</span>
<a name="l00583"></a>00583 <a class="code" href="structmatrix.html">Matrix</a> * eqs = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(nbEqs, nbEqs+b+1);
<a name="l00584"></a>00584 <span class="keywordflow">for</span> (i=0; i< nbEqs; i++) {
<a name="l00585"></a>00585 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>(eqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][i], d-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[0][i]);
<a name="l00586"></a>00586 }
<a name="l00587"></a>00587 <a class="code" href="matrix__addon_8c.html#cb90cceb8e7a674a3d5796a1402f0c9e" title="Copies a contiguous submatrix of M1 into M2, at the indicated position.">Matrix_copySubMatrix</a>(B, 0, 0, nbEqs, b, eqs, 0, nbEqs);
<a name="l00588"></a>00588 <a class="code" href="matrix__addon_8c.html#cb90cceb8e7a674a3d5796a1402f0c9e" title="Copies a contiguous submatrix of M1 into M2, at the indicated position.">Matrix_copySubMatrix</a>(C, 0, 0, nbEqs, 1, eqs, 0, nbEqs+b);
<a name="l00589"></a>00589
<a name="l00590"></a>00590 <span class="comment">/* 2- the solution is the validity lattice of the equalities */</span>
<a name="l00591"></a>00591 <a class="code" href="compress__parms_8c.html#e018fc28835ce2d99a74dba09055acc0" title="Computes the validity lattice of a set of equalities.">Equalities_validityLattice</a>(eqs, nbEqs, imb);
<a name="l00592"></a>00592 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(eqs);
<a name="l00593"></a>00593 } <span class="comment">/* Equalities_intModBasis */</span>
<a name="l00594"></a>00594
<a name="l00595"></a>00595 <span class="comment"></span>
<a name="l00596"></a>00596 <span class="comment">/** kept here for backwards compatiblity. Wrapper to Equalities_intModBasis() */</span>
<a name="l00597"></a><a class="code" href="compress__parms_8h.html#fdd668f63e1141067dc0caef3ef03374">00597</a> <a class="code" href="structmatrix.html">Matrix</a> * <a class="code" href="compress__parms_8c.html#091ae8062b33511134d13b0035a56777" title="kept here for backwards compatiblity.">int_mod_basis</a>(<a class="code" href="structmatrix.html">Matrix</a> * B, <a class="code" href="structmatrix.html">Matrix</a> * C, <a class="code" href="structmatrix.html">Matrix</a> * d) {
<a name="l00598"></a>00598 <a class="code" href="structmatrix.html">Matrix</a> * imb = NULL;
<a name="l00599"></a>00599 <a class="code" href="compress__parms_8c.html#12b7b863af43c3d85682b9df2385938c" title="Given an integer matrix B with m rows and integer m-vectors C and d, computes the...">Equalities_intModBasis</a>(B, C, d, &imb);
<a name="l00600"></a>00600 <span class="keywordflow">return</span> imb;
<a name="l00601"></a>00601 } <span class="comment">/* int_mod_basis */</span>
<a name="l00602"></a>00602
<a name="l00603"></a>00603 <span class="comment"></span>
<a name="l00604"></a>00604 <span class="comment">/**</span>
<a name="l00605"></a>00605 <span class="comment"> * Given a parameterized constraints matrix with m equalities, computes the</span>
<a name="l00606"></a>00606 <span class="comment"> * compression matrix G such that there is an integer solution in the variables</span>
<a name="l00607"></a>00607 <span class="comment"> * space for each value of N', with N = G N' (N are the "nb_parms" parameters)</span>
<a name="l00608"></a>00608 <span class="comment"> * @param E a matrix of parametric equalities @param nb_parms the number of</span>
<a name="l00609"></a>00609 <span class="comment"> * parameters</span>
<a name="l00610"></a>00610 <span class="comment"> * <b>Note: </b>this function is mostly here for backwards</span>
<a name="l00611"></a>00611 <span class="comment"> * compatibility. Prefer the use of <tt>Equalities_validityLattice</tt>.</span>
<a name="l00612"></a>00612 <span class="comment">*/</span>
<a name="l00613"></a><a class="code" href="compress__parms_8h.html#3cec7363dc147b76f23dea6738a10161">00613</a> <a class="code" href="structmatrix.html">Matrix</a> * <a class="code" href="compress__parms_8c.html#4877b02bfffc51db4d9ac702475c3765" title="Given a parameterized constraints matrix with m equalities, computes the compression...">compress_parms</a>(<a class="code" href="structmatrix.html">Matrix</a> * E, <span class="keywordtype">int</span> nbParms) {
<a name="l00614"></a>00614 <a class="code" href="structmatrix.html">Matrix</a> * vl=NULL;
<a name="l00615"></a>00615 <a class="code" href="compress__parms_8c.html#e018fc28835ce2d99a74dba09055acc0" title="Computes the validity lattice of a set of equalities.">Equalities_validityLattice</a>(E, E-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2-nbParms, &vl);
<a name="l00616"></a>00616 <span class="keywordflow">return</span> vl;
<a name="l00617"></a>00617 }<span class="comment">/* compress_parms */</span>
<a name="l00618"></a>00618
<a name="l00619"></a>00619 <span class="comment"></span>
<a name="l00620"></a>00620 <span class="comment">/** Removes the equalities that involve only parameters, by eliminating some</span>
<a name="l00621"></a>00621 <span class="comment"> * parameters in the polyhedron's constraints and in the context.<p> </span>
<a name="l00622"></a>00622 <span class="comment"> * <b>Updates M and Ctxt.</b></span>
<a name="l00623"></a>00623 <span class="comment"> * @param M1 the polyhedron's constraints</span>
<a name="l00624"></a>00624 <span class="comment"> * @param Ctxt1 the constraints of the polyhedron's context</span>
<a name="l00625"></a>00625 <span class="comment"> * @param renderSpace tells if the returned equalities must be expressed in the</span>
<a name="l00626"></a>00626 <span class="comment"> * parameters space (renderSpace=0) or in the combined var/parms space</span>
<a name="l00627"></a>00627 <span class="comment"> * (renderSpace = 1)</span>
<a name="l00628"></a>00628 <span class="comment"> * @param elimParms the list of parameters that have been removed: an array</span>
<a name="l00629"></a>00629 <span class="comment"> * whose 1st element is the number of elements in the list. (returned)</span>
<a name="l00630"></a>00630 <span class="comment"> * @return the system of equalities that involve only parameters.</span>
<a name="l00631"></a>00631 <span class="comment"> */</span>
<a name="l00632"></a><a class="code" href="compress__parms_8h.html#1d7622dc1bb2a0f564af26632797b0d2">00632</a> <a class="code" href="structmatrix.html">Matrix</a> * <a class="code" href="compress__parms_8c.html#ca0035f9313236fd8046ab042180f544" title="Removes the equalities that involve only parameters, by eliminating some parameters...">Constraints_Remove_parm_eqs</a>(<a class="code" href="structmatrix.html">Matrix</a> ** M1, <a class="code" href="structmatrix.html">Matrix</a> ** Ctxt1,
<a name="l00633"></a>00633 <span class="keywordtype">int</span> renderSpace,
<a name="l00634"></a>00634 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ** elimParms) {
<a name="l00635"></a>00635 <span class="keywordtype">int</span> i, j, k, nbEqsParms =0;
<a name="l00636"></a>00636 <span class="keywordtype">int</span> nbEqsM, nbEqsCtxt, allZeros, nbTautoM = 0, nbTautoCtxt = 0;
<a name="l00637"></a>00637 <a class="code" href="structmatrix.html">Matrix</a> * M = (*M1);
<a name="l00638"></a>00638 <a class="code" href="structmatrix.html">Matrix</a> * Ctxt = (*Ctxt1);
<a name="l00639"></a>00639 <span class="keywordtype">int</span> nbVars = M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>;
<a name="l00640"></a>00640 <a class="code" href="structmatrix.html">Matrix</a> * Eqs;
<a name="l00641"></a>00641 <a class="code" href="structmatrix.html">Matrix</a> * EqsMTmp;
<a name="l00642"></a>00642
<a name="l00643"></a>00643 <span class="comment">/* 1- build the equality matrix(ces) */</span>
<a name="l00644"></a>00644 nbEqsM = 0;
<a name="l00645"></a>00645 <span class="keywordflow">for</span> (i=0; i< M-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00646"></a>00646 k = <a class="code" href="vector_8c.html#b719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00647"></a>00647 <span class="comment">/* if it is a tautology, count it as such */</span>
<a name="l00648"></a>00648 <span class="keywordflow">if</span> (k==-1) {
<a name="l00649"></a>00649 nbTautoM++;
<a name="l00650"></a>00650 }
<a name="l00651"></a>00651 <span class="keywordflow">else</span> {
<a name="l00652"></a>00652 <span class="comment">/* if it only involves parameters, count it */</span>
<a name="l00653"></a>00653 <span class="keywordflow">if</span> (k>= nbVars+1) nbEqsM++;
<a name="l00654"></a>00654 }
<a name="l00655"></a>00655 }
<a name="l00656"></a>00656
<a name="l00657"></a>00657 nbEqsCtxt = 0;
<a name="l00658"></a>00658 <span class="keywordflow">for</span> (i=0; i< Ctxt-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00659"></a>00659 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Ctxt-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0])) {
<a name="l00660"></a>00660 <span class="keywordflow">if</span> (<a class="code" href="vector_8c.html#b719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(Ctxt-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>)==-1) {
<a name="l00661"></a>00661 nbTautoCtxt++;
<a name="l00662"></a>00662 }
<a name="l00663"></a>00663 <span class="keywordflow">else</span> {
<a name="l00664"></a>00664 nbEqsCtxt ++;
<a name="l00665"></a>00665 }
<a name="l00666"></a>00666 }
<a name="l00667"></a>00667 }
<a name="l00668"></a>00668 nbEqsParms = nbEqsM + nbEqsCtxt;
<a name="l00669"></a>00669
<a name="l00670"></a>00670 <span class="comment">/* nothing to do in this case */</span>
<a name="l00671"></a>00671 <span class="keywordflow">if</span> (nbEqsParms+nbTautoM+nbTautoCtxt==0) {
<a name="l00672"></a>00672 (*elimParms) = (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>*) malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));
<a name="l00673"></a>00673 (*elimParms)[0] = 0;
<a name="l00674"></a>00674 <span class="keywordflow">if</span> (renderSpace==0) {
<a name="l00675"></a>00675 <span class="keywordflow">return</span> <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(0,Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00676"></a>00676 }
<a name="l00677"></a>00677 <span class="keywordflow">else</span> {
<a name="l00678"></a>00678 <span class="keywordflow">return</span> <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(0,M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00679"></a>00679 }
<a name="l00680"></a>00680 }
<a name="l00681"></a>00681
<a name="l00682"></a>00682 Eqs= <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(nbEqsParms, Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00683"></a>00683 EqsMTmp= <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(nbEqsParms, M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00684"></a>00684
<a name="l00685"></a>00685 <span class="comment">/* copy equalities from the context */</span>
<a name="l00686"></a>00686 k = 0;
<a name="l00687"></a>00687 <span class="keywordflow">for</span> (i=0; i< Ctxt-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00688"></a>00688 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#827532f2140ae2aa96e46baebae09723">value_zero_p</a>(Ctxt-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0])
<a name="l00689"></a>00689 && <a class="code" href="vector_8c.html#b719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(Ctxt-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>)!=-1) {
<a name="l00690"></a>00690 <a class="code" href="vector_8c.html#b6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Ctxt-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], Eqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k], Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00691"></a>00691 <a class="code" href="vector_8c.html#b6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Ctxt-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i]+1, EqsMTmp-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k]+nbVars+1,
<a name="l00692"></a>00692 Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1);
<a name="l00693"></a>00693 k++;
<a name="l00694"></a>00694 }
<a name="l00695"></a>00695 }
<a name="l00696"></a>00696 <span class="keywordflow">for</span> (i=0; i< M-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00697"></a>00697 j=<a class="code" href="vector_8c.html#b719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00698"></a>00698 <span class="comment">/* copy equalities that involve only parameters from M */</span>
<a name="l00699"></a>00699 <span class="keywordflow">if</span> (j>=nbVars+1) {
<a name="l00700"></a>00700 <a class="code" href="vector_8c.html#b6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i]+nbVars+1, Eqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k]+1, Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1);
<a name="l00701"></a>00701 <a class="code" href="vector_8c.html#b6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i]+nbVars+1, EqsMTmp-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k]+nbVars+1,
<a name="l00702"></a>00702 Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1);
<a name="l00703"></a>00703 <span class="comment">/* mark these equalities for removal */</span>
<a name="l00704"></a>00704 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], 2);
<a name="l00705"></a>00705 k++;
<a name="l00706"></a>00706 }
<a name="l00707"></a>00707 <span class="comment">/* mark the all-zero equalities for removal */</span>
<a name="l00708"></a>00708 <span class="keywordflow">if</span> (j==-1) {
<a name="l00709"></a>00709 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], 2);
<a name="l00710"></a>00710 }
<a name="l00711"></a>00711 }
<a name="l00712"></a>00712
<a name="l00713"></a>00713 <span class="comment">/* 2- eliminate parameters until all equalities are used or until we find a</span>
<a name="l00714"></a>00714 <span class="comment"> contradiction (overconstrained system) */</span>
<a name="l00715"></a>00715 (*elimParms) = (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *) malloc((Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>+1) * <span class="keyword">sizeof</span>(int));
<a name="l00716"></a>00716 (*elimParms)[0] = 0;
<a name="l00717"></a>00717 allZeros = 0;
<a name="l00718"></a>00718 <span class="keywordflow">for</span> (i=0; i< Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00719"></a>00719 <span class="comment">/* find a variable that can be eliminated */</span>
<a name="l00720"></a>00720 k = <a class="code" href="vector_8c.html#b719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(Eqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00721"></a>00721 <span class="keywordflow">if</span> (k!=-1) { <span class="comment">/* nothing special to do for tautologies */</span>
<a name="l00722"></a>00722
<a name="l00723"></a>00723 <span class="comment">/* if there is a contradiction, return empty matrices */</span>
<a name="l00724"></a>00724 <span class="keywordflow">if</span> (k==Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1) {
<a name="l00725"></a>00725 printf(<span class="stringliteral">"Contradiction in %dth row of Eqs: "</span>,k);
<a name="l00726"></a>00726 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(Eqs);
<a name="l00727"></a>00727 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Eqs);
<a name="l00728"></a>00728 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(EqsMTmp);
<a name="l00729"></a>00729 (*M1) = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(0, M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00730"></a>00730 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(M);
<a name="l00731"></a>00731 (*Ctxt1) = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(0,Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00732"></a>00732 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ctxt);
<a name="l00733"></a>00733 free(*elimParms);
<a name="l00734"></a>00734 (*elimParms) = (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *) malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));
<a name="l00735"></a>00735 (*elimParms)[0] = 0;
<a name="l00736"></a>00736 <span class="keywordflow">if</span> (renderSpace==1) {
<a name="l00737"></a>00737 <span class="keywordflow">return</span> <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(0,(*M1)->NbColumns);
<a name="l00738"></a>00738 }
<a name="l00739"></a>00739 <span class="keywordflow">else</span> {
<a name="l00740"></a>00740 <span class="keywordflow">return</span> <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(0,(*Ctxt1)->NbColumns);
<a name="l00741"></a>00741 }
<a name="l00742"></a>00742 }
<a name="l00743"></a>00743 <span class="comment">/* if we have something we can eliminate, do it in 3 places:</span>
<a name="l00744"></a>00744 <span class="comment"> Eqs, Ctxt, and M */</span>
<a name="l00745"></a>00745 <span class="keywordflow">else</span> {
<a name="l00746"></a>00746 k--; <span class="comment">/* k is the rank of the variable, now */</span>
<a name="l00747"></a>00747 (*elimParms)[0]++;
<a name="l00748"></a>00748 (*elimParms)[(*elimParms[0])]=k;
<a name="l00749"></a>00749 <span class="keywordflow">for</span> (j=0; j< Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; j++) {
<a name="l00750"></a>00750 <span class="keywordflow">if</span> (i!=j) {
<a name="l00751"></a>00751 <a class="code" href="matrix__addon_8c.html#79d19aa329285819b31bc7a602241842" title="use an eliminator row to eliminate a variable in a victim row (without changing the...">eliminate_var_with_constr</a>(Eqs, i, Eqs, j, k);
<a name="l00752"></a>00752 <a class="code" href="matrix__addon_8c.html#79d19aa329285819b31bc7a602241842" title="use an eliminator row to eliminate a variable in a victim row (without changing the...">eliminate_var_with_constr</a>(EqsMTmp, i, EqsMTmp, j, k+nbVars);
<a name="l00753"></a>00753 }
<a name="l00754"></a>00754 }
<a name="l00755"></a>00755 <span class="keywordflow">for</span> (j=0; j< Ctxt-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; j++) {
<a name="l00756"></a>00756 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Ctxt-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0])) {
<a name="l00757"></a>00757 <a class="code" href="matrix__addon_8c.html#79d19aa329285819b31bc7a602241842" title="use an eliminator row to eliminate a variable in a victim row (without changing the...">eliminate_var_with_constr</a>(Eqs, i, Ctxt, j, k);
<a name="l00758"></a>00758 }
<a name="l00759"></a>00759 }
<a name="l00760"></a>00760 <span class="keywordflow">for</span> (j=0; j< M-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; j++) {
<a name="l00761"></a>00761 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#fee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], 2)) {
<a name="l00762"></a>00762 <a class="code" href="matrix__addon_8c.html#79d19aa329285819b31bc7a602241842" title="use an eliminator row to eliminate a variable in a victim row (without changing the...">eliminate_var_with_constr</a>(EqsMTmp, i, M, j, k+nbVars);
<a name="l00763"></a>00763 }
<a name="l00764"></a>00764 }
<a name="l00765"></a>00765 }
<a name="l00766"></a>00766 }
<a name="l00767"></a>00767 <span class="comment">/* if (k==-1): count the tautologies in Eqs to remove them later */</span>
<a name="l00768"></a>00768 <span class="keywordflow">else</span> {
<a name="l00769"></a>00769 allZeros++;
<a name="l00770"></a>00770 }
<a name="l00771"></a>00771 }
<a name="l00772"></a>00772
<a name="l00773"></a>00773 <span class="comment">/* elimParms may have been overallocated. Now we know how many parms have</span>
<a name="l00774"></a>00774 <span class="comment"> been eliminated so we can reallocate the right amount of memory. */</span>
<a name="l00775"></a>00775 <span class="keywordflow">if</span> (!realloc((*elimParms), ((*elimParms)[0]+1)*<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>))) {
<a name="l00776"></a>00776 fprintf(stderr, <span class="stringliteral">"Constraints_Remove_parm_eqs > cannot realloc()"</span>);
<a name="l00777"></a>00777 }
<a name="l00778"></a>00778
<a name="l00779"></a>00779 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(EqsMTmp);
<a name="l00780"></a>00780
<a name="l00781"></a>00781 <span class="comment">/* 3- remove the "bad" equalities from the input matrices</span>
<a name="l00782"></a>00782 <span class="comment"> and copy the equalities involving only parameters */</span>
<a name="l00783"></a>00783 EqsMTmp = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(M-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>-nbEqsM-nbTautoM, M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00784"></a>00784 k=0;
<a name="l00785"></a>00785 <span class="keywordflow">for</span> (i=0; i< M-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00786"></a>00786 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#fee537d2d3f20ba6a656fe84ce54c6ce">value_cmp_si</a>(M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], 2)) {
<a name="l00787"></a>00787 <a class="code" href="vector_8c.html#b6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(M-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], EqsMTmp-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k], M-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00788"></a>00788 k++;
<a name="l00789"></a>00789 }
<a name="l00790"></a>00790 }
<a name="l00791"></a>00791 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(M);
<a name="l00792"></a>00792 (*M1) = EqsMTmp;
<a name="l00793"></a>00793
<a name="l00794"></a>00794 EqsMTmp = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(Ctxt-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>-nbEqsCtxt-nbTautoCtxt, Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00795"></a>00795 k=0;
<a name="l00796"></a>00796 <span class="keywordflow">for</span> (i=0; i< Ctxt-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00797"></a>00797 <span class="keywordflow">if</span> (<a class="code" href="source_2arith_2arithmetique_8h.html#47d32925340d2dc99ef2d4215080a60d">value_notzero_p</a>(Ctxt-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0])) {
<a name="l00798"></a>00798 <a class="code" href="vector_8c.html#b6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Ctxt-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], EqsMTmp-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k], Ctxt-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00799"></a>00799 k++;
<a name="l00800"></a>00800 }
<a name="l00801"></a>00801 }
<a name="l00802"></a>00802 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ctxt);
<a name="l00803"></a>00803 (*Ctxt1) = EqsMTmp;
<a name="l00804"></a>00804
<a name="l00805"></a>00805 <span class="keywordflow">if</span> (renderSpace==0) {<span class="comment">/* renderSpace=0: equalities in the parameter space */</span>
<a name="l00806"></a>00806 EqsMTmp = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>-allZeros, Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00807"></a>00807 k=0;
<a name="l00808"></a>00808 <span class="keywordflow">for</span> (i=0; i<Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00809"></a>00809 <span class="keywordflow">if</span> (<a class="code" href="vector_8c.html#b719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(Eqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>)!=-1) {
<a name="l00810"></a>00810 <a class="code" href="vector_8c.html#b6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Eqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], EqsMTmp-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k], Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00811"></a>00811 k++;
<a name="l00812"></a>00812 }
<a name="l00813"></a>00813 }
<a name="l00814"></a>00814 }
<a name="l00815"></a>00815 <span class="keywordflow">else</span> {<span class="comment">/* renderSpace=1: equalities rendered in the combined space */</span>
<a name="l00816"></a>00816 EqsMTmp = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>-allZeros, (*M1)->NbColumns);
<a name="l00817"></a>00817 k=0;
<a name="l00818"></a>00818 <span class="keywordflow">for</span> (i=0; i<Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00819"></a>00819 <span class="keywordflow">if</span> (<a class="code" href="vector_8c.html#b719ec10095622cd0ad8024da53cdd4c">First_Non_Zero</a>(Eqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>)!=-1) {
<a name="l00820"></a>00820 <a class="code" href="vector_8c.html#b6eca9ad03a2f4a60dd79182289e0e0b">Vector_Copy</a>(Eqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i], &(EqsMTmp-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[k][nbVars]), Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>);
<a name="l00821"></a>00821 k++;
<a name="l00822"></a>00822 }
<a name="l00823"></a>00823 }
<a name="l00824"></a>00824 }
<a name="l00825"></a>00825 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Eqs);
<a name="l00826"></a>00826 Eqs = EqsMTmp;
<a name="l00827"></a>00827
<a name="l00828"></a>00828 <span class="keywordflow">return</span> Eqs;
<a name="l00829"></a>00829 } <span class="comment">/* Constraints_Remove_parm_eqs */</span>
<a name="l00830"></a>00830
<a name="l00831"></a>00831 <span class="comment"></span>
<a name="l00832"></a>00832 <span class="comment">/** Removes equalities involving only parameters, but starting from a</span>
<a name="l00833"></a>00833 <span class="comment"> * Polyhedron and its context.</span>
<a name="l00834"></a>00834 <span class="comment"> * @param P the polyhedron</span>
<a name="l00835"></a>00835 <span class="comment"> * @param C P's context</span>
<a name="l00836"></a>00836 <span class="comment"> * @param renderSpace: 0 for the parameter space, =1 for the combined space.</span>
<a name="l00837"></a>00837 <span class="comment"> * @maxRays Polylib's usual <i>workspace</i>.</span>
<a name="l00838"></a>00838 <span class="comment"> */</span>
<a name="l00839"></a><a class="code" href="compress__parms_8h.html#86df15994f14c73d49980bbf61f6f7e5">00839</a> <a class="code" href="structpolyhedron.html">Polyhedron</a> * <a class="code" href="compress__parms_8c.html#86df15994f14c73d49980bbf61f6f7e5" title="Removes equalities involving only parameters, but starting from a Polyhedron and...">Polyhedron_Remove_parm_eqs</a>(<a class="code" href="structpolyhedron.html">Polyhedron</a> ** P, <a class="code" href="structpolyhedron.html">Polyhedron</a> ** C,
<a name="l00840"></a>00840 <span class="keywordtype">int</span> renderSpace,
<a name="l00841"></a>00841 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ** elimParms,
<a name="l00842"></a>00842 <span class="keywordtype">int</span> <a class="code" href="testCompressParms_8c.html#508eb31b6faa4939e1c32adaef41b8c8">maxRays</a>) {
<a name="l00843"></a>00843 <a class="code" href="structmatrix.html">Matrix</a> * Eqs;
<a name="l00844"></a>00844 <a class="code" href="structpolyhedron.html">Polyhedron</a> * Peqs;
<a name="l00845"></a>00845 <a class="code" href="structmatrix.html">Matrix</a> * M = <a class="code" href="polyhedron_8c.html#69417a994cd682d0c391ecff6d223cd2">Polyhedron2Constraints</a>((*P));
<a name="l00846"></a>00846 <a class="code" href="structmatrix.html">Matrix</a> * Ct = <a class="code" href="polyhedron_8c.html#69417a994cd682d0c391ecff6d223cd2">Polyhedron2Constraints</a>((*C));
<a name="l00847"></a>00847
<a name="l00848"></a>00848 <span class="comment">/* if the Minkowski representation is not computed yet, do not compute it in</span>
<a name="l00849"></a>00849 <span class="comment"> Constraints2Polyhedron */</span>
<a name="l00850"></a>00850 <span class="keywordflow">if</span> (<a class="code" href="types_8h.html#19f1ae711bb0e3063ba1962cb8a898a0">F_ISSET</a>((*P), <a class="code" href="types_8h.html#2ac4c28a3acbe4578e03ad20db7939cc">POL_VALID</a> | <a class="code" href="types_8h.html#1869e11b8e9a1e9e89e8145c242e0eea">POL_INEQUALITIES</a>) &&
<a name="l00851"></a>00851 (<a class="code" href="types_8h.html#19f1ae711bb0e3063ba1962cb8a898a0">F_ISSET</a>((*C), <a class="code" href="types_8h.html#2ac4c28a3acbe4578e03ad20db7939cc">POL_VALID</a> | <a class="code" href="types_8h.html#1869e11b8e9a1e9e89e8145c242e0eea">POL_INEQUALITIES</a>))) {
<a name="l00852"></a>00852 <a class="code" href="types_8h.html#cd3e6da08aea98ada4bad87b9a63a4e0">FL_INIT</a>(maxRays, <a class="code" href="types_8h.html#754586a0aee88f21ad4c98b1cddee1be">POL_NO_DUAL</a>);
<a name="l00853"></a>00853 }
<a name="l00854"></a>00854
<a name="l00855"></a>00855 Eqs = <a class="code" href="compress__parms_8c.html#ca0035f9313236fd8046ab042180f544" title="Removes the equalities that involve only parameters, by eliminating some parameters...">Constraints_Remove_parm_eqs</a>(&M, &Ct, renderSpace, elimParms);
<a name="l00856"></a>00856 Peqs = <a class="code" href="polyhedron_8c.html#efb77665a187d751bdd44f106b12465e" title="Given a matrix of constraints (&#39;Constraints&#39;), construct and return a polyhedron...">Constraints2Polyhedron</a>(Eqs, maxRays);
<a name="l00857"></a>00857 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Eqs);
<a name="l00858"></a>00858
<a name="l00859"></a>00859 <span class="comment">/* particular case: no equality involving only parms is found */</span>
<a name="l00860"></a>00860 <span class="keywordflow">if</span> (Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>==0) {
<a name="l00861"></a>00861 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(M);
<a name="l00862"></a>00862 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ct);
<a name="l00863"></a>00863 <span class="keywordflow">return</span> Peqs;
<a name="l00864"></a>00864 }
<a name="l00865"></a>00865 <a class="code" href="polyhedron_8c.html#4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(*P);
<a name="l00866"></a>00866 <a class="code" href="polyhedron_8c.html#4ae97b9794e3a616f1d38c68e6515cc3">Polyhedron_Free</a>(*C);
<a name="l00867"></a>00867 (*P) = <a class="code" href="polyhedron_8c.html#efb77665a187d751bdd44f106b12465e" title="Given a matrix of constraints (&#39;Constraints&#39;), construct and return a polyhedron...">Constraints2Polyhedron</a>(M, maxRays);
<a name="l00868"></a>00868 (*C) = <a class="code" href="polyhedron_8c.html#efb77665a187d751bdd44f106b12465e" title="Given a matrix of constraints (&#39;Constraints&#39;), construct and return a polyhedron...">Constraints2Polyhedron</a>(Ct, maxRays);
<a name="l00869"></a>00869 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(M);
<a name="l00870"></a>00870 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ct);
<a name="l00871"></a>00871 <span class="keywordflow">return</span> Peqs;
<a name="l00872"></a>00872 } <span class="comment">/* Polyhedron_Remove_parm_eqs */</span>
<a name="l00873"></a>00873
<a name="l00874"></a>00874 <span class="comment"></span>
<a name="l00875"></a>00875 <span class="comment">/**</span>
<a name="l00876"></a>00876 <span class="comment"> * Given a matrix with m parameterized equations, compress the nb_parms</span>
<a name="l00877"></a>00877 <span class="comment"> * parameters and n-m variables so that m variables are integer, and transform</span>
<a name="l00878"></a>00878 <span class="comment"> * the variable space into a n-m space by eliminating the m variables (using</span>
<a name="l00879"></a>00879 <span class="comment"> * the equalities) the variables to be eliminated are chosen automatically by</span>
<a name="l00880"></a>00880 <span class="comment"> * the function.</span>
<a name="l00881"></a>00881 <span class="comment"> * <b>Deprecated.</b> Try to use Constraints_fullDimensionize instead.</span>
<a name="l00882"></a>00882 <span class="comment"> * @param M the constraints </span>
<a name="l00883"></a>00883 <span class="comment"> * @param the number of parameters</span>
<a name="l00884"></a>00884 <span class="comment"> * @param validityLattice the the integer lattice underlying the integer</span>
<a name="l00885"></a>00885 <span class="comment"> * solutions.</span>
<a name="l00886"></a>00886 <span class="comment">*/</span>
<a name="l00887"></a><a class="code" href="compress__parms_8h.html#16589dade8bf119ae773e7991adc83ae">00887</a> <a class="code" href="structmatrix.html">Matrix</a> * <a class="code" href="compress__parms_8c.html#b67657b853a34d82fdc72a3f771bc72c" title="Given a matrix with m parameterized equations, compress the nb_parms parameters and...">full_dimensionize</a>(<a class="code" href="structmatrix.html">Matrix</a> <span class="keyword">const</span> * M, <span class="keywordtype">int</span> nbParms,
<a name="l00888"></a>00888 <a class="code" href="structmatrix.html">Matrix</a> ** validityLattice) {
<a name="l00889"></a>00889 <a class="code" href="structmatrix.html">Matrix</a> * Eqs, * Ineqs;
<a name="l00890"></a>00890 <a class="code" href="structmatrix.html">Matrix</a> * permutedEqs, * permutedIneqs;
<a name="l00891"></a>00891 <a class="code" href="structmatrix.html">Matrix</a> * Full_Dim;
<a name="l00892"></a>00892 <a class="code" href="structmatrix.html">Matrix</a> * WVL; <span class="comment">/* The Whole Validity Lattice (vars+parms) */</span>
<a name="l00893"></a>00893 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i,j;
<a name="l00894"></a>00894 <span class="keywordtype">int</span> nbElimVars;
<a name="l00895"></a>00895 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> * permutation, * permutationInv;
<a name="l00896"></a>00896 <span class="comment">/* 0- Split the equalities and inequalities from each other */</span>
<a name="l00897"></a>00897 <a class="code" href="matrix__addon_8c.html#288db1ffeb5425aada82cabf5c824bc4" title="splits a matrix of constraints M into a matrix of equalities Eqs and a matrix of...">split_constraints</a>(M, &Eqs, &Ineqs);
<a name="l00898"></a>00898
<a name="l00899"></a>00899 <span class="comment">/* 1- if the polyhedron is already full-dimensional, return it */</span>
<a name="l00900"></a>00900 <span class="keywordflow">if</span> (Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>==0) {
<a name="l00901"></a>00901 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Eqs);
<a name="l00902"></a>00902 (*validityLattice) = <a class="code" href="matrix__addon_8c.html#33f64eb039ac943c1bddbafc3be3ece6">Identity_Matrix</a>(nbParms+1);
<a name="l00903"></a>00903 <span class="keywordflow">return</span> Ineqs;
<a name="l00904"></a>00904 }
<a name="l00905"></a>00905 nbElimVars = Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>;
<a name="l00906"></a>00906
<a name="l00907"></a>00907 <span class="comment">/* 2- put the vars to be eliminated at the first positions, </span>
<a name="l00908"></a>00908 <span class="comment"> and compress the other vars/parms</span>
<a name="l00909"></a>00909 <span class="comment"> -> [ variables to eliminate / parameters / variables to keep ] */</span>
<a name="l00910"></a>00910 permutation = <a class="code" href="matrix__permutations_8c.html#f43c186b57b2df6caa02a812c175a4d1" title="finds a valid permutation : for a set of m equations, find m variables that will...">find_a_permutation</a>(Eqs, nbParms);
<a name="l00911"></a>00911 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00912"></a>00912 printf(<span class="stringliteral">"Permuting the vars/parms this way: [ "</span>);
<a name="l00913"></a>00913 <span class="keywordflow">for</span> (i=0; i< Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>; i++) {
<a name="l00914"></a>00914 printf(<span class="stringliteral">"%d "</span>, permutation[i]);
<a name="l00915"></a>00915 }
<a name="l00916"></a>00916 printf(<span class="stringliteral">"]\n"</span>);
<a name="l00917"></a>00917 }
<a name="l00918"></a>00918 permutedEqs = <a class="code" href="matrix__permutations_8c.html#e642907b1f7aac2f4ec8f174b27ab830" title="permutes the variables of the constraints of a polyhedron">mpolyhedron_permute</a>(Eqs, permutation);
<a name="l00919"></a>00919 WVL = <a class="code" href="compress__parms_8c.html#4877b02bfffc51db4d9ac702475c3765" title="Given a parameterized constraints matrix with m equalities, computes the compression...">compress_parms</a>(permutedEqs, Eqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-2-Eqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>);
<a name="l00920"></a>00920 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00921"></a>00921 printf(<span class="stringliteral">"Whole validity lattice: "</span>);
<a name="l00922"></a>00922 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(WVL);
<a name="l00923"></a>00923 }
<a name="l00924"></a>00924 <a class="code" href="matrix__addon_8c.html#44f487e1b38f0f47c115d2115087a017" title="compress the last vars/pars of the polyhedron M expressed as a polylib matrixadresses...">mpolyhedron_compress_last_vars</a>(permutedEqs, WVL);
<a name="l00925"></a>00925 permutedIneqs = <a class="code" href="matrix__permutations_8c.html#e642907b1f7aac2f4ec8f174b27ab830" title="permutes the variables of the constraints of a polyhedron">mpolyhedron_permute</a>(Ineqs, permutation);
<a name="l00926"></a>00926 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00927"></a>00927 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(permutedEqs);
<a name="l00928"></a>00928 }
<a name="l00929"></a>00929 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Eqs);
<a name="l00930"></a>00930 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(Ineqs);
<a name="l00931"></a>00931 <a class="code" href="matrix__addon_8c.html#44f487e1b38f0f47c115d2115087a017" title="compress the last vars/pars of the polyhedron M expressed as a polylib matrixadresses...">mpolyhedron_compress_last_vars</a>(permutedIneqs, WVL);
<a name="l00932"></a>00932 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00933"></a>00933 printf(<span class="stringliteral">"After compression: "</span>);
<a name="l00934"></a>00934 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(permutedIneqs);
<a name="l00935"></a>00935 }
<a name="l00936"></a>00936 <span class="comment">/* 3- eliminate the first variables */</span>
<a name="l00937"></a>00937 <span class="keywordflow">if</span> (!<a class="code" href="matrix__addon_8c.html#649c9050ca9d6229d5b48e966da1f35c" title="use a set of m equalities Eqs to eliminate m variables in the polyhedron Ineqs represented...">mpolyhedron_eliminate_first_variables</a>(permutedEqs, permutedIneqs)) {
<a name="l00938"></a>00938 fprintf(stderr,<span class="stringliteral">"full-dimensionize > variable elimination failed. \n"</span>);
<a name="l00939"></a>00939 <span class="keywordflow">return</span> NULL;
<a name="l00940"></a>00940 }
<a name="l00941"></a>00941 <span class="keywordflow">if</span> (<a class="code" href="compress__parms_8c.html#22fb119bf6f583cf5b74c2bddaa53e70" title="Idcompress_parms.c,v 1.32 2006/11/03 17:34:26 skimo Exp ">dbgCompParm</a>) {
<a name="l00942"></a>00942 printf(<span class="stringliteral">"After elimination of the variables: "</span>);
<a name="l00943"></a>00943 <a class="code" href="matrix__addon_8h.html#11468159c7fa7d75fadfa10e2e929fee" title="Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set...">show_matrix</a>(permutedIneqs);
<a name="l00944"></a>00944 }
<a name="l00945"></a>00945
<a name="l00946"></a>00946 <span class="comment">/* 4- get rid of the first (zero) columns, </span>
<a name="l00947"></a>00947 <span class="comment"> which are now useless, and put the parameters back at the end */</span>
<a name="l00948"></a>00948 Full_Dim = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(permutedIneqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>,
<a name="l00949"></a>00949 permutedIneqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-nbElimVars);
<a name="l00950"></a>00950 <span class="keywordflow">for</span> (i=0; i< permutedIneqs-><a class="code" href="structmatrix.html#16ad614d15c6e81c0041e877b623c72d">NbRows</a>; i++) {
<a name="l00951"></a>00951 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>(Full_Dim-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][0], 1);
<a name="l00952"></a>00952 <span class="keywordflow">for</span> (j=0; j< nbParms; j++)
<a name="l00953"></a>00953 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>(Full_Dim-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j+Full_Dim-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-nbParms-1],
<a name="l00954"></a>00954 permutedIneqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j+nbElimVars+1]);
<a name="l00955"></a>00955 <span class="keywordflow">for</span> (j=0; j< permutedIneqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-nbParms-2-nbElimVars; j++)
<a name="l00956"></a>00956 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>(Full_Dim-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j+1],
<a name="l00957"></a>00957 permutedIneqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][nbElimVars+nbParms+j+1]);
<a name="l00958"></a>00958 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>(Full_Dim-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][Full_Dim-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1],
<a name="l00959"></a>00959 permutedIneqs-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][permutedIneqs-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1]);
<a name="l00960"></a>00960 }
<a name="l00961"></a>00961 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(permutedIneqs);
<a name="l00962"></a>00962
<a name="l00963"></a>00963 <span class="comment">/* 5- Keep only the the validity lattice restricted to the parameters */</span>
<a name="l00964"></a>00964 *validityLattice = <a class="code" href="matrix_8c.html#c0b29e1d99a2823ad00b5f2157879d80">Matrix_Alloc</a>(nbParms+1, nbParms+1);
<a name="l00965"></a>00965 <span class="keywordflow">for</span> (i=0; i< nbParms; i++) {
<a name="l00966"></a>00966 <span class="keywordflow">for</span> (j=0; j< nbParms; j++)
<a name="l00967"></a>00967 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>((*validityLattice)->p[i][j],
<a name="l00968"></a>00968 WVL-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][j]);
<a name="l00969"></a>00969 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>((*validityLattice)->p[i][nbParms],
<a name="l00970"></a>00970 WVL-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[i][WVL-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1]);
<a name="l00971"></a>00971 }
<a name="l00972"></a>00972 <span class="keywordflow">for</span> (j=0; j< nbParms; j++)
<a name="l00973"></a>00973 <a class="code" href="source_2arith_2arithmetique_8h.html#8cc56567a4a29271559ac0fd5f6c5bfa">value_set_si</a>((*validityLattice)->p[nbParms][j], 0);
<a name="l00974"></a>00974 <a class="code" href="source_2arith_2arithmetique_8h.html#864613888dc46f15679aa4f63e468f89">value_assign</a>((*validityLattice)->p[nbParms][nbParms],
<a name="l00975"></a>00975 WVL-><a class="code" href="structmatrix.html#2c6d840d8d911ae95c2ae4fc96f4b5ba">p</a>[WVL-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1][WVL-><a class="code" href="structmatrix.html#68858fd3b57684ef38bdfce13c65d182">NbColumns</a>-1]);
<a name="l00976"></a>00976
<a name="l00977"></a>00977 <span class="comment">/* 6- Clean up */</span>
<a name="l00978"></a>00978 <a class="code" href="matrix_8c.html#fcb312b7c12a6997cd66964ecc34e1a6">Matrix_Free</a>(WVL);
<a name="l00979"></a>00979 <span class="keywordflow">return</span> Full_Dim;
<a name="l00980"></a>00980 } <span class="comment">/* full_dimensionize */</span>
<a name="l00981"></a>00981
<a name="l00982"></a>00982 <span class="preprocessor">#undef dbgCompParm</span>
<a name="l00983"></a>00983 <span class="preprocessor"></span><span class="preprocessor">#undef dbgCompParmMore</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Sep 15 18:33:58 2009 for polylib by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>
|