1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611
|
%-------------------------------------------------------------------------------
% The UserGuide.m4tex file. Processed into UserGuide.tex via m4.
%-------------------------------------------------------------------------------
% \documentstyle[12pt,fullpage]{article}
\documentclass[12pt]{article}
\usepackage{times}
\newcommand{\m}[1]{{\bf{#1}}} % for matrices and vectors
\newcommand{\tr}{^{\sf T}} % transpose
\usepackage[colorlinks,pdftex]{hyperref}
\begin{document}
\author{Timothy A. Davis \\
Dept. of Computer and Information Science and Engineering \\
Univ. of Florida, Gainesville, FL}
\title{UMFPACK Version 3.2 User Guide}
\date{January 1, 2002}
\maketitle
%-------------------------------------------------------------------------------
\begin{abstract}
UMFPACK is a set of routines for solving unsymmetric sparse linear
systems, \newline $\m{Ax}=\m{b}$, using the Unsymmetric MultiFrontal method
and direct sparse LU factorization. It is written in ANSI/ISO C, with a
MATLAB (Version 6.0 or 6.1) interface. UMFPACK relies on the Level-3 Basic
Linear Algebra Subprograms (dense matrix multiply) for its performance.
\end{abstract}
%-------------------------------------------------------------------------------
Copyright\copyright 2002 by Timothy A. Davis, University of Florida,
davis@cise.ufl.edu. All Rights Reserved.
{\bf UMFPACK License:}
Your use or distribution of UMFPACK or any derivative code implies that
you agree to this License.
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
Permission is hereby granted to use or copy this program, provided
that the Copyright, this License, and the Availability of the original
version is retained on all copies. User documentation of any code that
uses this code or any derivative code must cite the Copyright, this
License, the Availability note, and "Used by permission." If this
code or any derivative code is accessible from within MATLAB, then
typing "help umfpack" must cite the Copyright, and "type umfpack"
must also cite this License and the Availability note. Permission to
modify the code and to distribute modified code is granted, provided
the Copyright, this License, and the Availability note are retained,
and a notice that the code was modified is included. This software
was developed with support from the National Science Foundation, and
is provided to you free of charge.
{\bf Acknowledgments:}
This work was supported by the National Science Foundation, under
grants DMS-9504974 and DMS-9803599.
%-------------------------------------------------------------------------------
\newpage
%-------------------------------------------------------------------------------
\tableofcontents
%-------------------------------------------------------------------------------
\newpage
\section{Overview}
%-------------------------------------------------------------------------------
UMFPACK Version 3.2 is a set of routines for solving systems of linear
equations, $\m{Ax}=\m{b}$, when $\m{A}$ is sparse and unsymmetric. It is based
on the Unsymmetric MultiFrontal method \cite{DavisDuff97,DavisDuff99},
which factorizes $\m{PAQ}$ into the product $\m{LU}$, where $\m{L}$ and $\m{U}$
are lower and upper triangular, respectively, and $\m{P}$ are $\m{Q}$ are
permutation matrices. Both $\m{P}$ and $\m{Q}$ are chosen to reduce fill-in
(new nonzeros in $\m{L}$ and $\m{U}$ that are not present in $\m{A}$). The
permutation $\m{P}$ has the dual role of reducing fill-in and maintaining
numerical accuracy (via relaxed partial pivoting and row interchanges).
UMFPACK first finds a column pre-ordering that reduces fill-in, without regard
to numerical values, with a modified version of COLAMD
\cite{DavisGilbertLarimoreNg00_algo,DavisGilbertLarimoreNg00,Larimore98}.
The method finds a symmetric permutation $\m{Q}$ of the matrix $\m{A}\tr\m{A}$
(without forming $\m{A}\tr\m{A}$ explicitly). This is a good choice for
$\m{Q}$, since the Cholesky factors of $\m{(AQ)\tr(AQ)}$ are an upper bound (in
terms of nonzero pattern) of the factor $\m{U}$ for the unsymmetric LU
factorization ($\m{PAQ}=\m{LU}$) regardless of the choice of $\m{P}$
\cite{GeorgeNg85,GeorgeNg87,GilbertNg93}.
Next, the method breaks the factorization of the matrix $\m{A}$ down into a
sequence of dense rectangular frontal matrices. The frontal matrices are
related to each other by a supernodal column elimination tree, in which each
node in the tree represents one frontal matrix. This analysis phase also
determines upper bounds on the memory usage, the floating-point operation count,
and the number of nonzeros in the LU factors.
UMFPACK factorizes each {\em chain} of frontal matrices in a single working
array, similar to how the unifrontal method \cite{dusc:96} factorizes the whole
matrix. A chain of frontal matrices is a sequence of fronts where the parent
of front $i$ is $i$+1 in the supernodal column elimination tree. UMFPACK is an
outer-product based, right-looking method. At the $k$-th step of Gaussian
elimination, it represents the updated submatrix $\m{A}_k$ as an implicit
summation of a set of dense submatrices (referred to as {\em elements},
borrowing a phrase from finite-element methods) that arise when the frontal
matrices are factorized and their pivot rows and columns eliminated.
Each frontal matrix represents the elimination of one or more columns;
each column of $\m{A}$ will be eliminated in a specific frontal matrix,
and which frontal matrix will be used for each column is determined by
the pre-analysis phase. The pre-analysis phase also determines the worst-case
size of each frontal matrix so that they can hold any candidate pivot column
and any candidate pivot row. From the perspective of the analysis phase, any
candidate pivot column in the frontal matrix is identical (in terms of nonzero
pattern), and so is any row. However, the numerical factorization phase has
more information than the analysis phase. It uses this information to reorder
the columns within each frontal matrix to reduce fill-in. Similarly, since
the number of nonzeros in each row and column are maintained (more precisely,
COLMMD-style approximate degrees \cite{GilbertMolerSchreiber}), a pivot row can
be selected based on sparsity-preserving criteria (low degree) as well as
numerical considerations (relaxed threshold partial pivoting). This information
about row and column degrees is not available to left-looking methods such as
{\tt SuperLU} \cite{SuperLU99} or MATLAB's {\tt LU}
\cite{GilbertMolerSchreiber,GilbertPeierls88}.
More details of the method, including experimental results, are
described in \cite{Davis02,Davis02_algo}, available at
www.cise.ufl.edu/tech-reports.
%-------------------------------------------------------------------------------
\section{Availability}
%-------------------------------------------------------------------------------
UMFPACK Version 3.2 is available at www.cise.ufl.edu/research/sparse,
and has been submitted as a collected algorithm of the ACM
\cite{Davis02,Davis02_algo}.
It makes use of a modified version of COLAMD V2.0 by Timothy A.~Davis, Stefan
Larimore, John Gilbert, and Esmond Ng. The original COLAMD V2.0 is available in
MATLAB V6.0 (or later), and at www.cise.ufl.edu/research/sparse.
These codes are also available in Netlib \cite{netlib} at
www.netlib.org.
Prior versions of UMFPACK, co-authored with Iain Duff, are available at
www.cise.ufl.edu/research/sparse and as MA38 (functionally
equivalent to Version 2.2.1) in the Harwell Subroutine Library.
%-------------------------------------------------------------------------------
\section{Using UMFPACK in MATLAB}
%-------------------------------------------------------------------------------
The easiest way to use UMFPACK is within MATLAB. This discussion assumes that
you have MATLAB Version 6.0 or later (which includes the BLAS, and the
{\tt colamd} ordering routine). To compile the UMFPACK mexFunction, you can
either type {\tt make umfpack} in the Unix system shell, or type
{\tt umfpack\_make} in MATLAB (which should work on any system, including
Windows). See Section~\ref{Install} for more details on how to install UMFPACK.
Once installed, the UMFPACK mexFunction can analyze, factor, and solve linear
systems. Table~\ref{matlab} summarizes some of the more common uses
of UMFPACK within MATLAB.
\begin{table}
\caption{Using UMFPACK's MATLAB interface}
\label{matlab}
\vspace{0.1in}
{\footnotesize
\begin{tabular}{l|l|l}
\hline
Function & Using UMFPACK & MATLAB 6.0 equivalent \\
\hline
& & \\
\begin{minipage}[t]{1.5in}
Solve $\m{Ax}=\m{b}$.
\end{minipage}
&
\begin{minipage}[t]{2.2in}
\begin{verbatim}
x = umfpack (A,'\',b) ;
\end{verbatim}
\end{minipage}
&
\begin{minipage}[t]{2.2in}
\begin{verbatim}
x = A \ b ;
\end{verbatim}
\end{minipage}
\\
& & \\
\hline
& & \\
\begin{minipage}[t]{1.5in}
Solve $\m{Ax}=\m{b}$ using a different column pre-ordering.
\end{minipage}
&
\begin{minipage}[t]{2.2in}
\begin{verbatim}
S = spones (A) ;
Q = symamd (S+S') ;
x = umfpack (A,Q,'\',b) ;
\end{verbatim}
\end{minipage}
&
\begin{minipage}[t]{2.2in}
\begin{verbatim}
spparms ('autommd',0) ;
S = spones (A) ;
Q = symamd (S+S') ;
x = A (:,Q) \ b ;
x (Q) = x ;
spparms ('autommd',1) ;
\end{verbatim}
\end{minipage}
\\
& & \\
\hline
& & \\
\begin{minipage}[t]{1.5in}
Solve $\m{A}\tr\m{x}\tr = \m{b}\tr$.
\end{minipage}
&
\begin{minipage}[t]{2.2in}
\begin{verbatim}
x = umfpack (b,'/',A) ;
\end{verbatim}
\end{minipage}
&
\begin{minipage}[t]{2.2in}
\begin{verbatim}
x = b / A ;
\end{verbatim}
\end{minipage}
\\
& & \\
\hline
& & \\
\begin{minipage}[t]{1.5in}
Factorize $\m{A}$, then solve $\m{Ax}=\m{b}$.
\end{minipage}
&
\begin{minipage}[t]{2.2in}
\begin{verbatim}
[L,U,P,Q] = umfpack (A) ;
x = U \ (L \ (b (P))) ;
x (Q) = x ;
\end{verbatim}
\end{minipage}
&
\begin{minipage}[t]{2.2in}
\begin{verbatim}
Q = colamd (A) ;
[L,U,P] = lu (A (:,Q)) ;
x = U \ (L \ (P*b)) ;
x (Q) = x ;
\end{verbatim}
\end{minipage}
\\
& & \\
\hline
\end{tabular}
}
\end{table}
UMFPACK requires {\tt A} to be square, sparse,
nonsingular and not complex, and it requires {\tt b} to be a dense column vector
(and not complex). This is more restrictive than what you can do with MATLAB's
backslash or {\tt LU}. Future releases of UMFPACK may remove some of these
restrictions.
MATLAB's {\tt [L,U,P] = lu (A)} returns a lower triangular {\tt L}, an upper
triangular {\tt U}, and a permutation matrix {\tt P} such that {\tt P*A} is
equal to {\tt L*U}. UMFPACK behaves differently; it returns {\tt P} and {\tt Q}
such that {\tt A (P,Q)} is equal to {\tt L*U}, where {\tt P} and {\tt Q} are
permutation vectors. If you prefer permutation matrices, use the following
MATLAB code:
{\footnotesize
\begin{verbatim}
[L,U,P,Q] = umfpack (A) ;
n = size (A,1) ;
I = speye (n) ;
P = I (P,:) ;
Q = I (:,Q) ;
\end{verbatim}
}
Now {\tt P*A*Q} is equal to {\tt L*U}. Note that
{\tt x = umfpack (A, '}$\backslash${\tt ', b)}
requires that {\tt b} be a dense column vector.
If you wish to use the LU factors from UMFPACK to solve a
linear system, $\m{Ax}=\m{b}$ where $\m{b}$ is a either a dense or sparse
matrix with more than one column, do this:
{\footnotesize
\begin{verbatim}
[L,U,P,Q] = umfpack (A) ;
x = U \ (L \ (b (P,:))) ;
x (Q,:) = x ;
\end{verbatim}
}
The above two examples do not make use of the iterative refinement
that is built into
{\tt x = umfpack (A, '}$\backslash${\tt ', b)}
however.
Since the numeric factorization refines its column pre-ordering, the {\tt Q}
in {\tt [L,U,P,Q] = umfpack (A)} and {\tt [Q,F,C] = umfpack (A, 'symbolic')}
will in general be different.
There are more options; you can provide your own column pre-ordering (in which
case UMFPACK does not call COLAMD), you can modify other control settings
(similar to the {\tt spparms} in MATLAB), and you get various statistics on
the analysis, factorization, and solution of the linear system. Type
{\tt help umfpack\_details} and {\tt help umfpack\_report} in MATLAB for more
information. Two demo m-files are provided. Just type {\tt umfpack\_simple}
and {\tt umfpack\_demo} to run them. They roughly correspond to the C programs
{\tt umfpack\_simple.c} and {\tt umfpack\_demo.c}. You may want to type
{\tt more on} before running the {\tt umfpack\_simple} demo since it generates
lots of output.
A simple M-file ({\tt umfpack\_btf}) is provided that first permutes the matrix
to upper block triangular form, using MATLAB's {\tt dmperm} routine. It
solves $\m{Ax}=\m{b}$; the LU factors are not returned. Its usage is simple:
{\tt x = umfpack\_btf (A, b)}.
Type {\tt help umfpack\_btf} for more options.
One issue you may encounter is how UMFPACK allocates its memory when being used
in a mexFunction. One part of its working space is of variable size. The
symbolic analysis phase determines an upper bound on the size of this memory,
but not all of this memory will typically be used in the numerical
factorization. UMFPACK tries to allocate a decent amount of working space
(70\% of the upper bound, by default), with some elbow room so
that it can run more efficiently. If this fails, it reduces its request and
uses less memory. However, {\tt mxMalloc} aborts the {\tt umfpack} mexFunction
if it fails, so this strategy doesn't work in MATLAB. The strategy works fine
when {\tt malloc} is used instead. If you run out of memory in MATLAB, try
reducing {\tt Control(7)} to be less than 0.70, and try again.
Alternatively, set {\tt Control(7)} to 1.0 or 1.05 to avoid all reallocations
of memory.
Type {\tt help umfpack\_details} and {\tt umfpack\_report} for more
information, and refer to the {\tt Control [UMFPACK\_ALLOC\_INIT]} parameter
described in {\tt umfpack\_numeric} in Section~\ref{Primary}, below.
There is a solution to this problem, but it relies on undocumented internal
routines. See the {\tt -DMATHWORKS} option in {\tt umf\_config.h} in
Section~\ref{Config} for details.
Memory allocation on a PC is notoriously bad, so I recommend setting
{\tt Control(7)} to a non-default value of 1.0 or even 1.05.
This will avoid most reallocations of memory.
%-------------------------------------------------------------------------------
\section{Using UMFPACK in a C program}
%-------------------------------------------------------------------------------
The C-callable UMFPACK library consists of 24 user-callable routines and one
include file. Twenty-three of the routines come in dual versions, with
different sizes of integers. All user-callable routine names begin with
{\tt umfpack\_} or {\tt umfpack\_l\_}; other routine names beginning with
{\tt umf\_} or {\tt umfl\_} are internal to the package, and should not be
called by the user. The include file {\tt umfpack.h}, listed in
Section~\ref{Include}, must be included in any C program that uses UMFPACK.
%-------------------------------------------------------------------------------
\subsection{The size of an integer}
%-------------------------------------------------------------------------------
There are two versions of each user-callable routine (except for one routine).
The routine names starting with just {\tt umfpack\_} use {\tt int} integer
arguments; those starting with {\tt umfpack\_l\_} use {\tt long} integer
arguments. If you compile UMFPACK in the standard ILP32 mode (32-bit
{\tt int}'s, {\tt long}'s, an pointers) then the versions are essentially
identical. You will be able to solve problems using up to 4GB of memory.
If you compile UMFPACK in the standard LP64 mode, the size of an {\tt int}
remains 32-bits, but the size of a {\tt long} and a pointer both get promoted
to 64-bits. In the LP64 mode, the {\tt umfpack\_l\_*} routines can solve huge
problems (not limited to 4GB), limited of course by the amount of available
memory. The only drawback to the 64-bit mode is that few BLAS libraries
support 64-bit integers. This limits the performance you will obtain.
Both versions are discussed below. Use only one version for any one problem;
do not attempt to use one version to analyze the matrix and another version to
factorize the matrix, for example.
%-------------------------------------------------------------------------------
\subsection{Primary routines, and a simple example}
%-------------------------------------------------------------------------------
Five primary UMFPACK routines are required to solve $\m{Ax}=\m{b}$. They are
fully described in Section~\ref{Primary}:
\begin{itemize}
\item {\tt umfpack\_symbolic}, {\tt umfpack\_l\_symbolic}:
Pre-orders the columns of $\m{A}$ to reduce fill-in, based on its sparsity
pattern only, finds the supernodal column elimination tree, and post-orders
the tree. Returns an opaque {\tt Symbolic} object as a {\tt void *}
pointer. The object contains the symbolic analysis and is needed for the
numerical factorization. This routine requires only $O(|\m{A}|)$ space,
where $|\m{A}|$ is the number of nonzero entries in the matrix. It computes
upper bounds on the nonzeros in $\m{L}$ and $\m{U}$, the floating-point
operations required, and the memory usage of {\tt umfpack\_numeric}. The
{\tt Symbolic} object is small; it contains just the column pre-ordering,
the supernodal column elimination tree, and information about each frontal
matrix, and is no larger than about $6n$ integers (where $\m{A}$ is
$n$-by-$n$). The matrix must be structurally non-singular (more precisely,
each row and column must have at least one entry).
\item {\tt umfpack\_numeric}, {\tt umfpack\_l\_numeric}:
Numerically factorizes a sparse matrix into $\m{PAQ}=\m{LU}$. Requires the
symbolic ordering and analysis computed by {\tt umfpack\_symbolic} or
{\tt umfpack\_qsymbolic}. Returns an opaque {\tt Numeric} object as a
{\tt void *} pointer. The object contains the numerical factorization and
is used by {\tt umfpack\_solve}. You can factorize a new matrix with a
different values (but identical pattern) as the matrix analyzed by
{\tt umfpack\_symbolic} or {\tt umfpack\_qsymbolic} by re-using the
{\tt Symbolic} object (this feature is available when using UMFPACK in a
C program, but not in MATLAB). The matrix must be non-singular.
\item {\tt umfpack\_solve}, {\tt umfpack\_l\_solve}:
Solves a sparse linear system ($\m{Ax}=\m{b}$, $\m{A}\tr\m{x}=\m{b}$, or
systems involving just $\m{L}$ or $\m{U}$), using the numeric factorization
computed by {\tt umfpack\_numeric}. Iterative refinement with sparse
backward error \cite{ardd:89} is used by default.
\item {\tt umfpack\_free\_symbolic}, {\tt umfpack\_l\_free\_symbolic}:
Frees the {\tt Symbolic} object created by {\tt umfpack\_symbolic} or
{\tt umfpack\_qsymbolic}.
\item {\tt umfpack\_free\_numeric}, {\tt umfpack\_l\_free\_numeric}:
Frees the {\tt Numeric} object created by {\tt umfpack\_numeric}.
\end{itemize}
Be careful not to free a {\tt Symbolic} object with
{\tt umfpack\_free\_numeric}. Nor should you attempt to free a {\tt Numeric}
object with {\tt umfpack\_free\_symbolic}. Failure to free these objects will
lead to memory leaks.
The matrix $\m{A}$ is represented in compressed column form, which is
identical to the sparse matrix representation used by MATLAB. It consists
of three arrays, where the matrix is {\tt n}-by{\tt n}, with {\tt nz} entries.
For the {\tt int} version of UMFPACK:
{\footnotesize
\begin{verbatim}
int Ap [n+1] ;
int Ai [nz] ;
double Ax [nz] ;
\end{verbatim}
}
For the {\tt long} version of UMFPACK:
{\footnotesize
\begin{verbatim}
long Ap [n+1] ;
long Ai [nz] ;
double Ax [nz] ;
\end{verbatim}
}
All nonzeros are entries, but an entry may be numerically zero. The row indices
of entries in column {\tt j} are stored in
{\tt Ai[Ap[j]} ... {\tt Ap[j+1]-1]}.
The corresponding numerical values are stored in
{\tt Ax[Ap[j]} ... {\tt Ap[j+1]-1]}.
No duplicate row indices may be present, and the row indices in any given
column must be sorted in ascending order. The first entry {\tt Ap [0]} must be
zero. The total number of entries in the matrix is thus {\tt nz = Ap [n]}.
Except for the fact that extra zero entries can be included, there is thus a
unique compressed column representation of any given matrix $\m{A}$.
Here is a simple main program, {\tt umfpack\_simple.c}, that illustrates the
basic usage of UMFPACK.
{\footnotesize
\begin{verbatim}
#include <stdio.h>
#include "umfpack.h"
int n = 5 ;
int Ap [ ] = {0, 2, 5, 9, 10, 12} ;
int Ai [ ] = { 0, 1, 0, 2, 4, 1, 2, 3, 4, 2, 1, 4} ;
double Ax [ ] = {2., 3., 3., -1., 4., 4., -3., 1., 2., 2., 6., 1.} ;
double b [ ] = {8., 45., -3., 3., 19.} ;
double x [5] ;
int main (int argc, char **argv)
{
double *Control = (double *) NULL, *Info = (double *) NULL ;
int i ;
void *Symbolic, *Numeric ;
(void) umfpack_symbolic (n, Ap, Ai, &Symbolic, Control, Info) ;
(void) umfpack_numeric (Ap, Ai, Ax, Symbolic, &Numeric, Control, Info) ;
umfpack_free_symbolic (&Symbolic) ;
(void) umfpack_solve ("Ax=b", Ap, Ai, Ax, x, b, Numeric, Control, Info) ;
umfpack_free_numeric (&Numeric) ;
for (i = 0 ; i < n ; i++) printf ("x [%d] = %g\n", i, x [i]) ;
return (0) ;
}
\end{verbatim}
}
It solves the same linear system as the {\tt umfpack\_simple.m} MATLAB m-file.
The {\tt Ap}, {\tt Ai}, and {\tt Ax} arrays represent the matrix
\[
\m{A} = \left[
\begin{array}{rrrrr}
2 & 3 & 0 & 0 & 0 \\
3 & 0 & 4 & 0 & 6 \\
0 & -1 & -3 & 2 & 0 \\
0 & 0 & 1 & 0 & 0 \\
0 & 4 & 2 & 0 & 1 \\
\end{array}
\right].
\]
and the solution is $\m{x} = [1 \, 2 \, 3 \, 4 \, 5]\tr$. The program uses
default control settings and does not return any statistics about the ordering,
factorization, or solution ({\tt Control} and {\tt Info} are both
{\tt (double *) NULL}).
%-------------------------------------------------------------------------------
\subsection{Alternative routines}
%-------------------------------------------------------------------------------
Three alternative routines are provided that modify UMFPACK's default
behavior. They are fully described in Section~\ref{Alternative}:
\begin{itemize}
\item {\tt umfpack\_defaults}, {\tt umfpack\_l\_defaults}:
Sets the default control parameters in the {\tt Control} array. These can
then be modified as desired before passing the array to the other UMFPACK
routines. Control parameters are fully described in Section~\ref{defaults}.
One particular parameter deserves special notice.
UMFPACK uses relaxed partial pivoting, where a candidate pivot entry is
numerically acceptable if its magnitude is greater than or equal to a
tolerance parameter times the magnitude of the largest entry in the same
column. The parameter {\tt Info [UMFPACK\_PIVOT\_TOLERANCE]} has a default
value of 0.1. This may be too small for some matrices, particularly for
ill-conditioned or poorly scaled ones. With the default pivot tolerance
and default iterative refinement,
{\tt x = umfpack (A, '}$\backslash${\tt ', b)}
is just as accurate as
{\tt x = A}$\backslash${\tt b}
in MATLAB for nearly all matrices.
\item {\tt umfpack\_qsymbolic}, {\tt umfpack\_l\_qsymbolic}:
An alternative to {\tt umfpack\_symbolic}. Allows the user to specify his
or her own column pre-ordering, rather than using the default COLAMD
pre-ordering.
\item {\tt umfpack\_wsolve}, {\tt umfpack\_l\_wsolve}:
An alternative to {\tt umfpack\_solve} which does not dynamically allocate
any memory. Requires the user to pass several additional size-$n$ work
arrays.
\end{itemize}
%-------------------------------------------------------------------------------
\subsection{Matrix manipulation routines}
%-------------------------------------------------------------------------------
The compressed column data structure is compact, and simplifies the UMFPACK
routines that operate on the sparse matrix $\m{A}$. However, it can be
inconvenient for the user to generate. Section~\ref{Manipulate} presents the
details of routines for manipulating sparse matrices in {\em triplet} form,
compressed column form, and compressed row form (the transpose of the
compressed column form). The triplet form of a matrix consists of three arrays.
For the {\tt int} version of UMFPACK:
{\footnotesize
\begin{verbatim}
int Ti [nz] ;
int Tj [nz] ;
double Tx [nz] ;
\end{verbatim}
}
For the {\tt long} version:
{\footnotesize
\begin{verbatim}
long Ti [nz] ;
long Tj [nz] ;
double Tx [nz] ;
\end{verbatim}
}
The {\tt k}-th triplet is $(i,j,a_{ij})$, where $i =$ {\tt Ti [k]},
$j =$ {\tt Tj [k]}, and $a_{ij} =$ {\tt Tx [k]}. The triplets can be in any
order in the {\tt Ti}, {\tt Tj}, and {\tt Tx} arrays, and duplicate entries may
exist. Any duplicate entries are summed when the triplet form is converted to
compressed column form. This is a convenient way to create a matrix arising in
finite-element methods, for example.
Three routines are provided for manipulating sparse matrices:
\begin{itemize}
\item {\tt umfpack\_triplet\_to\_col}, {\tt umfpack\_l\_triplet\_to\_col}:
Converts a triplet form of a matrix to compressed column form (ready for
input to {\tt umfpack\_symbolic}, {\tt umfpack\_qsymbolic}, and
{\tt umfpack\_numeric}). Identical to {\tt A = spconvert (i,j,x)} in
MATLAB, except that zero entries are not removed, so that the pattern of
entries in the compressed column form of $\m{A}$ are fully under user
control. This is important if you want to factorize a new matrix with the
{\tt Symbolic} object from a prior matrix with the same pattern as the new
one. MATLAB never stores explicitly zero entries.
\item {\tt umfpack\_col\_to\_triplet}, {\tt umfpack\_l\_col\_to\_triplet}:
The opposite of {\tt umfpack\_triplet\_to\_col}. Identical to
{\tt [i,j,x] = find (A)} in MATLAB, except that numerically zero entries
may be included.
\item {\tt umfpack\_transpose}, {\tt umfpack\_l\_transpose}:
Transposes and optionally permutes a column form matrix \cite{Gustavson78}.
Identical to {\tt B = A (P,Q)'} in MATLAB, except for the presence of
numerically zero entries.
\end{itemize}
It is quite easy to add matrices in triplet form, transpose them, and permute
them. See the discussion in {\tt umfpack\_triplet\_to\_col} in
Section~\ref{Manipulate} for more details. All of the matrix manipulation
routines can correctly operate on singular matrices.
%-------------------------------------------------------------------------------
\subsection{Getting the contents of opaque objects}
%-------------------------------------------------------------------------------
There are cases where the user would like to do more with the LU factorization
of a matrix than solve a linear system. The opaque {\tt Symbolic} and
{\tt Numeric} objects are just that - opaque. In addition, the LU factors
are stored in the {\tt Numeric} object in a compact way that does not store
all of the row and column indices \cite{GeorgeLiu}. These objects may not be
dereferenced by the user, and even if they were, it would be difficult for a
typical user to understand how the LU factors are stored. Thus, three routines
are provided for copying their contents into user-provided arrays using simpler
data structures. They are fully described in Section~\ref{Get}:
\begin{itemize}
\item {\tt umfpack\_get\_lunz}, {\tt umfpack\_l\_get\_lunz}:
Returns the number of nonzeros in $\m{L}$ and $\m{U}$.
\item {\tt umfpack\_get\_numeric}, {\tt umfpack\_l\_get\_numeric}:
Copies $\m{L}$, $\m{U}$, $\m{P}$, and $\m{Q}$ from the {\tt Numeric} object
into arrays provided by the user. The matrix $\m{L}$ is returned in
compressed row form (with the column indices in each row sorted in ascending
order). The matrix $\m{U}$ is returned in compressed column form (also with
sorted columns). There are no explicit zero entries in $\m{L}$ and $\m{U}$,
but such entries may exist in the {\tt Numeric} object. The permutations
$\m{P}$ and $\m{Q}$ are represented as permutation vectors, where
{\tt P [k] = i} means that row {\tt i} of the original matrix is the
{\tt k}-th pivot row (or the {\tt k}-th row of $\m{PAQ}$), and where
{\tt Q [k] = j} means that column {\tt j} of the original matrix is the
{\tt k}-th pivot column. This is identical to how MATLAB uses permutation
vectors.
\item {\tt umfpack\_get\_symbolic}, {\tt umfpack\_l\_get\_symbolic}:
Copies the contents of the {\tt Symbolic} object (the initial column
preordering, and supernodal column elimination tree, and information
about each frontal matrix) into arrays provided by the user.
\end{itemize}
UMFPACK itself does not make use of the output of the {\tt umfpack\_get\_*}
routines; they are provided solely for returning the contents of the opaque
{\tt Symbolic} and {\tt Numeric} objects to the user.
%-------------------------------------------------------------------------------
\subsection{Reporting routines}
%-------------------------------------------------------------------------------
None of the UMFPACK routines discussed so far prints anything, even when an
error occurs. UMFPACK provides you with nine routines for printing the input
and output arguments (including the {\tt Control} settings and {\tt Info}
statistics) of UMFPACK routines discussed above. They are fully described in
Section~\ref{Report}:
\begin{itemize}
\item {\tt umfpack\_report\_status}, {\tt umfpack\_l\_report\_status}:
Prints the status (return value) of other {\tt umfpack\_*} routines.
\item {\tt umfpack\_report\_info}, {\tt umfpack\_l\_report\_info}:
Prints the statistics returned in the {\tt Info} array by
{\tt umfpack\_*symbolic}, {\tt umfpack\_numeric}, and {\tt umfpack\_*solve}.
\item {\tt umfpack\_report\_control}, {\tt umfpack\_l\_report\_control}:
Prints the {\tt Control} settings.
\item {\tt umfpack\_report\_matrix}, {\tt umfpack\_l\_report\_matrix}:
Verifies and prints a compressed column-form or compressed row-form sparse
matrix.
\item {\tt umfpack\_report\_triplet}, {\tt umfpack\_l\_report\_triplet}:
Verifies and prints a matrix in triplet form.
\item {\tt umfpack\_report\_symbolic}, {\tt umfpack\_l\_report\_symbolic}:
Verifies and prints a {\tt Symbolic} object.
\item {\tt umfpack\_report\_numeric}, {\tt umfpack\_l\_report\_numeric}:
Verifies and prints a {\tt Numeric} object.
\item {\tt umfpack\_report\_perm}, {\tt umfpack\_l\_report\_perm}:
Verifies and prints a permutation vector.
\item {\tt umfpack\_report\_vector}, {\tt umfpack\_l\_report\_vector}:
Verifies and prints a real vector.
\end{itemize}
The {\tt umfpack\_report\_*} routines behave slightly differently when compiled
into the C-callable UMFPACK library than when used in the MATLAB mexFunction.
MATLAB stores its sparse matrices using the same compressed column data
structure discussed above, where row and column indices are in the range {\tt 0}
to {\tt n-1}, but it prints them as if they are in the range {\tt 1} to {\tt n}.
The UMFPACK mexFunction behaves the same way.
You can control how much the {\tt umfpack\_report\_*} routines print by
modifying the {\tt Control [UMFPACK\_PRL]} parameter. Its default value is
{\tt UMFPACK\_DEFAULT\_PRL} which is equal to 1. Here is a summary of how
the routines use this print level parameter:
\begin{itemize}
\item {\tt umfpack\_report\_status}, {\tt umfpack\_l\_report\_status}:
No output if the print level is 0 or less, even when an error occurs.
If 1, then error messages are printed, and nothing is printed if
the status is {\tt UMFPACK\_OK}. If 2 or more, then the status is always
printed. If 4 or more, then the UMFPACK Copyright is printed.
If 6 or more, then the UMFPACK License is printed. See also the first page
of this User Guide for the Copyright and License.
\item {\tt umfpack\_report\_control}, {\tt umfpack\_l\_report\_control}:
No output if the print level is 1 or less. If 2 or more, all of
{\tt Control} is printed.
\item {\tt umfpack\_report\_info}, {\tt umfpack\_l\_report\_info}:
No output if the print level is 1 or less. If 2 or more, all of
{\tt Info} is printed.
\item all other {\tt umfpack\_report\_*} routines:
If the print level is 2 or less, then these routines return silently without
checking their inputs. If 3 or more, the inputs are fully verified and a
short status summary is printed. If 4, then the first few entries of the
input arguments are printed. If 5, then all of the input arguments are
printed.
\end{itemize}
%-------------------------------------------------------------------------------
\subsection{Utility routines}
%-------------------------------------------------------------------------------
UMFPACK includes a routine that returns the time used by the process,
{\tt umfpack\_timer}. The routine uses either {\tt getrusage} (which is
preferred), or the ANSI C {\tt clock} routine if that is not available.
It is fully described in Section~\ref{Utility}. It is the only routine
that is identical in both {\tt int} and {\tt long} versions (there is no
{\tt umfpack\_l\_timer} routine).
%-------------------------------------------------------------------------------
\subsection{Control parameters}
%-------------------------------------------------------------------------------
UMFPACK uses an optional {\tt double} array, {\tt Control}, to modify
its control parameters. These may be modified by the user
(see {\tt umfpack\_defaults} and {\tt umfpack\_l\_defaults}). Each
user-callable routine includes a complete description of how each control
setting modifies its behavior. Table~\ref{control} summarizes the entire
contents of the {\tt Control} array. Future versions may make use of
additional entries in the {\tt Control} array.
Note that ANSI C uses 0-based indexing, while MATLAB user's 1-based
indexing. Thus, {\tt Control(1)} in MATLAB is the same as
{\tt Control[0]} or {\tt Control[UMFPACK\_PRL]} in ANSI C.
\begin{table}
\caption{UMFPACK Control parameters}
\label{control}
{\footnotesize
\begin{tabular}{llll}
\hline
MATLAB & ANSI C & default & description \\
\hline
\multicolumn{4}{l}{Used by reporting routines:} \\
{\tt Control(1)} & {\tt Control[UMFPACK\_PRL]} & 1 & printing level \\
\hline
% /* used in UMFPACK_*symbolic only: */
\multicolumn{4}{l}{Used by {\tt umfpack\_*symbolic:}} \\
{\tt Control(2)} & {\tt Control[UMFPACK\_DENSE\_ROW]} & 0.2 & dense row threshold \\
{\tt Control(3)} & {\tt Control[UMFPACK\_DENSE\_COL]} & 0.2 & dense column threshold \\
\hline
% /* used in UMFPACK_numeric only: */
\multicolumn{4}{l}{Used by {\tt umfpack\_*numeric:}} \\
{\tt Control(4)} & {\tt Control[UMFPACK\_PIVOT\_TOLERANCE]} & 0.1 & partial pivoting tolerance \\
{\tt Control(5)} & {\tt Control[UMFPACK\_BLOCK\_SIZE]} & 24 & BLAS block size \\
{\tt Control(6)} & {\tt Control[UMFPACK\_RELAXED\_AMALGAMATION]} & 0.25 & amalgamation \\
{\tt Control(7)} & {\tt Control[UMFPACK\_ALLOC\_INIT]} & 0.7 & initial memory allocation \\
{\tt Control(13)} & {\tt Control[UMFPACK\_PIVOT\_OPTION]} & 0 & symmetric pivot preference \\
{\tt Control(14)} & {\tt Control[UMFPACK\_RELAXED2\_AMALGAMATION]} & 0.1 & amalgamation \\
{\tt Control(15)} & {\tt Control[UMFPACK\_RELAXED3\_AMALGAMATION]} & 0.125 & amalgamation \\
\hline
% /* used in UMFPACK_*solve only: */
\multicolumn{4}{l}{Used by {\tt umfpack\_*solve:}} \\
{\tt Control(8)} & {\tt Control[UMFPACK\_IRSTEP]} & 2 & max iter. refinement steps \\
\hline
%
% /* compile-time settings - Control [8..11] cannot be changed at run time: */
\multicolumn{4}{l}{Can only be changed at compile time:} \\
{\tt Control(9)} & {\tt Control[UMFPACK\_COMPILED\_WITH\_BLAS]} & - & true if BLAS is used \\
{\tt Control(10)} & {\tt Control[UMFPACK\_COMPILED\_FOR\_MATLAB]} & - & true for mexFunction \\
{\tt Control(11)} & {\tt Control[UMFPACK\_COMPILED\_WITH\_GETRUSAGE]} & - & true if {\tt getrusage} used \\
{\tt Control(12)} & {\tt Control[UMFPACK\_COMPILED\_IN\_DEBUG\_MODE]} & - & true if debug mode enabled \\
%
%/* Control [15...19] unused */
\hline
\end{tabular}
}
\end{table}
%-------------------------------------------------------------------------------
\subsection{Larger examples}
%-------------------------------------------------------------------------------
A full example of all user-callable UMFPACK routines (the {\tt int} routines)
is available in the C main program, {\tt umfpack\_demo.c} listed in
Section~\ref{Demo}. A nearly identical program that uses the {\tt long} integer
version of UMFPACK is in {\tt umfpack\_l\_demo.c}. Another example is
the UMFPACK mexFunction, {\tt umfpackmex.c}. The mexFunction accesses only the
user-callable C interface to UMFPACK. The only features that it does not use
are the support for the triplet form (MATLAB's sparse arrays are already in the
compressed column form) and the ability to reuse the {\tt Symbolic} object to
numerically factorize a matrix whose pattern is the same as a prior matrix
analyzed by {\tt umfpack\_symbolic} or {\tt umfpack\_qsymbolic}. The latter is
an important feature, but the mexFunction does not return its opaque
{\tt Symbolic} and {\tt Numeric} objects to MATLAB. Instead, it gets the
contents of these objects after extracting them via the {\tt umfpack\_get\_*}
routines, and returns them as MATLAB sparse matrices.
%-------------------------------------------------------------------------------
\section{Synopsis of all C-callable routines ({\tt int} version)}
%-------------------------------------------------------------------------------
Each subsection, below, summarizes the input variables, output variables, return
values, and calling sequences of the routines in one category. Variables with
the same name as those already listed in a prior category have the same size
and type.
%-------------------------------------------------------------------------------
\subsection{Primary routines}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
#include "umfpack.h"
int status, n, nz, Ap [n+1], Ai [nz] ;
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO], Ax [nz], X [n], B [n] ;
void *Symbolic, *Numeric ;
char *sys ;
status = umfpack_symbolic (n, Ap, Ai, &Symbolic, Control, Info) ;
status = umfpack_numeric (Ap, Ai, Ax, Symbolic, &Numeric, Control, Info) ;
status = umfpack_solve (sys, Ap, Ai, Ax, X, B, Numeric, Control, Info) ;
umfpack_free_symbolic (&Symbolic) ;
umfpack_free_numeric (&Numeric) ;
\end{verbatim}
}
%-------------------------------------------------------------------------------
\subsection{Alternative routines}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
int Qinit [n], Wi [n] ;
double W [n], Y [n], Z [n], S [n] ;
umfpack_defaults (Control) ;
status = umfpack_qsymbolic (n, Ap, Ai, Qinit, &Symbolic, Control, Info) ;
status = umfpack_wsolve (sys, Ap, Ai, Ax, X, B, Numeric, Control, Info,
Wi, W, Y, Z, S) ;
\end{verbatim}
}
%-------------------------------------------------------------------------------
\subsection{Matrix manipulation routines}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
int Ti [nz], Tj [nz], Bp [n+1], Bi [max(n,nz)], P [n], Q [n], Cp [n+1], Ci [nz] ;
double Tx [nz], Cx [nz], Bx [nz] ;
status = umfpack_col_to_triplet (n, Ap, Tj) ;
status = umfpack_triplet_to_col (n, nz, Ti, Tj, Tx, Bp, Bi, Bx) ;
status = umfpack_transpose (n, Ap, Ai, Ax, P, Q, Cp, Ci, Cx) ;
\end{verbatim}
}
%-------------------------------------------------------------------------------
\subsection{Getting the contents of opaque objects}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
int lnz, unz, Lp [n+1], Li [lnz], Up [n+1], Ui [unz] ;
double Lx [lnz], Ux [unz] ;
int nfr, nchains, nsparse_col, Qtree [n], Front_npivots [n], Front_parent [n],
Chain_start [n], Chain_maxrows [n], Chain_maxcols [n] ;
status = umfpack_get_lunz (&lnz, &unz, &n, Numeric) ;
status = umfpack_get_numeric (Lp, Li, Lx, Up, Ui, Ux, P, Q, Numeric) ;
status = umfpack_get_symbolic (&n, &nz, &nfr, &nchains, &nsparse_col,
Qtree, Front_npivots, Front_parent, Chain_start, Chain_maxrows,
Chain_maxcols, Symbolic) ;
\end{verbatim}
}
Note: the {\tt nsparse\_col} argument is no longer relevant.
It is always equal to {\tt n} in this version.
%-------------------------------------------------------------------------------
\subsection{Reporting routines}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
char *name, *form ;
umfpack_report_status (Control, status) ;
umfpack_report_control (Control) ;
umfpack_report_info (Control, Info) ;
status = umfpack_report_matrix (name, n, Ap, Ai, Ax, form, Control) ;
status = umfpack_report_numeric (name, Numeric, Control) ;
status = umfpack_report_perm (name, n, P, Control) ;
status = umfpack_report_symbolic (name, Symbolic, Control) ;
status = umfpack_report_triplet (name, n, nz, Ti, Tj, Tx, Control) ;
status = umfpack_report_vector (name, n, X, Control) ;
\end{verbatim}
}
%-------------------------------------------------------------------------------
\section{Synopsis of all C-callable routines ({\tt long} version)}
%-------------------------------------------------------------------------------
Each subsection, below, summarizes the input variables, output variables, return
values, and calling sequences of the routines in one category. Variables with
the same name as those already listed in a prior category have the same size
and type. Note that the include file, {\tt umfpack.h}, is the same for both
{\tt int} and {\tt long} versions of UMFPACK.
%-------------------------------------------------------------------------------
\subsection{Primary routines}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
#include "umfpack.h"
long status, n, nz, Ap [n+1], Ai [nz] ;
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO], Ax [nz], X [n], B [n] ;
void *Symbolic, *Numeric ;
char *sys ;
status = umfpack_l_symbolic (n, Ap, Ai, &Symbolic, Control, Info) ;
status = umfpack_l_numeric (Ap, Ai, Ax, Symbolic, &Numeric, Control, Info) ;
status = umfpack_l_solve (sys, Ap, Ai, Ax, X, B, Numeric, Control, Info) ;
umfpack_l_free_symbolic (&Symbolic) ;
umfpack_l_free_numeric (&Numeric) ;
\end{verbatim}
}
%-------------------------------------------------------------------------------
\subsection{Alternative routines}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
long Qinit [n], Wi [n] ;
double W [n], Y [n], Z [n], S [n] ;
umfpack_l_defaults (Control) ;
status = umfpack_l_qsymbolic (n, Ap, Ai, Qinit, &Symbolic, Control, Info) ;
status = umfpack_l_wsolve (sys, Ap, Ai, Ax, X, B, Numeric, Control, Info,
Wi, W, Y, Z, S) ;
\end{verbatim}
}
%-------------------------------------------------------------------------------
\subsection{Matrix manipulation routines}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
long Ti [nz], Tj [nz], Bp [n+1], Bi [max(n,nz)], P [n], Q [n], Cp [n+1], Ci [nz] ;
double Tx [nz], Cx [nz], Bx [nz] ;
status = umfpack_l_col_to_triplet (n, Ap, Tj) ;
status = umfpack_l_triplet_to_col (n, nz, Ti, Tj, Tx, Bp, Bi, Bx) ;
status = umfpack_l_transpose (n, Ap, Ai, Ax, P, Q, Cp, Ci, Cx) ;
\end{verbatim}
}
%-------------------------------------------------------------------------------
\subsection{Getting the contents of opaque objects}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
long lnz, unz, Lp [n+1], Li [lnz], Up [n+1], Ui [unz] ;
double Lx [lnz], Ux [unz] ;
long nfr, nchains, nsparse_col, Qtree [n], Front_npivots [n], Front_parent [n],
Chain_start [n], Chain_maxrows [n], Chain_maxcols [n] ;
status = umfpack_l_get_lunz (&lnz, &unz, &n, Numeric) ;
status = umfpack_l_get_numeric (Lp, Li, Lx, Up, Ui, Ux, P, Q, Numeric) ;
status = umfpack_l_get_symbolic (&n, &nz, &nfr, &nchains, &nsparse_col,
Qtree, Front_npivots, Front_parent, Chain_start, Chain_maxrows,
Chain_maxcols, Symbolic) ;
\end{verbatim}
}
Note: the {\tt nsparse\_col} argument is no longer relevant.
It is always equal to {\tt n} in this version.
%-------------------------------------------------------------------------------
\subsection{Reporting routines}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
char *name, *form ;
umfpack_l_report_status (Control, status) ;
umfpack_l_report_control (Control) ;
umfpack_l_report_info (Control, Info) ;
status = umfpack_l_report_matrix (name, n, Ap, Ai, Ax, form, Control) ;
status = umfpack_l_report_numeric (name, Numeric, Control) ;
status = umfpack_l_report_perm (name, n, P, Control) ;
status = umfpack_l_report_symbolic (name, Symbolic, Control) ;
status = umfpack_l_report_triplet (name, n, nz, Ti, Tj, Tx, Control) ;
status = umfpack_l_report_vector (name, n, X, Control) ;
\end{verbatim}
}
%-------------------------------------------------------------------------------
\section{Synopsis of utility routines}
%-------------------------------------------------------------------------------
This routine is the same in both {\tt int} and {\tt long} versions of UMFPACK.
{\footnotesize
\begin{verbatim}
double t ;
t = umfpack_timer ( ) ;
\end{verbatim}
}
%-------------------------------------------------------------------------------
\section{Installation}
\label{Install}
%-------------------------------------------------------------------------------
UMFPACK comes with a {\tt Makefile} for compiling the C-callable {\tt umfpack.a}
library and the {\tt umfpack} mexFunction on Unix. System-dependent
configurations are controlled by the {\tt Makefile}, and defined in
{\tt umf\_config.h} listed in Section~\ref{Config}. You should not have to
modify {\tt umf\_config.h}.
To compile {\tt umfpack.a} on most Unix systems, all you need to do is to type
{\tt make}. This will use the generic configuration, in {\tt Make.generic}.
The three demo programs will be executed, and the output of
{\tt umfpack\_demo.c} and {\tt umfpack\_l\_demo.c} will be compared with
{\tt umfpack\_demo.out} and {\tt umfpack\_l\_demo.out}. These two demo programs
are identical, except that {\tt umfpack\_demo.c} uses the {\tt int} version,
while {\tt umfpack\_l\_demo.out} uses the {\tt long} version of UMFPACK.
Expect to see a few differences, such as residual norms, compile-time control
settings, and perhaps memory usage differences. (The Compaq Alpha uses the
LP64 model by default, so if you're using that computer compare your output
with the 64-bit Solaris output in {\tt umfpack\_demo.out64} and
{\tt umfpack\_l\_demo.out64}). The BLAS \cite{DaydeDuff99,ACM679a,ATLAS}
will not be used, so the performance of UMFPACK will not be as high as possible.
For better performance, edit the {\tt Makefile} and un-comment the
{\tt include Make.*} statement that is specific to your computer. For example,
{\footnotesize
\begin{verbatim}
# include Make.generic
# include Make.linux
# include Make.sgi
include Make.solaris
# include Make.alpha
# include Make.rs6000
\end{verbatim}
}
will include the Solaris-specific configurations, which uses the Sun Performance
Library BLAS ({\tt sunperf}), and compiler optimizations that are different than
the generic settings. If you change the {\tt Makefile} or your system-specific
{\tt Make.*} file, be sure to type {\tt make purge} before recompiling. Here
are the various parameters that you can control in your {\tt Make.*} file;
more details are in {\tt umf\_config.h} listed in Section~\ref{Config}:
\begin{itemize}
\item {\tt CC = } your C compiler, usually, {\tt cc}. If you don't modify
this string at all in your {\tt Make.*}, then the {\tt make} program will
use your default C compiler (if {\tt make} is installed properly).
\item {\tt RANLIB = } your system's {\tt ranlib} program, if needed.
\item {\tt CFLAGS = } optimization flags, such as {\tt -O}.
\item {\tt CONFIG = } configuration settings.
\item {\tt LIB = } your libraries, such as {\tt -lm} or {\tt -lblas}.
\end{itemize}
The {\tt CONFIG} string can include combinations of the following:
\begin{itemize}
\item {\tt -DNBLAS} if you do not have any BLAS at all. By default,
{\tt umf\_config.h} assumes you have some version of the BLAS. The BLAS
are de-selected in {\tt Make.generic} with the statement
{\tt CONFIG = -DNBLAS}.
\item {\tt -DNCBLAS} if you do not have the C-BLAS \cite{ATLAS}.
The interface to the C-BLAS is identical on any system (Unix or Windows).
By default, {\tt umf\_config.h} assumes you have the C-BLAS,
except for Solaris (which has {\tt sunperf}) and MATLAB,
which has its own BLAS for compiling the MATLAB mexFunction on any system.
\item {\tt -DNSUNPERF} if you are on Solaris but do not have {\tt sunperf}.
\item {\tt -DLONGBLAS} if your BLAS can take {\tt long} integer input
arguments. If not defined, then the {\tt umfpack\_l\_*} version of
UMFPACK that uses {\tt long} integers does not call the BLAS.
\item {\tt -DGETRUSAGE} if you have the {\tt getrusage} function. This should
exist on any UNIX system.
\item Options for controlling how C calls the Fortran BLAS:
{\tt -DBLAS\_BY\_VALUE}, \newline {\tt -DBLAS\_NO\_UNDERSCORE},
and {\tt -DBLAS\_CHAR\_ARG}. These are set automatically for Sun Solaris,
SGI Irix, Red Hat Linux, Compaq Alpha, and AIX (the IBM RS 6000).
\end{itemize}
To compile the {\tt umfpack} mexFunction on Unix, type {\tt make umfpack}. The
MATLAB {\tt mex} command will select the appropriate compiler and compiler flags
for your system, and the BLAS internal to MATLAB will be used. The
{\tt mexopts.sh} file in your UMFPACK directory has been modified from the
MATLAB default; the unmodified version is in {\tt mexopts.sh.orig} for
comparison.
If you're running Windows, and all you want to do is use UMFPACK in MATLAB,
then just type {\tt umfpack\_make} in MATLAB. MATLAB Version 6.0 or higher is
required. You won't be able to use the BLAS when compiling with the {\tt lcc}
compiler provided with MATLAB Version 6.0); you will get an error
stating that {\tt \_dgemm} is undefined. There is no work-around for this
problem. Either use a different C compiler, or don't use the BLAS.
%-------------------------------------------------------------------------------
\section{Future work}
\label{Future}
%-------------------------------------------------------------------------------
Here are a few features that are not in UMFPACK Version 3.2, in no particular
order. They may appear in a future release of UMFPACK. If you are interested,
let me know and I could consider including them:
\begin{enumerate}
\item Future versions may have different default {\tt Control} parameters.
\item a condition number estimator. You can write your own in MATLAB by
making a copy of the built-in MATLAB {\tt condest.m} routine and replacing
{\tt LU} with {\tt umfpack}. Be sure to do so only if your MATLAB license
allows you to, and do not distribute the derivative MATLAB code without
direct permission from The Mathworks, Inc.
\item an estimate of the 1-norm of $\m{PAQ}-\m{LU}$. \newline
See {\tt ftp://ftp.mathworks.com/pub/contrib/v4/linalg/normest1.m}
for a similar algorithm that computes the 1-norm estimate of
$\sigma \m{I}+\m{AA}\tr-\m{LL}\tr$. It can easily be modified to compute
the 1-norm estimate of $\m{PAQ}-\m{LU}$. See also \cite{DavisHager99}.
\item a complex version.
\item when using iterative refinement, the residual $\m{Ax}-\m{b}$ could be
returned by {\tt umfpack\_solve} ({\tt umfpack\_wsolve} already does so,
but this is not documented).
\item the solve routines could handle multiple right-hand sides, and sparse
right-hand sides.
\item an option to redirect the error and diagnostic output to something
other than standard output.
\item permutation to block-triangular-form \cite{Duff78a} for the C-callable
interface.
\item the symbolic and numeric factorization could handle singular matrices,
just like MATLAB's {\tt LU}.
\item the ability to use user-provided {\tt malloc}, {\tt free}, and
{\tt realloc} memory allocation routines. Note that UMFPACK makes very
few calls to these routines.
\item the ability to use user-provided work arrays, so that {\tt malloc},
{\tt free}, and {\tt realloc} realloc are not called. The
{\tt umfpack\_wsolve} routine is one example.
\item future versions may return more statistics in the {\tt Info} array, and
they may use more entries in the {\tt Control} array.
\item use a method that takes time proportional to the number of nonzeros in
$\m{A}$ to analyze $\m{A}$ when {\tt Qinit} is provided (or when
{\tt Qinit} is not provided and {\tt umf\_colamd} ignores "dense" rows)
\cite{GilbertNgPeyton94}. The current method in {\tt umf\_analyze.c} takes
time proportional to the number of nonzeros in the upper bound of $\m{U}$.
\item an option of extracting the diagonal of $\m{U}$ (or other subsets of
$\m{L}$ and $\m{U}$) from the {\tt Numeric} object without having to extract
the entire LU factorization.
\item a Fortran interface (this would probably require modifying UMFPACK to use
user-provided work arrays).
\item a C++ interface.
\item a parallel version using MPI.
\end{enumerate}
%-------------------------------------------------------------------------------
\newpage
\section{The primary UMFPACK routines}
\label{Primary}
%-------------------------------------------------------------------------------
The include files are the same for both {\tt int} and {\tt long} versions of
UMFPACK. The generic integer type is {\tt Int}, which is an {\tt int} or
{\tt long}, depending on which version of UMFPACK you are using.
\subsection{umfpack\_symbolic and umfpack\_l\_symbolic}
{\footnotesize
\begin{verbatim}
int umfpack_symbolic
(
int n,
const int Ap [ ],
const int Ai [ ],
void **Symbolic,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO]
) ;
long umfpack_l_symbolic
(
long n,
const long Ap [ ],
const long Ai [ ],
void **Symbolic,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO]
) ;
int Syntax:
#include "umfpack.h"
void *Symbolic ;
int n, *Ap, *Ai, status ;
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO] ;
status = umfpack_symbolic (n, Ap, Ai, &Symbolic, Control, Info) ;
long Syntax:
#include "umfpack.h"
void *Symbolic ;
long n, *Ap, *Ai, status ;
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO] ;
status = umfpack_l_symbolic (n, Ap, Ai, &Symbolic, Control, Info) ;
Purpose:
Given nonzero pattern of a sparse matrix A in column-oriented form,
umfpack_symbolic performs a column pre-ordering to reduce fill-in
(using UMF_colamd, modified from colamd V2.0 for UMFPACK), and a symbolic
factorization. This is required before the matrix can be numerically
factorized with umfpack_numeric. If you wish to bypass the UMF_colamd
pre-ordering, use umfpack_qsymbolic instead.
Returns:
The status code is returned. See Info [UMFPACK_STATUS], below.
Arguments:
Int n ; Input argument, not modified.
A is an n-by-n matrix. Restriction: n > 0.
Int Ap [n+1] ; Input argument, not modified.
Ap is an integer array of size n+1. On input, it holds the "pointers"
for the column form of the sparse matrix A. Column j of the matrix A
is held in Ai [(Ap [j]) ... (Ap [j+1]-1)]. The first entry, Ap [0],
must be zero, and Ap [j] < Ap [j+1] must hold for all j in the range
0 to n-1. The value nz = Ap [n] is thus the total number of entries
in the pattern of the matrix A. nz must be greater than zero.
Int Ai [nz] ; Input argument, not modified, of size nz = Ap [n].
The nonzero pattern (row indices) for column j is stored in
Ai [(Ap [j]) ... (Ap [j+1]-1)]. The row indices in a given column j
must be in ascending order, and no duplicate row indices may be present.
Row indices must be in the range 0 to n-1 (the matrix is 0-based).
See umfpack_triplet_to_col for how to sort the columns of a matrix
and sum up the duplicate entries. See umfpack_report_matrix for how to
print the matrix A.
void **Symbolic ; Output argument.
**Symbolic is the address of a (void *) pointer variable in the user's
calling routine (see Syntax, above). On input, the contents of this
variable are not defined. On output, this variable holds a (void *)
pointer to the Symbolic object (if successful), or (void *) NULL if
a failure occurred.
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_DENSE_ROW]: rows with more than
max (16, Control [UMFPACK_DENSE_ROW] * 16 * sqrt (n))
entries (after "dense" columns are removed) are ignored in the
column pre-ordering, UMF_colamd. Default: 0.2.
Control [UMFPACK_DENSE_COL]: columns with more than
max (16, Control [UMFPACK_DENSE_COL] * 16 * sqrt (n))
entries are placed placed last in the column pre-ordering by
UMF_colamd. Default: 0.2.
Control [UMFPACK_BLOCK_SIZE]: the block size to use for Level-3 BLAS
in the subsequent numerical factorization (umfpack_numeric).
A value less than 1 is treated as 1. Default: 24. Modifying this
parameter affects when updates are applied to the working frontal
matrix, and can indirectly affect fill-in and operation count.
As long as the block size is large enough (8 or so), this parameter
has modest effect on performance. In Version 3.0, this parameter
was an input to umfpack_numeric, and had a default value of 16.
On a Sun UltraSparc, a block size of 24 is better for larger
matrices (16 is better for smaller ones, but not by much). In the
current version, it is required in the symbolic analysis phase, and
is thus an input to this phase.
double Info [UMFPACK_INFO] ; Output argument, not defined on input.
Contains statistics about the symbolic analysis. If a (double *) NULL
pointer is passed, then no statistics are returned in Info (this is not
an error condition). The entire Info array is cleared (all entries set
to -1) and then the following statistics are computed:
Info [UMFPACK_STATUS]: status code. This is also the return value,
whether or not Info is present.
UMFPACK_OK
Each column of the input matrix contained row indices
in increasing order, with no duplicates. Only in this case
does umfpack_symbolic compute a valid symbolic factorization.
For the other cases below, no Symbolic object is created
(*Symbolic is (void *) NULL).
UMFPACK_ERROR_jumbled_matrix
Columns of input matrix were jumbled (unsorted columns or
duplicate entries).
UMFPACK_ERROR_n_nonpositive
n is less than or equal to zero.
UMFPACK_ERROR_singular_matrix
Matrix is singular.
UMFPACK_ERROR_nz_negative
Number of entries in the matrix is negative.
UMFPACK_ERROR_Ap0_nonzero
Ap [0] is nonzero.
UMFPACK_ERROR_col_length_negative
A column has a negative number of entries.
UMFPACK_ERROR_row_index_out_of_bounds
A row index is out of bounds.
UMFPACK_ERROR_out_of_memory
Insufficient memory to perform the symbolic analysis.
UMFPACK_ERROR_argument_missing
One or more required arguments (Ap and/or Ai) is missing.
UMFPACK_ERROR_internal_error
Something very serious went wrong. This is a bug.
Please contact the author (davis@cise.ufl.edu).
Info [UMFPACK_N]: the value of the input argument n.
Info [UMFPACK_NZ]: the number of entries in the input matrix (Ap [n]).
Info [UMFPACK_SIZE_OF_UNIT]: the number of bytes in a Unit,
for memory usage statistics below.
Info [UMFPACK_SIZE_OF_INT]: the number of bytes in an int.
Info [UMFPACK_SIZE_OF_LONG]: the number of bytes in a long.
Info [UMFPACK_SIZE_OF_POINTER]: the number of bytes in a void *
pointer.
Info [UMFPACK_SIZE_OF_ENTRY]: the number of bytes in a numerical entry.
Info [UMFPACK_NDENSE_ROW]: number of "dense" rows in A. These rows are
ignored when the column pre-ordering is computed in UMF_colamd.
If > 0, then the matrix had to be re-analyzed by UMF_analyze, which
does not ignore these rows. Note that all rows are stored in the
same data structure, regardless of whether they are "sparse",
"dense", or "empty".
Info [UMFPACK_NEMPTY_ROW]: number of "empty" rows in A. These are
rows whose entries are all in "dense" columns. Any given row
is classified as either "dense" or "empty" or "sparse".
Info [UMFPACK_NDENSE_COL]: number of "dense" columns in A.
These columns are ordered last in the factorization.
Any given column is classified as either "dense" or "empty" or
"sparse". All columns are stored in the same data structure,
however (Version 3.0 stored dense columns in a separate dense
array, but this is no longer true for Version 3.1 and following).
Info [UMFPACK_NEMPTY_COL]: number of "empty" columns in A. These are
columns whose entries are all in "dense" rows. These columns are
ordered last in the factorization, along with "dense" columns.
Info [UMFPACK_SYMBOLIC_DEFRAG]: number of garbage collections
performed in UMF_colamd, the column pre-ordering routine, and in
UMF_analyze, which is called if UMF_colamd isn't, or if UMF_colamd
ignores one or more "dense" rows.
Info [UMFPACK_SYMBOLIC_PEAK_MEMORY]: the amount of memory (in Units)
required for umfpack_symbolic to complete. This is roughly
2.2*nz + (20 to 25)*n integers, depending on the matrix. This
count includes the size of the Symbolic object itself, which is
reported in Info [UMFPACK_SYMBOLIC_SIZE].
Info [UMFPACK_SYMBOLIC_SIZE]: the final size of the Symbolic object (in
Units). This is fairly small, roughly (1 to 6)*n integers,
depending on the matrix.
Info [UMFPACK_VARIABLE_INIT_ESTIMATE]: the Numeric object contains two
components. The first is fixed in size (O (n) information, plus
the "dense" part of the LU factors). The second part holds the
sparse LU factors and the contribution blocks from factorized
frontal matrices. This part changes in size during factorization.
Info [UMFPACK_VARIABLE_INIT_ESTIMATE] is the exact size (in Units)
required for this second variable-sized part in order for the
numerical factorization to start.
Info [UMFPACK_VARIABLE_PEAK_ESTIMATE]: the estimated peak size (in
Units) of the variable-sized part of the Numeric object. This is
usually an upper bound, but that is not guaranteed.
Info [UMFPACK_VARIABLE_FINAL_ESTIMATE]: the estimated final size (in
Units) of the variable-sized part of the Numeric object. This is
usually an upper bound, but that is not guaranteed. It holds just
the sparse LU factors.
Info [UMFPACK_NUMERIC_SIZE_ESTIMATE]: an estimate of the final size (in
Units) of the entire Numeric object (both fixed-size and variable-
sized parts), which holds the LU factorization (including the L, U,
P and Q matrices).
Info [UMFPACK_PEAK_MEMORY_ESTIMATE]: an estimate of the total amount of
memory (in Units) required by umfpack_symbolic and umfpack_numeric
to perform both the symbolic and numeric factorization. This is the
larger of the amount of memory needed in umfpack_numeric itself, and
the amount of memory needed in umfpack_symbolic
(Info [UMFPACK_SYMBOLIC_PEAK_MEMORY]). The count includes the size
of both the Symbolic and Numeric objects themselves.
Info [UMFPACK_FLOPS_ESTIMATE]: an estimate of the total floating-point
operations required to factorize the matrix. This is a "true"
theoretical estimate of the number of flops that would be performed
by a flop-parsimonious sparse LU algorithm. It assumes that no
extra flops are performed except for what is strictly required to
compute the LU factorization. It ignores, for example, the flops
performed by umfpack_numeric to add contribution blocks of frontal
matrices together. If L and U are the upper bound on the pattern
of the factors, then this flop count estimate can be represented in
Matlab as:
Lnz = full (sum (spones (L))) - 1 ; % nz in each col of L
Unz = full (sum (spones (U')))' - 1 ; % nz in each row of U
flops = 2*Lnz*Unz + sum (Lnz) ;
The flop counts include add, subtract, multiply, and divide. They
exclude max, absolute value computations, and comparisons.
The actual "true flop" count found by umfpack_numeric will be less
than this estimate.
Info [UMFPACK_LNZ_ESTIMATE]: an estimate of the number of nonzeros in
L, including the diagonal. Since L is unit-diagonal, the diagonal
of L is not stored. This estimate is a strict upper bound on the
actual nonzeros in L to be computed by umfpack_numeric.
Info [UMFPACK_UNZ_ESTIMATE]: an estimate of the number of nonzeros in
U, including the diagonal. This estimate is a strict upper bound on
the actual nonzeros in U to be computed by umfpack_numeric.
Info [UMFPACK_SYMBOLIC_TIME]: The time taken by umfpack_symbolic, in
seconds. In the ANSI C version, this may be invalid if the time
taken is more than about 36 minutes, because of wrap-around in
the ANSI C clock ( ) function. Compile UMFPACK with -DGETRUSAGE
if you have the more accurate getrusage ( ) function.
At the start of umfpack_symbolic, all of Info is set of -1, and then
after that only the above listed Info [...] entries are accessed.
Future versions might modify different parts of Info.
\end{verbatim}
}
\newpage
\subsection{umfpack\_numeric and umfpack\_l\_numeric}
{\footnotesize
\begin{verbatim}
int umfpack_numeric
(
const int Ap [ ],
const int Ai [ ],
const double Ax [ ],
void *Symbolic,
void **Numeric,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO]
) ;
long umfpack_l_numeric
(
const long Ap [ ],
const long Ai [ ],
const double Ax [ ],
void *Symbolic,
void **Numeric,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO]
) ;
int Syntax:
#include "umfpack.h"
void *Symbolic, *Numeric ;
int *Ap, *Ai, status ;
double *Ax, Control [UMFPACK_CONTROL], Info [UMFPACK_INFO] ;
status = umfpack_numeric (Ap, Ai, Ax, Symbolic, &Numeric, Control, Info) ;
long Syntax:
#include "umfpack.h"
void *Symbolic, *Numeric ;
long *Ap, *Ai, status ;
double *Ax, Control [UMFPACK_CONTROL], Info [UMFPACK_INFO] ;
status = umfpack_l_numeric (Ap, Ai, Ax, Symbolic, &Numeric, Control, Info) ;
Purpose:
Given a sparse matrix A in column-oriented form, and a symbolic analysis
computed by umfpack_symbolic, the umfpack_numeric routine performs the
numerical factorization, PAQ=LU, where P and Q are permutation matrices
(represented as permutation vectors), L is unit-lower triangular, and U
is upper triangular. This is required before the system Ax=b (or other
related linear systems) can be solved. umfpack_numeric can be called
multiple times for each call to umfpack_symbolic, to factorize a sequence
of matrices with identical nonzero pattern. Simply compute the Symbolic
object once, with umfpack_*symbolic, and reuse it for subsequent matrices.
umfpack_numeric safely detects if the pattern changes, and sets an
appropriate error code.
Returns:
The status code is returned. See Info [UMFPACK_STATUS], below.
Arguments:
Int Ap [n+1] ; Input argument, not modified.
This must be identical to the Ap array passed to umfpack_symbolic.
The value of n is what was passed to umfpack_symbolic (this is held in
the Symbolic object).
Int Ai [nz] ; Input argument, not modified, of size nz = Ap [n].
This must be identical to the Ai array passed to umfpack_symbolic.
Not all changes to Ai and Ap are detected; if the matrix has the same
number of nonzeros and can be factorized in the existing frontal
matrices as defined in the Symbolic object, then umfpack_numeric will
not complain, and will successfully factorize the matrix and return a
valid Numeric object.
double Ax [nz] ; Input argument, not modified, of size nz = Ap [n].
The numerical values of the sparse matrix A. The nonzero pattern (row
indices) for column j is stored in Ai [(Ap [j]) ... (Ap [j+1]-1)], and
the corresponding numerical values are stored in
Ax [(Ap [j]) ... (Ap [j+1]-1)].
void *Symbolic ; Input argument, not modified.
The Symbolic object, which holds the symbolic factorization computed by
umfpack_symbolic. The Symbolic object is not modified by
umfpack_numeric.
void **Numeric ; Output argument.
**Numeric is the addres of a (void *) pointer variable in the user's
calling routine (see Syntax, above). On input, the contents of this
variable are not defined. On output, this variable holds a (void *)
pointer to the Numeric object (if successful), or (void *) NULL if
a failure occurred.
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_PIVOT_TOLERANCE]: relative pivot tolerance for
threshold partial pivoting with row interchanges. In any given
column, an entry is numerically acceptable if it is greater than or
equal to Control [UMFPACK_PIVOT_TOLERANCE] times the largest
absolute value in the column. A value of 1.0 gives true partial
pivoting. A value of zero is treated as 1.0. Default: 0.1.
Smaller values tend to lead to sparser LU factors, but the solution
to the linear system can become inaccurate. Larger values can lead
to a more accurate solution (but not always), and usually an
increase in the total work.
Control [UMFPACK_RELAXED_AMALGAMATION]: This controls the creation of
"elements" (small dense submatrices) that are formed when a frontal
matrix is factorized. A new element is created if the current one,
plus the new pivot, contains "too many" explicitly zero numerical
entries. The two elements are merged if the number of extra zero
entries is < Control [UMFPACK_RELAXED_AMALGAMATION] times the
size of the merged element. A lower setting
decreases fill-in, but run-time and memory usage can increase.
A larger setting increases fill-in (because the extra zeros are
treated as normal entries during pivot selection), but this can
lead to an increase in run-time but (paradoxically) a decrease in
memory usage (one merged elements can take less space than two
separate elements). Except for the initial column ordering,
this parameter has the most impact on the run-time, fill-in,
operation count, and memory usage.
Default: 0.25, which is fine for nearly all matrices.
(For nearly all matrices, different values of this parameter can
decrease the run-time by at most 5%, but can also dramatically
increase the run time for some matrices).
Control [UMFPACK_RELAXED2_AMALGAMATION]: This, along with the block
size (Control [UMFPACK_BLOCK_SIZE]), controls how often the
pending updates are applied when the next pivot entry resides in
the current frontal matrix. If the number of zero entries in the
LU part of the current frontal matrix would exceed this parameter
times the size of the LU part, then the pending updates are applied
before the next pivot is included in the frontal matrix.
Default: 0.20 (that is, more than 10% zero entries causes the
pending updates to be applied). This input parameter is new
since Version 3.1.
Control [UMFPACK_RELAXED3_AMALGAMATION]: This, along with the block
size (Control [UMFPACK_BLOCK_SIZE]), controls how often the
pending updates are applied when the next pivot entry does NOT reside
in the current frontal matrix. If the number of zero entries in the
LU part of the current frontal matrix would exceed this parameter
times the size of the LU part, then the pending updates are applied
before the next pivot is included in the frontal matrix.
Default: 0.10 (that is, more than 10% zero entries causes the
pending updates to be applied). This input parameter is new
since Version 3.1.
Control [UMFPACK_ALLOC_INIT]: When umfpack_numeric starts, it allocates
memory for the Numeric object. Part of this is of fixed size
(approximately n double's + 12*n integers).
The remainder is of variable size, which grows to hold the LU
factors and the frontal matrices created during factorization.
A estimate of the upper bound is computed by umfpack_symbolic, and
returned by umfpack_*symbolic in
Info [UMFPACK_VARIABLE_PEAK_ESTIMATE]. umfpack_numeric initially
allocates space for the variable-sized part equal to this estimate
times Control [UMFPACK_ALLOC_INIT]. Typically, umfpack_numeric
needs only about half the estimated memory space, so a setting of
0.5 or 0.6 often provides enough memory for umfpack_numeric to
factorize the matrix with no subsequent increases in the size of
this block. A value less than zero is treated as zero (in which
case, just the bare minimum amount of memory needed to start the
factorization is initially allocated). The bare initial memory
required is returned by umfpack_*symbolic in
Info [UMFPACK_VARIABLE_INIT_ESTIMATE] (which in fact not an
estimate, but exact). If the variable-size part of the Numeric
object is found to be too small sometime after numerical
factorization has started, the memory is increased in size by a
factor of 1.2. If this fails, the request is reduced by a factor
of 0.95 until it succeeds, or until it determines that no increase
in size is possible. Garbage collection then occurs. These two
factors (1.2 and 0.95) are fixed control parameters defined in
umf_internal.h and cannot be changed at run-time. You would need
to edit umf_internal.h to modify them. If you do this, be sure that
the two factors are greater than 1 and less than 1, respectively.
The strategy of attempting to malloc a working space, and re-trying
with a smaller space, may not work under Matlab, since mxMalloc
aborts the mexFunction if it fails. I may try to address this is
issue in a future release - in the mean time, decrease
Control [UMFPACK_ALLOC_INIT] if you run out of memory in Matlab.
Default initial allocation size: 0.7. Thus, with the default
control settings, the upper-bound is reached after two reallocations
(0.7 * 1.2 * 1.2 = 1.008).
Changing this parameter has no affect on fill-in or operation count.
It has a small impact on run-time (the extra time required to do
the garbage collection and memory reallocation).
Control [UMFPACK_PIVOT_OPTION]: If this is nonzero, then entries on
the diagonal of A are given preference over off-diagonal entries.
This can improve the fill-in on matrices with symmmetric nonzero
pattern. Default: 0 (do not give preference to the diagonal of A).
This parameter was added for UMFPACK Version 3.1.
double Info [UMFPACK_INFO] ; Output argument.
Contains statistics about the numeric factorization. If a
(double *) NULL pointer is passed, then no statistics are returned in
Info (this is not an error condition). The following statistics are
computed in umfpack_numeric:
Info [UMFPACK_STATUS]: status code. This is also the return value,
whether or not Info is present.
UMFPACK_OK
Numeric factorization was successful. Only in this case
does umfpack_numeric compute a valid numeric factorization.
For the other cases below, no Numeric object is created
(*Numeric is (void *) NULL).
UMFPACK_ERROR_out_of_memory
Insufficient memory to complete the numeric factorization.
UMFPACK_ERROR_argument_missing
One or more required arguments (Ap, Ai, and/or Ax) are missing.
UMFPACK_ERROR_singular_matrix
The input matrix is singular.
UMFPACK_ERROR_invalid_Symbolic_object
Symbolic object provided as input is invalid.
UMFPACK_ERROR_different_pattern
The pattern (Ap and/or Ai) has changed since the call to
umfpack_*symbolic which produced the Symbolic object.
Info [UMFPACK_N]: the value of n stored in the Symbolic object.
Info [UMFPACK_NZ]: the number of entries in the input matrix.
This value is obtained from the Symbolic object.
Info [UMFPACK_SIZE_OF_UNIT]: the number of bytes in a Unit, for memory
usage statistics below.
Info [UMFPACK_VARIABLE_INIT]: the initial size (in Units) of the
variable-sized part of the Numeric object. If this differs from
Info [UMFPACK_VARIABLE_INIT_ESTIMATE], then the pattern (Ap and/or
Ai) has changed since the last call to umfpack_*symbolic, which is
an error condition.
Info [UMFPACK_VARIABLE_PEAK]: the peak size (in Units) of the
variable-sized part of the Numeric object. This size is the amount
of space actually used inside the block of memory, not the space
allocated via UMF_malloc. You can reduce UMFPACK's memory
requirements by setting Control [UMFPACK_ALLOC_INIT] to the ratio
Info [UMFPACK_VARIABLE_PEAK] / Info[UMFPACK_VARIABLE_PEAK_ESTIMATE].
This will ensure that no memory reallocations occur (you may want to
add 0.001 to make sure that integer roundoff does not lead to a
memory size that is 1 Unit too small; otherwise, garbage collection
and reallocation will occur).
Info [UMFPACK_VARIABLE_FINAL]: the final size (in Units) of the
variable-sized part of the Numeric object. It holds just the
sparse LU factors.
Info [UMFPACK_NUMERIC_SIZE]: the actual final size (in Units) of the
entire Numeric object, including the final size of the variable
part of the object. Info [UMFPACK_NUMERIC_SIZE_ESTIMATE],
an estimate, was computed by umfpack_symbolic. The estimate is
normally an upper bound on the actual final size, but this is not
guaranteed.
Info [UMFPACK_PEAK_MEMORY]: the actual peak memory usage (in Units) of
both umfpack_symbolic and umfpack_numeric. An estimate,
Info [UMFPACK_PEAK_MEMORY_ESTIMATE], was computed by
umfpack_symbolic. The estimate is normally an upper bound on the
actual peak usage, but this is not guaranteed. With testing on
hundreds of matrix arising in real applications, I have never
observed a matrix where this estimate or the Numeric size estimate
was less than the actual result, but this is theoretically possible.
Please send me one if you find such a matrix.
Info [UMFPACK_FLOPS]: the actual count of the (useful) floating-point
operations performed. An estimate, Info [UMFPACK_FLOPS_ESTIMATE],
was computed by umfpack_symbolic. The estimate is guaranteed to be
an upper bound on this flop count. The flop count excludes
"useless" flops on zero values, flops performed during the pivot
search (for tentative updates and assembly of candidate columns),
and flops performed to add frontal matrices together. It does
include the flops performed to factorize the "dense" and "empty"
columns.
Info [UMFPACK_LNZ]: the actual nonzero entries in final factor L,
including the diagonal. This excludes any zero entries in L,
although some of these are stored in the Numeric object. It does
include entries in "dense" or "empty" columns. The
Info [UMFPACK_LU_ENTRIES] statistic does account for all
explicitly stored zeros, however. Info [UMFPACK_LNZ_ESTIMATE],
an estimate, was computed by umfpack_symbolic. The estimate is
guaranteed to be an upper bound on Info [UMFPACK_LNZ].
Info [UMFPACK_UNZ]: the actual nonzero entries in final factor U,
including the diagonal. This excludes any zero entries in U,
although some of these are stored in the Numeric object. It does
include entries in "dense" or "empty" columns. The
Info [UMFPACK_LU_ENTRIES] statistic does account for all
explicitly stored zeros, however. Info [UMFPACK_UNZ_ESTIMATE],
an estimate, was computed by umfpack_symbolic. The estimate is
guaranteed to be an upper bound on Info [UMFPACK_UNZ].
Info [UMFPACK_NUMERIC_DEFRAG]: The number of garbage collections
performed during umfpack_numeric, to compact contents of the
variable-sized workspace used by umfpack_numeric. No estimate was
computed by umfpack_symbolic. In the current version of UMFPACK,
garbage collection is performed and then the memory is reallocated,
so this statistic is the same as Info [UMFPACK_NUMERIC_REALLOC],
below. It may differ in future releases.
Info [UMFPACK_NUMERIC_REALLOC]: The number of times that the Numeric
object was increased in size from its initial size. A rough upper
bound on the peak size of the Numeric object was computed by
umfpack_symbolic, so reallocations should be rare. However, if
umfpack_numeric is unable to allocate that much storage, it reduces
its request until either the allocation succeeds, or until it gets
too small to do anything with. If the memory that it finally got
was small, but usable, then the reallocation count could be high.
No estimate of this count was computed by umfpack_symbolic.
Info [UMFPACK_NUMERIC_COSTLY_REALLOC]: The number of times that the
system realloc ( ) library routine had to move the workspace.
Realloc can sometimes increase the size of a block of memory
without moving it, which is much faster. This statistic will
always be <= Info [UMFPACK_NUMERIC_REALLOC]. If your memory space
is fragmented, then the number of "costly" realloc's will be equal
to Info [UMFPACK_NUMERIC_REALLOC].
Info [UMFPACK_COMPRESSED_PATTERN]: The number of integers used to
represent the pattern of "sparse" part L and U. The "sparse" part
of L and U excludes entries on the diagonal, which is stored
separately. It excludes entries in the "dense" and "empty"
columns. Those are stored together in a single dense array of
size n by (Info [UMFPACK_NDENSE_COL] + Info [UMFPACK_NEMPTY_COL]),
and no integers are required to represent their pattern.
Info [UMFPACK_LU_ENTRIES]: The total number of numerical values that
are stored for the LU factors, including the dense array for "dense"
and "empty" columns. Some of the values may be explicitly zero.
Info [UMFPACK_NUMERIC_TIME]: The time taken by umfpack_numeric, in
seconds. In the ANSI C version, this may be invalid if the time
taken is more than about 36 minutes, because of wrap-around in
the ANSI C clock ( ) function. Compile UMFPACK with -DGETRUSAGE
if you have the more accurate getrusage ( ) function.
Only the above listed Info [...] entries are accessed. The remaining
entries of Info are not accessed or modified by umfpack_numeric.
Future versions might modify different parts of Info.
\end{verbatim}
}
\newpage
\subsection{umfpack\_solve and umfpack\_l\_solve}
{\footnotesize
\begin{verbatim}
int umfpack_solve
(
const char sys [ ],
const int Ap [ ],
const int Ai [ ],
const double Ax [ ],
double X [ ],
const double B [ ],
void *Numeric,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO]
) ;
long umfpack_l_solve
(
const char sys [ ],
const long Ap [ ],
const long Ai [ ],
const double Ax [ ],
double X [ ],
const double B [ ],
void *Numeric,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO]
) ;
int Syntax:
#include "umfpack.h"
void *Numeric ;
int status, *Ap, *Ai ;
char *sys ;
double *B, *X, *Ax, Info [UMFPACK_INFO], Control [UMFPACK_CONTROL] ;
status = umfpack_solve (sys, Ap, Ai, Ax, X, B, Numeric, Control, Info) ;
long Syntax:
#include "umfpack.h"
void *Numeric ;
long status, *Ap, *Ai ;
char *sys ;
double *B, *X, *Ax, Info [UMFPACK_INFO], Control [UMFPACK_CONTROL] ;
status = umfpack_l_solve (sys, Ap, Ai, Ax, X, B, Numeric, Control, Info);
Purpose:
Given LU factors computed by umfpack_numeric (PAQ=LU) and the
right-hand-side, B, solve a linear system for the solution X. Iterative
refinement is optionally performed. This routine dynamically allocates
workspace of size O(n).
Returns:
The status code is returned. See Info [UMFPACK_STATUS], below.
Arguments:
char sys [ ] ; Input argument, not modified.
A string that defines which system to solve. Iterative refinement can
be optionally performed when the sys argument is:
"Ax=b"
"A'x=b"
For these values of the sys argument, iterative refinement is not
performed (Control [UMFPACK_IRSTEP], Ap, Ai, and Ax are ignored):
"P'Lx=b"
"L'Px=b"
"UQ'x=b"
"QU'x=b"
"Lx=b"
"L'x=b"
"Ux=b"
"U'x=b"
Int Ap [n+1] ; Input argument, not modified.
Int Ai [nz] ; Input argument, not modified.
double Ax [nz] ; Input argument, not modified.
If iterative refinement is requested (Control [UMFPACK_IRSTEP] >= 1 and
Ax=b or A'x=b is being solved), then these arrays must be identical to
the same ones passed to umfpack_numeric. The umfpack_solve routine
does not check the contents of these three arguments, so the results
are undefined if Ap, Ai, and/or Ax are modified between the calls the
umfpack_numeric and umfpack_solve. These three arrays do not need to
be present (NULL pointers can be passed) if Control [UMFPACK_IRSTEP] is
zero, or if a system other than Ax=b or A'x=b is being solved.
double X [n] ; Output argument.
The solution to the linear system.
double B [n] ; Input argument, not modified.
The right-hand side vector, b, stored as a conventional array of size n.
This routine does not solve for multiple right-hand-sides, nor does it
allow b to be stored in a sparse-column form.
void *Numeric ; Input argument, not modified.
Numeric must point to a valid Numeric object, computed by
umfpack_numeric.
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_IRSTEP]: The maximum number of iterative refinement
steps to attempt. A value less than zero is treated as zero. If
less than 1, or if Ax=b or A'x=b is not being solved, then the Ap,
Ai, and Ax arguments are not accessed. Default: 2.
double Info [UMFPACK_INFO] ; Output argument.
Contains statistics about the solution factorization. If a
(double *) NULL pointer is passed, then no statistics are returned in
Info (this is not an error condition). The following statistics are
computed in umfpack_solve:
Info [UMFPACK_STATUS]: status code. This is also the return value,
whether or not Info is present.
UMFPACK_OK
The linear system was successfully solved.
UMFPACK_ERROR_out_of_memory
Insufficient memory to solve the linear system.
UMFPACK_ERROR_argument_missing
One or more required arguments are missing. The B, X, and
sys arguments are always required. Info and Control are
not required. Ap, Ai, and Ax are required if Ax=b or A'x=b
is to be solve and the (default) iterative refinement is
requested.
UMFPACK_ERROR_invalid_Numeric_object
The Numeric object is not valid.
Info [UMFPACK_N]: the value of n stored in the Numeric object.
Info [UMFPACK_NZ]: the number of entries in the input matrix, Ap [n],
if iterative refinement is requested (sys is "Ax=b" or "A'x=b"
and Control [UMFPACK_IRSTEP] >= 1).
Info [UMFPACK_IR_TAKEN]: The number of iterative refinement steps
effectively taken. The number of steps attempted may be one more
than this; the refinement algorithm backtracks if the last
refinement step worsens the solution. This is set to -1 if
iterative refinement was not requested.
Info [UMFPACK_IR_ATTEMPTED]: The number of iterative refinement steps
attempted. The number of times a linear system was solved is one
more than this (once for the initial Ax=b, and once for each Ay=r
solved for each iterative refinement step attempted). This
statistic is set to -1 if iterative refinement was not requested.
Info [UMFPACK_OMEGA1]: sparse backward error estimate, omega1, if
iterative refinement was performed, or -1 if iterative refinement
not performed.
Info [UMFPACK_OMEGA2]: sparse backward error estimate, omega2, if
iterative refinement was performed, or -1 if iterative refinement
not performed.
Info [UMFPACK_SOLVE_FLOPS]: the number of floating point operations
performed to solve the linear system. This includes the work
taken for all iterative refinement steps, including the backtrack
(if any).
Info [UMFPACK_SOLVE_TIME]: The time taken by umfpack_solve, in
seconds. In the ANSI C version, this may be invalid if the time
taken is more than about 36 minutes, because of wrap-around in
the ANSI C clock ( ) function. Compile UMFPACK with -DGETRUSAGE
if you have the more accurate getrusage ( ) function.
Only the above listed Info [...] entries are accessed. The remaining
entries of Info are not accessed or modified by umfpack_solve.
Future versions might modify different parts of Info.
\end{verbatim}
}
\newpage
\subsection{umfpack\_free\_symbolic and umfpack\_l\_free\_symbolic}
{\footnotesize
\begin{verbatim}
void umfpack_free_symbolic
(
void **Symbolic
) ;
void umfpack_l_free_symbolic
(
void **Symbolic
) ;
int Syntax:
#include "umfpack.h"
void *Symbolic ;
umfpack_free_symbolic (&Symbolic) ;
long Syntax:
#include "umfpack.h"
void *Symbolic ;
umfpack_l_free_symbolic (&Symbolic) ;
Purpose:
Deallocates the Symbolic object and sets the Symbolic handle to NULL.
This routine is the only valid way of destroying the Symbolic object;
any other action (such as using "free (Symbolic) ;" or not freeing Symbolic
at all) will lead to memory leaks.
Arguments:
void **Symbolic ; Input argument, deallocated and Symbolic is
set to (void *) NULL on output.
Symbolic must point to a valid Symbolic object, computed by
umfpack_symbolic. No action is taken if Symbolic is a (void *) NULL
pointer.
\end{verbatim}
}
\newpage
\subsection{umfpack\_free\_numeric and umfpack\_l\_free\_numeric}
{\footnotesize
\begin{verbatim}
void umfpack_free_numeric
(
void **Numeric
) ;
void umfpack_l_free_numeric
(
void **Numeric
) ;
int Syntax:
#include "umfpack.h"
void *Numeric ;
umfpack_free_numeric (&Numeric) ;
long Syntax:
#include "umfpack.h"
void *Numeric ;
umfpack_l_free_numeric (&Numeric) ;
Purpose:
Deallocates the Numeric object and sets the Numeric handle to NULL.
This routine is the only valid way of destroying the Numeric object;
any other action (such as using "free (Numeric) ;" or not freeing Numeric
at all) will lead to memory leaks.
Arguments:
void **Numeric ; Input argument, deallocated and Numeric is
set to (void *) NULL on output.
Numeric must point to a valid Numeric object, computed by
umfpack_numeric. No action is taken if Numeric is a (void *) NULL
pointer.
\end{verbatim}
}
%-------------------------------------------------------------------------------
\newpage
\section{Alternatives routines}
\label{Alternative}
%-------------------------------------------------------------------------------
\subsection{umfpack\_defaults and umfpack\_l\_defaults}
\label{defaults}
{\footnotesize
\begin{verbatim}
void umfpack_defaults
(
double Control [UMFPACK_CONTROL]
) ;
void umfpack_l_defaults
(
double Control [UMFPACK_CONTROL]
) ;
int Syntax:
#include "umfpack.h"
double Control [UMFPACK_CONTROL] ;
umfpack_defaults (Control) ;
long Syntax:
#include "umfpack.h"
double Control [UMFPACK_CONTROL] ;
umfpack_l_defaults (Control) ;
Purpose:
Sets the default control parameter settings.
Arguments:
double Control [UMFPACK_CONTROL] ; Output argument.
Control is set to the default control parameter settings. You can
then modify individual settings by changing specific entries in the
Control array. If Control is a (double *) NULL pointer, then
umfpack_defaults returns silently (no error is generated, since
passing a NULL pointer for Control to any UMFPACK routine is valid).
\end{verbatim}
}
\newpage
\subsection{umfpack\_qsymbolic and umfpack\_l\_qsymbolic}
{\footnotesize
\begin{verbatim}
int umfpack_qsymbolic
(
int n,
const int Ap [ ],
const int Ai [ ],
const int Qinit [ ],
void **Symbolic,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO]
) ;
long umfpack_l_qsymbolic
(
long n,
const long Ap [ ],
const long Ai [ ],
const long Qinit [ ],
void **Symbolic,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO]
) ;
int Syntax:
#include "umfpack.h"
void *Symbolic ;
int n, *Ap, *Ai, *Qinit, status ;
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO] ;
status = umfpack_qsymbolic (n, Ap, Ai, Qinit, &Symbolic, Control, Info) ;
long Syntax:
#include "umfpack.h"
void *Symbolic ;
long n, *Ap, *Ai, *Qinit, status ;
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO] ;
status = umfpack_l_qsymbolic (n, Ap, Ai, Qinit, &Symbolic, Control, Info) ;
Purpose:
Given the nonzero pattern of a sparse matrix A in column-oriented form, and
a sparsity preserving column preordering Qinit, umfpack_qsymbolic performs
the symbolic factorization of A*Qinit (or A (:,Qinit) in Matlab notation).
It also computes the column elimination tree post-ordering. This is
identical to umfpack_symbolic, except that colamd is not called and the
user input column order Qinit is used instead. Note that in general, the
Qinit passed to umfpack_qsymbolic will differ from the final Q found in
umfpack_numeric, because of the column etree postordering done in
umfpack_qsymbolic and sparsity-preserving modifications made within each
frontal matrix during umfpack_numeric.
*** WARNING *** A poor choice of Qinit can easily cause umfpack_numeric to
use a huge amount of memory and do a lot of work. The "default" symbolic
analysis method is umfpack_symbolic, not this routine. If you use this
routine, the performance of UMFPACK is your responsibility; UMFPACK will
not try to second-guess a poor choice of Qinit. If you are unsure about
the quality of your Qinit, then call both umfpack_symbolic and
umfpack_qsymbolic, and pick the one with lower estimates of work and
memory usage (Info [UMFPACK_FLOPS_ESTIMATE] and
Info [UMFPACK_PEAK_MEMORY_ESTIMATE]). Don't forget to call
umfpack_free_symbolic to free the Symbolic object that you don't need.
Returns:
The value of Info [UMFPACK_STATUS]; see below.
Arguments:
All arguments are the same as umfpack_symbolic, except for the following:
Int Qinit [n] ; Input argument, not modified.
The user's fill-reducing initial column preordering. This must be a
permutation of 0..n-1. If Qinit [k] = j, then column j is the kth
column of the matrix A (:,Qinit) to be factorized. If Qinit is an
(Int *) NULL pointer, then colamd is called instead. In fact,
Symbolic = umfpack_symbolic (n, Ap, Ai, Control, Info) ;
is identical to
Symbolic = umfpack_qsymbolic (n, Ap, Ai, (Int *) NULL, Control, Info) ;
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
Identical to umfpack_symbolic if Qinit is (Int *) NULL. Otherwise,
if Qinit is present, it is identical to umfpack_symbolic except for the
following:
Control [UMFPACK_DENSE_ROW]: ignored.
Control [UMFPACK_DENSE_COL]: Let j be the leftmost column in
A (:,Qinit) with more entries than the value determined by the
dense column control parameter (see umfpack_symbolic), or j=n if
there is no such column. Columns j through n-1 are all treated as
"dense", and factorized in a (n-j)-by-n dense array. When
determining Qinit, be sure the "dense" columns of A (:,Qinit) are
as far to the right as possible.
double Info [UMFPACK_INFO] ; Output argument, not defined on input.
Identical to umfpack_symbolic if Qinit is (Int *) NULL. Otherwise,
if Qinit is present, it is identical to umfpack_symbolic except for the
following:
Info [UMFPACK_NDENSE_ROW]: zero
Info [UMFPACK_NEMPTY_ROW]: zero
Info [UMFPACK_NDENSE_COL]: n-j, where j is defined above.
Info [UMFPACK_NEMPTY_COL]: zero
\end{verbatim}
}
\newpage
\subsection{umfpack\_wsolve and umfpack\_l\_wsolve}
{\footnotesize
\begin{verbatim}
int umfpack_wsolve
(
const char sys [ ],
const int Ap [ ],
const int Ai [ ],
const double Ax [ ],
double X [ ],
const double B [ ],
void *Numeric,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO],
int Wi [ ],
double W [ ],
double Y [ ],
double Z [ ],
double S [ ]
) ;
long umfpack_l_wsolve
(
const char sys [ ],
const long Ap [ ],
const long Ai [ ],
const double Ax [ ],
double X [ ],
const double B [ ],
void *Numeric,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO],
long Wi [ ],
double W [ ],
double Y [ ],
double Z [ ],
double S [ ]
) ;
int Syntax:
#include "umfpack.h"
void *Numeric ;
int status, *Ap, *Ai ;
char *sys ;
double *B, *X, *Ax, Info [UMFPACK_INFO], Control [UMFPACK_CONTROL] ;
int *Wi ;
double *W, *Y, *Z, *S ;
status = umfpack_wsolve (sys, Ap, Ai, Ax, X, B, Numeric, Control, Info,
Wi, W, Y, Z, S) ;
long Syntax:
#include "umfpack.h"
void *Numeric ;
long status, *Ap, *Ai ;
char *sys ;
double *B, *X, *Ax, Info [UMFPACK_INFO], Control [UMFPACK_CONTROL] ;
long *Wi ;
double *W, *Y, *Z, *S ;
status = umfpack_l_wsolve (sys, Ap, Ai, Ax, X, B, Numeric, Control, Info,
Wi, W, Y, Z, S) ;
Purpose:
Given LU factors computed by umfpack_numeric (PAQ=LU) and the
right-hand-side, B, solve a linear system for the solution X. Iterative
refinement is optionally performed. This routine is identical to
umfpack_solve, except that it does not dynamically allocate any workspace.
When you have many linear systems to solve, this routine is slightly faster
than umfpack_solve, since the workspace (Wi, W, Y, Z, and S) needs to be
allocated only once, prior to calling umfpack_wsolve.
Returns:
The status code is returned. See Info [UMFPACK_STATUS], below.
Arguments:
char sys [ ] ; Input argument, not modified.
Int Ap [n+1] ; Input argument, not modified.
Int Ai [nz] ; Input argument, not modified.
double Ax [nz] ; Input argument, not modified.
double X [n] ; Output argument.
double B [n] ; Input argument, not modified.
void *Numeric ; Input argument, not modified.
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
double Info [UMFPACK_INFO] ; Output argument.
The above arguments are identical to umfpack_solve, except that the
error code UMFPACK_ERROR_out_of_memory will not be returned in
Info [UMFPACK_STATUS], since umfpack_wsolve does not allocate any
memory.
Int Wi [2*n] ; Workspace.
double W [n] ; Workspace.
double Y [n] ; Workspace, only needed for iterative refinement.
double Z [n] ; Workspace, only needed for iterative refinement.
double S [n] ; Workspace, only needed for iterative refinement.
The Wi, W, Y, Z, and S arguments are workspace used by umfpack_wsolve.
Their contents are undefined on output.
\end{verbatim}
}
%-------------------------------------------------------------------------------
\newpage
\section{Matrix manipulation routines}
\label{Manipulate}
%-------------------------------------------------------------------------------
\subsection{umfpack\_col\_to\_triplet and umfpack\_l\_col\_to\_triplet}
{\footnotesize
\begin{verbatim}
int umfpack_col_to_triplet
(
int n,
const int Ap [ ],
int Tj [ ]
) ;
long umfpack_l_col_to_triplet
(
long n,
const long Ap [ ],
long Tj [ ]
) ;
int Syntax:
#include "umfpack.h"
int n, *Tj, *Ap, status ;
status = umfpack_col_to_triplet (n, Ap, Tj) ;
long Syntax:
#include "umfpack.h"
long n, *Tj, *Ap, status ;
status = umfpack_l_col_to_triplet (n, Ap, Tj) ;
Purpose:
Converts a column-oriented matrix to a triplet form. Only the column
pointers, Ap, are required, and only the column indices of the triplet form
are constructed. This routine is the opposite of umfpack_triplet_to_col.
The matrix may be singular.
Returns:
UMFPACK_OK if successful
UMFPACK_ERROR_argument_missing if Ap or Tj is missing
UMFPACK_ERROR_n_nonpositive if n <= 0
UMFPACK_ERROR_Ap0_nonzero if Ap [0] != 0
UMFPACK_ERROR_nz_negative if Ap [n] < 0
UMFPACK_ERROR_col_length_negative if Ap [j] > Ap [j+1] for any j in the
range 0 to n-1.
Empty rows, unsorted columns, and duplicate entries do not cause an error
(these would only be evident by examining Ai). Empty columns are OK.
Arguments:
Int n ; Input argument, not modified.
A is an n-by-n matrix. Restriction: n > 0.
Int Ap [n+1] ; Input argument, not modified.
The column pointers of the column-oriented form of the matrix. See
umfpack_symbolic for a description. The number of entries in
the matrix is nz = Ap [n]. Restrictions on Ap are the same as those
for umfpack_transpose. Ap [0] must be zero, nz must be >= 0, and
Ap [j] <= Ap [j+1] and Ap [j] <= Ap [n] must be true for all j in the
range 0 to n-1. Empty columns are OK (that is, Ap [j] may equal
Ap [j+1] for any j in the range 0 to n-1).
Int Tj [nz] ; Output argument.
Tj is an integer array of size nz on input, where nz = Ap [n].
Suppose the column-form of the matrix is held in Ap, Ai, and Ax
(see umfpack_symbolic for a description). Then on output, the triplet
form of the same matrix is held in Ai (row indices), Tj (column
indices), and Ax (numerical values). Note, however, that this routine
does not require Ai and Ax in order to do the conversion.
\end{verbatim}
}
\newpage
\subsection{umfpack\_triplet\_to\_col and umfpack\_l\_triplet\_to\_col}
{\footnotesize
\begin{verbatim}
int umfpack_triplet_to_col
(
int n,
int nz,
const int Ti [ ],
const int Tj [ ],
const double Tx [ ],
int Bp [ ],
int Bi [ ],
double Bx [ ]
) ;
long umfpack_l_triplet_to_col
(
long n,
long nz,
const long Ti [ ],
const long Tj [ ],
const double Tx [ ],
long Bp [ ],
long Bi [ ],
double Bx [ ]
) ;
int Syntax:
#include "umfpack.h"
int n, nz, *Ti, *Tj, *Bp, *Bi, status ;
double *Tx, *Bx ;
status = umfpack_triplet_to_col (n, nz, Ti, Tj, Tx, Bp, Bi, Bx) ;
long Syntax:
#include "umfpack.h"
long n, nz, *Ti, *Tj, *Bp, *Bi, status ;
double *Tx, *Bx ;
status = umfpack_l_triplet_to_col (n, nz, Ti, Tj, Tx, Bp, Bi, Bx) ;
Purpose:
Converts a sparse matrix from "triplet" form to compressed-column form.
The triplet form of a matrix is a very simple data structure for basic
sparse matrix operations. For example, suppose you wish to factorize a
matrix A coming from a finite element method, in which A is a sum of
dense submatrices, A = E1 + E2 + E3 + ... . The entries in each element
matrix Ei can be concatenated together in the three triplet arrays, and
any overlap between the elements will be correctly summed by
umfpack_triplet_to_col.
Transposing a matrix in triplet form is simple; just interchange the
use of Ti and Tj.
Permuting a matrix in triplet form is also simple. If you want the matrix
PAQ, or A (P,Q) in Matlab notation, where P [k] = i means that row i of
A is the kth row of PAQ and Q [k] = j means that column j of A is the kth
column of PAQ, then do the following. First, create inverse permutations
Pinv and Qinv such that Pinv [i] = k if P [k] = i and Qinv [j] = k if
Q [k] = j. Next, for the mth triplet (Ti [m], Tj [m], Tx [m]), replace
Ti [m] with Pinv [Ti [m]] and replace Tj [m] with Qinv [Tj [m]].
If you have a column-form matrix with duplicate entries or unsorted
columns, you can sort it and sum up the duplicates by first converting it
to triplet form with umfpack_col_to_triplet, and then coverting it back
with umfpack_triplet_to_col.
You can print the input triplet form with umfpack_report_triplet, and
the output matrix with umfpack_report_matrix.
The matrix may be singular (nz can be zero, and empty rows and/or columns
may exist).
Returns:
UMFPACK_OK if successful.
UMFPACK_ERROR_argument_missing if Bp, Bi, Ti, and/or Tj are missing.
UMFPACK_ERROR_n_nonpositive if n <= 0.
UMFPACK_ERROR_nz_negative if nz < 0.
UMFPACK_ERROR_invalid_triplet if for any k, Ti [k] and/or Tj [k] are not in
the range 0 to n-1.
UMFPACK_ERROR_out_of_memory if unable to allocate sufficient workspace.
Arguments:
Int n ; Input argument, not modified.
A is an n-by-n matrix. Restriction: n > 0. All row and column indices
in the triplet form must be in the range 0 to n-1.
Int nz ; Input argument, not modified.
The number of entries in the triplet form of the matrix. Restriction:
nz >= 0.
Int Ti [nz] ; Input argument, not modified.
Int Tj [nz] ; Input argument, not modified.
double Tx [nz] ; Input argument, not modified.
Ti, Tj, and Tx hold the "triplet" form of a sparse matrix. The kth
nonzero entry is in row i = Ti [k], column j = Tj [k], and has a
numerical value of a_ij = Tx [k]. The row and column indices i and j
must be in the range 0 to n-1. Duplicate entries may be present; they
are summed in the output matrix. This is not an error condition.
The "triplets" may be in any order. Tx is optional; if Tx and/or Bx
are not present (a (double *) NULL pointer), then Bx is not computed.
Int Bp [n+1] ; Output argument, not modified.
Bp is an integer array of size n+1 on input.
On output, Bp holds the "pointers" for the column form of the sparse
matrix A. Column j of the matrix A is held in
Bi [(Bp [j]) ... (Bp [j+1]-1)]. The first entry, Bp [0], is zero, and
Bp [j] <= Bp [j+1] holds for all j in the range 0 to n-1. The value
nz2 = Bp [n] is thus the total number of entries in the pattern of the
matrix A. Equivalently, the number of duplicate triplets is
nz - Bp [n].
Int Bi [max(n,nz2)] ; Output argument, not modified.
Bi is an integer array of size max (n,nz2) on input, where nz2 <= nz.
Bi is also used as workspace during the conversion, and for this use
the size of Bi must also be at least n.
The nonzero pattern (row indices) for column j is stored in
Bi [(Bp [j]) ... (Bp [j+1]-1)]. The row indices in a given column j
are in ascending order, and no duplicate row indices are present.
Row indices are in the range 0 to n-1 (the matrix is 0-based).
double Bx [nz2] ; Output argument, not modified, of size nz2 = Bp [n].
Bx is a double array of size nz2 on input, where nz2 <= nz. Bx is
optional; if Tx and/or Bx are not present (a (double *) NULL pointer),
then Bx is not computed. If present, Bx holds the numerical values of
the sparse matrix A. The nonzero pattern (row indices) for column j is
stored in Bi [(Bp [j]) ... (Bp [j+1]-1)], and the corresponding
numerical values are stored in Bx [(Bp [j]) ... (Bp [j+1]-1)].
\end{verbatim}
}
\newpage
\subsection{umfpack\_transpose and umfpack\_l\_transpose}
{\footnotesize
\begin{verbatim}
int umfpack_transpose
(
int n,
const int Ap [ ],
const int Ai [ ],
const double Ax [ ],
const int P [ ],
const int Q [ ],
int Cp [ ],
int Ci [ ],
double Cx [ ]
) ;
long umfpack_l_transpose
(
long n,
const long Ap [ ],
const long Ai [ ],
const double Ax [ ],
const long P [ ],
const long Q [ ],
long Cp [ ],
long Ci [ ],
double Cx [ ]
) ;
int Syntax:
#include "umfpack.h"
int n, status, *Ap, *Ai, *P, *Q, *Cp, *Ci ;
double *Ax, *Cx ;
status = umfpack_transpose (n, Ap, Ai, Ax, P, Q, Cp, Ci, Cx) ;
long Syntax:
#include "umfpack.h"
long n, status, *Ap, *Ai, *P, *Q, *Cp, *Ci ;
double *Ax, *Cx ;
status = umfpack_l_transpose (n, Ap, Ai, Ax, P, Q, Cp, Ci, Cx) ;
Purpose:
Transposes and optionally permutes a sparse matrix in row or column-form,
C = (PAQ)'. In Matlab notation, C = (A (P,Q))'. Alternatively, this
routine can be viewed as converting A (P,Q) from column-form to row-form,
or visa versa. Empty rows and columns may exist.
The matrix A may be singular.
umfpack_transpose is useful if you want to factorize A' instead of A.
Factorizing A' instead of A can be much better, particularly if AA' is much
sparser than A'A. You can still solve Ax=b if you factorize A', by solving
with the sys argument "A'x=b" in umfpack_*solve.
The input A and output C can be printed with umfpack_report matrix, and the
permutation vectors can be printed with umfpack_report_perm.
Returns:
UMFPACK_OK if successful.
UMFPACK_ERROR_out_of_memory if umfpack_transpose fails to allocate a
size-n workspace.
UMFPACK_ERROR_argument_missing if Ai, Ap, Ci, and/or Cp are missing.
UMFPACK_ERROR_n_nonpositive if n <= 0.
UMFPACK_ERROR_invalid_permutation if P and/or Q are invalid.
UMFPACK_ERROR_nz_negative if Ap [n] < 0.
UMFPACK_ERROR_Ap0_nonzero if Ap [0] != 0.
UMFPACK_ERROR_col_length_negative if Ap [j] > Ap [j+1] for any j in the
range 0 to n-1.
UMFPACK_ERROR_row_index_out_of_bounds if any row index i is < 0 or >= n.
UMFPACK_ERROR_jumbled_matrix if the row indices in any column are not in
ascending order.
Arguments:
Int n ; Input argument, not modified.
A is an n-by-n matrix. Restriction: n > 0.
Int Ap [n+1] ; Input argument, not modified.
The column pointers of the column-oriented form of the matrix A. See
umfpack_symbolic for a description. The number of entries in
the matrix is nz = Ap [n]. Ap [0] must be zero, Ap [n] must be > 0, and
Ap [j] <= Ap [j+1] and Ap [j] <= Ap [n] must be true for all j in the
range 0 to n-1. Empty columns are OK (that is, Ap [j] may equal Ap
[j+1] for any j in the range 0 to n-1).
Int Ai [nz] ; Input argument, not modified, of size nz = Ap [n].
The nonzero pattern (row indices) for column j is stored in
Ai [(Ap [j]) ... (Ap [j+1]-1)]. The row indices in a given column j
must be in ascending order, and no duplicate row indices may be present.
Row indices must be in the range 0 to n-1 (the matrix is 0-based).
double Ax [nz] ; Input argument, not modified, of size nz = Ap [n].
If present, these are the numerical values of the sparse matrix A.
The nonzero pattern (row indices) for column j is stored in
Ai [(Ap [j]) ... (Ap [j+1]-1)], and the corresponding numerical values
are stored in Ax [(Ap [j]) ... (Ap [j+1]-1)]. If Ax and/or Cx are not
present, then the output Cx [...] is not computed, and only the pattern
is transposed. This is not an error condition.
Int P [n] ; Input argument, not modified.
The permutation vector P is defined as P [k] = i, where the original
row i of A is the kth row of PAQ. If you want to use the identity
permutation for P, simply pass (Int *) NULL for P. This is not an error
condition.
Int Q [n] ; Input argument, not modified.
The permutation vector Q is defined as Q [k] = j, where the original
column j of A is the kth column of PAQ. If you want to use the identity
permutation for Q, simply pass (Int *) NULL for Q. This is not an error
condition.
Int Cp [n+1] ; Output argument.
The column pointers of the matrix C = (A (P,Q))', in the same form
as the column pointers Ap for the matrix A.
Int Ci [nz] ; Output argument.
The row indices of the matrix C = (A (P,Q))', in the same form
as the row indices Ai for the matrix A.
double Cx [nz] ; Output argument.
If present, these are the numerical values of the sparse matrix C,
in the same form as the values Ax of the matrix A. If Ax and/or Cx
are not present, then the output Cx [...] is not computed, and only
the pattern is transposed. This is not an error condition.
\end{verbatim}
}
%-------------------------------------------------------------------------------
\newpage
\section{Getting the contents of opaque objects}
\label{Get}
%-------------------------------------------------------------------------------
\subsection{umfpack\_get\_lunz and umfpack\_l\_get\_lunz}
{\footnotesize
\begin{verbatim}
int umfpack_get_lunz
(
int *lnz,
int *unz,
int *n,
void *Numeric
) ;
long umfpack_l_get_lunz
(
long *lnz,
long *unz,
long *n,
void *Numeric
) ;
int Syntax:
#include "umfpack.h"
void *Numeric ;
int status, lnz, unz, n ;
status = umfpack_get_lunz (&lnz, &unz, &n, Numeric) ;
long Syntax:
#include "umfpack.h"
void *Numeric ;
long status, lnz, unz, n ;
status = umfpack_l_get_lunz (&lnz, &unz, &n, Numeric) ;
Purpose:
Determines the size and number of nonzeros in the LU factors held by the
Numeric object. These are also the sizes of the output arrays required
by umfpack_get_numeric.
This routine may seem redundant, since n is a value originally passed to
umfpack_symbolic by the user, and lnz and unz are available from the Info
array. However, the Info array is not always returned (its use is
optional). This routine is also useful in the context of many sparse linear
systems, with many Numeric handles. The user could store an array of
Numeric objects in an array of (void *) pointers, for example. The Info
array is re-initialized each time an UMFPACK routine is called, and thus the
lnz and unz information could be lost. Lnz and unz can differ from
different calls to umfpack_numeric with different numerical values (Ax),
even when using the same Symbolic object. This routine allows the LU
factors to be extracted from the Numeric object (with umfpack_get_numeric)
without the use of the corresponding Info array.
Returns:
UMFPACK_OK if successful.
UMFPACK_ERROR_invalid_Numeric_object if Numeric is not a valid object.
UMFPACK_ERROR_argument_missing if lnz, unz, or n are (Int *) NULL
Arguments:
Int *lnz ; Output argument.
The number of nonzeros in L, including the diagonal (which is all
one's). This value is the required size of the Li and Lx arrays as
computed by umfpack_get_numeric. The value of lnz is identical to
Info [UMFPACK_LNZ], if that value was returned by umfpack_numeric.
Int *unz ; Output argument.
The number of nonzeros in U, including the diagonal. This value is the
required size of the Ui and Ux arrays as computed by
umfpack_get_numeric. The value of unz is identical to
Info [UMFPACK_UNZ], if that value was returned by umfpack_numeric.
Int *n ; Output argument.
The order of the L and U matrices. The size of Lp and Up, as required
by umfpack_get_numeric, is n+1, and the size of P and Q are n. The
value of n is identical to that passed to umfpack_symbolic.
void *Numeric ; Input argument, not modified.
Numeric must point to a valid Numeric object, computed by
umfpack_numeric.
\end{verbatim}
}
\newpage
\subsection{umfpack\_get\_numeric and umfpack\_l\_get\_numeric}
{\footnotesize
\begin{verbatim}
int umfpack_get_numeric
(
int Lp [ ],
int Li [ ],
double Lx [ ],
int Up [ ],
int Ui [ ],
double Ux [ ],
int P [ ],
int Q [ ],
void *Numeric
) ;
long umfpack_l_get_numeric
(
long Lp [ ],
long Li [ ],
double Lx [ ],
long Up [ ],
long Ui [ ],
double Ux [ ],
long P [ ],
long Q [ ],
void *Numeric
) ;
int Syntax:
#include "umfpack.h"
void *Numeric ;
int *Lp, *Li, *Up, *Ui, *P, *Q, status ;
double *Lx, *Ux ;
status = umfpack_get_numeric (Lp, Li, Lx, Up, Ui, Ux, P, Q, Numeric) ;
long Syntax:
#include "umfpack.h"
void *Numeric ;
long *Lp, *Li, *Up, *Ui, *P, *Q, status ;
double *Lx, *Ux ;
status = umfpack_l_get_numeric (Lp, Li, Lx, Up, Ui, Ux, P, Q, Numeric) ;
Purpose:
This routine copies the LU factors and permutation vectors from the Numeric
object into user-accessible arrays. This routine is not needed to solve a
linear system. Note that the output arrays Lp, Li, Lx, Up, Ui, Ux, P, and
Q are not allocated by umfpack_get_numeric; they must exist on input.
Returns:
Returns UMFPACK_OK if successful. Returns UMFPACK_ERROR_out_of_memory
if insufficient memory is available for the 2*n integer workspace that
UMFPACK_get_numeric allocates to construct L and/or U. Returns
UMFPACK_ERROR_invalid_Numeric_object if the Numeric object provided as
input is invalid.
Arguments:
Int Lp [n+1] ; Output argument.
Int Li [lnz] ; Output argument.
double Lx [lnz] ; Output argument.
The matrix L is returned in compressed-row form. The column indices
of row i and corresponding numerical values are in:
Li [Lp [i] ... Lp [i+1]-1]
Lx [Lp [i] ... Lp [i+1]-1]
respectively. Each row is stored in sorted order, from low column
indices to higher. The last entry in each row is the diagonal, which
is numerically equal to one. The sizes of Lp, Li, and Lx are returned
by umfpack_get_lunz. If any one of the Lp, Li, or Lx arrays are not
present, the L matrix is not returned. This is not an error condition.
Thus, if you do not want the L matrix returned, simply pass
(Int *) NULL for Lp and Li, and (double *) NULL for Lx.
The L matrix can be printed if n, Lp, Li, and Lx are passed to
umfpack_report_matrix (using the "row" form).
Int Up [n+1] ; Output argument.
Int Ui [unz] ; Output argument.
double Ux [unz] ; Output argument.
The matrix U is returned in compressed-column form. The row indices
of column j and corresponding numerical values are in
Ui [Up [j] ... Up [j+1]-1]
Ux [Up [j] ... Up [j+1]-1]
respectively. Each column is stored in sorted order, from low row
indices to higher. The last entry in each column is the diagonal. The
sizes of Up, Ui, and Ux are returned by umfpack_get_lunz. If any one of
the Up, Ui, or Ux arrays are not present, the U matrix is not returned.
This is not an error condition. Thus, if you do not want the U matrix
returned, simply pass (Int *) NULL for Up and Ui, and (double *) NULL
for Ux. The U matrix can be printed if n, Up, Ui, and Ux are passed to
umfpack_report_matrix (using the "column" form).
Int P [n] ; Output argument.
The permutation vector P is defined as P [k] = i, where the original
row i of A is the kth pivot row in PAQ. If you do not want the P vector
to be returned, simply pass (Int *) NULL for P. This is not an error
condition. You can print P and Q with umfpack_report_perm.
Int Q [n] ; Output argument.
The permutation vector Q is defined as Q [k] = j, where the original
column j of A is the kth pivot column in PAQ. If you not want the Q
vector to be returned, simply pass (Int *) NULL for Q. This is not
an error condition. Note that Q is not necessarily identical to
Qtree, the column preordering held in the Symbolic object. Refer to
the description of Qtree and Front_npivots in umfpack_get_symbolic for
details.
void *Numeric ; Input argument, not modified.
Numeric must point to a valid Numeric object, computed by
umfpack_numeric.
\end{verbatim}
}
\newpage
\subsection{umfpack\_get\_symbolic and umfpack\_l\_get\_symbolic}
{\footnotesize
\begin{verbatim}
int umfpack_get_symbolic
(
int *n,
int *nz,
int *nfr,
int *nchains,
int *nsparse_col,
int Qtree [ ],
int Front_npivots [ ],
int Front_parent [ ],
int Chain_start [ ],
int Chain_maxrows [ ],
int Chain_maxcols [ ],
void *Symbolic
) ;
long umfpack_l_get_symbolic
(
long *n,
long *nz,
long *nfr,
long *nchains,
long *nsparse_col,
long Qtree [ ],
long Front_npivots [ ],
long Front_parent [ ],
long Chain_start [ ],
long Chain_maxrows [ ],
long Chain_maxcols [ ],
void *Symbolic
) ;
int Syntax:
#include "umfpack.h"
int status, n, nz, nfr, nchains, nsparse_col, *Qtree,
*Front_npivots, *Front_parent, *Chain_start, *Chain_maxrows,
*Chain_maxcols ;
void *Symbolic ;
status = umfpack_get_symbolic (&n, &nz, &nfr, &nchains, &nsparse_col,
Qtree, Front_npivots, Front_parent, Chain_start, Chain_maxrows,
Chain_maxcols, Symbolic) ;
long Syntax:
#include "umfpack.h"
long status, n, nz, nfr, nchains, nsparse_col, *Qtree,
*Front_npivots, *Front_parent, *Chain_start, *Chain_maxrows,
*Chain_maxcols ;
void *Symbolic ;
status = umfpack_l_get_symbolic (&n, &nz, &nfr, &nchains, &nsparse_col,
Qtree, Front_npivots, Front_parent, Chain_start, Chain_maxrows,
Chain_maxcols, Symbolic) ;
Purpose:
Copies the contents of the Symbolic object into simple integer arrays
accessible to the user. This routine is not needed to factorize
and/or solve a sparse linear system using UMFPACK. Note that the output
arrays Qtree, Front_npivots, Front_parent, Chain_start, Chain_maxrows,
and Chain_maxcols are not allocated by umfpack_get_symbolic; they must
exist on input.
The Symbolic object is small. It size, in integers, is
(3*nchains + n + 2*nfr + 20), which is no greater than 6*n+20. The object
holds the initial column permutation, the supernodal column elimination
tree, and information about each frontal matrix. You can print it with
umfpack_report_symbolic.
Returns:
Returns UMFPACK_OK if successful, UMFPACK_ERROR_invalid_Symbolic_object
if Symbolic is an invalid object.
Arguments:
Note that if any of the output arguments are (Int *) NULL pointers, then
that argument is not returned. This is not an error condition. Thus,
if you do not want a particular component of the Symbolic object to be
returned to you, simply pass a (Int *) NULL pointer for that particular
output argument.
Int *n ; Output argument.
The dimension of the matrix A analyzed by the call to umfpack_symbolic
that generated the Symbolic object.
Int *nz ; Output argument.
The number of nonzeros in A.
Int *nfr ; Output argument.
The number of frontal matrices that will be used by umfpack_numeric
to factorize the matrix A. One or more pivots are contained in each
frontal matrix, and the total number of pivots in the frontal matrices
is n (see the description of nsparse_col, below).
Thus, nfr is in the range 1 to n.
Int *nchains ; Output argument.
The frontal matrices are related to one another by the supernodal
column elimination tree. Each node in this tree is one frontal matrix.
The tree is partitioned into a set of disjoint paths, and a frontal
matrix chain is one path in this tree. Each chain is factorized using
a unifrontal technique, with a single working array that holds each
frontal matrix in the chain, one at a time. nchains is in the range
1 to nfr.
Int *nsparse_col ; Output argument.
This is equal to n. It differed from n in Version 3.0.
Int Qtree [n] ; Output argument.
The initial column permutation. If Qtree [k] = j, then this means that
column j is the kth pivot column in the preordered matrix.
Qtree is not necessarily the same as the final
column permutation Q, computed by umfpack_numeric. The numeric
factorization may reorder the pivot columns within each frontal matrix
to reduce fill-in.
Int Front_npivots [nfr] ; Output argument.
This array should be of size at least n, in order to guarantee that it
will be large enough to hold the output. Only the first nfr entries
are used, however. The kth frontal matrix holds Front_npivots [k] pivot
columns. Thus, the first frontal matrix, front 0, is used to factorize
the first Front_npivots [0] columns; these correspond to the original
columns Qtree [0] through Qtree [Front_npivots [0]-1]. The next frontal
matrix is used to factorize the next Front_npivots [1] columns, which
are thus the original columns Qtree [Front_npivots [0]] through
Qtree [Front_npivots [0] + Front_npivots [1] - 1], and so on.
The sum of Front_npivots [0..nfr-1] is equal to n.
Any modifications that umfpack_numeric makes to the initial column
permutation are constrained to within each frontal matrix. Thus,
for the first frontal matrix, Q [0] through Q [Front_npivots [0]-1] is
some permutation of the columns Qtree [0] through
Qtree [Front_npivots [0]-1]. For second frontal matrix,
Q [Front_npivots [0]] through Q [Front_npivots [0] + Front_npivots[1]-1]
is some permutation of the same portion of Qtree, and so on. All pivot
columns are numerically factorized within the frontal matrix originally
determined by the symbolic factorization; there is no delayed pivoting
across frontal matrices.
Int Front_parent [nfr] ; Output argument.
This array should be of size at least n, in order to guarantee that it
will be large enough to hold the output. Only the first nfr entries
are used, however. Front_parent [0..nfr-1] holds the supernodal column
elimination tree. Each node in the tree corresponds to a single frontal
matrix. The parent of node f is Front_parent [f].
Int Chain_start [nchains+1] ; Output argument.
This array should be of size at least n+1, in order to guarantee that it
will be large enough to hold the output. Only the first nchains+1
entries are used, however. The kth frontal matrix chain consists of
frontal matrices Chain_start [k] through Chain_start [k+1]-1. Thus,
Chain_start [0] is always 0, and Chain_start [nchains] is the total
number of frontal matrices, nfr. For two adjacent fronts f and f+1
within a single chain, f+1 is always the parent of f (that is,
Front_parent [f] = f+1).
Int Chain_maxrows [nchains] ; Output argument.
Int Chain_maxcols [nchains] ; Output argument.
These arrays should be of size at least n, in order to guarantee that
they will be large enough to hold the output. Only the first nchains
entries of Chain_maxrows and Chain_maxcols are used, however. The kth
frontal matrix chain requires a single working array of dimension
Chain_maxrows [k] by Chain_maxcols [k], for the unifrontal technique
that factorizes the frontal matrix chain. Since the symbolic
factorization only provides an upper bound on the size of each frontal
matrix, not all of the working array is necessarily used during the
numerical factorization.
Note that the upper bound on the number of rows and columns of each
frontal matrix is computed by umfpack_symbolic, but all that is
required by umfpack_numeric is the maximum of these two sets of
values for each frontal matrix chain. Thus, the size of each
individual frontal matrix is not preserved in the Symbolic object.
void *Symbolic ; Input argument, not modified.
The Symbolic object, which holds the symbolic factorization computed by
umfpack_symbolic. The Symbolic object is not modified by
umfpack_get_symbolic.
\end{verbatim}
}
%-------------------------------------------------------------------------------
\newpage
\section{Reporting routines}
\label{Report}
%-------------------------------------------------------------------------------
\subsection{umfpack\_report\_status and umfpack\_l\_report\_status}
{\footnotesize
\begin{verbatim}
void umfpack_report_status
(
const double Control [UMFPACK_CONTROL],
int status
) ;
void umfpack_l_report_status
(
const double Control [UMFPACK_CONTROL],
long status
) ;
int Syntax:
#include "umfpack.h"
double Control [UMFPACK_CONTROL] ;
int status ;
umfpack_report_status (Control, status) ;
long Syntax:
#include "umfpack.h"
double Control [UMFPACK_CONTROL] ;
long status ;
umfpack_l_report_status (Control, status) ;
Purpose:
Prints the status (return value) of other umfpack_* routines.
Arguments:
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_PRL]: printing level.
0 or less: no output, even when an error occurs
1: error messages only
2 or more: print status, whether or not an error occured
4 or more: also print the UMFPACK Copyright
6 or more: also print the UMFPACK License
Default: 1
Int status ; Input argument, not modified.
The return value from another umfpack_* routine.
\end{verbatim}
}
\newpage
\subsection{umfpack\_report\_control and umfpack\_l\_report\_control}
{\footnotesize
\begin{verbatim}
void umfpack_report_control
(
const double Control [UMFPACK_CONTROL]
) ;
void umfpack_l_report_control
(
const double Control [UMFPACK_CONTROL]
) ;
int Syntax:
#include "umfpack.h"
double Control [UMFPACK_CONTROL] ;
umfpack_report_control (Control) ;
long Syntax:
#include "umfpack.h"
double Control [UMFPACK_CONTROL] ;
umfpack_l_report_control (Control) ;
Purpose:
Prints the current control settings. Note that with the default print
level, nothing is printed. Does nothing if Control is (double *) NULL.
Arguments:
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_PRL]: printing level.
1 or less: no output
2 or more: print all of Control
Default: 1
\end{verbatim}
}
\newpage
\subsection{umfpack\_report\_info and umfpack\_l\_report\_info}
{\footnotesize
\begin{verbatim}
void umfpack_report_info
(
const double Control [UMFPACK_CONTROL],
const double Info [UMFPACK_INFO]
) ;
void umfpack_l_report_info
(
const double Control [UMFPACK_CONTROL],
const double Info [UMFPACK_INFO]
) ;
int Syntax:
#include "umfpack.h"
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO] ;
umfpack_report_info (Control, Info) ;
long Syntax:
#include "umfpack.h"
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO] ;
umfpack_l_report_info (Control, Info) ;
Purpose:
Reports statistics from the umfpack_*symbolic, umfpack_numeric, and
umfpack_*solve routines.
Arguments:
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_PRL]: printing level.
0 or less: no output, even when an error occurs
1: error messages only
2 or more: error messages, and print all of Info
Default: 1
double Info [UMFPACK_INFO] ; Input argument, not modified.
Info is an output argument of several UMFPACK routines.
The contents of Info are printed on standard output.
\end{verbatim}
}
\newpage
\subsection{umfpack\_report\_matrix and umfpack\_l\_report\_matrix}
{\footnotesize
\begin{verbatim}
int umfpack_report_matrix
(
const char name [ ],
int n,
const int Ap [ ],
const int Ai [ ],
const double Ax [ ],
const char form [ ],
const double Control [UMFPACK_CONTROL]
) ;
long umfpack_l_report_matrix
(
const char name [ ],
long n,
const long Ap [ ],
const long Ai [ ],
const double Ax [ ],
const char form [ ],
const double Control [UMFPACK_CONTROL]
) ;
int Syntax:
#include "umfpack.h"
int n, *Ap, *Ai, status ;
double *Ax, Control [UMFPACK_CONTROL] ;
status = umfpack_report_matrix ("A", n, Ap, Ai, Ax, "column", Control) ;
or:
status = umfpack_report_matrix ("A", n, Ap, Ai, Ax, "row", Control) ;
long Syntax:
#include "umfpack.h"
long n, *Ap, *Ai, status ;
double *Ax, Control [UMFPACK_CONTROL] ;
status = umfpack_l_report_matrix ("A", n, Ap, Ai, Ax, "column", Control) ;
or:
status = umfpack_l_report_matrix ("A", n, Ap, Ai, Ax, "row", Control) ;
Purpose:
Verifies and prints a row or column-oriented sparse matrix.
Returns:
UMFPACK_OK if Control [UMFPACK_PRL] <= 2 (the input is not checked).
Otherwise:
UMFPACK_OK if the matrix is valid and non-singular.
UMFPACK_ERROR_singular_matrix if the matrix is structurally singular but
otherwise valid. It has one or more rows or columns with no entries.
This test is made without considering the numerical values, but by just
looking at the pattern of the entries. Thus, all structurally singular
matrices are numerically singular, but not all numerically singular
matrices are structurally singular. The matrix may be operated on by
the matrix manipulation routines (umfpack_transpose,
umfpack_col_to_triplet) but it may not be analyzed by umfpack_*symbolic
or factorized by umfpack_numeric).
UMFPACK_ERROR_n_nonpositive if n <= 0.
UMFPACK_ERROR_argument_missing if Ap and/or Ai are missing.
UMFPACK_ERROR_nz_negative if Ap [n] < 0.
UMFPACK_ERROR_Ap0_nonzero if Ap [0] is not zero.
UMFPACK_ERROR_col_length_negative if Ap [j+1] < Ap [j] for any j in the
range 0 to n-1.
UMFPACK_ERROR_out_of_memory if out of memory.
UMFPACK_ERROR_row_index_out_of_bounds if any row index in Ai is not in
the range 0 to n-1.
UMFPACK_ERROR_jumbled_matrix if the row indices in any column are not in
ascending order, or contain duplicates.
Arguments:
char name [ ] ; Input argument, not modified.
The name of the matrix. This is optional; no name is printed if
a (char *) NULL pointer is passed.
Int n ; Input argument, not modified.
A is an n-by-n matrix. Restriction: n > 0.
Int Ap [n+1] ; Input argument, not modified.
Ap is an integer array of size n+1. If the form argument is "column",
then on input, it holds the "pointers" for the column form of the
sparse matrix A. The row indices of column j of the matrix A are held
in Ai [(Ap [j]) ... (Ap [j+1]-1)]. If form is "row", then Ap holds the
row pointers. The column indices of row j of the matrix are held
in Ai [(Ap [j]) ... (Ap [j+1]-1)].
The first entry, Ap [0], must be zero, and Ap [j] <= Ap [j+1] must hold
for all j in the range 0 to n-1. The value nz = Ap [n] is thus the
total number of entries in the pattern of the matrix A.
Restriction: Ap [0] == 0 and Ap [n] > 0.
Int Ai [nz] ; Input argument, not modified, of size nz = Ap [n].
If form is "column", then the nonzero pattern (row indices) for column
j is stored in Ai [(Ap [j]) ... (Ap [j+1]-1)]. Row indices must be in
the range 0 to n-1 (the matrix is 0-based).
If form is "row", then the nonzero pattern (column indices) for row
j is stored in Ai [(Ap [j]) ... (Ap [j+1]-1)]. Column indices must be in
the range 0 to n-1 (the matrix is 0-based).
double Ax [nz] ; Input argument, not modified, of size nz = Ap [n].
The numerical values of the sparse matrix A.
If form is "row", then the nonzero pattern (row indices) for column j
is stored in Ai [(Ap [j]) ... (Ap [j+1]-1)], and the corresponding
numerical values are stored in Ax [(Ap [j]) ... (Ap [j+1]-1)].
If form is "column", then the nonzero pattern (column indices) for row j
is stored in Ai [(Ap [j]) ... (Ap [j+1]-1)], and the corresponding
numerical values are stored in Ax [(Ap [j]) ... (Ap [j+1]-1)].
No numerical values are printed if Ax is a (double *) NULL pointer.
char *form ; Input argument, not modified.
The matrix is in row-oriented form if form is "row". Otherwise,
the matrix is in column-oriented form. The form argument may be
(char *) NULL, in which case the matrix is in column-oriented form.
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_PRL]: printing level.
2 or less: no output. returns silently without checking anything.
3: fully check input, and print a short summary of its status
4: as 3, but print first few entries of the input
5: as 3, but print all of the input
Default: 1
\end{verbatim}
}
\newpage
\subsection{umfpack\_report\_numeric and umfpack\_l\_report\_numeric}
{\footnotesize
\begin{verbatim}
int umfpack_report_numeric
(
const char name [ ],
void *Numeric,
const double Control [UMFPACK_CONTROL]
) ;
long umfpack_l_report_numeric
(
const char name [ ],
void *Numeric,
const double Control [UMFPACK_CONTROL]
) ;
int Syntax:
#include "umfpack.h"
void *Numeric ;
double Control [UMFPACK_CONTROL] ;
int status ;
status = umfpack_report_numeric ("Numeric", Numeric, Control) ;
long Syntax:
#include "umfpack.h"
void *Numeric ;
double Control [UMFPACK_CONTROL] ;
long status ;
status = umfpack_l_report_numeric ("Numeric", Numeric, Control) ;
Purpose:
Verifies and prints a Numeric object. This routine checks the object more
carefully than the computational routines. Normally, this check is not
required, since umfpack_numeric either returns (void *) NULL, or a valid
Numeric object. However, if you suspect that your own code has corrupted
the Numeric object (by overruning memory bounds, for example), then this
routine might be able to detect a corrupted Numeric object. Since this
is a complex object, not all such user-generated errors are guaranteed to
be caught by this routine.
Returns:
UMFPACK_OK if Control [UMFPACK_PRL] <= 2 (the input is not checked).
Otherwise:
UMFPACK_OK if the Numeric object is valid.
UMFPACK_ERROR_invalid_Numeric_object if the Numeric object is invalid.
UMFPACK_ERROR_out_of_memory if out of memory.
Arguments:
char name [ ] ; Input argument, not modified.
The name of the Numeric object. This is optional; no name is printed
if a (char *) NULL pointer is passed.
void *Numeric ; Input argument, not modified.
The Numeric object, which holds the numeric factorization computed by
umfpack_numeric.
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_PRL]: printing level.
2 or less: no output. returns silently without checking anything.
3: fully check input, and print a short summary of its status
4: as 3, but print first few entries of the input
5: as 3, but print all of the input
Default: 1
\end{verbatim}
}
\newpage
\subsection{umfpack\_report\_perm and umfpack\_l\_report\_perm}
{\footnotesize
\begin{verbatim}
int umfpack_report_perm
(
const char name [ ],
int n,
const int P [ ],
const double Control [UMFPACK_CONTROL]
) ;
long umfpack_l_report_perm
(
const char name [ ],
long n,
const long P [ ],
const double Control [UMFPACK_CONTROL]
) ;
int Syntax:
#include "umfpack.h"
int n, *P, status ;
double Control [UMFPACK_CONTROL] ;
status = umfpack_report_perm ("P", n, P, Control) ;
long Syntax:
#include "umfpack.h"
long n, *P, status ;
double Control [UMFPACK_CONTROL] ;
status = umfpack_l_report_perm ("P", n, P, Control) ;
Purpose:
Verifies and prints a permutation vector.
Returns:
UMFPACK_OK if Control [UMFPACK_PRL] <= 2 (the input is not checked).
Otherwise:
UMFPACK_OK if the permutation vector is valid (this includes that case
when P is (Int *) NULL, which is not an error condition.
UMFPACK_ERROR_n_nonpositive if n <= 0.
UMFPACK_ERROR_out_of_memory if out of memory.
UMFPACK_ERROR_invalid_permutation if P is not a valid permutation vector.
Arguments:
char name [ ] ; Input argument, not modified.
The name of the permutation vector. This is optional; no name is
printed if a (char *) NULL pointer is passed.
Int n ; Input argument, not modified.
P is an integer vector of size n. Restriction: n > 0.
Int P [n] ; Input argument, not modified.
A permutation vector of size n. If P is not present (a (Int *) NULL
pointer, then P is assumed to be the identity permutation. This is
consistent with its use as an input argument to umfpack_qsymbolic.
If P is present, the entries in P must range between 0 and n-1, and no
duplicates may exists.
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_PRL]: printing level.
2 or less: no output. returns silently without checking anything.
3: fully check input, and print a short summary of its status
4: as 3, but print first few entries of the input
5: as 3, but print all of the input
Default: 1
\end{verbatim}
}
\newpage
\subsection{umfpack\_report\_symbolic and umfpack\_l\_report\_symbolic}
{\footnotesize
\begin{verbatim}
int umfpack_report_symbolic
(
const char name [ ],
void *Symbolic,
const double Control [UMFPACK_CONTROL]
) ;
long umfpack_l_report_symbolic
(
const char name [ ],
void *Symbolic,
const double Control [UMFPACK_CONTROL]
) ;
int Syntax:
#include "umfpack.h"
void *Symbolic ;
double Control [UMFPACK_CONTROL] ;
int status ;
status = umfpack_report_symbolic ("Symbolic", Symbolic, Control) ;
long Syntax:
#include "umfpack.h"
void *Symbolic ;
double Control [UMFPACK_CONTROL] ;
long status ;
status = umfpack_l_report_symbolic ("Symbolic", Symbolic, Control) ;
Purpose:
Verifies and prints a Symbolic object. This routine checks the object more
carefully than the computational routines. Normally, this check is not
required, since umfpack_*symbolic either returns (void *) NULL, or a valid
Symbolic object. However, if you suspect that your own code has corrupted
the Symbolic object (by overruning memory bounds, for example), then this
routine might be able to detect a corrupted Symbolic object. Since this is
a complex object, not all such user-generated errors are guaranteed to be
caught by this routine.
Returns:
UMFPACK_OK if Control [UMFPACK_PRL] is <= 2 (no inputs are checked).
Otherwise:
UMFPACK_OK if the Symbolic object is valid.
UMFPACK_ERROR_invalid_Symbolic_object if the Symbolic object is invalid.
UMFPACK_ERROR_out_of_memory if out of memory.
Arguments:
char name [ ] ; Input argument, not modified.
The name of the Symbolic object. This is optional; no name is printed
if a (char *) NULL pointer is passed.
void *Symbolic ; Input argument, not modified.
The Symbolic object, which holds the symbolic factorization computed by
umfpack_symbolic.
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_PRL]: printing level.
2 or less: no output. returns silently without checking anything.
3: fully check input, and print a short summary of its status
4: as 3, but print first few entries of the input
5: as 3, but print all of the input
Default: 1
\end{verbatim}
}
\newpage
\subsection{umfpack\_report\_triplet and umfpack\_l\_report\_triplet}
{\footnotesize
\begin{verbatim}
int umfpack_report_triplet
(
const char name [ ],
int n,
int nz,
const int Ti [ ],
const int Tj [ ],
const double Tx [ ],
const double Control [UMFPACK_CONTROL]
) ;
long umfpack_l_report_triplet
(
const char name [ ],
long n,
long nz,
const long Ti [ ],
const long Tj [ ],
const double Tx [ ],
const double Control [UMFPACK_CONTROL]
) ;
int Syntax:
#include "umfpack.h"
int n, nz, *Ti, *Tj, status ;
double *Tx, Control [UMFPACK_CONTROL] ;
status = umfpack_report_triplet ("Triplet", n, nz, Ti, Tj, Tx, Control) ;
long Syntax:
#include "umfpack.h"
long n, nz, *Ti, *Tj, status ;
double *Tx, Control [UMFPACK_CONTROL] ;
status = umfpack_l_report_triplet ("Triplet", n, nz, Ti, Tj, Tx, Control) ;
Purpose:
Verifies and prints a matrix in triplet form.
Returns:
UMFPACK_OK if Control [UMFPACK_PRL] <= 2 (the input is not checked).
Otherwise:
UMFPACK_OK if the Triplet matrix is OK.
UMFPACK_ERROR_argument_missing if Ti and/or Tj are missing.
UMFPACK_ERROR_n_nonpositive if n <= 0.
UMFPACK_ERROR_nz_negative if nz < 0.
UMFPACK_ERROR_invalid_triplet if any row or column index in Ti and/or Tj
is not in the range 0 to n-1.
Arguments:
char name [ ] ; Input argument, not modified.
The name of the matrix. This is optional; no name is printed if
a (char *) NULL pointer is passed.
Int n ; Input argument, not modified.
A is an n-by-n matrix.
Int nz ; Input argument, not modified.
The number of entries in the triplet form of the matrix.
Int Ti [nz] ; Input argument, not modified.
Int Tj [nz] ; Input argument, not modified.
double Tx [nz] ; Input argument, not modified.
Ti, Tj, and Tx hold the "triplet" form of a sparse matrix. The kth
nonzero entry is in row i = Ti [k], column j = Tj [k], and has a
numerical value of a_ij = Tx [k]. The row and column indices i and j
must be in the range 0 to n-1. Duplicate entries
may be present; they are summed in the output matrix. This is not an
error condition. The "triplets" may be in any order. Tx is optional;
if Tx is not present (a (double *) NULL pointer), then the numerical
values are not printed.
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_PRL]: printing level.
2 or less: no output. returns silently without checking anything.
3: fully check input, and print a short summary of its status
4: as 3, but print first few entries of the input
5: as 3, but print all of the input
Default: 1
\end{verbatim}
}
\newpage
\subsection{umfpack\_report\_vector and umfpack\_l\_report\_vector}
{\footnotesize
\begin{verbatim}
int umfpack_report_vector
(
const char name [ ],
int n,
const double X [ ],
const double Control [UMFPACK_CONTROL]
) ;
long umfpack_l_report_vector
(
const char name [ ],
long n,
const double X [ ],
const double Control [UMFPACK_CONTROL]
) ;
int Syntax:
#include "umfpack.h"
int n, status ;
double *X, Control [UMFPACK_CONTROL] ;
status = umfpack_report_vector ("X", n, X, Control) ;
long Syntax:
#include "umfpack.h"
long n, status ;
double *X, Control [UMFPACK_CONTROL] ;
status = umfpack_l_report_vector ("X", n, X, Control) ;
Purpose:
Verifies and prints a real vector.
Returns:
UMFPACK_OK if Control [UMFPACK_PRL] <= 2 (the input is not checked).
Otherwise:
UMFPACK_OK if the vector is valid.
UMFPACK_ERROR_argument_missing if X is missing.
UMFPACK_ERROR_n_nonpositive if n <= 0.
Arguments:
char name [ ] ; Input argument, not modified.
The name of the vector. This is optional; no name is
printed if a (char *) NULL pointer is passed.
Int n ; Input argument, not modified.
X is a real vector of size n. Restriction: n > 0.
double X [n] ; Input argument, not modified.
A real vector of size n. X must not be (double *) NULL.
double Control [UMFPACK_CONTROL] ; Input argument, not modified.
If a (double *) NULL pointer is passed, then the default control
settings are used. Otherwise, the settings are determined from the
Control array. See umfpack_defaults on how to fill the Control
array with the default settings. The following Control parameters
are used:
Control [UMFPACK_PRL]: printing level.
2 or less: no output. returns silently without checking anything.
3: fully check input, and print a short summary of its status
4: as 3, but print first few entries of the input
5: as 3, but print all of the input
Default: 1
\end{verbatim}
}
%-------------------------------------------------------------------------------
\newpage
\section{Utility routines}
\label{Utility}
%-------------------------------------------------------------------------------
\subsection{umfpack\_timer}
{\footnotesize
\begin{verbatim}
double umfpack_timer ( void ) ;
Syntax (for both int and long versions):
#include "umfpack.h"
double t ;
t = umfpack_timer ( ) ;
Purpose:
Returns the CPU time used by the process. Includes both "user" and "system"
time (the latter is time spent by the system on behalf of the process, and
is thus charged to the process).
This routine uses the Unix getrusage ( ) routine, if available. It is not
subject to overflow. If getrusage ( ) is not available, the portable ANSI
C clock ( ) routine is used instead. Unfortunately, clock ( ) overflows
if the CPU time exceeds 2147 seconds (about 36 minutes) when
sizeof (clock_t) is 4 bytes. If you have getrusage ( ), be sure to compile
UMFPACK with the -DGETRUSAGE flag set; see umf_config.h and the User Guide
for details.
Arguments:
None.
\end{verbatim}
}
%-------------------------------------------------------------------------------
\newpage
\section{{\tt umfpack.h} include file}
\label{Include}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
/*
This is the umfpack.h include file, and should be included in all user code
that uses UMFPACK. Do not include any of the umf_* header files in user
code. All routines in UMFPACK starting with "umfpack_" are user-callable
(the 24 routines listed below). All other routines are prefixed "umf_",
and are not user-callable.
*/
#ifndef UMFPACK_H
#define UMFPACK_H
/* -------------------------------------------------------------------------- */
/* size of Info and Control arrays */
/* -------------------------------------------------------------------------- */
#define UMFPACK_INFO 90
#define UMFPACK_CONTROL 20
/* -------------------------------------------------------------------------- */
/* User-callable routines */
/* -------------------------------------------------------------------------- */
/* Primary routines: */
#include "umfpack_symbolic.h"
#include "umfpack_numeric.h"
#include "umfpack_solve.h"
#include "umfpack_free_symbolic.h"
#include "umfpack_free_numeric.h"
/* Alternative routines: */
#include "umfpack_defaults.h"
#include "umfpack_qsymbolic.h"
#include "umfpack_wsolve.h"
/* Matrix manipulation routines: */
#include "umfpack_triplet_to_col.h"
#include "umfpack_col_to_triplet.h"
#include "umfpack_transpose.h"
/* Getting the contents of the Symbolic and Numeric opaque objects: */
#include "umfpack_get_lunz.h"
#include "umfpack_get_numeric.h"
#include "umfpack_get_symbolic.h"
/* Reporting routines (the above 14 routines print nothing): */
#include "umfpack_report_status.h"
#include "umfpack_report_info.h"
#include "umfpack_report_control.h"
#include "umfpack_report_matrix.h"
#include "umfpack_report_triplet.h"
#include "umfpack_report_symbolic.h"
#include "umfpack_report_numeric.h"
#include "umfpack_report_perm.h"
#include "umfpack_report_vector.h"
/* Utility routines: */
#include "umfpack_timer.h"
/* -------------------------------------------------------------------------- */
/* Version, copyright, and license */
/* -------------------------------------------------------------------------- */
#define UMFPACK_VERSION "UMFPACK V3.2"
#define UMFPACK_COPYRIGHT \
"UMFPACK: Copyright (c) 2002 by Timothy A. Davis, University of Florida,\n" \
"davis@cise.ufl.edu. All Rights Reserved.\n"
#define UMFPACK_LICENSE \
"\nUMFPACK License:\n" \
"\n" \
" Your use or distribution of UMFPACK or any derivative code implies that\n"\
" you agree to this License.\n" \
"\n" \
" THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY\n" \
" EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.\n" \
"\n" \
" Permission is hereby granted to use or copy this program, provided\n" \
" that the Copyright, this License, and the Availability of the original\n" \
" version is retained on all copies. User documentation of any code that\n"\
" uses this code or any derivative code must cite the Copyright, this\n" \
" License, the Availability note, and \"Used by permission.\" If this\n" \
" code or any derivative code is accessible from within MATLAB, then\n" \
" typing \"help umfpack\" must cite the Copyright, and \"type umfpack\"\n" \
" must also cite this License and the Availability note. Permission to\n" \
" modify the code and to distribute modified code is granted, provided\n" \
" the Copyright, this License, and the Availability note are retained,\n" \
" and a notice that the code was modified is included. This software\n" \
" was developed with support from the National Science Foundation, and\n" \
" is provided to you free of charge.\n" \
"\n" \
"Availability: http://www.cise.ufl.edu/research/sparse\n" \
"\n"
/* -------------------------------------------------------------------------- */
/* contents of Info */
/* -------------------------------------------------------------------------- */
/* Note that umfpack_report.m must coincide with these definitions. */
/* returned by all routines that use Info: */
#define UMFPACK_STATUS 0
#define UMFPACK_N 1
#define UMFPACK_NZ 2
/* computed in UMFPACK_*symbolic and UMFPACK_numeric: */
#define UMFPACK_SIZE_OF_UNIT 3
/* computed in UMFPACK_*symbolic: */
#define UMFPACK_SIZE_OF_INT 4
#define UMFPACK_SIZE_OF_LONG 5
#define UMFPACK_SIZE_OF_POINTER 6
#define UMFPACK_SIZE_OF_ENTRY 7
#define UMFPACK_NDENSE_ROW 8
#define UMFPACK_NEMPTY_ROW 9
#define UMFPACK_NDENSE_COL 10
#define UMFPACK_NEMPTY_COL 11
#define UMFPACK_SYMBOLIC_DEFRAG 12
#define UMFPACK_SYMBOLIC_PEAK_MEMORY 13
#define UMFPACK_SYMBOLIC_SIZE 14
#define UMFPACK_SYMBOLIC_TIME 15
/* Info [16..19] unused */
/* estimates computed in UMFPACK_*symbolic: */
#define UMFPACK_NUMERIC_SIZE_ESTIMATE 20
#define UMFPACK_PEAK_MEMORY_ESTIMATE 21
#define UMFPACK_FLOPS_ESTIMATE 22
#define UMFPACK_LNZ_ESTIMATE 23
#define UMFPACK_UNZ_ESTIMATE 24
#define UMFPACK_VARIABLE_INIT_ESTIMATE 25
#define UMFPACK_VARIABLE_PEAK_ESTIMATE 26
#define UMFPACK_VARIABLE_FINAL_ESTIMATE 27
#define UMFPACK_MAX_FRONT_SIZE_ESTIMATE 28
/* Info [29..39] unused */
/* exact values, (estimates shown above) computed in UMFPACK_numeric: */
#define UMFPACK_NUMERIC_SIZE 40
#define UMFPACK_PEAK_MEMORY 41
#define UMFPACK_FLOPS 42
#define UMFPACK_LNZ 43
#define UMFPACK_UNZ 44
#define UMFPACK_VARIABLE_INIT 45
#define UMFPACK_VARIABLE_PEAK 46
#define UMFPACK_VARIABLE_FINAL 47
#define UMFPACK_MAX_FRONT_SIZE 48
/* Info [49..59] unused */
/* computed in UMFPACK_numeric: */
#define UMFPACK_NUMERIC_DEFRAG 60
#define UMFPACK_NUMERIC_REALLOC 61
#define UMFPACK_NUMERIC_COSTLY_REALLOC 62
#define UMFPACK_COMPRESSED_PATTERN 63
#define UMFPACK_LU_ENTRIES 64
#define UMFPACK_NUMERIC_TIME 65
/* Info [66..79] unused */
/* computed in UMFPACK_solve: */
#define UMFPACK_IR_TAKEN 80
#define UMFPACK_IR_ATTEMPTED 81
#define UMFPACK_OMEGA1 82
#define UMFPACK_OMEGA2 83
#define UMFPACK_SOLVE_FLOPS 84
#define UMFPACK_SOLVE_TIME 85
/* Info [86..89] unused */
/* Unused parts of Info may be used in future versions of UMFPACK. */
/* -------------------------------------------------------------------------- */
/* contents of Control */
/* -------------------------------------------------------------------------- */
/* used in all UMFPACK_report_* routines: */
#define UMFPACK_PRL 0
/* used in UMFPACK_*symbolic only: */
#define UMFPACK_DENSE_ROW 1
#define UMFPACK_DENSE_COL 2
/* used in UMFPACK_numeric only: */
#define UMFPACK_PIVOT_TOLERANCE 3
#define UMFPACK_BLOCK_SIZE 4
#define UMFPACK_RELAXED_AMALGAMATION 5
#define UMFPACK_ALLOC_INIT 6
#define UMFPACK_PIVOT_OPTION 12
#define UMFPACK_RELAXED2_AMALGAMATION 13
#define UMFPACK_RELAXED3_AMALGAMATION 14
/* used in UMFPACK_*solve only: */
#define UMFPACK_IRSTEP 7
/* compile-time settings - Control [8..11] cannot be changed at run time: */
#define UMFPACK_COMPILED_WITH_BLAS 8
#define UMFPACK_COMPILED_FOR_MATLAB 9
#define UMFPACK_COMPILED_WITH_GETRUSAGE 10
#define UMFPACK_COMPILED_IN_DEBUG_MODE 11
/* Control [15...19] unused */
/* Unused parts of Control may be used in future versions of UMFPACK. */
/* -------------------------------------------------------------------------- */
/* default values of Control [0..7,12..13]: */
/* -------------------------------------------------------------------------- */
/* Note that the default block sized changed for Version 3.1 and following. */
#define UMFPACK_DEFAULT_PRL 1
#define UMFPACK_DEFAULT_DENSE_ROW 0.2
#define UMFPACK_DEFAULT_DENSE_COL 0.2
#define UMFPACK_DEFAULT_PIVOT_TOLERANCE 0.1
#define UMFPACK_DEFAULT_BLOCK_SIZE 24
#define UMFPACK_DEFAULT_RELAXED_AMALGAMATION 0.25
#define UMFPACK_DEFAULT_RELAXED2_AMALGAMATION 0.1
#define UMFPACK_DEFAULT_RELAXED3_AMALGAMATION 0.125
#define UMFPACK_DEFAULT_ALLOC_INIT 0.7
#define UMFPACK_DEFAULT_IRSTEP 2
#define UMFPACK_DEFAULT_PIVOT_OPTION 0
/* default values of Control [0..7,12..13] may change in future versions */
/* of UMFPACK. */
/* -------------------------------------------------------------------------- */
/* status codes */
/* -------------------------------------------------------------------------- */
#define UMFPACK_OK (0)
#define UMFPACK_ERROR_out_of_memory (-1)
#define UMFPACK_ERROR_singular_matrix (-2)
#define UMFPACK_ERROR_invalid_Numeric_object (-3)
#define UMFPACK_ERROR_invalid_Symbolic_object (-4)
#define UMFPACK_ERROR_argument_missing (-5)
#define UMFPACK_ERROR_n_nonpositive (-6)
#define UMFPACK_ERROR_nz_negative (-7)
#define UMFPACK_ERROR_jumbled_matrix (-8)
#define UMFPACK_ERROR_Ap0_nonzero (-9)
#define UMFPACK_ERROR_row_index_out_of_bounds (-10)
#define UMFPACK_ERROR_different_pattern (-11)
#define UMFPACK_ERROR_col_length_negative (-12)
#define UMFPACK_ERROR_invalid_system (-13)
#define UMFPACK_ERROR_invalid_triplet (-14)
#define UMFPACK_ERROR_invalid_permutation (-15)
#define UMFPACK_ERROR_problem_too_large (-16)
#define UMFPACK_ERROR_internal_error (-911)
#endif /* UMFPACK_H */
\end{verbatim}
}
%-------------------------------------------------------------------------------
\newpage
\section{Demo C main program, {\tt umfpack\_demo.c}}
\label{Demo}
%-------------------------------------------------------------------------------
The {\tt umfpack\_l\_demo.c} is identical except that all the routine names
are changed, and {\tt long}'s are used instead of {\tt int}'s.
{\footnotesize
\begin{verbatim}
/*
A demo of UMFPACK Version 3.2: See umfpack_demo.m for a (roughly)
equivalent Matlab version. The only difference is that while the Matlab
umfpack mexFunction provides separate access to umfpack_symbolic, via
umfpack (A, 'symbolic'), it does not use its output for a subsequent
numerical factorization. Thus, you will find that the output of this
program and the Matlab diary are slightly different. The Matlab output also
uses 1-based matrix row and column indices, not 0-based (the internal
represention is the same).
First, factor and solve a 5-by-5 system, Ax=b, using default parameters,
[ 2 3 0 0 0 ] [ 8 ] [ 1 ]
[ 3 0 4 0 6 ] [ 45 ] [ 2 ]
A = [ 0 -1 -3 2 0 ], b = [ -3 ]. Solution is x = [ 3 ].
[ 0 0 1 0 0 ] [ 3 ] [ 4 ]
[ 0 4 2 0 1 ] [ 19 ] [ 5 ]
Then solve A'x=b, with solution:
x = [ 1.8158 1.4561 1.5000 -24.8509 10.2632 ]'
using the factors of A. Modify one entry (A (1,4) = 0, where the row and
column indices range from 0 to 4, obtaining the system:
[ 2 3 0 0 0 ] [ 8 ] [ 11.0 ]
[ 3 0 4 0 0 ] [ 45 ] [ -4.6667 ]
A = [ 0 -1 -3 2 0 ], b = [ -3 ]. Solution is x = [ 3.0 ].
[ 0 0 1 0 0 ] [ 3 ] [ 0.6667 ]
[ 0 4 2 0 1 ] [ 19 ] [ 31.6667 ]
The pattern of A has not changed (it has explicitly zero entry), so a
reanalysis with umfpack_symbolic does not need to be done (the Matlab
umfpack_demo.m will need to redo it, because the Matlab caller is not
provided with the Symbolic object). Refactorize (with umfpack_numeric),
and solve Ax=b. Note that the pivot ordering has changed. Next, change all
of the entries in A, but not the pattern. The system becomes
[ 2 13 0 0 0 ] [ 8 ] [ 8.5012 ]
[ 2 0 23 0 39 ] [ 45 ] [ -0.6925 ]
A = [ 0 7 15 30 0 ], b = [ -3 ]. Solution is x = [ 0.1667 ].
[ 0 0 18 0 0 ] [ 3 ] [ -0.0218 ]
[ 0 10 18 0 37 ] [ 19 ] [ 0.6196 ]
Finally, compute B = A', and do the symbolic and numeric factorization of B.
Factorizing A' can sometimes be better than factorizing A itself (less work
and memory usage). Solve B'x=b twice; the solution is the same as the
solution to Ax=b for the above A.
*/
/* -------------------------------------------------------------------------- */
/* definitions */
/* -------------------------------------------------------------------------- */
#include <stdio.h>
#include <stdlib.h>
#include "umfpack.h"
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
/* -------------------------------------------------------------------------- */
/* triplet form of the matrix. The triplets can be in any order. */
/* -------------------------------------------------------------------------- */
static int n = 5 ;
static int nz = 12 ;
static int Arow [ ] = { 0, 4, 1, 1, 2, 2, 0, 1, 2, 3, 4, 4} ;
static int Acol [ ] = { 0, 4, 0, 2, 1, 2, 1, 4, 3, 2, 1, 2} ;
static double Aval [ ] = {2., 1., 3., 4., -1., -3., 3., 6., 2., 1., 4., 2.} ;
static double b [ ] = {8., 45., -3., 3., 19.} ;
static double x [5] ;
static double r [5] ;
/* -------------------------------------------------------------------------- */
/* error: print a message and exit */
/* -------------------------------------------------------------------------- */
static void error
(
char *message
)
{
printf ("\n\n====== error: %s =====\n\n", message) ;
exit (1) ;
}
/* -------------------------------------------------------------------------- */
/* resid: compute the residual, r = Ax-b or r = A'x=b and return maxnorm (r) */
/* -------------------------------------------------------------------------- */
static double resid
(
int n,
int Ap [ ],
int Ai [ ],
double Ax [ ],
double x [ ],
double r [ ],
int transpose
)
{
int i, j, p ;
double norm ;
for (i = 0 ; i < n ; i++)
{
r [i] = -b [i] ;
}
if (transpose)
{
for (j = 0 ; j < n ; j++)
{
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
i = Ai [p] ;
r [j] += Ax [p] * x [i] ;
}
}
}
else
{
for (j = 0 ; j < n ; j++)
{
for (p = Ap [j] ; p < Ap [j+1] ; p++)
{
i = Ai [p] ;
r [i] += Ax [p] * x [j] ;
}
}
}
norm = 0. ;
for (i = 0 ; i < n ; i++)
{
norm = MAX (norm, ABS (r [i])) ;
}
return (norm) ;
}
/* -------------------------------------------------------------------------- */
/* main program */
/* -------------------------------------------------------------------------- */
/*ARGSUSED0*/ /* argc and argv are unused */
int main
(
int argc,
char **argv
)
{
double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL], *Ax, *Bx, *Lx, *Ux,
*W, *Y, *Z, *S, t ;
int *Ap, *Ai, *Bp, *Bi, row, col, p, lnz, unz, nn, *Lp, *Li, *Ui, *Up,
*P, *Q, *Lj, i, j, k, anz, nfr, nchains, nsparse_col, *Qtree, fnpiv,
status, *Front_npivots, *Front_parent, *Chain_start, *Wi,
*Chain_maxrows, *Chain_maxcols ;
void *Symbolic, *Numeric ;
/* ---------------------------------------------------------------------- */
/* initializations */
/* ---------------------------------------------------------------------- */
t = umfpack_timer ( ) ;
printf ("\n%s demo:\n", UMFPACK_VERSION) ;
/* get the default control parameters */
umfpack_defaults (Control) ;
/* change the default print level for this demo */
/* (otherwise, nothing will print) */
Control [UMFPACK_PRL] = 6 ;
/* print the license agreement */
umfpack_report_status (Control, UMFPACK_OK) ;
Control [UMFPACK_PRL] = 5 ;
/* print the control parameters */
umfpack_report_control (Control) ;
/* ---------------------------------------------------------------------- */
/* print A and b, and convert A to column-form */
/* ---------------------------------------------------------------------- */
/* print the right-hand-side */
(void) umfpack_report_vector ("b", n, b, Control) ;
/* print the triplet form of the matrix */
(void) umfpack_report_triplet ("A", n, nz, Arow, Acol, Aval, Control) ;
/* convert to column form */
Ap = (int *) malloc ((n+1) * sizeof (int)) ;
Ai = (int *) malloc (nz * sizeof (int)) ;
Ax = (double *) malloc (nz * sizeof (double)) ;
if (!Ap || !Ai || !Ax)
{
error ("out of memory") ;
}
status = umfpack_triplet_to_col (n, nz, Arow, Acol, Aval, Ap, Ai, Ax) ;
if (status != UMFPACK_OK)
{
umfpack_report_status (Control, status) ;
error ("umfpack_triplet_to_col failed") ;
}
/* print the column-form of A */
(void) umfpack_report_matrix ("A", n, Ap, Ai, Ax, "column", Control) ;
/* ---------------------------------------------------------------------- */
/* symbolic factorization */
/* ---------------------------------------------------------------------- */
status = umfpack_symbolic (n, Ap, Ai, &Symbolic, Control, Info) ;
if (status != UMFPACK_OK)
{
umfpack_report_info (Control, Info) ;
umfpack_report_status (Control, status) ;
error ("umfpack_symbolic failed") ;
}
/* print the symbolic factorization */
(void) umfpack_report_symbolic ("Symbolic factorization of A",
Symbolic, Control) ;
/* ---------------------------------------------------------------------- */
/* numeric factorization */
/* ---------------------------------------------------------------------- */
status = umfpack_numeric (Ap, Ai, Ax, Symbolic, &Numeric, Control, Info) ;
if (status != UMFPACK_OK)
{
umfpack_report_info (Control, Info) ;
umfpack_report_status (Control, status) ;
error ("umfpack_numeric failed") ;
}
/* print the numeric factorization */
(void) umfpack_report_numeric ("Numeric factorization of A",
Numeric, Control) ;
/* ---------------------------------------------------------------------- */
/* solve Ax=b */
/* ---------------------------------------------------------------------- */
status = umfpack_solve ("Ax=b", Ap, Ai, Ax, x, b, Numeric, Control, Info) ;
umfpack_report_info (Control, Info) ;
umfpack_report_status (Control, status) ;
if (status != UMFPACK_OK)
{
error ("umfpack_solve failed") ;
}
(void) umfpack_report_vector ("x (solution of Ax=b)", n, x, Control) ;
printf ("maxnorm of residual: %g\n\n", resid (n, Ap, Ai, Ax, x, r, FALSE)) ;
/* ---------------------------------------------------------------------- */
/* solve A'x=b */
/* ---------------------------------------------------------------------- */
status = umfpack_solve ("A'x=b", Ap, Ai, Ax, x, b, Numeric, Control, Info) ;
umfpack_report_info (Control, Info) ;
if (status != UMFPACK_OK)
{
error ("umfpack_solve failed") ;
}
(void) umfpack_report_vector ("x (solution of A'x=b)", n, x, Control) ;
printf ("maxnorm of residual: %g\n\n", resid (n, Ap, Ai, Ax, x, r, TRUE)) ;
/* ---------------------------------------------------------------------- */
/* modify one numerical value in the column-form of A */
/* ---------------------------------------------------------------------- */
/* change A (1,4), look for row index 1 in column 4. */
row = 1 ;
col = 4 ;
for (p = Ap [col] ; p < Ap [col+1] ; p++)
{
if (row == Ai [p])
{
printf ("\nchanging A (%d,%d) from %g", row, col, Ax [p]) ;
Ax [p] = 0.0 ;
printf (" to %g\n", Ax [p]) ;
break ;
}
}
(void) umfpack_report_matrix ("modified A", n, Ap, Ai, Ax, "column",
Control) ;
/* ---------------------------------------------------------------------- */
/* redo the numeric factorization */
/* ---------------------------------------------------------------------- */
/* The pattern (Ap and Ai) hasn't changed, so the symbolic factorization */
/* doesn't have to be redone, no matter how much we change Ax. */
/* We don't need the Numeric object any more, so free it. */
umfpack_free_numeric (&Numeric) ;
/* Note that a memory leak would have occured if the old Numeric */
/* had not been free'd with umfpack_free_numeric above. */
status = umfpack_numeric (Ap, Ai, Ax, Symbolic, &Numeric, Control, Info) ;
if (status != UMFPACK_OK)
{
umfpack_report_info (Control, Info) ;
umfpack_report_status (Control, status) ;
error ("umfpack_numeric failed") ;
}
(void) umfpack_report_numeric ("Numeric factorization of modified A",
Numeric, Control) ;
/* ---------------------------------------------------------------------- */
/* solve Ax=b, with the modified A */
/* ---------------------------------------------------------------------- */
status = umfpack_solve ("Ax=b", Ap, Ai, Ax, x, b, Numeric, Control, Info) ;
umfpack_report_info (Control, Info) ;
if (status != UMFPACK_OK)
{
umfpack_report_status (Control, status) ;
error ("umfpack_solve failed") ;
}
(void) umfpack_report_vector ("x (with modified A)", n, x, Control) ;
printf ("maxnorm of residual: %g\n\n", resid (n, Ap, Ai, Ax, x, r, FALSE)) ;
/* ---------------------------------------------------------------------- */
/* modify all of the numerical values of A, but not the pattern */
/* ---------------------------------------------------------------------- */
for (col = 0 ; col < n ; col++)
{
for (p = Ap [col] ; p < Ap [col+1] ; p++)
{
row = Ai [p] ;
printf ("changing A (%d,%d) from %g", row, col, Ax [p]) ;
Ax [p] = Ax [p] + col*10 - row ;
printf (" to %g\n", Ax [p]) ;
}
}
(void) umfpack_report_matrix ("completely modified A (same pattern)",
n, Ap, Ai, Ax, "column", Control) ;
/* ---------------------------------------------------------------------- */
/* redo the numeric factorization */
/* ---------------------------------------------------------------------- */
umfpack_free_numeric (&Numeric) ;
status = umfpack_numeric (Ap, Ai, Ax, Symbolic, &Numeric, Control, Info) ;
if (status != UMFPACK_OK)
{
umfpack_report_info (Control, Info) ;
umfpack_report_status (Control, status) ;
error ("umfpack_numeric failed") ;
}
(void) umfpack_report_numeric (
"Numeric factorization of completely modified A", Numeric, Control) ;
/* ---------------------------------------------------------------------- */
/* solve Ax=b, with the modified A */
/* ---------------------------------------------------------------------- */
status = umfpack_solve ("Ax=b", Ap, Ai, Ax, x, b, Numeric, Control, Info) ;
umfpack_report_info (Control, Info) ;
if (status != UMFPACK_OK)
{
umfpack_report_status (Control, status) ;
error ("umfpack_solve failed") ;
}
(void) umfpack_report_vector ("x (with completely modified A)",
n, x, Control) ;
printf ("maxnorm of residual: %g\n\n", resid (n, Ap, Ai, Ax, x, r, FALSE)) ;
/* ---------------------------------------------------------------------- */
/* free the symbolic and numeric factorization */
/* ---------------------------------------------------------------------- */
umfpack_free_symbolic (&Symbolic) ;
umfpack_free_numeric (&Numeric) ;
/* ---------------------------------------------------------------------- */
/* B = transpose of A */
/* ---------------------------------------------------------------------- */
Bp = (int *) malloc ((n+1) * sizeof (int)) ;
Bi = (int *) malloc (nz * sizeof (int)) ;
Bx = (double *) malloc (nz * sizeof (double)) ;
if (!Bp || !Bi || !Bx)
{
error ("out of memory") ;
}
status = umfpack_transpose (n, Ap, Ai, Ax, (int *) NULL, (int *) NULL,
Bp, Bi, Bx) ;
if (status != UMFPACK_OK)
{
umfpack_report_status (Control, status) ;
error ("umfpack_transpose failed") ;
}
(void) umfpack_report_matrix ("B (transpose of A)",
n, Bp, Bi, Bx, "column", Control) ;
/* ---------------------------------------------------------------------- */
/* symbolic factorization of B */
/* ---------------------------------------------------------------------- */
status = umfpack_symbolic (n, Bp, Bi, &Symbolic, Control, Info) ;
if (status != UMFPACK_OK)
{
umfpack_report_info (Control, Info) ;
umfpack_report_status (Control, status) ;
error ("umfpack_symbolic failed") ;
}
(void) umfpack_report_symbolic ("Symbolic factorization of B",
Symbolic, Control) ;
/* ---------------------------------------------------------------------- */
/* copy the contents of Symbolic into user arrays print them */
/* ---------------------------------------------------------------------- */
printf ("\nGet the contents of the Symbolic object for B:\n") ;
printf ("(compare with umfpack_report_symbolic output, above)\n") ;
Qtree = (int *) malloc (n * sizeof (int)) ;
Front_npivots = (int *) malloc (n * sizeof (int)) ;
Front_parent = (int *) malloc (n * sizeof (int)) ;
Chain_start = (int *) malloc ((n+1) * sizeof (int)) ;
Chain_maxrows = (int *) malloc (n * sizeof (int)) ;
Chain_maxcols = (int *) malloc (n * sizeof (int)) ;
if (!Qtree || !Front_npivots || !Front_parent || !Chain_start ||
!Chain_maxrows || !Chain_maxcols)
{
error ("out of memory") ;
}
status = umfpack_get_symbolic (&nn, &anz, &nfr, &nchains, &nsparse_col,
Qtree, Front_npivots, Front_parent, Chain_start,
Chain_maxrows, Chain_maxcols, Symbolic) ;
printf ("From the Symbolic object, B is of dimension n = %d\n", nn) ;
printf (" with nz = %d, number of fronts = %d,\n", nz, nfr) ;
printf (" number of frontal matrix chains = %d\n", nchains) ;
printf ("\nPivot columns in each front, and parent of each front:\n") ;
k = 0 ;
for (i = 0 ; i < nfr ; i++)
{
fnpiv = Front_npivots [i] ;
printf (" Front %d: parent front: %d number of pivots: %d\n",
i, Front_parent [i], fnpiv) ;
for (j = 0 ; j < fnpiv ; j++)
{
col = Qtree [k] ;
printf (
" %d-th pivot column is column %d in original matrix\n",
k, col) ;
k++ ;
}
}
printf ("\nNote that the column ordering, above, will be refined\n") ;
printf ("in the numeric factorization below. The assignment of pivot\n") ;
printf ("columns to frontal matrices will always remain unchanged.\n") ;
printf ("\nTotal number of pivot columns in frontal matrices: %d\n", k) ;
printf ("\nFrontal matrix chains:\n") ;
for (j = 0 ; j < nchains ; j++)
{
printf (" Frontal matrices %d to %d are factorized in a single\n",
Chain_start [j], Chain_start [j+1] - 1) ;
printf (" working array of size %d-by-%d\n",
Chain_maxrows [j], Chain_maxcols [j]) ;
}
/* ---------------------------------------------------------------------- */
/* numeric factorization of B */
/* ---------------------------------------------------------------------- */
status = umfpack_numeric (Bp, Bi, Bx, Symbolic, &Numeric, Control, Info) ;
if (status != UMFPACK_OK)
{
error ("umfpack_numeric failed") ;
}
(void) umfpack_report_numeric ("Numeric factorization of B",
Numeric, Control) ;
/* ---------------------------------------------------------------------- */
/* extract the LU factors of B and print them */
/* ---------------------------------------------------------------------- */
if (umfpack_get_lunz (&lnz, &unz, &nn, Numeric) != UMFPACK_OK)
{
error ("umfpack_get_lunz failed") ;
}
Lp = (int *) malloc ((n+1) * sizeof (int)) ;
Li = (int *) malloc (lnz * sizeof (int)) ;
Lx = (double *) malloc (lnz * sizeof (double)) ;
Up = (int *) malloc ((n+1) * sizeof (int)) ;
Ui = (int *) malloc (unz * sizeof (int)) ;
Ux = (double *) malloc (unz * sizeof (double)) ;
P = (int *) malloc (n * sizeof (int)) ;
Q = (int *) malloc (n * sizeof (int)) ;
if (!Lp || !Li || !Lx || !Up || !Ui || !Ux || !P || !Q)
{
error ("out of memory") ;
}
status = umfpack_get_numeric (Lp, Li, Lx, Up, Ui, Ux, P, Q, Numeric) ;
if (status != UMFPACK_OK)
{
error ("umfpack_get_numeric failed") ;
}
(void) umfpack_report_matrix ("L (lower triangular factor of B)",
n, Lp, Li, Lx, "row", Control) ;
(void) umfpack_report_matrix ("U (upper triangular factor of B)",
n, Up, Ui, Ux, "column", Control) ;
(void) umfpack_report_perm ("P", n, P, Control) ;
(void) umfpack_report_perm ("Q", n, Q, Control) ;
/* ---------------------------------------------------------------------- */
/* convert L to triplet form and print it */
/* ---------------------------------------------------------------------- */
printf ("\nConverting L to triplet form, and printing it:\n") ;
Lj = (int *) malloc (lnz * sizeof (int)) ;
if (!Lj)
{
error ("out of memory") ;
}
if (umfpack_col_to_triplet (n, Lp, Lj) != UMFPACK_OK)
{
error ("umfpack_col_to_triplet failed") ;
}
(void) umfpack_report_triplet ("L, in triplet form", n, lnz, Li, Lj, Lx,
Control) ;
/* ---------------------------------------------------------------------- */
/* solve B'x=b */
/* ---------------------------------------------------------------------- */
status = umfpack_solve ("A'x=b", Bp, Bi, Bx, x, b, Numeric, Control, Info) ;
umfpack_report_info (Control, Info) ;
if (status != UMFPACK_OK)
{
umfpack_report_status (Control, status) ;
error ("umfpack_solve failed") ;
}
(void) umfpack_report_vector ("x (solution of B'x=b)", n, x, Control) ;
printf ("maxnorm of residual: %g\n\n", resid (n, Bp, Bi, Bx, x, r, TRUE)) ;
/* ---------------------------------------------------------------------- */
/* solve B'x=b again, using umfpack_wsolve instead */
/* ---------------------------------------------------------------------- */
printf ("\nSolving B'x=b again, using umfpack_wsolve instead:\n") ;
Wi = (int *) malloc (n * sizeof (int)) ;
W = (double *) malloc (n * sizeof (double)) ;
Y = (double *) malloc (n * sizeof (double)) ;
Z = (double *) malloc (n * sizeof (double)) ;
S = (double *) malloc (n * sizeof (double)) ;
if (!Wi || !W || !Y || !Z || !S)
{
error ("out of memory") ;
}
status = umfpack_wsolve ("A'x=b", Bp, Bi, Bx, x, b, Numeric, Control, Info,
Wi, W, Y, Z, S) ;
umfpack_report_info (Control, Info) ;
if (status != UMFPACK_OK)
{
umfpack_report_status (Control, status) ;
error ("umfpack_wsolve failed") ;
}
(void) umfpack_report_vector ("x (solution of B'x=b)", n, x, Control) ;
printf ("maxnorm of residual: %g\n\n", resid (n, Bp, Bi, Bx, x, r, TRUE)) ;
/* ---------------------------------------------------------------------- */
/* free everything */
/* ---------------------------------------------------------------------- */
/* This is not strictly required since the process is exiting and the */
/* system will reclaim the memory anyway. It's useful, though, just as */
/* a list of what is currently malloc'ed by this program. Plus, it's */
/* always a good habit to explicitly free whatever you malloc. */
free (Ap) ;
free (Ai) ;
free (Ax) ;
free (Bp) ;
free (Bi) ;
free (Bx) ;
free (Qtree) ;
free (Front_npivots) ;
free (Front_parent) ;
free (Chain_start) ;
free (Chain_maxrows) ;
free (Chain_maxcols) ;
free (Lp) ;
free (Li) ;
free (Lx) ;
free (Up) ;
free (Ui) ;
free (Ux) ;
free (P) ;
free (Q) ;
free (Lj) ;
free (Wi) ;
free (W) ;
free (Y) ;
free (Z) ;
free (S) ;
umfpack_free_symbolic (&Symbolic) ;
umfpack_free_numeric (&Numeric) ;
/* ---------------------------------------------------------------------- */
/* print the total time spent in this demo */
/* ---------------------------------------------------------------------- */
t = umfpack_timer ( ) - t ;
printf ("\numfpack demo complete. Total time: %5.2f (seconds)\n", t) ;
return (0) ;
}
\end{verbatim}
}
%-------------------------------------------------------------------------------
\newpage
\section{Configuration file {\tt umf\_config.h}}
\label{Config}
%-------------------------------------------------------------------------------
{\footnotesize
\begin{verbatim}
/*
This file controls the compile-time configuration of UMFPACK. Modify the
Makefile, the architecture-dependent Make.* file, and this file if
necessary, to control these options. The following compile-time flags are
available:
-DNBLAS
BLAS mode. If -DNBLAS is set, then no BLAS will be used. Vanilla
C code will be used instead. This is portable, and easier to
install, but you won't get the best performance.
If -DNBLAS is not set, then externally-available BLAS routines
(dgemm, dger, and dgemv or the equivalent C-BLAS routines) will be
used. This will give you the best performance, but perhaps at the
expense of portability.
The default is to use the BLAS, for both the C-callable umfpack.a
library and the Matlab mexFunction. If you have trouble installing
UMFPACK, set -DNBLAS.
-DNCBLAS
If -DNCBLAS is set, then the C-BLAS will not be called. This is the
default when compiling the Matlab mexFunction, or when compiling
umfpack.a on Sun Solaris or SGI IRIX.
If -DNCBLAS is not set, then the C-BLAS interface to the BLAS is
used. If your vendor-supplied BLAS library does not have a C-BLAS
interface, you can obtain the ATLAS BLAS, available at
http://www.netlib.org/atlas.
Using the C-BLAS is the default when compiling umfpack.a on all
architectures except Sun Solaris (the Sun Performance Library is
somewhat faster). The ANSI C interface to the BLAS is fully
portable.
This flag is ignored if -DNBLAS is set.
-DLONGBLAS
If not defined, then the BLAS are not called in the long integer
version of UMFPACK (the umfpack_l_* routines). The most common
definitions of the BLAS, unfortunately, use int arguments, and
are thus not suitable for use in the LP64 model. Only the Sun
Performance Library, as far as I can tell, has a version of the
BLAS that allows long integer (64-bit) input arguments. This
flag is set automatically in Sun Solaris if you are using the
Sun Performance BLAS. You can set it yourself, too, if your BLAS
routines can take long integer input arguments.
-DNSUNPERF
Applies only to Sun Solaris. If -DNSUNPERF is set, then the Sun
Performance Library BLAS will not be used.
The Sun Performance Library BLAS is used by default when compiling
the C-callable umfpack.a library on Sun Solaris.
This flag is ignored if -DNBLAS is set.
-DNSCSL
Applies only to SGI IRIX. If -DSCSL is set, then the SGI SCSL
Scientific Library BLAS will not be used.
The SGI SCSL Scientific Library BLAS is used by default when
compiling the C-callable umfpack.a library on SGI IRIX.
This flag is ignored if -DNBLAS is set.
-DGETRUSAGE
If -DGETRUSAGE is set, then your system's getrusage routine will be
used for getting the process CPU time. Otherwise the ANSI C clock
routine will be used. The default is to use getrusage on Sun
Solaris, SGI Irix, Linux, and AIX (IBM RS 6000) and to use clock on
all other architectures.
C-to-Fortran interface, for the Fortran BLAS (these are set automatically
for the C-BLAS or Sun Performance BLAS):
-DBLAS_BY_VALUE if scalars are passed by value, not reference
-DBLAS_NO_UNDERSCORE if no underscore should be appended
-DBLAS_CHAR_ARG if BLAS options are single char's, not strings
You should normally not set these flags yourself:
-DMATLAB_MEX_FILE
This flag is turned on when compiling the umfpack mexFunction for
use in Matlab. When compiling the Matlab mexFunction, the Matlab
BLAS are used by default (this is set in the Makefile).
-DMATHWORKS
This flag is turned on when compiling umfpack as a built-in routine
in Matlab. It can also be used when compiling umfpack as a
mexFunction. Internal routines utMalloc, utFree, utRealloc, and
utPrintf are used, and the "util.h" file is included. This avoids
the problem discussed in the User Guide regarding memory allocation
in Matlab. utMalloc returns NULL on failure, instead of terminating
the mexFunction (which is what mxMalloc does). However, the ut*
routines are not documented by The MathWorks, Inc., so I cannot
guarantee that you will always be able to use them.
-DNDEBUG
Debugging mode (if NDEBUG is not defined). The default, of course,
is no debugging. Turning on debugging takes some work (see below).
*/
/* ========================================================================== */
/* === NDEBUG =============================================================== */
/* ========================================================================== */
/*
UMFPACK will be exceedingly slow when running in debug mode. The next three
lines ensure that debugging is turned off. If you want to compile UMFPACK
in debugging mode, you must comment out the three lines below:
*/
#ifndef NDEBUG
#define NDEBUG
#endif
/*
Next, you must either remove the -DNDEBUG option in the Makefile, or simply
add the following line:
#undef NDEBUG
*/
/* ========================================================================== */
/* === Memory allocator ===================================================== */
/* ========================================================================== */
/* The Matlab mexFunction uses Matlab's memory manager, while the C-callable */
/* umfpack.a library uses the ANSI C malloc, free, and realloc routines. */
#ifdef MATLAB_MEX_FILE
#include "matrix.h"
#define ALLOCATE mxMalloc
#define FREE mxFree
#define REALLOCATE mxRealloc
#else
#ifdef MATHWORKS
#include "util.h"
/* Compiling UMFPACK as a built-in routine. */
/* Since UMFPACK carefully checks for out-of-memory after every allocation, */
/* we can use ut* routines here. */
#define ALLOCATE utMalloc
#define FREE utFree
#define REALLOCATE utRealloc
#else
#define ALLOCATE malloc
#define FREE free
#define REALLOCATE realloc
#endif
#endif
/* ========================================================================== */
/* === PRINTF macro ========================================================= */
/* ========================================================================== */
/* All output goes through the PRINTF macro. Printing occurs only from the */
/* UMFPACK_report_* routines. */
#ifdef MATLAB_MEX_FILE
#include "mex.h"
#define PRINTF(params) { (void) mexPrintf params ; }
#else
#ifdef MATHWORKS
/* Already #included "util.h" above in Memory allocator section */
#define PRINTF(params) { (void) utPrintf params ; }
#else
#define PRINTF(params) { (void) printf params ; }
#endif
#endif
/* ========================================================================== */
/* === 0-based or 1-based printing ========================================== */
/* ========================================================================== */
#if defined (MATLAB_MEX_FILE) || defined (MATHWORKS)
/* In Matlab, matrices are 1-based to the user, but 0-based internally. */
/* One is added to all row and column indices when printing matrices */
/* in UMFPACK_report_*. */
#define INDEX(i) ((i)+1)
#else
/* In ANSI C, matrices are 0-based and indices are reported as such. */
#define INDEX(i) (i)
#endif
/* ========================================================================== */
/* === Architecture ========================================================= */
/* ========================================================================== */
#if defined (__sun)
#define UMFPACK_ARCHITECTURE "Sun Solaris"
#endif
#if defined (__sgi)
#define UMFPACK_ARCHITECTURE "SGI Irix"
#endif
#if defined (__linux)
#define UMFPACK_ARCHITECTURE "Linux"
#endif
#if defined (_AIX)
#define UMFPACK_ARCHITECTURE "IBM AIX"
#endif
#if defined (__alpha)
#define UMFPACK_ARCHITECTURE "Compaq Alpha"
#endif
/* ========================================================================== */
/* === Timer ================================================================ */
/* ========================================================================== */
/*
If you have the getrusage routine (all Unix systems I've test do), then use
that. Otherwise, use the ANSI C clock function. Note that on many
systems, the ANSI clock function wraps around after only 2147 seconds, or
about 36 minutes. BE CAREFUL: if you compare the run time of UMFPACK with
other sparse matrix packages, be sure to use the same timer. See
umfpack_timer.c for the timer used by UMFPACK.
*/
/* Sun Solaris, SGI Irix, Linux, Compaq Alpha, and IBM RS 6000 all have */
/* getrusage. It's in BSD unix, so perhaps all unix systems have it. */
#if defined (__sun) || defined (__sgi) || defined (__linux) \
|| defined (__alpha) || defined (_AIX)
#define GETRUSAGE
#endif
/* ========================================================================== */
/* === BLAS ================================================================= */
/* ========================================================================== */
/*
Determine if the BLAS exists for the long integer version. It exists if
LONGBLAS is defined in the Makefile, or if using the BLAS from the
Sun Performance Library, or SGI's SCSL Scientific Library.
*/
#if !defined (MATLAB_MEX_FILE) && defined (__sun) && !defined (NSUNPERF)
#define BLAS_SUNPERF
#ifndef LONGBLAS
#define LONGBLAS
#endif
#endif
#if !defined (MATLAB_MEX_FILE) && defined (__sgi) && !defined (NSCSL)
#define BLAS_SCSL
#ifndef LONGBLAS
#define LONGBLAS
#endif
#endif
#if defined (DLONG) && !defined (LONGBLAS) && !defined (NBLAS)
#define NBLAS
#endif
/* -------------------------------------------------------------------------- */
#ifndef NBLAS
/*
If the compile-time flag -DNBLAS is defined, then the BLAS are not used,
portable vanilla C code is used instead, and the remainder of this file
is ignored.
Using the BLAS is much faster, but how C calls the Fortran BLAS is
machine-dependent and thus can cause portability problems. Thus, use
-DNBLAS to ensure portability (at the expense of speed).
Preferences:
*** The best interface to use, regardless of the option you select
below, is the standard C-BLAS interface. Not all vendor-supplied
BLAS libraries use this interface (as of April 2001). The only
problem with this interface is that it does not extend to the LP64
model.
1) most preferred: use the optimized vendor-supplied library (such as
the Sun Performance Library, or IBM's ESSL). This is often the
fastest, but might not be portable and might not always be
available. When compiling a Matlab mexFunction it might be
difficult get the mex compiler script to recognize the vendor-
supplied BLAS (I was not able get my mexFunction to use the
Sun Performance Library BLAS, for example, because of linking
difficulties).
2) When compiling the UMFPACK mexFunction to use UMFPACK in Matlab, use
the BLAS provided by The Mathworks, Inc. This assumes you are using
Matlab V6 or higher, since the BLAS are not incorporated in V5 or
earlier versions. On my Sun workstation, the Matlab BLAS gave
slightly worse performance than the Sun Perf. BLAS. The advantage
of using the Matlab BLAS is that it's available on any computer that
has Matlab V6 or higher. I have not tried using Matlab BLAS outside
of a mexFunction in a stand-alone C code, but Matlab (V6) allows for
this. This is well worth trying if you have Matlab and don't want
to bother installing the ATLAS BLAS (option 3a, below). The only
glitch to this is that Matlab does not provide a portable interface
to the BLAS (an underscore is required for some but not all
architectures). These variations are taken into account in the
mexopts.sh file provided with UMFPACK.
3) Use a portable high-performance BLAS library:
(a) The ATLAS BLAS, available at http://www.netlib.org/atlas,
by R. Clint Whaley, Antoine Petitet, and Jack Dongarra.
This has a standard C interface, and thus the interface to it is
fully portable. Its performance rivals, and sometimes exceeds,
the vendor-supplied BLAS on many computers.
(b) The Fortran RISC BLAS by Michel Dayde', Iain Duff, Antoine
Petitet, and Abderrahim Qrichi Aniba, available via anonymous
ftp to ftp.enseeiht.fr in the pub/numerique/BLAS/RISC directory,
See M. J. Dayde' and I. S. Duff, "The RISC BLAS: A blocked
implementation of level 3 BLAS for RISC processors, ACM Trans.
Math. Software, vol. 25, no. 3., Sept. 1999. This will give
you good performance, but with the same C-to-Fortran portability
problems as option (1).
4) Use UMFPACK's built-in vanilla C code by setting -DNBLAS at compile
time. The key advantage is portability, which is guaranteed if you
have an ANSI C compliant compiler. You also don't need to download
any other package - UMFPACK is stand-alone. No Fortran is used
anywhere in UMFPACK. UMFPACK will be much slower than when using
options (1) through (3), however.
5) least preferred: use the standard Fortran implementation of the
BLAS, also available at Netlib (http://www.netlib.org/blas). This
will be no faster than option (4), and not portable because of
C-to-Fortran calling conventions. Don't bother trying option (5).
The mechanics of how C calls the BLAS on various computers are as follows:
* C-BLAS (from the ATLAS library, for example):
The same interface is used on all computers. This is the default
(except on Sun Solaris, or when compiling the Matlab mexFunction).
SGI Irix provides a C-BLAS interface to its vendor-supplied BLAS.
* Defaults for calling the Fortran BLAS:
add underscore, pass scalars by reference, use string arguments.
* The Fortran BLAS on Sun Solaris (when compiling the Matlab mexFunction
or when using the Fortran RISC BLAS), SGI, Linux:
use defaults.
* Sun Solaris (when using the C-callable Sun Performance library):
no underscore, pass scalars by value, use character arguments.
* The Fortran BLAS (ESSL Library) on the IBM RS 6000:
no underscore, pass scalars by reference, use string arguments.
* The Fortran BLAS on the HP PA:
no underscore, pass scalars by reference, use string arguments.
This has not been tested. For the umfpack.a library, I recommend
using the C-BLAS in the ATLAS library instead. The Matlab
mexFunction needs to have the -DBLAS_NO_UNDERSCORE compile-time
flag set. I've modified the mexopts.sh file to do this, but have
not tested it.
* The Fortran BLAS on Windows:
no underscore, pass scalars by reference, use string arguments.
This has not been tested. For the umfpack.a library, I recommend
using the C-BLAS in the ATLAS library instead. The Mathworks-
provided lcc compiler prepends an underscore to all C routine names.
Thus, dgemm becomes _dgemm. However, the Mathworks BLAS library has
dgemm, not _dgemm. I've contacted Mathworks and so far there is
no work-around for this problem. Use another compiler. If you must
use lcc then either do not use the BLAS in Matlab or use the C-BLAS.
*/
#ifndef NCBLAS
/* -------------------------------------------------------------------------- */
/* use the C-BLAS (any computer) */
/* -------------------------------------------------------------------------- */
/* This is the default, except for Solaris and IRIX umfpack.a, and for the */
/* mexFunction on any architecture. */
/* If you use the ATLAS C-BLAS, then be sure to set the -I flag to */
/* -I/path/ATLAS/include, where /path/ATLAS is the ATLAS installation */
/* directory. Note that UMFPACK uses column-major storage for its dense */
/* matrices, but these are not visible to the user. */
#include "cblas.h"
#define BLAS_DGEMM_ROUTINE cblas_dgemm
#define BLAS_DGEMV_ROUTINE cblas_dgemv
#define BLAS_DGER_ROUTINE cblas_dger
#define BLAS_NO_TRANSPOSE CblasNoTrans
#define BLAS_TRANSPOSE CblasTrans
/* This argument is present only for the C-BLAS: */
#define BLAS_COLUMN_MAJOR_ORDER CblasColMajor,
#define BLAS_SCALAR(n) n
#define BLAS_INT_SCALAR(n) n
#else
/* No such argument when not using the C-BLAS */
#define BLAS_COLUMN_MAJOR_ORDER
/* -------------------------------------------------------------------------- */
/* use Fortran (or other architecture-specific) BLAS */
/* -------------------------------------------------------------------------- */
/* Determine which architecture we're on and set options accordingly. */
#ifdef BLAS_SUNPERF
/* Sun Solaris sunperf library - the default for Solaris umfpack.a */
#include <sunperf.h>
#define BLAS_BY_VALUE
#define BLAS_NO_UNDERSCORE
#define BLAS_CHAR_ARG
#endif
#ifdef BLAS_SCSL
/* SGI SCSL library - the default for SGI umfpack.a */
#if defined (LP64)
#include <scsl_blas_i8.h>
#else
#include <scsl_blas.h>
#endif
#define BLAS_BY_VALUE
#define BLAS_NO_UNDERSCORE
#endif
/* The IBM RS 6000 does not add the underscore */
#if defined (_AIX)
#define BLAS_NO_UNDERSCORE
#endif
/*
Add your own architecture-dependent settings here.
For example, to call the Fortran BLAS on Windows, or HP PA:
#if defined (__win32) || defined (__hppa)
#define BLAS_NO_UNDERSCORE
#endif
*/
/* -------------------------------------------------------------------------- */
/* BLAS names */
/* -------------------------------------------------------------------------- */
#if defined (LP64) && defined (BLAS_SUNPERF)
/* 64-bit sunperf BLAS, for Sun Solaris only */
#define BLAS_DGEMM_ROUTINE dgemm_64
#define BLAS_DGEMV_ROUTINE dgemv_64
#define BLAS_DGER_ROUTINE dger_64
#else
/* naming convention (use underscore, or not) */
#ifdef BLAS_NO_UNDERSCORE
#define BLAS_DGEMM_ROUTINE dgemm
#define BLAS_DGEMV_ROUTINE dgemv
#define BLAS_DGER_ROUTINE dger
#else
/* default: add underscore */
#define BLAS_DGEMM_ROUTINE dgemm_
#define BLAS_DGEMV_ROUTINE dgemv_
#define BLAS_DGER_ROUTINE dger_
#endif
#endif /* LP64 && BLAS_SUNPERF */
/* -------------------------------------------------------------------------- */
/* BLAS scalars */
/* -------------------------------------------------------------------------- */
/* pass scalars by value or by reference */
#ifdef BLAS_BY_VALUE
#define BLAS_SCALAR(n) n
#else
/* default: pass scalars by reference */
#define BLAS_SCALAR(n) &(n)
#endif
#if defined (BLAS_SCSL) && defined (LP64)
#define BLAS_INT_SCALAR(n) ((long long) n)
#else
#define BLAS_INT_SCALAR(n) BLAS_SCALAR(n)
#endif
/* -------------------------------------------------------------------------- */
/* BLAS strings */
/* -------------------------------------------------------------------------- */
/* pass strings or single characters */
#ifdef BLAS_CHAR_ARG
#define BLAS_NO_TRANSPOSE 'N'
#define BLAS_TRANSPOSE 'T'
#else
/* default: use string arguments */
#define BLAS_NO_TRANSPOSE "N"
#define BLAS_TRANSPOSE "T"
#endif
#endif /* NCBLAS */
/* -------------------------------------------------------------------------- */
/* BLAS macros, for all interfaces */
/* -------------------------------------------------------------------------- */
/* C = C - A*B, where A is m-by-k, B is k-by-n, and leading dimension is d */
#define BLAS_DGEMM(m,n,k,A,B,C,d) \
{ \
double alpha = -1.0 ; \
double beta = 1.0 ; \
(void) BLAS_DGEMM_ROUTINE (BLAS_COLUMN_MAJOR_ORDER \
BLAS_NO_TRANSPOSE, BLAS_NO_TRANSPOSE, \
BLAS_INT_SCALAR (m), BLAS_INT_SCALAR (n), BLAS_INT_SCALAR (k), \
BLAS_SCALAR (alpha), \
A, BLAS_INT_SCALAR (d), B, BLAS_INT_SCALAR (d), BLAS_SCALAR (beta), \
C, BLAS_INT_SCALAR (d)) ; \
}
/* A = A - x*y', where A is m-by-n with leading dimension d */
#define BLAS_DGER(m,n,x,y,A,d) \
{ \
double alpha = -1.0 ; \
Int incx = 1 ; \
(void) BLAS_DGER_ROUTINE (BLAS_COLUMN_MAJOR_ORDER \
BLAS_INT_SCALAR (m), BLAS_INT_SCALAR (n), BLAS_SCALAR (alpha), \
x, BLAS_INT_SCALAR (incx), y, BLAS_INT_SCALAR (d), A, BLAS_INT_SCALAR (d)) ; \
}
/* y = y - A'*x, where A is m-by-n with leading dimension d, */
/* and x and y are row vectors with stride d */
#define BLAS_DGEMV_ROW(m,n,A,x,y,d) \
{ \
double alpha = -1.0 ; \
double beta = 1.0 ; \
(void) BLAS_DGEMV_ROUTINE (BLAS_COLUMN_MAJOR_ORDER \
BLAS_TRANSPOSE, \
BLAS_INT_SCALAR (m), BLAS_INT_SCALAR (n), BLAS_SCALAR (alpha), \
A, BLAS_INT_SCALAR (d), x, BLAS_INT_SCALAR (d), BLAS_SCALAR (beta), \
y, BLAS_INT_SCALAR (d)) ; \
}
/* y = y - A*x, where A is m-by-n with leading dimension d, */
/* and x and y are column vectors with stride 1 */
#define BLAS_DGEMV_COL(m,n,A,x,y,d) \
{ \
double alpha = -1.0 ; \
double beta = 1.0 ; \
Int incx = 1 ; \
Int incy = 1 ; \
(void) BLAS_DGEMV_ROUTINE (BLAS_COLUMN_MAJOR_ORDER \
BLAS_NO_TRANSPOSE, \
BLAS_INT_SCALAR (m), BLAS_INT_SCALAR (n), BLAS_SCALAR (alpha), \
A, BLAS_INT_SCALAR (d), x, BLAS_INT_SCALAR (incx), BLAS_SCALAR (beta), \
y, BLAS_INT_SCALAR (incy)) ; \
}
#endif /* NBLAS */
\end{verbatim}
}
%-------------------------------------------------------------------------------
\newpage
% References
%-------------------------------------------------------------------------------
\bibliographystyle{plain}
\bibliography{UserGuide}
\end{document}
|