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
|
@ifhelp
?
F U D G I T Version 2.42
The three different modes are accessed by commands: 'fmode', 'pmode'
and 'cmode'. All fmode commands can be abbreviated down to 2
characters. Vectors have upper case name and scalar variables lower
case. A mix of both upper and lower cases results in forming a string
variable. Read the "Intro" help topic for an overview. See the
"README" help item for complete copyrights.
Send bugs or comments to <isaac@physics.mcgill.ca>.
?Intro
FUDGIT is a double-precision multi purpose fitting program.
It can manipulate complete columns of numbers in the form
of vector arithmetic. FUDGIT is also an expression language
interpreter understanding most of C grammar except pointers.
It supports all functions from the C math library. Finally,
FUDGIT is a front end for any plotting program supporting
commands from stdin. It is a nice mathematical complement
to GNUPLOT, for example.
The main features of FUDGIT are:
- Command shell including history;
- Possible abbreviation of all the ``fitting mode'' commands;
- Possible plural when it makes sense too;
- Interactive shell supporting flow control (while,
if-else-endif, foreach);
- User definable macros;
- User definable aliases;
- On-line help;
- On-line loadable procedure- or function-objects;
- On-line selectable plotting program;
- Fourier transforms;
- Smoothing;
- Double-precision built-in calculator;
- Built-in interpreter supporting most of C language including
flow control (if, else, while, for, break, continue);
- User definable functions and procedures;
- Double-precision vector arithmetic;
- Access to the complete C math library;
- Built-in fitting series such as:
+ power series (polynomial);
+ sine series;
+ cosine series;
+ Legendre polynomials;
+ series of Gaussians;
+ series of Lorentzians;
+ series of exponentials;
- User definable fitting functions;
- Totally dynamical allocation of variables and parameters;
- Possible selection of fitting ranges;
FUDGIT has a collection of fitting routines including:
- straight line (linear) least squares;
- straight line (linear) least absolute deviation;
- general linear least squares using QR decomposition;
- general linear least squares using singular value decomposition;
- nonlinear Marquardt-Levenberg method;
Refer to the ``User's Manual'' for a complete description and a
tutorial on I/O and fitting.
See also:
Modes, C, cmode, fmode, pmode, fit, set, read, save, let
?Modes
FUDGIT is composed of three different modes. These modes can be
thought of as a C-shell like interpreter linked with a calculator,
sharing the same variables in memory, and with a plotting program of
our choice.
The C-shell like interpreter is called the ``fitting mode''. It is
the central mode and is the one from which all accesses to the disk
are done. This mode has a range of commands allowing the user to read
vectors from or save vectors to a data file, to read a command script,
save the command history, do a Fourier transform of a vector, make a
linear or nonlinear least square fit, etc\ldots This mode also allows the
user to define macros and aliases, and to perform plotting-fitting
batch processes by using some of the built-in flow control commands
(while, foreach, if-else-endif). All the commands in the fitting mode
can be abbreviated. It is worth mentioning that in the fitting mode
the command line parsing is done by analyzing words separated by one
or more blanks (space or tab), as in an interactive csh.
The ``C-calculator mode'' is a language interpreter supporting most of
C grammar except pointers. It also supports the complete
double-precision C math library. Thus, recognized keywords cannot be
abbreviated, and the different tokens need not be separated. Most of
the C operators and keywords are understood and a few extra operators
have been added. This mode does essentially all the possible
calculations on variables or vectors. Functions and procedures can be
defined. String variables, string comparison, addition, subtraction
are also supported by C-calculator mode. This mode is accessed by the
command `cmode'.
Finally, the ``plotting mode'' is a channel talking directly to the
plotting program of your choice. Therefore, FUDGIT can serve as a
front end to any plotting program able to accept input from stdin.
This way, vectors can be build from the calculator and then plotted by
your favorite plotting program. The default plotting program is
GNUPLOT.
@endif
@ifhelp
?\&
@else
\section{\&}
@endif
The `\&' operator forces \fudgit\ to use the built-in following fitting
mode command and to ignore any existing macro or alias with the same
name. This can be useful in constructions like:
@ifhelp
@endif
\nopagebreak\begin{verbatim}
macro cd 1
pmode cd "$1"
&cd $1 # The built-in cd
stop
\end{verbatim}
\Seealso
\bq macro, cd \eq
@ifhelp
?\verb+\+
@else
\section{$\backslash$}
@endif
If anywhere in the middle of a line, a `\verb+\+' will indicate
\fudgit\ to take the following character as is. If at the end of a
line, a `\verb+\+' indicates that the present line continues on the
following one, and thus to ignore the following carriage return.
\Seealso
\bq line editing\eq
@ifhelp
?!
@else
\section{!}
@endif
Any line beginning with the so-called bang operator `!' will execute
the system command line with a Bourne shell. Aliased commands as found
in your interactive C-shell do not hold any more. For example,
commands like {\tt !rm} will not be interactive (i.e. /bin/rm -i) even
if you have such an alias in your {\it .cshrc} file. Be careful! A
nice turnaround is to alias rm to `{\tt ! rm -i}' in your {\it
.fudgitrc} file and to use the {\tt rm} command directly from
\fudgit's shell.
When used in a macro name or an alias name, the `!' character has
still another meaning. This tells the parser that characters following
the `!' are optional. Therefore, if one types the following,
interactively, (see NOTE)
@ifhelp
@endif
\nopagebreak\begin{verbatim}
set noexpand
alias da!te !date
set expand
\end{verbatim}
@ifhelp
@endif
then the parser will recognize {\tt da}, {\tt dat} and {\tt date} as
all synonymous to the system command {\tt ! date} run through a Bourne
shell.
NOTE: In interactive mode, the history functions will try to interpret
a history substitution if the `!' is not followed by a space. See the
appendices. To avoid that the line be scanned for a history event
designator, use the {\tt set noexpand} command. In some cases, it
might be simpler to use the {\tt system} command.
\Syntax
\bq !{\it command}\eq
\Example
\bq ! mail\eq
\Seealso
\bq alias, ls, vi, foreach, system, set expand\eq
@ifhelp
?help?
@else
\section{?}
@endif
A question mark will indicate \fudgit\ to try to get the possible
options available to the command presently typed. This kind of help is
context sensitive and works when an insufficient number of arguments
is supplied. The question mark also serves as a wild character in
string subtraction.
\Syntax
\bq {\it command} ? \eq
\Examples
\bq ?\\
show ?\\
set function ?\eq
\Seealso
\bq help, strings \eq
@ifhelp
?\$
@else
\section{\$}
@endif
The `\$' operator expands scalar variables or constants (double
precision numbers from C-calculator mode lookup table) as well as
string variables or constants. Existing scalar variables can thus be
expanded as a string in order to serve as a file name or directory
name, for example. The expansion is done according to the value given
to the {\tt set vformat} command which initially defaults to
"\%.3g". Using the scalar variable expansion operator in
C-calculator mode is not recommanded since a lot of precision might be
lost (actually it is a waste!). Scalar variable expansion is
essentially provided to allow alternative procedures in certain cases,
such as generating filenames from numbers. Math function {\tt scan}
can be considered as the complement of scalar variable expansion.
The `\$' character also expands string variables. Expansion is done by
replacing the \${\it String-Variable-Name} by the value of the string
variable. This can be used to replace {\tt scan} in cases where the
string variable or constant represents a number. For example
@ifhelp
@endif
\nopagebreak\begin{verbatim}
foreach File in echo 2.2 4.4 6.7 8.32
let x = $File
.
.
.
end
\end{verbatim}
In both cases, if the variable name has to be followed by alphanumeric
characters, then the variable name can be delimited by braces as in
standard csh.
Followed by an integer number, the `\$' character serves to designate
the arguments of a macro. Refer to the description of {\tt macro},
concerning this point.
\Syntax
\bq \${\it name}\eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq\$\{{\it name}\}\eq
\Seealso
\bq C, cmode, macro, echo, exit \eq
@ifhelp
?_dumplot
@else
\section{\_dumplot}
@endif
Command {\tt \_dumplot} is generally used in a macro to dump vectors
in the plotting pipe. It is described in more detail under {\tt
special} item.
@ifhelp
?_killplot
@else
\section{\_killplot}
@endif
Command {\tt \_killplot} is rarely used. It sends a KILL signal to the
plotting program. It is described in more detail under {\tt special}
item.
@ifhelp
?adjust
@else
\section{adjust}
@endif
The {\tt adjust} command is used to specify the parameters to be
adjusted in the ``least square linear'' and the ``Marquardt-Levenberg
nonlinear'' fitting methods. Parameters not being adjusted will have
their standard deviation set to zero. {\tt adjust} also recognizes
the string "all" in which case all parameters are adjusted.
\Syntax
\bq adjust {\it index-list} \eq
\Example
\bq adjust 1 2 4\\
adjust all\eq
\Seealso
\bq set parameters, set method, set function, fit, show fit \eq
@ifhelp
?alias
@else
\section{alias}
@endif
The {\tt alias} command is used to alias a multiple word command to a
single word. Although macros and aliases are different objects, it is
not allowed to define a macro and an alias with the same name since
aliases are always expanded first. Recall that the bang operator
(`!'), at the beginning of a line is recognized from a macro, an alias
or a script file so that an alias like
@ifhelp
@endif
\nopagebreak\begin{verbatim}
alias date !date
\end{verbatim}
@ifhelp
@endif
is perfectly legal. However, this would have to be typed
@ifhelp
@endif
\nopagebreak\begin{verbatim}
alias date ! date
\end{verbatim}
@ifhelp
@endif
at the interactive command line, to avoid that the `!' be interpreted
by the history functions.
When called without arguments, {\tt alias} will list all the current
aliases. For obvious reasons, it is not allowed to {\tt alias} {\it
unalias}. {\tt alias} also supports the command abbreviation character
`!'. To enter a `!' without having it interpreted by the history
functions, just {\tt set noexpand} for the time entering the command.
When a `!' is part of the alias name this indicates that the alias
command name can be abbreviated down to that point. Since the {\tt \&}
operator is used to refer to the native commands, it is therefore
forbidden to start an alias name by character '\&'.
\Syntax
\bq alias {\it command} {\it command-list} \eq
\Examples
\nopagebreak\begin{verbatim}
alias mv !mv
alias . quit
alias da!te !date
\end{verbatim}
\Seealso
\bq !, \&, macro, unalias, set expand \eq
@ifhelp
?append
@else
\section{append and save}
@endif
The {\tt append} command can be used to append various things to an
existing file. If the file does not already exists, it will be
automatically created.
The {\tt save} command can be used to save various things to a file.
If a file with the same name already exists, it will be overwritten
without any warning.
@ifhelp
?append history
?save history
@else
\subsection{append history}
@endif
History can be saved or appended to a file. Any file saved this way
can later be executed by the {\tt load} command. Note that {\tt append
history} will silently fail if the file does not exist.
\Syntax
\bq append history {\it filename}\\
save history {\it filename}\eq
\Seealso
\bq load, line editing, fmode \eq
@ifhelp
?append macros
?save macros
@else
\subsection{append macros}
@endif
All the current macros and aliases can be saved or appended to a file.
Any file saved this way can be subsequently {\tt load}ed at any time.
To avoid confusion between data files and script files we recommand
that you use the {\it .ft} extension for your script files.
\Syntax
\bq append macros {\it filename}\\
save macros {\it filename}\eq
\Seealso
\bq alias, unalias, load, show, macro, unmacro \eq
@ifhelp
?append parameters
?save parameters
@else
\subsection{append parameters}
@endif
Parameters can be saved into a file at any time. The number output
format will be the one chosen by the {\tt set format} command. The
column order will be a parameter followed by its standard deviation.
All columns are separated by a tab. Therefore, if one has previously
set parameters, i.e.
@ifhelp
@endif
\nopagebreak\begin{verbatim}
set parameters MYPAR 3
.
.
.
save parameters myfile
\end{verbatim}
@ifhelp
@endif
then there will be 6 columns as follows:
@ifhelp
@endif
\nopagebreak\begin{verbatim}
MYPAR[1] DMYPAR[1] . . . MYPAR[3] DMYPAR[3]
\end{verbatim}
@ifhelp
@endif
in file {\it myfile}. Most of the time, the user will desire to
save parameters along with some variables or constants. This can be
done by giving the variable or constant (either string or scalar)
names on the command line. For example,
@ifhelp
@endif
\nopagebreak\begin{verbatim}
let t = 0.23
set parameters A 2
.
.
.
save parameters t parfile
\end{verbatim}
@ifhelp
@endif
will create a file {\it parfile} containing the value of scalar
variable {\tt t}, followed by the 2 values of parameters {\tt A},
alternated with the value of their standard deviations {\tt DA}.
Note that the given list of variables will be printed first.
\Syntax
\bq append parameters {\it variable-list\optio} {\it filename}\\
save parameters {\it variable-list\optio} {\it filename}\eq
\Seealso
\bq set format, set parameters, show parameters\eq
@ifhelp
?append variables
?save variables
@else
\subsection{append variables}
@endif
Any variable or number of variables can be saved to a file at any
time. Vector elements referenced by an explicit index are considered
as variables. String variables and constants are recognized as well.
\Syntax
\bq append variables {\it variable-list} {\it filename} \\
save variables {\it variable-list} {\it filename}\eq
\Examples
\nopagebreak\begin{verbatim}
append variables x Y[3] a VECTOR[78] datafile1
save variables t PARAM[2] DPARAM[2] datafile2
\end{verbatim}
\Seealso
\bq load, cmode, let, C, show, auto \eq
@ifhelp
?append vectors
?save vectors
@else
\subsection{append vectors}
@endif
Any vector or number of vectors can be saved to a file. All the values
are written in columns separated by a tab. The number format will be
the one chosen by the {\tt set format} command. A it is the case
for the {\tt read} function, a range of values as [{\it low}:{\it high}]
or a range of lines as \{{\it low}:{\it high}:{\it increment}\} can be
specified as well. See {\tt read} for more details.
\Syntax
\bq append vectors {\it VECTOR-list} {\it filename}\\
save vectors {\it VECTOR-list} {\it filename}\eq
\Examples
\nopagebreak\begin{verbatim}
append vectors X Y ERROR1 TEST2 datafile1
save vectors TIME[0:1] TEMP DT datafile2
\end{verbatim}
\Seealso
\bq set format, set data, read, fit, fft, show, auto \eq
@ifhelp
?auto
@else
\section{auto}
@endif
The {\tt auto} keyword is used to define automatic variables. The type
of variable can be a scalar variable, a VECTOR or a String, depending
on the upper-lower case letters in the variable name. The scope of
auto variables is delimited by braces as in C. All auto variables are
stored on the stack and are freed when the scope of the variable is
left. Definition of variables can only be done right after a brace has
been opened. Only scalar variables can be assigned as the are defined,
while vectors are assigned to zero, and strings are empty. Contrarily
to C, automatic scalar variables are set to zero if not assigned.
{\tt auto} is a C-calculator mode keyword.
\Syntax
\bq auto {\it var-list} \eq
\Examples
\nopagebreak\begin{verbatim}
# Some dummy examples
set data 100
cmode
x = y = 1 # These (x, y) are global
X = y++ # As well as vector X
{ auto x=2, X, Y # All these variables are local...
X=3; Y=sin(x)
.
.
.
} # ...and stop existing here
x # This x still contains 1
# An example with a procedure
proc test(x) {
auto y=2
z = x + y++ # This z is global
}
fmode
\end{verbatim}
\Seealso
\bq C, cmode, func, proc\eq
@ifhelp
?break
@else
\section{break}
@endif
The {\tt break} keyword is used as in C to break C-calculator mode
{\tt for} or {\tt while} loops. {\tt break} is a C-calculator mode
command.
\Syntax
\bq break \eq
\Seealso
\bq C, continue, cmode, for, while \eq
@ifhelp
?C
@else
\section{C}
@endif
The following gives a brief description of the supported C-calculator
syntax and differences with standard C.
The following operators are recognized, in order of precedence:
@ifhelp
@endif
\nopagebreak\begin{verbatim}
++, -- (post and pre) increment-decrement
-, ! unary minus and logical NOT
^ exponentiation, right associative
/, *, % division, multiplication, modulo
+, - addition, subtraction
>, >=, <, <=, ==, != relational operators
&& logical AND
|| logical OR
=, +=, -=, /=, *= assignments, right associative
\end{verbatim}
All operators are left associatives except those specified.
They are all common to C except for the exponentiation operator.
The following keywords are reserved tokens: {\tt auto, if, else, while,
for, break, continue}, and {\tt return}, plus two extra keywords {\tt
proc, func}. They roughly obey the same syntax as in C so that statements
like:
\bq if ({\it conditions})\\
{\it cmode-line-statement}\\
{\it required empty line}\eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq if ({\it conditions}) {\it cmode-line-statement} \eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq if ({\it conditions}) \{\\
{\it cmode-statements}\\
\}\eq
Note that the absence of command delimiter (i.e. ';') requires the
presence of a trailing empty line in the first form.
The same thing is true for the else constructions {\tt else} of which
some examples follow:
\bq if ({\it conditions}) \\
{\it cmode-line-statement}\\
else\\
{\it cmode-line-statement}\eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq if ({\it conditions}) \{\\
{\it cmode-statements}\\
\} else \{\\
{\it cmode-statements}\\
\}\eq
Here {\it cmode-line-statement} means any semicolon separated list
of C-calculator mode statements typed on the same line. Since
semicolons are separators and not terminators, empty statements are
defined by empty braces {\tt \{ \}}.
The {\tt return} keyword must have parentheses when returning a value
from a function as in {\tt return(x * sin(y))}. A single {\tt return}
will only be recognized from within a procedure.
To avoid potential confusion with variables, keywords cannot be
abbreviated.
As opposed to C, there exists no integer in the C-calculator mode. All
scalar variables and numbers are double precision. This means that
logical true is 1.0 and false is 0.0. As in C, one must be careful
with comparison operators. The C {\tt switch} syntax is not supported
(would require integers).
As an extension, string comparison is possible with the equality
operators `==' and `!='. This will return true or false if the string
variables (or constants) are identical or not. Assignments of string
variables actually copies all characters of the string on the RHS to
the string variable on the LHS. String additions and subtractions are
also possible.
Function and procedure definitions are defined with prototypes, i.e.,
a list of variables representing the proper kind of variable. At
run-time, the arguments of the function are checked for type
compatibility and for their number.
All variables are global except automatic variables defined using the
{\tt auto} keyword.
\Seealso
\bq cmode, let, math, scan, strings, auto \eq
@ifhelp
?cd
@else
\section{cd}
@endif
The {\tt cd} command changes the working directory. Called with no
argument, {\tt cd} will bring you to your \$HOME directory. Note that
{\tt cd} changes the current working directory of \fudgit\ only.
Therefore, your plotting program will still be in the previous
directory. To get around this difficulty, you only have to define a
macro as follows, if your plotting program supports {\tt cd}:
@ifhelp
@endif
\nopagebreak\begin{verbatim}
macro Cd 1
pmode cd "$1"
&cd $1
stop
alias cd Cd
\end{verbatim}
\Syntax
\bq cd {\it filename\optio}\eq
\Examples
\nopagebreak\begin{verbatim}
cd
cd /nazgul/users/fulano
\end{verbatim}
\Seealso
\bq \&, pwd, alias\eq
@ifhelp
?cmode
@else
\section{cmode}
@endif
The {\tt cmode} command allows you to go in the C-calculator mode. The
only way to come back to the main fitting mode is by using the {\tt
fmode} command or to type \^{ }D in interactive mode. Commands cannot
be abbreviated in {\tt cmode}. Parallel to the {\tt cmode} command,
the {\tt let} command can be used to pass one single command, or
command line to mathematical parser. To be consistent with {\tt pmode}
command, {\tt cmode} also accepts arguments in which case it is
equivalent to the {\tt let} command. It is not an error to call {\tt
cmode} from the C-calculator mode. A warning message will be given
though.
\Syntax
\bq cmode {\it command-list\optio}\eq
The C-calculator mode supports most of C syntax (see item C), and most
of the C math library. Thus, the following functions are supported:
@ifhelp
@endif
\nopagebreak\begin{verbatim}
trigo: hyperbolic: expo: special: conversion: random:
cos() cosh() ln() besy0() trunc() srand()
cot() coth() log() besy1() floor() rand()
csc() csch() exp() besj0() ceil()
sec() sech() sqrt() besj1() rint()
sin() sinh() cbrt() besjn() abs()
tan() tanh() besyn() int()
acos() acosh() erf() scan()
asin() asinh() erfc() min()
atan() atanh() lgamma() max()
atan2() interp() sum()
vread()
\end{verbatim}
Any upper case variable (possibly including `\_') possibly mixed with
digits will be recognized as a vector, e.g., {\tt TEMP\_2, TEST, D},
etc. Any lower case name will be taken as a scalar variable, e.g.,
{\tt x, t4}, etc. There are two predefined constants, {\tt pi} $=\pi$
and {\tt e}$=e$, which should not be unlocked and modified. As well,
the built-in constant {\tt data} contains the current size of the
vectors and can be modified through the {\tt set data} command, by the
{\tt read}/{\tt exec} commands, or by {\tt unlock}ing the constant and
modifying it directly. The built-in constant {\tt chi2} contains the
value of $\chi^2$ as obtained from the latest fit. And finally, the
built-in scalar constant {\tt param} contains the number of parameters
as defined by {\tt set parameters}.
A mix of upper case and lower case letters will serve to indicate a
string variable. Strings values are indicated by double quotes as in
C. Unlike C, \fudgit\ considers strings as self-contained objects that
can be added, subtracted, and checked for (in)equality. Thus, string
objects (i.e. string variables, string constants and string values)
can: serve as argument to {\tt scan} function; be part of string
assignment statements or of a truth statement involving (in)equality
operator; be added (concatenated using the `+' operator) one with
another; be subtracted (remove string termination using the `-'
operator) one with another; and finally be argument of string
functions.
A predefined string constant called {\tt Tmp} contains the string
"/tmp/fudgitPID" where PID is the process id number of the current
process. This file, and any file belonging to you, whose name starts
with the same string, will be erased automatically by the {\tt exit}
or {\tt quit} commands. This string is typically used by the {\tt
gnuplot} macro in order to pass data to the \gnuplot\ plotting program
which cannot read data from standard input. Another predefined string
constant is {\tt ReadFile} which contains the last data filename that
has been loaded. Finally, the string constant {\tt Cwd} is made
available in order to get the current working directory.
The following table contains all the built-in constants.
@ifhelp
@endif
\nopagebreak\begin{verbatim}
chi2 Value of chi^2 from the last fit;
data Length of all vectors (< samples) as set by set data;
e Neperian number;
param Number of parameters as set by set parameters;
pi Guess this one;
Cwd Current working directory;
ReadFile The last file (program) read by read (exec);
Tmp A temporary filename "/tmp/fudgitPID";
\end{verbatim}
Constants (either strings and scalars) can also be created by {\tt
lock}ing a variable. In the same manner, a constant can be modified
directly if it has been {\tt unlock}ed.
The algebraic operations applicable to scalar variables can be applied
to vectors. Vector algebra can be mixed with scalar variable algebra
in which case the user has to take the implied loop into account. For
example, although the following operation is not standard C
programming:
@iftex
\footnote
@else
@endif
{NOTE: In order to show that some commands can be typed from both
C-calculator mode and the fitting fmode, the following examples shows
the typing mode from the first line. However, one can always type the
same C-calculator mode command from the fitting mode by using the {\tt
let} command (or {\tt cmode} command).}
@ifhelp
@endif
\nopagebreak\begin{verbatim}
cmode
x = 0
X = x++
\end{verbatim}
@ifhelp
@endif
will define a vector $X$ of size {\tt data} (see {\tt set data})
ranging from $X[1]$ to $X[data]$ and taking values from 0 to
$data-1$. Multiple commands can be given with the separator `;', for
example, another version of the previous command could be written
@ifhelp
@endif
\nopagebreak\begin{verbatim}
cmode
x=0;X=++x
\end{verbatim}
@ifhelp
@endif
in which case a vector $X$ taking values from 1 to $data$ will be
created. (Note that the latter uses a pre-increment whereas the
former uses a post-increment operator on {\tt x}: results are thus
different). Vector elements can be referenced by elements using
standard C grammar. Therefore, the same vector could be created by
using a {\tt while} construction as in:
@ifhelp
@endif
\nopagebreak\begin{verbatim}
fmode
set data 1000
let X=0;i=0
cmode
while (i++ <= data)
X[i] = i
fmode
\end{verbatim}
@ifhelp
@endif
or, using a {\tt for} loop,
@ifhelp
@endif
\nopagebreak\begin{verbatim}
cmode
for (x=0;x<=data;x++) {
X[x] = x
}
fmode
\end{verbatim}
Noninteger variables will be truncated to the nearest lower integer to
form a vector index.
@ifhelp
@endif
\nopagebreak\begin{verbatim}
cmode
y= 2.01
x=2.23; X[2]=Z[y]+5^x
\end{verbatim}
Assigning a vector to a constant will assign all the elements to that
constant.
@ifhelp
@endif
\nopagebreak\begin{verbatim}
fmode
let X = pi
let Z2 = 0
\end{verbatim}
The C-calculator checks for undefined variables on the RHS of any
assignment. From C-calculator mode, variables values can be seen by
typing the variable name by itself or by using the {\tt print}
command, if the output is selected to be {\it stdout}. From the
fitting mode, contents of constants and variables (either strings or
scalars) is displayed using {\tt show variables} command, or by using
the `\$' expansion operator. However, vectors can be only be seen from
the fitting mode by using the {\tt show vector} command.
Each unknown vector name given on the command line allocates a vector
of {\tt sample} size.
To be a calculator as such, the C-calculator prints the value of the
expression given on the command line. Thus, the statement
@ifhelp
@endif
\nopagebreak\begin{verbatim}
cmode
x + 2
\end{verbatim}
@ifhelp
@endif
will print the value of $x + 2.0$. The contents of many variables can
be displayed at the same time by giving a coma separated list such as
in
@ifhelp
@endif
\nopagebreak\begin{verbatim}
cmode
x,"temperature", t
\end{verbatim}
@ifhelp
@endif
where the string {\it temperature} will be printed between the values
of variables $x$ and $t$. Note that the C-calculator mode recognizes
strings by double quotes. Special characters such as '\verb+\n+' are
also legal in a string.
We conclude by giving some examples involving string variables:
@ifhelp
@endif
\nopagebreak\begin{verbatim}
fmode
let String = "new.file"
let x = (String == "new.file")
let y = ("file1" == "file2")
let Bing = "\a\a\a"
let Here = Cwd # Store the value of the current working directory
let Input = Read() # Read from stdin
let Test = FileName(ReadFile) - ".data"
let Dir = DirName(InputFile)
let y = scan(Read(), "%lf")
let File = "STRING_23.4"
let number = scan("%*[_A-Z]%lf", File)
let Message = "A tab \t and a newline\n"
\end{verbatim}
@ifhelp
@endif
where the truth statement could be legally used as a condition for an
{\tt if}, a {\tt while}, or a {\tt for}.
\Seealso
\bq let, C, data, func, proc, print, fmode, math, while, for, return,\\
auto, if, break, samples, quotes, strings\eq
@ifhelp
?comments
@else
\section{comments}
@endif
By default, anything following a `{\tt \#}' will be treated as a
comment and ignored. This holds for data files as well as for command
script files loaded with the {\tt load} command. This default can be
changed with the {\tt set comment} command. Sometimes a comment
character needs to be taken literally in a script file. The comment
character will be accepted as data if it follows the `\verb+\+' escape
operator, i.e. `\verb+\+\#', or, in the fitting mode only, whenever the
comment character is somewhere inside quotes or parentheses. The
comment character is always accepted literally when typed on the
interactive command line.
\Seealso
\bq set comment, read, load, show comment, exec \eq
@ifhelp
?continue
@else
\section{continue}
@endif
The {\tt continue} keyword has the same usage it has in C for sending
the control to the next iteration of a {\tt for} or {\tt while} loop.
{\tt continue} is a C-calculator mode command.
\Syntax
\bq continue \eq
\Seealso
\bq for, while, cmode, C \eq
@ifhelp
?datafiles
@else
\section{data files}
@endif
Files containing data are loaded by specifying the name of the data
file to the {\tt read} command. Data files should contain one data
point per line. A data point can be a 256 dimensional object. By
default, anything following character `{\tt \#}' will be treated as
comment and ignored. In all cases, the numbers on each line of a data
file must be separated by any number of blank spaces or tabs. These
blanks divide each line into columns. Thus, \fudgit\ can handle up to
256 columns per line. Warning will be given if a line has a different
number of columns. Strings such as {\it NaN} or {\it Infinity} are
recognized and refused. The default compilation gives a maximum line
size of 1024 characters.
\Seealso
\bq read, exec, set comment \eq
@ifhelp
?echo
@else
\section{echo}
@endif
The {\tt echo} command allows the user to print a string to the
standard output. If no argument is given {\tt echo} will only print a
newline. This command can be used to display a message or, when
coupled with the variable expansion operator `\$', to see the value of
a printable (either string or scalar) variable defined in the
C-calculator. The "-n" option prevents the output of the ending newline.
\Syntax
\bq echo -n\optio {\it string-list}\eq
\Examples
\nopagebreak\begin{verbatim}
echo Starting the fit
echo $Mydir
echo -n "Hello: "
\end{verbatim}
\Seealso
\bq cmode, \$ \eq
@ifhelp
?else
@else
\section{else}
@endif
The {\tt else} keyword is used in {\tt if} constructions, both in
C-calculator anf fitting modes. Refer to the {\tt if} entries for a
complete description.
@ifhelp
?end
@else
\section{end}
@endif
The {\tt end} command is used to complete a {\tt foreach} loop or a
{\tt while} loop. Keyword {\tt end} is also used to tell {\tt read}
that we are finished writing data to stdin. This command should always
be found on a line by itself (comments are allowed though).
\Seealso \bq foreach, while, read, stop\eq
@ifhelp
?endif
@else
\section{endif}
@endif
The {\tt endif} command is used to complete an {\tt if} construction
in fitting mode. Keyword {\tt endif} must always be used on a line by
itself (comments are allowed though). Refer to the {\tt if} entries
for a the complete description.
@ifhelp
?environment
@else
\section{environment}
@endif
\fudgit\ is sensitive to the following environment variables:
$\bullet$ PAGER for the program called to format long listings.
$\bullet$ HOME for the directory to which {\tt cd} defaults.
$\bullet$ SHELL for the shell called by {\tt system} when this
latter is called without arguments.
If not defined, the default pager is {\it /usr/?/more} (path depends
on system) and the default shell {\it /bin/csh}.
\Seealso
\bq cd, system, show vectors, help \eq
@ifhelp
?exec
@else
\section{exec}
@endif
The command {\tt exec} executes a program and reads data from it. It
supports the same syntax {\tt read} does except that the program name
replaces the file name. A program is a program name or anything that
can be typed in a shell. If the command line has more than one string,
it must be glued with quotes. On a successful call, {\tt exec} will
set the string constant {\tt ReadFile} to the name of the program
which generated the data.
\Syntax
\bq exec {\it commands} {\it assignment$[$range$]$\optio\{linerange\}\optio} \ldots\eq
\Examples
\nopagebreak\begin{verbatim}
exec simulate X Y[0:200]
exec simulate X:1 Y:2[0:200]
exec "cat data | myfilter -g" X1:1[0:*] X2:2 X3:4
\end{verbatim}
\Seealso
\bq read, comments\eq
@ifhelp
?exit
@else
\section{exit}
@endif
The commands {\tt exit} and {\tt quit} will exit \fudgit.
See details under item {\tt quit}.
\Syntax
\bq exit\eq
\Seealso
\bq quit, cmode \eq
@ifhelp
?fft
@else
\section{fft}
@endif
The {\tt fft} command will take the Fourier transform of the specified
vectors and put the real part in a vector specified by the third
argument. The imaginary part will be put in a vector specified by the
fourth argument. Input vectors can be used for output. The resulting
vectors will contain frequencies ranging from 0 to $N/2$ followed by
$-(N/2 - 1)$ to $-1$ in units of $1/(N*\Delta)$ where $\Delta$ is the
sampling rate. If a real vector is transformed $h(t) -> H(f)$, we
should have $H(-f) = H^*(f)$. Therefore, with $H = R + iI$ and
$H^* = R - iI$ be the transformed vectors, we should have
$R(-f) = R(f)$ and $I(-f) = -I(f)$, where $f$ is discrete and ranges
as mentioned above. In terms of vector indices, these relations
become $R[i] = R[N-i+2]$ and $I[i] = -I[N-i+2]$ for $1 < i < N/2$ in
addition to the fact that $I[1] = I[(N/2)+1] = 0$. Therefore, because
the negative frequency part is the mirror image of the positive one,
it is common to plot only the positive frequencies of the Fourier
transform of a real vector. This can be done by reducing {\tt data} to
half its value.
Because of the use of a FFT algorithm, the number of data points must
be an integer power of 2. If not, the user should pad the vector with
zeros up to the next largest power of two. Each transform is
normalized by the factor $\sqrt{(N)}$ so that {\tt fft RE IM T\_RE T\_IM}
followed by {\tt invfft T\_RE T\_IMA RE2 IMA2} will not introduce a
factor $N$ in vectors {\tt RE2} and {\tt IMA2} (i.e., {\tt RE} = {\tt RE2}
and {\tt IM} = {\tt IM2}). At his choice, the user can use the
C-calculator functionality in order to implement windowing.
The power spectrum can be obtained from:
@ifhelp
@endif
\nopagebreak\begin{verbatim}
fft RE IMA T_RE T_IMA
let POW = T_RE^2 + T_IMA^2
\end{verbatim}
@ifhelp
@endif
where $POW[i]$ will contain the power value associated with frequency $f$,
which goes from 0 to $N/2$ followed by $-(N/2 - 1)$ to $-1$ (in units
of $1/(N*\Delta)$) as $i$ goes from 1 to $N$.
\Syntax
\bq fft {\it real-VECTOR} {\it ima-VECTOR} {\it real-VECTOR} {\it ima-VECTOR}\eq
\Examples
\nopagebreak\begin{verbatim}
# real vector X
let IM=0
# re-use IM vector for output
fft X IM Z IM
# complex vectors X+iY where i = sqrt(-1) transformed in V+iW
fft X Y V W
\end{verbatim}
\Seealso
\bq invfft, smooth, cmode, let, read, math, data \eq
@ifhelp
?fit
@else
\section{fit}
@endif
The {\tt fit} command is used to fit a function, chosen by {\tt set
function}, to a pair of vectors containing the independent and
dependent variables. Depending on the type of fit, selected by the
{\tt set method} command, a third vector containing the standard
deviation might be required. {\tt fit} allocates a vector having the
name of the dependent variable appended with the string {\tt FIT}.
This vector contains the computed values of the function for the given
independent vector. Depending on the method, the built-in constant
{\tt chi2} will contain the value of the mean square deviation
weighted by vector {\it $\sigma$-VECTOR} or the mean absolute deviation.
\Syntax
\bq fit {\it independent-VECTOR} {\it dependent-VECTOR} {\it $\sigma$-VECTOR}\eq
\Example
\nopagebreak\begin{verbatim}
fit X Y DY
\end{verbatim}
@ifhelp
@endif
will create a vector {\tt YFIT} containing the value of the fitted
function for each of the values of the independent vector {\tt X}.
Note that the standard deviation is required for most fitting routines
since it is used to weigh the value of local square deviation from the
fit (in fact, this is the definition of $\chi^2$). If {\it
$\sigma$-VECTOR} is unavailable just use
@ifhelp
@endif
\nopagebreak\begin{verbatim}
let DY=1
\end{verbatim}
@ifhelp
@endif
using the previous example. This simply gives the same weight to all
data points.
\Seealso
\bq set method, set function, show fit, show parameters, append\eq
@ifhelp
?fmode
@else
\section{fmode}
@endif
The {\tt fmode} command allows you to return to the fitting mode, when
the program is in one of the C-calculator or plotting modes. The
fitting mode, is the main mode of the program. The two other modes are
the C-calculator mode, accessed by the {\tt cmode} command, and the
plotting mode, accessed by the {\tt pmode} command. When used
interactively, \^{ }D returns to the fitting mode from either of the
C-calculator mode or from the plotting mode. It is not an error to
call {\tt fmode} from the fitting mode. A warning message will be
given though.
\Syntax
\bq fmode\eq
\Seealso
\bq cmode, pmode, let\eq
@ifhelp
?for
@else
\section{for}
@endif
The {\tt for} command is a C-calculator mode command. It behaves
roughly like a standard C {\tt for} construction. In interactive
mode, any new input line will be prompted with a ``n\{\ldots n\verb+\t+''
where `n' stands for the nesting level and `\verb+\t+' for a tab.
Keyword {\tt for} is a C-calculator mode command.
\Syntax
\bq for ({\it init-expressions}; {\it cond-expressions}; {\it loop-expressions}) \\
{\it cmode-line-statement}\eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq for ({\it init-expressions}; {\it cond-expressions}; {\it loop-expressions}) \{\\
{\it cmode-statements}\\
\}\eq
\Examples
\nopagebreak\begin{verbatim}
cmode
for (i=1,j=2;i+j <= data; i+=2,j+=3) A[i] = X[j]
fmode
# Another example:
# A macro to remove point x in a vector. Syntax: delete "vector" "index"
macro delete 2
cmode
for(i=$2;i<data;i++) {
$1[i] = $1[i+1]
}
fmode
unlock data
let data--
lock data
stop
\end{verbatim}
\Seealso
\bq C, break, continue, cmode, if, set data, func, proc, if, lock, math \eq
@ifhelp
?foreach
@else
\section{foreach}
@endif
The {\tt foreach} command loops through the strings obtained from a
given \unix\ command. Wild card characters are allowed since
everything following the {\tt in} keyword is passed to a Bourne shell
for execution. Strings can be obtained from any program including the
easiest cases {\it echo, ls} and {\it cat}. The variable name must be
of string type, i.e., consisting of both upper case and lower case
letters (and possibly \_'s and digits).
\Syntax
\bq foreach {\it StringVarName} in {\it \unix-command}\\
{\it body of the loop}\\
end\eq
\Example
\nopagebreak\begin{verbatim}
#convert columns 2 and 3 of the following files in log-log format
foreach Fname in ls data*.7[0-9] datatest.42 data*.8[4-7]
echo $Fname ...
read $Fname X:2[0.001:*] Y:3[0.001:*]
let X = log(X)
let Y = log(Y)
save vectors X Y $Fname.log
end
\end{verbatim}
\Seealso
\bq for, math function scan, while, macro \eq
@ifhelp
?free
@else
\section{free}
@endif
The command {\tt free} is made available for memory management. It is
used to free vectors, variables, functions, procedures, and numbers
that were allocated in the C-calculator mode.
When called with the special argument ``@all'', {\tt free} will erase
all the user vectors, numbers and variables, as well as all active
functions and procedures (not macros and aliases). When called with
the special argument ``@allvec'', {\tt free} will only erase
vectors. Note that {\tt set samples} internally calls {\tt free @allvec}.
In other cases, {\tt free} will free the specified vector(s) or
variable(s). Constants (either scalar or string) cannot be removed
without first unlocking them.
\Syntax
\bq free {\it VECTOR- or variable-list} \\
free @all\\
free @allvec\eq
\Examples
\nopagebreak\begin{verbatim}
free @all
free @allvec x MyString
free X y TEMP
\end{verbatim}
\Seealso
\bq unlock, C, cmode, show table, show memory, samples, let \eq
@ifhelp
?func
@else
\section{func}
@endif
The {\tt func} command defines a function. A function is distinct from
a procedure from the fact that a function must return a value whereas
a procedure must not. Arguments are given in the definition with any
name prototype representative of the data type. As in C, the argument
list must be comma separated when calling the function (after having
defined it). An example follows. {\tt func} is a C-calculator mode
command.
The prototype list defines the type of variable to be used. Although
all global variables are accessible from within the function,
variables are always searched for from the prototype list first, then
from the local list ({\tt auto} variables), and finally from the
global list. All scalar variables are passed by value: thus any scalar
expression is legal as scalar argument. String arguments and vector
arguments are passed by pointer: thus string and vector arguments must
refer to a variable explicitly. The {\tt show table} can be used to
list all the installed objects at a given time.
\Syntax
\bq func {\it functionname}({\it proto-list\optio}) {\it cmode-line-statement}; return({\it value})\eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq func {\it functionname}({\it proto-list\optio}) \{\\
{\it cmode-statements}\\
return({\it value})\\
\}\eq
\Examples
\nopagebreak\begin{verbatim}
# The following example will print the factorial of all integers up to 120.
cmode
func fac(x) { # This `x' is a prototype: it does not exist.
if (x <= 0) {
return(1)
} else {
return(x * fac(--x))
}
}
x=1 # This `x' is a global scalar variable
while (x<120) {
fac(x++)
}
fmode
# The following calculates the average of a vector
cmode
func avg(X) {
auto i,x
for (x=0,i=1;i<=data;i++) {
x += X[i]
}
return(x/data)
}
fmode
\end{verbatim}
\Seealso
\bq C, return, for, while, cmode, math, free, proc, show table, install \eq
@ifhelp
?help
@else
\section{help}
@endif
The {\tt help} command displays on-line help. To specify information on a
particular topic use the syntax:
\bq help {\it topic}\eq
If {\it topic} is not specified, a short message is displayed about
\fudgit. Topic names can be abbreviated down to the shortest
unambiguous string. In case of doubt, {\tt help} will print out all
possible completions. Thus, {\tt help f} will print all help topics
starting with the letter `f'. After help for the requested topic has
been given, help for a subtopic may be requested by typing the
subtopic name, extending the help request. After that subtopic help
has been displayed, the request may be extended again, or pressing
return will return one level back to the previous topic. Eventually,
the fitting mode prompt will return.
\Seealso
\bq help? \eq
@ifhelp
?history
@else
\section{history}
@endif
The {\tt history} command lists all the previous command lines, along
with a number. History lines can be called using the !{\it string}
construction or the !{\it number}. History is only available in
interactive mode. See Appendix A for more details.
\Syntax \bq history\eq
\Seealso
\bq append history, line editing \eq
@ifhelp
?if
@else
\section{if}
@endif
There are two kinds of {\tt if} constructions available in \fudgit,
one in the fitting mode and the other in the C-calculator mode.
@ifhelp
?if cmode_style
@else
\subsection{C-calculator mode if}
@endif
In C-calculator mode, {\tt if} and {\tt else} are reserved keywords.
C-calculator mode {\tt if} construction is similar to the one in
standard C. Note that {\it cmode-statements} refers to any sequence of
C-calculator mode commands and that {\it cmode-line-statement} refers
to a semicolon separated list of C-calculator mode commands typed on
the same line.
\Syntax
\bq if ({\it conditions}) {\it cmode-line-statement}\eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq if ({\it conditions})\\
{\it cmode-line-statement}\\
{\it required newline}\eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq if ({\it conditions}) \{\\
{\it cmode-statements}\\
\}\eq
@ifhelp
@endif
Note that the first form requires the presence of a trailing empty
line. I recommand using braces to avoid confusion.
Using the {\tt else} constructions, this becomes
@ifhelp
@endif
\bq if ({\it conditions})\\
{\it cmode-line-statement}\\
else\\
{\it cmode-line-statement}\eq
@ifhelp
@endif
or, for statements on more than one line,
@ifhelp
@endif
\bq if ({\it conditions}) \{\\
{\it cmode-statements}\\
\} else if ({\it conditions}) \{\\
{\it cmode-statements}\\
\} else \{\\
{\it cmode-statements}\\
\}\eq
\Seealso
\bq C, cmode \eq
@ifhelp
?if fmode-style
@else
\subsection{Fitting mode if}
@endif
Fitting mode {\tt if} has a syntax very similar to the one in C-shell.
It requires the keywords {\tt then} and {\tt endif} and supports {\tt
else} constructions. The difference resides in the fact that the
conditional statement has to follow C-calculator mode grammar and
syntax and thus has a richer set of operators. The `\$' expansion
operator is therefore not needed in the conditional statement, as it
is in C-shell conditional statements. All active variables, constants,
and their string counterparts, are directly available to the
conditional statement. Note that the {\it fmode-statements} can also
contain C-calculator mode commands (even possibly including
C-calculator mode {\tt if}'s!).
\Syntax
\bq if ({\it conditions}) then\\
{\it fmode-statements}\\
endif\eq
@ifhelp
@endif
or, using the {\tt else} constructions,
@ifhelp
@endif
\bq if ({\it conditions}) then\\
{\it fmode-statements}\\
else if ({\it conditions}) then\\
{\it fmode-statements}\\
else\\
{\it fmode-statements}\\
endif\eq
\Seealso
\bq while, foreach, macro\eq
@ifhelp
?in
@else
\section{in}
@endif
The {\tt in} keyword is required in {\tt foreach} constructions in
fitting mode. Refer to the latter for details.
@ifhelp
?install
@else
\section{install}
@endif
The {\tt install} command dynamically loads defined routines from an
object file. The user decides on the internal name of the routine but
the internal name must consist of lower case letters only. The object
file is an object compiled by the C or FORTRAN compiler. On IRIX, the
object must be compiled with the option {\tt -G 0} given to either the
C or FORTRAN compiler. On SVR4, the object must be compiled with the
{\tt -G} option and the GNU compiler cannot be used to link the shared
object. The {\it rtn-name} is the name of one of the
procedure(s) or function(s) the user wants to install from the
object file. The routine will be installed as {\it name} and as a
procedure (not returning value) or as a function (returning value)
depending on the name separator being a {\tt :} (colon) or a {\tt =}
(equal sign) respectively. (See example below).
NOTE: This option is only available on IRIX, SVR4 and SUNOS for the moment.
The external routine must expect pointers to double for all its
arguments. Thus, all arguments are passed by pointers except that
pointers to variables do not point to the variables as such but to a
temporary copy of them. This allows us to have expressions like
{\tt f = mycall(X, sin(x) + 1, data)}
for which the value {\tt sin(x) + 1} must necessarily be a temporary copy.
In this example, the prototype is a function {\tt mycall(VEC, expr, expr)}.
We shall consider an example in more detail below. All arguments are
strongly typed as vector, parameter, expression or string. Prototyping
is done using the uppercase-lowercase convention. Parameters are prototyped
using the word {\tt PARAM} or less (e.g. {\tt PAR}).
On IRIX, the linker will create a binary file built from the module
name and with the extension {\it file}.{\tt ld}. This binary is the
one that will be loaded in memory. Time stamps are included so that
{\tt ld(1)} will not be called if not necessary. These files are not
erased at exit, since they are reusable and prevent the linker to be
called if nothing changed between two sessions of \fudgit.
On SVR4 an object is created as normal with {\tt cc -c} or {\tt gcc -c}
and then linked to yield a shared object using {\tt cc -G}---the GNU C
compiler {\it cannot} be used for the linking phase. Objects which
reference external libraries should be linked with these libraries
{\tt cc -G ... -llib1 -llib2 ...}. In particular FORTRAN libraries should
be linked in this fashion.
Successive calls of {\tt install} with the same module should not be
done unless the same functions and procedures are reinstalled. If this
is the case, the user should then reinstall the same modules (that
could have been modified and recompiled in the mean time) using the
{\tt reinstall} command. If a module is reinstalled with different
routines or function or procedure names, the previously defined
functions or procedures might not be properly installed anymore and
calling them might result in an undefined behavior.
The file {\it fudgit.h} describes the functions user-defined programs
can linked with. Among other things, these functions allow the user to
have elegant error handling and exit.
The {\tt show table} command can be used to list all the installed
objects at a given time.
A file having the same base name of the module but with the extension
{\it libs} can be put in the same directory in order to include extra
libraries while loading the module. On IRIX, these extra libraries
must all contain objects compiled with the flag {\it -G 0} (see {\tt
cc(1)}). (For example, some IRIX systems have a -lm\_G0 math
library.) User-defined libraries can be specified along with system
libraries. A typical example could be a line like:
\bq /home/myname/myproject/libmyG0.a /usr/lib/libmG0.a \eq
for linking with user's library {\it /home/myname/myproject/libmyG0.a}.
Equivalently, for non-IRIX systems, loading a FORTRAN object might
require something like this:
\bq /usr/lib/libF77.a /usr/lib/libm.a \eq
Library names can be on multiple lines. However, the file cannot have
more than 1024 bytes. A `{\tt \#}' found anywhere in this file will make
the rest of the file to be ignored.
Note that when loading FORTRAN code, the user must append an underscore
to the routine name so that {\tt install} or {\tt reinstall} can find it.
The IRIX version does not fully support incremental linking, i.e., to
use, in an object to be installed, symbols that were defined in
previously {\tt install}ed objects. However, all the symbols contained
in the original \fudgit\ executable remain at all time available to
all linked routines. Therefore, IRIX users should make sure that
external objects are self-contained and only reference to external
routines that are intrinsic to \fudgit\ or come directly (and once)
from linked libraries at installation time.
\Syntax
\bq install {\it object-file} {\it rtn-name}[:|=]{\it name}(arg-list)\ldots\eq
\Example
\nopagebreak\begin{verbatim}
hostname: cat mymodule.c
#include <math.h>
#include "fudgit.h"
/* An example of a user-defined routine inversing the order of an even
* vector. Typical call would be:
* myproc(A_VEC, data)
* from C-calculator mode. NOTE that both VEC and expr are pointers.
* To make things explicit, fudgit.h contains a few typedef's.
*/
void myproc(X, dn)
VEC X;
expr dn;
{
int i, half_n;
int n = (int)*dn; /* note that dn is a pointer to a double */
double tmp;
if (n%2 == 1) /* report error if odd number (Why not?)*/
fprintf(stderror, "%s: Called with an odd number %d.", "myproc", n);
/* You have full use of math and stdio libraries too!!! */
fprintf(stderr,
"BTW, Did you know that %lf is the sqrt(pi)?\n", sqrt(M_PI));
half_n = n >>1; /* half of n */
for (i=0;i<half_n;i++) { /* Standard C: indices from 0 to data-1 */
tmp = X[i];
X[i] = X[n-i];
X[n-i] = tmp;
}
}
/*
* Another example involving a function. The following calculates the
* non-normalized correlation between vectors A and B as defined by
* corr(A, B) = <A*B> - <A> * <B>
*
*/
double myfunc(A, B, dn)
VEC A, B;
expr dn;
{
int i, n = (int)*dn; /* Again, dn is a pointer to a double */
double sumA, sumB, sumAB;
sumA = sumB = sumAB = 0.0;
/* sum up the values of interest */
for (i=0;i<n; i++) { /* indices go from 0 to data-1 */
sumA += A[i];
sumB += B[i];
sumAB += A[i] * B[i];
}
/* leave it simple */
sumA /= *dn;
sumB /= *dn;
sumAB /= *dn;
return (sumAB - sumA*sumB);
}
hostname: cc -G 0 -O -c mymodule.c
hostname: cat loadex.ft
# This is an example for loading
# Install function myfunc as corr() and procedure myproc as inverse()
# Prototypes are made from any name representing the proper type:
install mymodule.o myproc:inverse(V, n) myfunc=corr(V, V, n)
set data 24
let x=1;X=x++
let Y=sin(X)
cmode
# Inverse order of vector X
inverse(X, data)
# Calculate correlation between X and Y
y=corr(X, Y, data)
# Print its value
"correlation:", y
fmode
hostname: fudgit loadex.ft
install: myproc installed as procedure inverse.
install: myfunc installed as function corr.
BTW, Did you know that 1.772454 is the sqrt(pi)?
correlation: 9.20717026e-01
\end{verbatim}
When linking FORTRAN functions or subroutines, the user must append an
underscore after every function or subroutine name. All argument
variables and vectors have to be defined {\tt double precision} as
well as returning functions. Typical examples are included in the
distribution in the {\it tools} directory.
\Seealso
\bq C, cmode, show table, func, proc \eq
@ifhelp
?invfft
@else
\section{invfft}
@endif
Command {\tt invfft} performs the inverse Fourier transform of the
given vectors. It assumes that the frequencies are ordered from 0 to
$N/2$ followed by negative frequencies ranging from $-(N-1)/2$ to $-1$
in units of $1/(N*\Delta)$ where $\Delta$ is the sampling interval.
The results are normalized by a factor $1/\sqrt{(N)}$ so that a
transform followed by an inverse transform should give the original
vector. The resulting vectors are stored in the third and fourth
arguments. Thus, {\tt invfft X Y V W} inverse transforms X+iY into
V+iW. Input vectors can be used as output vectors. See {\tt fft} for
more details.
\Syntax
\bq invfft {\it real-VECTOR} {\it ima-VECTOR} {\it real-VECTOR} {\it ima-VECTOR}\eq
\Seealso
\bq fft, smooth, cmode, let, read, math, data \eq
@ifhelp
?let
@else
\section{let}
@endif
The {\tt let} command opens the door to the C-calculator mode from the
fitting mode, but leaves the program in fitting mode. All the {\tt
let} commands can always be typed directly from the C-calculator mode
without having to prepend with the {\tt let} keyword. The converse is
also true; all the commands given in C-calculator mode could be typed
from the fitting mode by prepending them with the {\tt let} command.
Although {\tt let} is typed from the fitting mode, the remainder of
the line is parsed according to C-calculator mode rules, and thus
quotes are no longer swallowed. Variable expansion operator `\$' is
still recognized, but its use is not recommanded for C-calculator
statements. See `\$' for more details on this point.
\Syntax
\bq let {\it C-calculator-mode-commands}\eq
\Examples
\nopagebreak\begin{verbatim}
# generate the zero order first kind bessel
# function between (0, 2*pi]
fmode
set data 2000
let x=1; X=x++
let tmp = 2*pi/data # compute sequence only once
let X *= tmp
let Y = besj0(X)
\end{verbatim}
\Seealso
\bq cmode, C, math \eq
@ifhelp
?editing
?line
@else
\section{line editing and history}
@endif
The command shell supports line editing and history. The editing
commands are based on the basic \emacs\ commands. A short summary
follows but a more complete description can be found in Appendix B.
Line editing:
$\bullet$ \^{ }B moves back a single character.
$\bullet$ \^{ }F moves forward a single character.
$\bullet$ \^{ }A moves to the beginning of the line.
$\bullet$ \^{ }E moves to the end of the line.
$\bullet$ \^{ }H and DEL delete the previous character.
$\bullet$ \^{ }D deletes the current character.
$\bullet$ \^{ }K deletes from current position to the end of line.
$\bullet$ \^{ }L,\^{ }R redraws line in case it gets trashed.
$\bullet$ \^{ }U deletes the entire line.
$\bullet$ \^{ }W deletes the last word.
History:
$\bullet$ \^{ }P moves back through history.
$\bullet$ \^{ }N moves forward through history.
$\bullet$ !! previous command.
$\bullet$ !\$ previous command last argument.
$\bullet$ !{\it string} last command starting with {\it string}.
Completion:
$\bullet$ tab complete command if first arg, filename otherwise.
$\bullet$ esc-? or double tab list possible completions.
Each line of input must be smaller than 1024 bytes which is more than
sufficient for most applications. Lines can be continued on several
lines provided carriage returns follow a `\verb+\+' (as in standard
shells).
\Seealso
\bq append history, \$, history\eq
@ifhelp
?load
?source
@else
\section{load}
@endif
The {\tt load} command executes each line of the specified input file
as if it had been typed in interactively. Files created by the {\tt
save history} command can be {\tt load}ed directly. Text files
containing valid commands can be created and then executed by the {\tt
load} command. Files being {\tt load}ed may themselves contain {\tt
load} commands. See {\tt comment} for information about comments in
command scripts. The {\tt load} command is recursive so it can be
nested. The only limitation is the I/O stack which has a default
capacity of 32. This value can be easily changed at compilation time
of the program.
The current working directory always returns to the value in effect
before the loaded script was called. This is valid for nested {\tt
load} commands too.
In order to avoid confusion between data files and script files we
strongly recommand you to stick to the conventional {\it .ft} extension
for your script files.
\Syntax
\bq load {\it filename.ft}\eq
A {\tt load} command is also performed implicitly on any filenames
given as arguments to {\tt fudgit}, when called from your \unix\
session. These are loaded and executed in the order specified, and
then \fudgit\ exits.
\Seealso
\bq set comment, exec, startup, append history, append macros \eq
@ifhelp
?lock
?constant
@else
\section{lock}
@endif
Variables can be turned into constants using the {\tt lock} command.
Once a variable is {\tt lock}ed, any assignment trying to change its
value will result in a parsing error. This is valid for both scalar
and string variables. It is not an error to try to lock a constant. A
warning message will be given though. However, trying to lock an
unexisting variable or something else than a constant or variable will
result in an error.
\Syntax
\bq lock {\it var-list}\eq
\Seealso
\bq C, cmode, unlock \eq
@ifhelp
?ls
@else
\section{ls}
@endif
The command {\tt ls} calls ``/bin/ls -FC''. If any arguments are
given, those are passed to ``/bin/ls -FC''. Wild card characters are
possible since expansion is done by a Bourne shell.
\Syntax
\bq ls {\it ls-argument-list}\eq
\Examples
\nopagebreak\begin{verbatim}
ls p* test?
ls -l datafile
ls -l *.data
\end{verbatim}
\Seealso
\bq system, alias \eq
@ifhelp
?macro
@else
\section{macro}
@endif
The {\tt macro} command allows the user to define macros. Macros can
be embedded, but another macro cannot be defined from within a macro,
mainly because of their common way to refer to arguments. The name of
the macro followed by the number of arguments required must be given.
The maximum number of arguments a macro can have is 16. An exclamation
mark in the macro name will indicate that the macro name can be
abbreviated and that the characters following the exclamation point
are optional. Macros are only recognized in the fitting mode. The
total length of each macro is limited to 2048 bytes in size. Macros
can be nested to a maximum of 32. Macros are only recognized from the
fitting mode.
\Syntax
\bq macro {\it macroname} {\it argument-number}\\
{\it body of the macro}\\
stop\eq
\Example
\nopagebreak\begin{verbatim}
# define a macro named fpl!ot (o, t, are optional)
# requiring 3 arguments . Uses the plotting program gnuplot.
# Syntax: fplot X Y YFIT
# plot X Y with data points and X YFIT with solid line
macro fpl!ot 3
# save vectors in temp file (will be automatically removed on exit)
save vec $1 $2 $3 $Tmp.fplot
# plot second column with points and third with line
pmode plot '$Tmp.fplot' us 1:2 wi point, \
'$Tmp.fplot' us 1:3 wi line
stop
\end{verbatim}
\Seealso
\bq append macros, show macros, load, startup, unmacro, alias, unalias \eq
@ifhelp
?math
@else
\section{math functions}
@endif
The C-calculator mode math functions found in \fudgit\ are very close
to the corresponding functions found in the \unix\ math library. Some
other functions, not found in the math library, are also part of
\fudgit. Most of the numerically unstable functions (i.e. ln, log,
exp,\ldots) check for both an argument out of range and a value out of
domain at each call. All math functions are double precision and can
only be called from the C-calculator mode, or by using the {\tt let}
command from the fitting mode. These functions are also available in
the conditional statements of the fitting mode {\tt if} and {\tt
while}, since these statements are C-calculator mode statements,
although part of fitting mode constructions.
@ifhelp
?math abs
?abs
@else
\subsection{math function abs}
@endif
The {\tt abs()} function returns the absolute value of its argument.
@ifhelp
?math acos
?acos
@else
\subsection{math function acos}
@endif
The {\tt acos()} function returns the arc cosine (inverse cosine) of
its argument. {\tt acos()} returns its argument in radians.
@ifhelp
?math acosh
?acosh
@else
\subsection{math function acosh}
@endif
The {\tt acosh()} function returns the positive (principal) hyperbolic
arc cosine (inverse cosine) of its argument.
@ifhelp
?math asin
?asin
@else
\subsection{math function asin}
@endif
The {\tt asin()} function returns the arc sine (inverse sine) of its
argument. {\tt asin()} returns its argument in radians.
@ifhelp
?math asinh
?asinh
@else
\subsection{math function asinh}
@endif
The {\tt asinh()} function returns the hyperbolic arc sine (inverse
sine) of its argument.
@ifhelp
?math atan
?atan
@else
\subsection{math function atan}
@endif
The {\tt atan()} function returns the arc tangent (inverse tangent) of
its argument. {\tt atan()} returns its argument in radians.
@ifhelp
?math atan2
?atan2
@else
\subsection{math function atan2}
@endif
The {\tt atan2(y, x)} function returns the arc tangent (inverse
tangent) of the ratio of its arguments $(y/x)$. {\tt atan2()} returns
its argument in radians. The signs of $y$ and $x$ are used to
determine the quadrant.
@ifhelp
?math atanh
?atanh
@else
\subsection{math function atanh}
@endif
The {\tt atanh()} function returns the hyperbolic arc tangent (inverse
tangent) of its argument.
@ifhelp
?math besj0
?besj0
@else
\subsection{math function besj0}
@endif
The {\tt besj0()} function returns the j0th Bessel function of its
argument, i.e it returns the zero$^{th}$ order Bessel function of the
first kind. {\tt besj0()} expects its argument to be in radians.
@ifhelp
?math besj1
?besj1
@else
\subsection{math function besj1}
@endif
The {\tt besj1()} function returns the j1st Bessel function of its
argument, i.e it returns the first order Bessel function of the first
kind. {\tt besj1()} expects its argument to be in radians.
@ifhelp
?math besjn
?besjn
@else
\subsection{math function besjn}
@endif
The {\tt besjn(n, x)} function returns the jnst Bessel function of its
argument, i.e it returns the $n^{th}$ order Bessel function of the
first kind. {\tt besjn()} expects its second argument to be in
radians.
@ifhelp
?math besy0
?besy0
@else
\subsection{math function besy0}
@endif
The {\tt besy0()} function returns the y0th Bessel function of its
argument, i.e it returns the zero$^{th}$ order Bessel function of the
second kind. {\tt besy0()} expects its argument to be in radians.
@ifhelp
?math besy1
?besy1
@else
\subsection{math function besy1}
@endif
The {\tt besy1()} function returns the y1st Bessel function of its
argument, i.e it returns the first order Bessel function of the second
kind. {\tt besy1()} expects its argument to be in radians.
@ifhelp
?math besyn
?besyn
@else
\subsection{math function besyn}
@endif
The {\tt besyn(n, x)} function returns the ynst Bessel function of its
argument, i.e it returns the $n^{th}$ order Bessel function of the
second kind. {\tt besyn()} expects its second argument to be in
radians.
@ifhelp
?math cbrt
?cbrt
@else
\subsection{math function cbrt}
@endif
The {\tt cbrt()} function returns the cubic root of its argument.
@ifhelp
?math ceil
?ceil
@else
\subsection{math function ceil}
@endif
The {\tt ceil()} function returns the smallest integer that is not
less than its argument.
@ifhelp
?math cos
?cos
@else
\subsection{math function cos}
@endif
The {\tt cos()} function returns the cosine of its argument. {\tt
cos()} expects its argument to be in radians.
@ifhelp
?math cosh
?cosh
@else
\subsection{math function cosh}
@endif
The {\tt cosh()} function returns the hyperbolic cosine of its
argument.
@ifhelp
?math cot
?cot
@else
\subsection{math function cot}
@endif
The {\tt cot()} function returns the cotangent of its argument. {\tt
cot()} expects its argument to be in radians.
@ifhelp
?math coth
?coth
@else
\subsection{math function coth}
@endif
The {\tt coth()} function returns the hyperbolic cotangent of its
argument.
@ifhelp
?math csc
?csc
@else
\subsection{math function csc}
@endif
The {\tt csc()} function returns the cosecant of its argument. {\tt
csc()} expects its argument to be in radians.
@ifhelp
?math csch
?csch
@else
\subsection{math function csch}
@endif
The {\tt csch()} function returns the hyperbolic cosecant of its
argument.
@ifhelp
?math erf
?erf
@else
\subsection{math function erf}
@endif
The {\tt erf()} function returns the error function of its argument.
The error function is defined as
@iftex
\[ \frac{2}{\sqrt\pi} \int_0^x e^{-t^2} dt \]
@else
2/sqrt(pi) * integral from 0 to x of { exp(-t^2) dt }
@endif
@ifhelp
?math erfc
?erfc
@else
\subsection{math function erfc}
@endif
The {\tt erfc()} function returns {\tt 1 - erf()} where {\tt erf()} is
the error function of its argument. It is provided because of the
extreme loss of relative accuracy if {\tt erf(x)} is called for large
$x$ and the result subtracted from 1.0 (e.g., for $x = 10$, 12 places
are lost).
@ifhelp
?math exp
?exp
@else
\subsection{math function exp}
@endif
The {\tt exp()} function returns the exponential function of its
argument ($e$ raised to the power of its argument). Overflow is
checked on all {\tt exp()} operations.
@ifhelp
?math floor
?floor
@else
\subsection{math function floor}
@endif
The {\tt floor()} function returns the largest integer not greater
than its argument.
@ifhelp
?math hypoth
?hypot
@else
\subsection{math function hypot}
@endif
The {\tt hypot(x, y)} function returns sqrt(x*x+y*y) computed in such
a way that underflow will not happen, and overflow occurs only if the
final result deserves it.
@ifhelp
?math int
?int
@else
\subsection{math function int}
@endif
The {\tt int()} function returns the integer part of its argument,
truncated toward zero. The returned value is still a double. This
function is equivalent to trunc() is is kept for compatibility.
@ifhelp
?math interp
?interp
@else
\subsection{math function interp}
@endif
The {\tt interp()} function returns an interpolated value of the
function at the value of its argument. The functional relation is
previously initialized using the fitting mode command {\tt spline}.
The interpolation is obtained from cubic splines. {\it Natural} (i.e.,
the second derivative of the interpolating function at either or both
the first and last point of the original data equal zero) cubic spline
or specific first derivatives at the extreme points of the original
data set are specified while initializing the process using {\tt spline}
command.
\Seealso
\bq spline\eq
@ifhelp
?math lgamma
?lgamma
@else
\subsection{math function lgamma}
@endif
The {\tt lgamma()} function returns the natural logarithm of the gamma
function of its argument. For an integer {\tt n, lgamma(n+1) =
ln(fac(n))} where fac is a factorial function.
@ifhelp
?math ln
?ln
@else
\subsection{math function ln}
@endif
The {\tt ln()} function returns the natural logarithm (base $e$ ) of
its argument. Illegal argument is checked for.
@ifhelp
?math log
?log
@else
\subsection{math function log}
@endif
The {\tt log()} function returns the logarithm (base 10) of its
argument.
@ifhelp
?math max
?max
@else
\subsection{math function max}
@endif
The built-in function {\tt max(x, y)} returns the maximum value of
x and y. {\tt max(x, max(y, z))} obviously returns the largest value
of x, y, and z.
@ifhelp
?math min
?min
@else
\subsection{math function min}
@endif
The built-in function {\tt min(x, y)} returns the minimum value of
x and y. {\tt min(x, min(y, z))} obviously returns the smallest value
of x, y, and z.
@ifhelp
?math rand
?rand
@else
\subsection{math function rand}
@endif
The {\tt rand()} function returns a random number between [0,1).
Depending on the machine on which it is compiled, it might use the
extended 48 bits random number generator or less.
@ifhelp
?math rint
?rint
@else
\subsection{math function rint}
@endif
The {\tt rint()} function returns the value of its argument rounded to
the nearest integer.
@ifhelp
?math scan
?scan
@else
\subsection{math function scan}
@endif
This math function is a bit different from others in the fact that it
handles strings and returns a number. In fact, the {\tt scan({\it
String, Format})} function returns a double precision number as
extracted from string {\it String} and according to string format {\it
Format}. The format is built with the same rules {\tt sscanf} uses.
See man pages on {\tt scanf(3)}. Note that the format must contain
one active "\%lf". An example might be of some help here, especially
to show how to use {\tt scan} in conjunction with C-calculator mode
defined strings. {\tt scan} is particularly helpful to extract numbers
from filenames. Recall that strings are defined by double quotes as
in standard C.
At this point, it might be useful for you to know the "\%[ ]" scanf
construction. Let's go through some examples: {\tt "\%*[a-zA-Z]"}
means to ignore the longest string matched so that it is composed of
any letter; {\tt "\%*[\^{ }0-9]"} means to ignore the longest string
matched so that it is NOT composed of any digit; {\tt "\%*[\^{ }\_.]"}
means to ignore the longest string matched so that it is not composed
of characters `\_' or `.'.
\Examples
\nopagebreak\begin{verbatim}
# define a string called Testname
let Testname = "dummy25.dat"
# let y be the Neperian log of the number contained in that string
let y = ln(scan(Testname, "%*[^0-9]%lf.dat"))
# The following reads a number from stdin
let input = scan(Read(), "%lf")
\end{verbatim}
\Seealso
\bq \$, strings, C, cmode, quotes \eq
@ifhelp
?math sec
?sec
@else
\subsection{math function sec}
@endif
The {\tt sec()} function returns the secant of its argument. {\tt
sec()} expects its argument to be in radians.
@ifhelp
?math sech
?sech
@else
\subsection{math function sech}
@endif
The {\tt sech()} function returns the hyperbolic secant of its
argument.
@ifhelp
?math sin
?sin
@else
\subsection{math function sin}
@endif
The {\tt sin()} function returns the sine of its argument. {\tt
sin()} expects its argument to be in radians.
@ifhelp
?math sinh
?sinh
@else
\subsection{math function sinh}
@endif
The {\tt sinh()} function returns the hyperbolic sine of its
argument. {\tt sinh()} expects its argument to be in radians.
@ifhelp
?math sqrt
?sqrt
@else
\subsection{math function sqrt}
@endif
The {\tt sqrt()} function returns the square root of its argument.
@ifhelp
?math srand
?srand
@else
\subsection{math function srand}
@endif
The {\tt srand()} function sets the seed of the random number
generator. Its argument will always be truncated to an integer
towards zero. {\tt srand()} returns the truncated value.
@ifhelp
?math sum
?sum
@else
\subsection{math function sum}
@endif
The {\tt sum} function returns the sum of the elements of the vector
passed as an argument. Recall that vector are passed by pointers so
that {\tt y = sum(X$^2$)} is not legal. Instead, on must explicitly
calculate
@ifhelp
@endif
\nopagebreak\begin{verbatim}
# Given vector X, the following calculates the sum of X^2
let X2 = X^2
let y = sum(X2)
\end{verbatim}
@ifhelp
@endif
in order to evaluate the sum. The {\tt sum} function can be used to
calculate basic statistics (mean, standard deviation, correlation, ...)
and to do basic integration together with a spline-interp algorithm
if the points are distant and the function smooth enough.
\Seealso
\bq interp, spline \eq
@ifhelp
?math tan
?tan
@else
\subsection{math function tan}
@endif
The {\tt tan()} function returns the tangent of its argument. {\tt
tan()} expects its argument to be in radians.
@ifhelp
?math tanh
?tanh
@else
\subsection{math function tanh}
@endif
The {\tt tanh()} function returns the hyperbolic tangent of its
argument. {\tt tanh()} expects its argument to be in radians.
@ifhelp
?math trunc
?trunc
@else
\subsection{math function trunc}
@endif
The {\tt trunc()} function returns the value of the argument when
truncated towards zero.
@ifhelp
?pause
?wait
@else
\section{pause}
@endif
The {\tt pause} command displays any text associated with the command
and then waits a specified amount of time or until a carriage return is
pressed if the given time value is a negative integer. The {\tt pause}
command is especially useful in conjunction with {\tt load}ed files.
\Syntax
\bq pause {\it value} {\it string\optio}\eq
\Examples
\nopagebreak\begin{verbatim}
pause -1
pause 3
pause -1 Hit return to continue
pause 10 This fits equation 4 to file $ReadFile.
\end{verbatim}
\Seealso
\bq echo, load \eq
@ifhelp
?plot
@else
\section{plot}
@endif
There exists no plot command as such. However two macros are
predefined. One is {\tt gnu!plot} to use with \gnuplot\ and {\tt
sgi!plot} to use with \sgiplot. As they currently are, only two
vectors can be passed to these macros. They serve like examples for
building your own macros as well. See {\tt show macros} to see the
contents of the predefined macros of your site.
\Seealso
\bq set plotting, special, macro, show macros \eq
@ifhelp
?pmode
@else
\section{pmode}
@endif
The {\tt pmode} command talks directly to the plotting program chosen
with the {\tt set plotting} command. Any command usually typed to the
plotting routine is now valid. Furthermore, all the current variables,
constants and their string counterparts can be expanded in the
plotting mode. The fitting macros and aliases are not recognized in
this mode. The command {\tt fmode} permits the user to return from the
plotting mode as does \^{ }D when typed interactively. If {\tt pmode}
is called with trailing arguments, the remainder of the line will be
passed to the plotting program while remaining in fitting mode. It is
not an error to call {\tt pmode} from the plotting mode. An warning
message will be given though.
If the plotting program is defined as a null string ({\tt set plotting ""})
then all command lines given in {\tt pmode} will be ignored and
warning messages will be given accordingly.
\Syntax
\bq pmode {\it command\optio}\eq
\Examples
\nopagebreak\begin{verbatim}
pmode
pmode set nokey
pmode plot "fudgfile" with lines
\end{verbatim}
\Seealso
\bq set plotting, set prompt-pm, special \eq
@ifhelp
?print
@else
\section{print}
@endif
The {\tt print} command is a C-calculator mode command that writes the
value of a valid mathematical expression to a file selected by {\tt
set output}. The default is {\it stdout}. If there is more than one
variable, a coma separated list must be given in which case each
expression value will printed on the same line and separated by a tab.
As with other number output commands, the output format is the one
selected by the {\tt set format} command. The default is "\% 10.8e".
The {\tt print} command differs from {\tt show variables} as follows:
$\bullet$ {\tt print} accepts any expression for indexing vector elements;
$\bullet$ {\tt print} requires a comma separated list;
$\bullet$ {\tt print} can be part of a function or procedure;
$\bullet$ {\tt print} can print strings provided they are in double
quotes. This includes characters '\verb+\n+', '\verb+\t+', '\verb+\a+', \ldots;
$\bullet$ {\tt print} does not append a newline.
$\bullet$ {\tt print} can print any mathemetical expression.
$\bullet$ {\tt print} is a C-calculator mode command.
A simpler way to print variables to {\it stdout} from the C-calculator
mode is to use the feature that any variable or coma separated list of
variables given on the command line will be displayed, separated by tabs
and appended with a newline character. Thus the construction
@ifhelp
@endif
\nopagebreak\begin{verbatim}
set output stdout
cmode
print x, y, "\n"
\end{verbatim}
@ifhelp
@endif
is equivalent to
@ifhelp
@endif
\nopagebreak\begin{verbatim}
cmode
x, y
\end{verbatim}
@ifhelp
@endif
typed in C-calculator mode (it becomes {\tt let x,y} in fitting mode).
The only difference between {\tt print} and the automatic printing
feature of C-calculator mode is that (1) {\tt set output} only affects
{\tt print} command, and that (2) {\tt print} does not automatically
append a new line character.
\Syntax
\bq print {\it coma-separated-var-list} \eq
\Examples
\nopagebreak\begin{verbatim}
cmode
print x+2
print String, x, y, z
print "Warning \a\a\a", "x = ", x, "\n"
\end{verbatim}
\Seealso
\bq cmode, func, C, show table, show variable, math functions, quotes,\\
set format, set output\eq
@ifhelp
?proc
@else
\section{proc}
@endif
The {\tt proc} command is a C-calculator command used to define
procedures. Procedures differs from functions in the fact that they do
not return any value. The procedure arguments are passed and referred
to the same way they are in functions. Keyword {\tt proc} is a
C-calculator mode command. The {\tt show table} command can be used
to list all the installed objects at a given time.
\Syntax
\bq proc {\it procedurename}({\it proto-list\optio}) {\it cmode-line-statement} \eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq proc {\it procedurename}({\it proto-list\optio}) \{\\
{\it cmode-statements}\\
\}\eq
\Examples
\nopagebreak\begin{verbatim}
# The following example will print the Fibonacci numbers lower than 1000
cmode
proc fib(x) {
a = 0
b = 1
while (b < x) {
print b
c = b
b += a
a = c
}
print "\n"
}
# The following 'for' loop is equivalent to the preceding fib()
proc fib2(x) {
auto a,b,c # This proc creates no global variable
for(a=0,b=1;b<x;c=b,b+=a,a=c) {
print b
}
print "\n"
}
fib(1000) # A procedure as called from C-calculator mode.
fmode
let fib2(1000) # A procedure as called from fitting mode.
# A short example involving a vector
set data 10
let proc init(X, x) X=x
let b=3
let init(Y, 2/4 + b) # Shows that scalar can also be expressions.
\end{verbatim}
\Seealso
\bq return, cmode, C, func, auto, math, show table, install \eq
@ifhelp
?pwd
?cwd
@else
\section{pwd}
@endif
The {\tt pwd} command prints the name of the working directory on
the screen.
\Syntax
\bq pwd\eq
\Seealso
\bq cd, ls \eq
@ifhelp
?quit
@else
\section{quit}
@endif
The commands {\tt exit} and {\tt quit} are equivalent and both will
exit \fudgit. On exit, all temporary files {\it /tmp/fudgitPID*} (note
the wild card) will be erased. Here PID is the current process number.
Moreover, if a plotting process is active, it will be sent a KILL
signal. It is therefore a good habit to use the {\tt \$Tmp} string
variable to build your temporary files.
\Syntax
\bq quit\eq
\Seealso
\bq cmode, exit \eq
@ifhelp
?quotes
@else
\section{quotes}
@endif
In the fitting mode, single and double quotes serve to indicate that
all the characters between quotes should be taken as only one word,
even if there are some blanks (tab or space) among them. The
difference between single and double quotes is that within the former
variable expansion (using `\$') does not take place whereas it does in
the latter. Quotes are not recognized between parentheses.
In C-calculator mode, double quotes serve to indicate a string and
parsing is done accordingly. As in C, double quotes can be included in
a string using the `\verb+\+' operator. Note that C special characters
as '\verb+\n+' for a newline, '\verb+\a+' for a bell, '\verb+\t+' for
a tab, and so on, are recognized in a string. Single quotes have no
special meanings. The only way to pass a `\$' without expanding the
following name is to escape the `\$' with a `\verb+\+'.
Thus, a null string is given by {\tt ''} or {\tt ""} in the fitting
mode and by {\tt ""} only in C-calculator mode.
In pmode, both single and double quotes are freely passed to the
plotting program. This is valid when trailing commands are are passed
to {\tt pmode}, although \fudgit\ implicitly stays in the fitting
mode. Once again, expansion of a `\$' followed by a string can be
avoided using the escape character, i.e., by typing `\verb+\+\$'.
\Seealso
\bq exec, set plotting, math function scan, print \eq
@ifhelp
?read
@else
\section{read}
@endif
The {\tt read} command is used to read data points from a file or from
standard input. Each column is assigned to a given vector. Vectors not
already allocated will automatically be. Range of values can be
specified on any variable using the [{\it low}:{\it high}] syntax.
The default behaviour is to ignore out of range data and continue
to read the file. However, {\tt read} can be told to stop reading the
file from the moment it encounters an out of range data line. This
done by prepending a 'b' (break) or a 'c' (continue) to the range
value. For example, [b0:c10] will make stop reading if the value
is smaller than 0, but continue if larger than 10. Note that the
'c' is there for completeness since it is the default behaviour. A
`{\tt *}' replacing a value means an unexisting limit. Range of lines
can be specified on any variable using the \{{\it low}:{\it high}\} or
the \{{\it low}:{\it high}:{\it increment}\} syntax. The last line range
given will be the only one in effect. If the file name specified is
`\dash' data will be read from the current standard input until the
keyword {\tt end} is found on a line by itself. The {\tt read} \dash
and the {\tt load} commands are recursive functions so they can be
nested insofar as you can understand what is going on. An assignment
consists in a vector name and a column number separated by a colon.
After a file has been successfully read, {\tt read} will put the name
of the data file in string constant {\tt ReadFile}. Now some examples!
\Syntax
\bq read {\it filename} {\it vector:column\optio$[$range$]$\optio\{linerange\}\optio} \ldots\eq
\Examples
\nopagebreak\begin{verbatim}
read file1 X:1[0:*] Y:2
read file1 X[0:*] Y
read file2 T:2[b1E-7:*]
read file3 TIME:2{100:400}
read - T VALUE
1 2.3
2 4.7
. .
. .
. .
end
\end{verbatim}
@ifhelp
@endif
The first two forms will read all positive values from the first
column in vector $X$ and corresponding values of the second in vector
$Y$. The third form will read the second column until a value smaller
than 1E-7 is read. All elements following this value (smaller or not)
will be ignored. The fourth will read the second column of file {\it
file3} from line 100 to line 400. The fifth will read $T$ and {\it
VALUE} from stdin. The assignment does not need to be in increasing
order of the columns. Also note that first column number is 1.
\Seealso
\bq exec, data \eq
@ifhelp
?reinstall
@else
\section{reinstall}
@endif
The {\tt reinstall} command is used to perform the dynamical loading
of a module that was already loaded. Typically, this is done after a
module has been modified and recompiled. Refer to {\tt install} for
more detail.
@ifhelp
?return
@else
\section{return}
@endif
The C-calculator {\tt return} keyword is used as in standard C to
return from a function or a procedure. Contrary to C, {\tt return}
requires parentheses when returning a value from a function. It is an
error to return a value from a procedure or to not return anything
from a function. {\tt return} is a C-calculator mode command.
\Syntax
\bq return({\it expression})\\
return \eq
\Seealso
\bq C, cmode, func, proc, auto \eq
@ifhelp
?save
@else
\section{save}
@endif
Look under {\tt append} command description.
@ifhelp
?set
@else
\section{set}
@endif
The {\tt set} command sets a lot of options, as follows.
@ifhelp
?set comment
@else
\subsection{set comment}
@endif
The {\tt set comment} command selects the character which will cause
the rest of the line to be ignored. The default value is `{\tt \#}'.
Note that the effect of a comment character will be void if: (1) found
somewhere between single quotes in fitting mode or (2) escaped with a
`\verb+\+'.
\Syntax
\bq set comment {\it character} \eq
\Example
\nopagebreak\begin{verbatim}
set comment ?
\end{verbatim}
\Seealso
\bq show comment, comments \eq
@ifhelp
?set data
?data
@else
\subsection{set data}
@endif
The {\tt set data} command changes the effective size of vectors. All
the vector arithmetic checks for index boundaries. The {\tt data}
constant is the higher bound of the check and necessarily the size of
all vectors. Changing the {\tt data} value does not change the values
nor the capacity of vectors. It only changes the upper bound on the
value the index can take. The {\tt data} constant is also changed by
the commands {\tt read} and {\tt exec}, which set it to the number of
valid data points read. Because the upper bound can never be higher
than the effective capacity of vectors, a {\tt data} value higher than
the current {\tt samples} value will be refused. See {\tt set
samples}. Typically, {\tt set data} is used when one wants the
C-calculator to generate (and plot) vectors. The {\tt read} and {\tt
exec} commands take care of adjusting it. {\tt data} constant can also
be changed from the C-calculator mode if the constant is {\tt
unlock}ed. However, no check is made to ensure the given value is not
higher than {\tt sample} size, in which case a segmentation fault will
crash the whole program. It is always safer to use {\tt set data}.
\Syntax
\bq set data {\it number}\eq
\Example
\nopagebreak\begin{verbatim}
set data 300
\end{verbatim}
\Seealso
\bq lock, unlock, read, exec, cmode\eq
@ifhelp
?set debug
?debug
@else
\subsection{set debug}
@endif
The {\tt set debug} command puts the reading of {\tt load}ed files in
verbose mode, so that debugging is more easily done. All the commands,
expanded macros and/or string variables are echoed as they are
executed. There are some different debug levels at the present time:
$\bullet$ 0 clear all the debugging states.
$\bullet$ 1 echo the expanded lines as they are read. The command is
parsed and comments are stripped out. This is most useful
for debugging script files. History substitutions are shown.
$\bullet$ 2 display all command lines as they are read from the script.
$\bullet$ 3 display the line numbers of the ignored lines as they are
read from datafiles.
$\bullet$ 4 echo command lines as they are passed to the math parser.
$\bullet$ 5 turn the math parser debugger on. To use this, the program
must have been compiled with the YYDEBUG preprocessor
variable on.
$\bullet$ 6 trace the flow of fitting mode {\tt if} constructions.
Debugging values are not exclusive so that more than one level
can be turned on. Levels are subject to change.
\Syntax
\bq set debug {\it value-list} \eq
\Example
\bq set debug 0 1 3\eq
\Seealso
\bq load \eq
@ifhelp
?set error
?error
@else
\subsection{set error}
@endif
\fudgit\ allows the user to select among different possible error
checks to be made on each single mathematical operations. The
{\tt set error} command will set computational error checks as follows:
$\bullet$ 0: clear all computational error check bits.
$\bullet$ 1: check for `infinity' values.
$\bullet$ 2: check for `not a number' values.
$\bullet$ 3: check for `out of domain' math function errors.
$\bullet$ 4: check for `out of range' math function errors.
Error checks are not exclusive and more than one can be specified on
the command line. The default status has all error check levels
activated (1 2 3 4).
It is sometimes desirable to disable one of the checks. For example,
the operation $y = 1/sinh(x)$ will give a `out of range' error for
large $x$ ( $> 709$ on most machines), although $y$ is in fact 0.
If one uses {\tt set error 0 1 2 3}, then no error will be reported
and $y$ will be set to zero accordingly.
\Syntax
\bq set debug {\it value-list} \eq
\Example
\bq set error 0 2 3\eq
\Seealso
\bq C, cmode \eq
@ifhelp
?set expand
?expand
@else
\subsection{set expand}
@endif
In interactive mode, history expansion and substitution will occur
only if the {\tt expand} variable is set. It is disabled using {\tt
set noexpand}. The default is on.
\Syntax
\bq set expand \eq
\Seealso
\bq set noexpand, history, line editing \eq
@ifhelp
?set format
?format
@else
\subsection{set format}
@endif
The command {\tt set format} will set the printf format for variables.
Use only if you are sure of what you are doing. It defaults to
"\% 10.8e". See {\tt man printf(3)} if in doubt.
\Syntax
\bq set format {\it string}\eq
\Examples
\nopagebreak\begin{verbatim}
set format %6.2lf
set format "% .8g"
\end{verbatim}
\Seealso
\bq show, append \eq
@ifhelp
?set function
?function
@else
\subsection{set function}
@endif
The {\tt set function} command is perhaps the most crucial command in
data fitting. It is used to select a built-in fitting function or to
enter a user-defined function. The following fitting functions are
available:
@ifhelp
@endif
\nopagebreak\begin{verbatim}
NAME DESCRIPTION PARAMETERS REQUIRED
---- ----------- -------------------
straight Straight line (2 parameters)
sine Sine series (N parameters)
cosine Cosine series (N parameters)
legendre Legendre series (N parameters)
polynomial Power series (N parameters)
gauss Gaussian series (3N parameters)
lorentz Lorentzian series (3N parameters)
expo Exponential series (2N parameters)
user User-defined function (N parameters)
\end{verbatim}
Assume a variable vector $X$ and a parameter vector $A$ then,
the nonlinear gauss fitting function is a series of gaussians where
@iftex
\[ f(X,A) = \sum_{i=3,6, \ldots, N} A[i-2] \times e^{ A[i-1] * (X-A[i])^ 2}. \]
@else
f(X,A) = SUM (i=3,7,...,N) of A[i-2] * exp(A[i-1]*(X-A[i])^ 2).
@endif
The nonlinear expo function is a series of exponentials where
@iftex
\[ f(X,A) = \sum_{i=2,4,\ldots, N} A[i-1] \times e^{X*A[i]} .\]
@else
f(X,A) = SUM (i=2,4,...,N) of A[i-1] * exp(X*A[i]).
@endif
The nonlinear lorentzian function is a series given by
@iftex
\[ f(X,A) = \sum_{i=3,6,\ldots,N}
A[i-1]*\frac{(X*A[i])^2}{(X^2-A[i-2]^2)^2+(X*A[i])^2}.
\]
@else
f(X,A) = SUM (i=3,6,...,N) of
A[i-1] * (X*A[i])^2/((X^2-A[i-2]^2)^2+(X*A[i])^2).
@endif
For a user-defined function, the {\tt set function user} will prompt
for more input. The following input is related to the variable to
fit. For purposes of clarity, let's say that we have to fit vectors
{\tt X Y DY}. This requires a fit function {\tt YFIT} (the name is
made from the dependent variable appended with {\tt FIT}) and all the
partial derivatives {\tt DYFITD1, DYFITD2, \ldots, DYFITDN} taken with
respect to the parameters $n=1,\ldots N$. All these functions are
defined one per line as in the case of a macro until a {\tt stop} is
entered. Temporary variables are permitted. {\tt set function user}
actually defines a C-calculator mode macro that will be executed
before each iteration of the fit. Therefore the complete C-calculator
mode grammar is fully supported here. Temporary vectors can thus be
used to speed up the calculation.
The C-calculator macro can be a simple call to a predefined procedure.
When defined so, the parsing does not have to be done at each iteration,
and a slightly faster process should result.
\Example
\nopagebreak\begin{verbatim}
# read column 1, 2 and 3 of file "file"
read file T:1 R:2 DR:3
# make a three parameter fit
set parameter K 3
# this is a linear fit; use singular value decomposition
set method svd_fit
# enter my function
set function user
RFIT = K[1] + K[2]*T^0.5 + K[3]*T^1.5
DRFITD1 = 1
DRFITD2 = T^0.5
DRFITD3 = T^1.5
stop
fit T R DR
\end{verbatim}
The vector {\tt RFIT} will contain the fitted function. The difference
between the fit and real data can be obtained right away by defining a
vector
@ifhelp
@endif
\nopagebreak\begin{verbatim}
let RDIFF = R - RFIT
\end{verbatim}
@ifhelp
@endif
that can be plotted with respect to {\tt T}.
The same thing is done for nonlinear fit with the exception that the
partial derivatives of the function with respect to the parameters
will contain reference to some parameter(s). (This is precisely the
meaning of nonlinear here).
There is virtually no restriction on the number of parameters (memory
is the sole limitation: {\tt set parameter} command allocates a
matrix of {\tt parameters} X {\tt samples} ). The only conditions are
that a linear regression must have 2 parameters defined (this is
obvious) and the built-in nonlinear functions must be modulo 3 for the
series of gaussians and modulo 2 for the series of exponentials.
\Seealso
\bq fit, set method, adjust, proc, auto \eq
@ifhelp
?set input
?input
@else
\subsection{set input}
@endif
The {\tt set input} command selects the file for the input of the
C-calculator mode {\tt Read} and {\tt vread} command. The string {\it
stdin} is valid as a filename. If the selected file does not exist or
cannot be read, an error message will be given and the value will go
back to the default value, which is {\it stdin}.
\Syntax
\bq set input {\it filename} \eq
\Seealso
\bq Read, vread \eq
@ifhelp
?set iteration
?iteration
@else
\subsection{set iteration}
@endif
The {\tt set iteration} command permits the user to change the
iteration number for the Marquardt-Levenberg nonlinear fitting method.
See {\tt set function}. The default value is 10. However, the fitting
process will stop if there is no difference in $\chi^2$ for two
consecutive iterations. However, a negative value will force to
iterate up to the absolute value of that number, without checking for
convergence.
\Syntax
\bq set iteration {\it value}\eq
\Example
\bq set iteration 3\eq
\Seealso
\bq fit, set method, set function \eq
@ifhelp
?set method
?method
@else
\subsection{set method}
@endif
The {\tt set method} command allows the user to select the fitting
method to be used when calling the {\tt fit} command. The following
methods are available:
@ifhelp
@endif
\nopagebreak\begin{verbatim}
NAME DESCRIPTION
---- -----------
ls_reg least square linear regression (2 parameters)
lad_reg least absolute deviation linear regression (2 parameters)
ls_fit general least square linear fit using QR decomposition
svd_fit general least square linear fit using singular value
decomposition
ml_fit general least square nonlinear fit using
Marquardt-Levenberg method
\end{verbatim}
Among them, only {\tt ml\_fit} and {\tt ls\_fit} depends on {\tt iteration}
and {\tt adjust}.
For all methods except {\tt lad\_reg}, the value of $\chi^2$ will be put
in the scalar constant {\tt chi2}. In the case of {\tt lad\_reg}, $\chi^2$
will contain the average absolute deviation.
\Syntax
\bq set method {\it method}\eq
\Example
\bq set method svd\eq
\Seealso
\bq fit, set iteration, set function \eq
@ifhelp
?set noexpand
?noexpand
@else
\subsection{set noexpand}
@endif
The {\tt set noexpand} command disallows history expansion on the
interactive command line.
\Syntax
\bq set noexpand \eq
\Seealso
\bq set expand \eq
@ifhelp
?set output
?output
@else
\subsection{set output}
@endif
The {\tt set output} command selects the file for the output of the
C-calculator mode {\tt print} command. The strings {\it stdout} and
{\it stderr} are both valid as a filename. If the selected file
already exists, it will be overwritten with no warning. The default
value is {\it stdout}.
\Syntax
\bq set output {\it filename} \eq
\Seealso
\bq print \eq
@ifhelp
?set pager
?pager
@else
\subsection{set pager}
@endif
The {\tt set pager} command allows the user to select a pager. A pager
is the program that is called when the structure to be displayed has
more than 24 elements. The default pager is (1) the environment
variable PAGER if it exists or (2) {\it /usr/?/more} (path depends on
system) if not. If {\tt pager} is defined to a null string ({\tt ""}),
then no pager will be used.
\Syntax
\bq set pager {\it string}\eq
\Example
\bq set pager "more -c"\eq
\Seealso
\bq show, show pager \eq
@ifhelp
?set parameters
?parameters
@else
\subsection{set parameters}
@endif
The command {\tt set parameters} will fix the parameter name and
size. Since the set of parameters is a kind of vector, parameter name
cannot contain lower case letters. Parameters are initialized to
zero. A built-in scalar constant called {\tt param} contains the
number of parameters at all time.
\Syntax
\bq set parameters {\it parameter-name} {\it size}\eq
\Example
\nopagebreak\begin{verbatim}
# set the vector D of size 3 to be determined by the fit.
set parameters D 3
\end{verbatim}
\Seealso
\bq show parameters, show setup\eq
@ifhelp
?set plotting
?plotting
@else
\subsection{set plotting}
@endif
The {\tt set plotting} command changes the default plotting program
used by the plotting mode. The default is \gnuplot\ but this can be
changed to any plotting program that can be driven from stdin. A
maximum of 16 arguments can be passed when the program is first
called. Changing the plotting program will send a KILL signal to the
existing plotting program (if any). If the plotting program is set to
a null string ({\tt ""}), \fudgit\ will ignore all the plotting
commands and warning messages will be given. Setting the plotting
program to a file that cannot be found or executed will result in an
error at the first {\tt pmode} call.
\Syntax
\bq set plotting {\it command}\eq
\Examples
\nopagebreak\begin{verbatim}
set plotting "/usr/local/bin/sgiplot -p"
set plotting /usr/local/bin/gnuplot
\end{verbatim}
\Seealso
\bq show plotting \eq
@ifhelp
?set prompts
?prompts
@else
\subsection{set prompts}
@endif
All three \fudgit\ prompts can be changed by the {\tt set} command.
The name of the prompts are:
$\bullet$ {\tt prompt-cm} for the C-calculator mode prompt
(default: "cmode$>$ ";
$\bullet$ {\tt prompt-fm} for the fitting mode prompt
(default: "fudgit$>$ ";
$\bullet$ {\tt prompt-pm} for the plotting mode prompt
(default: "pmode$>$ ".
A null string {\tt ""} (i.e., two consecutive quotes) can be given to
any of these.
\Syntax
\bq set prompt-cm {\it string}\\
set prompt-fm {\it string}\\
set prompt-pm {\it string}\eq
\Seealso
\bq show prompts \eq
@ifhelp
?set samples
?samples
@else
\subsection{set samples}
@endif
The command {\tt set samples} changes the current capacity of the
fitting program. Typically, {\tt samples} is set at the beginning of a
session since all the existing vectors and variables are erased on
this call. The default setting is 4000 points.
Note that {\tt set samples} internally calls {\tt free @allvec} and
thus erases all the currnet vectors from the symbol table.
\Syntax
\bq set samples {\it value}\eq
\Example
\bq set samples 6000\eq
\Seealso
\bq set data, cmode, let, lock, free \eq
@ifhelp
?set vformat
?vformat
@else
\subsection{set vformat}
@endif
The command {\tt set vformat} will set the sprintf format used for the
expansion of scalar variables by the expansion operator `\$'. Use
only if you are sure of what you are doing. It defaults to "\%.3lg".
See {\tt man printf(3)} if in doubt.
\Syntax
\bq set vformat {\it string}\eq
\Examples
\nopagebreak\begin{verbatim}
set vformat %6.2lf
set vformat "%.4lg"
\end{verbatim}
\Seealso
\bq \$, cmode, C \eq
@ifhelp
?shell
@else
\section{shell}
@endif
The {\tt shell} command starts a shell according to your SHELL
environment variable. It is equivalent to {\tt system} command. Refer
to the latter for details.
@ifhelp
?show
@else
\section{show}
@endif
The {\tt show} command is used to see the chosen options or to look at
any defined vectors, parameters or variables.
\Seealso
\bq set, echo \eq
@ifhelp
?show comment
@else
\subsection{show comment}
@endif
The {\tt show comment} command echoes the current comment escape
character.
\Syntax
\bq show comment \eq
\Seealso
\bq set comment, comments \eq
@ifhelp
?show data
@else
\subsection{show data}
@endif
The {\tt show data} command displays the current value of {\tt data}
constant. Left for compatibility.
\Syntax
\bq show data \eq
\Seealso
\bq set data, lock, unlock, set samples \eq
@ifhelp
?show debug
@else
\subsection{show debug}
@endif
The {\tt show debug} command displays the current value of the {\tt
debug} variable. The value is displayed in octal since the
{\tt set debug} $n$ command turns on the $n^{th}$ bit of this number.
\Syntax
\bq show debug \eq
\Seealso
\bq set debug \eq
@ifhelp
?show error
@else
\subsection{show error}
@endif
The {\tt show error} command displays the current value of the {\tt
error} computational check variable. The value is displayed in octal
since the {\tt set error} $n$ command turns on the $n^{th}$ bit of
this number.
\Syntax
\bq show error \eq
\Seealso
\bq set error \eq
@ifhelp
?show input
@else
\subsection{show input}
@endif
The {\tt show input} command shows the filename selected for the
input of the C-calculator mode {\tt Read} and {\tt vread} command.
The default value is {\it stdin}
\Syntax
\bq show input \eq
\Seealso
\bq set input, Read, vread \eq
@ifhelp
?show iterations
@else
\subsection{show iteration}
@endif
The {\tt show iteration} command displays the current value of
{\tt iteration} variable.
\Syntax
\bq show iteration \eq
\Seealso
\bq set iteration, set method \eq
@ifhelp
?show fit
@else
\subsection{show fit}
@endif
The {\tt show fit} command displays the different quantities relevant
to the current fitting method. Typical examples are $\chi^2$, the
covariance matrix, the curvature matrix, correlation factor, etc\ldots
\Syntax
\bq show fit\eq
\Seealso
\bq fit, set parameters, set function, set method \eq
@ifhelp
?show format
@else
\subsection{show format}
@endif
The {\tt show format} command displays the current value of
{\tt format} variable. The {\tt format} string is used when
displaying any number on the screen. Refer to printf(3) of
the \unix\ manual.
\Syntax
\bq show format \eq
\Seealso
\bq set format, show \eq
@ifhelp
?show function
@else
\subsection{show function}
@endif
The command {\tt show function} displays the current function type. If
the function type is {\tt user}, then the user-defined function will
be displayed.
\Syntax
\bq show function\eq
\Seealso
\bq set function, show setup, fit, math \eq
@ifhelp
?show macros
@else
\subsection{show macros}
@endif
If called with an argument, the {\tt show macros} command will display
the specified macro. Otherwise, all currently defined macros will be
displayed. The selected {\tt pager} is called if the command is given
in interactive mode (at the command line prompt).
\Syntax
\bq show macros {\it macroname}\optio\eq
\Seealso
\bq set pager, save macros, alias \eq
@ifhelp
?show memory
?memory
@else
\subsection{show memory}
@endif
The {\tt show memory} function will display the current state of
memory consumption of the program. All sizes are given in bytes. It
uses a direct call to mallinfo(3). The arena is the size of memory
requested by the process to the kernel. It is then split in different
blocks shared among the internal matrices and user's vectors, macros,
functions, procedures, variables and history.
\Syntax
\bq show memory\eq
\Seealso
\bq free, show table \eq
@ifhelp
?show method
@else
\subsection{show method}
@endif
The {\tt show method} command displays the current value of the
fitting {\tt method}. It contains {\it none} by default.
\Syntax
\bq show method \eq
\Seealso
\bq set method, fit, set function \eq
@ifhelp
?show output
@else
\subsection{show output}
@endif
The {\tt show output} command shows the filename selected
for the output of the C-calculator mode {\tt print} command.
The default value is {\it stdout}
\Syntax
\bq show output \eq
\Seealso
\bq set output, print \eq
@ifhelp
?show pager
@else
\subsection{show pager}
@endif
The {\tt show pager} command displays the current value of the
{\tt pager} program.
\Syntax
\bq show pager \eq
\Seealso
\bq set pager, environment, show\eq
@ifhelp
?show parameters
@else
\subsection{show parameters}
@endif
The command {\tt show parameters} will display the parameter values on
the screen. If the number of parameters is larger than 24, then the
selected {\tt pager} will be called if the command is given in
interactive mode (at the command line prompt). As with {\tt append}
and {\tt save parameters}, {\tt show parameter} can accept optional
variable or constant (either string or scalar) list of names, in which
case the value of the given variables will be displayed along with the
parameter values.
\Syntax
\bq show parameters {\it variable-list\optio}\eq
\Seealso
\bq set pager, set parameters, save parameters, show fit \eq
@ifhelp
?show plotting
@else
\subsection{show plotting}
@endif
The {\tt show plotting} command displays the current value of the
{\tt plotting} program.
\Syntax
\bq show plotting \eq
\Seealso
\bq set plotting, startup, pmode\eq
@ifhelp
?show prompts
@else
\subsection{show prompts}
@endif
The {\tt show prompts} command displays the current values of the
different mode {\tt prompts}.
\Syntax
\bq show prompt-cm\\
show prompt-fm\\
show prompt-pm\eq
\Seealso
\bq set prompt, startup\eq
@ifhelp
?show samples
@else
\subsection{show samples}
@endif
The {\tt show samples} command displays the current value of the {\tt
samples} variable. Recall that although {\tt data} is responsible for
the visible part of all vectors, vectors all have a fixed allocated
length of {\tt samples} long. Any change to {\tt samples} through {\tt
set samples} frees all the existing vectors.
\Syntax
\bq show samples \eq
\Seealso
\bq set samples, set data, cmode\eq
@ifhelp
?show setup
?setup
@else
\subsection{show setup}
@endif
The command {\tt show setup} will show some values of the program,
such as the last data filename read, the number of data points,
current capacity, current comment character, current iteration number,
current plotting program, etc. Left for compatibility.
\Syntax
\bq show setup\eq
\Seealso
\bq set comments\eq
@ifhelp
?show table
?table
@else
\subsection{show table}
@endif
The command {\tt show table} displays the current lookup table of the
C-calculator mode parser. It shows all current variables, numbers,
vectors and functions included in the internal table. It also shows
the state of the internal machine (C interpreter), stack and frame
used in the C-calculator. This is used mainly for debugging or to
prevent stack or machine code overflow.
\Syntax
\bq show table\eq
\Seealso
\bq free, show memory, cmode \eq
@ifhelp
?show variables
@else
\subsection{show variables}
@endif
Any constants or variables can be displayed on the screen.
The {\tt show variable} command differs from {\tt print} as follows:
$\bullet$ {\tt show variables} only accepts integers for indexing
vector elements;
$\bullet$ {\tt show variables} requires a blank separated list;
$\bullet$ {\tt show variables} cannot be part of a function or procedure.
As it has been mentioned previously, this is due to the different
types of parsing between the C-calculator and fitting modes. As with
all other number displaying commands, the printing format is
always the one selected by the {\tt set format} command.
\Syntax
\bq show variables {\it variable-list} \eq
\Example
\bq show variables x X[2] Y[2] DY[2] time\eq
\Seealso
\bq print, save variables, show table, show vectors, cmode \eq
@ifhelp
?show vectors
@else
\subsection{show vectors}
@endif
Any vector or number of vectors can be seen on the screen. If the size
of vectors is larger than 24, the selected {\tt pager} will be called
if the command is given in interactive mode (at the command line
prompt).
\Syntax
\bq show vectors {\it VECTOR-list} \eq
\Example
\bq show vectors X Y DY\eq
\Seealso
\bq set pager, append vectors, read, cmode, let \eq
@ifhelp
?show vformat
?vformat
@else
\subsection{show vformat}
@endif
The command {\tt show vformat} will display the printf format used
for the expansion of scalar variables by the expansion operator `\$'.
Refer to the printf(3) description in the \unix\ manual for more details.
\Syntax
\bq show vformat\eq
\Seealso
\bq \$, cmode, C, set vformat \eq
@ifhelp
?smooth
@else
\section{smooth}
@endif
The {\tt smooth} command uses a gaussian windowing function (low-pass
filter) on a Fourier transform loop in order to smooth the given
vector. The windowing function is $\exp(-(f/(\sigma \times f_{max}))^2)$
where $f_{max}$ is equal to half of the smallest power of 2 larger
than the number of data points {\tt data}. Variable $f$ is the
frequency that ranges from 0 to $f_{max}$. More likely, the smoothing
factor is a non null positive real number from the (0, 1] interval. A
smoothing factor $\sigma >= 1$ leaves the vector unchanged.
The number of data points {\tt data} needs not to be a power of 2.
To be used with discernment!
\Syntax
\bq smooth {\it $\sigma$} {\it in-VECTOR} {\it out-VECTOR}\eq
\Seealso
\bq fft, invfft, cmode, C \eq
@ifhelp
?special
@else
\section{special}
@endif
The following special commands are left for debugging or macro purposes.
They start with an underscore to avoid mistakes and remind of their
special character.
{\tt \_killplot} will kill the current plotting program.
\Syntax
\bq \_killplot \eq
{\tt \_dumplot} will send the following vectors in the plotting
program pipe. This is only useful if the current plotting program
accept data from its stdin. {\tt \_dumplot} can accept up to 16
arguments.
\Syntax
\bq \_dumplot {\it VECTOR-list}\eq
\Example
\bq \_dumplot X Y DY \eq
\Seealso
\bq macro, show macros, plot \eq
@ifhelp
?spline
@else
\section{spline}
@endif
The {\tt spline} function initializes the internal table for the
calculation of interpolated values using cubic spline method.
Interpolated values are obtained from calls to the C-calculator math
function {\tt interp()}. The value of the first derivative at the
first and last data points can be specified by optional arguments. If
not specified, or if one of the optional arguments is an asterisk {\tt *},
then a {\it natural} cubic spline is assumed in which case the
interpolated curve is such that the second derivative at the extreme
points (or one of them) is null. The asterisk is more likely to be used
in cases where the user would like to specify the first derivative at
the last point only. The independent vector must be such that its
value increases monotonically.
\Syntax
\bq spline {\it indep-VECTOR} {\it dep-VECTOR} {\it y1\optio} {\it yn\optio}\eq
\Example
\nopagebreak\begin{verbatim}
# Read vectors having a functional relation Y = F(X) from file "datafile"
read datafile X:1 Y:2
# Initialize the spline (as being natural)
spline X Y
# Save extreme values
let from = X[1]; to = X[data]
# Say there were data=10 points and you want 100
set data 100
# Rebuild X vector
# First build X ranging [0, 1]
let x=0; X=x++; tmp=data-1; X/=tmp
# Then from 'from' to 'to': from + (to - from)*X
let tmp=(to-from); X = from + X*tmp
# Rebuild Y vector possibly containing original values as a subset
let Y = interp(X)
# Note that any value can be asked for
let interp(2.34*pi)
\end{verbatim}
\Seealso
\bq math interp\eq
@ifhelp
?startup
@else
\section{startup}
@endif
If a file {\it .fudgitrc} exists in your home directory, it will be
automatically loaded at startup time of the program. This is useful if
one wants to include his own macros or have his own preferences loaded
to \fudgit. This file is loaded for both interactive use ({\tt fudgit})
and batch use ({\tt fudgit {\it script1} {\it script2}\ldots}).
\Examples
\nopagebreak\begin{verbatim}
set plotting /usr/local/bin/sgiplot
set prompt-pm ""
set comment ?
set samples 10000
\end{verbatim}
A file called {\it .hist\_fudgit} is will be created in your home
directory in order to keep history between calls of \fudgit. The
number of events is determined at compilation time and defaults to 52.
\Seealso
\bq environment, alias, set plotting, set prompt \eq
@ifhelp
?stop
@else
\section{stop}
@endif
The command {\tt stop} is used to terminate a macro or a fitting
function defined by the user. However, it can also be used in a script
file in order to stop execution at a certain point. In this case, an
warning message will report that {\tt stop} is being used outside a
macro or function and the file from which the command was found will
be considered as at the end of file (EOF).
\Seealso
\bq macro, set function \eq
@ifhelp
?strings
?Strings
@else
\section{string functions}
@endif
\fudgit\ has a set of functions returning string objects. These are
made available to deal with filename construction, or to read from
standard input. To be consistent with string type, string functions
are named with both lower case and upper case letters.
Strings can be added or subtracted in the C-calculator mode. String
addition {\it s1} + {\it s2} simply concatenates strings {\it s2} to
string {\it s1}. String subtraction {\it s1} - {\it s2} removes {\it
s2} from the end of {\it s1}. Note that the wild card `?' is supported
in string subtractions.
@ifhelp
?Strings DirName
?strings DirName
?DirName
@else
\subsection{string function DirName}
@endif
The string function {\tt DirName} returns the directory name as extracted
from the filename given as an argument.
\Syntax
\bq Dirname({\it String})\eq
\Seealso
\bq string functions FileName, Scan, Read\eq
@ifhelp
?strings FileName
?Strings FileName
?FileName
@else
\subsection{string function FileName}
@endif
The string function {\tt FileName} strips the leading directory names
of the filename given as an argument. Note that the \unix\ command:
@ifhelp
@endif
\bq basename {\it File} {\it Extension}\eq
@ifhelp
@endif
is equivalent to the \fudgit\ command:
@ifhelp
@endif
\bq FileName({\it File}) - {\it Extension}\eq
@ifhelp
@endif
so that filename constructions can be made in {\tt foreach} loop
for example.
\Syntax
\bq FileName({\it String})\eq
\Examples
\nopagebreak\begin{verbatim}
foreach File in ls /usr/machin/data/*.32
read $File X:1 Y:2{2:23}
# Some commands
.
.
# let File be the filename only, less the ".32" extension
let File = FileName(File) - ".32"
# And let Dir be the directory name
let Dir = DirName(File)
end
\end{verbatim}
\Seealso
\bq foreach, string functions, cmode, \$ \eq
@ifhelp
?strings Read
?Strings Read
?Read
@else
\subsection{string function Read}
@endif
The {\tt Read} function read a line from the file chosen by the {\tt
set input} function, strips the newline character and returns the
resulting string. If the input is {\tt stdin}, the user will be
prompted by a {\it ?} and the program will stop until a non-null
string is entered. This is most likely to be used in macros requiring
some input during run time. The {\tt Read()} function can be used to
read numbers with the help of {\tt scan()}. See the example below.
{\tt Read} can also be used to build vectors by taking one every $n$
points. This can be done by two imbedded {\tt for} loops.
Note: The newline character is not passed to the string.
\Examples
\nopagebreak\begin{verbatim}
# Read a string from stdin (the default)
set input stdin
let String = Read()
# How to get a value out of a string: equivalent to vread()
let value = scan(Read(), "%lf") \eq
# How to skip lines in a file
# Read say file project/numbers.data
set input project/numbers.data
cmode
for (i=1; i<=top; i++) {
Line = Read() # Read one line
X[i] = scan(Line, "%lf"); # get first column
Y[i] = scan(Line, "%*lf %*lf %lf"); # get third column
for (j=1; j<n; j++) {
Line = Read() # Read n-1 lines
}
}
fmode
set input stdin
\end{verbatim}
\Seealso
\bq set input, math function scan, string functions, \$ \eq
@ifhelp
?strings Scan
?Scan
@else
\subsection{string function Scan}
@endif
{\tt Scan({\it String, Format})} function returns a string as
extracted from string {\it String} and according to string format {\it
Format}. The format is built with the same rules {\tt sscanf} uses.
See man pages on {\tt scanf(3)}. Note that the format must contain one
active "\%s" or "\%[]" construction. An example might be of some help
here, especially to show how to use {\tt Scan} in conjunction with
C-calculator mode defined strings. {\tt Scan} is particularly helpful
to extract parts of filenames. Recall that strings are defined by
double quotes as in standard C.
Knowing about the "\%[ ]" scanf(3) construction might be useful at
this point. Consider the following few examples: {\tt "\%[a-zA-Z]"}
means to read the longest string matched so that it is composed of any
letter; {\tt "\%[\^{ }0-9]"} means to read the longest string matched
so that it is NOT composed of any digit; {\tt "\%[\^{ }\_.]"} means to
read the longest string matched so that it is not composed of
characters `\_' or `.'.
\Examples
\nopagebreak\begin{verbatim}
# define a string called Testname
let Testname = "dummy25.dat"
# Read until a point is encountered
let Base = Scan(Testname, "%[^.]"))
\end{verbatim}
\Seealso
\bq \$, scan, string functions Read, DirName, FileName, C, cmode, quotes \eq
@ifhelp
?system
@else
\section{system}
@endif
When called with arguments, the {\tt system} command is equivalent to
the `!' bang operator, so the remainder of the line will be given to a
Bourne shell for execution. If {\tt system} has no argument, a shell
(depending on environment variable SHELL) will be started.
\Syntax
\bq system {\it shell-commands\optio}\eq
\Seealso
\bq environment, !, shell \eq
@ifhelp
?then
@else
\section{then}
@endif
The {\tt then} keyword is required in the fitting mode {\tt if}
constructions. Refer to the latter for details.
@ifhelp
?unalias
@else
\section{unalias}
@endif
The {\tt unalias} command unaliases any alias previously assigned
by the {\tt alias} command.
\Syntax
\bq unalias {\it alias\_name} \eq
\Examples
\bq unalias date\\
unalias gnuplot \eq
\Seealso
\bq \&, alias, macro, unmacro, append, show \eq
@ifhelp
?unlock
@else
\section{unlock}
@endif
The {\tt unlock} command changes a constant into a variable and thus
allows the user to change its value. This is particularly useful in
functions and procedures needing to change the value of the {\tt data}
constant. Unlocking {\tt data} gives the user complete freedom on the
effective size of vectors. No check is done on {\tt data}
assignments, and therefore assigning a value to {\tt data} that is
superior to {\tt samples} will result in a program crash. For this
reason, it is always safer to change {\tt data} using the {\tt set
data} command. It is not an error to unlock a variable. A warning
message will be given though. However, trying to unlock something else
than a constant or variable will result in an error.
\Seealso
\bq lock, set data, set samples, cmode \eq
@ifhelp
?unmacro
@else
\section{unmacro}
@endif
The {\tt unmacro} command is the counterpart of {\tt macro}. It is
used to undefine macros. As does {\tt free}, {\tt unmacro} accepts the
``@all'' string in which case all the macros will be erased and freed
from memory.
\Syntax
\bq unmacro {\it macro-list} \\
unmacro @all \eq
\Examples
\nopagebreak\begin{verbatim}
unmacro myplot
unmacro @all
\end{verbatim}
\Seealso
\bq alias, unalias, append, show \eq
@ifhelp
?version
@else
\section{version}
@endif
The {\tt version} command displays the version number and the
welcoming message of \fudgit.
@ifhelp
?vi
?editor
@else
\section{vi}
@endif
The command {\tt vi} calls the editor. It is equivalent to
{\tt !vi filename}. Note that wild cards are also recognized and
expanded.
\Syntax
\bq vi {\it argument-list} \eq
\Examples
\nopagebreak\begin{verbatim}
vi file
vi test.*
\end{verbatim}
\Seealso
\bq !, system, alias, shell\eq
@ifhelp
?while
?loop
@else
\section{while}
@endif
The {\tt while} command allows the user to construct controlled loops
on a series of operations. However, \fudgit\ supports two kinds of
{\tt while} constructions, one in the fitting mode and the other in
the C-calculator mode.
@ifhelp
?while cmode_style
@else
\subsection{C-calculator while}
@endif
The C-calculator mode while construction has a syntax similar to
that of standard C. In interactive mode, any new input line will be
prompted with a ``n\{\ldots n\verb+\t+'' where `n' stands for the nesting
level and `\verb+\t+' for a tab. Recall that {\it cmode-line-statement}
means a string of semicolon separated C-calculator mode commands.
\Syntax
\bq while ({\it conditions}) {\it cmode-line-statement}\eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq while ({\it conditions})\\
{\it cmode-line-statement}\eq
@ifhelp
@endif
or
@ifhelp
@endif
\bq while ({\it conditions}) \{\\
{\it cmode-statements}\\
\}\eq
\Example
\nopagebreak\begin{verbatim}
read file X:1 Y:2
let x=12;sum1=0;sum2=0
while (x++<=100) {
sum1 += X[x]+Y[x]
sum2 += X[x]^2 + Y[x]^2
}
\end{verbatim}
\Seealso
\bq C, break, continue, cmode, for, func, proc, auto, math \eq
@ifhelp
?while fmode_style
@else
\subsection{Fitting mode while}
@endif
The fitting mode {\tt while} is very similar to the C-shell
{\tt while}. As for the {\tt if} construction, the difference remains
in a broader range of operators available to the conditional
statement and the fact that the variable expansion operator `\$' is
not required.
As for the {\tt foreach} construction, a {\tt end} keyword is
required to indicate the end of the loop. Note that
{\it fmode-statements} can also contain C-calculator mode commands
(including cmode {\tt while} loops!). Recall that the conditional
statement is a C-calculator mode expression.
\Syntax
\bq while({\it conditions})\\
{\it fmode-statements}\\
end\eq
\Seealso
\bq foreach, if, cmode \eq
@ifhelp
?Credits
@include ../Credits
@endif
@ifhelp
?README
@include ../Copyrights
@endif
|