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
|
@c DO NOT EDIT! Generated automatically by munge-texi.pl.
@c Copyright (C) 1996-2025 The Octave Project Developers
@c
@c This file is part of Octave.
@c
@c Octave is free software: you can redistribute it and/or modify it
@c under the terms of the GNU General Public License as published by
@c the Free Software Foundation, either version 3 of the License, or
@c (at your option) any later version.
@c
@c Octave is distributed in the hope that it will be useful, but
@c WITHOUT ANY WARRANTY; without even the implied warranty of
@c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@c GNU General Public License for more details.
@c
@c You should have received a copy of the GNU General Public License
@c along with Octave; see the file COPYING. If not, see
@c <https://www.gnu.org/licenses/>.
@node Linear Algebra
@chapter Linear Algebra
@cindex linear algebra
This chapter documents the linear algebra functions provided in Octave.
Reference material for many of these functions may be found in
@nospell{Golub and Van Loan}, @cite{Matrix Computations, 2nd Ed.},
Johns Hopkins, 1989, and in the @cite{@sc{lapack} Users' Guide}, SIAM, 1992.
The @cite{@sc{lapack} Users' Guide} is available at:
@cite{http://www.netlib.org/lapack/lug/}
A common text for engineering courses is @nospell{G. Strang},
@cite{Linear Algebra and Its Applications, 4th Edition}. It has become a
widespread reference for linear algebra. An alternative is P. Lax
@cite{Linear Algebra and Its Applications}, and also is a good choice. It
claims to be suitable for high school students with substantial mathematical
interests as well as first-year undergraduates.
@menu
* Techniques Used for Linear Algebra::
* Basic Matrix Functions::
* Matrix Factorizations::
* Functions of a Matrix::
* Specialized Solvers::
@end menu
@node Techniques Used for Linear Algebra
@section Techniques Used for Linear Algebra
@cindex linear algebra, techniques
Octave includes a polymorphic solver that selects an appropriate matrix
factorization depending on the properties of the matrix itself.
Generally, the cost of determining the matrix type is small relative to
the cost of factorizing the matrix itself. In any case the matrix type
is cached once it is calculated so that it is not re-determined each
time it is used in a linear equation.
The selection tree for how the linear equation is solved or a matrix
inverse is formed is given by:
@enumerate 1
@item If the matrix is upper or lower triangular sparse use a forward or
backward substitution using the @sc{lapack} xTRTRS function, and goto 4.
@c Permuted triangular matrices currently disabled in the code
@c
@c @item If the matrix is a upper triangular matrix with column permutations
@c or lower triangular matrix with row permutations, perform a forward or
@c backward substitution, and goto 5.
@item If the matrix is square, Hermitian with a real positive diagonal,
attempt Cholesky@tie{}factorization using the @sc{lapack} xPOTRF function.
@item If the Cholesky@tie{}factorization failed or the matrix is not
Hermitian with a real positive diagonal, and the matrix is square, factorize
using the @sc{lapack} xGETRF function.
@item If the matrix is not square, or any of the previous solvers flags
a singular or near singular matrix, find a least squares solution using
the @sc{lapack} xGELSD function.
@end enumerate
The user can force the type of the matrix with the @code{matrix_type}
function. This overcomes the cost of discovering the type of the matrix.
However, it should be noted that identifying the type of the matrix incorrectly
will lead to unpredictable results, and so @code{matrix_type} should be
used with care.
It should be noted that the test for whether a matrix is a candidate for
Cholesky@tie{}factorization, performed above, and by the @code{matrix_type}
function, does not make certain that the matrix is
Hermitian. However, the attempt to factorize the matrix will quickly
detect a non-Hermitian matrix.
@node Basic Matrix Functions
@section Basic Matrix Functions
@cindex matrix functions, basic
@c balance libinterp/corefcn/balance.cc
@anchor{XREFbalance}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{AA} =} balance (@var{A})
@deftypefnx {} {@var{AA} =} balance (@var{A}, @var{opt})
@deftypefnx {} {[@var{DD}, @var{AA}] =} balance (@var{A}, @var{opt})
@deftypefnx {} {[@var{D}, @var{P}, @var{AA}] =} balance (@var{A}, @var{opt})
@deftypefnx {} {[@var{CC}, @var{DD}, @var{AA}, @var{BB}] =} balance (@var{A}, @var{B}, @var{opt})
Balance the matrix @var{A} to reduce numerical errors in future
calculations.
Compute @code{@var{AA} = @var{DD} \ @var{A} * @var{DD}} in which @var{AA}
is a matrix whose row and column norms are roughly equal in magnitude, and
@code{@var{DD} = @var{P} * @var{D}}, in which @var{P} is a permutation
matrix and @var{D} is a diagonal matrix of powers of two. This allows the
equilibration to be computed without round-off. Results of eigenvalue
calculation are typically improved by balancing first.
If two output values are requested, @code{balance} returns
the diagonal @var{D} and the permutation @var{P} separately as vectors.
In this case, @code{@var{DD} = eye(n)(:,@var{P}) * diag (@var{D})}, where
@math{n} is the matrix size.
If four output values are requested, compute @code{@var{AA} =
@var{CC}*@var{A}*@var{DD}} and @code{@var{BB} = @var{CC}*@var{B}*@var{DD}},
in which @var{AA} and @var{BB} have nonzero elements of approximately the
same magnitude and @var{CC} and @var{DD} are permuted diagonal matrices as
in @var{DD} for the algebraic eigenvalue problem.
The eigenvalue balancing option @var{opt} may be one of:
@table @asis
@item @qcode{"noperm"}, @qcode{"S"}
Scale only; do not permute.
@item @qcode{"noscal"}, @qcode{"P"}
Permute only; do not scale.
@end table
Algebraic eigenvalue balancing uses standard @sc{lapack} routines.
Generalized eigenvalue problem balancing uses Ward's algorithm
(SIAM Journal on Scientific and Statistical Computing, 1981).
@end deftypefn
@c bandwidth scripts/linear-algebra/bandwidth.m
@anchor{XREFbandwidth}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{bw} =} bandwidth (@var{A}, @var{type})
@deftypefnx {} {[@var{lower}, @var{upper}] =} bandwidth (@var{A})
Compute the bandwidth of @var{A}.
The @var{type} argument is the string @qcode{"lower"} for the lower
bandwidth and @qcode{"upper"} for the upper bandwidth. If no @var{type} is
specified return both the lower and upper bandwidth of @var{A}.
The lower/upper bandwidth of a matrix is the number of
subdiagonals/superdiagonals with nonzero entries.
@xseealso{@ref{XREFisbanded,,isbanded}, @ref{XREFisdiag,,isdiag}, @ref{XREFistril,,istril}, @ref{XREFistriu,,istriu}}
@end deftypefn
@c cond scripts/linear-algebra/cond.m
@anchor{XREFcond}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{c} =} cond (@var{A})
@deftypefnx {} {@var{c} =} cond (@var{A}, @var{p})
Compute the @var{p}-norm condition number of a matrix with respect to
inversion.
@code{cond (@var{A})} is defined as
@tex
$ {\parallel A \parallel_p * \parallel A^{-1} \parallel_p .} $
@end tex
@ifnottex
@code{norm (@var{A}, @var{p}) * norm (inv (@var{A}), @var{p})}.
@end ifnottex
By default, @code{@var{p} = 2} is used which implies a (relatively slow)
singular value decomposition. Other possible selections are
@code{@var{p} = 1, Inf, "fro"} which are generally faster. For a full
discussion of possible @var{p} values, @pxref{XREFnorm,,@code{norm}}.
The condition number of a matrix quantifies the sensitivity of the matrix
inversion operation when small changes are made to matrix elements. Ideally
the condition number will be close to 1. When the number is large this
indicates small changes (such as underflow or round-off error) will produce
large changes in the resulting output. In such cases the solution results
from numerical computing are not likely to be accurate.
@xseealso{@ref{XREFcondest,,condest}, @ref{XREFrcond,,rcond}, @ref{XREFcondeig,,condeig}, @ref{XREFnorm,,norm}, @ref{XREFsvd,,svd}}
@end deftypefn
@c condeig scripts/linear-algebra/condeig.m
@anchor{XREFcondeig}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{c} =} condeig (@var{a})
@deftypefnx {} {[@var{v}, @var{lambda}, @var{c}] =} condeig (@var{a})
Compute condition numbers of a matrix with respect to eigenvalues.
The condition numbers are the reciprocals of the cosines of the angles
between the left and right eigenvectors; Large values indicate that the
matrix has multiple distinct eigenvalues.
The input @var{a} must be a square numeric matrix.
The outputs are:
@itemize @bullet
@item
@var{c} is a vector of condition numbers for the eigenvalues of
@var{a}.
@item
@var{v} is the matrix of right eigenvectors of @var{a}. The result is
equivalent to calling @code{[@var{v}, @var{lambda}] = eig (@var{a})}.
@item
@var{lambda} is the diagonal matrix of eigenvalues of @var{a}. The
result is equivalent to calling
@code{[@var{v}, @var{lambda}] = eig (@var{a})}.
@end itemize
Example
@example
@group
a = [1, 2; 3, 4];
c = condeig (a)
@result{} c =
1.0150
1.0150
@end group
@end example
@xseealso{@ref{XREFeig,,eig}, @ref{XREFcond,,cond}, @ref{XREFbalance,,balance}}
@end deftypefn
@c det libinterp/corefcn/det.cc
@anchor{XREFdet}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{d} =} det (@var{A})
@deftypefnx {} {[@var{d}, @var{rcond}] =} det (@var{A})
Compute the determinant of @var{A}.
Return an estimate of the reciprocal condition number if requested.
Programming Notes: Routines from @sc{lapack} are used for full matrices and
code from @sc{umfpack} is used for sparse matrices.
The determinant should not be used to check a matrix for singularity.
For that, use any of the condition number functions: @code{cond},
@code{condest}, @code{rcond}.
@xseealso{@ref{XREFcond,,cond}, @ref{XREFcondest,,condest}, @ref{XREFrcond,,rcond}}
@end deftypefn
@c eig libinterp/corefcn/eig.cc
@anchor{XREFeig}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{lambda} =} eig (@var{A})
@deftypefnx {} {@var{lambda} =} eig (@var{A}, @var{B})
@deftypefnx {} {[@var{V}, @var{lambda}] =} eig (@var{A})
@deftypefnx {} {[@var{V}, @var{lambda}] =} eig (@var{A}, @var{B})
@deftypefnx {} {[@var{V}, @var{lambda}, @var{W}] =} eig (@var{A})
@deftypefnx {} {[@var{V}, @var{lambda}, @var{W}] =} eig (@var{A}, @var{B})
@deftypefnx {} {[@dots{}] =} eig (@var{A}, @var{balanceOption})
@deftypefnx {} {[@dots{}] =} eig (@var{A}, @var{B}, @var{algorithm})
@deftypefnx {} {[@dots{}] =} eig (@dots{}, @var{eigvalOption})
Compute the eigenvalues (@var{lambda}) and optionally the right eigenvectors
(@var{V}) and the left eigenvectors (@var{W}) of a matrix or pair of matrices.
The flag @var{balanceOption} can be one of:
@table @asis
@item @qcode{"balance"} (default)
Preliminary balancing is on.
@item @qcode{"nobalance"}
Disables preliminary balancing.
@end table
The flag @var{eigvalOption} can be one of:
@table @asis
@item @qcode{"matrix"}
Return the eigenvalues in a diagonal matrix. (default if 2 or 3 outputs
are requested)
@item @qcode{"vector"}
Return the eigenvalues in a column vector. (default if only 1 output is
requested, e.g., @code{@var{lambda} = eig (@var{A})})
@end table
The flag @var{algorithm} can be one of:
@table @asis
@item @qcode{"chol"}
Use the Cholesky factorization of B. (default if @var{A} is symmetric
(Hermitian) and @var{B} is symmetric (Hermitian) positive definite)
@item @qcode{"qz"}
Use the QZ algorithm. (used whenever @var{A} or @var{B} are not symmetric)
@end table
@multitable @columnfractions .44 .14 .14 .10
@headitem A and B @tab no flag @tab chol @tab qz
@item both are symmetric
@tab @qcode{"chol"}
@tab @qcode{"chol"}
@tab @qcode{"qz"}
@item at least one is not symmetric
@tab @qcode{"qz"}
@tab @qcode{"qz"}
@tab @qcode{"qz"}
@end multitable
The eigenvalues returned by @code{eig} are not ordered.
@xseealso{@ref{XREFeigs,,eigs}, @ref{XREFsvd,,svd}}
@end deftypefn
@c givens libinterp/corefcn/givens.cc
@anchor{XREFgivens}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{G} =} givens (@var{x}, @var{y})
@deftypefnx {} {[@var{c}, @var{s}] =} givens (@var{x}, @var{y})
Compute the Givens rotation matrix @var{G}.
@tex
The Givens matrix is a $2\times 2$ orthogonal matrix
$$
G = \left[\matrix{c & s\cr -s'& c\cr}\right]
$$
such that
$$
G \left[\matrix{x\cr y}\right] = \left[\matrix{\ast\cr 0}\right]
$$
with $x$ and $y$ scalars.
@end tex
@ifnottex
The Givens matrix is a 2-by-2 orthogonal matrix
@example
@group
@var{G} = [ @var{c} , @var{s}
-@var{s}', @var{c}]
@end group
@end example
@noindent
such that
@example
@var{G} * [@var{x}; @var{y}] = [*; 0]
@end example
@noindent
with @var{x} and @var{y} scalars.
@end ifnottex
If two output arguments are requested, return the factors @var{c} and @var{s}
rather than the Givens rotation matrix.
For example:
@example
@group
givens (1, 1)
@result{} 0.70711 0.70711
-0.70711 0.70711
@end group
@end example
Note: The Givens matrix represents a counterclockwise rotation of a 2-D
plane and can be used to introduce zeros into a matrix prior to complete
factorization.
@xseealso{@ref{XREFplanerot,,planerot}, @ref{XREFqr,,qr}}
@end deftypefn
@c gsvd libinterp/corefcn/gsvd.cc
@anchor{XREFgsvd}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{S} =} gsvd (@var{A}, @var{B})
@deftypefnx {} {[@var{U}, @var{V}, @var{X}, @var{C}, @var{S}] =} gsvd (@var{A}, @var{B})
@deftypefnx {} {[@var{U}, @var{V}, @var{X}, @var{C}, @var{S}] =} gsvd (@var{A}, @var{B}, 0)
Compute the generalized singular value decomposition of (@var{A}, @var{B}).
The generalized singular value decomposition is defined by the following
relations:
@tex
$$ A = U C X^\dagger $$
$$ B = V S X^\dagger $$
$$ C^\dagger C + S^\dagger S = eye (columns (A)) $$
@end tex
@ifnottex
@example
@group
A = U*C*X'
B = V*S*X'
C'*C + S'*S = eye (columns (A))
@end group
@end example
@end ifnottex
The function @code{gsvd} normally returns just the vector of generalized
singular values
@tex
$$ \sqrt{{{diag (C^\dagger C)} \over {diag (S^\dagger S)}}} $$
@end tex
@ifnottex
@code{sqrt (diag (C'*C) ./ diag (S'*S))}.
@end ifnottex
If asked for five return values, it also computes
@tex
$U$, $V$, $X$, and $C$.
@end tex
@ifnottex
U, V, X, and C.
@end ifnottex
If the optional third input is present, @code{gsvd} constructs the
"economy-sized" decomposition where the number of columns of @var{U}, @var{V}
and the number of rows of @var{C}, @var{S} is less than or equal to the number
of columns of @var{A}. This option is not yet implemented.
Programming Note: the code is a wrapper to the corresponding @sc{lapack} dggsvd
and zggsvd routines. If matrices @var{A} and @var{B} are @emph{both} rank
deficient then @sc{lapack} will return an incorrect factorization. Programmers
should avoid this combination.
@xseealso{@ref{XREFsvd,,svd}}
@end deftypefn
@c planerot scripts/linear-algebra/planerot.m
@anchor{XREFplanerot}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{G}, @var{y}] =} planerot (@var{x})
Compute the Givens rotation matrix for the two-element column vector
@var{x}.
@tex
The Givens matrix is a $2\times 2$ orthogonal matrix
$$
G = \left[\matrix{c & s\cr -s'& c\cr}\right]
$$
such that
$$
G \left[\matrix{x(1)\cr x(2)}\right] = \left[\matrix{\ast\cr 0}\right]
$$
@end tex
@ifnottex
The Givens matrix is a 2-by-2 orthogonal matrix
@example
@group
@var{G} = [ @var{c} , @var{s}
-@var{s}', @var{c}]
@end group
@end example
@noindent
such that
@example
@var{y} = @var{G} * [@var{x}(1); @var{x}(2)] @equiv{} [*; 0]
@end example
@end ifnottex
Note: The Givens matrix represents a counterclockwise rotation of a 2-D
plane and can be used to introduce zeros into a matrix prior to complete
factorization.
@xseealso{@ref{XREFgivens,,givens}, @ref{XREFqr,,qr}}
@end deftypefn
@c inv libinterp/corefcn/inv.cc
@anchor{XREFinv}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{x} =} inv (@var{A})
@deftypefnx {} {[@var{x}, @var{rcond}] =} inv (@var{A})
@deftypefnx {} {[@dots{}] =} inverse (@dots{})
Compute the inverse of the square matrix @var{A}.
Return an estimate of the reciprocal condition number if requested,
otherwise warn of an ill-conditioned matrix if the reciprocal condition
number is small.
In general it is best to avoid calculating the inverse of a matrix directly.
For example, it is both faster and more accurate to solve systems of
equations (@var{A}*@math{x} = @math{b}) with
@code{@var{y} = @var{A} \ @math{b}}, rather than
@code{@var{y} = inv (@var{A}) * @math{b}}.
If called with a sparse matrix, then in general @var{x} will be a full
matrix requiring significantly more storage. Avoid forming the inverse of a
sparse matrix if possible.
Programming Note: @code{inverse} is an alias for @code{inv} and can be used
interchangeably.
@xseealso{@ref{XREFldivide,,ldivide}, @ref{XREFrdivide,,rdivide}, @ref{XREFpinv,,pinv}}
@end deftypefn
@c linsolve scripts/linear-algebra/linsolve.m
@anchor{XREFlinsolve}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{x} =} linsolve (@var{A}, @var{b})
@deftypefnx {} {@var{x} =} linsolve (@var{A}, @var{b}, @var{opts})
@deftypefnx {} {[@var{x}, @var{R}] =} linsolve (@dots{})
Solve the linear system @code{A*x = b}.
With no options, this function is equivalent to the left division operator
@w{(@code{x = A \ b})}@ or the matrix-left-divide function
@w{(@code{x = mldivide (A, b)})}.
Octave ordinarily examines the properties of the matrix @var{A} and chooses
a solver that best matches the matrix. By passing a structure @var{opts}
to @code{linsolve} you can inform Octave directly about the matrix @var{A}.
In this case Octave will skip the matrix examination and proceed directly
to solving the linear system.
@strong{Warning:} If the matrix @var{A} does not have the properties listed
in the @var{opts} structure then the result will not be accurate AND no
warning will be given. When in doubt, let Octave examine the matrix and
choose the appropriate solver as this step takes little time and the result
is cached so that it is only done once per linear system.
Possible @var{opts} fields (set value to true/false):
@table @asis
@item LT
@var{A} is lower triangular
@item UT
@var{A} is upper triangular
@item UHESS
@var{A} is upper Hessenberg (currently makes no difference)
@item SYM
@var{A} is symmetric or complex Hermitian (currently makes no difference)
@item POSDEF
@var{A} is positive definite
@item RECT
@var{A} is general rectangular (currently makes no difference)
@item TRANSA
Solve @code{A'*x = b} if true rather than @code{A*x = b}
@end table
The optional second output @var{R} is the inverse condition number of
@var{A} (zero if matrix is singular).
@xseealso{@ref{XREFmldivide,,mldivide}, @ref{XREFmatrix_type,,matrix_type}, @ref{XREFrcond,,rcond}}
@end deftypefn
@c matrix_type libinterp/corefcn/matrix_type.cc
@anchor{XREFmatrix_type}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{type} =} matrix_type (@var{A})
@deftypefnx {} {@var{type} =} matrix_type (@var{A}, "nocompute")
@deftypefnx {} {@var{A} =} matrix_type (@var{A}, @var{type})
@deftypefnx {} {@var{A} =} matrix_type (@var{A}, "upper", @var{perm})
@deftypefnx {} {@var{A} =} matrix_type (@var{A}, "lower", @var{perm})
@deftypefnx {} {@var{A} =} matrix_type (@var{A}, "banded", @var{nl}, @var{nu})
Identify the matrix type or mark a matrix as a particular type.
This allows more rapid solutions of linear equations involving @var{A} to be
performed.
Called with a single argument, @code{matrix_type} returns the type of the
matrix and caches it for future use.
Called with more than one argument, @code{matrix_type} allows the type of
the matrix to be defined.
If the option @qcode{"nocompute"} is given, the function will not attempt
to guess the type if it is still unknown. This is useful for debugging
purposes.
The possible matrix types depend on whether the matrix is full or sparse,
and can be one of the following
@table @asis
@item @qcode{"unknown"}
Remove any previously cached matrix type, and mark type as unknown.
@item @qcode{"full"}
Mark the matrix as full.
@item @qcode{"positive definite"}
Probable full positive definite matrix.
@item @qcode{"diagonal"}
Diagonal matrix. (Sparse matrices only)
@item @qcode{"permuted diagonal"}
Permuted Diagonal matrix. The permutation does not need to be specifically
indicated, as the structure of the matrix explicitly gives this. (Sparse
matrices only)
@item @qcode{"upper"}
Upper triangular. If the optional third argument @var{perm} is given, the
matrix is assumed to be a permuted upper triangular with the permutations
defined by the vector @var{perm}.
@item @qcode{"lower"}
Lower triangular. If the optional third argument @var{perm} is given, the
matrix is assumed to be a permuted lower triangular with the permutations
defined by the vector @var{perm}.
@item @qcode{"banded"}
@itemx @qcode{"banded positive definite"}
Banded matrix with the band size of @var{nl} below the diagonal and @var{nu}
above it. If @var{nl} and @var{nu} are 1, then the matrix is tridiagonal
and treated with specialized code. In addition the matrix can be marked as
probably a positive definite. (Sparse matrices only)
@item @qcode{"singular"}
The matrix is assumed to be singular and will be treated with a minimum norm
solution.
@end table
Note that the matrix type will be discovered automatically on the first
attempt to solve a linear equation involving @var{A}. Therefore
@code{matrix_type} is only useful to give Octave hints of the matrix type.
Incorrectly defining the matrix type will result in incorrect results from
solutions of linear equations; it is entirely @strong{the responsibility of
the user} to correctly identify the matrix type.
Also, the test for positive definiteness is a low-cost test for a Hermitian
matrix with a real positive diagonal. This does not guarantee that the
matrix is positive definite, but only that it is a probable candidate. When
such a matrix is factorized, a Cholesky@tie{}factorization is first
attempted, and if that fails the matrix is then treated with an
LU@tie{}factorization. Once the matrix has been factorized,
@code{matrix_type} will return the correct classification of the matrix.
@end deftypefn
@c norm libinterp/corefcn/data.cc
@anchor{XREFnorm}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{n} =} norm (@var{A})
@deftypefnx {} {@var{n} =} norm (@var{A}, @var{p})
@deftypefnx {} {@var{n} =} norm (@var{A}, @var{p}, @var{opt})
Compute the p-norm of the matrix @var{A}.
If the second argument is not given, @w{@code{p = 2}}@ is used.
If @var{A} is a matrix (or sparse matrix):
@table @asis
@item @var{p} = @code{1}
1-norm, the largest column sum of the absolute values of @var{A}.
@item @var{p} = @code{2}
Largest singular value of @var{A}.
@item @var{p} = @code{Inf} or @qcode{"inf"}
@cindex infinity norm
Infinity norm, the largest row sum of the absolute values of @var{A}.
@item @var{p} = @qcode{"fro"}
@cindex @nospell{Frobenius} norm
@nospell{Frobenius} norm of @var{A},
@code{sqrt (sum (diag (@var{A}' * @var{A})))}.
@item other @var{p}, @code{@var{p} > 1}
@cindex general p-norm
maximum @code{norm (A*x, p)} such that @code{norm (x, p) == 1}
@end table
If @var{A} is a vector or a scalar:
@table @asis
@item @var{p} = @code{Inf} or @qcode{"inf"}
@code{max (abs (@var{A}))}.
@item @var{p} = @code{-Inf}
@code{min (abs (@var{A}))}.
@item @var{p} = @qcode{"fro"}
@nospell{Frobenius} norm of @var{A}, @code{sqrt (sumsq (abs (A)))}.
@item @var{p} = 0
Hamming norm---the number of nonzero elements.
@item other @var{p}, @code{@var{p} > 1}
p-norm of @var{A}, @code{(sum (abs (@var{A}) .^ @var{p})) ^ (1/@var{p})}.
@item other @var{p} @code{@var{p} < 1}
the p-pseudonorm defined as above.
@end table
If @var{opt} is the value @qcode{"rows"}, treat each row as a vector and
compute its norm. The result is returned as a column vector.
Similarly, if @var{opt} is @qcode{"columns"} or @qcode{"cols"} then
compute the norms of each column and return a row vector.
@xseealso{@ref{XREFnormest,,normest}, @ref{XREFnormest1,,normest1}, @ref{XREFvecnorm,,vecnorm}, @ref{XREFcond,,cond}, @ref{XREFsvd,,svd}}
@end deftypefn
@c null scripts/linear-algebra/null.m
@anchor{XREFnull}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{Z} =} null (@var{A})
@deftypefnx {} {@var{Z} =} null (@var{A}, @var{tol})
Return an orthonormal basis @var{Z} of the null space of @var{A}.
The dimension of the null space @var{Z} is taken as the number of singular
values of @var{A} not greater than @var{tol}. If the argument @var{tol}
is missing, it is computed as
@example
max (size (@var{A})) * max (svd (@var{A}, 0)) * eps
@end example
@xseealso{@ref{XREForth,,orth}, @ref{XREFsvd,,svd}}
@end deftypefn
@c orth scripts/linear-algebra/orth.m
@anchor{XREForth}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{B} =} orth (@var{A})
@deftypefnx {} {@var{B} =} orth (@var{A}, @var{tol})
Return an orthonormal basis of the range space of @var{A}.
The dimension of the range space is taken as the number of singular values
of @var{A} greater than @var{tol}. If the argument @var{tol} is missing, it
is computed as
@example
max (size (@var{A})) * max (svd (@var{A})) * eps
@end example
@xseealso{@ref{XREFnull,,null}}
@end deftypefn
@c mgorth libinterp/corefcn/mgorth.cc
@anchor{XREFmgorth}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{y}, @var{h}] =} mgorth (@var{x}, @var{v})
Orthogonalize a given column vector @var{x} with respect to a set of
orthonormal vectors comprising the columns of @var{v} using the modified
Gram-Schmidt method.
On exit, @var{y} is a unit vector such that:
@example
@group
norm (@var{y}) = 1
@var{v}' * @var{y} = 0
@var{x} = [@var{v}, @var{y}]*@var{h}'
@end group
@end example
@end deftypefn
@c pinv libinterp/corefcn/pinv.cc
@anchor{XREFpinv}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{B} =} pinv (@var{A})
@deftypefnx {} {@var{B} =} pinv (@var{A}, @var{tol})
Return the @nospell{Moore-Penrose} pseudoinverse of @var{A}.
Singular values less than @var{tol} are ignored.
If the second argument is omitted, it is taken to be
@example
tol = max ([rows(@var{x}), columns(@var{x})]) * norm (@var{x}) * eps
@end example
@xseealso{@ref{XREFinv,,inv}, @ref{XREFldivide,,ldivide}}
@end deftypefn
@cindex pseudoinverse
@c rank scripts/linear-algebra/rank.m
@anchor{XREFrank}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{k} =} rank (@var{A})
@deftypefnx {} {@var{k} =} rank (@var{A}, @var{tol})
Compute the rank of matrix @var{A}, using the singular value decomposition.
The rank is taken to be the number of singular values of @var{A} that are
greater than the specified tolerance @var{tol}. If the second argument is
omitted, it is taken to be
@example
tol = max (size (@var{A})) * sigma(1) * eps;
@end example
@noindent
where @code{eps} is machine precision and @code{sigma(1)} is the largest
singular value of @var{A}.
The rank of a matrix is the number of linearly independent rows or columns
and equals the dimension of the row and column space. The function
@code{orth} may be used to compute an orthonormal basis of the column space.
For testing if a system @code{@var{A}*@var{x} = @var{b}} of linear equations
is solvable, one can use
@example
rank (@var{A}) == rank ([@var{A} @var{b}])
@end example
In this case, @code{@var{x} = @var{A} \ @var{b}} finds a particular solution
@var{x}. The general solution is @var{x} plus the null space of matrix
@var{A}. The function @code{null} may be used to compute a basis of the
null space.
Example:
@example
@group
A = [1 2 3
4 5 6
7 8 9];
rank (A)
@result{} 2
@end group
@end example
@noindent
In this example, the number of linearly independent rows is only 2 because
the final row is a linear combination of the first two rows:
@example
A(3,:) == -A(1,:) + 2 * A(2,:)
@end example
@xseealso{@ref{XREFnull,,null}, @ref{XREForth,,orth}, @ref{XREFsprank,,sprank}, @ref{XREFsvd,,svd}, @ref{XREFeps,,eps}}
@end deftypefn
@c rcond libinterp/corefcn/rcond.cc
@anchor{XREFrcond}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{c} =} rcond (@var{A})
Compute the 1-norm estimate of the reciprocal condition number as returned
by @sc{lapack}.
If the matrix is well-conditioned then @var{c} will be near 1 and if the
matrix is poorly conditioned it will be close to 0.
The matrix @var{A} must not be sparse. If the matrix is sparse then
@code{condest (@var{A})} or @code{rcond (full (@var{A}))} should be used
instead.
@xseealso{@ref{XREFcond,,cond}, @ref{XREFcondest,,condest}}
@end deftypefn
@c trace scripts/linear-algebra/trace.m
@anchor{XREFtrace}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{t} =} trace (@var{A})
Compute the trace of @var{A}, the sum of the elements along the main
diagonal.
The implementation is straightforward: @code{sum (diag (@var{A}))}.
@xseealso{@ref{XREFeig,,eig}}
@end deftypefn
@c rref scripts/linear-algebra/rref.m
@anchor{XREFrref}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{r} =} rref (@var{A})
@deftypefnx {} {@var{r} =} rref (@var{A}, @var{tol})
@deftypefnx {} {[@var{r}, @var{k}] =} rref (@dots{})
Return the reduced row echelon form of @var{A}.
@var{tol} defaults to
@code{eps * max (size (@var{A})) * norm (@var{A}, inf)}.
The optional return argument @var{k} contains the vector of
"bound variables", which are those columns on which elimination has been
performed.
@end deftypefn
@c vecnorm scripts/linear-algebra/vecnorm.m
@anchor{XREFvecnorm}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{n} =} vecnorm (@var{A})
@deftypefnx {} {@var{n} =} vecnorm (@var{A}, @var{p})
@deftypefnx {} {@var{n} =} vecnorm (@var{A}, @var{p}, @var{dim})
Return the vector p-norm of the elements of array @var{A} along dimension
@var{dim}.
The p-norm of a vector is defined as
@tex
$$ {\Vert A \Vert}_p = \left[ \sum_{i=1}^N {| A_i |}^p \right] ^ {1/p} $$
@end tex
@ifnottex
@example
@var{p-norm} (@var{A}, @var{p}) = (sum (abs (@var{A}) .^ @var{p})) ^ (1/@var{p})
@end example
@end ifnottex
The input @var{p} must be a positive scalar. If omitted it defaults to 2
(Euclidean norm or distance). Other special values of @var{p} are 1
(Manhattan norm, sum of absolute values) and @code{Inf} (absolute value of
largest element).
The input @var{dim} specifies the dimension of the array on which the
function operates and must be a positive integer. If omitted the first
non-singleton dimension is used.
@xseealso{@ref{XREFnorm,,norm}}
@end deftypefn
@node Matrix Factorizations
@section Matrix Factorizations
@cindex matrix factorizations
@c chol libinterp/corefcn/chol.cc
@anchor{XREFchol}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{R} =} chol (@var{A})
@deftypefnx {} {[@var{R}, @var{p}] =} chol (@var{A})
@deftypefnx {} {[@var{R}, @var{p}, @var{Q}] =} chol (@var{A})
@deftypefnx {} {[@var{R}, @var{p}, @var{Q}] =} chol (@var{A}, "vector")
@deftypefnx {} {[@var{L}, @dots{}] =} chol (@dots{}, "lower")
@deftypefnx {} {[@var{R}, @dots{}] =} chol (@dots{}, "upper")
@cindex Cholesky factorization
Compute the upper Cholesky@tie{}factor, @var{R}, of the real symmetric
or complex Hermitian positive definite matrix @var{A}.
The upper Cholesky@tie{}factor @var{R} is computed by using the upper
triangular part of matrix @var{A} and is defined by
@tex
$ R^T R = A $.
@end tex
@ifnottex
@example
@var{R}' * @var{R} = @var{A}.
@end example
@end ifnottex
Calling @code{chol} using the optional @qcode{"upper"} flag has the
same behavior. In contrast, using the optional @qcode{"lower"} flag,
@code{chol} returns the lower triangular factorization, computed by using
the lower triangular part of matrix @var{A}, such that
@tex
$ L L^T = A $.
@end tex
@ifnottex
@example
@var{L} * @var{L}' = @var{A}.
@end example
@end ifnottex
Called with one output argument @code{chol} fails if matrix @var{A} is
not positive definite. Note that if matrix @var{A} is not real symmetric
or complex Hermitian then the lower triangular part is considered to be
the (complex conjugate) transpose of the upper triangular part, or vice
versa, given the @qcode{"lower"} flag.
Called with two or more output arguments @var{p} flags whether the matrix
@var{A} was positive definite and @code{chol} does not fail. A zero value
of @var{p} indicates that matrix @var{A} is positive definite and @var{R}
gives the factorization. Otherwise, @var{p} will have a positive value.
If called with three output arguments matrix @var{A} must be sparse and
a sparsity preserving row/column permutation is applied to matrix @var{A}
prior to the factorization. That is @var{R} is the factorization of
@code{@var{A}(@var{Q},@var{Q})} such that
@tex
$ R^T R = Q^T A Q$.
@end tex
@ifnottex
@example
@var{R}' * @var{R} = @var{Q}' * @var{A} * @var{Q}.
@end example
@end ifnottex
The sparsity preserving permutation is generally returned as a matrix.
However, given the optional flag @qcode{"vector"}, @var{Q} will be
returned as a vector such that
@tex
$ R^T R = A (Q, Q)$.
@end tex
@ifnottex
@example
@var{R}' * @var{R} = @var{A}(@var{Q}, @var{Q}).
@end example
@end ifnottex
In general the lower triangular factorization is significantly faster for
sparse matrices.
@xseealso{@ref{XREFhess,,hess}, @ref{XREFlu,,lu}, @ref{XREFqr,,qr}, @ref{XREFqz,,qz}, @ref{XREFschur,,schur}, @ref{XREFsvd,,svd}, @ref{XREFichol,,ichol}, @ref{XREFcholinv,,cholinv}, @ref{XREFchol2inv,,chol2inv}, @ref{XREFcholupdate,,cholupdate}, @ref{XREFcholinsert,,cholinsert}, @ref{XREFcholdelete,,choldelete}, @ref{XREFcholshift,,cholshift}}
@end deftypefn
@c cholinv libinterp/corefcn/chol.cc
@anchor{XREFcholinv}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{Ainv} =} cholinv (@var{A})
Compute the inverse of the symmetric positive definite matrix @var{A} using
the Cholesky@tie{}factorization.
@xseealso{@ref{XREFchol,,chol}, @ref{XREFchol2inv,,chol2inv}, @ref{XREFinv,,inv}}
@end deftypefn
@c chol2inv libinterp/corefcn/chol.cc
@anchor{XREFchol2inv}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{Ainv} =} chol2inv (@var{R})
Invert a symmetric, positive definite square matrix from its Cholesky
decomposition, @var{R}.
Note that @var{R} should be an upper-triangular matrix with positive diagonal
elements. @code{chol2inv (@var{U})} provides @code{inv (@var{R}'*@var{R})} but
is much faster than using @code{inv}.
@xseealso{@ref{XREFchol,,chol}, @ref{XREFcholinv,,cholinv}, @ref{XREFinv,,inv}}
@end deftypefn
@c cholupdate libinterp/corefcn/chol.cc
@anchor{XREFcholupdate}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{R1}, @var{info}] =} cholupdate (@var{R}, @var{u}, @var{op})
Update or downdate a Cholesky@tie{}factorization.
Given an upper triangular matrix @var{R} and a column vector @var{u},
attempt to determine another upper triangular matrix @var{R1} such that
@itemize @bullet
@item
@var{R1}'*@var{R1} = @var{R}'*@var{R} + @var{u}*@var{u}'
if @var{op} is @qcode{"+"}
@item
@var{R1}'*@var{R1} = @var{R}'*@var{R} - @var{u}*@var{u}'
if @var{op} is @qcode{"-"}
@end itemize
If @var{op} is @qcode{"-"}, @var{info} is set to
@itemize
@item 0 if the downdate was successful,
@item 1 if @var{R}'*@var{R} - @var{u}*@var{u}' is not positive definite,
@item 2 if @var{R} is singular.
@end itemize
If @var{info} is not present, an error message is printed in cases 1 and 2.
@xseealso{@ref{XREFchol,,chol}, @ref{XREFcholinsert,,cholinsert}, @ref{XREFcholdelete,,choldelete}, @ref{XREFcholshift,,cholshift}}
@end deftypefn
@c cholinsert libinterp/corefcn/chol.cc
@anchor{XREFcholinsert}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{R1} =} cholinsert (@var{R}, @var{j}, @var{u})
@deftypefnx {} {[@var{R1}, @var{info}] =} cholinsert (@var{R}, @var{j}, @var{u})
Update a Cholesky factorization given a row or column to insert in the
original factored matrix.
Given a Cholesky@tie{}factorization of a real symmetric or complex Hermitian
positive definite matrix @w{@var{A} = @var{R}'*@var{R}}, @var{R}@tie{}upper
triangular, return the Cholesky@tie{}factorization of
@var{A1}, where @w{A1(p,p) = A}, @w{A1(:,j) = A1(j,:)' = u}@ and
@w{p = [1:j-1,j+1:n+1]}. @w{u(j)}@ should be positive.
On return, @var{info} is set to
@itemize
@item 0 if the insertion was successful,
@item 1 if @var{A1} is not positive definite,
@item 2 if @var{R} is singular.
@end itemize
If @var{info} is not present, an error message is printed in cases 1 and 2.
@xseealso{@ref{XREFchol,,chol}, @ref{XREFcholupdate,,cholupdate}, @ref{XREFcholdelete,,choldelete}, @ref{XREFcholshift,,cholshift}}
@end deftypefn
@c choldelete libinterp/corefcn/chol.cc
@anchor{XREFcholdelete}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{R1} =} choldelete (@var{R}, @var{j})
Update a Cholesky factorization given a row or column to delete from the
original factored matrix.
Given a Cholesky@tie{}factorization of a real symmetric or complex Hermitian
positive definite matrix @w{@var{A} = @var{R}'*@var{R}}, @var{R}@tie{}upper
triangular, return the Cholesky@tie{}factorization of @w{A(p,p)}, where
@w{p = [1:j-1,j+1:n+1]}.
@xseealso{@ref{XREFchol,,chol}, @ref{XREFcholupdate,,cholupdate}, @ref{XREFcholinsert,,cholinsert}, @ref{XREFcholshift,,cholshift}}
@end deftypefn
@c cholshift libinterp/corefcn/chol.cc
@anchor{XREFcholshift}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{R1} =} cholshift (@var{R}, @var{i}, @var{j})
Update a Cholesky factorization given a range of columns to shift in the
original factored matrix.
Given a Cholesky@tie{}factorization of a real symmetric or complex Hermitian
positive definite matrix @w{@var{A} = @var{R}'*@var{R}}, @var{R}@tie{}upper
triangular, return the Cholesky@tie{}factorization of
@w{@var{A}(p,p)}, where p is the permutation @*
@code{p = [1:i-1, circshift(i:j, 1), j+1:n]} if @w{@var{i} < @var{j}} @*
or @*
@code{p = [1:j-1, circshift(j:i,-1), i+1:n]} if @w{@var{j} < @var{i}}. @*
@xseealso{@ref{XREFchol,,chol}, @ref{XREFcholupdate,,cholupdate}, @ref{XREFcholinsert,,cholinsert}, @ref{XREFcholdelete,,choldelete}}
@end deftypefn
@c hess libinterp/corefcn/hess.cc
@anchor{XREFhess}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{H} =} hess (@var{A})
@deftypefnx {} {[@var{P}, @var{H}] =} hess (@var{A})
@cindex Hessenberg decomposition
Compute the Hessenberg decomposition of the matrix @var{A}.
The Hessenberg decomposition is
@tex
$$
A = PHP^T
$$
where $P$ is a square unitary matrix ($P^TP = I$), and $H$
is upper Hessenberg ($H_{i,j} = 0, \forall i > j+1$).
@end tex
@ifnottex
@code{@var{P} * @var{H} * @var{P}' = @var{A}} where @var{P} is a square
unitary matrix (@code{@var{P}' * @var{P} = I}, using complex-conjugate
transposition) and @var{H} is upper Hessenberg
(@code{@var{H}(i, j) = 0 forall i > j+1)}.
@end ifnottex
The Hessenberg decomposition is usually used as the first step in an
eigenvalue computation, but has other applications as well
(see @nospell{Golub, Nash, and Van Loan},
IEEE Transactions on Automatic Control, 1979).
@xseealso{@ref{XREFeig,,eig}, @ref{XREFchol,,chol}, @ref{XREFlu,,lu}, @ref{XREFqr,,qr}, @ref{XREFqz,,qz}, @ref{XREFschur,,schur}, @ref{XREFsvd,,svd}}
@end deftypefn
@c lu libinterp/corefcn/lu.cc
@anchor{XREFlu}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{L}, @var{U}] =} lu (@var{A})
@deftypefnx {} {[@var{L}, @var{U}, @var{P}] =} lu (@var{A})
@deftypefnx {} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} lu (@var{S})
@deftypefnx {} {[@var{L}, @var{U}, @var{P}, @var{Q}, @var{R}] =} lu (@var{S})
@deftypefnx {} {[@dots{}] =} lu (@var{S}, @var{thresh})
@deftypefnx {} {@var{y} =} lu (@dots{})
@deftypefnx {} {[@dots{}] =} lu (@dots{}, "vector")
@cindex LU decomposition
Compute the LU@tie{}decomposition of @var{A}.
If @var{A} is full then subroutines from @sc{lapack} are used, and if
@var{A} is sparse then @sc{umfpack} is used.
The result is returned in a permuted form, according to the optional return
value @var{P}. For example, given the matrix @code{@var{A} = [1, 2; 3, 4]},
@example
[@var{L}, @var{U}, @var{P}] = lu (@var{A})
@end example
@noindent
returns
@example
@group
L =
1.00000 0.00000
0.33333 1.00000
U =
3.00000 4.00000
0.00000 0.66667
P =
0 1
1 0
@end group
@end example
The matrix is not required to be square.
When called with two or three output arguments and a sparse input matrix,
@code{lu} does not attempt to perform sparsity preserving column permutations.
Called with a fourth output argument, the sparsity preserving column
transformation @var{Q} is returned, such that
@code{@var{P} * @var{A} * @var{Q} = @var{L} * @var{U}}. This is the
@strong{preferred} way to call @code{lu} with sparse input matrices.
Called with a fifth output argument and a sparse input matrix, @code{lu}
attempts to use a scaling factor @var{R} on the input matrix such that
@code{@var{P} * (@var{R} \ @var{A}) * @var{Q} = @var{L} * @var{U}}.
This typically leads to a sparser and more stable factorization.
An additional input argument @var{thresh} that defines the pivoting
threshold can be given. @var{thresh} can be a scalar, in which case
it defines the @sc{umfpack} pivoting tolerance for both symmetric and
unsymmetric cases. If @var{thresh} is a 2-element vector, then the first
element defines the pivoting tolerance for the unsymmetric @sc{umfpack}
pivoting strategy and the second for the symmetric strategy. By default,
the values defined by @code{spparms} are used ([0.1, 0.001]).
Given the string argument @qcode{"vector"}, @code{lu} returns the values
of @var{P} and @var{Q} as vector values, such that for full matrix,
@code{@var{A}(@var{P},:) = @var{L} * @var{U}}, and @code{@var{R}(@var{P},:)
* @var{A}(:,@var{Q}) = @var{L} * @var{U}}.
With two output arguments, returns the permuted forms of the upper and
lower triangular matrices, such that @code{@var{A} = @var{L} * @var{U}}.
With one output argument @var{y}, then the matrix returned by the
@sc{lapack} routines is returned. If the input matrix is sparse then the
matrix @var{L} is embedded into @var{U} to give a return value similar to
the full case. For both full and sparse matrices, @code{lu} loses the
permutation information.
@xseealso{@ref{XREFluupdate,,luupdate}, @ref{XREFilu,,ilu}, @ref{XREFchol,,chol}, @ref{XREFhess,,hess}, @ref{XREFqr,,qr}, @ref{XREFqz,,qz}, @ref{XREFschur,,schur}, @ref{XREFsvd,,svd}}
@end deftypefn
@c luupdate libinterp/corefcn/lu.cc
@anchor{XREFluupdate}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{L}, @var{U}] =} luupdate (@var{L}, @var{U}, @var{x}, @var{y})
@deftypefnx {} {[@var{L}, @var{U}, @var{P}] =} luupdate (@var{L}, @var{U}, @var{P}, @var{x}, @var{y})
Given an LU@tie{}factorization of a real or complex matrix
@w{@var{A} = @var{L}*@var{U}}, @var{L}@tie{}lower unit trapezoidal and
@var{U}@tie{}upper trapezoidal, return the LU@tie{}factorization
of @w{@var{A} + @var{x}*@var{y}.'}, where @var{x} and @var{y} are
column vectors (rank-1 update) or matrices with equal number of columns
(rank-k update).
Optionally, row-pivoted updating can be used by supplying a row permutation
(pivoting) matrix @var{P}; in that case, an updated permutation matrix is
returned. Note that if @var{L}, @var{U}, @var{P} is a pivoted
LU@tie{}factorization as obtained by @code{lu}:
@example
[@var{L}, @var{U}, @var{P}] = lu (@var{A});
@end example
@noindent
then a factorization of @tcode{@var{A}+@var{x}*@var{y}.'} can be obtained
either as
@example
[@var{L1}, @var{U1}] = lu (@var{L}, @var{U}, @var{P}*@var{x}, @var{y})
@end example
@noindent
or
@example
[@var{L1}, @var{U1}, @var{P1}] = lu (@var{L}, @var{U}, @var{P}, @var{x}, @var{y})
@end example
The first form uses the unpivoted algorithm, which is faster, but less
stable. The second form uses a slower pivoted algorithm, which is more
stable.
The matrix case is done as a sequence of rank-1 updates; thus, for large
enough k, it will be both faster and more accurate to recompute the
factorization from scratch.
@xseealso{@ref{XREFlu,,lu}, @ref{XREFcholupdate,,cholupdate}, @ref{XREFqrupdate,,qrupdate}}
@end deftypefn
@c qr libinterp/corefcn/qr.cc
@anchor{XREFqr}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{Q}, @var{R}] =} qr (@var{A})
@deftypefnx {} {[@var{Q}, @var{R}, @var{P}] =} qr (@var{A})
@deftypefnx {} {@var{X} =} qr (@var{A}) # non-sparse A
@deftypefnx {} {@var{R} =} qr (@var{A}) # sparse A
@deftypefnx {} {@var{X} =} qr (@var{A}, @var{B}) # sparse A
@deftypefnx {} {[@var{C}, @var{R}] =} qr (@var{A}, @var{B})
@deftypefnx {} {[@dots{}] =} qr (@dots{}, "econ")
@deftypefnx {} {[@dots{}] =} qr (@dots{}, "vector")
@deftypefnx {} {[@dots{}] =} qr (@dots{}, "matrix")
@deftypefnx {} {[@dots{}] =} qr (@dots{}, 0)
@cindex QR factorization
Compute the QR@tie{}factorization of @var{A}, using standard @sc{lapack}
subroutines.
The QR@tie{}factorization is
@tex
$QR = A$ where $Q$ is an orthogonal matrix and $R$ is upper triangular.
@end tex
@ifnottex
@example
@var{Q} * @var{R} = @var{A}
@end example
@noindent
where @var{Q} is an orthogonal matrix and @var{R} is upper triangular.
@end ifnottex
For example, given the matrix @code{@var{A} = [1, 2; 3, 4]},
@example
[@var{Q}, @var{R}] = qr (@var{A})
@end example
@noindent
returns
@example
@group
@var{Q} =
-0.31623 -0.94868
-0.94868 0.31623
@var{R} =
-3.16228 -4.42719
0.00000 -0.63246
@end group
@end example
@noindent
which multiplied together return the original matrix
@example
@group
@var{Q} * @var{R}
@result{}
1.0000 2.0000
3.0000 4.0000
@end group
@end example
If just a single return value is requested then it is either @var{R}, if
@var{A} is sparse, or @var{X}, such that @code{@var{R} = triu (@var{X})} if
@var{A} is full. (Note: unlike most commands, the single return value is not
the first return value when multiple values are requested.)
If a third output @var{P} is requested, then @code{qr} calculates the permuted
QR@tie{}factorization
@tex
$QR = AP$ where $Q$ is an orthogonal matrix, $R$ is upper triangular, and $P$
is a permutation matrix.
@end tex
@ifnottex
@example
@var{Q} * @var{R} = @var{A} * @var{P}
@end example
@noindent
where @var{Q} is an orthogonal matrix, @var{R} is upper triangular, and
@var{P} is a permutation matrix.
@end ifnottex
If @var{A} is dense, the permuted QR@tie{}factorization has the additional
property that the diagonal entries of @var{R} are ordered by decreasing
magnitude. In other words, @code{abs (diag (@var{R}))} will be ordered
from largest to smallest.
If @var{A} is sparse, @var{P} is a fill-reducing ordering of the columns
of @var{A}. In that case, the diagonal entries of @var{R} are not ordered by
decreasing magnitude.
For example, given the matrix @code{@var{A} = [1, 2; 3, 4]},
@example
[@var{Q}, @var{R}, @var{P}] = qr (@var{A})
@end example
@noindent
returns
@example
@group
@var{Q} =
-0.44721 -0.89443
-0.89443 0.44721
@var{R} =
-4.47214 -3.13050
0.00000 0.44721
@var{P} =
0 1
1 0
@end group
@end example
If the input matrix @var{A} is sparse, the sparse QR@tie{}factorization
is computed by using @sc{SPQR} or @sc{cxsparse} (e.g., if @sc{SPQR} is not
available). Because the matrix @var{Q} is, in general, a full matrix, it is
recommended to request only one return value @var{R}. In that case, the
computation avoids the construction of @var{Q} and returns a sparse @var{R}
such that @code{@var{R} = chol (@var{A}' * @var{A})}.
If @var{A} is dense, an additional input matrix @var{B} is supplied, and two
return values are requested, then @code{qr} returns @var{C}, where
@code{@var{C} = @var{Q}' * @var{B}}. This allows the least squares
approximation of @code{@var{A} \ @var{B}} to be calculated as
@example
@group
[@var{C}, @var{R}] = qr (@var{A}, @var{B})
@var{X} = @var{R} \ @var{C}
@end group
@end example
If @var{A} is a sparse @nospell{MxN} matrix and an additional matrix @var{B} is
supplied, one or two return values are possible. If one return value @var{X}
is requested and M < N, then @var{X} is the minimum 2-norm solution of
@w{@code{@var{A} \ @var{B}}}. If M >= N, @var{X} is the least squares
approximation @w{of @code{@var{A} \ @var{B}}}. If two return values are
requested, @var{C} and @var{R} have the same meaning as in the dense case
(@var{C} is dense and @var{R} is sparse). The version with one return
parameter should be preferred because it uses less memory and can handle
rank-deficient matrices better.
If the final argument is the string @qcode{"vector"} then @var{P} is a
permutation vector (of the columns of @var{A}) instead of a permutation
matrix. In this case, the defining relationship is:
@example
@var{Q} * @var{R} = @var{A}(:, @var{P})
@end example
The default, however, is to return a permutation matrix and this may be
explicitly specified by using a final argument of @qcode{"matrix"}.
When the optional argument is the string @qcode{"econ"}, an economy
factorization is returned. If the original matrix @var{A} has size
@nospell{MxN} and M > N, then the economy factorization will calculate just N
rows in @var{R} and N columns in @var{Q} and omit the zeros in @var{R}. If M
@leq{} N, there is no difference between the economy and standard
factorizations.
If the optional argument is the numeric value 0 then @code{qr} acts as if
the @qcode{"econ"} and @qcode{"vector"} arguments were both given.
@strong{Warning:} This syntax is accepted, but no longer recommended and may
be removed in the future. Use @qcode{"econ"} instead.
Background: The QR factorization has applications in the solution of least
squares problems
@tex
$$
\min_x \left\Vert A x - b \right\Vert_2
$$
@end tex
@ifnottex
@example
min norm (A*x - b)
@end example
@end ifnottex
for overdetermined systems of equations (i.e.,
@tex
$A$
@end tex
@ifnottex
@var{A}
@end ifnottex
is a tall, thin matrix).
The permuted QR@tie{}factorization
@code{[@var{Q}, @var{R}, @var{P}] = qr (@var{A})} allows the construction of an
orthogonal basis of @code{span (A)}.
@xseealso{@ref{XREFchol,,chol}, @ref{XREFhess,,hess}, @ref{XREFlu,,lu}, @ref{XREFqz,,qz}, @ref{XREFschur,,schur}, @ref{XREFsvd,,svd}, @ref{XREFqrupdate,,qrupdate}, @ref{XREFqrinsert,,qrinsert}, @ref{XREFqrdelete,,qrdelete}, @ref{XREFqrshift,,qrshift}}
@end deftypefn
@c qrupdate libinterp/corefcn/qr.cc
@anchor{XREFqrupdate}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{Q1}, @var{R1}] =} qrupdate (@var{Q}, @var{R}, @var{u}, @var{v})
Update a QR factorization given update vectors or matrices.
Given a QR@tie{}factorization of a real or complex matrix
@w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and
@var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of
@w{@var{A} + @var{u}*@var{v}'}, where @var{u} and @var{v} are column vectors
(rank-1 update) or matrices with equal number of columns
(rank-k update). Notice that the latter case is done as a sequence of
rank-1 updates; thus, for k large enough, it will be both faster and more
accurate to recompute the factorization from scratch.
The QR@tie{}factorization supplied may be either full (Q is square) or
economized (R is square).
@xseealso{@ref{XREFqr,,qr}, @ref{XREFqrinsert,,qrinsert}, @ref{XREFqrdelete,,qrdelete}, @ref{XREFqrshift,,qrshift}}
@end deftypefn
@c qrinsert libinterp/corefcn/qr.cc
@anchor{XREFqrinsert}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{Q1}, @var{R1}] =} qrinsert (@var{Q}, @var{R}, @var{j}, @var{x}, @var{orient})
Update a QR factorization given a row or column to insert in the original
factored matrix.
Given a QR@tie{}factorization of a real or complex matrix
@w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and
@var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of
@w{[A(:,1:j-1) x A(:,j:n)]}, where @var{u} is a column vector to be inserted
into @var{A} (if @var{orient} is @qcode{"col"}), or the
QR@tie{}factorization of @w{[A(1:j-1,:);x;A(:,j:n)]}, where @var{x} is a row
vector to be inserted into @var{A} (if @var{orient} is @qcode{"row"}).
The default value of @var{orient} is @qcode{"col"}. If @var{orient} is
@qcode{"col"}, @var{u} may be a matrix and @var{j} an index vector
resulting in the QR@tie{}factorization of a matrix @var{B} such that
@w{B(:,@var{j})}@ gives @var{u} and @w{B(:,@var{j}) = []}@ gives @var{A}.
Notice that the latter case is done as a sequence of k insertions;
thus, for k large enough, it will be both faster and more accurate to
recompute the factorization from scratch.
If @var{orient} is @qcode{"col"}, the QR@tie{}factorization supplied may
be either full (Q is square) or economized (R is square).
If @var{orient} is @qcode{"row"}, full factorization is needed.
@xseealso{@ref{XREFqr,,qr}, @ref{XREFqrupdate,,qrupdate}, @ref{XREFqrdelete,,qrdelete}, @ref{XREFqrshift,,qrshift}}
@end deftypefn
@c qrdelete libinterp/corefcn/qr.cc
@anchor{XREFqrdelete}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{Q1}, @var{R1}] =} qrdelete (@var{Q}, @var{R}, @var{j}, @var{orient})
Update a QR factorization given a row or column to delete from the original
factored matrix.
Given a QR@tie{}factorization of a real or complex matrix
@w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and
@var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of
@w{[A(:,1:j-1), U, A(:,j:n)]},
where @var{u} is a column vector to be inserted into @var{A}
(if @var{orient} is @qcode{"col"}),
or the QR@tie{}factorization of @w{[A(1:j-1,:);X;A(:,j:n)]},
where @var{x} is a row @var{orient} is @qcode{"row"}).
The default value of @var{orient} is @qcode{"col"}.
If @var{orient} is @qcode{"col"}, @var{j} may be an index vector
resulting in the QR@tie{}factorization of a matrix @var{B} such that
@w{A(:,@var{j}) = []}@ gives @var{B}. Notice that the latter case is done as
a sequence of k deletions; thus, for k large enough, it will be both faster
and more accurate to recompute the factorization from scratch.
If @var{orient} is @qcode{"col"}, the QR@tie{}factorization supplied may
be either full (Q is square) or economized (R is square).
If @var{orient} is @qcode{"row"}, full factorization is needed.
@xseealso{@ref{XREFqr,,qr}, @ref{XREFqrupdate,,qrupdate}, @ref{XREFqrinsert,,qrinsert}, @ref{XREFqrshift,,qrshift}}
@end deftypefn
@c qrshift libinterp/corefcn/qr.cc
@anchor{XREFqrshift}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{Q1}, @var{R1}] =} qrshift (@var{Q}, @var{R}, @var{i}, @var{j})
Update a QR factorization given a range of columns to shift in the original
factored matrix.
Given a QR@tie{}factorization of a real or complex matrix
@w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and
@var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization
of @w{@var{A}(:,p)}, where @w{p} is the permutation @*
@code{p = [1:i-1, circshift(i:j, 1), j+1:n]} if @w{@var{i} < @var{j}} @*
or @*
@code{p = [1:j-1, circshift(j:i,-1), i+1:n]} if @w{@var{j} < @var{i}}. @*
@xseealso{@ref{XREFqr,,qr}, @ref{XREFqrupdate,,qrupdate}, @ref{XREFqrinsert,,qrinsert}, @ref{XREFqrdelete,,qrdelete}}
@end deftypefn
@c qz libinterp/corefcn/qz.cc
@anchor{XREFqz}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{AA}, @var{BB}, @var{Q}, @var{Z}, @var{V}, @var{W}] =} qz (@var{A}, @var{B})
@deftypefnx {} {[@var{AA}, @var{BB}, @var{Q}, @var{Z}, @var{V}, @var{W}] =} qz (@var{A}, @var{B}, @var{opt})
Compute the QZ@tie{}decomposition of a generalized eigenvalue problem.
The generalized eigenvalue problem is defined as
@tex
$$A x = \lambda B x$$
@end tex
@ifnottex
@math{A x = @var{lambda} B x}
@end ifnottex
There are two calling forms of the function:
@enumerate
@item @code{[@var{AA}, @var{BB}, @var{Q}, @var{Z}, @var{V}, @var{W}] = qz (@var{A}, @var{B})}
Compute the complex QZ@tie{}decomposition, generalized eigenvectors, and
generalized eigenvalues.
@tex
$$ AA = Q \cdot A \cdot Z, BB = Q \cdot B \cdot Z $$
$$ A \cdot V \cdot {\rm diag}(BB) = B \cdot V \cdot {\rm diag}(AA) $$
$$ {\rm diag}(BB) \cdot W^T \cdot A = {\rm diag}(AA) \cdot W^T \cdot B $$
@end tex
@ifnottex
@example
@group
@var{AA} = @var{Q} * @var{A} * @var{Z}, @var{BB} = @var{Q} * @var{B} * @var{Z}
@var{A} * @var{V} * diag (diag (@var{BB})) = @var{B} * @var{V} * diag (diag (@var{AA}))
diag (diag (@var{BB})) * @var{W}' * @var{A} = diag (diag (@var{AA})) * @var{W}' * @var{B}
@end group
@end example
@end ifnottex
with @var{AA} and @var{BB} upper triangular, and @var{Q} and @var{Z}
unitary. The matrices @var{V} and @var{W} respectively contain the right
and left generalized eigenvectors.
@item @code{[@var{AA}, @var{BB}, @var{Q}, @var{Z}, @var{V}, @var{W}] = qz (@var{A}, @var{B}, @var{opt})}
The @var{opt} argument must be equal to either @qcode{"real"} or
@qcode{"complex"}. If it is equal to @qcode{"complex"}, then this
calling form is equivalent to the first one with only two input
arguments.
If @var{opt} is equal to @qcode{"real"}, then the real QZ decomposition
is computed. In particular, @var{AA} is only guaranteed to be
quasi-upper triangular with 1-by-1 and 2-by-2 blocks on the diagonal,
and @var{Q} and @var{Z} are orthogonal. The identities mentioned above
for right and left generalized eigenvectors are only verified if
@var{AA} is upper triangular (i.e., when all the generalized eigenvalues
are real, in which case the real and complex QZ coincide).
@end enumerate
Note: @code{qz} performs permutation balancing, but not scaling
(@pxref{XREFbalance,,@code{balance}}), which may lead to less accurate
results than @code{eig}. The order of output arguments was selected for
compatibility with @sc{matlab}.
For eigenvalues, use the @code{ordeig} function to compute them based on
the resulting @var{AA} and @var{BB} matrices.
@xseealso{@ref{XREFeig,,eig}, @ref{XREFgsvd,,gsvd}, @ref{XREFbalance,,balance}, @ref{XREFchol,,chol}, @ref{XREFhess,,hess}, @ref{XREFlu,,lu}, @ref{XREFqr,,qr}, @ref{XREFqzhess,,qzhess}, @ref{XREFschur,,schur}, @ref{XREFordeig,,ordeig}}
@end deftypefn
@c qzhess scripts/linear-algebra/qzhess.m
@anchor{XREFqzhess}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{aa}, @var{bb}, @var{q}, @var{z}] =} qzhess (@var{A}, @var{B})
Compute the Hessenberg-triangular decomposition of the matrix pencil
@code{(@var{A}, @var{B})}, returning
@code{@var{aa} = @var{q} * @var{A} * @var{z}},
@code{@var{bb} = @var{q} * @var{B} * @var{z}}, with @var{q} and @var{z}
orthogonal.
For example:
@example
@group
[aa, bb, q, z] = qzhess ([1, 2; 3, 4], [5, 6; 7, 8])
@result{} aa =
-3.02244 -4.41741
0.92998 0.69749
@result{} bb =
-8.60233 -9.99730
0.00000 -0.23250
@result{} q =
-0.58124 -0.81373
-0.81373 0.58124
@result{} z =
Diagonal Matrix
1 0
0 1
@end group
@end example
The Hessenberg-triangular decomposition is the first step in
@nospell{Moler and Stewart's} QZ@tie{}decomposition algorithm.
Algorithm taken from @nospell{Golub and Van Loan},
@cite{Matrix Computations, 2nd edition}.
@xseealso{@ref{XREFlu,,lu}, @ref{XREFchol,,chol}, @ref{XREFhess,,hess}, @ref{XREFqr,,qr}, @ref{XREFqz,,qz}, @ref{XREFschur,,schur}, @ref{XREFsvd,,svd}}
@end deftypefn
@c schur libinterp/corefcn/schur.cc
@anchor{XREFschur}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{S} =} schur (@var{A})
@deftypefnx {} {@var{S} =} schur (@var{A}, "real")
@deftypefnx {} {@var{S} =} schur (@var{A}, "complex")
@deftypefnx {} {@var{S} =} schur (@var{A}, @var{opt})
@deftypefnx {} {[@var{U}, @var{S}] =} schur (@dots{})
@cindex Schur decomposition
Compute the Schur@tie{}decomposition of @var{A}.
The Schur@tie{}decomposition of a square matrix @var{A} is defined as
@tex
$$
S = U^T A U
$$
@end tex
@ifnottex
@example
@code{@var{S} = @var{U}' * @var{A} * @var{U}}
@end example
@end ifnottex
where @var{U} is a unitary matrix
@tex
($U^T U$ is identity)
@end tex
@ifnottex
(@code{@var{U}'* @var{U}} is identity)
@end ifnottex
and @var{S} is upper triangular. The eigenvalues of @var{A} (and @var{S})
are the diagonal elements of @var{S}. If the matrix @var{A} is real, then
the real Schur@tie{}decomposition is computed, in which the matrix @var{U}
is orthogonal and @var{S} is block upper triangular with blocks of size at
most
@tex
$2 \times 2$
@end tex
@ifnottex
@code{2 x 2}
@end ifnottex
along the diagonal.
The default for real matrices is a real Schur@tie{}decomposition. A complex
decomposition may be forced by passing the flag @qcode{"complex"}.
The eigenvalues are optionally ordered along the diagonal according to the
value of @var{opt}:
@table @asis
@item @qcode{@var{opt} = "a"}
Move eigenvalues with negative real parts to the leading block of @var{S}.
Mnemonic: @qcode{"a"} for Algebraic @nospell{Riccati} Equations, where this
ordering is useful.
@item @qcode{@var{opt} = "d"}
Move eigenvalues with magnitude less than one to the leading block of @var{S}.
Mnemonic: @qcode{"d"} for Discrete Algebraic @nospell{Riccati} Equations,
where this ordering is useful.
@item @qcode{@var{opt} = "u"}
Unordered. No particular ordering of eigenvalues (default).
@end table
The leading @var{k} columns of @var{U} always span the @var{A}-invariant
subspace corresponding to the @var{k} leading eigenvalues of @var{S}.
@xseealso{@ref{XREFrsf2csf,,rsf2csf}, @ref{XREFordschur,,ordschur}, @ref{XREFordeig,,ordeig}, @ref{XREFlu,,lu}, @ref{XREFchol,,chol}, @ref{XREFhess,,hess}, @ref{XREFqr,,qr}, @ref{XREFqz,,qz}, @ref{XREFsvd,,svd}, @ref{XREFeig,,eig}}
@end deftypefn
@c rsf2csf libinterp/corefcn/schur.cc
@anchor{XREFrsf2csf}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{U}, @var{T}] =} rsf2csf (@var{UR}, @var{TR})
Convert a real, upper quasi-triangular Schur@tie{}form @var{TR} to a
complex, upper triangular Schur@tie{}form @var{T}.
Note that the following relations hold:
@tex
$UR \cdot TR \cdot {UR}^T = U T U^{\dagger}$ and
$U^{\dagger} U$ is the identity matrix I.
@end tex
@ifnottex
@tcode{@var{UR} * @var{TR} * @var{UR}' = @var{U} * @var{T} * @var{U}'} and
@code{@var{U}' * @var{U}} is the identity matrix I.
@end ifnottex
Note also that @var{U} and @var{T} are not unique.
@xseealso{@ref{XREFschur,,schur}}
@end deftypefn
@c ordschur libinterp/corefcn/ordschur.cc
@anchor{XREFordschur}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{UR}, @var{SR}] =} ordschur (@var{U}, @var{S}, @var{select})
Reorder the real Schur factorization (@var{U},@var{S}) obtained with the
@code{schur} function, so that selected eigenvalues appear in the upper left
diagonal blocks of the quasi triangular Schur matrix.
The logical vector @var{select} specifies the selected eigenvalues as they
appear along @var{S}'s diagonal.
For example, given the matrix @code{@var{A} = [1, 2; 3, 4]}, and its Schur
decomposition
@example
[@var{U}, @var{S}] = schur (@var{A})
@end example
@noindent
which returns
@example
@group
@var{U} =
-0.82456 -0.56577
0.56577 -0.82456
@var{S} =
-0.37228 -1.00000
0.00000 5.37228
@end group
@end example
It is possible to reorder the decomposition so that the positive eigenvalue
is in the upper left corner, by doing:
@example
[@var{U}, @var{S}] = ordschur (@var{U}, @var{S}, [0,1])
@end example
@xseealso{@ref{XREFschur,,schur}, @ref{XREFordeig,,ordeig}, @ref{XREFordqz,,ordqz}}
@end deftypefn
@c ordqz libinterp/corefcn/ordqz.cc
@anchor{XREFordqz}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{AR}, @var{BR}, @var{QR}, @var{ZR}] =} ordqz (@var{AA}, @var{BB}, @var{Q}, @var{Z}, @var{keyword})
@deftypefnx {} {[@var{AR}, @var{BR}, @var{QR}, @var{ZR}] =} ordqz (@var{AA}, @var{BB}, @var{Q}, @var{Z}, @var{select})
Reorder the QZ@tie{}decomposition of a generalized eigenvalue problem.
The generalized eigenvalue problem is defined as
@tex
$$A x = \lambda B x$$
@end tex
@ifnottex
@math{A x = @var{lambda} B x}
@end ifnottex
Its generalized Schur decomposition is computed using the @code{qz} algorithm:
@code{[@var{AA}, @var{BB}, @var{Q}, @var{Z}] = qz (@var{A}, @var{B})}
where @var{AA}, @var{BB}, @var{Q}, and @var{Z} fulfill
@tex
$$ AA = Q \cdot A \cdot Z, BB = Q \cdot B \cdot Z $$
@end tex
@ifnottex
@example
@group
@var{AA} = @var{Q} * @var{A} * @var{Z}, @var{BB} = @var{Q} * @var{B} * @var{Z}
@end group
@end example
@end ifnottex
The @code{ordqz} function computes a unitary transformation @var{QR} and
@var{ZR} such that the order of the eigenvalue on the diagonal of @var{AA} and
@var{BB} is changed. The resulting reordered matrices @var{AR} and @var{BR}
fulfill:
@tex
$$ A_R = Q_R \cdot A \cdot Z_R, B_R = Q_R \cdot B \cdot Z_R $$
@end tex
@ifnottex
@example
@group
@var{AR} = @var{QR} * @var{A} * @var{ZR}, @var{BR} = @var{QR} * @var{B} * @var{ZR}
@end group
@end example
@end ifnottex
The function can either be called with the @var{keyword} argument which
selects the eigenvalues in the top left block of @var{AR} and @var{BR} in the
following way:
@table @asis
@item @qcode{"S"}, @nospell{@qcode{"udi"}}
small: leading block has all
@tex
$|\lambda| < 1$
@end tex
@ifnottex
|@var{lambda}| < 1
@end ifnottex
@item @qcode{"B"}, @nospell{@qcode{"udo"}}
big: leading block has all
@tex
$|\lambda| \geq 1$
@end tex
@ifnottex
|@var{lambda}| @geq{} 1
@end ifnottex
@item @qcode{"-"}, @nospell{@qcode{"lhp"}}
negative real part: leading block has all eigenvalues in the open left
half-plane
@item @qcode{"+"}, @nospell{@qcode{"rhp"}}
non-negative real part: leading block has all eigenvalues in the closed right
half-plane
@end table
If a logical vector @var{select} is given instead of a keyword the @code{ordqz}
function reorders all eigenvalues @code{k} to the left block for which
@code{select(k)} is true.
Note: The keywords are compatible with the ones from @code{qr}.
@xseealso{@ref{XREFeig,,eig}, @ref{XREFordeig,,ordeig}, @ref{XREFqz,,qz}, @ref{XREFschur,,schur}, @ref{XREFordschur,,ordschur}}
@end deftypefn
@c ordeig scripts/linear-algebra/ordeig.m
@anchor{XREFordeig}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{lambda} =} ordeig (@var{A})
@deftypefnx {} {@var{lambda} =} ordeig (@var{A}, @var{B})
Return the eigenvalues of quasi-triangular matrices in their order of
appearance in the matrix @var{A}.
The quasi-triangular matrix @var{A} is usually the result of a Schur
factorization. If called with a second input @var{B} then the generalized
eigenvalues of the pair @var{A}, @var{B} are returned in the order of
appearance of the matrix @code{@var{A}-@var{lambda}*@var{B}}. The pair
@var{A}, @var{B} is usually the result of a QZ decomposition.
@xseealso{@ref{XREFordschur,,ordschur}, @ref{XREFordqz,,ordqz}, @ref{XREFeig,,eig}, @ref{XREFschur,,schur}, @ref{XREFqz,,qz}}
@end deftypefn
@c subspace scripts/linear-algebra/subspace.m
@anchor{XREFsubspace}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{angle} =} subspace (@var{A}, @var{B})
Determine the largest principal angle between two subspaces
spanned by the columns of matrices @var{A} and @var{B}.
@end deftypefn
@c svd libinterp/corefcn/svd.cc
@anchor{XREFsvd}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{s} =} svd (@var{A})
@deftypefnx {} {[@var{U}, @var{S}, @var{V}] =} svd (@var{A})
@deftypefnx {} {[@var{U}, @var{S}, @var{V}] =} svd (@var{A}, "econ")
@deftypefnx {} {[@var{U}, @var{S}, @var{V}] =} svd (@var{A}, 0)
@cindex singular value decomposition
Compute the singular value decomposition of @var{A}.
The singular value decomposition is defined by the relation
@tex
$$
A = U S V^{\dagger}
$$
@end tex
@ifnottex
@example
A = U*S*V'
@end example
@end ifnottex
The function @code{svd} normally returns only the vector of singular values.
When called with three return values, it computes
@tex
$U$, $S$, and $V$.
@end tex
@ifnottex
@var{U}, @var{S}, and @var{V}.
@end ifnottex
For example,
@example
svd (hilb (3))
@end example
@noindent
returns
@example
@group
ans =
1.4083189
0.1223271
0.0026873
@end group
@end example
@noindent
and
@example
[u, s, v] = svd (hilb (3))
@end example
@noindent
returns
@example
@group
u =
-0.82704 0.54745 0.12766
-0.45986 -0.52829 -0.71375
-0.32330 -0.64901 0.68867
s =
1.40832 0.00000 0.00000
0.00000 0.12233 0.00000
0.00000 0.00000 0.00269
v =
-0.82704 0.54745 0.12766
-0.45986 -0.52829 -0.71375
-0.32330 -0.64901 0.68867
@end group
@end example
When given a second argument that is not 0, @code{svd} returns an economy-sized
decomposition, eliminating the unnecessary rows or columns of @var{U} or
@var{V}.
If the second argument is exactly 0, then the choice of decomposition is based
on the matrix @var{A}. If @var{A} has more rows than columns then an
economy-sized decomposition is returned, otherwise a regular decomposition
is calculated.
Algorithm Notes: When calculating the full decomposition (left and right
singular matrices in addition to singular values) there is a choice of two
routines in @sc{lapack}. The default routine used by Octave is @code{gesvd}.
The alternative is @code{gesdd} which is 5X faster, but may use more memory
and may be inaccurate for some input matrices. There is a third routine
@code{gejsv}, suitable for better accuracy at extreme scale. See the
documentation for @code{svd_driver} for more information on choosing a driver.
@xseealso{@ref{XREFsvd_driver,,svd_driver}, @ref{XREFsvds,,svds}, @ref{XREFeig,,eig}, @ref{XREFlu,,lu}, @ref{XREFchol,,chol}, @ref{XREFhess,,hess}, @ref{XREFqr,,qr}, @ref{XREFqz,,qz}}
@end deftypefn
@c svd_driver libinterp/corefcn/svd.cc
@anchor{XREFsvd_driver}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{val} =} svd_driver ()
@deftypefnx {} {@var{old_val} =} svd_driver (@var{new_val})
@deftypefnx {} {@var{old_val} =} svd_driver (@var{new_val}, "local")
Query or set the underlying @sc{lapack} driver used by @code{svd}.
Currently recognized values are @qcode{"gesdd"}, @qcode{"gesvd"}, and
@qcode{"gejsv"}. The default is @qcode{"gesvd"}.
When called from inside a function with the @qcode{"local"} option, the
variable is changed locally for the function and any subroutines it calls.
The original variable value is restored when exiting the function.
Algorithm Notes: The @sc{lapack} library routines @code{gesvd} and @code{gesdd}
are different only when calculating the full singular value decomposition (left
and right singular matrices as well as singular values). When calculating just
the singular values the following discussion is not relevant.
The newer @code{gesdd} routine is based on a Divide-and-Conquer algorithm that
is 5X faster than the alternative @code{gesvd}, which is based on QR
factorization. However, the new algorithm can use significantly more memory.
For an @nospell{MxN} input matrix the memory usage is of order O(min(M,N) ^ 2),
whereas the alternative is of order O(max(M,N)).
The routine @code{gejsv} uses a preconditioned Jacobi SVD algorithm. Unlike
@code{gesvd} and @code{gesdd}, in @code{gejsv}, there is no bidiagonalization
step that could contaminate accuracy in some extreme cases. Also, @code{gejsv}
is known to be optimally accurate in some sense. However, the speed is slower
(single threaded at its core) and uses more memory (O(min(M,N) ^ 2 + M + N)).
Beyond speed and memory issues, there have been instances where some input
matrices were not accurately decomposed by @code{gesdd}. See currently active
bug @url{https://savannah.gnu.org/bugs/?55564}. Until these accuracy issues
are resolved in a new version of the @sc{lapack} library, the default driver
in Octave has been set to @qcode{"gesvd"}.
@xseealso{@ref{XREFsvd,,svd}}
@end deftypefn
@c FIXME: should there be a new section here?
@c housh scripts/linear-algebra/housh.m
@anchor{XREFhoush}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{housv}, @var{beta}, @var{zer}] =} housh (@var{x}, @var{j}, @var{z})
Compute Householder reflection vector @var{housv} to reflect @var{x} to be
the j-th column of identity, i.e.,
@example
@group
(I - beta*housv*housv')x = norm (x)*e(j) if x(j) < 0,
(I - beta*housv*housv')x = -norm (x)*e(j) if x(j) >= 0
@end group
@end example
@noindent
Inputs
@table @var
@item x
vector
@item j
index into vector
@item z
threshold for zero (usually should be the number 0)
@end table
@noindent
Outputs (see @nospell{Golub and Van Loan}):
@table @var
@item beta
If beta = 0, then no reflection need be applied (@nospell{zer} set to 0)
@item housv
householder vector
@end table
@end deftypefn
@c krylov scripts/linear-algebra/krylov.m
@anchor{XREFkrylov}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {[@var{u}, @var{h}, @var{nu}] =} krylov (@var{A}, @var{V}, @var{k}, @var{eps1}, @var{pflg})
Construct an orthogonal basis @var{u} of a block Krylov subspace.
The block Krylov subspace has the following form:
@example
[v a*v a^2*v @dots{} a^(k+1)*v]
@end example
@noindent
The construction is made with Householder reflections to guard against loss
of orthogonality.
If @var{V} is a vector, then @var{h} contains the Hessenberg matrix
such that @nospell{@tcode{a*u == u*h+rk*ek'}}, in which
@code{rk = a*u(:,k)-u*h(:,k)}, and @nospell{@tcode{ek'}} is the vector
@code{[0, 0, @dots{}, 1]} of length @var{k}. Otherwise, @var{h} is
meaningless.
If @var{V} is a vector and @var{k} is greater than @code{length (A) - 1},
then @var{h} contains the Hessenberg matrix such that @code{a*u == u*h}.
The value of @var{nu} is the dimension of the span of the Krylov subspace
(based on @var{eps1}).
If @var{b} is a vector and @var{k} is greater than @var{m-1}, then @var{h}
contains the Hessenberg decomposition of @var{A}.
The optional parameter @var{eps1} is the threshold for zero. The default
value is 1e-12.
If the optional parameter @var{pflg} is nonzero, row pivoting is used to
improve numerical behavior. The default value is 0.
Reference: @nospell{A. Hodel, P. Misra}, @cite{Partial Pivoting in the
Computation of Krylov Subspaces of Large Sparse Systems}, Proceedings of
the 42nd IEEE Conference on Decision and Control, December 2003.
@end deftypefn
@node Functions of a Matrix
@section Functions of a Matrix
@cindex matrix, functions of
@c expm scripts/linear-algebra/expm.m
@anchor{XREFexpm}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{r} =} expm (@var{A})
Return the exponential of a matrix.
The matrix exponential is defined as the infinite Taylor series
@tex
$$
\exp (A) = I + A + {A^2 \over 2!} + {A^3 \over 3!} + \cdots
$$
@end tex
@ifnottex
@example
expm (A) = I + A + A^2/2! + A^3/3! + @dots{}
@end example
@end ifnottex
However, the Taylor series is @emph{not} the way to compute the matrix
exponential; see @nospell{Moler and Van Loan}, @cite{Nineteen Dubious Ways
to Compute the Exponential of a Matrix}, SIAM Review, 1978. This routine
uses Ward's diagonal Pad@'e approximation method with three step
preconditioning (SIAM Journal on Numerical Analysis, 1977). Diagonal
Pad@'e approximations are rational polynomials of matrices
@tex
$D_q(A)^{-1}N_q(A)$
@end tex
@ifnottex
@example
@group
-1
D (A) N (A)
@end group
@end example
@end ifnottex
whose Taylor series matches the first
@tex
$2 q + 1 $
@end tex
@ifnottex
@code{2q+1}
@end ifnottex
terms of the Taylor series above; direct evaluation of the Taylor series
(with the same preconditioning steps) may be desirable in lieu of the
Pad@'e approximation when
@tex
$D_q(A)$
@end tex
@ifnottex
@code{Dq(A)}
@end ifnottex
is ill-conditioned.
@xseealso{@ref{XREFlogm,,logm}, @ref{XREFsqrtm,,sqrtm}}
@end deftypefn
@c logm scripts/linear-algebra/logm.m
@anchor{XREFlogm}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{s} =} logm (@var{A})
@deftypefnx {} {@var{s} =} logm (@var{A}, @var{opt_iters})
@deftypefnx {} {[@var{s}, @var{iters}] =} logm (@dots{})
Compute the matrix logarithm of the square matrix @var{A}.
The implementation utilizes a Pad@'e approximant and the identity
@example
logm (@var{A}) = 2^k * logm (@var{A}^(1 / 2^k))
@end example
The optional input @var{opt_iters} is the maximum number of square roots
to compute and defaults to 100.
The optional output @var{iters} is the number of square roots actually
computed.
@xseealso{@ref{XREFexpm,,expm}, @ref{XREFsqrtm,,sqrtm}}
@end deftypefn
@c sqrtm libinterp/corefcn/sqrtm.cc
@anchor{XREFsqrtm}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{s} =} sqrtm (@var{A})
@deftypefnx {} {[@var{s}, @var{error_estimate}] =} sqrtm (@var{A})
Compute the matrix square root of the square matrix @var{A}.
Ref: @nospell{N.J. Higham}. @cite{A New sqrtm for @sc{matlab}}. Numerical
Analysis Report No.@: 336, Manchester @nospell{Centre} for Computational
Mathematics, Manchester, England, January 1999.
@xseealso{@ref{XREFexpm,,expm}, @ref{XREFlogm,,logm}}
@end deftypefn
@c kron libinterp/corefcn/kron.cc
@anchor{XREFkron}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{C} =} kron (@var{A}, @var{B})
@deftypefnx {} {@var{C} =} kron (@var{A1}, @var{A2}, @dots{})
Form the Kronecker product of two or more matrices.
This is defined block by block as
@example
c = [ a(i,j)*b ]
@end example
For example:
@example
@group
kron (1:4, ones (3, 1))
@result{} 1 2 3 4
1 2 3 4
1 2 3 4
@end group
@end example
If there are more than two input arguments @var{A1}, @var{A2}, @dots{},
@var{An} the Kronecker product is computed as
@example
kron (kron (@var{A1}, @var{A2}), @dots{}, @var{An})
@end example
@noindent
Since the Kronecker product is associative, this is well-defined.
@xseealso{@ref{XREFtensorprod,,tensorprod}}
@end deftypefn
@c tensorprod scripts/linear-algebra/tensorprod.m
@anchor{XREFtensorprod}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{C} =} tensorprod (@var{A}, @var{B}, @var{dimA}, @var{dimB})
@deftypefnx {} {@var{C} =} tensorprod (@var{A}, @var{B}, @var{dim})
@deftypefnx {} {@var{C} =} tensorprod (@var{A}, @var{B})
@deftypefnx {} {@var{C} =} tensorprod (@var{A}, @var{B}, "all")
@deftypefnx {} {@var{C} =} tensorprod (@var{A}, @var{B}, @dots{}, "NumDimensionsA", @var{value})
Compute the tensor product between numeric tensors @var{A} and @var{B}.
The dimensions of @var{A} and @var{B} that are contracted are defined by
@var{dimA} and @var{dimB}, respectively. @var{dimA} and @var{dimB} are
scalars or equal length vectors that define the dimensions to match up.
The matched dimensions of @var{A} and @var{B} must have the same number of
elements.
When only @var{dim} is used, it is equivalent to
@code{@var{dimA} = @var{dimB} = @var{dim}}.
When no dimensions are specified, @code{@var{dimA} = @var{dimB} = []}. This
computes the outer product between @var{A} and @var{B}.
Using the @qcode{"all"} option results in the inner product between @var{A}
and @var{B}. This requires @code{size (@var{A}) == size (@var{B})}.
Use the property-value pair with the property name
@nospell{@qcode{"NumDimensionsA"}} when @var{A} has trailing singleton
dimensions that should be transferred to @var{C}. The specified @var{value}
should be the total number of dimensions of @var{A}.
@sc{matlab} Compatibility: Octave does not currently support the
@qcode{"@var{property_name}=@var{value}"} syntax for the
@nospell{@qcode{"NumDimensionsA"}} parameter.
@xseealso{@ref{XREFkron,,kron}, @ref{XREFdot,,dot}, @ref{XREFmtimes,,mtimes}}
@end deftypefn
@c blkmm libinterp/corefcn/dot.cc
@anchor{XREFblkmm}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{C} =} blkmm (@var{A}, @var{B})
Compute products of matrix blocks.
The blocks are given as 2-dimensional subarrays of the arrays @var{A},
@var{B}. The size of @var{A} must have the form @code{[m,k,@dots{}]} and
size of @var{B} must be @code{[k,n,@dots{}]}. The result is then of size
@code{[m,n,@dots{}]} and is computed as follows:
@example
@group
for i = 1:prod (size (@var{A})(3:end))
@var{C}(:,:,i) = @var{A}(:,:,i) * @var{B}(:,:,i)
endfor
@end group
@end example
@end deftypefn
@c sylvester libinterp/corefcn/sylvester.cc
@anchor{XREFsylvester}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{X} =} sylvester (@var{A}, @var{B}, @var{C})
Solve the Sylvester equation.
The Sylvester equation is defined as:
@tex
$$
A X + X B = C
$$
@end tex
@ifnottex
@example
A X + X B = C
@end example
@end ifnottex
The solution is computed using standard @sc{lapack} subroutines.
For example:
@example
@group
sylvester ([1, 2; 3, 4], [5, 6; 7, 8], [9, 10; 11, 12])
@result{} [ 0.50000, 0.66667; 0.66667, 0.50000 ]
@end group
@end example
@end deftypefn
@node Specialized Solvers
@section Specialized Solvers
@cindex matrix, specialized solvers
@c bicg scripts/sparse/bicg.m
@anchor{XREFbicg}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{x} =} bicg (@var{A}, @var{b})
@deftypefnx {} {@var{x} =} bicg (@var{A}, @var{b}, @var{tol})
@deftypefnx {} {@var{x} =} bicg (@var{A}, @var{b}, @var{tol}, @var{maxit})
@deftypefnx {} {@var{x} =} bicg (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M})
@deftypefnx {} {@var{x} =} bicg (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M1}, @var{M2})
@deftypefnx {} {@var{x} =} bicg (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M}, [], @var{x0})
@deftypefnx {} {@var{x} =} bicg (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M1}, @var{M2}, @var{x0})
@deftypefnx {} {@var{x} =} bicg (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M}, [], @var{x0}, @dots{})
@deftypefnx {} {@var{x} =} bicg (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M1}, @var{M2}, @var{x0}, @dots{})
@deftypefnx {} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} bicg (@var{A}, @var{b}, @dots{})
Solve the linear system of equations
@w{@code{@var{A} * @var{x} = @var{b}}}@ by means of the Bi-Conjugate
Gradient iterative method.
The input arguments are:
@itemize
@item @var{A} is the matrix of the linear system and it must be square.
@var{A} can be passed as a matrix, function handle, or inline function
@code{Afcn} such that @w{@code{Afcn (x, "notransp") = A * x}}@ and
@w{@code{Afcn (x, "transp") = A' * x}}. Additional parameters to
@code{Afcn} may be passed after @var{x0}.
@item @var{b} is the right-hand side vector. It must be a column vector
with the same number of rows as @var{A}.
@item
@var{tol} is the required relative tolerance for the residual error,
@w{@code{@var{b} - @var{A} * @var{x}}}. The iteration stops if
@w{@code{norm (@var{b} - @var{A} * @var{x})} @leq{}
@w{@code{@var{tol} * norm (@var{b})}}}.
If @var{tol} is omitted or empty, then a tolerance of 1e-6 is used.
@item
@var{maxit} is the maximum allowed number of iterations; if @var{maxit}
is omitted or empty then a value of 20 is used.
@item
@var{M1}, @var{M2} are the preconditioners. The preconditioner @var{M} is
given as @code{@var{M} = @var{M1} * @var{M2}}. Both @var{M1} and @var{M2}
can be passed as a matrix or as a function handle or inline function
@code{g} such that
@w{@code{g (@var{x}, "notransp") = @var{M1} \ @var{x}}}@ or
@w{@code{g (@var{x}, "notransp") = @var{M2} \ @var{x}}}@ and
@w{@code{g (@var{x}, "transp") = @var{M1}' \ @var{x}}}@ or
@w{@code{g (@var{x}, "transp") = @var{M2}' \ @var{x}}}.
If @var{M1} is omitted or empty, then preconditioning is not applied.
The preconditioned system is theoretically equivalent to applying the
@code{bicg} method to the linear system
@code{inv (@var{M1}) * A * inv (@var{M2}) * @var{y} = inv
(@var{M1}) * @var{b}} and
@code{inv (@var{M2'}) * A' * inv (@var{M1'}) * @var{z} =
inv (@var{M2'}) * @var{b}} and then setting
@code{@var{x} = inv (@var{M2}) * @var{y}}.
@item
@var{x0} is the initial guess. If @var{x0} is omitted or empty then the
function sets @var{x0} to a zero vector by default.
@end itemize
Any arguments which follow @var{x0} are treated as parameters, and passed in
an appropriate manner to any of the functions (@var{Afcn} or @var{Mfcn}) or
that have been given to @code{bicg}.
The output parameters are:
@itemize
@item
@var{x} is the computed approximation to the solution of
@w{@code{@var{A} * @var{x} = @var{b}}}. If the algorithm did not converge,
then @var{x} is the iteration which has the minimum residual.
@item
@var{flag} indicates the exit status:
@itemize
@item 0: The algorithm converged to within the prescribed tolerance.
@item 1: The algorithm did not converge and it reached the maximum number of
iterations.
@item 2: The preconditioner matrix is singular.
@item 3: The algorithm stagnated, i.e., the absolute value of the
difference between the current iteration @var{x} and the previous is less
than @code{eps * norm (@var{x},2)}.
@item 4: The algorithm could not continue because intermediate values
became too small or too large for reliable computation.
@end itemize
@item
@var{relres} is the ratio of the final residual to its initial value,
measured in the Euclidean norm.
@item
@var{iter} is the iteration which @var{x} is computed.
@item
@var{resvec} is a vector containing the residual at each iteration.
The total number of iterations performed is given by
@code{length (@var{resvec}) - 1}.
@end itemize
Consider a trivial problem with a tridiagonal matrix
@smallexample
@group
n = 20;
A = toeplitz (sparse ([1, 1], [1, 2], [2, 1] * n ^ 2, 1, n)) + ...
toeplitz (sparse (1, 2, -1, 1, n) * n / 2, ...
sparse (1, 2, 1, 1, n) * n / 2);
b = A * ones (n, 1);
restart = 5;
[M1, M2] = ilu (A); # in this tridiag case, it corresponds to lu (A)
M = M1 * M2;
Afcn = @@(x, string) strcmp (string, "notransp") * (A * x) + ...
strcmp (string, "transp") * (A' * x);
Mfcn = @@(x, string) strcmp (string, "notransp") * (M \ x) + ...
strcmp (string, "transp") * (M' \ x);
M1fcn = @@(x, string) strcmp (string, "notransp") * (M1 \ x) + ...
strcmp (string, "transp") * (M1' \ x);
M2fcn = @@(x, string) strcmp (string, "notransp") * (M2 \ x) + ...
strcmp (string, "transp") * (M2' \ x);
@end group
@end smallexample
@sc{Example 1:} simplest usage of @code{bicg}
@example
x = bicg (A, b)
@end example
@sc{Example 2:} @code{bicg} with a function that computes
@code{@var{A}*@var{x}} and @code{@var{A'}*@var{x}}
@example
x = bicg (Afcn, b, [], n)
@end example
@sc{Example 3:} @code{bicg} with a preconditioner matrix @var{M}
@example
x = bicg (A, b, 1e-6, n, M)
@end example
@sc{Example 4:} @code{bicg} with a function as preconditioner
@example
x = bicg (Afcn, b, 1e-6, n, Mfcn)
@end example
@sc{Example 5:} @code{bicg} with preconditioner matrices @var{M1}
and @var{M2}
@example
x = bicg (A, b, 1e-6, n, M1, M2)
@end example
@sc{Example 6:} @code{bicg} with functions as preconditioners
@example
x = bicg (Afcn, b, 1e-6, n, M1fcn, M2fcn)
@end example
@sc{Example 7:} @code{bicg} with as input a function requiring an argument
@example
@group
function y = Ap (A, x, string, z)
## compute A^z * x or (A^z)' * x
y = x;
if (strcmp (string, "notransp"))
for i = 1:z
y = A * y;
endfor
elseif (strcmp (string, "transp"))
for i = 1:z
y = A' * y;
endfor
endif
endfunction
Apfcn = @@(x, string, p) Ap (A, x, string, p);
x = bicg (Apfcn, b, [], [], [], [], [], 2);
@end group
@end example
Reference:
@nospell{Y. Saad}, @cite{Iterative Methods for Sparse Linear Systems},
Second edition, 2003, SIAM.
@xseealso{@ref{XREFbicgstab,,bicgstab}, @ref{XREFcgs,,cgs}, @ref{XREFgmres,,gmres}, @ref{XREFpcg,,pcg}, @ref{XREFqmr,,qmr}, @ref{XREFtfqmr,,tfqmr}}
@end deftypefn
@c bicgstab scripts/sparse/bicgstab.m
@anchor{XREFbicgstab}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{x} =} bicgstab (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M1}, @var{M2}, @var{x0}, @dots{})
@deftypefnx {} {@var{x} =} bicgstab (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M}, [], @var{x0}, @dots{})
@deftypefnx {} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} bicgstab (@var{A}, @var{b}, @dots{})
Solve @code{A x = b} using the stabilized Bi-conjugate gradient iterative
method.
The input parameters are:
@itemize @minus
@item @var{A} is the matrix of the linear system and it must be square.
@var{A} can be passed as a matrix, function handle, or inline
function @code{Afcn} such that @code{Afcn(x) = A * x}. Additional
parameters to @code{Afcn} are passed after @var{x0}.
@item @var{b} is the right hand side vector. It must be a column vector
with the same number of rows as @var{A}.
@item
@var{tol} is the required relative tolerance for the residual error,
@w{@code{@var{b} - @var{A} * @var{x}}}. The iteration stops if
@w{@code{norm (@var{b} - @var{A} * @var{x})} @leq{}
@w{@code{@var{tol} * norm (@var{b})}}}.
If @var{tol} is omitted or empty, then a tolerance of 1e-6 is used.
@item @var{maxit} the maximum number of outer iterations, if not given or
set to [] the default value @code{min (20, numel (b))} is used.
@item @var{M1}, @var{M2} are the preconditioners. The preconditioner
@var{M} is given as @code{@var{M} = @var{M1} * @var{M2}}.
Both @var{M1} and @var{M2} can be passed as a matrix or as a function
handle or inline function @code{g} such that
@code{g(@var{x}) = @var{M1} \ @var{x}} or
@code{g(@var{x}) = @var{M2} \ @var{x}}.
The technique used is the right preconditioning, i.e., it is
solved @code{@var{A} * inv (@var{M}) * @var{y} = @var{b}} and then
@code{@var{x} = inv (@var{M}) * @var{y}}.
@item @var{x0} the initial guess, if not given or set to [] the default
value @code{zeros (size (@var{b}))} is used.
@end itemize
The arguments which follow @var{x0} are treated as parameters, and passed in
a proper way to any of the functions (@var{A} or @var{M}) which are passed
to @code{bicstab}.
The output parameters are:
@itemize @minus
@item @var{x} is the approximation computed. If the method doesn't
converge then it is the iterated with the minimum residual.
@item @var{flag} indicates the exit status:
@itemize @minus
@item 0: iteration converged to the within the chosen tolerance
@item 1: the maximum number of iterations was reached before convergence
@item 2: the preconditioner matrix is singular
@item 3: the algorithm reached stagnation
@item 4: the algorithm can't continue due to a division by zero
@end itemize
@item @var{relres} is the relative residual obtained with as
@code{(@var{A}*@var{x}-@var{b}) / @code{norm(@var{b})}}.
@item @var{iter} is the (possibly half) iteration which @var{x} is
computed. If it is an half iteration then it is @code{@var{iter} + 0.5}
@item @var{resvec} is a vector containing the residual of each half and
total iteration (There are also the half iterations since @var{x} is
computed in two steps at each iteration).
Doing @code{(length(@var{resvec}) - 1) / 2} is possible to see the
total number of (total) iterations performed.
@end itemize
Let us consider a trivial problem with a tridiagonal matrix
@example
@group
n = 20;
A = toeplitz (sparse ([1, 1], [1, 2], [2, 1] * n ^ 2, 1, n)) + ...
toeplitz (sparse (1, 2, -1, 1, n) * n / 2, ...
sparse (1, 2, 1, 1, n) * n / 2);
b = A * ones (n, 1);
restart = 5;
[M1, M2] = ilu (A); # in this tridiag case, it corresponds to lu (A)
M = M1 * M2;
Afcn = @@(x) A * x;
Mfcn = @@(x) M \ x;
M1fcn = @@(x) M1 \ x;
M2fcn = @@(x) M2 \ x;
@end group
@end example
@sc{Example 1:} simplest usage of @code{bicgstab}
@example
x = bicgstab (A, b, [], n)
@end example
@sc{Example 2:} @code{bicgstab} with a function which computes
@code{@var{A} * @var{x}}
@example
x = bicgstab (Afcn, b, [], n)
@end example
@sc{Example 3:} @code{bicgstab} with a preconditioner matrix @var{M}
@example
x = bicgstab (A, b, [], 1e-06, n, M)
@end example
@sc{Example 4:} @code{bicgstab} with a function as preconditioner
@example
x = bicgstab (Afcn, b, 1e-6, n, Mfcn)
@end example
@sc{Example 5:} @code{bicgstab} with preconditioner matrices @var{M1}
and @var{M2}
@example
x = bicgstab (A, b, [], 1e-6, n, M1, M2)
@end example
@sc{Example 6:} @code{bicgstab} with functions as preconditioners
@example
x = bicgstab (Afcn, b, 1e-6, n, M1fcn, M2fcn)
@end example
@sc{Example 7:} @code{bicgstab} with as input a function requiring
an argument
@example
@group
function y = Ap (A, x, z) # compute A^z * x
y = x;
for i = 1:z
y = A * y;
endfor
endfunction
Apfcn = @@(x, string, p) Ap (A, x, string, p);
x = bicgstab (Apfcn, b, [], [], [], [], [], 2);
@end group
@end example
@sc{Example 8:} explicit example to show that @code{bicgstab} uses a
right preconditioner
@example
@group
[M1, M2] = ilu (A + 0.1 * eye (n)); # factorization of A perturbed
M = M1 * M2;
## reference solution computed by bicgstab after one iteration
[x_ref, fl] = bicgstab (A, b, [], 1, M)
## right preconditioning
[y, fl] = bicgstab (A / M, b, [], 1)
x = M \ y # compare x and x_ref
@end group
@end example
Reference:
@nospell{Y. Saad}, @cite{Iterative Methods for Sparse Linear
Systems}, Second edition, 2003, SIAM
@xseealso{@ref{XREFbicg,,bicg}, @ref{XREFcgs,,cgs}, @ref{XREFgmres,,gmres}, @ref{XREFpcg,,pcg}, @ref{XREFqmr,,qmr}, @ref{XREFtfqmr,,tfqmr}}
@end deftypefn
@c cgs scripts/sparse/cgs.m
@anchor{XREFcgs}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{x} =} cgs (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M1}, @var{M2}, @var{x0}, @dots{})
@deftypefnx {} {@var{x} =} cgs (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M}, [], @var{x0}, @dots{})
@deftypefnx {} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} cgs (@var{A}, @var{b}, @dots{})
Solve @code{A x = b}, where @var{A} is a square matrix, using the
Conjugate Gradients Squared method.
The input arguments are:
@itemize @minus
@item @var{A} is the matrix of the linear system and it must be square.
@var{A} can be passed as a matrix, function handle, or inline
function @code{Afcn} such that @code{Afcn(x) = A * x}. Additional
parameters to @code{Afcn} are passed after @var{x0}.
@item @var{b} is the right hand side vector. It must be a column vector
with same number of rows of @var{A}.
@item @var{tol} is the relative tolerance, if not given or set to [] the
default value 1e-6 is used.
@item @var{maxit} the maximum number of outer iterations, if not given or
set to [] the default value @code{min (20, numel (b))} is used.
@item @var{M1}, @var{M2} are the preconditioners. The preconditioner
matrix is given as @code{M = M1 * M2}. Both @var{M1}
and @var{M2} can be passed as a matrix or as a function handle or inline
function @code{g} such that @code{g(x) = M1 \ x} or @code{g(x) = M2 \ x}.
If M1 is empty or not passed then no preconditioners are applied.
The technique used is the right preconditioning, i.e., it is solved
@code{@var{A}*inv(@var{M})*y = b} and then @code{@var{x} = inv(@var{M})*y}.
@item @var{x0} the initial guess, if not given or set to [] the default
value @code{zeros (size (b))} is used.
@end itemize
The arguments which follow @var{x0} are treated as parameters, and passed in
a proper way to any of the functions (@var{A} or @var{P}) which are passed
to @code{cgs}.
The output parameters are:
@itemize @minus
@item @var{x} is the approximation computed. If the method doesn't
converge then it is the iterated with the minimum residual.
@item @var{flag} indicates the exit status:
@itemize @minus
@item 0: iteration converged to the within the chosen tolerance
@item 1: the maximum number of iterations was reached before convergence
@item 2: the preconditioner matrix is singular
@item 3: the algorithm reached stagnation
@item 4: the algorithm can't continue due to a division by zero
@end itemize
@item @var{relres} is the relative residual obtained with as
@code{(@var{A}*@var{x}-@var{b}) / @code{norm(@var{b})}}.
@item @var{iter} is the iteration which @var{x} is computed.
@item @var{resvec} is a vector containing the residual at each iteration.
Doing @code{length(@var{resvec}) - 1} is possible to see the total number
of iterations performed.
@end itemize
Let us consider a trivial problem with a tridiagonal matrix
@smallexample
@group
n = 20;
A = toeplitz (sparse ([1, 1], [1, 2], [2, 1] * n ^ 2, 1, n)) + ...
toeplitz (sparse (1, 2, -1, 1, n) * n / 2, ...
sparse (1, 2, 1, 1, n) * n / 2);
b = A * ones (n, 1);
restart = 5;
[M1, M2] = ilu (A); # in this tridiag case it corresponds to chol (A)'
M = M1 * M2;
Afcn = @@(x) A * x;
Mfcn = @@(x) M \ x;
M1fcn = @@(x) M1 \ x;
M2fcn = @@(x) M2 \ x;
@end group
@end smallexample
@sc{Example 1:} simplest usage of @code{cgs}
@example
x = cgs (A, b, [], n)
@end example
@sc{Example 2:} @code{cgs} with a function which computes
@code{@var{A} * @var{x}}
@example
x = cgs (Afcn, b, [], n)
@end example
@sc{Example 3:} @code{cgs} with a preconditioner matrix @var{M}
@example
x = cgs (A, b, [], 1e-06, n, M)
@end example
@sc{Example 4:} @code{cgs} with a function as preconditioner
@example
x = cgs (Afcn, b, 1e-6, n, Mfcn)
@end example
@sc{Example 5:} @code{cgs} with preconditioner matrices @var{M1}
and @var{M2}
@example
x = cgs (A, b, [], 1e-6, n, M1, M2)
@end example
@sc{Example 6:} @code{cgs} with functions as preconditioners
@example
x = cgs (Afcn, b, 1e-6, n, M1fcn, M2fcn)
@end example
@sc{Example 7:} @code{cgs} with as input a function requiring an argument
@example
@group
function y = Ap (A, x, z) # compute A^z * x
y = x;
for i = 1:z
y = A * y;
endfor
endfunction
Apfcn = @@(x, string, p) Ap (A, x, string, p);
x = cgs (Apfcn, b, [], [], [], [], [], 2);
@end group
@end example
@sc{Example 8:} explicit example to show that @code{cgs} uses a
right preconditioner
@example
@group
[M1, M2] = ilu (A + 0.3 * eye (n)); # factorization of A perturbed
M = M1 * M2;
## reference solution computed by cgs after one iteration
[x_ref, fl] = cgs (A, b, [], 1, M)
## right preconditioning
[y, fl] = cgs (A / M, b, [], 1)
x = M \ y # compare x and x_ref
@end group
@end example
References:
@nospell{Y. Saad}, @cite{Iterative Methods for Sparse Linear Systems},
Second edition, 2003, SIAM
@xseealso{@ref{XREFpcg,,pcg}, @ref{XREFbicgstab,,bicgstab}, @ref{XREFbicg,,bicg}, @ref{XREFgmres,,gmres}, @ref{XREFqmr,,qmr}, @ref{XREFtfqmr,,tfqmr}}
@end deftypefn
@c gmres scripts/sparse/gmres.m
@anchor{XREFgmres}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{x} =} gmres (@var{A}, @var{b}, @var{restart}, @var{tol}, @var{maxit}, @var{M1}, @var{M2}, @var{x0}, @dots{})
@deftypefnx {} {@var{x} =} gmres (@var{A}, @var{b}, @var{restart}, @var{tol}, @var{maxit}, @var{M}, [], @var{x0}, @dots{})
@deftypefnx {} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} gmres (@var{A}, @var{b}, @dots{})
Solve @code{A x = b} using the Preconditioned GMRES iterative method with
restart, a.k.a. PGMRES(restart).
The input arguments are:
@itemize @minus
@item @var{A} is the matrix of the linear system and it must be square.
@var{A} can be passed as a matrix, function handle, or inline
function @code{Afcn} such that @code{Afcn(x) = A * x}. Additional
parameters to @code{Afcn} are passed after @var{x0}.
@item @var{b} is the right hand side vector. It must be a column vector
with the same numbers of rows as @var{A}.
@item @var{restart} is the number of iterations before that the
method restarts. If it is [] or N = numel (b), then the restart
is not applied.
@item @var{tol} is the required relative tolerance for the
preconditioned residual error,
@code{inv (@var{M}) * (@var{b} - @var{a} * @var{x})}. The iteration
stops if @code{norm (inv (@var{M}) * (@var{b} - @var{a} * @var{x}))
@leq{} @var{tol} * norm (inv (@var{M}) * @var{B})}. If @var{tol} is
omitted or empty, then a tolerance of 1e-6 is used.
@item @var{maxit} is the maximum number of outer iterations, if not given or
set to [], then the default value @code{min (10, @var{N} / @var{restart})}
is used.
Note that, if @var{restart} is empty, then @var{maxit} is the maximum number
of iterations. If @var{restart} and @var{maxit} are not empty, then
the maximum number of iterations is @code{@var{restart} * @var{maxit}}.
If both @var{restart} and @var{maxit} are empty, then the maximum
number of iterations is set to @code{min (10, @var{N})}.
@item @var{M1}, @var{M2} are the preconditioners. The preconditioner
@var{M} is given as @code{M = M1 * M2}. Both @var{M1} and @var{M2} can
be passed as a matrix, function handle, or inline function @code{g} such
that @code{g(x) = M1 \ x} or @code{g(x) = M2 \ x}. If @var{M1} is [] or not
given, then the preconditioner is not applied.
The technique used is the left-preconditioning, i.e., it is solved
@code{inv(@var{M}) * @var{A} * @var{x} = inv(@var{M}) * @var{b}} instead of
@code{@var{A} * @var{x} = @var{b}}.
@item @var{x0} is the initial guess,
if not given or set to [], then the default value
@code{zeros (size (@var{b}))} is used.
@end itemize
The arguments which follow @var{x0} are treated as parameters, and passed in
a proper way to any of the functions (@var{A} or @var{M} or
@var{M1} or @var{M2}) which are passed to @code{gmres}.
The outputs are:
@itemize @minus
@item @var{x} the computed approximation. If the method does not
converge, then it is the iterated with minimum residual.
@item @var{flag} indicates the exit status:
@table @asis
@item 0 : iteration converged to within the specified tolerance
@item 1 : maximum number of iterations exceeded
@item 2 : the preconditioner matrix is singular
@item 3 : algorithm reached stagnation (the relative difference between two
consecutive iterations is less than eps)
@end table
@item @var{relres} is the value of the relative preconditioned
residual of the approximation @var{x}.
@item @var{iter} is a vector containing the number of outer iterations and
inner iterations performed to compute @var{x}. That is:
@itemize
@item @var{iter(1)}: number of outer iterations, i.e., how many
times the method restarted. (if @var{restart} is empty or @var{N},
then it is 1, if not 1 @leq{} @var{iter(1)} @leq{} @var{maxit}).
@item @var{iter(2)}: the number of iterations performed before the
restart, i.e., the method restarts when
@code{@var{iter(2)} = @var{restart}}. If @var{restart} is empty or
@var{N}, then 1 @leq{} @var{iter(2)} @leq{} @var{maxit}.
@end itemize
To be more clear, the approximation @var{x} is computed at the iteration
@code{(@var{iter(1)} - 1) * @var{restart} + @var{iter(2)}}.
Since the output @var{x} corresponds to the minimal preconditioned
residual solution, the total number of iterations that
the method performed is given by @code{length (resvec) - 1}.
@item @var{resvec} is a vector containing the preconditioned
relative residual at each iteration, including the 0-th iteration
@code{norm (@var{A} * @var{x0} - @var{b})}.
@end itemize
Let us consider a trivial problem with a tridiagonal matrix
@example
@group
n = 20;
A = toeplitz (sparse ([1, 1], [1, 2], [2, 1] * n ^ 2, 1, n)) + ...
toeplitz (sparse (1, 2, -1, 1, n) * n / 2, ...
sparse (1, 2, 1, 1, n) * n / 2);
b = A * ones (n, 1);
restart = 5;
[M1, M2] = ilu (A); # in this tridiag case, it corresponds to lu (A)
M = M1 * M2;
Afcn = @@(x) A * x;
Mfcn = @@(x) M \ x;
M1fcn = @@(x) M1 \ x;
M2fcn = @@(x) M2 \ x;
@end group
@end example
@sc{Example 1:} simplest usage of @code{gmres}
@example
x = gmres (A, b, [], [], n)
@end example
@sc{Example 2:} @code{gmres} with a function which computes
@code{@var{A} * @var{x}}
@example
x = gmres (Afcn, b, [], [], n)
@end example
@sc{Example 3:} usage of @code{gmres} with the restart
@example
x = gmres (A, b, restart);
@end example
@sc{Example 4:} @code{gmres} with a preconditioner matrix @var{M}
with and without restart
@example
@group
x = gmres (A, b, [], 1e-06, n, M)
x = gmres (A, b, restart, 1e-06, n, M)
@end group
@end example
@sc{Example 5:} @code{gmres} with a function as preconditioner
@example
x = gmres (Afcn, b, [], 1e-6, n, Mfcn)
@end example
@sc{Example 6:} @code{gmres} with preconditioner matrices @var{M1}
and @var{M2}
@example
x = gmres (A, b, [], 1e-6, n, M1, M2)
@end example
@sc{Example 7:} @code{gmres} with functions as preconditioners
@example
x = gmres (Afcn, b, 1e-6, n, M1fcn, M2fcn)
@end example
@sc{Example 8:} @code{gmres} with as input a function requiring an argument
@example
@group
function y = Ap (A, x, p) # compute A^p * x
y = x;
for i = 1:p
y = A * y;
endfor
endfunction
Apfcn = @@(x, p) Ap (A, x, p);
x = gmres (Apfcn, b, [], [], [], [], [], [], 2);
@end group
@end example
@sc{Example 9:} explicit example to show that @code{gmres} uses a
left preconditioner
@example
@group
[M1, M2] = ilu (A + 0.1 * eye (n)); # factorization of A perturbed
M = M1 * M2;
## reference solution computed by gmres after two iterations
[x_ref, fl] = gmres (A, b, [], [], 1, M)
## left preconditioning
[x, fl] = gmres (M \ A, M \ b, [], [], 1)
x # compare x and x_ref
@end group
@end example
Reference:
@nospell{Y. Saad}, @cite{Iterative Methods for Sparse Linear
Systems}, Second edition, 2003, SIAM
@xseealso{@ref{XREFbicg,,bicg}, @ref{XREFbicgstab,,bicgstab}, @ref{XREFcgs,,cgs}, @ref{XREFpcg,,pcg}, @ref{XREFpcr,,pcr}, @ref{XREFqmr,,qmr}, @ref{XREFtfqmr,,tfqmr}}
@end deftypefn
@c qmr scripts/sparse/qmr.m
@anchor{XREFqmr}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{x} =} qmr (@var{A}, @var{b}, @var{rtol}, @var{maxit}, @var{M1}, @var{M2}, @var{x0})
@deftypefnx {} {@var{x} =} qmr (@var{A}, @var{b}, @var{rtol}, @var{maxit}, @var{P})
@deftypefnx {} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} qmr (@var{A}, @var{b}, @dots{})
Solve @code{A x = b} using the Quasi-Minimal Residual iterative method
(without look-ahead).
@itemize @minus
@item @var{rtol} is the relative tolerance, if not given or set to [] the
default value 1e-6 is used.
@item @var{maxit} the maximum number of outer iterations, if not given or
set to [] the default value @code{min (20, numel (b))} is used.
@item @var{x0} the initial guess, if not given or set to [] the default
value @code{zeros (size (b))} is used.
@end itemize
@var{A} can be passed as a matrix or as a function handle or inline
function @code{f} such that @code{f(x, "notransp") = A*x} and
@code{f(x, "transp") = A'*x}.
The preconditioner @var{P} is given as @code{P = M1 * M2}. Both @var{M1}
and @var{M2} can be passed as a matrix or as a function handle or inline
function @code{g} such that @code{g(x, "notransp") = M1 \ x} or
@code{g(x, "notransp") = M2 \ x} and @code{g(x, "transp") = M1' \ x} or
@code{g(x, "transp") = M2' \ x}.
If called with more than one output parameter
@itemize @minus
@item @var{flag} indicates the exit status:
@itemize @minus
@item 0: iteration converged to the within the chosen tolerance
@item 1: the maximum number of iterations was reached before convergence
@item 3: the algorithm reached stagnation
@end itemize
(the value 2 is unused but skipped for compatibility).
@item @var{relres} is the final value of the relative residual.
@item @var{iter} is the number of iterations performed.
@item @var{resvec} is a vector containing the residual norms at each
iteration.
@end itemize
References:
@enumerate
@item
@nospell{R. Freund and N. Nachtigal}, @cite{QMR: a quasi-minimal residual
method for non-Hermitian linear systems}, @nospell{Numerische Mathematik},
1991, 60, pp.@: 315--339.
@item
@nospell{ R. Barrett, M. Berry, T. Chan, J. Demmel, J. Donato, J. Dongarra},
@nospell{ V. Eijkhour, R. Pozo, C. Romine, and H. van der Vorst},
@cite{Templates for the solution of linear systems: Building blocks
for iterative methods}, SIAM, 2nd ed., 1994.
@end enumerate
@xseealso{@ref{XREFbicg,,bicg}, @ref{XREFbicgstab,,bicgstab}, @ref{XREFcgs,,cgs}, @ref{XREFgmres,,gmres}, @ref{XREFpcg,,pcg}}
@end deftypefn
@c tfqmr scripts/sparse/tfqmr.m
@anchor{XREFtfqmr}
@html
<span style="display:block; margin-top:-4.5ex;"> </span>
@end html
@deftypefn {} {@var{x} =} tfqmr (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M1}, @var{M2}, @var{x0}, @dots{})
@deftypefnx {} {@var{x} =} tfqmr (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{M}, [], @var{x0}, @dots{})
@deftypefnx {} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} tfqmr (@var{A}, @var{b}, @dots{})
Solve @code{A x = b} using the Transpose-Tree qmr method, based on the cgs.
The input parameters are:
@itemize @minus
@item @var{A} is the matrix of the linear system and it must be square.
@var{A} can be passed as a matrix, function handle, or inline
function @code{Afcn} such that @code{Afcn(x) = A * x}. Additional
parameters to @code{Afcn} are passed after @var{x0}.
@item @var{b} is the right hand side vector. It must be a column vector
with the same number of rows as @var{A}.
@item @var{tol} is the relative tolerance, if not given or set to [] the
default value 1e-6 is used.
@item @var{maxit} the maximum number of outer iterations, if not given or
set to [] the default value @code{min (20, numel (b))} is used. To be
compatible, since the method as different behaviors in the iteration
number is odd or even, is considered as iteration in @code{tfqmr} the
entire odd-even cycle. That is, to make an entire iteration, the algorithm
performs two sub-iterations: the odd one and the even one.
@item @var{M1}, @var{M2} are the preconditioners. The preconditioner
@var{M} is given as @code{M = M1 * M2}.
Both @var{M1} and @var{M2} can be passed as a matrix or as a function
handle or inline function @code{g} such that @code{g(x) = M1 \ x} or
@code{g(x) = M2 \ x}.
The technique used is the right-preconditioning, i.e., it is solved
@code{A*inv(M)*y = b} and then @code{x = inv(M)*y}, instead of
@code{A x = b}.
@item @var{x0} the initial guess, if not given or set to [] the default
value @code{zeros (size (b))} is used.
@end itemize
The arguments which follow @var{x0} are treated as parameters, and passed in
a proper way to any of the functions (@var{A} or @var{M}) which are passed
to @code{tfqmr}.
The output parameters are:
@itemize @minus
@item @var{x} is the approximation computed. If the method doesn't
converge then it is the iterated with the minimum residual.
@item @var{flag} indicates the exit status:
@itemize @minus
@item 0: iteration converged to the within the chosen tolerance
@item 1: the maximum number of iterations was reached before convergence
@item 2: the preconditioner matrix is singular
@item 3: the algorithm reached stagnation
@item 4: the algorithm can't continue due to a division by zero
@end itemize
@item @var{relres} is the relative residual obtained as
@code{(@var{A}*@var{x}-@var{b}) / @code{norm (@var{b})}}.
@item @var{iter} is the iteration which @var{x} is
computed.
@item @var{resvec} is a vector containing the residual at each iteration
(including @code{norm (b - A x0)}).
Doing @code{length (@var{resvec}) - 1} is possible to see the
total number of iterations performed.
@end itemize
Let us consider a trivial problem with a tridiagonal matrix
@smallexample
@group
n = 20;
A = toeplitz (sparse ([1, 1], [1, 2], [2, 1] * n ^ 2, 1, n)) + ...
toeplitz (sparse (1, 2, -1, 1, n) * n / 2, ...
sparse (1, 2, 1, 1, n) * n / 2);
b = A * ones (n, 1);
restart = 5;
[M1, M2] = ilu (A); # in this tridiag case it corresponds to chol (A)'
M = M1 * M2;
Afcn = @@(x) A * x;
Mfcn = @@(x) M \ x;
M1fcn = @@(x) M1 \ x;
M2fcn = @@(x) M2 \ x;
@end group
@end smallexample
@sc{Example 1:} simplest usage of @code{tfqmr}
@example
x = tfqmr (A, b, [], n)
@end example
@sc{Example 2:} @code{tfqmr} with a function which computes
@code{@var{A} * @var{x}}
@example
x = tfqmr (Afcn, b, [], n)
@end example
@sc{Example 3:} @code{tfqmr} with a preconditioner matrix @var{M}
@example
x = tfqmr (A, b, [], 1e-06, n, M)
@end example
@sc{Example 4:} @code{tfqmr} with a function as preconditioner
@example
x = tfqmr (Afcn, b, 1e-6, n, Mfcn)
@end example
@sc{Example 5:} @code{tfqmr} with preconditioner matrices @var{M1}
and @var{M2}
@example
x = tfqmr (A, b, [], 1e-6, n, M1, M2)
@end example
@sc{Example 6:} @code{tfmqr} with functions as preconditioners
@example
x = tfqmr (Afcn, b, 1e-6, n, M1fcn, M2fcn)
@end example
@sc{Example 7:} @code{tfqmr} with as input a function requiring an argument
@example
@group
function y = Ap (A, x, z) # compute A^z * x
y = x;
for i = 1:z
y = A * y;
endfor
endfunction
Apfcn = @@(x, string, p) Ap (A, x, string, p);
x = tfqmr (Apfcn, b, [], [], [], [], [], 2);
@end group
@end example
@sc{Example 8:} explicit example to show that @code{tfqmr} uses a
right preconditioner
@example
@group
[M1, M2] = ilu (A + 0.3 * eye (n)); # factorization of A perturbed
M = M1 * M2;
## reference solution computed by tfqmr after one iteration
[x_ref, fl] = tfqmr (A, b, [], 1, M)
## right preconditioning
[y, fl] = tfqmr (A / M, b, [], 1)
x = M \ y # compare x and x_ref
@end group
@end example
Reference:
@nospell{Y. Saad}, @cite{Iterative Methods for Sparse Linear Systems},
Second edition, 2003, SIAM
@xseealso{@ref{XREFbicg,,bicg}, @ref{XREFbicgstab,,bicgstab}, @ref{XREFcgs,,cgs}, @ref{XREFgmres,,gmres}, @ref{XREFpcg,,pcg}, @ref{XREFqmr,,qmr}, @ref{XREFpcr,,pcr}}
@end deftypefn
|