/usr/lib/perl5/PDL/LinearAlgebra/Real.pm is in libpdl-linearalgebra-perl 0.08-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 | #
# GENERATED WITH PDL::PP! Don't modify!
#
package PDL::LinearAlgebra::Real;
@EXPORT_OK = qw( PDL::PP gesvd PDL::PP gesdd PDL::PP ggsvd PDL::PP geev PDL::PP geevx PDL::PP ggev PDL::PP ggevx PDL::PP gees PDL::PP geesx PDL::PP gges PDL::PP ggesx PDL::PP syev PDL::PP syevd PDL::PP syevx PDL::PP syevr PDL::PP sygv PDL::PP sygvd PDL::PP sygvx PDL::PP gesv PDL::PP gesvx PDL::PP sysv PDL::PP sysvx PDL::PP posv PDL::PP posvx PDL::PP gels PDL::PP gelsy PDL::PP gelss PDL::PP gelsd PDL::PP gglse PDL::PP ggglm PDL::PP getrf PDL::PP getf2 PDL::PP sytrf PDL::PP sytf2 PDL::PP potrf PDL::PP potf2 PDL::PP getri PDL::PP sytri PDL::PP potri PDL::PP trtri PDL::PP trti2 PDL::PP getrs PDL::PP sytrs PDL::PP potrs PDL::PP trtrs PDL::PP latrs PDL::PP gecon PDL::PP sycon PDL::PP pocon PDL::PP trcon PDL::PP geqp3 PDL::PP geqrf PDL::PP orgqr PDL::PP ormqr PDL::PP gelqf PDL::PP orglq PDL::PP ormlq PDL::PP geqlf PDL::PP orgql PDL::PP ormql PDL::PP gerqf PDL::PP orgrq PDL::PP ormrq PDL::PP tzrzf PDL::PP ormrz PDL::PP gehrd PDL::PP orghr PDL::PP hseqr PDL::PP trevc PDL::PP tgevc PDL::PP gebal PDL::PP gebak PDL::PP lange PDL::PP lansy PDL::PP lantr PDL::PP gemm PDL::PP mmult PDL::PP crossprod PDL::PP syrk PDL::PP dot PDL::PP axpy PDL::PP nrm2 PDL::PP asum PDL::PP scal PDL::PP rot PDL::PP rotg PDL::PP lasrt PDL::PP lacpy PDL::PP laswp PDL::PP lamch PDL::PP labad PDL::PP tricpy PDL::PP cplx_eigen PDL::PP augment PDL::PP mstack PDL::PP charpol );
%EXPORT_TAGS = (Func=>[@EXPORT_OK]);
use PDL::Core;
use PDL::Exporter;
use DynaLoader;
$PDL::LinearAlgebra::Real::VERSION = '0.08';
@ISA = ( 'PDL::Exporter','DynaLoader' );
push @PDL::Core::PP, __PACKAGE__;
bootstrap PDL::LinearAlgebra::Real $VERSION;
use strict;
{
package PDL;
my $warningFlag;
BEGIN{
$warningFlag = $^W;
$^W = 0;
}
use overload (
'x' => sub {PDL::mmult($_[0], $_[1])},
);
BEGIN{ $^W = $warningFlag;}
}
=encoding Latin-1
=head1 NAME
PDL::LinearAlgebra::Real - PDL interface to the real lapack linear algebra programming library
=head1 SYNOPSIS
use PDL::LinearAlgebra::Real;
$a = random (100,100);
$s = zeroes(100);
$u = zeroes(100,100);
$v = zeroes(100,100);
$info = 0;
$job = 0;
gesdd($a, $job, $info, $s , $u, $v);
Blas vector routine use increment.
=head1 DESCRIPTION
This module provides an interface to parts of the real lapack library.
These routines accept either float or double piddles.
=head1 FUNCTIONS
=cut
=head2 gesvd
=for sig
Signature: ([io,phys]A(m,n); int jobu(); int jobvt(); [o,phys]s(r); [o,phys]U(p,q); [o,phys]VT(s,t); int [o,phys]info())
=for ref
Computes the singular value decomposition (SVD) of a real
M-by-N matrix A.
The SVD is written
A = U * SIGMA * V'
where SIGMA is an M-by-N matrix which is zero except for its
min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and
V is an N-by-N orthogonal matrix. The diagonal elements of SIGMA
are the singular values of A; they are real and non-negative, and
are returned in descending order. The first min(m,n) columns of
U and V are the left and right singular vectors of A.
Note that the routine returns VT = V', not V.
jobu: Specifies options for computing all or part of the matrix U:
= 0: no columns of U (no left singular vectors) are
computed.
= 1: all M columns of U are returned in array U:
= 2: the first min(m,n) columns of U (the left singular
vectors) are returned in the array U;
= 3: the first min(m,n) columns of U (the left singular
vectors) are overwritten on the array A;
jobvt: Specifies options for computing all or part of the matrix
V':
= 0: no rows of V' (no right singular vectors) are
computed.
= 1: all N rows of V' are returned in the array VT;
= 2: the first min(m,n) rows of V' (the right singular
vectors) are returned in the array VT;
= 3: the first min(m,n) rows of V' (the right singular
vectors) are overwritten on the array A;
jobvt and jobu cannot both be 3.
A: On entry, the M-by-N matrix A.
On exit,
if jobu = 3, A is overwritten with the first min(m,n)
columns of U (the left singular vectors,
stored columnwise);
if jobvt = 3, A is overwritten with the first min(m,n)
rows of V' (the right singular vectors,
stored rowwise);
if jobu != 3 and jobvt != 3, the contents of A
are destroyed.
s: The singular values of A, sorted so that s(i) >= s(i+1).
U: If jobu = 1, U contains the M-by-M orthogonal matrix U;
if jobu = 3, U contains the first min(m,n) columns of U
(the left singular vectors, stored columnwise);
if jobu = 0 or 3, U is not referenced.
Min size = [1,1].
VT: If jobvt = 1, VT contains the N-by-N orthogonal matrix
V';
if jobvt = 2, VT contains the first min(m,n) rows of
V' (the right singular vectors, stored rowwise);
if jobvt = 0 or 3, VT is not referenced.
Min size = [1,1].
info: = 0: successful exit.
< 0: if info = -i, the i-th argument had an illegal value.
> 0: if bdsqr did not converge, info specifies how many
superdiagonals of an intermediate bidiagonal form B
did not converge to zero.
=for example
$a = random (float, 100,100);
$s = zeroes(float, 100);
$u = zeroes(float, 100,100);
$vt = zeroes(float, 100,100);
$info = pdl(long, 0);
gesvd($a, 2, 2, $s , $u, $vt, $info);
=for bad
gesvd ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gesvd = \&PDL::gesvd;
=head2 gesdd
=for sig
Signature: ([io,phys]A(m,n); int job(); [o,phys]s(r); [o,phys]U(p,q); [o,phys]VT(s,t); int [o,phys]info())
=for ref
Computes the singular value decomposition (SVD) of a real
M-by-N matrix A.
This routine use the Coppen's divide and conquer algorithm.
It is much faster than the simple driver for large matrices, but uses more workspace.
job: Specifies options for computing all or part of matrix:
= 0: no columns of U or rows of V' are computed;
= 1: all M columns of U and all N rows of V' are
returned in the arrays U and VT;
= 2: the first min(M,N) columns of U and the first
min(M,N) rows of V' are returned in the arrays U
and VT;
= 3: If M >= N, the first N columns of U are overwritten
on the array A and all rows of V' are returned in
the array VT;
otherwise, all columns of U are returned in the
array U and the first M rows of V' are overwritten
on the array A.
A: On entry, the M-by-N matrix A.
On exit,
if job = 3, A is overwritten with the first N columns
of U (the left singular vectors, stored
columnwise) if M >= N;
A is overwritten with the first M rows
of V' (the right singular vectors, stored
rowwise) otherwise.
if job != 3, the contents of A are destroyed.
s: The singular values of A, sorted so that s(i) >= s(i+1).
U: If job = 1 or job = 3 and M < N, U contains the M-by-M
orthogonal matrix U;
if job = 2, U contains the first min(M,N) columns of U
(the left singular vectors, stored columnwise);
if job = 3 and M >= N, or job = 0, U is not referenced.
Min size = [1,1].
VT: If job = 1 or job = 3 and M >= N, VT contains the
N-by-N orthogonal matrix V';
if job = 2, VT contains the first min(M,N) rows of
V' (the right singular vectors, stored rowwise);
if job = 3 and M < N, or job = 0, VT is not referenced.
Min size = [1,1].
info: = 0: successful exit.
< 0: if info = -i, the i-th argument had an illegal value.
> 0: bdsdc did not converge, updating process failed.
=for example
$lines = 50;
$columns = 100;
$a = random (float, $lines, $columns);
$min = $lines < $columns ? $lines : $columns;
$s = zeroes(float, $min);
$u = zeroes(float, $lines, $lines);
$vt = zeroes(float, $columns, $columns);
$info = long (0);
gesdd($a, 1, $s , $u, $vt, $info);
=for bad
gesdd ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gesdd = \&PDL::gesdd;
=head2 ggsvd
=for sig
Signature: ([io,phys]A(m,n); int jobu(); int jobv(); int jobq(); [io,phys]B(p,n); int [o,phys]k(); int [o,phys]l();[o,phys]alpha(n);[o,phys]beta(n); [o,phys]U(q,r); [o,phys]V(s,t); [o,phys]Q(u,v); int [o,phys]iwork(n); int [o,phys]info())
=for ref
Computes the generalized singular value decomposition (GSVD)
of an M-by-N real matrix A and P-by-N real matrix B:
U'*A*Q = D1*( 0 R ), V'*B*Q = D2*( 0 R )
where U, V and Q are orthogonal matrices, and Z' is the transpose
of Z.
Let K+L = the effective numerical rank of the matrix (A',B')',
then R is a K+L-by-K+L nonsingular upper triangular matrix, D1 and
D2 are M-by-(K+L) and P-by-(K+L) "diagonal" matrices and of the
following structures, respectively:
If M-K-L >= 0,
K L
D1 = K ( I 0 )
L ( 0 C )
M-K-L ( 0 0 )
K L
D2 = L ( 0 S )
P-L ( 0 0 )
N-K-L K L
( 0 R ) = K ( 0 R11 R12 )
L ( 0 0 R22 )
where
C = diag( ALPHA(K+1), ... , ALPHA(K+L) ),
S = diag( BETA(K+1), ... , BETA(K+L) ),
C**2 + S**2 = I.
R is stored in A(1:K+L,N-K-L+1:N) on exit.
If M-K-L < 0,
K M-K K+L-M
D1 = K ( I 0 0 )
M-K ( 0 C 0 )
K M-K K+L-M
D2 = M-K ( 0 S 0 )
K+L-M ( 0 0 I )
P-L ( 0 0 0 )
N-K-L K M-K K+L-M
( 0 R ) = K ( 0 R11 R12 R13 )
M-K ( 0 0 R22 R23 )
K+L-M ( 0 0 0 R33 )
where
C = diag( ALPHA(K+1), ... , ALPHA(M) ),
S = diag( BETA(K+1), ... , BETA(M) ),
C**2 + S**2 = I.
(R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), and R33 is stored
( 0 R22 R23 )
in B(M-K+1:L,N+M-K-L+1:N) on exit.
The routine computes C, S, R, and optionally the orthogonal
transformation matrices U, V and Q.
In particular, if B is an N-by-N nonsingular matrix, then the GSVD of
A and B implicitly gives the SVD of A*inv(B):
A*inv(B) = U*(D1*inv(D2))*V'.
If ( A',B')' has orthonormal columns, then the GSVD of A and B is
also equal to the CS decomposition of A and B. Furthermore, the GSVD
can be used to derive the solution of the eigenvalue problem:
A'*A x = lambda* B'*B x.
In some literature, the GSVD of A and B is presented in the form
U'*A*X = ( 0 D1 ), V'*B*X = ( 0 D2 )
where U and V are orthogonal and X is nonsingular, D1 and D2 are "diagonal".
The former GSVD form can be converted to the latter
form by taking the nonsingular matrix X as
X = Q*( I 0 )
( 0 inv(R) ).
Arguments
=========
jobu: = 0: U is not computed.
= 1: Orthogonal matrix U is computed;
jobv: = 0: V is not computed.
= 1: Orthogonal matrix V is computed;
jobq: = 0: Q is not computed.
= 1: Orthogonal matrix Q is computed;
k:
l: On exit, k and l specify the dimension of the subblocks
described in the Purpose section.
k + l = effective numerical rank of (A',B')'.
A: On entry, the M-by-N matrix A.
On exit, A contains the triangular matrix R, or part of R.
B: On entry, the P-by-N matrix B.
On exit, B contains the triangular matrix R if M-k-l < 0.
alpha:
beta: On exit, alpha and beta contain the generalized singular
value pairs of A and B;
alpha(1:k) = 1,
beta(1:k) = 0,
and if M-k-l >= 0,
alpha(k+1:k+l) = C,
beta(k+1:k+l) = S,
or if M-k-l < 0,
alpha(k+1:M)=C, alpha(M+1:k+l)=0
beta(k+1:M) =S, beta(M+1:k+l) =1
and
alpha(k+l+1:N) = 0
beta(k+l+1:N) = 0
U: If jobu = 1, U contains the M-by-M orthogonal matrix U.
If jobu = 0, U is not referenced.
Need a minimum array of (1,1) if jobu = 0;
V: If jobv = 1, V contains the P-by-P orthogonal matrix V.
If jobv = 0, V is not referenced.
Need a minimum array of (1,1) if jobv = 0;
Q: If jobq = 1, Q contains the N-by-N orthogonal matrix Q.
If jobq = 0, Q is not referenced.
Need a minimum array of (1,1) if jobq = 0;
iwork: On exit, iwork stores the sorting information. More
precisely, the following loop will sort alpha
for I = k+1, min(M,k+l)
swap alpha(I) and alpha(iwork(I))
endfor
such that alpha(1) >= alpha(2) >= ... >= alpha(N).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
> 0: if info = 1, the Jacobi-type procedure failed to
converge. For further details, see subroutine tgsja.
=for example
$k = null;
$l = null;
$A = random(5,6);
$B = random(7,6);
$alpha = zeroes(6);
$beta = zeroes(6);
$U = zeroes(5,5);
$V = zeroes(7,7);
$Q = zeroes(6,6);
$iwork = zeroes(long, 6);
$info = null;
ggsvd($A,1,1,1,$B,$k,$l,$alpha, $beta,$U, $V, $Q, $iwork,$info);
=for bad
ggsvd ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*ggsvd = \&PDL::ggsvd;
=head2 geev
=for sig
Signature: ([phys]A(n,n); int jobvl(); int jobvr(); [o,phys]wr(n); [o,phys]wi(n); [o,phys]vl(m,m); [o,phys]vr(p,p); int [o,phys]info())
=for ref
Computes for an N-by-N real nonsymmetric matrix A, the
eigenvalues and, optionally, the left and/or right eigenvectors.
The right eigenvector v(j) of A satisfies:
A * v(j) = lambda(j) * v(j)
where lambda(j) is its eigenvalue.
The left eigenvector u(j) of A satisfies:
u(j)**H * A = lambda(j) * u(j)**H
where u(j)**H denotes the conjugate transpose of u(j).
The computed eigenvectors are normalized to have Euclidean norm
equal to 1 and largest component real.
Arguments
=========
jobvl: = 0: left eigenvectors of A are not computed;
= 1: left eigenvectors of A are computed.
jobvr: = 0: right eigenvectors of A are not computed;
= 1: right eigenvectors of A are computed.
A: A is overwritten.
wr:
wi: wr and wi contain the real and imaginary parts,
respectively, of the computed eigenvalues. Complex
conjugate pairs of eigenvalues appear consecutively
with the eigenvalue having the positive imaginary part
first.
vl: If jobvl = 1, the left eigenvectors u(j) are stored one
after another in the columns of vl, in the same order
as their eigenvalues else vl is not referenced.
If the j-th eigenvalue is real, then u(j) = vl(:,j),
the j-th column of vl.
If the j-th and (j+1)-st eigenvalues form a complex
conjugate pair, then u(j) = vl(:,j) + i*vl(:,j+1) and
u(j+1) = vl(:,j) - i*vl(:,j+1).
Min size = [1].
vr: If jobvr = 1, the right eigenvectors v(j) are stored one
after another in the columns of vr, in the same order
as their eigenvalues else vr is not referenced.
If the j-th eigenvalue is real, then v(j) = vr(:,j),
the j-th column of vr.
If the j-th and (j+1)-st eigenvalues form a complex
conjugate pair, then v(j) = vr(:,j) + i*vr(:,j+1) and
v(j+1) = vr(:,j) - i*vr(:,j+1).
Min size = [1].
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
> 0: if info = i, the QR algorithm failed to compute all the
eigenvalues, and no eigenvectors have been computed;
elements i+1:N of wr and wi contain eigenvalues which
have converged.
=for example
$a = random (5, 5);
$wr = zeroes(5);
$wi = zeroes($wr);
$vl = zeroes($a);
$vr = zeroes($a);
$info = null;
geev($a, 1, 1, $wr, $wi, $vl, $vr, $info);
=for bad
geev ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*geev = \&PDL::geev;
=head2 geevx
=for sig
Signature: ([io,phys]A(n,n); int jobvl(); int jobvr(); int balance(); int sense(); [o,phys]wr(n); [o,phys]wi(n); [o,phys]vl(m,m); [o,phys]vr(p,p); int [o,phys]ilo(); int [o,phys]ihi(); [o,phys]scale(n); [o,phys]abnrm(); [o,phys]rconde(q); [o,phys]rcondv(r); int [o,phys]info())
=for ref
Computes for an N-by-N real nonsymmetric matrix A, the
eigenvalues and, optionally, the left and/or right eigenvectors.
Optionally also, it computes a balancing transformation to improve
the conditioning of the eigenvalues and eigenvectors (ilo, ihi,
scale, and abnrm), reciprocal condition numbers for the eigenvalues
(rconde), and reciprocal condition numbers for the right
eigenvectors (rcondv).
The right eigenvector v(j) of A satisfies:
A * v(j) = lambda(j) * v(j)
where lambda(j) is its eigenvalue.
The left eigenvector u(j) of A satisfies:
u(j)**H * A = lambda(j) * u(j)**H
where u(j)**H denotes the conjugate transpose of u(j).
The computed eigenvectors are normalized to have Euclidean norm
equal to 1 and largest component real.
Balancing a matrix means permuting the rows and columns to make it
more nearly upper triangular, and applying a diagonal similarity
transformation D * A * D**(-1), where D is a diagonal matrix, to
make its rows and columns closer in norm and the condition numbers
of its eigenvalues and eigenvectors smaller. The computed
reciprocal condition numbers correspond to the balanced matrix.
Permuting rows and columns will not change the condition numbers
(in exact arithmetic) but diagonal scaling will. For further
explanation of balancing, see section 4.10.2 of the LAPACK
Users' Guide.
Arguments
=========
balance:
Indicates how the input matrix should be diagonally scaled
and/or permuted to improve the conditioning of its
eigenvalues.
= 0: Do not diagonally scale or permute;
= 1: Perform permutations to make the matrix more nearly
upper triangular. Do not diagonally scale;
= 2: Diagonally scale the matrix, i.e. replace A by
D*A*D**(-1), where D is a diagonal matrix chosen
to make the rows and columns of A more equal in
norm. Do not permute;
= 3: Both diagonally scale and permute A.
Computed reciprocal condition numbers will be for the matrix
after balancing and/or permuting. Permuting does not change
condition numbers (in exact arithmetic), but balancing does.
jobvl: = 0: left eigenvectors of A are not computed;
= 1: left eigenvectors of A are computed.
If sense = 1 or 3, jobvl must = 1.
jobvr; = 0: right eigenvectors of A are not computed;
= 1: right eigenvectors of A are computed.
If sense = 1 or 3, jobvr must = 1.
sense: Determines which reciprocal condition numbers are computed.
= 0: None are computed;
= 1: Computed for eigenvalues only;
= 2: Computed for right eigenvectors only;
= 3: Computed for eigenvalues and right eigenvectors.
If sense = 1 or 3, both left and right eigenvectors
must also be computed (jobvl = 1 and jobvr = 1).
A: The N-by-N matrix.
It is overwritten. If jobvl = 1 or
jobvr = 1, A contains the real Schur form of the balanced
version of the input matrix A.
wr
wi: wr and wi contain the real and imaginary parts,
respectively, of the computed eigenvalues. Complex
conjugate pairs of eigenvalues will appear consecutively
with the eigenvalue having the positive imaginary part
first.
vl: If jobvl = 1, the left eigenvectors u(j) are stored one
after another in the columns of vl, in the same order
as their eigenvalues else vl is not referenced.
If the j-th eigenvalue is real, then u(j) = vl(:,j),
the j-th column of vl.
If the j-th and (j+1)-st eigenvalues form a complex
conjugate pair, then u(j) = vl(:,j) + i*vl(:,j+1) and
u(j+1) = vl(:,j) - i*vl(:,j+1).
Min size = [1].
vr: If jobvr = 1, the right eigenvectors v(j) are stored one
after another in the columns of vr, in the same order
as their eigenvalues else vr is not referenced.
If the j-th eigenvalue is real, then v(j) = vr(:,j),
the j-th column of vr.
If the j-th and (j+1)-st eigenvalues form a complex
conjugate pair, then v(j) = vr(:,j) + i*vr(:,j+1) and
v(j+1) = vr(:,j) - i*vr(:,j+1).
Min size = [1].
ilo,ihi:Integer values determined when A was
balanced. The balanced A(i,j) = 0 if I > J and
J = 1,...,ilo-1 or I = ihi+1,...,N.
scale: Details of the permutations and scaling factors applied
when balancing A. If P(j) is the index of the row and column
interchanged with row and column j, and D(j) is the scaling
factor applied to row and column j, then
scale(J) = P(J), for J = 1,...,ilo-1
= D(J), for J = ilo,...,ihi
= P(J) for J = ihi+1,...,N.
The order in which the interchanges are made is N to ihi+1,
then 1 to ilo-1.
abnrm: The one-norm of the balanced matrix (the maximum
of the sum of absolute values of elements of any column).
rconde: rconde(j) is the reciprocal condition number of the j-th
eigenvalue.
rcondv: rcondv(j) is the reciprocal condition number of the j-th
right eigenvector.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
> 0: if info = i, the QR algorithm failed to compute all the
eigenvalues, and no eigenvectors or condition numbers
have been computed; elements 1:ilo-1 and i+1:N of wr
and wi contain eigenvalues which have converged.
=for example
$a = random (5,5);
$wr = zeroes(5);
$wi = zeroes(5);
$vl = zeroes(5,5);
$vr = zeroes(5,5);
$ilo = null;
$ihi = null;
$scale = zeroes(5);
$abnrm = null;
$rconde = zeroes(5);
$rcondv = zeroes(5);
$info = null;
geevx($a, 1,1,3,3,$wr, $wi, $vl, $vr, $ilo, $ihi, $scale, $abnrm,$rconde, $rcondv, $info);
=for bad
geevx ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*geevx = \&PDL::geevx;
=head2 ggev
=for sig
Signature: ([phys]A(n,n); int jobvl();int jobvr();[phys]B(n,n);[o,phys]alphar(n);[o,phys]alphai(n);[o,phys]beta(n);[o,phys]VL(m,m);[o,phys]VR(p,p);int [o,phys]info())
=for ref
Computes for a pair of N-by-N real nonsymmetric matrices (A,B)
the generalized eigenvalues, and optionally, the left and/or right
generalized eigenvectors.
A generalized eigenvalue for a pair of matrices (A,B) is a scalar
lambda or a ratio alpha/beta = lambda, such that A - lambda*B is
singular. It is usually represented as the pair (alpha,beta), as
there is a reasonable interpretation for beta=0, and even for both
being zero.
The right eigenvector v(j) corresponding to the eigenvalue lambda(j)
of (A,B) satisfies
A * v(j) = lambda(j) * B * v(j).
The left eigenvector u(j) corresponding to the eigenvalue lambda(j)
of (A,B) satisfies
u(j)**H * A = lambda(j) * u(j)**H * B .
where u(j)**H is the conjugate-transpose of u(j).
Arguments
=========
jobvl: = 0: do not compute the left generalized eigenvectors;
= 1: compute the left generalized eigenvectors.
jobvr: = 0: do not compute the right generalized eigenvectors;
= 1: compute the right generalized eigenvectors.
A: On entry, the matrix A in the pair (A,B).
On exit, A has been overwritten.
B: On entry, the matrix B in the pair (A,B).
On exit, B has been overwritten.
alphar:
alphai:
beta: On exit, (alphar(j) + alphai(j)*i)/beta(j), j=1,...,N, will
be the generalized eigenvalues. If alphai(j) is zero, then
the j-th eigenvalue is real; if positive, then the j-th and
(j+1)-st eigenvalues are a complex conjugate pair, with
alphai(j+1) negative.
Note: the quotients alphar(j)/beta(j) and alphai(j)/beta(j)
may easily over- or underflow, and beta(j) may even be zero.
Thus, the user should avoid naively computing the ratio
alpha/beta. However, alphar and alphai will be always less
than and usually comparable with norm(A) in magnitude, and
beta always less than and usually comparable with norm(B).
VL: If jobvl = 1, the left eigenvectors u(j) are stored one
after another in the columns of VL, in the same order as
their eigenvalues. If the j-th eigenvalue is real, then
u(j) = VL(:,j), the j-th column of VL. If the j-th and
(j+1)-th eigenvalues form a complex conjugate pair, then
u(j) = VL(:,j)+i*VL(:,j+1) and u(j+1) = VL(:,j)-i*VL(:,j+1).
Each eigenvector will be scaled so the largest component have
abs(real part)+abs(imag. part)=1.
Not referenced if jobvl = 0.
VR: If jobvr = 1, the right eigenvectors v(j) are stored one
after another in the columns of VR, in the same order as
their eigenvalues. If the j-th eigenvalue is real, then
v(j) = VR(:,j), the j-th column of VR. If the j-th and
(j+1)-th eigenvalues form a complex conjugate pair, then
v(j) = VR(:,j)+i*VR(:,j+1) and v(j+1) = VR(:,j)-i*VR(:,j+1).
Each eigenvector will be scaled so the largest component have
abs(real part)+abs(imag. part)=1.
Not referenced if jobvr = 0.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
= 1,...,N:
The QZ iteration failed. No eigenvectors have been
calculated, but alphar(j), alphai(j), and beta(j)
should be correct for j=info+1,...,N.
> N: =N+1: other than QZ iteration failed in hgeqz.
=N+2: error return from tgevc.
=for example
$a = random(5,5);
$b = random(5,5);
$alphar = zeroes(5);
$alphai = zeroes(5);
$beta = zeroes(5);
$vl = zeroes(5,5);
$vr = zeroes(5,5);
ggev($a, 1, 1, $b, $alphar, $alphai, $beta, $vl, $vr, ($info=null));
=for bad
ggev ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*ggev = \&PDL::ggev;
=head2 ggevx
=for sig
Signature: ([io,phys]A(n,n);int balanc();int jobvl();int jobvr();int sense();[io,phys]B(n,n);[o,phys]alphar(n);[o,phys]alphai(n);[o,phys]beta(n);[o,phys]VL(m,m);[o,phys]VR(p,p);int [o,phys]ilo();int [o,phys]ihi();[o,phys]lscale(n);[o,phys]rscale(n);[o,phys]abnrm();[o,phys]bbnrm();[o,phys]rconde(r);[o,phys]rcondv(s);int [o,phys]info())
=for ref
Computes for a pair of N-by-N real nonsymmetric matrices (A,B)
the generalized eigenvalues, and optionally, the left and/or right
generalized eigenvectors.
Optionally also, it computes a balancing transformation to improve
the conditioning of the eigenvalues and eigenvectors (ilo, ihi,
lscale, rscale, abnrm, and bbnrm), reciprocal condition numbers for
the eigenvalues (rconde), and reciprocal condition numbers for the
right eigenvectors (rcondv).
A generalized eigenvalue for a pair of matrices (A,B) is a scalar
lambda or a ratio alpha/beta = lambda, such that A - lambda*B is
singular. It is usually represented as the pair (alpha,beta), as
there is a reasonable interpretation for beta=0, and even for both
being zero.
The right eigenvector v(j) corresponding to the eigenvalue lambda(j)
of (A,B) satisfies
A * v(j) = lambda(j) * B * v(j) .
The left eigenvector u(j) corresponding to the eigenvalue lambda(j)
of (A,B) satisfies
u(j)**H * A = lambda(j) * u(j)**H * B.
where u(j)**H is the conjugate-transpose of u(j).
Further Details
===============
Balancing a matrix pair (A,B) includes, first, permuting rows and
columns to isolate eigenvalues, second, applying diagonal similarity
transformation to the rows and columns to make the rows and columns
as close in norm as possible. The computed reciprocal condition
numbers correspond to the balanced matrix. Permuting rows and columns
will not change the condition numbers (in exact arithmetic) but
diagonal scaling will. For further explanation of balancing, see
section 4.11.1.2 of LAPACK Users' Guide.
An approximate error bound on the chordal distance between the i-th
computed generalized eigenvalue w and the corresponding exact
eigenvalue lambda is
chord(w, lambda) <= EPS * norm(abnrm, bbnrm) / rconde(I)
An approximate error bound for the angle between the i-th computed
eigenvector vl(i) or vr(i) is given by
EPS * norm(abnrm, bbnrm) / DIF(i).
For further explanation of the reciprocal condition numbers rconde
and rcondv, see section 4.11 of LAPACK User's Guide.
Arguments
=========
balanc: Specifies the balance option to be performed.
= 0: do not diagonally scale or permute;
= 1: permute only;
= 2: scale only;
= 3: both permute and scale.
Computed reciprocal condition numbers will be for the
matrices after permuting and/or balancing. Permuting does
not change condition numbers (in exact arithmetic), but
balancing does.
jobvl: = 0: do not compute the left generalized eigenvectors;
= 1: compute the left generalized eigenvectors.
jobvr: = 0: do not compute the right generalized eigenvectors;
= 1: compute the right generalized eigenvectors.
sense: Determines which reciprocal condition numbers are computed.
= 0: none are computed;
= 1: computed for eigenvalues only;
= 2: computed for eigenvectors only;
= 3: computed for eigenvalues and eigenvectors.
A: On entry, the matrix A in the pair (A,B).
On exit, A has been overwritten. If jobvl=1 or jobvr=1
or both, then A contains the first part of the real Schur
form of the "balanced" versions of the input A and B.
B: On entry, the matrix B in the pair (A,B).
On exit, B has been overwritten. If jobvl=1 or jobvr=1
or both, then B contains the second part of the real Schur
form of the "balanced" versions of the input A and B.
alphar:
alphai:
beta: On exit, (alphar(j) + alphai(j)*i)/beta(j), j=1,...,N, will
be the generalized eigenvalues. If alphai(j) is zero, then
the j-th eigenvalue is real; if positive, then the j-th and
(j+1)-st eigenvalues are a complex conjugate pair, with
alphai(j+1) negative.
Note: the quotients alphar(j)/beta(j) and alphai(j)/beta(j)
may easily over- or underflow, and beta(j) may even be zero.
Thus, the user should avoid naively computing the ratio
ALPHA/beta. However, alphar and alphai will be always less
than and usually comparable with norm(A) in magnitude, and
beta always less than and usually comparable with norm(B).
vl: If jobvl = 1, the left eigenvectors u(j) are stored one
after another in the columns of vl, in the same order as
their eigenvalues. If the j-th eigenvalue is real, then
u(j) = vl(:,j), the j-th column of vl. If the j-th and
(j+1)-th eigenvalues form a complex conjugate pair, then
u(j) = vl(:,j)+i*vl(:,j+1) and u(j+1) = vl(:,j)-i*vl(:,j+1).
Each eigenvector will be scaled so the largest component have
abs(real part) + abs(imag. part) = 1.
Not referenced if jobvl = 0.
vr: If jobvr = 1, the right eigenvectors v(j) are stored one
after another in the columns of vr, in the same order as
their eigenvalues. If the j-th eigenvalue is real, then
v(j) = vr(:,j), the j-th column of vr. If the j-th and
(j+1)-th eigenvalues form a complex conjugate pair, then
v(j) = vr(:,j)+i*vr(:,j+1) and v(j+1) = vr(:,j)-i*vr(:,j+1).
Each eigenvector will be scaled so the largest component have
abs(real part) + abs(imag. part) = 1.
Not referenced if jobvr = 0.
ilo,ihi:ilo and ihi are integer values such that on exit
A(i,j) = 0 and B(i,j) = 0 if i > j and
j = 1,...,ilo-1 or i = ihi+1,...,N.
If balanc = 0 or 2, ilo = 1 and ihi = N.
lscale: Details of the permutations and scaling factors applied
to the left side of A and B. If PL(j) is the index of the
row interchanged with row j, and DL(j) is the scaling
factor applied to row j, then
lscale(j) = PL(j) for j = 1,...,ilo-1
= DL(j) for j = ilo,...,ihi
= PL(j) for j = ihi+1,...,N.
The order in which the interchanges are made is N to ihi+1,
then 1 to ilo-1.
rscale: Details of the permutations and scaling factors applied
to the right side of A and B. If PR(j) is the index of the
column interchanged with column j, and DR(j) is the scaling
factor applied to column j, then
rscale(j) = PR(j) for j = 1,...,ilo-1
= DR(j) for j = ilo,...,ihi
= PR(j) for j = ihi+1,...,N
The order in which the interchanges are made is N to ihi+1,
then 1 to ilo-1.
abnrm: The one-norm of the balanced matrix A.
bbnrm: The one-norm of the balanced matrix B.
rconde: If sense = 1 or 3, the reciprocal condition numbers of
the selected eigenvalues, stored in consecutive elements of
the array. For a complex conjugate pair of eigenvalues two
consecutive elements of rconde are set to the same value.
Thus rconde(j), rcondv(j), and the j-th columns of vl and vr
all correspond to the same eigenpair (but not in general the
j-th eigenpair, unless all eigenpairs are selected).
If sense = 2, rconde is not referenced.
rcondv: If sense = 2 or 3, the estimated reciprocal condition
numbers of the selected eigenvectors, stored in consecutive
elements of the array. For a complex eigenvector two
consecutive elements of rcondv are set to the same value. If
the eigenvalues cannot be reordered to compute rcondv(j),
rcondv(j) is set to 0; this can only occur when the true
value would be very small anyway.
If sense = 1, rcondv is not referenced.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
= 1,...,N:
The QZ iteration failed. No eigenvectors have been
calculated, but alphar(j), alphai(j), and beta(j)
should be correct for j=info+1,...,N.
> N: =N+1: other than QZ iteration failed in hgeqz.
=N+2: error return from tgevc.
=for example
$a = random(5,5);
$b = random(5,5);
$alphar = zeroes(5);
$alphai = zeroes(5);
$beta = zeroes(5);
$vl = zeroes(5,5);
$vr = zeroes(5,5);
$lscale = zeroes(5);
$rscale = zeroes(5);
$ilo = null;
$ihi = null;
$abnrm = null;
$bbnrm = null;
$rconde = zeroes(5);
$rcondv = zeroes(5);
ggevx($a, 3, 1, 1, 3, $b, $alphar, $alphai, $beta, $vl, $vr,
$ilo, $ihi, $lscale, $rscale, $abnrm, $bbnrm, $rconde,$rcondv,($info=null));
=for bad
ggevx ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*ggevx = \&PDL::ggevx;
=head2 gees
=for sig
Signature: ([io,phys]A(n,n); int jobvs(); int sort(); [o,phys]wr(n); [o,phys]wi(n); [o,phys]vs(p,p); int [o,phys]sdim(); int [o,phys]info(); SV* select_func)
=for ref
Computes for an N-by-N real nonsymmetric matrix A, the
eigenvalues, the real Schur form T, and, optionally, the matrix of
Schur vectors Z. This gives the Schur factorization A = Z*T*Z'.
Optionally, it also orders the eigenvalues on the diagonal of the
real Schur form so that selected eigenvalues are at the top left.
The leading columns of Z then form an orthonormal basis for the
invariant subspace corresponding to the selected eigenvalues.
A matrix is in real Schur form if it is upper quasi-triangular with
1-by-1 and 2-by-2 blocks. 2-by-2 blocks will be standardized in the
form
[ a b ]
[ c a ]
where b*c < 0.
The eigenvalues of such a block are a +- sqrt(bc).
Arguments
=========
jobvs: = 0: Schur vectors are not computed;
= 1: Schur vectors are computed.
sort: Specifies whether or not to order the eigenvalues on the
diagonal of the Schur form.
= 0: Eigenvalues are not ordered;
= 1: Eigenvalues are ordered (see select_func).
select_func:
If sort = 1, select_func is used to select eigenvalues to sort
to the top left of the Schur form.
If sort = 0, select_func is not referenced.
An eigenvalue wr(j)+sqrt(-1)*wi(j) is selected if
select_func(SCALAR(wr(j)), SCALAR(wi(j))) is true; i.e.,
if either one of a complex conjugate pair of eigenvalues
is selected, then both complex eigenvalues are selected.
Note that a selected complex eigenvalue may no longer
satisfy select_func(wr(j),wi(j)) = 1 after ordering, since
ordering may change the value of complex eigenvalues
(especially if the eigenvalue is ill-conditioned); in this
case info is set to N+2 (see info below).
A: The N-by-N matrix A.
On exit, A has been overwritten by its real Schur form T.
sdim: If sort = 0, sdim = 0.
If sort = 1, sdim = number of eigenvalues (after sorting)
for which select_func is true. (Complex conjugate
pairs for which select_func is true for either
eigenvalue count as 2.)
wr:
wi: wr and wi contain the real and imaginary parts,
respectively, of the computed eigenvalues in the same order
that they appear on the diagonal of the output Schur form T.
Complex conjugate pairs of eigenvalues will appear
consecutively with the eigenvalue having the positive
imaginary part first.
vs: If jobvs = 1, vs contains the orthogonal matrix Z of Schur
vectors else vs is not referenced.
info = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
> 0: if info = i, and i is
<= N: the QR algorithm failed to compute all the
eigenvalues; elements 1:ILO-1 and i+1:N of wr and wi
contain those eigenvalues which have converged; if
jobvs = 1, vs contains the matrix which reduces A
to its partially converged Schur form.
= N+1: the eigenvalues could not be reordered because some
eigenvalues were too close to separate (the problem
is very ill-conditioned);
= N+2: after reordering, roundoff changed values of some
complex eigenvalues so that leading eigenvalues in
the Schur form no longer satisfy select_func = 1 This
could also be caused by underflow due to scaling.
=for example
sub select_function{
my ($a, $b ) = @_;
# Stable "continuous time" eigenspace
return $a < 0 ? 1 : 0;
}
$A = random (5,5);
$wr= zeroes(5);
$wi = zeroes(5);
$vs = zeroes(5,5);
$sdim = null;
$info = null;
gees($A, 1,1, $wr, $wi, $vs, $sdim, $info,\&select_function);
=for bad
gees ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gees = \&PDL::gees;
=head2 geesx
=for sig
Signature: ([io,phys]A(n,n); int jobvs(); int sort(); int sense(); [o,phys]wr(n); [o,phys]wi(n); [o,phys]vs(p,p); int [o,phys]sdim(); [o,phys]rconde();[o,phys]rcondv(); int [o,phys]info(); SV* select_func)
=for ref
Computes for an N-by-N real nonsymmetric matrix A, the
eigenvalues, the real Schur form T, and, optionally, the matrix of
Schur vectors Z. This gives the Schur factorization A = Z*T*Z'.
Optionally, it also orders the eigenvalues on the diagonal of the
real Schur form so that selected eigenvalues are at the top left;
computes a reciprocal condition number for the average of the
selected eigenvalues (rconde); and computes a reciprocal condition
number for the right invariant subspace corresponding to the
selected eigenvalues (rcondv). The leading columns of Z form an
orthonormal basis for this invariant subspace.
For further explanation of the reciprocal condition numbers rconde
and rcondv, see Section 4.10 of the LAPACK Users' Guide (where
these quantities are called s and sep respectively).
A real matrix is in real Schur form if it is upper quasi-triangular
with 1-by-1 and 2-by-2 blocks. 2-by-2 blocks will be standardized in
the form
[ a b ]
[ c a ]
where b*c < 0. The eigenvalues of such a block are a +- sqrt(bc).
Arguments
=========
jobvs: = 0: Schur vectors are not computed;
= 1: Schur vectors are computed.
sort: Specifies whether or not to order the eigenvalues on the
diagonal of the Schur form.
= 0: Eigenvalues are not ordered;
= 1: Eigenvalues are ordered (see select_func).
select_func:
If sort = 1, select_func is used to select eigenvalues to sort
to the top left of the Schur form else select_func is not referenced.
An eigenvalue wr(j)+sqrt(-1)*wi(j) is selected if
select_func(wr(j),wi(j)) is true; i.e., if either one of a
complex conjugate pair of eigenvalues is selected, then both
are. Note that a selected complex eigenvalue may no longer
satisfy select_func(wr(j),wi(j)) = 1 after ordering, since
ordering may change the value of complex eigenvalues
(especially if the eigenvalue is ill-conditioned); in this
case info may be set to N+3 (see info below).
sense: Determines which reciprocal condition numbers are computed.
= 0: None are computed;
= 1: Computed for average of selected eigenvalues only;
= 2: Computed for selected right invariant subspace only;
= 3: Computed for both.
If sense = 1, 2 or 3, sort must equal 1.
A: On entry, the N-by-N matrix A.
On exit, A is overwritten by its real Schur form T.
sdim: If sort = 0, sdim = 0.
If sort = 1, sdim = number of eigenvalues (after sorting)
for which select_func is 1. (Complex conjugate
pairs for which select_func is 1 for either
eigenvalue count as 2.)
wr:
wi: wr and wi contain the real and imaginary parts, respectively,
of the computed eigenvalues, in the same order that they
appear on the diagonal of the output Schur form T. Complex
conjugate pairs of eigenvalues appear consecutively with the
eigenvalue having the positive imaginary part first.
vs If jobvs = 1, vs contains the orthogonal matrix Z of Schur
vectors else vs is not referenced.
rconde: If sense = 1 or 3, rconde contains the reciprocal
condition number for the average of the selected eigenvalues.
Not referenced if sense = 0 or 2.
rcondv: If sense = 2 or 3, rcondv contains the reciprocal
condition number for the selected right invariant subspace.
Not referenced if sense = 0 or 1.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
> 0: if info = i, and i is
<= N: the QR algorithm failed to compute all the
eigenvalues; elements 1:ilo-1 and i+1:N of wr and wi
contain those eigenvalues which have converged; if
jobvs = 1, vs contains the transformation which
reduces A to its partially converged Schur form.
= N+1: the eigenvalues could not be reordered because some
eigenvalues were too close to separate (the problem
is very ill-conditioned);
= N+2: after reordering, roundoff changed values of some
complex eigenvalues so that leading eigenvalues in
the Schur form no longer satisfy select_func=1 This
could also be caused by underflow due to scaling.
=for example
sub select_function{
my ($a, $b) = @_;
# Stable "discrete time" eigenspace
return sqrt($a**2 + $b**2) < 1 ? 1 : 0;
}
$A = random (5,5);
$wr= zeroes(5);
$wi = zeroes(5);
$vs = zeroes(5,5);
$sdim = null;
$rconde = null;
$rcondv = null;
$info = null;
geesx($A, 1,1, 3, $wr, $wi, $vs, $sdim, $rconde, $rcondv, $info, \&select_function);
=for bad
geesx ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*geesx = \&PDL::geesx;
=head2 gges
=for sig
Signature: ([io,phys]A(n,n); int jobvsl();int jobvsr();int sort();[io,phys]B(n,n);[o,phys]alphar(n);[o,phys]alphai(n);[o,phys]beta(n);[o,phys]VSL(m,m);[o,phys]VSR(p,p);int [o,phys]sdim();int [o,phys]info(); SV* select_func)
=for ref
Computes for a pair of N-by-N real nonsymmetric matrices (A,B),
the generalized eigenvalues, the generalized real Schur form (S,T),
optionally, the left and/or right matrices of Schur vectors (VSL and
VSR). This gives the generalized Schur factorization
(A,B) = ( (VSL)*S*(VSR)', (VSL)*T*(VSR)' )
Optionally, it also orders the eigenvalues so that a selected cluster
of eigenvalues appears in the leading diagonal blocks of the upper
quasi-triangular matrix S and the upper triangular matrix T.The
leading columns of VSL and VSR then form an orthonormal basis for the
corresponding left and right eigenspaces (deflating subspaces).
(If only the generalized eigenvalues are needed, use the driver
ggev instead, which is faster.)
A generalized eigenvalue for a pair of matrices (A,B) is a scalar w
or a ratio alpha/beta = w, such that A - w*B is singular. It is
usually represented as the pair (alpha,beta), as there is a
reasonable interpretation for beta=0 or both being zero.
A pair of matrices (S,T) is in generalized real Schur form if T is
upper triangular with non-negative diagonal and S is block upper
triangular with 1-by-1 and 2-by-2 blocks. 1-by-1 blocks correspond
to real generalized eigenvalues, while 2-by-2 blocks of S will be
"standardized" by making the corresponding elements of T have the
form:
[ a 0 ]
[ 0 b ]
and the pair of corresponding 2-by-2 blocks in S and T will have a
complex conjugate pair of generalized eigenvalues.
Arguments
=========
jobvsl: = 0: do not compute the left Schur vectors;
= 1: compute the left Schur vectors.
jobvsr: = 0: do not compute the right Schur vectors;
= 1: compute the right Schur vectors.
sort: Specifies whether or not to order the eigenvalues on the
diagonal of the generalized Schur form.
= 0: Eigenvalues are not ordered;
= 1: Eigenvalues are ordered (see delztg);
delztg: If sort = 0, delztg is not referenced.
If sort = 1, delztg is used to select eigenvalues to sort
to the top left of the Schur form.
An eigenvalue (alphar(j)+alphai(j))/beta(j) is selected if
delztg(alphar(j),alphai(j),beta(j)) is true; i.e. if either
one of a complex conjugate pair of eigenvalues is selected,
then both complex eigenvalues are selected.
Note that in the ill-conditioned case, a selected complex
eigenvalue may no longer satisfy delztg(alphar(j),alphai(j),
beta(j)) = 1 after ordering. info is to be set to N+2
in this case.
A: On entry, the first of the pair of matrices.
On exit, A has been overwritten by its generalized Schur
form S.
B: On entry, the second of the pair of matrices.
On exit, B has been overwritten by its generalized Schur
form T.
sdim: If sort = 0, sdim = 0.
If sort = 1, sdim = number of eigenvalues (after sorting)
for which delztg is true. (Complex conjugate pairs for which
delztg is true for either eigenvalue count as 2.)
alphar:
alphai:
beta: On exit, (alphar(j) + alphai(j)*i)/beta(j), j=1,...,N, will
be the generalized eigenvalues. alphar(j) + alphai(j)*i,
and beta(j),j=1,...,N are the diagonals of the complex Schur
form (S,T) that would result if the 2-by-2 diagonal blocks of
the real Schur form of (A,B) were further reduced to
triangular form using 2-by-2 complex unitary transformations.
If alphai(j) is zero, then the j-th eigenvalue is real; if
positive, then the j-th and (j+1)-st eigenvalues are a
complex conjugate pair, with alphai(j+1) negative.
Note: the quotients alphar(j)/beta(j) and alphai(j)/beta(j)
may easily over- or underflow, and beta(j) may even be zero.
Thus, the user should avoid naively computing the ratio.
However, alphar and alphai will be always less than and
usually comparable with norm(A) in magnitude, and beta always
less than and usually comparable with norm(B).
VSL: If jobvsl = 1, VSL will contain the left Schur vectors.
Not referenced if jobvsl = 0.
The leading dimension must always be >=1.
VSR: If jobvsr = 1, VSR will contain the right Schur vectors.
Not referenced if jobvsr = 0.
The leading dimension must always be >=1.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
= 1,...,N:
The QZ iteration failed. (A,B) are not in Schur
form, but alphar(j), alphai(j), and beta(j) should
be correct for j=info+1,...,N.
> N: =N+1: other than QZ iteration failed in hgeqz.
=N+2: after reordering, roundoff changed values of
some complex eigenvalues so that leading
eigenvalues in the Generalized Schur form no
longer satisfy delztg=1 This could also
be caused due to scaling.
=N+3: reordering failed in tgsen.
=for example
sub my_select{
my ($zr, $zi, $d) = @_;
# stable generalized eigenvalues for continuous time
return ( ($zr < 0 && $d > 0 ) || ($zr > 0 && $d < 0) ) ? 1 : 0;
}
$a = random(5,5);
$b = random(5,5);
$sdim = null;
$alphar = zeroes(5);
$alphai = zeroes(5);
$beta = zeroes(5);
$vsl = zeroes(5,5);
$vsr = zeroes(5,5);
gges($a, 1, 1, 1, $b, $alphar, $alphai, $beta, $vsl, $vsr, $sdim,($info=null), \&my_select);
=for bad
gges ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gges = \&PDL::gges;
=head2 ggesx
=for sig
Signature: ([io,phys]A(n,n); int jobvsl();int jobvsr();int sort();int sense();[io,phys]B(n,n);[o,phys]alphar(n);[o,phys]alphai(n);[o,phys]beta(n);[o,phys]VSL(m,m);[o,phys]VSR(p,p);int [o,phys]sdim();[o,phys]rconde(q);[o,phys]rcondv(r);int [o,phys]info(); SV* select_func)
=for ref
Computes for a pair of N-by-N real nonsymmetric matrices
(A,B), the generalized eigenvalues, the real Schur form (S,T), and,
optionally, the left and/or right matrices of Schur vectors (VSL and
VSR). This gives the generalized Schur factorization
(A,B) = ( (VSL) S (VSR)', (VSL) T (VSR)' )
Optionally, it also orders the eigenvalues so that a selected cluster
of eigenvalues appears in the leading diagonal blocks of the upper
quasi-triangular matrix S and the upper triangular matrix T; computes
a reciprocal condition number for the average of the selected
eigenvalues (RCONDE); and computes a reciprocal condition number for
the right and left deflating subspaces corresponding to the selected
eigenvalues (RCONDV). The leading columns of VSL and VSR then form
an orthonormal basis for the corresponding left and right eigenspaces
(deflating subspaces).
A generalized eigenvalue for a pair of matrices (A,B) is a scalar w
or a ratio alpha/beta = w, such that A - w*B is singular. It is
usually represented as the pair (alpha,beta), as there is a
reasonable interpretation for beta=0 or for both being zero.
A pair of matrices (S,T) is in generalized real Schur form if T is
upper triangular with non-negative diagonal and S is block upper
triangular with 1-by-1 and 2-by-2 blocks. 1-by-1 blocks correspond
to real generalized eigenvalues, while 2-by-2 blocks of S will be
"standardized" by making the corresponding elements of T have the
form:
[ a 0 ]
[ 0 b ]
and the pair of corresponding 2-by-2 blocks in S and T will have a
complex conjugate pair of generalized eigenvalues.
Further details
===============
An approximate (asymptotic) bound on the average absolute error of
the selected eigenvalues is
EPS * norm((A, B)) / RCONDE( 1 ).
An approximate (asymptotic) bound on the maximum angular error in
the computed deflating subspaces is
EPS * norm((A, B)) / RCONDV( 2 ).
See LAPACK User's Guide, section 4.11 for more information.
Arguments
=========
jobvsl: = 0: do not compute the left Schur vectors;
= 1: compute the left Schur vectors.
jobvsr: = 0: do not compute the right Schur vectors;
= 1: compute the right Schur vectors.
sort: Specifies whether or not to order the eigenvalues on the
diagonal of the generalized Schur form.
= 0: Eigenvalues are not ordered;
= 1: Eigenvalues are ordered (see delztg);
delztg: If sort = 0, delztg is not referenced.
If sort = 1, delztg is used to select eigenvalues to sort
to the top left of the Schur form.
An eigenvalue (alphar(j)+alphai(j))/beta(j) is selected if
delztg(alphar(j),alphai(j),beta(j)) is true; i.e. if either
one of a complex conjugate pair of eigenvalues is selected,
then both complex eigenvalues are selected.
Note that in the ill-conditioned case, a selected complex
eigenvalue may no longer satisfy delztg(alphar(j),alphai(j),
beta(j)) = 1 after ordering. info is to be set to N+2
in this case.
sense: Determines which reciprocal condition numbers are computed.
= 0 : None are computed;
= 1 : Computed for average of selected eigenvalues only;
= 2 : Computed for selected deflating subspaces only;
= 3 : Computed for both.
If sense = 1, 2, or 3, sort must equal 1.
A: On entry, the first of the pair of matrices.
On exit, A has been overwritten by its generalized Schur
form S.
B: On entry, the second of the pair of matrices.
On exit, B has been overwritten by its generalized Schur
form T.
sdim: If sort = 0, sdim = 0.
If sort = 1, sdim = number of eigenvalues (after sorting)
for which delztg is true. (Complex conjugate pairs for which
delztg is true for either eigenvalue count as 2.)
alphar:
alphai:
beta: On exit, (alphar(j) + alphai(j)*i)/beta(j), j=1,...,N, will
be the generalized eigenvalues. alphar(j) + alphai(j)*i,
and beta(j),j=1,...,N are the diagonals of the complex Schur
form (S,T) that would result if the 2-by-2 diagonal blocks of
the real Schur form of (A,B) were further reduced to
triangular form using 2-by-2 complex unitary transformations.
If alphai(j) is zero, then the j-th eigenvalue is real; if
positive, then the j-th and (j+1)-st eigenvalues are a
complex conjugate pair, with alphai(j+1) negative.
Note: the quotients alphar(j)/beta(j) and alphai(j)/beta(j)
may easily over- or underflow, and beta(j) may even be zero.
Thus, the user should avoid naively computing the ratio.
However, alphar and alphai will be always less than and
usually comparable with norm(A) in magnitude, and beta always
less than and usually comparable with norm(B).
VSL: If jobvsl = 1, VSL will contain the left Schur vectors.
Not referenced if jobvsl = 0.
The leading dimension must always be >=1.
VSR: If jobvsr = 1, VSR will contain the right Schur vectors.
Not referenced if jobvsr = 0.
The leading dimension must always be >=1.
rconde: If sense = 1 or 3, rconde(1) and rconde(2) contain the
reciprocal condition numbers for the average of the selected
eigenvalues.
Not referenced if sense = 0 or 2.
rcondv: If sense = 2 or 3, rcondv(1) and rcondv(2) contain the
reciprocal condition numbers for the selected deflating
subspaces.
Not referenced if sense = 0 or 1.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
= 1,...,N:
The QZ iteration failed. (A,B) are not in Schur
form, but alphar(j), alphai(j), and beta(j) should
be correct for j=info+1,...,N.
> N: =N+1: other than QZ iteration failed in hgeqz.
=N+2: after reordering, roundoff changed values of
some complex eigenvalues so that leading
eigenvalues in the Generalized Schur form no
longer satisfy delztg=1 This could also
be caused due to scaling.
=N+3: reordering failed in tgsen.
=for example
sub my_select{
my ($zr, $zi, $d) = @_;
# Eigenvalue : (ZR/D) + sqrt(-1)*(ZI/D)
# stable generalized eigenvalues for discrete time
return (sqrt($zr**2 + $zi**2) < abs($d) ) ? 1 : 0;
}
$a = random(5,5);
$b = random(5,5);
$sdim = null;
$alphar = zeroes(5);
$alphai = zeroes(5);
$beta = zeroes(5);
$vsl = zeroes(5,5);
$vsr = zeroes(5,5);
$rconde = zeroes(2);
$rcondv = zeroes(2);
ggesx($a, 1, 1, 1, 3,$b, $alphar, $alphai, $beta, $vsl, $vsr, $sdim, $rconde, $rcondv, ($info=null), \&my_select);
=for bad
ggesx ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*ggesx = \&PDL::ggesx;
=head2 syev
=for sig
Signature: ([io,phys]A(n,n); int jobz(); int uplo(); [o,phys]w(n); int [o,phys]info())
=for ref
Computes all eigenvalues and, optionally, eigenvectors of a
real symmetric matrix A.
Arguments
=========
jobz: = 0: Compute eigenvalues only;
= 1: Compute eigenvalues and eigenvectors.
uplo = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A. If uplo = 0, the
leading N-by-N upper triangular part of A contains the
upper triangular part of the matrix A. If uplo = 1,
the leading N-by-N lower triangular part of A contains
the lower triangular part of the matrix A.
On exit, if jobz = 1, then if info = 0, A contains the
orthonormal eigenvectors of the matrix A.
If jobz = 0, then on exit the lower triangle (if uplo=1)
or the upper triangle (if uplo=0) of A, including the
diagonal, is destroyed.
w: If info = 0, the eigenvalues in ascending order.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, the algorithm failed to converge; i
off-diagonal elements of an intermediate tridiagonal
form did not converge to zero.
=for example
# Assume $a is symmetric ;)
$a = random (5,5);
syev($a, 1,1, (my $w = zeroes(5)), (my $info=null));
=for bad
syev ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*syev = \&PDL::syev;
=head2 syevd
=for sig
Signature: ([io,phys]A(n,n); int jobz(); int uplo(); [o,phys]w(n); int [o,phys]info())
=for ref
Computes all eigenvalues and, optionally, eigenvectors of a
real symmetric matrix A. If eigenvectors are desired, it uses a
divide and conquer algorithm.
The divide and conquer algorithm makes very mild assumptions about
floating point arithmetic. It will work on machines with a guard
digit in add/subtract, or on those binary machines without guard
digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
Cray-2. It could conceivably fail on hexadecimal or decimal machines
without guard digits, but we know of none.
Because of large use of BLAS of level 3, syevd needs N**2 more
workspace than syevx.
Arguments
=========
jobz: = 0: Compute eigenvalues only;
= 1: Compute eigenvalues and eigenvectors.
uplo = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A. If uplo = 0, the
leading N-by-N upper triangular part of A contains the
upper triangular part of the matrix A. If uplo = 1,
the leading N-by-N lower triangular part of A contains
the lower triangular part of the matrix A.
On exit, if jobz = 1, then if info = 0, A contains the
orthonormal eigenvectors of the matrix A.
If jobz = 0, then on exit the lower triangle (if uplo=1)
or the upper triangle (if uplo=0) of A, including the
diagonal, is destroyed.
w: If info = 0, the eigenvalues in ascending order.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, the algorithm failed to converge; i
off-diagonal elements of an intermediate tridiagonal
form did not converge to zero.
=for example
# Assume $a is symmetric ;)
$a = random (5,5);
syevd($a, 1,1, (my $w = zeroes(5)), (my $info=null));
=for bad
syevd ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*syevd = \&PDL::syevd;
=head2 syevx
=for sig
Signature: ([phys]A(n,n); int jobz(); int range(); int uplo(); [phys]vl(); [phys]vu(); int [phys]il(); int [phys]iu(); [phys]abstol(); int [o,phys]m(); [o,phys]w(n); [o,phys]z(p,q);int [o,phys]ifail(r); int [o,phys]info())
=for ref
Computes selected eigenvalues and, optionally, eigenvectors
of a real symmetric matrix A. Eigenvalues and eigenvectors can be
selected by specifying either a range of values or a range of indices
for the desired eigenvalues.
Arguments
=========
jobz: = 0: Compute eigenvalues only;
= 1: Compute eigenvalues and eigenvectors.
range: = 0: all eigenvalues will be found.
= 1: all eigenvalues in the half-open interval (vl,vu]
will be found.
= 1: the il-th through iu-th eigenvalues will be found.
uplo = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A. If uplo = 0, the
leading N-by-N upper triangular part of A contains the
upper triangular part of the matrix A. If uplo = 1,
the leading N-by-N lower triangular part of A contains
the lower triangular part of the matrix A.
On exit, the lower triangle (if uplo=1) or the upper
triangle (if uplo=0) of A, including the diagonal, is
destroyed.
vl:
vu: If range=1, the lower and upper bounds of the interval to
be searched for eigenvalues. vl < vu.
Not referenced if range = 0 or 2.
il:
iu: If range=2, the indices (in ascending order) of the
smallest and largest eigenvalues to be returned.
1 <= il <= iu <= N, if N > 0; il = 1 and iu = 0 if N = 0.
Not referenced if range = 0 or 1.
abstol: The absolute error tolerance for the eigenvalues.
An approximate eigenvalue is accepted as converged
when it is determined to lie in an interval [a,b]
of width less than or equal to
abstol + EPS * max( |a|,|b| ) ,
where EPS is the machine precision. If abstol is less than
or equal to zero, then EPS*|T| will be used in its place,
where |T| is the 1-norm of the tridiagonal matrix obtained
by reducing A to tridiagonal form.
Eigenvalues will be computed most accurately when abstol is
set to twice the underflow threshold 2*lamch(1), not zero.
If this routine returns with info>0, indicating that some
eigenvectors did not converge, try setting abstol to
2*lamch(1).
See "Computing Small Singular Values of Bidiagonal Matrices
with Guaranteed High Relative Accuracy," by Demmel and
Kahan, LAPACK Working Note #3.
m: The total number of eigenvalues found. 0 <= m <= N.
If range = 0, m = N, and if range = 2, m = iu-il+1.
w: On normal exit, the first M elements contain the selected
eigenvalues in ascending order.
z: If jobz = 1, then if info = 0, the first m columns of z
contain the orthonormal eigenvectors of the matrix A
corresponding to the selected eigenvalues, with the i-th
column of z holding the eigenvector associated with w(i).
If an eigenvector fails to converge, then that column of z
contains the latest approximation to the eigenvector, and the
index of the eigenvector is returned in ifail.
If jobz = 0, then z is not referenced.
Note: the user must ensure that at least max(1,m) columns are
supplied in the array z; if range = 1, the exact value of m
is not known in advance and an upper bound must be used.
ifail: If jobz = 1, then if info = 0, the first m elements of
ifail are zero. If info > 0, then ifail contains the
indices of the eigenvectors that failed to converge.
If jobz = 0, then ifail is not referenced.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, then i eigenvectors failed to converge.
Their indices are stored in array ifail.
=for example
# Assume $a is symmetric ;)
$a = random (5,5);
$unfl = lamch(1);
$ovfl = lamch(9);
labad($unfl, $ovfl);
$abstol = $unfl + $unfl;
$m = null;
$info = null;
$ifail = zeroes(5);
$w = zeroes(5);
$z = zeroes(5,5);
syevx($a, 1,0,1,0,0,0,0,$abstol, $m, $w, $z ,$ifail, $info);
=for bad
syevx ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*syevx = \&PDL::syevx;
=head2 syevr
=for sig
Signature: ([phys]A(n,n); int jobz(); int range(); int uplo(); [phys]vl(); [phys]vu(); int [phys]il(); int [phys]iu();[phys]abstol();int [o,phys]m();[o,phys]w(n); [o,phys]z(p,q);int [o,phys]isuppz(r); int [o,phys]info())
=for ref
Computes selected eigenvalues and, optionally, eigenvectors
of a real symmetric matrix T. Eigenvalues and eigenvectors can be
selected by specifying either a range of values or a range of
indices for the desired eigenvalues.
Whenever possible, syevr calls stegr to compute the
eigenspectrum using Relatively Robust Representations. stegr
computes eigenvalues by the dqds algorithm, while orthogonal
eigenvectors are computed from various "good" L D L^T representations
(also known as Relatively Robust Representations). Gram-Schmidt
orthogonalization is avoided as far as possible. More specifically,
the various steps of the algorithm are as follows. For the i-th
unreduced block of T,
(a) Compute T - sigma_i = L_i D_i L_i^T, such that L_i D_i L_i^T
is a relatively robust representation,
(b) Compute the eigenvalues, lambda_j, of L_i D_i L_i^T to high
relative accuracy by the dqds algorithm,
(c) If there is a cluster of close eigenvalues, "choose" sigma_i
close to the cluster, and go to step (a),
(d) Given the approximate eigenvalue lambda_j of L_i D_i L_i^T,
compute the corresponding eigenvector by forming a
rank-revealing twisted factorization.
The desired accuracy of the output can be specified by the input
parameter abstol.
For more details, see "A new O(n^2) algorithm for the symmetric
tridiagonal eigenvalue/eigenvector problem", by Inderjit Dhillon,
Computer Science Division Technical Report No. UCB//CSD-97-971,
UC Berkeley, May 1997.
Note 1 : syevr calls stegr when the full spectrum is requested
on machines which conform to the ieee-754 floating point standard.
syevr calls stebz and stein on non-ieee machines and
when partial spectrum requests are made.
Normal execution of stegr may create NaNs and infinities and
hence may abort due to a floating point exception in environments
which do not handle NaNs and infinities in the ieee standard default
manner.
Arguments
=========
jobz: = 0: Compute eigenvalues only;
= 1: Compute eigenvalues and eigenvectors.
range: = 0: all eigenvalues will be found.
= 1: all eigenvalues in the half-open interval (vl,vu]
will be found.
= 2: the il-th through iu-th eigenvalues will be found.
********* For range = 1 or 2 and iu - il < N - 1, stebz and
********* stein are called
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A. If uplo = 0, the
leading N-by-N upper triangular part of A contains the
upper triangular part of the matrix A. If uplo = 1,
the leading N-by-N lower triangular part of A contains
the lower triangular part of the matrix A.
On exit, the lower triangle (if uplo=1) or the upper
triangle (if uplo=0) of A, including the diagonal, is
destroyed.
vl:
vu: If range=1, the lower and upper bounds of the interval to
be searched for eigenvalues. vl < vu.
Not referenced if range = 0 or 2.
il:
iu: If range=2, the indices (in ascending order) of the
smallest and largest eigenvalues to be returned.
1 <= il <= iu <= N, if N > 0; il = 1 and iu = 0 if N = 0.
Not referenced if range = 0 or 1.
abstol: The absolute error tolerance for the eigenvalues.
An approximate eigenvalue is accepted as converged
when it is determined to lie in an interval [a,b]
of width less than or equal to
abstol + EPS * max( |a|,|b| ) ,
where EPS is the machine precision. If abstol is less than
or equal to zero, then EPS*|T| will be used in its place,
where |T| is the 1-norm of the tridiagonal matrix obtained
by reducing A to tridiagonal form.
See "Computing Small Singular Values of Bidiagonal Matrices
with Guaranteed High Relative Accuracy," by Demmel and
Kahan, LAPACK Working Note #3.
If high relative accuracy is important, set abstol to
lamch(1). Doing so will guarantee that
eigenvalues are computed to high relative accuracy when
possible in future releases. The current code does not
make any guarantees about high relative accuracy, but
furure releases will. See J. Barlow and J. Demmel,
"Computing Accurate Eigensystems of Scaled Diagonally
Dominant Matrices", LAPACK Working Note #7, for a discussion
of which matrices define their eigenvalues to high relative
accuracy.
m: The total number of eigenvalues found. 0 <= m <= N.
If range = 0, m = N, and if range = 2, m = iu-il+1.
w: The first m elements contain the selected eigenvalues in
ascending order.
z: If jobz = 1, then if info = 0, the first m columns of z
contain the orthonormal eigenvectors of the matrix A
corresponding to the selected eigenvalues, with the i-th
column of z holding the eigenvector associated with w(i).
If jobz = 0, then z is not referenced.
Note: the user must ensure that at least max(1,m) columns are
supplied in the array z; if range = 1, the exact value of m
is not known in advance and an upper bound must be used.
isuppz: array of int, dimension ( 2*max(1,m) )
The support of the eigenvectors in z, i.e., the indices
indicating the nonzero elements in z. The i-th eigenvector
is nonzero only in elements isuppz( 2*i-1 ) through
isuppz( 2*i ).
********* Implemented only for range = 0 or 2 and iu - il = N - 1
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: Internal error
=for example
# Assume $a is symmetric ;)
$a = random (5,5);
$unfl = lamch(1);
$ovfl = lamch(9);
labad($unfl, $ovfl);
$abstol = $unfl + $unfl;
$m = null;
$info = null;
$isuppz = zeroes(10);
$w = zeroes(5);
$z = zeroes(5,5);
syevr($a, 1,0,1,0,0,0,0,$abstol, $m, $w, $z ,$isuppz, $info);
=for bad
syevr ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*syevr = \&PDL::syevr;
=head2 sygv
=for sig
Signature: ([io,phys]A(n,n);int [phys]itype();int jobz(); int uplo();[io,phys]B(n,n);[o,phys]w(n); int [o,phys]info())
=for ref
Computes all the eigenvalues, and optionally, the eigenvectors
of a real generalized symmetric-definite eigenproblem, of the form
A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x.
Here A and B are assumed to be symmetric and B is also
positive definite.
Arguments
=========
itype: Specifies the problem type to be solved:
= 1: A*x = (lambda)*B*x
= 2: A*B*x = (lambda)*x
= 3: B*A*x = (lambda)*x
jobz: = 0: Compute eigenvalues only;
= 1: Compute eigenvalues and eigenvectors.
uplo: = 0: Upper triangles of A and B are stored;
= 1: Lower triangles of A and B are stored.
A: On entry, the symmetric matrix A. If uplo = 0, the
leading N-by-N upper triangular part of A contains the
upper triangular part of the matrix A. If uplo = 1,
the leading N-by-N lower triangular part of A contains
the lower triangular part of the matrix A.
On exit, if jobz = 1, then if info = 0, A contains the
matrix Z of eigenvectors. The eigenvectors are normalized
as follows:
if itype = 1 or 2, Z'*B*Z = I;
if itype = 3, Z'*inv(B)*Z = I.
If jobz = 0, then on exit the upper triangle (if uplo=0)
or the lower triangle (if uplo=1) of A, including the
diagonal, is destroyed.
B: On entry, the symmetric positive definite matrix B.
If uplo = 0, the leading N-by-N upper triangular part of B
contains the upper triangular part of the matrix B.
If uplo = 1, the leading N-by-N lower triangular part of B
contains the lower triangular part of the matrix B.
On exit, if info <= N, the part of B containing the matrix is
overwritten by the triangular factor U or L from the Cholesky
factorization B = U'*U or B = L*L'.
W: If info = 0, the eigenvalues in ascending order.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: potrf or syev returned an error code:
<= N: if info = i, syev failed to converge;
i off-diagonal elements of an intermediate
tridiagonal form did not converge to zero;
> N: if info = N + i, for 1 <= i <= N, then the leading
minor of order i of B is not positive definite.
The factorization of B could not be completed and
no eigenvalues or eigenvectors were computed.
=for example
# Assume $a is symmetric ;)
$a = random (5,5);
# Assume $a is symmetric and positive definite ;)
$b = random (5,5);
sygv($a, 1,1, 0, $b, (my $w = zeroes(5)), (my $info=null));
=for bad
sygv ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*sygv = \&PDL::sygv;
=head2 sygvd
=for sig
Signature: ([io,phys]A(n,n);int [phys]itype();int jobz(); int uplo();[io,phys]B(n,n);[o,phys]w(n); int [o,phys]info())
=for ref
Computes all the eigenvalues, and optionally, the eigenvectors
of a real generalized symmetric-definite eigenproblem, of the form
A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x.
Here A and B are assumed to be symmetric and B is also
positive definite.
The divide and conquer algorithm makes very mild assumptions about
floating point arithmetic. It will work on machines with a guard
digit in add/subtract, or on those binary machines without guard
digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
Cray-2. It could conceivably fail on hexadecimal or decimal machines
without guard digits, but we know of none.
Arguments
=========
itype: Specifies the problem type to be solved:
= 1: A*x = (lambda)*B*x
= 2: A*B*x = (lambda)*x
= 3: B*A*x = (lambda)*x
jobz: = 0: Compute eigenvalues only;
= 1: Compute eigenvalues and eigenvectors.
uplo: = 0: Upper triangles of A and B are stored;
= 1: Lower triangles of A and B are stored.
A: On entry, the symmetric matrix A. If uplo = 0, the
leading N-by-N upper triangular part of A contains the
upper triangular part of the matrix A. If uplo = 1,
the leading N-by-N lower triangular part of A contains
the lower triangular part of the matrix A.
On exit, if jobz = 1, then if info = 0, A contains the
matrix Z of eigenvectors. The eigenvectors are normalized
as follows:
if itype = 1 or 2, Z'*B*Z = I;
if itype = 3, Z'*inv(B)*Z = I.
If jobz = 0, then on exit the upper triangle (if uplo=0)
or the lower triangle (if uplo=1) of A, including the
diagonal, is destroyed.
B: On entry, the symmetric positive definite matrix B.
If uplo = 0, the leading N-by-N upper triangular part of B
contains the upper triangular part of the matrix B.
If uplo = 1, the leading N-by-N lower triangular part of B
contains the lower triangular part of the matrix B.
On exit, if info <= N, the part of B containing the matrix is
overwritten by the triangular factor U or L from the Cholesky
factorization B = U'*U or B = L*L'.
W: If info = 0, the eigenvalues in ascending order.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: potrf or syev returned an error code:
<= N: if info = i, syevd failed to converge;
i off-diagonal elements of an intermediate
tridiagonal form did not converge to zero;
> N: if info = N + i, for 1 <= i <= N, then the leading
minor of order i of B is not positive definite.
The factorization of B could not be completed and
no eigenvalues or eigenvectors were computed.
=for example
# Assume $a is symmetric ;)
$a = random (5,5);
# Assume $b is symmetric positive definite ;)
$b = random (5,5);
sygvd($a, 1,1, 0, $b, (my $w = zeroes(5)), (my $info=null));
=for bad
sygvd ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*sygvd = \&PDL::sygvd;
=head2 sygvx
=for sig
Signature: ([io,phys]A(n,n);int [phys]itype();int jobz();int range(); int uplo();[io,phys]B(n,n);[phys]vl();[phys]vu();int [phys]il();int [phys]iu();[phys]abstol();int [o,phys]m();[o,phys]w(n); [o,phys]Z(p,q);int [o,phys]ifail(r);int [o,phys]info())
=for ref
Computes selected eigenvalues, and optionally, eigenvectors
of a real generalized symmetric-definite eigenproblem, of the form
A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A
and B are assumed to be symmetric and B is also positive definite.
Eigenvalues and eigenvectors can be selected by specifying either a
range of values or a range of indices for the desired eigenvalues.
Arguments
=========
itype: Specifies the problem type to be solved:
= 1: A*x = (lambda)*B*x
= 2: A*B*x = (lambda)*x
= 3: B*A*x = (lambda)*x
jobz: = 0: Compute eigenvalues only;
= 1: Compute eigenvalues and eigenvectors.
range: = 0: all eigenvalues will be found.
= 1: all eigenvalues in the half-open interval (vl,vu]
will be found.
= 2: the il-th through iu-th eigenvalues will be found.
uplo: = 0: Upper triangle of A and B are stored;
= 1: Lower triangle of A and B are stored.
A: On entry, the symmetric matrix A. If uplo = 0, the
leading N-by-N upper triangular part of A contains the
upper triangular part of the matrix A. If uplo = 1,
the leading N-by-N lower triangular part of A contains
the lower triangular part of the matrix A.
On exit, the lower triangle (if uplo=1) or the upper
triangle (if uplo=0) of A, including the diagonal, is
destroyed.
B: On entry, the symmetric matrix B. If uplo = 0, the
leading N-by-N upper triangular part of B contains the
upper triangular part of the matrix B. If uplo = 1,
the leading N-by-N lower triangular part of B contains
the lower triangular part of the matrix B.
On exit, if info <= N, the part of B containing the matrix is
overwritten by the triangular factor U or L from the Cholesky
factorization B = U'*U or B = L*L'.
vl:
vu: If range=1, the lower and upper bounds of the interval to
be searched for eigenvalues. vl < vu.
Not referenced if range = 0 or 2.
il:
iu: If range=2, the indices (in ascending order) of the
smallest and largest eigenvalues to be returned.
1 <= il <= iu <= N, if N > 0; il = 1 and iu = 0 if N = 0.
Not referenced if range = 0 or 1.
abstol: The absolute error tolerance for the eigenvalues.
An approximate eigenvalue is accepted as converged
when it is determined to lie in an interval [a,b]
of width less than or equal to
abstol + EPS * max( |a|,|b| ) ,
where EPS is the machine precision. If abstol is less than
or equal to zero, then EPS*|T| will be used in its place,
where |T| is the 1-norm of the tridiagonal matrix obtained
by reducing A to tridiagonal form.
Eigenvalues will be computed most accurately when abstol is
set to twice the underflow threshold 2*lamch(1), not zero.
If this routine returns with info>0, indicating that some
eigenvectors did not converge, try setting abstol to
2* lamch(1).
m: The total number of eigenvalues found. 0 <= m <= N.
If range = 0, m = N, and if range = 2, m = iu-il+1.
w: On normal exit, the first m elements contain the selected
eigenvalues in ascending order.
Z: If jobz = 0, then Z is not referenced.
If jobz = 1, then if info = 0, the first m columns of Z
contain the orthonormal eigenvectors of the matrix A
corresponding to the selected eigenvalues, with the i-th
column of Z holding the eigenvector associated with w(i).
The eigenvectors are normalized as follows:
if itype = 1 or 2, Z'*B*Z = I;
if itype = 3, Z'*inv(B)*Z = I.
If an eigenvector fails to converge, then that column of Z
contains the latest approximation to the eigenvector, and the
index of the eigenvector is returned in ifail.
Note: the user must ensure that at least max(1,m) columns are
supplied in the array Z; if range = 1, the exact value of m
is not known in advance and an upper bound must be used.
ifail: If jobz = 1, then if info = 0, the first M elements of
ifail are zero. If info > 0, then ifail contains the
indices of the eigenvectors that failed to converge.
If jobz = 0, then ifail is not referenced.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: potrf or syevx returned an error code:
<= N: if info = i, syevx failed to converge;
i eigenvectors failed to converge. Their indices
are stored in array ifail.
> N: if info = N + i, for 1 <= i <= N, then the leading
minor of order i of B is not positive definite.
The factorization of B could not be completed and
no eigenvalues or eigenvectors were computed.
=for example
# Assume $a is symmetric ;)
$a = random (5,5);
# Assume $b is symmetric positive definite ;)
$b = random (5,5);
$unfl = lamch(1);
$ovfl = lamch(9);
labad($unfl, $ovfl);
$abstol = $unfl + $unfl;
$m = null;
$w=zeroes(5);
$z = zeroes(5,5);
$ifail = zeroes(5);
sygvx($a, 1,1, 0,0, $b, 0, 0, 0, 0, $abstol, $m, $w, $z,$ifail,(my $info=null));
=for bad
sygvx ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*sygvx = \&PDL::sygvx;
=head2 gesv
=for sig
Signature: ([io,phys]A(n,n); [io,phys]B(n,m); int [o,phys]ipiv(n); int [o,phys]info())
=for ref
Computes the solution to a real system of linear equations
A * X = B,
where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
The LU decomposition with partial pivoting and row interchanges is
used to factor A as
A = P * L * U,
where P is a permutation matrix, L is unit lower triangular, and U is
upper triangular.
The factored form of A is then used to solve the
system of equations A * X = B.
Arguments
=========
A: On entry, the N-by-N coefficient matrix A.
On exit, the factors L and U from the factorization
A = P*L*U; the unit diagonal elements of L are not stored.
ipiv: The pivot indices that define the permutation matrix P;
row i of the matrix was interchanged with row ipiv(i).
B: On entry, the N-by-NRHS matrix of right hand side matrix B.
On exit, if info = 0, the N-by-NRHS solution matrix X.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, U(i,i) is exactly zero. The factorization
has been completed, but the factor U is exactly
singular, so the solution could not be computed.
=for example
$a = random (5,5);
$a = transpose($a);
$b = random (5,5);
$b = transpose($b);
gesv($a,$b, (my $ipiv=zeroes(5)),(my $info=null));
print "The solution matrix X is :". transpose($b)."\n" unless $info;
=for bad
gesv ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gesv = \&PDL::gesv;
=head2 gesvx
=for sig
Signature: ([io,phys]A(n,n); int trans(); int fact(); [io,phys]B(n,m); [io,phys]af(n,n); int [io,phys]ipiv(n); int [io]equed(); [io,phys]r(n); [io,phys]c(n); [o,phys]X(n,m); [o,phys]rcond(); [o,phys]ferr(m); [o,phys]berr(m);[o,phys]rpvgrw();int [o,phys]info())
=for ref
Uses the LU factorization to compute the solution to a real
system of linear equations
A * X = B,
where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
Error bounds on the solution and a condition estimate are also
provided.
=for desc
The following steps are performed:
=over 3
=item 1
If fact = 2, real scaling factors are computed to equilibrate
the system:
trans = 0: diag(r)*A*diag(c) *inv(diag(c))*X = diag(c)*B
trans = 1: (diag(r)*A*diag(c))' *inv(diag(r))*X = diag(c)*B
trans = 2: (diag(r)*A*diag(c))**H *inv(diag(r))*X = diag(c)*B
Whether or not the system will be equilibrated depends on the
scaling of the matrix A, but if equilibration is used, A is
overwritten by diag(r)*A*diag(c) and B by diag(r)*B (if trans=0)
or diag(c)*B (if trans = 1 or 2).
=item 2
If fact = 1 or 2, the LU decomposition is used to factor the
matrix A (after equilibration if fact = 2) as
A = P * L * U,
where P is a permutation matrix, L is a unit lower triangular
matrix, and U is upper triangular.
=item 3
If some U(i,i)=0, so that U is exactly singular, then the routine
returns with info = i. Otherwise, the factored form of A is used
to estimate the condition number of the matrix A. If the
reciprocal of the condition number is less than machine precision,
info = N+1 is returned as a warning, but the routine still goes on
to solve for X and compute error bounds as described below.
=item 4
The system of equations is solved for X using the factored form
of A.
=item 5
Iterative refinement is applied to improve the computed solution
matrix and calculate error bounds and backward error estimates
for it.
=item 6
If equilibration was used, the matrix X is premultiplied by
diag(c) (if trans = 0) or diag(r) (if trans = 1 or 2) so
that it solves the original system before equilibration.
=back
Arguments
=========
fact: Specifies whether or not the factored form of the matrix A is
supplied on entry, and if not, whether the matrix A should be
equilibrated before it is factored.
= 0: On entry, af and ipiv contain the factored form of A.
If equed is not 0, the matrix A has been
equilibrated with scaling factors given by r and c.
A, af, and ipiv are not modified.
= 1: The matrix A will be copied to af and factored.
= 2: The matrix A will be equilibrated if necessary, then
copied to af and factored.
trans: Specifies the form of the system of equations:
= 0: A * X = B (No transpose)
= 1: A' * X = B (Transpose)
= 2: A**H * X = B (Transpose)
A: On entry, the N-by-N matrix A. If fact = 0 and equed is
not 0, then A must have been equilibrated by the scaling
factors in r and/or c. A is not modified if fact = 0 or
1, or if fact = 2 and equed = 0 on exit.
On exit, if equed != 0, A is scaled as follows:
equed = 1: A := diag(r) * A
equed = 2: A := A * diag(c)
equed = 3: A := diag(r) * A * diag(c).
af: If fact = 0, then af is an input argument and on entry
contains the factors L and U from the factorization
A = P*L*U as computed by getrf. If equed != 0, then
af is the factored form of the equilibrated matrix A.
If fact = 1, then af is an output argument and on exit
returns the factors L and U from the factorization A = P*L*U
of the original matrix A.
If fact = 2, then af is an output argument and on exit
returns the factors L and U from the factorization A = P*L*U
of the equilibrated matrix A (see the description of A for
the form of the equilibrated matrix).
ipiv: If fact = 0, then ipiv is an input argument and on entry
contains the pivot indices from the factorization A = P*L*U
as computed by getrf; row i of the matrix was interchanged
with row ipiv(i).
If fact = 1, then ipiv is an output argument and on exit
contains the pivot indices from the factorization A = P*L*U
of the original matrix A.
If fact = 2, then ipiv is an output argument and on exit
contains the pivot indices from the factorization A = P*L*U
of the equilibrated matrix A.
equed: Specifies the form of equilibration that was done.
= 0: No equilibration (always true if fact = 1).
= 1: Row equilibration, i.e., A has been premultiplied by
diag(r).
= 2: Column equilibration, i.e., A has been postmultiplied
by diag(c).
= 3: Both row and column equilibration, i.e., A has been
replaced by diag(r) * A * diag(c).
equed is an input argument if fact = 0; otherwise, it is an
output argument.
r: The row scale factors for A. If equed = 1 or 3, A is
multiplied on the left by diag(r); if equed = 0 or 2, r
is not accessed. r is an input argument if fact = 0;
otherwise, r is an output argument. If fact = 0 and
equed = 1 or 3, each element of r must be positive.
c: The column scale factors for A. If equed = 2 or 3, A is
multiplied on the right by diag(c); if equed = 0 or 1, c
is not accessed. c is an input argument if fact = 0;
otherwise, c is an output argument. If fact = 0 and
equed = 2 or 3, each element of c must be positive.
B: On entry, the N-by-NRHS right hand side matrix B.
On exit,
if equed = 0, B is not modified;
if trans = 0 and equed = 1 or 3, B is overwritten by
diag(r)*B;
if trans = 1 or 2 and equed = 2 or 3, B is
overwritten by diag(c)*B.
X: If info = 0 or info = N+1, the N-by-NRHS solution matrix X
to the original system of equations. Note that A and B are
modified on exit if equed != 0, and the solution to the
equilibrated system is inv(diag(c))*X if trans = 0 and
equed = 2 or 3, or inv(diag(r))*X if trans = 1 or 2
and equed = 1 or 3.
rcond: The estimate of the reciprocal condition number of the matrix
A after equilibration (if done). If rcond is less than the
machine precision (in particular, if rcond = 0), the matrix
is singular to working precision. This condition is
indicated by a return code of info > 0.
ferr: The estimated forward error bound for each solution vector
X(j) (the j-th column of the solution matrix X).
If XTRUE is the true solution corresponding to X(j), ferr(j)
is an estimated upper bound for the magnitude of the largest
element in (X(j) - XTRUE) divided by the magnitude of the
largest element in X(j). The estimate is as reliable as
the estimate for rcond, and is almost always a slight
overestimate of the true error.
berr: The componentwise relative backward error of each solution
vector X(j) (i.e., the smallest relative change in
any element of A or B that makes X(j) an exact solution).
rpvgrw: Contains the reciprocal pivot growth factor norm(A)/norm(U).
The "max absolute element" norm is used. If it is much less
than 1, then the stability of the LU factorization of the
(equilibrated) matrix A could be poor. This also means that
the solution X, condition estimator rcond, and forward error
bound ferr could be unreliable. If factorization fails with
0<info<=N, then it contains the reciprocal pivot growth factor
for the leading info columns of A.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, and i is
<= N: U(i,i) is exactly zero. The factorization has
been completed, but the factor U is exactly
singular, so the solution and error bounds
could not be computed. rcond = 0 is returned.
= N+1: U is nonsingular, but rcond is less than machine
precision, meaning that the matrix is singular
to working precision. Nevertheless, the
solution and error bounds are computed because
there are a number of situations where the
computed solution can be more accurate than the
value of rcond would suggest.
=for example
$a= random(5,5);
$b = random(5,5);
$a = transpose($a);
$b = transpose($b);
$rcond = pdl(0);
$rpvgrw = pdl(0);
$equed = pdl(long,0);
$info = pdl(long,0);
$berr = zeroes(5);
$ipiv = zeroes(5);
$ferr = zeroes(5);
$r = zeroes(5);
$c = zeroes(5);
$X = zeroes(5,5);
$af = zeroes(5,5);
gesvx($a,0, 2, $b, $af, $ipiv, $equed, $r, $c, $X, $rcond, $ferr, $berr, $rpvgrw, $info);
print "The solution matrix X is :". transpose($X)."\n" unless $info;
=for bad
gesvx ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gesvx = \&PDL::gesvx;
=head2 sysv
=for sig
Signature: ([io,phys]A(n,n); int uplo(); [io,phys]B(n,m); int [o,phys]ipiv(n); int [o,phys]info())
=for ref
Computes the solution to a real system of linear equations
A * X = B,
where A is an N-by-N symmetric matrix and X and B are N-by-NRHS
matrices.
The diagonal pivoting method is used to factor A as
A = U * D * U', if uplo = 0, or
A = L * D * L', if uplo = 1,
where U (or L) is a product of permutation and unit upper (lower)
triangular matrices, and D is symmetric and block diagonal with
1-by-1 and 2-by-2 diagonal blocks.
The factored form of A is then
used to solve the system of equations A * X = B.
Arguments
=========
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A. If uplo = 0, the leading
N-by-N upper triangular part of A contains the upper
triangular part of the matrix A, and the strictly lower
triangular part of A is not referenced. If uplo = 1, the
leading N-by-N lower triangular part of A contains the lower
triangular part of the matrix A, and the strictly upper
triangular part of A is not referenced.
On exit, if info = 0, the block diagonal matrix D and the
multipliers used to obtain the factor U or L from the
factorization A = U*D*U' or A = L*D*L' as computed by
sytrf.
ipiv: Details of the interchanges and the block structure of D, as
determined by sytrf. If ipiv(k) > 0, then rows and columns
k and ipiv(k) were interchanged, and D(k,k) is a 1-by-1
diagonal block. If uplo = 0 and ipiv(k) = ipiv(k-1) < 0,
then rows and columns k-1 and -ipiv(k) were interchanged and
D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If uplo = 1 and
ipiv(k) = ipiv(k+1) < 0, then rows and columns k+1 and
-ipiv(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2
diagonal block.
B: On entry, the N-by-NRHS right hand side matrix B.
On exit, if info = 0, the N-by-NRHS solution matrix X.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, D(i,i) is exactly zero. The factorization
has been completed, but the block diagonal matrix D is
exactly singular, so the solution could not be computed.
=for example
# Assume $a is symmetric ;)
$a = random (5,5);
$a = transpose($a);
$b = random(4,5);
$b = transpose($b);
sysv($a, 1, $b, (my $ipiv=zeroes(5)),(my $info=null));
print "The solution matrix X is :". transpose($b)."\n" unless $info;
=for bad
sysv ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*sysv = \&PDL::sysv;
=head2 sysvx
=for sig
Signature: ([phys]A(n,n); int uplo(); int fact(); [phys]B(n,m); [io,phys]af(n,n); int [io,phys]ipiv(n); [o,phys]X(n,m); [o,phys]rcond(); [o,phys]ferr(m); [o,phys]berr(m); int [o,phys]info())
=for ref
Uses the diagonal pivoting factorization to compute the
solution to a real system of linear equations A * X = B,
where A is an N-by-N symmetric matrix and X and B are N-by-NRHS
matrices.
Error bounds on the solution and a condition estimate are also
provided.
The following steps are performed:
=over 3
=item 1
If fact = 0, the diagonal pivoting method is used to factor A.
The form of the factorization is
A = U * D * U', if uplo = 0, or
A = L * D * L', if uplo = 1,
where U (or L) is a product of permutation and unit upper (lower)
triangular matrices, and D is symmetric and block diagonal with
1-by-1 and 2-by-2 diagonal blocks.
=item 2
If some D(i,i)=0, so that D is exactly singular, then the routine
returns with info = i. Otherwise, the factored form of A is used
to estimate the condition number of the matrix A. If the
reciprocal of the condition number is less than machine precision,
info = N+1 is returned as a warning, but the routine still goes on
to solve for X and compute error bounds as described below.
=item 3
The system of equations is solved for X using the factored form
of A.
=item 4
Iterative refinement is applied to improve the computed solution
matrix and calculate error bounds and backward error estimates
for it.
=back
Arguments
=========
fact: Specifies whether or not the factored form of A has been
supplied on entry.
= 0: The matrix A will be copied to af and factored.
= 1: On entry, af and ipiv contain the factored form of
A. af and ipiv will not be modified.
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: The symmetric matrix A. If uplo = 0, the leading N-by-N
upper triangular part of A contains the upper triangular part
of the matrix A, and the strictly lower triangular part of A
is not referenced. If uplo = 1, the leading N-by-N lower
triangular part of A contains the lower triangular part of
the matrix A, and the strictly upper triangular part of A is
not referenced.
af: If fact = 1, then af is an input argument and on entry
contains the block diagonal matrix D and the multipliers used
to obtain the factor U or L from the factorization
A = U*D*U' or A = L*D*L' as computed by sytrf.
If fact = 0, then af is an output argument and on exit
returns the block diagonal matrix D and the multipliers used
to obtain the factor U or L from the factorization
A = U*D*U' or A = L*D*L'.
ipiv: If fact = 1, then ipiv is an input argument and on entry
contains details of the interchanges and the block structure
of D, as determined by sytrf.
If ipiv(k) > 0, then rows and columns k and ipiv(k) were
interchanged and D(k,k) is a 1-by-1 diagonal block.
If uplo = 0 and ipiv(k) = ipiv(k-1) < 0, then rows and
columns k-1 and -ipiv(k) were interchanged and D(k-1:k,k-1:k)
is a 2-by-2 diagonal block. If uplo = 1 and ipiv(k) =
ipiv(k+1) < 0, then rows and columns k+1 and -ipiv(k) were
interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
If fact = 0, then ipiv is an output argument and on exit
contains details of the interchanges and the block structure
of D, as determined by sytrf.
B: The N-by-NRHS right hand side matrix B.
X: If info = 0 or info = N+1, the N-by-NRHS solution matrix X.
rcond: The estimate of the reciprocal condition number of the matrix
A. If rcond is less than the machine precision (in
particular, if rcond = 0), the matrix is singular to working
precision. This condition is indicated by a return code of
info > 0.
ferr: The estimated forward error bound for each solution vector
X(j) (the j-th column of the solution matrix X).
If XTRUE is the true solution corresponding to X(j), ferr(j)
is an estimated upper bound for the magnitude of the largest
element in (X(j) - XTRUE) divided by the magnitude of the
largest element in X(j). The estimate is as reliable as
the estimate for rcond, and is almost always a slight
overestimate of the true error.
berr: The componentwise relative backward error of each solution
vector X(j) (i.e., the smallest relative change in
any element of A or B that makes X(j) an exact solution).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, and i is
<= N: D(i,i) is exactly zero. The factorization
has been completed but the factor D is exactly
singular, so the solution and error bounds could
not be computed. rcond = 0 is returned.
= N+1: D is nonsingular, but rcond is less than machine
precision, meaning that the matrix is singular
to working precision. Nevertheless, the
solution and error bounds are computed because
there are a number of situations where the
computed solution can be more accurate than the
value of rcond would suggest.
=for example
$a= random(5,5);
$b = random(10,5);
$a = transpose($a);
$b = transpose($b);
$X = zeroes($b);
$af = zeroes($a);
$ipiv = zeroes(long, 5);
$rcond = pdl(0);
$ferr = zeroes(10);
$berr = zeroes(10);
$info = pdl(long, 0);
# Assume $a is symmetric
sysvx($a, 0, 0, $b,$af, $ipiv, $X, $rcond, $ferr, $berr,$info);
print "The solution matrix X is :". transpose($X)."\n";
=for bad
sysvx ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*sysvx = \&PDL::sysvx;
=head2 posv
=for sig
Signature: ([io,phys]A(n,n); int uplo(); [io,phys]B(n,m); int [o,phys]info())
=for ref
Computes the solution to a real system of linear equations
A * X = B,
where A is an N-by-N symmetric positive definite matrix and X and B
are N-by-NRHS matrices.
The Cholesky decomposition is used to factor A as
A = U'* U, if uplo = 0, or
A = L * L', if uplo = 1,
where U is an upper triangular matrix and L is a lower triangular
matrix.
The factored form of A is then used to solve the system of
equations A * X = B.
Arguments
=========
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A. If uplo = 0, the leading
N-by-N upper triangular part of A contains the upper
triangular part of the matrix A, and the strictly lower
triangular part of A is not referenced. If uplo = 1, the
leading N-by-N lower triangular part of A contains the lower
triangular part of the matrix A, and the strictly upper
triangular part of A is not referenced.
On exit, if info = 0, the factor U or L from the Cholesky
factorization A = U'*U or A = L*L'.
B: On entry, the N-by-NRHS right hand side matrix B.
On exit, if info = 0, the N-by-NRHS solution matrix X.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, the leading minor of order i of A is not
positive definite, so the factorization could not be
completed, and the solution has not been computed.
=for example
# Assume $a is symmetric positive definite ;)
$a = random (5,5);
$a = transpose($a);
$b = random(4,5);
$b = transpose($b);
posv($a, 1, $b, (my $info=null));
print "The solution matrix X is :". transpose($b)."\n" unless $info;
=for bad
posv ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*posv = \&PDL::posv;
=head2 posvx
=for sig
Signature: ([io,phys]A(n,n); int uplo(); int fact(); [io,phys]B(n,m); [io,phys]af(n,n); int [io]equed(); [io,phys]s(n); [o,phys]X(n,m); [o,phys]rcond(); [o,phys]ferr(m); [o,phys]berr(m); int [o,phys]info())
=for ref
Uses the Cholesky factorization A = U'*U or A = L*L' to
compute the solution to a real system of linear equations
A * X = B,
where A is an N-by-N symmetric positive definite matrix and X and B
are N-by-NRHS matrices.
Error bounds on the solution and a condition estimate are also
provided.
The following steps are performed:
=over 3
=item 1
If fact = 2, real scaling factors are computed to equilibrate
the system:
diag(s) * A * diag(s) * inv(diag(s)) * X = diag(s) * B
Whether or not the system will be equilibrated depends on the
scaling of the matrix A, but if equilibration is used, A is
overwritten by diag(s)*A*diag(s) and B by diag(s)*B.
=item 2
If fact = 1 or 2, the Cholesky decomposition is used to
factor the matrix A (after equilibration if fact = 2) as
A = U'* U, if uplo = 0, or
A = L * L', if uplo = 1,
where U is an upper triangular matrix and L is a lower triangular
matrix.
=item 3
If the leading i-by-i principal minor is not positive definite,
then the routine returns with info = i. Otherwise, the factored
form of A is used to estimate the condition number of the matrix
A. If the reciprocal of the condition number is less than machine
precision, info = N+1 is returned as a warning, but the routine
still goes on to solve for X and compute error bounds as
described below.
=item 4
The system of equations is solved for X using the factored form
of A.
=item 5
Iterative refinement is applied to improve the computed solution
matrix and calculate error bounds and backward error estimates
for it.
=item 6
If equilibration was used, the matrix X is premultiplied by
diag(s) so that it solves the original system before
equilibration.
=back
Arguments
=========
fact: Specifies whether or not the factored form of the matrix A is
supplied on entry, and if not, whether the matrix A should be
equilibrated before it is factored.
= 0: On entry, af contains the factored form of A.
If equed = 1, the matrix A has been equilibrated
with scaling factors given by s. A and af will not
be modified.
= 1: The matrix A will be copied to af and factored.
= 2: The matrix A will be equilibrated if necessary, then
copied to af and factored.
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A, except if fact = 0 and
equed = 1, then A must contain the equilibrated matrix
diag(s)*A*diag(s). If uplo = 0, the leading
N-by-N upper triangular part of A contains the upper
triangular part of the matrix A, and the strictly lower
triangular part of A is not referenced. If uplo = 1, the
leading N-by-N lower triangular part of A contains the lower
triangular part of the matrix A, and the strictly upper
triangular part of A is not referenced. A is not modified if
fact = 0 or 1, or if fact = 2 and equed = 0 on exit.
On exit, if fact = 2 and equed = 1, A is overwritten by
diag(s)*A*diag(s).
af: If fact = 0, then af is an input argument and on entry
contains the triangular factor U or L from the Cholesky
factorization A = U'*U or A = L*L', in the same storage
format as A. If equed != 0, then af is the factored form
of the equilibrated matrix diag(s)*A*diag(s).
If fact = 1, then af is an output argument and on exit
returns the triangular factor U or L from the Cholesky
factorization A = U'*U or A = L*L' of the original
matrix A.
If fact = 2, then af is an output argument and on exit
returns the triangular factor U or L from the Cholesky
factorization A = U'*U or A = L*L' of the equilibrated
matrix A (see the description of A for the form of the
equilibrated matrix).
equed: Specifies the form of equilibration that was done.
= 0: No equilibration (always true if fact = 1).
= 1: Equilibration was done, i.e., A has been replaced by
diag(s) * A * diag(s).
equed is an input argument if fact = 0; otherwise, it is an
output argument.
s: The scale factors for A; not accessed if equed = 0. s is
an input argument if fact = 0; otherwise, s is an output
argument. If fact = 0 and equed = 1, each element of s
must be positive.
B: On entry, the N-by-NRHS right hand side matrix B.
On exit, if equed = 0, B is not modified; if equed = 1,
B is overwritten by diag(s) * B.
X: If info = 0 or info = N+1, the N-by-NRHS solution matrix X to
the original system of equations. Note that if equed = 1,
A and B are modified on exit, and the solution to the
equilibrated system is inv(diag(s))*X.
rcond: The estimate of the reciprocal condition number of the matrix
A after equilibration (if done). If rcond is less than the
machine precision (in particular, if rcond = 0), the matrix
is singular to working precision. This condition is
indicated by a return code of info > 0.
ferr: The estimated forward error bound for each solution vector
X(j) (the j-th column of the solution matrix X).
If XTRUE is the true solution corresponding to X(j), FERR(j)
is an estimated upper bound for the magnitude of the largest
element in (X(j) - XTRUE) divided by the magnitude of the
largest element in X(j). The estimate is as reliable as
the estimate for rcond, and is almost always a slight
overestimate of the true error.
berr: The componentwise relative backward error of each solution
vector X(j) (i.e., the smallest relative change in
any element of A or B that makes X(j) an exact solution).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, and i is
<= N: the leading minor of order i of A is
not positive definite, so the factorization
could not be completed, and the solution has not
been computed. rcond = 0 is returned.
= N+1: U is nonsingular, but rcond is less than machine
precision, meaning that the matrix is singular
to working precision. Nevertheless, the
solution and error bounds are computed because
there are a number of situations where the
computed solution can be more accurate than the
value of rcond would suggest.
=for example
$a= random(5,5);
$b = random(5,5);
$a = transpose($a);
$b = transpose($b);
# Assume $a is symmetric positive definite
$rcond = pdl(0);
$equed = pdl(long,0);
$info = pdl(long,0);
$berr = zeroes(5);
$ferr = zeroes(5);
$s = zeroes(5);
$X = zeroes(5,5);
$af = zeroes(5,5);
posvx($a,0,2,$b,$af, $equed, $s, $X, $rcond, $ferr, $berr,$info);
print "The solution matrix X is :". transpose($X)."\n" unless $info;
=for bad
posvx ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*posvx = \&PDL::posvx;
=head2 gels
=for sig
Signature: ([io,phys]A(m,n); int trans(); [io,phys]B(p,q);int [o,phys]info())
=for ref
Solves overdetermined or underdetermined real linear systems
involving an M-by-N matrix A, or its transpose, using a QR or LQ
factorization of A. It is assumed that A has full rank.
The following options are provided:
=over 3
=item 1
If trans = 0 and m >= n: find the least squares solution of
an overdetermined system, i.e., solve the least squares problem
minimize || B - A*X ||.
=item 2
If trans = 0 and m < n: find the minimum norm solution of
an underdetermined system A * X = B.
=item 3
If trans = 1 and m >= n: find the minimum norm solution of
an undetermined system A' * X = B.
=item 4
If trans = 1 and m < n: find the least squares solution of
an overdetermined system, i.e., solve the least squares problem
minimize || B - A' * X ||.
=back
Several right hand side vectors b and solution vectors x can be
handled in a single call; they are stored as the columns of the
M-by-NRHS right hand side matrix B and the N-by-NRHS solution
matrix X.
Arguments
=========
trans: = 0: the linear system involves A;
= 1: the linear system involves A'.
A: On entry, the M-by-N matrix A.
On exit,
if M >= N, A is overwritten by details of its QR
factorization as returned by geqrf;
if M < N, A is overwritten by details of its LQ
factorization as returned by gelqf.
B: On entry, the matrix B of right hand side vectors, stored
columnwise; B is M-by-NRHS if trans = 0, or N-by-NRHS
if trans = 1.
On exit, B is overwritten by the solution vectors, stored
columnwise:
if trans = 0 and m >= n, rows 1 to n of B contain the least
squares solution vectors; the residual sum of squares for the
solution in each column is given by the sum of squares of
elements N+1 to M in that column;
if trans = 0 and m < n, rows 1 to N of B contain the
minimum norm solution vectors;
if trans = 1 and m >= n, rows 1 to M of B contain the
minimum norm solution vectors;
if trans = 1 and m < n, rows 1 to M of B contain the
least squares solution vectors; the residual sum of squares
for the solution in each column is given by the sum of
squares of elements M+1 to N in that column.
The leading dimension of the array B >= max(1,M,N).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a= random(7,5);
# $b will contain X
# TODO better example with slice
$b = random(7,6);
gels($a, 1, $b, ($info = null));
=for bad
gels ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gels = \&PDL::gels;
=head2 gelsy
=for sig
Signature: ([io,phys]A(m,n); [io,phys]B(p,q); [phys]rcond(); int [io,phys]jpvt(n); int [o,phys]rank();int [o,phys]info())
=for ref
Computes the minimum-norm solution to a real linear least
squares problem:
minimize || A * X - B ||
using a complete orthogonal factorization of A.
A is an M-by-N matrix which may be rank-deficient.
Several right hand side vectors b and solution vectors x can be
handled in a single call; they are stored as the columns of the
M-by-NRHS right hand side matrix B and the N-by-NRHS solution
matrix X.
The routine first computes a QR factorization with column pivoting:
A * P = Q * [ R11 R12 ]
[ 0 R22 ]
with R11 defined as the largest leading submatrix whose estimated
condition number is less than 1/rcond. The order of R11, rank,
is the effective rank of A.
Then, R22 is considered to be negligible, and R12 is annihilated
by orthogonal transformations from the right, arriving at the
complete orthogonal factorization:
A * P = Q * [ T11 0 ] * Z
[ 0 0 ]
The minimum-norm solution is then
X = P * Z' [ inv(T11)*Q1'*B ]
[ 0 ]
where Q1 consists of the first rank columns of Q.
Arguments
=========
A: On entry, the M-by-N matrix A.
On exit, A has been overwritten by details of its
complete orthogonal factorization.
B: On entry, the M-by-NRHS right hand side matrix B.
On exit, the N-by-NRHS solution matrix X.
The leading dimension of the array B >= max(1,M,N).
jpvt: On entry, if jpvt(i) != 0, the i-th column of A is permuted
to the front of AP, otherwise column i is a free column.
On exit, if jpvt(i) = k, then the i-th column of AP
was the k-th column of A.
rcond: rcond is used to determine the effective rank of A, which
is defined as the order of the largest leading triangular
submatrix R11 in the QR factorization with pivoting of A,
whose estimated condition number < 1/rcond.
rank: The effective rank of A, i.e., the order of the submatrix
R11. This is the same as the order of the submatrix T11
in the complete orthogonal factorization of A.
info: = 0: successful exit
< 0: If info = -i, the i-th argument had an illegal value.
=for example
$a= random(7,5);
# $b will contain X
# TODO better example with slice
$b = random(7,6);
$jpvt = zeroes(long, 5);
$eps = lamch(0);
#Threshold for rank estimation
$rcond = sqrt($eps) - (sqrt($eps) - $eps) / 2;
gelsy($a, $b, $rcond, $jpvt,($rank=null),($info = null));
=for bad
gelsy ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gelsy = \&PDL::gelsy;
=head2 gelss
=for sig
Signature: ([io,phys]A(m,n); [io,phys]B(p,q); [phys]rcond(); [o,phys]s(r); int [o,phys]rank();int [o,phys]info())
=for ref
Computes the minimum norm solution to a real linear least
squares problem:
Minimize 2-norm(| b - A*x |).
using the singular value decomposition (SVD) of A. A is an M-by-N
matrix which may be rank-deficient.
Several right hand side vectors b and solution vectors x can be
handled in a single call; they are stored as the columns of the
M-by-NRHS right hand side matrix B and the N-by-NRHS solution matrix
X.
The effective rank of A is determined by treating as zero those
singular values which are less than rcond times the largest singular
value.
Arguments
=========
A: On entry, the M-by-N matrix A.
On exit, the first min(m,n) rows of A are overwritten with
its right singular vectors, stored rowwise.
B: On entry, the M-by-NRHS right hand side matrix B.
On exit, B is overwritten by the N-by-NRHS solution
matrix X. If m >= n and rank = n, the residual
sum-of-squares for the solution in the i-th column is given
by the sum of squares of elements n+1:m in that column.
The leading dimension of the array B >= max(1,M,N).
s: The singular values of A in decreasing order.
The condition number of A in the 2-norm = s(1)/s(min(m,n)).
rcond: rcond is used to determine the effective rank of A.
Singular values s(i) <= rcond*s(1) are treated as zero.
If rcond < 0, machine precision is used instead.
rank: The effective rank of A, i.e., the number of singular values
which are greater than rcond*s(1).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
> 0: the algorithm for computing the SVD failed to converge;
if info = i, i off-diagonal elements of an intermediate
bidiagonal form did not converge to zero.
=for example
$a= random(7,5);
# $b will contain X
# TODO better example with slice
$b = random(7,6);
$eps = lamch(0);
$s =zeroes(5);
#Threshold for rank estimation
$rcond = sqrt($eps) - (sqrt($eps) - $eps) / 2;
gelss($a, $b, $rcond, $s, ($rank=null),($info = null));
=for bad
gelss ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gelss = \&PDL::gelss;
=head2 gelsd
=for sig
Signature: ([io,phys]A(m,n); [io,phys]B(p,q); [phys]rcond(); [o,phys]s(r); int [o,phys]rank();int [o,phys]info())
=for ref
Computes the minimum-norm solution to a real linear least
squares problem:
minimize 2-norm(| b - A*x |)
using the singular value decomposition (SVD) of A. A is an M-by-N
matrix which may be rank-deficient.
Several right hand side vectors b and solution vectors x can be
handled in a single call; they are stored as the columns of the
M-by-NRHS right hand side matrix B and the N-by-NRHS solution
matrix X.
The problem is solved in three steps:
=over 3
=item 1
Reduce the coefficient matrix A to bidiagonal form with
Householder transformations, reducing the original problem
into a "bidiagonal least squares problem" (BLS)
=item 2
Solve the BLS using a divide and conquer approach.
=item 3
Apply back all the Householder tranformations to solve
the original least squares problem.
=back
The effective rank of A is determined by treating as zero those
singular values which are less than rcond times the largest singular
value.
The divide and conquer algorithm makes very mild assumptions about
floating point arithmetic. It will work on machines with a guard
digit in add/subtract, or on those binary machines without guard
digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
Cray-2. It could conceivably fail on hexadecimal or decimal machines
without guard digits, but we know of none.
Arguments
=========
A: On entry, the M-by-N matrix A.
On exit, A has been destroyed.
B: On entry, the M-by-NRHS right hand side matrix B.
On exit, B is overwritten by the N-by-NRHS solution
matrix X. If m >= n and rank = n, the residual
sum-of-squares for the solution in the i-th column is given
by the sum of squares of elements n+1:m in that column.
The leading dimension of the array B >= max(1,M,N).
s: The singular values of A in decreasing order.
The condition number of A in the 2-norm = s(1)/s(min(m,n)).
rcond: rcond is used to determine the effective rank of A.
Singular values s(i) <= rcond*s(1) are treated as zero.
If rcond < 0, machine precision is used instead.
rank: The effective rank of A, i.e., the number of singular values
which are greater than rcond*s(1).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
> 0: the algorithm for computing the SVD failed to converge;
if info = i, i off-diagonal elements of an intermediate
bidiagonal form did not converge to zero.
=for example
$a= random(7,5);
# $b will contain X
# TODO better example with slice
$b = random(7,6);
$eps = lamch(0);
$s =zeroes(5);
#Threshold for rank estimation
$rcond = sqrt($eps) - (sqrt($eps) - $eps) / 2;
gelsd($a, $b, $rcond, $s, ($rank=null),($info = null));
=for bad
gelsd ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gelsd = \&PDL::gelsd;
=head2 gglse
=for sig
Signature: ([phys]A(m,n); [phys]B(p,n);[io,phys]c(m);[phys]d(p);[o,phys]x(n);int [o,phys]info())
=for ref
Solves the linear equality-constrained least squares (LSE)
problem:
minimize || c - A*x ||_2 subject to B*x = d
where A is an M-by-N matrix, B is a P-by-N matrix, c is a given
M-vector, and d is a given P-vector. It is assumed that
P <= N <= M+P, and
rank(B) = P and rank( ( A ) ) = N.
( ( B ) )
These conditions ensure that the LSE problem has a unique solution,
which is obtained using a GRQ factorization of the matrices B and A.
Arguments
=========
A: On entry, the M-by-N matrix A.
On exit, A is destroyed.
B: On entry, the P-by-N matrix B.
On exit, B is destroyed.
c: On entry, c contains the right hand side vector for the
least squares part of the LSE problem.
On exit, the residual sum of squares for the solution
is given by the sum of squares of elements N-P+1 to M of
vector c.
d: On entry, d contains the right hand side vector for the
constrained equation.
On exit, d is destroyed.
x: On exit, x is the solution of the LSE problem.
info: = 0: successful exit.
< 0: if info = -i, the i-th argument had an illegal value.
=for example
$a = random(7,5);
$b = random(4,5);
$c = random(7);
$d = random(4);
$x = zeroes(5);
gglse($a, $b, $c, $d, $x, ($info=null));
=for bad
gglse ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gglse = \&PDL::gglse;
=head2 ggglm
=for sig
Signature: ([phys]A(n,m); [phys]B(n,p);[phys]d(n);[o,phys]x(m);[o,phys]y(p);int [o,phys]info())
=for ref
Solves a general Gauss-Markov linear model (GLM) problem:
minimize || y ||_2 subject to d = A*x + B*y
x
where A is an N-by-M matrix, B is an N-by-P matrix, and d is a
given N-vector. It is assumed that M <= N <= M+P, and
rank(A) = M and rank( A B ) = N.
Under these assumptions, the constrained equation is always
consistent, and there is a unique solution x and a minimal 2-norm
solution y, which is obtained using a generalized QR factorization
of A and B.
In particular, if matrix B is square nonsingular, then the problem
GLM is equivalent to the following weighted linear least squares
problem
minimize || inv(B)*(d-A*x) ||_2
x
where inv(B) denotes the inverse of B.
Arguments
=========
A: On entry, the N-by-M matrix A.
On exit, A is destroyed.
B: On entry, the N-by-P matrix B.
On exit, B is destroyed.
d: On entry, d is the left hand side of the GLM equation.
On exit, d is destroyed.
x:
y: On exit, x and y are the solutions of the GLM problem.
info: = 0: successful exit.
< 0: if info = -i, the i-th argument had an illegal value.
=for example
$a = random(7,5);
$b = random(7,4);
$d = random(7);
$x = zeroes(5);
$y = zeroes(4);
ggglm($a, $b, $d, $x, $y,($info=null));
=for bad
ggglm ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*ggglm = \&PDL::ggglm;
=head2 getrf
=for sig
Signature: ([io,phys]A(m,n); int [o,phys]ipiv(p); int [o,phys]info())
=for ref
Computes an LU factorization of a general M-by-N matrix A
using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit
diagonal elements (lower trapezoidal if m > n), and U is upper
triangular (upper trapezoidal if m < n).
This is the right-looking Level 3 BLAS version of the algorithm.
Arguments
=========
A: On entry, the M-by-N matrix to be factored.
On exit, the factors L and U from the factorization
A = P*L*U; the unit diagonal elements of L are not stored.
ipiv: The pivot indices; for 1 <= i <= min(M,N), row i of the
matrix was interchanged with row ipiv(i).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, U(i,i) is exactly zero. The factorization
has been completed, but the factor U is exactly
singular, and division by zero will occur if it is used
to solve a system of equations.
=for example
$a = random (float, 100,50);
$ipiv = zeroes(long, 50);
$info = null;
getrf($a, $ipiv, $info);
=for bad
getrf ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*getrf = \&PDL::getrf;
=head2 getf2
=for sig
Signature: ([io,phys]A(m,n); int [o,phys]ipiv(p); int [o,phys]info())
=for ref
Computes an LU factorization of a general M-by-N matrix A
using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit
diagonal elements (lower trapezoidal if m > n), and U is upper
triangular (upper trapezoidal if m < n).
This is the right-looking Level 2 BLAS version of the algorithm.
Arguments
=========
A: On entry, the M-by-N matrix to be factored.
On exit, the factors L and U from the factorization
A = P*L*U; the unit diagonal elements of L are not stored.
ipiv: The pivot indices; for 1 <= i <= min(M,N), row i of the
matrix was interchanged with row ipiv(i).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, U(i,i) is exactly zero. The factorization
has been completed, but the factor U is exactly
singular, and division by zero will occur if it is used
to solve a system of equations.
=for example
$a = random (float, 100,50);
$ipiv = zeroes(long, 50);
$info = null;
getf2($a, $ipiv, $info);
=for bad
getf2 ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*getf2 = \&PDL::getf2;
=head2 sytrf
=for sig
Signature: ([io,phys]A(n,n); int uplo(); int [o,phys]ipiv(n); int [o,phys]info())
=for ref
Computes the factorization of a real symmetric matrix A using
the Bunch-Kaufman diagonal pivoting method. The form of the
factorization is
A = U*D*U' or A = L*D*L'
where U (or L) is a product of permutation and unit upper (lower)
triangular matrices, and D is symmetric and block diagonal with
1-by-1 and 2-by-2 diagonal blocks.
This is the blocked version of the algorithm, calling Level 3 BLAS.
Arguments
=========
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A. If uplo = 0, the leading
N-by-N upper triangular part of A contains the upper
triangular part of the matrix A, and the strictly lower
triangular part of A is not referenced. If uplo = 1, the
leading N-by-N lower triangular part of A contains the lower
triangular part of the matrix A, and the strictly upper
triangular part of A is not referenced.
On exit, the block diagonal matrix D and the multipliers used
to obtain the factor U or L (see below for further details).
ipiv: Details of the interchanges and the block structure of D.
If ipiv(k) > 0, then rows and columns k and ipiv(k) were
interchanged and D(k,k) is a 1-by-1 diagonal block.
If uplo = 0 and ipiv(k) = ipiv(k-1) < 0, then rows and
columns k-1 and -ipiv(k) were interchanged and D(k-1:k,k-1:k)
is a 2-by-2 diagonal block. If uplo = 1 and ipiv(k) =
ipiv(k+1) < 0, then rows and columns k+1 and -ipiv(k) were
interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, D(i,i) is exactly zero. The factorization
has been completed, but the block diagonal matrix D is
exactly singular, and division by zero will occur if it
is used to solve a system of equations.
Further Details
===============
If uplo = 0, then A = U*D*U', where
U = P(n)*U(n)* ... *P(k)U(k)* ...,
i.e., U is a product of terms P(k)*U(k), where k decreases from n to
1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
defined by ipiv(k), and U(k) is a unit upper triangular matrix, such
that if the diagonal block D(k) is of order s (s = 1 or 2), then
( I v 0 ) k-s
U(k) = ( 0 I 0 ) s
( 0 0 I ) n-k
k-s s n-k
If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).
If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),
and A(k,k), and v overwrites A(1:k-2,k-1:k).
If uplo = 1, then A = L*D*L', where
L = P(1)*L(1)* ... *P(k)*L(k)* ...,
i.e., L is a product of terms P(k)*L(k), where k increases from 1 to
n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
defined by ipiv(k), and L(k) is a unit lower triangular matrix, such
that if the diagonal block D(k) is of order s (s = 1 or 2), then
( I 0 0 ) k-1
L(k) = ( 0 I 0 ) s
( 0 v I ) n-k-s+1
k-1 s n-k-s+1
If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).
If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),
and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).
=for example
$a = random(100,100);
$ipiv = zeroes(100);
$info = null;
# Assume $a is symmetric
sytrf($a, 0, $ipiv, $info);
=for bad
sytrf ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*sytrf = \&PDL::sytrf;
=head2 sytf2
=for sig
Signature: ([io,phys]A(n,n); int uplo(); int [o,phys]ipiv(n); int [o,phys]info())
=for ref
Computes the factorization of a real symmetric matrix A using
the Bunch-Kaufman diagonal pivoting method. The form of the
factorization is
A = U*D*U' or A = L*D*L'
where U (or L) is a product of permutation and unit upper (lower)
triangular matrices, and D is symmetric and block diagonal with
1-by-1 and 2-by-2 diagonal blocks.
This is the unblocked version of the algorithm, calling Level 2 BLAS.
Arguments
=========
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A. If uplo = 0, the leading
N-by-N upper triangular part of A contains the upper
triangular part of the matrix A, and the strictly lower
triangular part of A is not referenced. If uplo = 1, the
leading N-by-N lower triangular part of A contains the lower
triangular part of the matrix A, and the strictly upper
triangular part of A is not referenced.
On exit, the block diagonal matrix D and the multipliers used
to obtain the factor U or L (see below for further details).
ipiv: Details of the interchanges and the block structure of D.
If ipiv(k) > 0, then rows and columns k and ipiv(k) were
interchanged and D(k,k) is a 1-by-1 diagonal block.
If uplo = 0 and ipiv(k) = ipiv(k-1) < 0, then rows and
columns k-1 and -ipiv(k) were interchanged and D(k-1:k,k-1:k)
is a 2-by-2 diagonal block. If uplo = 1 and ipiv(k) =
ipiv(k+1) < 0, then rows and columns k+1 and -ipiv(k) were
interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, D(i,i) is exactly zero. The factorization
has been completed, but the block diagonal matrix D is
exactly singular, and division by zero will occur if it
is used to solve a system of equations.
For further details see sytrf
=for example
$a = random(100,100);
$ipiv = zeroes(100);
$info = null;
# Assume $a is symmetric
sytf2($a, 0, $ipiv, $info);
=for bad
sytf2 ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*sytf2 = \&PDL::sytf2;
=head2 potrf
=for sig
Signature: ([io,phys]A(n,n); int uplo(); int [o,phys]info())
=for ref
Computes the Cholesky factorization of a real symmetric
positive definite matrix A.
The factorization has the form
A = U' * U, if uplo = 0, or
A = L * L', if uplo = 1,
where U is an upper triangular matrix and L is lower triangular.
This is the block version of the algorithm, calling Level 3 BLAS.
Arguments
=========
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A. If uplo = 0, the leading
N-by-N upper triangular part of A contains the upper
triangular part of the matrix A, and the strictly lower
triangular part of A is not referenced. If uplo = 1, the
leading N-by-N lower triangular part of A contains the lower
triangular part of the matrix A, and the strictly upper
triangular part of A is not referenced.
On exit, if info = 0, the factor U or L from the Cholesky
factorization A = U'*U or A = L*L'.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, the leading minor of order i is not
positive definite, and the factorization could not be
completed.
=for example
$a = random(100,100);
# Assume $a is symmetric positive definite
potrf($a, 0, ($info = null));
=for bad
potrf ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*potrf = \&PDL::potrf;
=head2 potf2
=for sig
Signature: ([io,phys]A(n,n); int uplo(); int [o,phys]info())
=for ref
Computes the Cholesky factorization of a real symmetric
positive definite matrix A.
The factorization has the form
A = U' * U, if uplo = 0, or
A = L * L', if uplo = 1,
where U is an upper triangular matrix and L is lower triangular.
This is the unblocked version of the algorithm, calling Level 2 BLAS.
Arguments
=========
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the symmetric matrix A. If uplo = 0, the leading
N-by-N upper triangular part of A contains the upper
triangular part of the matrix A, and the strictly lower
triangular part of A is not referenced. If uplo = 1, the
leading N-by-N lower triangular part of A contains the lower
triangular part of the matrix A, and the strictly upper
triangular part of A is not referenced.
On exit, if info = 0, the factor U or L from the Cholesky
factorization A = U'*U or A = L*L'.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, the leading minor of order i is not
positive definite, and the factorization could not be
completed.
=for example
$a = random(100,100);
# Assume $a is symmetric positive definite
potf2($a, 0, ($info = null));
=for bad
potf2 ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*potf2 = \&PDL::potf2;
=head2 getri
=for sig
Signature: ([io,phys]A(n,n); int [phys]ipiv(n); int [o,phys]info())
=for ref
Computes the inverse of a matrix using the LU factorization
computed by C<getrf>.
This method inverts U and then computes inv(A) by solving the system
inv(A)*L = inv(U) for inv(A).
Arguments
=========
A: On entry, the factors L and U from the factorization
A = P*L*U as computed by getrf.
On exit, if info = 0, the inverse of the original matrix A.
ipiv: The pivot indices from getrf; for 1<=i<=N, row i of the
matrix was interchanged with row ipiv(i).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, U(i,i) is exactly zero; the matrix is
singular and its inverse could not be computed.
=for example
$a = random (float, 100, 100);
$ipiv = zeroes(long, 100);
$info = null;
getrf($a, $ipiv, $info);
if ($info == 0){
getri($a, $ipiv, $info);
}
print "Inverse of \$a is :\n $a" unless $info;
=for bad
getri ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*getri = \&PDL::getri;
=head2 sytri
=for sig
Signature: ([io,phys]A(n,n); int uplo(); int [phys]ipiv(n); int [o,phys]info())
=for ref
Computes the inverse of a real symmetric indefinite matrix
A using the factorization A = U*D*U' or A = L*D*L' computed by
C<sytrf>.
Arguments
=========
uplo: Specifies whether the details of the factorization are stored
as an upper or lower triangular matrix.
= 0: Upper triangular, form is A = U*D*U';
= 1: Lower triangular, form is A = L*D*L'.
A: On entry, the block diagonal matrix D and the multipliers
used to obtain the factor U or L as computed by sytrf.
On exit, if info = 0, the (symmetric) inverse of the original
matrix. If uplo = 0, the upper triangular part of the
inverse is formed and the part of A below the diagonal is not
referenced; if uplo = 1 the lower triangular part of the
inverse is formed and the part of A above the diagonal is
not referenced.
ipiv: Details of the interchanges and the block structure of D
as determined by sytrf.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, D(i,i) = 0; the matrix is singular and its
inverse could not be computed.
=for example
$a = random (float, 100, 100);
# assume $a is symmetric
$ipiv = zeroes(long, 100);
sytrf($a, 0, $ipiv, ($info=null));
if ($info == 0){
sytri($a, 0, $ipiv, $info);
}
print "Inverse of \$a is :\n $a" unless $info;
=for bad
sytri ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*sytri = \&PDL::sytri;
=head2 potri
=for sig
Signature: ([io,phys]A(n,n); int uplo(); int [o,phys]info())
=for ref
Computes the inverse of a real symmetric positive definite
matrix A using the Cholesky factorization A = U'*U or A = L*L'
computed by C<potrf>.
Arguments
=========
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: On entry, the triangular factor U or L from the Cholesky
factorization A = U'*U or A = L*L', as computed by
potrf.
On exit, the upper or lower triangle of the (symmetric)
inverse of A, overwriting the input factor U or L.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, the (i,i) element of the factor U or L is
zero, and the inverse could not be computed.
=for example
$a = random (float, 100, 100);
# Assume $a is symmetric positive definite
potrf($a, 0, ($info = null));
if ($info == 0){ # Hum... is it positive definite????
potri($a, 0,$info);
}
print "Inverse of \$a is :\n $a" unless $info;
=for bad
potri ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*potri = \&PDL::potri;
=head2 trtri
=for sig
Signature: ([io,phys]A(n,n); int uplo(); int diag(); int [o,phys]info())
=for ref
Computes the inverse of a real upper or lower triangular
matrix A.
This is the Level 3 BLAS version of the algorithm.
Arguments
=========
uplo: = 0: A is upper triangular;
= 1: A is lower triangular.
diag: = 0: A is non-unit triangular;
= 1: A is unit triangular.
A: On entry, the triangular matrix A. If uplo = 0, the
leading N-by-N upper triangular part of the array A contains
the upper triangular matrix, and the strictly lower
triangular part of A is not referenced. If uplo = 1, the
leading N-by-N lower triangular part of the array A contains
the lower triangular matrix, and the strictly upper
triangular part of A is not referenced. If diag = 1, the
diagonal elements of A are also not referenced and are
assumed to be 1.
On exit, the (triangular) inverse of the original matrix, in
the same storage format.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, A(i,i) is exactly zero. The triangular
matrix is singular and its inverse can not be computed.
=for example
$a = random (float, 100, 100);
# assume $a is upper triangular
trtri($a, 1, ($info=null));
print "Inverse of \$a is :\n transpose($a)" unless $info;
=for bad
trtri ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*trtri = \&PDL::trtri;
=head2 trti2
=for sig
Signature: ([io,phys]A(n,n); int uplo(); int diag(); int [o,phys]info())
=for ref
Computes the inverse of a real upper or lower triangular
matrix A.
This is the Level 2 BLAS version of the algorithm.
Arguments
=========
uplo: = 0: A is upper triangular;
= 1: A is lower triangular.
diag: = 0: A is non-unit triangular;
= 1: A is unit triangular.
A: On entry, the triangular matrix A. If uplo = 0, the
leading N-by-N upper triangular part of the array A contains
the upper triangular matrix, and the strictly lower
triangular part of A is not referenced. If uplo = 1, the
leading N-by-N lower triangular part of the array A contains
the lower triangular matrix, and the strictly upper
triangular part of A is not referenced. If diag = 1, the
diagonal elements of A are also not referenced and are
assumed to be 1.
On exit, the (triangular) inverse of the original matrix, in
the same storage format.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 100, 100);
# assume $a is upper triangular
trtri2($a, 1, ($info=null));
print "Inverse of \$a is :\n transpose($a)" unless $info;
=for bad
trti2 ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*trti2 = \&PDL::trti2;
=head2 getrs
=for sig
Signature: ([phys]A(n,n); int trans(); [io,phys]B(n,m); int [phys]ipiv(n); int [o,phys]info())
=for ref
Solves a system of linear equations
A * X = B or A' * X = B
with a general N-by-N matrix A using the LU factorization computed
by getrf.
Arguments
=========
trans: Specifies the form of the system of equations:
= 0: A * X = B (No transpose)
= 1: A'* X = B (Transpose)
A: The factors L and U from the factorization A = P*L*U
as computed by getrf.
ipiv: The pivot indices from getrf; for 1<=i<=N, row i of the
matrix was interchanged with row ipiv(i).
B: On entry, the right hand side matrix B.
On exit, the solution matrix X.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 100, 100);
$ipiv = zeroes(long, 100);
$b = random(100,50);
getrf($a, $ipiv, ($info=null));
if ($info == 0){
getrs($a, 0, $b, $ipiv, $info);
}
print "X is :\n $b" unless $info;
=for bad
getrs ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*getrs = \&PDL::getrs;
=head2 sytrs
=for sig
Signature: ([phys]A(n,n); int uplo();[io,phys]B(n,m); int [phys]ipiv(n); int [o,phys]info())
=for ref
Solves a system of linear equations A*X = B with a real
symmetric matrix A using the factorization A = U*D*U' or
A = L*D*L' computed by C<sytrf>.
Arguments
=========
uplo: Specifies whether the details of the factorization are stored
as an upper or lower triangular matrix.
= 0: Upper triangular, form is A = U*D*U';
= 1: Lower triangular, form is A = L*D*L'.
A: The block diagonal matrix D and the multipliers used to
obtain the factor U or L as computed by sytrf.
ipiv: Details of the interchanges and the block structure of D
as determined by sytrf.
B: On entry, the right hand side matrix B.
On exit, the solution matrix X.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 100, 100);
$b = random(50,100);
$a = transpose($a);
$b = transpose($b);
# Assume $a is symmetric
sytrf($a, 0, ($ipiv=zeroes(100)), ($info=null));
if ($info == 0){
sytrs($a, 0, $b, $ipiv, $info);
}
print("X is :\n".transpose($b))unless $info;
=for bad
sytrs ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*sytrs = \&PDL::sytrs;
=head2 potrs
=for sig
Signature: ([phys]A(n,n); int uplo(); [io,phys]B(n,m); int [o,phys]info())
=for ref
Solves a system of linear equations A*X = B with a symmetric
positive definite matrix A using the Cholesky factorization
A = U'*U or A = L*L' computed by C<potrf>.
Arguments
=========
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: The triangular factor U or L from the Cholesky factorization
A = U'*U or A = L*L', as computed by potrf.
B: On entry, the right hand side matrix B.
On exit, the solution matrix X.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 100, 100);
$b = random(50,100);
$a = transpose($a);
$b = transpose($b);
# Assume $a is symmetric positive definite
potrf($a, 0, ($info=null));
if ($info == 0){
potrs($a, 0, $b, $info);
}
print("X is :\n".transpose($b))unless $info;
=for bad
potrs ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*potrs = \&PDL::potrs;
=head2 trtrs
=for sig
Signature: ([phys]A(n,n); int uplo(); int trans(); int diag();[io,phys]B(n,m); int [o,phys]info())
=for ref
Solves a triangular system of the form
A * X = B or A' * X = B,
where A is a triangular matrix of order N, and B is an N-by-NRHS
matrix.
A check is made to verify that A is nonsingular.
Arguments
=========
uplo: = 0: A is upper triangular;
= 1: A is lower triangular.
trans: Specifies the form of the system of equations:
= 0: A * X = B (No transpose)
= 1: A**T * X = B (Transpose)
diag: = 0: A is non-unit triangular;
= 1: A is unit triangular.
A: The triangular matrix A. If uplo = 0, the leading N-by-N
upper triangular part of the array A contains the upper
triangular matrix, and the strictly lower triangular part of
A is not referenced. If uplo = 1, the leading N-by-N lower
triangular part of the array A contains the lower triangular
matrix, and the strictly upper triangular part of A is not
referenced. If diag = 1, the diagonal elements of A are
also not referenced and are assumed to be 1.
B: On entry, the right hand side matrix B.
On exit, if info = 0, the solution matrix X.
info = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, the i-th diagonal element of A is zero,
indicating that the matrix is singular and the solutions
X have not been computed.
=for example
# Assume $a is upper triangular
$a = random (float, 100, 100);
$b = random(50,100);
$a = transpose($a);
$b = transpose($b);
$info = null;
trtrs($a, 0, 0, 0, $b, $info);
print("X is :\n".transpose($b))unless $info;
=for bad
trtrs ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*trtrs = \&PDL::trtrs;
=head2 latrs
=for sig
Signature: ([phys]A(n,n); int uplo(); int trans(); int diag(); int normin();[io,phys]x(n); [o,phys]scale();[io,phys]cnorm(n);int [o,phys]info())
=for ref
Solves one of the triangular systems
A *x = s*b or A'*x = s*b
with scaling to prevent overflow. Here A is an upper or lower
triangular matrix, A' denotes the transpose of A, x and b are
n-element vectors, and s is a scaling factor, usually less than
or equal to 1, chosen so that the components of x will be less than
the overflow threshold. If the unscaled problem will not cause
overflow, the Level 2 BLAS routine C<trsv> is called. If the matrix A
is singular (A(j,j) = 0 for some j), then s is set to 0 and a
non-trivial solution to A*x = 0 is returned.
Further Details
======= =======
A rough bound on x is computed; if that is less than overflow, trsv
is called, otherwise, specific code is used which checks for possible
overflow or divide-by-zero at every operation.
A columnwise scheme is used for solving A*x = b. The basic algorithm
if A is lower triangular is
x[1:n] := b[1:n]
for j = 1, ..., n
x(j) := x(j) / A(j,j)
x[j+1:n] := x[j+1:n] - x(j) * A[j+1:n,j]
end
Define bounds on the components of x after j iterations of the loop:
M(j) = bound on x[1:j]
G(j) = bound on x[j+1:n]
Initially, let M(0) = 0 and G(0) = max{x(i), i=1,...,n}.
Then for iteration j+1 we have
M(j+1) <= G(j) / | A(j+1,j+1) |
G(j+1) <= G(j) + M(j+1) * | A[j+2:n,j+1] |
<= G(j) ( 1 + cnorm(j+1) / | A(j+1,j+1) | )
where cnorm(j+1) is greater than or equal to the infinity-norm of
column j+1 of A, not counting the diagonal.
Hence
G(j) <= G(0) product ( 1 + cnorm(i) / | A(i,i) | )
1<=i<=j
and
|x(j)| <= ( G(0) / |A(j,j)| ) product ( 1 + cnorm(i) / |A(i,i)| )
1<=i< j
Since |x(j)| <= M(j), we use the Level 2 BLAS routine DTRSV if the
reciprocal of the largest M(j), j=1,..,n, is larger than
max(underflow, 1/overflow).
The bound on x(j) is also used to determine when a step in the
columnwise method can be performed without fear of overflow. If
the computed bound is greater than a large constant, x is scaled to
prevent overflow, but if the bound overflows, x is set to 0, x(j) to
1, and scale to 0, and a non-trivial solution to A*x = 0 is found.
Similarly, a row-wise scheme is used to solve A'*x = b. The basic
algorithm for A upper triangular is
for j = 1, ..., n
x(j) := ( b(j) - A[1:j-1,j]' * x[1:j-1] ) / A(j,j)
end
We simultaneously compute two bounds
G(j) = bound on ( b(i) - A[1:i-1,i]' * x[1:i-1] ), 1<=i<=j
M(j) = bound on x(i), 1<=i<=j
The initial values are G(0) = 0, M(0) = max{b(i), i=1,..,n}, and we
add the constraint G(j) >= G(j-1) and M(j) >= M(j-1) for j >= 1.
Then the bound on x(j) is
M(j) <= M(j-1) * ( 1 + cnorm(j) ) / | A(j,j) |
<= M(0) * product ( ( 1 + cnorm(i) ) / |A(i,i)| )
1<=i<=j
and we can safely call trsv if 1/M(n) and 1/G(n) are both greater
than max(underflow, 1/overflow).
Arguments
=========
uplo: Specifies whether the matrix A is upper or lower triangular.
= 0: Upper triangular
= 1: Lower triangular
trans: Specifies the operation applied to A.
= 0: Solve A * x = s*b (No transpose)
= 1: Solve A'* x = s*b (Transpose)
diag: Specifies whether or not the matrix A is unit triangular.
= 0: Non-unit triangular
= 1: Unit triangular
normin: Specifies whether cnorm has been set or not.
= 1: cnorm contains the column norms on entry
= 0: cnorm is not set on entry. On exit, the norms will
be computed and stored in cnorm.
A: The triangular matrix A. If uplo = 0, the leading n by n
upper triangular part of the array A contains the upper
triangular matrix, and the strictly lower triangular part of
A is not referenced. If uplo = 1, the leading n by n lower
triangular part of the array A contains the lower triangular
matrix, and the strictly upper triangular part of A is not
referenced. If diag = 1, the diagonal elements of A are
also not referenced and are assumed to be 1.
x: On entry, the right hand side b of the triangular system.
On exit, x is overwritten by the solution vector x.
scale: The scaling factor s for the triangular system
A * x = s*b or A'* x = s*b.
If scale = 0, the matrix A is singular or badly scaled, and
the vector x is an exact or approximate solution to A*x = 0.
cnorm: If normin = 0, cnorm is an output argument and cnorm(j)
returns the 1-norm of the offdiagonal part of the j-th column
of A.
If normin = 1, cnorm is an input argument and cnorm(j)
contains the norm of the off-diagonal part of the j-th column
of A. If trans = 0, cnorm(j) must be greater than or equal
to the infinity-norm, and if trans = 1, cnorm(j)
must be greater than or equal to the 1-norm.
info: = 0: successful exit
< 0: if info = -k, the k-th argument had an illegal value
=for example
# Assume $a is upper triangular
$a = random (float, 100, 100);
$b = random(100);
$a = transpose($a);
$info = null;
$scale= null;
$cnorm = zeroes(100);
latrs($a, 0, 0, 0, 0,$b, $scale, $cnorm,$info);
=for bad
latrs ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*latrs = \&PDL::latrs;
=head2 gecon
=for sig
Signature: ([phys]A(n,n); int norm(); [phys]anorm(); [o,phys]rcond();int [o,phys]info())
=for ref
Estimates the reciprocal of the condition number of a general
real matrix A, in either the 1-norm or the infinity-norm, using
the LU factorization computed by C<getrf>.
An estimate is obtained for norm(inv(A)), and the reciprocal of the
condition number is computed as
rcond = 1 / ( norm(A) * norm(inv(A)) ).
Arguments
=========
norm: Specifies whether the 1-norm condition number or the
infinity-norm condition number is required:
= 0: Infinity-norm.
= 1: 1-norm;
A: The factors L and U from the factorization A = P*L*U
as computed by getrf.
anorm: If norm = 0, the infinity-norm of the original matrix A.
If norm = 1, the 1-norm of the original matrix A.
rcond: The reciprocal of the condition number of the matrix A,
computed as rcond = 1/(norm(A) * norm(inv(A))).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 100, 100);
$anorm = $a->lange(1);
$ipiv = zeroes(long, 100);
$info = null;
getrf($a, $ipiv, $info);
($rcond, $info) = gecon($a, 1, $anorm) unless $info != 0;
=for bad
gecon ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gecon = \&PDL::gecon;
=head2 sycon
=for sig
Signature: ([phys]A(n,n); int uplo(); int ipiv(n); [phys]anorm(); [o,phys]rcond();int [o,phys]info())
=for ref
Estimates the reciprocal of the condition number (in the
1-norm) of a real symmetric matrix A using the factorization
A = U*D*U' or A = L*D*L' computed by C<sytrf>.
An estimate is obtained for norm(inv(A)), and the reciprocal of the
condition number is computed as rcond = 1 / (anorm * norm(inv(A))).
Arguments
=========
uplo: Specifies whether the details of the factorization are stored
as an upper or lower triangular matrix.
= 0: Upper triangular, form is A = U*D*U';
= 1: Lower triangular, form is A = L*D*L'.
A: The block diagonal matrix D and the multipliers used to
obtain the factor U or L as computed by sytrf.
ipiv: Details of the interchanges and the block structure of D
as determined by sytrf.
anorm: The 1-norm of the original matrix A.
rcond: The reciprocal of the condition number of the matrix A,
computed as rcond = 1/(anorm * aimvnm), where ainvnm is an
estimate of the 1-norm of inv(A) computed in this routine.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
=for example
# Assume $a is symmetric
$a = random (float, 100, 100);
$anorm = $a->lansy(1,1);
$ipiv = zeroes(long, 100);
$info = null;
sytrf($a, 1,$ipiv, $info);
($rcond, $info) = sycon($a, 1, $anorm) unless $info != 0;
=for bad
sycon ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*sycon = \&PDL::sycon;
=head2 pocon
=for sig
Signature: ([phys]A(n,n); int uplo(); [phys]anorm(); [o,phys]rcond();int [o,phys]info())
=for ref
Estimates the reciprocal of the condition number (in the
1-norm) of a real symmetric positive definite matrix using the
Cholesky factorization A = U'*U or A = L*L' computed by C<potrf>.
An estimate is obtained for norm(inv(A)), and the reciprocal of the
condition number is computed as rcond = 1 / (anorm * norm(inv(A))).
Arguments
=========
uplo: = 0: Upper triangle of A is stored;
= 1: Lower triangle of A is stored.
A: The triangular factor U or L from the Cholesky factorization
A = U'*U or A = L*L', as computed by potrf.
anorm: The 1-norm of the matrix A.
rcond: The reciprocal of the condition number of the matrix A,
computed as rcond = 1/(anorm * ainvnm), where ainvnm is an
estimate of the 1-norm of inv(A) computed in this routine.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
# Assume $a is symmetric positive definite
$a = random (float, 100, 100);
$anorm = $a->lansy(1,1);
$info = null;
potrf($a, 0, $info);
($rcond, $info) = pocon($a, 1, $anorm) unless $info != 0;
=for bad
pocon ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*pocon = \&PDL::pocon;
=head2 trcon
=for sig
Signature: ([phys]A(n,n); int norm();int uplo();int diag(); [o,phys]rcond();int [o,phys]info())
=for ref
Estimates the reciprocal of the condition number of a
triangular matrix A, in either the 1-norm or the infinity-norm.
The norm of A is computed and an estimate is obtained for
norm(inv(A)), then the reciprocal of the condition number is
computed as
rcond = 1 / ( norm(A) * norm(inv(A)) ).
Arguments
=========
norm: Specifies whether the 1-norm condition number or the
infinity-norm condition number is required:
= 0: Infinity-norm.
= 1: 1-norm;
uplo: = 0: A is upper triangular;
= 1: A is lower triangular.
diag: = 0: A is non-unit triangular;
= 1: A is unit triangular.
A: The triangular matrix A. If uplo = 0, the leading N-by-N
upper triangular part of the array A contains the upper
triangular matrix, and the strictly lower triangular part of
A is not referenced. If uplo = 1, the leading N-by-N lower
triangular part of the array A contains the lower triangular
matrix, and the strictly upper triangular part of A is not
referenced. If diag = 1, the diagonal elements of A are
also not referenced and are assumed to be 1.
rcond: The reciprocal of the condition number of the matrix A,
computed as rcond = 1/(norm(A) * norm(inv(A))).
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
# Assume $a is upper triangular
$a = random (float, 100, 100);
$info = null;
($rcond, $info) = trcon($a, 1, 1, 0) unless $info != 0;
=for bad
trcon ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*trcon = \&PDL::trcon;
=head2 geqp3
=for sig
Signature: ([io,phys]A(m,n); int [io,phys]jpvt(n); [o,phys]tau(k); int [o,phys]info())
=for ref
geqp3 computes a QR factorization using Level 3 BLAS with column pivoting of a
matrix A:
A*P = Q*R
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v'
where tau is a real/complex scalar, and v is a real/complex vector
with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in
A(i+1:m,i), and tau in tau(i).
Arguments
=========
A: On entry, the M-by-N matrix A.
On exit, the upper triangle of the array contains the
min(M,N)-by-N upper trapezoidal matrix R; the elements below
the diagonal, together with the array tau, represent the
orthogonal matrix Q as a product of min(M,N) elementary
reflectors.
jpvt: On entry, if jpvt(J)!=0, the J-th column of A is permuted
to the front of A*P (a leading column); if jpvt(J)=0,
the J-th column of A is a free column.
On exit, if jpvt(J)=K, then the J-th column of A*P was the
the K-th column of A.
tau: The scalar factors of the elementary reflectors.
info: = 0: successful exit.
< 0: if info = -i, the i-th argument had an illegal value.
=for example
$a = random (float, 100, 50);
$info = null;
$tau = zeroes(float, 50);
$jpvt = zeroes(long, 50);
geqp3($a, $jpvt, $tau, $info);
=for bad
geqp3 ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*geqp3 = \&PDL::geqp3;
=head2 geqrf
=for sig
Signature: ([io,phys]A(m,n); [o,phys]tau(k); int [o,phys]info())
=for ref
geqrf computes a QR factorization of a
matrix A:
A = Q * R
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v'
where tau is a real/complex scalar, and v is a real/complex vector
with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in
A(i+1:m,i), and tau in tau(i).
Arguments
=========
A: On exit, the elements on and above the diagonal of the array
contain the min(M,N)-by-N upper trapezoidal matrix R (R is
upper triangular if m >= n); the elements below the diagonal,
with the array TAU, represent the orthogonal matrix Q as a
product of min(m,n) elementary reflectors.
tau: The scalar factors of the elementary reflectors.
info: = 0: successful exit.
< 0: if info = -i, the i-th argument had an illegal value.
=for example
$a = random (float, 100, 50);
$info = null;
$tau = zeroes(float, 50);
geqrf($a, $tau, $info);
=for bad
geqrf ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*geqrf = \&PDL::geqrf;
=head2 orgqr
=for sig
Signature: ([io,phys]A(m,n); [phys]tau(k); int [o,phys]info())
=for ref
Generates an M-by-N real matrix Q with orthonormal columns,
which is defined as the first N columns of a product of K elementary
reflectors of order M
Q = H(1) H(2) . . . H(k)
as returned by geqrf or geqp3.
Arguments
=========
A: On entry, the i-th column must contain the vector which
defines the elementary reflector H(i), for i = 1,2,...,k, as
returned by geqrf or geqp3 in the first k columns of its array
argument A.
On exit, the M-by-N matrix Q.
tau: tau(i) must contain the scalar factor of the elementary
reflector H(i), as returned by geqrf or geqp3.
info: = 0: successful exit
< 0: if info = -i, the i-th argument has an illegal value
=for example
$a = random (float, 100, 50);
$info = null;
$tau = zeroes(float, 50);
geqrf($a, $tau, $info);
orgqr($a, $tau, $info) unless $info != 0;
=for bad
orgqr ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*orgqr = \&PDL::orgqr;
=head2 ormqr
=for sig
Signature: ([phys]A(p,k); int side(); int trans(); [phys]tau(k); [io,phys]C(m,n);int [o,phys]info())
=for ref
Overwrites the general real M-by-N matrix C with
side = 0 side = 1
trans = 0: Q * C C * Q
trans = 1: Q' * C C * Q'
where Q is a real orthogonal matrix defined as the product of k
elementary reflectors
Q = H(1) H(2) . . . H(k)
as returned by geqrf or geqp3.
Q is of order M if C<side> = 0 and of order N
if C<side> = 1.
Arguments
=========
side: = 0: apply Q or Q' from the Left;
= 1: apply Q or Q' from the Right.
trans: = 0: No transpose, apply Q;
= 1: Transpose, apply Q'.
A: The i-th column must contain the vector which defines the
elementary reflector H(i), for i = 1,2,...,k, as returned by
geqrf or geqp3 in the first k columns of its array argument A.
A is modified by the routine but restored on exit.
tau: tau(i) must contain the scalar factor of the elementary
reflector H(i), as returned by geqrf or geqp3.
C: On entry, the M-by-N matrix C.
On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 50, 100);
$a = transpose($a);
$info = null;
$tau = zeroes(float, 50);
geqrf($a, $tau, $info);
$c = random(70,50);
# $c will contain the result
$c->reshape(70,100);
$c = transpose($c);
ormqr($a, $tau, $c, $info);
=for bad
ormqr ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*ormqr = \&PDL::ormqr;
=head2 gelqf
=for sig
Signature: ([io,phys]A(m,n); [o,phys]tau(k); int [o,phys]info())
=for ref
Computes an LQ factorization of a real M-by-N matrix A:
A = L * Q.
The matrix Q is represented as a product of elementary reflectors
Q = H(k) . . . H(2) H(1), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v'
where tau is a real scalar, and v is a real vector with
v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n),
and tau in tau(i).
Arguments
=========
A: On entry, the M-by-N matrix A.
On exit, the elements on and below the diagonal of the array
contain the m-by-min(m,n) lower trapezoidal matrix L (L is
lower triangular if m <= n); the elements above the diagonal,
with the array tau, represent the orthogonal matrix Q as a
product of elementary reflectors.
tau: The scalar factors of the elementary reflectors.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 100, 50);
$info = null;
$tau = zeroes(float, 50);
gelqf($a, $tau, $info);
=for bad
gelqf ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gelqf = \&PDL::gelqf;
=head2 orglq
=for sig
Signature: ([io,phys]A(m,n); [phys]tau(k); int [o,phys]info())
=for ref
Generates an M-by-N real matrix Q with orthonormal rows,
which is defined as the first M rows of a product of K elementary
reflectors of order N
Q = H(k) . . . H(2) H(1)
as returned by gelqf.
Arguments
=========
A: On entry, the i-th row must contain the vector which defines
the elementary reflector H(i), for i = 1,2,...,k, as returned
by gelqf in the first k rows of its array argument A.
On exit, the M-by-N matrix Q.
tau: tau(i) must contain the scalar factor of the elementary
reflector H(i), as returned by gelqf.
info: = 0: successful exit
< 0: if info = -i, the i-th argument has an illegal value
=for example
$a = random (float, 100, 50);
$info = null;
$tau = zeroes(float, 50);
gelqf($a, $tau, $info);
orglq($a, $tau, $info) unless $info != 0;
=for bad
orglq ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*orglq = \&PDL::orglq;
=head2 ormlq
=for sig
Signature: ([phys]A(k,p); int side(); int trans(); [phys]tau(k); [io,phys]C(m,n);int [o,phys]info())
=for ref
Overwrites the general real M-by-N matrix C with
side = 0 side = 1
trans = 0: Q * C C * Q
trans = 1: Q' * C C * Q'
where Q is a real orthogonal matrix defined as the product of k
elementary reflectors
Q = H(k) . . . H(2) H(1)
as returned by gelqf.
Q is of order M if C<side> = 0 and of order N
if C<side> = 1.
Arguments
=========
side: = 0: apply Q or Q' from the Left;
= 1: apply Q or Q' from the Right.
trans: = 0: No transpose, apply Q;
= 1: Transpose, apply Q'.
A: The i-th row must contain the vector which defines the
elementary reflector H(i), for i = 1,2,...,k, as returned by
gelqf in the first k rows of its array argument A.
A is modified by the routine but restored on exit.
tau: tau(i) must contain the scalar factor of the elementary
reflector H(i), as returned by gelqf.
C: On entry, the M-by-N matrix C.
On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 50, 100);
$a = transpose($a);
$info = null;
$tau = zeroes(float, 50);
gelqf($a, $tau, $info);
$c = random(70,50);
# $c will contain the result
$c->reshape(70,100);
$c = transpose($c);
ormlq($a, $tau, $c, $info);
=for bad
ormlq ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*ormlq = \&PDL::ormlq;
=head2 geqlf
=for sig
Signature: ([io,phys]A(m,n); [o,phys]tau(k); int [o,phys]info())
=for ref
Computes a QL factorization of a real M-by-N matrix A:
A = Q * L
The matrix Q is represented as a product of elementary reflectors
Q = H(k) . . . H(2) H(1), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v'
where tau is a real scalar, and v is a real vector with
v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in
A(1:m-k+i-1,n-k+i), and tau in TAU(i).
Arguments
=========
A: On entry, the M-by-N matrix A.
On exit,
if m >= n, the lower triangle of the subarray
A(m-n+1:m,1:n) contains the N-by-N lower triangular matrix L;
if m <= n, the elements on and below the (n-m)-th
superdiagonal contain the M-by-N lower trapezoidal matrix L;
the remaining elements, with the array tau, represent the
orthogonal matrix Q as a product of elementary reflectors.
tau: The scalar factors of the elementary reflectors.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 100, 50);
$info = null;
$tau = zeroes(float, 50);
geqlf($a, $tau, $info);
=for bad
geqlf ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*geqlf = \&PDL::geqlf;
=head2 orgql
=for sig
Signature: ([io,phys]A(m,n); [phys]tau(k); int [o,phys]info())
=for ref
Generates an M-by-N real matrix Q with orthonormal columns,
which is defined as the last N columns of a product of K elementary
reflectors of order M
Q = H(k) . . . H(2) H(1)
as returned by geqlf.
Arguments
=========
A: On entry, the (n-k+i)-th column must contain the vector which
defines the elementary reflector H(i), for i = 1,2,...,k, as
returned by geqlf in the last k columns of its array
argument A.
On exit, the M-by-N matrix Q.
tau: tau(i) must contain the scalar factor of the elementary
reflector H(i), as returned by geqlf.
info: = 0: successful exit
< 0: if info = -i, the i-th argument has an illegal value
=for example
$a = random (float, 100, 50);
$info = null;
$tau = zeroes(float, 50);
geqlf($a, $tau, $info);
orgql($a, $tau, $info) unless $info != 0;
=for bad
orgql ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*orgql = \&PDL::orgql;
=head2 ormql
=for sig
Signature: ([phys]A(p,k); int side(); int trans(); [phys]tau(k); [io,phys]C(m,n);int [o,phys]info())
=for ref
Overwrites the general real M-by-N matrix C with
side = 0 side = 1
trans = 0: Q * C C * Q
trans = 1: Q' * C C * Q'
where Q is a real orthogonal matrix defined as the product of k
elementary reflectors
Q = H(k) . . . H(2) H(1)
as returned by geqlf.
Q is of order M if C<side> = 0 and of order N
if C<side> = 1.
Arguments
=========
side: = 0: apply Q or Q' from the Left;
= 1: apply Q or Q' from the Right.
trans: = 0: No transpose, apply Q;
= 1: Transpose, apply Q'.
A: The i-th row must contain the vector which defines the
elementary reflector H(i), for i = 1,2,...,k, as returned by
geqlf in the last k rows of its array argument A.
A is modified by the routine but restored on exit.
tau: tau(i) must contain the scalar factor of the elementary
reflector H(i), as returned by geqlf.
C: On entry, the M-by-N matrix C.
On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 50, 100);
$a = transpose($a);
$info = null;
$tau = zeroes(float, 50);
geqlf($a, $tau, $info);
$c = random(70,50);
# $c will contain the result
$c->reshape(70,100);
$c = transpose($c);
ormql($a, $tau, $c, $info);
=for bad
ormql ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*ormql = \&PDL::ormql;
=head2 gerqf
=for sig
Signature: ([io,phys]A(m,n); [o,phys]tau(k); int [o,phys]info())
=for ref
Computes an RQ factorization of a real M-by-N matrix A:
A = R * Q.
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v'
where tau is a real scalar, and v is a real vector with
v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in
A(m-k+i,1:n-k+i-1), and tau in TAU(i).
Arguments
=========
A: On entry, the M-by-N matrix A.
On exit,
if m <= n, the upper triangle of the subarray
A(1:m,n-m+1:n) contains the M-by-M upper triangular matrix R;
if m >= n, the elements on and above the (m-n)-th subdiagonal
contain the M-by-N upper trapezoidal matrix R;
the remaining elements, with the array tau, represent the
orthogonal matrix Q as a product of min(m,n) elementary
reflectors (see Further Details).
tau: The scalar factors of the elementary reflectors.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 100, 50);
$info = null;
$tau = zeroes(float, 50);
gerqf($a, $tau, $info);
=for bad
gerqf ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gerqf = \&PDL::gerqf;
=head2 orgrq
=for sig
Signature: ([io,phys]A(m,n); [phys]tau(k); int [o,phys]info())
=for ref
Generates an M-by-N real matrix Q with orthonormal rows,
which is defined as the last M rows of a product of K elementary
reflectors of order N
Q = H(1) H(2) . . . H(k)
as returned by gerqf.
Arguments
=========
A: On entry, the (m-k+i)-th row must contain the vector which
defines the elementary reflector H(i), for i = 1,2,...,k, as
returned by gerqf in the last k rows of its array argument
A.
On exit, the M-by-N matrix Q.
tau: tau(i) must contain the scalar factor of the elementary
reflector H(i), as returned by gerqf.
info: = 0: successful exit
< 0: if info = -i, the i-th argument has an illegal value
=for example
$a = random (float, 100, 50);
$info = null;
$tau = zeroes(float, 50);
gerqf($a, $tau, $info);
orgrq($a, $tau, $info) unless $info != 0;
=for bad
orgrq ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*orgrq = \&PDL::orgrq;
=head2 ormrq
=for sig
Signature: ([phys]A(k,p); int side(); int trans(); [phys]tau(k); [io,phys]C(m,n);int [o,phys]info())
=for ref
Overwrites the general real M-by-N matrix C with
side = 0 side = 1
trans = 0: Q * C C * Q
trans = 1: Q' * C C * Q'
where Q is a real orthogonal matrix defined as the product of k
elementary reflectors
Q = H(1) H(2) . . . H(k)
as returned by gerqf.
Q is of order M if C<side> = 0 and of order N
if C<side> = 1.
Arguments
=========
side: = 0: apply Q or Q' from the Left;
= 1: apply Q or Q' from the Right.
trans: = 0: No transpose, apply Q;
= 1: Transpose, apply Q'.
A: The i-th row must contain the vector which defines the
elementary reflector H(i), for i = 1,2,...,k, as returned by
gerqf in the last k rows of its array argument A.
A is modified by the routine but restored on exit.
tau: tau(i) must contain the scalar factor of the elementary
reflector H(i), as returned by gerqf.
C: On entry, the M-by-N matrix C.
On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 50, 100);
$a = transpose($a);
$info = null;
$tau = zeroes(float, 50);
gerqf($a, $tau, $info);
$c = random(70,50);
# $c will contain the result
$c->reshape(70,100);
$c = transpose($c);
ormrq($a, $tau, $c, $info);
=for bad
ormrq ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*ormrq = \&PDL::ormrq;
=head2 tzrzf
=for sig
Signature: ([io,phys]A(m,n); [o,phys]tau(k); int [o,phys]info())
=for ref
Reduces the M-by-N ( M <= N ) real upper trapezoidal matrix A
to upper triangular form by means of orthogonal transformations.
The upper trapezoidal matrix A is factored as
A = ( R 0 ) * Z,
where Z is an N-by-N orthogonal matrix and R is an M-by-M upper
triangular matrix.
The factorization is obtained by Householder's method. The kth
transformation matrix, Z( k ), which is used to introduce zeros into
the ( m - k + 1 )th row of A, is given in the form
Z( k ) = ( I 0 ),
( 0 T( k ) )
where
T( k ) = I - tau*u( k )*u( k )', u( k ) = ( 1 ),
( 0 )
( z( k ) )
tau is a scalar and z( k ) is an ( n - m ) element vector.
tau and z( k ) are chosen to annihilate the elements of the kth row
of X.
The scalar tau is returned in the kth element of C<tau> and the vector
u( k ) in the kth row of A, such that the elements of z( k ) are
in a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in
the upper triangular part of A.
Z is given by
Z = Z( 1 ) * Z( 2 ) * ... * Z( m ).
Arguments
=========
A: On entry, the leading M-by-N upper trapezoidal part of the
array A must contain the matrix to be factorized.
On exit, the leading M-by-M upper triangular part of A
contains the upper triangular matrix R, and elements M+1 to
N of the first M rows of A, with the array tau, represent the
orthogonal matrix Z as a product of M elementary reflectors.
tau: The scalar factors of the elementary reflectors.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 50, 100);
$info = null;
$tau = zeroes(float, 50);
tzrzf($a, $tau, $info);
=for bad
tzrzf ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*tzrzf = \&PDL::tzrzf;
=head2 ormrz
=for sig
Signature: ([phys]A(k,p); int side(); int trans(); [phys]tau(k); [io,phys]C(m,n);int [o,phys]info())
=for ref
Overwrites the general real M-by-N matrix C with
side = 0 side = 1
trans = 0: Q * C C * Q
trans = 1: Q' * C C * Q'
where Q is a real orthogonal matrix defined as the product of k
elementary reflectors
Q = H(1) H(2) . . . H(k)
as returned by tzrzf.
Q is of order M if C<side> = 0 and of order N
if C<side> = 1.
Arguments
=========
side: = 0: apply Q or Q' from the Left;
= 1: apply Q or Q' from the Right.
trans: = 0: No transpose, apply Q;
= 1: Transpose, apply Q'.
A: The i-th row must contain the vector which defines the
elementary reflector H(i), for i = 1,2,...,k, as returned by
tzrzf in the last k rows of its array argument A.
A is modified by the routine but restored on exit.
tau: tau(i) must contain the scalar factor of the elementary
reflector H(i), as returned by tzrzf.
C: On entry, the M-by-N matrix C.
On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (float, 50, 100);
$a = transpose($a);
$info = null;
$tau = zeroes(float, 50);
tzrzf($a, $tau, $info);
$c = random(70,50);
# $c will contain the result
$c->reshape(70,100);
$c = transpose($c);
ormrz($a, $tau, $c, $info);
=for bad
ormrz ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*ormrz = \&PDL::ormrz;
=head2 gehrd
=for sig
Signature: ([io,phys]A(n,n); int [phys]ilo();int [phys]ihi();[o,phys]tau(k); int [o,phys]info())
=for ref
Reduces a real general matrix A to upper Hessenberg form H by
an orthogonal similarity transformation: Q' * A * Q = H .
Further Details
===============
The matrix Q is represented as a product of (ihi-ilo) elementary
reflectors
Q = H(ilo) H(ilo+1) . . . H(ihi-1).
Each H(i) has the form
H(i) = I - tau * v * v'
where tau is a real scalar, and v is a real vector with
v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on
exit in A(i+2:ihi,i), and tau in tau(i).
The contents of A are illustrated by the following example, with
n = 7, ilo = 2 and ihi = 6:
on entry, on exit,
( a a a a a a a ) ( a a h h h h a )
( a a a a a a ) ( a h h h h a )
( a a a a a a ) ( h h h h h h )
( a a a a a a ) ( v2 h h h h h )
( a a a a a a ) ( v2 v3 h h h h )
( a a a a a a ) ( v2 v3 v4 h h h )
( a ) ( a )
where a denotes an element of the original matrix A, h denotes a
modified element of the upper Hessenberg matrix H, and vi denotes an
element of the vector defining H(i).
Arguments
=========
ilo:
ihi: It is assumed that A is already upper triangular in rows
and columns 1:ilo-1 and ihi+1:N. ilo and ihi are normally
set by a previous call to gebal; otherwise they should be
set to 1 and N respectively. See Further Details.
1 <= ilo <= ihi <= N, if N > 0; ilo=1 and ihi=0, if N=0.
A: On entry, the N-by-N general matrix to be reduced.
On exit, the upper triangle and the first subdiagonal of A
are overwritten with the upper Hessenberg matrix H, and the
elements below the first subdiagonal, with the array tau,
represent the orthogonal matrix Q as a product of elementary
reflectors. See Further Details.
tau: The scalar factors of the elementary reflectors (see Further
Details). Elements 1:ilo-1 and ihi:N-1 of tau are set to
zero. (dimension (N-1))
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
=for example
$a = random (50, 50);
$info = null;
$tau = zeroes(50);
gehrd($a, 1, 50, $tau, $info);
=for bad
gehrd ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gehrd = \&PDL::gehrd;
=head2 orghr
=for sig
Signature: ([io,phys]A(n,n); int [phys]ilo();int [phys]ihi();[phys]tau(k); int [o,phys]info())
=for ref
Generates a real orthogonal matrix Q which is defined as the
product of ihi-ilo elementary reflectors of order N, as returned by
C<gehrd>:
Q = H(ilo) H(ilo+1) . . . H(ihi-1).
Arguments
=========
ilo:
ihi: ilo and ihi must have the same values as in the previous call
of gehrd. Q is equal to the unit matrix except in the
submatrix Q(ilo+1:ihi,ilo+1:ihi).
1 <= ilo <= ihi <= N, if N > 0; ilo=1 and ihi=0, if N=0.
A: On entry, the vectors which define the elementary reflectors,
as returned by gehrd.
On exit, the N-by-N orthogonal matrix Q.
tau: tau(i) must contain the scalar factor of the elementary
reflector H(i), as returned by gehrd.(dimension (N-1))
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (50, 50);
$info = null;
$tau = zeroes(50);
gehrd($a, 1, 50, $tau, $info);
orghr($a, 1, 50, $tau, $info);
=for bad
orghr ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*orghr = \&PDL::orghr;
=head2 hseqr
=for sig
Signature: ([io,phys]H(n,n); int job();int compz();int [phys]ilo();int [phys]ihi();[o,phys]wr(n); [o,phys]wi(n);[o,phys]Z(m,m); int [o,phys]info())
=for ref
Computes the eigenvalues of a real upper Hessenberg matrix H
and, optionally, the matrices T and Z from the Schur decomposition
H = Z T Z**T, where T is an upper quasi-triangular matrix (the Schur
form), and Z is the orthogonal matrix of Schur vectors.
Optionally Z may be postmultiplied into an input orthogonal matrix Q,
so that this routine can give the Schur factorization of a matrix A
which has been reduced to the Hessenberg form H by the orthogonal
matrix Q: A = Q*H*Q**T = (QZ)*T*(QZ)**T.
Arguments
=========
job: = 0: compute eigenvalues only;
= 1: compute eigenvalues and the Schur form T.
compz: = 0: no Schur vectors are computed;
= 1: Z is initialized to the unit matrix and the matrix Z
of Schur vectors of H is returned;
= 2: Z must contain an orthogonal matrix Q on entry, and
the product Q*Z is returned.
ilo:
ihi: It is assumed that H is already upper triangular in rows
and columns 1:ilo-1 and ihi+1:N. ilo and ihi are normally
set by a previous call to gebal, and then passed to gehrd
when the matrix output by gebal is reduced to Hessenberg
form. Otherwise ilo and ihi should be set to 1 and N
respectively.
1 <= ilo <= ihi <= N, if N > 0; ilo=1 and ihi=0, if N=0.
H: On entry, the upper Hessenberg matrix H.
On exit, if job = 1, H contains the upper quasi-triangular
matrix T from the Schur decomposition (the Schur form);
2-by-2 diagonal blocks (corresponding to complex conjugate
pairs of eigenvalues) are returned in standard form, with
H(i,i) = H(i+1,i+1) and H(i+1,i)*H(i,i+1) < 0. If job = 0,
the contents of H are unspecified on exit.
wr:
wi: The real and imaginary parts, respectively, of the computed
eigenvalues. If two eigenvalues are computed as a complex
conjugate pair, they are stored in consecutive elements of
wr and wi, say the i-th and (i+1)th, with wi(i) > 0 and
wi(i+1) < 0. If job = 1, the eigenvalues are stored in the
same order as on the diagonal of the Schur form returned in
H, with wr(i) = H(i,i) and, if H(i:i+1,i:i+1) is a 2-by-2
diagonal block, wi(i) = sqrt(H(i+1,i)*H(i,i+1)) and
wi(i+1) = -wi(i).
Z: If compz = 0: Z is not referenced.
If compz = 1: on entry, Z need not be set, and on exit, Z
contains the orthogonal matrix Z of the Schur vectors of H.
If compz = 2: on entry Z must contain an N-by-N matrix Q,
which is assumed to be equal to the unit matrix except for
the submatrix Z(ilo:ihi,ilo:ihi); on exit Z contains Q*Z.
Normally Q is the orthogonal matrix generated by orghr after
the call to gehrd which formed the Hessenberg matrix H.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
> 0: if info = i, hseqr failed to compute all of the
eigenvalues in a total of 30*(ihi-ilo+1) iterations;
elements 1:ilo-1 and i+1:n of wr and wi contain those
eigenvalues which have been successfully computed.
=for example
$a = random (50, 50);
$info = null;
$tau = zeroes(50);
$z= zeroes(1,1);
gehrd($a, 1, 50, $tau, $info);
hseqr($a,0,0,1,50,($wr=null),($wi=null),$z,$info);
=for bad
hseqr ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*hseqr = \&PDL::hseqr;
=head2 trevc
=for sig
Signature: ([io,phys]T(n,n); int side();int howmny();int [phys]select(q);[io,phys]VL(m,r); [io,phys]VR(p,s);int [o,phys]m(); int [o,phys]info())
=for ref
Computes some or all of the right and/or left eigenvectors of
a real upper quasi-triangular matrix T.
The right eigenvector x and the left eigenvector y of T corresponding
to an eigenvalue w are defined by:
T*x = w*x, y'*T = w*y'
where y' denotes the conjugate transpose of the vector y.
If all eigenvectors are requested, the routine may either return the
matrices X and/or Y of right or left eigenvectors of T, or the
products Q*X and/or Q*Y, where Q is an input orthogonal
matrix. If T was obtained from the real-Schur factorization of an
original matrix A = Q*T*Q', then Q*X and Q*Y are the matrices of
right or left eigenvectors of A.
T must be in Schur canonical form (as returned by hseqr), that is,
block upper triangular with 1-by-1 and 2-by-2 diagonal blocks; each
2-by-2 diagonal block has its diagonal elements equal and its
off-diagonal elements of opposite sign. Corresponding to each 2-by-2
diagonal block is a complex conjugate pair of eigenvalues and
eigenvectors; only one eigenvector of the pair is computed, namely
the one corresponding to the eigenvalue with positive imaginary part.
Further Details
===============
The algorithm used in this program is basically backward (forward)
substitution, with scaling to make the the code robust against
possible overflow.
Each eigenvector is normalized so that the element of largest
magnitude has magnitude 1; here the magnitude of a complex number
(x,y) is taken to be |x| + |y|.
Arguments
=========
side: = 0 : compute both right and left eigenvectors;
= 1 : compute right eigenvectors only;
= 2 : compute left eigenvectors only.
howmny: = 0: compute all right and/or left eigenvectors;
= 1: compute all right and/or left eigenvectors,
and backtransform them using the input matrices
supplied in VR and/or VL;
= 2: compute selected right and/or left eigenvectors,
specified by the logical array select.
select: If howmny = 2, select specifies the eigenvectors to be
computed.
If howmny = 0 or 1, select is not referenced.
To select the real eigenvector corresponding to a real
eigenvalue w(j), select(j) must be set to TRUE. To select
the complex eigenvector corresponding to a complex conjugate
pair w(j) and w(j+1), either select(j) or select(j+1) must be
set to TRUE; then on exit select(j) is TRUE and
select(j+1) is FALSE.
T: The upper quasi-triangular matrix T in Schur canonical form.
VL: On entry, if side = 2 or 0 and howmny = 1, VL must
contain an N-by-N matrix Q (usually the orthogonal matrix Q
of Schur vectors returned by hseqr).
On exit, if side = 2 or 0, VL contains:
if howmny = 0, the matrix Y of left eigenvectors of T;
VL has the same quasi-lower triangular form
as T'. If T(i,i) is a real eigenvalue, then
the i-th column VL(i) of VL is its
corresponding eigenvector. If T(i:i+1,i:i+1)
is a 2-by-2 block whose eigenvalues are
complex-conjugate eigenvalues of T, then
VL(i)+sqrt(-1)*VL(i+1) is the complex
eigenvector corresponding to the eigenvalue
with positive real part.
if howmny = 1, the matrix Q*Y;
if howmny = 2, the left eigenvectors of T specified by
select, stored consecutively in the columns
of VL, in the same order as their
eigenvalues.
A complex eigenvector corresponding to a complex eigenvalue
is stored in two consecutive columns, the first holding the
real part, and the second the imaginary part.
If side = 1, VL is not referenced.
VR: On entry, if side = 1 or 0 and howmny = 1, VR must
contain an N-by-N matrix Q (usually the orthogonal matrix Q
of Schur vectors returned by hseqr).
On exit, if side = 1 or 0, VR contains:
if howmny = 0, the matrix X of right eigenvectors of T;
VR has the same quasi-upper triangular form
as T. If T(i,i) is a real eigenvalue, then
the i-th column VR(i) of VR is its
corresponding eigenvector. If T(i:i+1,i:i+1)
is a 2-by-2 block whose eigenvalues are
complex-conjugate eigenvalues of T, then
VR(i)+sqrt(-1)*VR(i+1) is the complex
eigenvector corresponding to the eigenvalue
with positive real part.
if howmny = 1, the matrix Q*X;
if howmny = 2, the right eigenvectors of T specified by
select, stored consecutively in the columns
of VR, in the same order as their
eigenvalues.
A complex eigenvector corresponding to a complex eigenvalue
is stored in two consecutive columns, the first holding the
real part and the second the imaginary part.
If side = 2, VR is not referenced.
m: The number of columns in the arrays VL and/or VR actually
used to store the eigenvectors.
If howmny = 0 or 1, m is set to N.
Each selected real eigenvector occupies one column and each
selected complex eigenvector occupies two columns.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random (50, 50);
$info = null;
$tau = zeroes(50);
$z= zeroes(1,1);
gehrd($a, 1, 50, $tau, $info);
hseqr($a,0,0,1,50,($wr=null),($wi=null),$z,$info);
=for bad
trevc ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*trevc = \&PDL::trevc;
=head2 tgevc
=for sig
Signature: ([io,phys]A(n,n); int side();int howmny();[io,phys]B(n,n);int [phys]select(q);[io,phys]VL(m,r); [io,phys]VR(p,s);int [o,phys]m(); int [o,phys]info())
=for ref
Computes some or all of the right and/or left generalized
eigenvectors of a pair of real upper triangular matrices (A,B).
The right generalized eigenvector x and the left generalized
eigenvector y of (A,B) corresponding to a generalized eigenvalue
w are defined by:
(A - wB) * x = 0 and y**H * (A - wB) = 0
where y**H denotes the conjugate tranpose of y.
If an eigenvalue w is determined by zero diagonal elements of both A
and B, a unit vector is returned as the corresponding eigenvector.
If all eigenvectors are requested, the routine may either return
the matrices X and/or Y of right or left eigenvectors of (A,B), or
the products Z*X and/or Q*Y, where Z and Q are input orthogonal
matrices. If (A,B) was obtained from the generalized real-Schur
factorization of an original pair of matrices
(A0,B0) = (Q*A*Z**H,Q*B*Z**H),
then Z*X and Q*Y are the matrices of right or left eigenvectors of
A.
A must be block upper triangular, with 1-by-1 and 2-by-2 diagonal
blocks. Corresponding to each 2-by-2 diagonal block is a complex
conjugate pair of eigenvalues and eigenvectors; only one
eigenvector of the pair is computed, namely the one corresponding
to the eigenvalue with positive imaginary part.
Arguments
=========
side: = 0 : compute both right and left eigenvectors;
= 1 : compute right eigenvectors only;
= 2 : compute left eigenvectors only.
howmny: = 0 : compute all right and/or left eigenvectors;
= 1 : compute all right and/or left eigenvectors, and
backtransform them using the input matrices supplied
in VR and/or VL;
= 2 : compute selected right and/or left eigenvectors,
specified by the logical array select.
select: If howmny=2, select specifies the eigenvectors to be
computed.
If howmny=0 or 1, select is not referenced.
To select the real eigenvector corresponding to the real
eigenvalue w(j), select(j) must be set to TRUE To select
the complex eigenvector corresponding to a complex conjugate
pair w(j) and w(j+1), either select(j) or select(j+1) must
be set to TRUE.
A: The upper quasi-triangular matrix A.
B: The upper triangular matrix B. If A has a 2-by-2 diagonal
block, then the corresponding 2-by-2 block of B must be
diagonal with positive elements.
VL: On entry, if side = 2 or 0 and howmny = 1, VL must
contain an N-by-N matrix Q (usually the orthogonal matrix Q
of left Schur vectors returned by hgqez).
On exit, if side = 2 or 0, VL contains:
if howmny = 0, the matrix Y of left eigenvectors of (A,B);
if howmny = 1, the matrix Q*Y;
if howmny = 2, the left eigenvectors of (A,B) specified by
select, stored consecutively in the columns of
VL, in the same order as their eigenvalues.
If side = 1, VL is not referenced.
A complex eigenvector corresponding to a complex eigenvalue
is stored in two consecutive columns, the first holding the
real part, and the second the imaginary part.
VR: On entry, if side = 1 or 0 and howmny = 1, VR must
contain an N-by-N matrix Q (usually the orthogonal matrix Z
of right Schur vectors returned by hgeqz).
On exit, if side = 1 or 0, VR contains:
if howmny = 0, the matrix X of right eigenvectors of (A,B);
if howmny = 1, the matrix Z*X;
if howmny = 2, the right eigenvectors of (A,B) specified by
select, stored consecutively in the columns of
VR, in the same order as their eigenvalues.
If side = 2, VR is not referenced.
A complex eigenvector corresponding to a complex eigenvalue
is stored in two consecutive columns, the first holding the
real part and the second the imaginary part.
M: The number of columns in the arrays VL and/or VR actually
used to store the eigenvectors. If howmny = 0 or 1, M
is set to N. Each selected real eigenvector occupies one
column and each selected complex eigenvector occupies two
columns.
info: = 0: successful exit.
< 0: if info = -i, the i-th argument had an illegal value.
> 0: the 2-by-2 block (info:info+1) does not have a complex
eigenvalue.
=for example
$a = random (50, 50);
$info = null;
$tau = zeroes(50);
$z= zeroes(1,1);
gehrd($a, 1, 50, $tau, $info);
hseqr($a,0,0,1,50,($wr=null),($wi=null),$z,$info);
=for bad
tgevc ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*tgevc = \&PDL::tgevc;
=head2 gebal
=for sig
Signature: ([io,phys]A(n,n); int job(); int [o,phys]ilo();int [o,phys]ihi();[o,phys]scale(n); int [o,phys]info())
=for ref
Balances a general real matrix A. This involves, first,
permuting A by a similarity transformation to isolate eigenvalues
in the first 1 to ilo-1 and last ihi+1 to N elements on the
diagonal; and second, applying a diagonal similarity transformation
to rows and columns ilo to ihi to make the rows and columns as
close in norm as possible. Both steps are optional.
Balancing may reduce the 1-norm of the matrix, and improve the
accuracy of the computed eigenvalues and/or eigenvectors.
Further Details
===============
The permutations consist of row and column interchanges which put
the matrix in the form
( T1 X Y )
P A P = ( 0 B Z )
( 0 0 T2 )
where T1 and T2 are upper triangular matrices whose eigenvalues lie
along the diagonal. The column indices ilo and ihi mark the starting
and ending columns of the submatrix B. Balancing consists of applying
a diagonal similarity transformation inv(D) * B * D to make the
1-norms of each row of B and its corresponding column nearly equal.
The output matrix is
( T1 X*D Y )
( 0 inv(D)*B*D inv(D)*Z ).
( 0 0 T2 )
Information about the permutations P and the diagonal matrix D is
returned in the vector C<scale>.
Arguments
=========
job: Specifies the operations to be performed on A:
= 0: none: simply set ilo = 1, ihi = N, scale(I) = 1.0
for i = 1,...,N;
= 1: permute only;
= 2: scale only;
= 3: both permute and scale.
A: On entry, the input matrix A.
On exit, A is overwritten by the balanced matrix.
If job = 0, A is not referenced.
See Further Details.
ilo:
ihi: ilo and ihi are set to integers such that on exit
A(i,j) = 0 if i > j and j = 1,...,ilo-1 or I = ihi+1,...,N.
If job = 0 or 2, ilo = 1 and ihi = N.
scale: Details of the permutations and scaling factors applied to
A. If P(j) is the index of the row and column interchanged
with row and column j and D(j) is the scaling factor
applied to row and column j, then
scale(j) = P(j) for j = 1,...,ilo-1
= D(j) for j = ilo,...,ihi
= P(j) for j = ihi+1,...,N.
The order in which the interchanges are made is N to ihi+1,
then 1 to ilo-1.
info: = 0: successful exit.
< 0: if info = -i, the i-th argument had an illegal value.
=for example
$a = random (50, 50);
$scale = zeroes(50);
$info = null;
$ilo = null;
$ihi = null;
gebal($a, $ilo, $ihi, $scale, $info);
=for bad
gebal ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gebal = \&PDL::gebal;
=head2 gebak
=for sig
Signature: ([io,phys]A(n,m); int job(); int side();int [phys]ilo();int [phys]ihi();[phys]scale(n); int [o,phys]info())
=for ref
gebak forms the right or left eigenvectors of a real general matrix
by backward transformation on the computed eigenvectors of the
balanced matrix output by gebal.
Arguments
=========
A: On entry, the matrix of right or left eigenvectors to be
transformed, as returned by hsein or trevc.
On exit, A is overwritten by the transformed eigenvectors.
job: Specifies the type of backward transformation required:
= 0 , do nothing, return immediately;
= 1, do backward transformation for permutation only;
= 2, do backward transformation for scaling only;
= 3, do backward transformations for both permutation and
scaling.
job must be the same as the argument job supplied to gebal.
side: = 0: V contains left eigenvectors.
= 1: V contains right eigenvectors;
ilo:
ihi: The integers ilo and ihi determined by gebal.
1 <= ilo <= ihi <= N, if N > 0; ilo=1 and ihi=0, if N=0.
Here N is the the number of rows of the matrix A.
scale: Details of the permutation and scaling factors, as returned
by gebal.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value.
=for example
$a = random (50, 50);
$scale = zeroes(50);
$info = null;
$ilo = null;
$ihi = null;
gebal($a, $ilo, $ihi, $scale, $info);
# Compute eigenvectors ($ev)
gebak($ev, $ilo, $ihi, $scale, $info);
=for bad
gebak ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gebak = \&PDL::gebak;
=head2 lange
=for sig
Signature: ([phys]A(n,m); int norm(); [o]b())
=for ref
Computes the value of the one norm, or the Frobenius norm, or
the infinity norm, or the element of largest absolute value of a
real matrix A.
Description
===========
returns the value
lange = ( max(abs(A(i,j))), norm = 0
(
( norm1(A), norm = 1
(
( normI(A), norm = 2
(
( normF(A), norm = 3
where norm1 denotes the one norm of a matrix (maximum column sum),
normI denotes the infinity norm of a matrix (maximum row sum) and
normF denotes the Frobenius norm of a matrix (square root of sum of
squares). Note that max(abs(A(i,j))) is not a matrix norm.
Arguments
=========
norm: Specifies the value to be returned in lange as described
above.
A: The n by m matrix A.
=for example
$a = random (float, 100, 100);
$norm = $a->lange(1);
=for bad
lange ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*lange = \&PDL::lange;
=head2 lansy
=for sig
Signature: ([phys]A(n,n); int uplo(); int norm(); [o]b())
=for ref
Computes the value of the one norm, or the Frobenius norm, or
the infinity norm, or the element of largest absolute value of a
real symmetric matrix A.
Description
===========
returns the value
lansy = ( max(abs(A(i,j))), norm = 0
(
( norm1(A), norm = 1
(
( normI(A), norm = 2
(
( normF(A), norm = 3
where norm1 denotes the one norm of a matrix (maximum column sum),
normI denotes the infinity norm of a matrix (maximum row sum) and
normF denotes the Frobenius norm of a matrix (square root of sum of
squares). Note that max(abs(A(i,j))) is not a matrix norm.
norm: Specifies the value to be returned in lansy as described
above.
uplo: Specifies whether the upper or lower triangular part of the
symmetric matrix A is to be referenced.
= 0: Upper triangular part of A is referenced
= 1: Lower triangular part of A is referenced
A: The symmetric matrix A. If uplo = 0, the leading n by n
upper triangular part of A contains the upper triangular part
of the matrix A, and the strictly lower triangular part of A
is not referenced. If uplo = 1, the leading n by n lower
triangular part of A contains the lower triangular part of
the matrix A, and the strictly upper triangular part of A is
not referenced.
=for example
# Assume $a is symmetric
$a = random (float, 100, 100);
$norm = $a->lansy(1, 1);
=for bad
lansy ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*lansy = \&PDL::lansy;
=head2 lantr
=for sig
Signature: ([phys]A(m,n);int uplo();int norm();int diag();[o]b())
=for ref
Computes the value of the one norm, or the Frobenius norm, or
the infinity norm, or the element of largest absolute value of a
trapezoidal or triangular matrix A.
Description
===========
returns the value
lantr = ( max(abs(A(i,j))), norm = 0
(
( norm1(A), norm = 1
(
( normI(A), norm = 2
(
( normF(A), norm = 3
where norm1 denotes the one norm of a matrix (maximum column sum),
normI denotes the infinity norm of a matrix (maximum row sum) and
normF denotes the Frobenius norm of a matrix (square root of sum of
squares). Note that max(abs(A(i,j))) is not a matrix norm.
norm: Specifies the value to be returned in lantr as described
above.
uplo: Specifies whether the matrix A is upper or lower trapezoidal.
= 0: Upper triangular part of A is referenced
= 1: Lower triangular part of A is referenced
Note that A is triangular instead of trapezoidal if M = N.
diag: Specifies whether or not the matrix A has unit diagonal.
= 0: Non-unit diagonal
= 1: Unit diagonal
A: The trapezoidal matrix A (A is triangular if m = n).
If uplo = 0, the leading m by n upper trapezoidal part of
the array A contains the upper trapezoidal matrix, and the
strictly lower triangular part of A is not referenced.
If uplo = 1, the leading m by n lower trapezoidal part of
the array A contains the lower trapezoidal matrix, and the
strictly upper triangular part of A is not referenced. Note
that when diag = 1, the diagonal elements of A are not
referenced and are assumed to be one.
=for example
# Assume $a is upper triangular
$a = random (float, 100, 100);
$norm = $a->lantr(1, 1, 0);
=for bad
lantr ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*lantr = \&PDL::lantr;
=head2 gemm
=for sig
Signature: ([phys]A(m,n); int transa(); int transb(); [phys]B(p,q);[phys]alpha(); [phys]beta(); [io,phys]C(r,s))
=for ref
Performs one of the matrix-matrix operations
C := alpha*op( A )*op( B ) + beta*C,
where op( X ) is one of p( X ) = X or op( X ) = X',
alpha and beta are scalars, and A, B and C are matrices, with op( A )
an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
Parameters
==========
transa: On entry, transa specifies the form of op( A ) to be used in
the matrix multiplication as follows:
transa = 0, op( A ) = A.
transa = 1, op( A ) = A'.
transb: On entry, transb specifies the form of op( B ) to be used in
the matrix multiplication as follows:
transb = 0, op( B ) = B.
transb = 1, op( B ) = B'.
alpha: On entry, alpha specifies the scalar alpha.
A: Before entry with transa = 0, the leading m by k
part of the array A must contain the matrix A, otherwise
the leading k by m part of the array A must contain the
matrix A.
B: Before entry with transb = 0, the leading k by n
part of the array B must contain the matrix B, otherwise
the leading n by k part of the array B must contain the
matrix B.
beta: On entry, beta specifies the scalar beta. When beta is
supplied as zero then C need not be set on input.
C: Before entry, the leading m by n part of the array C must
contain the matrix C, except when beta is zero, in which
case C need not be set on entry.
On exit, the array C is overwritten by the m by n matrix
( alpha*op( A )*op( B ) + beta*C ).
=for example
$a = random(5,4);
$b = random(5,4);
$alpha = pdl(0.5);
$beta = pdl(0);
$c = zeroes(5,5);
gemm($a, 0, 1,$b, $alpha, $beta, $c);
=for bad
gemm ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*gemm = \&PDL::gemm;
=head2 mmult
=for sig
Signature: ([phys]A(m,n); [phys]B(p,m); [o,phys]C(p,n))
=for ref
Blas matrix multiplication based on gemm
=for bad
mmult ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*mmult = \&PDL::mmult;
=head2 crossprod
=for sig
Signature: ([phys]A(n,m); [phys]B(p,m); [o,phys]C(p,n))
=for ref
Blas matrix cross product based on gemm
=for bad
crossprod ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*crossprod = \&PDL::crossprod;
=head2 syrk
=for sig
Signature: ([phys]A(m,n); int uplo(); int trans(); [phys]alpha(); [phys]beta(); [io,phys]C(p,p))
=for ref
Performs one of the symmetric rank k operations
C := alpha*A*A' + beta*C,
or
C := alpha*A'*A + beta*C,
where alpha and beta are scalars, C is an n by n symmetric matrix
and A is an n by k matrix in the first case and a k by n matrix
in the second case.
Parameters
==========
uplo: On entry, uplo specifies whether the upper or lower
triangular part of the array C is to be referenced as
follows:
uplo = 0 Only the upper triangular part of C
is to be referenced.
uplo = 1 Only the lower triangular part of C
is to be referenced.
Unchanged on exit.
trans: On entry, trans specifies the operation to be performed as
follows:
trans = 0 C := alpha*A*A' + beta*C.
trans = 1 C := alpha*A'*A + beta*C.
alpha: On entry, alpha specifies the scalar alpha.
Unchanged on exit.
A: Before entry with trans = 0, the leading n by k
part of the array A must contain the matrix A, otherwise
the leading k by n part of the array A must contain the
matrix A.
beta: On entry, beta specifies the scalar beta.
C: Before entry with uplo = 0, the leading n by n
upper triangular part of the array C must contain the upper
triangular part of the symmetric matrix and the strictly
lower triangular part of C is not referenced. On exit, the
upper triangular part of the array C is overwritten by the
upper triangular part of the updated matrix.
Before entry with uplo = 1, the leading n by n
lower triangular part of the array C must contain the lower
triangular part of the symmetric matrix and the strictly
upper triangular part of C is not referenced. On exit, the
lower triangular part of the array C is overwritten by the
lower triangular part of the updated matrix.
=for example
$a = random(5,4);
$b = zeroes(5,5);
$alpha = 1;
$beta = 0;
syrk ($a, 1,0,$alpha, $beta , $b);
=for bad
syrk ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*syrk = \&PDL::syrk;
=head2 dot
=for sig
Signature: ([phys]a(n);int [phys]inca();[phys]b(m);int [phys]incb();[o,phys]c())
=for ref
Dot product of two vectors using Blas.
=for example
$a = random(5);
$b = random(5);
$c = dot($a, 1, $b, 1)
=for bad
dot ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*dot = \&PDL::dot;
=head2 axpy
=for sig
Signature: ([phys]a(n);int [phys]inca();[phys] alpha();[io,phys]b(m);int [phys]incb())
=for ref
Linear combination of vectors ax + b using Blas.
Returns result in b.
=for example
$a = random(5);
$b = random(5);
axpy($a, 1, 12, $b, 1)
=for bad
axpy ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*axpy = \&PDL::axpy;
=head2 nrm2
=for sig
Signature: ([phys]a(n);int [phys]inca();[o,phys]b())
=for ref
Euclidean norm of a vector using Blas.
=for example
$a = random(5);
$norm2 = norm2($a,1)
=for bad
nrm2 ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*nrm2 = \&PDL::nrm2;
=head2 asum
=for sig
Signature: ([phys]a(n);int [phys]inca();[o,phys]b())
=for ref
Sum of absolute values of a vector using Blas.
=for example
$a = random(5);
$absum = asum($a,1)
=for bad
asum ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*asum = \&PDL::asum;
=head2 scal
=for sig
Signature: ([io,phys]a(n);int [phys]inca();[phys]scale())
=for ref
Scale a vector by a constant using Blas.
=for example
$a = random(5);
$a->scal(1, 0.5)
=for bad
scal ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*scal = \&PDL::scal;
=head2 rot
=for sig
Signature: ([io,phys]a(n);int [phys]inca();[phys]c(); [phys]s();[io,phys]b(n);int [phys]incb())
=for ref
Applies plane rotation using Blas.
=for example
$a = random(5);
$b = random(5);
rot($a, 1, 0.5, 0.7, $b, 1)
=for bad
rot ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*rot = \&PDL::rot;
=head2 rotg
=for sig
Signature: ([io,phys]a();[io,phys]b();[o,phys]c(); [o,phys]s())
=for ref
Generates plane rotation using Blas.
=for example
$a = sequence(4);
rotg($a(0), $a(1),$a(2),$a(3))
=for bad
rotg ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*rotg = \&PDL::rotg;
=head2 lasrt
=for sig
Signature: ([io,phys]d(n); int id();int [o,phys]info())
=for ref
Sort the numbers in d in increasing order (if id = 0) or
in decreasing order (if id = 1 ).
Use Quick Sort, reverting to Insertion sort on arrays of
size <= 20. Dimension of stack limits N to about 2**32.
Arguments
=========
id: = 0: sort d in increasing order;
= 1: sort d in decreasing order.
d: On entry, the array to be sorted.
On exit, d has been sorted into increasing order
(d(1) <= ... <= d(N) ) or into decreasing order
(d(1) >= ... >= d(N) ), depending on id.
info: = 0: successful exit
< 0: if info = -i, the i-th argument had an illegal value
=for example
$a = random(5);
lasrt ($a, 0, ($info = null));
=for bad
lasrt ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*lasrt = \&PDL::lasrt;
=head2 lacpy
=for sig
Signature: ([phys]A(m,n); int uplo(); [o,phys]B(p,n))
=for ref
Copies all or part of a two-dimensional matrix A to another
matrix B.
Arguments
=========
uplo: Specifies the part of the matrix A to be copied to B.
= 0: Upper triangular part
= 1: Lower triangular part
Otherwise: All of the matrix A
A: The m by n matrix A. If uplo = 0, only the upper triangle
or trapezoid is accessed; if uplo = 1, only the lower
triangle or trapezoid is accessed.
B: On exit, B = A in the locations specified by uplo.
=for example
$a = random(5,5);
$b = zeroes($a);
lacpy ($a, 0, $b);
=for bad
lacpy ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*lacpy = \&PDL::lacpy;
=head2 laswp
=for sig
Signature: ([io,phys]A(m,n);int [phys]k1();int [phys] k2(); int [phys]ipiv(p);int [phys]inc())
=for ref
Performs a series of row interchanges on the matrix A.
One row interchange is initiated for each of rows k1 through k2 of A.
Dosen't use PDL indice (start = 1).
Arguments
=========
A: On entry, the matrix of column dimension N to which the row
interchanges will be applied.
On exit, the permuted matrix.
k1: The first element of ipiv for which a row interchange will
be done.
k2: The last element of ipiv for which a row interchange will
be done.
ipiv: The vector of pivot indices. Only the elements in positions
k1 through k2 of ipiv are accessed.
ipiv(k) = l implies rows k and l are to be interchanged.
inc: The increment between successive values of ipiv. If ipiv
is negative, the pivots are applied in reverse order.
=for example
$a = random(5,5);
# reverse row (col for PDL)
$b = pdl([5,4,3,2,1]);
$a->laswp(1,2,$b,1);
=for bad
laswp ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*laswp = \&PDL::laswp;
=head2 lamch
=for sig
Signature: (cmach(); [o]precision())
=for ref
Determines precision machine parameters.
Works inplace.
Arguments
=========
cmach: Specifies the value to be returned by lamch:
= 0 LAMCH := eps
= 1 LAMCH := sfmin
= 2 LAMCH := base
= 3 LAMCH := eps*base
= 4 LAMCH := t
= 5 LAMCH := rnd
= 6 LAMCH := emin
= 7 LAMCH := rmin
= 8 LAMCH := emax
= 9 LAMCH := rmax
where
eps = relative machine precision
sfmin = safe minimum, such that 1/sfmin does not overflow
base = base of the machine
prec = eps*base
t = number of (base) digits in the mantissa
rnd = 1.0 when rounding occurs in addition, 0.0 otherwise
emin = minimum exponent before (gradual) underflow
rmin = underflow threshold - base**(emin-1)
emax = largest exponent before overflow
rmax = overflow threshold - (base**emax)*(1-eps)
=for example
$a = lamch (0);
print "EPS is $a for double\n";
=for bad
lamch ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*lamch = \&PDL::lamch;
=head2 labad
=for sig
Signature: ([io,phys]small(); [io,phys]large())
=for ref
Takes as input the values computed by C<lamch> for underflow and
overflow, and returns the square root of each of these values if the
log of large is sufficiently large. This subroutine is intended to
identify machines with a large exponent range, such as the Crays, and
redefine the underflow and overflow limits to be the square roots of
the values computed by C<lamch>. This subroutine is needed because
lamch does not compensate for poor arithmetic in the upper half of
the exponent range, as is found on a Cray.
Arguments
=========
small: On entry, the underflow threshold as computed by lamch.
On exit, if LOG10(large) is sufficiently large, the square
root of small, otherwise unchanged.
large: On entry, the overflow threshold as computed by lamch.
On exit, if LOG10(large) is sufficiently large, the square
root of large, otherwise unchanged.
=for example
$underflow = lamch(7);
$overflow = lamch(9);
labad ($underflow, $overflow);
=for bad
labad ignores the bad-value flag of the input piddles.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*labad = \&PDL::labad;
=head2 tricpy
=for sig
Signature: (A(m,n);int uplo();[o] C(m,n))
=for ref
Copy triangular part to another matrix. If uplo == 0 copy upper triangular part.
=for bad
tricpy does not process bad values.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*tricpy = \&PDL::tricpy;
=head2 cplx_eigen
=for sig
Signature: (eigreval(n);eigimval(n); eigvec(n,p);int fortran();[o]cplx_val(q=2,n);[o]cplx_vec(r=2,n,p))
=for ref
Output complex eigen-values/vectors from eigen-values/vectors
as computed by geev or geevx.
'fortran' means fortran storage type.
=for bad
cplx_eigen does not process bad values.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*cplx_eigen = \&PDL::cplx_eigen;
=head2 augment
=for sig
Signature: (x(n); y(p);[o]out(q))
=for ref
Combine two pidlles into a single piddle.
This routine does backward and forward dataflow automatically.
=for bad
augment does not process bad values.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*augment = \&PDL::augment;
=head2 mstack
=for sig
Signature: (x(n,m);y(n,p);[o]out(n,q))
=for ref
Combine two pidlles into a single piddle.
This routine does backward and forward dataflow automatically.
=for bad
mstack does not process bad values.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*mstack = \&PDL::mstack;
=head2 charpol
=for sig
Signature: ([phys]A(n,n);[phys,o]Y(n,n);[phys,o]out(p))
=for ref
Compute adjoint matrix and characteristic polynomial.
=for bad
charpol does not process bad values.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*charpol = \&PDL::charpol;
;
=head1 AUTHOR
Copyright (C) Grégory Vanuxem 2005-2007.
This library is free software; you can redistribute it and/or modify
it under the terms of the artistic license as specified in the Artistic
file.
=cut
# Exit with OK status
1;
|