/usr/include/libalglib/interpolation.h is in libalglib-dev 3.10.0-1.
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 | /*************************************************************************
ALGLIB 3.10.0 (source code generated 2015-08-19)
Copyright (c) Sergey Bochkanov (ALGLIB project).
>>> SOURCE LICENSE >>>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation (www.fsf.org); either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
A copy of the GNU General Public License is available at
http://www.fsf.org/licensing/licenses
>>> END OF LICENSE >>>
*************************************************************************/
#ifndef _interpolation_pkg_h
#define _interpolation_pkg_h
#include "ap.h"
#include "alglibinternal.h"
#include "alglibmisc.h"
#include "linalg.h"
#include "solvers.h"
#include "optimization.h"
#include "specialfunctions.h"
#include "integration.h"
/////////////////////////////////////////////////////////////////////////
//
// THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (DATATYPES)
//
/////////////////////////////////////////////////////////////////////////
namespace alglib_impl
{
typedef struct
{
ae_int_t n;
ae_int_t nx;
ae_int_t d;
double r;
ae_int_t nw;
kdtree tree;
ae_int_t modeltype;
ae_matrix q;
ae_vector xbuf;
ae_vector tbuf;
ae_vector rbuf;
ae_matrix xybuf;
ae_int_t debugsolverfailures;
double debugworstrcond;
double debugbestrcond;
} idwinterpolant;
typedef struct
{
ae_int_t n;
double sy;
ae_vector x;
ae_vector y;
ae_vector w;
} barycentricinterpolant;
typedef struct
{
ae_bool periodic;
ae_int_t n;
ae_int_t k;
ae_int_t continuity;
ae_vector x;
ae_vector c;
} spline1dinterpolant;
typedef struct
{
double taskrcond;
double rmserror;
double avgerror;
double avgrelerror;
double maxerror;
} polynomialfitreport;
typedef struct
{
double taskrcond;
ae_int_t dbest;
double rmserror;
double avgerror;
double avgrelerror;
double maxerror;
} barycentricfitreport;
typedef struct
{
double taskrcond;
double rmserror;
double avgerror;
double avgrelerror;
double maxerror;
} spline1dfitreport;
typedef struct
{
double taskrcond;
ae_int_t iterationscount;
ae_int_t varidx;
double rmserror;
double avgerror;
double avgrelerror;
double maxerror;
double wrmserror;
ae_matrix covpar;
ae_vector errpar;
ae_vector errcurve;
ae_vector noise;
double r2;
} lsfitreport;
typedef struct
{
ae_int_t optalgo;
ae_int_t m;
ae_int_t k;
double epsf;
double epsx;
ae_int_t maxits;
double stpmax;
ae_bool xrep;
ae_vector s;
ae_vector bndl;
ae_vector bndu;
ae_matrix taskx;
ae_vector tasky;
ae_int_t npoints;
ae_vector taskw;
ae_int_t nweights;
ae_int_t wkind;
ae_int_t wits;
double diffstep;
double teststep;
ae_bool xupdated;
ae_bool needf;
ae_bool needfg;
ae_bool needfgh;
ae_int_t pointindex;
ae_vector x;
ae_vector c;
double f;
ae_vector g;
ae_matrix h;
ae_vector wcur;
ae_vector tmp;
ae_vector tmpf;
ae_matrix tmpjac;
ae_matrix tmpjacw;
double tmpnoise;
matinvreport invrep;
ae_int_t repiterationscount;
ae_int_t repterminationtype;
ae_int_t repvaridx;
double reprmserror;
double repavgerror;
double repavgrelerror;
double repmaxerror;
double repwrmserror;
lsfitreport rep;
minlmstate optstate;
minlmreport optrep;
ae_int_t prevnpt;
ae_int_t prevalgo;
rcommstate rstate;
} lsfitstate;
typedef struct
{
ae_int_t n;
ae_bool periodic;
ae_vector p;
spline1dinterpolant x;
spline1dinterpolant y;
} pspline2interpolant;
typedef struct
{
ae_int_t n;
ae_bool periodic;
ae_vector p;
spline1dinterpolant x;
spline1dinterpolant y;
spline1dinterpolant z;
} pspline3interpolant;
typedef struct
{
ae_int_t ny;
ae_int_t nx;
ae_int_t nc;
ae_int_t nl;
kdtree tree;
ae_matrix xc;
ae_matrix wr;
double rmax;
ae_matrix v;
ae_int_t gridtype;
ae_bool fixrad;
double lambdav;
double radvalue;
double radzvalue;
ae_int_t nlayers;
ae_int_t aterm;
ae_int_t algorithmtype;
double epsort;
double epserr;
ae_int_t maxits;
double h;
ae_int_t n;
ae_matrix x;
ae_matrix y;
ae_vector calcbufxcx;
ae_matrix calcbufx;
ae_vector calcbuftags;
} rbfmodel;
typedef struct
{
ae_int_t arows;
ae_int_t acols;
ae_int_t annz;
ae_int_t iterationscount;
ae_int_t nmv;
ae_int_t terminationtype;
} rbfreport;
typedef struct
{
ae_int_t k;
ae_int_t stype;
ae_int_t n;
ae_int_t m;
ae_int_t d;
ae_vector x;
ae_vector y;
ae_vector f;
} spline2dinterpolant;
typedef struct
{
ae_int_t k;
ae_int_t stype;
ae_int_t n;
ae_int_t m;
ae_int_t l;
ae_int_t d;
ae_vector x;
ae_vector y;
ae_vector z;
ae_vector f;
} spline3dinterpolant;
}
/////////////////////////////////////////////////////////////////////////
//
// THIS SECTION CONTAINS C++ INTERFACE
//
/////////////////////////////////////////////////////////////////////////
namespace alglib
{
/*************************************************************************
IDW interpolant.
*************************************************************************/
class _idwinterpolant_owner
{
public:
_idwinterpolant_owner();
_idwinterpolant_owner(const _idwinterpolant_owner &rhs);
_idwinterpolant_owner& operator=(const _idwinterpolant_owner &rhs);
virtual ~_idwinterpolant_owner();
alglib_impl::idwinterpolant* c_ptr();
alglib_impl::idwinterpolant* c_ptr() const;
protected:
alglib_impl::idwinterpolant *p_struct;
};
class idwinterpolant : public _idwinterpolant_owner
{
public:
idwinterpolant();
idwinterpolant(const idwinterpolant &rhs);
idwinterpolant& operator=(const idwinterpolant &rhs);
virtual ~idwinterpolant();
};
/*************************************************************************
Barycentric interpolant.
*************************************************************************/
class _barycentricinterpolant_owner
{
public:
_barycentricinterpolant_owner();
_barycentricinterpolant_owner(const _barycentricinterpolant_owner &rhs);
_barycentricinterpolant_owner& operator=(const _barycentricinterpolant_owner &rhs);
virtual ~_barycentricinterpolant_owner();
alglib_impl::barycentricinterpolant* c_ptr();
alglib_impl::barycentricinterpolant* c_ptr() const;
protected:
alglib_impl::barycentricinterpolant *p_struct;
};
class barycentricinterpolant : public _barycentricinterpolant_owner
{
public:
barycentricinterpolant();
barycentricinterpolant(const barycentricinterpolant &rhs);
barycentricinterpolant& operator=(const barycentricinterpolant &rhs);
virtual ~barycentricinterpolant();
};
/*************************************************************************
1-dimensional spline interpolant
*************************************************************************/
class _spline1dinterpolant_owner
{
public:
_spline1dinterpolant_owner();
_spline1dinterpolant_owner(const _spline1dinterpolant_owner &rhs);
_spline1dinterpolant_owner& operator=(const _spline1dinterpolant_owner &rhs);
virtual ~_spline1dinterpolant_owner();
alglib_impl::spline1dinterpolant* c_ptr();
alglib_impl::spline1dinterpolant* c_ptr() const;
protected:
alglib_impl::spline1dinterpolant *p_struct;
};
class spline1dinterpolant : public _spline1dinterpolant_owner
{
public:
spline1dinterpolant();
spline1dinterpolant(const spline1dinterpolant &rhs);
spline1dinterpolant& operator=(const spline1dinterpolant &rhs);
virtual ~spline1dinterpolant();
};
/*************************************************************************
Polynomial fitting report:
TaskRCond reciprocal of task's condition number
RMSError RMS error
AvgError average error
AvgRelError average relative error (for non-zero Y[I])
MaxError maximum error
*************************************************************************/
class _polynomialfitreport_owner
{
public:
_polynomialfitreport_owner();
_polynomialfitreport_owner(const _polynomialfitreport_owner &rhs);
_polynomialfitreport_owner& operator=(const _polynomialfitreport_owner &rhs);
virtual ~_polynomialfitreport_owner();
alglib_impl::polynomialfitreport* c_ptr();
alglib_impl::polynomialfitreport* c_ptr() const;
protected:
alglib_impl::polynomialfitreport *p_struct;
};
class polynomialfitreport : public _polynomialfitreport_owner
{
public:
polynomialfitreport();
polynomialfitreport(const polynomialfitreport &rhs);
polynomialfitreport& operator=(const polynomialfitreport &rhs);
virtual ~polynomialfitreport();
double &taskrcond;
double &rmserror;
double &avgerror;
double &avgrelerror;
double &maxerror;
};
/*************************************************************************
Barycentric fitting report:
RMSError RMS error
AvgError average error
AvgRelError average relative error (for non-zero Y[I])
MaxError maximum error
TaskRCond reciprocal of task's condition number
*************************************************************************/
class _barycentricfitreport_owner
{
public:
_barycentricfitreport_owner();
_barycentricfitreport_owner(const _barycentricfitreport_owner &rhs);
_barycentricfitreport_owner& operator=(const _barycentricfitreport_owner &rhs);
virtual ~_barycentricfitreport_owner();
alglib_impl::barycentricfitreport* c_ptr();
alglib_impl::barycentricfitreport* c_ptr() const;
protected:
alglib_impl::barycentricfitreport *p_struct;
};
class barycentricfitreport : public _barycentricfitreport_owner
{
public:
barycentricfitreport();
barycentricfitreport(const barycentricfitreport &rhs);
barycentricfitreport& operator=(const barycentricfitreport &rhs);
virtual ~barycentricfitreport();
double &taskrcond;
ae_int_t &dbest;
double &rmserror;
double &avgerror;
double &avgrelerror;
double &maxerror;
};
/*************************************************************************
Spline fitting report:
RMSError RMS error
AvgError average error
AvgRelError average relative error (for non-zero Y[I])
MaxError maximum error
Fields below are filled by obsolete functions (Spline1DFitCubic,
Spline1DFitHermite). Modern fitting functions do NOT fill these fields:
TaskRCond reciprocal of task's condition number
*************************************************************************/
class _spline1dfitreport_owner
{
public:
_spline1dfitreport_owner();
_spline1dfitreport_owner(const _spline1dfitreport_owner &rhs);
_spline1dfitreport_owner& operator=(const _spline1dfitreport_owner &rhs);
virtual ~_spline1dfitreport_owner();
alglib_impl::spline1dfitreport* c_ptr();
alglib_impl::spline1dfitreport* c_ptr() const;
protected:
alglib_impl::spline1dfitreport *p_struct;
};
class spline1dfitreport : public _spline1dfitreport_owner
{
public:
spline1dfitreport();
spline1dfitreport(const spline1dfitreport &rhs);
spline1dfitreport& operator=(const spline1dfitreport &rhs);
virtual ~spline1dfitreport();
double &taskrcond;
double &rmserror;
double &avgerror;
double &avgrelerror;
double &maxerror;
};
/*************************************************************************
Least squares fitting report. This structure contains informational fields
which are set by fitting functions provided by this unit.
Different functions initialize different sets of fields, so you should
read documentation on specific function you used in order to know which
fields are initialized.
TaskRCond reciprocal of task's condition number
IterationsCount number of internal iterations
VarIdx if user-supplied gradient contains errors which were
detected by nonlinear fitter, this field is set to
index of the first component of gradient which is
suspected to be spoiled by bugs.
RMSError RMS error
AvgError average error
AvgRelError average relative error (for non-zero Y[I])
MaxError maximum error
WRMSError weighted RMS error
CovPar covariance matrix for parameters, filled by some solvers
ErrPar vector of errors in parameters, filled by some solvers
ErrCurve vector of fit errors - variability of the best-fit
curve, filled by some solvers.
Noise vector of per-point noise estimates, filled by
some solvers.
R2 coefficient of determination (non-weighted, non-adjusted),
filled by some solvers.
*************************************************************************/
class _lsfitreport_owner
{
public:
_lsfitreport_owner();
_lsfitreport_owner(const _lsfitreport_owner &rhs);
_lsfitreport_owner& operator=(const _lsfitreport_owner &rhs);
virtual ~_lsfitreport_owner();
alglib_impl::lsfitreport* c_ptr();
alglib_impl::lsfitreport* c_ptr() const;
protected:
alglib_impl::lsfitreport *p_struct;
};
class lsfitreport : public _lsfitreport_owner
{
public:
lsfitreport();
lsfitreport(const lsfitreport &rhs);
lsfitreport& operator=(const lsfitreport &rhs);
virtual ~lsfitreport();
double &taskrcond;
ae_int_t &iterationscount;
ae_int_t &varidx;
double &rmserror;
double &avgerror;
double &avgrelerror;
double &maxerror;
double &wrmserror;
real_2d_array covpar;
real_1d_array errpar;
real_1d_array errcurve;
real_1d_array noise;
double &r2;
};
/*************************************************************************
Nonlinear fitter.
You should use ALGLIB functions to work with fitter.
Never try to access its fields directly!
*************************************************************************/
class _lsfitstate_owner
{
public:
_lsfitstate_owner();
_lsfitstate_owner(const _lsfitstate_owner &rhs);
_lsfitstate_owner& operator=(const _lsfitstate_owner &rhs);
virtual ~_lsfitstate_owner();
alglib_impl::lsfitstate* c_ptr();
alglib_impl::lsfitstate* c_ptr() const;
protected:
alglib_impl::lsfitstate *p_struct;
};
class lsfitstate : public _lsfitstate_owner
{
public:
lsfitstate();
lsfitstate(const lsfitstate &rhs);
lsfitstate& operator=(const lsfitstate &rhs);
virtual ~lsfitstate();
ae_bool &needf;
ae_bool &needfg;
ae_bool &needfgh;
ae_bool &xupdated;
real_1d_array c;
double &f;
real_1d_array g;
real_2d_array h;
real_1d_array x;
};
/*************************************************************************
Parametric spline inteprolant: 2-dimensional curve.
You should not try to access its members directly - use PSpline2XXXXXXXX()
functions instead.
*************************************************************************/
class _pspline2interpolant_owner
{
public:
_pspline2interpolant_owner();
_pspline2interpolant_owner(const _pspline2interpolant_owner &rhs);
_pspline2interpolant_owner& operator=(const _pspline2interpolant_owner &rhs);
virtual ~_pspline2interpolant_owner();
alglib_impl::pspline2interpolant* c_ptr();
alglib_impl::pspline2interpolant* c_ptr() const;
protected:
alglib_impl::pspline2interpolant *p_struct;
};
class pspline2interpolant : public _pspline2interpolant_owner
{
public:
pspline2interpolant();
pspline2interpolant(const pspline2interpolant &rhs);
pspline2interpolant& operator=(const pspline2interpolant &rhs);
virtual ~pspline2interpolant();
};
/*************************************************************************
Parametric spline inteprolant: 3-dimensional curve.
You should not try to access its members directly - use PSpline3XXXXXXXX()
functions instead.
*************************************************************************/
class _pspline3interpolant_owner
{
public:
_pspline3interpolant_owner();
_pspline3interpolant_owner(const _pspline3interpolant_owner &rhs);
_pspline3interpolant_owner& operator=(const _pspline3interpolant_owner &rhs);
virtual ~_pspline3interpolant_owner();
alglib_impl::pspline3interpolant* c_ptr();
alglib_impl::pspline3interpolant* c_ptr() const;
protected:
alglib_impl::pspline3interpolant *p_struct;
};
class pspline3interpolant : public _pspline3interpolant_owner
{
public:
pspline3interpolant();
pspline3interpolant(const pspline3interpolant &rhs);
pspline3interpolant& operator=(const pspline3interpolant &rhs);
virtual ~pspline3interpolant();
};
/*************************************************************************
RBF model.
Never try to directly work with fields of this object - always use ALGLIB
functions to use this object.
*************************************************************************/
class _rbfmodel_owner
{
public:
_rbfmodel_owner();
_rbfmodel_owner(const _rbfmodel_owner &rhs);
_rbfmodel_owner& operator=(const _rbfmodel_owner &rhs);
virtual ~_rbfmodel_owner();
alglib_impl::rbfmodel* c_ptr();
alglib_impl::rbfmodel* c_ptr() const;
protected:
alglib_impl::rbfmodel *p_struct;
};
class rbfmodel : public _rbfmodel_owner
{
public:
rbfmodel();
rbfmodel(const rbfmodel &rhs);
rbfmodel& operator=(const rbfmodel &rhs);
virtual ~rbfmodel();
};
/*************************************************************************
RBF solution report:
* TerminationType - termination type, positive values - success,
non-positive - failure.
*************************************************************************/
class _rbfreport_owner
{
public:
_rbfreport_owner();
_rbfreport_owner(const _rbfreport_owner &rhs);
_rbfreport_owner& operator=(const _rbfreport_owner &rhs);
virtual ~_rbfreport_owner();
alglib_impl::rbfreport* c_ptr();
alglib_impl::rbfreport* c_ptr() const;
protected:
alglib_impl::rbfreport *p_struct;
};
class rbfreport : public _rbfreport_owner
{
public:
rbfreport();
rbfreport(const rbfreport &rhs);
rbfreport& operator=(const rbfreport &rhs);
virtual ~rbfreport();
ae_int_t &arows;
ae_int_t &acols;
ae_int_t &annz;
ae_int_t &iterationscount;
ae_int_t &nmv;
ae_int_t &terminationtype;
};
/*************************************************************************
2-dimensional spline inteprolant
*************************************************************************/
class _spline2dinterpolant_owner
{
public:
_spline2dinterpolant_owner();
_spline2dinterpolant_owner(const _spline2dinterpolant_owner &rhs);
_spline2dinterpolant_owner& operator=(const _spline2dinterpolant_owner &rhs);
virtual ~_spline2dinterpolant_owner();
alglib_impl::spline2dinterpolant* c_ptr();
alglib_impl::spline2dinterpolant* c_ptr() const;
protected:
alglib_impl::spline2dinterpolant *p_struct;
};
class spline2dinterpolant : public _spline2dinterpolant_owner
{
public:
spline2dinterpolant();
spline2dinterpolant(const spline2dinterpolant &rhs);
spline2dinterpolant& operator=(const spline2dinterpolant &rhs);
virtual ~spline2dinterpolant();
};
/*************************************************************************
3-dimensional spline inteprolant
*************************************************************************/
class _spline3dinterpolant_owner
{
public:
_spline3dinterpolant_owner();
_spline3dinterpolant_owner(const _spline3dinterpolant_owner &rhs);
_spline3dinterpolant_owner& operator=(const _spline3dinterpolant_owner &rhs);
virtual ~_spline3dinterpolant_owner();
alglib_impl::spline3dinterpolant* c_ptr();
alglib_impl::spline3dinterpolant* c_ptr() const;
protected:
alglib_impl::spline3dinterpolant *p_struct;
};
class spline3dinterpolant : public _spline3dinterpolant_owner
{
public:
spline3dinterpolant();
spline3dinterpolant(const spline3dinterpolant &rhs);
spline3dinterpolant& operator=(const spline3dinterpolant &rhs);
virtual ~spline3dinterpolant();
};
/*************************************************************************
IDW interpolation
INPUT PARAMETERS:
Z - IDW interpolant built with one of model building
subroutines.
X - array[0..NX-1], interpolation point
Result:
IDW interpolant Z(X)
-- ALGLIB --
Copyright 02.03.2010 by Bochkanov Sergey
*************************************************************************/
double idwcalc(const idwinterpolant &z, const real_1d_array &x);
/*************************************************************************
IDW interpolant using modified Shepard method for uniform point
distributions.
INPUT PARAMETERS:
XY - X and Y values, array[0..N-1,0..NX].
First NX columns contain X-values, last column contain
Y-values.
N - number of nodes, N>0.
NX - space dimension, NX>=1.
D - nodal function type, either:
* 0 constant model. Just for demonstration only, worst
model ever.
* 1 linear model, least squares fitting. Simpe model for
datasets too small for quadratic models
* 2 quadratic model, least squares fitting. Best model
available (if your dataset is large enough).
* -1 "fast" linear model, use with caution!!! It is
significantly faster than linear/quadratic and better
than constant model. But it is less robust (especially
in the presence of noise).
NQ - number of points used to calculate nodal functions (ignored
for constant models). NQ should be LARGER than:
* max(1.5*(1+NX),2^NX+1) for linear model,
* max(3/4*(NX+2)*(NX+1),2^NX+1) for quadratic model.
Values less than this threshold will be silently increased.
NW - number of points used to calculate weights and to interpolate.
Required: >=2^NX+1, values less than this threshold will be
silently increased.
Recommended value: about 2*NQ
OUTPUT PARAMETERS:
Z - IDW interpolant.
NOTES:
* best results are obtained with quadratic models, worst - with constant
models
* when N is large, NQ and NW must be significantly smaller than N both
to obtain optimal performance and to obtain optimal accuracy. In 2 or
3-dimensional tasks NQ=15 and NW=25 are good values to start with.
* NQ and NW may be greater than N. In such cases they will be
automatically decreased.
* this subroutine is always succeeds (as long as correct parameters are
passed).
* see 'Multivariate Interpolation of Large Sets of Scattered Data' by
Robert J. Renka for more information on this algorithm.
* this subroutine assumes that point distribution is uniform at the small
scales. If it isn't - for example, points are concentrated along
"lines", but "lines" distribution is uniform at the larger scale - then
you should use IDWBuildModifiedShepardR()
-- ALGLIB PROJECT --
Copyright 02.03.2010 by Bochkanov Sergey
*************************************************************************/
void idwbuildmodifiedshepard(const real_2d_array &xy, const ae_int_t n, const ae_int_t nx, const ae_int_t d, const ae_int_t nq, const ae_int_t nw, idwinterpolant &z);
/*************************************************************************
IDW interpolant using modified Shepard method for non-uniform datasets.
This type of model uses constant nodal functions and interpolates using
all nodes which are closer than user-specified radius R. It may be used
when points distribution is non-uniform at the small scale, but it is at
the distances as large as R.
INPUT PARAMETERS:
XY - X and Y values, array[0..N-1,0..NX].
First NX columns contain X-values, last column contain
Y-values.
N - number of nodes, N>0.
NX - space dimension, NX>=1.
R - radius, R>0
OUTPUT PARAMETERS:
Z - IDW interpolant.
NOTES:
* if there is less than IDWKMin points within R-ball, algorithm selects
IDWKMin closest ones, so that continuity properties of interpolant are
preserved even far from points.
-- ALGLIB PROJECT --
Copyright 11.04.2010 by Bochkanov Sergey
*************************************************************************/
void idwbuildmodifiedshepardr(const real_2d_array &xy, const ae_int_t n, const ae_int_t nx, const double r, idwinterpolant &z);
/*************************************************************************
IDW model for noisy data.
This subroutine may be used to handle noisy data, i.e. data with noise in
OUTPUT values. It differs from IDWBuildModifiedShepard() in the following
aspects:
* nodal functions are not constrained to pass through nodes: Qi(xi)<>yi,
i.e. we have fitting instead of interpolation.
* weights which are used during least squares fitting stage are all equal
to 1.0 (independently of distance)
* "fast"-linear or constant nodal functions are not supported (either not
robust enough or too rigid)
This problem require far more complex tuning than interpolation problems.
Below you can find some recommendations regarding this problem:
* focus on tuning NQ; it controls noise reduction. As for NW, you can just
make it equal to 2*NQ.
* you can use cross-validation to determine optimal NQ.
* optimal NQ is a result of complex tradeoff between noise level (more
noise = larger NQ required) and underlying function complexity (given
fixed N, larger NQ means smoothing of compex features in the data). For
example, NQ=N will reduce noise to the minimum level possible, but you
will end up with just constant/linear/quadratic (depending on D) least
squares model for the whole dataset.
INPUT PARAMETERS:
XY - X and Y values, array[0..N-1,0..NX].
First NX columns contain X-values, last column contain
Y-values.
N - number of nodes, N>0.
NX - space dimension, NX>=1.
D - nodal function degree, either:
* 1 linear model, least squares fitting. Simpe model for
datasets too small for quadratic models (or for very
noisy problems).
* 2 quadratic model, least squares fitting. Best model
available (if your dataset is large enough).
NQ - number of points used to calculate nodal functions. NQ should
be significantly larger than 1.5 times the number of
coefficients in a nodal function to overcome effects of noise:
* larger than 1.5*(1+NX) for linear model,
* larger than 3/4*(NX+2)*(NX+1) for quadratic model.
Values less than this threshold will be silently increased.
NW - number of points used to calculate weights and to interpolate.
Required: >=2^NX+1, values less than this threshold will be
silently increased.
Recommended value: about 2*NQ or larger
OUTPUT PARAMETERS:
Z - IDW interpolant.
NOTES:
* best results are obtained with quadratic models, linear models are not
recommended to use unless you are pretty sure that it is what you want
* this subroutine is always succeeds (as long as correct parameters are
passed).
* see 'Multivariate Interpolation of Large Sets of Scattered Data' by
Robert J. Renka for more information on this algorithm.
-- ALGLIB PROJECT --
Copyright 02.03.2010 by Bochkanov Sergey
*************************************************************************/
void idwbuildnoisy(const real_2d_array &xy, const ae_int_t n, const ae_int_t nx, const ae_int_t d, const ae_int_t nq, const ae_int_t nw, idwinterpolant &z);
/*************************************************************************
Rational interpolation using barycentric formula
F(t) = SUM(i=0,n-1,w[i]*f[i]/(t-x[i])) / SUM(i=0,n-1,w[i]/(t-x[i]))
Input parameters:
B - barycentric interpolant built with one of model building
subroutines.
T - interpolation point
Result:
barycentric interpolant F(t)
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
double barycentriccalc(const barycentricinterpolant &b, const double t);
/*************************************************************************
Differentiation of barycentric interpolant: first derivative.
Algorithm used in this subroutine is very robust and should not fail until
provided with values too close to MaxRealNumber (usually MaxRealNumber/N
or greater will overflow).
INPUT PARAMETERS:
B - barycentric interpolant built with one of model building
subroutines.
T - interpolation point
OUTPUT PARAMETERS:
F - barycentric interpolant at T
DF - first derivative
NOTE
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void barycentricdiff1(const barycentricinterpolant &b, const double t, double &f, double &df);
/*************************************************************************
Differentiation of barycentric interpolant: first/second derivatives.
INPUT PARAMETERS:
B - barycentric interpolant built with one of model building
subroutines.
T - interpolation point
OUTPUT PARAMETERS:
F - barycentric interpolant at T
DF - first derivative
D2F - second derivative
NOTE: this algorithm may fail due to overflow/underflor if used on data
whose values are close to MaxRealNumber or MinRealNumber. Use more robust
BarycentricDiff1() subroutine in such cases.
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void barycentricdiff2(const barycentricinterpolant &b, const double t, double &f, double &df, double &d2f);
/*************************************************************************
This subroutine performs linear transformation of the argument.
INPUT PARAMETERS:
B - rational interpolant in barycentric form
CA, CB - transformation coefficients: x = CA*t + CB
OUTPUT PARAMETERS:
B - transformed interpolant with X replaced by T
-- ALGLIB PROJECT --
Copyright 19.08.2009 by Bochkanov Sergey
*************************************************************************/
void barycentriclintransx(const barycentricinterpolant &b, const double ca, const double cb);
/*************************************************************************
This subroutine performs linear transformation of the barycentric
interpolant.
INPUT PARAMETERS:
B - rational interpolant in barycentric form
CA, CB - transformation coefficients: B2(x) = CA*B(x) + CB
OUTPUT PARAMETERS:
B - transformed interpolant
-- ALGLIB PROJECT --
Copyright 19.08.2009 by Bochkanov Sergey
*************************************************************************/
void barycentriclintransy(const barycentricinterpolant &b, const double ca, const double cb);
/*************************************************************************
Extracts X/Y/W arrays from rational interpolant
INPUT PARAMETERS:
B - barycentric interpolant
OUTPUT PARAMETERS:
N - nodes count, N>0
X - interpolation nodes, array[0..N-1]
F - function values, array[0..N-1]
W - barycentric weights, array[0..N-1]
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void barycentricunpack(const barycentricinterpolant &b, ae_int_t &n, real_1d_array &x, real_1d_array &y, real_1d_array &w);
/*************************************************************************
Rational interpolant from X/Y/W arrays
F(t) = SUM(i=0,n-1,w[i]*f[i]/(t-x[i])) / SUM(i=0,n-1,w[i]/(t-x[i]))
INPUT PARAMETERS:
X - interpolation nodes, array[0..N-1]
F - function values, array[0..N-1]
W - barycentric weights, array[0..N-1]
N - nodes count, N>0
OUTPUT PARAMETERS:
B - barycentric interpolant built from (X, Y, W)
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void barycentricbuildxyw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, barycentricinterpolant &b);
/*************************************************************************
Rational interpolant without poles
The subroutine constructs the rational interpolating function without real
poles (see 'Barycentric rational interpolation with no poles and high
rates of approximation', Michael S. Floater. and Kai Hormann, for more
information on this subject).
Input parameters:
X - interpolation nodes, array[0..N-1].
Y - function values, array[0..N-1].
N - number of nodes, N>0.
D - order of the interpolation scheme, 0 <= D <= N-1.
D<0 will cause an error.
D>=N it will be replaced with D=N-1.
if you don't know what D to choose, use small value about 3-5.
Output parameters:
B - barycentric interpolant.
Note:
this algorithm always succeeds and calculates the weights with close
to machine precision.
-- ALGLIB PROJECT --
Copyright 17.06.2007 by Bochkanov Sergey
*************************************************************************/
void barycentricbuildfloaterhormann(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t d, barycentricinterpolant &b);
/*************************************************************************
Conversion from barycentric representation to Chebyshev basis.
This function has O(N^2) complexity.
INPUT PARAMETERS:
P - polynomial in barycentric form
A,B - base interval for Chebyshev polynomials (see below)
A<>B
OUTPUT PARAMETERS
T - coefficients of Chebyshev representation;
P(x) = sum { T[i]*Ti(2*(x-A)/(B-A)-1), i=0..N-1 },
where Ti - I-th Chebyshev polynomial.
NOTES:
barycentric interpolant passed as P may be either polynomial obtained
from polynomial interpolation/ fitting or rational function which is
NOT polynomial. We can't distinguish between these two cases, and this
algorithm just tries to work assuming that P IS a polynomial. If not,
algorithm will return results, but they won't have any meaning.
-- ALGLIB --
Copyright 30.09.2010 by Bochkanov Sergey
*************************************************************************/
void polynomialbar2cheb(const barycentricinterpolant &p, const double a, const double b, real_1d_array &t);
/*************************************************************************
Conversion from Chebyshev basis to barycentric representation.
This function has O(N^2) complexity.
INPUT PARAMETERS:
T - coefficients of Chebyshev representation;
P(x) = sum { T[i]*Ti(2*(x-A)/(B-A)-1), i=0..N },
where Ti - I-th Chebyshev polynomial.
N - number of coefficients:
* if given, only leading N elements of T are used
* if not given, automatically determined from size of T
A,B - base interval for Chebyshev polynomials (see above)
A<B
OUTPUT PARAMETERS
P - polynomial in barycentric form
-- ALGLIB --
Copyright 30.09.2010 by Bochkanov Sergey
*************************************************************************/
void polynomialcheb2bar(const real_1d_array &t, const ae_int_t n, const double a, const double b, barycentricinterpolant &p);
void polynomialcheb2bar(const real_1d_array &t, const double a, const double b, barycentricinterpolant &p);
/*************************************************************************
Conversion from barycentric representation to power basis.
This function has O(N^2) complexity.
INPUT PARAMETERS:
P - polynomial in barycentric form
C - offset (see below); 0.0 is used as default value.
S - scale (see below); 1.0 is used as default value. S<>0.
OUTPUT PARAMETERS
A - coefficients, P(x) = sum { A[i]*((X-C)/S)^i, i=0..N-1 }
N - number of coefficients (polynomial degree plus 1)
NOTES:
1. this function accepts offset and scale, which can be set to improve
numerical properties of polynomial. For example, if P was obtained as
result of interpolation on [-1,+1], you can set C=0 and S=1 and
represent P as sum of 1, x, x^2, x^3 and so on. In most cases you it
is exactly what you need.
However, if your interpolation model was built on [999,1001], you will
see significant growth of numerical errors when using {1, x, x^2, x^3}
as basis. Representing P as sum of 1, (x-1000), (x-1000)^2, (x-1000)^3
will be better option. Such representation can be obtained by using
1000.0 as offset C and 1.0 as scale S.
2. power basis is ill-conditioned and tricks described above can't solve
this problem completely. This function will return coefficients in
any case, but for N>8 they will become unreliable. However, N's
less than 5 are pretty safe.
3. barycentric interpolant passed as P may be either polynomial obtained
from polynomial interpolation/ fitting or rational function which is
NOT polynomial. We can't distinguish between these two cases, and this
algorithm just tries to work assuming that P IS a polynomial. If not,
algorithm will return results, but they won't have any meaning.
-- ALGLIB --
Copyright 30.09.2010 by Bochkanov Sergey
*************************************************************************/
void polynomialbar2pow(const barycentricinterpolant &p, const double c, const double s, real_1d_array &a);
void polynomialbar2pow(const barycentricinterpolant &p, real_1d_array &a);
/*************************************************************************
Conversion from power basis to barycentric representation.
This function has O(N^2) complexity.
INPUT PARAMETERS:
A - coefficients, P(x) = sum { A[i]*((X-C)/S)^i, i=0..N-1 }
N - number of coefficients (polynomial degree plus 1)
* if given, only leading N elements of A are used
* if not given, automatically determined from size of A
C - offset (see below); 0.0 is used as default value.
S - scale (see below); 1.0 is used as default value. S<>0.
OUTPUT PARAMETERS
P - polynomial in barycentric form
NOTES:
1. this function accepts offset and scale, which can be set to improve
numerical properties of polynomial. For example, if you interpolate on
[-1,+1], you can set C=0 and S=1 and convert from sum of 1, x, x^2,
x^3 and so on. In most cases you it is exactly what you need.
However, if your interpolation model was built on [999,1001], you will
see significant growth of numerical errors when using {1, x, x^2, x^3}
as input basis. Converting from sum of 1, (x-1000), (x-1000)^2,
(x-1000)^3 will be better option (you have to specify 1000.0 as offset
C and 1.0 as scale S).
2. power basis is ill-conditioned and tricks described above can't solve
this problem completely. This function will return barycentric model
in any case, but for N>8 accuracy well degrade. However, N's less than
5 are pretty safe.
-- ALGLIB --
Copyright 30.09.2010 by Bochkanov Sergey
*************************************************************************/
void polynomialpow2bar(const real_1d_array &a, const ae_int_t n, const double c, const double s, barycentricinterpolant &p);
void polynomialpow2bar(const real_1d_array &a, barycentricinterpolant &p);
/*************************************************************************
Lagrange intepolant: generation of the model on the general grid.
This function has O(N^2) complexity.
INPUT PARAMETERS:
X - abscissas, array[0..N-1]
Y - function values, array[0..N-1]
N - number of points, N>=1
OUTPUT PARAMETERS
P - barycentric model which represents Lagrange interpolant
(see ratint unit info and BarycentricCalc() description for
more information).
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
void polynomialbuild(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
void polynomialbuild(const real_1d_array &x, const real_1d_array &y, barycentricinterpolant &p);
/*************************************************************************
Lagrange intepolant: generation of the model on equidistant grid.
This function has O(N) complexity.
INPUT PARAMETERS:
A - left boundary of [A,B]
B - right boundary of [A,B]
Y - function values at the nodes, array[0..N-1]
N - number of points, N>=1
for N=1 a constant model is constructed.
OUTPUT PARAMETERS
P - barycentric model which represents Lagrange interpolant
(see ratint unit info and BarycentricCalc() description for
more information).
-- ALGLIB --
Copyright 03.12.2009 by Bochkanov Sergey
*************************************************************************/
void polynomialbuildeqdist(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
void polynomialbuildeqdist(const double a, const double b, const real_1d_array &y, barycentricinterpolant &p);
/*************************************************************************
Lagrange intepolant on Chebyshev grid (first kind).
This function has O(N) complexity.
INPUT PARAMETERS:
A - left boundary of [A,B]
B - right boundary of [A,B]
Y - function values at the nodes, array[0..N-1],
Y[I] = Y(0.5*(B+A) + 0.5*(B-A)*Cos(PI*(2*i+1)/(2*n)))
N - number of points, N>=1
for N=1 a constant model is constructed.
OUTPUT PARAMETERS
P - barycentric model which represents Lagrange interpolant
(see ratint unit info and BarycentricCalc() description for
more information).
-- ALGLIB --
Copyright 03.12.2009 by Bochkanov Sergey
*************************************************************************/
void polynomialbuildcheb1(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
void polynomialbuildcheb1(const double a, const double b, const real_1d_array &y, barycentricinterpolant &p);
/*************************************************************************
Lagrange intepolant on Chebyshev grid (second kind).
This function has O(N) complexity.
INPUT PARAMETERS:
A - left boundary of [A,B]
B - right boundary of [A,B]
Y - function values at the nodes, array[0..N-1],
Y[I] = Y(0.5*(B+A) + 0.5*(B-A)*Cos(PI*i/(n-1)))
N - number of points, N>=1
for N=1 a constant model is constructed.
OUTPUT PARAMETERS
P - barycentric model which represents Lagrange interpolant
(see ratint unit info and BarycentricCalc() description for
more information).
-- ALGLIB --
Copyright 03.12.2009 by Bochkanov Sergey
*************************************************************************/
void polynomialbuildcheb2(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
void polynomialbuildcheb2(const double a, const double b, const real_1d_array &y, barycentricinterpolant &p);
/*************************************************************************
Fast equidistant polynomial interpolation function with O(N) complexity
INPUT PARAMETERS:
A - left boundary of [A,B]
B - right boundary of [A,B]
F - function values, array[0..N-1]
N - number of points on equidistant grid, N>=1
for N=1 a constant model is constructed.
T - position where P(x) is calculated
RESULT
value of the Lagrange interpolant at T
IMPORTANT
this function provides fast interface which is not overflow-safe
nor it is very precise.
the best option is to use PolynomialBuildEqDist()/BarycentricCalc()
subroutines unless you are pretty sure that your data will not result
in overflow.
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
double polynomialcalceqdist(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t);
double polynomialcalceqdist(const double a, const double b, const real_1d_array &f, const double t);
/*************************************************************************
Fast polynomial interpolation function on Chebyshev points (first kind)
with O(N) complexity.
INPUT PARAMETERS:
A - left boundary of [A,B]
B - right boundary of [A,B]
F - function values, array[0..N-1]
N - number of points on Chebyshev grid (first kind),
X[i] = 0.5*(B+A) + 0.5*(B-A)*Cos(PI*(2*i+1)/(2*n))
for N=1 a constant model is constructed.
T - position where P(x) is calculated
RESULT
value of the Lagrange interpolant at T
IMPORTANT
this function provides fast interface which is not overflow-safe
nor it is very precise.
the best option is to use PolIntBuildCheb1()/BarycentricCalc()
subroutines unless you are pretty sure that your data will not result
in overflow.
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
double polynomialcalccheb1(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t);
double polynomialcalccheb1(const double a, const double b, const real_1d_array &f, const double t);
/*************************************************************************
Fast polynomial interpolation function on Chebyshev points (second kind)
with O(N) complexity.
INPUT PARAMETERS:
A - left boundary of [A,B]
B - right boundary of [A,B]
F - function values, array[0..N-1]
N - number of points on Chebyshev grid (second kind),
X[i] = 0.5*(B+A) + 0.5*(B-A)*Cos(PI*i/(n-1))
for N=1 a constant model is constructed.
T - position where P(x) is calculated
RESULT
value of the Lagrange interpolant at T
IMPORTANT
this function provides fast interface which is not overflow-safe
nor it is very precise.
the best option is to use PolIntBuildCheb2()/BarycentricCalc()
subroutines unless you are pretty sure that your data will not result
in overflow.
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
double polynomialcalccheb2(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t);
double polynomialcalccheb2(const double a, const double b, const real_1d_array &f, const double t);
/*************************************************************************
This subroutine builds linear spline interpolant
INPUT PARAMETERS:
X - spline nodes, array[0..N-1]
Y - function values, array[0..N-1]
N - points count (optional):
* N>=2
* if given, only first N points are used to build spline
* if not given, automatically detected from X/Y sizes
(len(X) must be equal to len(Y))
OUTPUT PARAMETERS:
C - spline interpolant
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
-- ALGLIB PROJECT --
Copyright 24.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline1dbuildlinear(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, spline1dinterpolant &c);
void spline1dbuildlinear(const real_1d_array &x, const real_1d_array &y, spline1dinterpolant &c);
/*************************************************************************
This subroutine builds cubic spline interpolant.
INPUT PARAMETERS:
X - spline nodes, array[0..N-1].
Y - function values, array[0..N-1].
OPTIONAL PARAMETERS:
N - points count:
* N>=2
* if given, only first N points are used to build spline
* if not given, automatically detected from X/Y sizes
(len(X) must be equal to len(Y))
BoundLType - boundary condition type for the left boundary
BoundL - left boundary condition (first or second derivative,
depending on the BoundLType)
BoundRType - boundary condition type for the right boundary
BoundR - right boundary condition (first or second derivative,
depending on the BoundRType)
OUTPUT PARAMETERS:
C - spline interpolant
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
SETTING BOUNDARY VALUES:
The BoundLType/BoundRType parameters can have the following values:
* -1, which corresonds to the periodic (cyclic) boundary conditions.
In this case:
* both BoundLType and BoundRType must be equal to -1.
* BoundL/BoundR are ignored
* Y[last] is ignored (it is assumed to be equal to Y[first]).
* 0, which corresponds to the parabolically terminated spline
(BoundL and/or BoundR are ignored).
* 1, which corresponds to the first derivative boundary condition
* 2, which corresponds to the second derivative boundary condition
* by default, BoundType=0 is used
PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
However, this subroutine doesn't require you to specify equal values for
the first and last points - it automatically forces them to be equal by
copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
Y[last_point]. However it is recommended to pass consistent values of Y[],
i.e. to make Y[first_point]=Y[last_point].
-- ALGLIB PROJECT --
Copyright 23.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline1dbuildcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, spline1dinterpolant &c);
void spline1dbuildcubic(const real_1d_array &x, const real_1d_array &y, spline1dinterpolant &c);
/*************************************************************************
This function solves following problem: given table y[] of function values
at nodes x[], it calculates and returns table of function derivatives d[]
(calculated at the same nodes x[]).
This function yields same result as Spline1DBuildCubic() call followed by
sequence of Spline1DDiff() calls, but it can be several times faster when
called for ordered X[] and X2[].
INPUT PARAMETERS:
X - spline nodes
Y - function values
OPTIONAL PARAMETERS:
N - points count:
* N>=2
* if given, only first N points are used
* if not given, automatically detected from X/Y sizes
(len(X) must be equal to len(Y))
BoundLType - boundary condition type for the left boundary
BoundL - left boundary condition (first or second derivative,
depending on the BoundLType)
BoundRType - boundary condition type for the right boundary
BoundR - right boundary condition (first or second derivative,
depending on the BoundRType)
OUTPUT PARAMETERS:
D - derivative values at X[]
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
Derivative values are correctly reordered on return, so D[I] is always
equal to S'(X[I]) independently of points order.
SETTING BOUNDARY VALUES:
The BoundLType/BoundRType parameters can have the following values:
* -1, which corresonds to the periodic (cyclic) boundary conditions.
In this case:
* both BoundLType and BoundRType must be equal to -1.
* BoundL/BoundR are ignored
* Y[last] is ignored (it is assumed to be equal to Y[first]).
* 0, which corresponds to the parabolically terminated spline
(BoundL and/or BoundR are ignored).
* 1, which corresponds to the first derivative boundary condition
* 2, which corresponds to the second derivative boundary condition
* by default, BoundType=0 is used
PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
However, this subroutine doesn't require you to specify equal values for
the first and last points - it automatically forces them to be equal by
copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
Y[last_point]. However it is recommended to pass consistent values of Y[],
i.e. to make Y[first_point]=Y[last_point].
-- ALGLIB PROJECT --
Copyright 03.09.2010 by Bochkanov Sergey
*************************************************************************/
void spline1dgriddiffcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, real_1d_array &d);
void spline1dgriddiffcubic(const real_1d_array &x, const real_1d_array &y, real_1d_array &d);
/*************************************************************************
This function solves following problem: given table y[] of function values
at nodes x[], it calculates and returns tables of first and second
function derivatives d1[] and d2[] (calculated at the same nodes x[]).
This function yields same result as Spline1DBuildCubic() call followed by
sequence of Spline1DDiff() calls, but it can be several times faster when
called for ordered X[] and X2[].
INPUT PARAMETERS:
X - spline nodes
Y - function values
OPTIONAL PARAMETERS:
N - points count:
* N>=2
* if given, only first N points are used
* if not given, automatically detected from X/Y sizes
(len(X) must be equal to len(Y))
BoundLType - boundary condition type for the left boundary
BoundL - left boundary condition (first or second derivative,
depending on the BoundLType)
BoundRType - boundary condition type for the right boundary
BoundR - right boundary condition (first or second derivative,
depending on the BoundRType)
OUTPUT PARAMETERS:
D1 - S' values at X[]
D2 - S'' values at X[]
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
Derivative values are correctly reordered on return, so D[I] is always
equal to S'(X[I]) independently of points order.
SETTING BOUNDARY VALUES:
The BoundLType/BoundRType parameters can have the following values:
* -1, which corresonds to the periodic (cyclic) boundary conditions.
In this case:
* both BoundLType and BoundRType must be equal to -1.
* BoundL/BoundR are ignored
* Y[last] is ignored (it is assumed to be equal to Y[first]).
* 0, which corresponds to the parabolically terminated spline
(BoundL and/or BoundR are ignored).
* 1, which corresponds to the first derivative boundary condition
* 2, which corresponds to the second derivative boundary condition
* by default, BoundType=0 is used
PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
However, this subroutine doesn't require you to specify equal values for
the first and last points - it automatically forces them to be equal by
copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
Y[last_point]. However it is recommended to pass consistent values of Y[],
i.e. to make Y[first_point]=Y[last_point].
-- ALGLIB PROJECT --
Copyright 03.09.2010 by Bochkanov Sergey
*************************************************************************/
void spline1dgriddiff2cubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, real_1d_array &d1, real_1d_array &d2);
void spline1dgriddiff2cubic(const real_1d_array &x, const real_1d_array &y, real_1d_array &d1, real_1d_array &d2);
/*************************************************************************
This function solves following problem: given table y[] of function values
at old nodes x[] and new nodes x2[], it calculates and returns table of
function values y2[] (calculated at x2[]).
This function yields same result as Spline1DBuildCubic() call followed by
sequence of Spline1DDiff() calls, but it can be several times faster when
called for ordered X[] and X2[].
INPUT PARAMETERS:
X - old spline nodes
Y - function values
X2 - new spline nodes
OPTIONAL PARAMETERS:
N - points count:
* N>=2
* if given, only first N points from X/Y are used
* if not given, automatically detected from X/Y sizes
(len(X) must be equal to len(Y))
BoundLType - boundary condition type for the left boundary
BoundL - left boundary condition (first or second derivative,
depending on the BoundLType)
BoundRType - boundary condition type for the right boundary
BoundR - right boundary condition (first or second derivative,
depending on the BoundRType)
N2 - new points count:
* N2>=2
* if given, only first N2 points from X2 are used
* if not given, automatically detected from X2 size
OUTPUT PARAMETERS:
F2 - function values at X2[]
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
Function values are correctly reordered on return, so F2[I] is always
equal to S(X2[I]) independently of points order.
SETTING BOUNDARY VALUES:
The BoundLType/BoundRType parameters can have the following values:
* -1, which corresonds to the periodic (cyclic) boundary conditions.
In this case:
* both BoundLType and BoundRType must be equal to -1.
* BoundL/BoundR are ignored
* Y[last] is ignored (it is assumed to be equal to Y[first]).
* 0, which corresponds to the parabolically terminated spline
(BoundL and/or BoundR are ignored).
* 1, which corresponds to the first derivative boundary condition
* 2, which corresponds to the second derivative boundary condition
* by default, BoundType=0 is used
PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
However, this subroutine doesn't require you to specify equal values for
the first and last points - it automatically forces them to be equal by
copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
Y[last_point]. However it is recommended to pass consistent values of Y[],
i.e. to make Y[first_point]=Y[last_point].
-- ALGLIB PROJECT --
Copyright 03.09.2010 by Bochkanov Sergey
*************************************************************************/
void spline1dconvcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y2);
void spline1dconvcubic(const real_1d_array &x, const real_1d_array &y, const real_1d_array &x2, real_1d_array &y2);
/*************************************************************************
This function solves following problem: given table y[] of function values
at old nodes x[] and new nodes x2[], it calculates and returns table of
function values y2[] and derivatives d2[] (calculated at x2[]).
This function yields same result as Spline1DBuildCubic() call followed by
sequence of Spline1DDiff() calls, but it can be several times faster when
called for ordered X[] and X2[].
INPUT PARAMETERS:
X - old spline nodes
Y - function values
X2 - new spline nodes
OPTIONAL PARAMETERS:
N - points count:
* N>=2
* if given, only first N points from X/Y are used
* if not given, automatically detected from X/Y sizes
(len(X) must be equal to len(Y))
BoundLType - boundary condition type for the left boundary
BoundL - left boundary condition (first or second derivative,
depending on the BoundLType)
BoundRType - boundary condition type for the right boundary
BoundR - right boundary condition (first or second derivative,
depending on the BoundRType)
N2 - new points count:
* N2>=2
* if given, only first N2 points from X2 are used
* if not given, automatically detected from X2 size
OUTPUT PARAMETERS:
F2 - function values at X2[]
D2 - first derivatives at X2[]
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
Function values are correctly reordered on return, so F2[I] is always
equal to S(X2[I]) independently of points order.
SETTING BOUNDARY VALUES:
The BoundLType/BoundRType parameters can have the following values:
* -1, which corresonds to the periodic (cyclic) boundary conditions.
In this case:
* both BoundLType and BoundRType must be equal to -1.
* BoundL/BoundR are ignored
* Y[last] is ignored (it is assumed to be equal to Y[first]).
* 0, which corresponds to the parabolically terminated spline
(BoundL and/or BoundR are ignored).
* 1, which corresponds to the first derivative boundary condition
* 2, which corresponds to the second derivative boundary condition
* by default, BoundType=0 is used
PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
However, this subroutine doesn't require you to specify equal values for
the first and last points - it automatically forces them to be equal by
copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
Y[last_point]. However it is recommended to pass consistent values of Y[],
i.e. to make Y[first_point]=Y[last_point].
-- ALGLIB PROJECT --
Copyright 03.09.2010 by Bochkanov Sergey
*************************************************************************/
void spline1dconvdiffcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y2, real_1d_array &d2);
void spline1dconvdiffcubic(const real_1d_array &x, const real_1d_array &y, const real_1d_array &x2, real_1d_array &y2, real_1d_array &d2);
/*************************************************************************
This function solves following problem: given table y[] of function values
at old nodes x[] and new nodes x2[], it calculates and returns table of
function values y2[], first and second derivatives d2[] and dd2[]
(calculated at x2[]).
This function yields same result as Spline1DBuildCubic() call followed by
sequence of Spline1DDiff() calls, but it can be several times faster when
called for ordered X[] and X2[].
INPUT PARAMETERS:
X - old spline nodes
Y - function values
X2 - new spline nodes
OPTIONAL PARAMETERS:
N - points count:
* N>=2
* if given, only first N points from X/Y are used
* if not given, automatically detected from X/Y sizes
(len(X) must be equal to len(Y))
BoundLType - boundary condition type for the left boundary
BoundL - left boundary condition (first or second derivative,
depending on the BoundLType)
BoundRType - boundary condition type for the right boundary
BoundR - right boundary condition (first or second derivative,
depending on the BoundRType)
N2 - new points count:
* N2>=2
* if given, only first N2 points from X2 are used
* if not given, automatically detected from X2 size
OUTPUT PARAMETERS:
F2 - function values at X2[]
D2 - first derivatives at X2[]
DD2 - second derivatives at X2[]
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
Function values are correctly reordered on return, so F2[I] is always
equal to S(X2[I]) independently of points order.
SETTING BOUNDARY VALUES:
The BoundLType/BoundRType parameters can have the following values:
* -1, which corresonds to the periodic (cyclic) boundary conditions.
In this case:
* both BoundLType and BoundRType must be equal to -1.
* BoundL/BoundR are ignored
* Y[last] is ignored (it is assumed to be equal to Y[first]).
* 0, which corresponds to the parabolically terminated spline
(BoundL and/or BoundR are ignored).
* 1, which corresponds to the first derivative boundary condition
* 2, which corresponds to the second derivative boundary condition
* by default, BoundType=0 is used
PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
However, this subroutine doesn't require you to specify equal values for
the first and last points - it automatically forces them to be equal by
copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
Y[last_point]. However it is recommended to pass consistent values of Y[],
i.e. to make Y[first_point]=Y[last_point].
-- ALGLIB PROJECT --
Copyright 03.09.2010 by Bochkanov Sergey
*************************************************************************/
void spline1dconvdiff2cubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y2, real_1d_array &d2, real_1d_array &dd2);
void spline1dconvdiff2cubic(const real_1d_array &x, const real_1d_array &y, const real_1d_array &x2, real_1d_array &y2, real_1d_array &d2, real_1d_array &dd2);
/*************************************************************************
This subroutine builds Catmull-Rom spline interpolant.
INPUT PARAMETERS:
X - spline nodes, array[0..N-1].
Y - function values, array[0..N-1].
OPTIONAL PARAMETERS:
N - points count:
* N>=2
* if given, only first N points are used to build spline
* if not given, automatically detected from X/Y sizes
(len(X) must be equal to len(Y))
BoundType - boundary condition type:
* -1 for periodic boundary condition
* 0 for parabolically terminated spline (default)
Tension - tension parameter:
* tension=0 corresponds to classic Catmull-Rom spline (default)
* 0<tension<1 corresponds to more general form - cardinal spline
OUTPUT PARAMETERS:
C - spline interpolant
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
However, this subroutine doesn't require you to specify equal values for
the first and last points - it automatically forces them to be equal by
copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
Y[last_point]. However it is recommended to pass consistent values of Y[],
i.e. to make Y[first_point]=Y[last_point].
-- ALGLIB PROJECT --
Copyright 23.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline1dbuildcatmullrom(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundtype, const double tension, spline1dinterpolant &c);
void spline1dbuildcatmullrom(const real_1d_array &x, const real_1d_array &y, spline1dinterpolant &c);
/*************************************************************************
This subroutine builds Hermite spline interpolant.
INPUT PARAMETERS:
X - spline nodes, array[0..N-1]
Y - function values, array[0..N-1]
D - derivatives, array[0..N-1]
N - points count (optional):
* N>=2
* if given, only first N points are used to build spline
* if not given, automatically detected from X/Y sizes
(len(X) must be equal to len(Y))
OUTPUT PARAMETERS:
C - spline interpolant.
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
-- ALGLIB PROJECT --
Copyright 23.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline1dbuildhermite(const real_1d_array &x, const real_1d_array &y, const real_1d_array &d, const ae_int_t n, spline1dinterpolant &c);
void spline1dbuildhermite(const real_1d_array &x, const real_1d_array &y, const real_1d_array &d, spline1dinterpolant &c);
/*************************************************************************
This subroutine builds Akima spline interpolant
INPUT PARAMETERS:
X - spline nodes, array[0..N-1]
Y - function values, array[0..N-1]
N - points count (optional):
* N>=2
* if given, only first N points are used to build spline
* if not given, automatically detected from X/Y sizes
(len(X) must be equal to len(Y))
OUTPUT PARAMETERS:
C - spline interpolant
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
-- ALGLIB PROJECT --
Copyright 24.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline1dbuildakima(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, spline1dinterpolant &c);
void spline1dbuildakima(const real_1d_array &x, const real_1d_array &y, spline1dinterpolant &c);
/*************************************************************************
This subroutine calculates the value of the spline at the given point X.
INPUT PARAMETERS:
C - spline interpolant
X - point
Result:
S(x)
-- ALGLIB PROJECT --
Copyright 23.06.2007 by Bochkanov Sergey
*************************************************************************/
double spline1dcalc(const spline1dinterpolant &c, const double x);
/*************************************************************************
This subroutine differentiates the spline.
INPUT PARAMETERS:
C - spline interpolant.
X - point
Result:
S - S(x)
DS - S'(x)
D2S - S''(x)
-- ALGLIB PROJECT --
Copyright 24.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline1ddiff(const spline1dinterpolant &c, const double x, double &s, double &ds, double &d2s);
/*************************************************************************
This subroutine unpacks the spline into the coefficients table.
INPUT PARAMETERS:
C - spline interpolant.
X - point
OUTPUT PARAMETERS:
Tbl - coefficients table, unpacked format, array[0..N-2, 0..5].
For I = 0...N-2:
Tbl[I,0] = X[i]
Tbl[I,1] = X[i+1]
Tbl[I,2] = C0
Tbl[I,3] = C1
Tbl[I,4] = C2
Tbl[I,5] = C3
On [x[i], x[i+1]] spline is equals to:
S(x) = C0 + C1*t + C2*t^2 + C3*t^3
t = x-x[i]
NOTE:
You can rebuild spline with Spline1DBuildHermite() function, which
accepts as inputs function values and derivatives at nodes, which are
easy to calculate when you have coefficients.
-- ALGLIB PROJECT --
Copyright 29.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline1dunpack(const spline1dinterpolant &c, ae_int_t &n, real_2d_array &tbl);
/*************************************************************************
This subroutine performs linear transformation of the spline argument.
INPUT PARAMETERS:
C - spline interpolant.
A, B- transformation coefficients: x = A*t + B
Result:
C - transformed spline
-- ALGLIB PROJECT --
Copyright 30.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline1dlintransx(const spline1dinterpolant &c, const double a, const double b);
/*************************************************************************
This subroutine performs linear transformation of the spline.
INPUT PARAMETERS:
C - spline interpolant.
A, B- transformation coefficients: S2(x) = A*S(x) + B
Result:
C - transformed spline
-- ALGLIB PROJECT --
Copyright 30.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline1dlintransy(const spline1dinterpolant &c, const double a, const double b);
/*************************************************************************
This subroutine integrates the spline.
INPUT PARAMETERS:
C - spline interpolant.
X - right bound of the integration interval [a, x],
here 'a' denotes min(x[])
Result:
integral(S(t)dt,a,x)
-- ALGLIB PROJECT --
Copyright 23.06.2007 by Bochkanov Sergey
*************************************************************************/
double spline1dintegrate(const spline1dinterpolant &c, const double x);
/*************************************************************************
This function builds monotone cubic Hermite interpolant. This interpolant
is monotonic in [x(0),x(n-1)] and is constant outside of this interval.
In case y[] form non-monotonic sequence, interpolant is piecewise
monotonic. Say, for x=(0,1,2,3,4) and y=(0,1,2,1,0) interpolant will
monotonically grow at [0..2] and monotonically decrease at [2..4].
INPUT PARAMETERS:
X - spline nodes, array[0..N-1]. Subroutine automatically
sorts points, so caller may pass unsorted array.
Y - function values, array[0..N-1]
N - the number of points(N>=2).
OUTPUT PARAMETERS:
C - spline interpolant.
-- ALGLIB PROJECT --
Copyright 21.06.2012 by Bochkanov Sergey
*************************************************************************/
void spline1dbuildmonotone(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, spline1dinterpolant &c);
void spline1dbuildmonotone(const real_1d_array &x, const real_1d_array &y, spline1dinterpolant &c);
/*************************************************************************
This subroutine fits piecewise linear curve to points with Ramer-Douglas-
Peucker algorithm, which stops after generating specified number of linear
sections.
IMPORTANT:
* it does NOT perform least-squares fitting; it builds curve, but this
curve does not minimize some least squares metric. See description of
RDP algorithm (say, in Wikipedia) for more details on WHAT is performed.
* this function does NOT work with parametric curves (i.e. curves which
can be represented as {X(t),Y(t)}. It works with curves which can be
represented as Y(X). Thus, it is impossible to model figures like
circles with this functions.
If you want to work with parametric curves, you should use
ParametricRDPFixed() function provided by "Parametric" subpackage of
"Interpolation" package.
INPUT PARAMETERS:
X - array of X-coordinates:
* at least N elements
* can be unordered (points are automatically sorted)
* this function may accept non-distinct X (see below for
more information on handling of such inputs)
Y - array of Y-coordinates:
* at least N elements
N - number of elements in X/Y
M - desired number of sections:
* at most M sections are generated by this function
* less than M sections can be generated if we have N<M
(or some X are non-distinct).
OUTPUT PARAMETERS:
X2 - X-values of corner points for piecewise approximation,
has length NSections+1 or zero (for NSections=0).
Y2 - Y-values of corner points,
has length NSections+1 or zero (for NSections=0).
NSections- number of sections found by algorithm, NSections<=M,
NSections can be zero for degenerate datasets
(N<=1 or all X[] are non-distinct).
NOTE: X2/Y2 are ordered arrays, i.e. (X2[0],Y2[0]) is a first point of
curve, (X2[NSection-1],Y2[NSection-1]) is the last point.
-- ALGLIB --
Copyright 02.10.2014 by Bochkanov Sergey
*************************************************************************/
void lstfitpiecewiselinearrdpfixed(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, real_1d_array &x2, real_1d_array &y2, ae_int_t &nsections);
/*************************************************************************
This subroutine fits piecewise linear curve to points with Ramer-Douglas-
Peucker algorithm, which stops after achieving desired precision.
IMPORTANT:
* it performs non-least-squares fitting; it builds curve, but this curve
does not minimize some least squares metric. See description of RDP
algorithm (say, in Wikipedia) for more details on WHAT is performed.
* this function does NOT work with parametric curves (i.e. curves which
can be represented as {X(t),Y(t)}. It works with curves which can be
represented as Y(X). Thus, it is impossible to model figures like circles
with this functions.
If you want to work with parametric curves, you should use
ParametricRDPFixed() function provided by "Parametric" subpackage of
"Interpolation" package.
INPUT PARAMETERS:
X - array of X-coordinates:
* at least N elements
* can be unordered (points are automatically sorted)
* this function may accept non-distinct X (see below for
more information on handling of such inputs)
Y - array of Y-coordinates:
* at least N elements
N - number of elements in X/Y
Eps - positive number, desired precision.
OUTPUT PARAMETERS:
X2 - X-values of corner points for piecewise approximation,
has length NSections+1 or zero (for NSections=0).
Y2 - Y-values of corner points,
has length NSections+1 or zero (for NSections=0).
NSections- number of sections found by algorithm,
NSections can be zero for degenerate datasets
(N<=1 or all X[] are non-distinct).
NOTE: X2/Y2 are ordered arrays, i.e. (X2[0],Y2[0]) is a first point of
curve, (X2[NSection-1],Y2[NSection-1]) is the last point.
-- ALGLIB --
Copyright 02.10.2014 by Bochkanov Sergey
*************************************************************************/
void lstfitpiecewiselinearrdp(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double eps, real_1d_array &x2, real_1d_array &y2, ae_int_t &nsections);
/*************************************************************************
Fitting by polynomials in barycentric form. This function provides simple
unterface for unconstrained unweighted fitting. See PolynomialFitWC() if
you need constrained fitting.
Task is linear, so linear least squares solver is used. Complexity of this
computational scheme is O(N*M^2), mostly dominated by least squares solver
SEE ALSO:
PolynomialFitWC()
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
X - points, array[0..N-1].
Y - function values, array[0..N-1].
N - number of points, N>0
* if given, only leading N elements of X/Y are used
* if not given, automatically determined from sizes of X/Y
M - number of basis functions (= polynomial_degree + 1), M>=1
OUTPUT PARAMETERS:
Info- same format as in LSFitLinearW() subroutine:
* Info>0 task is solved
* Info<=0 an error occured:
-4 means inconvergence of internal SVD
P - interpolant in barycentric form.
Rep - report, same format as in LSFitLinearW() subroutine.
Following fields are set:
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
NOTES:
you can convert P from barycentric form to the power or Chebyshev
basis with PolynomialBar2Pow() or PolynomialBar2Cheb() functions from
POLINT subpackage.
-- ALGLIB PROJECT --
Copyright 10.12.2009 by Bochkanov Sergey
*************************************************************************/
void polynomialfit(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
void smp_polynomialfit(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
void polynomialfit(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
void smp_polynomialfit(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
/*************************************************************************
Weighted fitting by polynomials in barycentric form, with constraints on
function values or first derivatives.
Small regularizing term is used when solving constrained tasks (to improve
stability).
Task is linear, so linear least squares solver is used. Complexity of this
computational scheme is O(N*M^2), mostly dominated by least squares solver
SEE ALSO:
PolynomialFit()
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
X - points, array[0..N-1].
Y - function values, array[0..N-1].
W - weights, array[0..N-1]
Each summand in square sum of approximation deviations from
given values is multiplied by the square of corresponding
weight. Fill it by 1's if you don't want to solve weighted
task.
N - number of points, N>0.
* if given, only leading N elements of X/Y/W are used
* if not given, automatically determined from sizes of X/Y/W
XC - points where polynomial values/derivatives are constrained,
array[0..K-1].
YC - values of constraints, array[0..K-1]
DC - array[0..K-1], types of constraints:
* DC[i]=0 means that P(XC[i])=YC[i]
* DC[i]=1 means that P'(XC[i])=YC[i]
SEE BELOW FOR IMPORTANT INFORMATION ON CONSTRAINTS
K - number of constraints, 0<=K<M.
K=0 means no constraints (XC/YC/DC are not used in such cases)
M - number of basis functions (= polynomial_degree + 1), M>=1
OUTPUT PARAMETERS:
Info- same format as in LSFitLinearW() subroutine:
* Info>0 task is solved
* Info<=0 an error occured:
-4 means inconvergence of internal SVD
-3 means inconsistent constraints
P - interpolant in barycentric form.
Rep - report, same format as in LSFitLinearW() subroutine.
Following fields are set:
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
IMPORTANT:
this subroitine doesn't calculate task's condition number for K<>0.
NOTES:
you can convert P from barycentric form to the power or Chebyshev
basis with PolynomialBar2Pow() or PolynomialBar2Cheb() functions from
POLINT subpackage.
SETTING CONSTRAINTS - DANGERS AND OPPORTUNITIES:
Setting constraints can lead to undesired results, like ill-conditioned
behavior, or inconsistency being detected. From the other side, it allows
us to improve quality of the fit. Here we summarize our experience with
constrained regression splines:
* even simple constraints can be inconsistent, see Wikipedia article on
this subject: http://en.wikipedia.org/wiki/Birkhoff_interpolation
* the greater is M (given fixed constraints), the more chances that
constraints will be consistent
* in the general case, consistency of constraints is NOT GUARANTEED.
* in the one special cases, however, we can guarantee consistency. This
case is: M>1 and constraints on the function values (NOT DERIVATIVES)
Our final recommendation is to use constraints WHEN AND ONLY when you
can't solve your task without them. Anything beyond special cases given
above is not guaranteed and may result in inconsistency.
-- ALGLIB PROJECT --
Copyright 10.12.2009 by Bochkanov Sergey
*************************************************************************/
void polynomialfitwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
void smp_polynomialfitwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
void polynomialfitwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
void smp_polynomialfitwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
/*************************************************************************
This function calculates value of four-parameter logistic (4PL) model at
specified point X. 4PL model has following form:
F(x|A,B,C,D) = D+(A-D)/(1+Power(x/C,B))
INPUT PARAMETERS:
X - current point, X>=0:
* zero X is correctly handled even for B<=0
* negative X results in exception.
A, B, C, D- parameters of 4PL model:
* A is unconstrained
* B is unconstrained; zero or negative values are handled
correctly.
* C>0, non-positive value results in exception
* D is unconstrained
RESULT:
model value at X
NOTE: if B=0, denominator is assumed to be equal to 2.0 even for zero X
(strictly speaking, 0^0 is undefined).
NOTE: this function also throws exception if all input parameters are
correct, but overflow was detected during calculations.
NOTE: this function performs a lot of checks; if you need really high
performance, consider evaluating model yourself, without checking
for degenerate cases.
-- ALGLIB PROJECT --
Copyright 14.05.2014 by Bochkanov Sergey
*************************************************************************/
double logisticcalc4(const double x, const double a, const double b, const double c, const double d);
/*************************************************************************
This function calculates value of five-parameter logistic (5PL) model at
specified point X. 5PL model has following form:
F(x|A,B,C,D,G) = D+(A-D)/Power(1+Power(x/C,B),G)
INPUT PARAMETERS:
X - current point, X>=0:
* zero X is correctly handled even for B<=0
* negative X results in exception.
A, B, C, D, G- parameters of 5PL model:
* A is unconstrained
* B is unconstrained; zero or negative values are handled
correctly.
* C>0, non-positive value results in exception
* D is unconstrained
* G>0, non-positive value results in exception
RESULT:
model value at X
NOTE: if B=0, denominator is assumed to be equal to Power(2.0,G) even for
zero X (strictly speaking, 0^0 is undefined).
NOTE: this function also throws exception if all input parameters are
correct, but overflow was detected during calculations.
NOTE: this function performs a lot of checks; if you need really high
performance, consider evaluating model yourself, without checking
for degenerate cases.
-- ALGLIB PROJECT --
Copyright 14.05.2014 by Bochkanov Sergey
*************************************************************************/
double logisticcalc5(const double x, const double a, const double b, const double c, const double d, const double g);
/*************************************************************************
This function fits four-parameter logistic (4PL) model to data provided
by user. 4PL model has following form:
F(x|A,B,C,D) = D+(A-D)/(1+Power(x/C,B))
Here:
* A, D - unconstrained (see LogisticFit4EC() for constrained 4PL)
* B>=0
* C>0
IMPORTANT: output of this function is constrained in such way that B>0.
Because 4PL model is symmetric with respect to B, there is no
need to explore B<0. Constraining B makes algorithm easier
to stabilize and debug.
Users who for some reason prefer to work with negative B's
should transform output themselves (swap A and D, replace B by
-B).
4PL fitting is implemented as follows:
* we perform small number of restarts from random locations which helps to
solve problem of bad local extrema. Locations are only partially random
- we use input data to determine good initial guess, but we include
controlled amount of randomness.
* we perform Levenberg-Marquardt fitting with very tight constraints on
parameters B and C - it allows us to find good initial guess for the
second stage without risk of running into "flat spot".
* second Levenberg-Marquardt round is performed without excessive
constraints. Results from the previous round are used as initial guess.
* after fitting is done, we compare results with best values found so far,
rewrite "best solution" if needed, and move to next random location.
Overall algorithm is very stable and is not prone to bad local extrema.
Furthermore, it automatically scales when input data have very large or
very small range.
INPUT PARAMETERS:
X - array[N], stores X-values.
MUST include only non-negative numbers (but may include
zero values). Can be unsorted.
Y - array[N], values to fit.
N - number of points. If N is less than length of X/Y, only
leading N elements are used.
OUTPUT PARAMETERS:
A, B, C, D- parameters of 4PL model
Rep - fitting report. This structure has many fields, but ONLY
ONES LISTED BELOW ARE SET:
* Rep.IterationsCount - number of iterations performed
* Rep.RMSError - root-mean-square error
* Rep.AvgError - average absolute error
* Rep.AvgRelError - average relative error (calculated for
non-zero Y-values)
* Rep.MaxError - maximum absolute error
* Rep.R2 - coefficient of determination, R-squared. This
coefficient is calculated as R2=1-RSS/TSS (in case
of nonlinear regression there are multiple ways to
define R2, each of them giving different results).
NOTE: after you obtained coefficients, you can evaluate model with
LogisticCalc4() function.
NOTE: if you need better control over fitting process than provided by this
function, you may use LogisticFit45X().
NOTE: step is automatically scaled according to scale of parameters being
fitted before we compare its length with EpsX. Thus, this function
can be used to fit data with very small or very large values without
changing EpsX.
-- ALGLIB PROJECT --
Copyright 14.02.2014 by Bochkanov Sergey
*************************************************************************/
void logisticfit4(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, double &a, double &b, double &c, double &d, lsfitreport &rep);
/*************************************************************************
This function fits four-parameter logistic (4PL) model to data provided
by user, with optional constraints on parameters A and D. 4PL model has
following form:
F(x|A,B,C,D) = D+(A-D)/(1+Power(x/C,B))
Here:
* A, D - with optional equality constraints
* B>=0
* C>0
IMPORTANT: output of this function is constrained in such way that B>0.
Because 4PL model is symmetric with respect to B, there is no
need to explore B<0. Constraining B makes algorithm easier
to stabilize and debug.
Users who for some reason prefer to work with negative B's
should transform output themselves (swap A and D, replace B by
-B).
4PL fitting is implemented as follows:
* we perform small number of restarts from random locations which helps to
solve problem of bad local extrema. Locations are only partially random
- we use input data to determine good initial guess, but we include
controlled amount of randomness.
* we perform Levenberg-Marquardt fitting with very tight constraints on
parameters B and C - it allows us to find good initial guess for the
second stage without risk of running into "flat spot".
* second Levenberg-Marquardt round is performed without excessive
constraints. Results from the previous round are used as initial guess.
* after fitting is done, we compare results with best values found so far,
rewrite "best solution" if needed, and move to next random location.
Overall algorithm is very stable and is not prone to bad local extrema.
Furthermore, it automatically scales when input data have very large or
very small range.
INPUT PARAMETERS:
X - array[N], stores X-values.
MUST include only non-negative numbers (but may include
zero values). Can be unsorted.
Y - array[N], values to fit.
N - number of points. If N is less than length of X/Y, only
leading N elements are used.
CnstrLeft- optional equality constraint for model value at the left
boundary (at X=0). Specify NAN (Not-a-Number) if you do
not need constraint on the model value at X=0 (in C++ you
can pass alglib::fp_nan as parameter, in C# it will be
Double.NaN).
See below, section "EQUALITY CONSTRAINTS" for more
information about constraints.
CnstrRight- optional equality constraint for model value at X=infinity.
Specify NAN (Not-a-Number) if you do not need constraint
on the model value (in C++ you can pass alglib::fp_nan as
parameter, in C# it will be Double.NaN).
See below, section "EQUALITY CONSTRAINTS" for more
information about constraints.
OUTPUT PARAMETERS:
A, B, C, D- parameters of 4PL model
Rep - fitting report. This structure has many fields, but ONLY
ONES LISTED BELOW ARE SET:
* Rep.IterationsCount - number of iterations performed
* Rep.RMSError - root-mean-square error
* Rep.AvgError - average absolute error
* Rep.AvgRelError - average relative error (calculated for
non-zero Y-values)
* Rep.MaxError - maximum absolute error
* Rep.R2 - coefficient of determination, R-squared. This
coefficient is calculated as R2=1-RSS/TSS (in case
of nonlinear regression there are multiple ways to
define R2, each of them giving different results).
NOTE: after you obtained coefficients, you can evaluate model with
LogisticCalc4() function.
NOTE: if you need better control over fitting process than provided by this
function, you may use LogisticFit45X().
NOTE: step is automatically scaled according to scale of parameters being
fitted before we compare its length with EpsX. Thus, this function
can be used to fit data with very small or very large values without
changing EpsX.
EQUALITY CONSTRAINTS ON PARAMETERS
4PL/5PL solver supports equality constraints on model values at the left
boundary (X=0) and right boundary (X=infinity). These constraints are
completely optional and you can specify both of them, only one - or no
constraints at all.
Parameter CnstrLeft contains left constraint (or NAN for unconstrained
fitting), and CnstrRight contains right one. For 4PL, left constraint
ALWAYS corresponds to parameter A, and right one is ALWAYS constraint on
D. That's because 4PL model is normalized in such way that B>=0.
-- ALGLIB PROJECT --
Copyright 14.02.2014 by Bochkanov Sergey
*************************************************************************/
void logisticfit4ec(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double cnstrleft, const double cnstrright, double &a, double &b, double &c, double &d, lsfitreport &rep);
/*************************************************************************
This function fits five-parameter logistic (5PL) model to data provided
by user. 5PL model has following form:
F(x|A,B,C,D,G) = D+(A-D)/Power(1+Power(x/C,B),G)
Here:
* A, D - unconstrained
* B - unconstrained
* C>0
* G>0
IMPORTANT: unlike in 4PL fitting, output of this function is NOT
constrained in such way that B is guaranteed to be positive.
Furthermore, unlike 4PL, 5PL model is NOT symmetric with
respect to B, so you can NOT transform model to equivalent one,
with B having desired sign (>0 or <0).
5PL fitting is implemented as follows:
* we perform small number of restarts from random locations which helps to
solve problem of bad local extrema. Locations are only partially random
- we use input data to determine good initial guess, but we include
controlled amount of randomness.
* we perform Levenberg-Marquardt fitting with very tight constraints on
parameters B and C - it allows us to find good initial guess for the
second stage without risk of running into "flat spot". Parameter G is
fixed at G=1.
* second Levenberg-Marquardt round is performed without excessive
constraints on B and C, but with G still equal to 1. Results from the
previous round are used as initial guess.
* third Levenberg-Marquardt round relaxes constraints on G and tries two
different models - one with B>0 and one with B<0.
* after fitting is done, we compare results with best values found so far,
rewrite "best solution" if needed, and move to next random location.
Overall algorithm is very stable and is not prone to bad local extrema.
Furthermore, it automatically scales when input data have very large or
very small range.
INPUT PARAMETERS:
X - array[N], stores X-values.
MUST include only non-negative numbers (but may include
zero values). Can be unsorted.
Y - array[N], values to fit.
N - number of points. If N is less than length of X/Y, only
leading N elements are used.
OUTPUT PARAMETERS:
A,B,C,D,G- parameters of 5PL model
Rep - fitting report. This structure has many fields, but ONLY
ONES LISTED BELOW ARE SET:
* Rep.IterationsCount - number of iterations performed
* Rep.RMSError - root-mean-square error
* Rep.AvgError - average absolute error
* Rep.AvgRelError - average relative error (calculated for
non-zero Y-values)
* Rep.MaxError - maximum absolute error
* Rep.R2 - coefficient of determination, R-squared. This
coefficient is calculated as R2=1-RSS/TSS (in case
of nonlinear regression there are multiple ways to
define R2, each of them giving different results).
NOTE: after you obtained coefficients, you can evaluate model with
LogisticCalc5() function.
NOTE: if you need better control over fitting process than provided by this
function, you may use LogisticFit45X().
NOTE: step is automatically scaled according to scale of parameters being
fitted before we compare its length with EpsX. Thus, this function
can be used to fit data with very small or very large values without
changing EpsX.
-- ALGLIB PROJECT --
Copyright 14.02.2014 by Bochkanov Sergey
*************************************************************************/
void logisticfit5(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, double &a, double &b, double &c, double &d, double &g, lsfitreport &rep);
/*************************************************************************
This function fits five-parameter logistic (5PL) model to data provided
by user, subject to optional equality constraints on parameters A and D.
5PL model has following form:
F(x|A,B,C,D,G) = D+(A-D)/Power(1+Power(x/C,B),G)
Here:
* A, D - with optional equality constraints
* B - unconstrained
* C>0
* G>0
IMPORTANT: unlike in 4PL fitting, output of this function is NOT
constrained in such way that B is guaranteed to be positive.
Furthermore, unlike 4PL, 5PL model is NOT symmetric with
respect to B, so you can NOT transform model to equivalent one,
with B having desired sign (>0 or <0).
5PL fitting is implemented as follows:
* we perform small number of restarts from random locations which helps to
solve problem of bad local extrema. Locations are only partially random
- we use input data to determine good initial guess, but we include
controlled amount of randomness.
* we perform Levenberg-Marquardt fitting with very tight constraints on
parameters B and C - it allows us to find good initial guess for the
second stage without risk of running into "flat spot". Parameter G is
fixed at G=1.
* second Levenberg-Marquardt round is performed without excessive
constraints on B and C, but with G still equal to 1. Results from the
previous round are used as initial guess.
* third Levenberg-Marquardt round relaxes constraints on G and tries two
different models - one with B>0 and one with B<0.
* after fitting is done, we compare results with best values found so far,
rewrite "best solution" if needed, and move to next random location.
Overall algorithm is very stable and is not prone to bad local extrema.
Furthermore, it automatically scales when input data have very large or
very small range.
INPUT PARAMETERS:
X - array[N], stores X-values.
MUST include only non-negative numbers (but may include
zero values). Can be unsorted.
Y - array[N], values to fit.
N - number of points. If N is less than length of X/Y, only
leading N elements are used.
CnstrLeft- optional equality constraint for model value at the left
boundary (at X=0). Specify NAN (Not-a-Number) if you do
not need constraint on the model value at X=0 (in C++ you
can pass alglib::fp_nan as parameter, in C# it will be
Double.NaN).
See below, section "EQUALITY CONSTRAINTS" for more
information about constraints.
CnstrRight- optional equality constraint for model value at X=infinity.
Specify NAN (Not-a-Number) if you do not need constraint
on the model value (in C++ you can pass alglib::fp_nan as
parameter, in C# it will be Double.NaN).
See below, section "EQUALITY CONSTRAINTS" for more
information about constraints.
OUTPUT PARAMETERS:
A,B,C,D,G- parameters of 5PL model
Rep - fitting report. This structure has many fields, but ONLY
ONES LISTED BELOW ARE SET:
* Rep.IterationsCount - number of iterations performed
* Rep.RMSError - root-mean-square error
* Rep.AvgError - average absolute error
* Rep.AvgRelError - average relative error (calculated for
non-zero Y-values)
* Rep.MaxError - maximum absolute error
* Rep.R2 - coefficient of determination, R-squared. This
coefficient is calculated as R2=1-RSS/TSS (in case
of nonlinear regression there are multiple ways to
define R2, each of them giving different results).
NOTE: after you obtained coefficients, you can evaluate model with
LogisticCalc5() function.
NOTE: if you need better control over fitting process than provided by this
function, you may use LogisticFit45X().
NOTE: step is automatically scaled according to scale of parameters being
fitted before we compare its length with EpsX. Thus, this function
can be used to fit data with very small or very large values without
changing EpsX.
EQUALITY CONSTRAINTS ON PARAMETERS
5PL solver supports equality constraints on model values at the left
boundary (X=0) and right boundary (X=infinity). These constraints are
completely optional and you can specify both of them, only one - or no
constraints at all.
Parameter CnstrLeft contains left constraint (or NAN for unconstrained
fitting), and CnstrRight contains right one.
Unlike 4PL one, 5PL model is NOT symmetric with respect to change in sign
of B. Thus, negative B's are possible, and left constraint may constrain
parameter A (for positive B's) - or parameter D (for negative B's).
Similarly changes meaning of right constraint.
You do not have to decide what parameter to constrain - algorithm will
automatically determine correct parameters as fitting progresses. However,
question highlighted above is important when you interpret fitting results.
-- ALGLIB PROJECT --
Copyright 14.02.2014 by Bochkanov Sergey
*************************************************************************/
void logisticfit5ec(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double cnstrleft, const double cnstrright, double &a, double &b, double &c, double &d, double &g, lsfitreport &rep);
/*************************************************************************
This is "expert" 4PL/5PL fitting function, which can be used if you need
better control over fitting process than provided by LogisticFit4() or
LogisticFit5().
This function fits model of the form
F(x|A,B,C,D) = D+(A-D)/(1+Power(x/C,B)) (4PL model)
or
F(x|A,B,C,D,G) = D+(A-D)/Power(1+Power(x/C,B),G) (5PL model)
Here:
* A, D - unconstrained
* B>=0 for 4PL, unconstrained for 5PL
* C>0
* G>0 (if present)
INPUT PARAMETERS:
X - array[N], stores X-values.
MUST include only non-negative numbers (but may include
zero values). Can be unsorted.
Y - array[N], values to fit.
N - number of points. If N is less than length of X/Y, only
leading N elements are used.
CnstrLeft- optional equality constraint for model value at the left
boundary (at X=0). Specify NAN (Not-a-Number) if you do
not need constraint on the model value at X=0 (in C++ you
can pass alglib::fp_nan as parameter, in C# it will be
Double.NaN).
See below, section "EQUALITY CONSTRAINTS" for more
information about constraints.
CnstrRight- optional equality constraint for model value at X=infinity.
Specify NAN (Not-a-Number) if you do not need constraint
on the model value (in C++ you can pass alglib::fp_nan as
parameter, in C# it will be Double.NaN).
See below, section "EQUALITY CONSTRAINTS" for more
information about constraints.
Is4PL - whether 4PL or 5PL models are fitted
LambdaV - regularization coefficient, LambdaV>=0.
Set it to zero unless you know what you are doing.
EpsX - stopping condition (step size), EpsX>=0.
Zero value means that small step is automatically chosen.
See notes below for more information.
RsCnt - number of repeated restarts from random points. 4PL/5PL
models are prone to problem of bad local extrema. Utilizing
multiple random restarts allows us to improve algorithm
convergence.
RsCnt>=0.
Zero value means that function automatically choose small
amount of restarts (recommended).
OUTPUT PARAMETERS:
A, B, C, D- parameters of 4PL model
G - parameter of 5PL model; for Is4PL=True, G=1 is returned.
Rep - fitting report. This structure has many fields, but ONLY
ONES LISTED BELOW ARE SET:
* Rep.IterationsCount - number of iterations performed
* Rep.RMSError - root-mean-square error
* Rep.AvgError - average absolute error
* Rep.AvgRelError - average relative error (calculated for
non-zero Y-values)
* Rep.MaxError - maximum absolute error
* Rep.R2 - coefficient of determination, R-squared. This
coefficient is calculated as R2=1-RSS/TSS (in case
of nonlinear regression there are multiple ways to
define R2, each of them giving different results).
NOTE: after you obtained coefficients, you can evaluate model with
LogisticCalc5() function.
NOTE: step is automatically scaled according to scale of parameters being
fitted before we compare its length with EpsX. Thus, this function
can be used to fit data with very small or very large values without
changing EpsX.
EQUALITY CONSTRAINTS ON PARAMETERS
4PL/5PL solver supports equality constraints on model values at the left
boundary (X=0) and right boundary (X=infinity). These constraints are
completely optional and you can specify both of them, only one - or no
constraints at all.
Parameter CnstrLeft contains left constraint (or NAN for unconstrained
fitting), and CnstrRight contains right one. For 4PL, left constraint
ALWAYS corresponds to parameter A, and right one is ALWAYS constraint on
D. That's because 4PL model is normalized in such way that B>=0.
For 5PL model things are different. Unlike 4PL one, 5PL model is NOT
symmetric with respect to change in sign of B. Thus, negative B's are
possible, and left constraint may constrain parameter A (for positive B's)
- or parameter D (for negative B's). Similarly changes meaning of right
constraint.
You do not have to decide what parameter to constrain - algorithm will
automatically determine correct parameters as fitting progresses. However,
question highlighted above is important when you interpret fitting results.
-- ALGLIB PROJECT --
Copyright 14.02.2014 by Bochkanov Sergey
*************************************************************************/
void logisticfit45x(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double cnstrleft, const double cnstrright, const bool is4pl, const double lambdav, const double epsx, const ae_int_t rscnt, double &a, double &b, double &c, double &d, double &g, lsfitreport &rep);
/*************************************************************************
Weghted rational least squares fitting using Floater-Hormann rational
functions with optimal D chosen from [0,9], with constraints and
individual weights.
Equidistant grid with M node on [min(x),max(x)] is used to build basis
functions. Different values of D are tried, optimal D (least WEIGHTED root
mean square error) is chosen. Task is linear, so linear least squares
solver is used. Complexity of this computational scheme is O(N*M^2)
(mostly dominated by the least squares solver).
SEE ALSO
* BarycentricFitFloaterHormann(), "lightweight" fitting without invididual
weights and constraints.
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
X - points, array[0..N-1].
Y - function values, array[0..N-1].
W - weights, array[0..N-1]
Each summand in square sum of approximation deviations from
given values is multiplied by the square of corresponding
weight. Fill it by 1's if you don't want to solve weighted
task.
N - number of points, N>0.
XC - points where function values/derivatives are constrained,
array[0..K-1].
YC - values of constraints, array[0..K-1]
DC - array[0..K-1], types of constraints:
* DC[i]=0 means that S(XC[i])=YC[i]
* DC[i]=1 means that S'(XC[i])=YC[i]
SEE BELOW FOR IMPORTANT INFORMATION ON CONSTRAINTS
K - number of constraints, 0<=K<M.
K=0 means no constraints (XC/YC/DC are not used in such cases)
M - number of basis functions ( = number_of_nodes), M>=2.
OUTPUT PARAMETERS:
Info- same format as in LSFitLinearWC() subroutine.
* Info>0 task is solved
* Info<=0 an error occured:
-4 means inconvergence of internal SVD
-3 means inconsistent constraints
-1 means another errors in parameters passed
(N<=0, for example)
B - barycentric interpolant.
Rep - report, same format as in LSFitLinearWC() subroutine.
Following fields are set:
* DBest best value of the D parameter
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
IMPORTANT:
this subroutine doesn't calculate task's condition number for K<>0.
SETTING CONSTRAINTS - DANGERS AND OPPORTUNITIES:
Setting constraints can lead to undesired results, like ill-conditioned
behavior, or inconsistency being detected. From the other side, it allows
us to improve quality of the fit. Here we summarize our experience with
constrained barycentric interpolants:
* excessive constraints can be inconsistent. Floater-Hormann basis
functions aren't as flexible as splines (although they are very smooth).
* the more evenly constraints are spread across [min(x),max(x)], the more
chances that they will be consistent
* the greater is M (given fixed constraints), the more chances that
constraints will be consistent
* in the general case, consistency of constraints IS NOT GUARANTEED.
* in the several special cases, however, we CAN guarantee consistency.
* one of this cases is constraints on the function VALUES at the interval
boundaries. Note that consustency of the constraints on the function
DERIVATIVES is NOT guaranteed (you can use in such cases cubic splines
which are more flexible).
* another special case is ONE constraint on the function value (OR, but
not AND, derivative) anywhere in the interval
Our final recommendation is to use constraints WHEN AND ONLY WHEN you
can't solve your task without them. Anything beyond special cases given
above is not guaranteed and may result in inconsistency.
-- ALGLIB PROJECT --
Copyright 18.08.2009 by Bochkanov Sergey
*************************************************************************/
void barycentricfitfloaterhormannwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &b, barycentricfitreport &rep);
void smp_barycentricfitfloaterhormannwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &b, barycentricfitreport &rep);
/*************************************************************************
Rational least squares fitting using Floater-Hormann rational functions
with optimal D chosen from [0,9].
Equidistant grid with M node on [min(x),max(x)] is used to build basis
functions. Different values of D are tried, optimal D (least root mean
square error) is chosen. Task is linear, so linear least squares solver
is used. Complexity of this computational scheme is O(N*M^2) (mostly
dominated by the least squares solver).
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
X - points, array[0..N-1].
Y - function values, array[0..N-1].
N - number of points, N>0.
M - number of basis functions ( = number_of_nodes), M>=2.
OUTPUT PARAMETERS:
Info- same format as in LSFitLinearWC() subroutine.
* Info>0 task is solved
* Info<=0 an error occured:
-4 means inconvergence of internal SVD
-3 means inconsistent constraints
B - barycentric interpolant.
Rep - report, same format as in LSFitLinearWC() subroutine.
Following fields are set:
* DBest best value of the D parameter
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
-- ALGLIB PROJECT --
Copyright 18.08.2009 by Bochkanov Sergey
*************************************************************************/
void barycentricfitfloaterhormann(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, barycentricinterpolant &b, barycentricfitreport &rep);
void smp_barycentricfitfloaterhormann(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, barycentricinterpolant &b, barycentricfitreport &rep);
/*************************************************************************
Fitting by penalized cubic spline.
Equidistant grid with M nodes on [min(x,xc),max(x,xc)] is used to build
basis functions. Basis functions are cubic splines with natural boundary
conditions. Problem is regularized by adding non-linearity penalty to the
usual least squares penalty function:
S(x) = arg min { LS + P }, where
LS = SUM { w[i]^2*(y[i] - S(x[i]))^2 } - least squares penalty
P = C*10^rho*integral{ S''(x)^2*dx } - non-linearity penalty
rho - tunable constant given by user
C - automatically determined scale parameter,
makes penalty invariant with respect to scaling of X, Y, W.
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
X - points, array[0..N-1].
Y - function values, array[0..N-1].
N - number of points (optional):
* N>0
* if given, only first N elements of X/Y are processed
* if not given, automatically determined from X/Y sizes
M - number of basis functions ( = number_of_nodes), M>=4.
Rho - regularization constant passed by user. It penalizes
nonlinearity in the regression spline. It is logarithmically
scaled, i.e. actual value of regularization constant is
calculated as 10^Rho. It is automatically scaled so that:
* Rho=2.0 corresponds to moderate amount of nonlinearity
* generally, it should be somewhere in the [-8.0,+8.0]
If you do not want to penalize nonlineary,
pass small Rho. Values as low as -15 should work.
OUTPUT PARAMETERS:
Info- same format as in LSFitLinearWC() subroutine.
* Info>0 task is solved
* Info<=0 an error occured:
-4 means inconvergence of internal SVD or
Cholesky decomposition; problem may be
too ill-conditioned (very rare)
S - spline interpolant.
Rep - Following fields are set:
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
IMPORTANT:
this subroitine doesn't calculate task's condition number for K<>0.
NOTE 1: additional nodes are added to the spline outside of the fitting
interval to force linearity when x<min(x,xc) or x>max(x,xc). It is done
for consistency - we penalize non-linearity at [min(x,xc),max(x,xc)], so
it is natural to force linearity outside of this interval.
NOTE 2: function automatically sorts points, so caller may pass unsorted
array.
-- ALGLIB PROJECT --
Copyright 18.08.2009 by Bochkanov Sergey
*************************************************************************/
void spline1dfitpenalized(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfitpenalized(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void spline1dfitpenalized(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfitpenalized(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
/*************************************************************************
Weighted fitting by penalized cubic spline.
Equidistant grid with M nodes on [min(x,xc),max(x,xc)] is used to build
basis functions. Basis functions are cubic splines with natural boundary
conditions. Problem is regularized by adding non-linearity penalty to the
usual least squares penalty function:
S(x) = arg min { LS + P }, where
LS = SUM { w[i]^2*(y[i] - S(x[i]))^2 } - least squares penalty
P = C*10^rho*integral{ S''(x)^2*dx } - non-linearity penalty
rho - tunable constant given by user
C - automatically determined scale parameter,
makes penalty invariant with respect to scaling of X, Y, W.
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
X - points, array[0..N-1].
Y - function values, array[0..N-1].
W - weights, array[0..N-1]
Each summand in square sum of approximation deviations from
given values is multiplied by the square of corresponding
weight. Fill it by 1's if you don't want to solve weighted
problem.
N - number of points (optional):
* N>0
* if given, only first N elements of X/Y/W are processed
* if not given, automatically determined from X/Y/W sizes
M - number of basis functions ( = number_of_nodes), M>=4.
Rho - regularization constant passed by user. It penalizes
nonlinearity in the regression spline. It is logarithmically
scaled, i.e. actual value of regularization constant is
calculated as 10^Rho. It is automatically scaled so that:
* Rho=2.0 corresponds to moderate amount of nonlinearity
* generally, it should be somewhere in the [-8.0,+8.0]
If you do not want to penalize nonlineary,
pass small Rho. Values as low as -15 should work.
OUTPUT PARAMETERS:
Info- same format as in LSFitLinearWC() subroutine.
* Info>0 task is solved
* Info<=0 an error occured:
-4 means inconvergence of internal SVD or
Cholesky decomposition; problem may be
too ill-conditioned (very rare)
S - spline interpolant.
Rep - Following fields are set:
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
IMPORTANT:
this subroitine doesn't calculate task's condition number for K<>0.
NOTE 1: additional nodes are added to the spline outside of the fitting
interval to force linearity when x<min(x,xc) or x>max(x,xc). It is done
for consistency - we penalize non-linearity at [min(x,xc),max(x,xc)], so
it is natural to force linearity outside of this interval.
NOTE 2: function automatically sorts points, so caller may pass unsorted
array.
-- ALGLIB PROJECT --
Copyright 19.10.2010 by Bochkanov Sergey
*************************************************************************/
void spline1dfitpenalizedw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfitpenalizedw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void spline1dfitpenalizedw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfitpenalizedw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
/*************************************************************************
Weighted fitting by cubic spline, with constraints on function values or
derivatives.
Equidistant grid with M-2 nodes on [min(x,xc),max(x,xc)] is used to build
basis functions. Basis functions are cubic splines with continuous second
derivatives and non-fixed first derivatives at interval ends. Small
regularizing term is used when solving constrained tasks (to improve
stability).
Task is linear, so linear least squares solver is used. Complexity of this
computational scheme is O(N*M^2), mostly dominated by least squares solver
SEE ALSO
Spline1DFitHermiteWC() - fitting by Hermite splines (more flexible,
less smooth)
Spline1DFitCubic() - "lightweight" fitting by cubic splines,
without invididual weights and constraints
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
X - points, array[0..N-1].
Y - function values, array[0..N-1].
W - weights, array[0..N-1]
Each summand in square sum of approximation deviations from
given values is multiplied by the square of corresponding
weight. Fill it by 1's if you don't want to solve weighted
task.
N - number of points (optional):
* N>0
* if given, only first N elements of X/Y/W are processed
* if not given, automatically determined from X/Y/W sizes
XC - points where spline values/derivatives are constrained,
array[0..K-1].
YC - values of constraints, array[0..K-1]
DC - array[0..K-1], types of constraints:
* DC[i]=0 means that S(XC[i])=YC[i]
* DC[i]=1 means that S'(XC[i])=YC[i]
SEE BELOW FOR IMPORTANT INFORMATION ON CONSTRAINTS
K - number of constraints (optional):
* 0<=K<M.
* K=0 means no constraints (XC/YC/DC are not used)
* if given, only first K elements of XC/YC/DC are used
* if not given, automatically determined from XC/YC/DC
M - number of basis functions ( = number_of_nodes+2), M>=4.
OUTPUT PARAMETERS:
Info- same format as in LSFitLinearWC() subroutine.
* Info>0 task is solved
* Info<=0 an error occured:
-4 means inconvergence of internal SVD
-3 means inconsistent constraints
S - spline interpolant.
Rep - report, same format as in LSFitLinearWC() subroutine.
Following fields are set:
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
IMPORTANT:
this subroitine doesn't calculate task's condition number for K<>0.
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
SETTING CONSTRAINTS - DANGERS AND OPPORTUNITIES:
Setting constraints can lead to undesired results, like ill-conditioned
behavior, or inconsistency being detected. From the other side, it allows
us to improve quality of the fit. Here we summarize our experience with
constrained regression splines:
* excessive constraints can be inconsistent. Splines are piecewise cubic
functions, and it is easy to create an example, where large number of
constraints concentrated in small area will result in inconsistency.
Just because spline is not flexible enough to satisfy all of them. And
same constraints spread across the [min(x),max(x)] will be perfectly
consistent.
* the more evenly constraints are spread across [min(x),max(x)], the more
chances that they will be consistent
* the greater is M (given fixed constraints), the more chances that
constraints will be consistent
* in the general case, consistency of constraints IS NOT GUARANTEED.
* in the several special cases, however, we CAN guarantee consistency.
* one of this cases is constraints on the function values AND/OR its
derivatives at the interval boundaries.
* another special case is ONE constraint on the function value (OR, but
not AND, derivative) anywhere in the interval
Our final recommendation is to use constraints WHEN AND ONLY WHEN you
can't solve your task without them. Anything beyond special cases given
above is not guaranteed and may result in inconsistency.
-- ALGLIB PROJECT --
Copyright 18.08.2009 by Bochkanov Sergey
*************************************************************************/
void spline1dfitcubicwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfitcubicwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void spline1dfitcubicwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfitcubicwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
/*************************************************************************
Weighted fitting by Hermite spline, with constraints on function values
or first derivatives.
Equidistant grid with M nodes on [min(x,xc),max(x,xc)] is used to build
basis functions. Basis functions are Hermite splines. Small regularizing
term is used when solving constrained tasks (to improve stability).
Task is linear, so linear least squares solver is used. Complexity of this
computational scheme is O(N*M^2), mostly dominated by least squares solver
SEE ALSO
Spline1DFitCubicWC() - fitting by Cubic splines (less flexible,
more smooth)
Spline1DFitHermite() - "lightweight" Hermite fitting, without
invididual weights and constraints
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
X - points, array[0..N-1].
Y - function values, array[0..N-1].
W - weights, array[0..N-1]
Each summand in square sum of approximation deviations from
given values is multiplied by the square of corresponding
weight. Fill it by 1's if you don't want to solve weighted
task.
N - number of points (optional):
* N>0
* if given, only first N elements of X/Y/W are processed
* if not given, automatically determined from X/Y/W sizes
XC - points where spline values/derivatives are constrained,
array[0..K-1].
YC - values of constraints, array[0..K-1]
DC - array[0..K-1], types of constraints:
* DC[i]=0 means that S(XC[i])=YC[i]
* DC[i]=1 means that S'(XC[i])=YC[i]
SEE BELOW FOR IMPORTANT INFORMATION ON CONSTRAINTS
K - number of constraints (optional):
* 0<=K<M.
* K=0 means no constraints (XC/YC/DC are not used)
* if given, only first K elements of XC/YC/DC are used
* if not given, automatically determined from XC/YC/DC
M - number of basis functions (= 2 * number of nodes),
M>=4,
M IS EVEN!
OUTPUT PARAMETERS:
Info- same format as in LSFitLinearW() subroutine:
* Info>0 task is solved
* Info<=0 an error occured:
-4 means inconvergence of internal SVD
-3 means inconsistent constraints
-2 means odd M was passed (which is not supported)
-1 means another errors in parameters passed
(N<=0, for example)
S - spline interpolant.
Rep - report, same format as in LSFitLinearW() subroutine.
Following fields are set:
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
IMPORTANT:
this subroitine doesn't calculate task's condition number for K<>0.
IMPORTANT:
this subroitine supports only even M's
ORDER OF POINTS
Subroutine automatically sorts points, so caller may pass unsorted array.
SETTING CONSTRAINTS - DANGERS AND OPPORTUNITIES:
Setting constraints can lead to undesired results, like ill-conditioned
behavior, or inconsistency being detected. From the other side, it allows
us to improve quality of the fit. Here we summarize our experience with
constrained regression splines:
* excessive constraints can be inconsistent. Splines are piecewise cubic
functions, and it is easy to create an example, where large number of
constraints concentrated in small area will result in inconsistency.
Just because spline is not flexible enough to satisfy all of them. And
same constraints spread across the [min(x),max(x)] will be perfectly
consistent.
* the more evenly constraints are spread across [min(x),max(x)], the more
chances that they will be consistent
* the greater is M (given fixed constraints), the more chances that
constraints will be consistent
* in the general case, consistency of constraints is NOT GUARANTEED.
* in the several special cases, however, we can guarantee consistency.
* one of this cases is M>=4 and constraints on the function value
(AND/OR its derivative) at the interval boundaries.
* another special case is M>=4 and ONE constraint on the function value
(OR, BUT NOT AND, derivative) anywhere in [min(x),max(x)]
Our final recommendation is to use constraints WHEN AND ONLY when you
can't solve your task without them. Anything beyond special cases given
above is not guaranteed and may result in inconsistency.
-- ALGLIB PROJECT --
Copyright 18.08.2009 by Bochkanov Sergey
*************************************************************************/
void spline1dfithermitewc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfithermitewc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void spline1dfithermitewc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfithermitewc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
/*************************************************************************
Least squares fitting by cubic spline.
This subroutine is "lightweight" alternative for more complex and feature-
rich Spline1DFitCubicWC(). See Spline1DFitCubicWC() for more information
about subroutine parameters (we don't duplicate it here because of length)
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
-- ALGLIB PROJECT --
Copyright 18.08.2009 by Bochkanov Sergey
*************************************************************************/
void spline1dfitcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfitcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void spline1dfitcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfitcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
/*************************************************************************
Least squares fitting by Hermite spline.
This subroutine is "lightweight" alternative for more complex and feature-
rich Spline1DFitHermiteWC(). See Spline1DFitHermiteWC() description for
more information about subroutine parameters (we don't duplicate it here
because of length).
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
-- ALGLIB PROJECT --
Copyright 18.08.2009 by Bochkanov Sergey
*************************************************************************/
void spline1dfithermite(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfithermite(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void spline1dfithermite(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void smp_spline1dfithermite(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
/*************************************************************************
Weighted linear least squares fitting.
QR decomposition is used to reduce task to MxM, then triangular solver or
SVD-based solver is used depending on condition number of the system. It
allows to maximize speed and retain decent accuracy.
IMPORTANT: if you want to perform polynomial fitting, it may be more
convenient to use PolynomialFit() function. This function gives
best results on polynomial problems and solves numerical
stability issues which arise when you fit high-degree
polynomials to your data.
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
Y - array[0..N-1] Function values in N points.
W - array[0..N-1] Weights corresponding to function values.
Each summand in square sum of approximation deviations
from given values is multiplied by the square of
corresponding weight.
FMatrix - a table of basis functions values, array[0..N-1, 0..M-1].
FMatrix[I, J] - value of J-th basis function in I-th point.
N - number of points used. N>=1.
M - number of basis functions, M>=1.
OUTPUT PARAMETERS:
Info - error code:
* -4 internal SVD decomposition subroutine failed (very
rare and for degenerate systems only)
* -1 incorrect N/M were specified
* 1 task is solved
C - decomposition coefficients, array[0..M-1]
Rep - fitting report. Following fields are set:
* Rep.TaskRCond reciprocal of condition number
* R2 non-adjusted coefficient of determination
(non-weighted)
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
ERRORS IN PARAMETERS
This solver also calculates different kinds of errors in parameters and
fills corresponding fields of report:
* Rep.CovPar covariance matrix for parameters, array[K,K].
* Rep.ErrPar errors in parameters, array[K],
errpar = sqrt(diag(CovPar))
* Rep.ErrCurve vector of fit errors - standard deviations of empirical
best-fit curve from "ideal" best-fit curve built with
infinite number of samples, array[N].
errcurve = sqrt(diag(F*CovPar*F')),
where F is functions matrix.
* Rep.Noise vector of per-point estimates of noise, array[N]
NOTE: noise in the data is estimated as follows:
* for fitting without user-supplied weights all points are
assumed to have same level of noise, which is estimated from
the data
* for fitting with user-supplied weights we assume that noise
level in I-th point is inversely proportional to Ith weight.
Coefficient of proportionality is estimated from the data.
NOTE: we apply small amount of regularization when we invert squared
Jacobian and calculate covariance matrix. It guarantees that
algorithm won't divide by zero during inversion, but skews
error estimates a bit (fractional error is about 10^-9).
However, we believe that this difference is insignificant for
all practical purposes except for the situation when you want
to compare ALGLIB results with "reference" implementation up
to the last significant digit.
NOTE: covariance matrix is estimated using correction for degrees
of freedom (covariances are divided by N-M instead of dividing
by N).
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitlinearw(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void smp_lsfitlinearw(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void lsfitlinearw(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void smp_lsfitlinearw(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
/*************************************************************************
Weighted constained linear least squares fitting.
This is variation of LSFitLinearW(), which searchs for min|A*x=b| given
that K additional constaints C*x=bc are satisfied. It reduces original
task to modified one: min|B*y-d| WITHOUT constraints, then LSFitLinearW()
is called.
IMPORTANT: if you want to perform polynomial fitting, it may be more
convenient to use PolynomialFit() function. This function gives
best results on polynomial problems and solves numerical
stability issues which arise when you fit high-degree
polynomials to your data.
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
Y - array[0..N-1] Function values in N points.
W - array[0..N-1] Weights corresponding to function values.
Each summand in square sum of approximation deviations
from given values is multiplied by the square of
corresponding weight.
FMatrix - a table of basis functions values, array[0..N-1, 0..M-1].
FMatrix[I,J] - value of J-th basis function in I-th point.
CMatrix - a table of constaints, array[0..K-1,0..M].
I-th row of CMatrix corresponds to I-th linear constraint:
CMatrix[I,0]*C[0] + ... + CMatrix[I,M-1]*C[M-1] = CMatrix[I,M]
N - number of points used. N>=1.
M - number of basis functions, M>=1.
K - number of constraints, 0 <= K < M
K=0 corresponds to absence of constraints.
OUTPUT PARAMETERS:
Info - error code:
* -4 internal SVD decomposition subroutine failed (very
rare and for degenerate systems only)
* -3 either too many constraints (M or more),
degenerate constraints (some constraints are
repetead twice) or inconsistent constraints were
specified.
* 1 task is solved
C - decomposition coefficients, array[0..M-1]
Rep - fitting report. Following fields are set:
* R2 non-adjusted coefficient of determination
(non-weighted)
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
IMPORTANT:
this subroitine doesn't calculate task's condition number for K<>0.
ERRORS IN PARAMETERS
This solver also calculates different kinds of errors in parameters and
fills corresponding fields of report:
* Rep.CovPar covariance matrix for parameters, array[K,K].
* Rep.ErrPar errors in parameters, array[K],
errpar = sqrt(diag(CovPar))
* Rep.ErrCurve vector of fit errors - standard deviations of empirical
best-fit curve from "ideal" best-fit curve built with
infinite number of samples, array[N].
errcurve = sqrt(diag(F*CovPar*F')),
where F is functions matrix.
* Rep.Noise vector of per-point estimates of noise, array[N]
IMPORTANT: errors in parameters are calculated without taking into
account boundary/linear constraints! Presence of constraints
changes distribution of errors, but there is no easy way to
account for constraints when you calculate covariance matrix.
NOTE: noise in the data is estimated as follows:
* for fitting without user-supplied weights all points are
assumed to have same level of noise, which is estimated from
the data
* for fitting with user-supplied weights we assume that noise
level in I-th point is inversely proportional to Ith weight.
Coefficient of proportionality is estimated from the data.
NOTE: we apply small amount of regularization when we invert squared
Jacobian and calculate covariance matrix. It guarantees that
algorithm won't divide by zero during inversion, but skews
error estimates a bit (fractional error is about 10^-9).
However, we believe that this difference is insignificant for
all practical purposes except for the situation when you want
to compare ALGLIB results with "reference" implementation up
to the last significant digit.
NOTE: covariance matrix is estimated using correction for degrees
of freedom (covariances are divided by N-M instead of dividing
by N).
-- ALGLIB --
Copyright 07.09.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitlinearwc(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void smp_lsfitlinearwc(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void lsfitlinearwc(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const real_2d_array &cmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void smp_lsfitlinearwc(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const real_2d_array &cmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
/*************************************************************************
Linear least squares fitting.
QR decomposition is used to reduce task to MxM, then triangular solver or
SVD-based solver is used depending on condition number of the system. It
allows to maximize speed and retain decent accuracy.
IMPORTANT: if you want to perform polynomial fitting, it may be more
convenient to use PolynomialFit() function. This function gives
best results on polynomial problems and solves numerical
stability issues which arise when you fit high-degree
polynomials to your data.
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
Y - array[0..N-1] Function values in N points.
FMatrix - a table of basis functions values, array[0..N-1, 0..M-1].
FMatrix[I, J] - value of J-th basis function in I-th point.
N - number of points used. N>=1.
M - number of basis functions, M>=1.
OUTPUT PARAMETERS:
Info - error code:
* -4 internal SVD decomposition subroutine failed (very
rare and for degenerate systems only)
* 1 task is solved
C - decomposition coefficients, array[0..M-1]
Rep - fitting report. Following fields are set:
* Rep.TaskRCond reciprocal of condition number
* R2 non-adjusted coefficient of determination
(non-weighted)
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
ERRORS IN PARAMETERS
This solver also calculates different kinds of errors in parameters and
fills corresponding fields of report:
* Rep.CovPar covariance matrix for parameters, array[K,K].
* Rep.ErrPar errors in parameters, array[K],
errpar = sqrt(diag(CovPar))
* Rep.ErrCurve vector of fit errors - standard deviations of empirical
best-fit curve from "ideal" best-fit curve built with
infinite number of samples, array[N].
errcurve = sqrt(diag(F*CovPar*F')),
where F is functions matrix.
* Rep.Noise vector of per-point estimates of noise, array[N]
NOTE: noise in the data is estimated as follows:
* for fitting without user-supplied weights all points are
assumed to have same level of noise, which is estimated from
the data
* for fitting with user-supplied weights we assume that noise
level in I-th point is inversely proportional to Ith weight.
Coefficient of proportionality is estimated from the data.
NOTE: we apply small amount of regularization when we invert squared
Jacobian and calculate covariance matrix. It guarantees that
algorithm won't divide by zero during inversion, but skews
error estimates a bit (fractional error is about 10^-9).
However, we believe that this difference is insignificant for
all practical purposes except for the situation when you want
to compare ALGLIB results with "reference" implementation up
to the last significant digit.
NOTE: covariance matrix is estimated using correction for degrees
of freedom (covariances are divided by N-M instead of dividing
by N).
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void smp_lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void smp_lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
/*************************************************************************
Constained linear least squares fitting.
This is variation of LSFitLinear(), which searchs for min|A*x=b| given
that K additional constaints C*x=bc are satisfied. It reduces original
task to modified one: min|B*y-d| WITHOUT constraints, then LSFitLinear()
is called.
IMPORTANT: if you want to perform polynomial fitting, it may be more
convenient to use PolynomialFit() function. This function gives
best results on polynomial problems and solves numerical
stability issues which arise when you fit high-degree
polynomials to your data.
COMMERCIAL EDITION OF ALGLIB:
! Commercial version of ALGLIB includes two important improvements of
! this function, which can be used from C++ and C#:
! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
! * multithreading support
!
! Intel MKL gives approximately constant (with respect to number of
! worker threads) acceleration factor which depends on CPU being used,
! problem size and "baseline" ALGLIB edition which is used for
! comparison.
!
! Speed-up provided by multithreading greatly depends on problem size
! - only large problems (number of coefficients is more than 500) can be
! efficiently multithreaded.
!
! Generally, commercial ALGLIB is several times faster than open-source
! generic C edition, and many times faster than open-source C# edition.
!
! We recommend you to read 'Working with commercial version' section of
! ALGLIB Reference Manual in order to find out how to use performance-
! related features provided by commercial edition of ALGLIB.
INPUT PARAMETERS:
Y - array[0..N-1] Function values in N points.
FMatrix - a table of basis functions values, array[0..N-1, 0..M-1].
FMatrix[I,J] - value of J-th basis function in I-th point.
CMatrix - a table of constaints, array[0..K-1,0..M].
I-th row of CMatrix corresponds to I-th linear constraint:
CMatrix[I,0]*C[0] + ... + CMatrix[I,M-1]*C[M-1] = CMatrix[I,M]
N - number of points used. N>=1.
M - number of basis functions, M>=1.
K - number of constraints, 0 <= K < M
K=0 corresponds to absence of constraints.
OUTPUT PARAMETERS:
Info - error code:
* -4 internal SVD decomposition subroutine failed (very
rare and for degenerate systems only)
* -3 either too many constraints (M or more),
degenerate constraints (some constraints are
repetead twice) or inconsistent constraints were
specified.
* 1 task is solved
C - decomposition coefficients, array[0..M-1]
Rep - fitting report. Following fields are set:
* R2 non-adjusted coefficient of determination
(non-weighted)
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
IMPORTANT:
this subroitine doesn't calculate task's condition number for K<>0.
ERRORS IN PARAMETERS
This solver also calculates different kinds of errors in parameters and
fills corresponding fields of report:
* Rep.CovPar covariance matrix for parameters, array[K,K].
* Rep.ErrPar errors in parameters, array[K],
errpar = sqrt(diag(CovPar))
* Rep.ErrCurve vector of fit errors - standard deviations of empirical
best-fit curve from "ideal" best-fit curve built with
infinite number of samples, array[N].
errcurve = sqrt(diag(F*CovPar*F')),
where F is functions matrix.
* Rep.Noise vector of per-point estimates of noise, array[N]
IMPORTANT: errors in parameters are calculated without taking into
account boundary/linear constraints! Presence of constraints
changes distribution of errors, but there is no easy way to
account for constraints when you calculate covariance matrix.
NOTE: noise in the data is estimated as follows:
* for fitting without user-supplied weights all points are
assumed to have same level of noise, which is estimated from
the data
* for fitting with user-supplied weights we assume that noise
level in I-th point is inversely proportional to Ith weight.
Coefficient of proportionality is estimated from the data.
NOTE: we apply small amount of regularization when we invert squared
Jacobian and calculate covariance matrix. It guarantees that
algorithm won't divide by zero during inversion, but skews
error estimates a bit (fractional error is about 10^-9).
However, we believe that this difference is insignificant for
all practical purposes except for the situation when you want
to compare ALGLIB results with "reference" implementation up
to the last significant digit.
NOTE: covariance matrix is estimated using correction for degrees
of freedom (covariances are divided by N-M instead of dividing
by N).
-- ALGLIB --
Copyright 07.09.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitlinearc(const real_1d_array &y, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void smp_lsfitlinearc(const real_1d_array &y, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void lsfitlinearc(const real_1d_array &y, const real_2d_array &fmatrix, const real_2d_array &cmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
void smp_lsfitlinearc(const real_1d_array &y, const real_2d_array &fmatrix, const real_2d_array &cmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
/*************************************************************************
Weighted nonlinear least squares fitting using function values only.
Combination of numerical differentiation and secant updates is used to
obtain function Jacobian.
Nonlinear task min(F(c)) is solved, where
F(c) = (w[0]*(f(c,x[0])-y[0]))^2 + ... + (w[n-1]*(f(c,x[n-1])-y[n-1]))^2,
* N is a number of points,
* M is a dimension of a space points belong to,
* K is a dimension of a space of parameters being fitted,
* w is an N-dimensional vector of weight coefficients,
* x is a set of N points, each of them is an M-dimensional vector,
* c is a K-dimensional vector of parameters being fitted
This subroutine uses only f(c,x[i]).
INPUT PARAMETERS:
X - array[0..N-1,0..M-1], points (one row = one point)
Y - array[0..N-1], function values.
W - weights, array[0..N-1]
C - array[0..K-1], initial approximation to the solution,
N - number of points, N>1
M - dimension of space
K - number of parameters being fitted
DiffStep- numerical differentiation step;
should not be very small or large;
large = loss of accuracy
small = growth of round-off errors
OUTPUT PARAMETERS:
State - structure which stores algorithm state
-- ALGLIB --
Copyright 18.10.2008 by Bochkanov Sergey
*************************************************************************/
void lsfitcreatewf(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const double diffstep, lsfitstate &state);
void lsfitcreatewf(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const double diffstep, lsfitstate &state);
/*************************************************************************
Nonlinear least squares fitting using function values only.
Combination of numerical differentiation and secant updates is used to
obtain function Jacobian.
Nonlinear task min(F(c)) is solved, where
F(c) = (f(c,x[0])-y[0])^2 + ... + (f(c,x[n-1])-y[n-1])^2,
* N is a number of points,
* M is a dimension of a space points belong to,
* K is a dimension of a space of parameters being fitted,
* w is an N-dimensional vector of weight coefficients,
* x is a set of N points, each of them is an M-dimensional vector,
* c is a K-dimensional vector of parameters being fitted
This subroutine uses only f(c,x[i]).
INPUT PARAMETERS:
X - array[0..N-1,0..M-1], points (one row = one point)
Y - array[0..N-1], function values.
C - array[0..K-1], initial approximation to the solution,
N - number of points, N>1
M - dimension of space
K - number of parameters being fitted
DiffStep- numerical differentiation step;
should not be very small or large;
large = loss of accuracy
small = growth of round-off errors
OUTPUT PARAMETERS:
State - structure which stores algorithm state
-- ALGLIB --
Copyright 18.10.2008 by Bochkanov Sergey
*************************************************************************/
void lsfitcreatef(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const double diffstep, lsfitstate &state);
void lsfitcreatef(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const double diffstep, lsfitstate &state);
/*************************************************************************
Weighted nonlinear least squares fitting using gradient only.
Nonlinear task min(F(c)) is solved, where
F(c) = (w[0]*(f(c,x[0])-y[0]))^2 + ... + (w[n-1]*(f(c,x[n-1])-y[n-1]))^2,
* N is a number of points,
* M is a dimension of a space points belong to,
* K is a dimension of a space of parameters being fitted,
* w is an N-dimensional vector of weight coefficients,
* x is a set of N points, each of them is an M-dimensional vector,
* c is a K-dimensional vector of parameters being fitted
This subroutine uses only f(c,x[i]) and its gradient.
INPUT PARAMETERS:
X - array[0..N-1,0..M-1], points (one row = one point)
Y - array[0..N-1], function values.
W - weights, array[0..N-1]
C - array[0..K-1], initial approximation to the solution,
N - number of points, N>1
M - dimension of space
K - number of parameters being fitted
CheapFG - boolean flag, which is:
* True if both function and gradient calculation complexity
are less than O(M^2). An improved algorithm can
be used which corresponds to FGJ scheme from
MINLM unit.
* False otherwise.
Standard Jacibian-bases Levenberg-Marquardt algo
will be used (FJ scheme).
OUTPUT PARAMETERS:
State - structure which stores algorithm state
See also:
LSFitResults
LSFitCreateFG (fitting without weights)
LSFitCreateWFGH (fitting using Hessian)
LSFitCreateFGH (fitting using Hessian, without weights)
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitcreatewfg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const bool cheapfg, lsfitstate &state);
void lsfitcreatewfg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const bool cheapfg, lsfitstate &state);
/*************************************************************************
Nonlinear least squares fitting using gradient only, without individual
weights.
Nonlinear task min(F(c)) is solved, where
F(c) = ((f(c,x[0])-y[0]))^2 + ... + ((f(c,x[n-1])-y[n-1]))^2,
* N is a number of points,
* M is a dimension of a space points belong to,
* K is a dimension of a space of parameters being fitted,
* x is a set of N points, each of them is an M-dimensional vector,
* c is a K-dimensional vector of parameters being fitted
This subroutine uses only f(c,x[i]) and its gradient.
INPUT PARAMETERS:
X - array[0..N-1,0..M-1], points (one row = one point)
Y - array[0..N-1], function values.
C - array[0..K-1], initial approximation to the solution,
N - number of points, N>1
M - dimension of space
K - number of parameters being fitted
CheapFG - boolean flag, which is:
* True if both function and gradient calculation complexity
are less than O(M^2). An improved algorithm can
be used which corresponds to FGJ scheme from
MINLM unit.
* False otherwise.
Standard Jacibian-bases Levenberg-Marquardt algo
will be used (FJ scheme).
OUTPUT PARAMETERS:
State - structure which stores algorithm state
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitcreatefg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const bool cheapfg, lsfitstate &state);
void lsfitcreatefg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const bool cheapfg, lsfitstate &state);
/*************************************************************************
Weighted nonlinear least squares fitting using gradient/Hessian.
Nonlinear task min(F(c)) is solved, where
F(c) = (w[0]*(f(c,x[0])-y[0]))^2 + ... + (w[n-1]*(f(c,x[n-1])-y[n-1]))^2,
* N is a number of points,
* M is a dimension of a space points belong to,
* K is a dimension of a space of parameters being fitted,
* w is an N-dimensional vector of weight coefficients,
* x is a set of N points, each of them is an M-dimensional vector,
* c is a K-dimensional vector of parameters being fitted
This subroutine uses f(c,x[i]), its gradient and its Hessian.
INPUT PARAMETERS:
X - array[0..N-1,0..M-1], points (one row = one point)
Y - array[0..N-1], function values.
W - weights, array[0..N-1]
C - array[0..K-1], initial approximation to the solution,
N - number of points, N>1
M - dimension of space
K - number of parameters being fitted
OUTPUT PARAMETERS:
State - structure which stores algorithm state
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitcreatewfgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, lsfitstate &state);
void lsfitcreatewfgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, lsfitstate &state);
/*************************************************************************
Nonlinear least squares fitting using gradient/Hessian, without individial
weights.
Nonlinear task min(F(c)) is solved, where
F(c) = ((f(c,x[0])-y[0]))^2 + ... + ((f(c,x[n-1])-y[n-1]))^2,
* N is a number of points,
* M is a dimension of a space points belong to,
* K is a dimension of a space of parameters being fitted,
* x is a set of N points, each of them is an M-dimensional vector,
* c is a K-dimensional vector of parameters being fitted
This subroutine uses f(c,x[i]), its gradient and its Hessian.
INPUT PARAMETERS:
X - array[0..N-1,0..M-1], points (one row = one point)
Y - array[0..N-1], function values.
C - array[0..K-1], initial approximation to the solution,
N - number of points, N>1
M - dimension of space
K - number of parameters being fitted
OUTPUT PARAMETERS:
State - structure which stores algorithm state
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitcreatefgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, lsfitstate &state);
void lsfitcreatefgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, lsfitstate &state);
/*************************************************************************
Stopping conditions for nonlinear least squares fitting.
INPUT PARAMETERS:
State - structure which stores algorithm state
EpsF - stopping criterion. Algorithm stops if
|F(k+1)-F(k)| <= EpsF*max{|F(k)|, |F(k+1)|, 1}
EpsX - >=0
The subroutine finishes its work if on k+1-th iteration
the condition |v|<=EpsX is fulfilled, where:
* |.| means Euclidian norm
* v - scaled step vector, v[i]=dx[i]/s[i]
* dx - ste pvector, dx=X(k+1)-X(k)
* s - scaling coefficients set by LSFitSetScale()
MaxIts - maximum number of iterations. If MaxIts=0, the number of
iterations is unlimited. Only Levenberg-Marquardt
iterations are counted (L-BFGS/CG iterations are NOT
counted because their cost is very low compared to that of
LM).
NOTE
Passing EpsF=0, EpsX=0 and MaxIts=0 (simultaneously) will lead to automatic
stopping criterion selection (according to the scheme used by MINLM unit).
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitsetcond(const lsfitstate &state, const double epsf, const double epsx, const ae_int_t maxits);
/*************************************************************************
This function sets maximum step length
INPUT PARAMETERS:
State - structure which stores algorithm state
StpMax - maximum step length, >=0. Set StpMax to 0.0, if you don't
want to limit step length.
Use this subroutine when you optimize target function which contains exp()
or other fast growing functions, and optimization algorithm makes too
large steps which leads to overflow. This function allows us to reject
steps that are too large (and therefore expose us to the possible
overflow) without actually calculating function value at the x+stp*d.
NOTE: non-zero StpMax leads to moderate performance degradation because
intermediate step of preconditioned L-BFGS optimization is incompatible
with limits on step size.
-- ALGLIB --
Copyright 02.04.2010 by Bochkanov Sergey
*************************************************************************/
void lsfitsetstpmax(const lsfitstate &state, const double stpmax);
/*************************************************************************
This function turns on/off reporting.
INPUT PARAMETERS:
State - structure which stores algorithm state
NeedXRep- whether iteration reports are needed or not
When reports are needed, State.C (current parameters) and State.F (current
value of fitting function) are reported.
-- ALGLIB --
Copyright 15.08.2010 by Bochkanov Sergey
*************************************************************************/
void lsfitsetxrep(const lsfitstate &state, const bool needxrep);
/*************************************************************************
This function sets scaling coefficients for underlying optimizer.
ALGLIB optimizers use scaling matrices to test stopping conditions (step
size and gradient are scaled before comparison with tolerances). Scale of
the I-th variable is a translation invariant measure of:
a) "how large" the variable is
b) how large the step should be to make significant changes in the function
Generally, scale is NOT considered to be a form of preconditioner. But LM
optimizer is unique in that it uses scaling matrix both in the stopping
condition tests and as Marquardt damping factor.
Proper scaling is very important for the algorithm performance. It is less
important for the quality of results, but still has some influence (it is
easier to converge when variables are properly scaled, so premature
stopping is possible when very badly scalled variables are combined with
relaxed stopping conditions).
INPUT PARAMETERS:
State - structure stores algorithm state
S - array[N], non-zero scaling coefficients
S[i] may be negative, sign doesn't matter.
-- ALGLIB --
Copyright 14.01.2011 by Bochkanov Sergey
*************************************************************************/
void lsfitsetscale(const lsfitstate &state, const real_1d_array &s);
/*************************************************************************
This function sets boundary constraints for underlying optimizer
Boundary constraints are inactive by default (after initial creation).
They are preserved until explicitly turned off with another SetBC() call.
INPUT PARAMETERS:
State - structure stores algorithm state
BndL - lower bounds, array[K].
If some (all) variables are unbounded, you may specify
very small number or -INF (latter is recommended because
it will allow solver to use better algorithm).
BndU - upper bounds, array[K].
If some (all) variables are unbounded, you may specify
very large number or +INF (latter is recommended because
it will allow solver to use better algorithm).
NOTE 1: it is possible to specify BndL[i]=BndU[i]. In this case I-th
variable will be "frozen" at X[i]=BndL[i]=BndU[i].
NOTE 2: unlike other constrained optimization algorithms, this solver has
following useful properties:
* bound constraints are always satisfied exactly
* function is evaluated only INSIDE area specified by bound constraints
-- ALGLIB --
Copyright 14.01.2011 by Bochkanov Sergey
*************************************************************************/
void lsfitsetbc(const lsfitstate &state, const real_1d_array &bndl, const real_1d_array &bndu);
/*************************************************************************
This function provides reverse communication interface
Reverse communication interface is not documented or recommended to use.
See below for functions which provide better documented API
*************************************************************************/
bool lsfititeration(const lsfitstate &state);
/*************************************************************************
This family of functions is used to launcn iterations of nonlinear fitter
These functions accept following parameters:
state - algorithm state
func - callback which calculates function (or merit function)
value func at given point x
grad - callback which calculates function (or merit function)
value func and gradient grad at given point x
hess - callback which calculates function (or merit function)
value func, gradient grad and Hessian hess at given point x
rep - optional callback which is called after each iteration
can be NULL
ptr - optional pointer which is passed to func/grad/hess/jac/rep
can be NULL
NOTES:
1. this algorithm is somewhat unusual because it works with parameterized
function f(C,X), where X is a function argument (we have many points
which are characterized by different argument values), and C is a
parameter to fit.
For example, if we want to do linear fit by f(c0,c1,x) = c0*x+c1, then
x will be argument, and {c0,c1} will be parameters.
It is important to understand that this algorithm finds minimum in the
space of function PARAMETERS (not arguments), so it needs derivatives
of f() with respect to C, not X.
In the example above it will need f=c0*x+c1 and {df/dc0,df/dc1} = {x,1}
instead of {df/dx} = {c0}.
2. Callback functions accept C as the first parameter, and X as the second
3. If state was created with LSFitCreateFG(), algorithm needs just
function and its gradient, but if state was created with
LSFitCreateFGH(), algorithm will need function, gradient and Hessian.
According to the said above, there ase several versions of this
function, which accept different sets of callbacks.
This flexibility opens way to subtle errors - you may create state with
LSFitCreateFGH() (optimization using Hessian), but call function which
does not accept Hessian. So when algorithm will request Hessian, there
will be no callback to call. In this case exception will be thrown.
Be careful to avoid such errors because there is no way to find them at
compile time - you can see them at runtime only.
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitfit(lsfitstate &state,
void (*func)(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr),
void (*rep)(const real_1d_array &c, double func, void *ptr) = NULL,
void *ptr = NULL);
void lsfitfit(lsfitstate &state,
void (*func)(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr),
void (*grad)(const real_1d_array &c, const real_1d_array &x, double &func, real_1d_array &grad, void *ptr),
void (*rep)(const real_1d_array &c, double func, void *ptr) = NULL,
void *ptr = NULL);
void lsfitfit(lsfitstate &state,
void (*func)(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr),
void (*grad)(const real_1d_array &c, const real_1d_array &x, double &func, real_1d_array &grad, void *ptr),
void (*hess)(const real_1d_array &c, const real_1d_array &x, double &func, real_1d_array &grad, real_2d_array &hess, void *ptr),
void (*rep)(const real_1d_array &c, double func, void *ptr) = NULL,
void *ptr = NULL);
/*************************************************************************
Nonlinear least squares fitting results.
Called after return from LSFitFit().
INPUT PARAMETERS:
State - algorithm state
OUTPUT PARAMETERS:
Info - completion code:
* -7 gradient verification failed.
See LSFitSetGradientCheck() for more information.
* 1 relative function improvement is no more than
EpsF.
* 2 relative step is no more than EpsX.
* 4 gradient norm is no more than EpsG
* 5 MaxIts steps was taken
* 7 stopping conditions are too stringent,
further improvement is impossible
C - array[0..K-1], solution
Rep - optimization report. On success following fields are set:
* R2 non-adjusted coefficient of determination
(non-weighted)
* RMSError rms error on the (X,Y).
* AvgError average error on the (X,Y).
* AvgRelError average relative error on the non-zero Y
* MaxError maximum error
NON-WEIGHTED ERRORS ARE CALCULATED
* WRMSError weighted rms error on the (X,Y).
ERRORS IN PARAMETERS
This solver also calculates different kinds of errors in parameters and
fills corresponding fields of report:
* Rep.CovPar covariance matrix for parameters, array[K,K].
* Rep.ErrPar errors in parameters, array[K],
errpar = sqrt(diag(CovPar))
* Rep.ErrCurve vector of fit errors - standard deviations of empirical
best-fit curve from "ideal" best-fit curve built with
infinite number of samples, array[N].
errcurve = sqrt(diag(J*CovPar*J')),
where J is Jacobian matrix.
* Rep.Noise vector of per-point estimates of noise, array[N]
IMPORTANT: errors in parameters are calculated without taking into
account boundary/linear constraints! Presence of constraints
changes distribution of errors, but there is no easy way to
account for constraints when you calculate covariance matrix.
NOTE: noise in the data is estimated as follows:
* for fitting without user-supplied weights all points are
assumed to have same level of noise, which is estimated from
the data
* for fitting with user-supplied weights we assume that noise
level in I-th point is inversely proportional to Ith weight.
Coefficient of proportionality is estimated from the data.
NOTE: we apply small amount of regularization when we invert squared
Jacobian and calculate covariance matrix. It guarantees that
algorithm won't divide by zero during inversion, but skews
error estimates a bit (fractional error is about 10^-9).
However, we believe that this difference is insignificant for
all practical purposes except for the situation when you want
to compare ALGLIB results with "reference" implementation up
to the last significant digit.
NOTE: covariance matrix is estimated using correction for degrees
of freedom (covariances are divided by N-M instead of dividing
by N).
-- ALGLIB --
Copyright 17.08.2009 by Bochkanov Sergey
*************************************************************************/
void lsfitresults(const lsfitstate &state, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
/*************************************************************************
This subroutine turns on verification of the user-supplied analytic
gradient:
* user calls this subroutine before fitting begins
* LSFitFit() is called
* prior to actual fitting, for each point in data set X_i and each
component of parameters being fited C_j algorithm performs following
steps:
* two trial steps are made to C_j-TestStep*S[j] and C_j+TestStep*S[j],
where C_j is j-th parameter and S[j] is a scale of j-th parameter
* if needed, steps are bounded with respect to constraints on C[]
* F(X_i|C) is evaluated at these trial points
* we perform one more evaluation in the middle point of the interval
* we build cubic model using function values and derivatives at trial
points and we compare its prediction with actual value in the middle
point
* in case difference between prediction and actual value is higher than
some predetermined threshold, algorithm stops with completion code -7;
Rep.VarIdx is set to index of the parameter with incorrect derivative.
* after verification is over, algorithm proceeds to the actual optimization.
NOTE 1: verification needs N*K (points count * parameters count) gradient
evaluations. It is very costly and you should use it only for low
dimensional problems, when you want to be sure that you've
correctly calculated analytic derivatives. You should not use it
in the production code (unless you want to check derivatives
provided by some third party).
NOTE 2: you should carefully choose TestStep. Value which is too large
(so large that function behaviour is significantly non-cubic) will
lead to false alarms. You may use different step for different
parameters by means of setting scale with LSFitSetScale().
NOTE 3: this function may lead to false positives. In case it reports that
I-th derivative was calculated incorrectly, you may decrease test
step and try one more time - maybe your function changes too
sharply and your step is too large for such rapidly chanding
function.
NOTE 4: this function works only for optimizers created with LSFitCreateWFG()
or LSFitCreateFG() constructors.
INPUT PARAMETERS:
State - structure used to store algorithm state
TestStep - verification step:
* TestStep=0 turns verification off
* TestStep>0 activates verification
-- ALGLIB --
Copyright 15.06.2012 by Bochkanov Sergey
*************************************************************************/
void lsfitsetgradientcheck(const lsfitstate &state, const double teststep);
/*************************************************************************
This function builds non-periodic 2-dimensional parametric spline which
starts at (X[0],Y[0]) and ends at (X[N-1],Y[N-1]).
INPUT PARAMETERS:
XY - points, array[0..N-1,0..1].
XY[I,0:1] corresponds to the Ith point.
Order of points is important!
N - points count, N>=5 for Akima splines, N>=2 for other types of
splines.
ST - spline type:
* 0 Akima spline
* 1 parabolically terminated Catmull-Rom spline (Tension=0)
* 2 parabolically terminated cubic spline
PT - parameterization type:
* 0 uniform
* 1 chord length
* 2 centripetal
OUTPUT PARAMETERS:
P - parametric spline interpolant
NOTES:
* this function assumes that there all consequent points are distinct.
I.e. (x0,y0)<>(x1,y1), (x1,y1)<>(x2,y2), (x2,y2)<>(x3,y3) and so on.
However, non-consequent points may coincide, i.e. we can have (x0,y0)=
=(x2,y2).
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline2build(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline2interpolant &p);
/*************************************************************************
This function builds non-periodic 3-dimensional parametric spline which
starts at (X[0],Y[0],Z[0]) and ends at (X[N-1],Y[N-1],Z[N-1]).
Same as PSpline2Build() function, but for 3D, so we won't duplicate its
description here.
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline3build(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline3interpolant &p);
/*************************************************************************
This function builds periodic 2-dimensional parametric spline which
starts at (X[0],Y[0]), goes through all points to (X[N-1],Y[N-1]) and then
back to (X[0],Y[0]).
INPUT PARAMETERS:
XY - points, array[0..N-1,0..1].
XY[I,0:1] corresponds to the Ith point.
XY[N-1,0:1] must be different from XY[0,0:1].
Order of points is important!
N - points count, N>=3 for other types of splines.
ST - spline type:
* 1 Catmull-Rom spline (Tension=0) with cyclic boundary conditions
* 2 cubic spline with cyclic boundary conditions
PT - parameterization type:
* 0 uniform
* 1 chord length
* 2 centripetal
OUTPUT PARAMETERS:
P - parametric spline interpolant
NOTES:
* this function assumes that there all consequent points are distinct.
I.e. (x0,y0)<>(x1,y1), (x1,y1)<>(x2,y2), (x2,y2)<>(x3,y3) and so on.
However, non-consequent points may coincide, i.e. we can have (x0,y0)=
=(x2,y2).
* last point of sequence is NOT equal to the first point. You shouldn't
make curve "explicitly periodic" by making them equal.
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline2buildperiodic(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline2interpolant &p);
/*************************************************************************
This function builds periodic 3-dimensional parametric spline which
starts at (X[0],Y[0],Z[0]), goes through all points to (X[N-1],Y[N-1],Z[N-1])
and then back to (X[0],Y[0],Z[0]).
Same as PSpline2Build() function, but for 3D, so we won't duplicate its
description here.
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline3buildperiodic(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline3interpolant &p);
/*************************************************************************
This function returns vector of parameter values correspoding to points.
I.e. for P created from (X[0],Y[0])...(X[N-1],Y[N-1]) and U=TValues(P) we
have
(X[0],Y[0]) = PSpline2Calc(P,U[0]),
(X[1],Y[1]) = PSpline2Calc(P,U[1]),
(X[2],Y[2]) = PSpline2Calc(P,U[2]),
...
INPUT PARAMETERS:
P - parametric spline interpolant
OUTPUT PARAMETERS:
N - array size
T - array[0..N-1]
NOTES:
* for non-periodic splines U[0]=0, U[0]<U[1]<...<U[N-1], U[N-1]=1
* for periodic splines U[0]=0, U[0]<U[1]<...<U[N-1], U[N-1]<1
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline2parametervalues(const pspline2interpolant &p, ae_int_t &n, real_1d_array &t);
/*************************************************************************
This function returns vector of parameter values correspoding to points.
Same as PSpline2ParameterValues(), but for 3D.
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline3parametervalues(const pspline3interpolant &p, ae_int_t &n, real_1d_array &t);
/*************************************************************************
This function calculates the value of the parametric spline for a given
value of parameter T
INPUT PARAMETERS:
P - parametric spline interpolant
T - point:
* T in [0,1] corresponds to interval spanned by points
* for non-periodic splines T<0 (or T>1) correspond to parts of
the curve before the first (after the last) point
* for periodic splines T<0 (or T>1) are projected into [0,1]
by making T=T-floor(T).
OUTPUT PARAMETERS:
X - X-position
Y - Y-position
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline2calc(const pspline2interpolant &p, const double t, double &x, double &y);
/*************************************************************************
This function calculates the value of the parametric spline for a given
value of parameter T.
INPUT PARAMETERS:
P - parametric spline interpolant
T - point:
* T in [0,1] corresponds to interval spanned by points
* for non-periodic splines T<0 (or T>1) correspond to parts of
the curve before the first (after the last) point
* for periodic splines T<0 (or T>1) are projected into [0,1]
by making T=T-floor(T).
OUTPUT PARAMETERS:
X - X-position
Y - Y-position
Z - Z-position
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline3calc(const pspline3interpolant &p, const double t, double &x, double &y, double &z);
/*************************************************************************
This function calculates tangent vector for a given value of parameter T
INPUT PARAMETERS:
P - parametric spline interpolant
T - point:
* T in [0,1] corresponds to interval spanned by points
* for non-periodic splines T<0 (or T>1) correspond to parts of
the curve before the first (after the last) point
* for periodic splines T<0 (or T>1) are projected into [0,1]
by making T=T-floor(T).
OUTPUT PARAMETERS:
X - X-component of tangent vector (normalized)
Y - Y-component of tangent vector (normalized)
NOTE:
X^2+Y^2 is either 1 (for non-zero tangent vector) or 0.
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline2tangent(const pspline2interpolant &p, const double t, double &x, double &y);
/*************************************************************************
This function calculates tangent vector for a given value of parameter T
INPUT PARAMETERS:
P - parametric spline interpolant
T - point:
* T in [0,1] corresponds to interval spanned by points
* for non-periodic splines T<0 (or T>1) correspond to parts of
the curve before the first (after the last) point
* for periodic splines T<0 (or T>1) are projected into [0,1]
by making T=T-floor(T).
OUTPUT PARAMETERS:
X - X-component of tangent vector (normalized)
Y - Y-component of tangent vector (normalized)
Z - Z-component of tangent vector (normalized)
NOTE:
X^2+Y^2+Z^2 is either 1 (for non-zero tangent vector) or 0.
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline3tangent(const pspline3interpolant &p, const double t, double &x, double &y, double &z);
/*************************************************************************
This function calculates derivative, i.e. it returns (dX/dT,dY/dT).
INPUT PARAMETERS:
P - parametric spline interpolant
T - point:
* T in [0,1] corresponds to interval spanned by points
* for non-periodic splines T<0 (or T>1) correspond to parts of
the curve before the first (after the last) point
* for periodic splines T<0 (or T>1) are projected into [0,1]
by making T=T-floor(T).
OUTPUT PARAMETERS:
X - X-value
DX - X-derivative
Y - Y-value
DY - Y-derivative
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline2diff(const pspline2interpolant &p, const double t, double &x, double &dx, double &y, double &dy);
/*************************************************************************
This function calculates derivative, i.e. it returns (dX/dT,dY/dT,dZ/dT).
INPUT PARAMETERS:
P - parametric spline interpolant
T - point:
* T in [0,1] corresponds to interval spanned by points
* for non-periodic splines T<0 (or T>1) correspond to parts of
the curve before the first (after the last) point
* for periodic splines T<0 (or T>1) are projected into [0,1]
by making T=T-floor(T).
OUTPUT PARAMETERS:
X - X-value
DX - X-derivative
Y - Y-value
DY - Y-derivative
Z - Z-value
DZ - Z-derivative
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline3diff(const pspline3interpolant &p, const double t, double &x, double &dx, double &y, double &dy, double &z, double &dz);
/*************************************************************************
This function calculates first and second derivative with respect to T.
INPUT PARAMETERS:
P - parametric spline interpolant
T - point:
* T in [0,1] corresponds to interval spanned by points
* for non-periodic splines T<0 (or T>1) correspond to parts of
the curve before the first (after the last) point
* for periodic splines T<0 (or T>1) are projected into [0,1]
by making T=T-floor(T).
OUTPUT PARAMETERS:
X - X-value
DX - derivative
D2X - second derivative
Y - Y-value
DY - derivative
D2Y - second derivative
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline2diff2(const pspline2interpolant &p, const double t, double &x, double &dx, double &d2x, double &y, double &dy, double &d2y);
/*************************************************************************
This function calculates first and second derivative with respect to T.
INPUT PARAMETERS:
P - parametric spline interpolant
T - point:
* T in [0,1] corresponds to interval spanned by points
* for non-periodic splines T<0 (or T>1) correspond to parts of
the curve before the first (after the last) point
* for periodic splines T<0 (or T>1) are projected into [0,1]
by making T=T-floor(T).
OUTPUT PARAMETERS:
X - X-value
DX - derivative
D2X - second derivative
Y - Y-value
DY - derivative
D2Y - second derivative
Z - Z-value
DZ - derivative
D2Z - second derivative
-- ALGLIB PROJECT --
Copyright 28.05.2010 by Bochkanov Sergey
*************************************************************************/
void pspline3diff2(const pspline3interpolant &p, const double t, double &x, double &dx, double &d2x, double &y, double &dy, double &d2y, double &z, double &dz, double &d2z);
/*************************************************************************
This function calculates arc length, i.e. length of curve between t=a
and t=b.
INPUT PARAMETERS:
P - parametric spline interpolant
A,B - parameter values corresponding to arc ends:
* B>A will result in positive length returned
* B<A will result in negative length returned
RESULT:
length of arc starting at T=A and ending at T=B.
-- ALGLIB PROJECT --
Copyright 30.05.2010 by Bochkanov Sergey
*************************************************************************/
double pspline2arclength(const pspline2interpolant &p, const double a, const double b);
/*************************************************************************
This function calculates arc length, i.e. length of curve between t=a
and t=b.
INPUT PARAMETERS:
P - parametric spline interpolant
A,B - parameter values corresponding to arc ends:
* B>A will result in positive length returned
* B<A will result in negative length returned
RESULT:
length of arc starting at T=A and ending at T=B.
-- ALGLIB PROJECT --
Copyright 30.05.2010 by Bochkanov Sergey
*************************************************************************/
double pspline3arclength(const pspline3interpolant &p, const double a, const double b);
/*************************************************************************
This subroutine fits piecewise linear curve to points with Ramer-Douglas-
Peucker algorithm. This function performs PARAMETRIC fit, i.e. it can be
used to fit curves like circles.
On input it accepts dataset which describes parametric multidimensional
curve X(t), with X being vector, and t taking values in [0,N), where N is
a number of points in dataset. As result, it returns reduced dataset X2,
which can be used to build parametric curve X2(t), which approximates
X(t) with desired precision (or has specified number of sections).
INPUT PARAMETERS:
X - array of multidimensional points:
* at least N elements, leading N elements are used if more
than N elements were specified
* order of points is IMPORTANT because it is parametric
fit
* each row of array is one point which has D coordinates
N - number of elements in X
D - number of dimensions (elements per row of X)
StopM - stopping condition - desired number of sections:
* at most M sections are generated by this function
* less than M sections can be generated if we have N<M
(or some X are non-distinct).
* zero StopM means that algorithm does not stop after
achieving some pre-specified section count
StopEps - stopping condition - desired precision:
* algorithm stops after error in each section is at most Eps
* zero Eps means that algorithm does not stop after
achieving some pre-specified precision
OUTPUT PARAMETERS:
X2 - array of corner points for piecewise approximation,
has length NSections+1 or zero (for NSections=0).
Idx2 - array of indexes (parameter values):
* has length NSections+1 or zero (for NSections=0).
* each element of Idx2 corresponds to same-numbered
element of X2
* each element of Idx2 is index of corresponding element
of X2 at original array X, i.e. I-th row of X2 is
Idx2[I]-th row of X.
* elements of Idx2 can be treated as parameter values
which should be used when building new parametric curve
* Idx2[0]=0, Idx2[NSections]=N-1
NSections- number of sections found by algorithm, NSections<=M,
NSections can be zero for degenerate datasets
(N<=1 or all X[] are non-distinct).
NOTE: algorithm stops after:
a) dividing curve into StopM sections
b) achieving required precision StopEps
c) dividing curve into N-1 sections
If both StopM and StopEps are non-zero, algorithm is stopped by the
FIRST criterion which is satisfied. In case both StopM and StopEps
are zero, algorithm stops because of (c).
-- ALGLIB --
Copyright 02.10.2014 by Bochkanov Sergey
*************************************************************************/
void parametricrdpfixed(const real_2d_array &x, const ae_int_t n, const ae_int_t d, const ae_int_t stopm, const double stopeps, real_2d_array &x2, integer_1d_array &idx2, ae_int_t &nsections);
/*************************************************************************
This function serializes data structure to string.
Important properties of s_out:
* it contains alphanumeric characters, dots, underscores, minus signs
* these symbols are grouped into words, which are separated by spaces
and Windows-style (CR+LF) newlines
* although serializer uses spaces and CR+LF as separators, you can
replace any separator character by arbitrary combination of spaces,
tabs, Windows or Unix newlines. It allows flexible reformatting of
the string in case you want to include it into text or XML file.
But you should not insert separators into the middle of the "words"
nor you should change case of letters.
* s_out can be freely moved between 32-bit and 64-bit systems, little
and big endian machines, and so on. You can serialize structure on
32-bit machine and unserialize it on 64-bit one (or vice versa), or
serialize it on SPARC and unserialize on x86. You can also
serialize it in C++ version of ALGLIB and unserialize in C# one,
and vice versa.
*************************************************************************/
void rbfserialize(rbfmodel &obj, std::string &s_out);
/*************************************************************************
This function unserializes data structure from string.
*************************************************************************/
void rbfunserialize(std::string &s_in, rbfmodel &obj);
/*************************************************************************
This function creates RBF model for a scalar (NY=1) or vector (NY>1)
function in a NX-dimensional space (NX=2 or NX=3).
Newly created model is empty. It can be used for interpolation right after
creation, but it just returns zeros. You have to add points to the model,
tune interpolation settings, and then call model construction function
RBFBuildModel() which will update model according to your specification.
USAGE:
1. User creates model with RBFCreate()
2. User adds dataset with RBFSetPoints() (points do NOT have to be on a
regular grid)
3. (OPTIONAL) User chooses polynomial term by calling:
* RBFLinTerm() to set linear term
* RBFConstTerm() to set constant term
* RBFZeroTerm() to set zero term
By default, linear term is used.
4. User chooses specific RBF algorithm to use: either QNN (RBFSetAlgoQNN)
or ML (RBFSetAlgoMultiLayer).
5. User calls RBFBuildModel() function which rebuilds model according to
the specification
6. User may call RBFCalc() to calculate model value at the specified point,
RBFGridCalc() to calculate model values at the points of the regular
grid. User may extract model coefficients with RBFUnpack() call.
INPUT PARAMETERS:
NX - dimension of the space, NX=2 or NX=3
NY - function dimension, NY>=1
OUTPUT PARAMETERS:
S - RBF model (initially equals to zero)
NOTE 1: memory requirements. RBF models require amount of memory which is
proportional to the number of data points. Memory is allocated
during model construction, but most of this memory is freed after
model coefficients are calculated.
Some approximate estimates for N centers with default settings are
given below:
* about 250*N*(sizeof(double)+2*sizeof(int)) bytes of memory is
needed during model construction stage.
* about 15*N*sizeof(double) bytes is needed after model is built.
For example, for N=100000 we may need 0.6 GB of memory to build
model, but just about 0.012 GB to store it.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfcreate(const ae_int_t nx, const ae_int_t ny, rbfmodel &s);
/*************************************************************************
This function adds dataset.
This function overrides results of the previous calls, i.e. multiple calls
of this function will result in only the last set being added.
INPUT PARAMETERS:
S - RBF model, initialized by RBFCreate() call.
XY - points, array[N,NX+NY]. One row corresponds to one point
in the dataset. First NX elements are coordinates, next
NY elements are function values. Array may be larger than
specific, in this case only leading [N,NX+NY] elements
will be used.
N - number of points in the dataset
After you've added dataset and (optionally) tuned algorithm settings you
should call RBFBuildModel() in order to build a model for you.
NOTE: this function has some serialization-related subtleties. We
recommend you to study serialization examples from ALGLIB Reference
Manual if you want to perform serialization of your models.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfsetpoints(const rbfmodel &s, const real_2d_array &xy, const ae_int_t n);
void rbfsetpoints(const rbfmodel &s, const real_2d_array &xy);
/*************************************************************************
This function sets RBF interpolation algorithm. ALGLIB supports several
RBF algorithms with different properties.
This algorithm is called RBF-QNN and it is good for point sets with
following properties:
a) all points are distinct
b) all points are well separated.
c) points distribution is approximately uniform. There is no "contour
lines", clusters of points, or other small-scale structures.
Algorithm description:
1) interpolation centers are allocated to data points
2) interpolation radii are calculated as distances to the nearest centers
times Q coefficient (where Q is a value from [0.75,1.50]).
3) after performing (2) radii are transformed in order to avoid situation
when single outlier has very large radius and influences many points
across all dataset. Transformation has following form:
new_r[i] = min(r[i],Z*median(r[]))
where r[i] is I-th radius, median() is a median radius across entire
dataset, Z is user-specified value which controls amount of deviation
from median radius.
When (a) is violated, we will be unable to build RBF model. When (b) or
(c) are violated, model will be built, but interpolation quality will be
low. See http://www.alglib.net/interpolation/ for more information on this
subject.
This algorithm is used by default.
Additional Q parameter controls smoothness properties of the RBF basis:
* Q<0.75 will give perfectly conditioned basis, but terrible smoothness
properties (RBF interpolant will have sharp peaks around function values)
* Q around 1.0 gives good balance between smoothness and condition number
* Q>1.5 will lead to badly conditioned systems and slow convergence of the
underlying linear solver (although smoothness will be very good)
* Q>2.0 will effectively make optimizer useless because it won't converge
within reasonable amount of iterations. It is possible to set such large
Q, but it is advised not to do so.
INPUT PARAMETERS:
S - RBF model, initialized by RBFCreate() call
Q - Q parameter, Q>0, recommended value - 1.0
Z - Z parameter, Z>0, recommended value - 5.0
NOTE: this function has some serialization-related subtleties. We
recommend you to study serialization examples from ALGLIB Reference
Manual if you want to perform serialization of your models.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfsetalgoqnn(const rbfmodel &s, const double q, const double z);
void rbfsetalgoqnn(const rbfmodel &s);
/*************************************************************************
This function sets RBF interpolation algorithm. ALGLIB supports several
RBF algorithms with different properties.
This algorithm is called RBF-ML. It builds multilayer RBF model, i.e.
model with subsequently decreasing radii, which allows us to combine
smoothness (due to large radii of the first layers) with exactness (due
to small radii of the last layers) and fast convergence.
Internally RBF-ML uses many different means of acceleration, from sparse
matrices to KD-trees, which results in algorithm whose working time is
roughly proportional to N*log(N)*Density*RBase^2*NLayers, where N is a
number of points, Density is an average density if points per unit of the
interpolation space, RBase is an initial radius, NLayers is a number of
layers.
RBF-ML is good for following kinds of interpolation problems:
1. "exact" problems (perfect fit) with well separated points
2. least squares problems with arbitrary distribution of points (algorithm
gives perfect fit where it is possible, and resorts to least squares
fit in the hard areas).
3. noisy problems where we want to apply some controlled amount of
smoothing.
INPUT PARAMETERS:
S - RBF model, initialized by RBFCreate() call
RBase - RBase parameter, RBase>0
NLayers - NLayers parameter, NLayers>0, recommended value to start
with - about 5.
LambdaV - regularization value, can be useful when solving problem
in the least squares sense. Optimal lambda is problem-
dependent and require trial and error. In our experience,
good lambda can be as large as 0.1, and you can use 0.001
as initial guess.
Default value - 0.01, which is used when LambdaV is not
given. You can specify zero value, but it is not
recommended to do so.
TUNING ALGORITHM
In order to use this algorithm you have to choose three parameters:
* initial radius RBase
* number of layers in the model NLayers
* regularization coefficient LambdaV
Initial radius is easy to choose - you can pick any number several times
larger than the average distance between points. Algorithm won't break
down if you choose radius which is too large (model construction time will
increase, but model will be built correctly).
Choose such number of layers that RLast=RBase/2^(NLayers-1) (radius used
by the last layer) will be smaller than the typical distance between
points. In case model error is too large, you can increase number of
layers. Having more layers will make model construction and evaluation
proportionally slower, but it will allow you to have model which precisely
fits your data. From the other side, if you want to suppress noise, you
can DECREASE number of layers to make your model less flexible.
Regularization coefficient LambdaV controls smoothness of the individual
models built for each layer. We recommend you to use default value in case
you don't want to tune this parameter, because having non-zero LambdaV
accelerates and stabilizes internal iterative algorithm. In case you want
to suppress noise you can use LambdaV as additional parameter (larger
value = more smoothness) to tune.
TYPICAL ERRORS
1. Using initial radius which is too large. Memory requirements of the
RBF-ML are roughly proportional to N*Density*RBase^2 (where Density is
an average density of points per unit of the interpolation space). In
the extreme case of the very large RBase we will need O(N^2) units of
memory - and many layers in order to decrease radius to some reasonably
small value.
2. Using too small number of layers - RBF models with large radius are not
flexible enough to reproduce small variations in the target function.
You need many layers with different radii, from large to small, in
order to have good model.
3. Using initial radius which is too small. You will get model with
"holes" in the areas which are too far away from interpolation centers.
However, algorithm will work correctly (and quickly) in this case.
4. Using too many layers - you will get too large and too slow model. This
model will perfectly reproduce your function, but maybe you will be
able to achieve similar results with less layers (and less memory).
-- ALGLIB --
Copyright 02.03.2012 by Bochkanov Sergey
*************************************************************************/
void rbfsetalgomultilayer(const rbfmodel &s, const double rbase, const ae_int_t nlayers, const double lambdav);
void rbfsetalgomultilayer(const rbfmodel &s, const double rbase, const ae_int_t nlayers);
/*************************************************************************
This function sets linear term (model is a sum of radial basis functions
plus linear polynomial). This function won't have effect until next call
to RBFBuildModel().
INPUT PARAMETERS:
S - RBF model, initialized by RBFCreate() call
NOTE: this function has some serialization-related subtleties. We
recommend you to study serialization examples from ALGLIB Reference
Manual if you want to perform serialization of your models.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfsetlinterm(const rbfmodel &s);
/*************************************************************************
This function sets constant term (model is a sum of radial basis functions
plus constant). This function won't have effect until next call to
RBFBuildModel().
INPUT PARAMETERS:
S - RBF model, initialized by RBFCreate() call
NOTE: this function has some serialization-related subtleties. We
recommend you to study serialization examples from ALGLIB Reference
Manual if you want to perform serialization of your models.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfsetconstterm(const rbfmodel &s);
/*************************************************************************
This function sets zero term (model is a sum of radial basis functions
without polynomial term). This function won't have effect until next call
to RBFBuildModel().
INPUT PARAMETERS:
S - RBF model, initialized by RBFCreate() call
NOTE: this function has some serialization-related subtleties. We
recommend you to study serialization examples from ALGLIB Reference
Manual if you want to perform serialization of your models.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfsetzeroterm(const rbfmodel &s);
/*************************************************************************
This function builds RBF model and returns report (contains some
information which can be used for evaluation of the algorithm properties).
Call to this function modifies RBF model by calculating its centers/radii/
weights and saving them into RBFModel structure. Initially RBFModel
contain zero coefficients, but after call to this function we will have
coefficients which were calculated in order to fit our dataset.
After you called this function you can call RBFCalc(), RBFGridCalc() and
other model calculation functions.
INPUT PARAMETERS:
S - RBF model, initialized by RBFCreate() call
Rep - report:
* Rep.TerminationType:
* -5 - non-distinct basis function centers were detected,
interpolation aborted
* -4 - nonconvergence of the internal SVD solver
* 1 - successful termination
Fields are used for debugging purposes:
* Rep.IterationsCount - iterations count of the LSQR solver
* Rep.NMV - number of matrix-vector products
* Rep.ARows - rows count for the system matrix
* Rep.ACols - columns count for the system matrix
* Rep.ANNZ - number of significantly non-zero elements
(elements above some algorithm-determined threshold)
NOTE: failure to build model will leave current state of the structure
unchanged.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfbuildmodel(const rbfmodel &s, rbfreport &rep);
/*************************************************************************
This function calculates values of the RBF model in the given point.
This function should be used when we have NY=1 (scalar function) and NX=2
(2-dimensional space). If you have 3-dimensional space, use RBFCalc3(). If
you have general situation (NX-dimensional space, NY-dimensional function)
you should use general, less efficient implementation RBFCalc().
If you want to calculate function values many times, consider using
RBFGridCalc2(), which is far more efficient than many subsequent calls to
RBFCalc2().
This function returns 0.0 when:
* model is not initialized
* NX<>2
*NY<>1
INPUT PARAMETERS:
S - RBF model
X0 - first coordinate, finite number
X1 - second coordinate, finite number
RESULT:
value of the model or 0.0 (as defined above)
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
double rbfcalc2(const rbfmodel &s, const double x0, const double x1);
/*************************************************************************
This function calculates values of the RBF model in the given point.
This function should be used when we have NY=1 (scalar function) and NX=3
(3-dimensional space). If you have 2-dimensional space, use RBFCalc2(). If
you have general situation (NX-dimensional space, NY-dimensional function)
you should use general, less efficient implementation RBFCalc().
This function returns 0.0 when:
* model is not initialized
* NX<>3
*NY<>1
INPUT PARAMETERS:
S - RBF model
X0 - first coordinate, finite number
X1 - second coordinate, finite number
X2 - third coordinate, finite number
RESULT:
value of the model or 0.0 (as defined above)
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
double rbfcalc3(const rbfmodel &s, const double x0, const double x1, const double x2);
/*************************************************************************
This function calculates values of the RBF model at the given point.
This is general function which can be used for arbitrary NX (dimension of
the space of arguments) and NY (dimension of the function itself). However
when you have NY=1 you may find more convenient to use RBFCalc2() or
RBFCalc3().
This function returns 0.0 when model is not initialized.
INPUT PARAMETERS:
S - RBF model
X - coordinates, array[NX].
X may have more than NX elements, in this case only
leading NX will be used.
OUTPUT PARAMETERS:
Y - function value, array[NY]. Y is out-parameter and
reallocated after call to this function. In case you want
to reuse previously allocated Y, you may use RBFCalcBuf(),
which reallocates Y only when it is too small.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfcalc(const rbfmodel &s, const real_1d_array &x, real_1d_array &y);
/*************************************************************************
This function calculates values of the RBF model at the given point.
Same as RBFCalc(), but does not reallocate Y when in is large enough to
store function values.
INPUT PARAMETERS:
S - RBF model
X - coordinates, array[NX].
X may have more than NX elements, in this case only
leading NX will be used.
Y - possibly preallocated array
OUTPUT PARAMETERS:
Y - function value, array[NY]. Y is not reallocated when it
is larger than NY.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfcalcbuf(const rbfmodel &s, const real_1d_array &x, real_1d_array &y);
/*************************************************************************
This function calculates values of the RBF model at the regular grid.
Grid have N0*N1 points, with Point[I,J] = (X0[I], X1[J])
This function returns 0.0 when:
* model is not initialized
* NX<>2
*NY<>1
INPUT PARAMETERS:
S - RBF model
X0 - array of grid nodes, first coordinates, array[N0]
N0 - grid size (number of nodes) in the first dimension
X1 - array of grid nodes, second coordinates, array[N1]
N1 - grid size (number of nodes) in the second dimension
OUTPUT PARAMETERS:
Y - function values, array[N0,N1]. Y is out-variable and
is reallocated by this function.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfgridcalc2(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, real_2d_array &y);
/*************************************************************************
This function "unpacks" RBF model by extracting its coefficients.
INPUT PARAMETERS:
S - RBF model
OUTPUT PARAMETERS:
NX - dimensionality of argument
NY - dimensionality of the target function
XWR - model information, array[NC,NX+NY+1].
One row of the array corresponds to one basis function:
* first NX columns - coordinates of the center
* next NY columns - weights, one per dimension of the
function being modelled
* last column - radius, same for all dimensions of
the function being modelled
NC - number of the centers
V - polynomial term , array[NY,NX+1]. One row per one
dimension of the function being modelled. First NX
elements are linear coefficients, V[NX] is equal to the
constant part.
-- ALGLIB --
Copyright 13.12.2011 by Bochkanov Sergey
*************************************************************************/
void rbfunpack(const rbfmodel &s, ae_int_t &nx, ae_int_t &ny, real_2d_array &xwr, ae_int_t &nc, real_2d_array &v);
/*************************************************************************
This subroutine calculates the value of the bilinear or bicubic spline at
the given point X.
Input parameters:
C - coefficients table.
Built by BuildBilinearSpline or BuildBicubicSpline.
X, Y- point
Result:
S(x,y)
-- ALGLIB PROJECT --
Copyright 05.07.2007 by Bochkanov Sergey
*************************************************************************/
double spline2dcalc(const spline2dinterpolant &c, const double x, const double y);
/*************************************************************************
This subroutine calculates the value of the bilinear or bicubic spline at
the given point X and its derivatives.
Input parameters:
C - spline interpolant.
X, Y- point
Output parameters:
F - S(x,y)
FX - dS(x,y)/dX
FY - dS(x,y)/dY
FXY - d2S(x,y)/dXdY
-- ALGLIB PROJECT --
Copyright 05.07.2007 by Bochkanov Sergey
*************************************************************************/
void spline2ddiff(const spline2dinterpolant &c, const double x, const double y, double &f, double &fx, double &fy, double &fxy);
/*************************************************************************
This subroutine performs linear transformation of the spline argument.
Input parameters:
C - spline interpolant
AX, BX - transformation coefficients: x = A*t + B
AY, BY - transformation coefficients: y = A*u + B
Result:
C - transformed spline
-- ALGLIB PROJECT --
Copyright 30.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline2dlintransxy(const spline2dinterpolant &c, const double ax, const double bx, const double ay, const double by);
/*************************************************************************
This subroutine performs linear transformation of the spline.
Input parameters:
C - spline interpolant.
A, B- transformation coefficients: S2(x,y) = A*S(x,y) + B
Output parameters:
C - transformed spline
-- ALGLIB PROJECT --
Copyright 30.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline2dlintransf(const spline2dinterpolant &c, const double a, const double b);
/*************************************************************************
This subroutine makes the copy of the spline model.
Input parameters:
C - spline interpolant
Output parameters:
CC - spline copy
-- ALGLIB PROJECT --
Copyright 29.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline2dcopy(const spline2dinterpolant &c, spline2dinterpolant &cc);
/*************************************************************************
Bicubic spline resampling
Input parameters:
A - function values at the old grid,
array[0..OldHeight-1, 0..OldWidth-1]
OldHeight - old grid height, OldHeight>1
OldWidth - old grid width, OldWidth>1
NewHeight - new grid height, NewHeight>1
NewWidth - new grid width, NewWidth>1
Output parameters:
B - function values at the new grid,
array[0..NewHeight-1, 0..NewWidth-1]
-- ALGLIB routine --
15 May, 2007
Copyright by Bochkanov Sergey
*************************************************************************/
void spline2dresamplebicubic(const real_2d_array &a, const ae_int_t oldheight, const ae_int_t oldwidth, real_2d_array &b, const ae_int_t newheight, const ae_int_t newwidth);
/*************************************************************************
Bilinear spline resampling
Input parameters:
A - function values at the old grid,
array[0..OldHeight-1, 0..OldWidth-1]
OldHeight - old grid height, OldHeight>1
OldWidth - old grid width, OldWidth>1
NewHeight - new grid height, NewHeight>1
NewWidth - new grid width, NewWidth>1
Output parameters:
B - function values at the new grid,
array[0..NewHeight-1, 0..NewWidth-1]
-- ALGLIB routine --
09.07.2007
Copyright by Bochkanov Sergey
*************************************************************************/
void spline2dresamplebilinear(const real_2d_array &a, const ae_int_t oldheight, const ae_int_t oldwidth, real_2d_array &b, const ae_int_t newheight, const ae_int_t newwidth);
/*************************************************************************
This subroutine builds bilinear vector-valued spline.
Input parameters:
X - spline abscissas, array[0..N-1]
Y - spline ordinates, array[0..M-1]
F - function values, array[0..M*N*D-1]:
* first D elements store D values at (X[0],Y[0])
* next D elements store D values at (X[1],Y[0])
* general form - D function values at (X[i],Y[j]) are stored
at F[D*(J*N+I)...D*(J*N+I)+D-1].
M,N - grid size, M>=2, N>=2
D - vector dimension, D>=1
Output parameters:
C - spline interpolant
-- ALGLIB PROJECT --
Copyright 16.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline2dbuildbilinearv(const real_1d_array &x, const ae_int_t n, const real_1d_array &y, const ae_int_t m, const real_1d_array &f, const ae_int_t d, spline2dinterpolant &c);
/*************************************************************************
This subroutine builds bicubic vector-valued spline.
Input parameters:
X - spline abscissas, array[0..N-1]
Y - spline ordinates, array[0..M-1]
F - function values, array[0..M*N*D-1]:
* first D elements store D values at (X[0],Y[0])
* next D elements store D values at (X[1],Y[0])
* general form - D function values at (X[i],Y[j]) are stored
at F[D*(J*N+I)...D*(J*N+I)+D-1].
M,N - grid size, M>=2, N>=2
D - vector dimension, D>=1
Output parameters:
C - spline interpolant
-- ALGLIB PROJECT --
Copyright 16.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline2dbuildbicubicv(const real_1d_array &x, const ae_int_t n, const real_1d_array &y, const ae_int_t m, const real_1d_array &f, const ae_int_t d, spline2dinterpolant &c);
/*************************************************************************
This subroutine calculates bilinear or bicubic vector-valued spline at the
given point (X,Y).
INPUT PARAMETERS:
C - spline interpolant.
X, Y- point
F - output buffer, possibly preallocated array. In case array size
is large enough to store result, it is not reallocated. Array
which is too short will be reallocated
OUTPUT PARAMETERS:
F - array[D] (or larger) which stores function values
-- ALGLIB PROJECT --
Copyright 16.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline2dcalcvbuf(const spline2dinterpolant &c, const double x, const double y, real_1d_array &f);
/*************************************************************************
This subroutine calculates bilinear or bicubic vector-valued spline at the
given point (X,Y).
INPUT PARAMETERS:
C - spline interpolant.
X, Y- point
OUTPUT PARAMETERS:
F - array[D] which stores function values. F is out-parameter and
it is reallocated after call to this function. In case you
want to reuse previously allocated F, you may use
Spline2DCalcVBuf(), which reallocates F only when it is too
small.
-- ALGLIB PROJECT --
Copyright 16.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline2dcalcv(const spline2dinterpolant &c, const double x, const double y, real_1d_array &f);
/*************************************************************************
This subroutine unpacks two-dimensional spline into the coefficients table
Input parameters:
C - spline interpolant.
Result:
M, N- grid size (x-axis and y-axis)
D - number of components
Tbl - coefficients table, unpacked format,
D - components: [0..(N-1)*(M-1)*D-1, 0..19].
For T=0..D-1 (component index), I = 0...N-2 (x index),
J=0..M-2 (y index):
K := T + I*D + J*D*(N-1)
K-th row stores decomposition for T-th component of the
vector-valued function
Tbl[K,0] = X[i]
Tbl[K,1] = X[i+1]
Tbl[K,2] = Y[j]
Tbl[K,3] = Y[j+1]
Tbl[K,4] = C00
Tbl[K,5] = C01
Tbl[K,6] = C02
Tbl[K,7] = C03
Tbl[K,8] = C10
Tbl[K,9] = C11
...
Tbl[K,19] = C33
On each grid square spline is equals to:
S(x) = SUM(c[i,j]*(t^i)*(u^j), i=0..3, j=0..3)
t = x-x[j]
u = y-y[i]
-- ALGLIB PROJECT --
Copyright 16.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline2dunpackv(const spline2dinterpolant &c, ae_int_t &m, ae_int_t &n, ae_int_t &d, real_2d_array &tbl);
/*************************************************************************
This subroutine was deprecated in ALGLIB 3.6.0
We recommend you to switch to Spline2DBuildBilinearV(), which is more
flexible and accepts its arguments in more convenient order.
-- ALGLIB PROJECT --
Copyright 05.07.2007 by Bochkanov Sergey
*************************************************************************/
void spline2dbuildbilinear(const real_1d_array &x, const real_1d_array &y, const real_2d_array &f, const ae_int_t m, const ae_int_t n, spline2dinterpolant &c);
/*************************************************************************
This subroutine was deprecated in ALGLIB 3.6.0
We recommend you to switch to Spline2DBuildBicubicV(), which is more
flexible and accepts its arguments in more convenient order.
-- ALGLIB PROJECT --
Copyright 05.07.2007 by Bochkanov Sergey
*************************************************************************/
void spline2dbuildbicubic(const real_1d_array &x, const real_1d_array &y, const real_2d_array &f, const ae_int_t m, const ae_int_t n, spline2dinterpolant &c);
/*************************************************************************
This subroutine was deprecated in ALGLIB 3.6.0
We recommend you to switch to Spline2DUnpackV(), which is more flexible
and accepts its arguments in more convenient order.
-- ALGLIB PROJECT --
Copyright 29.06.2007 by Bochkanov Sergey
*************************************************************************/
void spline2dunpack(const spline2dinterpolant &c, ae_int_t &m, ae_int_t &n, real_2d_array &tbl);
/*************************************************************************
This subroutine calculates the value of the trilinear or tricubic spline at
the given point (X,Y,Z).
INPUT PARAMETERS:
C - coefficients table.
Built by BuildBilinearSpline or BuildBicubicSpline.
X, Y,
Z - point
Result:
S(x,y,z)
-- ALGLIB PROJECT --
Copyright 26.04.2012 by Bochkanov Sergey
*************************************************************************/
double spline3dcalc(const spline3dinterpolant &c, const double x, const double y, const double z);
/*************************************************************************
This subroutine performs linear transformation of the spline argument.
INPUT PARAMETERS:
C - spline interpolant
AX, BX - transformation coefficients: x = A*u + B
AY, BY - transformation coefficients: y = A*v + B
AZ, BZ - transformation coefficients: z = A*w + B
OUTPUT PARAMETERS:
C - transformed spline
-- ALGLIB PROJECT --
Copyright 26.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline3dlintransxyz(const spline3dinterpolant &c, const double ax, const double bx, const double ay, const double by, const double az, const double bz);
/*************************************************************************
This subroutine performs linear transformation of the spline.
INPUT PARAMETERS:
C - spline interpolant.
A, B- transformation coefficients: S2(x,y) = A*S(x,y,z) + B
OUTPUT PARAMETERS:
C - transformed spline
-- ALGLIB PROJECT --
Copyright 26.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline3dlintransf(const spline3dinterpolant &c, const double a, const double b);
/*************************************************************************
Trilinear spline resampling
INPUT PARAMETERS:
A - array[0..OldXCount*OldYCount*OldZCount-1], function
values at the old grid, :
A[0] x=0,y=0,z=0
A[1] x=1,y=0,z=0
A[..] ...
A[..] x=oldxcount-1,y=0,z=0
A[..] x=0,y=1,z=0
A[..] ...
...
OldZCount - old Z-count, OldZCount>1
OldYCount - old Y-count, OldYCount>1
OldXCount - old X-count, OldXCount>1
NewZCount - new Z-count, NewZCount>1
NewYCount - new Y-count, NewYCount>1
NewXCount - new X-count, NewXCount>1
OUTPUT PARAMETERS:
B - array[0..NewXCount*NewYCount*NewZCount-1], function
values at the new grid:
B[0] x=0,y=0,z=0
B[1] x=1,y=0,z=0
B[..] ...
B[..] x=newxcount-1,y=0,z=0
B[..] x=0,y=1,z=0
B[..] ...
...
-- ALGLIB routine --
26.04.2012
Copyright by Bochkanov Sergey
*************************************************************************/
void spline3dresampletrilinear(const real_1d_array &a, const ae_int_t oldzcount, const ae_int_t oldycount, const ae_int_t oldxcount, const ae_int_t newzcount, const ae_int_t newycount, const ae_int_t newxcount, real_1d_array &b);
/*************************************************************************
This subroutine builds trilinear vector-valued spline.
INPUT PARAMETERS:
X - spline abscissas, array[0..N-1]
Y - spline ordinates, array[0..M-1]
Z - spline applicates, array[0..L-1]
F - function values, array[0..M*N*L*D-1]:
* first D elements store D values at (X[0],Y[0],Z[0])
* next D elements store D values at (X[1],Y[0],Z[0])
* next D elements store D values at (X[2],Y[0],Z[0])
* ...
* next D elements store D values at (X[0],Y[1],Z[0])
* next D elements store D values at (X[1],Y[1],Z[0])
* next D elements store D values at (X[2],Y[1],Z[0])
* ...
* next D elements store D values at (X[0],Y[0],Z[1])
* next D elements store D values at (X[1],Y[0],Z[1])
* next D elements store D values at (X[2],Y[0],Z[1])
* ...
* general form - D function values at (X[i],Y[j]) are stored
at F[D*(N*(M*K+J)+I)...D*(N*(M*K+J)+I)+D-1].
M,N,
L - grid size, M>=2, N>=2, L>=2
D - vector dimension, D>=1
OUTPUT PARAMETERS:
C - spline interpolant
-- ALGLIB PROJECT --
Copyright 26.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline3dbuildtrilinearv(const real_1d_array &x, const ae_int_t n, const real_1d_array &y, const ae_int_t m, const real_1d_array &z, const ae_int_t l, const real_1d_array &f, const ae_int_t d, spline3dinterpolant &c);
/*************************************************************************
This subroutine calculates bilinear or bicubic vector-valued spline at the
given point (X,Y,Z).
INPUT PARAMETERS:
C - spline interpolant.
X, Y,
Z - point
F - output buffer, possibly preallocated array. In case array size
is large enough to store result, it is not reallocated. Array
which is too short will be reallocated
OUTPUT PARAMETERS:
F - array[D] (or larger) which stores function values
-- ALGLIB PROJECT --
Copyright 26.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline3dcalcvbuf(const spline3dinterpolant &c, const double x, const double y, const double z, real_1d_array &f);
/*************************************************************************
This subroutine calculates trilinear or tricubic vector-valued spline at the
given point (X,Y,Z).
INPUT PARAMETERS:
C - spline interpolant.
X, Y,
Z - point
OUTPUT PARAMETERS:
F - array[D] which stores function values. F is out-parameter and
it is reallocated after call to this function. In case you
want to reuse previously allocated F, you may use
Spline2DCalcVBuf(), which reallocates F only when it is too
small.
-- ALGLIB PROJECT --
Copyright 26.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline3dcalcv(const spline3dinterpolant &c, const double x, const double y, const double z, real_1d_array &f);
/*************************************************************************
This subroutine unpacks tri-dimensional spline into the coefficients table
INPUT PARAMETERS:
C - spline interpolant.
Result:
N - grid size (X)
M - grid size (Y)
L - grid size (Z)
D - number of components
SType- spline type. Currently, only one spline type is supported:
trilinear spline, as indicated by SType=1.
Tbl - spline coefficients: [0..(N-1)*(M-1)*(L-1)*D-1, 0..13].
For T=0..D-1 (component index), I = 0...N-2 (x index),
J=0..M-2 (y index), K=0..L-2 (z index):
Q := T + I*D + J*D*(N-1) + K*D*(N-1)*(M-1),
Q-th row stores decomposition for T-th component of the
vector-valued function
Tbl[Q,0] = X[i]
Tbl[Q,1] = X[i+1]
Tbl[Q,2] = Y[j]
Tbl[Q,3] = Y[j+1]
Tbl[Q,4] = Z[k]
Tbl[Q,5] = Z[k+1]
Tbl[Q,6] = C000
Tbl[Q,7] = C100
Tbl[Q,8] = C010
Tbl[Q,9] = C110
Tbl[Q,10]= C001
Tbl[Q,11]= C101
Tbl[Q,12]= C011
Tbl[Q,13]= C111
On each grid square spline is equals to:
S(x) = SUM(c[i,j,k]*(x^i)*(y^j)*(z^k), i=0..1, j=0..1, k=0..1)
t = x-x[j]
u = y-y[i]
v = z-z[k]
NOTE: format of Tbl is given for SType=1. Future versions of
ALGLIB can use different formats for different values of
SType.
-- ALGLIB PROJECT --
Copyright 26.04.2012 by Bochkanov Sergey
*************************************************************************/
void spline3dunpackv(const spline3dinterpolant &c, ae_int_t &n, ae_int_t &m, ae_int_t &l, ae_int_t &d, ae_int_t &stype, real_2d_array &tbl);
}
/////////////////////////////////////////////////////////////////////////
//
// THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (FUNCTIONS)
//
/////////////////////////////////////////////////////////////////////////
namespace alglib_impl
{
double idwcalc(idwinterpolant* z,
/* Real */ ae_vector* x,
ae_state *_state);
void idwbuildmodifiedshepard(/* Real */ ae_matrix* xy,
ae_int_t n,
ae_int_t nx,
ae_int_t d,
ae_int_t nq,
ae_int_t nw,
idwinterpolant* z,
ae_state *_state);
void idwbuildmodifiedshepardr(/* Real */ ae_matrix* xy,
ae_int_t n,
ae_int_t nx,
double r,
idwinterpolant* z,
ae_state *_state);
void idwbuildnoisy(/* Real */ ae_matrix* xy,
ae_int_t n,
ae_int_t nx,
ae_int_t d,
ae_int_t nq,
ae_int_t nw,
idwinterpolant* z,
ae_state *_state);
void _idwinterpolant_init(void* _p, ae_state *_state);
void _idwinterpolant_init_copy(void* _dst, void* _src, ae_state *_state);
void _idwinterpolant_clear(void* _p);
void _idwinterpolant_destroy(void* _p);
double barycentriccalc(barycentricinterpolant* b,
double t,
ae_state *_state);
void barycentricdiff1(barycentricinterpolant* b,
double t,
double* f,
double* df,
ae_state *_state);
void barycentricdiff2(barycentricinterpolant* b,
double t,
double* f,
double* df,
double* d2f,
ae_state *_state);
void barycentriclintransx(barycentricinterpolant* b,
double ca,
double cb,
ae_state *_state);
void barycentriclintransy(barycentricinterpolant* b,
double ca,
double cb,
ae_state *_state);
void barycentricunpack(barycentricinterpolant* b,
ae_int_t* n,
/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_state *_state);
void barycentricbuildxyw(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
barycentricinterpolant* b,
ae_state *_state);
void barycentricbuildfloaterhormann(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t d,
barycentricinterpolant* b,
ae_state *_state);
void barycentriccopy(barycentricinterpolant* b,
barycentricinterpolant* b2,
ae_state *_state);
void _barycentricinterpolant_init(void* _p, ae_state *_state);
void _barycentricinterpolant_init_copy(void* _dst, void* _src, ae_state *_state);
void _barycentricinterpolant_clear(void* _p);
void _barycentricinterpolant_destroy(void* _p);
void polynomialbar2cheb(barycentricinterpolant* p,
double a,
double b,
/* Real */ ae_vector* t,
ae_state *_state);
void polynomialcheb2bar(/* Real */ ae_vector* t,
ae_int_t n,
double a,
double b,
barycentricinterpolant* p,
ae_state *_state);
void polynomialbar2pow(barycentricinterpolant* p,
double c,
double s,
/* Real */ ae_vector* a,
ae_state *_state);
void polynomialpow2bar(/* Real */ ae_vector* a,
ae_int_t n,
double c,
double s,
barycentricinterpolant* p,
ae_state *_state);
void polynomialbuild(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
barycentricinterpolant* p,
ae_state *_state);
void polynomialbuildeqdist(double a,
double b,
/* Real */ ae_vector* y,
ae_int_t n,
barycentricinterpolant* p,
ae_state *_state);
void polynomialbuildcheb1(double a,
double b,
/* Real */ ae_vector* y,
ae_int_t n,
barycentricinterpolant* p,
ae_state *_state);
void polynomialbuildcheb2(double a,
double b,
/* Real */ ae_vector* y,
ae_int_t n,
barycentricinterpolant* p,
ae_state *_state);
double polynomialcalceqdist(double a,
double b,
/* Real */ ae_vector* f,
ae_int_t n,
double t,
ae_state *_state);
double polynomialcalccheb1(double a,
double b,
/* Real */ ae_vector* f,
ae_int_t n,
double t,
ae_state *_state);
double polynomialcalccheb2(double a,
double b,
/* Real */ ae_vector* f,
ae_int_t n,
double t,
ae_state *_state);
void spline1dbuildlinear(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
spline1dinterpolant* c,
ae_state *_state);
void spline1dbuildcubic(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t boundltype,
double boundl,
ae_int_t boundrtype,
double boundr,
spline1dinterpolant* c,
ae_state *_state);
void spline1dgriddiffcubic(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t boundltype,
double boundl,
ae_int_t boundrtype,
double boundr,
/* Real */ ae_vector* d,
ae_state *_state);
void spline1dgriddiff2cubic(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t boundltype,
double boundl,
ae_int_t boundrtype,
double boundr,
/* Real */ ae_vector* d1,
/* Real */ ae_vector* d2,
ae_state *_state);
void spline1dconvcubic(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t boundltype,
double boundl,
ae_int_t boundrtype,
double boundr,
/* Real */ ae_vector* x2,
ae_int_t n2,
/* Real */ ae_vector* y2,
ae_state *_state);
void spline1dconvdiffcubic(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t boundltype,
double boundl,
ae_int_t boundrtype,
double boundr,
/* Real */ ae_vector* x2,
ae_int_t n2,
/* Real */ ae_vector* y2,
/* Real */ ae_vector* d2,
ae_state *_state);
void spline1dconvdiff2cubic(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t boundltype,
double boundl,
ae_int_t boundrtype,
double boundr,
/* Real */ ae_vector* x2,
ae_int_t n2,
/* Real */ ae_vector* y2,
/* Real */ ae_vector* d2,
/* Real */ ae_vector* dd2,
ae_state *_state);
void spline1dbuildcatmullrom(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t boundtype,
double tension,
spline1dinterpolant* c,
ae_state *_state);
void spline1dbuildhermite(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* d,
ae_int_t n,
spline1dinterpolant* c,
ae_state *_state);
void spline1dbuildakima(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
spline1dinterpolant* c,
ae_state *_state);
double spline1dcalc(spline1dinterpolant* c, double x, ae_state *_state);
void spline1ddiff(spline1dinterpolant* c,
double x,
double* s,
double* ds,
double* d2s,
ae_state *_state);
void spline1dcopy(spline1dinterpolant* c,
spline1dinterpolant* cc,
ae_state *_state);
void spline1dunpack(spline1dinterpolant* c,
ae_int_t* n,
/* Real */ ae_matrix* tbl,
ae_state *_state);
void spline1dlintransx(spline1dinterpolant* c,
double a,
double b,
ae_state *_state);
void spline1dlintransy(spline1dinterpolant* c,
double a,
double b,
ae_state *_state);
double spline1dintegrate(spline1dinterpolant* c,
double x,
ae_state *_state);
void spline1dconvdiffinternal(/* Real */ ae_vector* xold,
/* Real */ ae_vector* yold,
/* Real */ ae_vector* dold,
ae_int_t n,
/* Real */ ae_vector* x2,
ae_int_t n2,
/* Real */ ae_vector* y,
ae_bool needy,
/* Real */ ae_vector* d1,
ae_bool needd1,
/* Real */ ae_vector* d2,
ae_bool needd2,
ae_state *_state);
void spline1drootsandextrema(spline1dinterpolant* c,
/* Real */ ae_vector* r,
ae_int_t* nr,
ae_bool* dr,
/* Real */ ae_vector* e,
/* Integer */ ae_vector* et,
ae_int_t* ne,
ae_bool* de,
ae_state *_state);
void heapsortdpoints(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* d,
ae_int_t n,
ae_state *_state);
void solvepolinom2(double p0,
double m0,
double p1,
double m1,
double* x0,
double* x1,
ae_int_t* nr,
ae_state *_state);
void solvecubicpolinom(double pa,
double ma,
double pb,
double mb,
double a,
double b,
double* x0,
double* x1,
double* x2,
double* ex0,
double* ex1,
ae_int_t* nr,
ae_int_t* ne,
/* Real */ ae_vector* tempdata,
ae_state *_state);
ae_int_t bisectmethod(double pa,
double ma,
double pb,
double mb,
double a,
double b,
double* x,
ae_state *_state);
void spline1dbuildmonotone(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
spline1dinterpolant* c,
ae_state *_state);
void _spline1dinterpolant_init(void* _p, ae_state *_state);
void _spline1dinterpolant_init_copy(void* _dst, void* _src, ae_state *_state);
void _spline1dinterpolant_clear(void* _p);
void _spline1dinterpolant_destroy(void* _p);
void lstfitpiecewiselinearrdpfixed(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
/* Real */ ae_vector* x2,
/* Real */ ae_vector* y2,
ae_int_t* nsections,
ae_state *_state);
void lstfitpiecewiselinearrdp(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
double eps,
/* Real */ ae_vector* x2,
/* Real */ ae_vector* y2,
ae_int_t* nsections,
ae_state *_state);
void polynomialfit(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
barycentricinterpolant* p,
polynomialfitreport* rep,
ae_state *_state);
void _pexec_polynomialfit(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
barycentricinterpolant* p,
polynomialfitreport* rep, ae_state *_state);
void polynomialfitwc(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
/* Real */ ae_vector* xc,
/* Real */ ae_vector* yc,
/* Integer */ ae_vector* dc,
ae_int_t k,
ae_int_t m,
ae_int_t* info,
barycentricinterpolant* p,
polynomialfitreport* rep,
ae_state *_state);
void _pexec_polynomialfitwc(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
/* Real */ ae_vector* xc,
/* Real */ ae_vector* yc,
/* Integer */ ae_vector* dc,
ae_int_t k,
ae_int_t m,
ae_int_t* info,
barycentricinterpolant* p,
polynomialfitreport* rep, ae_state *_state);
double logisticcalc4(double x,
double a,
double b,
double c,
double d,
ae_state *_state);
double logisticcalc5(double x,
double a,
double b,
double c,
double d,
double g,
ae_state *_state);
void logisticfit4(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
double* a,
double* b,
double* c,
double* d,
lsfitreport* rep,
ae_state *_state);
void logisticfit4ec(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
double cnstrleft,
double cnstrright,
double* a,
double* b,
double* c,
double* d,
lsfitreport* rep,
ae_state *_state);
void logisticfit5(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
double* a,
double* b,
double* c,
double* d,
double* g,
lsfitreport* rep,
ae_state *_state);
void logisticfit5ec(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
double cnstrleft,
double cnstrright,
double* a,
double* b,
double* c,
double* d,
double* g,
lsfitreport* rep,
ae_state *_state);
void logisticfit45x(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
double cnstrleft,
double cnstrright,
ae_bool is4pl,
double lambdav,
double epsx,
ae_int_t rscnt,
double* a,
double* b,
double* c,
double* d,
double* g,
lsfitreport* rep,
ae_state *_state);
void barycentricfitfloaterhormannwc(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
/* Real */ ae_vector* xc,
/* Real */ ae_vector* yc,
/* Integer */ ae_vector* dc,
ae_int_t k,
ae_int_t m,
ae_int_t* info,
barycentricinterpolant* b,
barycentricfitreport* rep,
ae_state *_state);
void _pexec_barycentricfitfloaterhormannwc(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
/* Real */ ae_vector* xc,
/* Real */ ae_vector* yc,
/* Integer */ ae_vector* dc,
ae_int_t k,
ae_int_t m,
ae_int_t* info,
barycentricinterpolant* b,
barycentricfitreport* rep, ae_state *_state);
void barycentricfitfloaterhormann(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
barycentricinterpolant* b,
barycentricfitreport* rep,
ae_state *_state);
void _pexec_barycentricfitfloaterhormann(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
barycentricinterpolant* b,
barycentricfitreport* rep, ae_state *_state);
void spline1dfitpenalized(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
double rho,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep,
ae_state *_state);
void _pexec_spline1dfitpenalized(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
double rho,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep, ae_state *_state);
void spline1dfitpenalizedw(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
ae_int_t m,
double rho,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep,
ae_state *_state);
void _pexec_spline1dfitpenalizedw(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
ae_int_t m,
double rho,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep, ae_state *_state);
void spline1dfitcubicwc(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
/* Real */ ae_vector* xc,
/* Real */ ae_vector* yc,
/* Integer */ ae_vector* dc,
ae_int_t k,
ae_int_t m,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep,
ae_state *_state);
void _pexec_spline1dfitcubicwc(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
/* Real */ ae_vector* xc,
/* Real */ ae_vector* yc,
/* Integer */ ae_vector* dc,
ae_int_t k,
ae_int_t m,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep, ae_state *_state);
void spline1dfithermitewc(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
/* Real */ ae_vector* xc,
/* Real */ ae_vector* yc,
/* Integer */ ae_vector* dc,
ae_int_t k,
ae_int_t m,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep,
ae_state *_state);
void _pexec_spline1dfithermitewc(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
/* Real */ ae_vector* xc,
/* Real */ ae_vector* yc,
/* Integer */ ae_vector* dc,
ae_int_t k,
ae_int_t m,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep, ae_state *_state);
void spline1dfitcubic(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep,
ae_state *_state);
void _pexec_spline1dfitcubic(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep, ae_state *_state);
void spline1dfithermite(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep,
ae_state *_state);
void _pexec_spline1dfithermite(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
spline1dinterpolant* s,
spline1dfitreport* rep, ae_state *_state);
void lsfitlinearw(/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
/* Real */ ae_matrix* fmatrix,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
/* Real */ ae_vector* c,
lsfitreport* rep,
ae_state *_state);
void _pexec_lsfitlinearw(/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
/* Real */ ae_matrix* fmatrix,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
/* Real */ ae_vector* c,
lsfitreport* rep, ae_state *_state);
void lsfitlinearwc(/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
/* Real */ ae_matrix* fmatrix,
/* Real */ ae_matrix* cmatrix,
ae_int_t n,
ae_int_t m,
ae_int_t k,
ae_int_t* info,
/* Real */ ae_vector* c,
lsfitreport* rep,
ae_state *_state);
void _pexec_lsfitlinearwc(/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
/* Real */ ae_matrix* fmatrix,
/* Real */ ae_matrix* cmatrix,
ae_int_t n,
ae_int_t m,
ae_int_t k,
ae_int_t* info,
/* Real */ ae_vector* c,
lsfitreport* rep, ae_state *_state);
void lsfitlinear(/* Real */ ae_vector* y,
/* Real */ ae_matrix* fmatrix,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
/* Real */ ae_vector* c,
lsfitreport* rep,
ae_state *_state);
void _pexec_lsfitlinear(/* Real */ ae_vector* y,
/* Real */ ae_matrix* fmatrix,
ae_int_t n,
ae_int_t m,
ae_int_t* info,
/* Real */ ae_vector* c,
lsfitreport* rep, ae_state *_state);
void lsfitlinearc(/* Real */ ae_vector* y,
/* Real */ ae_matrix* fmatrix,
/* Real */ ae_matrix* cmatrix,
ae_int_t n,
ae_int_t m,
ae_int_t k,
ae_int_t* info,
/* Real */ ae_vector* c,
lsfitreport* rep,
ae_state *_state);
void _pexec_lsfitlinearc(/* Real */ ae_vector* y,
/* Real */ ae_matrix* fmatrix,
/* Real */ ae_matrix* cmatrix,
ae_int_t n,
ae_int_t m,
ae_int_t k,
ae_int_t* info,
/* Real */ ae_vector* c,
lsfitreport* rep, ae_state *_state);
void lsfitcreatewf(/* Real */ ae_matrix* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
/* Real */ ae_vector* c,
ae_int_t n,
ae_int_t m,
ae_int_t k,
double diffstep,
lsfitstate* state,
ae_state *_state);
void lsfitcreatef(/* Real */ ae_matrix* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* c,
ae_int_t n,
ae_int_t m,
ae_int_t k,
double diffstep,
lsfitstate* state,
ae_state *_state);
void lsfitcreatewfg(/* Real */ ae_matrix* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
/* Real */ ae_vector* c,
ae_int_t n,
ae_int_t m,
ae_int_t k,
ae_bool cheapfg,
lsfitstate* state,
ae_state *_state);
void lsfitcreatefg(/* Real */ ae_matrix* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* c,
ae_int_t n,
ae_int_t m,
ae_int_t k,
ae_bool cheapfg,
lsfitstate* state,
ae_state *_state);
void lsfitcreatewfgh(/* Real */ ae_matrix* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
/* Real */ ae_vector* c,
ae_int_t n,
ae_int_t m,
ae_int_t k,
lsfitstate* state,
ae_state *_state);
void lsfitcreatefgh(/* Real */ ae_matrix* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* c,
ae_int_t n,
ae_int_t m,
ae_int_t k,
lsfitstate* state,
ae_state *_state);
void lsfitsetcond(lsfitstate* state,
double epsf,
double epsx,
ae_int_t maxits,
ae_state *_state);
void lsfitsetstpmax(lsfitstate* state, double stpmax, ae_state *_state);
void lsfitsetxrep(lsfitstate* state, ae_bool needxrep, ae_state *_state);
void lsfitsetscale(lsfitstate* state,
/* Real */ ae_vector* s,
ae_state *_state);
void lsfitsetbc(lsfitstate* state,
/* Real */ ae_vector* bndl,
/* Real */ ae_vector* bndu,
ae_state *_state);
ae_bool lsfititeration(lsfitstate* state, ae_state *_state);
void lsfitresults(lsfitstate* state,
ae_int_t* info,
/* Real */ ae_vector* c,
lsfitreport* rep,
ae_state *_state);
void lsfitsetgradientcheck(lsfitstate* state,
double teststep,
ae_state *_state);
void lsfitscalexy(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_vector* w,
ae_int_t n,
/* Real */ ae_vector* xc,
/* Real */ ae_vector* yc,
/* Integer */ ae_vector* dc,
ae_int_t k,
double* xa,
double* xb,
double* sa,
double* sb,
/* Real */ ae_vector* xoriginal,
/* Real */ ae_vector* yoriginal,
ae_state *_state);
void _polynomialfitreport_init(void* _p, ae_state *_state);
void _polynomialfitreport_init_copy(void* _dst, void* _src, ae_state *_state);
void _polynomialfitreport_clear(void* _p);
void _polynomialfitreport_destroy(void* _p);
void _barycentricfitreport_init(void* _p, ae_state *_state);
void _barycentricfitreport_init_copy(void* _dst, void* _src, ae_state *_state);
void _barycentricfitreport_clear(void* _p);
void _barycentricfitreport_destroy(void* _p);
void _spline1dfitreport_init(void* _p, ae_state *_state);
void _spline1dfitreport_init_copy(void* _dst, void* _src, ae_state *_state);
void _spline1dfitreport_clear(void* _p);
void _spline1dfitreport_destroy(void* _p);
void _lsfitreport_init(void* _p, ae_state *_state);
void _lsfitreport_init_copy(void* _dst, void* _src, ae_state *_state);
void _lsfitreport_clear(void* _p);
void _lsfitreport_destroy(void* _p);
void _lsfitstate_init(void* _p, ae_state *_state);
void _lsfitstate_init_copy(void* _dst, void* _src, ae_state *_state);
void _lsfitstate_clear(void* _p);
void _lsfitstate_destroy(void* _p);
void pspline2build(/* Real */ ae_matrix* xy,
ae_int_t n,
ae_int_t st,
ae_int_t pt,
pspline2interpolant* p,
ae_state *_state);
void pspline3build(/* Real */ ae_matrix* xy,
ae_int_t n,
ae_int_t st,
ae_int_t pt,
pspline3interpolant* p,
ae_state *_state);
void pspline2buildperiodic(/* Real */ ae_matrix* xy,
ae_int_t n,
ae_int_t st,
ae_int_t pt,
pspline2interpolant* p,
ae_state *_state);
void pspline3buildperiodic(/* Real */ ae_matrix* xy,
ae_int_t n,
ae_int_t st,
ae_int_t pt,
pspline3interpolant* p,
ae_state *_state);
void pspline2parametervalues(pspline2interpolant* p,
ae_int_t* n,
/* Real */ ae_vector* t,
ae_state *_state);
void pspline3parametervalues(pspline3interpolant* p,
ae_int_t* n,
/* Real */ ae_vector* t,
ae_state *_state);
void pspline2calc(pspline2interpolant* p,
double t,
double* x,
double* y,
ae_state *_state);
void pspline3calc(pspline3interpolant* p,
double t,
double* x,
double* y,
double* z,
ae_state *_state);
void pspline2tangent(pspline2interpolant* p,
double t,
double* x,
double* y,
ae_state *_state);
void pspline3tangent(pspline3interpolant* p,
double t,
double* x,
double* y,
double* z,
ae_state *_state);
void pspline2diff(pspline2interpolant* p,
double t,
double* x,
double* dx,
double* y,
double* dy,
ae_state *_state);
void pspline3diff(pspline3interpolant* p,
double t,
double* x,
double* dx,
double* y,
double* dy,
double* z,
double* dz,
ae_state *_state);
void pspline2diff2(pspline2interpolant* p,
double t,
double* x,
double* dx,
double* d2x,
double* y,
double* dy,
double* d2y,
ae_state *_state);
void pspline3diff2(pspline3interpolant* p,
double t,
double* x,
double* dx,
double* d2x,
double* y,
double* dy,
double* d2y,
double* z,
double* dz,
double* d2z,
ae_state *_state);
double pspline2arclength(pspline2interpolant* p,
double a,
double b,
ae_state *_state);
double pspline3arclength(pspline3interpolant* p,
double a,
double b,
ae_state *_state);
void parametricrdpfixed(/* Real */ ae_matrix* x,
ae_int_t n,
ae_int_t d,
ae_int_t stopm,
double stopeps,
/* Real */ ae_matrix* x2,
/* Integer */ ae_vector* idx2,
ae_int_t* nsections,
ae_state *_state);
void _pspline2interpolant_init(void* _p, ae_state *_state);
void _pspline2interpolant_init_copy(void* _dst, void* _src, ae_state *_state);
void _pspline2interpolant_clear(void* _p);
void _pspline2interpolant_destroy(void* _p);
void _pspline3interpolant_init(void* _p, ae_state *_state);
void _pspline3interpolant_init_copy(void* _dst, void* _src, ae_state *_state);
void _pspline3interpolant_clear(void* _p);
void _pspline3interpolant_destroy(void* _p);
void rbfcreate(ae_int_t nx, ae_int_t ny, rbfmodel* s, ae_state *_state);
void rbfsetpoints(rbfmodel* s,
/* Real */ ae_matrix* xy,
ae_int_t n,
ae_state *_state);
void rbfsetalgoqnn(rbfmodel* s, double q, double z, ae_state *_state);
void rbfsetalgomultilayer(rbfmodel* s,
double rbase,
ae_int_t nlayers,
double lambdav,
ae_state *_state);
void rbfsetlinterm(rbfmodel* s, ae_state *_state);
void rbfsetconstterm(rbfmodel* s, ae_state *_state);
void rbfsetzeroterm(rbfmodel* s, ae_state *_state);
void rbfsetcond(rbfmodel* s,
double epsort,
double epserr,
ae_int_t maxits,
ae_state *_state);
void rbfbuildmodel(rbfmodel* s, rbfreport* rep, ae_state *_state);
double rbfcalc2(rbfmodel* s, double x0, double x1, ae_state *_state);
double rbfcalc3(rbfmodel* s,
double x0,
double x1,
double x2,
ae_state *_state);
void rbfcalc(rbfmodel* s,
/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_state *_state);
void rbfcalcbuf(rbfmodel* s,
/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
ae_state *_state);
void rbfgridcalc2(rbfmodel* s,
/* Real */ ae_vector* x0,
ae_int_t n0,
/* Real */ ae_vector* x1,
ae_int_t n1,
/* Real */ ae_matrix* y,
ae_state *_state);
void rbfunpack(rbfmodel* s,
ae_int_t* nx,
ae_int_t* ny,
/* Real */ ae_matrix* xwr,
ae_int_t* nc,
/* Real */ ae_matrix* v,
ae_state *_state);
void rbfalloc(ae_serializer* s, rbfmodel* model, ae_state *_state);
void rbfserialize(ae_serializer* s, rbfmodel* model, ae_state *_state);
void rbfunserialize(ae_serializer* s, rbfmodel* model, ae_state *_state);
void _rbfmodel_init(void* _p, ae_state *_state);
void _rbfmodel_init_copy(void* _dst, void* _src, ae_state *_state);
void _rbfmodel_clear(void* _p);
void _rbfmodel_destroy(void* _p);
void _rbfreport_init(void* _p, ae_state *_state);
void _rbfreport_init_copy(void* _dst, void* _src, ae_state *_state);
void _rbfreport_clear(void* _p);
void _rbfreport_destroy(void* _p);
double spline2dcalc(spline2dinterpolant* c,
double x,
double y,
ae_state *_state);
void spline2ddiff(spline2dinterpolant* c,
double x,
double y,
double* f,
double* fx,
double* fy,
double* fxy,
ae_state *_state);
void spline2dlintransxy(spline2dinterpolant* c,
double ax,
double bx,
double ay,
double by,
ae_state *_state);
void spline2dlintransf(spline2dinterpolant* c,
double a,
double b,
ae_state *_state);
void spline2dcopy(spline2dinterpolant* c,
spline2dinterpolant* cc,
ae_state *_state);
void spline2dresamplebicubic(/* Real */ ae_matrix* a,
ae_int_t oldheight,
ae_int_t oldwidth,
/* Real */ ae_matrix* b,
ae_int_t newheight,
ae_int_t newwidth,
ae_state *_state);
void spline2dresamplebilinear(/* Real */ ae_matrix* a,
ae_int_t oldheight,
ae_int_t oldwidth,
/* Real */ ae_matrix* b,
ae_int_t newheight,
ae_int_t newwidth,
ae_state *_state);
void spline2dbuildbilinearv(/* Real */ ae_vector* x,
ae_int_t n,
/* Real */ ae_vector* y,
ae_int_t m,
/* Real */ ae_vector* f,
ae_int_t d,
spline2dinterpolant* c,
ae_state *_state);
void spline2dbuildbicubicv(/* Real */ ae_vector* x,
ae_int_t n,
/* Real */ ae_vector* y,
ae_int_t m,
/* Real */ ae_vector* f,
ae_int_t d,
spline2dinterpolant* c,
ae_state *_state);
void spline2dcalcvbuf(spline2dinterpolant* c,
double x,
double y,
/* Real */ ae_vector* f,
ae_state *_state);
void spline2dcalcv(spline2dinterpolant* c,
double x,
double y,
/* Real */ ae_vector* f,
ae_state *_state);
void spline2dunpackv(spline2dinterpolant* c,
ae_int_t* m,
ae_int_t* n,
ae_int_t* d,
/* Real */ ae_matrix* tbl,
ae_state *_state);
void spline2dbuildbilinear(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_matrix* f,
ae_int_t m,
ae_int_t n,
spline2dinterpolant* c,
ae_state *_state);
void spline2dbuildbicubic(/* Real */ ae_vector* x,
/* Real */ ae_vector* y,
/* Real */ ae_matrix* f,
ae_int_t m,
ae_int_t n,
spline2dinterpolant* c,
ae_state *_state);
void spline2dunpack(spline2dinterpolant* c,
ae_int_t* m,
ae_int_t* n,
/* Real */ ae_matrix* tbl,
ae_state *_state);
void _spline2dinterpolant_init(void* _p, ae_state *_state);
void _spline2dinterpolant_init_copy(void* _dst, void* _src, ae_state *_state);
void _spline2dinterpolant_clear(void* _p);
void _spline2dinterpolant_destroy(void* _p);
double spline3dcalc(spline3dinterpolant* c,
double x,
double y,
double z,
ae_state *_state);
void spline3dlintransxyz(spline3dinterpolant* c,
double ax,
double bx,
double ay,
double by,
double az,
double bz,
ae_state *_state);
void spline3dlintransf(spline3dinterpolant* c,
double a,
double b,
ae_state *_state);
void spline3dcopy(spline3dinterpolant* c,
spline3dinterpolant* cc,
ae_state *_state);
void spline3dresampletrilinear(/* Real */ ae_vector* a,
ae_int_t oldzcount,
ae_int_t oldycount,
ae_int_t oldxcount,
ae_int_t newzcount,
ae_int_t newycount,
ae_int_t newxcount,
/* Real */ ae_vector* b,
ae_state *_state);
void spline3dbuildtrilinearv(/* Real */ ae_vector* x,
ae_int_t n,
/* Real */ ae_vector* y,
ae_int_t m,
/* Real */ ae_vector* z,
ae_int_t l,
/* Real */ ae_vector* f,
ae_int_t d,
spline3dinterpolant* c,
ae_state *_state);
void spline3dcalcvbuf(spline3dinterpolant* c,
double x,
double y,
double z,
/* Real */ ae_vector* f,
ae_state *_state);
void spline3dcalcv(spline3dinterpolant* c,
double x,
double y,
double z,
/* Real */ ae_vector* f,
ae_state *_state);
void spline3dunpackv(spline3dinterpolant* c,
ae_int_t* n,
ae_int_t* m,
ae_int_t* l,
ae_int_t* d,
ae_int_t* stype,
/* Real */ ae_matrix* tbl,
ae_state *_state);
void _spline3dinterpolant_init(void* _p, ae_state *_state);
void _spline3dinterpolant_init_copy(void* _dst, void* _src, ae_state *_state);
void _spline3dinterpolant_clear(void* _p);
void _spline3dinterpolant_destroy(void* _p);
}
#endif
|