/usr/share/calc/help/full is in apcalc-common 2.12.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 17599 17600 17601 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 17683 17684 17685 17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 17760 17761 17762 17763 17764 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 17807 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 18045 18046 18047 18048 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 18201 18202 18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 18886 18887 18888 18889 18890 18891 18892 18893 18894 18895 18896 18897 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 19008 19009 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 19366 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 19395 19396 19397 19398 19399 19400 19401 19402 19403 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 19498 19499 19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 19576 19577 19578 19579 19580 19581 19582 19583 19584 19585 19586 19587 19588 19589 19590 19591 19592 19593 19594 19595 19596 19597 19598 19599 19600 19601 19602 19603 19604 19605 19606 19607 19608 19609 19610 19611 19612 19613 19614 19615 19616 19617 19618 19619 19620 19621 19622 19623 19624 19625 19626 19627 19628 19629 19630 19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 19648 19649 19650 19651 19652 19653 19654 19655 19656 19657 19658 19659 19660 19661 19662 19663 19664 19665 19666 19667 19668 19669 19670 19671 19672 19673 19674 19675 19676 19677 19678 19679 19680 19681 19682 19683 19684 19685 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 19719 19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 19731 19732 19733 19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 19761 19762 19763 19764 19765 19766 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 20339 20340 20341 20342 20343 20344 20345 20346 20347 20348 20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 20363 20364 20365 20366 20367 20368 20369 20370 20371 20372 20373 20374 20375 20376 20377 20378 20379 20380 20381 20382 20383 20384 20385 20386 20387 20388 20389 20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400 20401 20402 20403 20404 20405 20406 20407 20408 20409 20410 20411 20412 20413 20414 20415 20416 20417 20418 20419 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 20487 20488 20489 20490 20491 20492 20493 20494 20495 20496 20497 20498 20499 20500 20501 20502 20503 20504 20505 20506 20507 20508 20509 20510 20511 20512 20513 20514 20515 20516 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 20532 20533 20534 20535 20536 20537 20538 20539 20540 20541 20542 20543 20544 20545 20546 20547 20548 20549 20550 20551 20552 20553 20554 20555 20556 20557 20558 20559 20560 20561 20562 20563 20564 20565 20566 20567 20568 20569 20570 20571 20572 20573 20574 20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 20688 20689 20690 20691 20692 20693 20694 20695 20696 20697 20698 20699 20700 20701 20702 20703 20704 20705 20706 20707 20708 20709 20710 20711 20712 20713 20714 20715 20716 20717 20718 20719 20720 20721 20722 20723 20724 20725 20726 20727 20728 20729 20730 20731 20732 20733 20734 20735 20736 20737 20738 20739 20740 20741 20742 20743 20744 20745 20746 20747 20748 20749 20750 20751 20752 20753 20754 20755 20756 20757 20758 20759 20760 20761 20762 20763 20764 20765 20766 20767 20768 20769 20770 20771 20772 20773 20774 20775 20776 20777 20778 20779 20780 20781 20782 20783 20784 20785 20786 20787 20788 20789 20790 20791 20792 20793 20794 20795 20796 20797 20798 20799 20800 20801 20802 20803 20804 20805 20806 20807 20808 20809 20810 20811 20812 20813 20814 20815 20816 20817 20818 20819 20820 20821 20822 20823 20824 20825 20826 20827 20828 20829 20830 20831 20832 20833 20834 20835 20836 20837 20838 20839 20840 20841 20842 20843 20844 20845 20846 20847 20848 20849 20850 20851 20852 20853 20854 20855 20856 20857 20858 20859 20860 20861 20862 20863 20864 20865 20866 20867 20868 20869 20870 20871 20872 20873 20874 20875 20876 20877 20878 20879 20880 20881 20882 20883 20884 20885 20886 20887 20888 20889 20890 20891 20892 20893 20894 20895 20896 20897 20898 20899 20900 20901 20902 20903 20904 20905 20906 20907 20908 20909 20910 20911 20912 20913 20914 20915 20916 20917 20918 20919 20920 20921 20922 20923 20924 20925 20926 20927 20928 20929 20930 20931 20932 20933 20934 20935 20936 20937 20938 20939 20940 20941 20942 20943 20944 20945 20946 20947 20948 20949 20950 20951 20952 20953 20954 20955 20956 20957 20958 20959 20960 20961 20962 20963 20964 20965 20966 20967 20968 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 20980 20981 20982 20983 20984 20985 20986 20987 20988 20989 20990 20991 20992 20993 20994 20995 20996 20997 20998 20999 21000 21001 21002 21003 21004 21005 21006 21007 21008 21009 21010 21011 21012 21013 21014 21015 21016 21017 21018 21019 21020 21021 21022 21023 21024 21025 21026 21027 21028 21029 21030 21031 21032 21033 21034 21035 21036 21037 21038 21039 21040 21041 21042 21043 21044 21045 21046 21047 21048 21049 21050 21051 21052 21053 21054 21055 21056 21057 21058 21059 21060 21061 21062 21063 21064 21065 21066 21067 21068 21069 21070 21071 21072 21073 21074 21075 21076 21077 21078 21079 21080 21081 21082 21083 21084 21085 21086 21087 21088 21089 21090 21091 21092 21093 21094 21095 21096 21097 21098 21099 21100 21101 21102 21103 21104 21105 21106 21107 21108 21109 21110 21111 21112 21113 21114 21115 21116 21117 21118 21119 21120 21121 21122 21123 21124 21125 21126 21127 21128 21129 21130 21131 21132 21133 21134 21135 21136 21137 21138 21139 21140 21141 21142 21143 21144 21145 21146 21147 21148 21149 21150 21151 21152 21153 21154 21155 21156 21157 21158 21159 21160 21161 21162 21163 21164 21165 21166 21167 21168 21169 21170 21171 21172 21173 21174 21175 21176 21177 21178 21179 21180 21181 21182 21183 21184 21185 21186 21187 21188 21189 21190 21191 21192 21193 21194 21195 21196 21197 21198 21199 21200 21201 21202 21203 21204 21205 21206 21207 21208 21209 21210 21211 21212 21213 21214 21215 21216 21217 21218 21219 21220 21221 21222 21223 21224 21225 21226 21227 21228 21229 21230 21231 21232 21233 21234 21235 21236 21237 21238 21239 21240 21241 21242 21243 21244 21245 21246 21247 21248 21249 21250 21251 21252 21253 21254 21255 21256 21257 21258 21259 21260 21261 21262 21263 21264 21265 21266 21267 21268 21269 21270 21271 21272 21273 21274 21275 21276 21277 21278 21279 21280 21281 21282 21283 21284 | *************
* intro
*************
What is calc?
Calc is an interactive calculator which provides for easy large
numeric calculations, but which also can be easily programmed
for difficult or long calculations. It can accept a command line
argument, in which case it executes that single command and exits.
Otherwise, it enters interactive mode. In this mode, it accepts
commands one at a time, processes them, and displays the answers.
In the simplest case, commands are simply expressions which are
evaluated. For example, the following line can be input:
3 * (4 + 1)
and the calculator will print:
15
Calc as the usual collection of arithmetic operators +, -, /, *
as well as ^ (exponentiation), % (modulus) and // (integer divide).
For example:
3 * 19^43 - 1
will produce:
29075426613099201338473141505176993450849249622191102976
Notice that calc values can be very large. For example:
2^23209-1
will print:
402874115778988778181873329071 ... many digits ... 3779264511
The special '.' symbol (called dot), represents the result of the
last command expression, if any. This is of great use when a series
of partial results are calculated, or when the output mode is changed
and the last result needs to be redisplayed. For example, the above
result can be modified by typing:
. % (2^127-1)
and the calculator will print:
47385033654019111249345128555354223304
For more complex calculations, variables can be used to save the
intermediate results. For example, the result of adding 7 to the
previous result can be saved by typing:
curds = 15
whey = 7 + 2*curds
Functions can be used in expressions. There are a great number of
pre-defined functions. For example, the following will calculate
the factorial of the value of 'old':
fact(whey)
and the calculator prints:
13763753091226345046315979581580902400000000
The calculator also knows about complex numbers, so that typing:
(2+3i) * (4-3i)
cos(.)
will print:
17+6i
-55.50474777265624667147+193.9265235748927986537i
The calculator can calculate transcendental functions, and accept and
display numbers in real or exponential format. For example, typing:
config("display", 70)
epsilon(1e-70)
sin(1)
prints:
0.8414709848078965066525023216302989996225630607983710656727517099919104
Calc can output values in terms of fractions, octal or hexadecimal.
For example:
config("mode", "fraction"),
(17/19)^23
base(16),
(19/17)^29
will print:
19967568900859523802559065713/257829627945307727248226067259
0x9201e65bdbb801eaf403f657efcf863/0x5cd2e2a01291ffd73bee6aa7dcf7d1
All numbers are represented as fractions with arbitrarily large
numerators and denominators which are always reduced to lowest terms.
Real or exponential format numbers can be input and are converted
to the equivalent fraction. Hex, binary, or octal numbers can be
input by using numbers with leading '0x', '0b' or '0' characters.
Complex numbers can be input using a trailing 'i', as in '2+3i'.
Strings and characters are input by using single or double quotes.
Commands are statements in a C-like language, where each input
line is treated as the body of a procedure. Thus the command
line can contain variable declarations, expressions, labels,
conditional tests, and loops. Assignments to any variable name
will automatically define that name as a global variable. The
other important thing to know is that all non-assignment expressions
which are evaluated are automatically printed. Thus, you can evaluate
an expression's value by simply typing it in.
Many useful built-in mathematical functions are available. Use
the:
help builtin
command to list them.
You can also define your own functions by using the 'define' keyword,
followed by a function declaration very similar to C.
define f2(n)
{
local ans;
ans = 1;
while (n > 1)
ans *= (n -= 2);
return ans;
}
Thus the input:
f2(79)
will produce;
1009847364737869270905302433221592504062302663202724609375
Functions which only need to return a simple expression can be defined
using an equals sign, as in the example:
define sc(a,b) = a^3 + b^3
Thus the input:
sc(31, 61)
will produce;
256772
Variables in functions can be defined as either 'global', 'local',
or 'static'. Global variables are common to all functions and the
command line, whereas local variables are unique to each function
level, and are destroyed when the function returns. Static variables
are scoped within single input files, or within functions, and are
never destroyed. Variables are not typed at definition time, but
dynamically change as they are used.
For more information about the calc language and features, try:
help overview
In particular, check out the other help functions listed in the
overview help file.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: intro,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/intro,v $
##
## Under source code control: 1991/07/21 04:37:21
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* overview
*************
CALC - An arbitrary precision calculator.
by David I. Bell
This is a calculator program with arbitrary precision arithmetic.
All numbers are represented as fractions with arbitrarily large
numerators and denominators which are always reduced to lowest terms.
Real or exponential format numbers can be input and are converted
to the equivalent fraction. Hex, binary, or octal numbers can be
input by using numbers with leading '0x', '0b' or '0' characters.
Complex numbers can be input using a trailing 'i', as in '2+3i'.
Strings and characters are input by using single or double quotes.
Commands are statements in a C-like language, where each input
line is treated as the body of a procedure. Thus the command
line can contain variable declarations, expressions, labels,
conditional tests, and loops. Assignments to any variable name
will automatically define that name as a global variable. The
other important thing to know is that all non-assignment expressions
which are evaluated are automatically printed. Thus, you can evaluate
an expression's value by simply typing it in.
Many useful built-in mathematical functions are available. Use
the 'show builtins' command to list them. You can also define
your own functions by using the 'define' keyword, followed by a
function declaration very similar to C. Functions which only
need to return a simple expression can be defined using an
equals sign, as in the example 'define sc(a,b) = a^3 + b^3'.
Variables in functions can be defined as either 'global', 'local',
or 'static'. Global variables are common to all functions and the
command line, whereas local variables are unique to each function
level, and are destroyed when the function returns. Static variables
are scoped within single input files, or within functions, and are
never destroyed. Variables are not typed at definition time, but
dynamically change as they are used. So you must supply the correct
type of variable to those functions and operators which only work
for a subset of types.
Calc has a help command that will produce information about
every builtin function, command as well as a number of other
aspects of calc usage. Try the command:
help help
for and overview of the help system. The command:
help builtin
provides information on built-in mathematical functions, whereas:
help asinh
will provides information a specific function. The following
help files:
help command
help define
help operator
help statement
help variable
provide a good overview of the calc language. If you are familiar
with C, you should also try:
help unexpected
It contains information about differences between C and calc
that may surprize you.
To learn about calc standard resource files, try:
help resource
To learn how to invoke the calc command and about calc -flags, try:
help usage
To learn about calc shell scripts, try:
help script
A full and extensive overview of calc may be obtained by:
help full
By default, arguments to functions are passed by value (even
matrices). For speed, you can put an ampersand before any
variable argument in a function call, and that variable will be
passed by reference instead. However, if the function changes
its argument, the variable will change. Arguments to built-in
functions and object manipulation functions are always called
by reference. If a user-defined function takes more arguments
than are passed, the undefined arguments have the null value.
The 'param' function returns function arguments by argument
number, and also returns the number of arguments passed. Thus
functions can be written to handle an arbitrary number of
arguments.
The mat statement is used to create a matrix. It takes a
variable name, followed by the bounds of the matrix in square
brackets. The lower bounds are zero by default, but colons can
be used to change them. For example 'mat foo[3, 1:10]' defines
a two dimensional matrix, with the first index ranging from 0
to 3, and the second index ranging from 1 to 10. The bounds of
a matrix can be an expression calculated at runtime.
Lists of values are created using the 'list' function, and values can
be inserted or removed from either the front or the end of the list.
List elements can be indexed directly using double square brackets.
The obj statement is used to create an object. Objects are
user-defined values for which user-defined routines are
implicitly called to perform simple actions such as add,
multiply, compare, and print. Objects types are defined as in
the example 'obj complex {real, imag}', where 'complex' is the
name of the object type, and 'real' and 'imag' are element
names used to define the value of the object (very much like
structures). Variables of an object type are created as in the
example 'obj complex x,y', where 'x' and 'y' are variables.
The elements of an object are referenced using a dot, as in the
example 'x.real'. All user-defined routines have names composed
of the object type and the action to perform separated by an
underscore, as in the example 'complex_add'. The command 'show
objfuncs' lists all the definable routines. Object routines
which accept two arguments should be prepared to handle cases
in which either one of the arguments is not of the expected
object type.
These are the differences between the normal C operators and
the ones defined by the calculator. The '/' operator divides
fractions, so that '7 / 2' evaluates to 7/2. The '//' operator
is an integer divide, so that '7 // 2' evaluates to 3. The '^'
operator is a integral power function, so that 3^4 evaluates to
81. Matrices of any dimension can be treated as a zero based
linear array using double square brackets, as in 'foo[[3]]'.
Matrices can be indexed by using commas between the indices, as
in foo[3,4]. Object and list elements can be referenced by
using double square brackets.
The print statement is used to print values of expressions.
Separating values by a comma puts one space between the output
values, whereas separating values by a colon concatenates the
output values. A trailing colon suppresses printing of the end
of line. An example of printing is 'print \"The square of\",
x, \"is\", x^2\'.
The 'config' function is used to modify certain parameters that
affect calculations or the display of values. For example, the
output display mode can be set using 'config(\"mode\", type)',
where 'type' is one of 'frac', 'int', 'real', 'exp', 'hex',
'oct', or 'bin'. The default output mode is real. For the
integer, real, or exponential formats, a leading '~' indicates
that the number was truncated to the number of decimal places
specified by the default precision. If the '~' does not
appear, then the displayed number is the exact value.
The number of decimal places printed is set by using
'config(\"display\", n)'. The default precision for
real-valued functions can be set by using 'epsilon(x)', where x
is the required precision (such as 1e-50).
There is a command stack feature so that you can easily
re-execute previous commands and expressions from the terminal.
You can also edit the current command before it is completed.
Both of these features use emacs-like commands.
Files can be read in by using the 'read filename' command.
These can contain both functions to be defined, and expressions
to be calculated. Global variables which are numbers can be
saved to a file by using the 'write filename' command.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: overview,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/overview,v $
##
## Under source code control: 1991/07/21 04:37:23
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* help
*************
For more information while running calc, type help followed by one of the
following topics:
topic description
----- -----------
intro introduction to calc
overview overview of calc
help this file
assoc using associations
builtin builtin functions
command top level commands
config configuration parameters
custom information about the custom builtin interface
define how to define functions
environment how environment variables effect calc
errorcodes calc generated error codes
expression expression sequences
file using files
history command history
interrupt how interrupts are handled
list using lists
mat using matrices
obj user defined data types
operator math, relational, logic and variable access operators
statement flow control and declaration statements
types builtin data types
unexpected unexpected syntax/usage surprises for C programmers
usage how to invoke the calc command
variable variables and variable declarations
bindings input & history character bindings
custom_cal information about custom calc resource files
libcalc using the arbitrary precision routines in a C program
new_custom information about how to add new custom functions
resource standard calc resource files
script using calc shell scripts
cscript info on the calc shell scripts supplied with calc
archive where to get the latest versions of calc
bugs known bugs and mis-features
changes recent changes to calc
contrib how to contribute scripts, code or custom functions
todo list of priority action items for calc
wishlist wish list of future enhancements of calc
credit who wrote calc and who helped
copyright calc copyright and the GNU LGPL
copying details on the Calc GNU Lesser General Public License
copying-lgpl calc GNU Lesser General Public License text
full all of the above (in the above order)
For example:
help usage
will print the calc command usage information. One can obtain calc help
without invoking any startup code by running calc as follows:
calc -q help topic
where 'topic' is one of the topics listed above.
You can also ask for help on a particular builtin function name. For example:
help asinh
help round
See:
help builtin
for a list of builtin functions.
Some calc operators have their own help pages:
help =
help ->
help *
help .
help %
help //
help #
If the -m mode disallows opening files for reading or execution of programs,
then the help facility will be disabled. See:
help usage
for details of the -m mode.
The help command is able to display installed help files for custom builtin
functions. However, if the custom name is the same as a standard help
file, the standard help file will be displayed instead. The custom help
builtin should be used to directly access the custom help file.
For example, the custom help builtin has the same name as the standard
help file. That is:
help help
will print this file only. However the custom help builtin will print
only the custom builtin help file:
custom("help", "help");
will by-pass a standard help file and look for the custom version directly.
As a hack, the following:
help custhelp/anything
as the same effect as:
custom("help", "anything");
## Copyright (C) 1999-2007 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: help,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/help,v $
##
## Under source code control: 1991/07/21 04:37:20
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* assoc
*************
NAME
assoc - create a new association array
SYNOPSIS
assoc()
TYPES
return association
DESCRIPTION
This function returns an empty association array.
After A = assoc(), elements can be added to the association by
assignments of the forms
A[a_1] = v_1
A[a_1, a_2] = v_2
A[a_1, a_2, a_3] = v_3
A[a_1, a_2, a_3, a_4] = v_4
There are no restrictions on the values of the "indices" a_i or
the "values" v_i.
After the above assignments, so long as no new values have been
assigned to A[a_i], etc., the expressions A[a_1], A[a_1, a_2], etc.
will return the values v_1, v_2, ...
Until A[a_1], A[a_1, a_2], ... are defined as described above, these
expressions return the null value.
Thus associations act like matrices except that different elements
may have different numbers (between 1 and 4 inclusive) of indices,
and these indices need not be integers in specified ranges.
Assignment of a null value to an element of an association does not
delete the element, but a later reference to that element will return
the null value as if the element is undefined.
The elements of an association are stored in a hash table for
quick access. The index values are hashed to select the correct
hash chain for a small sequential search for the element. The hash
table will be resized as necessary as the number of entries in
the association becomes larger.
The size function returns the number of elements in an association.
This size will include elements with null values.
Double bracket indexing can be used for associations to walk through
the elements of the association. The order that the elements are
returned in as the index increases is essentially random. Any
change made to the association can reorder the elements, this making
a sequential scan through the elements difficult.
The search and rsearch functions can search for an element in an
association which has the specified value. They return the index
of the found element, or a NULL value if the value was not found.
Associations can be copied by an assignment, and can be compared
for equality. But no other operations on associations have meaning,
and are illegal.
EXAMPLE
; A = assoc(); print A
assoc (0 elements):
; A["zero"] = 0; A["one"] = 1; A["two"] = 2; A["three"] = 3;
; A["smallest", "prime"] = 2;
; print A
assoc (5 elements);
["two"] = 2
["three"] = 3
["one"] = 1
["zero"] = 0
["smallest","prime"] = 2
LIMITS
none
LINK LIBRARY
none
SEE ALSO
isassoc, rsearch, search, size
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: assoc,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/assoc,v $
##
## Under source code control: 1994/09/25 20:22:31
## File existed as early as: 1994
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* builtin
*************
Builtin functions
There is a large number of built-in functions. Many of the
functions work on several types of arguments, whereas some only
work for the correct types (e.g., numbers or strings). In the
following description, this is indicated by whether or not the
description refers to values or numbers. This display is generated
by the 'show builtin' command.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: builtin.top,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/builtin.top,v $
##
## Under source code control: 1995/07/10 01:17:53
## File existed as early as: 1995
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
Name Args Description
abs 1-2 absolute value within accuracy b
access 1-2 determine accessibility of file a for mode b
acos 1-2 arccosine of a within accuracy b
acosh 1-2 inverse hyperbolic cosine of a within accuracy b
acot 1-2 arccotangent of a within accuracy b
acoth 1-2 inverse hyperbolic cotangent of a within accuracy b
acsc 1-2 arccosecant of a within accuracy b
acsch 1-2 inverse csch of a within accuracy b
agd 1-2 inverse gudermannian function
append 1+ append values to end of list
appr 1-3 approximate a by multiple of b using rounding c
arg 1-2 argument (the angle) of complex number
argv 0-1 calc argc or argv string
asec 1-2 arcsecant of a within accuracy b
asech 1-2 inverse hyperbolic secant of a within accuracy b
asin 1-2 arcsine of a within accuracy b
asinh 1-2 inverse hyperbolic sine of a within accuracy b
assoc 0 create new association array
atan 1-2 arctangent of a within accuracy b
atan2 2-3 angle to point (b,a) within accuracy c
atanh 1-2 inverse hyperbolic tangent of a within accuracy b
avg 0+ arithmetic mean of values
base 0-1 set default output base
base2 0-1 set default secondary output base
bernoulli 1 Bernoulli number for index a
bit 2 whether bit b in value a is set
blk 0-3 block with or without name, octet number, chunksize
blkcpy 2-5 copy value to/from a block: blkcpy(d,s,len,di,si)
blkfree 1 free all storage from a named block
blocks 0-1 named block with specified index, or null value
bround 1-3 round value a to b number of binary places
btrunc 1-2 truncate a to b number of binary places
calc_tty 0 set tty for interactivity
calclevel 0 current calculation level
calcpath 0 current CALCPATH search path value
catalan 1 catalan number for index a
ceil 1 smallest integer greater than or equal to number
cfappr 1-3 approximate a within accuracy b using
continued fractions
cfsim 1-2 simplify number using continued fractions
char 1 character corresponding to integer value
cmdbuf 0 command buffer
cmp 2 compare values returning -1, 0, or 1
comb 2 combinatorial number a!/b!(a-b)!
config 1-2 set or read configuration value
conj 1 complex conjugate of value
copy 2-5 copy value to/from a block: copy(s,d,len,si,di)
cos 1-2 cosine of value a within accuracy b
cosh 1-2 hyperbolic cosine of a within accuracy b
cot 1-2 cotangent of a within accuracy b
coth 1-2 hyperbolic cotangent of a within accuracy b
count 2 count listr/matrix elements satisfying some condition
cp 2 cross product of two vectors
csc 1-2 cosecant of a within accuracy b
csch 1-2 hyperbolic cosecant of a within accuracy b
ctime 0 date and time as string
custom 0+ custom builtin function interface
delete 2 delete element from list a at position b
den 1 denominator of fraction
det 1 determinant of matrix
digit 2-3 digit at specified decimal place of number
digits 1-2 number of digits in base b representation of a
display 0-1 number of decimal digits for displaying numbers
dp 2 dot product of two vectors
epsilon 0-1 set or read allowed error for real calculations
errcount 0-1 set or read error count
errmax 0-1 set or read maximum for error count
errno 0-1 set or read calc_errno
error 0-1 generate error value
estr 1 exact text string representation of value
euler 1 Euler number
eval 1 evaluate expression from string to value
exp 1-2 exponential of value a within accuracy b
factor 1-3 lowest prime factor < b of a, return c if error
fcnt 2 count of times one number divides another
fib 1 Fibonacci number F(n)
forall 2 do function for all elements of list or matrix
frem 2 number with all occurrences of factor removed
fact 1 factorial
fclose 0+ close file
feof 1 whether EOF reached for file
ferror 1 whether error occurred for file
fflush 0+ flush output to file(s)
fgetc 1 read next char from file
fgetfield 1 read next white-space delimited field from file
fgetfile 1 read to end of file
fgetline 1 read next line from file, newline removed
fgets 1 read next line from file, newline is kept
fgetstr 1 read next null-terminated string from file, null
character is kept
files 0-1 return opened file or max number of opened files
floor 1 greatest integer less than or equal to number
fopen 2 open file name a in mode b
fpathopen 2-3 open file name a in mode b, search for a along
CALCPATH or path c
fprintf 2+ print formatted output to opened file
fputc 2 write a character to a file
fputs 2+ write one or more strings to a file
fputstr 2+ write one or more null-terminated strings to a file
free 0+ free listed or all global variables
freebernoulli 0 free stored Bernoulli numbers
freeeuler 0 free stored Euler numbers
freeglobals 0 free all global and visible static variables
freeredc 0 free redc data cache
freestatics 0 free all unscoped static variables
freopen 2-3 reopen a file stream to a named file
fscan 2+ scan a file for assignments to one or
more variables
fscanf 2+ formatted scan of a file for assignment to one
or more variables
fseek 2-3 seek to position b (offset from c) in file a
fsize 1 return the size of the file
ftell 1 return the file position
frac 1 fractional part of value
gcd 1+ greatest common divisor
gcdrem 2 a divided repeatedly by gcd with b
gd 1-2 gudermannian function
getenv 1 value of environment variable (or NULL)
hash 1+ return non-negative hash value for one or
more values
head 2 return list of specified number at head of a list
highbit 1 high bit number in base 2 representation
hmean 0+ harmonic mean of values
hnrmod 4 v mod h*2^n+r, h>0, n>0, r = -1, 0 or 1
hypot 2-3 hypotenuse of right triangle within accuracy c
ilog 2 integral log of a to integral base b
ilog10 1 integral log of a number base 10
ilog2 1 integral log of a number base 2
im 1 imaginary part of complex number
indices 2 indices of a specified assoc or mat value
inputlevel 0 current input depth
insert 2+ insert values c ... into list a at position b
int 1 integer part of value
inverse 1 multiplicative inverse of value
iroot 2 integer b'th root of a
isassoc 1 whether a value is an association
isatty 1 whether a file is a tty
isblk 1 whether a value is a block
isconfig 1 whether a value is a config state
isdefined 1 whether a string names a function
iserror 1 where a value is an error
iseven 1 whether a value is an even integer
isfile 1 whether a value is a file
ishash 1 whether a value is a hash state
isident 1 returns 1 if identity matrix
isint 1 whether a value is an integer
islist 1 whether a value is a list
ismat 1 whether a value is a matrix
ismult 2 whether a is a multiple of b
isnull 1 whether a value is the null value
isnum 1 whether a value is a number
isobj 1 whether a value is an object
isobjtype 1 whether a string names an object type
isodd 1 whether a value is an odd integer
isoctet 1 whether a value is an octet
isprime 1-2 whether a is a small prime, return b if error
isptr 1 whether a value is a pointer
isqrt 1 integer part of square root
isrand 1 whether a value is a additive 55 state
israndom 1 whether a value is a Blum state
isreal 1 whether a value is a real number
isrel 2 whether two numbers are relatively prime
isstr 1 whether a value is a string
issimple 1 whether value is a simple type
issq 1 whether or not number is a square
istype 2 whether the type of a is same as the type of b
jacobi 2 -1 => a is not quadratic residue mod b
1 => b is composite, or a is quad residue of b
join 1+ join one or more lists into one list
lcm 1+ least common multiple
lcmfact 1 lcm of all integers up till number
lfactor 2 lowest prime factor of a in first b primes
links 1 links to number or string value
list 0+ create list of specified values
ln 1-2 natural logarithm of value a within accuracy b
log 1-2 base 10 logarithm of value a within accuracy b
lowbit 1 low bit number in base 2 representation
ltol 1-2 leg-to-leg of unit right triangle (sqrt(1 - a^2))
makelist 1 create a list with a null elements
matdim 1 number of dimensions of matrix
matfill 2-3 fill matrix with value b (value c on diagonal)
matmax 2 maximum index of matrix a dim b
matmin 2 minimum index of matrix a dim b
matsum 1 sum the numeric values in a matrix
mattrace 1 return the trace of a square matrix
mattrans 1 transpose of matrix
max 0+ maximum value
memsize 1 number of octets used by the value, including overhead
meq 3 whether a and b are equal modulo c
min 0+ minimum value
minv 2 inverse of a modulo b
mmin 2 a mod b value with smallest abs value
mne 3 whether a and b are not equal modulo c
mod 2-3 residue of a modulo b, rounding type c
modify 2 modify elements of a list or matrix
name 1 name assigned to block or file
near 2-3 sign of (abs(a-b) - c)
newerror 0-1 create new error type with message a
nextcand 1-5 smallest value == d mod e > a, ptest(a,b,c) true
nextprime 1-2 return next small prime, return b if err
norm 1 norm of a value (square of absolute value)
null 0+ null value
num 1 numerator of fraction
ord 1 integer corresponding to character value
isupper 1 whether character is upper case
islower 1 whether character is lower case
isalnum 1 whether character is alpha-numeric
isalpha 1 whether character is alphabetic
iscntrl 1 whether character is a control character
isdigit 1 whether character is a digit
isgraph 1 whether character is a graphical character
isprint 1 whether character is printable
ispunct 1 whether character is a punctuation
isspace 1 whether character is a space character
isxdigit 1 whether character is a hexadecimal digit
param 1 value of parameter n (or parameter count if n
is zero)
perm 2 permutation number a!/(a-b)!
prevcand 1-5 largest value == d mod e < a, ptest(a,b,c) true
prevprime 1-2 return previous small prime, return b if err
pfact 1 product of primes up till number
pi 0-1 value of pi accurate to within epsilon
pix 1-2 number of primes <= a < 2^32, return b if error
places 1-2 places after "decimal" point (-1 if infinite)
pmod 3 mod of a power (a ^ b (mod c))
polar 2-3 complex value of polar coordinate (a * exp(b*1i))
poly 1+ evaluates a polynomial given its coefficients
or coefficient-list
pop 1 pop value from front of list
popcnt 1-2 number of bits in a that match b (or 1)
power 2-3 value a raised to the power b within accuracy c
protect 1-3 read or set protection level for variable
ptest 1-3 probabilistic primality test
printf 1+ print formatted output to stdout
prompt 1 prompt for input line using value a
push 1+ push values onto front of list
putenv 1-2 define an environment variable
quo 2-3 integer quotient of a by b, rounding type c
quomod 4-5 set c and d to quotient and remainder of a
divided by b
rand 0-2 additive 55 random number [0,2^64), [0,a), or [a,b)
randbit 0-1 additive 55 random number [0,2^a)
random 0-2 Blum-Blum-Shub random number [0,2^64), [0,a), or [a,b)
randombit 0-1 Blum-Blum-Sub random number [0,2^a)
randperm 1 random permutation of a list or matrix
rcin 2 convert normal number a to REDC number mod b
rcmul 3 multiply REDC numbers a and b mod c
rcout 2 convert REDC number a mod b to normal number
rcpow 3 raise REDC number a to power b mod c
rcsq 2 square REDC number a mod b
re 1 real part of complex number
remove 1 remove value from end of list
reverse 1 reverse a copy of a matrix or list
rewind 0+ rewind file(s)
rm 1+ remove file(s), -f turns off no-such-file errors
root 2-3 value a taken to the b'th root within accuracy c
round 1-3 round value a to b number of decimal places
rsearch 2-4 reverse search matrix or list for value b
starting at index c
runtime 0 user and kernel mode cpu time in seconds
saveval 1 set flag for saving values
scale 2 scale value up or down by a power of two
scan 1+ scan standard input for assignment to one
or more variables
scanf 2+ formatted scan of standard input for assignment
to variables
search 2-4 search matrix or list for value b starting
at index c
sec 1-2 sec of a within accuracy b
sech 1-2 hyperbolic secant of a within accuracy b
seed 0 return a 64 bit seed for a psuedo-random generator
segment 2-3 specified segment of specified list
select 2 form sublist of selected elements from list
setbit 2-3 set specified bit in string
sgn 1 sign of value (-1, 0, 1)
sha1 0+ Secure Hash Algorithm (SHS-1 FIPS Pub 180-1)
sin 1-2 sine of value a within accuracy b
sinh 1-2 hyperbolic sine of a within accuracy b
size 1 total number of elements in value
sizeof 1 number of octets used to hold the value
sleep 0-1 suspend operation for a seconds
sort 1 sort a copy of a matrix or list
sqrt 1-3 square root of value a within accuracy b
srand 0-1 seed the rand() function
srandom 0-4 seed the random() function
ssq 1+ sum of squares of values
stoponerror 0-1 assign value to stoponerror flag
str 1 simple value converted to string
strtoupper 1 Make string upper case
strtolower 1 Make string lower case
strcat 1+ concatenate strings together
strcmp 2 compare two strings
strcasecmp 2 compare two strings case independent
strcpy 2 copy string to string
strerror 0-1 string describing error type
strlen 1 length of string
strncmp 3 compare strings a, b to c characters
strncasecmp 3 compare strings a, b to c characters case independent
strncpy 3 copy up to c characters from string to string
strpos 2 index of first occurrence of b in a
strprintf 1+ return formatted output as a string
strscan 2+ scan a string for assignments to one or more variables
strscanf 2+ formatted scan of string for assignments to variables
substr 3 substring of a from position b for c chars
sum 0+ sum of list or object sums and/or other terms
swap 2 swap values of variables a and b (can be dangerous)
system 1 call Unix command
systime 0 kernel mode cpu time in seconds
tail 2 retain list of specified number at tail of list
tan 1-2 tangent of a within accuracy b
tanh 1-2 hyperbolic tangent of a within accuracy b
test 1 test that value is nonzero
time 0 number of seconds since 00:00:00 1 Jan 1970 UTC
trunc 1-2 truncate a to b number of decimal places
ungetc 2 unget char read from file
usertime 0 user mode cpu time in seconds
version 0 calc version string
xor 1+ logical xor
The config function sets or reads the value of a configuration
parameter. The first argument is a string which names the parameter
to be set or read. If only one argument is given, then the current
value of the named parameter is returned. If two arguments are given,
then the named parameter is set to the value of the second argument,
and the old value of the parameter is returned. Therefore you can
change a parameter and restore its old value later. The possible
parameters are explained in the next section.
The scale function multiplies or divides a number by a power of 2.
This is used for fractional calculations, unlike the << and >>
operators, which are only defined for integers. For example,
scale(6, -3) is 3/4.
The quomod function is used to obtain both the quotient and remainder
of a division in one operation. The first two arguments a and b are
the numbers to be divided. The last two arguments c and d are two
variables which will be assigned the quotient and remainder. For
nonnegative arguments, the results are equivalent to computing a//b
and a%b. If a is negative and the remainder is nonzero, then the
quotient will be one less than a//b. This makes the following three
properties always hold: The quotient c is always an integer. The
remainder d is always 0 <= d < b. The equation a = b * c + d always
holds. This function returns 0 if there is no remainder, and 1 if
there is a remainder. For examples, quomod(10, 3, x, y) sets x to 3,
y to 1, and returns the value 1, and quomod(-4, 3.14159, x, y) sets x
to -2, y to 2.28318, and returns the value 1.
The eval function accepts a string argument and evaluates the
expression represented by the string and returns its value.
The expression can include function calls and variable references.
For example, eval("fact(3) + 7") returns 13. When combined with
the prompt function, this allows the calculator to read values from
the user. For example, x=eval(prompt("Number: ")) sets x to the
value input by the user.
The digit and bit functions return individual digits of a number,
either in base 10 or in base 2, where the lowest digit of a number
is at digit position 0. For example, digit(5678, 3) is 5, and
bit(0b1000100, 2) is 1. Negative digit positions indicate places
to the right of the decimal or binary point, so that for example,
digit(3.456, -1) is 4.
The ptest builtin is a primality testing function. The
1st argument is the suspected prime to be tested. The
absolute value of the 2nd argument is an iteration count.
If ptest is called with only 2 args, the 3rd argument is
assumed to be 0. If ptest is called with only 1 arg, the
2nd argument is assumed to be 1. Thus, the following
calls are equivalent:
ptest(a)
ptest(a,1)
ptest(a,1,0)
Normally ptest performs a some checks to determine if the
value is divisable by some trivial prime. If the 2nd
argument is < 0, then the trivial check is omitted.
For example, ptest(a,10) performs the same work as:
ptest(a,-3) (7 tests without trivial check)
ptest(a,-7,3) (3 more tests without the trivial check)
The ptest function returns 0 if the number is definitely not
prime, and 1 is the number is probably prime. The chance
of a number which is probably prime being actually composite
is less than 1/4 raised to the power of the iteration count.
For example, for a random number p, ptest(p, 10) incorrectly
returns 1 less than once in every million numbers, and you
will probably never find a number where ptest(p, 20) gives
the wrong answer.
The first 3 args of nextcand and prevcand functions are the same
arguments as ptest. But unlike ptest, nextcand and prevcand return
the next and previous values for which ptest is true.
For example, nextcand(2^1000) returns 2^1000+297 because
2^1000+297 is the smallest value x > 2^1000 for which
ptest(x,1) is true. And for example, prevcand(2^31-1,10,5)
returns 2147483629 (2^31-19) because 2^31-19 is the largest
value y < 2^31-1 for which ptest(y,10,5) is true.
The nextcand and prevcand functions also have a 5 argument form:
nextcand(num, count, skip, modval, modulus)
prevcand(num, count, skip, modval, modulus)
return the smallest (or largest) value ans > num (or < num) that
is also == modval % modulus for which ptest(ans,count,skip) is true.
The builtins nextprime(x) and prevprime(x) return the
next and previous primes with respect to x respectively.
As of this release, x must be < 2^32. With one argument, they
will return an error if x is out of range. With two arguments,
they will not generate an error but instead will return y.
The builtin function pix(x) returns the number of primes <= x.
As of this release, x must be < 2^32. With one argument, pix(x)
will return an error if x is out of range. With two arguments,
pix(x,y) will not generate an error but instead will return y.
The builtin function factor may be used to search for the
smallest factor of a given number. The call factor(x,y)
will attempt to find the smallest factor of x < min(x,y).
As of this release, y must be < 2^32. If y is omitted, y
is assumed to be 2^32-1.
If x < 0, factor(x,y) will return -1. If no factor <
min(x,y) is found, factor(x,y) will return 1. In all other
cases, factor(x,y) will return the smallest prime factor
of x. Note except for the case when abs(x) == 1, factor(x,y)
will not return x.
If factor is called with y that is too large, or if x or y
is not an integer, calc will report an error. If a 3rd argument
is given, factor will return that value instead. For example,
factor(1/2,b,c) will return c instead of issuing an error.
The builtin lfactor(x,y) searches a number of primes instead
of below a limit. As of this release, y must be <= 203280221
(y <= pix(2^32-1)). In all other cases, lfactor is operates
in the same way as factor.
If lfactor is called with y that is too large, or if x or y
is not an integer, calc will report an error. If a 3rd argument
is given, lfactor will return that value instead. For example,
lfactor(1/2,b,c) will return c instead of issuing an error.
The lfactor function is slower than factor. If possible factor
should be used instead of lfactor.
The builtin isprime(x) will attempt to determine if x is prime.
As of this release, x must be < 2^32. With one argument, isprime(x)
will return an error if x is out of range. With two arguments,
isprime(x,y) will not generate an error but instead will return y.
The functions rcin, rcmul, rcout, rcpow, and rcsq are used to
perform modular arithmetic calculations for large odd numbers
faster than the usual methods. To do this, you first use the
rcin function to convert all input values into numbers which are
in a format called REDC format. Then you use rcmul, rcsq, and
rcpow to multiply such numbers together to produce results also
in REDC format. Finally, you use rcout to convert a number in
REDC format back to a normal number. The addition, subtraction,
negation, and equality comparison between REDC numbers are done
using the normal modular methods. For example, to calculate the
value 13 * 17 + 1 (mod 11), you could use:
p = 11;
t1 = rcin(13, p);
t2 = rcin(17, p);
t3 = rcin(1, p);
t4 = rcmul(t1, t2, p);
t5 = (t4 + t3) % p;
answer = rcout(t5, p);
The swap function exchanges the values of two variables without
performing copies. For example, after:
x = 17;
y = 19;
swap(x, y);
then x is 19 and y is 17. This function should not be used to
swap a value which is contained within another one. If this is
done, then some memory will be lost. For example, the following
should not be done:
mat x[5];
swap(x, x[0]);
The hash function returns a relatively small non-negative integer
for one or more input values. The hash values should not be used
across runs of the calculator, since the algorithms used to generate
the hash value may change with different versions of the calculator.
The base function allows one to specify how numbers should be
printed. The base function provides a numeric shorthand to the
config("mode") interface. With no args, base() will return the
current mode. With 1 arg, base(val) will set the mode according to
the arg and return the previous mode.
The following convention is used to declare modes:
base config
value string
2 "binary" binary fractions
8 "octal" octal fractions
10 "real" decimal floating point
16 "hex" hexadecimal fractions
-10 "int" decimal integer
1/3 "frac" decimal fractions
1e20 "exp" decimal exponential
For convenience, any non-integer value is assumed to mean "frac",
and any integer >= 2^64 is assumed to mean "exp".
## Copyright (C) 1999-2007 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: builtin.end,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/builtin.end,v $
##
## Under source code control: 1995/07/10 01:17:53
## File existed as early as: 1995
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* command
*************
Command sequence
This is a sequence of any the following command formats, where
each command is terminated by a semicolon or newline. Long command
lines can be extended by using a back-slash followed by a newline
character. When this is done, the prompt shows a double angle
bracket to indicate that the line is still in progress. Certain
cases will automatically prompt for more input in a similar manner,
even without the back-slash. The most common case for this is when
a function is being defined, but is not yet completed.
Each command sequence terminates only on an end of file. In
addition, commands can consist of expression sequences, which are
described in the next section.
define a function
-----------------
define function(params) { body }
define function(params) = expression
This first form defines a full function which can consist
of declarations followed by many statements which implement
the function.
The second form defines a simple function which calculates
the specified expression value from the specified parameters.
The expression cannot be a statement. However, the comma
and question mark operators can be useful. Examples of
simple functions are:
define sumcubes(a, b) = a^3 + b^3
define pimod(a) = a % pi()
define printnum(a, n, p)
{
if (p == 0) {
print a: "^": n, "=", a^n;
} else {
print a: "^": n, "mod", p, "=", pmod(a,n,p);
}
}
read calc commands
------------------
read $var
read -once $var
read filename
read -once filename
This reads definitions from the specified calc resource filename.
In the 1st and 2nd forms, if var is a global variable string
value, then the value of that variable is used as a filename.
The following is equivalent to read lucas.cal or read "lucas.cal":
global var = "lucas.cal";
read $var;
In the 3rd or 4th forms, the filename argument is treated
as a literal string, not a variable. In these forms, the
name can be quoted if desired.
The calculator uses the CALCPATH environment variable to
search through the specified directories for the filename,
similarly to the use of the PATH environment variable.
If CALCPATH is not defined, then a default path which is
usually ":/usr/local/lib/calc" is used.
The ".cal" extension is defaulted for input files, so that
if "filename" is not found, then "filename.cal" is then
searched for. The contents of the filename are command
sequences which can consist of expressions to evaluate or
functions to define, just like at the top level command level.
When -once is given, the read command acts like the regular
read expect that it will ignore filename if is has been
previously read.
The read -once form is particularly useful in a resource
file that needs to read a 2nd resource file. By using the
READ -once command, one will not reread that 2nd resource
file, nor will once risk entering into a infinite READ loop
(where that 2nd resource file directly or indirectly does
a READ of the first resource file).
If the -m mode disallows opening of files for reading,
this command will be disabled.
write calc commands
-------------------
write $var
write filename
This writes the values of all global variables to the
specified filename, in such a way that the file can be
later read in order to recreate the variable values.
For speed reasons, values are written as hex fractions.
This command currently only saves simple types, so that
matrices, lists, and objects are not saved. Function
definitions are also not saved.
In the 1st form, if var is a global variable string
value, then the value of that variable is used as a filename.
The following is equivalent to write dump.out or
write "dump.out":
global var = "dump.out";
write $var;
In the 2nd form, the filename argument is treated as a literal
string, not a variable. In this form, the name can be quoted
if desired.
If the -m mode disallows opening of files for writing,
this command will be disabled.
quit or exit
------------
quit
quit string
exit
exit string
The action of these commands depends on where they are used.
At the interactive level, they will cause calc it edit.
This is the normal way to leave the calculator. In any
other use, they will stop the current calculation as if
an error had occurred.
If a string is given, then the string is printed as the reason
for quitting, otherwise a general quit message is printed.
The routine name and line number which executed the quit is
also printed in either case.
Exit is an alias for quit.
Quit is useful when a routine detects invalid arguments,
in order to stop a calculation cleanly. For example,
for a square root routine, an error can be given if the
supplied parameter was a negative number, as in:
define mysqrt(n)
{
if (! isnum(n))
quit "non-numeric argument";
if (n < 0)
quit "Negative argument";
return sqrt(n);
}
See 'more information about abort and quit' below for
more information.
abort
-----
abort
abort string
This command behaves like QUIT except that it will attempt
to return to the interactive level if permitted, otherwise
calc exit.
See 'more information about abort and quit' below for
more information.
change current directory
------------------------
cd
cd dir
Change the current directory to 'dir'. If 'dir' is ommitted,
change the current directory to the home directory, if $HOME
is set in the environment.
show information
----------------
show item
This command displays some information where 'item' is
one of the following:
blocks unfreed named blocks
builtin built in functions
config config parameters and values
constants cache of numeric constants
custom custom functions if calc -C was used
errors new error-values created
files open files, file position and sizes
function user-defined functions
globaltypes global variables
objfunctions possible object functions
objtypes defined objects
opcodes func internal opcodes for function `func'
sizes size in octets of calc value types
realglobals numeric global variables
statics unscoped static variables
numbers calc number cache
redcdata REDC data defined
strings calc string cache
literals calc literal cache
Only the first 4 characters of item are examined, so:
show globals
show global
show glob
do the same thing.
calc help
---------
help $var
help name
This displays a help related to 'name' or general
help of none is given.
In the 1st form, if var is a global variable string
value, then the value of that variable is used as a name.
The following is equivalent to help command or help "command":
global var = "command";
help $var;
In the 2nd form, the filename argument is treated as a literal
string, not a variable. In this form, the name can be quoted
if desired.
=-=
more information about abort and quit
=====================================
Consider the following calc file called myfile.cal:
print "start of myfile.cal";
define q() {quit "quit from q()"; print "end of q()"}
define a() {abort "abort from a()"}
x = 3;
{print "start #1"; if (x > 1) q()} print "after #1";
{print "start #2"; if (x > 1) a()} print "after #2";
{print "start #3"; if (x > 1) quit "quit from 3rd statement"}
print "end of myfile.cal";
The command:
calc read myfile
will produce:
q() defined
a() defined
start statment #1
quit from q()
after statment #1
start statment #2
abort from a()
The QUIT within the q() function prevented the ``end of q()''
statement from being evaluated. This QUIT command caused
control to be returned to just after the place where q()
was called.
Notice that unlike QUIT, the ABORT inside function a() halts
the processing of statements from the input source (myfile.cal).
Because calc was not interactive, ABORT causes calc to exit.
The command:
calc -i read myfile
will produce:
q() defined
a() defined
start statment #1
quit from q()
after statment #1
start statment #2
abort from a()
; <==== calc interactive prompt
because the '-i' calc causes ABORT to drop into an
interactive prompt. However typing a QUIT or ABORT
at the interactive prompt level will always calc to exit,
even when calc is invoked with '-i'.
Also observe that both of these commands:
cat myfile.cal | calc
cat myfile.cal | calc -i
will produce:
q() defined
a() defined
start statment #1
quit from q()
after statment #1
start statment #2
abort from a()
The ABORT inside function a() halts the processing of statements
from the input source (standard input). Because standard input
is not a terminal, using '-i' does not force it to drop into
an interactive prompt.
If one were to type in the contents of myfile.cal interactively,
calc will produce:
; print "start of myfile.cal";
start of myfile.cal
; define q() {quit "quit from q()"; print "end of q()"}
q() defined
; define a() {abort "abort from a()"}
a() defined
; x = 3;
; {print "start #1"; if (x > 1) q()} print "after #1";
start statment #1
quit from q()
after statment #1
; {print "start #2"; if (x > 1) a()} print "after #2";
start statment #2
abort from a()
; {print "start #3"; if (x > 1) quit "quit from 3rd statement"}
start #3
quit from 3rd statement
The ABORT from within the a() function returned control to
the interactive level.
The QUIT (after the if (x > 1) ...) will cause calc to exit
because it was given at the interactive prompt level.
=-=
Also see the help topic:
statement flow control and declaration statements
usage how to invoke the calc command and calc -options
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: command,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/command,v $
##
## Under source code control: 1991/07/21 04:37:17
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* config
*************
NAME
config - configuration parameters
SYNOPSIS
config(parameter [,value])
TYPES
parameter string
value int, string, config state
return config state
DESCRIPTION
The config() builtin affects how the calculator performs certain
operations. Among features that are controlled by these parameters
are the accuracy of some calculations, the displayed format of results,
the choice from possible alternative algorithms, and whether or not
debugging information is displayed. The parameters are
read or set using the "config" built-in function; they remain in effect
until their values are changed by a config or equivalent instruction.
The following parameters can be specified:
"all" all configuration values listed below
"trace" turns tracing features on or off
"display" sets number of digits in prints.
"epsilon" sets error value for transcendentals.
"maxprint" sets maximum number of elements printed.
"mode" sets printout mode.
"mode2" sets 2nd base printout mode.
"mul2" sets size for alternative multiply.
"sq2" sets size for alternative squaring.
"pow2" sets size for alternate powering.
"redc2" sets size for alternate REDC.
"tilde" enable/disable printing of the roundoff '~'
"tab" enable/disable printing of leading tabs
"quomod" sets rounding mode for quomod
"quo" sets rounding mode for //, default for quo
"mod" sets "rounding" mode for %, default for mod
"sqrt" sets rounding mode for sqrt
"appr" sets rounding mode for appr
"cfappr" sets rounding mode for cfappr
"cfsim" sets rounding mode for cfsim
"round" sets rounding mode for round and bround
"outround" sets rounding mode for printing of numbers
"leadzero" enables/disables printing of 0 as in 0.5
"fullzero" enables/disables padding zeros as in .5000
"maxscan" maximum number of scan errors before abort
"prompt" default interactive prompt
"more" default interactive multi-line input prompt
"blkmaxprint" number of block octets to print, 0 means all
"blkverbose" TRUE => print all lines, FALSE=>skip duplicates
"blkbase" block output base
"blkfmt" block output format
"calc_debug" controls internal calc debug information
"resource_debug" controls resource file debug information
"user_debug" for user defined debug information
"verbose_quit" TRUE => print message on empty quit or abort
"ctrl_d" The interactive meaning of ^D (Control D)
"program" Read-only calc program or shell script path
"basename" Read-only basename of the program value
"windows" Read-only indicator of MS windows
"cygwin" TRUE=>calc compiled with cygwin, Read-only
"compile_custom" TRUE=>calc was compiled with custom functions
"allow_custom" TRUE=>custom functions are enabled
"version" Read-only calc version
"baseb" bits in calculation base, a read-only value
"redecl_warn" TRUE => warn when redeclaring
"dupvar_warn" TRUE => warn when variable names collide
"hz" Read-only operating system tick rate or 0
The "all" config value allows one to save/restore the configuration
set of values. The return of:
config("all")
is a CONFIG type which may be used as the 2rd arg in a later call.
One may save, modify and restore the configuration state as follows:
oldstate = config("all")
...
config("tab", 0)
config("mod", 10)
...
config("all", oldstate)
This save/restore method is useful within functions.
It allows functions to control their configuration without impacting
the calling function.
There are two configuration state aliases that may be set. To
set the backward compatible standard configuration:
config("all", "oldstd")
The "oldstd" will restore the configuration to the default at startup.
A new configuration that some people prefer may be set by:
config("all", "newstd")
The "newstd" is not backward compatible with the historic
configuration. Even so, some people prefer this configuration
and place the config("all", "newstd") command in their CALCRC
startup files; newstd may also be established by invoking calc
with the flag -n.
The following are synonyms for true:
"on"
"true"
"t"
"yes"
"y"
"set"
"1"
any non-zero number
The following are synonyms for false:
"off"
"false"
"f"
"no"
"n"
"unset"
"0"
the number zero (0)
Examples of setting some parameters are:
config("mode", "exp"); exponential output
config("display", 50); 50 digits of output
epsilon(epsilon() / 8); 3 bits more accuracy
config("tilde", 0) disable roundoff tilde printing
config("tab", "off") disable leading tab printing
=-=
config("trace", bitflag)
When nonzero, the "trace" parameter activates one or more features
that may be useful for debugging. These features correspond to
powers of 2 which contribute additively to config("trace"):
1: opcodes are displayed as functions are evaluated
2: disables the inclusion of debug lines in opcodes for functions
whose definitions are introduced with a left-brace.
4: the number of links for real and complex numbers are displayed
when the numbers are printed; for real numbers "#" or for
complex numbers "##", followed by the number of links, are
printed immediately after the number.
8: the opcodes for a new functions are displayed when the function
is successfully defined.
See also resource_debug, calc_debug and user_debug below for more
debug levels.
=-=
config("display", int)
The "display" parameter specifies the maximum number of digits after
the decimal point to be printed in real or exponential mode in
normal unformatted printing (print, strprint, fprint) or in
formatted printing (printf, strprintf, fprintf) when precision is not
specified. The initial value for oldstd is 20, for newstd 10.
The parameter may be changed to the value d by either
config("display", d) or by display (d). This parameter does not change
the stored value of a number. Where rounding is necessary to
display up to d decimal places, the type of rounding to be used is
controlled by config("outround").
=-=
config("epsilon", real)
epsilon(real)
The "epsilon" parameter specifies the default accuracy for the
calculation of functions for which exact values are not possible or
not desired. For most functions, the
remainder = exact value - calculated value
has absolute value less than epsilon, but, except when the sign of
the remainder is controlled by an appropriate parameter, the
absolute value of the remainder usually does not exceed epsilon/2.
Functions which require an epsilon value accept an
optional argument which overrides this default epsilon value for
that single call. The value v can be assigned to the "epsilon"
parameter by either config("epsilon", v) or epsilon(v); each of
these functions return the current epsilon value; config("epsilon")
or epsilon() returns but does not change the epsilon value.
For the transcendental functions and the functions sqrt() and
appr(), the calculated value is always a multiple of epsilon.
=-=
config("mode", "mode_string")
config("mode2", "mode_string")
The "mode" parameter is a string specifying the mode for printing of
numbers by the unformatted print functions, and the default
("%d" specifier) for formatted print functions. The initial mode
is "real". The available modes are:
config("mode") meaning equivalent
string base() call
"binary" base 2 fractions base(2)
"bin"
"octal" base 8 fractions base(8)
"oct"
"real" base 10 floating point base(10)
"float"
"default"
"integer" base 10 integer base(-10)
"int"
"hexadecimal" base 16 fractions base(16)
"hex"
"fraction" base 10 fractions base(1/3)
"frac"
"scientific" base 10 scientific notation base(1e20)
"sci"
"exp"
Where multiple strings are given, the first string listed is what
config("mode") will return.
The "mode2" controls the double base output. When set to a value
other than "off", calc outputs files in both the "base" mode as
well as the "base2" mode. The "mode2" value may be any of the
"mode" values with the addition of:
"off" disable 2nd base output mode base2(0)
The base() builtin function sets and returns the "mode" value.
The base2() builtin function sets and returns the "mode2" value.
The default "mode" is "real". The default "mode2" is "off".
=-=
config("maxprint", int)
The "maxprint" parameter specifies the maximum number of elements to
be displayed when a matrix or list is printed. The initial value is 16.
=-=
config("mul2", int)
config("sq2", int)
Mul2 and sq2 specify the sizes of numbers at which calc switches
from its first to its second algorithm for multiplying and squaring.
The first algorithm is the usual method of cross multiplying, which
runs in a time of O(N^2). The second method is a recursive and
complicated method which runs in a time of O(N^1.585). The argument
for these parameters is the number of binary words at which the
second algorithm begins to be used. The minimum value is 2, and
the maximum value is very large. If 2 is used, then the recursive
algorithm is used all the way down to single digits, which becomes
slow since the recursion overhead is high. If a number such as
1000000 is used, then the recursive algorithm is almost never used,
causing calculations for large numbers to slow down.
Units refer to internal calculation digits where each digit
is BASEB bits in length. The value of BASEB is returned by
config("baseb").
The default value for config("sq2") is 3388. This default was
established on a 1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS when
the two algorithms are about equal in speed. For that CPU test,
config("baseb") was 32. This means that by default numbers up to
(3388*32)+31 = 108447 bits in length (< 32645 decimal digits) use
the 1st algorithm, for squaring.
The default value for config("mul2") is 1780. This default was
established on a 1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS when
the two algorithms are about equal in speed. For that CPU test,
config("baseb") was 32. This means that by default numbers up to
(1779*32)+31 = 56927 bits in length (< 17137 decimal digits) use
the 1st algorithm, for multiplication.
A value of zero resets the parameter back to their default values.
The value of 1 and values < 0 are reserved for future use.
Usually there is no need to change these parameters.
=-=
config("pow2", int)
Pow2 specifies the sizes of numbers at which calc switches from
its first to its second algorithm for calculating powers modulo
another number. The first algorithm for calculating modular powers
is by repeated squaring and multiplying and dividing by the modulus.
The second method uses the REDC algorithm given by Peter Montgomery
which avoids divisions. The argument for pow2 is the size of the
modulus at which the second algorithm begins to be used.
Units refer to internal calculation digits where each digit
is BASEB bits in length. The value of BASEB is returned by
config("baseb").
The default value for config("pow2") is 176. This default was
established on a 1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS when
the two algorithms are about equal in speed. For that CPU test,
config("baseb") was 32. This means that by default numbers up to
(176*32)+31 = 5663 bits in length (< 1704 decimal digits) use the
1st algorithm, for calculating powers modulo another number.
A value of zero resets the parameter back to their default values.
The value of 1 and values < 0 are reserved for future use.
Usually there is no need to change these parameters.
=-=
config("redc2", int)
Redc2 specifies the sizes of numbers at which calc switches from
its first to its second algorithm when using the REDC algorithm.
The first algorithm performs a multiply and a modular reduction
together in one loop which runs in O(N^2). The second algorithm
does the REDC calculation using three multiplies, and runs in
O(N^1.585). The argument for redc2 is the size of the modulus at
which the second algorithm begins to be used.
Units refer to internal calculation digits where each digit
is BASEB bits in length. The value of BASEB is returned by
config("baseb").
The default value for config("redc2") is 220. This default was
established as 5/4 (the historical ratio of config("pow2") to
config("pow2")) of the config("pow2") value. This means that if
config("baseb") is 32, then by default numbers up to (220*32)+31 =
7071 bits in length (< 2128 decimal digits) use the REDC algorithm,
for calculating powers modulo another number.
A value of zero resets the parameter back to their default values.
The value of 1 and values < 0 are reserved for future use.
Usually there is no need to change these parameters.
=-=
config("tilde", boolean)
Config("tilde") controls whether or not a leading tilde ('~') is
printed to indicate that a number has not been printed exactly
because the number of decimal digits required would exceed the
specified maximum number. The initial "tilde" value is 1.
=-=
config("tab", boolean)
Config ("tab") controls the printing of a tab before results
automatically displayed when working interactively. It does not
affect the printing by the functions print, printf, etc. The initial
"tab" value is 1.
=-=
config("quomod", bitflag)
config("quo", bitflag)
config("mod", bitflag)
config("sqrt", bitflag)
config("appr", bitflag)
config("cfappr", bitflag)
config("cfsim", bitflag)
config("outround", bitflag)
config("round", bitflag)
The "quomod", "quo", "mod", "sqrt", "appr", "cfappr", "cfsim", and
"round" control the way in which any necessary rounding occurs.
Rounding occurs when for some reason, a calculated or displayed
value (the "approximation") has to differ from the "true value",
e.g. for quomod and quo, the quotient is to be an integer, for sqrt
and appr, the approximation is to be a multiple of an explicit or
implicit "epsilon", for round and bround (both controlled by
config("round")) the number of decimal places or fractional bits
in the approximation is limited. Zero value for any of these
parameters indicates that the true value is greater than the approximation,
i.e. the rounding is "down", or in the case of mod, that the
residue has the same sign as the divisor. If bit 4 of the
parameter is set, the rounding of to the nearest acceptable candidate
when this is uniquely determined; in the remaining ambiguous cases,
the type of rounding is determined by the lower bits of the parameter
value. If bit 3 is set, the rounding for quo, appr and sqrt,
is to the nearest even integer or the nearest even multiple of epsilon,
and for round to the nearest even "last decimal place". The effects
of the 3 lowest bits of the parameter value are as follows:
Bit 0: Unconditional reversal (down to up, even to odd, etc.)
Bit 1: Reversal if the exact value is negative
Bit 2: Reversal if the divisor or epsilon is negative
(Bit 2 is irrelevant for the functions round and bround since the
equivalent epsilon (a power of 1/10 or 1/2) is always positive.)
For quomod, the quotient is rounded to an integer value as if
evaluating quo with config("quo") == config("quomod"). Similarly,
quomod and mod give the same residues if config("mod") == config("quomod").
For the sqrt function, if bit 5 of config("sqrt") is set, the exact
square-root is returned when this is possible; otherwise the
result is rounded to a multiple of epsilon as determined by the
five lower order bits. Bit 6 of config("sqrt") controls whether the
principal or non-principal square-root is returned.
For the functions cfappr and cfsim, whether the "rounding" is down
or up, etc. is controlled by the appropriate bits of config("cfappr")
and config("cfsim") as for quomod, quo, etc.
The "outround" parameter determines the type of rounding to be used
by the various kinds of printing to the output: bits 0, 1, 3 and 4
are used in the same way as for the functions round and bround.
The C language method of modulus and integer division is:
config("quomod", 2)
config("quo", 2)
config("mod", 2)
=-=
config("leadzero", boolean)
The "leadzero" parameter controls whether or not a 0 is printed
before the decimal point in non-zero fractions with absolute value
less than 1, e.g. whether 1/2 is printed as 0.5 or .5. The
initial value is 0, corresponding to the printing .5.
=-=
config("fullzero", boolean)
The "fullzero" parameter controls whether or not in decimal floating-
point printing, the digits are padded with zeros to reach the
number of digits specified by config("display") or by a precision
specification in formatted printing. The initial value for this
parameter is 0, so that, for example, if config("display") >= 2,
5/4 will print in "real" mode as 1.25.
=-=
config("maxscan", int)
The maxscan value controls how many scan errors are allowed
before the compiling phase of a computation is aborted. The initial
value of "maxscan" is 20. Setting maxscan to 0 disables this feature.
=-=
config("prompt", str)
The default prompt when in interactive mode is "> ". One may change
this prompt to a more cut-and-paste friendly prompt by:
config("prompt", "; ")
On windowing systems that support cut/paste of a line, one may
cut/copy an input line and paste it directly into input. The
leading ';' will be ignored.
=-=
config("more", str)
When inside multi-line input, the more prompt is used. One may
change it by:
config("more", ";; ")
=-=
config("blkmaxprint", int)
The "blkmaxprint" config value limits the number of octets to print
for a block. A "blkmaxprint" of 0 means to print all octets of a
block, regardless of size.
The default is to print only the first 256 octets.
=-=
config("blkverbose", boolean)
The "blkverbose" determines if all lines, including duplicates
should be printed. If TRUE, then all lines are printed. If false,
duplicate lines are skipped and only a "*" is printed in a style
similar to od. This config value has not meaning if "blkfmt" is "str".
The default value for "blkverbose" is FALSE: duplicate lines are
not printed.
=-=
config("blkbase", "blkbase_string")
The "blkbase" determines the base in which octets of a block
are printed. Possible values are:
"hexadecimal" Octets printed in 2 digit hex
"hex"
"default"
"octal" Octets printed in 3 digit octal
"oct"
"character" Octets printed as chars with non-printing
"char" chars as \123 or \n, \t, \r
"binary" Octets printed as 0 or 1 chars
"bin"
"raw" Octets printed as is, i.e. raw binary
"none"
Where multiple strings are given, the first string listed is what
config("blkbase") will return.
The default "blkbase" is "hexadecimal".
=-=
config("blkfmt", "blkfmt_string")
The "blkfmt" determines for format of how block are printed:
"lines" print in lines of up to 79 chars + newline
"line"
"strings" print as one long string
"string"
"str"
"od_style" print in od-like format, with leading offset,
"odstyle" followed by octets in the given base
"od"
"hd_style" print in hex dump format, with leading offset,
"hdstyle" followed by octets in the given base, followed
"hd" by chars or '.' if no-printable or blank
"default"
Where multiple strings are given, the first string listed is what
config("blkfmt") will return.
The default "blkfmt" is "hd_style".
=-=
config("calc_debug", bitflag)
The "calc_debug" is intended for controlling internal calc routines
that test its operation, or collect or display information that
might be useful for debug purposes. Much of the output from these
will make sense only to calc wizards. Zero value (the default for
both oldstd and newstd) of config("resource_debug") corresponds to
switching off all these routines. For nonzero value, particular
bits currently have the following meanings:
n Meaning of bit n of config("calc_debug")
0 outputs shell commands prior to execution
1 outputs currently active functions when a quit instruction
is executed
2 some details of hash states are included in the output
when these are printed
3 when a function constructs a block value, tests are
made that the result has the properties required for use of
that block, e.g. that the pointer to the start of the
block is not NULL, and that its "length" is not negative.
A failure will result in a runtime error.
4 Report on changes to the state of stdin as well as changes
to internal variables that control the setting and restoring
of stdin.
5 Report on changes to the run state of calc.
6 Report on rand() subtractive 100 shuffle generator issues.
7 Report on custom function issues.
Bits >= 8 are reserved for future use and should not be used at this time.
By default, "calc_debug" is 0. The initial value may be overridden
by the -D command line option.
=-=
config("resource_debug", bitflag)
config("lib_debug", bitflag)
The "resource_debug" parameter is intended for controlling the possible
display of special information relating to functions, objects, and
other structures created by instructions in calc scripts.
Zero value of config("resource_debug") means that no such information
is displayed. For other values, the non-zero bits which currently
have meanings are as follows:
n Meaning of bit n of config("resource_debug")
0 When a function is defined, redefined or undefined at
interactive level, a message saying what has been done
is displayed.
1 When a function is defined, redefined or undefined during
the reading of a file, a message saying what has been done
is displayed.
2 Show func will display more information about a functions
arguments and argument summary information.
3 During execution, allow calc standard resource files
to output additional debugging information.
The value for config("resource_debug") in both oldstd and newstd
is 3, but if calc is invoked with the -d flag, its initial value
is zero. Thus, if calc is started without the -d flag, until
config("resource_debug") is changed, a message will be output when
a function is defined either interactively or during the reading of
a file.
The name config("lib_debug") is equivalent to config("resource_debug")
and is included for backward compatibility.
By default, "resource_debug" is 3. The -d flag changes this default to 0.
The initial value may be overridden by the -D command line option.
=-=
config("user_debug", int)
The "user_debug" is provided for use by users. Calc ignores this value
other than to set it to 0 by default (for both "oldstd" and "newstd").
No calc code or standard resource should change this value. Users
should feel free to use it in any way. In particular they may
use particular bits for special purposes as with "calc_debug", or
they may use it to indicate a debug level with larger values
indicating more stringent and more informative tests with presumably
slower operation or more memory usage, and a particular value (like
-1 or 0) corresponding to "no tests".
By default, "user_debug" is 0. The initial value may be overridden
by the -D command line option.
=-=
config("verbose_quit", boolean)
The "verbose_quit" controls the print of the message:
quit or abort executed
when a non-interactive quit or abort without an argument is encountered.
A quit of abort without an argument does not display a message when
invoked at the interactive level.
By default, "verbose_quit" is false.
=-=
config("ctrl_d", "ctrl_d_string")
For calc that is using the calc binding (not GNU-readline) facility:
The "ctrl_d" controls the interactive meaning of ^D (Control D):
"virgin_eof" If ^D is the only character that has been typed
"virgineof" on a line, then calc will exit. Otherwise ^D
"virgin" will act according to the calc binding, which
"default" by default is a Emacs-style delete-char.
"never_eof" The ^D never exits calc and only acts according
"nevereof" calc binding, which by default is a Emacs-style
"never" delete-char.
"empty_eof" The ^D always exits calc if typed on an empty line.
"emptyeof" This condition occurs when ^D either the first
"empty" character typed, or when all other characters on
the line have been removed (say by deleting them).
Where multiple strings are given, the first string listed is what
config("ctrl_d") will return.
Note that config("ctrl_d") actually controls each and every character
that is bound to ``delete_char''. By default, ``delete_char'' is
Control D. Any character(s) bound to ``delete_char'' will cause calc
to exit (or not exit) as directed by config("ctrl_d").
See the ``binding'' help for information on the default calc bindings.
The default "ctrl_d", without GNU-readline is "virgin_eof".
For calc that was compiled with the GNU-readline facility:
The "ctrl_d" controls the interactive meaning of ^D (Control D):
"virgin_eof" Same as "empty_eof"
"virgineof"
"virgin"
"default"
"never_eof" The ^D never exits calc and only acts according
"nevereof" calc binding, which by default is a Emacs-style
"never" delete-char.
"empty_eof" The ^D always exits calc if typed on an empty line.
"emptyeof" This condition occurs when ^D either the first
"empty" character typed, or when all other characters on
Where multiple strings are given, the first string listed is what
config("ctrl_d") will return.
The default "ctrl_d", with GNU-readline is effectively "empty_eof".
Literally it is "virgin_eof", but since "virgin_eof" is the
same as "empty_eof", the default is effectively "empty_eof".
Emacs users may find the default behavior objectionable, particularly
when using the GNU-readline facility. Such users may want to add the line:
config("ctrl_d", "never_eof"),;
to their ~/.calcrc startup file to prevent ^D from causing calc to exit.
=-=
config("program") <== NOTE: This is a read-only config value
The full path to the calc program, or the calc shell script can be
obtained by:
config("program")
This config parameter is read-only and cannot be set.
=-=
config("basename") <== NOTE: This is a read-only config value
The calc program, or the calc shell script basename can be obtained by:
config("basename")
The config("basename") is the config("program") without any leading
path. If config("program") has a / in it, config("basename") is
everything after the last /, otherwise config("basename") is the
same as config("program").
This config parameter is read-only and cannot be set.
=-=
config("windows") <== NOTE: This is a read-only config value
Returns TRUE if you are running on a MS windows system, false if you
are running on an operating system that does not hate you.
This config parameter is read-only and cannot be set.
=-=
config("cygwin") <== NOTE: This is a read-only config value
Returns TRUE if you calc was compiled with cygwin, false otherwise.
This config parameter is read-only and cannot be set.
=-=
config("compile_custom") <== NOTE: This is a read-only config value
Returns TRUE if you calc was compiled with -DCUSTOM. By default,
the calc Makefile uses ALLOW_CUSTOM= -DCUSTOM so by default
config("compile_custom") is TRUE. If, however, calc is compiled
without -DCUSTOM, then config("compile_custom") will be FALSE.
The config("compile_custom") value is only affected by compile
flags. The calc -D runtime command line option does not change
the config("compile_custom") value.
See also config("allow_custom").
This config parameter is read-only and cannot be set.
=-=
config("allow_custom") <== NOTE: This is a read-only config value
Returns TRUE if you custom functions are enabled. To allow the use
of custom functions, calc must be compiled with -DCUSTOM (which it
is by default) AND calc run be run with the -D runtime command line
option (which it is not by default).
If config("allow_custom") is TRUE, then custom functions are allowed.
If config("allow_custom") is FALSE, then custom functions are not
allowed.
See also config("compile_custom").
This config parameter is read-only and cannot be set.
=-=
config("version") <== NOTE: This is a read-only config value
The version string of the calc program can be obtained by:
config("version")
This config parameter is read-only and cannot be set.
=-=
config("baseb") <== NOTE: This is a read-only config value
Returns the number of bits in the fundamental base in which
internal calculations are performed. For example, a value of
32 means that calc will perform many internal calculations in
base 2^32 with digits that are 32 bits in length.
For libcalc programmers, this is the value of BASEB as defined
in the zmath.h header file.
This config parameter is read-only and cannot be set.
=-=
config("redecl_warn", boolean)
Config("redecl_warn") controls whether or not a warning is issued
when redeclaring variables.
The initial "redecl_warn" value is 1.
=-=
config("dupvar_warn", boolean)
Config("dupvar_warn") controls whether or not a warning is issued
when a variable name collides with an exist name of a higher scope.
Examples of collisions are when:
* both local and static variables have the same name
* both local and global variables have the same name
* both function parameter and local variables have the same name
* both function parameter and global variables have the same name
The initial "redecl_warn" value is 1.
=-=
config("hz") <== NOTE: This is a read-only config value
Returns the rate at which the operating system advances the clock
on POSIX based systems. Returns 0 on non-POSIX based systems.
The non-zero value returned is in Hetrz.
This config parameter is read-only and cannot be set.
EXAMPLE
; current_cfg = config("all");
; config("tilde", off),;
; config("calc_debug", 15),;
; config("all") == current_cfg
0
; config("all", current_cfg),;
; config("all") == current_cfg
1
; config("version")
"2.12.0"
; config("all")
mode "real"
mode2 "off"
display 20
epsilon 0.00000000000000000001
trace 0
maxprint 16
mul2 20
sq2 20
pow2 40
redc2 50
tilde 1
tab 1
quomod 0
quo 2
mod 0
sqrt 24
appr 24
cfappr 0
cfsim 8
outround 24
round 24
leadzero 1
fullzero 0
maxscan 20
prompt "; "
more ";; "
blkmaxprint 256
blkverbose 0
blkbase "hexadecimal"
blkfmt "hd_style"
resource_debug 3
lib_debug 3
calc_debug 0
user_debug 0
verbose_quit 0
ctrl_d "virgin_eof"
program "calc"
basename "calc"
windows 0
cygwin 0
compile_custom 1
allow_custom 0
version "2.12.0"
baseb 32
redecl_warn 1
dupvar_warn 1
hz 100
; display()
20
; config("display", 50),;
; display()
50
LIMITS
none
LINK LIBRARY
n/a
SEE ALSO
usage, custom, custom_cal, usage, epsilon, display
## Copyright (C) 1999-2007 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.3 $
## @(#) $Id: config,v 30.3 2007/09/21 01:27:27 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/config,v $
##
## Under source code control: 1991/07/21 04:37:17
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* custom
*************
NAME
custom - custom builtin interface
SYNOPSIS
custom([custname [, arg ...]])
TYPES
custname string
arg any
return any
DESCRIPTION
This function will invoke the custom function interface. Custom
functions are accessed by the custname argument. The remainder
of the args, if any, are passed to the custom function. The
custom function may return any value, including null. Calling
custom with no args is equivalent to the command 'show custom'.
In order to use the custom interface, two things must happen:
1) Calc must be built to allow custom functions. By default,
the master Makefile is shipped with ALLOW_CUSTOM= -DCUSTOM
which causes custom functions to be compiled in.
2) Calc must be invoked with an argument of -C as in:
calc -C
In other words, explicit action must be taken in order to
enable the use of custom functions. By default (no -C arg)
custom functions are compiled in but disabled so that only
portable calc scripts may be used.
The main focus for calc is to provide a portable platform for
multi-precision calculations in a C-like environment. You should
consider implementing algorithms in the calc language as a first
choice. Sometimes an algorithm requires use of special hardware, a
non-portable OS or pre-compiled C library. In these cases a custom
interface may be needed.
The custom function interface is intended to make is easy for
programmers to add functionality that would be otherwise
un-suitable for general distribution. Functions that are
non-portable (machine, hardware or OS dependent) or highly
specialized are possible candidates for custom functions.
To add a new custom function requires access to calc source.
For information on how to add a new custom function, try:
help new_custom
To serve as examples, calc is shipped with a few custom functions.
If calc if invoked with -C, then either of the following will
display information about the custom functions that are available:
show custom
or:
custom()
A few resource files that uses these function are also provided
to serve as usage examples.
We welcome submissions for new custom functions. For information
on how to submit new custom functions for general distribution, see:
help contrib
EXAMPLE
If calc compiled with ALLOW_CUSTOM= (custom disabled):
; print custom("sysinfo", "baseb")
Calc was built with custom functions disabled
Error 10195
If calc compiled with ALLOW_CUSTOM= -DCUSTOM and is invoked without -C:
; print custom("sysinfo", "baseb")
Calc must be run with a -C argument to use custom function
Error 10194
If calc compiled with ALLOW_CUSTOM= -DCUSTOM and is invoked with -C:
; print custom("sysinfo", "baseb")
32
LIMITS
By default, custom is limited to 100 args.
LINK LIBRARY
none
SEE ALSO
custom_cal, new_custom, contrib
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: custom,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/custom,v $
##
## Under source code control: 1997/03/09 16:33:22
## File existed as early as: 1997
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* define
*************
NAME
define - command keyword to start a function definition
SYNTAX
define fname([param_1 [= default_1], ...]) = [expr]
define fname([param_1 [= default_1], ...]) { [statement_1 ... ] }
TYPES
fname identifier, not a builtin function name
param_1, ... identifiers, no two the same
default_1, ... expressions
expr expression
statement_1, ... statements
DESCRIPTION
The intention of a function definition is that the identifier fname
becomes the name of a function which may be called by an expression
of the form fname(arg_1, arg_2, ...), where arg_1, arg_2, ... are
expressions (including possibly blanks, which are treated as
null values). Evaluation of the function begins with evaluation
of arg_1, arg_2, ...; then, in increasing order of i, if arg_i is
null-valued and "= default_i" has been included in the definition,
default_i is evaluated and its value becomes the value of arg_i.
The instructions in expr or the listed statements are then executed
with each occurrence of param_i replaced by the value obtained
for arg_i.
In a call, arg_i may be preceded by a backquote (`) to indicate that
evaluation of arg_i is not to include a final evaluation of an lvalue.
For example, suppose a function f and a global variable A have been
defined by:
; define f(x) = (x = 3);
; global mat A[3];
If g() is a function that evaluates to 2:
; f(A[g()]);
assigns the value of A[2] to the parameter x and then assigns the
value 3 to x:
; f(`A[g()]);
has essentially the effect of assigning A[2] as an lvalue to x and
then assigning the value 3 to A[2]. (Very old versions of calc
achieved the same result by using '&' as in f(&A[g()]).)
The number of arguments arg_1, arg_2, ... in a call need not equal the
number of parameters. If there are fewer arguments than parameters,
the "missing" values are assigned the null value.
In the definition of a function, the builtin function param(n)
provides a way of referring to the parameters. If n (which may
result from evaluating an expreession) is zero, it returns the number
of arguments in a call to the function, and if 1 <= n <= param(0),
param(n) refers to the parameter with index n.
If no error occurs and no quit statement or abort statement is
encountered during evaluation of the expression or the statements,
the function call returns a value. In the expression form, this is
simply the value of the expression.
In the statement form, if a return statement is encountered,
the "return" keyword is to be either immediately followed by an
expression or by a statement terminator (semicolon or rightbrace);
in the former case, the expression is evaluated, evaluation of
the function ceases, and the value obtained for the expression is
returned as the "value of the function"; in the no-expression case,
evaluation ceases immediately and the null-value is returned.
In the expression form of definition, the end of the expression expr
is to be indicated by either a semicolon or a newline not within
a part enclosed by parentheses; the definition may extend over
several physical lines by ending each line with a '\' character or by
enclosing the expression in parentheses. In interactive mode, that
a definition has not been completed is indicated by the continuation
prompt. A ctrl-C interrupt at this stage will abort the definition.
If the expr is omitted from an expression definition, as in:
; define h() = ;
any call to the function will evaluate the arguments and return the
null value.
In the statement form, the definition ends when a matching right
brace completes the "block" started by the initial left brace.
Newlines within the block are treated as white space; statements
within the block end with a ';' or a '}' matching an earlier '{'.
If a function with name fname had been defined earlier, the old
definition has no effect on the new definition, but if the definition
is completed successfully, the new definition replaces the old one;
otherwise the old definition is retained. The number of parameters
and their names in the new definiton may be quite different from
those in the old definition.
An attempt at a definition may fail because of scanerrors as the
definition is compiled. Common causes of these are: bad syntax,
using identifiers as names of variables not yet defined. It is
not a fault to have in the definition a call to a function that has
not yet been defined; it is sufficient that the function has been
defined when a call is made to the function.
After fname has been defined, the definition may be removed by the command:
; undefine fname
The definitions of all user-defined functions may be removed by:
; undefine *
If bit 0 of config("resource_debug") is set and the define command is
at interactive level, a message saying that fname has been defined
or redefined is displayed. The same message is displayed if bit 1
of config("resource_debug") is set and the define command is read
from a file.
The identifiers used for the parameters in a function definition do
not form part of the completed definition. For example,
; define f(a,b) = a + b;
; define g(alpha, beta) = alpha + beta;
result in identical code for the functions f, g.
If config("trace") & 8 is nonzero, the opcodes of a newly defined
function are displayed on completion of its definition, parameters
being specified by names used in the definition. For example:
; config("trace", 8),
; define f(a,b) = a + b
0: PARAMADDR a
2: PARAMADDR b
4: ADD
5: RETURN
f(a,b) defined
The opcodes may also be displayed later using the show opcodes command;
parameters will be specified by indices instead of by names. For example:
; show opco f
0: PARAMADDR 0
2: PARAMADDR 1
4: ADD
5: RETURN
When a function is defined by the statement mode, the opcodes normally
include DEBUG opcodes which specify statement boundaries at which
SIGINT interruptions are likely to be least risky. Inclusion of
the DEBUG opcodes is disabled if config("trace") & 2 is nonzero.
For details, see help interrupt.
While config("trace") & 1 is nonzero, the opcodes are displayed as
they are being evaluated. The current function is identified by its
name, or "*" in the case of a command-line and "**" in the case of
an eval(str) evaluation.
When a function is called, argument values may be of any type for
which the operations and any functions used within the body of the
definition can be executed. For example, whatever the intention at
the time they were defined, the functions f1(), f2() defined above
may be called with integer, fractional, or complex-number values, or
with both arguments strings, or under some compatibility conditions,
matrices or objects.
EXAMPLE
; define f(a,b) = 2*a + b;
; define g(alpha, beta)
;; {
;; local a, pi2;
;;
;; pi2 = 2 * pi();
;; a = sin(alpha % pi2);
;; if (a > 0.0) {
;; return a*beta;
;; }
;; if (beta > 0.0) {
;; a *= cos(-beta % pi2);
;; }
;; return a;
;; }
LIMITS
The number of arguments in a function-call cannot exceed 1024.
LIBRARY
none
SEE ALSO
param, variable, undefine, show
## Copyright (C) 2000-2006 David I. Bell, Landon Curt Noll and Ernest Bowen
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: define,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/define,v $
##
##
## Under source code control: 1991/07/21 04:37:18
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* environment
*************
Environment variables
CALCPATH
A :-separated list of directories used to search for
resource filenames (*.cal files) that do not begin with:
/ ./ ../ ~
If this variable does not exist, a compiled value
is used. Typically compiled in value is:
.:./cal:~/cal:${CALC_SHAREDIR}:${CUSTOMCALDIR}
which is usually:
.:./cal:~/cal:/usr/share/calc:/usr/share/calc/custom
This value is used by the READ command. It is an error
if no such readable file is found.
The CALCBINDINGS file searches the CALCPATH as well.
CALCRC
On startup (unless -h or -q was given on the command
line), calc searches for files along the :-separated
$CALCRC environment variable.
If this variable does not exist, a compiled value
is used. Typically compiled in value is:
${CALC_SHAREDIR}/startup:~/.calcrc:./.calcinit
which is usually:
/usr/share/calc/startup:~/.calcrc:./.calcinit
Missing files along the $CALCRC path are silently ignored.
CALCBINDINGS
On startup (unless -h or -q was given on the command
line), calc reads key bindings from the filename specified
in the $CALCRC environment variable. These key bindings
are used for command line editing and the command history.
If this variable does not exist, a compiled value is used.
Typically compiled in value is:
bindings
The bindings file is searched along the CALCPATH. Unlike
the READ command, a .cal extension is not added.
If the file could not be opened, or if standard input is not
a terminal, then calc will still run, but fancy command line
editing is disabled.
NOTE: If calc was compiled with GNU-readline support, the
CALCBINDINGS facility is ignored and the standard
readline mechanisms (see readline(3)) are used.
HOME
This value is taken to be the home directory of the
current user. It is used when files begin with '~/'.
If this variable does not exist, the home directory password
entry of the current user is used. If that information
is not available, '.' is used.
PAGER
When invoking help, this environment variable is used
to display a help file.
If this variable does not exist, a compiled value
is used. Typically compiled in value is something
such as 'more', 'less', 'pg' or 'cat'.
SHELL
When a !-command is used, the program indicated by
this environment variable is used.
If this variable does not exist, a compiled value
is used. Typically compiled in value is something
such as 'sh' is used.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: environment,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/environment,v $
##
## Under source code control: 1991/07/23 05:47:25
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* expression
*************
Expression sequences
This is a sequence of statements, of which expression statements
are the commonest case. Statements are separated with semicolons,
and the newline character generally ends the sequence. If any
statement is an expression by itself, or is associated with an
'if' statement which is true, then two special things can happen.
If the sequence is executed at the top level of the calculator,
then the value of '.' is set to the value of the last expression.
Also, if an expression is a non-assignment, then the value of the
expression is automatically printed if its value is not NULL.
Some operations such as pre-increment and plus-equals are also
treated as assignments.
Examples of this are the following:
expression sets '.' to prints
---------- ----------- ------
3+4 7 7
2*4; 8+1; fact(3) 6 8, 9, and 6
x=3^2 9 -
if (3 < 2) 5; else 6 6 6
x++ old x -
print fact(4) - 24
null() null() -
Variables can be defined at the beginning of an expression sequence.
This is most useful for local variables, as in the following example,
which sums the square roots of the first few numbers:
local s, i; s = 0; for (i = 0; i < 10; i++) s += sqrt(i); s
If a return statement is executed in an expression sequence, then
the result of the expression sequence is the returned value. In
this case, '.' is set to the value, but nothing is printed.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: expression,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/expression,v $
##
## Under source code control: 1991/07/21 04:37:18
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* errorcodes
*************
Calc generated error codes (see the error help file):
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: errorcodes.hdr,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/errorcodes.hdr,v $
##
## Under source code control: 1995/12/18 03:19:11
## File existed as early as: 1995
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
10001 Division by zero
10002 Indeterminate (0/0)
10003 Bad arguments for +
10004 Bad arguments for binary -
10005 Bad arguments for *
10006 Bad arguments for /
10007 Bad argument for unary -
10008 Bad argument for squaring
10009 Bad argument for inverse
10010 Bad argument for ++
10011 Bad argument for --
10012 Bad argument for int
10013 Bad argument for frac
10014 Bad argument for conj
10015 Bad first argument for appr
10016 Bad second argument for appr
10017 Bad third argument for appr
10018 Bad first argument for round
10019 Bad second argument for round
10020 Bad third argument for round
10021 Bad first argument for bround
10022 Bad second argument for bround
10023 Bad third argument for bround
10024 Bad first argument for sqrt
10025 Bad second argument for sqrt
10026 Bad third argument for sqrt
10027 Bad first argument for root
10028 Bad second argument for root
10029 Bad third argument for root
10030 Bad argument for norm
10031 Bad first argument for << or >>
10032 Bad second argument for << or >>
10033 Bad first argument for scale
10034 Bad second argument for scale
10035 Bad first argument for ^
10036 Bad second argument for ^
10037 Bad first argument for power
10038 Bad second argument for power
10039 Bad third argument for power
10040 Bad first argument for quo or //
10041 Bad second argument for quo or //
10042 Bad third argument for quo
10043 Bad first argument for mod or %
10044 Bad second argument for mod or %
10045 Bad third argument for mod
10046 Bad argument for sgn
10047 Bad first argument for abs
10048 Bad second argument for abs
10049 Scan error in argument for eval
10050 Non-simple type for str
10051 Non-real epsilon for exp
10052 Bad first argument for exp
10053 Non-file first argument for fputc
10054 Bad second argument for fputc
10055 File not open for writing for fputc
10056 Non-file first argument for fgetc
10057 File not open for reading for fgetc
10058 Non-string arguments for fopen
10059 Unrecognized mode for fopen
10060 Non-file first argument for freopen
10061 Non-string or unrecognized mode for freopen
10062 Non-string third argument for freopen
10063 Non-file argument for fclose
10064 Non-file argument for fflush
10065 Non-file first argument for fputs
10066 Non-string argument after first for fputs
10067 File not open for writing for fputs
10068 Non-file argument for fgets
10069 File not open for reading for fgets
10070 Non-file first argument for fputstr
10071 Non-string argument after first for fputstr
10072 File not open for writing for fputstr
10073 Non-file first argument for fgetstr
10074 File not open for reading for fgetstr
10075 Non-file argument for fgetline
10076 File not open for reading for fgetline
10077 Non-file argument for fgetfield
10078 File not open for reading for fgetfield
10079 Non-file argument for rewind
10080 Non-integer argument for files
10081 Non-string fmt argument for fprint
10082 Stdout not open for writing to ???
10083 Non-file first argument for fprintf
10084 Non-string second (fmt) argument for fprintf
10085 File not open for writing for fprintf
10086 Non-string first (fmt) argument for strprintf
10087 Error in attempting strprintf ???
10088 Non-file first argument for fscan
10089 File not open for reading for fscan
10090 Non-string first argument for strscan
10091 Non-file first argument for fscanf
10092 Non-string second (fmt) argument for fscanf
10093 Non-lvalue argument after second for fscanf
10094 File not open for reading or other error for fscanf
10095 Non-string first argument for strscanf
10096 Non-string second (fmt) argument for strscanf
10097 Non-lvalue argument after second for strscanf
10098 Some error in attempting strscanf ???
10099 Non-string first (fmt) argument for scanf
10100 Non-lvalue argument after first for scanf
10101 Some error in attempting scanf ???
10102 Non-file argument for ftell
10103 File not open or other error for ftell
10104 Non-file first argument for fseek
10105 Non-integer or negative second argument for fseek
10106 File not open or other error for fseek
10107 Non-file argument for fsize
10108 File not open or other error for fsize
10109 Non-file argument for feof
10110 File not open or other error for feof
10111 Non-file argument for ferror
10112 File not open or other error for ferror
10113 Non-file argument for ungetc
10114 File not open for reading for ungetc
10115 Bad second argument or other error for ungetc
10116 Exponent too big in scanning
10117 E_ISATTY1 is no longer used
10118 E_ISATTY2 is no longer used
10119 Non-string first argument for access
10120 Bad second argument for access
10121 Bad first argument for search
10122 Bad second argument for search
10123 Bad third argument for search
10124 Bad fourth argument for search
10125 Cannot find fsize or fpos for search
10126 File not readable for search
10127 Bad first argument for rsearch
10128 Bad second argument for rsearch
10129 Bad third argument for rsearch
10130 Bad fourth argument for rsearch
10131 Cannot find fsize or fpos for rsearch
10132 File not readable for rsearch
10133 Too many open files
10134 Attempt to rewind a file that is not open
10135 Bad argument type for strerror
10136 Index out of range for strerror
10137 Bad epsilon for cos
10138 Bad first argument for cos
10139 Bad epsilon for sin
10140 Bad first argument for sin
10141 Non-string argument for eval
10142 Bad epsilon for arg
10143 Bad first argument for arg
10144 Non-real argument for polar
10145 Bad epsilon for polar
10146 Non-integral argument for fcnt
10147 Non-variable first argument for matfill
10148 Non-matrix first argument-value for matfill
10149 Non-matrix argument for matdim
10150 Non-matrix argument for matsum
10151 E_ISIDENT is no longer used
10152 Non-matrix argument for mattrans
10153 Non-two-dimensional matrix for mattrans
10154 Non-matrix argument for det
10155 Matrix for det not of dimension 2
10156 Non-square matrix for det
10157 Non-matrix first argument for matmin
10158 Non-positive-integer second argument for matmin
10159 Second argument for matmin exceeds dimension
10160 Non-matrix first argument for matmin
10161 Second argument for matmax not positive integer
10162 Second argument for matmax exceeds dimension
10163 Non-matrix argument for cp
10164 Non-one-dimensional matrix for cp
10165 Matrix size not 3 for cp
10166 Non-matrix argument for dp
10167 Non-one-dimensional matrix for dp
10168 Different-size matrices for dp
10169 Non-string argument for strlen
10170 Non-string argument for strcat
10171 Non-string first argument for strcat
10172 Non-non-negative integer second argument for strcat
10173 Bad argument for char
10174 Non-string argument for ord
10175 Non-list-variable first argument for insert
10176 Non-integral second argument for insert
10177 Non-list-variable first argument for push
10178 Non-list-variable first argument for append
10179 Non-list-variable first argument for delete
10180 Non-integral second argument for delete
10181 Non-list-variable argument for pop
10182 Non-list-variable argument for remove
10183 Bad epsilon argument for ln
10184 Non-numeric first argument for ln
10185 Non-integer argument for error
10186 Argument outside range for error
10187 Attempt to eval at maximum input depth
10188 Unable to open string for reading
10189 First argument for rm is not a non-empty string
10190 Unable to remove a file
10191 Operation allowed because calc mode disallows read operations
10192 Operation allowed because calc mode disallows write operations
10193 Operation allowed because calc mode disallows exec operations
10194 Unordered arguments for min
10195 Unordered arguments for max
10196 Unordered items for minimum of list
10197 Unordered items for maximum of list
10198 Size undefined for argument type
10199 Calc must be run with a -C argument to use custom function
10200 Calc was built with custom functions disabled
10201 Custom function unknown, try: show custom
10202 Non-integral length for block
10203 Negative or too-large length for block
10204 Non-integral chunksize for block
10205 Negative or too-large chunksize for block
10206 Named block does not exist for blkfree
10207 Non-integral id specification for blkfree
10208 Block with specified id does not exist
10209 Block already freed
10210 No-realloc protection prevents blkfree
10211 Non-integer argument for blocks
10212 Non-allocated index number for blocks
10213 Non-integer or negative source index for copy
10214 Source index too large for copy
10215 E_COPY3 is no longer used
10216 Non-integer or negative number for copy
10217 Number too large for copy
10218 Non-integer or negative destination index for copy
10219 Destination index too large for copy
10220 Freed block source for copy
10221 Unsuitable source type for copy
10222 Freed block destinction for copy
10223 Unsuitable destination type for copy
10224 Incompatible source and destination for copy
10225 No-copy-from source variable
10226 No-copy-to destination variable
10227 No-copy-from source named block
10228 No-copy-to destination named block
10229 No-relocate destination for copy
10230 File not open for copy
10231 fseek or fsize failure for copy
10232 fwrite error for copy
10233 fread error for copy
10234 Non-variable first argument for protect
10235 Bad second argument for protect
10236 Bad third argument for protect
10237 No-copy-to destination for matfill
10238 No-assign-from source for matfill
10239 Non-matrix argument for mattrace
10240 Non-two-dimensional argument for mattrace
10241 Non-square argument for mattrace
10242 Bad epsilon for tan
10243 Bad argument for tan
10244 Bad epsilon for cot
10245 Bad argument for cot
10246 Bad epsilon for sec
10247 Bad argument for sec
10248 Bad epsilon for csc
10249 Bad argument for csc
10250 Bad epsilon for sinh
10251 Bad argument for sinh
10252 Bad epsilon for cosh
10253 Bad argument for cosh
10254 Bad epsilon for tanh
10255 Bad argument for tanh
10256 Bad epsilon for coth
10257 Bad argument for coth
10258 Bad epsilon for sech
10259 Bad argument for sech
10260 Bad epsilon for csch
10261 Bad argument for csch
10262 Bad epsilon for asin
10263 Bad argument for asin
10264 Bad epsilon for acos
10265 Bad argument for acos
10266 Bad epsilon for atan
10267 Bad argument for atan
10268 Bad epsilon for acot
10269 Bad argument for acot
10270 Bad epsilon for asec
10271 Bad argument for asec
10272 Bad epsilon for acsc
10273 Bad argument for acsc
10274 Bad epsilon for asin
10275 Bad argument for asinh
10276 Bad epsilon for acosh
10277 Bad argument for acosh
10278 Bad epsilon for atanh
10279 Bad argument for atanh
10280 Bad epsilon for acoth
10281 Bad argument for acoth
10282 Bad epsilon for asech
10283 Bad argument for asech
10284 Bad epsilon for acsch
10285 Bad argument for acsch
10286 Bad epsilon for gd
10287 Bad argument for gd
10288 Bad epsilon for agd
10289 Bad argument for agd
10290 Log of zero or infinity
10291 String addition failure
10292 String multiplication failure
10293 String reversal failure
10294 String subtraction failure
10295 Bad argument type for bit
10296 Index too large for bit
10297 Non-integer second argument for setbit
10298 Out-of-range index for setbit
10299 Non-string first argument for setbit
10300 Bad argument for or
10301 Bad argument for and
10302 Allocation failure for string or
10303 Allocation failure for string and
10304 Bad argument for xorvalue
10305 Bad argument for comp
10306 Allocation failure for string diff
10307 Allocation failure for string comp
10308 Bad first argument for segment
10309 Bad second argument for segment
10310 Bad third argument for segment
10311 Failure for string segment
10312 Bad argument type for highbit
10313 Non-integer argument for highbit
10314 Bad argument type for lowbit
10315 Non-integer argument for lowbit
10316 Bad argument type for unary hash op
10317 Bad argument type for binary hash op
10318 Bad first argument for head
10319 Bad second argument for head
10320 Failure for strhead
10321 Bad first argument for tail
10322 Bad second argument for tail
10323 Failure for strtail
10324 Failure for strshift
10325 Non-string argument for strcmp
10326 Bad argument type for strncmp
10327 Varying types of argument for xor
10328 Bad argument type for xor
10329 Bad argument type for strcpy
10330 Bad argument type for strncpy
10331 Bad argument type for unary backslash
10332 Bad argument type for setminus
10333 Bad first argument type for indices
10334 Bad second argument for indices
10335 Too-large re(argument) for exp
10336 Too-large re(argument) for sinh
10337 Too-large re(argument) for cosh
10338 Too-large im(argument) for sin
10339 Too-large im(argument) for cos
10340 Infinite or too-large result for gd
10341 Infinite or too-large result for agd
10342 Too-large value for power
10343 Too-large value for root
10344 Non-real first arg for digit
10345 Non-integral second arg for digit
10346 Bad third arg for digit
10347 Bad first argument for places
10348 Bad second argument for places
10349 Bad first argument for digits
10350 Bad second argument for digits
10351 Bad first argument for ilog
10352 Bad second argument for ilog
10353 Bad argument for ilog10
10354 Bad argument for ilog2
10355 Non-integer second arg for comb
10356 Too-large second arg for comb
10357 Bad argument for catalan
10358 Bad argument for bern
10359 Bad argument for euler
10360 Bad argument for sleep
10361 calc_tty failure
10362 No-copy-to destination for octet assign
10363 No-copy-from source for octet assign
10364 No-change destination for octet assign
10365 Non-variable destination for assign
10366 No-assign-to destination for assign
10367 No-assign-from source for assign
10368 No-change destination for assign
10369 No-type-change destination for assign
10370 No-error-value destination for assign
10371 No-copy argument for octet swap
10372 No-assign-to-or-from argument for swap
10373 Non-lvalue argument for swap
10374 Non-lvalue argument 3 or 4 for quomod
10375 Non-real-number arg 1 or 2 or bad arg 5 for quomod
10376 No-assign-to argument 3 or 4 for quomod
10377 No-copy-to or no-change argument for octet preinc
10378 Non-variable argument for preinc
10379 No-assign-to or no-change argument for preinc
10380 No-copy-to or no-change argument for octet predec
10381 Non-variable argument for predec
10382 No-assign-to or no-change argument for predec
10383 No-copy-to or no-change argument for octet postinc
10384 Non-variable argument for postinc
10385 No-assign-to or no-change argument for postinc
10386 No-copy-to or no-change argument for octet postdec
10387 Non-variable argument for postdec
10388 No-assign-to or no-change argument for postdec
10389 Error-type structure for initialization
10390 No-copy-to structure for initialization
10391 Too many initializer values
10392 Attempt to initialize freed named block
10393 Bad structure type for initialization
10394 No-assign-to element for initialization
10395 No-change element for initialization
10396 No-type-change element for initialization
10397 No-error-value element for initialization
10398 No-assign-or-copy-from source for initialization
10399 No-relocate for list insert
10400 No-relocate for list delete
10401 No-relocate for list push
10402 No-relocate for list append
10403 No-relocate for list pop
10404 No-relocate for list remove
10405 Non-variable first argument for modify
10406 Non-string second argument for modify
10407 No-change first argument for modify
10408 Undefined function for modify
10409 Unacceptable type first argument for modify
10410 Non-string arguments for fpathopen
10411 Unrecognized mode for fpathopen
10412 Bad epsilon argument for log
10413 Non-numeric first argument for log
10414 Non-file argument for fgetfile
10415 File argument for fgetfile not open for reading
10416 Unable to set file position in fgetfile
10417 Non-representable type for estr
10418 Non-string argument for strcasecmp
10419 Bad argument type for strncasecmp
10420 Bad argument for isupper
10421 Bad argument for islower
10422 Bad argument for isalnum
10423 Bad argument for isalpha
10424 Bad argument for isascii
10425 Bad argument for iscntrl
10426 Bad argument for isdigit
10427 Bad argument for isgraph
10428 Bad argument for isprint
10429 Bad argument for ispunct
10430 Bad argument for isspace
10431 Bad argument for isxdigit
10432 Bad argument type for strtoupper
10433 Bad argument type for strtolower
20000 base of user defined errors
*************
* file
*************
Using files
The calculator provides some functions which allow the program to
read or write text files. These functions use stdio internally,
and the functions appear similar to some of the stdio functions.
Some differences do occur, as will be explained here.
Names of files are subject to ~ expansion just like the C or
Korn shell. For example, the file name:
~/.rc.cal
refers to the file '.rc.cal' under your home directory. The
file name:
~chongo/.rc.cal
refers to the a file 'rc.cal' under the home directory of 'chongo'.
A file can be opened for either reading, writing, or appending.
To do this, the 'fopen' function is used, which accepts a filename
and an open mode, both as strings. You use 'r' for reading, 'w'
for writing, and 'a' for appending. For example, to open the file
'foo' for reading, the following could be used:
fd = fopen('foo', 'r');
If the open is unsuccessful, the numeric value of errno is returned.
If the open is successful, a value of type 'file' will be returned.
You can use the 'isfile' function to test the return value to see
if the open succeeded. You should assign the return value of fopen
to a variable for later use. File values can be copied to more than
one variable, and using any of the variables with the same file value
will produce the same results.
If you overwrite a variable containing a file value or don't save the
result of an 'fopen', the opened file still remains open. Such 'lost'
files can be recovered by using the 'files' function. This function
either takes no arguments or else takes one integer argument. If no
arguments are given, then 'files' returns the maximum number of opened
files. If an argument is given, then the 'files' function uses it as
an index into an internal table of open files, and returns a value
referring to one the open files. If that entry in the table is not
in use, then the null value is returned instead. Index 0 always
refers to standard input, index 1 always refers to standard output,
and index 2 always refers to standard error. These three files are
already open by the calculator and cannot be closed. As an example
of using 'files', if you wanted to assign a file value which is
equivalent to stdout, you could use:
stdout = files(1);
The 'fclose' function is used to close a file which had been opened.
When this is done, the file value associated with the file remains
a file value, but appears 'closed', and cannot be used in further
file-related calls (except fclose) without causing errors. This same
action occurs to all copies of the file value. You do not need to
explicitly close all the copies of a file value. The 'fclose'
function returns the numeric value of errno if there had been an
error using the file, or the null value if there was no error.
The builtin 'strerror' can be use to convert an errno number into
a slightly more meaningful error message:
badfile = fopen("not_a_file", "r");
if (!isfile(badfile)) {
print "error #" : badfile : ":", strerror(badfile);
}
File values can be printed. When this is done, the filename of the
opened file is printed inside of quote marks. If the file value had
been closed, then the null string is printed. If a file value is the
result of a top-level expression, then in addition to the filename,
the open mode, file position, and possible EOF, error, and closed
status is also displayed.
File values can be used inside of 'if' tests. When this is done,
an opened file is TRUE, and a closed file is FALSE. As an example
of this, the following loop will print the names of all the currently
opened non-standard files with their indexes, and then close them:
for (i = 3; i < files(); i++) {
if (files(i)) {
print i, files(i);
fclose(files(i));
}
}
The functions to read from files are 'fgetline' and 'fgetc'.
The 'fgetline' function accepts a file value, and returns the next
input line from a file. The line is returned as a string value, and
does not contain the end of line character. Empty lines return the
null string. When the end of file is reached, fgetline returns the
null value. (Note the distinction between a null string and a null
value.) If the line contained a numeric value, then the 'eval'
function can then be used to convert the string to a numeric value.
Care should be used when doing this, however, since eval will
generate an error if the string doesn't represent a valid expression.
The 'fgetc' function returns the next character from a file as a
single character string. It returns the null value when end of file
is reached.
The 'printf' and 'fprintf' functions are used to print results to a
file (which could be stdout or stderr). The 'fprintf' function
accepts a file variable, whereas the 'printf' function assumes the
use of 'files(1)' (stdout). They both require a format string, which
is used in almost the same way as in normal C. The differences come
in the interpretation of values to be printed for various formats.
Unlike in C, where an unmatched format type and value will cause
problems, in the calculator nothing bad will happen. This is because
the calculator knows the types of all values, and will handle them
all reasonably. What this means is that you can (for example), always
use %s or %d in your format strings, even if you are printing a non-
string or non-numeric value. For example, the following is valid:
printf("Two values are %d and %s\n", "fred", 4567);
and will print "Two values are fred and 4567".
Using particular format characters, however, is still useful if
you wish to use width or precision arguments in the format, or if
you wish to print numbers in a particular format. The following
is a list of the possible numeric formats:
%d print in currently defined numeric format
%f print as floating point
%e print as exponential
%r print as decimal fractions
%x print as hex fractions
%o print as octal fractions
%b print as binary fractions
Note then, that using %d in the format makes the output configurable
by using the 'config' function to change the output mode, whereas
the other formats override the mode and force the output to be in
the specified format.
Using the precision argument will override the 'config' function
to set the number of decimal places printed. For example:
printf("The number is %.100f\n", 1/3);
will print 100 decimal places no matter what the display configuration
value is set to.
The %s and %c formats are identical, and will print out the string
representation of the value. In these cases, the precision argument
will truncate the output the same way as in standard C.
If a matrix or list is printed, then the output mode and precision
affects the printing of each individual element. However, field
widths are ignored since these values print using multiple lines.
Field widths are also ignored if an object value prints on multiple
lines.
The functions 'fputc' and 'fputs' write a character and string to
a file respectively.
The final file-related functions are 'fflush', 'ferror', and 'feof'.
The 'fflush' function forces buffered output to a file. The 'ferror'
function returns nonzero if an error had occurred to a file. The
'feof' function returns nonzero if end of file has been reached
while reading a file.
The 'strprintf' function formats output similarly to 'printf',
but the output is returned as a string value instead of being
printed.
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: file,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/file,v $
##
## Under source code control: 1991/07/21 04:37:19
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* history
*************
Command history
There is a command line editor and history mechanism built
into calc, which is active when stdin is a terminal. When
stdin is not a terminal, then the command line editor is
disabled.
Lines of input to calc are always terminated by the return
(or enter) key. When the return key is typed, then the current
line is executed and is also saved into a command history list
for future recall.
Before the return key is typed, the current line can be edited
using emacs-like editing commands. As examples, ^A moves to
the beginning of the line, ^F moves forwards through the line,
backspace removes characters from the line, and ^K kills the
rest of the line.
Previously entered commands can be recalled by using the history
list. The history list functions in a LRU manner, with no
duplicated lines. This means that the most recently entered
lines are always at the end of the history list where they are
easiest to recall.
Typing <esc>h lists all of the commands in the command history
and numbers the lines. The most recently executed line is always
number 1, the next most recent number 2, and so on. The numbering
for a particular command therefore changes as lines are entered.
Typing a number at the beginning of a line followed by <esc>g
will recall that numbered line. So that for example, 2<esc>g
will recall the second most recent line that was entered.
The ^P and ^N keys move up and down the lines in the history list.
If they attempt to go off the top or bottom of the list, then a
blank line is shown to indicate this, and then they wrap around
to the other end of the list.
Typing a string followed by a ^R will search backwards through
the history and recall the most recent command which begins
with that string.
Typing ^O inserts the current line at the end of the history list
without executing it, and starts a new line. This is useful to
rearrange old history lines to become recent, or to save a partially
completed command so that another command can be typed ahead of it.
If your terminal has arrow keys which generate escape sequences
of a particular kind (<esc>[A and so on), then you can use
those arrow keys in place of the ^B, ^F, ^P, and ^N keys.
The actual keys used for editing are defined in a bindings file,
usually called /usr/local/lib/calc/bindings. Changing the entries
in this file will change the key bindings used for editing. If the
file is not readable, then a message will be output and command
line editing is disabled. In this case you can only edit each
line as provided by the terminal driver in the operating system.
A shell command can be executed by typing '!cmd', where cmd
is the command to execute. If cmd is not given, then a shell
command level is started.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: history,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/history,v $
##
## Under source code control: 1991/07/21 04:37:20
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* interrupt
*************
Interrupts
While a calculation is in progress, you can generate the SIGINT
signal, and the calculator will catch it. At appropriate points
within a calculation, the calculator will check that the signal
has been given, and will abort the calculation cleanly. If the
calculator is in the middle of a large calculation, it might be
a while before the interrupt has an effect.
You can generate the SIGINT signal multiple times if necessary,
and each time the calculator will abort the calculation at a more
risky place within the calculation. Each new interrupt prints a
message of the form:
[Abort level n]
where n ranges from 1 to 3. For n equal to 1, the calculator will
abort calculations at the next statement boundary specified by an
ABORT opcode as described below. For n equal to 2, the calculator
will abort calculations at the next opcode boundary. For n equal to 3,
the calculator will abort calculations at the next attempt to allocate
memory for the result of an integer arithmetic operation; this
level may be appropriate for stopping a builtin operation like
inversion of a large matrix.
If a final interrupt is given when n is 3, the calculator will
immediately abort the current calculation and longjmp back to the
top level command level. Doing this may result in corrupted data
structures and unpredictable future behavior, and so should only
be done as a last resort. You are advised to quit the calculator
after this has been done.
ABORT opcodes
If config("trace") & 2 is zero, ABORT opcodes are introduced at
various places in the opcodes for evaluation of command lines
and functions defined by "define ... { ... }" commands. In the
following, config("trace") has been set equal to 8 so that opcodes
are displayed when a function is defined. The function f(x)
evaluates x + (x - 1) + (x - 2) + ... until a zero term is
encountered. If f() is called with a negative or fractional x,
the calculation is never completed and to stop it, an interruption
(on many systems, by ctrl-C) will be necessary.
; config("trace", 8),
; define f(x) {local s; while (x) {s += x--} return s}
0: DEBUG line 2
2: PARAMADDR x
4: JUMPZ 19
6: DEBUG line 2
8: LOCALADDR s
10: DUPLICATE
11: PARAMADDR x
13: POSTDEC
14: POP
15: ADD
16: ASSIGNPOP
17: JUMP 2
19: DEBUG line 2
21: LOCALADDR s
23: RETURN
f(x) defined
(The line number following DEBUG refers to the line in the file
from which the definition is read.) If an attempt is made to
evaluate f(-1), the effect of the DEBUG at opcode 6 ensures that
a single SIGINT will stop the calculation at a start of
{s += x--} loop. In interactive mode, with ^C indicating
input of ctrl-C, the displayed output is as in:
; f(-1)
^C
[Abort level 1]
"f": line 2: Calculation aborted at statement boundary
The DEBUG opcodes are disabled by nonzero config("trace") & 2.
Changing config("trace") to achieve this, and defining g(x) with
the same definition as for f(x) gives:
; define g(x) {local s; while (x) {s += x--} return s}
0: PARAMADDR x
2: JUMPZ 15
4: LOCALADDR s
6: DUPLICATE
7: PARAMADDR x
9: POSTDEC
10: POP
11: ADD
12: ASSIGNPOP
13: JUMP 0
15: LOCALADDR s
17: RETURN
g(x) defined
If g(-1) is called, two interrupts are necessary, as in:
; g(-1)
^C
[Abort level 1]
^C
[Abort level 2]
"g": Calculation aborted in opcode
## Copyright (C) 1999-2006 David I. Bell, Landon Curt Noll and Ernest Bowen
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: interrupt,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/interrupt,v $
##
## Under source code control: 1991/07/21 04:37:21
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* list
*************
NAME
list - create list of specified values
SYNOPSIS
list([x, [x, ... ]])
TYPES
x any, &any
return list
DESCRIPTION
This function returns a list that is composed of the arguments x.
If no args are given, an empty list is returned.
Lists are a sequence of values which are doubly linked so that
elements can be removed or inserted anywhere within the list.
The function 'list' creates a list with possible initial elements.
For example,
x = list(4, 6, 7);
creates a list in the variable x of three elements, in the order
4, 6, and 7.
The 'push' and 'pop' functions insert or remove an element from
the beginning of the list. The 'append' and 'remove' functions
insert or remove an element from the end of the list. The 'insert'
and 'delete' functions insert or delete an element from the middle
(or ends) of a list. The functions which insert elements return
the null value, but the functions which remove an element return
the element as their value. The 'size' function returns the number
of elements in the list.
Note that these functions manipulate the actual list argument,
instead of returning a new list. Thus in the example:
push(x, 9);
x becomes a list of four elements, in the order 9, 4, 6, and 7.
Lists can be copied by assigning them to another variable.
An arbitrary element of a linked list can be accessed by using the
double-bracket operator. The beginning of the list has index 0.
Thus in the new list x above, the expression x[[0]] returns the
value of the first element of the list, which is 9. Note that this
indexing does not remove elements from the list.
Since lists are doubly linked in memory, random access to arbitrary
elements can be slow if the list is large. However, for each list
a pointer is kept to the latest indexed element, thus relatively
sequential accesses to the elements in a list will not be slow.
Lists can be searched for particular values by using the 'search'
and 'rsearch' functions. They return the element number of the
found value (zero based), or null if the value does not exist in
the list.
EXAMPLE
; list(2,"three",4i)
list (3 elements, 3 nonzero):
[[0]] = 2
[[1]] = "three"
[[2]] = 4i
; list()
list (0 elements, 0 nonzero)
LIMITS
none
LINK LIBRARY
none
SEE ALSO
append, delete, insert, islist, pop, push, remove, rsearch, search, size
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: list,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/list,v $
##
## Under source code control: 1994/03/19 03:13:19
## File existed as early as: 1994
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* mat
*************
NAME
mat - keyword to create a matrix value
SYNOPSIS
mat [index-range-list] [ = {value_0. ...} ]
mat [] [= {value_0, ...}]
mat variable_1 ... [index-range-list] [ = {value_0, ...} ]
mat variable_1 ... [] [ = {value_0, ...} ]
mat [index-range-list_1[index-ranges-list_2] ... [ = { { ...} ...} ]
decl id_1 id_2 ... [index-range-list] ...
TYPES
index-range-list range_1 [, range_2, ...] up to 4 ranges
range_1, ... integer, or integer_1 : integer_2
value, value_1, ... any
variable_1 ... lvalue
decl declarator = global, static or local
id_1, ... identifier
DESCRIPTION
The expression mat [index-range-list] returns a matrix value.
This may be assigned to one or more lvalues A, B, ... by either
mat A B ... [index-range-list]
or
A = B = ... = mat[index-range-list]
If a variable is specified by an expression that is not a symbol with
possibly object element specifiers, the expression should be enclosed
in parentheses. For example, parentheses are required in
mat (A[2]) [3] and mat (*p) [3] but mat P.x [3] is acceptable.
When an index-range is specified as integer_1 : integer_2, where
integer_1 and integer_2 are expressions which evaluate to integers,
the index-range consists of all integers from the minimum of the
two integers to the maximum of the two integers. For example,
mat[2:5, 0:4] and mat[5:2, 4:0] return the same matrix value.
If an index-range is an expression which evaluates to an integer,
the range is as if specified by 0 : integer - 1. For example,
mat[4] and mat[0:3] return the same 4-element matrix; mat[-2] and
mat[-3:0] return the same 4-element matrix.
If the variable A has a matrix value, then for integer indices
i_1, i_2, ..., equal in number to the number of ranges specified at
its creation, and such that each index is in the corresponding range,
the matrix element associated with those index list is given as an
lvalue by the expressions A[i_1, i_2, ...].
The elements of the matrix are stored internally as a linear array
in which locations are arranged in order of increasing indices.
For example, in order of location, the six element of A = mat [2,3]
are
A[0,0], A[0,1], A[0,2], A[1,0], A[1,,1], A[1,2].
These elements may also be specified using the double-bracket operator
with a single integer index as in A[[0]], A[[1]], ..., A[[5]].
If p is assigned the value &A[0.0], the address of A[[i]] for 0 <= i < 6
is p + i as long as A exists and a new value is not assigned to A.
When a matrix is created, each element is initially assigned the
value zero. Other values may be assigned then or later using the
"= {...}" assignment operation. Thus
A = {value_0, value_1, ...}
assigns the values value_0, value_1, ... to the elements A[[0]],
A[[1]], ... Any blank "value" is passed over. For example,
A = {1, , 2}
will assign the value 1 to A[[0]], 2 to A[[2]] and leave all other
elements unchanged. Values may also be assigned to elements by
simple assignments, as in A[0,0] = 1, A[0,2] = 2;
If the index-range is left blank but an initializer list is specified
as in:
; mat A[] = {1, 2 }
; B = mat[] = {1, , 3, }
the matrix created is one-dimensional. If the list contains a
positive number n of values or blanks, the result is as if the
range were specified by [n], i.e. the range of indices is from
0 to n - 1. In the above examples, A is of size 2 with A[0] = 1
and A[1] = 2; B is of size 4 with B[0] = 1, B[1] = B[3] = 0,
B[2] = 3. The specification mat[] = { } creates the same as mat[1].
If the index-range is left blank and no initializer list is specified,
as in mat C[] or C = mat[], the matrix assigned to C has zero
dimension; this has one element C[].
To assign a value using "= { ...}" at the same time as creating C,
parentheses are required as in (mat[]) = {value} or (mat C[]) =
{value}. Later a value may be assigned to C[] by C[] = value or
C = {value}.
The value assigned at any time to any element of a matrix can be of
any type - number, string, list, matrix, object of previously specified
type, etc. For some matrix operations there are of course conditions
that elements may have to satisfy: for example, addition of matrices
requires that addition of corresponding elements be possible.
If an element of a matrix is a structure for which indices or an
object element specifier is required, an element of that structure is
referred to by appropriate uses of [ ] or ., and so on if an element
of that element is required.
For example, one may have an expressions like:
; A[1,2][3].alpha[2];
if A[1,2][3].alpha is a list with at least three elements, A[1,2][3] is
an object of a type like obj {alpha, beta}, A[1,2] is a matrix of
type mat[4] and A is a mat[2,3] matrix. When an element of a matrix
is a matrix and the total number of indices does not exceed 4, the
indices can be combined into one list, e.g. the A[1,2][3] in the
above example can be shortened to A[1,2,3]. (Unlike C, A[1,2] cannot
be expressed as A[1][2].)
The function ismat(V) returns 1 if V is a matrix, 0 otherwise.
isident(V) returns 1 if V is a square matrix with diagonal elements 1,
off-diagonal elements zero, or a zero- or one-dimensional matrix with
every element 1; otherwise zero is returned. Thus isident(V) = 1
indicates that for V * A and A * V where A is any matrix of
for which either product is defined and the elements of A are real
or complex numbers, that product will equal A.
If V is matrix-valued, test(V) returns 0 if every element of V tests
as zero; otherwise 1 is returned.
The dimension of a matrix A, i.e. the number of index-ranges in the
initial creation of the matrix, is returned by the function matdim(A).
For 1 <= i <= matdim(A), the minimum and maximum values for the i-th
index range are returned by matmin(A, i) and matmax(A,i), respectively.
The total number of elements in the matrix is returned by size(A).
The sum of the elements in the matrix is returned by matsum(A).
The default method of printing matrices is to give a line of information
about the matrix, and to list on separate lines up to 15 elements,
the indices and either the value (for numbers, strings, objects) or
some descriptive information for lists or matrices, etc.
Numbers are displayed in the current number-printing mode.
The maximum number of elements to be printed can be assigned
any nonnegative integer value m by config("maxprint", m).
Users may define another method of printing matrices by defining a
function mat_print(M); for example, for a not too big 2-dimensional
matrix A it is a common practice to use a loop like:
define mat_print(A) {
local i,j;
for (i = matmin(A,1); i <= matmax(A,1); i++) {
if (i != matmin(A,1))
printf("\t");
for (j = matmin(A,2); j <= matmax(A,2); j++)
printf(" [%d,%d]: %e", i, j, A[i,j]);
if (i != matmax(A,1))
printf("\n");
}
}
So that when one defines a 2D matrix such as:
; mat X[2,3] = {1,2,3,4,5,6}
then printing X results in:
[0,0]: 1 [0,1]: 2 [0,2]: 3
[1,0]: 4 [1,1]: 5 [1,2]: 6
The default printing may be restored by
; undefine mat_print;
The keyword "mat" followed by two or more index-range-lists returns a
matrix with indices specified by the first list, whose elements are
matrices as determined by the later index-range-lists. For
example mat[2][3] is a 2-element matrix, each of whose elements has
as its value a 3-element matrix. Values may be assigned to the
elements of the innermost matrices by nested = {...} operations as in
; mat [2][3] = {{1,2,3},{4,5,6}}
An example of the use of mat with a declarator is
; global mat A B [2,3], C [4]
This creates, if they do not already exist, three global variables with
names A, B, C, and assigns to A and B the value mat[2,3] and to C mat[4].
Some operations are defined for matrices.
A == B
Returns 1 if A and B are of the same "shape" and "corresponding"
elements are equal; otherwise 0 is returned. Being of the same
shape means they have the same dimension d, and for each i <= d,
matmax(A,i) - matmin(A,i) == matmax(B,i) - matmin(B,i),
One consequence of being the same shape is that the matrices will
have the same size. Elements "correspond" if they have the same
double-bracket indices; thus A == B implies that A[[i]] == B[[i]]
for 0 <= i < size(A) == size(B).
A + B
A - B
These are defined A and B have the same shape, the element
with double-bracket index j being evaluated by A[[j]] + B[[j]] and
A[[j]] - B[[j]], respectively. The index-ranges for the results
are those for the matrix A.
A[i,j]
If A is two-dimensional, it is customary to speak of the indices
i, j in A[i,j] as referring to rows and columns; the number of
rows is matmax(A,1) - matmin(A,1) + 1; the number of columns if
matmax(A,2) - matmin(A,2) + 1. A matrix is said to be square
if it is two-dimensional and the number of rows is equal to the
number of columns.
A * B
Multiplication is defined provided certain conditions by the
dimensions and shapes of A and B are satisfied. If both have
dimension 2 and the column-index-list for A is the same as
the row-index-list for B, C = A * B is defined in the usual
way so that for i in the row-index-list of A and j in the
column-index-list for B,
C[i,j] = Sum A[i,k] * B[k,j]
the sum being over k in the column-index-list of A. The same
formula is used so long as the number of columns in A is the same
as the number of rows in B and k is taken to refer to the offset
from matmin(A,2) and matmin(B,1), respectively, for A and B.
If the multiplications and additions required cannot be performed,
an execution error may occur or the result for C may contain
one or more error-values as elements.
If A or B has dimension zero, the result for A * B is simply
that of multiplying the elements of the other matrix on the
left by A[] or on the right by B[].
If both A and B have dimension 1, A * B is defined if A and B
have the same size; the result has the same index-list as A
and each element is the product of corresponding elements of
A and B. If A and B have the same index-list, this multiplication
is consistent with multiplication of 2D matrices if A and B are
taken to represent 2D matrices for which the off-diagonal elements
are zero and the diagonal elements are those of A and B.
the real and complex numbers.
If A is of dimension 1 and B is of dimension 2, A * B is defined
if the number of rows in B is the same as the size of A. The
result has the same index-lists as B; each row of B is multiplied
on the left by the corresponding element of A.
If A is of dimension 2 and B is of dimension 1, A * B is defined
if number of columns in A is the same as the size of A. The
result has the same index-lists as A; each column of A is
multiplied on the right by the corresponding element of B.
The algebra of additions and multiplications involving both one-
and two-dimensional matrices is particularly simple when all the
elements are real or complex numbers and all the index-lists are
the same, as occurs, for example, if for some positive integer n,
all the matrices start as mat [n] or mat [n,n].
det(A)
If A is a square, det(A) is evaluated by an algorithm that returns
the determinant of A if the elements of A are real or complex
numbers, and if such an A is non-singular, inverse(A) returns
the inverse of A indexed in the same way as A. For matrix A of
dimension 0 or 1, det(A) is defined as the product of the elements
of A in the order in which they occur in A, inverse(A) returns
a matrix indexed in the same way as A with each element inverted.
The following functions are defined to return matrices with the same
index-ranges as A and the specified operations performed on all
elements of A. Here num is an arbitrary complex number (nonzero
when it is a divisor), int an integer, rnd a rounding-type
specifier integer, real a real number.
num * A
A * num
A / num
- A
conj(A)
A << int, A >> int
scale(A, int)
round(A, int, rnd)
bround(A, int, rnd)
appr(A, real, rnd)
int(A)
frac(A)
A // real
A % real
A ^ int
If A and B are one-dimensional of the same size dp(A, B) returns
their dot-product, i.e. the sum of the products of corresponding
elements.
If A and B are one-dimension and of size 3, cp(A, B) returns their
cross-product.
randperm(A) returns a matrix indexed the same as A in which the elements
of A have been randomly permuted.
sort(A) returns a matrix indexed the same as A in which the elements
of A have been sorted.
If A is an lvalue whose current value is a matrix, matfill(A, v)
assigns the value v to every element of A, and if also, A is
square, matfill(A, v1, v2) assigns v1 to the off-diagonal elements,
v2 to the diagonal elements. To create and assign to A the unit
n * n matrix, one may use matfill(mat A[n,n], 0, 1).
For a square matrix A, mattrace(A) returns the trace of A, i.e. the
sum of the diagonal elements. For zero- or one-dimensional A,
mattrace(A) returns the sum of the elements of A.
For a two-dimensional matrix A, mattrans(A) returns the transpose
of A, i.e. if A is mat[m,n], it returns a mat[n,m] matrix with
[i,j] element equal to A[j,i]. For zero- or one-dimensional A,
mattrace(A) returns a matrix with the same value as A.
The functions search(A, value, start, end]) and
rsearch(A, value, start, end]) return the first or last index i
for which A[[i]] == value and start <= i < end, or if there is
no such index, the null value. For further information on default
values and the use of an "accept" function, see the help files for
search and rsearch.
reverse(A) returns a matrix with the same index-lists as A but the
elements in reversed order.
The copy and blkcpy functions may be used to copy data to a matrix from
a matrix or list, or from a matrix to a list. In copying from a
matrix to a matrix the matrices need not have the same dimension;
in effect they are treated as linear arrays.
EXAMPLE
; obj point {x,y}
; mat A[5] = {1, 2+3i, "ab", mat[2] = {4,5}, obj point = {6,7}}
; A
mat [5] (5 elements, 5 nonzero):
[0] = 1
[1] = 2+3i
[2] = "ab"
[3] = mat [2] (2 elements, 2 nonzero)
[4] = obj point {6, 7}
; print A[0], A[1], A[2], A[3][0], A[4].x
1 2+3i ab 4 6
; define point_add(a,b) = obj point = {a.x + b.x, a.y + b.y}
point_add(a,b) defined
; mat [B] = {8, , "cd", mat[2] = {9,10}, obj point = {11,12}}
; A + B
mat [5] (5 elements, 5 nonzero):
[0] = 9
[1] = 2+3i
[2] = "abcd"
[3] = mat [2] (2 elements, 2 nonzero)
[4] = obj point {17, 19}
; mat C[2,2] = {1,2,3,4}
; C^10
mat [2,2] (4 elements, 4 nonzero):
[0,0] = 4783807
[0,1] = 6972050
[1,0] = 10458075
[1,1] = 15241882
; C^-10
mat [2,2] (4 elements, 4 nonzero):
[0,0] = 14884.650390625
[0,1] = -6808.642578125
[1,0] = -10212.9638671875
[1,1] = 4671.6865234375
; mat A[4] = {1,2,3,4}, A * reverse(A);
mat [4] (4 elements, 4 nonzero):
[0] = 4
[1] = 6
[2] = 6
[3] = 4
LIMITS
The theoretical upper bound for the absolute values of indices is
2^31 - 1, but the size of matrices that can be handled in practice will
be limited by the availability of memory and what is an acceptable
runtime. For example, although it may take only a fraction of a
second to invert a 10 * 10 matrix, it will probably take about 1000
times as long to invert a 100 * 100 matrix.
LINK LIBRARY
n/a
SEE ALSO
ismat, matdim, matmax, matmin, mattrans, mattrace, matsum, matfill,
det, inverse, isident, test, config, search, rsearch, reverse, copy,
blkcpy, dp, cp, randperm, sort
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: mat,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/mat,v $
##
## Under source code control: 1991/07/21 04:37:22
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* obj
*************
Using objects
Objects are user-defined types which are associated with user-
defined functions to manipulate them. Object types are defined
similarly to structures in C, and consist of one or more elements.
The advantage of an object is that the user-defined routines are
automatically called by the calculator for various operations,
such as addition, multiplication, and printing. Thus they can be
manipulated by the user as if they were just another kind of number.
An example object type is "surd", which represents numbers of the form
a + b*sqrt(D),
where D is a fixed integer, and 'a' and 'b' are arbitrary rational
numbers. Addition, subtraction, multiplication, and division can be
performed on such numbers, and the result can be put unambiguously
into the same form. (Complex numbers are an example of surds, where
D is -1.)
The "obj" statement defines either an object type or an actual
variable of that type. When defining the object type, the names of
its elements are specified inside of a pair of braces. To define
the surd object type, the following could be used:
obj surd {a, b};
Here a and b are the element names for the two components of the
surd object. An object type can be defined more than once as long
as the number of elements and their names are the same.
When an object is created, the elements are all defined with zero
values. A user-defined routine should be provided which will place
useful values in the elements. For example, for an object of type
'surd', a function called 'surd' can be defined to set the two
components as follows:
define surd(a, b)
{
local x;
obj surd x;
x.a = a;
x.b = b;
return x;
}
When an operation is attempted for an object, user functions with
particular names are automatically called to perform the operation.
These names are created by concatenating the object type name and
the operation name together with an underscore. For example, when
multiplying two objects of type surd, the function "surd_mul" is
called.
The user function is called with the necessary arguments for that
operation. For example, for "surd_mul", there are two arguments,
which are the two numbers. The order of the arguments is always
the order of the binary operands. If only one of the operands to
a binary operator is an object, then the user function for that
object type is still called. If the two operands are of different
object types, then the user function that is called is the one for
the first operand.
The above rules mean that for full generality, user functions
should detect that one of their arguments is not of its own object
type by using the 'istype' function, and then handle these cases
specially. In this way, users can mix normal numbers with object
types. (Functions which only have one operand don't have to worry
about this.) The following example of "surd_mul" demonstrates how
to handle regular numbers when used together with surds:
define surd_mul(a, b)
{
local x;
obj surd x;
if (!istype(a, x)) {
/* a not of type surd */
x.a = b.a * a;
x.b = b.b * a;
} else if (!istype(b, x)) {
/* b not of type surd */
x.a = a.a * b;
x.b = a.b * b;
} else {
/* both are surds */
x.a = a.a * b.a + D * a.b * b.b;
x.b = a.a * b.b + a.b * b.a;
}
if (x.b == 0)
return x.a; /* normal number */
return x; /* return surd */
}
In order to print the value of an object nicely, a user defined
routine can be provided. For small amounts of output, the print
routine should not print a newline. Also, it is most convenient
if the printed object looks like the call to the creation routine.
For output to be correctly collected within nested output calls,
output should only go to stdout. This means use the 'print'
statement, the 'printf' function, or the 'fprintf' function with
'files(1)' as the output file. For example, for the "surd" object:
define surd_print(a)
{
print "surd(" : a.a : "," : a.b : ")" : ;
}
It is not necessary to provide routines for all possible operations
for an object, if those operations can be defaulted or do not make
sense for the object. The calculator will attempt meaningful
defaults for many operations if they are not defined. For example,
if 'surd_square' is not defined to square a number, then 'surd_mul'
will be called to perform the squaring. When a default is not
possible, then an error will be generated.
Please note: Arguments to object functions are always passed by
reference (as if an '&' was specified for each variable in the call).
Therefore, the function should not modify the parameters, but should
copy them into local variables before modifying them. This is done
in order to make object calls quicker in general.
The double-bracket operator can be used to reference the elements
of any object in a generic manner. When this is done, index 0
corresponds to the first element name, index 1 to the second name,
and so on. The 'size' function will return the number of elements
in an object.
The following is a list of the operations possible for objects.
The 'xx' in each function name is replaced with the actual object
type name. This table is displayed by the 'show objfunctions' command.
Name Args Comments
xx_print 1 print value, default prints elements
xx_one 1 multiplicative identity, default is 1
xx_test 1 logical test (false,true => 0,1),
default tests elements
xx_add 2
xx_sub 2
xx_neg 1 negative
xx_mul 2
xx_div 2 non-integral division
xx_inv 1 multiplicative inverse
xx_abs 2 absolute value within given error
xx_norm 1 square of absolute value
xx_conj 1 conjugate
xx_pow 2 integer power, default does multiply,
square, inverse
xx_sgn 1 sign of value (-1, 0, 1)
xx_cmp 2 equality (equal,nonequal => 0,1),
default tests elements
xx_rel 2 relative order, positive for >, etc.
xx_quo 3 integer quotient
xx_mod 3 remainder of division
xx_int 1 integer part
xx_frac 1 fractional part
xx_inc 1 increment, default adds 1
xx_dec 1 decrement, default subtracts 1
xx_square 1 default multiplies by itself
xx_scale 2 multiply by power of 2
xx_shift 2 shift left by n bits (right if negative)
xx_round 3 round to given number of decimal places
xx_bround 3 round to given number of binary places
xx_root 3 root of value within given error
xx_sqrt 3 square root within given error
xx_or 2 bitwise or
xx_and 2 bitwise and
xx_not 1 logical not
xx_fact 1 factorial or postfix !
xx_min 1 value for min(...)
xx_max 1 value for max(...)
xx_sum 1 value for sum(...)
xx_assign 2 assign, defaults to a = b
xx_xor 2 value for binary ~
xx_comp 1 value for unary ~
xx_content 1 unary hash op
xx_hashop 2 binary hash op
xx_backslash 1 unary backslash op
xx_setminus 2 binary backslash op
xx_plus 1 unary + op
Also see the standard resource files:
deg.cal
dms.cal
ellip.cal
hms.cal
mod.cal
natnumset.cal
poly.cal
quat.cal
regress.cal
set8700.cal
surd.cal
test2300.cal
test3100.cal
## Copyright (C) 1999,2010 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.4 $
## @(#) $Id: obj.file,v 30.4 2013/08/11 08:41:38 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/obj.file,v $
##
## Under source code control: 1991/07/21 04:37:22
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* operator
*************
operators
The operators are similar to C, but there are some differences in
the associativity and precedence rules for some operators. In
addition, there are several operators not in C, and some C
operators are missing. A more detailed discussion of situations
that may be unexpected for the C programmer may be found in
the 'unexpected' help file.
Below is a list giving the operators arranged in order of
precedence, from the least tightly binding to the most tightly
binding. Except where otherwise indicated, operators at the same
level of precedence associate from left to right.
Unlike C, calc has a definite order for evaluation of terms (addends
in a sum, factors in a product, arguments for a function or a
matrix, etc.). This order is always from left to right. but
skipping of terms may occur for ||, && and ? : . For example,
an expression of the form:
A * B + C * D
is evaluated in the following order:
A
B
A * B
C
D
C * D
A * B + C * D
This order of evaluation is significant if evaluation of a
term changes a variable on which a later term depends. For example:
x++ * x++ + x++ * x++
returns the value of:
x * (x + 1) + (x + 2) * (x + 3)
and increments x as if by x += 4. Similarly, for functions f, g,
the expression:
f(x++, x++) + g(x++)
evaluates to:
f(x, x + 1) + g(x + 2)
and increments x three times.
In A || B, B is read only if A tests as false; in A && B, B is
read only if A tests as true. Thus if x is nonzero,
x++ || x++ returns x and increments x once; if x is zero,
it returns x + 1 and increments x twice.
, Comma operator.
a, b returns the value of b.
For situations in which a comma is used for another purpose
(function arguments, array indexing, and the print statement),
parenthesis must be used around the comma operator expression.
E.g., if A is a matrix, A[(a, b), c] evaluates a, b, and c, and
returns the value of A[b, c].
+= -= *= /= %= //= &= |= <<= >>= ^= **=
Operator-with-assignments.
These associate from left to right, e.g. a += b *= c has the
effect of a = (a + b) * c, where only a is required to be an
lvalue. For the effect of b *= c; a += b; when both a and b
are lvalues, use a += (b *= c).
= Assignment.
As in C, this, when repeated, this associates from right to left,
e.g. a = b = c has the effect of a = (b = c). Here both a and b
are to be lvalues.
? : Conditional value.
a ? b : c returns b if a tests as true (i.e. nonzero if
a is a number), c otherwise. Thus it is equivalent to:
if (a) return b; else return c;.
All that is required of the arguments in this function
is that the "is-it-true?" test is meaningful for a.
As in C, this operator associates from right to left,
i.e. a ? b : c ? d : e is evaluated as a ? b : (c ? d : e).
|| Logical OR.
Unlike C, the result for a || b is one of the operands
a, b rather than one of the numbers 0 and 1.
a || b is equivalent to a ? a : b, i.e. if a tests as
true, a is returned, otherwise b. The effect in a
test like "if (a || b) ... " is the same as in C.
&& Logical AND.
Unlike C, the result for a && b is one of the operands
a, b rather than one of the numbers 0 and 1.
a && b is equivalent to a ? b : a, i.e. if a tests as
true, b is returned, otherwise a. The effect in a
test like "if (a && b) ... " is the same as in C.
== != <= >= < >
Relations.
+ -
Binary plus and minus and unary plus and minus when applied to
a first or only term.
* / // %
Multiply, divide, and modulo.
Please Note: The '/' operator is a fractional divide,
whereas the '//' is an integral divide. Thus think of '/'
as division of real numbers, and think of '//' as division
of integers (e.g., 8 / 3 is 8/3 whereas 8 // 3 is 2).
The '%' is integral or fractional modulus (e.g., 11%4 is 3,
and 10%pi() is ~.575222).
| Bitwise OR.
In a | b, both a and b are to be real integers;
the signs of a and b are ignored, i.e.
a | b = abs(a) | abs(b) and the result will
be a non-negative integer.
& Bitwise AND.
In a & b, both a and b are to be real integers;
the signs of a and b are ignored as for a | b.
^ ** << >>
Powers and shifts.
The '^' and '**' are both exponentiation, e.g. 2^3
returns 8, 2^-3 returns .125. Note that in a^b, if
'a' == 0 and 'b' is real, then is must be >= 0 as well.
Also 0^0 and 0**0 return the value 1.
For the shift operators both arguments are to be
integers, or if the first is complex, it is to have
integral real and imaginary parts. Changing the
sign of the second argument reverses the shift, e.g.
a >> -b = a << b. The result has the same sign as
the first argument except that a nonzero value is
reduced to zero by a sufficiently long shift to the
right. These operators associate right to left,
e.g. a << b ^ c = a << (b ^ c).
+ - !
Plus (+) and minus (-) have their usual meanings as unary
prefix operators at this level of precedence when applied to
other than a first or only term.
As a prefix operator, '!' is the logical NOT: !a returns 0 if
a tests as nonzero, and 1 if a tests as zero, i.e. it is
equivalent to a ? 0 : 1. Be careful about
using this as the first character of a top level command,
since it is also used for executing shell commands.
As a postfix operator ! gives the factorial function, i.e.
a! = fact(a).
++ --
Pre or post incrementing or decrementing.
These are applicable only to variables.
[ ] [[ ]] . ( )
Indexing, double-bracket indexing, element references,
and function calls. Indexing can only be applied to matrices,
element references can only be applied to objects, but
double-bracket indexing can be applied to matrices, objects,
or lists.
variables constants . ( )
These are variable names and constants, the special '.' symbol,
or a parenthesized expression. Variable names begin with a
letter, but then can contain letters, digits, or underscores.
Constants are numbers in various formats, or strings inside
either single or double quote marks.
The most significant difference from the order of precedence in
C is that | and & have higher precedence than ==, +, -, *, / and %.
For example, in C a == b | c * d is interpreted as:
(a == b) | (c * d)
and calc it is:
a == ((b | c) * d)
Most of the operators will accept any real or complex numbers
as arguments. The exceptions are:
/ // %
Second argument must be nonzero.
^
The exponent must be an integer. When raising zero
to a power, the exponent must be non-negative.
| &
Both both arguments must be integers.
<< >>
The shift amount must be an integer. The value being
shifted must be an integer or a complex number with
integral real and imaginary parts.
See the 'unexpected' help file for a list of unexpected
surprises in calc syntax/usage. Persons familiar with C should
read the 'unexpected' help file to avoid confusion.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.2 $
## @(#) $Id: operator,v 30.2 2007/07/11 23:00:39 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/operator,v $
##
## Under source code control: 1991/07/21 04:37:23
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* statement
*************
Statements
Statements are very much like C statements. Most statements act
identically to those in C, but there are minor differences and
some additions. The following is a list of the statement types,
with explanation of the non-C statements.
Statements are generally terminated with semicolons or { ... }.
C-like statements
-----------------
{ statement }
{ statement; ... statement }
C-like flow control
-------------------
if (expr) statement
if (expr) statement else statement
for (optionalexpr ; optionalexpr ; optionalexpr) statement
while (expr) statement
do statement while (expr)
These all work like in normal C.
IMPORTANT NOTE: When statement is of the form { ... },
the leading { must be on the same line as the if, for,
while or do keyword.
This works as expected:
if (expr) {
...
}
However this WILL NOT WORK AS EXPECTED:
if (expr)
{
...
}
because calc will parse the if being terminated by
an empty statement followed by a
if (expr) ;
{
...
}
In the same way, use these forms:
for (optionalexpr ; optionalexpr ; optionalexpr) {
...
}
while (expr) {
...
}
do {
...
while (expr);
where the initial { is on the SAME LINE as the if, while,
for or do.
See 'help expression' for details on expressions.
See 'help builtin' for details on calc builtin functions.
See 'help unexpanded' for things C programmers do not expect.
See also 'help todo' and 'help bugs'.
C-like flow breaks
------------------
continue
break
goto label
These all work like in normal C.
See 'help expression' for details on expressions.
See 'help builtin' for details on calc builtin functions.
return
------
return
return expr
return ( expr )
This returns a value from a function. Functions always
have a return value, even if this statement is not used.
If no return statement is executed, or if no expression
is specified in the return statement, then the return
value from the function is the null type.
switch
------
switch (expr) { caseclauses }
Switch statements work similarly to C, except for the
following. A switch can be done on any type of value,
and the case statements can be of any type of values.
The case statements can also be expressions calculated
at runtime. The calculator compares the switch value
with each case statement in the order specified, and
selects the first case which matches. The default case
is the exception, and only matches once all other cases
have been tested.
matrix
------
mat variable [dimension] [dimension] ...
mat variable [dimension, dimension, ...]
mat variable [] = { value, ... }
This creates a matrix variable with the specified dimensions.
Matrices can have from 1 to 4 dimensions. When specifying
multiple dimensions, you can use either the standard C syntax,
or else you can use commas for separating the dimensions.
For example, the following two statements are equivalent,
and so will create the same two dimensional matrix:
mat foo[3][6];
mat foo[3,6];
By default, each dimension is indexed starting at zero,
as in normal C, and contains the specified number of
elements. However, this can be changed if a colon is
used to separate two values. If this is done, then the
two values become the lower and upper bounds for indexing.
This is convenient, for example, to create matrices whose
first row and column begin at 1. Examples of matrix
definitions are:
mat x[3] one dimension, bounds are 0-2
mat foo[4][5] two dimensions, bounds are 0-3 and 0-4
mat a[-7:7] one dimension, bounds are (-7)-7
mat s[1:9,1:9] two dimensions, bounds are 1-9 and 1-9
Note that the MAT statement is not a declaration, but is
executed at runtime. Within a function, the specified
variable must already be defined, and is just converted to
a matrix of the specified size, and all elements are set
to the value of zero. For convenience, at the top level
command level, the MAT command automatically defines a
global variable of the specified name if necessary.
Since the MAT statement is executed, the bounds on the
matrix can be full expressions, and so matrices can be
dynamically allocated. For example:
size = 20;
mat data[size*2];
allocates a matrix which can be indexed from 0 to 39.
Initial values for the elements of a matrix can be specified
by following the bounds information with an equals sign and
then a list of values enclosed in a pair of braces. Even if
the matrix has more than one dimension, the elements must be
specified as a linear list. If too few values are specified,
the remaining values are set to zero. If too many values are
specified, a runtime error will result. Examples of some
initializations are:
mat table1[5] = {77, 44, 22};
mat table2[2,2] = {1, 2, 3, 4};
When an initialization is done, the bounds of the matrix
can optionally be left out of the square brackets, and the
correct bounds (zero based) will be set. This can only be
done for one-dimensional matrices. An example of this is:
mat fred[] = {99, 98, 97};
The MAT statement can also be used in declarations to set
variables as being matrices from the beginning. For example:
local mat temp[5];
static mat strtable[] = {"hi", "there", "folks");
object
------
obj type { elementnames } optionalvariables
obj type variable
These create a new object type, or create one or more
variables of the specified type. For this calculator,
an object is just a structure which is implicitly acted
on by user defined routines. The user defined routines
implement common operations for the object, such as plus
and minus, multiply and divide, comparison and printing.
The calculator will automatically call these routines in
order to perform many operations.
To create an object type, the data elements used in
implementing the object are specified within a pair
of braces, separated with commas. For example, to
define an object will will represent points in 3-space,
whose elements are the three coordinate values, the
following could be used:
obj point {x, y, z};
This defines an object type called point, whose elements
have the names x, y, and z. The elements are accessed
similarly to structure element accesses, by using a period.
For example, given a variable 'v' which is a point object,
the three coordinates of the point can be referenced by:
v.x
v.y
v.z
A particular object type can only be defined once, and
is global throughout all functions. However, different
object types can be used at the same time.
In order to create variables of an object type, they
can either be named after the right brace of the object
creation statement, or else can be defined later with
another obj statement. To create two points using the
second (and most common) method, the following is used:
obj point p1, p2;
This statement is executed, and is not a declaration.
Thus within a function, the variables p1 and p2 must have
been previously defined, and are just changed to be the
new object type. For convenience, at the top level command
level, object variables are automatically defined as being
global when necessary.
Initial values for an object can be specified by following
the variable name by an equals sign and a list of values
enclosed in a pair of braces. For example:
obj point pt = {5, 6};
The OBJ statement can also be used in declarations to set
variables as being objects from the beginning. If multiple
variables are specified, then each one is defined as the
specified object type. Examples of declarations are:
local obj point temp1;
static obj point temp2 = {4, 3};
global obj point p1, p2, p3;
print expressions
-----------------
print expr
print expr, ... expr
print expr: ... expr
For interactive expression evaluation, the values of all
typed-in expressions are automatically displayed to the
user. However, within a function or loop, the printing of
results must be done explicitly. This can be done using
the 'printf' or 'fprintf' functions, as in standard C, or
else by using the built-in 'print' statement. The advantage
of the print statement is that a format string is not needed.
Instead, the given values are simply printed with zero or one
spaces between each value.
Print accepts a list of expressions, separated either by
commas or colons. Each expression is evaluated in order
and printed, with no other output, except for the following
special cases. The comma which separates expressions prints
a single space, and a newline is printed after the last
expression unless the statement ends with a colon. As
examples:
print 3, 4; prints "3 4" and newline.
print 5:; prints "5" with no newline.
print 'a' : 'b' , 'c'; prints "ab c" and newline.
print; prints a newline.
For numeric values, the format of the number depends on the
current "mode" configuration parameter. The initial mode
is to print real numbers, but it can be changed to other
modes such as exponential, decimal fractions, or hex.
If a matrix or list is printed, then the elements contained
within the matrix or list will also be printed, up to the
maximum number specified by the "maxprint" configuration
parameter. If an element is also a matrix or a list, then
their values are not recursively printed. Objects are printed
using their user-defined routine. Printing a file value
prints the name of the file that was opened.
Also see the help topic:
help command top level commands
help expression calc expression syntax
help builtin calc builtin functions
help usage how to invoke the calc command and calc -options
You may obtain help on individual builtin functions. For example:
help asinh
help round
See:
help builtin
for a list of builtin functions.
Some calc operators have their own help pages:
help ->
help *
help .
help %
help //
help #
See also:
help help
## Copyright (C) 1999-2007 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: statement,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/statement,v $
##
## Under source code control: 1991/07/21 04:37:23
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* resource
*************
Calc standard resource files
----------------------------
To load a resource file, try:
read filename
You do not need to add the .cal extension to the filename. Calc
will search along the $CALCPATH (see ``help environment'').
Normally a resource file will simply define some functions. By default,
most resource files will print out a short message when they are read.
For example:
; read lucas
lucas(h,n) defined
gen_u0(h,n,v1) defined
gen_v1(h,n) defined
ldebug(funct,str) defined
will cause calc to load and execute the 'lucas.cal' resource file.
Executing the resource file will cause several functions to be defined.
Executing the lucas function:
; lucas(149,60)
1
; lucas(146,61)
0
shows that 149*2^60-1 is prime whereas 146*2^61-1 is not.
=-=
Calc resource file files are provided because they serve as examples of
how use the calc language, and/or because the authors thought them to
be useful!
If you write something that you think is useful, please join the
low volume calc mailing list calc-tester. Then send your contribution
to the calc-tester mailing list.
To subscribe to the calc-tester mailing list, visit the following URL:
https://www.listbox.com/subscribe/?list_id=239342
To help determine you are a human and not just a spam bot,
you will be required to provide the following additional info:
Your Name
Calc Version
Operating System
The date 7 days ago
This is a low volume moderated mailing list.
This mailing list replaces calc-tester at asthe dot com list.
If you need a human to help you with your mailing list subscription,
please send EMail to our special:
calc-tester-maillist-help at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
address. To be sure we see your EMail asking for help with your
mailing list subscription, please use the following phase in your
EMail Subject line:
calc tester mailing list help
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
=-=
By convention, a resource file only defines and/or initializes functions,
objects and variables. (The regress.cal and testxxx.cal regression test
suite is an exception.) Also by convention, an additional usage message
regarding important object and functions is printed.
If a resource file needs to load another resource file, it should use
the -once version of read:
/* pull in needed resource files */
read -once "surd"
read -once "lucas"
This will cause the needed resource files to be read once. If these
files have already been read, the read -once will act as a noop.
The "resource_debug" parameter is intended for controlling the possible
display of special information relating to functions, objects, and
other structures created by instructions in calc resource files.
Zero value of config("resource_debug") means that no such information
is displayed. For other values, the non-zero bits which currently
have meanings are as follows:
n Meaning of bit n of config("resource_debug")
0 When a function is defined, redefined or undefined at
interactive level, a message saying what has been done
is displayed.
1 When a function is defined, redefined or undefined during
the reading of a file, a message saying what has been done
is displayed.
2 Show func will display more information about a functions
arguments as well as more argument summary information.
3 During execution, allow calc standard resource files
to output additional debugging information.
The value for config("resource_debug") in both oldstd and newstd is 3,
but if calc is invoked with the -d flag, its initial value is zero.
Thus, if calc is started without the -d flag, until config("resource_debug")
is changed, a message will be output when a function is defined
either interactively or during the reading of a file.
Sometimes the information printed is not enough. In addition to the
standard information, one might want to print:
* useful obj definitions
* functions with optional args
* functions with optional args where the param() interface is used
For these cases we suggest that you place at the bottom of your code
something that prints extra information if config("resource_debug") has
either of the bottom 2 bits set:
if (config("resource_debug") & 3) {
print "obj xyz defined";
print "funcA([val1 [, val2]]) defined";
print "funcB(size, mass, ...) defined";
}
If your the resource file needs to output special debugging information,
we recommend that you check for bit 3 of the config("resource_debug")
before printing the debug statement:
if (config("resource_debug") & 8) {
print "DEBUG: This a sample debug statement";
}
=-=
The following is a brief description of some of the calc resource files
that are shipped with calc. See above for example of how to read in
and execute these files.
alg_config.cal
global test_time
mul_loop(repeat,x) defined
mul_ratio(len) defined
best_mul2() defined
sq_loop(repeat,x) defined
sq_ratio(len) defined
best_sq2() defined
pow_loop(repeat,x,ex) defined
pow_ratio(len) defined
best_pow2() defined
These functions search for an optimal value of config("mul2"),
config("sq2"), and config("pow2"). The calc default values of these
configuration values were set by running this resource file on a
1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS.
The best_mul2() function returns the optimal value of config("mul2").
The best_sq2() function returns the optimal value of config("sq2").
The best_pow2() function returns the optimal value of config("pow2").
The other functions are just support functions.
By design, best_mul2(), best_sq2(), and best_pow2() take a few
minutes to run. These functions increase the number of times a
given computational loop is executed until a minimum amount of CPU
time is consumed. To watch these functions progress, one can set
the config("user_debug") value.
Here is a suggested way to use this resource file:
; read alg_config
; config("user_debug",2),;
; best_mul2(); best_sq2(); best_pow2();
; best_mul2(); best_sq2(); best_pow2();
; best_mul2(); best_sq2(); best_pow2();
NOTE: It is perfectly normal for the optimal value returned to differ
slightly from run to run. Slight variations due to inaccuracy in
CPU timings will cause the best value returned to differ slightly
from run to run.
One can use a calc startup file to change the initial values of
config("mul2"), config("sq2"), and config("pow2"). For example one
can place into ~/.calcrc these lines:
config("mul2", 1780),;
config("sq2", 3388),;
config("pow2", 176),;
to automatically and silently change these config values.
See help/config and CALCRC in help/environment for more information.
beer.cal
This calc resource is calc's contribution to the 99 Bottles of Beer
web page:
http://www.ionet.net/~timtroyr/funhouse/beer.html#calc
NOTE: This resource produces a lot of output. :-)
bernoulli.cal
B(n)
Calculate the nth Bernoulli number.
NOTE: There is now a bernoulli() builtin function. This file is
left here for backward compatibility and now simply returns
the builtin function.
bernpoly.cal
bernpoly(n,z)
Computes the nth Bernoulli polynomial at z for arbitrary n,z. See:
http://en.wikipedia.org/wiki/Bernoulli_polynomials
http://mathworld.wolfram.com/BernoulliPolynomial.html
for further information
bigprime.cal
bigprime(a, m, p)
A prime test, base a, on p*2^x+1 for even x>m.
brentsolve.cal
brentsolve(low, high,eps)
A root-finder implementwed with the Brent-Dekker trick.
brentsolve2(low, high,which,eps)
The second function, brentsolve2(low, high,which,eps) has some lines
added to make it easier to hardcode the name of the helper function
different from the obligatory "f".
See:
http://en.wikipedia.org/wiki/Brent%27s_method
http://mathworld.wolfram.com/BrentsMethod.html
to find out more about the Brent-Dekker method.
constants.cal
e()
G()
An implementation of different constants to arbitrary precision.
chi.cal
Z(x[, eps])
P(x[, eps])
chi_prob(chi_sq, v[, eps])
Computes the Probability, given the Null Hypothesis, that a given
Chi squared values >= chi_sq with v degrees of freedom.
The chi_prob() function does not work well with odd degrees of freedom.
It is reasonable with even degrees of freedom, although one must give
a sufficiently small error term as the degrees gets large (>100).
The Z(x) and P(x) are internal statistical functions.
eps is an optional epsilon() like error term.
chrem.cal
chrem(r1,m1 [,r2,m2, ...])
chrem(rlist, mlist)
Chinese remainder theorem/problem solver.
deg.cal
deg(deg, min, sec)
deg_add(a, b)
deg_neg(a)
deg_sub(a, b)
deg_mul(a, b)
deg_print(a)
Calculate in degrees, minutes, and seconds. For a more functional
version see dms.cal.
dms.cal
dms(deg, min, sec)
dms_add(a, b)
dms_neg(a)
dms_sub(a, b)
dms_mul(a, b)
dms_print(a)
dms_abs(a)
dms_norm(a)
dms_test(a)
dms_int(a)
dms_frac(a)
dms_rel(a,b)
dms_cmp(a,b)
dms_inc(a)
dms_dec(a)
Calculate in degrees, minutes, and seconds. Unlike deg.cal, increments
are on the arc second level. See also hms.cal.
dotest.cal
dotest(dotest_file [,dotest_code [,dotest_maxcond]])
dotest_file
Search along CALCPATH for dotest_file, which contains lines that
should evaluate to 1. Comment lines and empty lines are ignored.
Comment lines should use ## instead of the multi like /* ... */
because lines are evaluated one line at a time.
dotest_code
Assign the code number that is to be printed at the start of
each non-error line and after **** in each error line.
The default code number is 999.
dotest_maxcond
The maximum number of error conditions that may be detected.
An error condition is not a sign of a problem, in some cases
a line deliberately forces an error condition. A value of -1,
the default, implies a maximum of 2147483647.
Global variables and functions must be declared ahead of time because
the dotest scope of evaluation is a line at a time. For example:
read dotest.cal
read set8700.cal
dotest("set8700.line");
factorial.cal
factorial(n)
Calculates the product of the positive integers up to and including n.
See:
http://en.wikipedia.org/wiki/Factorial
for information on the factorial. This function depends on the script
toomcook.cal.
primorial(a,b)
Calculates the product of the primes between a and b. If a is not prime
the next higher prime is taken as the starting point. If b is not prime
the next lower prime is taking as the end point b. The end point b must
not exceed 4294967291. See:
http://en.wikipedia.org/wiki/Primorial
for information on the primorial.
factorial2.cal
This file contents a small variety of integer functions that can, with
more or less pressure, be related to the factorial.
doublefactorial(n)
Calculates the double factorial n!! with different algorithms for
- n odd
- n even and positive
- n (real|complex) sans the negative half integers
See:
http://en.wikipedia.org/wiki/Double_factorial
http://mathworld.wolfram.com/DoubleFactorial.html
for information on the double factorial. This function depends on
the script toomcook.cal, factorial.cal and specialfunctions.cal.
binomial(n,k)
Calculates the binomial coefficients for n large and k = k \pm
n/2. Defaults to the built-in function for smaller and/or different
values. Meant as a complete replacement for comb(n,k) with only a
very small overhead. See:
http://en.wikipedia.org/wiki/Binomial_coefficient
for information on the binomial. This function depends on the script
toomcook.cal factorial.cal and specialfunctions.cal.
bigcatalan(n)
Calculates the n-th Catalan number for n large. It is usefull
above n~50,000 but defaults to the builtin function for smaller
values.Meant as a complete replacement for catalan(n) with only a
very small overhead. See:
http://en.wikipedia.org/wiki/Catalan_number
http://mathworld.wolfram.com/CatalanNumber.html
for information on Catalan numbers. This function depends on the scripts
toomcook.cal, factorial.cal and specialfunctions.cal.
stirling1(n,m)
Calculates the Stirling number of the first kind. It does so with
building a list of all of the smaller results. It might be a good
idea, though, to run it once for the highest n,m first if many
Stirling numbers are needed at once, for example in a series. See:
http://en.wikipedia.org/wiki/Stirling_numbers_of_the_first_kind
http://mathworld.wolfram.com/StirlingNumberoftheFirstKind.html
Algorithm 3.17, Donald Kreher and Douglas Simpson, "Combinatorial
Algorithms", CRC Press, 1998, page 89.
for information on Stirling numbers of the first kind.
stirling2(n,m)
stirling2caching(n,m)
Calculate the Stirling number of the second kind.
The first function stirling2(n,m) does it with the sum
m
====
1 \ n m - k
-- > k (- 1) binomial(m, k)
m! /
====
k = 0
The other function stirling2caching(n,m) does it by way of the
reccurence relation and keeps all earlier results. This function
is much slower for computing a single value than stirling2(n,m) but
is very usefull if many Stirling numbers are needed, for example in
a series. See:
http://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind
http://mathworld.wolfram.com/StirlingNumberoftheSecondKind.html
Algorithm 3.17, Donald Kreher and Douglas Simpson, "Combinatorial
Algorithms", CRC Press, 1998, page 89.
for information on Stirling numbers of the second kind.
bell(n)
Calculate the n-th Bell number. This may take some time for large n.
See:
http://oeis.org/A000110
http://en.wikipedia.org/wiki/Bell_number
http://mathworld.wolfram.com/BellNumber.html
for information on Bell numbers.
subfactorial(n)
Calculate the n-th subfactorial or derangement. This may take some
time for large n. See:
http://mathworld.wolfram.com/Derangement.html
http://en.wikipedia.org/wiki/Derangement
for information on subfactorials.
risingfactorial(x,n)
Calculates the rising factorial or Pochammer symbol of almost arbitrary
x,n. See:
http://en.wikipedia.org/wiki/Pochhammer_symbol
http://mathworld.wolfram.com/PochhammerSymbol.html
for information on rising factorials.
fallingfactorial(x,n)
Calculates the rising factorial of almost arbitrary x,n. See:
http://en.wikipedia.org/wiki/Pochhammer_symbol
http://mathworld.wolfram.com/PochhammerSymbol.html
for information on falling factorials.
ellip.cal
efactor(iN, ia, B, force)
Attempt to factor using the elliptic functions: y^2 = x^3 + a*x + b.
gvec.cal
gvec(function, vector)
Vectorize any single-input function or trailing operator.
hello.cal
Calc's contribution to the Hello World! page:
http://www.latech.edu/~acm/HelloWorld.shtml
http://www.latech.edu/~acm/helloworld/calc.html
NOTE: This resource produces a lot of output. :-)
hms.cal
hms(hour, min, sec)
hms_add(a, b)
hms_neg(a)
hms_sub(a, b)
hms_mul(a, b)
hms_print(a)
hms_abs(a)
hms_norm(a)
hms_test(a)
hms_int(a)
hms_frac(a)
hms_rel(a,b)
hms_cmp(a,b)
hms_inc(a)
hms_dec(a)
Calculate in hours, minutes, and seconds. See also dmscal.
infinities.cal
isinfinite(x)
iscinf(x)
ispinf(x)
isninf(x)
cinf()
ninf()
pinf()
The symbolic handling of infinities. Needed for intnum.cal but might be
usefull elsewhere, too.
intfile.cal
file2be(filename)
Read filename and return an integer that is built from the
octets in that file in Big Endian order. The first octets
of the file become the most significant bits of the integer.
file2le(filename)
Read filename and return an integer that is built from the
octets in that file in Little Endian order. The first octets
of the file become the most significant bits of the integer.
be2file(v, filename)
Write the absolute value of v into filename in Big Endian order.
The v argument must be on integer. The most significant bits
of the integer become the first octets of the file.
le2file(v, filename)
Write the absolute value of v into filename in Little Endian order.
The v argument must be on integer. The least significant bits
of the integer become the last octets of the file.
intnum.cal
quadtsdeletenodes()
quadtscomputenodes(order, expo, eps)
quadtscore(a, b, n)
quadts(a, b, points)
quadglcomputenodes(N)
quadgldeletenodes()
quadglcore(a, b, n)
quadgl(a, b, points)
quad(a, b, points = -1, method = "tanhsinh")
makerange(start, end, steps)
makecircle(radius, center, points)
makeellipse(angle, a, b, center, points)
makepoints()
This file offers some methods for numerical integration. Implemented are
the Gauss-Legendre and the tanh-sinh quadrature.
All functions are usefull to some extend but the main function for
quadrature is quad(), which is not much more than an abstraction layer.
The main workers are quadgl() for Gauss-legendre and quadts() for the
tanh-sinh quadrature. The limits of the integral can be anything in the
complex plane and the extended real line. The latter means that infinite
limits are supported by way of the smbolic infinities implemented in the
file infinities.cal (automatically linked in by intnum.cal).
Integration in parts and contour is supported by the "points" argument
which takes either a number or a list. the functions starting with "make"
allow for a less error prone use.
The function to evaluate must have the name "f".
Examples (shamelessly stolen from mpmath):
; define f(x){return sin(x);}
f(x) defined
; quadts(0,pi()) - 2
0.00000000000000000000
; quadgl(0,pi()) - 2
0.00000000000000000000
Sometimes rounding errors accumulate, it might be a good idea to crank up
the working precision a notch or two.
; define f(x){ return exp(-x^2);}
f(x) redefined
; quadts(0,pinf()) - pi()
0.00000000000000000000
; quadgl(0,pinf()) - pi()
0.00000000000000000001
; define f(x){ return exp(-x^2);}
f(x) redefined
; quadgl(ninf(),pinf()) - sqrt(pi())
0.00000000000000000000
; quadts(ninf(),pinf()) - sqrt(pi())
-0.00000000000000000000
Using the "points" parameter is a bit tricky
; define f(x){ return 1/x; }
f(x) redefined
; quadts(1,1,mat[3]={1i,-1,-1i}) - 2i*pi()
0.00000000000000000001i
; quadgl(1,1,mat[3]={1i,-1,-1i}) - 2i*pi()
0.00000000000000000001i
The make* functions make it a bit simpler
; quadts(1,1,makepoints(1i,-1,-1i)) - 2i*pi()
0.00000000000000000001i
; quadgl(1,1,makepoints(1i,-1,-1i)) - 2i*pi()
0.00000000000000000001i
; define f(x){ return abs(sin(x));}
f(x) redefined
; quadts(0,2*pi(),makepoints(pi())) - 4
0.00000000000000000000
; quadgl(0,2*pi(),makepoints(pi())) - 4
0.00000000000000000000
The quad*core functions do not offer anything fancy but the third parameter
controls the so called "order" which is just the number of nodes computed.
This can be quite usefull in some circumstances.
; quadgldeletenodes()
; define f(x){ return exp(x);}
f(x) redefined
; s=usertime();quadglcore(-3,3)- (exp(3)-exp(-3));e=usertime();e-s
0.00000000000000000001
2.632164
; s=usertime();quadglcore(-3,3)- (exp(3)-exp(-3));e=usertime();e-s
0.00000000000000000001
0.016001
; quadgldeletenodes()
; s=usertime();quadglcore(-3,3,14)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000000
0.024001
; s=usertime();quadglcore(-3,3,14)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000000
0
It is not much but can sum up. The tanh-sinh algorithm is not optimizable
as much as the Gauss-Legendre algorithm but is per se much faster.
; s=usertime();quadtscore(-3,3)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000001
0.128008
; s=usertime();quadtscore(-3,3)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000001
0.036002
; s=usertime();quadtscore(-3,3,49)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000000
0.036002
; s=usertime();quadtscore(-3,3,49)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000000
0.01200
lambertw.cal
lambertw(z,branch)
Computes Lambert's W-function at "z" at branch "branch". See
http://en.wikipedia.org/wiki/Lambert_W_function
http://mathworld.wolfram.com/LambertW-Function.html
https://cs.uwaterloo.ca/research/tr/1993/03/W.pdf
http://arxiv.org/abs/1003.1628
to get more information.
This file includes also an implementation for the series described in
Corless et al. (1996) eq. 4.22 (W-pdf) and Verebic (2010) (arxive link)
eqs.35-37.
The series has been implemented to get a different algorithm
for checking the results. This was necessary because the results
of the implementation in Maxima, the only program with a general
lambert-w implementation at hand at that time, differed slightly. The
Maxima versions tested were: Maxima 5.21.1 and 5.29.1. The current
version of this code concurs with the results of Mathematica`s(tm)
ProductLog[branch,z] with the tested values.
The series is only valid for the branches 0,-1, real z, converges
for values of z _very_ near the branchpoint -exp(-1) only, and must
be given the branches explicitly. See the code in lambertw.cal
for further information.
linear.cal
linear(x0, y0, x1, y1, x)
Returns the value y such that (x,y) in on the line (x0,y0), (x1,y1).
Requires x0 != y0.
lnseries.cal
lnseries(limit)
lnfromseries(n)
deletelnseries()
Calculates a series of n natural logarithms at 1,2,3,4...n. It
does so by computing the prime factorization of all of the number
sequence 1,2,3...n, calculates the natural logarithms of the primes
in 1,2,3...n and uses the above factorization to build the natural
logarithms of the rest of the sequence by sadding the logarithms of
the primes in the factorization. This is faster for high precision
of the logarithms and/or long sequences.
The sequence need to be initiated by running either lnseries(n) or
lnfromseries(n) once with n the upper limit of the sequence.
lucas.cal
lucas(h, n)
Perform a primality test of h*2^n-1, with 1<=h<2*n.
lucas_chk.cal
lucas_chk(high_n)
Test all primes of the form h*2^n-1, with 1<=h<200 and n <= high_n.
Requires lucas.cal to be loaded. The highest useful high_n is 1000.
Used by regress.cal during the 2100 test set.
lucas_tbl.cal
Lucasian criteria for primality tables.
mersenne.cal
mersenne(p)
Perform a primality test of 2^p-1, for prime p>1.
mfactor.cal
mfactor(n [, start_k=1 [, rept_loop=10000 [, p_elim=17]]])
Return the lowest factor of 2^n-1, for n > 0. Starts looking for factors
at 2*start_k*n+1. Skips values that are multiples of primes <= p_elim.
By default, start_k == 1, rept_loop = 10000 and p_elim = 17.
The p_elim == 17 overhead takes ~3 minutes on an 200 Mhz r4k CPU and
requires about ~13 Megs of memory. The p_elim == 13 overhead
takes about 3 seconds and requires ~1.5 Megs of memory.
The value p_elim == 17 is best for long factorizations. It is the
fastest even thought the initial startup overhead is larger than
for p_elim == 13.
mod.cal
lmod(a)
mod_print(a)
mod_one()
mod_cmp(a, b)
mod_rel(a, b)
mod_add(a, b)
mod_sub(a, b)
mod_neg(a)
mod_mul(a, b)
mod_square(a)
mod_inc(a)
mod_dec(a)
mod_inv(a)
mod_div(a, b)
mod_pow(a, b)
Routines to handle numbers modulo a specified number.
natnumset.cal
isset(a)
setbound(n)
empty()
full()
isin(a, b)
addmember(a, n)
rmmember(a, n)
set()
mkset(s)
primes(a, b)
set_max(a)
set_min(a)
set_not(a)
set_cmp(a, b)
set_rel(a, b)
set_or(a, b)
set_and(a, b)
set_comp(a)
set_setminus(a, b)
set_diff(a,b)
set_content(a)
set_add(a, b)
set_sub(a, b)
set_mul(a, b)
set_square(a)
set_pow(a, n)
set_sum(a)
set_plus(a)
interval(a, b)
isinterval(a)
set_mod(a, b)
randset(n, a, b)
polyvals(L, A)
polyvals2(L, A, B)
set_print(a)
Demonstration of how the string operators and functions may be used
for defining and working with sets of natural numbers not exceeding a
user-specified bound.
pell.cal
pellx(D)
pell(D)
Solve Pell's equation; Returns the solution X to: X^2 - D * Y^2 = 1.
Type the solution to Pell's equation for a particular D.
pi.cal
qpi(epsilon)
piforever()
The qpi() calculate pi within the specified epsilon using the quartic
convergence iteration.
The piforever() prints digits of pi, nicely formatted, for as long
as your free memory space and system up time allows.
The piforever() function (written by Klaus Alexander Seistrup
<klaus@seistrup.dk>) was inspired by an algorithm conceived by
Lambert Meertens. See also the ABC Programmer's Handbook, by Geurts,
Meertens & Pemberton, published by Prentice-Hall (UK) Ltd., 1990.
pix.cal
pi_of_x(x)
Calculate the number of primes < x using A(n+1)=A(n-1)+A(n-2). This
is a SLOW painful method ... the builtin pix(x) is much faster.
Still, this method is interesting.
pollard.cal
pfactor(N, N, ai, af)
Factor using Pollard's p-1 method.
poly.cal
Calculate with polynomials of one variable. There are many functions.
Read the documentation in the resource file.
prompt.cal
adder()
showvalues(str)
Demonstration of some uses of prompt() and eval().
psqrt.cal
psqrt(u, p)
Calculate square roots modulo a prime
qtime.cal
qtime(utc_hr_offset)
Print the time as English sentence given the hours offset from UTC.
quat.cal
quat(a, b, c, d)
quat_print(a)
quat_norm(a)
quat_abs(a, e)
quat_conj(a)
quat_add(a, b)
quat_sub(a, b)
quat_inc(a)
quat_dec(a)
quat_neg(a)
quat_mul(a, b)
quat_div(a, b)
quat_inv(a)
quat_scale(a, b)
quat_shift(a, b)
Calculate using quaternions of the form: a + bi + cj + dk. In these
functions, quaternions are manipulated in the form: s + v, where
s is a scalar and v is a vector of size 3.
randbitrun.cal
randbitrun([run_cnt])
Using randbit(1) to generate a sequence of random bits, determine if
the number and length of identical bits runs match what is expected.
By default, run_cnt is to test the next 65536 random values.
This tests the a55 generator.
randmprime.cal
randmprime(bits, seed [,dbg])
Find a prime of the form h*2^n-1 >= 2^bits for some given x. The
initial search points for 'h' and 'n' are selected by a cryptographic
pseudo-random number generator. The optional argument, dbg, if set
to 1, 2 or 3 turn on various debugging print statements.
randombitrun.cal
randombitrun([run_cnt])
Using randombit(1) to generate a sequence of random bits, determine if
the number and length of identical bits runs match what is expected.
By default, run_cnt is to test the next 65536 random values.
This tests the Blum-Blum-Shub generator.
randomrun.cal
randomrun([run_cnt])
Perform the "G. Run test" (pp. 65-68) as found in Knuth's "Art of
Computer Programming - 2nd edition", Volume 2, Section 3.3.2 on
the builtin rand() function. This function will generate run_cnt
64 bit values. By default, run_cnt is to test the next 65536
random values.
This tests the Blum-Blum-Shub generator.
randrun.cal
randrun([run_cnt])
Perform the "G. Run test" (pp. 65-68) as found in Knuth's "Art of
Computer Programming - 2nd edition", Volume 2, Section 3.3.2 on
the builtin rand() function. This function will generate run_cnt
64 bit values. By default, run_cnt is to test the next 65536
random values.
This tests the a55 generator.
repeat.cal
repeat(digit_set, repeat_count)
Return the value of the digit_set repeated repeat_count times.
Both digit_set and repeat_count must be integers > 0.
For example repeat(423,5) returns the value 423423423423423,
which is the digit_set 423 repeated 5 times.
regress.cal
Test the correct execution of the calculator by reading this resource
file. Errors are reported with '****' messages, or worse. :-)
screen.cal
up
CUU /* same as up */
down = CUD
CUD /* same as down */
forward
CUF /* same as forward */
back = CUB
CUB /* same as back */
save
SCP /* same as save */
restore
RCP /* same as restore */
cls
home
eraseline
off
bold
faint
italic
blink
rapidblink
reverse
concealed
/* Lowercase indicates foreground, uppercase background */
black
red
green
yellow
blue
magenta
cyan
white
Black
Red
Green
Yellow
Blue
Magenta
Cyan
White
Define ANSI control sequences providing (i.e., cursor movement,
changing foreground or background color, etc.) for VT100 terminals
and terminal window emulators (i.e., xterm, Apple OS/X Terminal,
etc.) that support them.
For example:
read screen
print green:"This is green. ":red:"This is red.":black
seedrandom.cal
seedrandom(seed1, seed2, bitsize [,trials])
Given:
seed1 - a large random value (at least 10^20 and perhaps < 10^93)
seed2 - a large random value (at least 10^20 and perhaps < 10^93)
size - min Blum modulus as a power of 2 (at least 100, perhaps > 1024)
trials - number of ptest() trials (default 25) (optional arg)
Returns:
the previous random state
Seed the cryptographically strong Blum generator. This functions allows
one to use the raw srandom() without the burden of finding appropriate
Blum primes for the modulus.
set8700.cal
set8700_getA1() defined
set8700_getA2() defined
set8700_getvar() defined
set8700_f(set8700_x) defined
set8700_g(set8700_x) defined
Declare globals and define functions needed by dotest() (see
dotest.cal) to evaluate set8700.line a line at a time.
set8700.line
A line-by-line evaluation file for dotest() (see dotest.cal).
The set8700.cal file (and dotest.cal) should be read first.
smallfactors.cal
smallfactors(x0)
printsmallfactors(flist)
Lists the prime factors of numbers smaller than 2^32. Try for example:
printsmallfactors(smallfactors(10!)).
solve.cal
solve(low, high, epsilon)
Solve the equation f(x) = 0 to within the desired error value for x.
The function 'f' must be defined outside of this routine, and the
low and high values are guesses which must produce values with
opposite signs.
specialfunctions.cal
beta(a,b)
Calculates the value of the beta function. See:
https://en.wikipedia.org/wiki/Beta_function
http://mathworld.wolfram.com/BetaFunction.html
http://dlmf.nist.gov/5.12
for information on the beta function.
betainc(a,b,z)
Calculates the value of the regularized incomplete beta function. See:
https://en.wikipedia.org/wiki/Beta_function
http://mathworld.wolfram.com/RegularizedBetaFunction.html
http://dlmf.nist.gov/8.17
for information on the regularized incomplete beta function.
expoint(z)
Calculates the value of the exponential integral Ei(z) function at z.
See:
http://en.wikipedia.org/wiki/Exponential_integral
http://www.cs.utah.edu/~vpegorar/research/2011_JGT/
for information on the exponential integral Ei(z) function.
erf(z)
Calculates the value of the error function at z. See:
http://en.wikipedia.org/wiki/Error_function
for information on the error function function.
erfc(z)
Calculates the value of the complementary error function at z. See:
http://en.wikipedia.org/wiki/Error_function
for information on the complementary error function function.
erfi(z)
Calculates the value of the imaginary error function at z. See:
http://en.wikipedia.org/wiki/Error_function
for information on the imaginary error function function.
erfinv(x)
Calculates the inverse of the error function at x. See:
http://en.wikipedia.org/wiki/Error_function
for information on the inverse of the error function function.
faddeeva(z)
Calculates the value of the complex error function at z. See:
http://en.wikipedia.org/wiki/Faddeeva_function
for information on the complex error function function.
gamma(z)
Calculates the value of the Euler gamma function at z. See:
http://en.wikipedia.org/wiki/Gamma_function
http://dlmf.nist.gov/5
for information on the Euler gamma function.
gammainc(a,z)
Calculates the value of the lower incomplete gamma function for
arbitrary a, z. See:
http://en.wikipedia.org/wiki/Incomplete_gamma_function
for information on the lower incomplete gamma function.
gammap(a,z)
Calculates the value of the regularized lower incomplete gamma
function for a, z with a not in -N. See:
http://en.wikipedia.org/wiki/Incomplete_gamma_function
for information on the regularized lower incomplete gamma function.
gammaq(a,z)
Calculates the value of the regularized upper incomplete gamma
function for a, z with a not in -N. See:
http://en.wikipedia.org/wiki/Incomplete_gamma_function
for information on the regularized upper incomplete gamma function.
heavisidestep(x)
Computes the Heaviside stepp function (1+sign(x))/2
harmonic(limit)
Calculates partial values of the harmonic series up to limit. See:
http://en.wikipedia.org/wiki/Harmonic_series_(mathematics)
http://mathworld.wolfram.com/HarmonicSeries.html
for information on the harmonic series.
lnbeta(a,b)
Calculates the natural logarithm of the beta function. See:
https://en.wikipedia.org/wiki/Beta_function
http://mathworld.wolfram.com/BetaFunction.html
http://dlmf.nist.gov/5.12
for information on the beta function.
lngamma(z)
Calculates the value of the logarithm of the Euler gamma function
at z. See:
http://en.wikipedia.org/wiki/Gamma_function
http://dlmf.nist.gov/5.15
for information on the derivatives of the the Euler gamma function.
polygamma(m,z)
Calculates the value of the m-th derivative of the Euler gamma
function at z. See:
http://en.wikipedia.org/wiki/Polygamma
http://dlmf.nist.gov/5
for information on the n-th derivative ofthe Euler gamma function. This
function depends on the script zeta2.cal.
psi(z)
Calculates the value of the first derivative of the Euler gamma
function at z. See:
http://en.wikipedia.org/wiki/Digamma_function
http://dlmf.nist.gov/5
for information on the first derivative of the Euler gamma function.
zeta(s)
Calculates the value of the Rieman Zeta function at s. See:
http://en.wikipedia.org/wiki/Riemann_zeta_function
http://dlmf.nist.gov/25.2
for information on the Riemann zeta function. This function depends
on the script zeta2.cal.
statistics.cal
gammaincoctave(z,a)
Computes the regularized incomplete gamma function in a way to
correspond with the function in Octave.
invbetainc(x,a,b)
Computes the inverse of the regularized beta function. Does so the
brute-force way wich makes it a bit slower.
betapdf(x,a,b)
betacdf(x,a,b)
betacdfinv(x,a,b)
betamedian(a,b)
betamode(a,b)
betavariance(a,b)
betalnvariance(a,b)
betaskewness(a,b)
betakurtosis(a,b)
betaentropy(a,b)
normalpdf(x,mu,sigma)
normalcdf(x,mu,sigma)
probit(p)
normalcdfinv(p,mu,sigma)
normalmean(mu,sigma)
normalmedian(mu,sigma)
normalmode(mu,sigma)
normalvariance(mu,sigma)
normalskewness(mu,sigma)
normalkurtosis(mu,sigma)
normalentropy(mu,sigma)
normalmgf(mu,sigma,t)
normalcf(mu,sigma,t)
chisquaredpdf(x,k)
chisquaredpcdf(x,k)
chisquaredmean(x,k)
chisquaredmedian(x,k)
chisquaredmode(x,k)
chisquaredvariance(x,k)
chisquaredskewness(x,k)
chisquaredkurtosis(x,k)
chisquaredentropy(x,k)
chisquaredmfg(k,t)
chisquaredcf(k,t)
Calculates a bunch of (hopefully) aptly named statistical functions.
strings.cal
isascii(c)
isblank(c)
Implements some of the functions of libc's ctype.h and strings.h.
NOTE: A number of the ctype.h and strings.h functions are now builtin
functions in calc.
WARNING: If the remaining functions in this calc resource file become
calc builtin functions, then strings.cal may be removed in
a future release.
sumsq.cal
ss(p)
Determine the unique two positive integers whose squares sum to the
specified prime. This is always possible for all primes of the form
4N+1, and always impossible for primes of the form 4N-1.
sumtimes.cal
timematsum(N)
timelistsum(N)
timematsort(N)
timelistsort(N)
timematreverse(N)
timelistreverse(N)
timematssq(N)
timelistssq(N)
timehmean(N,M)
doalltimes(N)
Give the user CPU time for various ways of evaluating sums, sums of
squares, etc, for large lists and matrices. N is the size of
the list or matrix to use. The doalltimes() function will run
all fo the sumtimes tests. For example:
doalltimes(1e6);
surd.cal
surd(a, b)
surd_print(a)
surd_conj(a)
surd_norm(a)
surd_value(a, xepsilon)
surd_add(a, b)
surd_sub(a, b)
surd_inc(a)
surd_dec(a)
surd_neg(a)
surd_mul(a, b)
surd_square(a)
surd_scale(a, b)
surd_shift(a, b)
surd_div(a, b)
surd_inv(a)
surd_sgn(a)
surd_cmp(a, b)
surd_rel(a, b)
Calculate using quadratic surds of the form: a + b * sqrt(D).
test1700.cal
value
This resource files is used by regress.cal to test the read and
use keywords.
test2600.cal
global defaultverbose
global err
testismult(str, n, verbose)
testsqrt(str, n, eps, verbose)
testexp(str, n, eps, verbose)
testln(str, n, eps, verbose)
testpower(str, n, b, eps, verbose)
testgcd(str, n, verbose)
cpow(x, n, eps)
cexp(x, eps)
cln(x, eps)
mkreal()
mkcomplex()
mkbigreal()
mksmallreal()
testappr(str, n, verbose)
checkappr(x, y, z, verbose)
checkresult(x, y, z, a)
test2600(verbose, tnum)
This resource files is used by regress.cal to test some of builtin
functions in terms of accuracy and roundoff.
test2700.cal
global defaultverbose
mknonnegreal()
mkposreal()
mkreal_2700()
mknonzeroreal()
mkposfrac()
mkfrac()
mksquarereal()
mknonsquarereal()
mkcomplex_2700()
testcsqrt(str, n, verbose)
checksqrt(x, y, z, v)
checkavrem(A, B, X, eps)
checkrounding(s, n, t, u, z)
iscomsq(x)
test2700(verbose, tnum)
This resource files is used by regress.cal to test sqrt() for real and
complex values.
test3100.cal
obj res
global md
res_test(a)
res_sub(a, b)
res_mul(a, b)
res_neg(a)
res_inv(a)
res(x)
This resource file is used by regress.cal to test determinants of
a matrix.
test3300.cal
global defaultverbose
global err
testi(str, n, N, verbose)
testr(str, n, N, verbose)
test3300(verbose, tnum)
This resource file is used by regress.cal to provide for more
determinant tests.
test3400.cal
global defaultverbose
global err
test1(str, n, eps, verbose)
test2(str, n, eps, verbose)
test3(str, n, eps, verbose)
test4(str, n, eps, verbose)
test5(str, n, eps, verbose)
test6(str, n, eps, verbose)
test3400(verbose, tnum)
This resource file is used by regress.cal to test trig functions.
containing objects.
test3500.cal
global defaultverbose
global err
testfrem(x, y, verbose)
testgcdrem(x, y, verbose)
testf(str, n, verbose)
testg(str, n, verbose)
testh(str, n, N, verbose)
test3500(verbose, n, N)
This resource file is used by regress.cal to test the functions frem,
fcnt, gcdrem.
test4000.cal
global defaultverbose
global err
global BASEB
global BASE
global COUNT
global SKIP
global RESIDUE
global MODULUS
global K1
global H1
global K2
global H2
global K3
global H3
plen(N) defined
rlen(N) defined
clen(N) defined
ptimes(str, N, n, count, skip, verbose) defined
ctimes(str, N, n, count, skip, verbose) defined
crtimes(str, a, b, n, count, skip, verbose) defined
ntimes(str, N, n, count, skip, residue, mod, verbose) defined
testnextcand(str, N, n, cnt, skip, res, mod, verbose) defined
testnext1(x, y, count, skip, residue, modulus) defined
testprevcand(str, N, n, cnt, skip, res, mod, verbose) defined
testprev1(x, y, count, skip, residue, modulus) defined
test4000(verbose, tnum) defined
This resource file is used by regress.cal to test ptest, nextcand and
prevcand builtins.
test4100.cal
global defaultverbose
global err
global K1
global K2
global BASEB
global BASE
rlen_4100(N) defined
olen(N) defined
test1(x, y, m, k, z1, z2) defined
testall(str, n, N, M, verbose) defined
times(str, N, n, verbose) defined
powtimes(str, N1, N2, n, verbose) defined
inittimes(str, N, n, verbose) defined
test4100(verbose, tnum) defined
This resource file is used by regress.cal to test REDC operations.
test4600.cal
stest(str [, verbose]) defined
ttest([m, [n [,verbose]]]) defined
sprint(x) defined
findline(f,s) defined
findlineold(f,s) defined
test4600(verbose, tnum) defined
This resource file is used by regress.cal to test searching in files.
test5100.cal
global a5100
global b5100
test5100(x) defined
This resource file is used by regress.cal to test the new code generator
declaration scope and order.
test5200.cal
global a5200
static a5200
f5200(x) defined
g5200(x) defined
h5200(x) defined
This resource file is used by regress.cal to test the fix of a
global/static bug.
test8400.cal
test8400() defined
This resource file is used by regress.cal to check for quit-based
memory leaks.
test8500.cal
global err_8500
global L_8500
global ver_8500
global old_seed_8500
global cfg_8500
onetest_8500(a,b,rnd) defined
divmod_8500(N, M1, M2, testnum) defined
This resource file is used by regress.cal to the // and % operators.
test8600.cal
global min_8600
global max_8600
global hash_8600
global hmean_8600
This resource file is used by regress.cal to test a change of
allowing up to 1024 args to be passed to a builtin function.
test8900.cal
This function tests a number of calc resource functions contributed
by Christoph Zurnieden. These include:
bernpoly.cal
brentsolve.cal
constants.cal
factorial2.cal
factorial.cal
lambertw.cal
lnseries.cal
specialfunctions.cal
statistics.cal
toomcook.cal
zeta2.cal
unitfrac.cal
unitfrac(x)
Represent a fraction as sum of distinct unit fractions.
toomcook.cal
toomcook3(a,b)
toomcook4(a,b)
Toom-Cook multiplication algorithm. Multiply two integers a,b by
way of the Toom-Cook algorithm. See:
http://en.wikipedia.org/wiki/Toom%E2%80%93Cook_multiplication
toomcook3square(a)
toomcook4square(a)
Square the integer a by way of the Toom-Cook algorithm. See:
http://en.wikipedia.org/wiki/Toom%E2%80%93Cook_multiplication
The function toomCook4(a,b) calls the function toomCook3(a,b) which
calls built-in multiplication at a specific cut-off point. The
squaring functions act in the same way.
varargs.cal
sc(a, b, ...)
Example program to use 'varargs'. Program to sum the cubes of all
the specified numbers.
xx_print.cal
is_octet(a) defined
list_print(a) defined
mat_print (a) defined
octet_print(a) defined
blk_print(a) defined
nblk_print (a) defined
strchar(a) defined
file_print(a) defined
error_print(a) defined
Demo for the xx_print object routines.
zeta2.cal
hurwitzzeta(s,a)
Calculate the value of the Hurwitz Zeta function. See:
http://en.wikipedia.org/wiki/Hurwitz_zeta_function
http://dlmf.nist.gov/25.11
for information on this special zeta function.
## Copyright (C) 2000,2014 David I. Bell and Landon Curt Noll
##
## Primary author: Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.9 $
## @(#) $Id: README,v 30.9 2014/10/06 08:44:18 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/cal/RCS/README,v $
##
## Under source code control: 1990/02/15 01:50:32
## File existed as early as: before 1990
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* types
*************
Builtin types
The calculator has the following built-in types.
null value
This is the undefined value type. The function 'null'
returns this value. Functions which do not explicitly
return a value return this type. If a function is called
with fewer parameters than it is defined for, then the
missing parameters have the null type. The null value is
false if used in an IF test.
rational numbers
This is the basic data type of the calculator.
These are fractions whose numerators and denominators
can be arbitrarily large. The fractions are always
in lowest terms. Integers have a denominator of 1.
The numerator of the number contains the sign, so that
the denominator is always positive. When a number is
entered in floating point or exponential notation, it is
immediately converted to the appropriate fractional value.
Printing a value as a floating point or exponential value
involves a conversion from the fractional representation.
Numbers are stored in binary format, so that in general,
bit tests and shifts are quicker than multiplies and divides.
Similarly, entering or displaying of numbers in binary,
octal, or hex formats is quicker than in decimal. The
sign of a number does not affect the bit representation
of a number.
complex numbers
Complex numbers are composed of real and imaginary parts,
which are both fractions as defined above. An integer which
is followed by an 'i' character is a pure imaginary number.
Complex numbers such as "2+3i" when typed in, are processed
as the sum of a real and pure imaginary number, resulting
in the desired complex number. Therefore, parenthesis are
sometimes necessary to avoid confusion, as in the two values:
1+2i ^2 (which is -3)
(1+2i) ^2 (which is -3+4i)
Similar care is required when entering fractional complex
numbers. Note the differences below:
3/4i (which is -(3/4)i)
3i/4 (which is (3/4)i)
The imaginary unit itself is input using "1i".
strings
Strings are a sequence of zero or more characters.
They are input using either of the single or double
quote characters. The quote mark which starts the
string also ends it. Various special characters can
also be inserted using back-slash. Example strings:
"hello\n"
"that's all"
'lots of """"'
'a'
""
There is no distinction between single character and
multi-character strings. The 'str' and 'ord' functions
will convert between a single character string and its
numeric value. The 'str' and 'eval' functions will
convert between longer strings and the corresponding
numeric value (if legal). The 'strcat', 'strlen', and
'substr' functions are also useful.
matrices
These are one to four dimensional matrices, whose minimum
and maximum bounds can be specified at runtime. Unlike C,
the minimum bounds of a matrix do not have to start at 0.
The elements of a matrix can be of any type. There are
several built-in functions for matrices. Matrices are
created using the 'mat' statement.
associations
These are one to four dimensional matrices which can be
indexed by arbitrary values, instead of just integers.
These are also known as associative arrays. The elements of
an association can be of any type. Very few operations are
permitted on an association except for indexing. Associations
are created using the 'assoc' function.
lists
These are a sequence of values, which are linked together
so that elements can be easily be inserted or removed
anywhere in the list. The values can be of any type.
Lists are created using the 'list' function.
files
These are text files opened using stdio. Files may be opened
for sequential reading, writing, or appending. Opening a
file using the 'fopen' function returns a value which can
then be used to perform I/O to that file. File values can
be copied by normal assignments between variables, or by
using the result of the 'files' function. Such copies are
indistinguishable from each other.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: types,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/types,v $
##
## Under source code control: 1991/07/21 04:37:24
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* script
*************
Calc shell scripts
------------------
There are several ways calc may be used in shell scripts. The
syntax for these varies widely for different shells and systems,
but common to most are commands like echo, if, for, goto, shift,
and exit, as well as the accessing of environment parameters, shell
variables, and command-line arguments.
As a simple example, assuming a C or Bourne shell, let add be a
file containing just one line:
calc -q -- $1 + $2
Then:
./add 1.23 4.56
should respond with the display of:
5.9
The "-q" was included in the command to avoid reading of any
start-up calc files which could contain commands not wanted
here. The "--" indicates that there are no more options;
without it, if $1 began with '-', calc would interpret it as
the first character of another option. To execute the file,
the strings "1.23" and "4.56" were assigned to $1 and $2, so
calc was in effect asked to evaluate the string "1.23 + 4.56".
By making add executable by a command like:
chmod u+x add
the command used here may be simplified to:
./add 1.23 4.56
Here we shall assume that any script we refer to has been made
executable in this way.
Because $1 and $2, and instructions in the script, are to read
by calc as expressions or commands, they may be much more
complicated than in the above example, but if they involve
characters with special interpretations by the shell (spaces
for word separation, * or ? or [ ...] for file-name expansion,
! (without immediately following space) for history expansion,
( ... ) for shell-function arguments, { ... } for brace
expansion, $ for parameter or variable expansion, <, <<, >, >>
for redirection of input or output, etc.) it will usually be
necessary to quote or escape tho characters, or usually more
conveniently, quote whole expressions with single or double
quotes.
For example, the add script should have no problem with
commands like:
./add "sqrt(2)" "3 * 4"
./add "mat A[2,2] = {1,2,3,4}" "A^2"
./add "2 + 3i" "(3 + 4i)^2"
If the shell arguments are to be integers, one could use
scripts like the following with arithmetic expansion
for the bash and ksh:
declare -i a=$1
declare -i b=$2
calc -q -- $a + $b
and for csh:
@ a = $1
@ b = $2
calc -q -- $a + $b
Specifying the shell for a script may be done by including
in the script a first line with the "magic number" "#!" and
the full file path for the shell as in:
#!/bin/bash
declare -i a=$1
declare -i b=$2
calc -q -- $a + $b
For a script to multiply rather than add two expressions, one
could have a file mul with the one line:
calc -q -- $1 \* $2
or:
calc -q -- "$1 * $2"
which will work so long as $1 and $2 are literal numbers, but
will not work for:
./mul 2+3 4
or:
./mul "2 + 3" 4
both of which calc interprets as evaluating 2 + 3 * 4. What should
work for most shells is:
calc -q -- "($1) * ($2)"
For adding an arbitrary number of expressions that evaluate to
rational numbers expressible with at most 20 decimal places,
simple shell script could be used:
s=0
for i do
s=`calc -q -- $s + $i`
done
echo sum = $s
This is not particularly efficient since it calls calc once for
each argument. Also, a more serious script would permit more
general numbers.
Another way of handling a sum of several expressions is with
the script addall2 with a here document:
calc "-q -s" $* << +
global i, n, s;
n = argv();
for (i = 0; i < n; i++)
s += eval(argv(i));
print "sum =", s;
+
In executing the command:
./addall2 2 3 4
the $* in ths script expands to 2 3 4, and because of the "-s"
in the options, calc starts with argv(0) = "2", argv(1) = "3",
argv(2)= "4". As there is only one calc process involved and
the eval() function accepts as argument any string that
represents the body of a calc function, the strings argv(0),
argv(1), ... could evaluate to any value types for which the
additions to be performed are defined, and variables defined in
one argv() can be used in later arguments.
For systems that support interpreter files, essentially the
same thing may be done more efficiently by using calc as an
interpreter. Assuming the full path for calc is
/usr/local/bin/calc, one could use the file addall3 with contents
#!/usr/bin/calc -q -s -f
global i, n, s;
n = argv();
for (i = 1; i < n; i++)
s += eval(argv(i));
print "sum =", s;
IMPORTANT NOTE:
The -f flag must be at the very end of the #! line.
The #! line must be the first line of the exeuctable file.
The path after the #! must be the full path to the calc executable.
After the command:
addall3 2 3 4
the arguments calc receives are argv(0) = "addall3", argv(1) =
"2", argv(3) = "3", argv(4) = "4".
Another kind of script that can be useful is sqrts1:
calc -q 'global s; while (scanf("%s", s) == 1) print sqrt(eval(s));'
or what is essentially an interpreter equivalent sqrts2:
#!/usr/local/bin/calc -q -f
global s;
while (scanf('%s', s) == 1)
print sqrt(eval(s));
If sqrts is either of these scripts, the command:
echo 27 2+3i | sqrts
or, if datafile contains the one line:
27 2+3i
or the two lines:
27
2+3i
either:
cat datafile | ./sqrts
or:
./sqrts < datafile
should display the square-roots of 27 and 2+3i. The output could
be piped to another command by | or directed to a file by use of
; or >>.
With no specified input, either sqrts1 or sqrts2 will wait
without any prompt for input from the keyboard and as each line
is completed display the square-roots of the expressions
entered. Exit can be achieved by entering exit or entering
ctrl-D (interpreted as EOF) rather than a line of input.
One advantage of an interpreter file like sqrts2 (which has only
options, but neither "-s" nor "--" in its first line) is that it
can be invoked with further options as in
echo 2 3 4 | ./sqrts2 -i -D 32
An advantage of non-interpreter files is that they can use shell
features. For example, for unquoted arguments or arguments in
double quotes parameter expansion (indicated by unquoted '$') and
command substitution (using backquotes) occur before lines are
compiled by calc. For example, if doit is an executable
script with contents
calc -q -- "$1($2)"
it may be used as in:
./doit sqrt 7
and:
./doit exp 7
to display the values of sqrt(7) and exp(7). The "--" prevents a
leading '-' in the $1 argument as indicating one or more additional
options. E.g., without the "--" in doit,
./doit -sqrt 7
would be interpreted as:
calc -q "-sqrt(7)"
in which the dash in the quoted part would be taken as indicating a
list of options -s, -q, -r, etc.; this would give an "illegal option"
error as calc has no -r option.
In invoking the doit script it is not necessary that $1 expand to a
calc function name and $2 to an expression; all that is required is
that:
$1($2)
expands to a string that calc will recognize as a command. E.g.:
./doit "define f(x) = x^2; 2 + mod" "f(7), 6"
does the same as:
calc -q -- "define f(x) = x^2; 2 + mod(f(7), 6)"
Essentially the same is achieved by the contents of doit is changed to:
calc -q -p -- << +
$1($2)
+
The "-p" stops calc going interactive; without it the effect would be
be the same as that of a script with the one line:
calc -q -i -- "$1($2)"
For more information use the following calc commands:
help usage
help argv
help config
help cscript
## Copyright (C) 2000,2014 Landon Curt Noll and Ernest Bowen
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.2 $
## @(#) $Id: script,v 30.2 2014/08/24 22:38:56 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/script,v $
##
## Under source code control: 1999/11/30 05:29:48
## File existed as early as: 1999
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* usage
*************
calc(1) General Commands Manual calc(1)
NAME
calc - arbitrary precision calculator
SYNOPSIS
calc [-c] [-C] [-d]
[-D calc_debug[:resource_debug[:user_debug]]]
[-e] [-h] [-i] [-m mode] [-O]
[-p] [-q] [-s] [-u] [-v] [[--] calc_cmd ...]
#!/usr/bin/calc [other_flags ...] -f
DESCRIPTION
CALC OPTIONS
-c Continue reading command lines even after a scan/parse error has
caused the abandonment of a line. Note that this option only
deals with scanning and parsing of the calc language. It does
not deal with execution or run-time errors.
For example:
calc read many_errors.cal
will cause calc to abort on the first syntax error, whereas:
calc -c read many_errors.cal
will cause calc to try to process each line being read despite
the scan/parse errors that it encounters.
By default, calc startup resource files are silently ignored if
not found. This flag will report missing startup resource files
unless -d is also given.
-C Permit the execution of custom builtin functions. Without this
flag, calling the custom() builtin function will simply generate
an error.
Use of this flag may cause calc to execute functions that are
non-standard and that are not portable. Custom builtin func-
tions are disabled by default for this reason.
-d Disable the printing of the opening title. The printing of
resource file debug and informational messages is also disabled
as if config("resource_debug", 0) had been executed.
For example:
calc "read qtime; qtime(2)"
will output something like:
qtime(utc_hr_offset) defined
It's nearly ten past six.
whereas:
calc -d "read qtime; qtime(2)"
will just say:
It's nearly ten past six.
This flag disables the reporting of missing calc startup
resource files.
-D calc_debug[:resource_debug[:user_debug]]
Force the initial value of config("calc_debug"), con-
fig("resource_debug") and config("user_debug").
The : separated strings are interpreted as signed 32 bit inte-
gers. After an optional leading sign a leading zero indicates
octal conversion, and a leading ``0x'' or ``0X'' hexadecimal
conversion. Otherwise, decimal conversion is assumed.
By default, calc_debug is 0, resource_debug is 3 and user_debug
is 0.
For more information use the following calc command:
help config
-e Ignore any environment variables on startup. The getenv()
builtin will still return values, however.
-f This flag is required when using calc in shell script mode. It
must be at the end of the initial #! line of the script.
This flag is normally only at the end of a calc shell script.
If the first line of an executable file begins #! followed by
the absolute pathname of the calc program and the flag -f as in:
#!/usr/bin/calc [other_flags ...] -f
the rest of the file will be processed in shell script mode.
See SHELL SCRIPT MODE section of this man page below for
details.
The actual form of this flag is:
-f filename
On systems that treat an executable that begins with #! as a
script, the path of the executable is appended by the kernel as
the final argument to the exec() system call. This is why the
-f flag at the very end of the #! line.
It is possible use -f filename on the command line:
calc [other_flags ...] -f filename
This will cause calc to process lines in filename in shell
script mode.
Use of -f implies -s. In addition, -d and -p are implied if -i
is not given.
-h Print a help message. This option implies -q. This is equiva-
lent to the calc command help help. The help facility is dis-
abled unless the mode is 5 or 7. See -m.
-i Become interactive if possible. This flag will cause calc to
drop into interactive mode after the calc_cmd arguments on the
command line are evaluated. Without this flag, calc will exit
after they are evaluated.
For example:
calc 2+5
will print the value 7 and exit whereas:
calc -i 2+5
will print the value 7 and prompt the user for more calc com-
mands.
-m mode
This flag sets the permission mode of calc. It controls the
ability for calc to open files and execute programs. Mode may
be a number from 0 to 7.
The mode value is interpreted in a way similar to that of the
chmod(1) octal mode:
0 do not open any file, do not execute progs
1 do not open any file
2 do not open files for reading, do not execute progs
3 do not open files for reading
4 do not open files for writing, do not execute progs
5 do not open files for writing
6 do not execute any program
7 allow everything (default mode)
If one wished to run calc from a privileged user, one might want
to use -m 0 in an effort to make calc somewhat more secure.
Mode bits for reading and writing apply only on an open. Files
already open are not effected. Thus if one wanted to use the -m
0 in an effort to make calc somewhat more secure, but still
wanted to read and write a specific file, one might want to do
in sh(1), ksh(1), bash(1)-like shells:
calc -m 0 3<a.file
Files presented to calc in this way are opened in an unknown
mode. Calc will attempt to read or write them if directed.
If the mode disables opening of files for reading, then the
startup resource files are disabled as if -q was given. The
reading of key bindings is also disabled when the mode disables
opening of files for reading.
-O Use the old classic defaults instead of the default configura-
tion. This flag as the same effect as executing config("all",
"oldcfg") at startup time.
NOTE: Older versions of calc used -n to setup a modified form of
the default calc configuration. The -n flag currently does
nothing. Use of the -n flag is now deprecated and may be used
for something else in the future.
-p Pipe processing is enabled by use of -p. For example:
calc -p "2^21701-1" | fizzbin
In pipe mode, calc does not prompt, does not print leading tabs
and does not print the initial header. The -p flag overrides
-i.
-q Disable the reading of the startup scripts.
-s By default, all calc_cmd args are evaluated and executed. This
flag will disable their evaluation and instead make them avail-
able as strings for the argv() builtin function.
-u Disable buffering of stdin and stdout.
-v Print the calc version number and exit.
-- The double dash indicates to calc that no more options follow.
Thus calc will ignore a later argument on the command line even
if it starts with a dash. This is useful when entering negative
values on the command line as in:
calc -p -- -1 - -7
CALC COMMAND LINE
With no calc_cmd arguments, calc operates interactively. If one or
more arguments are given on the command line and -s is NOT given, then
calc will read and execute them and either attempt to go interactive
according as the -i flag was present or absent.
If -s is given, calc will not evaluate any calc_cmd arguments but
instead make them available as strings to the argv() builtin function.
Sufficiently simple commands with no characters like parentheses,
brackets, semicolons, '*', which have special interpretations in UNIX
shells may be entered, possibly with spaces, until the terminating new-
line. For example:
calc 23 + 47
will print 70. However, command lines will have problems:
calc 23 * 47
calc -23 + 47
The first example above fails because the shell interprets the '*' as a
file glob. The second example fails because '-23' is viewed as a calc
option (which it is not) and do calc objects to that it thinks of as an
unknown option. These cases can usually be made to work as expected by
enclosing the command between quotes:
calc '23 * 47'
calc "print sqrt(2), exp(1)"
or in parentheses and quotes to avoid leading -'s as in:
calc '(-23 + 47)'
One may also use a double dash to denote that calc options have ended
as in:
calc -- -23 + 47
calc -q -- -23 + 47
If '!' is to be used to indicate the factorial function, for shells
like csh(1) for which '!' followed by a non-space character is used for
history substitution, it may be necessary to include a space or use a
backslash to escape the special meaning of '!'. For example, the com-
mand:
print 27!^2
may have to be replaced by:
print 27! ^2 or print 27^2
CALC STARTUP FILES
Normally on startup, if the environment variable $CALCRC is undefined
and calc is invoked without the -q flag, or if $CALCRC is defined and
calc is invoked with -e, calc looks for a file "startup" in the calc
resource directory .calcrc in the user's home directory, and .calcinit
in the current directory. If one or more of these are found, they are
read in succession as calc scripts and their commands executed. When
defined, $CALCRC is to contain a ':' separated list of names of files,
and if calc is then invoked without either the -q or -e flags, these
files are read in succession and their commands executed. No error
condition is produced if a listed file is not found.
If the mode specified by -m disables opening of files for reading, then
the reading of startup files is also disabled as if -q was given.
CALC FILE SEARCH PATH
If the environment variable $CALCPATH is undefined, or if it is defined
and calc is invoked with the -e flag, when a file name not beginning
with /, ~ or ./, is specified as in:
calc read myfile
calc searches in succession:
./myfile
./myfile.cal
/usr/lib/myfile
/usr/lib/myfile.cal
/usr/share/calc/custom/myfile
/usr/share/calc/custom/myfile.cal
If the file is found, the search stops and the commands in the file are
executed. It is an error if no readable file with the specified name
is found. An alternative search path can be specified by defining
$CALCPATH in the same way as PATH is defined, as a ':' separated list
of directories, and then invoking calc without the -e flag.
Calc treats all open files, other than stdin, stdout and stderr as
files available for reading and writing. One may present calc with an
already open file using sh(1), ksh(1), bash(1)-like shells is to:
calc 3<open_file 4<open_file2
For more information use the following calc commands:
help help
help overview
help usage
help environment
help config
SHELL SCRIPT MODE
If the first line of an executable file begins #! followed by the
absolute pathname of the calc program and the flag -f as in:
#!/usr/bin/calc [other_flags ...] -f
the rest of the file will be processed in shell script mode. Note that
-f must be at the end of the initial ``#!'' line. Any other optional
other_flags must come before the -f.
In shell script mode the contents of the file are read and executed as
if they were in a file being processed by a read command, except that a
"command" beginning with '#' followed by whitespace and ending at the
next newline is treated as a comment. Any optional other_flags will be
parsed first followed by the later lines within the script itself.
In shell script mode, -s is always assumed. In addition, -d and -p are
automatically set if -i is not given.
For example, if the file /tmp/mersenne:
#!/usr/bin/calc -q -f
#
# mersenne - an example of a calc shell script file
/* parse args */
if (argv() != 1) {
fprintf(files(2), "usage: %s exp\n", config("program"));
abort "must give one exponent arg";
}
/* print the mersenne number */
print "2^": argv(0) : "-1 =", 2^eval(argv(0))-1;
is made an executable file by:
chmod +x /tmp/mersenne
then the command line:
/tmp/mersenne 127
will print:
2^127-1 = 170141183460469231731687303715884105727
Note that because -s is assumed in shell script mode and non-dashed
args are made available as strings via the argv() builtin function.
Therefore:
2^eval(argv(0))-1
will print the decimal value of 2^n-1 but
2^argv(0)-1
will not.
DATA TYPES
Fundamental builtin data types include integers, real numbers, rational
numbers, complex numbers and strings.
By use of an object, one may define an arbitrarily complex data types.
One may define how such objects behave a wide range of operations such
as addition, subtraction, multiplication, division, negation, squaring,
modulus, rounding, exponentiation, equality, comparison, printing and
so on.
For more information use the following calc commands:
help types
help obj
show objfuncs
VARIABLES
Variables in calc are typeless. In other words, the fundamental type
of a variable is determined by its content. Before a variable is
assigned a value it has the value of zero.
The scope of a variable may be global, local to a file, or local to a
procedure. Values may be grouped together in a matrix, or into a list
that permits stack and queue style operations.
For more information use the following calc commands:
help variable
help mat
help list
show globals
INPUT/OUTPUT
A leading ``0x'' implies a hexadecimal value, a leading ``0b'' implies
a binary value, and a ``0'' followed by a digit implies an octal value.
Complex numbers are indicated by a trailing ``i'' such as in ``3+4i''.
Strings may be delimited by either a pair of single or double quotes.
By default, calc prints values as if they were floating point numbers.
One may change the default to print values in a number of modes includ-
ing fractions, integers and exponentials.
A number of stdio-like file I/O operations are provided. One may open,
read, write, seek and close files. Filenames are subject to `` ''
expansion to home directories in a way similar to that of the Korn or
C-Shell.
For example:
~/.calcrc
~chongo/lib/fft_multiply.cal
For more information use the following calc command:
help file
CALC LANGUAGE
The calc language is a C-like language. The language includes commands
such as variable declarations, expressions, tests, labels, loops, file
operations, function calls. These commands are very similar to their
counterparts in C.
The language also include a number of commands particular to calc
itself. These include commands such as function definition, help,
reading in resource files, dump files to a file, error notification,
configuration control and status.
For more information use the following calc command:
help command
help statement
help expression
help operator
help config
FILES
/usr/bin/calc
calc binary
/usr/share/doc/apcalc/examples/*
calc shell scripts
/usr/lib/*.cal
calc standard resource files
/usr/lib/help/*
help files
/usr/lib/bindings
non-GNU-readline command line editor bindings
/usr/include/calc/*.h
include files for C interface use
/usr/lib/libcalc.a
calc binary link library
/usr/lib/libcustcalc.a
custom binary link library
/usr/share/calc/custom/*.cal
custom resource files
/usr/share/calc/custhelp/*
custom help files
ENVIRONMENT
CALCPATH
A :-separated list of directories used to search for calc resource
filenames that do not begin with /, ./ or ~.
Default value: .:./cal:~/.cal:/usr/local/share/calc:
/usr/share/calc:/usr/share/calc/custom
CALCRC
On startup (unless -h or -q was given on the command line), calc
searches for files along this :-separated environment variable.
Default value: /usr/share/calc/startup:
/usr/local/share/calc/startup:~/.calcrc:./.calcinit
CALCBINDINGS
On startup (unless -h or -q was given on the command line, or -m
disallows opening files for reading), calc reads key bindings from
the filename specified by this environment variable. The key
binding file is searched for along the $CALCPATH list of directo-
ries.
Default value: binding
This variable is not used if calc was compiled with GNU-readline
support. In that case, the standard readline mechanisms (see
readline(3)) are used.
CREDIT
The main chunk of calc was written by David I. Bell.
The calc primary mirror, calc mailing list and calc bug report process-
ing is performed by Landon Curt Noll.
Landon Curt Noll maintains the master reference source, performs
release control functions as well as other calc maintenance functions.
Thanks for suggestions and encouragement from Peter Miller, Neil Jus-
tusson, and Landon Noll.
Thanks to Stephen Rothwell for writing the original version of hist.c
which is used to do the command line editing.
Thanks to Ernest W. Bowen for supplying many improvements in accuracy
and generality for some numeric functions. Much of this was in terms
of actual code which I gratefully accepted. Ernest also supplied the
original text for many of the help files.
Portions of this program are derived from an earlier set of public
domain arbitrarily precision routines which was posted to the net
around 1984. By now, there is almost no recognizable code left from
that original source.
COPYING / CALC GNU LESSER GENERAL PUBLIC LICENSE
Calc is open software, and is covered under version 2.1 of the GNU
Lesser General Public License. You are welcome to change it and/or
distribute copies of it under certain conditions. The calc commands:
help copyright
help copying
help copying-lgpl
should display the contents of the COPYING and COPYING-LGPL files.
Those files contain information about the calc's GNU Lesser General
Public License, and in particular the conditions under which you are
allowed to change it and/or distribute copies of it.
You should have received a copy of the version 2.1 of the GNU Lesser
General Public License. If you do not have these files, write to:
Free Software Foundation, Inc.
51 Franklin Street
Fifth Floor
Boston, MA 02110-1301
USA
Calc is copyrighted in several different ways. These ways include:
Copyright (C) year David I. Bell
Copyright (C) year David I. Bell and Landon Curt Noll
Copyright (C) year David I. Bell and Ernest Bowen
Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen
Copyright (C) year Landon Curt Noll
Copyright (C) year Ernest Bowen and Landon Curt Noll
Copyright (C) year Ernest Bowen
This man page is:
Copyright (C) 1999 Landon Curt Noll
and is covered under version 2.1 GNU Lesser General Public License.
CALC MAILING LIST / CALC UPDATES / ENHANCEMENTS
To contribute comments, suggestions, enhancements and interesting calc
resource files, and shell scripts please join the calc-tester low vol-
ume moderated calc mailing list.
To the calc-tester mailing list, visit the following URL:
https://www.listbox.com/subscribe/?list_id=239342
To help determine you are a human and not just a spam bot, you will be
required to provide the following additional information:
Your Name
Calc Version
For example, the current version is: 2.12.5.0
Operating System
If you don't know your operating system, enter: unknown
The date 7 days ago
Consult a calendar :-)
If you need a human to help you with your mailing list subscription, or
if you have problems with the above procedure, please send EMail to our
special address:
calc-tester-maillist-help at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
NOTE: Yes, the EMail address uses 'asthe',
while the web site uses 'isthe'.
To be sure we see your EMail asking for help with your mailing list
subscription, please use the following phase in your EMail Subject line
your subject must contain the words:
calc tester mailing list help
You may have additional words in your subject line.
BUG REPORTS / BUG FIXES
Send bug reports and bug fixes to:
calc-bug-report at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
NOTE: Yes, the EMail address uses 'asthe',
while the web site uses 'isthe'.
Your subject must contain the words:
calc bug report
You may have additional words in your subject line.
However, you may find it more helpful to simply subscribe to the
calc-tester mailing list (see above) and then to send your report
to that mailing list as a wider set calc testers may be able to
help you.
See the BUGS source file or use the calc command:
help bugs
for more information about bug reporting.
CALC WEB SITE
Landon Noll maintains the calc web site is located at:
www.isthe.com/chongo/tech/comp/calc/
Share and Enjoy! :-)
2007-02-06 ^..^ calc(1)
*************
* cscript
*************
calc shell script examples
--------------------------
These calc shell scripts are provided because they serve as examples of
how use the calc language, and/or because the authors thought them to
be useful!
Please note that calc shell scripts must start with the line:
#!/usr/bin/calc -q -f
The above line MUST start in column 1 of the first line. The first line
must also end in -f. The -q is optional, but is recommended to disable
the processing of calc startup scripts.
Also please note that single # shell line comments are not supported in calc.
Comments must be /* c-like comment */ or start with a double ## symbol.
This is the correct way to form a calc shell script:
#!/usr/bin/calc -q -f
/* a correct comment */
## another correct comment
### two or more together is also a comment
/*
* another correct comment
*/
print "2+2 =", 2+2; ## yet another comment
The first argument after the path to calc executable must be an -S.
The next arguments are optional. The -q is often recommended because
it will disable the processing of the startup scripts.
For more informaton about calc command lines, see "help usage".
This next example WRONG:
#!/usr/bin/calc -q
# This is not a calc calc comment because it has only a single #
# You must to start comments with ## or /*
# is is also wrong because the first line does not end in -f
print "This example has invalid comments"
=-=
For more info, see:
help script
help cscript
#####
If you write something that you think is useful, please join the
low volume calc mailing list calc-tester. Then send your contribution
to the calc-tester mailing list.
To subscribe to the calc-tester mailing list, visit the following URL:
http://www.isthe.com/chongo/tech/comp/calc/calc-tester.html
This is a low volume moderated mailing list.
This mailing list replaces calc-tester at asthe dot com list.
If you need a human to help you with your mailing list subscription,
please send EMail to our special:
calc-tester-maillist-help at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
address. To be sure we see your EMail asking for help with your
mailing list subscription, please use the following phase in your
EMail Subject line:
calc tester mailing list help
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
=-=
4dsphere
Determine if 6 points lie on the surface of a 4-dimensional sphere in R^4.
4dsphere x0 y0 z0 w0 x1 y1 z1 w1 ... x5 y5 z5 w5
x0 y0 z0 w0 point 0 in R^4
x1 y1 z1 w1 point 1 in R^4
... ...
x5 y5 z5 w5 point 5 in R^4
fproduct filename term ...
Write the big Endian product of terms to a file. Use - for stdout.
mersenne exp
Print the value of 2^exp-1.
piforever
Print the value of pi forever, or as long as you cpu / memory allows.
plus arg ...
Print the sum of 1 or more arguments.
powerterm [base_limit] value
Print the value as a sum (or difference) of powers of integers up
to and including powers <= base_limit. By default, base_limit is 10000.
simple
A trivial example of a calc shell script.
## Copyright (C) 1999,2014 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.5 $
## @(#) $Id: README.src,v 30.5 2014/10/12 12:23:43 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/cscript/RCS/README.src,v $
##
## Under source code control: 1999/12/17 10:23:40
## File existed as early as: 1999
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* unexpected
*************
Unexpected
While calc is C-like, users of C will find some unexpected
surprises in calc syntax and usage. Persons familiar with C should
review this file.
Persons familiar with shell scripting may want to review this file
as well, particularly notes dealing with command line evaluation
and execution.
The Comma
=========
The comma is also used for continuation of obj and mat creation
expressions and for separation of expressions to be used for
arguments or values in function calls or initialization lists. The
precedence order of these different uses is: continuation,
separator, comma operator. For example, assuming the variables a,
b, c, d, e, and object type xx have been defined, the arguments
passed to f in:
f(a, b, c, obj xx d, e)
are a, b, c, and e, with e having the value of a newly created xx
object. In:
f((a, b), c, (obj xx d), e)
the arguments of f are b, c, d, e, with only d being a newly
created xx object.
In combination with other operators, the continuation use of the
comma has the same precedence as [] and ., the separator use the
same as the comma operator. For example, assuming xx.mul() has
been defined:
f(a = b, obj xx c, d = {1,2} * obj xx e = {3,4})
passes two arguments: a (with value b) and the product d * e of two
initialized xx objects.
^ is not xor
** is exponentiation
====================
In C, ^ is the xor operator. The expression:
a ^ b
yields "a to the b power", NOT "a xor b".
Unlike in C, calc evaluates the expression:
a ** b
also yields "a to the b power".
Here "a" and "b" can be a real value or a complex value:
2^3 3i^4
2.5 ^ 3.5 0.5i ^ 0.25
2.5 ^ 2.718i 3.13145i ^ 0.30103i
In addition, "a" can be matrix. In this case "b" must be an integer:
mat a[2,2] = {1,2,3,4};
a^3
Note that 'a' == 0 and 'b' is real, then is must be >= 0 as well.
Also 0^0 and 0**0 return the value 1.
Be careful about the precedence of operators. Note that:
-1 ^ 0.5 == -1
whereas:
(-1) ^ 0.5 == 1i
because the above expression in parsed as:
-(1 ^ 0.5) == -1
whereas:
(-1) ^ 0.5 == 1i
op= operators associate left to right
=====================================
Operator-with-assignments:
+= -= *= /= %= //= &= |= <<= >>= ^= **=
associate from left to right instead of right to left as in C.
For example:
a += b *= c
has the effect of:
a = (a + b) * c
where only 'a' is required to be an lvalue. For the effect of:
b *= c; a += b
when both 'a' and 'b' are lvalues, use:
a += (b *= c)
|| yields values other than 0 or 1
==================================
In C:
a || b
will produce 0 or 1 depending on the logical evaluation
of the expression. In calc, this expression will produce
either 'a' or 'b' and is equivalent to the expression:
a ? a : b
In other words, if 'a' is true, then 'a' is returned, otherwise
'b' is returned.
&& yields values other than 0 or 1
==================================
In C:
a && b
will produce 0 or 1 depending on the logical evaluation
of the expression. In calc, this expression will produce
either 'a' or 'b' and is equivalent to the expression:
a ? b : a
In other words, if 'a' is true, then 'b' is returned, otherwise
'a' is returned.
/ is fractional divide, // is integral divide
=============================================
In C:
x/y
performs integer division when 'x' and 'y' are integer types.
In calc, this expression yields a rational number.
Calc uses:
x//y
to perform division with integer truncation and is the equivalent to:
int(x/y)
| and & have higher precedence than ==, +, -, *, / and %
========================================================
Is C:
a == b | c * d
is interpreted as:
(a == b) | (c * d)
and calc it is interpreted as:
a == ((b | c) * d)
calc always evaluates terms from left to right
==============================================
Calc has a definite order for evaluation of terms (addends in a
sum, factors in a product, arguments for a function or a matrix,
etc.). This order is always from left to right. but skipping of
terms may occur for ||, && and ? : .
Consider, for example:
A * B + C * D
In calc above expression is evaluated in the following order:
A
B
A * B
C
D
C * D
A * B + C * D
This order of evaluation is significant if evaluation of a
term changes a variable on which a later term depends. For example:
x++ * x++ + x++ * x++
in calc returns the value:
x * (x + 1) + (x + 2) * (x + 3)
and increments x as if by x += 4. Similarly, for functions f, g,
the expression:
f(x++, x++) + g(x++)
evaluates to:
f(x, x + 1) + g(x + 2)
and increments x three times.
In an other example, this expression:
1<<8/2
evalues to 128, not 16, because <<8 is performed before the /2.
&A[0] and A are different things in calc
========================================
In calc, value of &A[0] is the address of the first element, whereas
A is the entire array.
*X may be used to to return the value of X
==========================================
If the current value of a variable X is an octet, number or string,
*X may be used to to return the value of X; in effect X is an
address and *X is the value at X.
freeing a variable has the effect of assigning the null value to it
===================================================================
The freeglobals(), freestatics(), freeredc() and free() free
builtins to not "undefine" the variables, but have the effect of
assigning the null value to them, and so frees the memory used for
elements of a list, matrix or object.
Along the same lines:
undefine *
undefines all current user-defined functions. After executing
all the above freeing functions (and if necessary free(.) to free
the current "old value"), the only remaining numbers as displayed by
show numbers
should be those associated with epsilon(), and if it has been
called, qpi().
#! is also a comment
====================
In addition to the C style /* comment lines */, lines that begin with
#! are treated as comments.
A single # is an calc operator, not a comment. However two or more
##'s in a row is a comment. See "help pound" for more information.
#!/usr/local/src/bin/calc/calc -q -f
/* a correct comment */
## another correct comment
### two or more together is also a comment
/*
* another correct comment
*/
print "2+2 =", 2+2; ## yet another comment
This next example is WRONG:
#!/usr/local/src/bin/calc/calc -q -f
# This is not a calc calc comment because it has only a single #
# You must to start comments with ## or /*
print "This example has invalid comments"
See "help cscript" and "help usage" for more information.
The { must be on the same line as an if, for, while or do
=========================================================
When statement is of the form { ... }, the leading { MUST BE ON
THE SAME LINE as the if, for, while or do keyword.
This works as expected:
if (expr) {
...
}
However this WILL NOT WORK AS EXPECTED:
if (expr)
{
...
}
because calc will parse the if being terminated by
an empty statement followed by a
if (expr) ;
{
...
}
In the same way, use these forms:
for (optionalexpr ; optionalexpr ; optionalexpr) {
...
}
while (expr) {
...
}
do {
...
while (expr);
where the initial { is on the SAME LINE as the if, while,
for or do keyword.
NOTE: See "help statement", "help todo", and "help bugs".
Shell evaluation of command line arguments
==========================================
In most interactive shells:
calc 2 * 3
will frequently produce a "Missing operator" error because the '*' is
evaluated as a "shell glob". To avoid this you must quote or escape
argument with characters that your interactive shell interprets.
For example, bash / ksh / sh shell users should use:
calc '2 * 3'
or:
calc 2 \* 3
or some other form of shell meta-character escaping.
Calc reads standard input after processing command line args
============================================================
The shell command:
seq 5 | while read i; do calc "($i+3)^2"; done
FYI: The command "seq 5" will write 1 through 5 on separate
lines on standard output, while read i sets $i to
the value of each line that is read from stdin.
will produce:
16
2
3
4
5
The reason why the last 4 lines of output are 2 through 5 is
that after calc evaluates the first line and prints (1+3)^2
(i.e., 16), calc continues to read stdin and slurps up all
of the remaining data on the pipe.
To avoid this problem, use:
seq 5 | while read i; do calc "($i+3)^2" </dev/null; done
which produces the expected results:
16
25
36
49
64
## Copyright (C) 1999-2007,2014 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.6 $
## @(#) $Id: unexpected,v 30.6 2014/08/24 21:59:45 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/unexpected,v $
##
## Under source code control: 1997/03/21 13:15:18
## File existed as early as: 1997
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* variable
*************
Variable declarations
Variables can be declared as either being global, local, or static.
Global variables are visible to all functions and on the command
line, and are permanent. Local variables are visible only within
a single function or command sequence. When the function or command
sequence returns, the local variables are deleted. Static variables
are permanent like global variables, but are only visible within the
same input file or function where they are defined.
To declare one or more variables, the 'local', 'global', or 'static'
keywords are used, followed by the desired list of variable names,
separated by commas. The definition is terminated with a semicolon.
Examples of declarations are:
local x, y, z;
global fred;
local foo, bar;
static var1, var2, var3;
Variables may have initializations applied to them. This is done
by following the variable name by an equals sign and an expression.
Global and local variables are initialized each time that control
reaches them (e.g., at the entry to a function which contains them).
Static variables are initialized once only, at the time that control
first reaches them (but in future releases the time of initialization
may change). Unlike in C, expressions for static variables may
contain function calls and refer to variables. Examples of such
initializations are:
local a1 = 7, a2 = 3;
static b = a1 + sin(a2);
Within function declarations, all variables must be defined.
But on the top level command line, assignments automatically define
global variables as needed. For example, on the top level command
line, the following defines the global variable x if it had not
already been defined:
x = 7
The static keyword may be used at the top level command level to
define a variable which is only accessible interactively, or within
functions defined interactively.
Variables have no fixed type, thus there is no need or way to
specify the types of variables as they are defined. Instead, the
types of variables change as they are assigned to or are specified
in special statements such as 'mat' and 'obj'. When a variable is
first defined using 'local', 'global', or 'static', it has the
value of zero.
If a procedure defines a local or static variable name which matches
a global variable name, or has a parameter name which matches a
global variable name, then the local variable or parameter takes
precedence within that procedure, and the global variable is not
directly accessible.
The MAT and OBJ keywords may be used within a declaration statement
in order to initially define variables as that type. Initialization
of these variables are also allowed. Examples of such declarations
are:
static mat table[3] = {5, 6, 7};
local obj point p1, p2;
When working with user-defined functions, the syntax for passing an
lvalue by reference rather than by value is to precede an expression
for the lvalue by a backquote. For example, if the function invert is
defined by:
define invert(x) {x = inverse(x)}
then invert(`A) achieves the effect of A = inverse(A). In other
words, passing and argument of `variable (with a back-quote)
will cause and changes to the function argument to be applied to
the calling variable. Calling invert(A) (without the ` backquote)
assigns inverse(A) to the temporary function parameter x and leaves
A unchanged.
In an argument, a backquote before other than an lvalue is ignored.
Consider, for example:
; define logplus(x,y,z) {return log(++x + ++y + ++z);}
; eh = 55;
; mi = 25;
; answer = logplus(eh, `mi, `17);
; print eh, mi, answer;
55 26 2
The value of eh is was not changed because eh was used as
an argument without a back-quote (`). However, mi was incremented
because it was passed as `mi (with a back-quote). Passing 17
(not an lvalue) as `17 has not effect on the value 17.
The back-quote should only be used before arguments to a function.
In all other contexts, a backquote causes a compile error.
Another method is to pass the address of the lvalue explicitly and
use the indirection operator * (star) to refer to the lvalue in the
function body. Consider the following function:
; define ten(a) { *a = 10; }
; n = 17;
; ten(n);
; print n;
17
; ten(`n);
; print n;
17
; ten(&n);
; print n;
10
Passing an argument with a & (ampersand) allows the tenmore()
function to modify the calling variable:
; wa = tenmore(&vx);
; print vx, wa;
65 65
Great care should be taken when using a pointer to a local variable
or element of a matrix, list or object, since the lvalue pointed to
is deleted when evaluation of the function is completed or the lvalue
whose value is the matrix, list or object is assigned another value.
As both of the above methods (using & arguments (ampersand) *value
(star) function values or by using ` arguments (back quote) alone)
copy the address rather than the value of the argument to the function
parameter, they allow for faster calls of functions when the memory
required for the value is huge (such as for a large matrix).
As the built-in functions and object functions always accept their
arguments as addresses, there is no gain in using the backquote when
calling these functions.
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: variable,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/variable,v $
##
## Under source code control: 1991/07/21 04:37:25
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* bindings
*************
# bindings - default key bindings for calc line editing functions
#
# Copyright (C) 1999 David I. Bell
#
# Calc is open software; you can redistribute it and/or modify it under
# the terms of the version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# Calc is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
# Public License for more details.
#
# A copy of version 2.1 of the GNU Lesser General Public License is
# distributed with calc under the filename COPYING-LGPL. You should have
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# @(#) $Revision: 30.1 $
# @(#) $Id: bindings,v 30.1 2007/03/16 11:09:54 chongo Exp $
# @(#) $Source: /usr/local/src/bin/calc/cal/RCS/bindings,v $
#
# Under source code control: 1993/05/02 20:09:19
# File existed as early as: 1993
#
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# NOTE: This facility is ignored if calc was compiled with GNU-readline.
# In that case, the standard readline mechanisms (see readline(3))
# are used in place of those found below.
map base-map
default insert-char
^@ set-mark
^A start-of-line
^B backward-char
^D delete-char
^E end-of-line
^F forward-char
^H backward-kill-char
^J new-line
^K kill-line
^L refresh-line
^M new-line
^N forward-history
^O save-line
^P backward-history
^R reverse-search
^T swap-chars
^U flush-input
^V quote-char
^W kill-region
^Y yank
^? backward-kill-char
^[ ignore-char esc-map
map esc-map
default ignore-char base-map
G start-of-line
H backward-history
P forward-history
K backward-char
M forward-char
O end-of-line
S delete-char
g goto-line
s backward-word
t forward-word
d forward-kill-word
u uppercase-word
l lowercase-word
h list-history
^[ flush-input
[ arrow-key
*************
* custom_cal
*************
Custom calc resource files
--------------------------
The following custom calc resource files are provided because they serve
as examples of how use the custom interface. The custom interface
allows for machine dependent and/or non-portable code to be added as
builtins to the calc program. A few example custom functions and
resource files are shipped with calc to provide you with examples.
By default, the custom builtin returns an error. Calc have been
built with:
ALLOW_CUSTOM= -DCUSTOM
in the top level Makefile (this is the shipped default) and calc
must be invoked with a -C argument:
calc -C
when it is run.
See the ../cal/README or "help resource" for information about
calc resource standards and guidelines.
=-=
argv.cal
argv(var, ...)
print information about various args
halflen.cal
halflen(num)
Calculate the length of a numeric value in HALF's.
pzasusb8.cal
Run custom("pzasusb8") on a standard set of data, print Endian
related information and print value size information.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: CUSTOM_CAL,v 30.1 2007/03/16 11:10:04 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/custom/RCS/CUSTOM_CAL,v $
##
## Under source code control: 1997/03/08 20:51:32
## File existed as early as: 1997
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* libcalc
*************
USING THE ARBITRARY PRECISION ROUTINES IN A C PROGRAM
Part of the calc release consists of an arbitrary precision math link library.
This link library is used by the calc program to perform its own calculations.
If you wish, you can ignore the calc program entirely and call the arbitrary
precision math routines from your own C programs.
The link library is called libcalc.a, and provides routines to handle arbitrary
precision arithmetic with integers, rational numbers, or complex numbers.
There are also many numeric functions such as factorial and gcd, along
with some transcendental functions such as sin and exp.
Take a look at the sample sub-directory. It contains a few simple
examples of how to use libcalc.a that might be helpful to look at
after you have read this file.
------------------
FIRST THINGS FIRST
------------------
...............................................................................
. .
. You MUST call libcalc_call_me_first() prior to using libcalc lib functions! .
. .
...............................................................................
The function libcalc_call_me_first() takes no args and returns void. You
need call libcalc_call_me_first() only once.
-------------
INCLUDE FILES
-------------
To use any of these routines in your own programs, you need to include the
appropriate include file. These include files are:
zmath.h (for integer arithmetic)
qmath.h (for rational arithmetic)
cmath.h (for complex number arithmetic)
You never need to include more than one of the above files, even if you wish
to use more than one type of arithmetic, since qmath.h automatically includes
zmath.h, and cmath.h automatically includes qmath.h.
The prototypes for the available routines are listed in the above include
files. Some of these routines are meant for internal use, and so aren't
convenient for outside use. So you should read the source for a routine
to see if it really does what you think it does. I won't guarantee that
obscure internal routines won't change or disappear in future releases!
When calc is installed, all of libraries are installed into /usr/lib.
All of the calc header files are installed under ${INCDIRCALC}.
If CALC_SRC is defined, then the calc header files will assume that
they are in or under the current directory. However, most external
programs most likely will not be located under calc'c source tree.
External programs most likely want to use the installed calc header
files under ${INCDIRCALC}. External programs most likely NOT want
to define CALC_SRC.
You need to include the following file to get the symbols and variables
related to error handling:
lib_calc.h
External programs may want to compile with:
-I${INCDIR} -L/usr/lib -lcalc
If custom functions are also used, they may want to compile with:
-I${INCDIR} -L/usr/lib -lcalc -lcustcalc
The CALC_SRC symbol should NOT be defined by default. However if you are
feeling pedantic you may want to force CALC_SRC to be undefined:
-UCALC_SRC
as well.
-------------------
MATH ERROR HANDLING
-------------------
The math_error() function is called by the math routines on an error
condition, such as malloc failures, division by zero, or some form of
an internal computation error. The routine is called in the manner of
printf, with a format string and optional arguments:
void math_error(char *fmt, ...);
Your program must handle math errors in one of three ways:
1) Print the error message and then exit
There is a math_error() function supplied with the calc library.
By default, this routine simply prints a message to stderr and
then exits. By simply linking in this link library, any calc
errors will result in a error message on stderr followed by
an exit.
2) Use setjmp and longjmp in your program
Use setjmp at some appropriate level in your program, and let
the longjmp in math_error() return to that level and to allow you
to recover from the error. This is what the calc program does.
If one sets up calc_matherr_jmpbuf, and then sets
calc_use_matherr_jmpbuf to non-zero then math_error() will
longjmp back with the return value of calc_use_matherr_jmpbuf.
In addition, the last calc error message will be found in
calc_err_msg; this error is not printed to stderr. The calc
error message will not have a trailing newline.
For example:
#include <setjmp.h>
#include "lib_calc.h"
int error;
...
if ((error = setjmp(calc_matherr_jmpbuf)) != 0) {
/* report the error */
printf("Ouch: %s\n", calc_err_msg);
/* reinitialize calc after the longjmp */
reinitialize();
}
calc_use_matherr_jmpbuf = 1;
If calc_use_matherr_jmpbuf is non-zero, then the jmp_buf value
calc_matherr_jmpbuf must be initialized by the setjmp() function
or your program will crash.
3) Supply your own math_error function:
void math_error(char *fmt, ...);
Your math_error() function may exit or transfer control to outside
of the calc library, but it must never return or calc will crash.
External programs can obtain the appropriate calc symbols by compiling with:
-I${INCDIR} -L/usr/lib -lcalc
-------------------------
PARSE/SCAN ERROR HANDLING
-------------------------
The scanerror() function is called when calc encounters a parse/scan
error. For example, scanerror() is called when calc is given code
with a syntax error.
The variable, calc_print_scanerr_msg, controls if calc prints to stderr,
any parse/scan errors. By default, this variable it set to 1 and so
parse/scan errors are printed to stderr. By setting this value to zero,
parse/scan errors are not printed:
#include "lib_calc.h"
/* do not print parse/scan errors to stderr */
calc_print_scanerr_msg = 0;
The last calc math error or calc parse/scan error message is kept
in the NUL terminated buffer:
char calc_err_msg[MAXERROR+1];
The value of calc_print_scanerr_msg does not change the use
of the calc_err_msg[] buffer. Messages are stored in that
buffer regardless of the calc_print_scanerr_msg value.
The calc_print_scanerr_msg and the calc_err_msg[] buffer are declared
lib_calc.h include file. The initialized storage for these variables
comes from the calc library. The MAXERROR symbol is also declared in
the lib_calc.h include file.
Your program must handle parse/scan errors in one of two ways:
1) exit on error
If you do not setup the calc_scanerr_jmpbuf, then when calc
encounters a parse/scan error, a message will be printed to
stderr and calc will exit.
2) Use setjmp and longjmp in your program
Use setjmp at some appropriate level in your program, and let
the longjmp in scanerror() return to that level and to allow you
to recover from the error. This is what the calc program does.
If one sets up calc_scanerr_jmpbuf, and then sets
calc_use_scanerr_jmpbuf to non-zero then scanerror() will longjmp
back with the return with a non-zero code. In addition, the last
calc error message will be found in calc_err_msg[]; this error is
not printed to stderr. The calc error message will not have a
trailing newline.
For example:
#include <setjmp.h>
#include "lib_calc.h"
int scan_error;
...
/* delay the printing of the parse/scan error */
calc_use_scanerr_jmpbuf = 0; /* this is optional */
if ((scan_error = setjmp(calc_scanerr_jmpbuf)) != 0) {
/* report the parse/scan */
if (calc_use_scanerr_jmpbuf == 0) {
printf("parse error: %s\n", calc_err_msg);
}
/* initialize calc after the longjmp */
initialize();
}
calc_use_scanerr_jmpbuf = 1;
If calc_use_scanerr_jmpbuf is non-zero, then the jmp_buf value
calc_scanerr_jmpbuf must be initialized by the setjmp() function
or your program will crash.
External programs can obtain the appropriate calc symbols by compiling with:
-I${INCDIR} -L/usr/lib -lcalc
---------------------------
PARSE/SCAN WARNING HANDLING
---------------------------
Calc parse/scan warning message are printed to stderr by the warning()
function. The routine is called in the manner of printf, with a format
string and optional arguments:
void warning(char *fmt, ...);
The variable, calc_print_scanwarn_msg, controls if calc prints to stderr,
any parse/scan warnings. By default, this variable it set to 1 and so
parse/scan warnings are printed to stderr. By setting this value to zero,
parse/scan warnings are not printed:
#include "lib_calc.h"
/* do not print parse/scan warnings to stderr */
calc_print_scanwarn_msg = 0;
The last calc calc parse/scan warning message is kept in the NUL
terminated buffer:
char calc_warn_msg[MAXERROR+1];
The value of calc_print_scanwarn_msg does not change the use
of the calc_warn_msg[] buffer. Messages are stored in that
buffer regardless of the calc_print_scanwarn_msg value.
Your program must handle parse/scan warnings in one of two ways:
1) print the warning to stderr and continue
The warning() from libcalc prints warning messages to
stderr and returns. The flow of execution is not changed.
This is what calc does by default.
2) Supply your own warning function:
void warning(char *fmt, ...);
Your warning function should simply return when it is finished.
External programs can obtain the appropriate calc symbols by compiling with:
-I${INCDIR} -L/usr/lib -lcalc
---------------
OUTPUT ROUTINES
---------------
The output from the routines in the link library normally goes to stdout.
You can divert that output to either another FILE handle, or else
to a string. Read the routines in zio.c to see what is available.
Diversions can be nested.
You use math_setfp to divert output to another FILE handle. Calling
math_setfp with stdout restores output to stdout.
Use math_divertio to begin diverting output into a string. Calling
math_getdivertedio will then return a string containing the output, and
clears the diversion. The string is reallocated as necessary, but since
it is in memory, there are obviously limits on the amount of data that can
be diverted into it. The string needs freeing when you are done with it.
Calling math_cleardiversions will clear all the diversions to strings, and
is useful on an error condition to restore output to a known state. You
should also call math_setfp on errors if you had changed that.
If you wish to mix your own output with numeric output from the math routines,
then you can call math_chr, math_str, math_fill, math_fmt, or math_flush.
These routines output single characters, output null-terminated strings,
output strings with space filling, output formatted strings like printf, and
flush the output. Output from these routines is diverted as described above.
You can change the default output mode by calling math_setmode, and you can
change the default number of digits printed by calling math_setdigits. These
routines return the previous values. The possible modes are described in
zmath.h.
--------------
USING INTEGERS
--------------
The arbitrary precision integer routines define a structure called a ZVALUE.
This is defined in zmath.h. A ZVALUE contains a pointer to an array of
integers, the length of the array, and a sign flag. The array is allocated
using malloc, so you need to free this array when you are done with a
ZVALUE. To do this, you should call zfree with the ZVALUE as an argument
(or call freeh with the pointer as an argument) and never try to free the
array yourself using free. The reason for this is that sometimes the pointer
points to one of two statically allocated arrays which should NOT be freed.
The ZVALUE structures are passed to routines by value, and are returned
through pointers. For example, to multiply two small integers together,
you could do the following:
ZVALUE z1, z2, z3;
itoz(3L, &z1);
itoz(4L, &z2);
zmul(z1, z2, &z3);
Use zcopy to copy one ZVALUE to another. There is no sharing of arrays
between different ZVALUEs even if they have the same value, so you MUST
use this routine. Simply assigning one value into another will cause
problems when one of the copies is freed. However, the special ZVALUE
values _zero_ and _one_ CAN be assigned to variables directly, since their
values of 0 and 1 are so common that special checks are made for them.
For initial values besides 0 or 1, you need to call itoz to convert a long
value into a ZVALUE, as shown in the above example. Or alternatively,
for larger numbers you can use the atoz routine to convert a string which
represents a number into a ZVALUE. The string can be in decimal, octal,
hex, or binary according to the leading digits.
Always make sure you free a ZVALUE when you are done with it or when you
are about to overwrite an old ZVALUE with another value by passing its
address to a routine as a destination value, otherwise memory will be
lost. The following shows an example of the correct way to free memory
over a long sequence of operations.
ZVALUE z1, z2, z3;
z1 = _one_;
atoz("12345678987654321", &z2);
zadd(z1, z2, &z3);
zfree(z1);
zfree(z2);
zsquare(z3, &z1);
zfree(z3);
itoz(17L, &z2);
zsub(z1, z2, &z3);
zfree(z1);
zfree(z2);
zfree(z3);
There are some quick checks you can make on integers. For example, whether
or not they are zero, negative, even, and so on. These are all macros
defined in zmath.h, and should be used instead of checking the parts of the
ZVALUE yourself. Examples of such checks are:
ziseven(z) (number is even)
zisodd(z) (number is odd)
ziszero(z) (number is zero)
zisneg(z) (number is negative)
zispos(z) (number is positive)
zisunit(z) (number is 1 or -1)
zisone(z) (number is 1)
zisnegone(z) (number is -1)
zistwo(z) (number is 2)
zisabstwo(z) (number is 2 or -2)
zisabsleone(z) (number is -1, 0 or 1)
zislezero(z) (number is <= 0)
zisleone(z) (number is <= 1)
zge16b(z) (number is >= 2^16)
zge24b(z) (number is >= 2^24)
zge31b(z) (number is >= 2^31)
zge32b(z) (number is >= 2^32)
zge64b(z) (number is >= 2^64)
Typically the largest unsigned long is typedefed to FULL. The following
macros are useful in dealing with this data type:
MAXFULL (largest positive FULL value)
MAXUFULL (largest unsigned FULL value)
zgtmaxfull(z) (number is > MAXFULL)
zgtmaxufull(z) (number is > MAXUFULL)
zgtmaxlong(z) (number is > MAXLONG, largest long value)
zgtmaxulong(z) (number is > MAXULONG, largest unsigned long value)
If zgtmaxufull(z) is false, then one may quickly convert the absolute
value of number into a full with the macro:
ztofull(z) (convert abs(number) to FULL)
ztoulong(z) (convert abs(number) to an unsigned long)
ztolong(z) (convert abs(number) to a long)
If the value is too large for ztofull(), ztoulong() or ztolong(), only
the low order bits converted.
There are two types of comparisons you can make on ZVALUEs. This is whether
or not they are equal, or the ordering on size of the numbers. The zcmp
function tests whether two ZVALUEs are equal, returning TRUE if they differ.
The zrel function tests the relative sizes of two ZVALUEs, returning -1 if
the first one is smaller, 0 if they are the same, and 1 if the first one
is larger.
---------------
USING FRACTIONS
---------------
The arbitrary precision fractional routines define a structure called NUMBER.
This is defined in qmath.h. A NUMBER contains two ZVALUEs for the numerator
and denominator of a fraction, and a count of the number of uses there are
for this NUMBER. The numerator and denominator are always in lowest terms,
and the sign of the number is contained in the numerator. The denominator
is always positive. If the NUMBER is an integer, the denominator has the
value 1.
Unlike ZVALUEs, NUMBERs are passed using pointers, and pointers to them are
returned by functions. So the basic type for using fractions is not really
(NUMBER), but is (NUMBER *). NUMBERs are allocated using the qalloc routine.
This returns a pointer to a number which has the value 1. Because of the
special property of a ZVALUE of 1, the numerator and denominator of this
returned value can simply be overwritten with new ZVALUEs without needing
to free them first. The following illustrates this:
NUMBER *q;
q = qalloc();
itoz(55L, &q->num);
A better way to create NUMBERs with particular values is to use the itoq,
iitoq, or atoq functions. Using itoq makes a long value into a NUMBER,
using iitoq makes a pair of longs into the numerator and denominator of a
NUMBER (reducing them first if needed), and atoq converts a string representing
a number into the corresponding NUMBER. The atoq function accepts input in
integral, fractional, real, or exponential formats. Examples of allocating
numbers are:
NUMBER *q1, *q2, *q3;
q1 = itoq(66L);
q2 = iitoq(2L, 3L);
q3 = atoq("456.78");
Also unlike ZVALUEs, NUMBERs are quickly copied. This is because they contain
a link count, which is the number of pointers there are to the NUMBER. The
qlink macro is used to copy a pointer to a NUMBER, and simply increments
the link count and returns the same pointer. Since it is a macro, the
argument should not be a function call, but a real pointer variable. The
qcopy routine will actually make a new copy of a NUMBER, with a new link
count of 1. This is not usually needed.
NUMBERs are deleted using the qfree routine. This decrements the link count
in the NUMBER, and if it reaches zero, then it will deallocate both of
the ZVALUEs contained within the NUMBER, and then puts the NUMBER structure
onto a free list for quick reuse. The following is an example of allocating
NUMBERs, copying them, adding them, and finally deleting them again.
NUMBER *q1, *q2, *q3;
q1 = itoq(111L);
q2 = qlink(q1);
q3 = qqadd(q1, q2);
qfree(q1);
qfree(q2);
qfree(q3);
Because of the passing of pointers and the ability to copy numbers easily,
you might wish to use the rational number routines even for integral
calculations. They might be slightly slower than the raw integral routines,
but are more convenient to program with.
The prototypes for the fractional routines are defined in qmath.h.
Many of the definitions for integer functions parallel the ones defined
in zmath.h. But there are also functions used only for fractions.
Examples of these are qnum to return the numerator, qden to return the
denominator, qint to return the integer part of, qfrac to return the
fractional part of, and qinv to invert a fraction.
There are some transcendental functions in the link library, such as sin
and cos. These cannot be evaluated exactly as fractions. Therefore,
they accept another argument which tells how accurate you want the result.
This is an "epsilon" value, and the returned value will be within that
quantity of the correct value. This is usually an absolute difference,
but for some functions (such as exp), this is a relative difference.
For example, to calculate sin(0.5) to 100 decimal places, you could do:
NUMBER *q, *ans, *epsilon;
q = atoq("0.5");
epsilon = atoq("1e-100");
ans = qsin(q, epsilon);
There are many convenience macros similar to the ones for ZVALUEs which can
give quick information about NUMBERs. In addition, there are some new ones
applicable to fractions. These are all defined in qmath.h. Some of these
macros are:
qiszero(q) (number is zero)
qisneg(q) (number is negative)
qispos(q) (number is positive)
qisint(q) (number is an integer)
qisfrac(q) (number is fractional)
qisunit(q) (number is 1 or -1)
qisone(q) (number is 1)
qisnegone(q) (number is -1)
qistwo(q) (number is 2)
qiseven(q) (number is an even integer)
qisodd(q) (number is an odd integer)
qistwopower(q) (number is a power of 2 >= 1)
The comparisons for NUMBERs are similar to the ones for ZVALUEs. You use the
qcmp and qrel functions.
There are four predefined values for fractions. You should qlink them when
you want to use them. These are _qzero_, _qone_, _qnegone_, and _qonehalf_.
These have the values 0, 1, -1, and 1/2. An example of using them is:
NUMBER *q1, *q2;
q1 = qlink(&_qonehalf_);
q2 = qlink(&_qone_);
---------------------
USING COMPLEX NUMBERS
---------------------
The arbitrary precision complex arithmetic routines define a structure
called COMPLEX. This is defined in cmath.h. This contains two NUMBERs
for the real and imaginary parts of a complex number, and a count of the
number of links there are to this COMPLEX number.
The complex number routines work similarly to the fractional routines.
You can allocate a COMPLEX structure using comalloc (NOT calloc!).
You can construct a COMPLEX number with desired real and imaginary
fractional parts using qqtoc. You can copy COMPLEX values using clink
which increments the link count. And you free a COMPLEX value using cfree.
The following example illustrates this:
NUMBER *q1, *q2;
COMPLEX *c1, *c2, *c3;
q1 = itoq(3L);
q2 = itoq(4L);
c1 = qqtoc(q1, q2);
qfree(q1);
qfree(q2);
c2 = clink(c1);
c3 = cmul(c1, c2);
cfree(c1);
cfree(c2);
cfree(c3);
As a shortcut, when you want to manipulate a COMPLEX value by a real value,
you can use the caddq, csubq, cmulq, and cdivq routines. These accept one
COMPLEX value and one NUMBER value, and produce a COMPLEX value.
There is no direct routine to convert a string value into a COMPLEX value.
But you can do this yourself by converting two strings into two NUMBERS,
and then using the qqtoc routine.
COMPLEX values are always returned from these routines. To split out the
real and imaginary parts into normal NUMBERs, you can simply qlink the
two components, as shown in the following example:
COMPLEX *c;
NUMBER *rp, *ip;
c = calloc();
rp = qlink(c->real);
ip = qlink(c->imag);
There are many macros for checking quick things about complex numbers,
similar to the ZVALUE and NUMBER macros. In addition, there are some
only used for complex numbers. Examples of macros are:
cisreal(c) (number is real)
cisimag(c) (number is pure imaginary)
ciszero(c) (number is zero)
cisnegone(c) (number is -1)
cisone(c) (number is 1)
cisrunit(c) (number is 1 or -1)
cisiunit(c) (number is i or -i)
cisunit(c) (number is 1, -1, i, or -i)
cistwo(c) (number is 2)
cisint(c) (number is has integer real and imaginary parts)
ciseven(c) (number is has even real and imaginary parts)
cisodd(c) (number is has odd real and imaginary parts)
There is only one comparison you can make for COMPLEX values, and that is
for equality. The ccmp function returns TRUE if two complex numbers differ.
There are three predefined values for complex numbers. You should clink
them when you want to use them. They are _czero_, _cone_, and _conei_.
These have the values 0, 1, and i.
----------------
LAST THINGS LAST
----------------
If you wish, when you are all doen you can call libcalc_call_me_last()
to free a small amount of storage associated with the libcalc_call_me_first()
call. This is not required, but is does bring things to a closure.
The function libcalc_call_me_last() takes no args and returns void. You
need call libcalc_call_me_last() only once.
## Copyright (C) 1999 David I. Bell and Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: LIBRARY,v 30.1 2007/03/16 11:09:46 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/RCS/LIBRARY,v $
##
## Under source code control: 1993/07/30 19:44:49
## File existed as early as: 1993
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* new_custom
*************
Guidelines for adding custom functions
--------------------------------------
Step 0: Determine if is should it be done?
The main focus for calc is to provide a portable platform for
multi-precision calculations in a C-like environment. You should
consider implementing algorithms in the calc language as a first
choice. Sometimes an algorithm requires use of special hardware, a
non-portable OS or pre-compiled C library. In these cases a custom
interface may be needed.
The custom function interface is intended to make is easy for
programmers to add functionality that would be otherwise
un-suitable for general distribution. Functions that are
non-portable (machine, hardware or OS dependent) or highly
specialized are possible candidates for custom functions.
So before you go to step 1, ask yourself:
+ Can I implement this as a calc resource file or calc shell script?
If Yes, write the shell script or resource file and be done with it.
If No, continue to the next question ...
+ Does it require the use of non-portable features,
OS specific support or special hardware?
If No, write it as a regular builtin function.
If Yes, continue to step 1 ...
Step 1: Do some background work
First ... read this file ALL THE WAY THROUGH before implementing
anything in Steps 2 and beyond!
If you are not familiar with calc internals, we recommend that
you look at some examples of custom functions. Look at the
the following source files:
custom.c
custom.h
custom/custtbl.c
custom/c_*.[ch]
custom/*.cal
help/custom (or run: calc help custom)
You would be well advised to look at a more recent calc source
such as one available in from the calc version archive.
See the following for more details:
help/archive (or run: calc help archive)
Step 2: Name your custom function
We suggest that you pick a name that does not conflict with
one of the builtin names. It makes it easier to get help
via the help interface and avoid confusion down the road.
You should avoid picking a name that matches a file or
directory name under ${HELPDIR} as well. Not all help
files are associated with builtin function names.
For purposes of this file, we will use the name 'curds'
as our example custom function name.
Step 3: Document your custom function
No this step is NOT out of order. We recommend that you write the
help file associated with your new custom function EARLY. By
experience we have found that the small amount of effort made to
write "how the custom function will be used" into a help file pays
off in a big way when it comes to coding. Often the effort of
writing a help file will clarify fuzzy aspects of your design.
Besides, unless you write the help file first, it will likely never
be written later on. :-(
OK ... we will stop preaching now ...
[[ From now on we will give filenames relative to the custom directory ]]
Take a look at one of the example custom help files:
custom/devnull
custom/argv
custom/help
custom/sysinfo
You can save time by using one of the custom help files
as a template. Copy one of these files to your own help file:
cd custom
cp sysinfo curds
and edit it accordingly.
Step 4: Write your test code
No this step is NOT out of order either. We recommend that you
write a simple calc script that will call your custom function and
check the results.
This script will be useful while you are debugging your code. In
addition, if you wish to submit your code for distribution, this
test code will be an import part of your submission. Your test
code will also service as additional for your custom function.
Oops ... we said we would stop preaching, sorry about that ...
You can use one of the following as a template:
custom/argv.cal
custom/halflen.cal
Copy one of these to your own file:
cd custom
cp halflen.cal curds.cal
and exit it accordingly. In particular you will want to:
remove our header disclaimer (or put your own on)
change the name from halflen() to curds()
change the comment from 'halflen - determine the length ...' to
'curds - brief description about ...'
change other code as needed.
Step 5: Write your custom function
By convention, the files we ship that contain custom function
interface code in filenames of the form:
c_*.c
We suggest that you use filenames of the form:
u_*.c
to avoid filename conflicts.
We recommend that you use one of the c_*.c files as a template.
Copy an appropriate file to your file:
cd custom
cp c_argv.c u_curds.c
Before you edit it, you should note that there are several important
features of this file.
a) All of the code in the file is found between #if ... #endif:
/*
* only comments and blank lines at the top
*/
#if defined(CUSTOM)
... all code, #includes, #defines etc.
#endif /* CUSTOM */
This allows this code to 'go away' when the upper Makefile
disables the custom code (because ALLOW_CUSTOM no longer
has the -DCUSTOM define).
b) The function type must be:
/*ARGSUSED*/
VALUE
u_curds(char *name, int count, VALUE **vals)
The 3 args are passed in by the custom interface
and have the following meaning:
name The name of the custom function that
was called. In particular, this is the first
string arg that was given to the custom()
builtin. This is the equivalent of argv[0] for
main() in C programming.
The same code can be used for multiple custom
functions by processing off of this value.
count This is the number of additional args that
was given to the custom() builtin. Note
that count does NOT include the name arg.
This is similar to argc except that count
is one less than the main() argc interface.
For example, a call of:
custom("curds", a, b, c)
would cause count to be passed as 3.
vals This is a pointer to an array of VALUEs.
This is the equivalent of argv+1 for
main() in C programming. The difference
here is that vals[0] refers to the 1st
parameter AFTER the same.
For example, a call of:
custom("curds", a, b, c)
would cause vals to point to the following array:
vals[0] points to a
vals[1] points to b
vals[2] points to c
NOTE: If you do not use any of the 3 function parameters,
then you should declare that function parameter to be UNUSED.
For example, if the count and vals parameters were not used
in your custom function, then your declaraction should be:
/*ARGSUSED*/
VALUE
u_curds(char *name, int UNUSED count, VALUE UNUSED **vals)
c) The return value is the function must be a VALUE.
The typical way to form a VALUE to return is by declaring
the following local variable:
VALUE result; /* what we will return */
d) You will need to include:
#if defined(CUSTOM)
/* any #include <foobar.h> here */
#include "../have_const.h"
#include "../value.h"
#include "custom.h"
#include "../have_unused.h"
Typically these will be included just below any system
includes and just below the #if defined(CUSTOM) line.
To better understand the VALUE type, read:
../value.h
The VALUE is a union of major value types found inside calc.
The v_type VALUE element determines which union element is
being used. Assume that we have:
VALUE *vp;
Then the value is determined according to v_type:
vp->v_type the value is which is a type defined in
---------- ------------ ---------- ---------------
V_NULL (none) n/a n/a
V_INT vp->v_int long n/a
V_NUM vp->v_num NUMBER * ../qmath.h
V_COM vp->v_com COMPLEX * ../cmath.h
V_ADDR vp->v_addr VALUE * ../value.h
V_STR vp->v_str char * n/a
V_MAT vp->v_mat MATRIX * ../value.h
V_LIST vp->v_list LIST * ../value.h
V_ASSOC vp->v_assoc ASSOC * ../value.h
V_OBJ vp->v_obj OBJECT * ../value.h
V_FILE vp->v_file FILEID ../value.h
V_RAND vp->v_rand RAND * ../zrand.h
V_RANDOM vp->v_random RANDOM * ../zrandom.h
V_CONFIG vp->v_config CONFIG * ../config.h
V_HASH vp->v_hash HASH * ../hash.h
V_BLOCK vp->v_block BLOCK * ../block.h
The V_OCTET is under review and should not be used at this time.
There are a number of macros that may be used to determine
information about the numerical values (ZVALUE, NUMBER and COMPLEX).
you might also want to read the following to understand
some of the numerical types of ZVALUE, NUMBER and COMPLEX:
../zmath.h
../qmath.h
../cmath.h
While we cannot go into full detail here are some cookbook
code for manipulating VALUEs. For these examples assume
that we will manipulate the return value:
VALUE result; /* what we will return */
To return NULL:
result.v_type = V_NULL;
return result;
To return a long you need to convert it to a NUMBER:
long variable;
result.v_type = V_NUM;
result.v_num = itoq(variable); /* see ../qmath.c */
return result;
To return a FULL you need to convert it to a NUMBER:
FULL variable;
result.v_type = V_NUM;
result.v_num = utoq(variable); /* see ../qmath.c */
return result;
To convert a ZVALUE to a NUMBER*:
ZVALUE variable;
result.v_type = V_NUM;
result.v_num = qalloc(); /* see ../qmath.c */
result.v_num->num = variable;
return result;
To convert a small NUMBER* into a long:
NUMBER *num;
long variable;
variable = qtoi(num);
To obtain a ZVALUE from a NUMBER*, extract the numerator:
NUMBER *num;
ZVALUE z_variable;
if (qisint(num)) {
z_variable = num->num;
}
To be sure that the value will fit, use the ZVALUE test macros:
ZVALUE z_num;
long variable;
unsigned long u_variable;
FULL f_variable;
short very_tiny_variable;
if (zgtmaxlong(z_num)) { /* see ../zmath.h */
variable = ztolong(z_num);
}
if (zgtmaxulong(z_num)) {
u_variable = ztoulong(z_num);
}
if (zgtmaxufull(z_num)) {
f_variable = ztofull(z_num);
}
if (zistiny(z_num)) {
very_tiny_variable = z1tol(z_num);
}
You can (and should) add debugging statements to your custom code
by examining bit 8 of the calc_debug config flag:
if (conf->calc_debug & CALCDBG_CUSTOM) {
fprintf(stderr, "%ssome custom debug note: msg\n",
(conf->tab_ok ? "\t" : ""),
((msg == NULL) ? "((NULL))" : msg));
}
One is able to set bit 8 by way of the calc command line:
calc -D 128
See the calc man page for details. One may also set that bit
while running calc by way of the config() builtin function:
config("calc_debug", 128);
See the help/config file for details on calc_debug.
Step 6: Register the function in the custom interface table
To allow the custom() builtin to transfer control to your function,
you need to add an entry into the CONST struct custom cust table
found in custom/custtbl.c:
/*
* custom interface table
*
* The order of the elements in struct custom are:
*
* { "xyz", "brief description of the xyz custom function",
* minimum_args, maximum_args, c_xyz },
*
* where:
*
* minimum_args an int >= 0
* maximum_args an int >= minimum_args and <= MAX_CUSTOM_ARGS
*
* Use MAX_CUSTOM_ARGS for maximum_args is the maximum number of args
* is potentially 'unlimited'.
*
* If the brief description cannot fit on the same line as the name
* without wrapping on a 80 col window, the description is probably
* too long and will not look nice in the show custom output.
*/
CONST struct custom cust[] = {
#if defined(CUSTOM)
/*
* add your own custom functions here
*
* We suggest that you sort the entries below by name
* so that show custom will produce a nice sorted list.
*/
{ "argv", "information about its args, returns arg count",
0, MAX_CUSTOM_ARGS, c_argv },
{ "devnull", "does nothing",
0, MAX_CUSTOM_ARGS, c_devnull },
{ "help", "help for custom functions",
1, 1, c_help },
{ "sysinfo", "return a calc #define value",
0, 1, c_sysinfo },
#endif /* CUSTOM */
/*
* This must be at the end of this table!!!
*/
{NULL, NULL,
0, 0, NULL}
};
The definition of struct custom may be found in custom.h.
It is important that your entry be placed inside the:
#if defined(CUSTOM) ... #endif /* CUSTOM */
lines so that when the custom interface is disabled by the upper
level Makefile, one does not have unsatisfied symbols.
The brief description should be brief so that 'show custom' looks well
formatted. If the brief description cannot fit on the same line as
the name without wrapping on a 80 col window, the description is
probably too long and will not look nice in the show custom output.
The minargs places a lower bound on the number of args that
must be supplied to the interface. This does NOT count
the name argument given to custom(). So if minargs is 2:
custom("curds") /* call blocked at high level interface */
custom("curds", a) /* call blocked at high level interface */
custom("curds", a, b) /* call passed down to "curds" interface */
The maxargs sets a limit on the number of args that may be passed.
If minargs == maxargs, then the call requires a fixed number of
argument. There is a upper limit on the number of args. If
one wants an effectively unlimited upper bound, use MAX_CUSTOM_ARGS.
Note that one must have:
0 <= minargs <= maxargs <= MAX_CUSTOM_ARGS
To allow the curds function to take at least 2 args and up
to 5 args, one would add the following entry to cust[]:
{ "curds", "brief description about curds interface",
2, 5, u_curds },
It is recommended that the cust[] remain in alphabetical order,
so one would place it before the "devnull" and after "argv".
Last, you must forward declare the u_curds near the top of the file:
#if defined(CUSTOM)
/*
* add your forward custom function declarations here
*
* Declare custom functions as follows:
*
* E_FUNC VALUE c_xyz(char*, int, VALUE**);
*
* We suggest that you sort the entries below by name.
*/
E_FUNC VALUE c_argv(char*, int, VALUE**);
E_FUNC VALUE c_devnull(char*, int, VALUE**);
E_FUNC VALUE c_help(char*, int, VALUE**);
E_FUNC VALUE c_sysinfo(char*, int, VALUE**);
For u_curds we would add the line:
E_FUNC VALUE u_curds(char*, int, VALUE**);
Step 7: Add the required information to the custom/Makefile.head
The calc test script, curds.cal, should be added to the
CUSTOM_CALC_FILES Makefile variable found in custom/Makefile.head:
CUSTOM_CALC_FILES= argv.cal halflen.cal curds.cal
The help file, curds, should be added to the CUSTOM_HELP
custom/Makefile.head variable:
CUSTOM_HELP= argv devnull help sysinfo curds
If you needed to create any .h files to support u_curds.c, these
files should be added to the CUSTOM_H_SRC custom/Makefile.head variable:
CUSTOM_H_SRC= u_curds.h otherfile.h
Your u_curds.c file MUST be added to the CUSTOM_SRC custom/Makefile.head
variable:
CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c u_curds.c
and so must the associated .o file:
CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o u_curds.o
Step 8: Compile and link in your code
If your calc was not previously setup to compile custom code,
you should set it up now. The upper level Makefile (and
the custom Makefile) should have the following Makefile
variable defined:
ALLOW_CUSTOM= -DCUSTOM
It is recommended that you build your code from the top level
Makefile. It saves having to sync the other Makefile values.
To try and build the new libcustcalc.a that contains u_curds.c:
(cd ..; make custom/libcustcalc.a)
Fix any compile and syntax errors as needed. :-)
Once libcustcalc.a successfully builds, compile calc:
cd ..
make calc
And check to be sure that the regression test suite still
works without errors:
make check
Step 9: Add the Make dependency tools
You should probably add the dependency lines to the bottom of
the Makefile. Given the required include files, you will at least
have the following entries placed at the bottom of the Makefile:
u_curds.o: ../alloc.h
u_curds.o: ../block.h
u_curds.o: ../byteswap.h
u_curds.o: ../calcerr.h
u_curds.o: ../cmath.h
u_curds.o: ../config.h
u_curds.o: ../endian_calc.h
u_curds.o: ../hash.h
u_curds.o: ../have_const.h
u_curds.o: ../have_malloc.h
u_curds.o: ../have_newstr.h
u_curds.o: ../have_stdlib.h
u_curds.o: ../have_string.h
u_curds.o: ../longbits.h
u_curds.o: ../nametype.h
u_curds.o: ../qmath.h
u_curds.o: ../shs.h
u_curds.o: ../value.h
u_curds.o: ../zmath.h
u_curds.o: u_curds.c
u_curds.o: ../custom.h
If you have the makedepend tool from the X11 development environment
(by Todd Brunhoff, Tektronix, Inc. and MIT Project Athena), you can
use the following to update your dependencies:
# cd to the top level calc directory if you are not there already
rm -f Makefile.bak custom/Makefile.bak
make depend
diff -c Makefile.bak Makefile # look at the changes
diff -c custom/Makefile.bak custom/Makefile # look at the changes
rm -f Makefile.bak custom/Makefile.bak # cleanup
Step 10: Test
Now that you have built calc with your new custom function, test it:
./calc -C # run the new calc with the -C arg
And then try out our test suite:
C-style arbitrary precision calculator (version 2.10.3t5.1)
[Type "exit" to exit, or "help" for help.]
> read custom/curds.cal
curds(a, b, [c, d, e]) defined
> custom("curds", 2, 3, 4)
Step 11: Install
Once you are satisfied that everything works, install the new code:
# cd to the top level calc directory if you are not there already
make install
Although calc does not run setuid, you may need to be root to install
the directories into which calc installs may be write protected.
Step 12: Contribute
Your custom function may be of interest to some people and/or
serve as an example of what one can do with custom functions.
Read the file:
help/contrib (or run: calc help contrib)
and consider submitting your custom function for possible
inclusion in later versions of calc.
## Copyright (C) 1999-2007 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.4 $
## @(#) $Id: HOW_TO_ADD,v 30.4 2007/09/21 01:27:27 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/custom/RCS/HOW_TO_ADD,v $
##
## Under source code control: 1997/03/10 03:03:21
## File existed as early as: 1997
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* resource
*************
Calc standard resource files
----------------------------
To load a resource file, try:
read filename
You do not need to add the .cal extension to the filename. Calc
will search along the $CALCPATH (see ``help environment'').
Normally a resource file will simply define some functions. By default,
most resource files will print out a short message when they are read.
For example:
; read lucas
lucas(h,n) defined
gen_u0(h,n,v1) defined
gen_v1(h,n) defined
ldebug(funct,str) defined
will cause calc to load and execute the 'lucas.cal' resource file.
Executing the resource file will cause several functions to be defined.
Executing the lucas function:
; lucas(149,60)
1
; lucas(146,61)
0
shows that 149*2^60-1 is prime whereas 146*2^61-1 is not.
=-=
Calc resource file files are provided because they serve as examples of
how use the calc language, and/or because the authors thought them to
be useful!
If you write something that you think is useful, please join the
low volume calc mailing list calc-tester. Then send your contribution
to the calc-tester mailing list.
To subscribe to the calc-tester mailing list, visit the following URL:
https://www.listbox.com/subscribe/?list_id=239342
To help determine you are a human and not just a spam bot,
you will be required to provide the following additional info:
Your Name
Calc Version
Operating System
The date 7 days ago
This is a low volume moderated mailing list.
This mailing list replaces calc-tester at asthe dot com list.
If you need a human to help you with your mailing list subscription,
please send EMail to our special:
calc-tester-maillist-help at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
address. To be sure we see your EMail asking for help with your
mailing list subscription, please use the following phase in your
EMail Subject line:
calc tester mailing list help
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
=-=
By convention, a resource file only defines and/or initializes functions,
objects and variables. (The regress.cal and testxxx.cal regression test
suite is an exception.) Also by convention, an additional usage message
regarding important object and functions is printed.
If a resource file needs to load another resource file, it should use
the -once version of read:
/* pull in needed resource files */
read -once "surd"
read -once "lucas"
This will cause the needed resource files to be read once. If these
files have already been read, the read -once will act as a noop.
The "resource_debug" parameter is intended for controlling the possible
display of special information relating to functions, objects, and
other structures created by instructions in calc resource files.
Zero value of config("resource_debug") means that no such information
is displayed. For other values, the non-zero bits which currently
have meanings are as follows:
n Meaning of bit n of config("resource_debug")
0 When a function is defined, redefined or undefined at
interactive level, a message saying what has been done
is displayed.
1 When a function is defined, redefined or undefined during
the reading of a file, a message saying what has been done
is displayed.
2 Show func will display more information about a functions
arguments as well as more argument summary information.
3 During execution, allow calc standard resource files
to output additional debugging information.
The value for config("resource_debug") in both oldstd and newstd is 3,
but if calc is invoked with the -d flag, its initial value is zero.
Thus, if calc is started without the -d flag, until config("resource_debug")
is changed, a message will be output when a function is defined
either interactively or during the reading of a file.
Sometimes the information printed is not enough. In addition to the
standard information, one might want to print:
* useful obj definitions
* functions with optional args
* functions with optional args where the param() interface is used
For these cases we suggest that you place at the bottom of your code
something that prints extra information if config("resource_debug") has
either of the bottom 2 bits set:
if (config("resource_debug") & 3) {
print "obj xyz defined";
print "funcA([val1 [, val2]]) defined";
print "funcB(size, mass, ...) defined";
}
If your the resource file needs to output special debugging information,
we recommend that you check for bit 3 of the config("resource_debug")
before printing the debug statement:
if (config("resource_debug") & 8) {
print "DEBUG: This a sample debug statement";
}
=-=
The following is a brief description of some of the calc resource files
that are shipped with calc. See above for example of how to read in
and execute these files.
alg_config.cal
global test_time
mul_loop(repeat,x) defined
mul_ratio(len) defined
best_mul2() defined
sq_loop(repeat,x) defined
sq_ratio(len) defined
best_sq2() defined
pow_loop(repeat,x,ex) defined
pow_ratio(len) defined
best_pow2() defined
These functions search for an optimal value of config("mul2"),
config("sq2"), and config("pow2"). The calc default values of these
configuration values were set by running this resource file on a
1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS.
The best_mul2() function returns the optimal value of config("mul2").
The best_sq2() function returns the optimal value of config("sq2").
The best_pow2() function returns the optimal value of config("pow2").
The other functions are just support functions.
By design, best_mul2(), best_sq2(), and best_pow2() take a few
minutes to run. These functions increase the number of times a
given computational loop is executed until a minimum amount of CPU
time is consumed. To watch these functions progress, one can set
the config("user_debug") value.
Here is a suggested way to use this resource file:
; read alg_config
; config("user_debug",2),;
; best_mul2(); best_sq2(); best_pow2();
; best_mul2(); best_sq2(); best_pow2();
; best_mul2(); best_sq2(); best_pow2();
NOTE: It is perfectly normal for the optimal value returned to differ
slightly from run to run. Slight variations due to inaccuracy in
CPU timings will cause the best value returned to differ slightly
from run to run.
One can use a calc startup file to change the initial values of
config("mul2"), config("sq2"), and config("pow2"). For example one
can place into ~/.calcrc these lines:
config("mul2", 1780),;
config("sq2", 3388),;
config("pow2", 176),;
to automatically and silently change these config values.
See help/config and CALCRC in help/environment for more information.
beer.cal
This calc resource is calc's contribution to the 99 Bottles of Beer
web page:
http://www.ionet.net/~timtroyr/funhouse/beer.html#calc
NOTE: This resource produces a lot of output. :-)
bernoulli.cal
B(n)
Calculate the nth Bernoulli number.
NOTE: There is now a bernoulli() builtin function. This file is
left here for backward compatibility and now simply returns
the builtin function.
bernpoly.cal
bernpoly(n,z)
Computes the nth Bernoulli polynomial at z for arbitrary n,z. See:
http://en.wikipedia.org/wiki/Bernoulli_polynomials
http://mathworld.wolfram.com/BernoulliPolynomial.html
for further information
bigprime.cal
bigprime(a, m, p)
A prime test, base a, on p*2^x+1 for even x>m.
brentsolve.cal
brentsolve(low, high,eps)
A root-finder implementwed with the Brent-Dekker trick.
brentsolve2(low, high,which,eps)
The second function, brentsolve2(low, high,which,eps) has some lines
added to make it easier to hardcode the name of the helper function
different from the obligatory "f".
See:
http://en.wikipedia.org/wiki/Brent%27s_method
http://mathworld.wolfram.com/BrentsMethod.html
to find out more about the Brent-Dekker method.
constants.cal
e()
G()
An implementation of different constants to arbitrary precision.
chi.cal
Z(x[, eps])
P(x[, eps])
chi_prob(chi_sq, v[, eps])
Computes the Probability, given the Null Hypothesis, that a given
Chi squared values >= chi_sq with v degrees of freedom.
The chi_prob() function does not work well with odd degrees of freedom.
It is reasonable with even degrees of freedom, although one must give
a sufficiently small error term as the degrees gets large (>100).
The Z(x) and P(x) are internal statistical functions.
eps is an optional epsilon() like error term.
chrem.cal
chrem(r1,m1 [,r2,m2, ...])
chrem(rlist, mlist)
Chinese remainder theorem/problem solver.
deg.cal
deg(deg, min, sec)
deg_add(a, b)
deg_neg(a)
deg_sub(a, b)
deg_mul(a, b)
deg_print(a)
Calculate in degrees, minutes, and seconds. For a more functional
version see dms.cal.
dms.cal
dms(deg, min, sec)
dms_add(a, b)
dms_neg(a)
dms_sub(a, b)
dms_mul(a, b)
dms_print(a)
dms_abs(a)
dms_norm(a)
dms_test(a)
dms_int(a)
dms_frac(a)
dms_rel(a,b)
dms_cmp(a,b)
dms_inc(a)
dms_dec(a)
Calculate in degrees, minutes, and seconds. Unlike deg.cal, increments
are on the arc second level. See also hms.cal.
dotest.cal
dotest(dotest_file [,dotest_code [,dotest_maxcond]])
dotest_file
Search along CALCPATH for dotest_file, which contains lines that
should evaluate to 1. Comment lines and empty lines are ignored.
Comment lines should use ## instead of the multi like /* ... */
because lines are evaluated one line at a time.
dotest_code
Assign the code number that is to be printed at the start of
each non-error line and after **** in each error line.
The default code number is 999.
dotest_maxcond
The maximum number of error conditions that may be detected.
An error condition is not a sign of a problem, in some cases
a line deliberately forces an error condition. A value of -1,
the default, implies a maximum of 2147483647.
Global variables and functions must be declared ahead of time because
the dotest scope of evaluation is a line at a time. For example:
read dotest.cal
read set8700.cal
dotest("set8700.line");
factorial.cal
factorial(n)
Calculates the product of the positive integers up to and including n.
See:
http://en.wikipedia.org/wiki/Factorial
for information on the factorial. This function depends on the script
toomcook.cal.
primorial(a,b)
Calculates the product of the primes between a and b. If a is not prime
the next higher prime is taken as the starting point. If b is not prime
the next lower prime is taking as the end point b. The end point b must
not exceed 4294967291. See:
http://en.wikipedia.org/wiki/Primorial
for information on the primorial.
factorial2.cal
This file contents a small variety of integer functions that can, with
more or less pressure, be related to the factorial.
doublefactorial(n)
Calculates the double factorial n!! with different algorithms for
- n odd
- n even and positive
- n (real|complex) sans the negative half integers
See:
http://en.wikipedia.org/wiki/Double_factorial
http://mathworld.wolfram.com/DoubleFactorial.html
for information on the double factorial. This function depends on
the script toomcook.cal, factorial.cal and specialfunctions.cal.
binomial(n,k)
Calculates the binomial coefficients for n large and k = k \pm
n/2. Defaults to the built-in function for smaller and/or different
values. Meant as a complete replacement for comb(n,k) with only a
very small overhead. See:
http://en.wikipedia.org/wiki/Binomial_coefficient
for information on the binomial. This function depends on the script
toomcook.cal factorial.cal and specialfunctions.cal.
bigcatalan(n)
Calculates the n-th Catalan number for n large. It is usefull
above n~50,000 but defaults to the builtin function for smaller
values.Meant as a complete replacement for catalan(n) with only a
very small overhead. See:
http://en.wikipedia.org/wiki/Catalan_number
http://mathworld.wolfram.com/CatalanNumber.html
for information on Catalan numbers. This function depends on the scripts
toomcook.cal, factorial.cal and specialfunctions.cal.
stirling1(n,m)
Calculates the Stirling number of the first kind. It does so with
building a list of all of the smaller results. It might be a good
idea, though, to run it once for the highest n,m first if many
Stirling numbers are needed at once, for example in a series. See:
http://en.wikipedia.org/wiki/Stirling_numbers_of_the_first_kind
http://mathworld.wolfram.com/StirlingNumberoftheFirstKind.html
Algorithm 3.17, Donald Kreher and Douglas Simpson, "Combinatorial
Algorithms", CRC Press, 1998, page 89.
for information on Stirling numbers of the first kind.
stirling2(n,m)
stirling2caching(n,m)
Calculate the Stirling number of the second kind.
The first function stirling2(n,m) does it with the sum
m
====
1 \ n m - k
-- > k (- 1) binomial(m, k)
m! /
====
k = 0
The other function stirling2caching(n,m) does it by way of the
reccurence relation and keeps all earlier results. This function
is much slower for computing a single value than stirling2(n,m) but
is very usefull if many Stirling numbers are needed, for example in
a series. See:
http://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind
http://mathworld.wolfram.com/StirlingNumberoftheSecondKind.html
Algorithm 3.17, Donald Kreher and Douglas Simpson, "Combinatorial
Algorithms", CRC Press, 1998, page 89.
for information on Stirling numbers of the second kind.
bell(n)
Calculate the n-th Bell number. This may take some time for large n.
See:
http://oeis.org/A000110
http://en.wikipedia.org/wiki/Bell_number
http://mathworld.wolfram.com/BellNumber.html
for information on Bell numbers.
subfactorial(n)
Calculate the n-th subfactorial or derangement. This may take some
time for large n. See:
http://mathworld.wolfram.com/Derangement.html
http://en.wikipedia.org/wiki/Derangement
for information on subfactorials.
risingfactorial(x,n)
Calculates the rising factorial or Pochammer symbol of almost arbitrary
x,n. See:
http://en.wikipedia.org/wiki/Pochhammer_symbol
http://mathworld.wolfram.com/PochhammerSymbol.html
for information on rising factorials.
fallingfactorial(x,n)
Calculates the rising factorial of almost arbitrary x,n. See:
http://en.wikipedia.org/wiki/Pochhammer_symbol
http://mathworld.wolfram.com/PochhammerSymbol.html
for information on falling factorials.
ellip.cal
efactor(iN, ia, B, force)
Attempt to factor using the elliptic functions: y^2 = x^3 + a*x + b.
gvec.cal
gvec(function, vector)
Vectorize any single-input function or trailing operator.
hello.cal
Calc's contribution to the Hello World! page:
http://www.latech.edu/~acm/HelloWorld.shtml
http://www.latech.edu/~acm/helloworld/calc.html
NOTE: This resource produces a lot of output. :-)
hms.cal
hms(hour, min, sec)
hms_add(a, b)
hms_neg(a)
hms_sub(a, b)
hms_mul(a, b)
hms_print(a)
hms_abs(a)
hms_norm(a)
hms_test(a)
hms_int(a)
hms_frac(a)
hms_rel(a,b)
hms_cmp(a,b)
hms_inc(a)
hms_dec(a)
Calculate in hours, minutes, and seconds. See also dmscal.
infinities.cal
isinfinite(x)
iscinf(x)
ispinf(x)
isninf(x)
cinf()
ninf()
pinf()
The symbolic handling of infinities. Needed for intnum.cal but might be
usefull elsewhere, too.
intfile.cal
file2be(filename)
Read filename and return an integer that is built from the
octets in that file in Big Endian order. The first octets
of the file become the most significant bits of the integer.
file2le(filename)
Read filename and return an integer that is built from the
octets in that file in Little Endian order. The first octets
of the file become the most significant bits of the integer.
be2file(v, filename)
Write the absolute value of v into filename in Big Endian order.
The v argument must be on integer. The most significant bits
of the integer become the first octets of the file.
le2file(v, filename)
Write the absolute value of v into filename in Little Endian order.
The v argument must be on integer. The least significant bits
of the integer become the last octets of the file.
intnum.cal
quadtsdeletenodes()
quadtscomputenodes(order, expo, eps)
quadtscore(a, b, n)
quadts(a, b, points)
quadglcomputenodes(N)
quadgldeletenodes()
quadglcore(a, b, n)
quadgl(a, b, points)
quad(a, b, points = -1, method = "tanhsinh")
makerange(start, end, steps)
makecircle(radius, center, points)
makeellipse(angle, a, b, center, points)
makepoints()
This file offers some methods for numerical integration. Implemented are
the Gauss-Legendre and the tanh-sinh quadrature.
All functions are usefull to some extend but the main function for
quadrature is quad(), which is not much more than an abstraction layer.
The main workers are quadgl() for Gauss-legendre and quadts() for the
tanh-sinh quadrature. The limits of the integral can be anything in the
complex plane and the extended real line. The latter means that infinite
limits are supported by way of the smbolic infinities implemented in the
file infinities.cal (automatically linked in by intnum.cal).
Integration in parts and contour is supported by the "points" argument
which takes either a number or a list. the functions starting with "make"
allow for a less error prone use.
The function to evaluate must have the name "f".
Examples (shamelessly stolen from mpmath):
; define f(x){return sin(x);}
f(x) defined
; quadts(0,pi()) - 2
0.00000000000000000000
; quadgl(0,pi()) - 2
0.00000000000000000000
Sometimes rounding errors accumulate, it might be a good idea to crank up
the working precision a notch or two.
; define f(x){ return exp(-x^2);}
f(x) redefined
; quadts(0,pinf()) - pi()
0.00000000000000000000
; quadgl(0,pinf()) - pi()
0.00000000000000000001
; define f(x){ return exp(-x^2);}
f(x) redefined
; quadgl(ninf(),pinf()) - sqrt(pi())
0.00000000000000000000
; quadts(ninf(),pinf()) - sqrt(pi())
-0.00000000000000000000
Using the "points" parameter is a bit tricky
; define f(x){ return 1/x; }
f(x) redefined
; quadts(1,1,mat[3]={1i,-1,-1i}) - 2i*pi()
0.00000000000000000001i
; quadgl(1,1,mat[3]={1i,-1,-1i}) - 2i*pi()
0.00000000000000000001i
The make* functions make it a bit simpler
; quadts(1,1,makepoints(1i,-1,-1i)) - 2i*pi()
0.00000000000000000001i
; quadgl(1,1,makepoints(1i,-1,-1i)) - 2i*pi()
0.00000000000000000001i
; define f(x){ return abs(sin(x));}
f(x) redefined
; quadts(0,2*pi(),makepoints(pi())) - 4
0.00000000000000000000
; quadgl(0,2*pi(),makepoints(pi())) - 4
0.00000000000000000000
The quad*core functions do not offer anything fancy but the third parameter
controls the so called "order" which is just the number of nodes computed.
This can be quite usefull in some circumstances.
; quadgldeletenodes()
; define f(x){ return exp(x);}
f(x) redefined
; s=usertime();quadglcore(-3,3)- (exp(3)-exp(-3));e=usertime();e-s
0.00000000000000000001
2.632164
; s=usertime();quadglcore(-3,3)- (exp(3)-exp(-3));e=usertime();e-s
0.00000000000000000001
0.016001
; quadgldeletenodes()
; s=usertime();quadglcore(-3,3,14)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000000
0.024001
; s=usertime();quadglcore(-3,3,14)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000000
0
It is not much but can sum up. The tanh-sinh algorithm is not optimizable
as much as the Gauss-Legendre algorithm but is per se much faster.
; s=usertime();quadtscore(-3,3)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000001
0.128008
; s=usertime();quadtscore(-3,3)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000001
0.036002
; s=usertime();quadtscore(-3,3,49)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000000
0.036002
; s=usertime();quadtscore(-3,3,49)- (exp(3)-exp(-3));e=usertime();e-s
-0.00000000000000000000
0.01200
lambertw.cal
lambertw(z,branch)
Computes Lambert's W-function at "z" at branch "branch". See
http://en.wikipedia.org/wiki/Lambert_W_function
http://mathworld.wolfram.com/LambertW-Function.html
https://cs.uwaterloo.ca/research/tr/1993/03/W.pdf
http://arxiv.org/abs/1003.1628
to get more information.
This file includes also an implementation for the series described in
Corless et al. (1996) eq. 4.22 (W-pdf) and Verebic (2010) (arxive link)
eqs.35-37.
The series has been implemented to get a different algorithm
for checking the results. This was necessary because the results
of the implementation in Maxima, the only program with a general
lambert-w implementation at hand at that time, differed slightly. The
Maxima versions tested were: Maxima 5.21.1 and 5.29.1. The current
version of this code concurs with the results of Mathematica`s(tm)
ProductLog[branch,z] with the tested values.
The series is only valid for the branches 0,-1, real z, converges
for values of z _very_ near the branchpoint -exp(-1) only, and must
be given the branches explicitly. See the code in lambertw.cal
for further information.
linear.cal
linear(x0, y0, x1, y1, x)
Returns the value y such that (x,y) in on the line (x0,y0), (x1,y1).
Requires x0 != y0.
lnseries.cal
lnseries(limit)
lnfromseries(n)
deletelnseries()
Calculates a series of n natural logarithms at 1,2,3,4...n. It
does so by computing the prime factorization of all of the number
sequence 1,2,3...n, calculates the natural logarithms of the primes
in 1,2,3...n and uses the above factorization to build the natural
logarithms of the rest of the sequence by sadding the logarithms of
the primes in the factorization. This is faster for high precision
of the logarithms and/or long sequences.
The sequence need to be initiated by running either lnseries(n) or
lnfromseries(n) once with n the upper limit of the sequence.
lucas.cal
lucas(h, n)
Perform a primality test of h*2^n-1, with 1<=h<2*n.
lucas_chk.cal
lucas_chk(high_n)
Test all primes of the form h*2^n-1, with 1<=h<200 and n <= high_n.
Requires lucas.cal to be loaded. The highest useful high_n is 1000.
Used by regress.cal during the 2100 test set.
lucas_tbl.cal
Lucasian criteria for primality tables.
mersenne.cal
mersenne(p)
Perform a primality test of 2^p-1, for prime p>1.
mfactor.cal
mfactor(n [, start_k=1 [, rept_loop=10000 [, p_elim=17]]])
Return the lowest factor of 2^n-1, for n > 0. Starts looking for factors
at 2*start_k*n+1. Skips values that are multiples of primes <= p_elim.
By default, start_k == 1, rept_loop = 10000 and p_elim = 17.
The p_elim == 17 overhead takes ~3 minutes on an 200 Mhz r4k CPU and
requires about ~13 Megs of memory. The p_elim == 13 overhead
takes about 3 seconds and requires ~1.5 Megs of memory.
The value p_elim == 17 is best for long factorizations. It is the
fastest even thought the initial startup overhead is larger than
for p_elim == 13.
mod.cal
lmod(a)
mod_print(a)
mod_one()
mod_cmp(a, b)
mod_rel(a, b)
mod_add(a, b)
mod_sub(a, b)
mod_neg(a)
mod_mul(a, b)
mod_square(a)
mod_inc(a)
mod_dec(a)
mod_inv(a)
mod_div(a, b)
mod_pow(a, b)
Routines to handle numbers modulo a specified number.
natnumset.cal
isset(a)
setbound(n)
empty()
full()
isin(a, b)
addmember(a, n)
rmmember(a, n)
set()
mkset(s)
primes(a, b)
set_max(a)
set_min(a)
set_not(a)
set_cmp(a, b)
set_rel(a, b)
set_or(a, b)
set_and(a, b)
set_comp(a)
set_setminus(a, b)
set_diff(a,b)
set_content(a)
set_add(a, b)
set_sub(a, b)
set_mul(a, b)
set_square(a)
set_pow(a, n)
set_sum(a)
set_plus(a)
interval(a, b)
isinterval(a)
set_mod(a, b)
randset(n, a, b)
polyvals(L, A)
polyvals2(L, A, B)
set_print(a)
Demonstration of how the string operators and functions may be used
for defining and working with sets of natural numbers not exceeding a
user-specified bound.
pell.cal
pellx(D)
pell(D)
Solve Pell's equation; Returns the solution X to: X^2 - D * Y^2 = 1.
Type the solution to Pell's equation for a particular D.
pi.cal
qpi(epsilon)
piforever()
The qpi() calculate pi within the specified epsilon using the quartic
convergence iteration.
The piforever() prints digits of pi, nicely formatted, for as long
as your free memory space and system up time allows.
The piforever() function (written by Klaus Alexander Seistrup
<klaus@seistrup.dk>) was inspired by an algorithm conceived by
Lambert Meertens. See also the ABC Programmer's Handbook, by Geurts,
Meertens & Pemberton, published by Prentice-Hall (UK) Ltd., 1990.
pix.cal
pi_of_x(x)
Calculate the number of primes < x using A(n+1)=A(n-1)+A(n-2). This
is a SLOW painful method ... the builtin pix(x) is much faster.
Still, this method is interesting.
pollard.cal
pfactor(N, N, ai, af)
Factor using Pollard's p-1 method.
poly.cal
Calculate with polynomials of one variable. There are many functions.
Read the documentation in the resource file.
prompt.cal
adder()
showvalues(str)
Demonstration of some uses of prompt() and eval().
psqrt.cal
psqrt(u, p)
Calculate square roots modulo a prime
qtime.cal
qtime(utc_hr_offset)
Print the time as English sentence given the hours offset from UTC.
quat.cal
quat(a, b, c, d)
quat_print(a)
quat_norm(a)
quat_abs(a, e)
quat_conj(a)
quat_add(a, b)
quat_sub(a, b)
quat_inc(a)
quat_dec(a)
quat_neg(a)
quat_mul(a, b)
quat_div(a, b)
quat_inv(a)
quat_scale(a, b)
quat_shift(a, b)
Calculate using quaternions of the form: a + bi + cj + dk. In these
functions, quaternions are manipulated in the form: s + v, where
s is a scalar and v is a vector of size 3.
randbitrun.cal
randbitrun([run_cnt])
Using randbit(1) to generate a sequence of random bits, determine if
the number and length of identical bits runs match what is expected.
By default, run_cnt is to test the next 65536 random values.
This tests the a55 generator.
randmprime.cal
randmprime(bits, seed [,dbg])
Find a prime of the form h*2^n-1 >= 2^bits for some given x. The
initial search points for 'h' and 'n' are selected by a cryptographic
pseudo-random number generator. The optional argument, dbg, if set
to 1, 2 or 3 turn on various debugging print statements.
randombitrun.cal
randombitrun([run_cnt])
Using randombit(1) to generate a sequence of random bits, determine if
the number and length of identical bits runs match what is expected.
By default, run_cnt is to test the next 65536 random values.
This tests the Blum-Blum-Shub generator.
randomrun.cal
randomrun([run_cnt])
Perform the "G. Run test" (pp. 65-68) as found in Knuth's "Art of
Computer Programming - 2nd edition", Volume 2, Section 3.3.2 on
the builtin rand() function. This function will generate run_cnt
64 bit values. By default, run_cnt is to test the next 65536
random values.
This tests the Blum-Blum-Shub generator.
randrun.cal
randrun([run_cnt])
Perform the "G. Run test" (pp. 65-68) as found in Knuth's "Art of
Computer Programming - 2nd edition", Volume 2, Section 3.3.2 on
the builtin rand() function. This function will generate run_cnt
64 bit values. By default, run_cnt is to test the next 65536
random values.
This tests the a55 generator.
repeat.cal
repeat(digit_set, repeat_count)
Return the value of the digit_set repeated repeat_count times.
Both digit_set and repeat_count must be integers > 0.
For example repeat(423,5) returns the value 423423423423423,
which is the digit_set 423 repeated 5 times.
regress.cal
Test the correct execution of the calculator by reading this resource
file. Errors are reported with '****' messages, or worse. :-)
screen.cal
up
CUU /* same as up */
down = CUD
CUD /* same as down */
forward
CUF /* same as forward */
back = CUB
CUB /* same as back */
save
SCP /* same as save */
restore
RCP /* same as restore */
cls
home
eraseline
off
bold
faint
italic
blink
rapidblink
reverse
concealed
/* Lowercase indicates foreground, uppercase background */
black
red
green
yellow
blue
magenta
cyan
white
Black
Red
Green
Yellow
Blue
Magenta
Cyan
White
Define ANSI control sequences providing (i.e., cursor movement,
changing foreground or background color, etc.) for VT100 terminals
and terminal window emulators (i.e., xterm, Apple OS/X Terminal,
etc.) that support them.
For example:
read screen
print green:"This is green. ":red:"This is red.":black
seedrandom.cal
seedrandom(seed1, seed2, bitsize [,trials])
Given:
seed1 - a large random value (at least 10^20 and perhaps < 10^93)
seed2 - a large random value (at least 10^20 and perhaps < 10^93)
size - min Blum modulus as a power of 2 (at least 100, perhaps > 1024)
trials - number of ptest() trials (default 25) (optional arg)
Returns:
the previous random state
Seed the cryptographically strong Blum generator. This functions allows
one to use the raw srandom() without the burden of finding appropriate
Blum primes for the modulus.
set8700.cal
set8700_getA1() defined
set8700_getA2() defined
set8700_getvar() defined
set8700_f(set8700_x) defined
set8700_g(set8700_x) defined
Declare globals and define functions needed by dotest() (see
dotest.cal) to evaluate set8700.line a line at a time.
set8700.line
A line-by-line evaluation file for dotest() (see dotest.cal).
The set8700.cal file (and dotest.cal) should be read first.
smallfactors.cal
smallfactors(x0)
printsmallfactors(flist)
Lists the prime factors of numbers smaller than 2^32. Try for example:
printsmallfactors(smallfactors(10!)).
solve.cal
solve(low, high, epsilon)
Solve the equation f(x) = 0 to within the desired error value for x.
The function 'f' must be defined outside of this routine, and the
low and high values are guesses which must produce values with
opposite signs.
specialfunctions.cal
beta(a,b)
Calculates the value of the beta function. See:
https://en.wikipedia.org/wiki/Beta_function
http://mathworld.wolfram.com/BetaFunction.html
http://dlmf.nist.gov/5.12
for information on the beta function.
betainc(a,b,z)
Calculates the value of the regularized incomplete beta function. See:
https://en.wikipedia.org/wiki/Beta_function
http://mathworld.wolfram.com/RegularizedBetaFunction.html
http://dlmf.nist.gov/8.17
for information on the regularized incomplete beta function.
expoint(z)
Calculates the value of the exponential integral Ei(z) function at z.
See:
http://en.wikipedia.org/wiki/Exponential_integral
http://www.cs.utah.edu/~vpegorar/research/2011_JGT/
for information on the exponential integral Ei(z) function.
erf(z)
Calculates the value of the error function at z. See:
http://en.wikipedia.org/wiki/Error_function
for information on the error function function.
erfc(z)
Calculates the value of the complementary error function at z. See:
http://en.wikipedia.org/wiki/Error_function
for information on the complementary error function function.
erfi(z)
Calculates the value of the imaginary error function at z. See:
http://en.wikipedia.org/wiki/Error_function
for information on the imaginary error function function.
erfinv(x)
Calculates the inverse of the error function at x. See:
http://en.wikipedia.org/wiki/Error_function
for information on the inverse of the error function function.
faddeeva(z)
Calculates the value of the complex error function at z. See:
http://en.wikipedia.org/wiki/Faddeeva_function
for information on the complex error function function.
gamma(z)
Calculates the value of the Euler gamma function at z. See:
http://en.wikipedia.org/wiki/Gamma_function
http://dlmf.nist.gov/5
for information on the Euler gamma function.
gammainc(a,z)
Calculates the value of the lower incomplete gamma function for
arbitrary a, z. See:
http://en.wikipedia.org/wiki/Incomplete_gamma_function
for information on the lower incomplete gamma function.
gammap(a,z)
Calculates the value of the regularized lower incomplete gamma
function for a, z with a not in -N. See:
http://en.wikipedia.org/wiki/Incomplete_gamma_function
for information on the regularized lower incomplete gamma function.
gammaq(a,z)
Calculates the value of the regularized upper incomplete gamma
function for a, z with a not in -N. See:
http://en.wikipedia.org/wiki/Incomplete_gamma_function
for information on the regularized upper incomplete gamma function.
heavisidestep(x)
Computes the Heaviside stepp function (1+sign(x))/2
harmonic(limit)
Calculates partial values of the harmonic series up to limit. See:
http://en.wikipedia.org/wiki/Harmonic_series_(mathematics)
http://mathworld.wolfram.com/HarmonicSeries.html
for information on the harmonic series.
lnbeta(a,b)
Calculates the natural logarithm of the beta function. See:
https://en.wikipedia.org/wiki/Beta_function
http://mathworld.wolfram.com/BetaFunction.html
http://dlmf.nist.gov/5.12
for information on the beta function.
lngamma(z)
Calculates the value of the logarithm of the Euler gamma function
at z. See:
http://en.wikipedia.org/wiki/Gamma_function
http://dlmf.nist.gov/5.15
for information on the derivatives of the the Euler gamma function.
polygamma(m,z)
Calculates the value of the m-th derivative of the Euler gamma
function at z. See:
http://en.wikipedia.org/wiki/Polygamma
http://dlmf.nist.gov/5
for information on the n-th derivative ofthe Euler gamma function. This
function depends on the script zeta2.cal.
psi(z)
Calculates the value of the first derivative of the Euler gamma
function at z. See:
http://en.wikipedia.org/wiki/Digamma_function
http://dlmf.nist.gov/5
for information on the first derivative of the Euler gamma function.
zeta(s)
Calculates the value of the Rieman Zeta function at s. See:
http://en.wikipedia.org/wiki/Riemann_zeta_function
http://dlmf.nist.gov/25.2
for information on the Riemann zeta function. This function depends
on the script zeta2.cal.
statistics.cal
gammaincoctave(z,a)
Computes the regularized incomplete gamma function in a way to
correspond with the function in Octave.
invbetainc(x,a,b)
Computes the inverse of the regularized beta function. Does so the
brute-force way wich makes it a bit slower.
betapdf(x,a,b)
betacdf(x,a,b)
betacdfinv(x,a,b)
betamedian(a,b)
betamode(a,b)
betavariance(a,b)
betalnvariance(a,b)
betaskewness(a,b)
betakurtosis(a,b)
betaentropy(a,b)
normalpdf(x,mu,sigma)
normalcdf(x,mu,sigma)
probit(p)
normalcdfinv(p,mu,sigma)
normalmean(mu,sigma)
normalmedian(mu,sigma)
normalmode(mu,sigma)
normalvariance(mu,sigma)
normalskewness(mu,sigma)
normalkurtosis(mu,sigma)
normalentropy(mu,sigma)
normalmgf(mu,sigma,t)
normalcf(mu,sigma,t)
chisquaredpdf(x,k)
chisquaredpcdf(x,k)
chisquaredmean(x,k)
chisquaredmedian(x,k)
chisquaredmode(x,k)
chisquaredvariance(x,k)
chisquaredskewness(x,k)
chisquaredkurtosis(x,k)
chisquaredentropy(x,k)
chisquaredmfg(k,t)
chisquaredcf(k,t)
Calculates a bunch of (hopefully) aptly named statistical functions.
strings.cal
isascii(c)
isblank(c)
Implements some of the functions of libc's ctype.h and strings.h.
NOTE: A number of the ctype.h and strings.h functions are now builtin
functions in calc.
WARNING: If the remaining functions in this calc resource file become
calc builtin functions, then strings.cal may be removed in
a future release.
sumsq.cal
ss(p)
Determine the unique two positive integers whose squares sum to the
specified prime. This is always possible for all primes of the form
4N+1, and always impossible for primes of the form 4N-1.
sumtimes.cal
timematsum(N)
timelistsum(N)
timematsort(N)
timelistsort(N)
timematreverse(N)
timelistreverse(N)
timematssq(N)
timelistssq(N)
timehmean(N,M)
doalltimes(N)
Give the user CPU time for various ways of evaluating sums, sums of
squares, etc, for large lists and matrices. N is the size of
the list or matrix to use. The doalltimes() function will run
all fo the sumtimes tests. For example:
doalltimes(1e6);
surd.cal
surd(a, b)
surd_print(a)
surd_conj(a)
surd_norm(a)
surd_value(a, xepsilon)
surd_add(a, b)
surd_sub(a, b)
surd_inc(a)
surd_dec(a)
surd_neg(a)
surd_mul(a, b)
surd_square(a)
surd_scale(a, b)
surd_shift(a, b)
surd_div(a, b)
surd_inv(a)
surd_sgn(a)
surd_cmp(a, b)
surd_rel(a, b)
Calculate using quadratic surds of the form: a + b * sqrt(D).
test1700.cal
value
This resource files is used by regress.cal to test the read and
use keywords.
test2600.cal
global defaultverbose
global err
testismult(str, n, verbose)
testsqrt(str, n, eps, verbose)
testexp(str, n, eps, verbose)
testln(str, n, eps, verbose)
testpower(str, n, b, eps, verbose)
testgcd(str, n, verbose)
cpow(x, n, eps)
cexp(x, eps)
cln(x, eps)
mkreal()
mkcomplex()
mkbigreal()
mksmallreal()
testappr(str, n, verbose)
checkappr(x, y, z, verbose)
checkresult(x, y, z, a)
test2600(verbose, tnum)
This resource files is used by regress.cal to test some of builtin
functions in terms of accuracy and roundoff.
test2700.cal
global defaultverbose
mknonnegreal()
mkposreal()
mkreal_2700()
mknonzeroreal()
mkposfrac()
mkfrac()
mksquarereal()
mknonsquarereal()
mkcomplex_2700()
testcsqrt(str, n, verbose)
checksqrt(x, y, z, v)
checkavrem(A, B, X, eps)
checkrounding(s, n, t, u, z)
iscomsq(x)
test2700(verbose, tnum)
This resource files is used by regress.cal to test sqrt() for real and
complex values.
test3100.cal
obj res
global md
res_test(a)
res_sub(a, b)
res_mul(a, b)
res_neg(a)
res_inv(a)
res(x)
This resource file is used by regress.cal to test determinants of
a matrix.
test3300.cal
global defaultverbose
global err
testi(str, n, N, verbose)
testr(str, n, N, verbose)
test3300(verbose, tnum)
This resource file is used by regress.cal to provide for more
determinant tests.
test3400.cal
global defaultverbose
global err
test1(str, n, eps, verbose)
test2(str, n, eps, verbose)
test3(str, n, eps, verbose)
test4(str, n, eps, verbose)
test5(str, n, eps, verbose)
test6(str, n, eps, verbose)
test3400(verbose, tnum)
This resource file is used by regress.cal to test trig functions.
containing objects.
test3500.cal
global defaultverbose
global err
testfrem(x, y, verbose)
testgcdrem(x, y, verbose)
testf(str, n, verbose)
testg(str, n, verbose)
testh(str, n, N, verbose)
test3500(verbose, n, N)
This resource file is used by regress.cal to test the functions frem,
fcnt, gcdrem.
test4000.cal
global defaultverbose
global err
global BASEB
global BASE
global COUNT
global SKIP
global RESIDUE
global MODULUS
global K1
global H1
global K2
global H2
global K3
global H3
plen(N) defined
rlen(N) defined
clen(N) defined
ptimes(str, N, n, count, skip, verbose) defined
ctimes(str, N, n, count, skip, verbose) defined
crtimes(str, a, b, n, count, skip, verbose) defined
ntimes(str, N, n, count, skip, residue, mod, verbose) defined
testnextcand(str, N, n, cnt, skip, res, mod, verbose) defined
testnext1(x, y, count, skip, residue, modulus) defined
testprevcand(str, N, n, cnt, skip, res, mod, verbose) defined
testprev1(x, y, count, skip, residue, modulus) defined
test4000(verbose, tnum) defined
This resource file is used by regress.cal to test ptest, nextcand and
prevcand builtins.
test4100.cal
global defaultverbose
global err
global K1
global K2
global BASEB
global BASE
rlen_4100(N) defined
olen(N) defined
test1(x, y, m, k, z1, z2) defined
testall(str, n, N, M, verbose) defined
times(str, N, n, verbose) defined
powtimes(str, N1, N2, n, verbose) defined
inittimes(str, N, n, verbose) defined
test4100(verbose, tnum) defined
This resource file is used by regress.cal to test REDC operations.
test4600.cal
stest(str [, verbose]) defined
ttest([m, [n [,verbose]]]) defined
sprint(x) defined
findline(f,s) defined
findlineold(f,s) defined
test4600(verbose, tnum) defined
This resource file is used by regress.cal to test searching in files.
test5100.cal
global a5100
global b5100
test5100(x) defined
This resource file is used by regress.cal to test the new code generator
declaration scope and order.
test5200.cal
global a5200
static a5200
f5200(x) defined
g5200(x) defined
h5200(x) defined
This resource file is used by regress.cal to test the fix of a
global/static bug.
test8400.cal
test8400() defined
This resource file is used by regress.cal to check for quit-based
memory leaks.
test8500.cal
global err_8500
global L_8500
global ver_8500
global old_seed_8500
global cfg_8500
onetest_8500(a,b,rnd) defined
divmod_8500(N, M1, M2, testnum) defined
This resource file is used by regress.cal to the // and % operators.
test8600.cal
global min_8600
global max_8600
global hash_8600
global hmean_8600
This resource file is used by regress.cal to test a change of
allowing up to 1024 args to be passed to a builtin function.
test8900.cal
This function tests a number of calc resource functions contributed
by Christoph Zurnieden. These include:
bernpoly.cal
brentsolve.cal
constants.cal
factorial2.cal
factorial.cal
lambertw.cal
lnseries.cal
specialfunctions.cal
statistics.cal
toomcook.cal
zeta2.cal
unitfrac.cal
unitfrac(x)
Represent a fraction as sum of distinct unit fractions.
toomcook.cal
toomcook3(a,b)
toomcook4(a,b)
Toom-Cook multiplication algorithm. Multiply two integers a,b by
way of the Toom-Cook algorithm. See:
http://en.wikipedia.org/wiki/Toom%E2%80%93Cook_multiplication
toomcook3square(a)
toomcook4square(a)
Square the integer a by way of the Toom-Cook algorithm. See:
http://en.wikipedia.org/wiki/Toom%E2%80%93Cook_multiplication
The function toomCook4(a,b) calls the function toomCook3(a,b) which
calls built-in multiplication at a specific cut-off point. The
squaring functions act in the same way.
varargs.cal
sc(a, b, ...)
Example program to use 'varargs'. Program to sum the cubes of all
the specified numbers.
xx_print.cal
is_octet(a) defined
list_print(a) defined
mat_print (a) defined
octet_print(a) defined
blk_print(a) defined
nblk_print (a) defined
strchar(a) defined
file_print(a) defined
error_print(a) defined
Demo for the xx_print object routines.
zeta2.cal
hurwitzzeta(s,a)
Calculate the value of the Hurwitz Zeta function. See:
http://en.wikipedia.org/wiki/Hurwitz_zeta_function
http://dlmf.nist.gov/25.11
for information on this special zeta function.
## Copyright (C) 2000,2014 David I. Bell and Landon Curt Noll
##
## Primary author: Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.9 $
## @(#) $Id: README,v 30.9 2014/10/06 08:44:18 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/cal/RCS/README,v $
##
## Under source code control: 1990/02/15 01:50:32
## File existed as early as: before 1990
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* archive
*************
Where to get the latest versions of calc
Landon Noll maintains the official calc home page at:
http://www.isthe.com/chongo/tech/comp/calc/
See:
http://www.isthe.com/chongo/tech/comp/calc/calc-download.html
for information on how to obtain up a recent version of calc.
Landon Curt Noll
http://www.isthe.com/chongo/
chongo <was here> /\../\
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.2 $
## @(#) $Id: archive,v 30.2 2013/08/11 01:08:32 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/archive,v $
##
## Under source code control: 1996/06/13 02:51:48
## File existed as early as: 1996
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* bugs
*************
If you notice something wrong, strange or broken, try rereading:
README.FIRST
HOWTO.INSTALL
BUGS (this file)
If that does not help, cd to the calc source directory and try:
make check
Look at the end of the output, it should say something like:
9998: passed all tests /\../\
9999: Ending regression tests
If it does not, then something is really broken!
If you made and modifications to calc beyond the simple Makefile
configuration, try backing them out and see if things get better.
To be sure that your version of calc is up to date, check out:
http://www.isthe.com/chongo/tech/comp/calc/calc-download.html
The calc web site is located at:
http://www.isthe.com/chongo/tech/comp/calc/index.html
=-=
If you have tried all of the above and things still are not right,
then it may be time to send in a bug report. You can send bug
and bug fixes reports to:
calc-bug-report at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
This replaces the old calc-bugs at asthe dot com address.
To be sure we see your EMail reporting a calc bug, please use the
following phase in your EMail Subject line:
calc bug report
That phrase in your subject line will help ensure your request
will get past our anti-spam filters. You may have additional
words in your subject line.
However, you may find it more helpful to simply subscribe
to the calc-tester mailing list (see below) and then to
send your report to that mailing list as a wider set calc
testers may be able to help you.
When you send your report, please include the following information:
* a description of the problem
* the version of calc you are using (if you cannot get calc
to run, then send us the 4 #define lines from version.c)
* if you modified calc from an official patch, send me the mods you made
* the type of system you were using
* the type of compiler you were using
* any compiler warnings or errors that you saw
* cd to the calc source directory, and type:
make debug > debug.out 2>&1 (sh, ksh, bash users)
make debug >& debug.out (csh, tcsh users)
and send the contents of the 'debug.out' file.
Stack traces from core dumps are useful to send as well.
Fell free to use the above address to send in big fixes (in the form
of a context diff patch).
=-=
Known bugs:
The output of the alg_config.cal resource file is bogus.
We would welcome a replacement for this code.
We are sure some more bugs exist. When you find them, please let
us know! See the above for details on how to report and were to
EMail your bug reports and hopefully patches to fix them.
=-=
mis-features in calc:
Some problems are not bugs but rather mis-features / things that could
work better. The following is a list of mis-features that should be
addressed and improved someday.
* When statement is of the form { ... }, the leading { MUST BE ON
THE SAME LINE as the if, for, while or do keyword.
This works as expected:
if (expr) {
...
}
However this WILL NOT WORK AS EXPECTED:
if (expr)
{
...
}
This needs to be changed. See also "help statement", "help unexpected",
and "help todo".
* The chi.cal resource file does not work well with odd degrees
of freedom. Can someone improve this algorithm?
* The intfile.cal resource file reads and writes big or little Endian
integers to/from files the hard way. It does NOT use blkcpy. The
following code:
i = (ord("\n") << 16) | (ord("i") << 8) | ord("H")
b = blk()
copy(i, b)
fd = fopen("file", "w")
copy(b, fd);
fclose(fd)
will write an extra NUL octet to the file. Where as:
read intfile
i = (ord("\n") << 16) | (ord("i") << 8) | ord("H")
be2file(i, "file2")
will not.
=-=
To subscribe to the calc-tester mailing list, visit the following URL:
http://www.isthe.com/chongo/tech/comp/calc/calc-tester.html
This is a low volume moderated mailing list.
This mailing list replaces calc-tester at asthe dot com list.
If you need a human to help you with your mailing list subscription,
please send EMail to our special:
calc-tester-maillist-help at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
address. To be sure we see your EMail asking for help with your
mailing list subscription, please use the following phase in your
EMail Subject line:
calc tester mailing list help
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
## Copyright (C) 1999-2014 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.5 $
## @(#) $Id: BUGS,v 30.5 2014/10/12 12:23:43 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/RCS/BUGS,v $
##
## Under source code control: 1994/03/18 14:06:13
## File existed as early as: 1994
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* changes
*************
The following are the changes from calc version 2.12.5.0 to date:
Calc has a new calc-tester mailing list. This list is for those
who are using/testing calc. We also use this list to announce
new versions of calc. To subscribe to the calc-tester mailing
list, visit the following URL:
http://www.isthe.com/chongo/tech/comp/calc/calc-tester.html
This is a low volume moderated mailing list.
This mailing list replaces calc-tester at asthe dot com list.
If you need a human to help you with your mailing list subscription,
please send EMail to our special:
calc-tester-maillist-help at asthe dot com
address. To be sure we see your EMail asking for help with your
mailing list subscription, please use the following phase in your
EMail Subject line:
calc tester mailing list help
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
There is a new calc bug report EMail address:
calc-bug-report at asthe dot com
This replaces the old calc-bugs at asthe dot com address.
To be sure we see your EMail reporting a calc bug, please use the
following phase in your EMail Subject line:
calc bug report
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
However, you may find it more helpful to simply subscribe
to the calc-tester mailing list (see above) and then to
send your report to that mailing list as a wider set calc
testers may be able to help you.
The following makefile rules that were related to printing the
upper values of the calc version, rules that were made obsolete
in calc version 2.12.4.14, have been removed:
calc_vers calc_ver calc_ve
vers ver ve
Noted that the hash() builtin function, internally known as
quickhash (used for internal objects such as the associative
arrays as well as other internal processes) uses the deprcated
32-bit FNV-0 hash. The use of this deprecated hash is sufficient
for calc internal purposes. Use of FNV-1a is recommended for
a general non-cryptographic quick hash.
The following are the changes from calc version 2.12.4.14 to date:
For Apple OS X / Darwin target:
MACOSX_DEPLOYMENT_TARGET is no longer defined
using clang compiler
By default, -install-name is used when forming shared libs.
To force -install-name to not be used, set SET_INSTALL_NAME=no.
The have_stdvs.c test uses <stdlib.h> and fixed va_start() test call
that didn't use last arg.
Fixed math_fmt (printf) in value.c where a LEN (SB32) be printed as %d.
Fixed a significant bug where that resulted in an incorrect
complex number comparison. Thanks goes to David Binderman
<dcb314 at hotmail dot com> for identifying the subtle typo!
Make minor fixes to the make depend rule.
Fixed places were calc defined a reserved identifier that
begin with either __ or _[A-Z]. For example, __FILE_H__ has
been replaced with INCLUDE_FILE_H.
Fixed the addall3 example in the script help file. Thanks for this
fix goes to Igor Furlan <igor dot furlan at gmail dot com>.
We made important fixes to the calc command line history:
Fixed a bug in the command line history where calc would somtimes
crash. There was code that used memcpy() instead of memmove()
that could corrupt the command line history when entering a
into into history that was similar to a previous entry. Thanks
goes to Einar Lielmanis <einars at spicausis dot lv> for first
identifying this mistake.
The calc command line history code, in general was not robust.
We made use a patch from Mathias Buhr <napcode at users dot sf
dot net>, that while it uses a bit more memory: is much more
flexible, readable and robust. This patch replaced the improer
use of memcpy() (see above) with better code. Thanks!
The alg_config.cal calc resource file has been reworked to produce
better diagnostics while attempting to determine the ideal values
for mul2, sq2, and pow2. However, it has been shown that this
code is not correct. Suggestions for a replacement are welcome!
calc -u 'read alg_config; config("user_debug", 2),; best_mul2();'
calc -u 'read alg_config; config("user_debug", 2),; best_sq2();'
calc -u 'read alg_config; config("user_debug", 2),; best_pow2();'
Fixed a number of pedantic compiler warnings.
Removed -W and -Wno-comment from the the CCWARN makefile variable.
Removed no_implicit.arg makefile rule. Removed HAVE_NO_IMPLICIT
makefile variable. Removed no_implicit.c source file.
Added WNO_IMPLICT makefile variable to hold the compiler flag
-Wno-implicit for use on selective compile lines.
Added WNO_ERROR_LONG_LONG makefile variable to hold the compiler flag
-Wno-error=long-long for use on selective compile lines.
Added WNO_LONG_LONG makefile variable to hold the compiler flag
-Wno-long-long for use on selective compile lines.
The makefile variable ${MKDIR_ARG} has been replaced with just -p.
Minor fixes were made to the calc.spec.in file.
The target rpm architecture changed from i686 to x86_64. For those
who do not run machine with x86_64, we continue to release a src
rpm. For those without the ability to process an rpm, we will always
to release src tarball.
When building the libcalc and libcustcalc shared libraries,
ONLY the .so and .so.${VERSION} files are created. The .so is
a symlink to the .so.${VERSION} file. Here ${VERSION} is the
full "w.x.y.z" calc version.
The following are the changes from calc version 2.12.4.11 to 2.12.4.13:
Fixed many typos in comments of the Makefile thanks to the review
work of Michael Somos.
Fixed typo in "help sysinfo".
The Makefile rule, debug, is now more verbose and prints more information
about the calc compiled constants.
Added a more of calc resource files by
Christoph Zurnieden <czurnieden at gmx dot de> including:
infinities.cal - handle infinities symbolically, a little helper file
intnum.cal - implementation of tanh sinh and Gauss-Legendre quadrature
smallfactors.cal - find the factors of a number < 2^32
strings.cal - implementation of isascii() and isblank()
Reformatted some calc resource files. Cleanup in comment the headers
of some calc resource files.
Minor formatting changes to a few help files.
No need to be special picky about the test8900.cal calc resource file.
Added a number of ctype-like builtins:
isalnum - whether character is alpha-numeric
isalpha - whether character is alphabetic
iscntrl - whether character is a control character
isdigit - whether character is a digit character
isgraph - whether character is a graphical character
islower - whether character is lower case
isprint - whether character is a printable
ispunct - whether character is a punctuation
isspace - whether character is a space character
isupper - whether character is upper case
isxdigit - whether character a hexadecimal digit
strcasecmp - compare two strings, case independent
strncasecmp - compare two strings up to n characters, case independent
strtolower - transform an ASCII string to lower case
strtoupper - transform an ASCII string to upper case
For details on these new builtins, see their help messages.
Thanks goes to Inge Zurnieden <inge dot zurnieden at gmx dot de> for
these new builtins.
Calc source code is now picky v2.3 clean using:
picky -s -v file file2 ..
With the exception of:
help/errorcodes.sed
cal/set8700.line
Due to the long lines in those files, we use:
picky -w -s -v help/errorcodes.sed cal/set8700.line
For more information about the picky tool, see:
http://cis.csuohio.edu/~somos/picky.html
Removed functions from strings.cal that have been replaced by
the new ctype-like builtin functions.
Fixed cal/Makefile to include missing intnum.cal file.
Added detail_help_list make target to cal/Makefile.
The detaillist make target in help/Makefile is now
called detail_help_list.
Removed requirement of gen_u0(h, n, v1) in lucas.cal that h
be odd. While still lucas(h, n) converts even h into an odd h
internally by incrementing n, gen_u0(h, n, v1) will output even
when h is even.
The following are the changes from calc version 2.12.4.6 to version 2.12.4.10:
Updated RPM build process to remove use of deprecated flags.
Applied a number of fixes to calc.spec and rpm.mk file.
See calc.spec.in for details. Changed rpm release to 2.1.
Set MACOSX_DEPLOYMENT_TARGET=10.8 as we upgraded all of
our development Mac OS X to 10.8.
Libraries are chmodded as 0644 to allow for building rpms
without root.
Silenced annoying warning about unused variable 'intp'
while compiline endian.c under some circumstances.
Fixed typo in redeclaration warnings. Thanks to
Christoph Zurnieden <czurnieden at gmx dot de> for this report.
Added a number of calc resource files by
Christoph Zurnieden <czurnieden at gmx dot de> including:
bernpoly.cal - Computes the nth Bernoulli polynomial at z for any n,z
brentsolve.cal - root-finder implementwed with the Brent-Dekker trick
factorial.cal - product of the positive integers
factorial2.cal - variety of integer functions quasi-related to factoral
lambertw.cal - Computes Lambert's W-function at "z" at branch "branch"
lnseries.cal - Calculates a series of natural logarithms at 1,2,3,4...n
specialfunctions.cal - Calculates the value of the beta function
statistics.cal - a wide vareity of stastical functions
toomcook.cal - Multiply by way of the Toom-Cook algorithm
zeta2.cal - Calculate the value of the Hurwitz Zeta function
Fixed a makefile bug that prevented the those new calc resource
files from being installed.
Improved the formatting of the output from:
help resource
We replaced COPYING-LGPL with the version that is found at
http://www.gnu.org/licenses/lgpl-2.1.txt because that version
contans some whitespace formatting cleanup. Otherwise the
license is the same.
We fixed a number of places where "the the" was used
when just "the" should be used.
NOTE: Fixes to grammar, spelling and minor formatting
problems are welcome. Please send us your patches!
With the exception of 3 source files, we became "picky" about
line lengths and other issues reported by the picky tool:
cal/test8900.cal
cal/set8700.line
help/errorcodes.sed
The above 3 files now pass picky -w (OK except for line length).
For more information about the picky tool, see:
http://cis.csuohio.edu/~somos/picky.html
The following are the changes from calc version 2.12.4.3 to 2.12.4.5:
Added gvec.cal resource script.
Added calc-symlink make rule to setup symlinks from stardard locations
into a tree specified by a non-empty ${T} makefile variable. Added
calc-unsymlink to remove any symlinks that may have been created by
the calc-symlink rule.
If is OK for the calc-symlink make rule to pre-remove a symlink.
Fixed bug was uncovered in calc that caused script failures when calc
is called within a while loop in BASH if the while loop is fed from
stdin due to calc's redirection/inheritance of stdin and no option
to change this behavior. Thanks gores to David C. Rankin
<drankinatty at gmail dot com> for the bug fix and to David Haller
<dnh at opensuse dot org> for helping debug this problem.
The following are the changes from calc version 2.12.4.0 to 2.12.4.2:
Fixed a documentation bug for the sgn() builtin.
Added the 1<<8/2 evaluation example to "help unexpected". That
expression evalutes to 128, not 16 as some C programmers might expect.
Fixed a bug in solve.cal where high was not returned in some situations.
Fixed a bug reported by Paul & Karen Tomlinson (paulnkaz at pktomlinson
dot fsnet dot co dot uk) where calling log multiple times with different
values of epsilon resulted in an incorrect value.
Removed cvd rule from Makefiles.
The Makefile used in the source rpm (calc-*.src.rpm) no longer uses
the -Werror compile flag. This is to help those distributions with
compilers that make produce (hopefully) complination warnings.
NOTE: For testing and calc build purposes will recommend and will
continue to use the -Werror flag.
Fixed a typo in the Makefile where the make variable ${SAMPLE_OBJ}
was misspelled as ${SAMPLE_OBJS}.
Added prep makefile rule to make is easier to compile calc without
an optimizer. By doing:
make clobber prep
one may build a calc binary that is easier to debug.
Fixed a bug where an certains typos (e.g., calling an unknown
function) would previously cause calc to exit.
Updated the COPYING file to reflect the new filenames associated
with the SHA1 hash function, and removed mention of files related
to the SHA (SHA0, not SHA1) and the MD5 hash functions (which is
no longer supported in calc).
Fixed a bug where a calling vsnprintf() twice created problems.
The thanks for this fix goes to Matthew Miller (mattdm at mattdm
dot org) for this patch.
Michael Penk (mpenk at wuska dot com) reported success in installs
under windoz via Cygwin by making a change to the Cygwin target.
These changes have been folded into the main calc Makefile.
The old recommendation of using 'make win32_hsrc' is no longer
required for Cygwin. See the README.WINDOWS file for details.
Added dms.cal and hms.cal resource files. The dms.cal is a more
functional version of deg.cal. It is a superset except that increment
and decrement is on the arc second level. The hms.cal is for
24-hour cycle instread of the 360 degree cycle of dms.cal.
Changed deg.cal object name from dms to deg so that the more functional
dms.cal can own the dms object name.
Updated 'help obj' to reflect changes to 'show objfunctions' and
resource file example list since 1999.
Fixed problem where CALC_BYTE_ORDER refering to CALC_BIG_ENDIAN
and CALC_LITTLE_ENDIAN instead of BIG_ENDIAN and LITTLE_ENDIAN.
The following are the changes from calc version 2.12.3.0 to 2.12.3.3:
Fixed the Jacobi function where it returned 1 when it should have
returned 0. Thanks goes to Kevin Sopp (baraclese at googlemail dot com)
for discovering the problem and suggesting the nature if the fix.
Calc versions will always be of the form x.y.z.w even when the
MINOR_PATCH (w) is 0. Thus, 2.12.3.0 will be printed as 2.12.3.0
instread of just 2.12.3.
Added MINGW32_NT-5.0 compile target based on a patch from
Brian L. Angus (angus at eng dot utah dot edu).
Removed the use of rpm.release in the Makefile.
Mac OS Darwin targets no longer attempt to use ldconfig. Under the
Darwin target, the LDCONFIG make variable is redefined to be
an empty value. Thanks goes to Ralf Trinler (art at infra dot de)
for reporting this problem.
The ${CALC_INCDIR}/custom is no longer being removed at install time
if it is empty. Now when ${ALLOW_CUSTOM} make variable is empty,
an empty ${CALC_INCDIR}/custom may be left hehind.
Fixed a problem where a "make clobber" would remove custom/Makefile
and fail to rebuilt it.
The following are the changes from calc version 2.12.2.3 to 2.12.2.4:
Added OpenBSD target.
Using the -r test instead of the -e test in Makefiles because some
out of date shells still do not have the -e test.
The Makefile now avoids the use of if ! command because some out of
date shells to not support the ! construct.
The following are the changes from calc version 2.12.1.1 to 2.12.2.2:
Added an explicit Solaris target.
Fixed confusion in Makefile where some uses of ${EXT} were misnamed ${EXE}.
Added a "make strip" rule, per suggestion from Igor Furlan <primorec
at sbcglobal dot net>, to allow one to strip previously built binary
executables and libraries.
Under the Darwin / OS X target, ${DARWIN_ARCH} is left empty meaning
that calc is compiled for the native CPU type instead of Universal
Binary (Intel and PPC).
By default, the calc binary that is built for the rpm forces
${LD_SHARE} to be empty. An empty ${LD_SHARE} means that the calc
from the rpm does not set rpath. This in turn causes the default
system path to be searched when looking for libcalc and libcustcalc.
The Makefile shipped with calc still sets ${LD_SHARE} for host targets.
By default, the dynamic shared library search path for all targets
starts with the source directory. Starting the search in the source
directory is convenient for testing and debugging but is not appropriate
for installation on a production system. To get the same effect
as the calc binary in the calc rpm, try:
make clobber
make calc-dynamic-only BLD_TYPE=calc-dynamic-only LD_SHARE=
make install
The libcalc and libcustcalc shared libraries are now tied to
the 4 level calc version instead of just 3 levels. For example,
under Linux calc version 2.12.2.1 uses /usr/lib/libcalc.so.2.12.2.1
instead of just the /usr/lib/libcalc.so.2.12.2 file. This change
was made so that calc produced by 'make clobber; make all install'
is consistent with the calc rpm.
Calc is now releasing the calc-debuginfo rpm for those RPM users who
which to use non-stripped libraries and binaries for debugging
purposes. By default, the calc rpm installed stripped binaries
and libraries.
Added this high priority item to the calc help/todo list:
It is overkill to have nearly everything wind up in libcalc.
Form a libcalcmath and a libcalclang so that an application
that just wants to link with the calc math libs can use them
without dragging in all of the other calc language, I/O,
and builtin functions.
Fixed the wording for the -i flag in the calc man page.
Added some notes to the help/unexpected file regarding calc
and interactice shells.
Fixed bug where a FILEPOS was copied FPOS_POS_BITS octets instead of
FPOS_POS_LEN octets.
Split out ${READLINE_EXTRAS} Makefile variables from ${READLINE_LIB}
to better deal with Fedora rpm requirements.
Bit 8 (0x80) of calc_debug is reserved for custom debugging.
See help/config and custom/HOW_TO_ADD for details.
When the Makefile variable ${ALLOW_CUSTOM} is not defined or empty,
the libcustcalc library is not built or linked against, certain make
rules skip going into the custom sub-directory, the install
rule skips certain custom installation actions, and the common
C flags (${COMMON_CFLAGS}) is given -UCUSTOM. Other make rules such
as "make clean" and "make clobber" still work as before. Also
the Makefile.simple assumes that the Makefile variable ${ALLOW_CUSTOM}
is -DCUSTOM.
Clarified that the calc builtin functions rand() and random()
operate over a half closed interval. The help/rand and help/random
refer to the top of the interval as "beyond" instead of "max".
Releaseing source tar balls using bzip2 instead of with gzip. So
what was calc-something.tar.gz is now calc-something.tar.bz2.
To "uncompress" use:
bunzip2 calc-something.tar.bz2
On some systems, one may untar directly by:
tar -jxvf calc-something.tar.bz2
The Makefile variable ${BYTE_ORDER} was replaced by ${CALC_BYTE_ORDER}.
Changed the way the Makefile can force the calc byte order. If you set
the Makefile variable ${CALC_BYTE_ORDER} to be -DCALC_BIG_ENDIAN then
endian.h will force the CPP symbol CALC_BYTE_ORDER to be BIG_ENDIAN.
If you set ${CALC_BYTE_ORDER} to be -DCALC_LITTLE_ENDIAN then endian.h
will force the CPP symbol CALC_BYTE_ORDER to be LITTLE_ENDIAN.
If the Makefile variable ${CALC_BYTE_ORDER} is empty, then the CPP
symbol CALC_BYTE_ORDER will set to the CPP symbol BYTE_ORDER as
defined by some system include file (if the Makefile can find such
an include file), or the Makefile compiling endian.c and hopefully
using that result to set CPP symbol CALC_BYTE_ORDER. Regardless of
how it happens, the CPP symbol CALC_BYTE_ORDER should end up set in
endian_calc.h include file.
The following are the changes from calc version 2.12.1.10 to 2.12.2:
Put back the missing -s flags on the cscripts: mersenne, 4dsphere,
fprodcut, plus, and powerterm. Thanks goes to Bradley Reed
<bradreed1 at gmail dot com> for discovering this problem.
All static variables are now declared with the symbol STATIC.
All extern variables are now declared with the symbol EXTERN.
All static functions are now declared with the symbol S_FUNC.
All extern functions are now declared with the symbol E_FUNC.
The include file decl.h defines these 4 symbols by default
to static, extern, static, and extern respectively. Under
Windoz, DLL is also defined according to the _EXPORTING symbol
and is prepended to the EXTERN and E_FUNC symbols. The decl.h
file has replaced the win32dll.h file.
When WITH_TLS is defined, calc attempts to compile with Thread Local
Storage. As of version 2.12.1.12 this mode is extremely experimental.
Calc may not compile when WITH_TLS defined.
Fixed E_FUNC vs EXTERN issues discovered by Mirko Viviani
<mirko at objectlab dot org>.
Removed include of <malloc.h>. The building of the include file
"have_malloc.h" has been removed from the Makefile. One some
systems such as FreeBSD, the file /usr/include/malloc.h exists
and contains an forced error saying that stdlib.h should be used
instead. The Makefile symbol HAVE_MALLOC has been removed.
Moved the sample code in the sample sub-directory up into the
main source level. The sample/many_random.c source file is
now sample_many.c. The sample/test_random.c source file is now
sample_rand.c. The sample Makefile and the sub-directory is no more.
Renamed the following source files:
math_error.h ==> lib_calc.h
string.c ==> str.c
string.h ==> str.h
Renamed the following variables related to calc error processing:
int calc_jmp ==> int calc_use_matherr_jmpbuf
jmp_buf calc_jmp_buf ==> jmp_buf calc_matherr_jmpbuf
int post_init ==> int calc_use_scanerr_jmpbuf
jmp_buf jmpbuf ==> jmpbuf calc_scanerr_jmpbuf
char *calc_error ==> char calc_err_msg[MAXERROR+1]
These values are now declared in the lib_calc.h include file.
The value MAXERROR is now defined in lib_calc.h instead of calc.h.
The calc_err_msg[] buffer is now used for math errors as well
as scan and parse errors.
Parse/scan errors will not be printed if calc_print_scanerr_msg
is zero. By default:
int calc_print_scanerr_msg = 1;
This variable is declared in the lib_calc.h include file. Storage
comes from libcalc.
Parse/scan warnings will not be printed if calc_print_scanwarn_msg
is zero. By default:
int calc_print_scanwarn_msg = 1;
This variable is declared in the lib_calc.h include file. Storage
comes from libcalc.
The last parse/scan error message is stored in the calc_err_msg[]
buffer. This happens even when calc_print_scanerr_msg is zero.
The last parse/scan warning message is stored in the calc_warn_msg[]
buffer. After each parse/scan warning condition is detected,
the value calc_warn_cnt is incremented. This happens even when
calc_print_scanwarn_msg is zero.
The calc_warn_msg[] buffer and calc_warn_cnt variables are declared
in the lib_calc.h include file. Storage comes from libcalc.
See the file, LIBRARY or use the calc command "help libcalc" for
more information on calc error processing. This file has been
updated to reflect the changes noted above in this section.
The make install rule removes std_arg.h, have_malloc.h, math_error.h,
string.h, and win32dll.h from ${INCDIR} if they exist. These calc
include files are no longer supported.
Do reduce the number of special case .o build rules, the
${ALLOW_CUSTOM} make flag is added to ${CFLAGS} by default. This means
that if ALLOW_CUSTOM= -DCUSTOM, then -DCUSTOM is given to the compile
line of most .c files.
Calc -v reports "w/custom functions" or "w/o custom functions" on
the version string depending on if calc was compiled with the
ALLOW_CUSTOM= -DCUSTOM or not.
Replaced the concept of compiler sets in the Makefile with
host target section in the Makefile. Initial host targets are:
Linux
Darwin
FreeBSD
(default) <<== Target does not match any previous target name
Simple
NOTE: If your target is not supported below and the default target
is not suitable for your needs, please send to the:
calc-contrib at asthe dot com
EMail address an "ifeq ($(target),YOUR_TARGET_NAME)"
... "endif" set of lines from the Makefile so that
we can consider them for the next release.
The custom/Makefile is now constructed from 3 parts: custom/Makefile.head,
the host target section in Makefile, and the custom/Makefile.tail.
The top level Makefile and the custom/Makefile require a GNU Make
(such as gmake) or an equivalently advanced make. On many targets,
the default make is sufficient. On FreeBSD for example, one must
use gmake instead of make.
If your target system does not have GNU Make (or equivalent), then
you should try using the Makefile.simple and custom/Makefile.simple
files:
mv Makefile Makefile.gmake
cp Makefile.simple Makefile
mv custom/Makefile custom/Makefile.gmake
cp custom/Makefile.simple custom/Makefile
make all
Added the ability to build calc with dynamic libraries, static
libraries or both. Many thanks goes to Matthew Miller (mattdm
at mattdm dot org) and Mirko Viviani (mirko at objectlab dot
org) for this help, encouragement, and testing of this major change!
Added BLD_TYPE Makefile variable to control how calc is
built. The BLD_TYPE value may be one of:
BLD_TYPE= calc-dynamic-only
BLD_TYPE= calc-static-only
Each host target establishes a default BLD_TYPE value. Of course
one can override the host target BLD_TYPE on the make command line:
make clobber
make calc-dynamic-only BLD_TYPE=calc-dynamic-only
make clobber
make calc-static-only BLD_TYPE=calc-static-only
NOTE: It is a very good idea to first clobber (remove) any previously
built .o, libs and executables before switching the build
between static and dynamic.
which have the same effect as make all with a given build phase set.
For Linux and Darwin, the default BLD_TYPE is calc-dynamic-only.
For the simple case, BLD_TYPE is calc-static-only. For the
default target (the target does not match any of the previous
defined targets), BLD_TYPE is calc-static-only.
Added ${CSFLAGS} make variable to hold the {$CC} flags for compiling
without shared library. By default, ${CFLAGS} is ${CSFLAGS} with
${CC_SHARE} added to it.
Added ${CC_SHARE}, ${LIBCALC_SHLIB}, ${LIBCUSTCALC_SHLIB}, and
${LD_SHARE} to the remaining compiler sets.
Fixed make depend and make uninstall rules. Performed various
makefile syntax cleanups.
Removed ${PROGS} and ${STATIC_PROGS} Makefile variables due to
the new BLD_TYPE system (see above).
Added missing help for cp, calcpath, and stoponerror.
Noted that calc fails the regression test (and will crash at
various times) when compiled with gcc v4.1.0. This problem was
first reported under Fedora Core 5 by Christian Siebert.
Set the LESSCHARSET to iso8859 so that less will not confuse or
upset the col utility with Invalid or incomplete multi-byte or wide
characters.
Updated the Free Software Foundation postal address and updated
the COPYING-LGPL from http://www.fsf.org/licensing/licenses/lgpl.txt
on 2007-Mar-14. Calc is using the same Version 2.1 of the LGPL,
only the postal address of the Free Software Foundation has
been updated. All source files were updated to RCS level 30.
Thanks goes to Martin Buck (m at rtin-buck dor de) for this patch.
Added printf arg checking for GNU C compilers that helps check
printf-style functions in calc. Thanks goes to Martin Buck (m at
rtin-buck dor de) for this patch.
Fixed issues where the argument of a printf-like did not match the
format type.
Removed build function md5(). The MD5 hash has been compromised to
such a degree that is it no longer advisable to use this function.
Removed build function sha(). The SHA hash has been compromised to
such a degree that is it no longer advisable to use this function.
Note that the SHA-1 hash has not been compromised to the same degree
and so this hash function remains.
Renamed shs1.c to sha1.c. Renamed shs1.h to sha1.h.
Added custom registers. The custom register function:
custom("register", 3)
returns the value of custom register 3. Custom registers, initialized
with 0, may take on any calc value:
custom("register", regnum, value)
Added REGNUM_MAX to the sysinfo custom function to return the maximum
register number:
custom("sysinfo", "REGNUM_MAX")
which defaults to 31. The first custom register is 0 and thus the
default number of custom registers is 32.
Added E_OK #define in calc.h to indicate no error (0).
Renamed C function powivalue() in value.c to powvalue() because it
now handles raising NUMBER or COMPLEX to a NUMBER or COMPLEX power.
The powervalue() function in value.c may be given a NULL epsilon
which will cause to the builtin epsilon value to be used.
Calc supports both real and complex exponentiation bases and exponents.
For a ^ b and a ** b, "a" and "b" can be a real value or a complex value:
2^3 3i^4
2.5 ^ 3.5 0.5i ^ 0.25
2.5 ^ 2.718i 3.13145i ^ 0.30103i
Fixed typos in the calc man page thanks to a Debian bug report
by A. Costa <agcosta at gis dot .net> that wsa kindly forwarded
to us by Martin Buck <m at rtin-buck dot de>.
The following are the changes from calc version 2.12.1.8 to 2.12.1.9:
Fixed calc cscripts that contained comments that were not valid calc
comments. Improved calc comment documentation in "help unexpected"
to help other avoid similar mistakes. Calc comments are of the form:
/* c style comments */
/*
* multi-line
* comments
*/
## two or more #-signs
### in a row
### Note that # along is a calc unary and binary operator
Added "help pound" or "help #' to document the # operator, comments,
and the first line of cscript files.
Documented these help commands in "help help":
help ->
help *
help .
help %
help //
help #
The usage help file is now formed from the contents of the calc man page.
So "help usage" prints the version of the calc man page. Added ${COL}
makefile symbol to support the formation of the calc.usage file from
calc.1 via the CALCPAGER (less) or NROFF (if NROFF is non-empty).
The "help calc" command is now equivalent to "help help".
The "help define" command is now equivalent to "help command".
Fixed calc command line usage message.
Fixed missing README.src file in RPM src and tgz src tarball.
Removed HAVE_SNPRINTF test in version.c. We now assume that
all systems come with the standard snprintf() library function.
Make does not assume that DONT_HAVE_VSPRINTF must be defined in
order to test for varargs (via have_varvs.c). Instead it uses the
${HAVE_VSPRINTF} to determine if the vsprintf() and vsnprintf()
should be tested to assumed to exist or not exist.
Tests for the existence of vsprintf() now also require the existence
of vsnprintf(). Test for the existence of vsnprintf() now also
require the existence of vsprintf().
The #define CALC_SIZE_T was never used except when memmove() was
not found. This symbol was renamed to MEMMOVE_SIZE_T. Calc
requires that size_t must be a known type.
Calc and cscripts are installed mode 0755 instead of 0555 to
make rpmlint happy.
Make clobber cleanup as suggested by Martin Buck <m at rtin-buck dot de>.
The clobber rule now depends on the clean rule.
The following are the changes from calc version 2.12.1.6 to 2.12.1.7:
Added the calc builtin function, usertime(), to return the amount of
user CPU time used by the current process. Unlike the old runtime()
builtin, the CPU time reported for long running processes will not
wrap around to 0 after only a few months.
Added the calc built0in function, systime(), to return the amount of
kernel CPU time used by the current process.
The runtime() builtin function now returns the total amount of CPU
time used by the current process. This time includes both user mode
and kernel mode time. Unlike the old runtime() builtin, the builtin
includes time spent executing operating system code on behalf of
the current process.
Fixed runtime() so that the CPU time reported for long running
processes will wrap around to 0 for a long time.
Added config("hz") to return the clock tick rate. This is
a read-only configuration value.
Added regression tests for recently added config() parameters.
Fixed the #define symbols that were created in have_strdup.h.
Previously this file looked as if have_rusage.h has been
included already.
Restored the function of "help" (without any args) printing the
default help file. Thanks for this fix goes to Silvan Minghetti
<bullet at users dot sourceforge dot net>.
Fixed a problem where some old MS environments failed some of the
regression tests because "read -once foo.cal" was not behaving
correctly due to how the _fullpath() was being called. Thanks for
this fix goes to Anatoly <notexistent-anb at yandex dot ru>.
Documented the mis-feature about how calc parses if, for, while
and do statements in an unexpected way. For example:
This works as expected:
if (expr) {
...
}
However this WILL NOT WORK AS EXPECTED:
if (expr)
{
...
}
because calc will parse the if being terminated by
an empty statement followed by a
if (expr) ;
{
...
}
See also "help statement", "help unexpected", "help todo", and
"help bugs".
The following are the changes from calc version 2.12.1 to 2.12.1.5:
Fixed minor typos in the 'version 2.12.0 to 2.12.0.8' section below.
Made minor formatting changes as well.
Changed use of ${Q} in the Makefile to avoid an make "feature"
related to OpenBSD. Added ${RM} make variable for make tools that
do not have builtin defined terms.
Removed the ECHO_PROG Makefile variable. Also removed it from
the sysinfo() custom function.
Improved the support for cross-compiled environments by using
make symbols for all non-shell commands executed by Makefiles.
Fixed a problem with the make chk awk script which failed under
OS X 10.4.7.
Fixed a few minor variables that were not set to default values in
lower level Makefiles.
Fixed a reference to a non-existent make variable in HOWTO.INSTALL.
The following are the changes from calc version 2.12.0 to 2.12.0.8:
Fixed ellip.cal to deal with a calc syntax change that happened
many ages ago but was never applied to this file until now.
This bug was fixed by Ernest Bowen <ebowen at une dot edu dot au>.
Fixed a problem where comments using # followed by a !, newline or
another # works. This bug was fixed by Ernest Bowen <ebowen at une
dot edu dot au>.
The show builtins display for functions with long descriptions
is now broken into multi-line descriptions.
The str functions, such as strcpy(s1, s2), will now copy as many
characters as possible from s2 to s1, treating '\0' like any other
character until the end of s2 is reached. If s2 is shorter than s1,
a '\0' is inserted.
The strcmp(s1, s2) builtin, for strings s1, s2: strcmp(s1, s2) == 0 now
means the same as s1 == s2.
The str(s) builtin has been changed so that it will return only the
string formed by the characters of 's' up to the first '\0'.
The substr(s, start, num) builtin has been changed so that '\0' characters
are treated like any other.
Fixed a bug where strcpy("", "a") used to cause a segmentation fault.
This bug was fixed by Ernest Bowen <ebowen at une dot edu dot au>.
Make minor change to natnumset.cal in how the tail variable is initialized.
Fixed bugs in the strcmp, strncmp, strcpy, and strncpy help files.
This bug was fixed by Ernest Bowen <ebowen at une dot edu dot au>.
Added cal/screen.cal which Defines ANSI control sequences providing
(i.e., cursor movement, changing foreground or background color,
etc.) for VT100 terminals and terminal window emulators (i.e., xterm,
Apple OS/X Terminal, etc.) that support them. For example:
; read screen
; print green:"This is green. ":red:"This is red.":black
Fixed a bug where too many open files returned E_FOPEN3. Now
a new error symbol F_MANYOPEN is used for too many open files.
Added the builtin function fpathopen() to open a file while
searching along a path:
; fd2 = fpathopen("tmp/date", "r", ".:~:~sc:/tmp:/var/tmp:/var")
; print fd2
"/var/tmp/date"
By default, fpathopen() searches along CALCPATH.
Added the calcpath() builtin function to return the current value
of CALCPATH.
Fixed prompt characters in the EXAMPLE section of help files.
Fixed problems related to the protect function and its documentation.
This bug was reported by David Gilham <davidgilham at gmail dot com>.
This bug was fixed by Ernest Bowen <ebowen at une dot edu dot au>.
Raised the limit of exponent in exponential notation. It was set to
arbitrary 1000000 (making 1e1000001 in invalid exponential notation
value). The exponent for exponential notation is now int(MAXLONG/10).
On 32 bit machines, this means a limit of 214748364. On 64 bit
machines, this means 922337203685477580. Of course, you may not
have enough memory to hold such huge values, but if you did you can
now express such values in exponential notation.
Added log() builtin for base 10 logarithm.
Fixed problems where internal use of libc strcpy() might have caused
a buffer overflow. Calc now only uses libc strcpy() when the source
string is a constant.
The calc STRING and STRINGHEAD now use the standard size_t (an unsigned
type) length. Calc mostly uses size_t in dealing with string lengths
and object sizes when possible.
Added ${CCWERR} make variable to allow one to force compiler warnings
to be treated as errors. The ${CC} make variable now uses ${CCWERR}
however the ${LCC} (used by the Makefile test code for building hsrc
files) does not use ${CCWERR}. By default, ${CCWERR} is empty.
In development Makefiles, we set CCWERR= -Werror to force us to
address compiler warnings before the next release.
The calc make variable, CALCPAGER, now defaults to CALCPAGER= less
because the less utility is now very common. Set CALCPAGER= more
if you do not have less.
Calc source had two styles of switch indentation. Converted the
style where case statements were indented with respect to the switch
statement into the style where the case statements are at the same
level. When comparing with older source, one may use the -b argument
of the diff command to ignore changes in amount of white space:
diff -b -r -u calc-2.11.11 calc-2.12.0
The read, write, and help commands use the value of global string
variable if the symbol name starts with a $. For example:
global x = "lucas.cal";
read $x; /* same as read lucas.cal or read "lucas.cal" */
Added dotest.cal resource. Based on a design by Ernest Bowen
<ebowen at une dot edu dot au>, the dotest evaluates individual
lines from a file. The dotest() function takes 1 to 3 arguments:
dotest(dotest_file [,dotest_code [,dotest_maxcond]])
dotest_file
Search along CALCPATH for dotest_file, which contains lines that
should evaluate to 1. Comment lines and empty lines are ignored.
Comment lines should use ## instead of the multi like /* ... */
because lines are evaluated one line at a time.
dotest_code
Assign the code number that is to be printed at the start of
each non-error line and after **** in each error line.
The default code number is 999.
dotest_maxcond
The maximum number of error conditions that may be detected.
An error condition is not a sign of a problem, in some cases
a line deliberately forces an error condition. A value of -1,
the default, implies a maximum of 2147483647.
Global variables and functions must be declared ahead of time because
the dotest scope of evaluation is a line at a time. For example:
; read dotest.cal
; read set8700.cal
; dotest("set8700.line");
Updated the todo / wish list items. The top priority now is to
convert calc to GNU autoconf / configure to build the calc.
; help todo
Added missing help file for the stoponerror() builtin.
Corrected and improved the help documentation for factor and lfactor.
Fixed a problem where some error messages that should have been
written to a file or string, went to stderr instead. This bug was
fixed by Ernest Bowen <ebowen at une dot edu dot au>.
Corrected the documentation relating to the calc -c command line option.
The -c relates to scan/parse errors only, not execution errors.
Corrected a stack overflow problem where the math_fmt() in zio.c
could be induced to overflow the stack. This problem was independently
reported by Chew Keong Tan of Secunia Research <vuln at secunia dot com>.
Corrected a stack overflow problem where the scanerror() in token.c
could be induced to overflow the stack by a malformed token.
Made math_error() in math_error.c more robust against a error
message constant that is too long.
Made read_bindings() in hist.c more robust against very long bindings
config lines.
Made listsort() in listfunc.c and matsort() matfunc.c more robust
against sorting of impossibly huge lists and matrices.
Warnings about an undefining a builtin or undefined function, a
constant before the comma operator, and an unterminated comment is
now processed by scanerrors (not simply written directly to stderr).
These warnings file and line number in which the "error" occurred
as well as a more precise message than before. If using -c on the
calc command line or if stoponerror(-1), then assuming there are
no other compile errors, only the unterminated comment will stop
completion of the function being defined.
The cal/regress.cal now reads most of the calc resource files.
The issq() test had a slight performance boost. A minor note
was added to the help/issq file.
Improved the documentation of the mul2, sq2, pow2, and redc2 config
parameters in help/config.
Added config("baseb"), a read-only configuration value to return
the number of bits in the fundamental base in which calculations
are performed. This is a read-only configuration value.
Calc now will allow syntax such as ++*p-- and ++*----*++p----
where p is an lvalue; successful evaluation of course require the
successive operations to be performed to have operands of appropriate
types; e.g. in *A, A is usually an lvalue whose current value is a
pointer. ++ and -- act on lvalues. In the above examples there are
implied parentheses from the beginning to immediately after p. If
there are no pre ++ or -- operations, as in **p++. The implied
parentheses are from immediately before p to the end.
Improved the error message when && is used as a prefix operator.
Changed the help/config file to read like a builtin function help file.
One can no longer set to 1, or to a value < 0, the config()
parameters: "mul2", "sq2", "pow2", and "redc2". These values
in the past would result in improper configuration of internal
calc algorithms. Changed cal/test4100.cal to use the minimal
value of 2 for "pow2", and "redc2".
Changed the default values for the following config() parameters:
config("mul2") == 1780
config("sq2") == 3388
config("pow2") == 176
These values were determined established on a 1.8GHz AMD 32-bit
CPU of ~3406 BogoMIPS by the new resource file:
cal/alg_config.cal
Regarding the alg_config.cal resource file:
The best_mul2() function returns the optimal value of config("mul2").
The best_sq2() function returns the optimal value of config("sq2").
The best_pow2() function returns the optimal value of config("pow2").
The other functions are just support functions.
By design, best_mul2(), best_sq2(), and best_pow2() take a few
minutes to run. These functions increase the number of times a
given computational loop is executed until a minimum amount of CPU
time is consumed. To watch these functions progress, one can set
the config("user_debug") value.
Here is a suggested way to use the alg_config.cal resource file:
; read alg_config
; config("user_debug",2),;
; best_mul2(); best_sq2(); best_pow2();
; best_mul2(); best_sq2(); best_pow2();
; best_mul2(); best_sq2(); best_pow2();
NOTE: It is perfectly normal for the optimal value returned
to differ slightly from run to run. Slight variations due to
inaccuracy in CPU timings will cause the best value returned to
differ slightly from run to run.
See "help resource" for more information on alg_config.cal.
Updated the "help variable" text to reflect the current calc
use of ` (backquote), * (star), and & (ampersand).
Removal of some restrictions on the use of the same identifier
for more than one of parameter, local, static or global variable.
For example, at command level, one could use:
for (local x = 0; x < 10; x++) print sqrt(x);
At the beginning of a statement, "(global A)" is a way of
indicating a reference to the variable A, whereas "global A"
would be taken as a declaration. Parentheses are not required in
"++global A" or "global A++" when "global" is used in this way.
The patch extends this "specifier" (or "qualifier") feature
to static variables, but such that "static A" refers only
to a static variable at the current file and function scope
levels. (If there is already a static variable A at the current
file and function levels, a declaration statement "static A"
would end the scope of that variable and define a new static
variable with identifier A. A "global A" declaration is more
drastic in that it ends the scope of any static variable A at
the same or higher scope levels.)
Unlike a static declaration in which an "initialization" occurs at
most once, in the specifier case, "static A = expr" is simply an
assignment which may be repeated any number of times. An example
of its use is:
define np() = static a = nextprime(a);
For n not too large, the n-th call to this function will
return the n-th prime. The variable a here will be private to
the function.
Because one can use "global", "local" or "static" to specify a
type of variable, there seems little point in restricting the
ways identifiers that can be used in more than one of these
or as parameters. Obviously, introducing A as a local variable
when it is being used as a parameter can lead to confusion and a
warning is appropriate, but if it is to be used only occasionally,
it might be convenient to be able to refer to it as "local A"
rather than introducing another identifier. While it may be
silly to use the same identifier for both a parameter and local
variable, it should not be illegal.
Added warnings for possibly questionable code in function definitions.
Added config("redecl_warn", boolean) to control if calc issues
warnings about variables being declared. The config("redecl_warn")
value is TRUE by default.
Added config("dupvar_warn", boolean) to control if calc issues
warnings about when variable names collide. The config("dupvar_warn")
value is TRUE by default. Examples of variable name collisions
include when:
* both local and static variables have the same name
* both local and global variables have the same name
* both function parameter and local variables have the same name
* both function parameter and global variables have the same name
Fix of a bug which causes some static variables not to be correctly
unscoped when their identifiers are used in a global declaration.
Change of "undefine" from a command-level keyword to statement level and
introduction of an "undefine static A" statement to end the scope of a
static variable A at the current file/function levels.
Change/restored the syntax rules for "for" and "while" loops to
recognize an unescaped newline in top-level command-level statements.
Updated help/avg, help/define, help/fprintf, help/gcd, help/hash,
help/hmean, help/lcm, help/max, help/min, help/null, help/poly,
help/printf, help/ssq, help/strcat, help/strprintf, help/sum,
help/xor.
Changed the definition of the function ssq() to enable list arguments
to be processed in the same way as in sum(). For example:
ssq(1,2, list(3,4,list(5,6)), list(), 7, 8)
returns the value of 1^2 + 2^2 + ... + 8^2 == 204.
Added the calc resource sumtimes.cal, to give the runtimes for
various ways of evaluating sums, sums of squares, etc, for large
lists and matrices. For example:
read sumtimes
doalltimes(1e6)
Calc now ignores carriage returns (\r), vertical tabs (\v), and
form feeds (\f) when token parsing. Thus users on Windoz systems
can write files using their \r\n format and users on non-Windoz
systems can read them without errors.
The quomod() builtin function now takes an optional 5th argument
which controls the rounding mode like config("quomod") does, but
only for that call. Now quomod() is in line with quo() and mod()
in that the final argument is an optional rounding mode.
Added a "make uninstall" rule which will attempt to remove everything
that was installed by a "make install".
Changed the "Copyright" line in the rpm spec file to a "License" line
as per new rpm v4.4 syntax.
The quomod() builtin function does not allow constants for its 3rd
and 4th arguments. Updated the "help quomod" file and added more
quomod regression tests.
Added patch from Ernest Bowen <ebowen at une dot edu dot au> to
add the builtin: estr(). The estr(x) will return a representation
of a null, string, real number, complex number, list, matrix,
object. block, named block, error as a string.
Added patch from Ernest Bowen <ebowen at une dot edu dot au> to
add the builtin: fgetfile(). The fgetfile(x) will return the rest
of an open file as a string.
Improved help files for fgetfield, fputs, name, or quomod.
The following are the changes from calc version 2.11.10.1 to 2.11.11:
Fixed a bug reported by the sourceforge user: cedars where:
ln(exp(6)) == 3 /* WRONG!!! */
incorrectly returned 1. This bug was fixed by Ernest Bowen
<ebowen at une dot edu dot au>. The regression test
was expanded to cover this issue.
Added minor improvements to hash regression testing of pi().
Fixed "help script" and the calc man page regarding the requirement
of -f to be the last -flag in shell script mode. Further clarified
the meaning and placement of the -f flag.
Moved issues with chi.cal intfile.cal into a "mis-features" section
of the BUGS file. See "help bugs" or the BUGS source file for details.
Added the bug about:
calc 'read ellip; efactor(13*17*19)'
to the BUGS file. See "help bugs" or the BUGS source file for details.
Anyone want to track down and fix this bug?
Fixed typo in the "help mat" example and improved the mat_print example.
Renamed most COMPLEX C function names to start with c_ to avoid
conflicts with new C standard functions. Note that the calc
builtin function names remain the same. The C function names
inside the C source that calc is written in changed. This means
that code that linked to libcalc.a will need to change in order
to call calc's functions instead of the C standard functions.
See cmath.h, comfunc.c, and commath.c for details. See also
http://www.opengroup.org/onlinepubs/009695399/basedefs/complex.h.html
for names of the new C standard functions.
Changed the calc man page to note that using -- in the command will
separate calc options from arguments as in:
calc -p -- -1 - -7
Noted how Apple OS X can make use of readline in the Makefile.
In particular:
# For Apple OS X: install fink from http://fink.sourceforge.net
# and then do a 'fink install readline' and then use:
#
READLINE_LIB= -L/sw/lib -lreadline -lhistory -lncurses
Added linear.cal as a calc standard resource file.
The following are the changes from calc version 2.11.10 to 2.11.10:
The cygwin config value is correctly tested while doing comparisons
between config states.
Added config("compile_custom") to determine if calc was compiled
with -DCUSTOM. By default, the Makefile uses ALLOW_CUSTOM= -DCUSTOM
so by default, config("compile_custom") is TRUE. If, however,
calc is compiled without -DCUSTOM, then config("compile_custom")
will be FALSE. NOTE: The config("compile_custom") value is only
affected by compile flags. The calc -D runtime command line option
does not change the config("compile_custom") value. This is a
read-only configuration value.
Added config("allow_custom") to determine if the use of custom
functions are allowed. To allow the use of custom functions, calc
must be compiled with -DCUSTOM (which it is by default) AND calc run
be run with the -D runtime command line option (which it is not by
default). If config("allow_custom") is TRUE, then custom functions
are allowed. If config("allow_custom") is FALSE, then custom
functions are not allowed. This is a read-only configuration value.
Correctly hash config state for windows and cygwin values. The value
of config("compile_custom") and config("allow_custom") also affect
the hash of the config state.
Fixed the custom/argv.cal test code to avoid use of a reserved
builtin function name.
Fixed custom/*.cal scripts to conform better with the cal/*.cal
resource files.
Removed the Makefile variables ${LONGLONG_BITS}, ${HAVE_LONGLONG},
and ${L64_FORMAT}. Removed longlong.c and longlong.h. The use
of HAVE_LONGLONG=0 was problematic. The lack of complaints about
the HAVE_LONGLONG=0 shows that the 'long long' type is wide spread
enough warrent not trying to support compilers without 'long long'.
Removed the SVAL and SHVAL macros from zrand.c, zrand.h, and zmath.h
as they were causing too many broken C pre-processors and C checkers
to become confused.
Added a 'make splint' rule to use the splint statically checking
tool on the calc source.
Removed support of the BSDI platform. The BSDI platform is no longer
directly supported and we lost our last BSDI machine on which we
could test calc. Best wishes to the former BSDI folk and thanks
for breaking important ground in the Open Source Movement!
Fixed several typos found in the documentation and buildin
function output by C Smith <smichr at hotmail dot com>.
Fixed -d so that:
calc -d 2/3
will print 0.66666666666666666667 without the leading tilde as
advertised in the man page.
Added a missing help file for the display builtin function as
requested by Igor Furlan <primorec at sbcglobal dot net>.
Changed the "help environment" file to reflect modern default
values of CALCPATH and CALCRC.
Added missing variables for printing by the "make env" rule.
Added EXT Makefile variable so that Cygwin can install calc as
calc.exe. By default, EXT is empty so that calc is calc on most
modern operating systems. Thanks goes to Ullal Devappa Kini <wmbfqj
at vsnl dot net> for helping identify this problem and testing our fix.
Added custom function:
custom("pmodm127", q)
to compute 2^(2^127-1) mod q. While currently slower than just
doing pmod(2,2^127-1,q), it is added to give an example of a
more complex custom function. Call calc with the -C flag to
use custom functions.
Made slight changes to the custom/HOW_TO_ADD documentation.
Fixed some \ formatting man page problems as reported by Keh-Cheng
Chu <kehcheng at quake dot Stanford dot edu>.
Fixed some comparison between signed and unsigned in md5.c
that was reported for the PowerMac G5 2GHz MacOS 10.3 by
Guillaume VERGNAUD <vergnaud at via dot ecp dot fr>.
Fixed a number of pending issues with help files filling in
missing LIMITS, LINK LIBRARY, and SEE ALSO information,
The following are the changes from calc version 2.11.9 to 2.11.9.3:
Fixed calc man page examples to move -f to the end of the line.
Thanks goes to Michael Somos for pointing this out.
Linux and gcc now compiled with -Wall -W -Wno-comment.
Fixed a post increment that was reported by R. Trinler <trinler at
web dot de> and fixed by Ernest Bowen <ernie at turing dot une dot
edu dot au>.
Fixed pi.cal to not depend on the buggy pre-2.11.9 post increment
behavior.
Added config("cygwin") to determine if calc was compiled under Cygwin.
The config("cygwin") is a read-only configuration value that is 1
when calc was compiled under Cygwin and 0 otherwise. Regression
tests 949 and 950 are skipped when config("cygwin") is true.
The Makefile variable HAVE_NO_IMPLICIT is empty by default so that
the Makefile will test if the compiler has a -Wno-implicit flag.
Added HAVE_UNUSED Makefile variable. If HAVE_UNUSED is empty,
then the Makefile will run the have_unused program to determine
if the unused attribute is supported. If HAVE_UNUSED is set to
-DHAVE_NO_UNUSED, then the unused attribute will not be used.
The Makefile builds have_unused.h which defines, if the unused
attribute is supported:
#define HAVE_UNUSED /* yes */
#define UNUSED __attribute__((unused)) /* yes */
or defines, if the unused is not supported (or if the Makefile
variable is HAVE_UNUSED= -DHAVE_NO_UNUSED):
#undef HAVE_UNUSED /* no */
#define UNUSED /* no */
Fixed numerous warnings about comparison between signed and unsigned
value warnings and unused parameter warnings in version.c, zrand.c,
string.c, shs1.c, shs.c, qtrans.c, qmath.c, qfunc.c, md5.c, matfunc.c,
hist.c, file.c, const.c, blkcpy.c, seed.c, opcodes.c, func.c, qio.c,
zrandom.c, custom/c_argv.c, custom/c_devnull.c, custom/c_help.c,
custom/c_sysinfo.c, addop.c and calc.c.
Fixed some typos in this file.
By default, compile with -O3 -g3. The Makefile comments on how some
distributions might need to use -O2 -g or -O -g.
The following are the changes from calc version 2.11.8.0 to 2.11.8.1:
Updated HOWTO.INSTALL to reflect the new RPM files.
Clarify that the internal hash as well as the hash builtin
function used by calc, while based on the Fowler/Noll/Vo
hash is NOT an FNV hash.
Made slight performance improvements to calc by an optimization of how
calc's internal hash is computed. The "make chk" regression test
runs about 1.5% faster (when compiled with -O3 on an AMD Athlon)
NO_HASH_CPU_OPTIMIZATION is not defined. Calc's internal hash values
have not changed. By default, NO_HASH_CPU_OPTIMIZATION is NOT defined
and the slightly faster expression is used.
A slight modification of what was known as the "calc new standard"
configuration (calc -n or config("all", "newstd")) is now the default
calc configuration. The flag:
calc -O
was added to get the old classic calc configuration. The flag command
line flag, -n, now does nothing. Use of -n is deprecated and may go
away / be used for something else in the future.
The following table gives the summary of these changes:
pre v2.11.8 v2.11.8
default pre v2.11.8 -O & oldstd v2.11.8
and oldstd -n & newstd classic cfg default
--------------------------------------------------------
epsilon 1e-20 1e-10 1e-20 1e-20
quo 2 2 2 2
outround 2 24 2 24
leadzero 0 1 0 1
fullzero 0 1 0 0
prompt > ; > ;
more >> ;; >> ;;
With the exception of epsilon being 1e-20, and fullzero being unset,
the new default calc config is like it was (pre-2.11.8) with calc -n /
config("all", "newstd").
The new default config is the old classic config with outround being
24, leadzero being set, and the prompts being ;'s.
Fixed a bug in the evaluation of tanh(1e-23) with an epsilon(1e-100).
Thanks goes to Dmitry G. Baksheyev <bd at nbsp dot nsk dot su>
for reporting the problem, and thanks goes to Ernest Bowen
<ernie at turing dot une dot edu dot au> for the fix.
The following are the changes from calc version 2.11.7.0 to 2.11.7.1:
Added support to build calc RPMs thanks to Petteri Kettunen
<petterik at users dot sourceforge dot net>.
Added rpm rule to Makefile to build rpm set. The rpm rule
uses the rpm.mk Makefile and the calc.spec.in spec template.
The default Makefile is now the Makefile used during rpm
creation. This Makefile assumes that system has readline,
ncurses (-lreadline -lhistory -lncurses), and less.
It compiled with a high gcc optimization level (-O3 -g3).
The Makefile used during rpm creation is the Makefile
that appears in the calc-src rpm as well.
The Makefile shipped with the old style gziped tarball
is still the same generic Makefile.
The Makefile now uses ${MKDIR} ${MKDIR_ARG} when creating
directories during installation. By default, it does
a mkdir -p when forming directories.
Fixed attributes on include and lib calc-devel files.
Adjusted the interaction between rpm.mk, and the calc.spec.in.
Release number now comes from calc.spec.in only.
Renamed calc and calc-devel RPMs to use .i686 instead of .i386.
The following are the changes from calc version 2.11.6.3 to date:
Fixed a bug in deg.cal where fixdms() was being called with
the wrong type of argument.
Changed the value of digits(1) and digits(0) to be 1. Now digits()
returns number of digits in the standard base-b representation
when x is truncated to an integer and the sign is ignored.
To be more precise: when abs(int(x)) > 0, this function returns
the value 1 + ilog(x, b). When abs(int(x)) == 0, then this
function returns the value 1.
As the result of the above digits() change, the repeat.cal
resource file script was modified to remove the special
case for repeating a value of 1. Also the regress tests
#715, #977 and #978 were changed.
Made a minor improvement to the "help places" documentation.
Fixed dms_neg(a) in deg.cal thanks to a bug report by kaa
<kaa76 at pochtamt dot ru>.
The following are the changes from calc version 2.11.6.0 to 2.11.6.2:
Clarified remark in lucas.cal about use of n mod 2^n == 0.
Fixed help typos reported by Marc Mezzarobba <mm at mm dot ovh dot org>.
Forced system("") to return 0 under windoz.
The direct.h include file is not used when compiling under Cygwin.
Fixed bug where random(10,11) caused calc to dump core when issued
the 2nd time.
Moved the setting of the Makefile variable ${CALC_INCDIR} to
the section where things like ${BINDIR} and ${LIBDIR} are set.
Idea from Clifford Kite <kite_public1 at ev1 dot net>.
The Makefile is shipped mode 0644 since a number of folks
edit it (to build and check calc) as a non-root user and later
on su to root to install. Idea from Clifford Kite <kite_public1
at ev1 dot net>.
Added base2() builtin function to calc. Normally calc prints
values according to base(). Frequently some users want to see
a value in two bases. Flipping back and forth between to bases
is a bit of a pain. With base2(), calc will output a value twice:
; 234567
234567
; base2(16),
; 234567
234567 /* 0x39447 */
; 131072
131072 /* 0x20000 */
; base2(0),
; 131072
131072
By default, base2() is disabled. Calling base2(0) will also turn
off the double base mode. Thanks goes to Erik Anggard
<erik dot anggard at packetfront dot com> for his idea and
his initial patch.
Added repeat.cal as a calc resource file script:
repeat(digit_set, repeat_count)
Return the value of the digit_set repeated repeat_count times.
Both digit_set and repeat_count must be integers > 0.
For example repeat(423,5) returns the value 423423423423423,
which is the digit_set 423 repeated 5 times.
Makefile no longer makes a direct reference to Red Hat 6.0.
Added missing math_setmode2() prototype to zmath.h.
Fixed some implicit declarations of functions by either making
them explicit or by including the proper system .h files.
Makefile no longer uses -Wno-implicit flag, by default, for
gcc based compiles on calc source. Makefile now attempts to
compile no_implicit.c with an explicit -Wno-implicit arg in an
effort to determine of -Wno-implicit is a valid compiler flag.
If no_implicit.c is compiled with -Wno-implicit, then
the file no_implicit.arg is created with the contents
of the -Wno-implicit flag. Otherwise no_implicit.arg
is created as an empty file.
Added the Makefile variable ${HAVE_NO_IMPLICIT}, which if
not set to YES will prevent no_implicit.c from being
compiled and prevent the -Wno-implicit flag from being used.
If ${HAVE_NO_IMPLICIT} is not YES, then an empty no_implicit.arg
file is created and no_implicit.c is not compiled.
The seed.c file, because the pseudo_seed() function contains
calls to a number of various system functions, attempts to
compile with the -Wno-implicit flag (if allowed by the
formation of the no_implicit.arg file).
Misc make depend fixes and cleanup.
Fixed formation of the custom/.all file.
Fixed repeat(1, repeat_count) bug.
The following are the changes from calc version 2.11.5.5 to 2.11.5.9:
Now using version numbers of one of these forms:
x.y.z.w
x.y.z
x.y
Changed the READLINE_LIB Makefile variable to not link with -lreadline
by default. If you do have readline, we recommend that you use it.
If you can install the GNU readline:
http://freshmeat.net/projects/gnureadline/
http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
we recommend it. But if not, you should set the USE_READLINE,
READLINE_LIB, and READLINE_INCLUDE Makefile variables to empty.
NOTE: See the BUGS file for a Linux issue when compiling calc
with -O (or -O2 or -O3) AND with -g (or -g3) AND with readline.
Removed an obsolete reference to TOPDIR. This was fixed thanks to
a bug report by Clifford Kite <kite_public1 at ev1 dot net>.
Fixed other inconsistencies related to things like BINDIR.
Fixed calc man page so that is refers to -f instead of the old -S flag.
Fixed thanks to Clifford Kite <kite_public1 at ev1 dot net> for
point this out.
All for loops end with /dev/null to avoid any problems related
to systems that cannot grok empty for loops.
Changed the libcalc functions creal and cimag to c_real and c_imag
to about conflicts with new libc such as those used by gcc v3.
Thanks Eli Zaretskii <eliz at is dot elta dot co dot il> and
Martin Buck <m at rtin-buck dot de> for alerting us to this conflict.
The Makefile no longer hard code's /usr/include. Instead it uses
the ${INCDIR} Makefile variable. Thanks goes to Eli Zaretskii
<eliz at is dot elta dot co dot il> for pointing out this inconsistency.
Added mods to support compilation under DJGPP. DJGPP runs on 386
and newer PCs running DOS or dos-compatible operating systems.
See http://www.delorie.com/djgpp/. Thanks goes to Eli Zaretskii
<eliz at is dot elta dot co dot il> for sending in these mods.
Updated README.WINDOWS to include information on building with DJGPP.
The pld folks are building RPMs based on our calc distributions.
See: ftp://ftp.pld.org.pl/dists/ra/PLD/i686/PLD/RPMS or
http://ftp.pld.org.pl/dists/ra/PLD/i686/PLD/RPMS more information.
We appreciate their work in this regard. In the next release, we
plan to also build and release our own RPMs based on their efforts.
Changed the Makefile variable CUSTOMLIBDIR to CUSTOMCALDIR.
Changed the Makefile variable CSHAREDIR to CALC_SHAREDIR.
Changed the Makefile variable INCDIRCALC to CALC_INCDIR.
Removed the Makefile variable SHAREDIR.
Updated the HOWTO.INSTALL and README.WINDOWS files.
Fixed definition of MAXUFULL. Thanks to a bus report from
Jill Poland <jpoland at cadence dot com>.
The following are the changes from calc version 2.11.5t4.1 to 2.11.5t4.4:
Updated dependency rules in Makefiles.
NOTE: -DSRC, as used in 2.11.5t4.1 was renamed -DCALC_SRC
in a later version.
Calc include files use #include "foo.h" to include other calc
header files if -DCALC_SRC. Otherwise they use <calc/foo.h>.
The -DCALC_SRC symbol is defined by default in calc's Makefile
and so it uses the header files from within the calc src tree.
If an external non-calc program includes an installed calc
header file (from under /usr/include), and it does NOT define
CALC_SRC, then it will obtain the calc header files from the
correct system location (such as /usr/include/calc/foo.h).
Added calc builtin function: version() which returns the calc
version string.
Added subject requirements for the calc-tester-request and
calc-bugs-mail EMail aliases. See:
http://www.isthe.com/chongo/tech/comp/calc/email.html
for details.
Corrected a bug that incorrectly set the default calc path
back in version 2.11.5t4. The default CALCPATH is now:
.:./cal:~/.cal:/usr/share/calc:/usr/share/calc/custom
and the default CALCRC is now:
/usr/share/calc/startup:~/.calcrc:./.calcinit
This fixes the missing bindings error and it places the calc
resource files into the default path.
If you are using the GNU readline then the Makefile recommends that
you link with the ncurses library.
Applied Makefile, cscript/Makefile and custom/Makefile patches to
fix install mode problems, to deal with sorting and dates in I18n
environments (such as Japanese), to fix some problems with calc.spec
and to fix the cscript #! header lines. Thanks goes to KAWAMURA Masao
(kawamura at mlb.co.jp) for the bug report and patch!
Fixed headers on fproduct.calc powerterm.calc 4dsphere.calc so
that they are correcly changed on installation.
Added ${GREP} Makefile variable.
The top level Makefile now sets LANG=C and passes it down to
lower level Makefiles.
Updated URLs in cal/lucas.cal comments.
Now shipping calc.spec, inst_files, spec-template and Makefile.linux
with the standard calc source distribution. Note that the standard
Makefile has not changed. The Makefile.linux only in minor ways
needed to build calc rpms.
Added $T Makefile variable. $T is the top level directory under
which calc will be installed. The calc install is performed under $T,
the calc build is performed under /. The purpose for $T is to allow
someone to install calc somewhere other than into the system area.
For example when forming the calc rpm, the Makefile is called with
T=$RPM_BUILD_ROOT. If $T is empty, calc is installed under /.
Removed all echo_XYZ rules except for echo_inst_files from lower
level makefile. The calc.spec will use a make install rule
with T=$RPM_BUILD_ROOT.
Updated LIBRARY file with instructions related to -DCALC_SRC,
the new default include file location and -lcustcalc.
The following are the changes from calc version 2.11.5t3 to 2.11.5t4:
The Makefile will now send both stdout and stderr to /dev/null
when compiling hsrc intermediates.
The config("verbose_quit") value was restored to a default
value of FALSE.
Added the cscript:
powerterm [base_limit] value
to write the value as the sum (or difference) of powers <= base_limit
where base_limit by default is 10000.
Applied a bug fix by Dr.D.J.Picton <dave at aps5.ph.bham.ac.uk>
to have help with no args print the default help file.
Renamed lavarand to LavaRnd.
Added rules to build a calc rpm.
All installed files are first formed as foo.new, and then moved
into place as foo via a atomic rename.
During installation, only files that are different are installed.
If the built file and the installed file are the same, no
installation is performed.
Calc has new default installation locations:
Makefile var old location new location
------------ ------------ ------------
TOPDIR /usr/local/lib <<no longer used>>
BINDIR /usr/local/bin /usr/bin
SHAREDIR <<not set>> /usr/share
INCDIR /usr/local/include /usr/include
LIBDIR /usr/local/lib/calc /usr/lib
CSHAREDIR <<not set>> /usr/share/calc
HELPDIR /usr/local/lib/calc/help /usr/share/calc/help
INCDIRCALC /usr/local/include/calc /usr/include/calc
CUSTOMLIBDIR /usr/local/lib/calc/custom /usr/share/calc/custom
CUSTOMHELPDIR /usr/local/lib/calc/help/custhelp /usr/share/calc/custhelp
CUSTOMINCDIR <<not set>> /usr/include/calc/custom
SCRIPTDIR /usr/local/bin/cscript /usr/bin/cscript
MANDIR <<not set>> /usr/share/man/man1
CATDIR <<not set>> <<not set>>
The Makefile variable ${TOPDIR} is no longer used. In some places
it has been replaced by a new Makefile variable ${SHAREDIR}. Some
of the old TOPDIR functionality has been replaced by ${CSHAREDIR}.
The install rules no longer remove old obsolete files. We assume
that these old files have long since vanished! :-)
Reduced the amount of output when doing a make all where nothing
needs to be made.
Reduced the amount of output when doing a make install where nothing
needs to be installed.
If you install using the new default locations, you can remove
old calc files installed in the old default location by doing:
make olduninstall
The following are the changes from calc version 2.11.5t2 to 2.11.5t2.1:
Fixed a bug, reported by Ernest Bowen <ernie at turing dot
une dot edu dot au> that caused command lines to be echoed in
interactive mode. Fixed a bug that sometimes left the terminal
in a non-echoing state when calc exited.
Renamed error codes E_FGETWORD1 and E_FGETWORD2 symbols to
E_FGETFIELD1 and E_FGETFIELD2.
Made a minor format change to the top of the calc man page.
The findid() function in file.c 2nd argument changed. The argument
is now mostly a writable flag. This function now finds the file
I/O structure for the specified file id, and verifies that
it is opened in the required manner (0 for reading or 1 for writing).
If the 2nd argument is -1, then no open checks are made at all and
NULL is then returned if the id represents a closed file.
The calc builtin function, fopen(), now allows one to specify
opening files in binary modes. On POSIX / Linux / Un*x-like systems,
text file is the same as a binary file and so 'b' to an fopen has
no effect and is ignored. However on systems such as MS Windoz
the 'b' / binary mode has meaning. See 'help fopen' for details.
On systems (such as MS Windoz), calc will produce a different error
message when it attempts to open /dev/tty. This will condition
will occur in things like calc scripts when they switch from ``batch
processing'' commands from and want to start interactive mode.
Regression tests fopen in binary mode in a few places where a
difference between text and binary string lengths matter.
The intfile calc resource file also uses binary mode.
Changed the rand() builtin and its related functions srand() and
randbit() to use the Subtractive 100 generator instead of the
additive 55 generator. This generator as improved random properties.
As a result, of this change, the values produced by rand(),
rand() and randbit() are now different.
Updated regression tests for new rand() and randbit() output.
Applied a bug fix from Ernest Bowen <ernie at turing dot une dot
edu dot au> dealing with one-line "static" declaration like:
static a = 1, b;
Added regression test 8310 to test for the static bug fix.
The following are the changes from calc version 2.11.5t0 to 2.11.5t1.1:
Fixed a compile problem with Linux 2.4 / Debian. Thanks goes
to Martin Buck <m at rtin-buck dot de> for help with this issue.
Fixed a bug in how L64_FORMAT (it determined if "%ld" or "%lld"
is appropriate for printing of 64 bit long longs) was determined.
Thanks goes to Martin Buck <m at rtin-buck dot de> for reporting
this bug and testing the fix.
An effort was made to make calc easier to build under Windoz
using the Cygwin project (http://sources.redhat.com/cygwin/).
Thanks to the work of Thomas Jones-Low (tjoneslo at softstart
dot com), a number of #if defined(_WIN32)'s have been added
to calc source. These changes should not effect Windoz
free system such as GNU/Linux, Solaris, POSIX-like, etc ...
Added windll.h to deal with Windoz related DLL issues.
Using the convention of 'extern DLL' instead of 'DLL extern'
to deal with symbols that export to or import from a DLL.
Added HAVE_MALLOC_H, HAVE_STDLIB_H, HAVE_STRING_H, HAVE_TIMES_H,
HAVE_SYS_TIMES_H, HAVE_TIME_H, HAVE_SYS_TIME_H, HAVE_UNISTD_H
and HAVE_URANDOM to the Makefile. If these symbols are empty,
then the Makefile looks for the appropriate system include file.
If they are YES, then the Makefile will assume they exist.
If they are NO, then the Makefile will assume they do not exist.
Changed HAVE_URANDOM to match the empty, YES, NO values.
If HAVE_URANDOM is empty, then the Makefile will look for /dev/urandom.
If HAVE_URANDOM is YES, then the Makefile will assume /dev/urandom exists.
If HAVE_URANDOM is NO, then the Makefile will assume /dev/urandom does
not exist.
If TERMCONTROL is -DUSE_WIN32, then the Windoz terminal control
(no TERMIOS, no TERMIO, no SGTTY) will be assumed.
Added a win32_hsrc Makefile rule to create hsrc files appropriate
for a Windoz system using Cygwin gcc environment. Added win32.mkdef
which is used by the win32_hsrc rule to set the Windoz specific
Makefile values to build hsrc files. The hsrc files are built
under the win32 directory.
Added FPOS_POS_BITS, OFF_T_BITS, DEV_BITS and INODE_BITS Makefile
symbols to allow one to force the size of a file position, file
offset, dev and inode value. Leaving these values blank will
Makefile to determine their size.
Fixed a bug in the way file offsets, device and inode values are copied.
Added chi.cal for a initial stab as a Chi^2 function. The chi_prob()
function does not work well with odd degrees of freedom, however.
Added big 3 to config("resource_debug"). Calc resource file scripts
check for config("resource_debug") & 8 prior to printing internal debug
statements. Thus by default they do not print them.
Added intfile.cal as a calc resource file script:
file2be(filename)
Read filename and return an integer that is built from the
octets in that file in Big Endian order. The first octets
of the file become the most significant bits of the integer.
file2le(filename)
Read filename and return an integer that is built from the
octets in that file in Little Endian order. The first octets
of the file become the most significant bits of the integer.
be2file(v, filename)
Write the absolute value of v into filename in Big Endian order.
The v argument must be on integer. The most significant bits
of the integer become the first octets of the file.
le2file(v, filename)
Write the absolute value of v into filename in Little Endian order.
The v argument must be on integer. The least significant bits
of the integer become the last octets of the file.
Added the following help aliases:
copy blkcpy
read command
write command
quit command
exit command
abort command
cd command
show command
Added the cscript:
fproduct filename term ...
to write the big Endian product of terms to a filename. Use - for stdout.
Fixed calc path in help/script.
Added read-only parameter, config("windows") to indicate if the system
is MS windowz WIN32 like system.
Configuration values that used to return "true" or "false" now return
1 (a true value) or 0 (a false value). Thus one can do:
if (config("tab")) { ... } else { ... }
The configuration values that now return 1 or 0 are:
config("tilde")
config("tab")
config("leadzero")
config("blkverbose")
config("verbose_quit")
config("windows")
Now shipping a win32 sub-directory that contains hsrc .h files
that have been attempted to be built for windoz.
The following are the changes from calc version 2.11.4t1 to 2.11.4t2:
Added missing test8600.cal test file.
Fixes cscript files to deal with the -S flag being replaced by
-f and possibly other flags.
Added regression tests for builtin functions bernoulli, catalan,
euler, freeeuler, and sleep. Added non-base 10 regression tests
for digit, digits and places.
The bernoulli.cal script now just calls the bernoulli() builtin
function. It remains for backward compatibility.
The Makefile now builds have_fpos_pos.h to determine if the
a non-scalar FILEPOS has a __pos stucture element. If it does,
the FILEPOS_BITS is taken to be the size of just the __pos element.
Misc fixes related to non-scalar (e.g., structure) FILEPOS. Fixed
a compile problems where non-scalar FILEPOS were incorrectly assigned.
Fixed make depend rule.
Return an error on malloc / realloc failures for bernoulli and
euler functions.
Added MAKEFILE_REV make variable to help determine Makefile version.
Fixed the way the env rule reports Makefile values.
The following are the changes from calc version 2.11.3t0 to 2.11.4:
Increased the maximum number of args for functions from 100 to 1024.
Increased calc's internal evaluation stack from 1024 to 2048 args.
Added test8600.cal to the regression suite to test these new limits.
Updated and fixed misc typos in calc/README.
Clarified in the COPYING file that ALL calc source files, both
LGPL covered and exceptions to the LGPL files may be freely used
and distributed.
Added help files or updated for: bernoulli, calc_tty, catalan,
digit, digits, euler, freeeuler, places and sleep.
A collection of 18 patches from Ernest Bowen
<ernie at turing dot une dot edu dot au>:
(1) A new flag -f has been defined which has the effect of a read
command without the need to terminate the file name with a semicolon
or newline. Thus:
calc "read alpha; read beta;"
may be replaced by:
calc -f alpha -f beta
Quotations marks are recognized in a command like
calc -f 'alpha beta'
in which the name of the file to be read includes a space.
(2) Flags are interpreted even if they are in a string, as in:
calc "-q -i define f(x) = x^2;"
which has the effect of:
calc -q -i "define f(x) = x^2;"
To achieve this, the use of getopts() in calc.c has been dropped in
favor of direct reading of the arguments produced by the shell.
In effect, until a "--" or "-s" or a calc command (recognized
by not starting with '-') is encountered, the quotation signs in
command lines like the above example are ignored. Dropping getopts()
permits calc to specify completely the syntax rules calc will apply
to whatever it is given by the shell being used.
(3) For executable script (also called interpreter) files with first
line starting with "#!", the starting of options with -S has been
replaced by ending the options with -f. For example, the first line:
#! full_pathname_for_calc -S -q -i
is to be replaced by:
#! full_pathname_for_calc -q -i -f
Thus, if the pathname is /usr/bin/calc and myfile contains:
#!/usr/bin/calc -q -i -f
global deg = pi()/180;
define Sin(x) = sin(x * deg);
and has been made executable by:
chmod u+x myfile
myfile would be like a version of calc that ignored any startup
files and had an already defined global variable deg and a function
Sin(x) which will return an approximation to the sine of x degrees.
The invocation of myfile may be followed by other options (since
the first line in the script has only flagged options) and/or calc
commands as in:
./myfile -c read alpha '; define f(x) = Sin(x)^2'
(The quotation marks avoid shell interpretation of the semicolon and
parentheses.)
(4) The old -S syntax for executable scripts implied the -s flag so that
arguments in an invocation like
./myfile alpha beta
are passed to calc; in this example argv(0) = 'alpha', argv(1) =
'beta'. This has been changed in two ways: an explicit -s is required
in the first line of the script and then the arguments passed in the
above example are argv(0) = 'myfile', argv(1) = 'alpha', argv(1) = 'beta'.
In an ordinary command line, "-s" indicates that the shell words
after the one in which "-s" occurred are to be passed as arguments
rather than commands or options. For example:
calc "-q -s A = 27;" alpha beta
invokes calc with the q-flag set, one command "A = 27;", and two arguments.
(5) Piping to calc may be followed by calc becoming interactive.
This should occur if there is no -p flag but -i is specified, e.g.:
cat beta | calc -i -f alpha
which will do essentially the same as:
calc -i -f alpha -f beta
(6) The read and help commands have been changed so that several
files may be referred to in succession by separating their names
by whitespace. For example:
; read alpha beta gamma;
does essentially the same as:
; read alpha; read beta; read gamma;
This is convenient for commands like:
calc read file?.cal
when file?.cal expands to something like file1.cal file2.cal file3.cal:
myfiles='alpha beta gamma'
calc read $myfiles
or for C-shell users:
set myfiles=(alpha beta gamma)
calc read $myfiles
(7) The -once option for read has been extended to -f. For example,
calc -f -once alpha
will ignore alpha if alpha has been read in the startup files. In a
multiple read statement, -once applies only to the next named file.
For example
; read -once alpha beta -once gamma;
will read alpha and gamma only if they have not already been read,
but in any case, will read beta.
(8) A fault in the programming for the cd command has been corrected
so that specifying a directory by a string constant will work. E.g:
; cd "my work"
should work if the current directory has a directory with name "my work".
(9) new functions bernoulli(n) and euler(n) have been defined to
return the Bernoulli number and the Euler number with index n.
After evaluation for an even positive n, this value and these for
smaller positive even n are stored in a table from which the values
can be reread when required. The memory used for the stored values
can be freed by calling the function freebernoulli() or freeeuler().
The function catalan(n) returns the catalan number with index n.
This is evaluated using essentially comb(2*n, n)/(n+1).
(10) A function sleep(n) has been defined which for positive n calls
the system function sleep(n) if n is an integer, usleep(n) for other
real n. This suspends operation for n seconds and returns the null
value except when n is integral and the sleep is interrupted by a
SIGINT, in which case the remaining number of seconds is returned.
(11) The effect of config("trace", 8) which displays opcodes of
functions as they are successfully defined has been restricted to
functions defined with explicit use of "define". Thus, it has been
deactivated for the ephemeral functions used for evaluation of calc
command lines or eval() functions.
(12) The functions digit(), digits(), places() have been extended to
admit an optional additional argument for an integral greater-than-one
base which defaults to 10. There is now no builtin limit on the
size of n in digit(x, n, b), for example, digit(1/7, -1e100) which
would not work before can now be handled.
(13) The function, digits(x), which returns the number of decimal
digits in the integer part of x has been changed so that if abs(x) <
1, it returns 0 rather than 1. This also now applies to digits(x,b).
(14) Some programming in value.c has been improved. In particular,
several occurrences of:
vres->v_type = v1->v_type;
...
if (v1->v_type < 0) {
copyvalue(v1, vres);
return;
}
have been replaced by code that achieves exactly the same result:
vres->v_type = v1->v_type;
...
if (v1->v_type < 0)
return;
(15) Some operations and functions involving null-valued arguments
have been changed so that they return null-value rather than "bad
argument-type" error-value. E.g. null() << 2 is now null-valued
rather than a "bad argument for <<" error-value.
(16) "global" and "local" may now be used in expressions. For example:
; for (local i = 0; i < 5; i++) print i^2;
is now acceptable, as is:
; define f(x = global x) = (global x = x)^2;
which breaks wise programming rules and would probably better be handled
by something like:
; global x
; define f(t = x) = (x = t)^2;
Both definitions produce the same code for f. For non-null t, f(t)
returns t^2 and assigns the value of t to x; f() and f(t) with null t
return x^2.
Within expressions, "global" and "local" are to be followed by just one
identifier. In "(global a = 2, b)" the comma is a comma-operator; the
global variable a is created if necessary and assigned the value 2, the
variable b has to already exist. The statement "global a = 2, b" is
a declaration of global variables and creates both a and b if they
don't already exist.
(18) In a config object, several components have been changed from
long to LEN so that they will now be 32 bit integers for machines with
either 32 or 64-bit longs. In setting such components, the arguments
are now to less than 2^31. Before this change:
; config("mul2", 2^32 + 3)
would be accepted on a 64-bit machine but result in the same as:
; config("mul2", 3)
The following are the changes from calc version 2.11.2t0 to 2.11.2t1.0:
Fixed a bug whereby help files are not displayed correctly on
systems such as NetBSD 1.4.1. Thanks to a fix from Jakob Naumann.
Changed EMail addresses to use asthe.com. Changed URLs to use
www.isthe.com. NOTE: The EMail address uses 'asthe' and the web
site URL uses 'isthe'.
Using calc-bugs at asthe dot com for calc bug reports,
calc-contrib at asthe dot com for calc contributions,
calc-tester-request at asthe dot com for requests to join calc-tester and
calc-tester at asthe dot com for the calc tester mailing list.
Replaced explicit EMail addresses found this file with the <user at
site dot domain> notation to reduce the potential for those folks
to be spammed.
The Makefile attempts to detect the existence of /dev/urandom with -e
instead of the less portable -c.
Misc Makefile fixes.
The following are the changes from calc version 2.11.1t3 to 2.11.1t4:
Removed non-portable strerror() tests (3715, 3724 and 3728) from
calc/regress.cal.
Fixed missing strdup() from func.c problem.
Fixed a problem that would have come up on a very long #! command line
if the system permitted it.
The following are the changes from calc version 2.11.1 to 2.11.1t2.2:
Placed calc under version 2.1 of the GNU Lesser General Public License.
The calc commands:
help copyright
help copying
help copying-lgpl
should display the generic calc copyright as well as the contents
of the COPYING and COPYING-LGPL files.
Those files contain information about the calc's GNU Lesser General
Public License, and in particular the conditions under which you
are allowed to change it and/or distribute copies of it.
Removed the lint facility from the Makefile. Eliminated Makefile
variables: ${LCFLAGS}, ${LINT}, ${LINTLIB} and ${LINTFLAGS}.
Removed the lint.sed file.
Cleaned up help display system. Help file lines that begin with
'##' are not displayed.
Calc source and documentation now uses these terms:
*.cal files calc resource file
*.a files calc binary link library
#! files calc shell script
Renamed 'help stdlib' to 'help resource'. The 'help stdlib' is
aliased to 'help resource' for arg compatibility.
Renamed config("lib_debug") to config("resource_debug").
The config("lib_debug") will have the same effect as
config("resource_debug") for backward compatibility.
Renamed the source sub-directory lib to cal. The default $CALCPATH
now uses ./cal:~/cal (instead of ./lib:~/lib). Changed LIB_PASSDOWN
Makefile variable to CAL_PASSDOWN.
Fixed misc compile warnings and bugs.
Fixed problem of incorrect paths in the formation of installed
calc shell scripts.
Changed the recommended Comqaq cc compile to be -std0 -fast -O4 -static.
Fixed a problem related to asking for help for a non-existent file.
Added ./.calcinit to the default calcrc.
Added cscript/README and help cscript to document the calc shell
script supplied with calc.
The following are the changes from calc version 2.11.0t10 to 2.11.0t11:
Misc code cleanup. Removed dead code. Removed trailing whitespace.
Fixed whitespace to make the best use of 8 character tabs.
Fixed some bugs relating to '// and %' in combination with some
of the rounding modes based on a patch from Ernest Bowen
<ernie at turing dot une dot edu dot au>.
A patch from Klaus Alexander Seistrup <klaus at seistrup dot dk>, when
used in combination with the GNU-readline facility, will prevent
it from saving empty lines.
Minor typos fixed in regress.cal
Added 8500 test series and test8500.cal to perform more extensive
tests on // and % with various rounding modes.
The 'unused value ignored' messages now start with Line 999: instead
of just 999:.
Fixed the long standing issue first reported by Saber-C in the
domul() function in zmil.c thanks to a patch by Ernest Bowen
<ernie at turing dot une dot edu dot au>.
Added zero dimensional matrices. A zero dimensional matrix is defined as:
mat A[] or A = mat[]
Updated the help/mat file to reflect the current status of matrices
including zero dimensional matrices.
Added indices() builtin function as written by Ernest Bowen <ernie
at turing dot une dot edu dot au> developed from an idea of Klaus
Seistrup <klaus at seistrup dot dk>. See help/indices for details.
Fixed a number of insure warnings as reported by Michel van der List
<vanderlistmj at sbphrd dot com>.
Fixed a number of help file typos discovered by Klaus Alexander
Seistrup <klaus at seistrup dot .dk>.
Removed REGRESS_CAL as a Makefile variable.
Added calcliblist and calcliblistfmt utility Makefile rules to allow
one to print the list of distribution files that are used (but not
built) to form either the libcalc.a or the libcustcalc.a library.
Added a patch from <Randall.Gray at marine dot csiro dot au> to make
^D terminate, but *only* if the line it is on is completely empty.
Removed lib/altbind and removed the CALCBINDINGS Makefile variable.
A new config("ctrl_d") value controls how the ``delete_char'', which
by default is bound to ^D (Control D), will or will not exit calc:
config("ctrl_d", "virgin_eof")
If ^D is the only character that has been typed on a line,
then calc will exit. Otherwise ^D will act according to the
calc binding, which by default is a Emacs-style delete-char.
This is the default mode.
config("ctrl_d", "never_eof")
The ^D never exits calc and only acts according calc binding,
which by default is a Emacs-style delete-char.
Emacs purists may want to set this in their ~/.calcrc startup file.
config("ctrl_d", "empty_eof")
The ^D always exits calc if typed on an empty line. This
condition occurs when ^D either the first character typed,
or when all other characters on the line have been removed
(say by deleting them).
Users who always want to exit when ^D is typed at the beginning
of a line may want to set this in their ~/.calcrc startup file.
Note that config("ctrl_d") apples to the character bound to each
and every ``delete_char''. So if an alternate binding it setup,
then those char(s) will have this functionality.
Updated help/config and help/mode, improved the readability and
fixed a few typos. Documented modes, block formats and block bases
("mode", "blkfmt" & "blkbase") that were previously left off out of
the documentation.
The config("blkbase") and config("blkfmt") values return strings
instead of returning integers. One cannot use integers to set
these values, so returning integers was useless.
Applied the dangling name fix from Ernest Bowen
<ernie at turing dot une dot edu dot au>.
Show func prints function on order of their indices, and with
config("lib_debug") & 4 == 4 some more details about the functions
are displayed.
Fixed another ``dangling name'' bug for when the object types list
exceeded 2000.
Fixed a bug related to opening to a calc session:
define res_add(a,b) = obj res {r} = {a.r + b.r};
...
obj res A = {1,2}. obj res B = {3,4}
A hash of an object takes into account the object type. If X and Y
are different kinds of objects but have the same component values,
they will probably return different rather than the same values for
hash(X) and hash(Y).
Added support for config("ctrl_d") to the GNU-readline interface
as written by Klaus Alexander Seistrup <klaus at seistrup dot dk>.
Currently, the config("ctrl_d", "virgin_eof") is not fully
supported. Under GNU-readline, it acts the same way as
config("ctrl_d", "empty_eof"). Emacs users may find this
objectionable as ``hi^A^D^D^D'' will cause calc to exit due to
the issuing of one too many ^D's.
Emacs users may want to put:
config("ctrl_d", "never_eof"),;
into their ~/.calcrc startup files to avoid this problem.
Made misc documentation fixes.
Fixed the make depend rule.
Applied Ernest Bowen's <ernie at turing dot une dot edu dot au>
complex function power(), exp() and transcendental function patch:
Calc will return a "too-large argument" error-value for exp(x,
epsilon) if re(x) >= 2^30 or if an estimate indicates that the
result will have absolute value greater than 2^2^30 * epsilon.
Otherwise the evaluation will be attempted but may fail due to
shortage of memory or may require a long runtime if the result
will be very large.
The power(a, b, epsilon) builtin will return a "too-large result"
if an estimate indicates that the result will have absolute value
that is > 2^2^30 * epsilon. Otherwise the evaluation will be
attempted but may fail due to shortage of memory or may require
a long runtime if the result will be very large.
Changes have been made to the algorithms used for some special
functions sinh(), cosh(), tanh(), sin(), cos(), etc., that make
use of exp(). In particular tanh(x) is now much faster and
doesn't run out of memory when x is very large - the value to
be returned is then 1 to a high degree of accuracy.
When the true value of a transcendental function is 1, as is
cos(x) for x == 0, calc's version of the function will now return
1 rather than the nearest multiple of epsilon. E.g. cos(0, 3/8)
no longer returns 9/8.
The restriction of abs(n) < 1000000 on scale(x, n) has been
removed. The only condition n now has to satisfy for calc to
attempt the operation is n < 2^31, the same as for calc to
attempt x << n and x^n.
Changed root(x,n) so that when x is negative and n is odd it
returns the principal complex n-th root of x rather than -1, e.g.
root(-1,3) now returns -.5+.8660...i.
Changed power(a,b) to permit a to be negative when b is real.
E.g. power(-2,3) will now return 8 rather than cause a "negative
base" error.
Fixed several improper free and link problems in the comfunc.c code.
Removed BOOL_B64 symbol from Makefile.
The following config values return "true" or "false" strings:
tilde tab leadzero fullzero blkverbose verbose_quit
These config values can still be set with same boolean strings
("on", "off", "true", "false", "t", ...) as well as via the
numerical values 0 (for "false") and non-0 (for "true"), however.
Added -s to the calc command line. The -s flag will cause unused
args (args after all of the -options on the command line) to remain
as unevaluated strings.
If calc is called with -s, then the new function argv() will return
the number of strings on the command line. Also argv(n) will return
the n-th such string or null is no such string exists.
Calc now handles calc shell scripts. A calc shell script is an
executable file that starts with:
#!/usr/local/bin/calc -S
Where ``/usr/local/bin/calc'' is the path to the calc binary.
Additional -options may be added to the line, but it MUST
start with -S. For example, the executable file ``plus''
contain the following:
#!/usr/local/bin/calc -S -e
/*
* This is a simple calc shell script to add two values
*/
print eval(argv(0)) + eval(argv(1));
then the following command:
./plus 23 'pi(1e-5)'
will print:
26.14159
If calc is called with -S as the first arg, then calc will assume that
it is being called from a #! calc shell script file. The -S implies
the -s flag. If -i is not given, -S also implies -d and -p.
Fixed the problem with non-literal string type checking for the
C printf-like functions. Able to determine if "%ld" or "%lld"
is appropriate for printing of 64 bit long longs by way of the C
symbol L64_FORMAT in the longlong.h header file.
The following lines are treated as comments by calc:
#! this is a comment
# this is a comment
# this is a comment
#
# The lone # above was also a comment
## is also a comment
Improved how calc makes changes to file descriptor interactive state.
Moved state changing code to calc_tty() and orig_tty() in lib_calc.c.
The libcalc_call_me_last() function will restore all changed descriptor
states that have not already been restored.
Added the following read-only config values:
config("program") path to calc program or calc shell script
config("basename") basename of config("program")
config("version") calc version string
The following are the changes from calc version 2.11.0t8.9.1 to 2.11.0t9.4.5:
The config("verbose_quit") will control the printing of the message:
Quit or abort executed
when a non-interactive ABORT, QUIT or EXIT is encountered. By default,
config("verbose_quit") is TRUE and the message is printed. If one does:
config("verbose_quit", 0)
the message is disabled.
Added 8400 regression test set and test8400.cal to test the new
quit and config("verbose_quit") functionality.
Fixed the BigEndian BASEB==16 regression bugs by correctly swapping
16 bit HALFs in a 64 bit value (such as a 64 bit file pointer).
Added calclevel() builtin to calculation level at which it is called.
Added help/calclevel and help/inputlevel help files.
Removed regression tests 951 and 5984 so that the regress test will
run in non-interactively / without a TTY such as under Debian's
build daemon.
The eval(str) builtin will return an error-value rather than cause
an execution error str has a scan-error.
Declarations are permitted to end with EOF as well as a newline or ';'.
When prompt() occurs while reading a file, it will take input from
the terminal rather than taking it from a file. For example:
/* This demonstrates the use of prompt() and some other things */
config("verbose_quit", 0);
define getnumber() {
local x;
for (;;) {
x = eval(prompt(">>> "));
if (isnum(x))
return x;
print "Not a number! Try again";
}
}
print "This will display the sqrt of each number you enter";
print "Enter quit to stop";
for (;;) {
print sqrt(getnumber());
}
print "Good bye";
Comments entered at input terminal level may be spread over several
lines. For example:
/*
* Assume that this calc script is called: comment.cal
* Then these commands now work:
* cat comment.cal | calc
* calc < comment.cal
*/
print "Hello";
Added:
-D calc_debug[:lib_debug:[user_debug]]
to set the initial value of config("calc_debug"), config("lib_debug")
and config("user_debug").
The : separated strings of -D are interpreted as signed 32 bit values.
After an optional leading sign a leading zero indicates octal
conversion, and a leading ``0x'' or ``0X'' hexadecimal conversion.
Otherwise, decimal conversion is assumed.
Reordered the config structure moving calc_debug ahead of lib_debug.
Added bits 4 and 5 to config("calc_debug"):
4 Report on changes to the state of stdin as well as changes
to internal variables that control the setting and restoring
of stdin.
5 Report on changes to the run state of calc.
Fixed portability issue in seed.c relating to /dev/urandom and ustat.
Added a fix from Martin Buck <mb at netwings dot ch> to detect when
calc aborts early instead of completing the regression test.
Now 'make chk' will require the last line of calc output to
end in the string ``Ending regression tests''.
Added a patch from Martin Buck <mb at netwings dot ch> to allow use of
GNU-readline. Note that GNU-readline is not shipped with calc.
His patch only provides the hooks to use it. One must comment out:
USE_READLINE=
READLINE_LIB=
READLINE_INCLUDE=
and comment in:
USE_READLINE= -DUSE_READLINE
READLINE_LIB= -lreadline -lhistory
READLINE_INCLUDE= -I/usr/include/readline
in addition to pre-installing GNU-readline in your system to use
this facility.
Changed the "object already defined" math_error to a scanerror message.
Removed the limit on the number of object types.
Calc tarballs are now named calc-version.tar.gz and untar into
a sub-directory called calc-version.
Made a small change to declarations of static variables to reduce
the internal opcodes needed to declare them.
Fixed a permission problem on ranlib-ed *.a files that was reported
by Michael Somos <somos at grail dot cba dot csuohio dot edu>.
Added patch by Klaus Alexander Seistrup <klaus at seistrup dot dk>
related to GNU-readline:
+ enable calc specific bindings in ~/.inputrc
+ save a copy of your session to disk and reload them next
time you're using calc
+ only add a line to the history if it is different from
the previous line
Added the Makefile symbol HAVE_GETRUSAGE to determine if the
system supports the getrusage() system call.
Fixed the make depend code in the custom and sample Makefiles.
Fixed how the help/builtin file is formed. The help/Makefile is
now given the name of the native C compiler by the top level Makefile.
The include files are installed under INCDIRCALC (a new Makefile variable)
which by default is ${INCDIR}/calc. The INCDIR (also a new Makefile var)
by default is /usr/local/include. Include files previously installed
directly under ${LIBDIR} will be removed.
Added the piforever() function to lib/pi.cal. It was written by
Klaus Alexander Seistrup <klaus at seistrup dot dk> and was inspired by
an algorithm conceived by Lambert Meertens. (See also the ABC
Programmer's Handbook, by Geurts, Meertens & Pemberton, published
by Prentice-Hall (UK) Ltd., 1990.) The piforever() function prints
digits of pi for as long as your memory and system uptime allows. :-)
Fixed the URLs found thruout the source and documentation which did
not and in /, but should for performance and server load reasons.
Cleaned up and improved handling of "mat" and "obj". The comma in:
mat A[2], B[3];
is changed to whatever is appropriate in the context:
+ comma operator
+ separator of arguments in a function call
+ separator of arguments in a definition
etc.
The expression (mat A[2]), B[3] returns B[3], assuming B already
exists as something created by a statement like: global mat B[4].
What used to be done by the expression:
mat A[2], B[3]
will now require something like:
mat A[2], mat B[3] or A = mat[2], B = mat[3]
For example, if obj point and obj pair are known types, the
following is now allowed:
L = list(mat[2], mat[3], obj point, obj pair)
As another example, the following is allowed:
define f(a = mat[2] = {3,4}) = 5 * a;
as well as the following:
obj point {x,y}, PP = obj pair {A,B} = {obj point, obj point}
which creates two object types at compile time and when executed,
assigns a pair-object value to a variable PP.
Fixed a bug whereby a for loop would behave incorrectly. For example:
config("trace", 2),
global x;
define f() {for ( ; x > 0; x--) {print x;}}
x = 5, f()
will stop after printing 1 instead of looping forever.
Added values l_format, which when CHECK_L_FORMAT is defined ahead
of including longlong.h will help detect when a system can deal with
'long long' but not '%lld' in printf. If a system with 'long long'
uses '%ld' to print a 64 bit value, then l_format will be > 0;
otherwise if "%lld" is required, l_format will be < 0.
Added HAVE_STRDUP Makefile variable as well as the have_strdup.c
program that forms the have_strdup.h file. The have_strdup.h file
will define HAVE_STRDUP is the system has strdup(). If HAVE_STRDUP
is not defined, then calc will use calc_strdup() to simulate
the real strdup() function.
Calc no longer makes use of sys_errlist and sys_nerr. Some systems
no longer support these values (even though they should from a
legacy prospective). Calc now relies on the fact that strerror()
will return NULL of no such system error exists. System errors >=
10000 will be considered calc errors instead. The Makefile symbol
ERRNO_DECL has gone away as well as calc_errno.c and calc_errno.h.
System errors that are are not known to to the libc strerror()
function, will now print (via the strerror() calc builtin function)
something such as:
Unknown error 9999
Fixed some insure code inspection tool issues that were discovered
and investigated by Michel van der List <vanderlistmj at sbphrd dot com>.
Made an effort to ensure that the v_subtype of VALUES are initialized
to V_NOSUBTYPE thruout the source code.
Established a separate calc-bugs address from the calc-tester
mailing list. Using anti-spam address forms in order to try and
stay under the radar of spammers as much as one can do so.
The following are the changes from calc version 2.11.0t8 to 2.11.0t8.9:
Moved 'wishlist' enhancements from the help/todo file to a new
help/wishlist file. Ordered, by priority, help/todo items into
Very High, High and Medium priority items.
The BUGS file now has a 'bugs' section as well as a 'mis-features'
section.
Improved how calc internally dealt with reading EOF or '\0' characters.
Calc now allows multiple defines to occur on the same line:
(Thanks goes to Ernest Bowen <ernie at turing dot une dot edu dot au>)
define f8300(x) = x^2; define g8300(x) = 1 - x;
Improved calc's ability to deal with and recover from errors.
Added inputlevel() builtin to return the input processing level.
In an interact mode, inputlevel() returns 0. When directly reading
a calc script, inputlevel() returns 1. When reading a script which
in turn reads another script, inputlevel() returns 2. etc...
If $CALCRC has more than one file as in file1:file2 and an error
occurs in file1, then calc -c will not read file2.
Fixed some of the old EMail addresses found in calc documentation.
Added HAVE_USTAT, HAVE_GETSID, HAVE_GETPGID, HAVE_GETTIME, HAVE_GETPRID
and HAVE_URANDOM symbols to the Makefile. These symbols, along with
have_ustat.c, have_getsid.c, have_getpgid.c, have_gettime.c and
have_getprid.c form: have_ustat.h, have_getsid.h, have_getpgid.h,
have_gettime.h, have_getprid.h and have_urandom.h which in turn
are used by pseudo_seed() in seed.c to determine what types of
system services can be used to form a pseudo-random seed.
Fixed the way calc -c will continue processing $CALCRC when errors
are encountered. Unless -d is also given, calc -c will report
when calc is unable to open a $CALCRC file.
Fixed the lower level make depend rules.
Misc cleanup on the have_*.c support source files.
Misc source file cleanup for things such as } else { style consistency.
Fixed the basis for FNV-1 hashes. Prior to this fix, the hash()
builtin produced FNV hash values that did not match the FNV-1
algorithm as specified in:
http://www.isthe.com/chongo/tech/comp/fnv/index.html
Removed an unused argument in the function getbody() in codegen.c.
Encountering of EOF in getbody() will cause a scanerror rather then
stop activity. This will now result in a scanerror:
echo 'define f(x) { ' > myfile
calc -i read myfile
A '{' at the start of a command and a later matching '}' surrounding zero
or more statements (and possibly newlines) results in a function body to
be "evaluated". This permits another command to follow on the same
line as the '}' as in:
{display(5)} read something;
and:
{static a = 5} define f(x) = a + x;
String constants can now be concatenated. For example:
s = "curds" ' and ' "whey";
Added FNV hash to the regression test suite.
Added Ernest Bowen's <ernie at turing dot une dot edu dot au> fix for the
FNV regression test of the hash() builtin function.
Added Ernest Bowen's <ernie at turing dot une dot edu dot au> patch to
improve the way config("calc_debug"). Now the lower 4 bits of the
config("calc_debug") parameter have the following meaning:
n Meaning of bit n of config("calc_debug")
0 Outputs shell commands prior to execution.
1 Outputs currently active functions when a quit instruction
is executed.
2 Some details of shs, shs1 and md5 hash states are included
in the output when these are printed.
3 When a function constructs a block value, tests are
made that the result has the properties required for use of
that block, e.g. that the pointer to the start of the
block is not NULL, and that its "length" is not negative.
A failure will result in a runtime error.
Changed the meaning of (config("calc_debug") & 1) from only printing
the shell commands (and pausing) while displaying help files into
the printing of any shell command prior to execution.
Documented the meaning of config("lib_debug"):
n Meaning of bit n of config("lib_debug")
0 When a function is defined, redefined or undefined at
interactive level, a message saying what has been done
is displayed.
1 When a function is defined, redefined or undefined during
the reading of a file, a message saying what has been done
is displayed.
The value for config("lib_debug") in both oldstd and newstd is
3, but if calc is invoked with the -d flag, its initial value
is zero. Thus, if calc is started without the -d flag, until
config("lib_debug") is changed, a message will be output when a
function is defined either interactively or during the reading
of a file.
Changed the calc lib files to reflect the new config("lib_debug")
bit field meaning. Calc lib files that need to print extra information
should now do something such as:
if (config("lib_debug") & 3) {
print "obj xyz defined";
print "funcA([val1 [, val2]]) defined";
print "funcB(size, mass, ...) defined";
}
Fixed the help/custom_cal, help/new_custom, and help/copy files so
that they contain the correct contents instead of the 'usage' file.
Fixed problem with loss of bindings when calc -i args runs into
an error while processing 'args' and drops into interactive mode
without the terminal bindings being set.
Added patch from Ernest Bowen to establish the abort command as
well as to clarify the roles of quit and exit. See the help/command
file for details.
Updated to some extend, the help/statement and help/command help
files with new information about SHOW, QUIT, EXIT and ABORT.
Added show sizes to pzasusb8.cal.
Updated calc man page and help/usage file to reflect recent
command line changes.
Fixed a bug, reported by Michael Somos <somos at grail dot cba dot
csuohio dot edu>, which prevented calc -m from being used.
Fixed misc compiler warnings.
The following are the changes from calc version 2.11.0t7 to 2.11.0t7.5:
Calc has some new command line flags / command line meaning:
(Thanks goes to Ernest Bowen <ernie at turing dot une dot edu dot au>)
-i Go into interactive mode if possible.
-c Continue reading command lines even after an execution
error has caused the abandonment of a line
To understand the -i and -c effects, consider the following
file (call it myfile.cal) which has deliberate errors in it:
print 1;
mat A[1] = {2,3};
print 2;
epsilon(-1);
print 3;
calc read myfile
Reports an error on the 2nd line and exits; prints 1 only.
calc -c read myfile
Report errors on the 2nd and 4th lines and exits; prints 1,2 and 3.
calc -i read myfile
Report errors on the 2nd and gives you a prompt; prints 1 only.
calc -i -c read myfile
Report errors on the 2nd and 4th and gives you a prompt;
prints 1, 2 and 3.
cat myfile | calc
Reports an error on the 2nd line and exits; prints 1 only.
cat myfile | calc -c
Report errors on the 2nd and 4th lines and exits; prints 1,2 and 3.
Note that continuation refers to command lines, not to statements. So:
calc -c 'print "start"; mat A[1] = {2,3}; print "end";'
since it contains no newline, the whole string is compiled,
but execution is abandoned when the error is encountered and
the string ``end'' is not printed.
You can use your shell to supply newlines in your command line
arguments. For example in sh, ksh, bash:
calc -c 'print "start";
mat A[1] = {2,3};
print "end";'
will print both ``start'' and ``end''. C-shell users can do:
calc -c 'print "start"; \
mat A[1] = {2,3}; \
print "end";'
however sh, ksh, bash will not see ``end'' printed because their
shell will remove the internal newlines.
Added display(n) builtin which does almost the same as config("display",n)
except that rather than causing an execution with an out-of-range or
bad-type argument type, it simply writes a message to stderr. This
also now happens to the errmax() builtin.
Added qtime.cal to the standard calc library.
Added another command line flag to calc:
-d Disable display of the opening title and config("lib_debug",0)
The command:
calc 'read qtime; qtime(2)'
will output something like:
qtime(utc_hr_offset) defined
It's nearly ten past six.
whereas:
calc -d 'read qtime; qtime(2)'
will just say:
It's nearly ten past six.
A call of errmax(-1) will prevent errcount from aborting calc.
Add the function stoponerror(n) which, as the name implies, controls
if calc stop on an error based on the value of n:
n > 0 stop on error even if -c was given on the command line
n == 0 if -c, continue, without -c, stop
n < 0 continue on error, even if -c was given on the command line
Calc compilation now stops at the first scanerror.
Restored the feature where -p disables the printing of leading tabs
as of config("tab",0) had been executed. So using calc in a pipe:
calc -p 2+17 | whey
will write '19' instead of '\t19' to the whey command.
Updated calc man page and help/usage file to reflect recent
command line changes.
Converted start_done into a general calc run state enum called
run_state within the calc source.
Removed README.OLD.
Added the Makefile variable ${LCC} to invoke the local c compiler.
By default, ${CC} also run the ${LCC} compiler. The distinction is
useful when using something such as purify. In the case of ${LCC},
only the local C compiler is invoked. In the case of ${CC} a purify
compile is invoked. Only the source that must be compiled and run
on the local machine use ${LCC}; everything else uses ${CC}.
Fixed memory buffer related problem in eatstring() in token.c.
Fixed memory leaks related to putenv().
Fixed memory leaks related to srandom().
Fixed compilation warnings and problems on BSDI.
Removed ${CCMAIN} as a variable from the Makefile. Now files
use either ${CFLAGS} for general C source and ${ICFLAGS} for
intermediate C source (e.g., special code for building hsrc files).
The main calc URL is now:
http://www.isthe.com/chongo/tech/comp/calc/
Misc calc man page fixes.
The following are the changes from calc version 2.11.0t1 to 2.11.0t6.3:
Removed the makefile symbol MAIN. Now forcing all functions to correctly
be declared main. To satisfy some old broken compilers, a return 0;
(instead of an exit(0);) is used at the end of main().
A few of files that were added to calc used 4 character indentation
whereas most of calc uses 8 character indentation. These imported
sources have been changed to conform better with the calc style.
Added the program calc_errno.c and the Makefile symbol ERRNO_DECL.
If ERRNO_DECL is empty, calc_errno.c will try various ways to
declare errno, sys_errlist and sys_nerr. On success or when
it gives up, calc_errno will output the middle of the calc_errno.h
header file. If ERRNO_DECL is -DERRNO_NO_DECL, or -DERRNO_STD_DECL
or -DERRNO_OLD_DECL then the Makefile will build the middle
of the calc_errno.h header file without calc_errno.c's help.
The func.c file now includes the constructed header file calc_errno.h
to ensure that errno, sys_errlist and sys_nerr are declared correctly.
Changed check.awk to be more 'old awk' friendly.
Made some of the source a little more ++ friendly. We are NOT
porting calc to C++! We will NOT support C++ compilation of calc.
Calc will written ANSI C. We just compiled with a suggestion from
Love-Jensen, John <jlove-jensen at globalmt dot com> to make calc's version
of C a little more to C++ compilers. We are simply avoiding symbols
such as new or try for example.
Renamed README to README.OLD. Renamed README.FIRST to README.
Updated README, lib/README and BUGS to reflect new URLs and addresses.
Added a HOWTO.INSTALL file.
Reordered cc Makefile variable sets in the main Makefile.
Fixed a bug in hnrmod() and applied a fix that was reported by Ernest
Bowen <ernie at turing dot une dot edu dot au>. Added regression tests
1103 to 1112 to confirm the fix.
Fixed a bug in version.c related to MINOR_PATCHs in both the
empty and non-empty MINOR_PATCH cases.
Fixed malloc and bad storage issues reported by Michel van der List
<vanderlistmj at sbphrd dot com>.
Fixed some problems related to path processing while opening files.
Under extreme cases, an excessively long filename or CALCPATH value
could create problems. Placed guards in opensearchfile() function
in input.c to catch these cases.
Fixed cases were malloc failures were silently ignored in input.c.
Eliminated the PATHSIZE limit and the PATHSIZE symbol.
Added MAX_CALCRC to limit the length of the $CALCRC environment
variable to 1024 chars.
Fixed the magic number relating to the initial number of constants
declared by initconstants(). It is now related to the length
of the initnumbs[] NUMBER array.
Added a 'Dec Alpha / Compaq Tru64 cc (non-gnu) compiler set'
section to the main Makefile.
Fixed a string handling bug discovered by Dr.D.J.Picton
<dave at aps5 dot ph dot bham dot ac dot uk> in the custom demo code.
Fixed a bug in the hnrmod() builtin that was discovered by
Ernest Bowen <ernie at turing dot une dot edu dot au>.
Added FORCE_STDC symbol. When defined it will force __STDC__ like
conditions. Thus for compilers with as the Solaris cc compiler
that are ANSI-like but still define __STDC__ as 0, one can use
-DFORCE_STDC and make use of ANSI-like features.
Removed the CCSHS symbol from the Makefile. The shs.c and shs1.c
files are now compiled with full ${CFLAGS}.
The custom.c file is now compiled with full ${CFLAGS}.
Rewrote command line / argument processing code. Calc is now
using getopt(3) argument processing.
Fixed a memory leak related to converting strings to numbers
in the str2q() function in qio.c.
Fixed a problem with reading uninitialized memory in the
v_subtype of a VALUE in the copyvalue() function in value.c.
Fixed problems in func.c where temporary VALUEs were not
having their v_type elements initialized.
Fixed a memory leak in qpi() in qtrans.c.
Fixed a memory leak in math_getdivertedio() in zio.c.
Fixed a problem with points going beyond the end of allocated
memory in addstring() in string.c.
Fixed a memory leak in zgcdrem(), f_putenv(), zlog() and
zlog10() in zfunc.c.
Fixed a memory leak in zdiv() and zshift() in zmath.c.
Fixed memory leaks in zsrand() in zrand.c.
Fixed a memory leak in zsrandom1() in zrandom.c. Fixed memory
leaks associated with replacing the internal random state with
another random state.
Added seed() builtin to return a 64 bit seed for a
pseudo-random generator.
Added functionality from Ernest Bowen <ernie at turing dot une dot
edu dot au> to permit nested "= {...}" assignments for lists as well
as matrices and objects. Now one can have a list, matrix or object,
some of whose elements are lists, matrices or objects, to any depth
of recursion, and assign values to any number of particular elements
by an appropriate "initialization" expression. For example:
A = mat[2] = {list(1,2), list(3,4,list(5,6))};
and then assign values to the 6 number elements by:
A = {{7,8}, {9,10,{11,12}}};
Closed files that were previously left open from test4600.cal
as executed by regress.cal and from opening /dev/null by
regress.cal itself.
Fixed memory leaks from f_strprintf() and f_putenv() in func.c.
The regress.cal test suite calls freeredc(), freestatics() and
freeglobals() at the end of the test suite to free storage
consumed during the regression.
Added custom function custom("pzasusb8", n) and lib/pzasusb8.cal based on
Ernest Bowen's diagnostic patch.
Thanks to the efforts of Ernest Bowen <ernie at turing dot une dot
edu dot au> and Dr.D.J.Picton <dave at aps5 dot ph dot bham dot ac
dot uk>, a nasty endian-ness bug in the sha and sha1 hash functions
that showed up on machines such as the Sparc was fixed.
Added functionality from Ernest Bowen <ernie at turing dot une
dot edu dot au> to give arguments as well as function names after
definitions when config("lib_debug") >= 0.
Removed if (config("lib_debug") >= 0) { ... } the ends of most
of the calc library scripts because it was redundant with the
new config("lib_debug") >= 0 functionality. Some of the calc
library still has a partial section because some useful
additional information was being printed:
chrem.cal deg.cal lucas_tbl.cal randrun.cal
mfactor.cal mod.cal poly.cal seedrandom.cal
surd.cal varargs.cal
Fixed ellip.cal so that its defined function does not conflict with
the factor() builtin function.
Fixed mod.cal so that a defined function does not conflict with
the mod() builtin function.
The regression test suite now reads in most calc libs. A few
libs are not read because they, by design, produce output
when read even when config("lib_debug") is set to -1.
Increased the maximum number of object types that one can define
from 10 to 128.
Added a patch from Ernest Bowen <ernie at turing dot une dot edu
dot au> to correctly hash a V_STR value-type that has an \0 byte
inside it.
A patch from Ernest Bowen <ernie at turing dot une dot edu dot au> now
defines special meaning to the first 2 bits of config("lib_debug"):
bit 0 set => messages printed when inputisterminal
bit 1 set => messages printed when reading from a file
The lib/regress.cal regression suite does:
config("lib_debug", -4);
to eliminate lib messages (both bit 0 and bit 1 are not set).
Fixed misc compile warnings and notices.
The following are the changes from calc version 2.10.3t5.38 to 2.11.0t0:
Fixed a few compile problems found under Red Hat 6.0 Linux.
The following are the changes from calc version 2.10.3t5.38 to 2.11.3t5.46:
Fixed a bug discovered by Ernest Bowen related to matrix-to-matrix copies.
Bitwise operations on integers have been extended so that negative
integers are treated in the same way as the integer types in C.
Some changes have been made to lib/regress.cal and lib/natnumset.cal.
Removed V_STRLITERAL and V_STRALLOC string type constants and
renumbered the V_protection types.
Added popcnt(x, bitval) builtin which counts the number of
bits in x that match bitval.
Misc compiler warning fixes.
Fixed improper use of putchar() and printf() when printing rationals
(inside qio.c).
Fixed previously reported bug in popcnt() in relation to . values.
Calc man page changes per suggestion from Martin Buck
<Martin-2.Buck at student dot uni-ulm dot de>. The calc man page is
edited with a few more parameters from the Makefile.
Misc Makefile changes per Martin Buck <Martin-2.Buck at student dot
uni-ulm dot de>.
Removed trailing blanks from files.
Consolidated in the Makefile, where the debug and check rules are found.
Fixed the regress.cal dependency list.
Make chk and check will exit with an error if check.awk detects
a problem in the regression output. (Martin Buck)
Fixed print line for test #4404.
Moved custom.c and custom.h to the upper level to fix unresolved symbols.
Moved help function processing into help.c.
Moved nearly everything into libcalc.a to allow programs access to
higher level calc objects (e.g., list, assoc, matrix, block, ...).
Renamed PATCH_LEVEL to MAJOR_PATCH and SUB_PATCH_LEVEL to MINOR_PATCH.
Added integers calc_major_ver, calc_minor_ver, calc_major_patch
and string calc_minor_patch to libcalc.a. Added CALC_TITLE to hold
the "C-style arbitrary precision calculator" string.
The function version(), now returns a malloced version string
without the title.
Consolidated multiple SGI IRIX -n32 sections (for r4k, r5k and r10k)
into a single section.
The following are the changes from calc version 2.10.3t5.34 to 2.10.3t5.37:
Per request from David I Bell, the README line:
I am allowing this calculator to be freely distributed for personal uses
to:
I am allowing this calculator to be freely distributed for your enjoyment
Added help files for:
address agd arrow dereference free freeglobals freeredc freestatics
gd isptr mattrace oldvalue saveval & * -> and .
Fixed blkcpy() and copy() arg order and processing. Now:
A = blk() = {1,2,3,4}
B = blk()
blkcpy(B,A)
blkcpy(B,A)
will result in B being twice as long as A.
Since "make chk" pipes the regression output to awk, we cannot
assume that stdout and stderr are ttys. Tests #5985 and #5986
have been removed for this reason. (thanks to Martin Buck
<Martin-2.Buck at student dot uni-ulm dot de> for this report)
Fixed the order of prints in regress.cal. By convention, a print
of a test line happens after the test. This is because function
parsed messages occur after the function is parsed. Also the
boolean test will verify before any print statements. Therefore
a non-test line is tested and printed as follows:
y = sha();
print '7125: y = sha()';
The perm(a,b) and comb(a,b) have been extended to arbitrary real a and
integer b.
Fixed a bug in minv().
Moved string.c into libcalc.a.
The NUMBER union was converted back into a flat structure. Changes
where 'num' and 'next' symbols were changed to avoid #define conflicts
were reverse since the #define's needed to support the union went away.
Removed trailing blanks from files.
Ernest Bowen <ernie at turing dot une dot edu dot au> sent in the
following patch which is described in the next 34 points:
(0) In the past:
A = B = strcat("abc", "def");
would store "abc" and "def" as literal strings never to be freed, and
store "abcdef" once each for both A and B. Now the "abc" and "bcd"
are freed immediately after they are concatenated and "abcdef" is stored
only once, just as the number 47 would be stored only once for
A = B = 47;
The new STRING structure that achieves this stores not only the
address of the first character in the string, but also the "length"
with which the string was created, the current "links" count, and
when links == 0 (which indicates the string has been freed) the
address of the next freed STRING. Except for the null string "",
all string values are "allocated"; the concept of literal string
remains for names of variables, object types and elements, etc.
(1) strings may now include '\0', as in A = "abc\0def". In normal printing
this prints as "abc" and strlen(A) returns 3, but its "real" length
of 7 is given by size(A). (As before there is an 8th zero character
and sizeof(A) returns 8.)
(2) If A is an lvalue whose current value is a string of size n, then
for 0 <= i < n, A[i] returns the character with index i as an addressed
octet using the same structure as for blocks, i.e. there is no
distinction between a string-octet and a block-octet. The same
operations and functions can be used for both, and as before, an octet
is in some respects a number in [0,256) and in others a one-character
string. For example, for A = "abc\0def" one will have both A[0] == "a"
and A[0] == 97. Assignments to octets can be used to change
characters in the string, e.g. A[0] = "A", A[1] = 0, A[2] -= 32,
A[3] = " " will change the above A to "A\0C def".
(3) "show strings" now displays the indices, links, length, and some or all
of the early and late characters in all unfreed strings which are values
of lvalues or occur as "constants" in function definitions,
using "\n", "\t", "\0", "\252", etc. when appropriate. For example,
the string A in (1) would be displayed as in the definition there.
Only one line is used for each string. I've also changed the
analogous "show numbers" so that only some digits of numbers that
would require more than one line are displayed.
(4) "show literals" is analogous to "show constants" for number "constants"
in that it displays only the strings that have been introduced by
literal strings as in A = "abc". There is a major difference between
strings and numbers in that there are operations by which characters
in any string may be changed. For example, after A = "abc",
A[0] = "X" changes A to "Xbc". It follows that if a literal string
is to be constant in the sense of never changing, such a character-
changing operation should never be applied to that string.
In this connection, it should be noted that if B is string-valued, then
A = B
results in A referring to exactly the same string as B rather than to
a copy of what is in B. This is like the use of character-pointers in
C, as in
char *s1, *s2;
s1 = "abc";
s2 = s1;
To achieve the effect of
s2 = (char *) malloc(4);
strcpy(s2, s1);
I have extended the str() function to accept a string as argument. Then
A = str(B);
will create a new string at a different location from that of B but
with the same length and characters. One will then have A == B,
*A == *B, but &*A != &*B, &A[0] != &B[0].
To assist in analyzing this sort of thing, I have defined a links()
function which for number or string valued argument returns the number
of links to the occurrence of that argument that is being referred to.
For example, supposing "abc" has not been used earlier:
; A = "abc"
; links(A)
2
; links(A)
1
The two links in the first call are to A and the current "oldvalue";
in the second call, the only link is to A, the oldvalue now being 2.
(5) strcat(S1, S2, ...) works as before; contribution of a string stops when
'\0' is encountered. E.g.
strcat("abc\0def", "ghi")
will return "abcghi".
(6) For concatenation of full strings I have chosen to follow
some other languages (like Java, but not Mathematica which uses "<>")
and use "+" so that, e.g.
"abc\0def" + "ghi"
returns the string "abc\0defghi". This immediately gives obvious
meanings to multiplication by positive integers as in
2 * "abc" = "abc" + "abc" = "abcabc",
to negation to reverse as string as in
- "abc" = "cba",
to multiplication by fractions as in
0.5 * "abcd" = "ab",
(where the length is int(0.5 * size("abcd")), and finally, by combining
these to
k * A and A * k
for any real number k and any string A. In the case of k == 1, these
return a new string rather than A itself. (This differs from
"" + A and A + "" which return A.)
(7) char(x) has been changed so that it will accept any integer x or octet
as argument and return a string of size one with character value
x % 256. In the past calc has required 0 <= x < 256; now negative
x is acceptable; for example, 1000 * char(-1) will now produce the
same as 1000 * "\377" or 1000 * "\xff".
(8) For a string s, test(s) now returns zero not only for the null string
"" but also for a string all of whose characters are '\0'.
(9) Similarly <, <=, etc. now compare all characters including occurrences
of '\0' until a difference is encountered or the end of a string is
reached. If no difference is encountered but one string is longer than
the other, the longer string is considered as greater even if the
remaining characters are all '\0'.
(10) To retain the C sense of comparison of null-terminated strings I have
defined strcmp(S1, S2), and then, for completeness, strncmp(S1, S2, n).
For similar reasons, strcpy(S1, S2) and strncpy(S1, S2, n) have been
defined.
(11) For strings, I have defined | and & as bitwise "or" and "and"
functions, with S1 | S2 having the size of the larger of S1 and S2,
S1 & S2 having the size of the smaller of S1 and S2. By using, say,
4-character strings, one can simulate a C integral type so far as the
| and & operations are concerned. It then seemed appropriate to
use the operator ~ for a "bitwise complement" as in C. Thus I have
defined ~s for a string s to be the string of the same size as s
with each character being complemented by the C ~ operation.
(12) For boolean algebra work on strings it is convenient also to have
the bitwise xor and setminus binary operations. Using C's '^' for xor
would be confusing when this is used elsewhere for powers, so I
decided to use ~. For setminus, I adopted the commonly used '\'.
Strings of fixed size n can now be used for a boolean algebra
structure with 8 * n elements. The zero element is n * char(0),
the unity is n * char(-1), and one have all of the usual laws like
A & (B | C) == A & B | A * C, A \ B = A & ~B, etc.
(13) Having extended the bitwise operations for strings, it was appropriate
to do the same for integers. Definitions of the binary ~ and \
operations for non-negative integers are straightforward. For
the unary ~ operation, I decided to do what C does with integer
types, and defined ~N to be -N - 1. With the appropriate extensions of
|, &, \ and the binary ~, one gets in effect the boolean algebra of
finite sets of natural numbers and their complements, by identifying
the set with distinct integer elements i_1, i_2, ... with the integer
2^i_1 + 2^i_2 + ...
For ~N for non-integer real N, I have simply used -N. There is some
logic in this and it is certainly better than an error value.
I have not defined the binary operations |, &, ~, \ for non-integral
arguments.
The use of ~N in this way conflicts with calc's method of displaying
a number when it has to be rounded to config("display") decimals.
To resolve this, my preference would be to replace the printing of
"~" as a prefix by a trailing ellipsis "...", the rounding always
being towards zero. E.g. with config("display", 5), 1/7 would print
as ".14285..." rather than "~.14285". The config("outround")
parameter would determine the type of rounding only for the
equivalent of config("tilde", 0).
(14) For objects, users may create their own definitions for binary |,
&, ~ and \ with xx_or, xx_and, xx_xor, xx_setminus functions.
For unary ~ and \ operations, I have used the names xx_comp and
xx_backslash.
(15) For the obviously useful feature corresponding to cardinality of a
set, I have defined #S for a string S to be the number of nonzero bits
in S. For a degree of consistency, it was then appropriate to
define #N for a nonnegative integer N to be the number of nonzero bits
in the binary representation of N. I've extended this to arbitrary
real N by using in effect #(abs(num(N))). I feel it is better to make
this available to users rather than having #N invoke an error message
or return an error value. For defining #X for an xx-object X, I
have used the name xx_content to suggest that it is appropriate for
something which has the sense of a content (like number of members of,
area, etc.).
(16) Having recognized # as a token, it seemed appropriate to permit its
use for a binary operation. For real numbers x and y I have defined
x # y to be abs(x - y). (This is often symbolized by x ~ y, but it
would be confusing to have x ~ y meaning xor(x,y) for strings and
abs(x-y) for numbers.) Because '#' is commonly called the hash symbol,
I have used xx_hashop to permit definition of x # y for xx-objects.
(17) For a similar reason I've added one line of code to codegen.c so that
/A returns the inverse of A.
(18) Also for a list L, +L now returns the sum of the elements of L. For
an xx object A, +A requires and uses the definition of xx_plus.
(19) I have given the unary operators ~, #, /, \, and except at the
beginning of an expression + and -, the same precedence with
right-to-left associativity. This precedence is now weaker than
unary * and &, but stronger than binary & and the shift and power
operators. One difference from before is that now
a ^ - b ^ c
evaluates as a ^ (- (b ^ c)) rather than a ^ ((- b) ^ c).
(20) For octets o1, o2, I've defined o1 | o2, o1 & o2, o1 ~ o2, ~o1 so
that they return 1-character strings. #o for an octet o returns the
number of nonzero bits in o.
(21) For substrings I've left substr() essentially as before, but
for consistency with the normal block/matrix indexing, I've extended
the segment function to accept a string as first argument. Then
segment(A, m, n)
returns essentially the string formed from the character with index m
to the character with index n, ignoring indices < 0 and indices >=
len(A); thus, if m and n are both in [0, size(A))
the string is of length abs(m - n) + 1, the order of the characters
being reversed if n < m. Here the indices for a list of size len are
0, 1, ..., len - 1. As it makes some sense, if 0 <= n < size(A),
segment(A, n)
now returns the one-character string with its character being that with
index n in A. (I've made a corresponding modification to the segment
function for lists.) Some examples, if A = "abcdef",
segment(A,2,4) = "cde",
segment(A,4,2) = "edc",
segment(A,3) = "d",
segment(A, -2, 8) = "abcdef",
segment(A,7,8) = "".
(22) As essentially particular cases of segment(), I've defined
head(A, n) and tail(A, n) to be the strings formed by the first
or last abs(n) characters of A, the strings being4]5O~? reversed '
if n is negative. I've changed the definitions of head and tail for
lists to be consistent with this interpretation of negative n.
(23) Similarly I've left strpos essentially as at present, but search
and rsearch have been extended to strings. For example,
search(A, B, m, n)
returns the index i of the first occurrence of the string B in A
if m <= i < n, or the null value if there is no such occurrence.
As for other uses of search, negative m is interpreted as
size(A) + m, negative n as size(A) + n. For a match in this
search, all size(B) characters, including occurrences of '\0',
in B must match successive characters in A.
The function rsearch() behaves similarly but searches in reverse order
of the indices.
(24) A string A of length N determines in obvious ways arrays of M = 8 * N
bits. If the characters in increasing index order are c_0, c_1, ...
and the bits in increasing order in c_i are b_j, b_j+1, ..., b_j+7
where j = 8 * i, I've taken the array of bits determined by A to be
b_0, b_1, ..., b_M-1
For example, since "a" = char(97) and 97 = 0b01100001, and
"b" = char(98) = 0b01100010, the string "ab" determines the 16-bit
array
1000011001000110
in which the bits in the binary representations of "a" and "b" have
been reversed.
bit with index n in this array. This is consistent with the use of
bit for a number ch in [0,256), i.e. bit(char(ch), n) = bit(ch, n).
For n < 0 or n >= size(A), bit(A,n) returns the null value.
(25) For assigning values to specified bits in a string, I've defined
setbit(A, n) and setbit(A, n, v). The first assigns the value 1 to
bit(A, n), the second assigns test(v) to bit(A, n).
(26) For consistency with the corresponding number operations, the shift
operations A << n and A >> n have been defined to give what look
like right- and left-shifts, respectively. For example, "ab" << 2
returns the 16-bit array
0010000110010001
in which the array for "ab" has been moved 2 bits to the right.
(27) To achieve much the same as the C strcpy and strncpy functions for
null-terminated strings, strcpy(S1, S2) and strncpy(S1, S2, n) have
been defined. Unlike the blkcpy() and copy() functions, the copying
for these is only from the beginning of the strings. Also, unlike C,
no memory overflow can occur as the copying ceases when size(S1) is
reached. Note that these overwrite the content of S1 (which affects
all strings linked to it) as well as returning S1. Examples:
S = strcpy(6 * "x", "abc") <=> S = "abc\0xx"
S = strcpy(3 * "x", "abcdef") <=> S = "abc"
S = strncpy(6 * "x", "abcd", 2) <=> S = "ab\0xxx"
S = strncpy(6 * "x", "ab", 4) <=> S = "ab\0\0xx"
S = strncpy(6 * "x", "ab", 20) <=> S = "ab\0\0\0\0"
If a new string S not linked to S1 is to be created, this can be
achieved by using str(S1) in place of S1. For example, the strcpy in
A = "xxxxxx"
S = strcpy(str("xxxxxx"), "abc")
would not change the value of A.
(28) I've extended the definitions of copy(A, B, ssi, num, dsi) and
blkcpy(B, A, num, ssi, dsi) to allow for string-to-string copying
and block-to-string copying, but num is now an upper bound for the
number of characters to be copied - copying will cease before num
characters are copied if the end of the data in the source A or the
end of the destination B is reached. As with other character-changing
operations, copying to a string B will not change the locations of
B[0], B[1], ... or the size of B.
In the case of copying a string to itself, characters are copied in
order of increasing index, which is different from block-to-block
copying where a memmove is used. This affects only copy from a
string to itself. For example,
A = "abcdefg";
copy(A, A, , , 2);
will result in A == "abababa". If the overwriting that occurs here
is not wanted, one may use
A = "abcdefg";
copy(str(A), A, , , 2);
which results in A == "ababcde".
(29) perm(a,b) and comb(a,b) have been extended to accept any real a and
any integer b except for perm(a, b) with integer a such that b <= a < 0
which gives a "division by zero" error. For positive b, both functions
are polynomials in a of degree b; for negative b, perm(a,b) is a
rational function (1/((a + 1) * (a+2) ...) with abs(b) factors in the
denominator), and comb(a,b) = 0. (An obvious "todo" is to extend this
to complex or other types of a.)
(30) Although it is not illegal, it seems pointless to use a comma operator
with a constant or simple variable as in
; 2 * 3,14159
14159
; a = 4; b = 5;
; A = (a , b + 2);
; A
7
I have added a few lines to addop.c so that when this occurs a
"unused value ignored" message and the relevant line number are
displayed. I have found this useful as I occasionally type ','
when I mean '.'.
There may be one or two other changes resulting from the way I have
rewritten the optimization code in addop.c. I think there was a bug
that assumed that PTR_SIZE would be the same as sizeof(long). By
the way, the new OP_STRING is now of index rather than pointer type.
It follows that pointers are now used in opcodes only for global
variables. By introducing a table of addresses of global variables
like those used for "constants" and "literal strings", the use of
pointers in opcodes could be eliminated.
(31) When calc has executed a quit (or exit) statement in a function or
eval evaluation, it has invoked a call to math_error() which causes
a long jump to an initial state without freeing any data on the
stack, etc. Maybe more detail should be added to math_error(), but
to achieve the freeing of memory for a quit statement and at the same
time give more information about its occurrence I have changed the
way opcodes.c handles OP_QUIT. Now it should free the local variables
and whatever is on the stack, and display the name and line-number,
for each of the functions currently being evaluated. The last
function listed should be the "top-level" one with name "*".
Strings being eval-ed will have name "**".
Here is a demo:
; global a;
;
; define f(x) {local i = x^2; a++;
;; if (x > 5) quit "Too large!"; return i;}
f() defined
; define g(x) = f(x) + f(2*x);
g() defined
; g(2)
20
; g(3)
Too large!
"f": line 3
"g": line 0
"*": line 6
; eval("g(3)")
Too large!
"f": line 3
"g": line 0
"**": line 1
"*": line 7
; a
6
(32) I've made several small changes like removing
if (vp->v_type == V_NUM) {
q = qinv(vp->v_num);
if (stack->v_type == V_NUM)
qfree(stack->v_num);
stack->v_num = q;
stack->v_type = V_NUM;
return;
}
from the definition of o_invert. Presumably these lines were intended
to speed up execution for the common case of numerical argument.
Comparing the runtimes with and without these lines for inverting
thousands of large random numbers in a matrix suggest that execution
for real numbers is slightly faster without these lines.
Maybe this and other similar treatment of "special cases" should be
looked at more closely.
(33) The new lib script lib/natnumset.cal demonstrates how the new
string operators and functions may be used for defining and
working with sets of natural numbers not exceeding a
user-specified bound.
The following are the changes from calc version 2.10.3t5.28 to 2.10.3t5.33:
Added hnrmod(v, h, n, r) builtin to compute:
v % (h * 2^n + r), h>0, n>0, r = -1, 0 or 1
Changed lucas.cal and mersenne.cal to make use of hnrmod().
A number of changes from Ernest Bowen:
(1) introduction of unary & and * analogous to those in C;
For an lvalue var, &var returns what I call a
value-pointer; this is a constant which may be assigned to
a variable as in p = &var, and then *p in expressions has
the same effect as var. Here is a simple example of their use:
; define s(L) {local v=0; while (size(L)) v+= *pop(L);return v;}
s() defined
; global a = 1, b = 2;
; L = list(&a, &b);
; print s(L)
3
; b = 3;
; print s(L)
4
Octet-pointers, number-pointers, and string-pointers in
much the same way, but have not attempted to do much with
the latter two.
To print a pointer, use the "%p" specifier.
Some arithmetic operations has been defined for corresponding
C operations. For example:
; A = mat[4];
; p = &A[0];
; *(p+2) == A[2]
; ++p
; *p == A[1]
There is at present no protection against "illegal" use of &
and *, e.g. if one attempts here to assign a value to *(p+5),
or to use p after assigning another value to A.
NOTE: Unlike C, in calc &A[0] and A are quite different things.
NOTE: If the current value of a variable X is an octet,
number or string, *X may be used to to return the value of
X; in effect X is an address and *X is the value at X.
Added isptr(p) builtin to return 0 is p is not a pointer,
and >0 if it is a pointer. The value of isptr(p) comes from
the V_XYZ #define (see the top of value.h) of the value to
which p points.
To allow & to be used as a C-like address operator, use of it
has been dropped in calls to user-defined functions. For the
time being I have replaced it by the back-quote `. For example:
; global a
; define f(a,b) = a = b
; f(&a,5)
; print a
0
; f(`a,5)
; print a
5
However, one may use & in a similar way as in:
; define g(a,b) = *a = b
; g(&a, 7)
; print a
7
There is no hashvalue for pointers. Thus, like error values,
they cannot be used as indices in an association.
The -> also works in calc. For example:
; obj xy {x,y}
; obj uvw {u, v, w}
; obj xy A = {1,2}
; obj uvw B = {3,4,5}
; p = &A
; q = &B
; p->x
1
; p->y = 6
; A
obj xy {1, 6}
; q -> u
3
; p->y = q
; A
obj xy {1, v-ptr: 1400474c0}
; p->y->u
3
; p->y->u = 7
; B
obj uvw {7, 4, 5}
; p -> y = p
; A
obj xy {1, v-ptr: 140047490}
; p -> y -> x
1
; p->y->y
v-ptr: 140047490
; p->y->y-> x
1
; p->y->y->x = 8
; A
obj xy {8, v-ptr: 140047490}
(2) a method of "protecting" variables;
For the various kinds of "protection", of an l_value var,
bits of var->v_subtype, of which only bits 0 and 1 have been
used in the past to indicate literal and allocated strings.
This has meant initialization of var->v_subtype when a new var
is introduced, and for assignments, etc., examination of the
appropriate bits to confirm that the operation is to be permitted.
See help/protect for details.
(3) automatic "freeing" of constants that are no longer required.
For the "freeing" of constants, the definition of a NUMBER
structure so that a NUMBER * q could be regarded as a
pointing to a "freed number" if q->links = 0.
The old q->num was changed to a union q->nu which had a pointer
to the old q->num if q->links > 0 and to the next freed number
if q->links = 0. The old "num" is #defined to "nu->n_num".
The prior method calc has used for handling "constants" amounted
to leakage. After:
; define f(x) = 27 + x;
; a = 27;
It is of course necessary for the constant 27 to be stored, but
if one now redefines f and a by:
; define f(x) = 45 + x;
; a = 45;
There seems little point in retaining 27 as a constant and
therefore using up memory. If this example seems trivial,
replace 27 with a few larger numbers like 2e12345, or better,
-2e12345, for which calc needs memory for both 2e12345 and
-2e12345!
Constants are automatically freed a definition when a
function is re- or un-defined.
The qalloc(q) and qfree(q) functions have been changed so
that that q->links = 0 is permitted and indicates that q
has been freed. If a number has been introduced as a
constant, i.e. by a literal numeral as in the above
examples, its links becoming zero indicates that it is no
longer required and its position in the table of constants
becomes available for a later new constant.
(4) extension of transcendental functions like tan, tanh, etc.
to complex arguments
(5) definition of gd(z) and agd(z), i.e. the gudermannian and
inverse gudermannian
(6) introduction of show options for displaying information about
current constants, global variables, static variables, and cached
redc moduli.
To help you follow what is going on, the following show
items have been introduced:
show constants ==> display the currently stored constants
show numbers ==> display the currently stored numbers
show redcdata ==> display the currently stored redc moduli
show statics ==> display info about static variables
show real ==> display only real-valued variables
The constants are automatically initialized as constants and
should always appear, with links >= 1, in in the list of constants.
The show command:
show globals
has been redefined so that it gives information about all
current global and still active static variables.
(7) definition of functions for freeing globals, statics, redc values
To free memory used by different kinds of variable, the following
builtins have been added:
freeglobals(); /* free all globals */
freestatics(); /* free all statics */
freeredc(); /* free redc moduli */
free(a, b, ...); /* free specific variables */
NOTE: These functions do not "undefine" the variables, but
have the effect of assigning the null value to them, and so
frees the memory used for elements of a list, matrix or object.
See 10) below for info about "undefine *".
(8) enhancement of handling of "old value": having it return an
lvalue and giving option of disabling updating.
Now, by default, "." return an lvalue with the appropriate
value instead of copying the old value.
So that a string of commands may be given without changing
the "oldvalue", the new builtin:
saveval(0)
function simply disables the updating of the "." value.
The default updating can be resumed by calling:
saveval(1)
The "." value:
; 2 + 2
4
; .
4
can now be treated as an unnamed variable. For example:
; mat x[3,3]={1,2,3,4,5,6,7,8,9}
; x
; print .[1,2]
6
(9) for a list L defining L[i] to be same as L[[i]]
(10) extending undefine to permit its application to all user-defined
functions by using "undefine *".
The command:
undefine *
undefines all current user-defined functions. After
executing all the above freeing functions (and if
necessary free(.) to free the current "old value"), the
only remaining numbers as displayed by:
show numbers
should be those associated with epsilon(), and if it has been
called, qpi().
(11) storing the most recently calculated value of qpi(epsilon)i and
epsilon so that when called again with the same epsilon it
is copied rather than recalculated.
(12) defining trace() for square matrices
(13) expression in parentheses may now be followed by a qualifier
computable with its type
When an expression in parentheses evaluates to an lvalue
whose current value is a matrix, list or object, it may
now be followed by a qualifier compatible with its type.
For example:
; A = list(1,2,4);
; B = mat[2,2] = {5,6,7,8};
; define f(x) = (x ? A : B)[[1]];
; print f(1), f(0)
2 6
; obj xy {x,y}
; C = obj xy = {4,5}
; p = &C
; *p.x
Not indexing matrix or object
; (*p).x
4
(14) swap(a,b) now permits swapping of octets in the same or different
blocks.
For example:
; A = blk() = {1,2,3}
; B = blk() = {4,5,6}
; swap(A[0], B[2])
; A
chunksize = 256, maxsize = 256, datalen = 3
060203
A few bug fixes from Ernest Bowen:
B1: qcmpi(q, n) in qmath.c sometimes gave the wrong result if
LONG_BITS > BASEB, len = 1 and nf = 0, since it then
reduces to the value of (nf != q->num.v[1]) in which
q->num.v[1] is not part of the size-1 array of HALFs for
q->num. At present this is used only for changing opcodes
for ^2 and ^4 from sequences involving OP_POWER to
sequences using OP_SQUARE, which has no effect on the
results of calculations.
B2: in matdet(m) in matfunc.c, a copy of the matrix m was not freed
when the determinant turned out have zero value.
B3: in f_search() in func.c, a qlinking of the NUMBER * storing the
the size of a file was not qfreed.
B4: in comalloc() in commath.c the initial zero values for real and
imag parts are qlinked but not qfreed when nonzero values are
assigned to them. Rather than changing
the definition of comalloc(), I have included any relevant
qfrees with the calls to comalloc() as in
c = comalloc();
qfree(c->real);
c->real = ...
B5: in calls to matsum(), zeros are qlinked but not qfreed. Rather
than changing addnumeric(), I have changed the definition
of matsum(m) so that it simply adds the components of m,
which requires only that the relevant additions be defined,
not that all components of m be numbers.
Simple arithmetic expressions with literal numbers are evaluated
during compilation rather than execution. So:
define f(x) = 2 + 3 + x;
will be stored as if defined by:
define f(x) = 5 + x;
Fixed bug with lowhex2bin conversation in lib_util.c. It did not
correctly convert from hex ASCII to binary values due to a table
loading error.
Fixed porting problem for NetBSD and FreeBSD by renaming the
qdiv() function in qmath.c to qqdiv().
Improved the speed of mfactor (from mfactor.cal library) for
long Mersenne factorizations. The default reporting loop
is now 10000 cycles.
SGI Mips r10k compile set is speced for IRIX6.5 with v7.2
compilers. A note for pre-IRIX6.5 and/or pre-v7.2 compilers
is given in the compile set.
Added regression tests related to saveval(), dot and pointers.
The following are the changes from calc version 2.10.3t5.11 to 2.10.3t5.27:
The todo help file as been updated with the in-progress items:
xxx - block print function is not written yet ...
Expanded the role of blk() to produce unnamed blocks as in:
B = blk(len, chunk)
and named blocks as in:
B = blk(str, len, chunk)
A block may be changed (with possible loss of data only if len is less
than the old len) by:
C = blk(B, len, chunk)
For an unnamed block B, this creates a new block C and copies
min(len, oldlen) octets to it, B remaining unchanged. For a named
block, the block B is changed and C refers to the same block as B,
so that for example, C[i] = x will result in B[i] == x. Thus, for a
named block, "B = " does nothing (other than B = B) in:
B = blk(B, len, chunk)
but is necessary for changing an unnamed block.
Renamed rmblk() to blkfree().
The builtin function blkfree(val) will free memory allocated to block.
If val is a named block, or the name of a named block, or the
identifying index for a named block, blkfree(val) frees the
memory block allocated to this named block. The block remains
in existence with the same name, identifying index, and chunksize,
but its size and maxsize becomes zero and the pointer for the start
of its data block null.
The builtin function blocks() returns the number of blocks that
have been created but not freed by the blkfree() function. When called
as blocks(id) and the argument id less than the number of named
blocks that have been created, blocks(id) returns the named block
with identifying index id.
Removed the artificial limit of 20 named blocks.
Added name() builtin to return the name of a type of value
as a string.
Added isdefined() to determine of a value is defined.
Added isobjtype() to determine the type of an object.
The isatty(v) builtin will return 1 if v is a file that associated
with a tty (terminal, xterm, etc.) and 0 otherwise. The isatty(v)
builtin will no longer return an error if v is not a file or
is a closed file.
The isident(m) builtin will return 1 if m is a identity matrix
and 0 otherwise. The isident(m) builtin will no longer return an
error if m is not a matrix.
Added extensive testing of isxxx() builtins and their operations
on various types.
Added md5() builtin to perform the MD5 Message-Digest Algorithm.
Renamed isset() to bit().
Blocks will expand when required by the copy() builtin function:
; f = fopen("help/full", "r")
; B = blk()
; B
chunksize = 256, maxsize = 256, datalen = 0
; copy(B, f)
; B
chunksize = 256, maxsize = 310272, datalen = 310084
2a2a2a2a2a2a2a2a2a2a2a2a2a0a2a20696e74726f0a2a2a2a2a2a2a2a2a...
NOTE: Your results will differ because changes to help/full.
The blkcpy() builtin args now more closely match that
of memcpy(), strncpy:
blkcpy(dst, src [, num [, dsi [, ssi]]])
The copy() builtin args now more closely match that the cp command:
copy(src, dst [, num [, ssi [, dsi]]])
but otherwise does the same thing as blkcpy.
Fixed lint problems for SunOS.
Added have_memmv.c and HAVE_MEMMOVE Makefile variable to control
use of memmove(). If empty, then memmove() is tested for and if
not found, or if HAVE_MEMMOVE= -DHAVE_NO_MEMMOVE then an internal
version of memmove() is used instead.
Added regression tests for sha, sha1 and md5 builtin hash functions.
Added xx_print to to the list of object routines are definable.
Added xx_print.cal to the library to demo this feature.
Moved blkcpy() routines have been moved to blkcpy.[ch].
The blkcpy() & copy() builtins can not copy to/from numbers.
For purposes of the copy, only the numerator is ignored.
Resolved a number of missing symbols for libcalc users.
Added lib_util.{c,h} to the calc source to support users of
libcalc.a. These utility routines are not directly used by
calc but are otherwise have utility to those programmers who
directly use libcalc.a instead.
Added sample sub-directory. This sub-directory contains a few
sample programs that use libcalc.a. These sample programs are
built via the all rule because they will help check to see that
libcalc.a library does not contain external references that
cannot be resolved. At the current time none of these sample
programs are installed.
Added a libcalc_call_me_last() call to return storage created
by the libcalc_call_me_first() call. This allows users of libcalc.a
to free up a small amount of storage.
Fixed some memory leaks associated with the random() Blum generator.
Fixed fseek() file operations for SunOS.
Fixed convz2hex() fencepost error. It also removes leading 0's.
Plugged a memory leak relating to pmod. The following calculation:
pmod(2, x, something)
where x was not 2^n-1 would leak memory. This has been fixed.
The following are the changes from calc version 2.10.3t5.1 to 2.10.3t5.10:
Misc printf warning bug fixes.
Calc now permits chains of initializations as in:
obj point {x,y} P = {1,2} = {3,4} = {5,6}
Here the initializations are applied from left to right. It may
look silly, but the 1, 2, ... could be replaced by expressions with
side effects. As an example of its use suppose A and B are
expressions with side effects:
P = {A, B}
has the effect of P.x = A; P.y = B. Sometimes one might want these in
the reverse order: P.y = B; P.x = A. This is achieved by:
P = { , B} = {A}
Another example of its use:
obj point Q = {P, P} = {{1, 2}, {3, 4}}
which results in Q having Q.x.x = 1, Q.x.y = 2, etc.
The role of the comma in has been changed. Expressions such as:
mat A[2], B[3]
are equivalent to:
(mat A[2]), (mat B[3])
Now, expr1, expr2 returns type of expr2 rather than EXPR_RVALUE. This
permits expressions such as:
(a = 2, b) = 3
Also, expr1 ? expr2 : expr3 returns type(expr2) | type(expr3).
This will make the result an lvalue (i.e. EXPR_RVALUE bit not set)
For example, if both expr2 and expr3 are lvalues. Then:
a ? b : c = d
has the effect of b = d if a is "nonzero", otherwise c = d.
This may be compared with
d = a ? b : c
which does d = b if a is "nonzero", otherwise d = c.
And now, expr1 || expr2 and expr1 && expr2 each return
htype(expr1)| type(expr2). So for example:
a || b = c
has the effect of a = c if a is "nonzero", otherwise b = c.
And for example:
a && b = c
has the effect of a = c if a is "zero", otherwise b = c.
At top level, newlines are neglected between '(' and the matching
')' in expressions and function calls. For example, if f() has been
already defined, then:
a = (
2
+
f
(
3
)
)
and
b = sqrt (
20
,
1
)
will be accepted, and in interactive mode the continue-line prompt
will be displayed.
When calc sees a "for", "while", "do", or "switch", newlines will be
ignored (and the line-continuation prompt displayed in interactive mode)
until the expected conditions and statements are completed.
For example:
s = 0;
for (i = 0; i < 5; i++)
{
s += i;
}
print s;
Now 's' will print '10' instead of '5'.
Added more regression tests to regress.cal. Changed the error
counter from 'err' to 'prob'. The errmax() is set very high and
the expected value of errcount() is kept in ecnt.
Added the 'unexpected' help file which gives some unexpected
surprises that C programmers may encounter.
Updated the 'help', 'intro' and 'overview' to reflect the
full list of non-builtin function help files. Reorered the
'full' help file.
The blkalloc() builtin has been renamed blk().
Only a "fixed" type of BLOCK will be used. Other types of
blocks in the future will be different VALUE types.
Introduced an undefine command so that
undefine f, g, ...
frees the memory used to store code for user-defined functions f,
g, ..., effectively removing them from the list of defined
functions.
When working from a terminal or when config("lib_debug") > 0 advice
that a function has been defined, undefined, or redefined is
displayed in format "f() defined".
Some experimental changes to block and octet handling, so that after:
B = blk(N)
B[i] for 0 <= i < N behaves for some operations like an lvalue for
a USB8 in B.
xx_assign added to object functions to permit the possibility of
specifying what A = B will do if A is an xx-object. Normal
assignment use of = is restored by the command: undefine
xx_assign.
For error-value err, errno(err) returns the error-code for err and
stores this in calc_errno; error(err) returns err as if
error(errno(err)) were called.
Anticipating probable future use, names have been introduced for
the four characters @, #, $, `. This completes the coverage of
printable characters on a standard keyboard.
Added sha() builtin to perform the old Secure Hash Algorithm
(SHS FIPS Pub 180).
Added sha1() builtin to perform the new Secure Hash Standard-1
(SHS-1 FIPS Pub 180-1).
Added ${LD_DEBUG} Makefile variable to allow for additional
libraries to be compiled into calc ... for debugging purposes.
In most cases, LD_DEBUG= is sufficient.
Added ${CALC_ENV} makefile variable to allow for particular
environment variables to be supplied for make {check,chk,debug}.
In most cases, CALC_ENV= CALCPATH=./lib is sufficient.
Added ${CALC_LIBS} to list the libraries created and used to
build calc. The CALC_LIBS= custom/libcustcalc.a libcalc.a
is standard for everyone.
Improved how 'make calc' and 'make all' rules work with respect
to building .h files.
Added 'make run' to only run calc interactively with the
${CALC_ENV} calc environment. Added 'make cvd', 'make dbx'
and 'make gdb' rules to run debug calc with the respective
debugger with the ${CALC_ENV} calc environment.
Added cvmalloc_error() function to lib_calc.c as a hook for
users of the SGI Workshop malloc debugging library.
Cut down on places where *.h files include system files.
The *.c should do that instead where it is reasonable.
To avoid symbol conflicts, *.h files produced and shipped
with calc are enclosed that as similar to the following:
#if !defined(__CALC_H__)
#define __CALC_H__
..
#endif /* !__CALC_H__ */
Added memsize(x) builtin to print the best approximation of the
size of 'x' including overhead. The sizeof(x) builtin attempts
to cover just the storage of the value and not the overhead.
Because -1, 0 and 1 ZVALUES are static common values, sizeof(x)
ignores their storage. Also sizeof(x) ignores the denominator of
integers, and the imaginary parts of pure real numbers. Added
regression tests for memsize(), sizeof() and size().
The following are the changes from calc version 2.10.3t4.16 to 2.10.3t5.0:
The calc source now comes with a custom sub-directory which
contains the custom interface code. The main Makefile now
drives the building and installing of this code in a similar
way that it drives the lib and help sub-directories. (see below)
Made minor edits to most help files beginning with a thru e.
The errno(n) sets a C-like errno to the value n; errno() returns
the current errno value. The argument for strerror() and error()
defaults to this errno.
Added more error() and errno() regression tests.
The convention of using the global variable lib_debug at the
end of calc library scripts has been replaced with config("lib_debug").
The "lib_debug" is reserved by convention for calc library scripts.
This config parameter takes the place of the lib_debug global variable.
By convention, "lib_debug" has the following meanings:
<-1 no debug messages are printed though some internal
debug actions and information may be collected
-1 no debug messages are printed, no debug actions will be taken
0 only usage message regarding each important object are
printed at the time of the read (default)
>0 messages regarding each important object are
printed at the time of the read in addition
to other debug messages
The "calc_debug" is reserved by convention for internal calc routines.
The output of "calc_debug" will change from release to release.
Generally this value is used by calc wizards and by the regress.cal
routine (make check). By convention, "calc_debug" has the following
meanings:
<-1 reserved for future use
-1 no debug messages are printed, no debug actions will be taken
0 very little, if any debugging is performed (and then mostly
in alpha test code). The only output is as a result of
internal fatal errors (typically either math_error() or
exit() will be called). (default)
>0 a greater degree of debugging is performed and more
verbose messages are printed (regress.cal uses 1).
The "user_debug" is provided for use by users. Calc ignores this value
other than to set it to 0 by default (for both "oldstd" and "newstd").
No calc code or shipped library will change this value other than
during startup or during a config("all", xyz) call.
The following is suggested as a convention for use of "user_debug".
These are only suggestions: feel free to use it as you like:
<-1 no debug messages are printed though some internal
debug actions and information may be collected
-1 no debug messages are printed, no debug actions will be taken
0 very little, if any debugging is performed. The only output
are from fatal errors. (default)
>0 a greater degree of debugging is performed and more
verbose messages are printed
Added more code related to the BLOCK type.
Added blkalloc() builtin.
Split NAMETYPE definition out into nametype.h.
Added OCTET type for use in processing block[i].
Added free, copy, cmp, quickhash and print functions for
HASH, BLOCK and OCTET.
Added notes to config.h about what needs to be looked at when
new configuration items are added.
The null() builtin now takes arguments.
Given the following:
obj point {x,y}
obj point P, Q
will will now create P and Q as obj point objects.
Added xx_or, xx_and, xx_not and xx_fact objfuncs.
Added the custom() builtin function. The custom() builtin
interface is designed to make it easier for local custom
modification to be added to calc. Custom functions are
non-standard or non-portable code. For these reasons, one must can
only execute custom() code by way of an explicit action.
By default, custom() returns an error. A new calc command line
option of '-C' is required (as well as ALLOW_CUSTOM= -DCUSTOM
Makefile variable set) to enable it.
Added -C as a calc command line option. This permits the
custom() interface to be used.
Added ALLOW_CUSTOM Makefile variable to permanently disable
or selective enable the custom builtin interface.
The rm() builtin now takes multiple filenames. If the first
arg is "-f", then 'no-such-file' errors are ignored.
Added errcount([count]) builtin to return or set the error
counter. Added errmax([limit]) to return or set the error
count limiter.
Added -n as a calc command line option. This has the effect
of calling config("all", "newstd") at startup time.
Added -e as a calc command line option to ignore all environment
variables at startup time. The getenv() builtin function will
still return values, however.
Added -i as a calc command line option. This has the effect
ignoring when errcount() exceeds errmax().
Changed the config("maxerr") name to config("maxscan"). The
old name of "maxerr" is kept for backward compatibility.
Using an unknown -flag on the calc command like will
generate a short usage message.
Doing a 'help calc' displays the same info as 'help usage'.
The 'make check' rule now uses the -i calc command line flag
so that regress.cal can continue beyond when errcount exceeds
errmax. In regress.cal, vrfy() reports when errcount exceeds
errmax and resets errmax to match errcount. This check
and report is independent of the test success of failure.
Fixed missing or out of order tests in regress.cal.
Misc Makefile cleanup in lib/Makefile and help/Makefile.
The default errmax() value on startup is now 20.
The custom() interface is now complete. See help/custom and
custom/HOW_TO_ADD files, which show up as the custom and new_custom
help files, for more information.
The help command will search ${LIBDIR}/custhelp if it fails to find
a file in ${LIBDIR}. This allows the help command to also print
help for a custom function. However if a standard help file and a
custom help file share the same name, help will only print the
standard help file. One can skip the standard help file and print
the custom help file by:
help custhelp/name
or by:
custom("help", "name")
Added minor sanity checks the help command's filename.
Added show custom to display custom function information.
Added the contrib help page to give information on how
and where to submit new calc code, modes or custom functions.
Added comment information to value.h about what needs to be
checked or modified when a new value type is added.
Both size(x) and sizeof(x) return information on all value types.
Moved size and sizeof information from func.c and into new file: size.c.
Added custom("devnull") to serve as a do-nothing interface tester.
Added custom("argv" [,arg ...]) to print information about args.
Added custom("sysinfo", "item") to print an internal calc #define
parameter.
The make depend rule also processes the custom/Makefile.
Added xx_max and xx_min for objfuncs.
The max(), min() builtins work for lists.
The following are the changes from calc version 2.10.3t3 to 2.10.3t4.15:
The priority of unary + and - to that of binary + and - when they are
applied to a first or only term. Thus:
-16^-2 == -1/256
-7^2 == -49
-3! == -6
Running ranlib is no longer the default. Systems that need RANLIB
should edit the Makefile and comment back in:
RANLIB=ranlib
Dropped support of SGI r8k.
Added support for the SGI r5k.
Added support for SGI Mips compiler version 7.1 or later.
Removed "random" as a config() option.
Removed CCZPRIME Makefile variable.
Added zsquaremod() back into zmod.c to be used by the Blum-Blum-Shub
generator for the special case of needing x^2 mod y.
Moved the Blum-Blum-Shub code and defines from zrand.c and zrand.h
into zrandom.c and zrandom.h. Now only the a55 generator resides
in zrand.c and zrand.h.
Added random, srandom and randombit help files.
Added random(), srandom() and randombit() builtin functions. The
cryptographically strong random number generator is code complete!
Removed cryrand.cal now that a Blum-Blum-Shub generator is builtin.
Improved the speed of seedrandom.cal. It now uses the 13th
builtin Blum-Blum-Shub seed.
The randmprime.cal script makes use of the Blum-Blum-Shub generator.
Added randombitrun.cal and randomrun.cal calc library files.
These are the Blum-Blum-Shub analogs to the randbitrun.cal
and randrun.cal a55 tests.
Improved hash.c interface to lower level hash functions. The hash
interface does not yet have a func.c interface ... it is still
under test.
Added randombitrun.cal to test the Blum-Blum-Shub generator.
Added calc.h, hash.h, shs.h and value.h to LIB_H_SRC because some
of the libcalc.a files need them.
In the original version, each call to newerror(str) created a new
error-value. Now a new value will be created only if str has not
been used in a previous call to newerror(). In effect, the string
serves to identify the error-value; for example:
return newerror("Non-integer argument");
can be used in one or more functions, some of which may be
repeatedly called, but after it has been called once, it will
always return the same value as if one had initially used the
assignment:
non_integer_argument_error = newerror("Non-integer argument")
and then in each function used:
return non_integer_argument_error;
The new definition of newerror() permits its freer use in cases like:
define foo(a) {
if (!isint(a))
return newerror("Non-integer argument");
...
}
One might say that "new" in "newerror" used to mean being different
from any earlier error-value. Now it means being not one of the
"original" or "old" error-values defined internally by calc.
As newerror() and newerror("") specify no non-null string, it has
been arranged that they return the same as newerror("???").
Added "show errors" command analogous to "show functions" for
user-defined functions. One difference is that whereas the
functions are created by explicit definitions, a new described
error is created only when a newerror(...) is executed.
Fixed macro symbol substitution problem uncovered by HPUX cpp bug in
HVAL and related zrand.h macros.
Added +e to CCMISC for HP-UX users.
Fixed the prompt bug.
Eliminated the hash_init() initialization function.
The 'struct block' has been moved from value.c to a new file: block.h.
Added "blkmaxprint" config value, which limits the octets to print
for a block. A "blkmaxprint" of 0 means to print all octets of a
block, regardless of size. The default is to print only the first
256 octets.
The "blkverbose" determines if all lines, including duplicates
should be printed. If TRUE, then all lines are printed. If false,
duplicate lines are skipped and only a "*" is printed in a style
similar to od. This config value has not meaning if "blkfmt" is
"str". The default value for "blkverbose" is FALSE: duplicate
lines are not printed.
The "blkbase" determines the base in which octets of a block
are printed. Possible values are:
"hexadecimal" Octets printed in 2 digit hex
"hex"
"octal" Octets printed in 3 digit octal
"oct"
"character" Octets printed as chars with non-printing
"char" chars as \123 or \n, \t, \r
"binary" Octets printed as 0 or 1 chars
"bin"
"raw" Octets printed as is, i.e. raw binary
"none"
The default "blkbase" is "hex".
The "blkfmt" determines for format of how block are printed:
"line" print in lines of up to 79 chars + newline
"lines"
"str" print as one long string
"string"
"strings"
"od" print in od-like format, with leading offset,
"odstyle" followed by octets in the given base
"od_style"
"hd" print in hex dump format, with leading offset,
"hdstyle" followed by octets in the given base, followed
"hd_style" by chars or '.' if no-printable or blank
The default "blkfmt" is "hd".
Fixed a bug in coth() when testing acoth using coth(acoth(x)) == x
within the rounding error.
Assignments to matrices and objects has been changed. The assignments in:
A = list(1,2,3,4);
B = makelist(4) = {1,2,3,4};
will result in A == B. Then:
A = {,,5}
will result in A == list(1,2,5,4).
Made minor edits to most help files beginning with a thru d.
Fixed error in using cmdbuf("").
The following are the changes from calc version 2.10.3t0 to 2.10.3t2:
Bumped to version 2.10.3 due to the amount of changes.
Renamed qabs() to qqabs() to avoid conflicts with stdlib.h.
Fixed a casting problem in label.c.
A lot of work was performed on the code generation by Ernest Bowen
<ernie at turing dot une dot edu dot au>. Declarations no longer
need to precede code:
define f(x) {
local i = x^2;
print "i = ":i;
local j = i;
...
}
The scope of a variable extends from the end of the declaration (including
initialization code for the variable) at which it is first created
to the limit given by the following rules:
local variable: to the end of the function being defined
global variable: to the end of the session with calc
static within a function definition: to the first of:
an end of a global, static or local declaration (including
initialization code) with the same identifier
the end of the definition
static at top level within a file: to the first of:
the next static declaration of the identifier at top level
in the file,
the next global declaration of the identifier at top level
in the file or in any function definition in the file,
the next global declaration of the identifier at any level
in a file being read as a result of a "read" command,
the end of the file.
The scope of a top-level global or static variable may be
interrupted by the use of the identifier as a parameter or local or
static variable within a function definition in the file being
read; it is restored (without change of value) after the definition.
For example, The two static variables a and b are created,
with zero value, when the definition is read; a is initialized
with the value x if and when f(x) is first called with a positive
even x, b is similarly initialized if and when f(x) is first called
positive odd x. Each time f(x) is called with positive integer x,
a or b is incremented. Finally the values of the static variables
are assigned to the global variables a and b, and the resulting
values displayed. Immediately after the last of several calls to
f(x), a = 0 if none of the x's have been positive even, otherwise
a = the first positive even x + the number of positive even x's,
and b = 0 if none of the x's have been positive odd, otherwise
b = the first positive odd x + the number of positive odd x's:
define f(x) {
if (isint(x) && x > 0) {
if (iseven(x)) {
static a = x;
a++;
} else {
static b = x;
b++;
}
}
global a = a, b = b;
print "a =",a,"b =",b;
}
Fixed some faults in the handling of syntax errors for the matrix
and object creation operators mat and obj. In previous versions of calc:
mat; <- Bad dimension 0 for matrix
mat A; <- Bad dimension 0 for matrix
global mat A; <- Bad dimension 0 for matrix
mat A[2], mat B[3] <- Semicolon expected
global mat A[2], mat B[3] <- Bad syntax in declaration statement
Now:
this statement has the same effect as
-------------- ----------------------
mat A[2], B[3] (A = mat[2]), B[3]
global mat A[2], B[3] global A, B; A = mat[2]; B = mat[3];
Initialization remains essentially as before except that for objects,
spaces between identifiers indicate assignments as in simple variable
declarations. Thus, after:
obj point {x,y};
obj point P, Q R = {1,2}
P has {0,0}, Q and R have {1,2}. In the corresponding expression with
matrices commas between identifiers before the initialization are ignored.
For example:
this statement has the same effect as
-------------- ----------------------
mat A, B C [2] = {1,2} A = B = C = (mat[2] = {1,2})
One can also do things like:
L = list(mat[2] = {1,2}, obj point = {3,4}, mat[2] = {5,6})
A = mat[2,2] = {1,2,3,4}^2
B = mat[2,2] = {1,2,3,4} * mat[2,2] = {5,6,7,8}
where the initialization = has stronger binding than the assignment = and
the * sign.
Matrices and objects can be mixed in declarations after any simple
variables as in:
global a, b, mat A, B[2] = {3,4}, C[2] = {4,5}, obj point P = {5,6}, Q
Fixed some bugs related to global and static scoping. See the
5200 regress test and lib/test5200.cal for details.
Optimized opcode generator so that functions defined using '=' do not
have two unreached opcodes. I.e.,:
define f(x) = x^2
show opcodes f
Also unreachable opcodes UNDEF and RETURN are now not included at
the end of any user-defined function.
Changed the "no offset" indicator in label.c from 0 to -1; this
permits goto jumps to the zero opcode position.
Changed the opcode generation for "if (...)" followed by
"break", "continue", or "goto", so that only one jump opcode is
required.
A label can now be immediately by a right-brace. For example:
define test_newop3(x) {if (x < 0) goto l132; ++x; l132: return x;}
The LONG_BITS make variable, if set, will force the size of a long
as well as forcing the USB8, SB8, USB16, SB16, USB32, SB32,
HAVE_B64, USB64, SB64, U(x) and L(x) types. If the longbits
program is given an arg (of 32 or 64), then it will output
based on a generic 32 or 64 bit machine where the long is
the same size as the wordsize.
Fixed how the SVAL and HVAL macros were formed for BASEB==16 machines.
Dropped explicit Makefile support for MIPS r8k since these processors
no longer need special compiler flags.
SGI 6.2 and later uses -xansi.
The following are the changes from calc version 2.10.2t33 to 2.10.2t34:
Fixed a bug related to fact().
Thanks to Ernest Bowen <ernie at turing dot une dot edu dot au>,
for two or three arguments,
search(x, val, start);
rsearch(x, val, start);
and for matrix, list or association x:
search(f, str, start);
rsearch(f, str, start);
for a file stream f open for reading, behave as before except for a few
differences:
(1) there are no limits on the integer-valued start.
(2) negative values of start are interpreted as offsets from the size of
x and f. For example,
search(x, val, -100)
searches the last 100 elements of x for the first i for which
x[[i]] = val.
(3) for a file f, when start + strlen(str) >= size(f) and
search(f, str, start) returns null, i.e. str is
not found, the file position after the search will be
size(f) - strlen(str) + 1
rather than size(f).
For four arguments:
search(a, b, c, d)
rsearch(a, b, c, d),
a has the role of x or f, and b the role of val or str as described
above for the three-argument case, and for search(), c is
essentially "start" as before, but for rsearch() is better for c
and d to be the same as for search(). For a non-file case, if:
0 <= c < d <= size(a),
the index-interval over which the search is to take place is:
c <= i < d.
If the user has defined a function accept(v,b), this is used rather
than the test v == b to decide for matrix, list, or association
searches when a "match" of v = a[[i]] with b occurs. E.g. after:
define accept(v,b) = (v >= b);
then calling:
search(a, 5, 100, 200)
will return, if it exists, the smallest index i for which
100 <= i < 200 and a[[i]] >= 5. To restore the effect of
the original "match" function, one would then have to:
define accept(v,b) == (v == b).
Renamed the calc symbol BYTE_ORDER to CALC_BYTE_ORDER in order
to avoid conflict.
Added beer.cal and hello.cal lib progs in support of: :-)
http://www.ionet.net/~timtroyr/funhouse/beer.html
http://www.latech.edu/~acm/HelloWorld.shtml
The following are the changes from calc version 2.10.2t25 to 2.10.2t32:
Eliminated use of VARARG and <varargs.h>. Calc supports only
<stdarg.h>. The VARARGS Makefile variable has been eliminated.
Source is converted to ANSI C. In particular, functions
will now have ANSI C style args. Any comments from old K&R
style args have been moved to function comment section.
Removed prototype.h. The PROTO() macro is no longer needed
or supported.
Added mfactor.cal to find the smallest factor of a Mersenne number.
The built .h file: have_times.h, determines if the system has
<time.h>, <times.h>, <sys/time.h> and <sys/times.h>.
Because shs.c depends on HASHFUNC, which in turn depends on
VALUE, shs.o has been moved out of libcalc.a. For the same
reasons, hash.h and shs.h are not being installed into
the ${LIBDIR} for now.
A number of the regression tests that need random numbers now
use different seeds.
Fixes for compiling under BSDI's BSD/OS 2.0. Added a Makefile
section for BSD/OS.
Added a Makefile compile section for Dec Alpha without gcc ...
provides a hack-a-round for Dec Alpha cc bug.
Minor comment changes to lucas.cal.
Added pix.cal, a slow painful but interesting way to compute pix(x).
Confusion over the scope of static and global values has been reduced
by a patch from Ernest Bowen <ernie at turing dot une dot edu dot au>.
The change introduced by the following patch terminates the
scope of a static variable at any static declaration with the
same name at the same level, or at any global declaration with
the same name at any level. With the example above, the scope
of the static "a" introduced in the third line ends when the
"global a" is read in the last line. Thus one may now use the
same name in several "static" areas as in:
; static a = 10;
; define f(x) = a + x;
; static a = 20;
; define g(x) = a + x;
; global a;
The first "a" exists only for the definition of f(); the second
"a" only for the definition of g(). At the end one has only
the global "a".
Ending the scope of a static variable in this way is consistent
with the normal use of static variables as in:
; static a = 10;
; define f(x) {static a = 20; return a++ + x;}
; define g(x) = a + x;
; global a;
The scope of the first "a" is temporarily interrupted by the
"static a" in the second line; the second "a" remains active
until its scope ends with the ending of the definition of f().
Thus one ends with g(x) = 10 + x and on successive calls to
f(), f(x) returns 20 + x, 21 + x, etc. With successive "static
a" declarations at the same level, the active one at any stage
is the most recent; if the instructions are being read from a
file, the scope of the last "static a" ends at the end-of-file.
Here I have assumed that no "global a" is encountered. As
there can be only one global variable with name "a", it seems
to me that its use must end the scope of any static "a". Thus
the changes I introduce are such that after:
; global a = 10;
; define f(x) = a + x;
; static a = 20;
; define g(x) = a + x;
; define h(x) {global a = 30; return a + x;}
; define i(x) = a + x;
g(x) will always return 20 + x, and until h(x) has been called,
f(x) and i(x) will return 10 + x; when h(x) is called, it
returns 30 + x and any later call to f(x) or i(x) will return
30 + x. It is the reading of "global a" in the definition of
h() that terminates the scope of the static a = 20, so that the
"a" for the last line is the global variable defined in the
first line. The "a = 30" is executed only when h() is called.
Users who find this confusing might be well advised to use
different names for different variables at the same scope level.
The other changes produced by the patch are more straightforward,
but some tricky programming was needed to get the possibility of
multiple assignments and what seems to be the appropriate order
of executions and assignments. For example, the order for the
declaration:
global a, b = expr1, c, d = expr2, e, f
will be:
evaluation of expr1;
assignment to b;
evaluation of expr2;
assignment to d;
Thus the effect is the same as for:
a = 0; b = expr1; c = 0; d = expr2; e = 0; f = 0;
The order is important when the same name is used for different
variables in the same context. E.g. one may have:
define f(x) {
global a = 10;
static a = a;
local a = a--;
while (--a > 0)
x++;
return x;
}
Every time this is called, the global "a" is assigned the value
10. The first time it is called, the value 10 is passed on to
the static "a" and then to the local "a". In each later call
the "static a = a" is ignored and the static "a" is one less than
it was in the preceding call. I'm not recommending this style of
programming but it is good that calc will be able to handle it.
I've also changed dumpop to do something recent versions do not do:
distinguish between static and global variables with the same name.
Other changes: commas may be replaced by spaces in a sequence of
identifiers in a declaration. so one may now write:
global a b c = 10, d e = 20
The comma after the 10 is still required. Multiple occurrences
of an identifier in a local declaration are now acceptable as
they are for global or static declarations:
local a b c = 10, a = 20;
does the same as:
local a b c;
a = b = c = 10;
a = 20;
The static case is different in that:
static a b c = 10, a = 20;
creates four static variables, the first "a" having a very short and
useless life.
Added new tests to verify the new assignments above.
Added the builtin test(x) which returns 1 or 0 according as x tests
as true or false for conditions.
Added have_posscl.c which attempts to determine if FILEPOS is
a scalar and defines HAVE_FILEPOS_SCALAR in have_posscl.h
accordingly. The Makefile variable HAVE_POSSCL determines
if have_posscl.c will test this condition or assume non-scalar.
Added have_offscl.c which attempts to determine if off_t is
a scalar and defines HAVE_OFF_T_SCALAR in have_posscl.h
accordingly. The Makefile variable HAVE_OFFSCL determines
if have_offscl.c will test this condition or assume non-scalar.
Reading to EOF leaves you positioned one character beyond
the last character in the file, just like Un*x read behavior.
Calc supports files and offsets up to 2^64 bytes, if the OS
and file system permits.
The following are the changes from calc version 2.10.2t4 to 2.10.2t24:
Added makefile debugging rules:
make chk like a 'make check' (run the regression tests)
except that only a few lines around interesting
(and presumable error messages) are printed.
No output if no errors are found.
make env print important makefile values
make mkdebug 'make env' + version information and a
make with verbose output and printing of
constructed files
make debug 'make mkdebug' with a 'make clobber'
so that the entire make is verbose and
a constructed files are printed
Improved instructions in 'BUGS' section on reporting problems.
In particular we made it easy for people to send in a full
diagnostic output by sending 'debug.out' which is made as follows:
make debug > debug.out
Added -v to calc command line to print the version and exit.
Fixed declarations of memcpy(), strcpy() and memset() in the
case of them HAVE_NEWSTR is false.
Fixed some compile time warnings.
Attempting to rewind a file this is not open generates an error.
Noted conversion problems in file.c in triple X comments.
Some extremely brain dead shells cannot correctly deal with if
clauses that do not have a non-empty else statement. Their
exit bogosity results in make problems. As a work-a-round,
Makefile if clauses have 'else true;' clauses for if statements
that previously did not have an else clause.
Fixed problems where the input stack depth reached the 10 levels.
The show keyword is now a statement instead of a command:
; define demo() {local f = open("foo", "w"); show files; fclose(f);}
; demo()
Added a new trace option for display of links to real and complex
numbers. This is activated by config("trace", 4). The printing of
a real number is immediately followed by "#" and the number of links
to that number; complex numbers are printed in the same except for
having "##" instead of "#". <ernie at turing dot une dot edu dot au>
The number of links for a number value is essentially the number of value
locations at which it is either stored or deemed to be stored. Here a
number value is the result of a reading or evaluation; when the result
is assigned to lvalues, "linking" rather than copying occurs. Different
sets of mutually linked values may contain the same number. For example:
a = b = 2 + 3; x, y = 2 + 3;
a and b are linked, and x and y are linked, but a and x are not linked.
Revised the credits help file and man page. Added archive help
file to indicate where recent versions of calc are available.
The regression test suite output has been changed so that it will
output the same information regardless of CPU performance. In
particular, cpu times of certain tests are not printed. This allows
one to compare the regression output of two different systems easier.
A matrix or object declaration is now considered an expression
and returns a matrix or object of the specified type. Thus one may
use assignments like:
A = mat[2]; /* same as: mat A[2]; */
P = obj point; /* same as: obj point P; */
The obj and mat keywords may be with "local", "global", "static" as in:
local mat A[2];
Several matrices or objects may be assigned or declared in the one
statement, as in:
mat A, B[2], C[3]; /* same as: mat A[2], B[2], C[3] */
except that only one matrix creation occurs and is copied as in:
A = B = mat[2];
Initialization of matrices and objects now occur before assignments:
mat A, B [2] = {1,2}; /* same as: A = B = (mat[2] = {1,2}); */
Missing arguments are considered as "no change" rather than
"assign null values". As in recent versions of calc, the default
value assigned to matrix elements is zero and the default for object
elements is a null value). Thus:
mat A[2] = {1,2};
A = { , 3};
will change the value of A to {1,3}.
If the relevant operation exists for matrices or has been defined for
the type of object A is, the assignment = may be combined with +, -, *,
etc. as in:
A += {3, 4}; /* same as: A[0] += 3; A[1] += 4; */
A += { }; /* same as: A += A; */
In (non-local) declarations, the earlier value of a variable may be
used in the initialization list:
mat A[3]={1,2,3}; mat A[3]={A[2],A[1],A[0]}; /* same as: A={3,2,1} */
Also:
mat A[3] = {1,2,3};
mat A[3] = {A, A, A};
produces a 3-element matrix, each of whose elements is a 3-element matrix.
The notation A[i][j] requires A[i] to be a matrix, whereas B[i,j]
accesses an element in a 2-dimensional matrix. Thus:
B == A[i] implies A[i][j] = B[j]
There is requirement in the use of A[i][j] that the matrices A[i]
for i = 0, 1, ... all be of the same size. Thus:
mat A[3] = {(mat[2]), (mat[3]), (mat[2])};
produces a matrix with a 7-element structure:
A[0][0], A[0][1], A[1][0], A[1][1], A[1][2], A[2][0], A[2][1]
One can initialize matrices and objects whose elements are matrices
and/or objects:
obj point {x,y}
obj point P;
obj point A = {P,P};
or:
obj point {x,y};
obj point P;
mat A[2] = {P,P};
A = {{1,2}, {3,4}};
The config("trace", 8) causes opcodes of newly defined functions
are displayed. Also show can now show the opcodes for a function.
For example:
config("trace", 8);
define f(x) = x^2;
show opcodes f;
define g(x,y) {static mat A[2]; A += {x,y}; return A;}
show opcodes g
g(2,3);
show opcodes g;
g(3,4);
The two sequences displayed for f should show the different ways
the parameter is displayed. The third sequence for g should also
show the effects of the static declaration of A.
Fixed a number of compiler warning and type cast problems.
Added a number of new error codes.
Misc bug fixes for gcc2 based Sparc systems.
Fixed a bug in the SVAL() macro on systems with 'long long'
type and on systems with 16 bit HALFs.
Reduced the Makefile CC set:
CCOPT are flags given to ${CC} for optimization
CCWARN are flags given to ${CC} for warning message control
CCMISC are misc flags given to ${CC}
CFLAGS are all flags given to ${CC}
[[often includes CCOPT, CCWARN, CCMISC]]
ICFLAGS are given to ${CC} for intermediate progs
CCMAIN are flags for ${CC} when files with main() instead of CFLAGS
CCSHS are flags given to ${CC} for compiling shs.c instead of CFLAGS
LCFLAGS are CC-style flags for ${LINT}
LDFLAGS are flags given to ${CC} for linking .o files
ILDFLAGS are flags given to ${CC} for linking .o files
for intermediate progs
CC is how the C compiler is invoked
Added more tests to regress.cal.
Port to HP-UX.
Moved config_print() from config.c to value.c so prevent printvalue()
and freevalue() from being unresolved symbols for libcalc.a users.
Calc will generate "maximum depth reached" messages or errors when
reading or eval() is attempted at maximum input depth.
Now each invocation of make is done via ${MAKE} and includes:
MAKE_FILE=${MAKE_FILE}
TOPDIR=${TOPDIR}
LIBDIR=${LIBDIR}
HELPDIR=${HELPDIR}
Setting MAKE_FILE= will cause make to not re-make if the Makefile
is edited.
Added libinit.c which contains the function libcalc_call_me_first().
Users of libcalc.a MUST CALL libcalc_call_me_first BEFORE THEY USE
ANY OTHER libcalc.a functions!
Added support for the SGI IRIX6.2 (or later) Mongoose 7.0 (or later)
C Compiler for the r4k, r8k and r10k. Added LD_NO_SHARED for
non-shared linker support.
Re-ordered and expanded options for the DEBUG make variable.
Make a few minor cosmetic comment changes/fixes in the main Makefile.
Statements such as:
mat A[2][3];
now to the same as:
mat M[3];
mat A[2] = {M, M};
To initialize such an A one can use a statement like
A = {{1,2,3}, {4,5,6}};
or combine initialization with creation by:
mat A[2][3] = {{1,2,3}, {4,5,6}};
One would then have, for example, A[1][0] = 4. Also, the inner braces
cannot be removed from the initialization for A:
mat A[2][3] = {1,2};
results in exactly the same as:
mat A[2] = {1,2};
Added rm("file") builtin to remove a file.
The regress test sections that create files also use rm() to remove
them before and afterward.
Added 4400-4500 set to test new mat and obj initialization rules.
Added 4600 to test version file operations.
Added CCZPRIME Makefile variable to the set for the short term
to work around a CC -O2 bug on some SGI machines.
Added regression test of _ variables and function names.
Added read of read and write, including read and write test for
long strings.
Fixed bug associated with read of a long string variable.
Renumbered some of the early regress.cal test numbers to make room
for more tests. Fixed all out of sequence test numbers. Fixed some
malformed regression reports.
Renamed STSIZE_BITS to OFF_T_BITS. Renamed SWAP_HALF_IN_STSIZE to
SWAP_HALF_IN_OFF_T.
The following are the changes from calc version 2.10.2t1 to 2.10.2t3:
Fixed bug in the regression suite that made test3400 and test4100
fail on correct computations.
The randbit() builtin, when given to argument, returns 1 random bit.
Fixed a bug in longlong.c which made is generate a syntax error
on systems such as the PowerPC where the make variable LONGLONG
was left empty.
By default, the Makefile leaves LONGLONG_BITS empty to allow for
testing of 64 bit data types. A few hosts may have problems with
this, but hopefully not. Such hosts can revert back to LONGLONG_BITS=0.
Improved SGI support. Understands SGI IRIX6.2 performance issues
for multiple architectures.
Fixed a number of implicit conversion from unsigned long to long to avoid
unexpected rounding, sign extension, or loss of accuracy side effects.
Added SHSCC because shs.c contains a large expression that some
systems need help in optimizing.
Added "show files" to display information about all currently open files.
Calc now prevents user-defined function having the same name as a
builtin function.
A number of new error codes (more than 100) have been added.
Added ctime() builtin for date and time as string value.
Added time() builtin for seconds since 00:00:00 1 Jan 1970 UTC.
Added strerror() builtin for string describing error type.
Added freopen() builtin to reopen a file.
Added frewind() builtin to rewind a file.
Added fputstr() builtin to write a null-terminated string to a file.
Added fgetstr() builtin to read a null-terminated string from a file.
Added fgetfield() builtin to read next field from file.
Added strscan() builtin to scan a string.
Added scan() builtin to scan of a file.
Added fscan() builtin to scan of a file.
Added fscanf() builtin to do a formatted scan of a file.
Added scanf() builtin to do a formatted scan of stdin.
Added strscanf() builtin to do a formatted scan of a string.
Added ungetc() builtin to unget character read from a file.
As before, files opened with fopen() will have an id different from
earlier files. But instead of returning the id to the FILEIO slot
used to store information about it, calc simply uses consecutive
numbers starting with 3. A calc file retains its id, even when the
file has been closed.
The builtin files(i) now returns the file opened with id == i
rather than the file with slot number i. For any i <= lastid,
files(i) has at some time been opened. Whether open or closed, it
may be "reopened" with the freopen() command. This write to a file
and then read it, use:
f = fopen("junk", "w")
freopen(f, "r")
To use the same stream f for a new file, one may use:
freopen(f, mode, newfilename)
which closes f (assuming it is open) and then opens newfilename on f.
And as before:
f = fopen("curds", "r")
g = fopen("curds", "r")
results in two file ids (f and g) that refer to the same file
name but with different pointers.
Calc now understands "w+", "a+" and "r+" file modes.
If calc opens a file without a mode there is a "guess" that mode
"r+" will work for any files with small descriptors found to be
open. In case it doesn't (as apparently happens if the file had
not been opened for both reading and reading) the function now also
tries "w" and "r", and if none work, gives up. This avoids having
"open" files with null fp.
The builtin rewind() calls the C rewind() function, but one may
now rewind several files at once by a call like rewind(f1, f2).
With no argument, rewind() rewinds all open files with id >= 3.
The functions fputstr(), fgetstr() have been defined to include the
terminating '\0' when writing a string to a file. This can be done
at present with a sequence of instructions like:
fputs(f, "Landon"); fputc(f, 0);
fputs(f, "Curt"); fputc(f, 0);
fputs(f, "Noll"); fputc(f, 0);
One may now do:
fputstr(f, "Landon", "Curt", "Noll");
and read them back by:
rewind(f);
x = fgetstr(f); /* returns "Landon" */
y = fgetstr(f); /* returns "Curt" */
z = fgetstr(f); /* returns "Noll" */
The builtin fgetfield() returns the next field of non-whitepsace
characters.
The builtins scan(), fscan(), strscan() read tokens (fields of
non-whitepsace characters) and evaluates them. Thus:
global a,b,c;
strscan("2+3 4^2\n c=a+b", a, b, 0);
results in a = 5, b = 16, c = 21
The functions scanf, fscanf, strscanf behave like the C functions
scanf, fscanf, sscanf. The conversion specifiers recognized are "%c",
"%s", "%[...]" as in C, with the options of *, width-specification,
and complementation (as in [^abc]), and "%n" for file-position, and
"%f", "%r", "%e", "%i" for numbers or simple number-expressions - any
width-specification is ignored; the expressions are not to include any
white space or characters other than decimal digits, +, -, *, /, e, and i.
E.g. expressions like 2e4i+7/8 are acceptable.
The builtin size(x) now returns the size of x if x is an open file
or -1 if x is a file but not open. If s is a string, size(s) returns
characters in s.
Added builtin access("foo", "w") returns the null value if a file
"foo" exists and is writable.
Some systems has a libc symbolic qadd() that conflicted with calc's
qadd function. To avoid this, qadd() has been renamed to qqadd().
The calc error codes are produced from the calcerr.tbl file.
Instead of changing #defines in value.h, one can not edit calcerr.tbl.
The Makefile builds calcerr.h from this file.
Calc error codes are now as follows:
<0 invalid
0 .. sys_nerr-1 system error ala C's errno values
sys_nerr .. E__BASE-1 reserved for future system errors
E__BASE .. E__HIGHEST calc internal errors
E__HIGHEST+1 .. E_USERDEF-1 invalid
E_USERDEF .. user defined errors
Currently, E__BASE == 10000 and E_USERDEF == 20000. Of course,
sys_nerr is system defined however is likely to be < E__BASE.
Renamed CONST_TYPE (as defined in have_const.h) to just CONST.
This symbol will either be 'const' or an empty string depending
on if your compiler understands const.
CONST is beginning to be used with read-only tables and some
function arguments. This allows certain compilers to better
optimize the code as well as alerts one to when some value
is being changed inappropriately. Use of CONST as in:
int foo(CONST int curds, char *CONST whey)
while legal C is not as useful because the caller is protected
by the fact that args are passed by value. However, the
in the following:
int bar(CONST char *fizbin, CONST HALF *data)
is useful because it calls the compiler that the string pointed
at by 'fizbin' and the HALF array pointer at by 'data' should be
treated as read-only.
The following are the changes from calc version 2.10.1t21 to 2.10.2t0:
Bumped patch level 2.10.2t0 in honor of having help files for
all builtin functions. Beta release will happen at the end of
the 2.10.2 cycle!!!
Fewer items listed in BUGS due to a number of bug fixes.
Less todo in the help/todo file because more has already been done. :-)
All builtin functions have help files! While a number need cleanup
and some of the LIMITS, LIBRARY and SEE ALSO sections need fixing
(or are missing), most of it is there. A Big round of thanks goes to
<ernie at turing dot une dot edu dot au> for his efforts in initial
write-ups for many of these files!
The recognition of '\' as an escape character in the format argument
of printf() has been dropped. Thus:
printf("\\n");
will print the two-character string "\n" rather than the a
one-character carriage return. <ernie at turing dot une dot edu dot au>
Missing args to printf-like functions will be treated as null values.
The scope of of config("fullzero") has been extended to integers,
so that for example, after config("mode","real"), config("display", 5),
config("fullzero", 1), both:
print 0, 1, 2;
printf("%d %d %d\n", 0, 1, 2);
print:
.00000 1.00000, 2.00000
The bug which caused calc to exit on:
b = "print 27+"
eval(b)
has been fixed. <ernie at turing dot une dot edu dot au>
Fixed bugs in zio.c which caused eval(str(x)) == x to fail
in non-real modes such as "oct". <ernie at turing dot une dot edu dot au>
The following:
for (i = 1; i < 10; i++) print i^2,;
now prints the same as:
for (i = 1; i < 10; i++) print i^2,;
The show globals will print '...' in the middle of large values.
<ernie at turing dot une dot edu dot au>
The param(n) builtin, then n > 0, returns the address rather than
the value of the n-th argument to save time and memory usage. This
is useful when a matrix with big number entries is passed as an arg.
<ernie at turing dot une dot edu dot au>
The param(n) builtin, then n > 0, may be used as an lvalue:
; define g() = (param(2) = param(1));
; define h() = (param(1)++, param(2)--);
; u = 5
; v = 10
; print g(u, &v), u, v;
5 5 5
; print h(&u, &v), u, v;
5 6 4
Missing args now evaluate to null as in:
A = list(1,,3)
B = list(,,)
mat C[] = {,,}
mat D[] = { }
The following are the changes from calc version 2.10.1t20 to 2.10.1t20:
Changes made in preparation for Blum Blum Shub random number generator.
REDC bug fixes: <ernie at turing dot une dot edu dot au>
Fixed yet another bug in zdiv which occasionally caused the "top digit"
of a nonzero quotient to be zero.
Fixed a bug in zredcmul() where a rarely required "topdigit" is
sometimes lost rather than added to the appropriate carry.
A new function zredcmodinv(ZVALUE z, ZVALUE *res) has been defined
for evaluating rp->inv in zredcalloc(). <ernie at turing dot une
dot edu dot au>
New functions zmod5(ZVALUE *zp) and zmod6(ZVALUE z, ZVALUE *res)
have been defined to give O(N^1.585)-runtime evaluation of z % m
for large N-word m. These require m and BASE^(2*N) // m to have
been stored at named locations lastmod, lastmodinv. zmod5() is
essentially for internal use by zmod6() and zpowermod(). <ernie at
turing dot une dot edu dot au>
Changes to rcmul(x,y,m) so that the result is always in [0, m-1].
<ernie at turing dot une dot edu dot au>
Changes to some of the detail of zredcmul() so that it should run slightly
faster. Also changes to zredcsq() in the hope that it might achieve
something like the improvement in speed of x^2 compared with x * x.
<ernie at turing dot une dot edu dot au>
A new "bignum" algorithm for evaluating pmod(x,k,m) when
N >= config("pow2"). For the multiplications and squaring
modulo m, or their equivalent, when N >= config("redc2"),
calc has used evaluations corresponding to rcout(x * y, m),
for which the runtime is essentially that of three multiplications.
<ernie at turing dot une dot edu dot au>
Yet more additions to the regress.cal test suite.
Fixed some ANSI-C compile nits in shs.c and quickhash.c.
Plugs some potential memory leaks in definitions in func.c.
Expressions such as qlink(vals[2]) in some circumstances are
neither qfreed nor returned as function values.
<ernie at turing dot une dot edu dot au>
The nextcand() and prevcand() functions handle modval, modulus
and skip by using ZVALUE rather than ZVALUE * and dropping
the long modulus, etc. <ernie at turing dot une dot edu dot au>
Changed a couple of occurrences of itoq(1) or itoq(0) to &_qone_
and &_qzero_. <ernie at turing dot une dot edu dot au>
In definition of f_primetest, changed ztolong(q2->num) to ztoi(q2->num)
so that the sign of count in ptest(n, count, skip) is not lost; and
ztolong(q3->num) to q3->num so that skip can be any integer.
<ernie at turing dot une dot edu dot au>
In zprime.c, in definition of small_factor(), adds "&& *tp != 1" to
the exit condition in the for loop so that searching for a factor
will continue beyond the table of primes, as required for e.g.
factor(2^59 - 1). <ernie at turing dot une dot edu dot au>
Changed zprimetest() so that skip in ptest(n, count, skip)
determines the way bases for the tests are selected. Neg values of
n are treated differently. When considering factorization,
primeness, etc. one is concerned with equivalence classes which for
the rational integers are {0}, {-1, 1}, {-2, 2}, etc. To refer to
an equivalence class users may use any of its elements but when
returning a value for a factor the computer normally gives the
non-negative member. The same sort of thing happens with integers
modulo an integer, with fractions, etc., etc. E.g. users may refer
to 3/4 as 6/8 or 9/12, etc. A simple summary of the way negative n
is treated is "the sign is ignored". E.g. isprime(-97) and
nextprime(-97) now return the same as isprime(97) and nextprime(97).
<ernie at turing dot une dot edu dot au>
The following are the changes from calc version 2.10.1t11 to 2.10.1t19:
Added many more regression tests to lib/regress.cal. Some
due to <ernie at turing dot une dot edu dot au>.
Added many help files, most due to <ernie at turing dot une dot edu dot au>.
Fixed exp() and ln() so that when they return a complex value with
a zero imaginary component, isreal() is true. <ernie at turing dot
une dot edu dot au>
Fixed cast problem in byteswap.c. <ernie at turing dot une dot edu dot au>
Fixed memory leak problem where repeated assignments did not
free the previous value. <ernie at turing dot une dot edu dot au>
Complex number ordering/comparison has been changed such that:
a < b implies a + c < b + c
a < b and c > 0 implies a * c < b * c
a < b implies -a > -b
To achieve a "natural" partial ordering of the complex numbers
with the above properties, cmp(a,b) for real or complex numbers
may be considered as follows:
cmp(a,b) = sgn(re(a) - re(b)) + sgn(im(a) - im(b)) * 1i
The cmp help file has been updated.
Change HASH type to QCKHASH. The HASH type is a name better suited
for the upcoming one-way hash interface.
Added the CONFIG type; a structure containing all of the configuration
values under the control of config(). Added V_CONFIG data type.
The call config("all") returns a V_CONFIG. One may now save/restore
the configuration state as follows:
x = config("all")
...
config("all",x)
Added two configuration aliases, "oldstd" (for old backward compatible
standard configuration) and "newstd" (for new style configuration).
One may set the historic configuration state by:
config("all", "oldstd")
One may use what some people consider to be a better but not backward
compatible configuration state by:
config("all", "newstd")
Renamed config.h (configuration file built during the make) to conf.h.
Added a new config.h to contain info on thw V_CONFIG type.
Fixed some ANSI C compile warnings.
The show config output is not indented by only one tab, unless
config("tab",0) in which case it is not indented.
The order of show config has been changed to reflect the config
type values.
Changed declaration of sys_errlst in func.c to be char *.
Added quo(x,y,rnd) and mod(x,y,rnd) to give function interfaces
to // and % with rounding mode arguments. Extended these functions
to work for list-values, complex numbers and matrices.
<ernie at turing dot une dot edu dot au>
For integer x, cfsim(x,8) returns 0.
<ernie at turing dot une dot edu dot au>
Fixed config("leadzero"). <ernie at turing dot une dot edu dot au>
Set config("cfsim",8) by default (in "oldstd"). Setup initial idea for
config("all", "newstd") to be the default with the following changes:
display 10
epsilon 1e-10
quo 0
outround 24
leadzero 1
fullzero 1
prompt "; " (allows full line cut/paste)
more ";; " (allows full line cut/paste)
The "newstd" is a (hopefully) more preferred configuration than the
historic default.
The fposval.h file defines DEV_BITS and INODE_BITS giving the
bit size of the st_dev and st_ino stat elements. Also added
SWAP_HALF_IN_DEV and SWAP_HALF_IN_STSIZE.
Added sec(), csc(), cot(), sech(), csch(), coth(), asec(), acsc(),
acot(), asech(), acsch() and acoth() builtins. <ernie at turing dot
une dot edu dot au>
The initmasks() call is no longer needed. The bitmask[] array
is a compiled into zmath.c directly.
Added isconfig(), ishash(), isrand() and israndom() builtins to
test is something is a configuration state, hash state, RAND
state or RANDOM state.
The lib/cryrand.cal library now no longer keeps the Blum prime
factors used to form he Blum modulus. The default modulus has
been expanded to 1062 bits product of two Blum primes.
The function hash_init() is called to initialize the hash function
interface.
Misc calc man page fixes and new command line updates.
Fixed bug related to srand(1).
Cleaned up some warning messages.
All calls to math_error() now have a /*NOTREACHED*/ comment after
them. This allows lint and compiler flow progs to note the jumpjmp
nature of math_error(). Unfortunately some due to some systems
not dealing with /*NOTREACHED*/ comments correctly, calls of the form:
if (foo)
math_error("bar");
must be turned into:
if (foo) {
math_error("bar");
/*NOTREACHED*/
}
The ploy() function can take a list of coefficients. See the
help/poly file. Added poly.c. <ernie at turing dot une dot edu
dot au>
Fixes and performance improvements to det(). <ernie at turing dot
une dot edu dot au>
Renamed atoq() and atoz() to str2q() and str2z() to avoid conflicts
with libc function names.
Fixed use of ${NROFF_ARG} when ${CATDIR} and ${NROFF} are set.
Fixed SWAP_HALF_IN_B64 macro use for Big Endian machines without
long long or with LONGLONG_BITS=0.
Added error() and iserror() to generate a value of a given error type.
See help/error for details. <ernie at turing dot une dot edu dot au>
Added singular forms of help files. For example one can now get
help for binding, bug, change, errorcode and type.
The builtin mmin(x, md) has been changed to return the same as
mod(x, md, 16). The old mmin(x, md) required md to be a positive
integer and x to be an integer. Now md can be any real number; x
can be real, complex, or a matrix or list with real elements, etc.
<ernie at turing dot une dot edu dot au>
The builtin avg(x_1, x_2, ...) has been changed to accept list-valued
arguments: a list x_i contributes its elements to the list of
items to be averaged. E.g. avg(list(1,2,list(3,4)),5) is treated
as if it were avg(1,2,3,4,5). If an error value is encountered in
the items to be averaged, the first such value is returned. If the
number of items to be averaged is zero, the null value is returned.
<ernie at turing dot une dot edu dot au>
The builtin hmean(x_1, x_2, ...) has been changed to admit types
other than real for x_1, x_2, ...; list arguments are treated in
the same way as in avg(). <ernie at turing dot une dot edu dot au>
The builtin eval(str) has been changed so that when str has a
syntax error, instead of call to math_error(), an error value is
returned. <ernie at turing dot une dot edu dot au>
The old frem(x,y) builtin returned the wrong value when y was a power of
2 greater than 2, e.g. f(8,4) is returned as 4 when its value should be 2.
This has been fixed by a small change to the definition of zfacrem().
Calc used to accept with no warning or error message, gcdrem(0,2) or
generally gcdrem(0,y) for any y with abs(y) > 1, but then went into an
infinite loop. This has been fixed by never calling zfacrem() with zero x.
Both frem(x,y) and gcdrem(x,y) now reject y = -1, 0 or 1 as errors. For
nonzero x, and y == -1 or 1, defining frem(x,y) and gcdrem(x,y) to equal
abs(x) is almost as natural as defining x^0 to be 1. Similarly, if x is
not zero then gcdrem(x,0) == 1. <ernie at turing dot une dot edu dot au>
Plugged some more memory leaks.
Fixed bug related randbit(x) skip (where x < 0).
Added seedrandom.cal to help users use the raw random() interface well.
Made extensive additions and changes to the rand() and random() generator
comments in zrand.c.
Fixed a bug in fposval.c that prevented calc from compiling on systems
with 16 bit device and/or inodes. Fixed error messages in fposval.c.
Fixed bug that would put calc into an infinite loop if it is ran
with errors in startup files (calc/startup, .calcrc).
Ha Lam <hl at kuhep5 dot phsx dot ukans dot edu>
The following are the changes from calc version 2.10.0t13 to 2.10.1t10:
Added SB8, USB8, SB16, USB16, SB32, USB32 typedefs, determined by
longbits and declared in longbits.h, to deal with 8, 16 and 32 bit
signed and unsigned values.
The longbits.h will define HAVE_B64 with a 64 bit type (long or
longlong) is available. If one is, then SB64 and US64 typedefs
are declared.
The U(x) and L(x) macros only used to define 33 to 64 bit signed
and unsigned constants. Without HAVE_B64, these macros cannot
be used.
Changed the way zmath.h declares types such as HALF and FULL.
Changed the PRINT typedef.
The only place where the long long type might be used is in longlong.c
and if HAVE_LONGLONG, in longbits.h if it is needed. The only place
were a long long constant might be used is in longlong.c. Any
long long constants, if HAVE_LONGLONG, are hidden under the U(x) and
L(x) macros on longbits.h. And of course, if you don't have long long,
then HAVE_LONGLONG will NOT be defined and long long's will not be used.
The longlong.h file is no longer directly used by the main calc source.
It only comes into play when compiling the longbits tool.
Added config("prompt") to change the default interactive prompt ("> ")
and config("more") to change the default continuation prompt (">> ").
Makefile builds align32.h with determines if 32 bit values must always
be aligned on 32 bit boundaries.
The CALCBINDINGS file is searched for along the CALCPATH. The Makefile
defines the default CALCBINDINGS is "bindings" (or "altbind") which
is now usually found in ./lib or ${LIBDIR}.
Per Ernest Bowen <ernie at turing dot une dot edu dot au>, an optional
third argument was added sqrt() so that in sqrt(x,y,z), y and z have
essentially the same role as in appr(x,y,z) except that of course
what is being approximated is the sqrt of x. Another difference is
that two more bits of z are used in sqrt: bit 5 gives the option of
exact results when they exist (the value of y is then ignored) and
bit 6 returns the non-principal root rather than the principal value.
If commands are given on the command line, leading tabs are not
printed in output. Giving a command on the command line implies
that config("tab",0) was given.
Pipe processing is enabled by use of -p. For example:
echo "print 2^21701-1, 2^23209-1" | calc -p | fizzbin
In pipe mode, calc does not prompt, does not print leading tabs
and does not print the initial version header.
Calc will now form FILE objects for any open file descriptor > 2
and < MAXFILES. Calc assumes they are available for reading
and writing. For example:
$ echo "A line of text in the file on descriptor 5" > datafile
$ calc 5<datafile
C-style arbitrary precision calculator (version 2.10.1t3)
[Type "exit" to exit, or "help" for help.]
; files(5)
FILE 5 "descriptor[5]" (unknown_mode, pos 0)
; fgetline(files(5))
"A line of text in the file on descriptor 5"
The -m mode flag now controls calc's ability to open files
and execute programs. This mode flag is a single digit that
is processed in a similar way as the octal chmod values:
0 do not open any file, do not execute progs
1 do not open any file
2 do not open files for reading, do not execute progs
3 do not open files for reading
4 do not open files for writing, do not execute progs
5 do not open files for writing
6 do not execute any program
7 allow everything (default mode)
Thus if one wished to run calc from a privileged user, one might
want to use -m 0 in an effort to make calc more secure.
The -m flags for reading and writing apply on open.
Files already open are not effected. Thus if one wanted to use
the -m 0 in an effort to make calc more secure, but still be
able to read and write a specific file, one might do:
calc -m 0 3<a.file 4>b.file
NOTE: Files presented to calc in this way are opened in an unknown
mode. Calc will try to read or write them if directed.
The maximum command line size it MAXCMD (16384) bytes. Calc objects to
command lines that are longer.
The -u flag cause calc to un-buffer stdin and stdout.
Added more help files. Improved other help files.
Removed trailing blanks from files.
Removed or rewrite the formally gross and disgusting hacks for
dealing with various sizes and byte sex FILEPOS and off_t types.
Defined ilog2(x), ilog10(x), ilog(x,y) so that sign of x is ignored,
e.g. ilog2(x) = ilog2(abs(x)).
The sixth bit of rnd in config("round", rnd) and config("bround", rnd)
is used to specify rounding to the given number of significant
digits or bits rather than places, e.g. round(.00238, 2, 32)
returns .0023, round(.00238, 2, 56) returns .0024.
The following are the changes from calc version 2.9.3t11 to 2.10.0t12:
The default ${LIBDIR}/bindings CALCBINDINGS uses ^D for editing.
The alternate CALCBINDINGS ${LIBDIR}/altbind uses ^D for EOF.
The Makefile CC flag system has been changed. The new CC flag system
includes:
CCMAIN are flags for ${CC} when compiling only files with main()
CCOPT are flags given to ${CC} for optimization
CCWARN are flags given to ${CC} for warning message control
CCMISC are misc flags given to ${CC}
CNOWARN are all flags given to ${CC} except ${CCWARN} flags
CFLAGS are all flags given to ${CC}
ICFLAGS are given to ${CC} for intermediate progs
LCFLAGS are CC-style flags for ${LINT}
LDFLAGS are flags given to ${CC} for linking .o files
ILDFLAGS are given to ${CC} for linking .o's for intermediate progs
CC is how the C compiler is invoked
The syntax error:
print a[3][[4]]
used to send calc into a loop printing 'missing expression'. This
has been fixed.
Added config("maxerr") and config("maxerr",val) to control the
maximum number of errors before a computation is aborted.
Removed regress.cal test #952 and #953 in case calc's stdout or
stderr is re-directed to a non-file by some test suite.
Changed how <stdarg.h>, <varags.h> or simulate stdarg is determined.
Changed how vsprintf() vs sprintf() is determined. The args.h file
is created by Makefile to test which combination works. Setting
VARARG and/or HAVE_VSPRINTF in the Makefile will alter these tests
and direct a specific combination to be used. Removed have_vs.c,
std_arg.h and try_stdarg.c. Added have_stdvs.c and have_varvs.c.
Added 3rd optional arg to round(), bround(), appr() to specify the type of
rounding to be used.
Moved fnvhash.c to quickhash.c.
Fixed a bug in appr rounding mode when >= 16.
Added test2600.cal and test2700.cal. They are used by the regress.cal
to provide a more extensive test suite for some builtin numeric
functions.
The following are the changes from calc version 2.9.3t9.2+ to 2.9.3t10:
Added many help files for builtin functions and some symbols.
More help files are needed, see help/todo.
Removed the calc malloc code. Calc now uses malloc and free to
manage storage since these implementations are often written to
work best for the local system. Removed CALC_MALLOC code and
Makefile symbol. Removed alloc.c.
Added getenv("name"), putenv("name=val") and putenv("name, "val")
builds for environment variable support thanks to "Dr." "D.J." Picton
<dave at aps2 dot ph dot bham dot ac dot uk>.
Added system("shell command") builtin to execute shell commands,
thanks to "Dr." "D.J." Picton <dave at aps2 dot ph dot bham dot ac dot uk>.
Added isatty(fd) builtin to determine if fd is attached to a tty
thanks to "Dr." "D.J." Picton <dave at aps2 dot ph dot bham dot ac dot uk>.
Added cmdbuf() builtin to return the command line executed by calc's
command line args thanks to "Dr." "D.J." Picton <dave at aps2 dot
ph dot bham dot ac dot uk>.
Added strpos(str1,str2) builtin to determine the first position where
str2 is found in str1 thanks to "Dr." "D.J." Picton
<dave at aps2 dot ph dot bham dot ac dot uk>.
Fixed bug that caused:
global a,b,c (newline with no semicolon)
read test.cal
the read command to not be recognized.
The show command looks at only the first 4 chars of the argument so
that:
show globals
show global
show glob
do the same thing.
Added show config to print the config values and parameters thanks
to Ernest Bowen <ernie at turing dot une dot edu dot au>.
Added show objtypes to print the defined objects thanks to Ernest Bowen
<ernie at turing dot une dot edu dot au>.
Added more builtin function help files.
Fixed the 3rd arg usage of the root builtin.
Expanded the regress.cal regression test suite.
Fixed -- and ++ with respect to objects and assignment (see the 2300
series in regress.cal).
Added isident(m) to determine if m is an identity matrix.
The append(), insert() and push() builtins can now append between
1 to 100 values to a list.
Added reverse() and join() builtins to reverse and join lists
thanks to Ernest Bowen <ernie at turing dot une dot edu dot au>.
Added sort() builtin to sort lists thanks to Ernest Bowen
<ernie at turing dot une dot edu dot au>.
Added head(), segment() and tail() builtins to return the head,
middle or tail of lists thanks to Ernest Bowen <ernie at turing dot
une dot edu dot au>.
Added more and fixed some help files.
The builtin help file is generated by the help makefile. Thus it will
reflect the actual calc builtin list instead of the last time someone
tried to update it correctly. :-)
Fixed non-standard void pointer usage.
Fixed base() bug with regards to the default base.
Renamed MATH_PROTO() and HIST_PROTO() to PROTO(). Moved PROTO()
into prototype.h.
Fixed many function prototypes. Calc does not declare functions
as static in one place and extern in another. Where reasonable
function prototypes were added. Several arg mismatch problems
were fixed.
Added support for SGI MIPSpro C compiler.
Changes the order that args are declared to match the order
of the function. Some source tools got confused when:
arg order did not match as in:
void
funct(foo,bar)
int bar; /* this caused a problem */
char *foo; /* even though it should not! */
{
}
The following are the changes from calc version 2.9.3t8 to 2.9.3t9.2:
Use of the macro zisleone(z) has been clarified. The zisleone(z) macro
tests if z <= 1. The macro zisabsleone(z) tests of z is 1, 0 or -1.
Added zislezero(z) macro. Bugs are related to this confusion have
been fixed.
Added zge64b(z) macro to zmath.h.
Added the macro zgtmaxufull(z) to determine if z will fit into a FULL.
Added the macro zgtmaxlong(z) to determine if z will fit into a long.
Added the macro zgtmaxulong(z) to determine if z will fit into a unsigned
long.
Added the macro ztoulong(z) to convert an absolute value of a ZVALUE to
an unsigned long, or to convert the low order bits of a ZVALUE.
Added the macro ztolong(z) to convert an absolute value of a ZVALUE to
an long, or to convert the low order bits of a ZVALUE.
Some non-ANSI C compilers define __STDC__ to be 0, whereas all ANSI
C compiles define it as non-zero. Code that depends on ANSI C now
uses #if defined(__STDC__) && __STDC__ != 0.
Fixed ptest(a,b) bug where (a mod 2^32) < b. Previously ptest()
incorrectly returned 1 in certain cases.
The second ptest() argument, which is now optional, defaults to 1.
This ptest(x) is the same as ptest(x,1).
Added an optional 3rd argument to ptest(). The 3rd arg tells how many
tests to skip. Thus ptest(a,10) performs the same probabilistic
tests as ptest(a,3) and ptest(a,7,3).
The ptest() builtin by default will determine if a value is divisible
by a trivial prime. Thus, ptest(a,0) will only perform a quick trivial
factor check. If the test count is < 0, then this trivial factor check
is omitted. Thus ptest(a,10) performs the same amount of work as
ptest(a,3) and ptest(a,-7,3) and the same amount of work as
ptest(a,-3) and ptest(a,7,3).
Added nextcand(a[,b[,c]]) and prevcand(a[,b[,c]]) to search for the
next/previous value v > a (or v < a) that passes ptest(v[,b[,c]]).
The nextcand() and prevcand() builtins take the same arguments
as ptest().
Added nextprime(x) and and prevprime(x) return the next and
previous primes with respect to x respectively. As of this
release, x must be < 2^32. With one argument, they will return
an error if x is out of range. With two arguments, they will
not generate an error but instead will return y.
Fixed some memory leaks, particularly those related with pmod().
Fixed some of the array bounds reference problems in domult().
Added a hack-a-round fix for the uninitialized memory reference
problems in zsquare/dosquare.
The LIBRARY file has been updated to include a note about calling
zio_init() first. Also some additional useful macros have been noted.
The lfactor() function returns -1 when given a negative value.
It will not search for factors beyond 2^32 or 203280221 primes.
Performance of lfactor() has been improved.
Added factor(x,y) to look for the smallest factor < min(sqrt(x),y).
Added libcalcerr.a for a math_error() routine for the convince of
progs that make use of libcalc.a. This routine by default will
print an message on stderr and exit. It can also be made to
longjump instead. See the file LIBRARY under ERROR HANDING.
Added isprime() to test if a value is prime. As of this release,
isprime() is limited to values < 2^32. With one argument,
isprime(x) will return an error if x is out of range. With
two arguments, isprime(x,y) will not generate an error but
instead will return y.
Added pix(x) to return the number of primes <= x. As of this
release, x must be < 2^32. With one argument, pix(x) will
return an error if x is out of range. With two arguments,
pix(x,y) will not generate an error but instead will return y.
Fixed the way *.h files are formed. Each file guards against
multiple inclusion.
Fixed numeric I/O on 64 bit systems. Previously the print and
constant conversion routines assumed a base of 2^16.
Added support for 'long long' type. If the Makefile is setup
with 'LONGLONG_BITS=', then it will attempt to detect support
for the 'long long' type. If the Makefile is setup with
'LONGLONG_BITS=64', then a 64 bit 'long long' is assumed.
Currently, only 64 bit 'long long' type is supported.
Use of 'long long' allows one to double the size of the
internal base, making a number of computations much faster.
If the Makefile is setup with 'LONGLONG_BITS=0', then the
'long long' type will not be used, even if the compiler
supports it.
Fixed avg() so that it will correctly handle matrix arguments.
Fixed btrunc() limit.
The ord("string") function can now take a string of multiple
characters. However it still will only operate on the first
character.
Renamed stdarg.h to std_arg.h and endian.h endian_calc.h to
avoid name conflicts with /usr/include on some systems that
have make utilities that are too smart for their own good.
Added additive 55 shuffle generator functions rand(), randbits()
and its seed function srand(). Calling rand(a,b) produces a
random value over the open half interval [a,b). With one arg,
rand(a) is equivalent to rand(0,a). Calling rand() produces
64 random bits and is equivalent to rand(0,2^64).
Calling randbit(x>0) produces x random bits. Calling randbit(skip<0)
skips -skip bits and returns -skip.
The srand() function will return the current state. The call
srand(0) returns the initial state. Calling srand(x), where
x > 0 will seed the generator to a different state. Calling
srand(mat55) (mat55 is a matrix of integers at least 55 elements long)
will seed the internal table with the matrix elements mod 2^64.
Finally calling srand(state) where state is a generator state
also sets/seeds the generator.
The cryrand.cal library has been modified to use the builtin
rand() number generator. The output of this generator is
different from previous versions of this generator because
the rand() builtin does not match the additive 55 / shuffle
generators from the old cryrand.cal file.
Added Makfile support for building BSD/386 releases.
The cmp() builtin can now compare complex values.
Added the errno() builtin to return the meaning of errno numbers.
Added fputc(), fputs(), fgets(), ftell(), fseek() builtins.
Added fsize() builtin to determine the size of an open file.
Supports systems where file positions and offsets are longer than 2^32
byte, longer than long and/or are not a simple type.
When a file file is printed, the file number is also printed:
FILE 3 "/etc/motd" (reading, pos 127)
Added matsum() to sum all numeric values in a matrix.
The following code now works, thanks to a fix by <ernie at turing
dot une dot edu dot au> (Ernest Bowen):
mat A[3] = {1, 2, 3};
A[0] = A;
print A[0];
Also thanks to ernie, calc can process compound expressions
such as 1 ? 2 ? 3 : 4 : 5.
Also^2 thanks to ernie, the = operator is more general:
(a = 3) = 4 (same as a = 3; a = 4)
(a += 3) *= 4 (same as a += 3; a *= 4)
matfill(B = A, 4) (same as B = A; matfill(B, 4);)
Also^3 thanks to ernie, the ++ and -- operators are more general.
a = 3
++(b = a) (a == 3, b == 4)
++++a (a == 5)
(++a)++ == 6 (a == 7)
(++a) *= b (a == 32, b == 4)
Fixed a bug related to calling epsilon(variable) thanks to ernie.
Removed trailing whitespace from source and help files.
Some compilers do not support the const type. The file have_const.h,
which is built from have_const.c will determine if we can or should
use const. See the Makefile for details.
Some systems do not have uid_t. The file have_uid_t.h, which is
built from have_uid_t.c will determine if we can or should depend
on uid_t being typefed by the system include files. See the Makefile
for details.
Some systems do not have memcpy(), memset() and strchr(). The
file have_newstr.h, which is built from have_newstr.c will
determine if we can or should depend libc providing these
functions. See the Makefile for details.
The Makefile symbol DONT_HAVE_VSPRINTF is now called HAVE_VSPRINTF.
The file have_vs.h, which is built from have_vs.c will determine if
we can or should depend libc providing vsprintf(). See the Makefile
for details.
Removed UID_T and OLD_BSD symbols from the Makefile.
A make all of the upper level Makefile will cause the all rule
of the lib and help subdirs to be made as well.
Fixed bug where reserved keyword used as symbol name caused a core dump.
The following are the changes from calc version 2.9.3t7 to 2.9.3t7:
The 'show' command by itself will issue an error message
that will remind one of the possible show arguments.
(thanks to Ha S. Lam <hl at kuhep4 dot phsx dot ukans dot edu>)
Fixed an ANSI-C related problem with the use of stringindex()
by the show command. ANSI-C interprets "bar\0foo..." as if
it were "bar\017oo...".
Added a cd command to change the current directory.
(thanks to Ha S. Lam <hl at kuhep4 dot phsx dot ukans dot edu>)
Calc will not output the initial version string, startup
message and command prompt if stdin is not a tty. Thus
the shell command:
echo "fact(100)" | calc
only prints the result. (thanks to Ha S. Lam <hl at kuhep4 dot phsx
dot ukans dot edu>)
The zmath.h macro zisbig() macro was replaced with zlt16b(),
zge24b(), zge31b(), zge32b() and zgtmaxfull() which are
independent of word size.
The 'too large' limit for factorial operations (e.g., fact, pfact,
lcmfact, perm and comb) is now 2^24. Previously it depended on the
word size which in the case of 64 bit systems was way too large.
The 'too large' limit for exponentiation, bit position (isset,
digit, ), matrix operations (size, index, creation), scaling,
shifting, rounding and computing a Fibonacci number is 2^31.
For example, one cannot raise a number by a power >= 2^31.
One cannot test for a bit position >= 2^31. One cannot round
a value to 2^31 decimal digit places. One cannot compute
the Fibonacci number F(2^31).
Andy Fingerhut <jaf at dworkin dot wustl dot edu> (thanks!) supplied
a fix to a subtle bug in the code generation routines. The basic
problem was that addop() is sometimes used to add a label to
the opcode table of a function. The addop() function did some
optimization tricks, and if one of these labels happens to be an
opcode that triggers optimization, incorrect opcodes were generated.
Added utoz(), ztou() to zmath.c, and utoq(), qtou() to qmath.c
in preparation for 2.9.3t9 mods.
The following are the changes from calc version 2.9.2 to 2.9.3t7:
Calc can now compile on OSF/1, SGI and IBM RS6000 systems.
A number of systems that have both <varargs.h> and <stdarg.h> do
not correctly implement both types. On some System V, MIPS and DEC
systems, vsprintf() and <stdarg.h> do not mix. While calc will
pass the regression test, use of undefined variables will cause
problems. The Makefile has been modified to look for this problem
and work around it.
Added randmprime.cal which find a prime of the form h*2^n-1 >= 2^x
for some given x. The initial search points for 'h' and 'n'
are selected by a cryptographic pseudo-random generator.
The library script nextprim.cal is now a link to nextprime.cal.
The lib/Makefile will take care of this link and install.
The show command now takes singular forms. For example, the
command 'show builtin' does the same as 'show builtins'. This
allows show to match the historic singular names used in
the help system.
Synced 'show builtin' output with 'help builtin' output.
Fixed the ilog2() builtin. Previously ilog2(2^-20) returned
-21 instead of -20.
The internal function qprecision() has been fixed. The changes
ensure that for any e for which 0 < e <= 1:
1/4 < sup(abs(appr(x,e) - x))/e <= 1/2.
Here 'sup' denotes the least upper bound over values of x (supremum).
Previously calc did: 1/4 <= sup(abs(appr(x,e) - x))/e < 1.
Certain 64 bit processors such as the Alpha are now supported.
Added -once to the READ command. The command:
read -once filename
like the regular READ expect that it will ignore filename if
is has been previously read.
Improved the makefile. One now can select the compiler type. The
make dependency lines are now simple foo.o: bar.h lines. While
this makes for a longer list, it is easier to maintain and will
make future Makefile patches smaller. Added special options for
gcc version 1 & 2, and for cc on RS6000 systems.
Calc compiles cleanly under the watchful eye of gcc version 2.4.5
with the exception of warnings about 'aggregate has a partly
bracketed initializer'. (gcc v2 should allow you to disable
this type of warning with using -Wall)
Fixed a longjmp bug that clobbered a local variable in main().
Fixed a number of cases where local variables or malloced storage was
being used before being set.
Fixed a number of fence post errors resulting in reads or writes
just outside of malloced storage.
A certain parallel processor optimizer would give up on
code in cases where math_error() was called. The obscure
work-a-rounds involved initializing or making static, certain
local variables.
The cryrand.cal library has been improved. Due to the way
the initial quadratic residues are selected, the random numbers
produced differ from previous versions.
The printing of a leading '~' on rounded values is now a config
option. By default, tilde is still printed. See help/config for
details.
The builtin function base() may be used to set the output mode or
base. Calling base(16) is a convenient shorthand for typing
config("mode","hex"). See help/builtin.
The printing of a leading tab is now a config option. This does not
alter the format of functions such as print or printf. By default,
a tab is printed. See help/config for details.
The value atan2(0,0) now returns 0 value in conformance with
the 4.3BSD ANSI/IEEE 754-1985 math library.
For all values of x, x^0 yields 1. The major change here is
that 0^0 yields 1 instead of an error.
Fixed gcd() bug that caused gcd(2,3,1/2) to ignore the 1/2 arg.
Fixed ltol() rounding so that exact results are returned, similar
to the way sqrt() and hypot() round, when they exist.
Fixed a bug involving ilog2().
Fixed quomod(a,b,c,d) to give correct value for d when a is between
0 and -b.
Fixed hmean() to perform the necessary multiplication by the number of
arguments.
The file help/full is now being built.
The man page is not installed by default. One may install either
the man page source or the cat (formatted man) page. See the
Makefile for details.
Added a quit binding. The file lib/bindings2 shows how this new
binding may be used.
One can now do a 'make check' to run the calc regression test
within in the source tree.
The regression test code is now more extensive.
Updated the help/todo list. A BUGS file was added. Volunteers are
welcome to send in patches!
The following are the changes from calc version 2.9.1 to 2.9.1:
Fixed floor() for values -1 < x < 0.
Fixed ceil() for values -1 < x < 0.
Fixed frac() for values < 0 so that int(x) + frac(x) == x.
Fixed wild fetch bug in zdiv, zquo and zmod code.
Fixed bug which caused regression test #719 to fail on some machines.
Added more regression test code.
The following are the changes from calc version 2.9.0 to 2.9.0:
A major bug was fixed in subtracting two numbers when the first
number was zero. The problem caused wrong answers and core dumps.
The following are the changes from calc version 1.27.0 to 2.8.0:
Full prototypes have been provided for all C functions, and are used
if calc is compiled with an ANSI compiler.
Newly defined variables are now initialized to the value of zero instead
of to the null value. The elements of new objects are also initialized
to the value of zero instead of null.
The gcd, lcm, and ismult functions now work for fractional values.
A major bug in the // division for fractions with a negative divisor
was fixed.
A major bug in the calculation of ln for small values was fixed.
A major bug in the calculation of the ln and power functions for complex
numbers was fixed.
A major lack of precision for sin and tan for small values was fixed.
A major lack of precision for complex square roots was fixed.
The "static" keyword has been implemented for variables. So permanent
variables can be defined to have either file scope or function scope.
Initialization of variables during their declaration are now allowed.
This is most convenient for the initialization of static variables.
The matrix definition statement can now be used within a declaration
statement, to immediately define a variable as a matrix.
Initializations of the elements of matrices are now allowed. One-
dimensional matrices may have implicit bounds when initialization is
used.
The obj definition statement can now be used within a declaration
statement, to immediately define a variable as an object.
Object definitions can be repeated as long as they are exactly the same
as the previous definition. This allows the rereading of files which
happen to define objects.
The integer, rational, and complex routines have been made into a
'libcalc.a' library so that they can be used in other programs besides
the calculator. The "math.h" include file has been split into three
include files: "zmath.h", "qmath.h", and "cmath.h".
Following is a list of visible changes to calc from version 1.26.4 to 1.26.4:
Added an assoc function to return a new type of value called an
association. Such values are indexed by one or more arbitrary values.
They are stored in a hash table for quick access.
Added a hash() function which accepts one or more values and returns
a quickly calculated small non-negative hash value for those values.
Following is a list of visible changes to calc from version 1.26.2 to 1.26.4:
Misc fixes to Makefiles.
Misc lint fixes.
Misc portability fixes.
Misc typo and working fixes to comments, help files and the man page.
Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
There is a new emacs-like command line editing and edit history
feature. The old history mechanism has been removed. The key
bindings for the new editing commands are slightly configurable
since they are read in from an initialization file. This file is
usually called /usr/lib/calc/bindings, but can be changed by the
CALCBINDINGS environment variable. All editing code is
self-contained in the new files hist.c and hist.h, which can be
easily extracted and used in other programs.
Two new library files have been added: chrem.cal and cryrand.cal.
The first of these solves the Chinese remainder problem for a set
of modulo's and remainders. The second of these implements several
very good random number generators for large numbers.
A small bug which allowed division by zero was fixed.
A major bug in the mattrans function was fixed.
A major bug in the acos function for negative arguments was fixed.
A major bug in the strprintf function when objects were being printed
was fixed.
A small bug in the library file regress.cal was fixed.
## Copyright (C) 2001-2014 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.46 $
## @(#) $Id: CHANGES,v 30.46 2014/10/12 12:46:23 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/RCS/CHANGES,v $
##
## Under source code control: 1993/06/02 18:12:57
## File existed as early as: 1989
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* contrib
*************
We welcome and encourage you to send us:
* calc resource files
* calc shell scripts
* any builtin functions that you have modified or written
* custom functions that you have modified or written
* any other source code modifications
Prior to doing so, you should consider applying your changes to the most
recent version of calc.
Landon Noll maintains the official calc home page at:
http://www.isthe.com/chongo/tech/comp/calc/
See:
http://www.isthe.com/chongo/tech/comp/calc/calc-download.html
for information on how to obtain up a recent version of calc.
=-=
In order to consider integrating your code, we need:
* the calc version you are working with (use the latest calc, see above)
* new help files or help file patches, if applicable (documentation)
* proposed text for the CHANGES file (brief description of what it does)
* regress.cal test patch, if applicable
* your source code and/or source code changes (:-))
The best way to send us new code, if your changes are small, is
via a patch (diff -c from the latest alpha code to your code).
If your change is large, you should send entire files (either
as a diff -c /dev/null your-file patch, or as a uuencoded and
gziped (or compressed) tar file).
To contribute code, scripts, resource files and/or to help please
join the low volume calc mailing list calc-tester. Then send
your contribution to the calc-tester mailing list.
To subscribe to the calc-tester mailing list, visit the following URL:
https://www.listbox.com/subscribe/?list_id=239342
To help determine you are a human and not just a spam bot,
you will be required to provide the following additional info:
Your Name
Calc Version
Operating System
The date 7 days ago
This is a low volume moderated mailing list.
This mailing list replaces calc-tester at asthe dot com list.
If you need a human to help you with your mailing list subscription,
please send EMail to our special:
calc-tester-maillist-help at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
address. To be sure we see your EMail asking for help with your
mailing list subscription, please use the following phase in your
EMail Subject line:
calc tester mailing list help
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
=-=
Calc bug reports and calc bug fixes should be sent to:
calc-bug-report at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
This replaces the old calc-bugs at asthe dot com address.
To be sure we see your EMail reporting a calc bug, please use the
following phase in your EMail Subject line:
calc bug report
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
However, you may find it more helpful to simply subscribe
to the calc-tester mailing list (see above) and then to
send your report to that mailing list as a wider set calc
testers may be able to help you.
=-=
The calc web site is located at:
http://www.isthe.com/chongo/tech/comp/calc/
NOTE: The EMail address uses 'asthe', while the web site uses 'isthe'.
=-=
Landon Curt Noll
http://www.isthe.com/chongo/
chongo (share and enjoy) /\../\
## Copyright (C) 1999,2014 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.2 $
## @(#) $Id: contrib,v 30.2 2014/10/06 08:39:45 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/contrib,v $
##
## Under source code control: 1997/03/09 16:33:22
## File existed as early as: 1997
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* credit
*************
Credits
The majority of calc was written by David I. Bell.
The Calc primary mirror, calc mailing list and calc bug report
processing is performed by Landon Curt Noll.
Landon Curt Noll maintains the master reference source, performs
release control functions as well as other calc maintenance functions.
Thanks for suggestions and encouragement from Peter Miller,
Neil Justusson, Ernest W. Bowen and Landon Noll.
Thanks to Stephen Rothwell for writing the original version of
hist.c which is used to do the command line editing.
Thanks to Ernest W. Bowen for supplying many improvements in
accuracy and generality for some numeric functions. Much of
this was in terms of actual code which I gratefully accepted.
Ernest also supplied the original text for many of the help files.
Portions of this program are derived from an earlier set of
public domain arbitrarily precision routines which was posted
to the net around 1984. By now, there is almost no recognizable
code left from that original source.
Most of this source and binary has one of the following copyrights:
Copyright (C) year David I. Bell
Copyright (C) year David I. Bell and Landon Curt Noll
Copyright (C) year David I. Bell and Ernest Bowen
Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen
Copyright (C) year Landon Curt Noll
Copyright (C) year Ernest Bowen and Landon Curt Noll
Copyright (C) year Ernest Bowen
Copying / Calc GNU Lesser General Public License
Calc is open software, and is covered under version 2.1 of the GNU
Lesser General Public License. You are welcome to change it and/or
distribute copies of it under certain conditions. The calc commands:
help copying
help copying-lgpl
should display the contents of the COPYING and COPYING-LGPL files.
Those files contain information about the calc's GNU Lesser General
Public License, and in particular the conditions under which you
are allowed to change it and/or distribute copies of it.
You should have received a copy of the version 2.1 GNU
Lesser General Public License. If you do not have these
files, write to:
Free Software Foundation, Inc.
51 Franklin Street
Fifth Floor
Boston, MA 02110-1301
USA
See also:
help copyright
help copying
help copying-lgpl
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: credit,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/credit,v $
##
## Under source code control: 1991/07/23 05:47:24
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* COPYING
*************
calc - arbitrary precision calculator
This file is Copyrighted
------------------------
This file is covered under the following Copyright:
Copyright (C) 1999-2014 Landon Curt Noll
All rights reserved.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
# @(#) $Revision: 30.6 $
# @(#) $Id: COPYING,v 30.6 2014/10/12 12:23:43 chongo Exp $
# @(#) $Source: /usr/local/src/bin/calc/RCS/COPYING,v $
-=-
Calc is covered by the GNU Lesser General Public License
--------------------------------------------------------
Calc is open software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation version 2.1 of the License.
Calc is several binary link libraries, several modules, associated
interface definition files and scripts used to control its compilation
and installation.
Calc is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
A copy of the GNU Lesser General Public License is distributed with
calc under the filename:
COPYING-LGPL
You may display this file by the calc command: help copying
You may display the GNU Lesser General
Public License by the calc command: help copying-lgpl
You should have received a copy of the version 2.1 GNU Lesser General
Public License with calc; if not, write to the following address:
Free Software Foundation, Inc.
51 Franklin Street
Fifth Floor
Boston, MA 02110-1301
USA
To subscribe to the calc-tester mailing list, visit the following URL:
http://www.isthe.com/chongo/tech/comp/calc/calc-tester.html
This is a low volume moderated mailing list.
This mailing list replaces calc-tester at asthe dot com list.
If you need a human to help you with your mailing list subscription,
please send EMail to our special:
calc-tester-maillist-help at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
address. To be sure we see your EMail asking for help with your
mailing list subscription, please use the following phase in your
EMail Subject line:
calc tester mailing list help
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
-=-
Calc bug reports and calc bug fixes should be sent to:
calc-bug-report at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
This replaces the old calc-bugs at asthe dot com address.
To be sure we see your EMail reporting a calc bug, please use the
following phase in your EMail Subject line:
calc bug report
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
However, you may find it more helpful to simply subscribe
to the calc-tester mailing list (see above) and then to
send your report to that mailing list as a wider set calc
testers may be able to help you.
-=-
The calc web site is located at:
http://www.isthe.com/chongo/tech/comp/calc/
NOTE: The EMail address uses 'asthe', while the web site uses 'isthe'.
-=-
Calc's relationship to the GNU Lesser General Public License
------------------------------------------------------------
In section 0 of the GNU Lesser General Public License, one finds
the following definition:
The "Library", below, refers to any such software library or
work which has been distributed under these terms.
Calc is distributed under the terms of the GNU Lesser
General Public License.
In the same section 0, one also find the following:
For a library, complete source code means all the source code
for all modules it contains, plus any associated interface
definition files, plus the scripts used to control compilation
and installation of the library.
There are at least two calc binary link libraries found in calc:
libcalc.a libcustcalc.a
Clearly all files that go into the creation of those binary link
libraries are covered under the License.
The ``scripts used to control compilation and installation of the
of the library'' include:
* Makefiles
* source files created by the Makefiles
* source code used in the creation of intermediate source files
All of those files are covered under the License.
The ``associated interface definition files'' are those files that:
* show how the calc binary link libraries are used
* test the validity of the binary link libraries
* document routines found in the binary link libraries
* show how one can interactively use the binary link libraries
Calc provides an extensive set of files that perform the above
functions.
* files under the sample sub-directory
* files under the help sub-directory
* files under the lib sub-directory
* the main calc.c file
The ``complete source code'' includes ALL files shipped with calc,
except for the exception files explicitly listed in the ``Calc
copyrights and exception files'' section below.
-=-
Calc copyrights and exception files
-----------------------------------
With the exception of the files listed below, Calc is covered under
the following GNU Lesser General Public License Copyrights:
Copyright (C) year David I. Bell
Copyright (C) year David I. Bell and Landon Curt Noll
Copyright (C) year David I. Bell and Ernest Bowen
Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen
Copyright (C) year Landon Curt Noll
Copyright (C) year Ernest Bowen and Landon Curt Noll
Copyright (C) year Ernest Bowen
Copyright (C) year Petteri Kettunen and Landon Curt Noll
Copyright (C) year Christoph Zurnieden
These files are not covered under one of the Copyrights listed above:
sha1.c sha1.h COPYING
COPYING-LGPL cal/qtime.cal cal/screen.cal
The file COPYING-LGPL, which contains a copy of the version 2.1
GNU Lesser General Public License, is itself Copyrighted by the
Free Software Foundation, Inc. Please note that the Free Software
Foundation, Inc. does NOT have a copyright over calc, only the
COPYING-LGPL that is supplied with calc.
This file, COPYING, is distributed under the Copyright found at the
top of this file. It is important to note that you may distribute
verbatim copies of this file but you may not modify this file.
Some of these exception files are in the public domain. Other files
are under the LGPL but have different authors that those listed above.
In all cases one may use and distribute these exception files freely.
And because one may freely distribute the LGPL covered files, the
entire calc source may be freely used and distributed.
-=-
General Copyleft and License info
---------------------------------
For general information on Copylefts, see:
http://www.gnu.org/copyleft/
For information on GNU Lesser General Public Licenses, see:
http://www.gnu.org/copyleft/lesser.html
http://www.gnu.org/copyleft/lesser.txt
-=-
Why calc did not use the GNU General Public License
---------------------------------------------------
It has been suggested that one should consider using the GNU General
Public License instead of the GNU Lesser General Public License:
http://www.gnu.org/philosophy/why-not-lgpl.html
As you can read in the above URL, there are times where a library
cannot give free software any particular advantage. One of those
times is when there is significantly similar versions available
that are not covered under a Copyleft such as the GNU General Public
License.
The reason why calc was placed under the GNU Lesser General Public
License is because for many years (1984 thru 1999), calc was offered
without any form of Copyleft. At the time calc was placed under
the GNU Lesser General Public License, a number of systems and
distributions distributed calc without a Copyleft.
*************
* COPYING-LGPL
*************
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
*************
* wishlist
*************
Calc Enhancement Wish List:
We welcome calc comments, suggestions, bug fixes, enhancements and
interesting calc scripts that you would like you see included in
future distributions.
To send such items, first subscribe to the calc-tester mailing list.
Then send your comments, suggestions, bug fixes, enhancements and
interesting calc scripts to the calc-tester mailing list.
To subscribe to the calc-tester mailing list, visit the following URL:
http://www.isthe.com/chongo/tech/comp/calc/calc-tester.html
This is a low volume moderated mailing list.
This mailing list replaces calc-tester at asthe dot com list.
If you need a human to help you with your mailing list subscription,
please send EMail to our special:
calc-tester-maillist-help at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
address. To be sure we see your EMail asking for help with your
mailing list subscription, please use the following phase in your
EMail Subject line:
calc tester mailing list help
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
=-=
* In general use faster algorithms for large numbers when they
become known. In particular, look at better algorithms for
very large numbers -- multiply, square and mod in particular.
* Implement an autoload feature. Associate a calc resource filename
with a function or global variable. On the first reference of
such item, perform an automatic load of that file.
* Add error handling statements, so that QUITs, errors from the
'eval' function, division by zeroes, and so on can be caught.
This should be done using syntax similar to:
ONERROR statement DO statement;
Something like signal isn't versatile enough.
* Add a debugging capability so that functions can be single stepped,
breakpoints inserted, variables displayed, and so on.
* Figure out how to write all variables out to a file, including
deeply nested arrays, lists, and objects.
Add the ability to read and write a value in some binary form.
Clearly this is easy for non-neg integers. The question of
everything else is worth pondering.
* Eliminate the need for the define keyword by doing smarter parsing.
* Allow results of a command (or all commands) to be re-directed to a
file or piped into a command.
* Add some kind of #include and #define facility. Perhaps use
the C pre-processor itself?
* Support a more general input and output base mode other than
just dec, hex or octal.
* Implement a form of symbolic algebra. Work on this has already
begun. This will use backquotes to define expressions, and new
functions will be able to act on expressions. For example:
x = `hello * strlen(mom)`;
x = sub(x, `hello`, `hello + 1`);
x = sub(x, `hello`, 10, `mom`, "curds");
eval(x);
prints 55.
* Place the results of previous commands into a parallel history list.
Add a binding that returns the saved result of the command so
that one does not need to re-execute a previous command simply
to obtain its value.
If you have a command that takes a very long time to execute,
it would be nice if you could get at its result without having
to spend the time to reexecute it.
* Add a binding to delete a value from the history list.
One may need to remove a large value from the history list if
it is very large. Deleting the value would replace the history
entry with a null value.
* Add a binding to delete a command from the history list.
Since you can delete values, you might as well be able to
delete commands.
* All one to alter the size of the history list thru config().
In some cases, 256 values is too small, in others it is too large.
* Add a builtin that returns a value from the history list.
As an example:
histval(-10)
returns the 10th value on the history value list, if such
a value is in the history list (null otherwise). And:
histval(23)
return the value of the 23rd command given to calc, if
such a value is in the history list (null otherwise).
It would be very helpful to use the history values in
subsequent equations.
* Add a builtin that returns command as a string from the
history list. As an example:
history(-10)
returns a string containing the 10th command on the
history list, if a such a value is in the history list
(empty string otherwise). And:
history(23)
return the string containing the 23rd command given to calc, if
such a value is in the history list (empty string otherwise).
One could use the eval() function to re-evaluate the command.
* Allow one to optionally restore the command number to calc
prompts. When going back in the history list, indicate the
command number that is being examined.
The command number was a useful item. When one is scanning the
history list, knowing where you are is hard without it. It can
get confusing when the history list wraps or when you use
search bindings. Command numbers would be useful in
conjunction with positive args for the history() and histval()
functions as suggested above.
* Add a builtin that returns the current command number.
For example:
cmdnum()
returns the current command number.
This would allow one to tag a value in the history list. One
could save the result of cmdnum() in a variable and later use
it as an arg to the histval() or history() functions.
* Add a factoring builtin functions. Provide functions that perform
multiple polynomial quadratic sieves, elliptic curve, difference
of two squares, N-1 factoring as so on. Provide a easy general
factoring builtin (say factor(foo)) that would attempt to apply
whatever process was needed based on the value.
Factoring builtins would return a matrix of factors.
It would be handy to configure, via config(), the maximum time
that one should try to factor a number. By default the time
should be infinite. If one set the time limit to a finite
value and the time limit was exceeded, the factoring builtin
would return whatever if had found thus far, even if no new
factors had been found.
Another factoring configuration interface, via config(), that
is needed would be to direct the factoring builtins to return
as soon as a factor was found.
* Allow one to config calc break up long output lines.
The command: calc '2^100000' will produce one very long
line. Many times this is reasonable. Long output lines
are a problem for some utilities. It would be nice if one
could configure, via config(), calc to fold long lines.
By default, calc should continue to produce long lines.
One option to config should be to specify the length to
fold output. Another option should be to append a trailing
\ on folded lines (as some symbolic packages use).
* Allow one to use the READ and WRITE commands inside a function.
* Remove or increase limits on factor(), lfactor(), isprime(),
nextprime(), and prevprime(). Currently these functions cannot
search for factors > 2^32.
* Add read -once -try "filename" which would do nothing
if "filename" was not a readable file.
=-=
Calc bug reports and calc bug fixes should be sent to:
calc-bug-report at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
This replaces the old calc-bugs at asthe dot com address.
To be sure we see your EMail reporting a calc bug, please use the
following phase in your EMail Subject line:
calc bug report
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
However, you may find it more helpful to simply subscribe
to the calc-tester mailing list (see above) and then to
send your report to that mailing list as a wider set calc
testers may be able to help you.
=-=
The calc web site is located at:
http://www.isthe.com/chongo/tech/comp/calc/
NOTE: The EMail address uses 'asthe', while the web site uses 'isthe'.
## Copyright (C) 1999,2014 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.3 $
## @(#) $Id: wishlist,v 30.3 2014/10/12 12:23:43 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/wishlist,v $
##
## Under source code control: 1991/07/21 04:37:24
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*************
* todo
*************
Calc Todo Items:
Code contributions are welcome. First Subscribe to the calc-tester
mailing list. Next, send patches to the calc-tester mailing list.
To subscribe to the calc-tester mailing list, visit the following URL:
http://www.isthe.com/chongo/tech/comp/calc/calc-tester.html
This is a low volume moderated mailing list.
This mailing list replaces calc-tester at asthe dot com list.
If you need a human to help you with your mailing list subscription,
please send EMail to our special:
calc-tester-maillist-help at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
address. To be sure we see your EMail asking for help with your
mailing list subscription, please use the following phase in your
EMail Subject line:
calc tester mailing list help
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
=-=
High priority items:
* Improve the way that calc parses statements such as if, for, while
and do so that when a C programmer does. This works as expected:
if (expr) {
...
}
However this WILL NOT WORK AS EXPECTED:
if (expr)
{
...
}
because calc will parse the if being terminated by
an empty statement followed by a
if (expr) ;
{
...
}
See also "help statement", "help unexpected", "help todo", and
"help bugs".
* Consider using GNU autoconf / configure to build calc.
* It is overkill to have nearly everything wind up in libcalc.
Form a libcalcmath and a libcalclang so that an application
that just wants to link with the calc math libs can use them
without dragging in all of the other calc language, I/O,
and builtin functions.
* Fix any 'Known bugs' as noted in the BUGS file or as
displayed by 'calc help bugs'.
=-=
Medium priority items:
* Verify, complete or fix the 'SEE ALSO' help file sections.
* Verify, complete or fix the 'LINK LIBRARY' help file sections.
* Verify, complete or fix the 'LIMITS' help file sections.
* Verify, complete or fix the 'SYNOPSIS' and 'TYPES' help file sections.
* Perform a code coverage analysis of the 'make check' action
and improve the coverage (within reason) of the regress.cal suite.
* Address, if possible and reasonable, any Calc Mis-features
as noted in the BUGS file or as displayed by 'calc help bugs'.
* Internationalize calc by converting calc error messages and
text strings (e.g., calc startup banner, show output, etc.)
into calls to the GNU gettext internationalization facility.
If somebody translated these strings into another language,
setting $LANG would allow calc to produce error messages
and text strings in that language.
=-=
Low priority items:
* Complete the use of CONST where appropriate:
CONST is beginning to be used with read-only tables and some
function arguments. This allows certain compilers to better
optimize the code as well as alerts one to when some value
is being changed inappropriately. Use of CONST as in:
int foo(CONST int curds, char *CONST whey)
while legal C is not as useful because the caller is protected
by the fact that args are passed by value. However, the
in the following:
int bar(CONST char *fizbin, CONST HALF *data)
is useful because it calls the compiler that the string pointed
at by 'fizbin' and the HALF array pointer at by 'data' should be
treated as read-only.
One should make available a the fundamental math operations
on ZVALUE, NUMBER and perhaps COMPLEX (without all of the
other stuff) in a separate library.
* Clean the source code and document it better.
* Add a builtin function to access the 64 bit FNV hash which
is currently being used internally in seed.c.
=-=
Calc bug reports and calc bug fixes should be sent to:
calc-bug-report at asthe dot com
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
This replaces the old calc-bugs at asthe dot com address.
To be sure we see your EMail reporting a calc bug, please use the
following phase in your EMail Subject line:
calc bug report
That phrase in your subject line will help ensure your
request will get past our anti-spam filters. You may have
additional words in your subject line.
However, you may find it more helpful to simply subscribe
to the calc-tester mailing list (see above) and then to
send your report to that mailing list as a wider set calc
testers may be able to help you.
=-=
The calc web site is located at:
http://www.isthe.com/chongo/tech/comp/calc/
NOTE: The EMail address uses 'asthe', while the web site uses 'isthe'.
## Copyright (C) 1999-2007,2014 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.4 $
## @(#) $Id: todo,v 30.4 2014/10/12 12:23:43 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/todo,v $
##
## Under source code control: 1999/10/20 07:42:55
## File existed as early as: 1999
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|