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
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Book SYSTEM "gapdoc.dtd">
<Book Name="guava"> <!-- REQUIRED -->
<!-- The title page -->
<TitlePage>
<!-- REQUIRED -->
<Title>
<Package>GUAVA</Package>
</Title>
<Subtitle> <!-- OPTIONAL -->
A &GAP;4 Package for computing with error-correcting codes
</Subtitle>
<Version>Version 3.6</Version>
<!-- OPTIONAL -->
<Author>
Jasper Cramwinckel
</Author>
<Author>
Erik Roijackers
</Author>
<Author>
Reinald Baart
</Author>
<Author>Eric Minkes, Lea Ruscio
</Author>
<Author>
Robert L Miller, <Email>rlm@robertlmiller.com</Email>
</Author>
<Author>
Tom Boothby
<!--
<Email>boothby@u.washington.edu</Email>
-->
</Author>
<Author>
Cen (``CJ'') Tjhai <!-- REQUIRED -->
<!--
<Address>
School of Computing, Communications and Electronics,<Br/>
University of Plymouth,<Br/>
Plymouth, Devon, PL4 8AA, UK.
</Address>
-->
<Email>cen.tjhai@plymouth.ac.uk</Email>
<Homepage>http://www.plymouth.ac.uk/staff/ctjhai</Homepage>
</Author>
<Author>
David Joyner (Maintainer), <!-- REQUIRED -->
<!--
<Address>
Mathematics Department,<Br/>
U. S. Naval Academy,<Br/>
Annapolis, MD,<Br/>
21402 USA.
</Address>
-->
<Email>wdjoyner@gmail.com</Email>
<Homepage>http://sage.math.washington.edu/home/wdj/guava/</Homepage>
</Author>
<Date>June 20, 2008</Date>
<!-- OPTIONAL -->
<Copyright>
<!-- OPTIONAL -->
<Package>GUAVA</Package>: ©right; The GUAVA Group: 1992-2003
Jasper Cramwinckel, Erik Roijackers,Reinald Baart, Eric Minkes,
Lea Ruscio (for the tex version), Jeffrey Leon
©right; 2004 David Joyner, Cen Tjhai, Jasper Cramwinckel, Erik Roijackers,
Reinald Baart, Eric Minkes, Lea Ruscio.
©right; 2007 Robert L Miller, Tom Boothby
<P/>
<Package>GUAVA</Package> is released under the
GNU General Public License (GPL).
<P/>
<Package>GUAVA</Package> is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
<P/>
<Package>GUAVA</Package> is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
<P/>
You should have received a copy of the GNU General Public License
along with <Package>GUAVA</Package>; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<P/>
For more details, see
<URL>http://www.fsf.org/licenses/gpl.html</URL>.
<P/>
For many years
<Package>GUAVA</Package> has been released along with the
``backtracking''
C programs of J. Leon. In one of his *.c files the following
statements occur:
``Copyright (C) 1992 by Jeffrey S. Leon.
This software may be used freely
for educational and research purposes.
Any other use requires permission from the author.''
The following should now be appended:
``I, Jeffrey S. Leon, agree to license all the partition
backtrack code which I have written under the GPL
(www.fsf.org) as of this date, April 17, 2007.''
<P/>
<Package>GUAVA</Package> documentation:
©right; Jasper Cramwinckel, Erik Roijackers,Reinald Baart, Eric Minkes,
Lea Ruscio (for the tex version),
David Joyner, Cen Tjhai, Jasper Cramwinckel, Erik Roijackers,
Reinald Baart, Eric Minkes, Lea Ruscio.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
</Copyright>
<!-- end of title page -->
<Acknowledgements>
<!-- OPTIONAL -->
<P/>
<Package>GUAVA</Package> was originally written by Jasper Cramwinckel,
Erik Roijackers, and Reinald Baart in the early-to-mid
1990's as a final project during their study of Mathematics at the
Delft University of Technology, Department of Pure Mathematics,
under the direction of Professor Juriaan Simonis.
This work was continued in Aachen, at Lehrstuhl D fur Mathematik.
In version 1.3, new functions were added by Eric Minkes, also from Delft
University of Technology.
<P/>
JC, ER and RB would like to thank the GAP people at the RWTH Aachen for
their support, A.E. Brouwer for his advice and J. Simonis for his
supervision.
<P/>
The GAP 4 version of <Package>GUAVA</Package> (versions 1.4 and 1.5)
was created by Lea Ruscio and (since 2001, starting with version 1.6)
is currently maintained by David Joyner, who (with the help of several students)
has added several new functions. Starting with version 2.7, the ``best linear code''
tables have been updated. For further details, see the CHANGES file in the
<Package>GUAVA</Package> directory, also available at
<URL>http://sage.math.washington.edu/home/wdj/guava/CHANGES.guava</URL>.
<P/>
<P/>This documentation was prepared with the
<Package>GAPDoc</Package> package of Frank Lübeck and Max Neunhöffer.
The conversion from TeX to
<Package>GAPDoc</Package>'s XML was done by David Joyner in 2004.
<P/>
Please send bug reports, suggestions and other comments about
<Package>GUAVA</Package> to
<Email>support@gap-system.org</Email>. Currently known bugs and
suggested <Package>GUAVA</Package> projects are listed on the
bugs and projects web page
<URL>http://sage.math.washington.edu/home/wdj/guava/guava2do.html</URL>.
Older releases and further history can be found on the
<Package>GUAVA</Package> web page
<URL>http://sage.math.washington.edu/home/wdj/guava/</URL>.
<P/>
<E>Contributors</E>: Other than the authors listed on the title page,
the following people have contributed code to the <Package>GUAVA</Package>
project: Alexander Hulpke, Steve Linton, Frank Lübeck, Aron Foster,
Wayne Irons, Clifton (Clipper) Lennon, Jason McGowan, Shuhong Gao,
Greg Gamble.
<P/>
For documentation on Leon's programs,
see the src/leon/doc subdirectory of <Package>GUAVA</Package>.
</Acknowledgements>
</TitlePage>
<TableOfContents/> <!-- OPTIONAL -->
<!-- The document -->
<Body> <!-- REQUIRED -->
<Chapter><Heading>Introduction</Heading>
<Section>
<Heading>Introduction to the <Package>GUAVA</Package> package</Heading>
<P/>
This is the manual of the GAP package <Package>GUAVA</Package>
that provides implementations of some routines
designed for the construction and analysis of in the theory of
error-correcting codes. This version of <Package>GUAVA</Package>
requires GAP 4.4.5 or later.
<P/>
The functions can be divided into three subcategories:
<List>
<Item>
Construction of codes:
<Package>GUAVA</Package> can construct unrestricted, linear and cyclic
codes. Information about the code, such as operations applicable
to the code, is stored in a record-like
data structure called a GAP object.
</Item>
<Item>
Manipulations of codes:
Manipulation transforms one code into another, or constructs a new code
from two codes. The new code can profit from the data in the record of
the old code(s), so in these cases calculation time decreases.
</Item>
<Item>
Computations of information about codes:
<Package>GUAVA</Package> can calculate important parameters
of codes quickly. The results are stored in the codes'
object components.
</Item>
</List>
<P/>
Except for the automorphism group and isomorphism
testing functions, which make use of J.S. Leon's
programs (see <Cite Key="Leon91"/> and the documentation
in the 'src/leon' subdirectory of the 'guava'
directory for some details), and
<Ref Func="MinimumWeight" Style="Number"/> function,
<Package>GUAVA</Package> is written in the GAP
language, and runs on any system supporting GAP4.3 and above.
Several algorithms that need the speed were integrated
in the GAP kernel.
<P/>
Good general references for error-correcting codes and the
technical terms in this manual are MacWilliams and Sloane
<Cite Key="MS83"/>
Huffman and Pless <Cite Key="HP03"/>.
</Section>
<Section>
<Heading>Installing <Package>GUAVA</Package></Heading>
<Label Name="Installing GUAVA"/>
To install <Package>GUAVA</Package>
(as a GAP 4 Package) unpack the archive file
in a directory in the `pkg' hierarchy of your version of GAP 4.
<P/>
After unpacking <Package>GUAVA</Package>
the GAP-only part of <Package>GUAVA</Package> is installed.
The parts of <Package>GUAVA</Package>
depending on J. Leon's backtrack programs package
(for computing automorphism groups) are only available in a UNIX
environment, where you should proceed as follows:
Go to the newly created `guava' directory and call
<C>`./configure /gappath'</C>
where <C>/gappath</C> is the path to the GAP
home directory. So for example, if
you install the package in the main `pkg' directory call
<Verb>
./configure ../..
</Verb>
This will fetch the architecture type for which GAP has been compiled
last and create a `Makefile'. Now call
<Verb>
make
</Verb>
to compile the binary and to install it in the appropriate place.
(For a windows machine with CYGWIN installed -
see <URL>http://www.cygwin.com/</URL> - instructions for
compiling Leon's binaries are likely to be similar to those above.
On a 64-bit SUSE linux computer, instead of the configure command above
- which will only compile the 32-bit binary - type
<Verb>
./configure ../.. --enable-libsuffix=64
make
</Verb>
to compile Leon's program as a 64 bit native binary. This may also
work for other 64-bit linux distributions as well.)
<P/>
Starting with version 2.5, you should also install the GAP
package <Package>SONATA</Package> to load GAP. You can download
this from the GAP website and unpack it in the `pkg'
subdirectory.
<P/>
This completes the installation of <Package>GUAVA</Package>
for a single architecture. If
you use this installation of <Package>GUAVA</Package>
on different hardware platforms you
will have to compile the binary for each platform separately.
</Section>
<Section>
<Heading>Loading <Package>GUAVA</Package></Heading>
After starting up GAP, the <Package>GUAVA</Package>
package needs to be loaded. Load
<Package>GUAVA</Package> by typing at the GAP prompt:
<Example>
gap> LoadPackage( "guava" );
</Example>
If <Package>GUAVA</Package> isn't already in memory, it is
loaded and the author information is displayed.
If you are a frequent user of <Package>GUAVA</Package>,
you might consider putting this line in your `.gaprc' file.
</Section>
</Chapter>
<Chapter>
<Heading>Coding theory functions in GAP</Heading>
<Label Name="Coding theory functions in the GAP"/>
This chapter will recall from the GAP4.4.5 manual some of the
GAP coding theory and finite field functions useful for
coding theory. Some of these functions are
partially written in C for speed. The main functions are
<List>
<Item>
<C>AClosestVectorCombinationsMatFFEVecFFE</C>,
</Item>
<Item>
<C>AClosestVectorCombinationsMatFFEVecFFECoords</C>,
</Item>
<Item>
<C>CosetLeadersMatFFE</C>,
</Item>
<Item>
<C>DistancesDistributionMatFFEVecFFE</C>,
</Item>
<Item>
<C>DistancesDistributionVecFFEsVecFFE</C>,
</Item>
<Item>
<C>DistanceVecFFE</C> and <C>WeightVecFFE</C>,
</Item>
<Item>
<C>ConwayPolynomial</C> and <C>IsCheapConwayPolynomial</C>,
</Item>
<Item>
<C>IsPrimitivePolynomial</C>,
and <C>RandomPrimitivePolynomial</C>.
</Item>
</List>
However, the GAP command
<C>PrimitivePolynomial</C> returns an integer primitive polynomial
not the finite field kind.
<P/>
<Section>
<Heading>
Distance functions
</Heading>
<Label Name="Distance functions"/>
<ManSection Label="AClosestVectorCombinationsMatFFEVecFFE">
<Func Name="AClosestVectorCombinationsMatFFEVecFFE"
Arg=" mat, F, vec, r, st "/>
<Description>
This command runs through the <A>F</A>-linear
combinations of the vectors in the rows of
the matrix <A>mat</A> that can be written as linear combinations of exactly
<A>r</A> rows (that is without using zero as a coefficient) and returns a
vector from these that is closest to the vector <A>vec</A>. The length of
the rows of <A>mat</A> and the length of <A>vec</A> must be equal,
and all elements must lie in <A>F</A>.
The rows of <A>mat</A> must be linearly independent.
If it finds a vector of distance at most <A>st</A>, which must be a
nonnegative integer, then it stops immediately and returns this vector.
</Description>
</ManSection>
<Example>
gap> F:=GF(3);;
gap> x:= Indeterminate( F );; pol:= x^2+1;
x_1^2+Z(3)^0
gap> C := GeneratorPolCode(pol,8,F);
a cyclic [8,6,1..2]1..2 code defined by generator polynomial over GF(3)
gap> v:=Codeword("12101111");
[ 1 2 1 0 1 1 1 1 ]
gap> v:=VectorCodeword(v);
[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ]
gap> G:=GeneratorMat(C);
[ [ Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ] ]
gap> AClosestVectorCombinationsMatFFEVecFFE(G,F,v,1,1);
[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ]
</Example>
<!--
F:=GF(3);; x:= Indeterminate( F );; pol:= x^2+1;
C := GeneratorPolCode(pol,8,F);
v:=Codeword("12101111");
v:=VectorCodeword(v);
G:=GeneratorMat(C);
AClosestVectorCombinationsMatFFEVecFFE(G,F,v,1,1);
-->
<ManSection Label="AClosestVectorCombinationsMatFFEVecFFECoords">
<Func Name="AClosestVectorComb..MatFFEVecFFECoords"
Arg=" mat, F, vec, r, st "/>
<Description>
<C>AClosestVectorCombinationsMatFFEVecFFECoords</C>
returns a two element list containing (a) the same closest
vector as in <C>AClosestVectorCombinationsMatFFEVecFFE</C>,
and (b) a vector <A>v</A> with exactly <A>r</A> non-zero
entries, such that <M>v*mat</M> is the closest vector.
</Description>
</ManSection>
<Example>
gap> F:=GF(3);;
gap> x:= Indeterminate( F );; pol:= x^2+1;
x_1^2+Z(3)^0
gap> C := GeneratorPolCode(pol,8,F);
a cyclic [8,6,1..2]1..2 code defined by generator polynomial over GF(3)
gap> v:=Codeword("12101111"); v:=VectorCodeword(v);;
[ 1 2 1 0 1 1 1 1 ]
gap> G:=GeneratorMat(C);;
gap> AClosestVectorCombinationsMatFFEVecFFECoords(G,F,v,1,1);
[ [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ],
[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0 ] ]
</Example>
<!--
F:=GF(3);; x:= Indeterminate( F );; pol:= x^2+1;
C := GeneratorPolCode(pol,8,F);
v:=Codeword("12101111"); v:=VectorCodeword(v);;
G:=GeneratorMat(C);;
AClosestVectorCombinationsMatFFEVecFFECoords(G,F,v,1,1);
-->
<ManSection Label="DistancesDistributionMatFFEVecFFE">
<Func Name="DistancesDistributionMatFFEVecFFE"
Arg=" mat, f, vec "/>
<Description>
<C>DistancesDistributionMatFFEVecFFE</C>
returns the distances distribution of the vector <A>vec</A> to the vectors
in the vector space generated by the rows of the matrix <A>mat</A> over the finite field <A>f</A>.
All vectors must have the same length, and all elements must lie in a common
field. The distances distribution is a list <M>d</M> of length
<M>Length(vec)+1</M>, such that the value <M>d[i]</M> is the number of
vectors in vecs that have distance <M>i+1</M> to <A>vec</A>.
</Description>
</ManSection>
<Example>
gap> v:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;
gap> vecs:=[ [ Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
> [ 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
> [ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3) ],
> [ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ],
> [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3) ],
> [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ] ];;
gap> DistancesDistributionMatFFEVecFFE(vecs,GF(3),v);
[ 0, 4, 6, 60, 109, 216, 192, 112, 30 ]
</Example>
<!--
v:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;
vecs:=[ [ Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ] ];;
DistancesDistributionMatFFEVecFFE(vecs,GF(3),v);
-->
<ManSection Label="DistancesDistributionVecFFEsVecFFE">
<Func Name="DistancesDistributionVecFFEsVecFFE"
Arg=" vecs, vec "/>
<Description>
<C>DistancesDistributionVecFFEsVecFFE</C> returns
the distances distribution of the vector
<A>vec</A> to the vectors in the list <A>vecs</A>. All vectors must
have the same length, and all elements must lie in a
common field. The distances distribution is a list <M>d</M> of
length <M>Length(vec)+1</M>, such that the value <M>d[i]</M>
is the number of vectors in <A>vecs</A> that have distance
<M>i+1</M> to <A>vec</A>.
</Description>
</ManSection>
<Example>
gap> v:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;
gap> vecs:=[ [ Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
> [ 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
> [ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3) ],
> [ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ],
> [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3) ],
> [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ] ];;
gap> DistancesDistributionVecFFEsVecFFE(vecs,v);
[ 0, 0, 0, 0, 0, 4, 0, 1, 1 ]
</Example>
<!--
v:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;
vecs:=[ [ Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3) ],
[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ] ];;
DistancesDistributionVecFFEsVecFFE(vecs,v);
-->
<ManSection Label="WeightVecFFE">
<Func Name="WeightVecFFE" Arg=" vec "/>
<Description>
<C>WeightVecFFE</C> returns the weight of the finite field
vector <A>vec</A>, i.e. the number of nonzero entries.
</Description>
</ManSection>
<Example>
gap> v:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;
gap> WeightVecFFE(v);
7
</Example>
<!--
v:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;
WeightVecFFE(v);
-->
<Index>
Hamming metric
</Index>
<ManSection Label="DistanceVecFFE">
<Func Name="DistanceVecFFE" Arg=" vec1 vec2 "/>
<Description>
The <E>Hamming metric</E> on <M>GF(q)^n</M> is the function
<Display>
dist((v_1,...,v_n),(w_1,...,w_n))
=|\{i\in [1..n]\ |\ v_i\not= w_i\}|.
</Display>
This is also called the (Hamming) distance
between <M>v=(v_1,...,v_n)</M> and <M>w=(w_1,...,w_n)</M>.
<C>DistanceVecFFE</C>
returns the distance between the two vectors <A>vec1</A> and
<A>vec2</A>, which must have the same length and whose
elements must lie in a common field. The distance is the number
of places where <A>vec1</A> and <A>vec2</A> differ.
</Description>
</ManSection>
<Example>
gap> v1:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;
gap> v2:=[ Z(3), Z(3)^0, Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;
gap> DistanceVecFFE(v1,v2);
2
</Example>
<!--
v1:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;
v2:=[ Z(3), Z(3)^0, Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;
DistanceVecFFE(v1,v2);
-->
</Section>
<Section>
<Heading>
Other functions
</Heading>
<Label Name="Other functions"/>
We basically repeat, with minor variation, the material
in the GAP manual or from Frank Luebeck's website
<URL>http://www.math.rwth-aachen.de:8001/~Frank.Luebeck/data/ConwayPol</URL>
on Conway polynomials.
<Index><M>GF(p)</M></Index>
The <B>prime fields</B>: If <M>p\geq 2</M> is a prime then
<M>GF(p)</M> denotes the field <M>{\mathbb{Z}}/p{\mathbb{Z}}</M>,
with addition and multiplication performed mod <M>p</M>.
<P/>
<Index><M>GF(q)</M></Index>
The <B>prime power fields</B>: Suppose <M>q=p^r</M> is a prime
power, <M>r>1</M>, and put <M>F=GF(p)</M>. Let <M>F[x]</M>
denote the ring of all polynomials over <M>F</M>
and let <M>f(x)</M> denote a monic irreducible
polynomial in <M>F[x]</M> of degree <M>r</M>. The quotient
<M>E = F[x]/(f(x))= F[x]/f(x)F[x]</M> is a field
with <M>q</M> elements.
If <M>f(x)</M> and <M>E</M> are related in this way, we say that
<M>f(x)</M> is the <B>defining polynomial</B> of <M>E</M>.
<Index>defining polynomial</Index>
Any defining polynomial factors completely into
distinct linear factors over the field it defines.
<P/>
For any finite field <M>F</M>, the multiplicative group of
non-zero elements <M>F^\times</M> is a cyclic group. An
<M>\alpha \in F</M> is called a <B>primitive element</B> if it is a
generator of <M>F^\times</M>. A defining polynomial
<M>f(x)</M> of <M>F</M> is said to be <B>primitive</B> if
it has a root in <M>F</M> which is a primitive element.
<Index>primitive element</Index>
<ManSection Label="ConwayPolynomial">
<Func Name="ConwayPolynomial" Arg=" p n "/>
<Description>
A standard notation for the elements of <M>GF(p)</M> is
given via the representatives <M>0, ..., p-1</M> of the cosets modulo <M>p</M>.
We order these elements by <M>0 \ \ \langle\ \ 1 \ \ \langle\ \ 2 \ \ \langle\ \ ... \ \ \langle\ \ p-1</M>.
We introduce an ordering of the polynomials of degree <M>r</M> over <M>GF(p)</M>.
Let <M>g(x) = g_rx^r + ... + g_0</M> and
<M>h(x) = h_rx^r + ... + h_0</M> (by convention, <M>g_i=h_i=0</M> for <M>i\ \ \rangle\ \ r</M>).
Then we define <M>g \ \ \langle\ \ h</M> if and only if
there is an index <M>k</M> with <M>g_i = h_i</M> for <M>i \ \ \rangle\ \ k</M> and
<M>(-1)^{r-k} g_k \ \ \langle\ \ (-1)^{r-k} h_k</M>.
<P/>
The <B>Conway polynomial</B> <M>f_{p,r}(x)</M> for <M>GF(p^r)</M> is the smallest
polynomial of degree <M>r</M> with respect to this ordering such that:
<List>
<Item>
<M>f_{p,r}(x)</M> is monic,
</Item>
<Item>
<M>f_{p,r}(x)</M> is primitive, that is, any zero is a generator of
the (cyclic) multiplicative group of <M>GF(p^r)</M>,
</Item>
<Item>
for each proper divisor <M>m</M> of <M>r</M> we have that
<M>f_{p,m}(x^{(p^r-1) / (p^m-1)}) \equiv 0 \pmod{f_{p,r}(x)}</M>;
that is, the <M>(p^r-1) / (p^m-1)</M>-th power of a zero of
<M>f_{p,r}(x)</M> is a zero of <M>f_{p,m}(x)</M>.
</Item>
</List>
<P/>
<C>ConwayPolynomial(p,n)</C> returns the polynomial <M>f_{p,r}(x)</M> defined above.
<P/>
<C>IsCheapConwayPolynomial(p,n)</C>
returns true if <C>ConwayPolynomial( p, n )</C> will give a result in
reasonable time. This is either the case when this polynomial is
pre-computed, or if <M>n,p</M> are not too big.
</Description>
</ManSection>
<Index>IsCheapConwayPolynomial</Index>
<ManSection Label="RandomPrimitivePolynomial">
<Func Name="RandomPrimitivePolynomial" Arg=" F n "/>
<Description>
For a finite field <A>F</A> and a positive integer <A>n</A> this function
returns a primitive polynomial of degree <A>n</A> over <A>F</A>,
that is a zero of this polynomial has maximal multiplicative order
<M>|F|^n-1</M>.
<P/>
<C>IsPrimitivePolynomial(f)</C> can be used to check if a
univariate polynomial <A>f</A> is primitive or not.
</Description>
</ManSection>
<Index>IsPrimitivePolynomial</Index>
</Section>
</Chapter>
<Chapter>
<Heading>Codewords</Heading>
<Label Name="Codewords"/>
Let <M>GF(q)</M> denote a finite field with <M>q</M> (a prime power)
elements. A <E>code</E> is a subset <M>C</M> of some
finite-dimensional vector space <M>V</M> over <M>GF(q)</M>. The
<E>length</E> of <M>C</M> is the dimension of <M>V</M>.
Usually, <M>V=GF(q)^n</M> and the length is the number of
coordinate entries. When <M>C</M> is itself a vector space
over <M>GF(q)</M> then it is called a <E>linear code</E>
<Index>linear code</Index> and
the <E>dimension</E> of <M>C</M>
is its dimension as a vector space over <M>GF(q)</M>.
<P/>
In <Package>GUAVA</Package>, a `codeword' is a GAP record,
with one of its components being an element in <M>V</M>.
Likewise, a `code' is a GAP record,
with one of its components being a subset (or subspace with given
basis, if <M>C</M> is linear) of <M>V</M>.
<Example>
gap> C:=RandomLinearCode(20,10,GF(4));
a [20,10,?] randomly generated code over GF(4)
gap> c:=Random(C);
[ 1 a 0 0 0 1 1 a^2 0 0 a 1 1 1 a 1 1 a a 0 ]
gap> NamesOfComponents(C);
[ "LeftActingDomain", "GeneratorsOfLeftOperatorAdditiveGroup", "WordLength",
"GeneratorMat", "name", "Basis", "NiceFreeLeftModule", "Dimension",
"Representative", "ZeroImmutable" ]
gap> NamesOfComponents(c);
[ "VectorCodeword", "WordLength", "treatAsPoly" ]
gap> c!.VectorCodeword;
[ immutable compressed vector length 20 over GF(4) ]
gap> Display(last);
[ Z(2^2), Z(2^2), Z(2^2), Z(2)^0, Z(2^2), Z(2^2)^2, 0*Z(2), Z(2^2), Z(2^2),
Z(2)^0, Z(2^2)^2, 0*Z(2), 0*Z(2), Z(2^2), 0*Z(2), 0*Z(2), 0*Z(2), Z(2^2)^2,
Z(2)^0, 0*Z(2) ]
gap> C!.Dimension;
10
</Example>
<!--
C:=RandomLinearCode(20,10,GF(4));
c:=Random(C);
NamesOfComponents(C);
NamesOfComponents(c);
c!.VectorCodeword;
Display(last);
C!.Dimension;
-->
Mathematically, a `codeword' is an element of a code <M>C</M>,
but in <Package>GUAVA</Package> the <C>Codeword</C>
and <C>VectorCodeword</C> commands have implementations which do not check if
the codeword belongs to <M>C</M> (i.e., are independent
of the code itself). They exist primarily to make it
easier for the user to construct a the associated GAP record.
Using these commands, one can enter into a GAP
both a codeword <M>c</M> (belonging to <M>C</M>)
and a received word <M>r</M> (not belonging to <M>C</M>)
using the same command. The user can input codewords in different
formats (as strings, vectors, and polynomials),
and output information is formatted in a readable way.
<P/>
A codeword <M>c</M> in a linear code <M>C</M> arises in practice by
an initial encoding of a 'block' message
<M>m</M>, adding enough redundancy to recover <M>m</M> after
<M>c</M> is transmitted via a 'noisy' communication medium.
In <Package>GUAVA</Package>, for linear codes,
the map <M>m\longmapsto c</M>
is computed using the command <C>c:=m*C</C> and
recovering <M>m</M> from <M>c</M> is obtained by the
command <C>InformationWord(C,c)</C>. These commands are explained
more below.
<P/>
Many operations are available on codewords themselves,
although codewords also work together with codes
(see chapter <Ref Label="Codes" Style="Number"/> on Codes).
<P/>
The first section describes how codewords are constructed (see
<Ref Func="Codeword" Style="Number"/> and
<Ref Func="IsCodeword" Style="Number"/>).
Sections <Ref Label="Comparisons of Codewords" Style="Number"/> and
<Ref Label="Arithmetic Operations for Codewords" Style="Number"/>
describe the arithmetic operations applicable to codewords.
Section
<Ref Label="convert Codewords to Vectors or Polynomials" Style="Number"/>
describe functions that convert codewords back to vectors or polynomials
(see
<Ref Func="VectorCodeword" Style="Number"/> and
<Ref Func="PolyCodeword" Style="Number"/>).
Section <Ref Label="Functions that Change the Display Form of a
Codeword" Style="Number"/> describe
functions that change the way a codeword is displayed (see
<Ref Func="TreatAsVector" Style="Number"/> and
<Ref Func="TreatAsPoly" Style="Number"/>).
Finally, Section <Ref Label="Other Codeword Functions" Style="Number"/>
describes a function to
generate a null word (see <Ref Func="NullWord" Style="Number"/>)
and some functions for extracting
properties of codewords
(see <Ref Func="DistanceCodeword" Style="Number"/>,
<Ref Func="Support" Style="Number"/>
and <Ref Func="WeightCodeword" Style="Number"/>).
<Section>
<Heading>Construction of Codewords</Heading>
<Label Name="Construction of Codewords"/>
<ManSection Label="Codeword">
<Func Name="Codeword" Arg=" obj [n] [F] "/>
<Description>
<C>Codeword</C> returns a codeword or a list of codewords constructed from
<Arg>obj</Arg>.
The object <Arg>obj</Arg> can be a vector, a string, a polynomial or a
codeword. It may also be a list of those (even a mixed list).
<P/>
If a number <Arg>n</Arg> is specified, all constructed codewords
have length <Arg>n</Arg>.
This is the only way to make sure that all elements of
<Arg>obj</Arg> are converted to codewords of the same length.
Elements of <Arg>obj</Arg> that are
longer than <Arg>n</Arg> are reduced in length by cutting of the last
positions. Elements of <Arg>obj</Arg> that are
shorter than <Arg>n</Arg> are lengthened by
adding zeros at the end. If no <Arg>n</Arg> is specified, each constructed
codeword is handled individually.
<P/>
If a Galois field <Arg>F</Arg> is specified, all
codewords are constructed over
this field. This is the only way to make sure that all elements of
<Arg>obj</Arg>
are converted to the same field <Arg>F</Arg>
(otherwise they are converted one by
one). Note that all elements of <Arg>obj</Arg> must have elements over
<Arg>F</Arg> or over `Integers'.
Converting from one Galois field to another is not
allowed. If no <Arg>F</Arg> is specified, vectors or
strings with integer elements
will be converted to the smallest Galois field possible.
<P/>
Note that a significant speed increase is achieved
if <Arg>F</Arg> is specified,
even when all elements of <Arg>obj</Arg> already have
elements over <Arg>F</Arg>.
<P/>
Every vector in <Arg>obj</Arg> can be a finite field vector over
<Arg>F</Arg> or a vector over `Integers'. In the last case, it is converted to
<Arg>F</Arg> or, if omitted, to the smallest Galois field possible.
<P/>
Every string in <Arg>obj</Arg> must be a string of numbers,
without spaces, commas
or any other characters. These numbers must be from 0 to 9. The string is
converted to a codeword over <Arg>F</Arg> or,
if <Arg>F</Arg> is omitted, over the smallest
Galois field possible. Note that since all numbers in the string are
interpreted as one-digit numbers, Galois fields of size larger than 10
are not properly represented when using strings. In fact, no
finite field of size larger than 11 arises in this fashion at all.
<P/>
Every polynomial in <Arg>obj</Arg> is converted to a codeword of
length <Arg>n</Arg> or, if
omitted, of a length dictated by the degree of the polynomial.
If <Arg>F</Arg> is specified, a polynomial in
<Arg>obj</Arg> must be over <Arg>F</Arg>.
<P/>
Every element of <Arg>obj</Arg> that is already a codeword is
changed to a codeword of length <Arg>n</Arg>.
If no <Arg>n</Arg> was specified, the
codeword doesn't change. If <Arg>F</Arg> is specified,
the codeword must have base field <Arg>F</Arg>.
<Example>
gap> c := Codeword([0,1,1,1,0]);
[ 0 1 1 1 0 ]
gap> VectorCodeword( c );
[ 0*Z(2), Z(2)^0, Z(2)^0, Z(2)^0, 0*Z(2) ]
gap> c2 := Codeword([0,1,1,1,0], GF(3));
[ 0 1 1 1 0 ]
gap> VectorCodeword( c2 );
[ 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, 0*Z(3) ]
gap> Codeword([c, c2, "0110"]);
[ [ 0 1 1 1 0 ], [ 0 1 1 1 0 ], [ 0 1 1 0 ] ]
gap> p := UnivariatePolynomial(GF(2), [Z(2)^0, 0*Z(2), Z(2)^0]);
Z(2)^0+x_1^2
gap> Codeword(p);
x^2 + 1
</Example>
<!--
c := Codeword([0,1,1,1,0]);
VectorCodeword( c );
c2 := Codeword([0,1,1,1,0], GF(3));
VectorCodeword( c2 );
Codeword([c, c2, "0110"]);
p := UnivariatePolynomial(GF(2), [Z(2)^0, 0*Z(2), Z(2)^0]);
Codeword(p);
-->
<P/>
This command can also be called using the syntax
<C>Codeword(obj,C)</C>.
In this format, the elements of <Arg>obj</Arg>
are converted to elements of the
same ambient vector space as the elements of a code <Arg>C</Arg>.
The command <C>Codeword(c,C)</C>
is the same as calling <C>Codeword(c,n,F)</C>, where
<Arg>n</Arg> is the word length of <Arg>C</Arg>
and the <Arg>F</Arg> is the ground field of <Arg>C</Arg>.
</Description>
</ManSection>
<Example>
gap> C := WholeSpaceCode(7,GF(5));
a cyclic [7,7,1]0 whole space code over GF(5)
gap> Codeword(["0220110", [1,1,1]], C);
[ [ 0 2 2 0 1 1 0 ], [ 1 1 1 0 0 0 0 ] ]
gap> Codeword(["0220110", [1,1,1]], 7, GF(5));
[ [ 0 2 2 0 1 1 0 ], [ 1 1 1 0 0 0 0 ] ]
gap> C:=RandomLinearCode(10,5,GF(3));
a linear [10,5,1..3]3..5 random linear code over GF(3)
gap> Codeword("1000000000",C);
[ 1 0 0 0 0 0 0 0 0 0 ]
gap> Codeword("1000000000",10,GF(3));
[ 1 0 0 0 0 0 0 0 0 0 ]
</Example>
<!--
C := WholeSpaceCode(7,GF(5));
Codeword(["0220110", [1,1,1]], C);
Codeword(["0220110", [1,1,1]], 7, GF(5));
C:=RandomLinearCode(10,5,GF(3));
Codeword("1000000000",C);
Codeword("1000000000",10,GF(3));
-->
<ManSection Label="CodewordNr">
<Func Name="CodewordNr" Arg=" C list "/>
<Description>
<C>CodewordNr</C> returns a list of codewords of <Arg>C</Arg>.
<Arg>list</Arg> may be a list of
integers or a single integer. For each integer of
<Arg>list</Arg>, the
corresponding codeword of <Arg>C</Arg> is returned.
The correspondence of a number
<M>i</M> with a codeword is determined as follows: if a list of elements of
<Arg>C</Arg> is available, the <M>i^{th}</M>
element is taken. Otherwise, it is
calculated by multiplication of the <M>i^{th}</M> information vector by the
generator matrix or generator polynomial, where the information vectors
are ordered lexicographically. In particular, the returned
codeword(s) could be a vector or a polynomial.
So <C>CodewordNr(C, i)</C> is equal to
<C>AsSSortedList(C)[i]</C>, described in the next chapter.
The latter function first calculates the set of all
the elements of <M>C</M> and then
returns the <M>i^{th}</M> element of that set, whereas the
former only calculates the <M>i^{th}</M> codeword.
</Description>
</ManSection>
<Example>
gap> B := BinaryGolayCode();
a cyclic [23,12,7]3 binary Golay code over GF(2)
gap> c := CodewordNr(B, 4);
x^22 + x^20 + x^17 + x^14 + x^13 + x^12 + x^11 + x^10
gap> R := ReedSolomonCode(2,2);
a cyclic [2,1,2]1 Reed-Solomon code over GF(3)
gap> AsSSortedList(R);
[ [ 0 0 ], [ 1 1 ], [ 2 2 ] ]
gap> CodewordNr(R, [1,3]);
[ [ 0 0 ], [ 2 2 ] ]
</Example>
<!--
B := BinaryGolayCode();
c := CodewordNr(B, 4);
R := ReedSolomonCode(2,2);
AsSSortedList(R);
CodewordNr(R, [1,3]);
-->
<ManSection>
<Func Name="IsCodeword" Arg=" obj "/>
<Description>
<C>IsCodeword</C> returns `true' if <Arg>obj</Arg>,
which can be an object of arbitrary
type, is of the codeword type and `false' otherwise. The function will
signal an error if <Arg>obj</Arg> is an unbound variable.
</Description>
</ManSection>
<Example>
gap> IsCodeword(1);
false
gap> IsCodeword(ReedMullerCode(2,3));
false
gap> IsCodeword("11111");
false
gap> IsCodeword(Codeword("11111"));
true
</Example>
<!--
IsCodeword(1);
IsCodeword(ReedMullerCode(2,3));
IsCodeword("11111");
IsCodeword(Codeword("11111"));
-->
</Section>
<Section>
<Heading>Comparisons of Codewords</Heading>
<Label Name="Comparisons of Codewords"/>
<ManSection Label="=">
<Func Name="=" Arg=" c1 c2"/>
<Description>
The equality operator <C>c1 = c2</C>
evaluates to `true' if the codewords
<A>c1</A>
and <A>c2</A> are equal, and to `false' otherwise.
Note that codewords are equal if and only if their base vectors are
equal. Whether they are represented as a vector or polynomial has
nothing to do with the comparison.
<P/>
Comparing codewords with objects of other types is not recommended,
although it is possible. If <A>c2</A> is the codeword, the other object
<A>c1</A> is first converted to a codeword, after which comparison is
possible. This way, a codeword can be compared with a vector, polynomial,
or string. If <A>c1</A> is the codeword, then problems may arise if
<A>c2</A> is a polynomial. In that case, the comparison always
yields a `false', because the polynomial comparison is called.
<P/>
The equality operator is also denoted <C>EQ</C>, and
<C>EQ(c1,c2)</C> is the same as <C>c1 = c2</C>.
There is also an inequality operator, &tlt; &tgt;,
or <C>not EQ</C>.
<Index>not =</Index>
<Index>&tlt; &tgt;</Index>
</Description>
</ManSection>
<Example>
gap> P := UnivariatePolynomial(GF(2), Z(2)*[1,0,0,1]);
Z(2)^0+x_1^3
gap> c := Codeword(P, GF(2));
x^3 + 1
gap> P = c; # codeword operation
true
gap> c2 := Codeword("1001", GF(2));
[ 1 0 0 1 ]
gap> c = c2;
true
gap> C:=HammingCode(3);
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> c1:=Random(C);
[ 1 0 0 1 1 0 0 ]
gap> c2:=Random(C);
[ 0 1 0 0 1 0 1 ]
gap> EQ(c1,c2);
false
gap> not EQ(c1,c2);
true
</Example>
<!--
P := UnivariatePolynomial(GF(2), Z(2)*[1,0,0,1]);
c := Codeword(P, GF(2));
P = c; # codeword operation
c2 := Codeword("1001", GF(2));
c = c2;
C:=HammingCode(3);
c1:=Random(C);
c2:=Random(C);
EQ(c1,c2);
not EQ(c1,c2);
-->
</Section>
<Section>
<Heading>Arithmetic Operations for Codewords</Heading>
<Label Name="Arithmetic Operations for Codewords"/>
<ManSection Label="+ codewords">
<Func Name="+" Arg="c1 c2"/>
<Description>
The following operations are always available for codewords. The operands
must have a common base field, and must have the same length. No implicit
conversions are performed.
<Index>codewords, addition</Index>
<P/>
The operator <C>+</C> evaluates to the sum of the codewords <A>c1</A>
and <A>c2</A>.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,5,GF(3));
a linear [10,5,1..3]3..5 random linear code over GF(3)
gap> c:=Random(C);
[ 1 0 2 2 2 2 1 0 2 0 ]
gap> Codeword(c+"2000000000");
[ 0 0 2 2 2 2 1 0 2 0 ]
gap> Codeword(c+"1000000000");
</Example>
<!--
C:=RandomLinearCode(10,5,GF(3));
c:=Random(C);
Codeword(c+"2000000000");
Codeword(c+"1000000000");
-->
The last command returns a GAP ERROR since
the `codeword' which <Package>GUAVA</Package>
associates to "1000000000" belongs to <M>GF(2)</M>
and not <M>GF(3)</M>.
<ManSection Label="-">
<Func Name="-" Arg="c1 c2"/>
<Description>
Similar to addition:
the operator <C>-</C> evaluates to the difference of the codewords
<A>c1</A> and <A>c2</A>.
<Index>codewords, subtraction</Index>
</Description>
</ManSection>
<ManSection Label="+">
<Func Name="+" Arg="v C"/>
<Description>
The operator <C>v+C</C> evaluates to the coset code of code <A>C</A>
after adding a `codeword' <A>v</A> to all codewords in <A>C</A>.
Note that if <M>c \in C</M> then mathematically
<M>c+C=C</M> but <Package>GUAVA</Package> only
sees them equal as <E>sets</E>.
See <Ref Func="CosetCode" Style="Number"/>.
<P/>
Note that the command <C>C+v</C> returns the same output
as the command <C>v+C</C>.
<P/>
<Index>codewords, cosets</Index>
</Description>
</ManSection>
<Index>coset</Index>
<Example>
gap> C:=RandomLinearCode(10,5);
a [10,5,?] randomly generated code over GF(2)
gap> c:=Random(C);
[ 0 0 0 0 0 0 0 0 0 0 ]
gap> c+C;
[ add. coset of a [10,5,?] randomly generated code over GF(2) ]
gap> c+C=C;
true
gap> IsLinearCode(c+C);
false
gap> v:=Codeword("100000000");
[ 1 0 0 0 0 0 0 0 0 ]
gap> v+C;
[ add. coset of a [10,5,?] randomly generated code over GF(2) ]
gap> C=v+C;
false
gap> C := GeneratorMatCode( [ [1, 0,0,0], [0, 1,0,0] ], GF(2) );
a linear [4,2,1]1 code defined by generator matrix over GF(2)
gap> Elements(C);
[ [ 0 0 0 0 ], [ 0 1 0 0 ], [ 1 0 0 0 ], [ 1 1 0 0 ] ]
gap> v:=Codeword("0011");
[ 0 0 1 1 ]
gap> C+v;
[ add. coset of a linear [4,2,4]1 code defined by generator matrix over GF(2) ]
gap> Elements(C+v);
[ [ 0 0 1 1 ], [ 0 1 1 1 ], [ 1 0 1 1 ], [ 1 1 1 1 ] ]
</Example>
<!--
C:=RandomLinearCode(10,5);
c:=Random(C);
c+C;
c+C=C;
IsLinearCode(c+C);
v:=Codeword("100000000");
v+C;
C=v+C;
C := GeneratorMatCode( [ [1, 0,0,0], [0, 1,0,0] ], GF(2) );
Elements(C);
v:=Codeword("0011");
C+v;
Elements(C+v);
-->
In general, the operations just described can also be performed on
codewords expressed as vectors, strings or polynomials,
although this is not recommended. The
vector, string or polynomial is first converted to a codeword, after
which the normal operation is performed. For this to go right, make sure
that at least one of the operands is a codeword. Further more, it will
not work when the right operand is a polynomial. In that case, the
polynomial operations (<C>FiniteFieldPolynomialOps</C>) are called, instead of
the codeword operations (<C>CodewordOps</C>).
<P/>
Some other code-oriented operations with codewords are described in
<Ref Subsect="Operations for Codes" Style="Number"/>.
</Section>
<Section>
<Heading>
Functions that Convert Codewords to Vectors or Polynomials
</Heading>
<Label Name="convert Codewords to Vectors or Polynomials"/>
<ManSection Label="VectorCodeword">
<Func Name="VectorCodeword" Arg="obj"/>
<Description>
Here <A>obj</A> can be a code word or a list of code words. This function
returns the corresponding vectors over a finite field.
</Description>
</ManSection>
<Example>
gap> a := Codeword("011011");;
gap> VectorCodeword(a);
[ 0*Z(2), Z(2)^0, Z(2)^0, 0*Z(2), Z(2)^0, Z(2)^0 ]
</Example>
<!--
a := Codeword("011011");;
VectorCodeword(a);
-->
<ManSection Label="PolyCodeword">
<Func Name="PolyCodeword" Arg="obj"/>
<Description>
<C>PolyCodeword</C> returns a polynomial or a list
of polynomials over a Galois field, converted from <A>obj</A>.
The object <A>obj</A> can be a codeword, or a list of codewords.
</Description>
</ManSection>
<Example>
gap> a := Codeword("011011");;
gap> PolyCodeword(a);
x_1+x_1^2+x_1^4+x_1^5
</Example>
<!--
a := Codeword("011011");;
PolyCodeword(a);
-->
</Section>
<Section>
<Heading>
Functions that Change the Display Form of a Codeword
</Heading>
<Label Name="Functions that Change the Display Form of a Codeword"/>
<ManSection Label="TreatAsVector">
<Func Name="TreatAsVector" Arg="obj"/>
<Description>
<C>TreatAsVector</C> adapts the codewords in
<A>obj</A> to make sure they are printed as vectors.
<A>obj</A> may be a codeword or a list of codewords.
Elements of <A>obj</A> that are not codewords are ignored. After
this function is called, the codewords will be treated as vectors. The
vector representation is obtained by using the coefficient list of the
polynomial.
<P/>
Note that this <E>only</E> changes the way a codeword is <E>printed</E>.
<C>TreatAsVector</C> returns nothing, it is called only for its side effect.
The function <C>VectorCodeword</C> converts codewords to vectors (see
<Ref Func="VectorCodeword" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> B := BinaryGolayCode();
a cyclic [23,12,7]3 binary Golay code over GF(2)
gap> c := CodewordNr(B, 4);
x^22 + x^20 + x^17 + x^14 + x^13 + x^12 + x^11 + x^10
gap> TreatAsVector(c);
gap> c;
[ 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 1 0 1 ]
</Example>
<!--
B := BinaryGolayCode();
c := CodewordNr(B, 4);
TreatAsVector(c);
c;
-->
<ManSection Label="TreatAsPoly">
<Func Name="TreatAsPoly" Arg="obj"/>
<Description>
<C>TreatAsPoly</C> adapts the codewords in <A>obj</A>
to make sure they are printed
as polynomials. <A>obj</A> may be a codeword or a list of codewords. Elements
of <A>obj</A> that are not codewords are ignored. After this function is
called, the codewords will be treated as polynomials. The finite field
vector that defines the codeword is used as a coefficient list of the
polynomial representation, where the first element of the vector is the
coefficient of degree zero, the second element is the coefficient of
degree one, etc, until the last element, which is the coefficient of
highest degree.
<P/>
Note that this <E>only</E> changes the way a codeword is
<E>printed</E>. <C>TreatAsPoly</C>
returns nothing, it is called only for its side effect. The function
<C>PolyCodeword</C> converts codewords to polynomials
(see <Ref Func="PolyCodeword" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> a := Codeword("00001",GF(2));
[ 0 0 0 0 1 ]
gap> TreatAsPoly(a); a;
x^4
gap> b := NullWord(6,GF(4));
[ 0 0 0 0 0 0 ]
gap> TreatAsPoly(b); b;
0
</Example>
<!--
a := Codeword("00001",GF(2));
TreatAsPoly(a); a;
b := NullWord(6,GF(4));
TreatAsPoly(b); b;
-->
</Section>
<Section>
<Heading>
Other Codeword Functions
</Heading>
<Label Name="Other Codeword Functions"/>
<ManSection Label="NullWord">
<Func Name="NullWord" Arg="n F"/>
<Description>
Other uses: <C>NullWord( n )</C> (default <M>F=GF(2)</M>)
and <C>NullWord( C )</C>.
<C>NullWord</C> returns a codeword of length <A>n</A> over the
field <A>F</A> of only zeros. The integer
<A>n</A> must be greater then zero. If
only a code <Arg>C</Arg> is specified, <C>NullWord</C>
will return a null word with both the
word length and the Galois field of <Arg>C</Arg>.
</Description>
</ManSection>
<Example>
gap> NullWord(8);
[ 0 0 0 0 0 0 0 0 ]
gap> Codeword("0000") = NullWord(4);
true
gap> NullWord(5,GF(16));
[ 0 0 0 0 0 ]
gap> NullWord(ExtendedTernaryGolayCode());
[ 0 0 0 0 0 0 0 0 0 0 0 0 ]
</Example>
<!--
NullWord(8);
Codeword("0000") = NullWord(4);
NullWord(5,GF(16));
NullWord(ExtendedTernaryGolayCode());
-->
<ManSection Label="DistanceCodeword">
<Func Name="DistanceCodeword" Arg="c1 c2"/>
<Description>
<C>DistanceCodeword</C> returns the Hamming distance from
<A>c1</A> to <A>c2</A>. Both
variables must be codewords with equal word length over the same Galois
field. The Hamming distance between two words is the number of places in
which they differ. As a result, <C>DistanceCodeword</C>
always returns an integer between zero and the word length of the codewords.
</Description>
</ManSection>
<Example>
gap> a := Codeword([0, 1, 2, 0, 1, 2]);; b := NullWord(6, GF(3));;
gap> DistanceCodeword(a, b);
4
gap> DistanceCodeword(b, a);
4
gap> DistanceCodeword(a, a);
0
</Example>
<!--
a := Codeword([0, 1, 2, 0, 1, 2]);; b := NullWord(6, GF(3));;
DistanceCodeword(a, b);
DistanceCodeword(b, a);
DistanceCodeword(a, a);
-->
<ManSection Label="Support">
<Func Name="Support" Arg="c"/>
<Description>
<C>Support</C> returns a set of integers indicating the positions of
the non-zero entries in a codeword <A>c</A>.
</Description>
</ManSection>
<Example>
gap> a := Codeword("012320023002");; Support(a);
[ 2, 3, 4, 5, 8, 9, 12 ]
gap> Support(NullWord(7));
[ ]
</Example>
<!--
a := Codeword("012320023002");; Support(a);
Support(NullWord(7));
-->
The support of a list with codewords can be calculated by taking the
union of the individual supports. The weight of the support is the length
of the set.
<Example>
gap> L := Codeword(["000000", "101010", "222000"], GF(3));;
gap> S := Union(List(L, i -> Support(i)));
[ 1, 2, 3, 5 ]
gap> Length(S);
4
</Example>
<!--
L := Codeword(["000000", "101010", "222000"], GF(3));;
S := Union(List(L, i -> Support(i)));
Length(S);
-->
<ManSection Label="WeightCodeword">
<Func Name="WeightCodeword" Arg="c"/>
<Description>
<C>WeightCodeword</C> returns the weight of a codeword
<M>c</M>, the number of non-zero entries in <A>c</A>.
As a result, <C>WeightCodeword</C> always returns an
integer between zero and the word length of the codeword.
</Description>
</ManSection>
<Example>
gap> WeightCodeword(Codeword("22222"));
5
gap> WeightCodeword(NullWord(3));
0
gap> C := HammingCode(3);
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> Minimum(List(AsSSortedList(C){[2..Size(C)]}, WeightCodeword ) );
3
</Example>
<!--
WeightCodeword(Codeword("22222"));
WeightCodeword(NullWord(3));
C := HammingCode(3);
Minimum(List(AsSSortedList(C){[2..Size(C)]}, WeightCodeword ) );
-->
</Section>
</Chapter>
<Chapter>
<Heading>Codes</Heading>
<Label Name="Codes"/>
A <E>code</E> is a set of codewords (recall a
<Index>code</Index>
<Index>code, elements of</Index>
codeword in <Package>GUAVA</Package> is simply
a sequence of elements of a finite field
<M>GF(q)</M>, where <M>q</M> is a prime power).
We call these the <E>elements</E> of the code.
Depending on the type of code, a codeword can be interpreted as
a vector or as a polynomial.
This is explained in more detail in Chapter
<Ref Label="Codewords" Style="Number"/>.
<P/>
In <Package>GUAVA</Package>,
codes can be a set specified by its elements (this will be called
an <E>unrestricted code</E>),
<Index>code, unrestricted</Index>
by a generator matrix listing a set of basis elements
(for a linear code) or by a
generator polynomial (for a cyclic code).
<P/>
Any code can be defined by its elements. If you like, you can give the
code a name.
<Example>
gap> C := ElementsCode(["1100", "1010", "0001"], "example code", GF(2) );
a (4,3,1..4)2..4 example code over GF(2)
</Example>
An <M>(n,M,d)</M> code is a code with word <E>length</E>
<M>n</M>, <E>size</E> <M>M</M> and
<E>minimum distance</E> <M>d</M>.
<Index>
code, <M>(n,M,d)</M>
</Index>
<Index>
minimum distance
</Index>
<Index>
length
</Index>
<Index>
size
</Index>
If the minimum distance has not yet been
calculated, the lower bound and upper bound are printed
(except in the case where the code is a random linear codes,
where these are not printed for efficiency reasons). So
<Verb>
a (4,3,1..4)2..4 code over GF(2)
</Verb>
means a binary unrestricted code of length <M>4</M>, with <M>3</M>
elements and the minimum distance is greater than or equal to
<M>1</M> and less than or equal to <M>4</M>
and the covering radius is greater than or equal to <M>2</M> and less
than or equal to <M>4</M>.
<Example>
gap> C := ElementsCode(["1100", "1010", "0001"], "example code", GF(2) );
a (4,3,1..4)2..4 example code over GF(2)
gap> MinimumDistance(C);
2
gap> C;
a (4,3,2)2..4 example code over GF(2)
</Example>
<!--
C := ElementsCode(["1100", "1010", "0001"], "example code", GF(2) );
MinimumDistance(C);
C;
-->
If the set of elements is a linear subspace of <M>GF(q)^n</M>,
the code is called <E>linear</E>. If a code is linear, it can be
defined by its <E>generator matrix</E> or <E>parity check matrix</E>.
<Index>code, linear</Index>
<Index>parity check matrix</Index>
By definition,
the rows of the generator matrix is a basis for
the code (as a vector space over <M>GF(q)</M>).
By definition,
the rows of the parity check matrix is a basis for the
dual space of the code,
<Display>
C^* = \{ v \in GF(q)^n\ |\ v\cdot c = 0,\ for \ all\ c \in C \}.
</Display>
<Example>
gap> G := GeneratorMatCode([[1,0,1],[0,1,2]], "demo code", GF(3) );
a linear [3,2,1..2]1 demo code over GF(3)
</Example>
So a linear <M>[n, k, d]r</M> code
<Index>
code, <M>[n, k, d]r</M>
</Index>
is a code with word <E>length</E> <M>n</M>,
<E>dimension</E> <M>k</M>, <E>minimum distance</E>
<M>d</M> and <E>covering radius</E> <M>r</M>.
<P/>
If the code is linear and all cyclic shifts of its codewords
(regarded as <M>n</M>-tuples) are again
codewords, the code is called <E>cyclic</E>.
<Index>code, cyclic</Index>
All elements of a cyclic code are multiples
of the monic polynomial modulo a polynomial <M>x^n -1</M>,
where <M>n</M> is the word length of the code.
Such a polynomial is called a <E>generator polynomial</E>
<Index>generator polynomial</Index>
The generator polynomial must divide <M>x^n-1</M> and its
quotient is called a <E>check polynomial</E>.
<Index>check polynomial</Index>
Multiplying a codeword in a cyclic code by the check
polynomial yields zero (modulo the polynomial <M>x^n -1</M>).
In <Package>GUAVA</Package>, a
cyclic code can be defined by either its generator polynomial or
check polynomial.
<Example>
gap> G := GeneratorPolCode(Indeterminate(GF(2))+Z(2)^0, 7, GF(2) );
a cyclic [7,6,1..2]1 code defined by generator polynomial over GF(2)
</Example>
It is possible that <Package>GUAVA</Package>
does not know that an unrestricted code is in fact
linear. This situation occurs for example when a code is generated from a
list of elements with the function <C>ElementsCode</C>
(see <Ref Func="ElementsCode" Style="Number"/>).
By calling the function <C>IsLinearCode</C> (see
<Ref Func="IsLinearCode" Style="Number"/>), <Package>GUAVA</Package>
tests if the code can be represented by a generator matrix.
If so, the code record and the operations are converted accordingly.
<Example>
gap> L := Z(2)*[ [0,0,0], [1,0,0], [0,1,1], [1,1,1] ];;
gap> C := ElementsCode( L, GF(2) );
a (3,4,1..3)1 user defined unrestricted code over GF(2)
# so far, GUAVA does not know what kind of code this is
gap> IsLinearCode( C );
true # it is linear
gap> C;
a linear [3,2,1]1 user defined unrestricted code over GF(2)
</Example>
<!--
L := Z(2)*[ [0,0,0], [1,0,0], [0,1,1], [1,1,1] ];;
C := ElementsCode( L, GF(2) );
IsLinearCode( C );
C;
-->
Of course the same holds for unrestricted codes that in fact are cyclic,
or codes, defined by a generator matrix, that actually are cyclic.
<P/>
Codes are printed simply by giving a small description of their
parameters, the word length, size or dimension and perhaps
the minimum distance,
followed by a short description and the base field of the code. The
function <C>Display</C> gives a more detailed description, showing the
construction history of the code.
<P/>
<Package>GUAVA</Package> doesn't place much emphasis on the
actual encoding and decoding
processes; some algorithms have been included though. Encoding works
simply by multiplying an information vector with a code, decoding is done
by the functions <C>Decode</C> or <C>Decodeword</C>.
For more information about encoding and
decoding, see sections
<Ref Label="Operations for Codes" Style="Number"/> and
<Ref Label="Decode" Style="Number"/>.
<Example>
gap> R := ReedMullerCode( 1, 3 );
a linear [8,4,4]2 Reed-Muller (1,3) code over GF(2)
gap> w := [ 1, 0, 1, 1 ] * R;
[ 1 0 0 1 1 0 0 1 ]
gap> Decode( R, w );
[ 1 0 1 1 ]
gap> Decode( R, w + "10000000" ); # One error at the first position
[ 1 0 1 1 ] # Corrected by Guava
</Example>
<!--
R := ReedMullerCode( 1, 3 );
w := [ 1, 0, 1, 1 ] * R;
Decode( R, w );
Decode( R, w + "10000000" );
-->
Sections <Ref Label="Comparisons of Codes" Style="Number"/> and
<Ref Label="Operations for Codes" Style="Number"/> describe the
operations that are available for codes.
Section <Ref Label="Boolean Functions for Codes" Style="Number"/> describe
the functions that tests
whether an object is a code and what kind of code it is (see <C>IsCode</C>,
<Ref Func="IsLinearCode" Style="Number"/> and <C>IsCyclicCode</C>)
and various other boolean functions for codes.
Section <Ref Label="Equivalence and Isomorphism of Codes" Style="Number"/>
describe functions about equivalence and isomorphism of
codes (see <Ref Func="IsEquivalent" Style="Number"/>,
<Ref Func="CodeIsomorphism" Style="Number"/> and
<Ref Func="AutomorphismGroup" Style="Number"/>).
Section <Ref Label="Domain Functions for Codes" Style="Number"/>
describes functions that work on
<E>domains</E> (see Chapter "Domains and their Elements" in the GAP
Reference Manual).
Section <Ref Label="Printing and Displaying Codes" Style="Number"/>
describes functions for printing and displaying codes.
Section
<Ref Label="Generating (Check) Matrices and Polynomials" Style="Number"/>
describes functions that return the matrices and polynomials
that define a code (see
<Ref Func="GeneratorMat" Style="Number"/>,
<Ref Func="CheckMat" Style="Number"/>,
<Ref Func="GeneratorPol" Style="Number"/>,
<Ref Func="CheckPol" Style="Number"/>,
<Ref Func="RootsOfCode" Style="Number"/>).
Section <Ref Label="Parameters of Codes" Style="Number"/>
describes functions that return the basic
parameters of codes (see <Ref Func="WordLength" Style="Number"/>,
<Ref Func="Redundancy" Style="Number"/> and
<Ref Func="MinimumDistance" Style="Number"/>).
Section <Ref Label="Distributions" Style="Number"/>
describes functions that return distance and
weight distributions (see
<Ref Func="WeightDistribution" Style="Number"/>,
<Ref Func="InnerDistribution" Style="Number"/>,
<Ref Func="OuterDistribution" Style="Number"/> and
<Ref Func="DistancesDistribution" Style="Number"/>).
Section <Ref Label="Decoding Functions" Style="Number"/>
describes functions that are related to
decoding (see <Ref Func="Decode" Style="Number"/>,
<Ref Func="Decodeword" Style="Number"/>,
<Ref Func="Syndrome" Style="Number"/>,
<Ref Func="SyndromeTable" Style="Number"/> and
<Ref Func="StandardArray" Style="Number"/>).
In Chapters <Ref Label="Generating Codes" Style="Number"/> and
<Ref Label="Manipulating Codes" Style="Number"/> which follow,
we describe functions that generate and manipulate codes.
<Section>
<Heading>Comparisons of Codes</Heading>
<Label Name="Comparisons of Codes"/>
<ManSection Label="= codes">
<Func Name="=" Arg=" C1 C2"/>
<Description>
The equality operator <C>C1 = C2</C>
evaluates to `true' if the codes <A>C1</A>
and <A>C2</A> are equal, and to `false' otherwise.
<P/>
The equality operator is also denoted <C>EQ</C>, and
<C>Eq(C1,C2)</C> is the same as <C>C1 = C2</C>.
There is also an inequality operator, &tlt; &tgt;,
or <C>not EQ</C>.
<P/>
Note that codes are equal if and only if their set of elements are equal. Codes
can also be compared with objects of other types. Of course they are
never equal.
</Description>
</ManSection>
<Index>not =</Index>
<Index>&tlt; &tgt;</Index>
<Example>
gap> M := [ [0, 0], [1, 0], [0, 1], [1, 1] ];;
gap> C1 := ElementsCode( M, GF(2) );
a (2,4,1..2)0 user defined unrestricted code over GF(2)
gap> M = C1;
false
gap> C2 := GeneratorMatCode( [ [1, 0], [0, 1] ], GF(2) );
a linear [2,2,1]0 code defined by generator matrix over GF(2)
gap> C1 = C2;
true
gap> ReedMullerCode( 1, 3 ) = HadamardCode( 8 );
true
gap> WholeSpaceCode( 5, GF(4) ) = WholeSpaceCode( 5, GF(2) );
false
</Example>
<!--
M := [ [0, 0], [1, 0], [0, 1], [1, 1] ];;
C1 := ElementsCode( M, GF(2) );
M = C1;
C2 := GeneratorMatCode( [ [1, 0], [0, 1] ], GF(2) );
C1 = C2;
ReedMullerCode( 1, 3 ) = HadamardCode( 8 );
WholeSpaceCode( 5, GF(4) ) = WholeSpaceCode( 5, GF(2) );
-->
Another way of comparing codes is <C>IsEquivalent</C>, which checks if two
codes are equivalent (see <Ref Func="IsEquivalent" Style="Number"/>).
By the way, this called <C>CodeIsomorphism</C>.
For the current version of <Package>GUAVA</Package>,
unless one of the codes is unrestricted,
this calls Leon's C program (which only works for binary linear codes
and only on a unix/linux computer).
</Section>
<Section>
<Heading>
Operations for Codes
</Heading>
<Label Name="Operations for Codes"/>
<ManSection Label="+ codes">
<Func Name="+" Arg=" C1 C2"/>
<Description>
<Index>
codes, addition
</Index>
<Index>
codes, direct sum
</Index>
The operator `+' evaluates to the direct sum of the codes <A>C1</A> and
<A>C2</A>. See <Ref Func="DirectSumCode" Style="Number"/>.
<P/>
</Description>
</ManSection>
<Example>
gap> C1:=RandomLinearCode(10,5);
a [10,5,?] randomly generated code over GF(2)
gap> C2:=RandomLinearCode(9,4);
a [9,4,?] randomly generated code over GF(2)
gap> C1+C2;
a linear [10,9,1]0..10 unknown linear code over GF(2)
</Example>
<ManSection Label="* codes">
<Func Name="*" Arg=" C1 C2"/>
<Description>
<Index>
codes, product
</Index>
The operator `*' evaluates to the direct product of the codes
<A>C1</A> and <A>C2</A>.
See <Ref Func="DirectProductCode" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> C1 := GeneratorMatCode( [ [1, 0,0,0], [0, 1,0,0] ], GF(2) );
a linear [4,2,1]1 code defined by generator matrix over GF(2)
gap> C2 := GeneratorMatCode( [ [0,0,1, 1], [0,0,0, 1] ], GF(2) );
a linear [4,2,1]1 code defined by generator matrix over GF(2)
gap> C1*C2;
a linear [16,4,1]4..12 direct product code
</Example>
<!--
C1 := GeneratorMatCode( [ [1, 0,0,0], [0, 1,0,0] ], GF(2) );
C2 := GeneratorMatCode( [ [0,0,1, 1], [0,0,0, 1] ], GF(2) );
C1*C2;
-->
<ManSection Label="*">
<Func Name="*" Arg=" m C"/>
<Description>
<Index>codes, encoding </Index>
<Index>encoder map </Index>
The operator <C>m*C</C> evaluates to the element of
<A>C</A> belonging to information word ('message') <A>m</A>.
Here <A>m</A> may be a vector, polynomial, string or
codeword or a list of those.
This is the way to do encoding in
<Package>GUAVA</Package>. <A>C</A> must be linear,
because in <Package>GUAVA</Package>,
encoding by multiplication is only defined for
linear codes. If <A>C</A> is a cyclic code, this multiplication is the same as
multiplying an information polynomial <A>m</A> by the generator
polynomial of <A>C</A>.
If <A>C</A> is a linear code, it is equal to the multiplication
of an information vector <A>m</A> by
a generator matrix of <A>C</A>.
<P/>
To invert this, use the function <C>InformationWord</C> (see
<Ref Func="InformationWord" Style="Number"/>,
which simply calls the function <C>Decode</C>).
</Description>
</ManSection>
<Example>
gap> C := GeneratorMatCode( [ [1, 0,0,0], [0, 1,0,0] ], GF(2) );
a linear [4,2,1]1 code defined by generator matrix over GF(2)
gap> m:=Codeword("11");
[ 1 1 ]
gap> m*C;
[ 1 1 0 0 ]
</Example>
<!--
C := GeneratorMatCode( [ [1, 0,0,0], [0, 1,0,0] ], GF(2) );
m:=Codeword("11");
m*C;
-->
<ManSection Label="InformationWord">
<Func Name="InformationWord" Arg=" C c"/>
<Description>
<Index>codes, decoding </Index>
<Index>information bits </Index>
Here <A>C</A> is a linear code and <A>c</A> is
a codeword in it. The command <C>InformationWord</C>
returns the message word (or 'information digits') <M>m</M>
satisfying <C>c=m*C</C>. This command simply calls <C>Decode</C>,
provided <C>c in C</C> is true. Otherwise, it returns an error.
<P/>
To invert this, use the encoding function <C>*</C> (see
<Ref Func="*" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C:=HammingCode(3);
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> c:=Random(C);
[ 0 0 0 1 1 1 1 ]
gap> InformationWord(C,c);
[ 0 1 1 1 ]
gap> c:=Codeword("1111100");
[ 1 1 1 1 1 0 0 ]
gap> InformationWord(C,c);
"ERROR: codeword must belong to code"
gap> C:=NordstromRobinsonCode();
a (16,256,6)4 Nordstrom-Robinson code over GF(2)
gap> c:=Random(C);
[ 0 0 0 1 0 0 0 1 0 0 1 0 1 1 0 1 ]
gap> InformationWord(C,c);
"ERROR: code must be linear"
</Example>
<!--
C:=HammingCode(3);
c:=Random(C);
InformationWord(C,c);
c:=Codeword("1111100");
InformationWord(C,c);
C:=NordstromRobinsonCode();
c:=Random(C);
InformationWord(C,c);
-->
</Section>
<Section>
<Heading>
Boolean Functions for Codes
</Heading>
<Label Name="Boolean Functions for Codes"/>
<ManSection Label="in">
<Func Name="in" Arg=" c C"/>
<Description>
<Index>code, element test</Index>
The command
<C>c in C</C> evaluates to `true' if <A>C</A> contains the codeword or
list of codewords specified by <A>c</A>.
Of course, <A>c</A> and <A>C</A> must have the
same word lengths and base fields.
</Description>
</ManSection>
<Example>
gap> C:= HammingCode( 2 );; eC:= AsSSortedList( C );
[ [ 0 0 0 ], [ 1 1 1 ] ]
gap> eC[2] in C;
true
gap> [ 0 ] in C;
false
</Example>
<!--
C:= HammingCode( 2 );; eC:= AsSSortedList( C );
eC[2] in C;
[ 0 ] in C;
-->
<ManSection Label="IsSubset">
<Func Name="IsSubset" Arg=" C1 C2"/>
<Description>
<Index>code, subcode</Index>
The command <C>IsSubset(C1,C2)</C> returns `true' if <A>C2</A>
is a subcode of <A>C1</A>,
i.e. if <A>C1</A> contains all the elements of <A>C2</A>.
</Description>
</ManSection>
<Example>
gap> IsSubset( HammingCode(3), RepetitionCode( 7 ) );
true
gap> IsSubset( RepetitionCode( 7 ), HammingCode( 3 ) );
false
gap> IsSubset( WholeSpaceCode( 7 ), HammingCode( 3 ) );
true
</Example>
<!--
IsSubset( HammingCode(3), RepetitionCode( 7 ) );
IsSubset( RepetitionCode( 7 ), HammingCode( 3 ) );
IsSubset( WholeSpaceCode( 7 ), HammingCode( 3 ) );
-->
<ManSection Label="IsCode">
<Func Name="IsCode" Arg=" obj "/>
<Description>
<C>IsCode</C> returns `true' if <A>obj</A>, which
can be an object of arbitrary type, is a code and
`false' otherwise. Will cause an error if <A>obj</A> is an
unbound variable.
</Description>
</ManSection>
<Example>
gap> IsCode( 1 );
false
gap> IsCode( ReedMullerCode( 2,3 ) );
true
</Example>
<!--
IsCode( 1 );
IsCode( ReedMullerCode( 2,3 ) );
-->
<ManSection Label="IsLinearCode">
<Func Name="IsLinearCode" Arg=" obj "/>
<Description>
<C>IsLinearCode</C> checks if object <A>obj</A>
(not necessarily a code) is a linear code.
If a code has already been marked as linear or cyclic, the
function automatically returns `true'. Otherwise, the function checks if
a basis <M>G</M> of the elements of <A>obj</A> exists that
generates the elements
of <A>obj</A>. If so, <M>G</M> is recorded as
a generator matrix of <A>obj</A> and the function
returns `true'. If not, the function returns `false'.
</Description>
</ManSection>
<Example>
gap> C := ElementsCode( [ [0,0,0],[1,1,1] ], GF(2) );
a (3,2,1..3)1 user defined unrestricted code over GF(2)
gap> IsLinearCode( C );
true
gap> IsLinearCode( ElementsCode( [ [1,1,1] ], GF(2) ) );
false
gap> IsLinearCode( 1 );
false
</Example>
<!--
C := ElementsCode( [ [0,0,0],[1,1,1] ], GF(2) );
IsLinearCode( C );
IsLinearCode( ElementsCode( [ [1,1,1] ], GF(2) ) );
IsLinearCode( 1 );
-->
<ManSection Label="IsCyclicCode">
<Func Name="IsCyclicCode" Arg=" obj "/>
<Description>
<C>IsCyclicCode</C> checks if the object <A>obj</A> is a cyclic code.
If a code has
already been marked as cyclic, the function automatically returns `true'.
Otherwise, the function checks if a polynomial <M>g</M> exists that generates
the elements of <A>obj</A>. If so, <M>g</M> is recorded as
a generator polynomial of
<A>obj</A> and the function returns `true'. If not, the function
returns `false'.
</Description>
</ManSection>
<Example>
gap> C := ElementsCode( [ [0,0,0], [1,1,1] ], GF(2) );
a (3,2,1..3)1 user defined unrestricted code over GF(2)
gap> # GUAVA does not know the code is cyclic
gap> IsCyclicCode( C ); # this command tells GUAVA to find out
true
gap> IsCyclicCode( HammingCode( 4, GF(2) ) );
false
gap> IsCyclicCode( 1 );
false
</Example>
<!--
C := ElementsCode( [ [0,0,0], [1,1,1] ], GF(2) );
IsCyclicCode( C );
IsCyclicCode( HammingCode( 4, GF(2) ) );
IsCyclicCode( 1 );
-->
<ManSection Label="IsPerfectCode">
<Func Name="IsPerfectCode" Arg=" C "/>
<Description>
<C>IsPerfectCode(C)</C> returns `true' if
<A>C</A> is a perfect code. If <M>C\subset GF(q)^n</M>
then, by definition, this means that for some
positive integer <M>t</M>, the space <M>GF(q)^n</M>
is covered by non-overlapping spheres of
(Hamming) radius <M>t</M> centered at the codewords in <A>C</A>.
For a code with odd minimum distance <M>d = 2t+1</M>,
this is the case when every word of the
vector space of <A>C</A> is at distance at most <M>t</M> from exactly
one element
of <A>C</A>. Codes with even minimum distance are never perfect.
<P/>
In fact, a code that is not "trivially perfect" (the binary repetition
codes of odd length, the codes consisting of one word, and the codes
consisting of the whole vector space), and does not have the parameters
of a Hamming or Golay code, cannot be perfect
(see section 1.12 in <Cite Key="HP03"/>).
</Description>
</ManSection>
<Index>code, perfect</Index>
<Example>
gap> H := HammingCode(2);
a linear [3,1,3]1 Hamming (2,2) code over GF(2)
gap> IsPerfectCode( H );
true
gap> IsPerfectCode( ElementsCode([[1,1,0],[0,0,1]],GF(2)) );
true
gap> IsPerfectCode( ReedSolomonCode( 6, 3 ) );
false
gap> IsPerfectCode( BinaryGolayCode() );
true
</Example>
<!--
H := HammingCode(2);
IsPerfectCode( H );
IsPerfectCode( ElementsCode([[1,1,0],[0,0,1]],GF(2)) );
IsPerfectCode( ReedSolomonCode( 6, 3 ) );
IsPerfectCode( BinaryGolayCode() );
-->
<ManSection Label="IsMDSCode">
<Func Name="IsMDSCode" Arg=" C "/>
<Description>
<C>IsMDSCode(C)</C> returns true if <A>C</A> is a
maximum distance separable (MDS) code.
A linear <M>[n, k, d]</M>-code of length
<M>n</M>, dimension <M>k</M> and minimum distance <M>d</M>
is an MDS code if <M>k=n-d+1</M>, in other words
if <A>C</A> meets the Singleton bound
(see <Ref Func="UpperBoundSingleton" Style="Number"/>). An unrestricted
<M>(n, M, d)</M> code is called <E>MDS</E>
if <M>k=n-d+1</M>, with <M>k</M> equal
to the largest integer less than or equal
to the logarithm of <M>M</M> with base
<M>q</M>, the size of the base field of <A>C</A>.
<P/>
Well-known MDS codes include the repetition codes, the whole space codes,
the even weight codes (these are the only <E>binary</E> MDS codes) and the
Reed-Solomon codes.
</Description>
</ManSection>
<Index>code, maximum distance separable</Index>
<Index>MDS</Index>
<Example>
gap> C1 := ReedSolomonCode( 6, 3 );
a cyclic [6,4,3]2 Reed-Solomon code over GF(7)
gap> IsMDSCode( C1 );
true # 6-3+1 = 4
gap> IsMDSCode( QRCode( 23, GF(2) ) );
false
</Example>
<!--
C1 := ReedSolomonCode( 6, 3 );
IsMDSCode( C1 );
IsMDSCode( QRCode( 23, GF(2) ) );
-->
<ManSection Label="IsSelfDualCode">
<Func Name="IsSelfDualCode" Arg=" C "/>
<Description>
<C>IsSelfDualCode(C)</C> returns `true' if <A>C</A> is self-dual,
i.e. when <A>C</A> is equal to its dual code
(see also <Ref Func="DualCode" Style="Number"/>).
A code is self-dual if it contains
all vectors that its elements are orthogonal to.
If a code is self-dual, it automatically
is self-orthogonal (see
<Ref Func="IsSelfOrthogonalCode" Style="Number"/>).
<P/>
If <A>C</A> is a non-linear code, it cannot be self-dual
(the dual code is always linear), so `false' is
returned. A linear code can only be self-dual when its
dimension <M>k</M> is equal to the redundancy <M>r</M>.
</Description>
</ManSection>
<Index>code, self-dual</Index>
<Example>
gap> IsSelfDualCode( ExtendedBinaryGolayCode() );
true
gap> C := ReedMullerCode( 1, 3 );
a linear [8,4,4]2 Reed-Muller (1,3) code over GF(2)
gap> DualCode( C ) = C;
true
</Example>
<Index>
self-orthogonal
</Index>
<ManSection Label="IsSelfOrthogonalCode">
<Func Name="IsSelfOrthogonalCode" Arg=" C "/>
<Description>
<C>IsSelfOrthogonalCode(C)</C> returns `true' if <A>C</A>
is self-orthogonal. A code is <E>self-orthogonal</E>
if every element of <A>C</A> is orthogonal to all
elements of <A>C</A>, including itself. (In the linear case, this simply means
that the generator matrix of <A>C</A> multiplied with its transpose yields a
null matrix.)
</Description>
</ManSection>
<Index>code, self-orthogonal</Index>
<Example>
gap> R := ReedMullerCode(1,4);
a linear [16,5,8]6 Reed-Muller (1,4) code over GF(2)
gap> IsSelfOrthogonalCode(R);
true
gap> IsSelfDualCode(R);
false
</Example>
<!--
R := ReedMullerCode(1,4);
IsSelfOrthogonalCode(R);
IsSelfDualCode(R);
-->
<Index>
doubly-even
</Index>
<ManSection Label="IsDoublyEvenCode">
<Func Name="IsDoublyEvenCode" Arg=" C "/>
<Description>
<C>IsDoublyEvenCode(C)</C> returns `true' if <A>C</A> is
a binary linear code which has codewords of weight divisible
by 4 only. According to <Cite Key="HP03"/>, a doubly-even code
is self-orthogonal and every row in its generator matrix has
weight that is divisible by 4.
</Description>
</ManSection>
<Index>code, doubly-even</Index>
<Example>
gap> C:=BinaryGolayCode();
a cyclic [23,12,7]3 binary Golay code over GF(2)
gap> WeightDistribution(C);
[ 1, 0, 0, 0, 0, 0, 0, 253, 506, 0, 0, 1288, 1288, 0, 0, 506, 253, 0, 0, 0, 0, 0, 0, 1 ]
gap> IsDoublyEvenCode(C);
false
gap> C:=ExtendedCode(C);
a linear [24,12,8]4 extended code
gap> WeightDistribution(C);
[ 1, 0, 0, 0, 0, 0, 0, 0, 759, 0, 0, 0, 2576, 0, 0, 0, 759, 0, 0, 0, 0, 0, 0, 0, 1 ]
gap> IsDoublyEvenCode(C);
true
</Example>
<!--
C:=BinaryGolayCode();
WeightDistribution(C);
IsDoublyEvenCode(C);
C:=ExtendedCode(C);
WeightDistribution(C);
IsDoublyEvenCode(C);
-->
<Index>
singly-even
</Index>
<ManSection Label="IsSinglyEvenCode">
<Func Name="IsSinglyEvenCode" Arg=" C "/>
<Description>
<C>IsSinglyEvenCode(C)</C> returns `true' if <A>C</A> is
a binary self-orthogonal linear code which is not doubly-even.
In other words, <A>C</A> is a binary self-orthogonal code which
has codewords of even weight.
</Description>
</ManSection>
<Index>code, singly-even</Index>
<Example>
gap> x:=Indeterminate(GF(2));
x_1
gap> C:=QuasiCyclicCode( [x^0, 1+x^3+x^5+x^6+x^7], 11, GF(2) );
a linear [22,11,1..6]4..7 quasi-cyclic code over GF(2)
gap> IsSelfDualCode(C); # self-dual is a restriction of self-orthogonal
true
gap> IsDoublyEvenCode(C);
false
gap> IsSinglyEvenCode(C);
true
</Example>
<!--
x:=Indeterminate(GF(2));
C:=QuasiCyclicCode( [x^0, 1+x^3+x^5+x^6+x^7], 11, GF(2) );
IsSelfDualCode(C); # self-dual is a restriction of self-orthogonal
IsDoublyEvenCode(C);
IsSinglyEvenCode(C);
-->
<Index>
even
</Index>
<ManSection Label="IsEvenCode">
<Func Name="IsEvenCode" Arg=" C "/>
<Description>
<C>IsEvenCode(C)</C> returns `true' if <A>C</A> is a binary
linear code which has codewords of even weight--regardless
whether or not it is self-orthogonal.
</Description>
</ManSection>
<Index>code, even</Index>
<Example>
gap> C:=BinaryGolayCode();
a cyclic [23,12,7]3 binary Golay code over GF(2)
gap> IsSelfOrthogonalCode(C);
false
gap> IsEvenCode(C);
false
gap> C:=ExtendedCode(C);
a linear [24,12,8]4 extended code
gap> IsSelfOrthogonalCode(C);
true
gap> IsEvenCode(C);
true
gap> C:=ExtendedCode(QRCode(17,GF(2)));
a linear [18,9,6]3..5 extended code
gap> IsSelfOrthogonalCode(C);
false
gap> IsEvenCode(C);
true
</Example>
<!--
C:=BinaryGolayCode();
IsSelfOrthogonalCode(C);
IsEvenCode(C);
C:=ExtendedCode(C);
IsSelfOrthogonalCode(C);
IsEvenCode(C);
C:=ExtendedCode(QRCode(17,GF(2)));
IsSelfOrthogonalCode(C);
IsEvenCode(C);
-->
<Index>
self complementary code
</Index>
<ManSection Label="IsSelfComplementaryCode">
<Func Name="IsSelfComplementaryCode" Arg=" C "/>
<Description>
<C>IsSelfComplementaryCode</C> returns `true' if
<Display>
v \in C \Rightarrow 1 - v \in C,
</Display>
where <M>1</M> is the all-one word of length <M>n</M>.
</Description>
</ManSection>
<Example>
gap> IsSelfComplementaryCode( HammingCode( 3, GF(2) ) );
true
gap> IsSelfComplementaryCode( EvenWeightSubcode(
> HammingCode( 3, GF(2) ) ) );
false
</Example>
<Index>
affine code
</Index>
<ManSection Label="IsAffineCode">
<Func Name="IsAffineCode" Arg=" C "/>
<Description>
<C>IsAffineCode</C> returns `true' if <A>C</A> is an affine code.
A code is called <E>affine</E> if it is an affine space.
In other words, a code is affine if it is a coset of a linear code.
</Description>
</ManSection>
<Example>
gap> IsAffineCode( HammingCode( 3, GF(2) ) );
true
gap> IsAffineCode( CosetCode( HammingCode( 3, GF(2) ),
> [ 1, 0, 0, 0, 0, 0, 0 ] ) );
true
gap> IsAffineCode( NordstromRobinsonCode() );
false
</Example>
<ManSection Label="IsAlmostAffineCode">
<Func Name="IsAlmostAffineCode" Arg=" C "/>
<Description>
<C>IsAlmostAffineCode</C> returns `true' if <A>C</A>
is an almost affine code. A code is called <E>almost affine</E>
if the size of any punctured code of <A>C</A> is <M>q^r</M>
for some <M>r</M>, where <M>q</M> is the size of the alphabet
of the code.
Every affine code is also almost affine, and every code over
<M>GF(2)</M> and <M>GF(3)</M> that is almost affine is also affine.
</Description>
</ManSection>
<Example>
gap> code := ElementsCode( [ [0,0,0], [0,1,1], [0,2,2], [0,3,3],
> [1,0,1], [1,1,0], [1,2,3], [1,3,2],
> [2,0,2], [2,1,3], [2,2,0], [2,3,1],
> [3,0,3], [3,1,2], [3,2,1], [3,3,0] ],
> GF(4) );;
gap> IsAlmostAffineCode( code );
true
gap> IsAlmostAffineCode( NordstromRobinsonCode() );
false
</Example>
<!--
code := ElementsCode( [ [0,0,0], [0,1,1], [0,2,2], [0,3,3], [1,0,1], [1,1,0], [1,2,3], [1,3,2], [2,0,2], [2,1,3], [2,2,0], [2,3,1], [3,0,3], [3,1,2], [3,2,1], [3,3,0] ], GF(4) );;
IsAlmostAffineCode( code );
IsAlmostAffineCode( NordstromRobinsonCode() );
-->
</Section>
<Section>
<Heading>
Equivalence and Isomorphism of Codes
</Heading>
<Label Name="Equivalence and Isomorphism of Codes"/>
<Index>
permutation equivalent codes
</Index>
<Index>
equivalent codes
</Index>
<ManSection Label="IsEquivalent">
<Func Name="IsEquivalent" Arg=" C1 C2 "/>
<Description>
We say that
<A>C1</A> is <E>permutation equivalent</E> to
<A>C2</A> if <A>C1</A> can be obtained from <A>C2</A> by
carrying out column permutations.
<C>IsEquivalent</C> returns true if <A>C1</A> and
<A>C2</A> are equivalent codes.
At this time,
<C>IsEquivalent</C> only handles <E>binary</E> codes.
(The external unix/linux program <B>desauto</B> from J. S. Leon
is called by <C>IsEquivalent</C>.)
Of course, if <A>C1</A> and <A>C2</A> are equal, they
are also equivalent.
<P/>
Note that the algorithm is <E>very slow</E> for non-linear codes.
<P/>
More generally, we say that
<A>C1</A> is <E>equivalent</E> to
<A>C2</A> if <A>C1</A> can be obtained from <A>C2</A> by
carrying out column permutations and a permutation of the
alphabet.
</Description>
</ManSection>
<Example>
gap> x:= Indeterminate( GF(2) );; pol:= x^3+x+1;
Z(2)^0+x_1+x_1^3
gap> H := GeneratorPolCode( pol, 7, GF(2));
a cyclic [7,4,1..3]1 code defined by generator polynomial over GF(2)
gap> H = HammingCode(3, GF(2));
false
gap> IsEquivalent(H, HammingCode(3, GF(2)));
true # H is equivalent to a Hamming code
gap> CodeIsomorphism(H, HammingCode(3, GF(2)));
(3,4)(5,6,7)
</Example>
<!--
x:= Indeterminate( GF(2) );; pol:= x^3+x+1;
H := GeneratorPolCode( pol, 7, GF(2));
H = HammingCode(3, GF(2));
IsEquivalent(H, HammingCode(3, GF(2)));
CodeIsomorphism(H, HammingCode(3, GF(2)));
-->
<ManSection Label="CodeIsomorphism">
<Func Name="CodeIsomorphism" Arg=" C1 C2 "/>
<Description>
If the two codes <A>C1</A> and <A>C2</A> are permutation equivalent codes (see
<Ref Func="IsEquivalent" Style="Number"/>),
<C>CodeIsomorphism</C> returns the permutation that
transforms <A>C1</A> into <A>C2</A>. If the codes are not equivalent,
it returns `false'.
<P/>
At this time,
<C>IsEquivalent</C> only computes isomorphisms
between <E>binary</E> codes on a linux/unix computer
(since it calls Leon's C program <B>desauto</B>).
</Description>
</ManSection>
<Example>
gap> x:= Indeterminate( GF(2) );; pol:= x^3+x+1;
Z(2)^0+x_1+x_1^3
gap> H := GeneratorPolCode( pol, 7, GF(2));
a cyclic [7,4,1..3]1 code defined by generator polynomial over GF(2)
gap> CodeIsomorphism(H, HammingCode(3, GF(2)));
(3,4)(5,6,7)
gap> PermutedCode(H, (3,4)(5,6,7)) = HammingCode(3, GF(2));
true
</Example>
<!--
x:= Indeterminate( GF(2) );; pol:= x^3+x+1;
H := GeneratorPolCode( pol, 7, GF(2));
CodeIsomorphism(H, HammingCode(3, GF(2)));
PermutedCode(H, (3,4)(5,6,7)) = HammingCode(3, GF(2));
-->
<ManSection Label="AutomorphismGroup">
<Func Name="AutomorphismGroup" Arg=" C "/>
<Description>
<C>AutomorphismGroup</C> returns the automorphism group of a
linear code <A>C</A>. For a binary code,
the automorphism group is the largest permutation group
of degree <M>n</M> such that each permutation applied to
the columns of <A>C</A> again yields <A>C</A>.
<Package>GUAVA</Package> calls the external program
<B>desauto</B> written by J. S. Leon, if it exists, to compute the
automorphism group. If Leon's program is not compiled on the
system (and in the default directory) then it calls instead the
much slower program <C>PermutationAutomorphismGroup</C>.
<P/>
See Leon <Cite Key="Leon82"/> for a more precise description of the
method, and the <File>guava/src/leon/doc</File> subdirectory for
for details about Leon's C programs.
<P/>
The function <C>PermutedCode</C>
permutes the columns of a code (see
<Ref Func="PermutedCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> R := RepetitionCode(7,GF(2));
a cyclic [7,1,7]3 repetition code over GF(2)
gap> AutomorphismGroup(R);
Sym( [ 1 .. 7 ] )
# every permutation keeps R identical
gap> C := CordaroWagnerCode(7);
a linear [7,2,4]3 Cordaro-Wagner code over GF(2)
gap> AsSSortedList(C);
[ [ 0 0 0 0 0 0 0 ], [ 0 0 1 1 1 1 1 ], [ 1 1 0 0 0 1 1 ], [ 1 1 1 1 1 0 0 ] ]
gap> AutomorphismGroup(C);
Group([ (3,4), (4,5), (1,6)(2,7), (1,2), (6,7) ])
gap> C2 := PermutedCode(C, (1,6)(2,7));
a linear [7,2,4]3 permuted code
gap> AsSSortedList(C2);
[ [ 0 0 0 0 0 0 0 ], [ 0 0 1 1 1 1 1 ], [ 1 1 0 0 0 1 1 ], [ 1 1 1 1 1 0 0 ] ]
gap> C2 = C;
true
</Example>
<!--
R := RepetitionCode(7,GF(2));
AutomorphismGroup(R);
C := CordaroWagnerCode(7);
AsSSortedList(C);
AutomorphismGroup(C);
C2 := PermutedCode(C, (1,6)(2,7));
AsSSortedList(C2);
C2 = C;
-->
<Index>PermutationAutomorphismGroup</Index>
<ManSection Label="PermutationAutomorphismGroup">
<Func Name="PermutationAutomorphismGroup" Arg=" C "/>
<Description>
<C>PermutationAutomorphismGroup</C> returns the permutation automorphism group
of a linear code <A>C</A>. This is the largest permutation group of
degree <M>n</M> such that each permutation applied to the
columns of <A>C</A> again yields <A>C</A>.
It is written in GAP, so is much slower than
<C>AutomorphismGroup</C>.
<P/>
When <A>C</A> is binary <C>PermutationAutomorphismGroup</C> does <E>not</E> call
<C>AutomorphismGroup</C>, even though they agree mathematically
in that case. This way <C>PermutationAutomorphismGroup</C> can be
called on any platform which runs GAP.
<P/>
The older name for this command,
<C>PermutationGroup</C>, will become obsolete in the next version of GAP.
</Description>
</ManSection>
<Example>
gap> R := RepetitionCode(3,GF(3));
a cyclic [3,1,3]2 repetition code over GF(3)
gap> G:=PermutationAutomorphismGroup(R);
Group([ (), (1,3), (1,2,3), (2,3), (1,3,2), (1,2) ])
gap> G=SymmetricGroup(3);
true
</Example>
<!--
R := RepetitionCode(3,GF(3));
G:=PermutationAutomorphismGroup(R);
G=SymmetricGroup(3);
-->
</Section>
<Section>
<Heading>
Domain Functions for Codes
</Heading>
<Label Name="Domain Functions for Codes"/>
These are some GAP functions that work on `Domains' in general.
Their specific effect on `Codes' is explained here.
<ManSection Label="IsFinite">
<Func Name="IsFinite" Arg=" C "/>
<Description>
<C>IsFinite</C> is an implementation of the GAP
domain function <C>IsFinite</C>. It returns true for a
code <A>C</A>.
</Description>
</ManSection>
<Example>
gap> IsFinite( RepetitionCode( 1000, GF(11) ) );
true
</Example>
<ManSection Label="Size">
<Func Name="Size" Arg=" C "/>
<Description>
<C>Size</C> returns the size of <A>C</A>, the number of elements
of the code. If the code is linear, the size of the code
is equal to <M>q^k</M>, where <M>q</M> is
the size of the base field of <A>C</A> and <M>k</M>
is the dimension.
</Description>
</ManSection>
<Example>
gap> Size( RepetitionCode( 1000, GF(11) ) );
11
gap> Size( NordstromRobinsonCode() );
256
</Example>
<ManSection Label="LeftActingDomain">
<Func Name="LeftActingDomain" Arg=" C "/>
<Description>
<C>LeftActingDomain</C> returns the base field of
a code <A>C</A>. Each element of <A>C</A>
consists of elements of this base field.
If the base field is <M>F</M>, and the word length
of the code is <M>n</M>, then the codewords are elements of
<M>F^n</M>.
If <A>C</A> is a cyclic code, its elements are interpreted
as polynomials with coefficients over <M>F</M>.
</Description>
</ManSection>
<Example>
gap> C1 := ElementsCode([[0,0,0], [1,0,1], [0,1,0]], GF(4));
a (3,3,1..3)2..3 user defined unrestricted code over GF(4)
gap> LeftActingDomain( C1 );
GF(2^2)
gap> LeftActingDomain( HammingCode( 3, GF(9) ) );
GF(3^2)
</Example>
<ManSection Label="Dimension">
<Func Name="Dimension" Arg=" C "/>
<Description>
<C>Dimension</C> returns the parameter <M>k</M> of <A>C</A>,
the dimension of the code, or the number of information
symbols in each codeword. The dimension is
not defined for non-linear codes;
<C>Dimension</C> then returns an error.
</Description>
</ManSection>
<Example>
gap> Dimension( NullCode( 5, GF(5) ) );
0
gap> C := BCHCode( 15, 4, GF(4) );
a cyclic [15,9,5]3..4 BCH code, delta=5, b=1 over GF(4)
gap> Dimension( C );
9
gap> Size( C ) = Size( LeftActingDomain( C ) ) ^ Dimension( C );
true
</Example>
<!--
Dimension( NullCode( 5, GF(5) ) );
C := BCHCode( 15, 4, GF(4) );
Dimension( C );
Size( C ) = Size( LeftActingDomain( C ) ) ^ Dimension( C );
-->
<ManSection Label="AsSSortedList">
<Func Name="AsSSortedList" Arg=" C "/>
<Description>
<C>AsSSortedList</C> (as strictly sorted list) returns an
immutable, duplicate free list of the elements of
<A>C</A>. For a finite field <M>GF(q)</M> generated by powers
of <M>Z(q)</M>, the ordering on
<Display>
GF(q)=\{ 0 , Z(q)^0, Z(q), Z(q)^2, ...Z(q)^{q-2} \}
</Display>
is that determined by the exponents <M>i</M>.
These elements are of the type codeword
(see <Ref Func="Codeword" Style="Number"/>). Note that for large codes,
generating the elements may be very time- and memory-consuming.
For generating a specific element or a subset of the elements,
use <C>CodewordNr</C> (see
<Ref Func="CodewordNr" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C := ConferenceCode( 5 );
a (5,12,2)1..4 conference code over GF(2)
gap> AsSSortedList( C );
[ [ 0 0 0 0 0 ], [ 0 0 1 1 1 ], [ 0 1 0 1 1 ], [ 0 1 1 0 1 ], [ 0 1 1 1 0 ],
[ 1 0 0 1 1 ], [ 1 0 1 0 1 ], [ 1 0 1 1 0 ], [ 1 1 0 0 1 ], [ 1 1 0 1 0 ],
[ 1 1 1 0 0 ], [ 1 1 1 1 1 ] ]
gap> CodewordNr( C, [ 1, 2 ] );
[ [ 0 0 0 0 0 ], [ 0 0 1 1 1 ] ]
</Example>
<!--
C := ConferenceCode( 5 );
AsSSortedList( C );
CodewordNr( C, [ 1, 2 ] );
-->
</Section>
<Section>
<Heading>
Printing and Displaying Codes
</Heading>
<Label Name="Printing and Displaying Codes"/>
<ManSection Label="Print">
<Func Name="Print" Arg=" C "/>
<Description>
<C>Print</C> prints information about <A>C</A>. This is the same as typing
the identifier <A>C</A> at the GAP-prompt.
<P/>
If the argument is an unrestricted code, information in the form
<Verb>
a (n,M,d)r ... code over GF(q)
</Verb>
is printed, where <A>n</A> is the word length, <A>M</A>
the number of elements of the code, <A>d</A> the minimum distance
and <A>r</A> the covering radius.
<P/>
If the argument is a linear code, information in the form
<Verb>
a linear [n,k,d]r ... code over GF(q)
</Verb>
is printed, where <A>n</A> is the word length, <A>k</A>
the dimension of the code, <A>d</A> the minimum distance
and <A>r</A> the covering radius.
<P/>
Except for codes produced by <C>RandomLinearCode</C>,
if <A>d</A> is not yet known, it is displayed in the form
<Verb>
lowerbound..upperbound
</Verb>
and if <A>r</A> is not yet known, it is displayed in the same way.
For certain ranges of <M>n</M>, the values of
<A>lowerbound</A> and <A>upperbound</A> are obtained from tables.
<P/>
The function <C>Display</C> gives more information.
See
<Ref Func="Display" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> C1 := ExtendedCode( HammingCode( 3, GF(2) ) );
a linear [8,4,4]2 extended code
gap> Print( "This is ", NordstromRobinsonCode(), ". \n");
This is a (16,256,6)4 Nordstrom-Robinson code over GF(2).
</Example>
<ManSection Label="String">
<Func Name="String" Arg=" C "/>
<Description>
<C>String</C> returns information about <A>C</A> in a string.
This function is used by <C>Print</C>.
</Description>
</ManSection>
<Example>
gap> x:= Indeterminate( GF(3) );; pol:= x^2+1;
x_1^2+Z(3)^0
gap> Factors(pol);
[ x_1^2+Z(3)^0 ]
gap> H := GeneratorPolCode( pol, 8, GF(3));
a cyclic [8,6,1..2]1..2 code defined by generator polynomial over GF(3)
gap> String(H);
"a cyclic [8,6,1..2]1..2 code defined by generator polynomial over GF(3)"
</Example>
<!--
x:= Indeterminate( GF(3) );; pol:= x^2+1;
Factors(pol);
H := GeneratorPolCode( pol, 8, GF(3));
String(H);
-->
<ManSection Label="Display">
<Func Name="Display" Arg=" C "/>
<Description>
<C>Display</C> prints the method of construction of code <A>C</A>.
With this history, in most cases an equal or equivalent code can be
reconstructed. If <A>C</A> is an unmanipulated code, the result
is equal to output of the function <C>Print</C> (see
<Ref Func="Print" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> Display( RepetitionCode( 6, GF(3) ) );
a cyclic [6,1,6]4 repetition code over GF(3)
gap> C1 := ExtendedCode( HammingCode(2) );;
gap> C2 := PuncturedCode( ReedMullerCode( 2, 3 ) );;
gap> Display( LengthenedCode( UUVCode( C1, C2 ) ) );
a linear [12,8,2]2..4 code, lengthened with 1 column(s) of
a linear [11,8,1]1..2 U U+V construction code of
U: a linear [4,1,4]2 extended code of
a linear [3,1,3]1 Hamming (2,2) code over GF(2)
V: a linear [7,7,1]0 punctured code of
a cyclic [8,7,2]1 Reed-Muller (2,3) code over GF(2)
</Example>
<!--
Display( RepetitionCode( 6, GF(3) ) );
C1 := ExtendedCode( HammingCode(2) );;
C2 := PuncturedCode( ReedMullerCode( 2, 3 ) );;
Display( LengthenedCode( UUVCode( C1, C2 ) ) );
-->
<ManSection Label="DisplayBoundsInfo">
<Func Name="DisplayBoundsInfo" Arg=" bds "/>
<Description>
<C>DisplayBoundsInfo</C> prints the method of construction of
the code <M>C</M> indicated in <C>bds:= BoundsMinimumDistance( n, k, GF(q) )</C>.
</Description>
</ManSection>
<Example>
gap> bounds := BoundsMinimumDistance( 20, 17, GF(4) );
gap> DisplayBoundsInfo(bounds);
an optimal linear [20,17,d] code over GF(4) has d=3
--------------------------------------------------------------------------------------------------
Lb(20,17)=3, by shortening of:
Lb(21,18)=3, by applying contruction B to a [81,77,3] code
Lb(81,77)=3, by shortening of:
Lb(85,81)=3, reference: Ham
--------------------------------------------------------------------------------------------------
Ub(20,17)=3, by considering shortening to:
Ub(7,4)=3, by considering puncturing to:
Ub(6,4)=2, by construction B applied to:
Ub(2,1)=2, repetition code
--------------------------------------------------------------------------------------------------
Reference Ham:
%T this reference is unknown, for more info
%T contact A.E. Brouwer (aeb@cwi.nl)
</Example>
<!--
bounds := BoundsMinimumDistance( 20, 17, GF(4) );
DisplayBoundsInfo(bounds);
-->
</Section>
<Section>
<Heading>
Generating (Check) Matrices and Polynomials
</Heading>
<Label Name="Generating (Check) Matrices and Polynomials"/>
<ManSection Label="GeneratorMat">
<Func Name="GeneratorMat" Arg=" C "/>
<Description>
<C>GeneratorMat</C> returns a generator matrix of <A>C</A>.
The code consists of all linear combinations of the rows of this matrix.
<P/>
If until now no generator matrix of <A>C</A> was determined,
it is computed from either the parity check matrix, the
generator polynomial, the check polynomial or the elements
(if possible), whichever is available.
<P/>
If <A>C</A> is a non-linear code, the function returns an error.
</Description>
</ManSection>
<Example>
gap> GeneratorMat( HammingCode( 3, GF(2) ) );
[ [ an immutable GF2 vector of length 7],
[ an immutable GF2 vector of length 7],
[ an immutable GF2 vector of length 7],
[ an immutable GF2 vector of length 7] ]
gap> Display(last);
1 1 1 . . . .
1 . . 1 1 . .
. 1 . 1 . 1 .
1 1 . 1 . . 1
gap> GeneratorMat( RepetitionCode( 5, GF(25) ) );
[ [ Z(5)^0, Z(5)^0, Z(5)^0, Z(5)^0, Z(5)^0 ] ]
gap> GeneratorMat( NullCode( 14, GF(4) ) );
[ ]
</Example>
<!--
GeneratorMat( HammingCode( 3, GF(2) ) );
Display(last);
GeneratorMat( RepetitionCode( 5, GF(25) ) );
GeneratorMat( NullCode( 14, GF(4) ) );
-->
<ManSection Label="CheckMat">
<Func Name="CheckMat" Arg=" C "/>
<Description>
<C>CheckMat</C> returns a parity check matrix of <A>C</A>.
The code consists of all
words orthogonal to each of the rows of this matrix. The transpose of the
matrix is a right inverse of the generator matrix. The parity check
matrix is computed from either the generator matrix, the generator
polynomial, the check polynomial or the elements of <A>C</A> (if possible),
whichever is available.
<P/>
If <A>C</A> is a non-linear code, the function returns an error.
</Description>
</ManSection>
<Example>
gap> CheckMat( HammingCode(3, GF(2) ) );
[ [ 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0, Z(2)^0, Z(2)^0, Z(2)^0 ],
[ 0*Z(2), Z(2)^0, Z(2)^0, 0*Z(2), 0*Z(2), Z(2)^0, Z(2)^0 ],
[ Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0 ] ]
gap> Display(last);
. . . 1 1 1 1
. 1 1 . . 1 1
1 . 1 . 1 . 1
gap> CheckMat( RepetitionCode( 5, GF(25) ) );
[ [ Z(5)^0, Z(5)^2, 0*Z(5), 0*Z(5), 0*Z(5) ],
[ 0*Z(5), Z(5)^0, Z(5)^2, 0*Z(5), 0*Z(5) ],
[ 0*Z(5), 0*Z(5), Z(5)^0, Z(5)^2, 0*Z(5) ],
[ 0*Z(5), 0*Z(5), 0*Z(5), Z(5)^0, Z(5)^2 ] ]
gap> CheckMat( WholeSpaceCode( 12, GF(4) ) );
[ ]
</Example>
<!--
CheckMat( HammingCode(3, GF(2) ) );
Display(last);
CheckMat( RepetitionCode( 5, GF(25) ) );
CheckMat( WholeSpaceCode( 12, GF(4) ) );
-->
<ManSection Label="GeneratorPol">
<Func Name="GeneratorPol" Arg=" C "/>
<Description>
<C>GeneratorPol</C> returns the generator polynomial of <A>C</A>.
The code consists of all multiples of the generator polynomial
modulo <M>x^{n}-1</M>, where <M>n</M>
is the word length of <A>C</A>.
The generator polynomial is determined from either the check
polynomial, the generator or check matrix or the
elements of <A>C</A> (if possible), whichever is available.
<P/>
If <A>C</A> is not a cyclic code, the function returns `false'.
</Description>
</ManSection>
<Example>
gap> GeneratorPol(GeneratorMatCode([[1, 1, 0], [0, 1, 1]], GF(2)));
Z(2)^0+x_1
gap> GeneratorPol( WholeSpaceCode( 4, GF(2) ) );
Z(2)^0
gap> GeneratorPol( NullCode( 7, GF(3) ) );
-Z(3)^0+x_1^7
</Example>
<!--
GeneratorPol(GeneratorMatCode([[1, 1, 0], [0, 1, 1]], GF(2)));
GeneratorPol( WholeSpaceCode( 4, GF(2) ) );
GeneratorPol( NullCode( 7, GF(3) ) );
-->
<ManSection Label="CheckPol">
<Func Name="CheckPol" Arg=" C "/>
<Description>
<C>CheckPol</C> returns the check polynomial of
<A>C</A>. The code consists of all polynomials <M>f</M>
with
<Display>
f\cdot h \equiv 0 \ ({\rm mod}\ x^n-1),
</Display>
where <M>h</M> is the check polynomial, and <M>n</M> is the
word length of <A>C</A>. The check polynomial is
computed from the generator polynomial, the generator or parity check
matrix or the elements of <A>C</A> (if possible), whichever is available.
<P/>
If <A>C</A> if not a cyclic code, the function returns an error.
</Description>
</ManSection>
<Example>
gap> CheckPol(GeneratorMatCode([[1, 1, 0], [0, 1, 1]], GF(2)));
Z(2)^0+x_1+x_1^2
gap> CheckPol(WholeSpaceCode(4, GF(2)));
Z(2)^0+x_1^4
gap> CheckPol(NullCode(7,GF(3)));
Z(3)^0
</Example>
<!--
CheckPol(GeneratorMatCode([[1, 1, 0], [0, 1, 1]], GF(2)));
CheckPol(WholeSpaceCode(4, GF(2)));
CheckPol(NullCode(7,GF(3)));
-->
<ManSection Label="RootsOfCode">
<Func Name="RootsOfCode" Arg=" C "/>
<Description>
<C>RootsOfCode</C> returns a list of all zeros of the generator polynomial of
a cyclic code <A>C</A>. These are finite field elements in the splitting field
of the generator polynomial, <M>GF(q^m)</M>, <M>m</M>
is the multiplicative order
of the size of the base field of the code, modulo the word length.
<P/>
The reverse process, constructing a code from a set of roots, can be
carried out by the function <C>RootsCode</C> (see
<Ref Func="RootsCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C1 := ReedSolomonCode( 16, 5 );
a cyclic [16,12,5]3..4 Reed-Solomon code over GF(17)
gap> RootsOfCode( C1 );
[ Z(17), Z(17)^2, Z(17)^3, Z(17)^4 ]
gap> C2 := RootsCode( 16, last );
a cyclic [16,12,5]3..4 code defined by roots over GF(17)
gap> C1 = C2;
true
</Example>
<!--
C1 := ReedSolomonCode( 16, 5 );
RootsOfCode( C1 );
C2 := RootsCode( 16, last );
C1 = C2;
-->
</Section>
<Section>
<Heading>
Parameters of Codes
</Heading>
<Label Name="Parameters of Codes"/>
<ManSection Label="WordLength">
<Func Name="WordLength" Arg=" C "/>
<Description>
<C>WordLength</C> returns the parameter <M>n</M> of
<A>C</A>, the word length of the elements. Elements of
cyclic codes are polynomials of maximum degree
<M>n-1</M>, as calculations are carried out modulo
<M>x^{n}-1</M>.
</Description>
</ManSection>
<Example>
gap> WordLength( NordstromRobinsonCode() );
16
gap> WordLength( PuncturedCode( WholeSpaceCode(7) ) );
6
gap> WordLength( UUVCode( WholeSpaceCode(7), RepetitionCode(7) ) );
14
</Example>
<!--
WordLength( NordstromRobinsonCode() );
WordLength( PuncturedCode( WholeSpaceCode(7) ) );
WordLength( UUVCode( WholeSpaceCode(7), RepetitionCode(7) ) );
-->
<ManSection Label="Redundancy">
<Func Name="Redundancy" Arg=" C "/>
<Description>
<C>Redundancy</C> returns the redundancy
<M>r</M> of <A>C</A>, which is equal to the
number of check symbols in each element.
If <A>C</A> is not a linear code the redundancy is
not defined and <C>Redundancy</C> returns an error.
<P/>
If a linear code <A>C</A> has dimension <M>k</M> and
word length <M>n</M>, it has redundancy <M>r=n-k</M>.
</Description>
</ManSection>
<Example>
gap> C := TernaryGolayCode();
a cyclic [11,6,5]2 ternary Golay code over GF(3)
gap> Redundancy(C);
5
gap> Redundancy( DualCode(C) );
6
</Example>
<!--
C := TernaryGolayCode();
Redundancy(C);
Redundancy( DualCode(C) );
-->
<ManSection Label="MinimumDistance">
<Func Name="MinimumDistance" Arg=" C "/>
<Description>
<C>MinimumDistance</C> returns the minimum distance
of <A>C</A>, the largest integer <M>d</M> with the
property that every element of <A>C</A> has at least a
Hamming distance <M>d</M> (see
<Ref Func="DistanceCodeword" Style="Number"/>)
to any other element of <A>C</A>.
For linear codes, the minimum distance is equal to the minimum
weight. This means that <M>d</M> is also the
smallest positive value with <M>w[d+1] \neq 0</M>, where
<M>w=(w[1],w[2],...,w[n])</M> is the weight distribution
of <A>C</A> (see
<Ref Func="WeightDistribution" Style="Number"/>). For unrestricted codes,
<M>d</M> is the smallest positive value with <M>w[d+1] \neq 0</M>,
where <M>w</M> is the inner distribution
of <A>C</A> (see
<Ref Func="InnerDistribution" Style="Number"/>).
<P/>
For codes with only one element, the minimum distance is defined to be
equal to the word length.
<P/>
For linear codes <A>C</A>, the algorithm used is the following:
After replacing <A>C</A> by a permutation equivalent <A>C'</A>,
one may assume the generator matrix has the following form
<M>G=(I_{k} \, | \, A)</M>, for some <M>k\times (n-k)</M>
matrix <M>A</M>. If <M>A=0</M> then return <M>d(C)=1</M>.
Next, find the minimum distance of the code spanned by the
rows of <M>A</M>. Call this distance <M>d(A)</M>.
Note that <M>d(A)</M> is equal to the
the Hamming distance <M>d(v,0)</M> where <M>v</M>
is some proper linear combination of <M>i</M>
distinct rows of <M>A</M>.
Return <M>d(C)=d(A)+i</M>, where <M>i</M> is as in the previous step.
<P/>
This command may also be called using the syntax
<C>MinimumDistance(C, w)</C>.
In this form, <C>MinimumDistance</C> returns the
minimum distance of a codeword <A>w</A> to the code <A>C</A>,
also called the <E>distance from <A>w</A> to</E> <A>C</A>. This is
the smallest value <M>d</M> for which there is an element
<M>c</M> of the code <A>C</A> which is at distance <M>d</M> from
<A>w</A>. So <M>d</M> is also the minimum value for
which <M>D[d+1] \neq 0</M>, where <M>D</M> is
the distance distribution of <A>w</A> to <A>C</A>
(see <Ref Func="DistancesDistribution" Style="Number"/>).
<P/>
Note that <A>w</A> must be an element of the same vector space
as the elements of <A>C</A>.
<A>w</A> does not necessarily belong to the code (if it does, the
minimum distance is zero).
</Description>
</ManSection>
<Example>
gap> C := MOLSCode(7);; MinimumDistance(C);
3
gap> WeightDistribution(C);
[ 1, 0, 0, 24, 24 ]
gap> MinimumDistance( WholeSpaceCode( 5, GF(3) ) );
1
gap> MinimumDistance( NullCode( 4, GF(2) ) );
4
gap> C := ConferenceCode(9);; MinimumDistance(C);
4
gap> InnerDistribution(C);
[ 1, 0, 0, 0, 63/5, 9/5, 18/5, 0, 9/10, 1/10 ]
gap> C := MOLSCode(7);; w := CodewordNr( C, 17 );
[ 3 3 6 2 ]
gap> MinimumDistance( C, w );
0
gap> C := RemovedElementsCode( C, w );; MinimumDistance( C, w );
3 # so w no longer belongs to C
</Example>
<!--
C := MOLSCode(7);; MinimumDistance(C);
WeightDistribution(C);
MinimumDistance( WholeSpaceCode( 5, GF(3) ) );
MinimumDistance( NullCode( 4, GF(2) ) );
C := ConferenceCode(9);; MinimumDistance(C);
InnerDistribution(C);
C := MOLSCode(7);; w := CodewordNr( C, 17 );
MinimumDistance( C, w );
C := RemovedElementsCode( C, w );; MinimumDistance( C, w );
-->
See also the <Package>GUAVA</Package>
commands relating to bounds on the
minimum distance in section
<Ref Label="Distance bounds on codes" Style="Number"/>.
<ManSection Label="MinimumDistanceLeon">
<Func Name="MinimumDistanceLeon" Arg=" C "/>
<Description>
<C>MinimumDistanceLeon</C> returns the ``probable'' minimum distance
<M>d_{Leon}</M> of a linear binary code <A>C</A>, using an implementation of
Leon's probabilistic polynomial time algorithm. Briefly:
Let <A>C</A> be a linear code of dimension <M>k</M> over
<M>GF(q)</M> as above. The algorithm has input parameters <M>s</M> and <M>\rho</M>,
where <M>s</M> is an integer between <M>2</M> and <M>n-k</M>, and
<M>\rho</M> is an integer between <M>2</M> and <M>k</M>.
<List>
<Item>
Find a generator matrix <M>G</M> of <M>C</M>.
</Item>
<Item>
Randomly permute the columns of <M>G</M>.
</Item>
<Item>
Perform Gaussian elimination on the permuted matrix to obtain a
new matrix of the following form:
<Display>
G=(I_{k} \, | \, Z \, | \, B)
</Display>
with <M>Z</M> a <M>k\times s</M> matrix. If <M>(Z,B)</M> is the
zero matrix then return <M>1</M> for the minimum distance.
If <M>Z=0</M> but not <M>B</M> then either choose another
permutation of the rows of <A>C</A> or return `method fails'.
</Item>
<Item>
Search <M>Z</M> for at most <M>\rho</M> rows that lead to codewords of
weight less than <M>\rho</M>.
</Item>
<Item>
For these codewords, compute the weight of the whole word in <A>C</A>.
Return this weight.
</Item>
</List>
(See for example J. S. Leon, <Cite Key="Leon88"/> for more details.)
Sometimes (as is the case in <Package>GUAVA</Package>)
this probabilistic algorithm
is repeated several times and the most commonly occurring value
is taken.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(50,22,GF(2));
a [50,22,?] randomly generated code over GF(2)
gap> MinimumDistanceLeon(C); time;
6
211
gap> MinimumDistance(C); time;
6
1204
</Example>
<!--
C:=RandomLinearCode(50,22,GF(2));
MinimumDistanceLeon(C); time;
MinimumDistance(C); time;
-->
<ManSection Label="MinimumWeight">
<Func Name="MinimumWeight" Arg=" C "/>
<Description>
<C>MinimumWeight</C> returns the minimum Hamming weight of a linear
code <A>C</A>. At the moment, this function works for binary and
ternary codes only. The <C>MinimumWeight</C> function relies on
an external executable program which is written in C language. As
a consequence, the execution time of <C>MinimumWeight</C> function
is faster than that of <Ref Func="MinimumDistance" Style="Number"/>
function.
<P/>
The <C>MinimumWeight</C> function implements Chen's <Cite Key="Chen69"/> algorithm
if <A>C</A> is cyclic, and Zimmermann's <Cite Key="Zimmermann96"/> algorithm
if <A>C</A> is a general linear code. This function has a built-in check on
the constraints of the minimum weight codewords. For example, for a self-orthogonal
code over GF(3), the minimum weight codewords have weight that is divisible by
3, i.e. 0 mod 3 congruence. Similary, self-orthogonal codes over GF(2) have
codeword weights that are divisible by 4 and even codes over GF(2) have codewords
weights that are divisible by 2. By taking these constraints into account, in many
cases, the execution time may be significantly reduced. Consider the minimum
Hamming weight enumeration of the <M>[151,45]</M> binary cyclic code (second
example below). This cyclic code is self-orthogonal, so the weight of all
codewords is divisible by 4. Without considering this constraint, the computation
will finish at information weight <M>10</M>, rather than <M>9</M>. We can see
that, this 0 mod 4 constraint on the codeword weights, has allowed us to avoid
enumeration of <M>b(45,10) = 3,190,187,286</M> additional codewords, where
<M>b(n,k)=n!/((n-k)!k!)</M> is the binomial coefficient of integers <M>n</M>
and <M>k</M>.
<P/>
Note that the C source code for this minimum weight computation has not yet
been optimised, especially the code for GF(3), and there are chances to improve
the speed of this function. Your contributions are most welcomed.
<P/>
If you find any bugs on this function, please report it to ctjhai@plymouth.ac.uk.
</Description>
</ManSection>
<Example>
gap> # Extended ternary quadratic residue code of length 48
gap> n := 47;;
gap> x := Indeterminate(GF(3));;
gap> F := Factors(x^n-1);;
gap> v := List([1..n], i->Zero(GF(3)));;
gap> v := v + MutableCopyMat(VectorCodeword( Codeword(F[2]) ));;
gap> G := CirculantMatrix(24, v);;
gap> for i in [1..Size(G)] do; s:=Zero(GF(3));
> for j in [1..Size(G[i])] do; s:=s+G[i][j]; od; Append(G[i], [ s ]);
> od;;
gap> C := GeneratorMatCodeNC(G, GF(3));
a [48,24,?] randomly generated code over GF(3)
gap> MinimumWeight(C);
[48,24] linear code over GF(3) - minimum weight evaluation
Known lower-bound: 1
There are 2 generator matrices, ranks : 24 24
The weight of the minimum weight codeword satisfies 0 mod 3 congruence
Enumerating codewords with information weight 1 (w=1)
Found new minimum weight 15
Number of matrices required for codeword enumeration 2
Completed w= 1, 48 codewords enumerated, lower-bound 6, upper-bound 15
Termination expected with information weight 6 at matrix 1
-----------------------------------------------------------------------------
Enumerating codewords with information weight 2 (w=2) using 2 matrices
Completed w= 2, 1104 codewords enumerated, lower-bound 6, upper-bound 15
Termination expected with information weight 6 at matrix 1
-----------------------------------------------------------------------------
Enumerating codewords with information weight 3 (w=3) using 2 matrices
Completed w= 3, 16192 codewords enumerated, lower-bound 9, upper-bound 15
Termination expected with information weight 6 at matrix 1
-----------------------------------------------------------------------------
Enumerating codewords with information weight 4 (w=4) using 2 matrices
Completed w= 4, 170016 codewords enumerated, lower-bound 12, upper-bound 15
Termination expected with information weight 6 at matrix 1
-----------------------------------------------------------------------------
Enumerating codewords with information weight 5 (w=5) using 2 matrices
Completed w= 5, 1360128 codewords enumerated, lower-bound 12, upper-bound 15
Termination expected with information weight 6 at matrix 1
-----------------------------------------------------------------------------
Enumerating codewords with information weight 6 (w=6) using 1 matrices
Completed w= 6, 4307072 codewords enumerated, lower-bound 15, upper-bound 15
-----------------------------------------------------------------------------
Minimum weight: 15
15
gap>
gap> # Binary cyclic code [151,45,36]
gap> n := 151;;
gap> x := Indeterminate(GF(2));;
gap> F := Factors(x^n-1);;
gap> C := CheckPolCode(F[2]*F[3]*F[3]*F[4], n, GF(2));
a cyclic [151,45,1..50]31..75 code defined by check polynomial over GF(2)
gap> MinimumWeight(C);
[151,45] cyclic code over GF(2) - minimum weight evaluation
Known lower-bound: 1
The weight of the minimum weight codeword satisfies 0 mod 4 congruence
Enumerating codewords with information weight 1 (w=1)
Found new minimum weight 56
Found new minimum weight 44
Number of matrices required for codeword enumeration 1
Completed w= 1, 45 codewords enumerated, lower-bound 8, upper-bound 44
Termination expected with information weight 11
-----------------------------------------------------------------------------
Enumerating codewords with information weight 2 (w=2) using 1 matrix
Completed w= 2, 990 codewords enumerated, lower-bound 12, upper-bound 44
Termination expected with information weight 11
-----------------------------------------------------------------------------
Enumerating codewords with information weight 3 (w=3) using 1 matrix
Found new minimum weight 40
Found new minimum weight 36
Completed w= 3, 14190 codewords enumerated, lower-bound 16, upper-bound 36
Termination expected with information weight 9
-----------------------------------------------------------------------------
Enumerating codewords with information weight 4 (w=4) using 1 matrix
Completed w= 4, 148995 codewords enumerated, lower-bound 20, upper-bound 36
Termination expected with information weight 9
-----------------------------------------------------------------------------
Enumerating codewords with information weight 5 (w=5) using 1 matrix
Completed w= 5, 1221759 codewords enumerated, lower-bound 24, upper-bound 36
Termination expected with information weight 9
-----------------------------------------------------------------------------
Enumerating codewords with information weight 6 (w=6) using 1 matrix
Completed w= 6, 8145060 codewords enumerated, lower-bound 24, upper-bound 36
Termination expected with information weight 9
-----------------------------------------------------------------------------
Enumerating codewords with information weight 7 (w=7) using 1 matrix
Completed w= 7, 45379620 codewords enumerated, lower-bound 28, upper-bound 36
Termination expected with information weight 9
-----------------------------------------------------------------------------
Enumerating codewords with information weight 8 (w=8) using 1 matrix
Completed w= 8, 215553195 codewords enumerated, lower-bound 32, upper-bound 36
Termination expected with information weight 9
-----------------------------------------------------------------------------
Enumerating codewords with information weight 9 (w=9) using 1 matrix
Completed w= 9, 886163135 codewords enumerated, lower-bound 36, upper-bound 36
-----------------------------------------------------------------------------
Minimum weight: 36
36
</Example>
<!--
# Extended ternary quadratic residue code of length 48
n := 47;;
x := Indeterminate(GF(3));;
F := Factors(x^n-1);;
v := List([1..n], i->Zero(GF(3)));;
v := v + MutableCopyMat(VectorCodeword( Codeword(F[2]) ));;
G := CirculantMatrix(24, v);;
for i in [1..Size(G)] do; s:=Zero(GF(3));
for j in [1..Size(G[i])] do; s:=s+G[i][j]; od; Append(G[i], [ s ]);
od;;
C := GeneratorMatCodeNC(G, GF(3));
MinimumWeight(C);
# Binary cyclic code [151,45,36]
n := 151;;
x := Indeterminate(GF(2));;
F := Factors(x^n-1);;
C := CheckPolCode(F[2]*F[3]*F[3]*F[4], n, GF(2));
MinimumWeight(C);
-->
<ManSection Label="DecreaseMinimumDistanceUpperBound">
<Func Name="DecreaseMinimumDistanceUpperBound" Arg=" C t m"/>
<Description>
<C>DecreaseMinimumDistanceUpperBound</C> is an implementation of the algorithm
for the minimum distance of a linear binary code <A>C</A> by Leon
<Cite Key="Leon88"/>.
This algorithm tries to find codewords with small minimum weights.
The parameter <A>t</A> is at least <M>1</M> and less than
the dimension of <A>C</A>.
The best results are obtained if it is close to the
dimension of the code. The parameter <A>m</A> gives the number of
runs that the algorithm will perform.
<P/>
The result returned is a record with two fields; the first, <C>mindist</C>,
gives the lowest weight found, and <C>word</C> gives the corresponding
codeword.
(This was implemented before <C>MinimumDistanceLeon</C> but independently.
The older manual had given the command incorrectly, so the command
was only found after reading all the <E>*.gi</E> files in the
<Package>GUAVA</Package> library. Though both <C>MinimumDistance</C> and
<C>MinimumDistanceLeon</C> often run much faster than
<C>DecreaseMinimumDistanceUpperBound</C>, <C>DecreaseMinimumDistanceUpperBound</C>
appears to be more accurate than <C>MinimumDistanceLeon</C>.)
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(5,2,GF(2));
a [5,2,?] randomly generated code over GF(2)
gap> DecreaseMinimumDistanceUpperBound(C,1,4);
rec( mindist := 3, word := [ 0*Z(2), Z(2)^0, Z(2)^0, 0*Z(2), Z(2)^0 ] )
gap> MinimumDistance(C);
3
gap> C:=RandomLinearCode(8,4,GF(2));
a [8,4,?] randomly generated code over GF(2)
gap> DecreaseMinimumDistanceUpperBound(C,3,4);
rec( mindist := 2,
word := [ Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0 ] )
gap> MinimumDistance(C);
2
</Example>
<ManSection Label="MinimumDistanceRandom">
<Func Name="MinimumDistanceRandom" Arg=" C num s "/>
<Description>
<C>MinimumDistanceRandom</C> returns an upper bound for the minimum distance
<M>d_{random}</M> of a linear binary code <A>C</A>, using a
probabilistic polynomial time algorithm. Briefly:
Let <A>C</A> be a linear code of dimension <M>k</M> over
<M>GF(q)</M> as above. The algorithm has input parameters <M>num</M> and <M>s</M>,
where <M>s</M> is an integer between <M>2</M> and <M>n-1</M>, and
<M>num</M> is an integer greater than or equal to <M>1</M>.
<List>
<Item>
Find a generator matrix <M>G</M> of <M>C</M>.
</Item>
<Item>
Randomly permute the columns of <M>G</M>, written <M>G_p</M>..
</Item>
<Item>
<Display>
G=(A, B)
</Display>
with <M>A</M> a <M>k\times s</M> matrix. If <M>A</M> is the
zero matrix then return `method fails'.
</Item>
<Item>
Search <M>A</M> for at most <M>5</M> rows that lead to codewords,
in the code <M>C_A</M> with generator matrix <M>A</M>, of
minimum weight.
</Item>
<Item>
For these codewords, use the associated linear combination to
compute the weight of the whole word in <A>C</A>.
Return this weight and codeword.
</Item>
</List>
This probabilistic algorithm
is repeated <A>num</A> times (with different random permutations of the
rows of <M>G</M> each time) and the weight and codeword of the lowest
occurring weight is taken.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(60,20,GF(2));
a [60,20,?] randomly generated code over GF(2)
gap> #mindist(C);time;
gap> #mindistleon(C,10,30);time; #doesn't work well
gap> a:=MinimumDistanceRandom(C,10,30);time; # done 10 times -with fastest time!!
This is a probabilistic algorithm which may return the wrong answer.
[ 12, [ 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0
1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 ] ]
130
gap> a[2] in C;
true
gap> b:=DecreaseMinimumDistanceUpperBound(C,10,1); time; #only done once!
rec( mindist := 12, word := [ 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2),
Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2),
0*Z(2), Z(2)^0, Z(2)^0, 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2),
Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2),
0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2),
0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2),
0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2) ] )
649
gap> Codeword(b!.word) in C;
true
gap> MinimumDistance(C);time;
12
196
gap> c:=MinimumDistanceLeon(C);time;
12
66
gap> C:=RandomLinearCode(30,10,GF(3));
a [30,10,?] randomly generated code over GF(3)
gap> a:=MinimumDistanceRandom(C,10,10);time;
This is a probabilistic algorithm which may return the wrong answer.
[ 13, [ 0 0 0 1 0 0 0 0 0 0 1 0 2 2 1 1 0 2 2 0 1 0 2 1 0 0 0 1 0 2 ] ]
229
gap> a[2] in C;
true
gap> MinimumDistance(C);time;
9
45
gap> c:=MinimumDistanceLeon(C);
Code must be binary. Quitting.
0
gap> a:=MinimumDistanceRandom(C,1,29);time;
This is a probabilistic algorithm which may return the wrong answer.
[ 10, [ 0 0 1 0 2 0 2 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 2 2 2 0 ] ]
53
</Example>
<!--
-->
<Index>
<M>t(n,k)</M>
</Index>
<Index>
covering code
</Index>
<ManSection Label="CoveringRadius">
<Func Name="CoveringRadius" Arg=" C "/>
<Description>
<C>CoveringRadius</C> returns the <E>covering radius</E> of
a linear code <A>C</A>. This is the smallest number <M>r</M> with the
property that each element <M>v</M> of the ambient vector space of
<A>C</A> has at most a distance <M>r</M> to the code <A>C</A>.
So for each vector <M>v</M>
there must be an element <M>c</M> of <A>C</A> with
<M>d(v,c) \leq r</M>.
The smallest covering radius of any <M>[n,k]</M> binary
linear code is denoted <M>t(n,k)</M>. A binary linear code
with reasonable small covering radius is called a
<E>covering code</E>.
<P/>
If <A>C</A> is a perfect code (see
<Ref Func="IsPerfectCode" Style="Number"/>), the covering radius is
equal to <M>t</M>, the number of errors the code can correct, where
<M>d = 2t+1</M>, with <M>d</M> the minimum distance of
<A>C</A> (see
<Ref Func="MinimumDistance" Style="Number"/>).
<P/>
If there exists a function called <C>SpecialCoveringRadius</C> in the
`operations' field of the code, then this function will be called to
compute the covering radius of the code.
At the moment, no code-specific functions are implemented.
<P/>
If the length of <C>BoundsCoveringRadius</C>
(see <Ref Func="BoundsCoveringRadius" Style="Number"/>),
is 1, then the value in
<Verb>
C.boundsCoveringRadius
</Verb>
is returned.
Otherwise, the function
<Verb>
C.operations.CoveringRadius
</Verb>
is executed, unless the redundancy of <A>C</A> is too large.
In the last case, a warning is issued.
<P/>
The algorithm used to compute the covering radius is the following.
First, <C>CosetLeadersMatFFE</C> is used to compute
the list of coset leaders (which returns a codeword in
each coset of <M>GF(q)^n/C</M> of minimum weight).
Then <C>WeightVecFFE</C> is used to compute the weight
of each of these coset leaders. The program returns the
maximum of these weights.
<!--
If you want to overrule this restriction, you might want to execute
<Verb>
C.operations.CoveringRadius
</Verb>
yourself. However, this algorithm might also issue a warning that it
cannot be executed, but this warning is sometimes issued too late,
resulting in GAP exiting with an memory error. If it does run, it can
only be stopped by pressing <B>ctrl-C</B> twice, thereby quitting GAP. It
will not enter the usual break-loop. Therefore it is recommended to save
your work before trying <C>code.operations.CoveringRadius</C>.
************
This seems to be wrong, since GAP doesn't like this command:
gap> H := RandomLinearCode(10, 5, GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> CoveringRadius( H );
3
gap> H.operations.CoveringRadius;
Error, illegal access to record component `obj.operations'
of the object <obj>. (Objects by default do not have record components.
The error might be a relic from translated GAP3 code.) called from
<function>( <arguments> ) called from read-eval-loop
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk>
************
-->
</Description>
</ManSection>
<Example>
gap> H := RandomLinearCode(10, 5, GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> CoveringRadius(H);
3
gap> H := HammingCode(4, GF(2));; IsPerfectCode(H);
true
gap> CoveringRadius(H);
1 # Hamming codes have minimum distance 3
gap> CoveringRadius(ReedSolomonCode(7,4));
3
gap> CoveringRadius( BCHCode( 17, 3, GF(2) ) );
3
gap> CoveringRadius( HammingCode( 5, GF(2) ) );
1
gap> C := ReedMullerCode( 1, 9 );;
gap> CoveringRadius( C );
CoveringRadius: warning, the covering radius of
this code cannot be computed straightforward.
Try to use IncreaseCoveringRadiusLowerBound( code ).
(see the manual for more details).
The covering radius of code lies in the interval:
[ 240 .. 248 ]
</Example>
<!--
H := RandomLinearCode(10, 5, GF(2));
CoveringRadius(H);
H := HammingCode(4, GF(2));; IsPerfectCode(H);
CoveringRadius(H);
CoveringRadius(ReedSolomonCode(7,4));
CoveringRadius( BCHCode( 17, 3, GF(2) ) );
CoveringRadius( HammingCode( 5, GF(2) ) );
C := ReedMullerCode( 1, 9 );;
CoveringRadius( C );
-->
See also the <Package>GUAVA</Package>
commands relating to bounds on the
minimum distance in section
<Ref Label="Covering radius bounds on codes" Style="Number"/>.
<ManSection Label="SetCoveringRadius">
<Func Name="SetCoveringRadius" Arg=" C intlist "/>
<Description>
<C>SetCoveringRadius</C> enables the user to set the covering radius
herself, instead of letting <Package>GUAVA</Package>
compute it.
If <A>intlist</A> is an integer, <Package>GUAVA</Package>
will simply put it in the `boundsCoveringRadius' field.
If it is a list of integers, however, it will intersect this list
with the `boundsCoveringRadius' field, thus taking the best of both
lists.
If this would leave an empty list, the field is set to <A>intlist</A>.
Because some other computations use the covering radius of the code,
it is important that the entered value is not wrong, otherwise
new results may be invalid.
</Description>
</ManSection>
<Example>
gap> C := BCHCode( 17, 3, GF(2) );;
gap> BoundsCoveringRadius( C );
[ 3 .. 4 ]
gap> SetCoveringRadius( C, [ 2 .. 3 ] );
gap> BoundsCoveringRadius( C );
[ [ 2 .. 3 ] ]
</Example>
<!--
C := BCHCode( 17, 3, GF(2) );;
BoundsCoveringRadius( C );
SetCoveringRadius( C, [ 2 .. 3 ] );
BoundsCoveringRadius( C );
-->
</Section>
<Section>
<Heading>
Distributions
</Heading>
<Label Name="Distributions"/>
<ManSection Label="MinimumWeightWords">
<Func Name="MinimumWeightWords" Arg=" C "/>
<Description>
<C>MinimumWeightWords</C> returns the list of minimum weight codewords of
<A>C</A>.
<P/>
This algorithm is written in GAP is slow, so is only suitable for small codes.
<P/>
This does not call the very fast function <C>MinimumWeight</C>
(see <Ref Func="MinimumWeight" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C:=HammingCode(3,GF(2));
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> MinimumWeightWords(C);
[ [ 1 0 0 0 0 1 1 ], [ 0 1 0 1 0 1 0 ], [ 0 1 0 0 1 0 1 ], [ 1 0 0 1 1 0 0 ], [ 0 0 1 0 1 1 0 ],
[ 0 0 1 1 0 0 1 ], [ 1 1 1 0 0 0 0 ] ]
</Example>
<!--
C:=HammingCode(3,GF(2));
MinimumWeightWords(C);
-->
<ManSection Label="WeightDistribution">
<Func Name="WeightDistribution" Arg=" C "/>
<Description>
<C>WeightDistribution</C> returns the weight distribution of
<A>C</A>, as a vector. The <M>i^{th}</M> element of this
vector contains the number of elements of <A>C</A> with
weight <M>i-1</M>. For linear codes, the weight
distribution is equal to the inner distribution (see
<Ref Func="InnerDistribution" Style="Number"/>).
If <M>w</M> is the weight distribution of
a linear code <A>C</A>, it must
have the zero codeword, so <M>w[1] = 1</M> (one word of weight 0).
<P/>
Some codes, such as the Hamming codes, have precomputed
weight distributions. For others, the program
WeightDistribution calls the GAP program
<C>DistancesDistributionMatFFEVecFFE</C>,
which is written in C. See also
<C>CodeWeightEnumerator</C>.
</Description>
</ManSection>
<Example>
gap> WeightDistribution( ConferenceCode(9) );
[ 1, 0, 0, 0, 0, 18, 0, 0, 0, 1 ]
gap> WeightDistribution( RepetitionCode( 7, GF(4) ) );
[ 1, 0, 0, 0, 0, 0, 0, 3 ]
gap> WeightDistribution( WholeSpaceCode( 5, GF(2) ) );
[ 1, 5, 10, 10, 5, 1 ]
</Example>
<!--
WeightDistribution( ConferenceCode(9) );
WeightDistribution( RepetitionCode( 7, GF(4) ) );
WeightDistribution( WholeSpaceCode( 5, GF(2) ) );
-->
<ManSection Label="InnerDistribution">
<Func Name="InnerDistribution" Arg=" C "/>
<Description>
<C>InnerDistribution</C> returns the inner distribution
of <A>C</A>. The <M>i^{th}</M> element of the vector contains the
average number of elements of <A>C</A> at
distance <M>i-1</M> to an element of <A>C</A>.
For linear codes, the inner distribution is equal
to the weight distribution (see
<Ref Func="WeightDistribution" Style="Number"/>).
<P/>
Suppose <M>w</M> is the inner distribution of <A>C</A>. Then
<M>w[1] = 1</M>, because each element of <A>C</A> has
exactly one element at distance zero (the element
itself). The minimum distance of <A>C</A> is the smallest
value <M>d > 0</M> with
<M>w[d+1] \neq 0</M>, because a distance between zero
and <M>d</M> never occurs. See
<Ref Func="MinimumDistance" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> InnerDistribution( ConferenceCode(9) );
[ 1, 0, 0, 0, 63/5, 9/5, 18/5, 0, 9/10, 1/10 ]
gap> InnerDistribution( RepetitionCode( 7, GF(4) ) );
[ 1, 0, 0, 0, 0, 0, 0, 3 ]
</Example>
<!--
InnerDistribution( ConferenceCode(9) );
InnerDistribution( RepetitionCode( 7, GF(4) ) );
-->
<Index>
distance
</Index>
<ManSection Label="DistancesDistribution">
<Func Name="DistancesDistribution" Arg=" C w "/>
<Description>
<C>DistancesDistribution</C> returns the distribution
of the distances of all
elements of <A>C</A> to a codeword <A>w</A> in the same vector space.
The <M>i^{th}</M>
element of the distance distribution is the
number of codewords of <A>C</A>
that have distance <M>i-1</M> to <A>w</A>.
The smallest value <M>d</M> with <M>w[d+1] \neq 0</M>, is
defined as the <E>distance to</E> <A>C</A>
(see
<Ref Func="MinimumDistance" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> H := HadamardCode(20);
a (20,40,10)6..8 Hadamard code of order 20 over GF(2)
gap> c := Codeword("10110101101010010101", H);
[ 1 0 1 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 ]
gap> DistancesDistribution(H, c);
[ 0, 0, 0, 0, 0, 1, 0, 7, 0, 12, 0, 12, 0, 7, 0, 1, 0, 0, 0, 0, 0 ]
gap> MinimumDistance(H, c);
5 # distance to H
</Example>
<!--
H := HadamardCode(20);
c := Codeword("10110101101010010101", H);
DistancesDistribution(H, c);
MinimumDistance(H, c);
-->
<ManSection Label="OuterDistribution">
<Func Name="OuterDistribution" Arg=" C "/>
<Description>
The function <C>OuterDistribution</C> returns a
list of length <M>q^n</M>, where
<M>q</M> is the size of the base field of <A>C</A> and <M>n</M>
is the word length. The elements of the list consist of pairs,
the first coordinate being an element of
<M>GF(q)^n</M> (this is a codeword type) and the
second coordinate being a distribution
of distances to the code (a list of integers).
This table is <E>very</E> large, and for
<M>n > 20</M> it will not fit
in the memory of most computers.
The function <C>DistancesDistribution</C>
(see
<Ref Func="DistancesDistribution" Style="Number"/>)
can be used to calculate one entry of the list.
</Description>
</ManSection>
<Example>
gap> C := RepetitionCode( 3, GF(2) );
a cyclic [3,1,3]1 repetition code over GF(2)
gap> OD := OuterDistribution(C);
[ [ [ 0 0 0 ], [ 1, 0, 0, 1 ] ], [ [ 1 1 1 ], [ 1, 0, 0, 1 ] ],
[ [ 0 0 1 ], [ 0, 1, 1, 0 ] ], [ [ 1 1 0 ], [ 0, 1, 1, 0 ] ],
[ [ 1 0 0 ], [ 0, 1, 1, 0 ] ], [ [ 0 1 1 ], [ 0, 1, 1, 0 ] ],
[ [ 0 1 0 ], [ 0, 1, 1, 0 ] ], [ [ 1 0 1 ], [ 0, 1, 1, 0 ] ] ]
gap> WeightDistribution(C) = OD[1][2];
true
gap> DistancesDistribution( C, Codeword("110") ) = OD[4][2];
true
</Example>
<!--
C := RepetitionCode( 3, GF(2) );
OD := OuterDistribution(C);
WeightDistribution(C) = OD[1][2];
DistancesDistribution( C, Codeword("110") ) = OD[4][2];
-->
</Section>
<Section>
<Heading>
Decoding Functions
</Heading>
<Label Name="Decoding Functions"/>
<ManSection Label="Decode">
<Func Name="Decode" Arg=" C r "/>
<Description>
<C>Decode</C> decodes <A>r</A> (a 'received word')
with respect to code <A>C</A> and returns the
`message word' (i.e., the information digits associated to
the codeword <M>c \in C</M> closest to <A>r</A>). Here
<A>r</A> can be a <Package>GUAVA</Package>
codeword or a list of codewords.
First, possible errors in <A>r</A> are corrected, then the
codeword is decoded to an <E>information codeword</E> <M>m</M>
(and not an element of <A>C</A>).
If the code record has a field `specialDecoder',
this special algorithm is used to decode
the vector. Hamming codes, BCH codes, cyclic codes,
and generalized Reed-Solomon have such a special algorithm.
(The algorithm used for BCH codes is the
Sugiyama algorithm described, for example, in
section 5.4.3 of <Cite Key="HP03"/>. A special decoder has
also being written for the generalized Reed-Solomon code
using the interpolation algorithm. For cyclic codes, the
error-trapping algorithm is used.)
If <A>C</A> is linear and no special decoder
field has been set then syndrome decoding is used.
Otherwise (when <A>C</A> is non-linear), the nearest neighbor decoding
algorithm is used (which is very slow).
<P/>
A special decoder can be created by defining a function
<Verb>
C!.SpecialDecoder := function(C, r) ... end;
</Verb>
The function uses the arguments <A>C</A> (the code
record itself) and <A>r</A> (a
vector of the codeword type) to decode <A>r</A> to an information
vector. A normal decoder would take a codeword <A>r</A> of the
same word length and field as <A>C</A>, and would return
an information vector of length <M>k</M>, the
dimension of <A>C</A>. The user is not restricted to these normal demands
though, and can for instance define a decoder for non-linear codes.
<P/>
Encoding is done by multiplying the
information vector with the code (see
<Ref Label="Operations for Codes" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C := HammingCode(3);
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> c := "1010"*C; # encoding
[ 1 0 1 1 0 1 0 ]
gap> Decode(C, c); # decoding
[ 1 0 1 0 ]
gap> Decode(C, Codeword("0010101"));
[ 1 1 0 1 ] # one error corrected
gap> C!.SpecialDecoder := function(C, c)
> return NullWord(Dimension(C));
> end;
function ( C, c ) ... end
gap> Decode(C, c);
[ 0 0 0 0 ] # new decoder always returns null word
</Example>
<!--
C := HammingCode(3);
c := "1010"*C; # encoding
Decode(C, c); # decoding
Decode(C, Codeword("0010101"));
C!.SpecialDecoder := function(C, c)
return NullWord(Dimension(C));
end;
Decode(C, c);
-->
<ManSection Label="Decodeword">
<Func Name="Decodeword" Arg=" C r "/>
<Description>
<C>Decodeword</C> decodes <A>r</A> (a 'received word')
with respect to code <A>C</A> and returns the
codeword <M>c \in C</M> closest to <A>r</A>. Here
<A>r</A> can be a <Package>GUAVA</Package>
codeword or a list of codewords.
If the code record has a field `specialDecoder',
this special algorithm is used to decode
the vector. Hamming codes, generalized Reed-Solomon codes,
and BCH codes have such a special algorithm.
(The algorithm used for BCH codes is the
Sugiyama algorithm described, for example, in
section 5.4.3 of <Cite Key="HP03"/>. The algorithm used for
generalized Reed-Solomon codes is the ``interpolation
algorithm'' described for example in chapter 5 of
<Cite Key="JH04"/>.)
If <A>C</A> is linear and no special decoder
field has been set then syndrome decoding is used.
Otherwise, when <A>C</A> is non-linear, the nearest neighbor algorithm has
been implemented (which should only be used for small-sized
codes).
</Description>
</ManSection>
<Example>
gap> C := HammingCode(3);
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> c := "1010"*C; # encoding
[ 1 0 1 1 0 1 0 ]
gap> Decodeword(C, c); # decoding
[ 1 0 1 1 0 1 0 ]
gap>
gap> R:=PolynomialRing(GF(11),["t"]);
GF(11)[t]
gap> P:=List([1,3,4,5,7],i->Z(11)^i);
[ Z(11), Z(11)^3, Z(11)^4, Z(11)^5, Z(11)^7 ]
gap> C:=GeneralizedReedSolomonCode(P,3,R);
a linear [5,3,1..3]2 generalized Reed-Solomon code over GF(11)
gap> MinimumDistance(C);
3
gap> c:=Random(C);
[ 0 9 6 2 1 ]
gap> v:=Codeword("09620");
[ 0 9 6 2 0 ]
gap> GeneralizedReedSolomonDecoderGao(C,v);
[ 0 9 6 2 1 ]
gap> Decodeword(C,v); # calls the special interpolation decoder
[ 0 9 6 2 1 ]
gap> G:=GeneratorMat(C);
[ [ Z(11)^0, 0*Z(11), 0*Z(11), Z(11)^8, Z(11)^9 ],
[ 0*Z(11), Z(11)^0, 0*Z(11), Z(11)^0, Z(11)^8 ],
[ 0*Z(11), 0*Z(11), Z(11)^0, Z(11)^3, Z(11)^8 ] ]
gap> C1:=GeneratorMatCode(G,GF(11));
a linear [5,3,1..3]2 code defined by generator matrix over GF(11)
gap> Decodeword(C,v); # calls syndrome decoding
[ 0 9 6 2 1 ]
</Example>
<!--
C := HammingCode(3);
c := "1010"*C; # encoding
Decodeword(C, c); # decoding
R:=PolynomialRing(GF(11),["t"]);
P:=List([1,3,4,5,7],i->Z(11)^i);
C:=GeneralizedReedSolomonCode(P,3,R);
#########a linear [5,3,1..3]2 generalized Reed-Solomon code over GF(11)
MinimumDistance(C);
c:=Random(C); ####### [ 0 9 6 2 1 ]
v:=Codeword("09620");
GeneralizedReedSolomonDecoderGao(C,v);
######## [ 0 9 6 2 1 ]
Decodeword(C,v);
######## [ 0 9 6 2 1 ]
Decodeword(C,v); time;
######## [ 0 9 6 2 1 ]
### 5
G:=GeneratorMat(C);
C1:=GeneratorMatCode(G,GF(11));
#########a linear [5,3,1..3]2 code defined by generator matrix over GF(11)
Decodeword(C,v); time;
######### [ 0 9 6 2 1 ]
######### 9
-->
<ManSection Label="GeneralizedReedSolomonDecoderGao">
<Func Name="GeneralizedReedSolomonDecoderGao" Arg=" C r "/>
<Description>
<C>GeneralizedReedSolomonDecoderGao</C> decodes <A>r</A> (a 'received word')
to a codeword <M>c \in C</M>
in a generalized Reed-Solomon code <A>C</A>
(see <Ref Func="GeneralizedReedSolomonCode" Style="Number"/>),
closest to <A>r</A>. Here
<A>r</A> must be a <Package>GUAVA</Package>
codeword.
If the code record does not have name
`generalized Reed-Solomon code' then an error is returned.
Otherwise, the Gao decoder <Cite Key="Gao03"/> is used
to compute <M>c</M>.
<P/>
For long codes, this method is faster in practice than the
interpolation method used in <C>Decodeword</C>.
</Description>
</ManSection>
<Example>
gap> R:=PolynomialRing(GF(11),["t"]);
GF(11)[t]
gap> P:=List([1,3,4,5,7],i->Z(11)^i);
[ Z(11), Z(11)^3, Z(11)^4, Z(11)^5, Z(11)^7 ]
gap> C:=GeneralizedReedSolomonCode(P,3,R);
a linear [5,3,1..3]2 generalized Reed-Solomon code over GF(11)
gap> MinimumDistance(C);
3
gap> c:=Random(C);
[ 0 9 6 2 1 ]
gap> v:=Codeword("09620");
[ 0 9 6 2 0 ]
gap> GeneralizedReedSolomonDecoderGao(C,v);
[ 0 9 6 2 1 ]
</Example>
<!--
R:=PolynomialRing(GF(11),["t"]);
P:=List([1,3,4,5,7],i->Z(11)^i);
C:=GeneralizedReedSolomonCode(P,3,R);
MinimumDistance(C);
c:=Random(C);
GeneralizedReedSolomonDecoderGao(C,v); time;
Decodeword(C,v); time;
R:=PolynomialRing(GF(71),["x"]);
P:=List([1..70],i->Z(71)^i);
C:=GeneralizedReedSolomonCode(P,3,R);
MinimumDistance(C);
c:=Random(C);
v:=ShallowCopy(c);;
v:=ShallowCopy(c);; for i in [1..30] do v[i]:=Zero(GF(71)); od;
v:=Codeword(v,C);
GeneralizedReedSolomonDecoderGao(C,v); time;
Decodeword(C,v); time;
R:=PolynomialRing(GF(2^8),["y"]);
P:=List([1..(2^8-1)],i->Z(2^8)^i);;
C:=GeneralizedReedSolomonCode(P,3,R);
#MinimumDistance(C); ## too time-consuming...it is MDS though
c:=Random(C);
v:=ShallowCopy(c);;
v:=ShallowCopy(c);; for i in [1..100] do v[i]:=Zero(GF(2^8)); od;
v:=Codeword(v,C);
GeneralizedReedSolomonDecoderGao(C,v); time;
Decodeword(C,v); time; #uses interpolation decoding...
-->
<ManSection Label="GeneralizedReedSolomonListDecoder">
<Func Name="GeneralizedReedSolomonListDecoder" Arg=" C r tau"/>
<Description>
<C>GeneralizedReedSolomonListDecoder</C> implements
Sudans list-decoding algorithm
(see section 12.1 of <Cite Key="JH04"/>) for ``low rate''
Reed-Solomon codes.
It returns the list of all codewords in C which are a distance
of at most <A>tau</A> from <A>r</A> (a 'received word').
<A>C</A> must be a generalized Reed-Solomon code <A>C</A>
(see <Ref Func="GeneralizedReedSolomonCode" Style="Number"/>) and
<A>r</A> must be a <Package>GUAVA</Package>
codeword.
</Description>
</ManSection>
<Example>
gap> F:=GF(16);
GF(2^4)
gap>
gap> a:=PrimitiveRoot(F);; b:=a^7;; b^4+b^3+1;
0*Z(2)
gap> Pts:=List([0..14],i->b^i);
[ Z(2)^0, Z(2^4)^7, Z(2^4)^14, Z(2^4)^6, Z(2^4)^13, Z(2^2), Z(2^4)^12, Z(2^4)^4,
Z(2^4)^11, Z(2^4)^3, Z(2^2)^2, Z(2^4)^2, Z(2^4)^9, Z(2^4), Z(2^4)^8 ]
gap> x:=X(F);;
gap> R1:=PolynomialRing(F,[x]);;
gap> vars:=IndeterminatesOfPolynomialRing(R1);;
gap> y:=X(F,vars);;
gap> R2:=PolynomialRing(F,[x,y]);;
gap> C:=GeneralizedReedSolomonCode(Pts,3,R1);
a linear [15,3,1..13]10..12 generalized Reed-Solomon code over GF(16)
gap> MinimumDistance(C); ## 6 error correcting
13
gap> z:=Zero(F);;
gap> r:=[z,z,z,z,z,z,z,z,b^6,b^2,b^5,b^14,b,b^7,b^11];;
gap> r:=Codeword(r);
[ 0 0 0 0 0 0 0 0 a^12 a^14 a^5 a^8 a^7 a^4 a^2 ]
gap> cs:=GeneralizedReedSolomonListDecoder(C,r,2); time;
[ [ 0 a^9 a^3 a^13 a^6 a^10 a^11 a a^12 a^14 a^5 a^8 a^7 a^4 a^2 ],
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] ]
250
gap> c1:=cs[1]; c1 in C;
[ 0 a^9 a^3 a^13 a^6 a^10 a^11 a a^12 a^14 a^5 a^8 a^7 a^4 a^2 ]
true
gap> c2:=cs[2]; c2 in C;
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]
true
gap> WeightCodeword(c1-r);
7
gap> WeightCodeword(c2-r);
7
</Example>
<!--
F:=GF(16);
a:=PrimitiveRoot(F);; b:=a^7; b^4+b^3+1; ## alpha in JH Ex 12.1.1
Pts:=List([0..14],i->b^i);
x:=X(F);;
R1:=PolynomialRing(F,[x]);;
vars:=IndeterminatesOfPolynomialRing(R1);;
y:=X(F,vars);;
R2:=PolynomialRing(F,[x,y]);;
C:=GeneralizedReedSolomonCode(Pts,3,R1); MinimumDistance(C);
z:=Zero(F);
r:=[z,z,z,z,z,z,z,z,b^6,b^2,b^5,b^14,b,b^7,b^11];;
r:=Codeword(r);
cs:=GeneralizedReedSolomonListDecoder(C,r,2); time;
c1:=cs[1]; c1 in C;
c2:=cs[2]; c2 in C;
WeightCodeword(c1-r);
WeightCodeword(c2-r);
-->
<ManSection Label="BitFlipDecoder">
<Func Name="BitFlipDecoder" Arg=" C r "/>
<Description>
The iterative decoding method
<C>BitFlipDecoder</C> must only be applied to LDPC codes.
For more information on LDPC codes, refer to Section
<Ref Label="LDPC" Style="Number"/>.
For these codes, <C>BitFlipDecoder</C> decodes very quickly.
(Warning: it can give wildly wrong results for arbitrary
binary linear codes.)
The bit flipping algorithm is described for example in Chapter 13 of
<Cite Key="JH04"/>.
</Description>
</ManSection>
<Example>
gap> C:=HammingCode(4,GF(2));
a linear [15,11,3]1 Hamming (4,2) code over GF(2)
gap> c:=Random(C);
[ 0 0 0 1 0 0 1 0 0 1 1 0 1 0 1 ]
gap> v:=List(c);
[ 0*Z(2), 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2), 0*Z(2),
Z(2)^0, Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0 ]
gap> v[1]:=Z(2)+v[1]; # flip 1st bit of c to create an error
Z(2)^0
gap> v:=Codeword(v);
[ 1 0 0 1 0 0 1 0 0 1 1 0 1 0 1 ]
gap> BitFlipDecoder(C,v);
[ 0 0 0 1 0 0 1 0 0 1 1 0 1 0 1 ]
</Example>
<!--
C:=HammingCode(4,GF(2));
c:=Random(C);
v:=List(c);
v[1]:=Z(2)+v[1]; # flip 1st bit of c to create an error
v:=Codeword(v);
BitFlipDecoder(C,v);
-->
<ManSection Label="NearestNeighborGRSDecodewords">
<Func Name="NearestNeighborGRSDecodewords" Arg=" C v dist"/>
<Description>
<C>NearestNeighborGRSDecodewords</C> finds all
generalized Reed-Solomon codewords within distance
<A>dist</A> from <A>v</A> <E>and</E> the associated polynomial,
using ``brute force''.
Input: <A>v</A> is a received vector (a <Package>GUAVA</Package> codeword),
<A>C</A> is a GRS code,
<A>dist</A> > 0 is the distance from <A>v</A> to search in <A>C</A>.
Output: a list of pairs <M>[c,f(x)]</M>, where <M>wt(c-v)\leq dist-1</M>
and <M>c = (f(x_1),...,f(x_n))</M>.
</Description>
</ManSection>
<Example>
gap> F:=GF(16);
GF(2^4)
gap> a:=PrimitiveRoot(F);; b:=a^7; b^4+b^3+1;
Z(2^4)^7
0*Z(2)
gap> Pts:=List([0..14],i->b^i);
[ Z(2)^0, Z(2^4)^7, Z(2^4)^14, Z(2^4)^6, Z(2^4)^13, Z(2^2), Z(2^4)^12,
Z(2^4)^4, Z(2^4)^11, Z(2^4)^3, Z(2^2)^2, Z(2^4)^2, Z(2^4)^9, Z(2^4),
Z(2^4)^8 ]
gap> x:=X(F);;
gap> R1:=PolynomialRing(F,[x]);;
gap> vars:=IndeterminatesOfPolynomialRing(R1);;
gap> y:=X(F,vars);;
gap> R2:=PolynomialRing(F,[x,y]);;
gap> C:=GeneralizedReedSolomonCode(Pts,3,R1);
a linear [15,3,1..13]10..12 generalized Reed-Solomon code over GF(16)
gap> MinimumDistance(C); # 6 error correcting
13
gap> z:=Zero(F);
0*Z(2)
gap> r:=[z,z,z,z,z,z,z,z,b^6,b^2,b^5,b^14,b,b^7,b^11];; # 7 errors
gap> r:=Codeword(r);
[ 0 0 0 0 0 0 0 0 a^12 a^14 a^5 a^8 a^7 a^4 a^2 ]
gap> cs:=NearestNeighborGRSDecodewords(C,r,7);
[ [ [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ], 0*Z(2) ],
[ [ 0 a^9 a^3 a^13 a^6 a^10 a^11 a a^12 a^14 a^5 a^8 a^7 a^4 a^2 ], x_1+Z(2)^0 ] ]
</Example>
<!--
F:=GF(16);
a:=PrimitiveRoot(F);; b:=a^7; b^4+b^3+1;
Pts:=List([0..14],i->b^i);
x:=X(F);;
R1:=PolynomialRing(F,[x]);;
vars:=IndeterminatesOfPolynomialRing(R1);;
y:=X(F,vars);;
R2:=PolynomialRing(F,[x,y]);;
C:=GeneralizedReedSolomonCode(Pts,3,R1);
MinimumDistance(C); # 6 error correcting
z:=Zero(F);
r:=[z,z,z,z,z,z,z,z,b^6,b^2,b^5,b^14,b,b^7,b^11];; # 7 errors
r:=Codeword(r);
cs:=NearestNeighborGRSDecodewords(C,r,7);
-->
<ManSection Label="NearestNeighborDecodewords">
<Func Name="NearestNeighborDecodewords" Arg=" C v dist"/>
<Description>
<C>NearestNeighborDecodewords</C> finds all
codewords in a linear code <A>C</A> within distance
<A>dist</A> from <A>v</A>, using ``brute force''.
Input: <A>v</A> is a received vector (a <Package>GUAVA</Package> codeword),
<A>C</A> is a linear code,
<A>dist</A> > 0 is the distance from <A>v</A> to search in <A>C</A>.
Output: a list of <M>c \in C</M>, where <M>wt(c-v)\leq dist-1</M>.
</Description>
</ManSection>
<Example>
gap> F:=GF(16);
GF(2^4)
gap> a:=PrimitiveRoot(F);; b:=a^7; b^4+b^3+1;
Z(2^4)^7
0*Z(2)
gap> Pts:=List([0..14],i->b^i);
[ Z(2)^0, Z(2^4)^7, Z(2^4)^14, Z(2^4)^6, Z(2^4)^13, Z(2^2), Z(2^4)^12,
Z(2^4)^4, Z(2^4)^11, Z(2^4)^3, Z(2^2)^2, Z(2^4)^2, Z(2^4)^9, Z(2^4),
Z(2^4)^8 ]
gap> x:=X(F);;
gap> R1:=PolynomialRing(F,[x]);;
gap> vars:=IndeterminatesOfPolynomialRing(R1);;
gap> y:=X(F,vars);;
gap> R2:=PolynomialRing(F,[x,y]);;
gap> C:=GeneralizedReedSolomonCode(Pts,3,R1);
a linear [15,3,1..13]10..12 generalized Reed-Solomon code over GF(16)
gap> MinimumDistance(C);
13
gap> z:=Zero(F);
0*Z(2)
gap> r:=[z,z,z,z,z,z,z,z,b^6,b^2,b^5,b^14,b,b^7,b^11];;
gap> r:=Codeword(r);
[ 0 0 0 0 0 0 0 0 a^12 a^14 a^5 a^8 a^7 a^4 a^2 ]
gap> cs:=NearestNeighborDecodewords(C,r,7);
[ [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ],
[ 0 a^9 a^3 a^13 a^6 a^10 a^11 a a^12 a^14 a^5 a^8 a^7 a^4 a^2 ] ]
</Example>
<!--
F:=GF(16);
a:=PrimitiveRoot(F);; b:=a^7; b^4+b^3+1;
Pts:=List([0..14],i->b^i);
x:=X(F);;
R1:=PolynomialRing(F,[x]);;
vars:=IndeterminatesOfPolynomialRing(R1);;
y:=X(F,vars);;
R2:=PolynomialRing(F,[x,y]);;
C:=GeneralizedReedSolomonCode(Pts,3,R1);
MinimumDistance(C);
z:=Zero(F);
r:=[z,z,z,z,z,z,z,z,b^6,b^2,b^5,b^14,b,b^7,b^11];;
r:=Codeword(r);
cs:=NearestNeighborDecodewords(C,r,7);
-->
<ManSection Label="Syndrome">
<Func Name="Syndrome" Arg=" C v "/>
<Description>
<C>Syndrome</C> returns the syndrome of word <A>v</A>
with respect to a linear code <A>C</A>. <A>v</A> is a codeword in the
ambient vector space of <A>C</A>. If <A>v</A> is an element of
<A>C</A>, the syndrome is a zero vector. The syndrome can be used for looking
up an error vector in the syndrome table (see
<Ref Func="SyndromeTable" Style="Number"/>) that is
needed to correct an error in <M>v</M>.
<P/>
A syndrome is not defined for non-linear codes.
<C>Syndrome</C> then returns an error.
</Description>
</ManSection>
<Example>
gap> C := HammingCode(4);
a linear [15,11,3]1 Hamming (4,2) code over GF(2)
gap> v := CodewordNr( C, 7 );
[ 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 ]
gap> Syndrome( C, v );
[ 0 0 0 0 ]
gap> Syndrome( C, Codeword( "000000001100111" ) );
[ 1 1 1 1 ]
gap> Syndrome( C, Codeword( "000000000000001" ) );
[ 1 1 1 1 ] # the same syndrome: both codewords are in the same
# coset of C
</Example>
<!--
C := HammingCode(4);
v := CodewordNr( C, 7 );
Syndrome( C, v );
Syndrome( C, Codeword( "000000001100111" ) );
Syndrome( C, Codeword( "000000000000001" ) );
-->
<ManSection Label="SyndromeTable">
<Func Name="SyndromeTable" Arg=" C "/>
<Description>
<C>SyndromeTable</C> returns a <E>syndrome table</E> of
a linear code <A>C</A>,
consisting of two columns. The first column consists of the error vectors
that correspond to the syndrome vectors in the second column. These
vectors both are of the codeword type. After calculating the syndrome of
a word <A>v</A> with <C>Syndrome</C> (see
<Ref Func="Syndrome" Style="Number"/>),
the error vector needed to
correct <A>v</A> can be found in the syndrome table. Subtracting this vector
from <A>v</A> yields an element of <A>C</A>.
To make the search for the syndrome as
fast as possible, the syndrome table is sorted according to the syndrome
vectors.
</Description>
</ManSection>
<Index>syndrome table</Index>
<Example>
gap> H := HammingCode(2);
a linear [3,1,3]1 Hamming (2,2) code over GF(2)
gap> SyndromeTable(H);
[ [ [ 0 0 0 ], [ 0 0 ] ], [ [ 1 0 0 ], [ 0 1 ] ],
[ [ 0 1 0 ], [ 1 0 ] ], [ [ 0 0 1 ], [ 1 1 ] ] ]
gap> c := Codeword("101");
[ 1 0 1 ]
gap> c in H;
false # c is not an element of H
gap> Syndrome(H,c);
[ 1 0 ] # according to the syndrome table,
# the error vector [ 0 1 0 ] belongs to this syndrome
gap> c - Codeword("010") in H;
true # so the corrected codeword is
# [ 1 0 1 ] - [ 0 1 0 ] = [ 1 1 1 ],
# this is an element of H
</Example>
<!--
H := HammingCode(2);
SyndromeTable(H);
c := Codeword("101");
c in H;
Syndrome(H,c);
c - Codeword("010") in H;
-->
<ManSection Label="StandardArray">
<Func Name="StandardArray" Arg=" C "/>
<Description>
<C>StandardArray</C> returns the standard array of a
code <A>C</A>. This is a matrix with elements of the codeword type.
It has <M>q^r</M> rows and <M>q^k</M> columns,
where <M>q</M> is the size of the base field of <A>C</A>,
<M>r=n-k</M> is the redundancy of <A>C</A>, and <M>k</M>
is the dimension of <A>C</A>. The first row contains all the
elements of <A>C</A>. Each other row contains words that do
not belong to the code, with in the first column their syndrome vector
(see
<Ref Func="Syndrome" Style="Number"/>).
<P/>
A non-linear code does not have a standard array.
<C>StandardArray</C> then returns an error.
<P/>
Note that calculating a standard array can be very time- and memory-
consuming.
</Description>
</ManSection>
<Example>
gap> StandardArray(RepetitionCode(3));
[ [ [ 0 0 0 ], [ 1 1 1 ] ], [ [ 0 0 1 ], [ 1 1 0 ] ],
[ [ 0 1 0 ], [ 1 0 1 ] ], [ [ 1 0 0 ], [ 0 1 1 ] ] ]
</Example>
<ManSection Label="PermutationDecode">
<Func Name="PermutationDecode" Arg=" C v "/>
<Description>
<C>PermutationDecode</C> performs permutation decoding when possible
and returns original vector and prints 'fail' when not possible.
<P/>
This uses <C>AutomorphismGroup</C> in the binary case, and
(the slower) <C>PermutationAutomorphismGroup</C> otherwise, to compute
the permutation automorphism group <M>P</M> of <A>C</A>.
The algorithm runs through the elements <M>p</M> of <M>P</M>
checking if the weight of <M>H(p\cdot v)</M>
is less than <M>(d-1)/2</M>. If it is then
the vector <M>p\cdot v</M> is used to decode <M>v</M>:
assuming <A>C</A> is in standard form then
<M>c=p^{-1}Em</M> is the decoded word, where <M>m</M>
is the information digits part of <M>p\cdot v</M>.
If no such <M>p</M> exists then ``fail'' is returned.
See, for example, section 10.2 of
Huffman and Pless <Cite Key="HP03"/> for more details.
</Description>
</ManSection>
<Example>
gap> C0:=HammingCode(3,GF(2));
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> G0:=GeneratorMat(C0);;
gap> G := List(G0, ShallowCopy);;
gap> PutStandardForm(G);
()
gap> Display(G);
1 . . . . 1 1
. 1 . . 1 . 1
. . 1 . 1 1 .
. . . 1 1 1 1
gap> H0:=CheckMat(C0);;
gap> Display(H0);
. . . 1 1 1 1
. 1 1 . . 1 1
1 . 1 . 1 . 1
gap> c0:=Random(C0);
[ 0 0 0 1 1 1 1 ]
gap> v01:=c0[1]+Z(2)^2;;
gap> v1:=List(c0, ShallowCopy);;
gap> v1[1]:=v01;;
gap> v1:=Codeword(v1);
[ 1 0 0 1 1 1 1 ]
gap> c1:=PermutationDecode(C0,v1);
[ 0 0 0 1 1 1 1 ]
gap> c1=c0;
true
</Example>
<!--
C0:=HammingCode(3,GF(2));
G0:=GeneratorMat(C0);;
G := List(G0, ShallowCopy);;
PutStandardForm(G);
Display(G);
H0:=CheckMat(C0);;
Display(H0);
c0:=Random(C0);
v01:=c0[1]+Z(2)^2;;
v1:=List(c0, ShallowCopy);;
v1[1]:=v01;;
v1:=Codeword(v1);
c1:=PermutationDecode(C0,v1);
c1=c0;
-->
<ManSection Label="PermutationDecodeNC">
<Func Name="PermutationDecodeNC" Arg=" C v P "/>
<Description>
Same as <C>PermutationDecode</C> except that one may enter
the permutation automorphism group <A>P</A> in as an
argument, saving time.
Here <A>P</A> is a subgroup of the
symmetric group on <M>n</M> letters,
where <M>n</M> is the word length of <A>C</A>.
</Description>
</ManSection>
</Section>
</Chapter>
<Chapter>
<Heading>Generating Codes</Heading>
<Label Name="Generating Codes"/>
In this chapter we describe functions for generating codes.
<P/>
Section
<Ref Label="Generating Unrestricted Codes" Style="Number"/>
describes functions for generating unrestricted codes.
<P/>
Section
<Ref Label="Generating Linear Codes" Style="Number"/>
describes functions for generating linear
codes.
<P/>
Section
<Ref Label="Gabidulin Codes" Style="Number"/>
describes functions for constructing certain
covering codes, such as the Gabidulin codes.
<P/>
Section
<Ref Label="Golay Codes" Style="Number"/>
describes functions for constructing the Golay codes.
<P/>
Section
<Ref Label="Generating Cyclic Codes" Style="Number"/>
describes functions for generating cyclic codes.
<P/>
Section
<Ref Label="Evaluation Codes" Style="Number"/>
describes functions for generating codes as the image
of an evaluation map applied to a space of functions.
For example, generalized Reed-Solomon codes and toric codes
are described there.
<P/>
Section
<Ref Label="Algebraic geometric codes" Style="Number"/>
describes functions for generating algebraic geometry codes.
<P/>
Section
<Ref Label="LDPC" Style="Number"/>
describes functions for constructing low-density parity-check (LDPC)
codes.
<Section>
<Heading>
Generating Unrestricted Codes
</Heading>
<Label Name="Generating Unrestricted Codes"/>
In this section we start with functions that creating code from user
defined matrices or special matrices (see
<Ref Func="ElementsCode" Style="Number"/>,
<Ref Func="HadamardCode" Style="Number"/>,
<Ref Func="ConferenceCode" Style="Number"/> and
<Ref Func="MOLSCode" Style="Number"/>). These codes are
unrestricted codes; they may later be discovered to be linear or cyclic.
<P/>
The next functions generate random codes (see
<Ref Func="RandomCode" Style="Number"/>) and the
Nordstrom-Robinson code (see
<Ref Func="NordstromRobinsonCode" Style="Number"/>), respectively.
<P/>
Finally, we describe two functions for generating Greedy codes. These are
codes that contructed by gathering codewords from a space (see
<Ref Func="GreedyCode" Style="Number"/> and
<Ref Func="LexiCode" Style="Number"/>).
<ManSection Label="ElementsCode">
<Func Name="ElementsCode" Arg=" L [name] F "/>
<Description>
<C>ElementsCode</C> creates an unrestricted code of the
list of elements <A>L</A>, in the field <A>F</A>.
<A>L</A> must be a list of vectors, strings, polynomials or
codewords. <A>name</A> can contain a short description of the code.
<P/>
If <A>L</A> contains a codeword more than once, it is removed from the list
and a GAP set is returned.
</Description>
</ManSection>
<Example>
gap> M := Z(3)^0 * [ [1, 0, 1, 1], [2, 2, 0, 0], [0, 1, 2, 2] ];;
gap> C := ElementsCode( M, "example code", GF(3) );
a (4,3,1..4)2 example code over GF(3)
gap> MinimumDistance( C );
4
gap> AsSSortedList( C );
[ [ 0 1 2 2 ], [ 1 0 1 1 ], [ 2 2 0 0 ] ]
</Example>
<!--
M := Z(3)^0 * [ [1, 0, 1, 1], [2, 2, 0, 0], [0, 1, 2, 2] ];;
C := ElementsCode( M, "example code", GF(3) );
MinimumDistance( C );
AsSSortedList( C );
-->
<Index>
code, Hadamard
</Index>
<ManSection Label="HadamardCode">
<Func Name="HadamardCode" Arg=" H [t] "/>
<Description>
The four forms this command can take are
<C>HadamardCode(H,t)</C>, <C>HadamardCode(H)</C>,
<C>HadamardCode(n,t)</C>, and <C>HadamardCode(n)</C>.
<P/>
In the case when the arguments <A>H</A> and <A>t</A> are both given,
<C>HadamardCode</C> returns a Hadamard code
of the <M>t^{th}</M> kind from the Hadamard matrix <A>H</A>
In case only <A>H</A> is given, <M>t = 3</M> is used.
<P/>
By definition, a Hadamard matrix is a square matrix <A>H</A> with
<M>H\cdot H^T = -n\cdot I_n</M>, where <M>n</M> is the size of
<A>H</A>. The entries of <A>H</A> are either 1 or -1.
<Index>Hadamard matrix</Index>
<P/>
The matrix <A>H</A> is first transformed into a binary matrix
<M>A_n</M> by replacing the <M>1</M>'s by <M>0</M>'s and
the <M>-1</M>'s by <M>1</M>s).
<P/>
The Hadamard matrix of the <E>first kind</E> (<M>t=1</M>) is
created by using the rows of <M>A_n</M> as elements,
after deleting the first column. This is a
<M>(n-1, n, n/2)</M> code. We use this code for creating the
Hadamard code of the <E>second kind</E> (<M>t=2</M>), by
adding all the complements of the already existing codewords. This
results in a <M>(n-1, 2n, n/2 -1)</M> code.
The <E>third kind</E> (<M>t=3</M>) is created
by using the rows of <M>A_n</M> (without cutting a column) and their
complements as elements. This way, we have an
<M>(n, 2n, n/2)</M>-code. The
returned code is generally an unrestricted code, but for <M>n = 2^r</M>,
the code is linear.
<P/>
The command <C>HadamardCode(n,t)</C> returns a Hadamard code with parameter
<A>n</A> of the <M>t^{th}</M> kind. For the
command <C>HadamardCode(n)</C>, <M>t=3</M> is used.
<P/>
When called in these forms, <C>HadamardCode</C> first creates a Hadamard
matrix (see <Ref Func="HadamardMat" Style="Number"/>), of size
<A>n</A> and then follows the same
procedure as described above. Therefore the same restrictions with
respect to <A>n</A> as for Hadamard matrices hold.
</Description>
</ManSection>
<Example>
gap> H4 := [[1,1,1,1],[1,-1,1,-1],[1,1,-1,-1],[1,-1,-1,1]];;
gap> HadamardCode( H4, 1 );
a (3,4,2)1 Hadamard code of order 4 over GF(2)
gap> HadamardCode( H4, 2 );
a (3,8,1)0 Hadamard code of order 4 over GF(2)
gap> HadamardCode( H4 );
a (4,8,2)1 Hadamard code of order 4 over GF(2)
gap> H4 := [[1,1,1,1],[1,-1,1,-1],[1,1,-1,-1],[1,-1,-1,1]];;
gap> C := HadamardCode( 4 );
a (4,8,2)1 Hadamard code of order 4 over GF(2)
gap> C = HadamardCode( H4 );
true
</Example>
<!--
H4 := [[1,1,1,1],[1,-1,1,-1],[1,1,-1,-1],[1,-1,-1,1]];;
HadamardCode( H4, 1 );
HadamardCode( H4, 2 );
HadamardCode( H4 );
H4 := [[1,1,1,1],[1,-1,1,-1],[1,1,-1,-1],[1,-1,-1,1]];;
C := HadamardCode( 4 );
C = HadamardCode( H4 );
-->
<Index>
code, conference
</Index>
<ManSection Label="ConferenceCode">
<Func Name="ConferenceCode" Arg=" H "/>
<Description>
<C>ConferenceCode</C> returns a code of length <M>n-1</M> constructed from a
symmetric 'conference matrix' <A>H</A>. A <E>conference matrix</E>
<A>H</A> is a symmetric matrix of
order <M>n</M>, which satisfies <M>H\cdot H^T = ((n-1)\cdot I</M>, with
<M>n \equiv 2 \pmod 4</M>. The rows of <M>\frac{1}{2}(H+I+J)</M>,
<M>\frac{1}{2}(-H+I+J)</M>, plus the zero and all-ones vectors
form the elements of a binary non-linear <M>(n-1, 2n, (n-2)/2)</M>
code.
<Index>conference matrix</Index>
<P/>
<Package>GUAVA</Package> constructs a symmetric conference
matrix of order <M>n+1</M> (<M>n\equiv 1 \pmod 4</M>) and uses
the rows of that matrix, plus the zero and
all-ones vectors, to construct a binary non-linear
<M>(n, 2(n+1), (n-1)/2)</M>-code.
</Description>
</ManSection>
<Example>
gap> H6 := [[0,1,1,1,1,1],[1,0,1,-1,-1,1],[1,1,0,1,-1,-1],
> [1,-1,1,0,1,-1],[1,-1,-1,1,0,1],[1,1,-1,-1,1,0]];;
gap> C1 := ConferenceCode( H6 );
a (5,12,2)1..4 conference code over GF(2)
gap> IsLinearCode( C1 );
false
gap> C2 := ConferenceCode( 5 );
a (5,12,2)1..4 conference code over GF(2)
gap> AsSSortedList( C2 );
[ [ 0 0 0 0 0 ], [ 0 0 1 1 1 ], [ 0 1 0 1 1 ], [ 0 1 1 0 1 ], [ 0 1 1 1 0 ],
[ 1 0 0 1 1 ], [ 1 0 1 0 1 ], [ 1 0 1 1 0 ], [ 1 1 0 0 1 ], [ 1 1 0 1 0 ],
[ 1 1 1 0 0 ], [ 1 1 1 1 1 ] ]
</Example>
<!--
H6 := [[0,1,1,1,1,1],[1,0,1,-1,-1,1],[1,1,0,1,-1,-1],
[1,-1,1,0,1,-1],[1,-1,-1,1,0,1],[1,1,-1,-1,1,0]];;
C1 := ConferenceCode( H6 );
IsLinearCode( C1 );
C2 := ConferenceCode( 5 );
AsSSortedList( C2 );
-->
<ManSection Label="MOLSCode">
<Func Name="MOLSCode" Arg=" [n] q "/>
<Description>
<C>MOLSCode</C> returns an <M>(n, q^2, n-1)</M> code over <M>GF(q)</M>.
The code is created from <M>n-2</M> 'Mutually Orthogonal Latin Squares'
(MOLS) of size <M>q \times q</M>. The default for <A>n</A> is <M>4</M>.
<Package>GUAVA</Package> can construct a MOLS code for
<M>n-2 \leq q</M>. Here <A>q</A> must be a prime power, <M>q > 2</M>.
If there are no <M>n-2</M> MOLS, an error is signalled.
<P/>
Since each of the <M>n-2</M> MOLS is a <M>q\times q</M> matrix, we can create a code
of size <M>q^2</M> by listing in each code element the entries that are in the
same position in each of the MOLS. We precede each of these lists with
the two coordinates that specify this position, making the word length
become <M>n</M>.
<P/>
The MOLS codes are MDS codes (see <Ref Func="IsMDSCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C1 := MOLSCode( 6, 5 );
a (6,25,5)3..4 code generated by 4 MOLS of order 5 over GF(5)
gap> mols := List( [1 .. WordLength(C1) - 2 ], function( nr )
> local ls, el;
> ls := NullMat( Size(LeftActingDomain(C1)), Size(LeftActingDomain(C1)) );
> for el in VectorCodeword( AsSSortedList( C1 ) ) do
> ls[IntFFE(el[1])+1][IntFFE(el[2])+1] := el[nr + 2];
> od;
> return ls;
> end );;
gap> AreMOLS( mols );
true
gap> C2 := MOLSCode( 11 );
a (4,121,3)2 code generated by 2 MOLS of order 11 over GF(11)
</Example>
<!--
C1 := MOLSCode( 6, 5 );
mols := List( [1 .. WordLength(C1) - 2 ], function( nr )
local ls, el;
ls := NullMat( Size(LeftActingDomain(C1)), Size(LeftActingDomain(C1)) );
for el in VectorCodeword( AsSSortedList( C1 ) ) do
ls[IntFFE(el[1])+1][IntFFE(el[2])+1] := el[nr + 2];
od;
return ls;
end );;
AreMOLS( mols );
C2 := MOLSCode( 11 );
-->
<ManSection Label="RandomCode">
<Func Name="RandomCode" Arg=" n M F "/>
<Description>
<C>RandomCode</C> returns a random unrestricted code of size
<A>M</A> with word length <A>n</A> over <A>F</A>. <A>M</A> must be
less than or equal to the number of elements in the space <M>GF(q)^n</M>.
<P/>
The function <C>RandomLinearCode</C> returns a random linear code (see
<Ref Func="RandomLinearCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C1 := RandomCode( 6, 10, GF(8) );
a (6,10,1..6)4..6 random unrestricted code over GF(8)
gap> MinimumDistance(C1);
3
gap> C2 := RandomCode( 6, 10, GF(8) );
a (6,10,1..6)4..6 random unrestricted code over GF(8)
gap> C1 = C2;
false
</Example>
<Index>
code, Nordstrom-Robinson
</Index>
<ManSection Label="NordstromRobinsonCode">
<Func Name="NordstromRobinsonCode" Arg=" "/>
<Description>
<C>NordstromRobinsonCode</C> returns a Nordstrom-Robinson code,
the best code with word length <M>n=16</M> and minimum distance
<M>d=6</M> over <M>GF(2)</M>. This is a non-linear <M>(16, 256, 6)</M>
code.
</Description>
</ManSection>
<Example>
gap> C := NordstromRobinsonCode();
a (16,256,6)4 Nordstrom-Robinson code over GF(2)
gap> OptimalityCode( C );
0
</Example>
<Index>
code, greedy
</Index>
<ManSection Label="GreedyCode">
<Func Name="GreedyCode" Arg=" L d F "/>
<Description>
<C>GreedyCode</C> returns a Greedy code with design distance
<A>d</A> over the finite field <A>F</A>. The
code is constructed using the greedy algorithm on the list of vectors
<A>L</A>. (The greedy algorithm checks each vector in <A>L</A> and
adds it to the code if its distance to the current
code is greater than or equal to <A>d</A>. It is
obvious that the resulting code has a minimum distance of
at least <A>d</A>.
<P/>
Greedy codes are often linear codes.
<P/>
The function <C>LexiCode</C> creates a greedy code from a basis instead of an
enumerated list (see <Ref Func="LexiCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C1 := GreedyCode( Tuples( AsSSortedList( GF(2) ), 5 ), 3, GF(2) );
a (5,4,3..5)2 Greedy code, user defined basis over GF(2)
gap> C2 := GreedyCode( Permuted( Tuples( AsSSortedList( GF(2) ), 5 ),
> (1,4) ), 3, GF(2) );
a (5,4,3..5)2 Greedy code, user defined basis over GF(2)
gap> C1 = C2;
false
</Example>
<!--
C1 := GreedyCode( Tuples( AsSSortedList( GF(2) ), 5 ), 3, GF(2) );
C2 := GreedyCode( Permuted(Tuples(AsSSortedList(GF(2)),5), (1,4)), 3, GF(2) );
C1 = C2;
-->
<ManSection Label="LexiCode">
<Func Name="LexiCode" Arg=" n d F "/>
<Description>
In this format, <C>Lexicode</C> returns a lexicode with word length
<A>n</A>, design distance <A>d</A> over <A>F</A>.
The code is constructed using the greedy algorithm on the
lexicographically ordered list of all vectors of length
<A>n</A> over <A>F</A>. Every time a vector is found that has a distance
to the current code of at least <A>d</A>, it is added to the
code. This results, obviously, in a code with minimum distance
greater than or equal to <A>d</A>.
<P/>
Another syntax which one can use is <C>LexiCode( B, d, F )</C>.
When called in this format, <C>LexiCode</C> uses the basis <A>B</A>
instead of the standard basis. <A>B</A> is a matrix of vectors
over <A>F</A>. The code is constructed using the greedy
algorithm on the list of vectors spanned by
<A>B</A>, ordered lexicographically with respect to <A>B</A>.
<P/>
Note that binary lexicodes are always linear.
</Description>
</ManSection>
<Example>
gap> C := LexiCode( 4, 3, GF(5) );
a (4,17,3..4)2..4 lexicode over GF(5)
gap> B := [ [Z(2)^0, 0*Z(2), 0*Z(2)], [Z(2)^0, Z(2)^0, 0*Z(2)] ];;
gap> C := LexiCode( B, 2, GF(2) );
a linear [3,1,2]1..2 lexicode over GF(2)
</Example>
The function <C>GreedyCode</C> creates a greedy code that is not restricted to
a lexicographical order (see <Ref Func="GreedyCode" Style="Number"/>).
</Section>
<Section>
<Heading>
Generating Linear Codes
</Heading>
<Label Name="Generating Linear Codes"/>
In this section we describe functions for constructing linear codes. A
linear code always has a generator or check matrix.
<P/>
The first two functions generate linear codes from the generator matrix
(<Ref Func="GeneratorMatCode" Style="Number"/>) or check matrix
(<Ref Func="CheckMatCode" Style="Number"/>). All linear codes
can be constructed with these functions.
<P/>
The next functions we describe generate some well-known codes, like
Hamming codes (<Ref Func="HammingCode" Style="Number"/>),
Reed-Muller codes (<Ref Func="ReedMullerCode" Style="Number"/>)
and the extended Golay codes
(<Ref Func="ExtendedBinaryGolayCode" Style="Number"/> and
<Ref Func="ExtendedTernaryGolayCode" Style="Number"/>).
<P/>
A large and powerful family of codes are alternant codes. They are
obtained by a small modification of the parity check matrix of a BCH code
(see <Ref Func="AlternantCode" Style="Number"/>,
<Ref Func="GoppaCode" Style="Number"/>,
<Ref Func="GeneralizedSrivastavaCode" Style="Number"/> and
<Ref Func="SrivastavaCode" Style="Number"/>).
<P/>
Finally, we describe a function for generating random linear codes (see
<Ref Func="RandomLinearCode" Style="Number"/>).
<P/>
<ManSection Label="GeneratorMatCode">
<Func Name="GeneratorMatCode" Arg=" G [name] F "/>
<Description>
<C>GeneratorMatCode</C> returns a linear code with generator matrix
<A>G</A>. <A>G</A> must be a matrix over finite field <A>F</A>.
<A>name</A> can contain a short description of the code.
The generator matrix is the basis of the
elements of the code. The resulting code has word length
<M>n</M>, dimension <M>k</M> if <A>G</A> is a <M>k \times n</M>-matrix.
If <M>GF(q)</M> is the field of the code, the
size of the code will be <M>q^k</M>.
<P/>
If the generator matrix does not have full row rank, the linearly
dependent rows are removed. This is done by the GAP
function <C>BaseMat</C> and results in an equal code.
The generator matrix can be retrieved with the function
<C>GeneratorMat</C> (see <Ref Func="GeneratorMat" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> G := Z(3)^0 * [[1,0,1,2,0],[0,1,2,1,1],[0,0,1,2,1]];;
gap> C1 := GeneratorMatCode( G, GF(3) );
a linear [5,3,1..2]1..2 code defined by generator matrix over GF(3)
gap> C2 := GeneratorMatCode( IdentityMat( 5, GF(2) ), GF(2) );
a linear [5,5,1]0 code defined by generator matrix over GF(2)
gap> GeneratorMatCode( List( AsSSortedList( NordstromRobinsonCode() ),
> x -> VectorCodeword( x ) ), GF( 2 ) );
a linear [16,11,1..4]2 code defined by generator matrix over GF(2)
# This is the smallest linear code that contains the N-R code
</Example>
<!--
G := Z(3)^0 * [[1,0,1,2,0],[0,1,2,1,1],[0,0,1,2,1]];;
C1 := GeneratorMatCode( G, GF(3) );
C2 := GeneratorMatCode( IdentityMat( 5, GF(2) ), GF(2) );
GeneratorMatCode(List(AsSSortedList(NordstromRobinsonCode()),x ->VectorCodeword(x)),GF(2));
-->
<ManSection Label="CheckMatCodeMutable">
<Func Name="CheckMatCodeMutable" Arg=" H [name] F "/>
<Description>
<C>CheckMatCodeMutable</C> is the same as
<C>CheckMatCode</C> except that the check matrix and generator
matrix are mutable.
</Description>
</ManSection>
<ManSection Label="CheckMatCode">
<Func Name="CheckMatCode" Arg=" H [name] F "/>
<Description>
<C>CheckMatCode</C> returns a linear code with check matrix
<A>H</A>. <A>H</A> must be a matrix over Galois field <A>F</A>.
<A>[name.</A> can contain a short description of
the code. The parity check matrix is the transposed of the nullmatrix of
the generator matrix of the code. Therefore,
<M>c\cdot H^T = 0</M> where <M>c</M> is an element of the code.
If <A>H</A> is a <M>r\times n</M>-matrix, the code has word
length <M>n</M>, redundancy <M>r</M> and dimension <M>n-r</M>.
<P/>
If the check matrix does not have full row rank, the linearly dependent
rows are removed. This is done by the GAP function <C>BaseMat</C>.
and results in an equal code. The check matrix can be retrieved with the
function
<C>CheckMat</C> (see <Ref Func="CheckMat" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> G := Z(3)^0 * [[1,0,1,2,0],[0,1,2,1,1],[0,0,1,2,1]];;
gap> C1 := CheckMatCode( G, GF(3) );
a linear [5,2,1..2]2..3 code defined by check matrix over GF(3)
gap> CheckMat(C1);
[ [ Z(3)^0, 0*Z(3), Z(3)^0, Z(3), 0*Z(3) ],
[ 0*Z(3), Z(3)^0, Z(3), Z(3)^0, Z(3)^0 ],
[ 0*Z(3), 0*Z(3), Z(3)^0, Z(3), Z(3)^0 ] ]
gap> C2 := CheckMatCode( IdentityMat( 5, GF(2) ), GF(2) );
a cyclic [5,0,5]5 code defined by check matrix over GF(2)
</Example>
<!--
G := Z(3)^0 * [[1,0,1,2,0],[0,1,2,1,1],[0,0,1,2,1]];;
C1 := CheckMatCode( G, GF(3) );
CheckMat(C1);
C2 := CheckMatCode( IdentityMat( 5, GF(2) ), GF(2) );
-->
<Index>
code, Hamming
</Index>
<ManSection Label="HammingCode">
<Func Name="HammingCode" Arg=" r F "/>
<Description>
<C>HammingCode</C> returns a Hamming code with redundancy
<A>r</A> over <A>F</A>. A Hamming code is a single-error-correcting
code. The parity check matrix of a Hamming code has all nonzero vectors
of length <A>r</A> in its columns,
except for a multiplication factor. The decoding algorithm of the Hamming
code (see <Ref Func="Decode" Style="Number"/>) makes use of this property.
<P/>
If <M>q</M> is the size of its field <A>F</A>, the returned
Hamming code is a linear <M>[(q^r-1)/(q-1), (q^r-1)/(q-1) - r, 3]</M> code.
</Description>
</ManSection>
<Example>
gap> C1 := HammingCode( 4, GF(2) );
a linear [15,11,3]1 Hamming (4,2) code over GF(2)
gap> C2 := HammingCode( 3, GF(9) );
a linear [91,88,3]1 Hamming (3,9) code over GF(9)
</Example>
<!--
C1 := HammingCode( 4, GF(2) );
C2 := HammingCode( 3, GF(9) );
-->
<Index>
code, Reed-Muller
</Index>
<ManSection Label="ReedMullerCode">
<Func Name="ReedMullerCode" Arg=" r k "/>
<Description>
<C>ReedMullerCode</C> returns a binary 'Reed-Muller code'
<A>R(r, k)</A> with dimension <A>k</A> and order <A>r</A>.
This is a code with length <M>2^k</M> and
minimum distance <M>2^{k-r}</M> (see for example,
section 1.10 in <Cite Key="HP03"/>). By definition, the <M>r^{th}</M>
order binary Reed-Muller code of length <M>n=2^m</M>, for
<M>0 \leq r \leq m</M>, is the set of all vectors <M>f</M>, where
<M>f</M> is a Boolean function which is a polynomial of degree
at most <M>r</M>.
</Description>
</ManSection>
<Example>
gap> ReedMullerCode( 1, 3 );
a linear [8,4,4]2 Reed-Muller (1,3) code over GF(2)
</Example>
<!--
ReedMullerCode( 1, 3 );
############# insert more examples #############
-->
See <Ref Func="GeneralizedReedMullerCode" Style="Number"/>
for a more general construction.
<Index>
code, alternant
</Index>
<ManSection Label="AlternantCode">
<Func Name="AlternantCode" Arg=" r Y [alpha] F "/>
<Description>
<C>AlternantCode</C> returns an 'alternant code',
with parameters <A>r</A>, <A>Y</A> and
<A>alpha</A> (optional). <A>F</A> denotes the (finite) base field.
Here, <A>r</A> is the design redundancy of the code. <A>Y</A> and
<A>alpha</A> are both vectors of length <A>n</A> from which
the parity check matrix is constructed.
The check matrix has the form <M>H=([a_i^j y_i])</M>,
where <M>0 \leq j\leq r-1</M>, <M>1 \leq i\leq n</M>,
and where <M>[...]</M>
is as in <Ref Func="VerticalConversionFieldMat" Style="Number"/>).
If no <A>alpha</A> is specified, the vector
<M>[1, a, a^2, .., a^{n-1}]</M> is used,
where <M>a</M> is a primitive element of a Galois field <A>F</A>.
</Description>
</ManSection>
<Example>
gap> Y := [ 1, 1, 1, 1, 1, 1, 1];; a := PrimitiveUnityRoot( 2, 7 );;
gap> alpha := List( [0..6], i -> a^i );;
gap> C := AlternantCode( 2, Y, alpha, GF(8) );
a linear [7,3,3..4]3..4 alternant code over GF(8)
</Example>
<!--
Y := [ 1, 1, 1, 1, 1, 1, 1];; a := PrimitiveUnityRoot( 2, 7 );;
alpha := List( [0..6], i -> a^i );;
C := AlternantCode( 2, Y, alpha, GF(8) );
-->
<Index>
code, Goppa (classical)
</Index>
<ManSection Label="GoppaCode">
<Func Name="GoppaCode" Arg=" G L "/>
<Description>
<C>GoppaCode</C> returns a Goppa code <A>C</A> from Goppa polynomial
<A>g</A>, having coefficients in a Galois Field <M>GF(q)</M>.
<A>L</A> must be a list of elements in <M>GF(q)</M>,
that are not roots of <A>g</A>. The word length of the code is
equal to the length of <A>L</A>. The parity check matrix has the
form <M>H=([a_i^j / G(a_i)])_{0 \leq j \leq deg(g)-1,\ a_i \in L}</M>,
where <M>a_i\in L</M>
and <M>[...]</M> is as in
<Ref Func="VerticalConversionFieldMat" Style="Number"/>,
so <M>H</M> has entries in <M>GF(q)</M>, <M>q=p^m</M>.
It is known that <M>d(C)\geq deg(g)+1</M>, with a better
bound in the binary case provided <M>g</M> has no
multiple roots. See Huffman and Pless
<Cite Key="HP03"/> section 13.2.2, and
MacWilliams and Sloane <Cite Key="MS83"/> section 12.3,
for more details.
<P/>
One can also call <C>GoppaCode</C> using the syntax
<C>GoppaCode(g,n)</C>.
When called with parameter <A>n</A>,
<Package>GUAVA</Package> constructs a list <M>L</M> of length
<A>n</A>, such that no element of <A>L</A> is a root of <A>g</A>.
<P/>
This is a special case of an alternant code.
</Description>
</ManSection>
<Example>
gap> x:=Indeterminate(GF(8),"x");
x
gap> L:=Elements(GF(8));
[ 0*Z(2), Z(2)^0, Z(2^3), Z(2^3)^2, Z(2^3)^3, Z(2^3)^4, Z(2^3)^5, Z(2^3)^6 ]
gap> g:=x^2+x+1;
x^2+x+Z(2)^0
gap> C:=GoppaCode(g,L);
a linear [8,2,5]3 Goppa code over GF(2)
gap> xx := Indeterminate( GF(2), "xx" );;
gap> gg := xx^2 + xx + 1;; L := AsSSortedList( GF(8) );;
gap> C1 := GoppaCode( gg, L );
a linear [8,2,5]3 Goppa code over GF(2)
gap> y := Indeterminate( GF(2), "y" );;
gap> h := y^2 + y + 1;;
gap> C2 := GoppaCode( h, 8 );
a linear [8,2,5]3 Goppa code over GF(2)
gap> C1=C2;
true
gap> C=C1;
true
</Example>
<!--
x:=Indeterminate(GF(8),"x");
L:=Elements(GF(8));
g:=x^2+x+1;
C:=GoppaCode(g,L);
xx := Indeterminate( GF(2), "xx" );;
gg := xx^2 + xx + 1;; L := AsSSortedList( GF( 8) );;
C1 := GoppaCode( gg, L );
y := Indeterminate( GF(2), "y" );;
h := y^2 + y + 1;;
C2 := GoppaCode( h, 8 );
C1=C2;
C=C1;
-->
<Index>
code, Srivastava
</Index>
<ManSection Label="GeneralizedSrivastavaCode">
<Func Name="GeneralizedSrivastavaCode" Arg=" a w z [t] F "/>
<Description>
<C>GeneralizedSrivastavaCode</C> returns a generalized Srivastava
code with parameters <A>a</A>, <A>w</A>, <A>z</A>,
<A>t</A>. <M>a =\{ a_1, ..., a_n\}</M> and
<M>w =\{ w_1, ..., w_s\}</M> are lists of <M>n+s</M>
distinct elements of <M>F=GF(q^m)</M>,
<M>z</M> is a list of length <M>n</M> of nonzero elements
of <M>GF(q^m)</M>. The parameter <A>t</A>
determines the designed distance: <M>d \geq st + 1</M>.
The check matrix of this code is the form
<Display>
H=([\frac{z_i}{(a_i - w_j)^k}]),
</Display>
<M>1\leq k\leq t</M>, where
<M>[...]</M> is as in
<Ref Func="VerticalConversionFieldMat" Style="Number"/>.
We use this definition of <M>H</M> to define the code.
The default for <A>t</A> is 1.
The original Srivastava codes (see
<Ref Func="SrivastavaCode" Style="Number"/>) are a
special case <M>t=1</M>, <M>z_i=a_i^\mu</M>, for some
<M>\mu</M>.
</Description>
</ManSection>
<Example>
gap> a := Filtered( AsSSortedList( GF(2^6) ), e -> e in GF(2^3) );;
gap> w := [ Z(2^6) ];; z := List( [1..8], e -> 1 );;
gap> C := GeneralizedSrivastavaCode( a, w, z, 1, GF(64) );
a linear [8,2,2..5]3..4 generalized Srivastava code over GF(2)
</Example>
<!--
a := Filtered( AsSSortedList( GF(2^6) ), e -> e in GF(2^3) );;
w := [ Z(2^6) ];; z := List( [1..8], e -> 1 );;
C := GeneralizedSrivastavaCode( a, w, z, 1, GF(64) );
-->
<ManSection Label="SrivastavaCode">
<Func Name="SrivastavaCode" Arg=" a w [mu] F "/>
<Description>
<M>SrivastavaCode</M> returns a Srivastava code with parameters
<A>a</A>, <A>w</A> (and optionally <A>mu</A>).
<M>a =\{ a_1, ..., a_n\}</M> and
<M>w =\{ w_1, ..., w_s\}</M> are lists of <M>n+s</M>
distinct elements of <M>F=GF(q^m)</M>.
The default for <A>mu</A> is 1. The
Srivastava code is a generalized Srivastava code,
in which <M>z_i = a_i^{mu}</M> for some <A>mu</A>
and <M>t=1</M>.
<P/>
J. N. Srivastava introduced this code in 1967,
though his work was not published.
See Helgert <Cite Key="He72"/> for more details on the
properties of this code.
Related reference:
G. Roelofsen,
<B>On Goppa and Generalized Srivastava Codes</B>
PhD thesis, Dept. Math. and Comp. Sci., Eindhoven Univ. of
Technology, the Netherlands, 1982.
<!--
H. J. Helgert. <E>Noncyclic generalizations of BCH and Srivastava codes</E>.
<B>Information and Control</B>, 21(3):280-290, October 1972.
-->
</Description>
</ManSection>
<Example>
gap> a := AsSSortedList( GF(11) ){[2..8]};;
gap> w := AsSSortedList( GF(11) ){[9..10]};;
gap> C := SrivastavaCode( a, w, 2, GF(11) );
a linear [7,5,3]2 Srivastava code over GF(11)
gap> IsMDSCode( C );
true # Always true if F is a prime field
</Example>
<!--
a := AsSSortedList( GF(11) ){[2..8]};;
w := AsSSortedList( GF(11) ){[9..10]};;
C := SrivastavaCode( a, w, 2, GF(11) );
IsMDSCode( C );
# Why is this always true if F is a prime field ?
# not in Helgert 1972 ...
-->
<Index>
code, Cordaro-Wagner
</Index>
<ManSection Label="CordaroWagnerCode">
<Func Name="CordaroWagnerCode" Arg=" n "/>
<Description>
<C>CordaroWagnerCode</C> returns a binary Cordaro-Wagner code.
This is a code of length <A>n</A> and dimension <M>2</M>
having the best possible minimum distance
<M>d</M>. This code is just a little bit less trivial than
<C>RepetitionCode</C>
(see <Ref Func="RepetitionCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C := CordaroWagnerCode( 11 );
a linear [11,2,7]5 Cordaro-Wagner code over GF(2)
gap> AsSSortedList(C);
[ [ 0 0 0 0 0 0 0 0 0 0 0 ], [ 0 0 0 0 1 1 1 1 1 1 1 ],
[ 1 1 1 1 0 0 0 1 1 1 1 ], [ 1 1 1 1 1 1 1 0 0 0 0 ] ]
</Example>
<ManSection Label="FerreroDesignCode">
<Func Name="FerreroDesignCode" Arg=" P m "/>
<Description>
<E>Requires the GAP package SONATA</E>
<P/>
A group <M>K</M> together with a group of
automorphism <M>H</M> of <M>K</M> such that the
semidirect product <M>KH</M> is a Frobenius group with
complement <M>H</M> is called a Ferrero pair <M>(K, H)</M>
in SONATA.
Take a Frobenius <M>(G,+)</M> group with kernel <M>K</M>
and complement <M>H</M>.
Consider the design <M>D</M> with point set <M>K</M> and block set
<M>\{ a^H + b\ |\ a, b \in K, a \not= 0 \}</M>.
Here <M>a^H</M> denotes the orbit of a under conjugation by elements
of <M>H</M>. Every planar near-ring design of type "*" can be obtained
in this way from groups.
These designs (from a Frobenius kernel
of order <M>v</M> and a Frobenius complement of order <M>k</M>) have
<M>v(v-1)/k</M> distinct blocks and they are all of size <M>k</M>.
Moreover each of the <M>v</M> points occurs in exactly <M>v-1</M> distinct
blocks. Hence the rows and the columns of the incidence
matrix <M>M</M> of the design are always of constant weight.
<P/>
<C>FerreroDesignCode</C>
constructs binary linear code arising from the incdence
matrix of a design associated to a "Ferrero pair" arising
from a fixed-point-free (fpf) automorphism groups and Frobenius group.
<P/>
INPUT: <M>P</M> is a list of prime powers describing an abelian group <M>G</M>.
<M>m > 0</M> is an integer such that <M>G</M> admits a cyclic fpf
automorphism group of size <M>m</M>.
This means that for all <M>q = p^k \in P</M>,
OrderMod(<M>p</M>, <M>m</M>) must divide <M>q</M>
(see the SONATA documentation for <C>FpfAutomorphismGroupsCyclic</C>).
<P/>
OUTPUT: The binary linear code whose generator matrix is the
incidence matrix of a design associated to a "Ferrero pair" arising
from the fixed-point-free (fpf) automorphism group of <M>G</M>.
The pair <M>(H,K)</M> is called a Ferraro pair and the semidirect product
<M>KH</M> is a Frobenius group with complement <M>H</M>.
<P/>
AUTHORS: Peter Mayr and David Joyner
</Description>
</ManSection>
<Example>
gap> G:=AbelianGroup([5,5] );
[ pc group of size 25 with 2 generators ]
gap> FpfAutomorphismGroupsMaxSize( G );
[ 24, 2 ]
gap> L:=FpfAutomorphismGroupsCyclic( [5,5], 3 );
[ [ [ f1, f2 ] -> [ f1*f2^2, f1*f2^3 ] ],
[ pc group of size 25 with 2 generators ] ]
gap> D := DesignFromFerreroPair( L[2], Group(L[1][1]), "*" );
[ a 2 - ( 25, 3, 2 ) nearring generated design ]
gap> M:=IncidenceMat( D );; Length(M); Length(TransposedMat(M));
25
200
gap> C1:=GeneratorMatCode(M*Z(2),GF(2));
a linear [200,25,1..24]62..100 code defined by generator matrix over GF(2)
gap> MinimumDistance(C1);
24
gap> C2:=FerreroDesignCode( [5,5],3);
a linear [200,25,1..24]62..100 code defined by generator matrix over GF(2)
gap> C1=C2;
true
</Example>
<!--
G:=AbelianGroup([5,5] );
FpfAutomorphismGroupsMaxSize( G );
L:=FpfAutomorphismGroupsCyclic( [5,5], 3 );
D := DesignFromFerreroPair( L[2], Group(L[1][1]), "*" );
M:=IncidenceMat( D );; Length(M); Length(TransposedMat(M));
C1:=GeneratorMatCode(M*Z(2),GF(2));
MinimumDistance(C1);
C2:=FerreroDesignCode( [5,5],3);
C1=C2;
-->
<ManSection Label="RandomLinearCode">
<Func Name="RandomLinearCode" Arg=" n k F "/>
<Description>
<C>RandomLinearCode</C> returns a random linear code with word length
<A>n</A>, dimension <A>k</A> over field <A>F</A>.
The method used is to first construct a
<M>k\times n</M> matrix of the block form <M>(I,A)</M>,
where <M>I</M> is a <M>k\times k</M> identity matrix
and <M>A</M> is a <M>k\times (n-k)</M> matrix
constructed using <C>Random(F)</C> repeatedly.
Then the columns are permuted using a randomly
selected element of <C>SymmetricGroup(n)</C>.
<P/>
To create a random unrestricted code, use <C>RandomCode</C> (see
<Ref Func="RandomCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C := RandomLinearCode( 15, 4, GF(3) );
a [15,4,?] randomly generated code over GF(3)
gap> Display(C);
a linear [15,4,1..6]6..10 random linear code over GF(3)
</Example>
<!--
C := RandomLinearCode( 15, 4, GF(3) );
Display(C);
-->
The method <Package>GUAVA</Package> chooses to output the result of a
<C>RandomLinearCode</C> command is different than other codes.
For example, the bounds on the minimum distance is not displayed.
Howeer, you can use the <C>Display</C> command to print this information.
This new display method was added in version 1.9 to speed up
the command (if <M>n</M> is about 80 and
<M>k</M> about 40, for example, the time it took to
look up and/or calculate the bounds on the minimum distance
was too long).
<ManSection Label="OptimalityCode">
<Func Name="OptimalityCode" Arg=" C "/>
<Description>
<!--In general this command is no longer accurate, since the
tables have not been updated since 1998. See the web site
<URL>http://www.win.tue.nl/~aeb/voorlincod.html</URL>
for more recent data.
<P/>-->
<C>OptimalityCode</C> returns the difference between the smallest
known upper bound and the actual size of the code. Note that the value of the
function <C>UpperBound</C> is not always equal to the actual upper bound
<M>A(n,d)</M> thus the result may not be equal to <M>0</M>
even if the code is optimal!
<P/>
<C>OptimalityLinearCode</C> is similar but applies only
to linear codes.
</Description>
</ManSection>
<ManSection Label="BestKnownLinearCode">
<Func Name="BestKnownLinearCode" Arg=" n k F "/>
<Description>
<!--In general this command is no longer accurate, since the
tables have not been updated since 1998. See the web site
<URL>http://www.win.tue.nl/~aeb/voorlincod.html</URL>
for more recent data.
<P/>-->
<C>BestKnownLinearCode</C> returns the best known (as of 11 May 2006<!--1998-->)
linear code of length <A>n</A>,
dimension <A>k</A> over field <A>F</A>.
The function uses the tables described in
section <Ref Func="BoundsMinimumDistance" Style="Number"/>
to construct this code.
<P/>
This command can also be called using the syntax
<C>BestKnownLinearCode( rec )</C>, where
<A>rec</A> must be a record containing the fields `lowerBound',
`upperBound' and `construction'. It uses the information in this field to
construct a code. This form is meant to be used together with the
function <C>BoundsMinimumDistance</C>
(see <Ref Func="BoundsMinimumDistance" Style="Number"/>), if the
bounds are already calculated.
</Description>
</ManSection>
<Example>
gap> C1 := BestKnownLinearCode( 23, 12, GF(2) );
a linear [23,12,7]3 punctured code
gap> C1 = BinaryGolayCode();
false # it's constructed differently
gap> C1 := BestKnownLinearCode( 23, 12, GF(2) );
a linear [23,12,7]3 punctured code
gap> G1 := MutableCopyMat(GeneratorMat(C1));;
gap> PutStandardForm(G1);
()
gap> Display(G1);
1 . . . . . . . . . . . 1 . 1 . 1 1 1 . . . 1
. 1 . . . . . . . . . . 1 1 1 1 1 . . 1 . . .
. . 1 . . . . . . . . . 1 1 . 1 . . 1 . 1 . 1
. . . 1 . . . . . . . . 1 1 . . . 1 1 1 . 1 .
. . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1 . 1
. . . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1 1
. . . . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1
. . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 1 . .
. . . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 1 .
. . . . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 .
. . . . . . . . . . 1 . 1 . 1 1 1 . . . 1 1 1
. . . . . . . . . . . 1 . 1 . 1 1 1 . . . 1 1
gap> C2 := BinaryGolayCode();
a cyclic [23,12,7]3 binary Golay code over GF(2)
gap> G2 := MutableCopyMat(GeneratorMat(C2));;
gap> PutStandardForm(G2);
()
gap> Display(G2);
1 . . . . . . . . . . . 1 . 1 . 1 1 1 . . . 1
. 1 . . . . . . . . . . 1 1 1 1 1 . . 1 . . 1
. . 1 . . . . . . . . . 1 1 . 1 . . 1 . 1 . 1
. . . 1 . . . . . . . . 1 1 . . . 1 1 1 . 1 1
. . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1 . .
. . . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1 .
. . . . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1
. . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 1 . .
. . . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 1 .
. . . . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 1
. . . . . . . . . . 1 . 1 . 1 1 1 . . . 1 1 .
. . . . . . . . . . . 1 . 1 . 1 1 1 . . . 1 1
## Despite their generator matrices are different, they are equivalent codes, see below.
gap> IsEquivalent(C1,C2);
true
gap> CodeIsomorphism(C1,C2);
(4,14,6,12,5)(7,17,18,11,19)(8,22,13,21,16)(10,23,15,20)
gap> Display( BestKnownLinearCode( 81, 77, GF(4) ) );
a linear [81,77,3]2..3 shortened code of
a linear [85,81,3]1 Hamming (4,4) code over GF(4)
gap> C:=BestKnownLinearCode(174,72);
a linear [174,72,31..36]26..87 code defined by generator matrix over GF(2)
gap> bounds := BoundsMinimumDistance( 81, 77, GF(4) );
rec( n := 81, k := 77, q := 4,
references := rec( Ham := [ "%T this reference is unknown, for more info",
"%T contact A.E. Brouwer (aeb@cwi.nl)" ],
cap := [ "%T this reference is unknown, for more info",
"%T contact A.E. Brouwer (aeb@cwi.nl)" ] ),
construction := [ (Operation "ShortenedCode"),
[ [ (Operation "HammingCode"), [ 4, 4 ] ], [ 1, 2, 3, 4 ] ] ],
lowerBound := 3,
lowerBoundExplanation := [ "Lb(81,77)=3, by shortening of:",
"Lb(85,81)=3, reference: Ham" ], upperBound := 3,
upperBoundExplanation := [ "Ub(81,77)=3, by considering shortening to:",
"Ub(18,14)=3, reference: cap" ] )
gap> C := BestKnownLinearCode( bounds );
a linear [81,77,3]2..3 shortened code
gap> C = BestKnownLinearCode(81, 77, GF(4) );
true
</Example>
<!--
C1 := BestKnownLinearCode( 23, 12, GF(2) );
C1 = BinaryGolayCode();
C1 := BestKnownLinearCode( 23, 12, GF(2) );
G1 := MutableCopyMat(GeneratorMat(C1));;
PutStandardForm(G1);
Display(G1);
C2 := BinaryGolayCode();
G2 := MutableCopyMat(GeneratorMat(C2));;
PutStandardForm(G2);
Display(G2);
IsEquivalent(C1,C2);
CodeIsomorphism(C1,C2);
Display( BestKnownLinearCode( 81, 77, GF(4) ) );
C:=BestKnownLinearCode(174,72);
bounds := BoundsMinimumDistance( 81, 77, GF(4) );
C := BestKnownLinearCode( bounds );
C = BestKnownLinearCode(81, 77, GF(4) );
-->
</Section>
<Section>
<Heading>
Gabidulin Codes
</Heading>
<Label Name="Gabidulin Codes"/>
<!--
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Section GabidulinCode, EnlargedGabidulinCode, DavydovCode,
% TombakCode, EnlargedTombakCode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-->
These five binary, linear
codes are derived from an article by Gabidulin, Davydov and
Tombak <Cite Key="GDT91"/>. All these codes are defined by
check matrices.
Exact definitions can be found in the article.
The Gabidulin code, the enlarged Gabidulin code, the Davydov code, the
Tombak code, and the enlarged Tombak code, correspond with theorem 1, 2,
3, 4, and 5, respectively in the article.
<P/>
Like the Hamming codes, these codes have fixed minimum
distance and covering radius, but can be arbitrarily long.
<Index>
code, Gabidulin
</Index>
<ManSection Label="GabidulinCode">
<Func Name="GabidulinCode" Arg=" m w1 w2 "/>
<Description>
<C>GabidulinCode</C> yields a code of length <M>5</M> .
<M>2^{m-2}-1</M>, redundancy <M>2m-1</M>,
minimum distance <M>3</M> and covering radius <M>2</M>.
<A>w1</A> and <A>w2</A> should be elements of
<M>GF(2^{m-2})</M>.
</Description>
</ManSection>
<ManSection Label="EnlargedGabidulinCode">
<Func Name="EnlargedGabidulinCode" Arg=" m w1 w2 e "/>
<Description>
<C>EnlargedGabidulinCode</C> yields a code of length
<M>7</M>. <M>2^{m-2}-2</M>, redundancy <M>2m</M>,
minimum distance <M>3</M> and covering radius <M>2</M>.
<A>w1</A> and <A>w2</A> are elements of
<M>GF(2^{m-2})</M>. <A>e</A> is an element of
<M>GF(2^m)</M>.
<!--
The core of an enlarged Gabidulin code consists of a Gabidulin code.
-->
</Description>
</ManSection>
<Index>
code, Davydov
</Index>
<ManSection Label="DavydovCode">
<Func Name="DavydovCode" Arg=" r v ei ej "/>
<Description>
<C>DavydovCode</C> yields a code of length <M>2^v + 2^{r-v} - 3</M>,
redundancy <A>r</A>, minimum distance <M>4</M>
and covering radius <M>2</M>. <A>v</A> is an integer between
<M>2</M> and <M>r-2</M>. <A>ei</A> and <A>ej</A> are
elements of <M>GF(2^v)</M> and <M>GF(2^{r-v})</M>,
respectively.
</Description>
</ManSection>
<Index>
code, Tombak
</Index>
<ManSection Label="TombakCode">
<Func Name="TombakCode" Arg=" m e beta gamma w1 w2 "/>
<Description>
<C>TombakCode</C> yields a code of length
<M>15 \cdot 2^{m-3} - 3</M>,
redundancy <M>2m</M>, minimum distance <M>4</M> and
covering radius <M>2</M>.
<A>e</A> is an element of <M>GF(2^m)</M>.
<A>beta</A> and <A>gamma</A> are elements of
<M>GF(2^{m-1})</M>.
<A>w1</A> and <A>w2</A> are elements of
<M>GF(2^{m-3})</M>.
</Description>
</ManSection>
<ManSection Label="EnlargedTombakCode">
<Func Name="EnlargedTombakCode" Arg=" m e beta gamma w1 w2 u "/>
<Description>
<C>EnlargedTombakCode</C> yields a code of length
<M>23 \cdot 2^{m-4} - 3</M>, redundancy <M>2m-1</M>,
minimum distance <M>4</M> and covering radius <M>2</M>.
The parameters <A>m</A>, <A>e</A>, <A>beta</A>, <A>gamma</A>,
<A>w1</A> and <A>w2</A> are defined as in <C>TombakCode</C>.
<A>u</A> is an element of <M>GF(2^{m-1})</M>.
<!--
The core of an enlarged Tombak code consists of a Tombak code.
-->
</Description>
</ManSection>
<Example>
gap> GabidulinCode( 4, Z(4)^0, Z(4)^1 );
a linear [19,12,3]2 Gabidulin code (m=4) over GF(2)
gap> EnlargedGabidulinCode( 4, Z(4)^0, Z(4)^1, Z(16)^11 );
a linear [26,18,3]2 enlarged Gabidulin code (m=4) over GF(2)
gap> DavydovCode( 6, 3, Z(8)^1, Z(8)^5 );
a linear [13,7,4]2 Davydov code (r=6, v=3) over GF(2)
gap> TombakCode( 5, Z(32)^6, Z(16)^14, Z(16)^10, Z(4)^0, Z(4)^1 );
a linear [57,47,4]2 Tombak code (m=5) over GF(2)
gap> EnlargedTombakCode( 6, Z(32)^6, Z(16)^14, Z(16)^10,
> Z(4)^0, Z(4)^0, Z(32)^23 );
a linear [89,78,4]2 enlarged Tombak code (m=6) over GF(2)
</Example>
<!--
GabidulinCode( 4, Z(4)^0, Z(4)^1 );
EnlargedGabidulinCode( 4, Z(4)^0, Z(4)^1, Z(16)^11 );
DavydovCode( 6, 3, Z(8)^1, Z(8)^5 );
TombakCode( 5, Z(32)^6, Z(16)^14, Z(16)^10, Z(4)^0, Z(4)^1 );
EnlargedTombakCode( 6, Z(32)^6, Z(16)^14, Z(16)^10, Z(4)^0, Z(4)^0, Z(32)^23 );
-->
</Section>
<Section>
<Heading>
Golay Codes
</Heading>
<Label Name="Golay Codes"/>
<Q>
The Golay code is probably the most important of all codes
for both practical and theoretical reasons.
</Q>
(<Cite Key="MS83"/>, pg. 64).
Though born in Switzerland, M. J. E. Golay (1902-1989) worked for
the US Army Labs for most of his career.
For more information on his life, see his obit in the June
1990 IEEE Information Society Newsletter.
<Index>
code, Golay (binary)
</Index>
<ManSection Label="BinaryGolayCode">
<Func Name="BinaryGolayCode" Arg=" "/>
<Description>
<C>BinaryGolayCode</C> returns a binary Golay code. This is a perfect
<M>[23,12,7]</M> code. It is also cyclic, and has generator polynomial
<M>g(x)=1+x^2+x^4+x^5+x^6+x^{10}+x^{11}</M>.
Extending it results in an extended Golay code (see
<Ref Func="ExtendedBinaryGolayCode" Style="Number"/>). There's also the
ternary Golay code (see
<Ref Func="TernaryGolayCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C:=BinaryGolayCode();
a cyclic [23,12,7]3 binary Golay code over GF(2)
gap> ExtendedBinaryGolayCode() = ExtendedCode(BinaryGolayCode());
true
gap> IsPerfectCode(C);
true
gap> IsCyclicCode(C);
true
</Example>
<!--
C:=BinaryGolayCode();
ExtendedBinaryGolayCode() = ExtendedCode(BinaryGolayCode());
IsPerfectCode(C);
IsCyclicCode(C);
-->
<ManSection Label="ExtendedBinaryGolayCode">
<Func Name="ExtendedBinaryGolayCode" Arg=" "/>
<Description>
<C>ExtendedBinaryGolayCode</C> returns an extended binary Golay code.
This is a <M>[24,12,8]</M> code. Puncturing in the last position
results in a perfect binary Golay code
(see <Ref Func="BinaryGolayCode" Style="Number"/>).
The code is self-dual.
</Description>
</ManSection>
<Example>
gap> C := ExtendedBinaryGolayCode();
a linear [24,12,8]4 extended binary Golay code over GF(2)
gap> IsSelfDualCode(C);
true
gap> P := PuncturedCode(C);
a linear [23,12,7]3 punctured code
gap> P = BinaryGolayCode();
true
gap> IsCyclicCode(C);
false
</Example>
<!--
C := ExtendedBinaryGolayCode();
IsSelfDualCode(C);
P := PuncturedCode(C);
P = BinaryGolayCode();
IsCyclicCode(C);
-->
<Index>
code, Golay (ternary)
</Index>
<ManSection Label="TernaryGolayCode">
<Func Name="TernaryGolayCode" Arg=" "/>
<Description>
<C>TernaryGolayCode</C> returns a ternary Golay code.
This is a perfect <M>[11,6,5]</M> code.
It is also cyclic, and has generator polynomial
<M>g(x)=2+x^2+2x^3+x^4+x^5</M>.
Extending it results in an extended Golay code
(see <Ref Func="ExtendedTernaryGolayCode" Style="Number"/>).
There's also the binary Golay code (see
<Ref Func="BinaryGolayCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C:=TernaryGolayCode();
a cyclic [11,6,5]2 ternary Golay code over GF(3)
gap> ExtendedTernaryGolayCode() = ExtendedCode(TernaryGolayCode());
true
gap> IsCyclicCode(C);
true
</Example>
<!--
C:=TernaryGolayCode();
ExtendedTernaryGolayCode() = ExtendedCode(TernaryGolayCode());
IsCyclicCode(C);
-->
<ManSection Label="ExtendedTernaryGolayCode">
<Func Name="ExtendedTernaryGolayCode" Arg=" "/>
<Description>
<C>ExtendedTernaryGolayCode</C> returns an
extended ternary Golay code.
This is a <M>[12,6,6]</M> code. Puncturing this code
results in a perfect ternary Golay code
(see <Ref Func="TernaryGolayCode" Style="Number"/>).
The code is self-dual.
</Description>
</ManSection>
<Example>
gap> C := ExtendedTernaryGolayCode();
a linear [12,6,6]3 extended ternary Golay code over GF(3)
gap> IsSelfDualCode(C);
true
gap> P := PuncturedCode(C);
a linear [11,6,5]2 punctured code
gap> P = TernaryGolayCode();
true
gap> IsCyclicCode(C);
false
</Example>
<!--
C := ExtendedTernaryGolayCode();
IsSelfDualCode(C);
P := PuncturedCode(C);
P = TernaryGolayCode();
IsCyclicCode(C);
-->
</Section>
<Section>
<Heading>
Generating Cyclic Codes
</Heading>
<Label Name="Generating Cyclic Codes"/>
The elements of a cyclic code <M>C</M> are all
multiples of a ('generator') polynomial <M>g(x)</M>,
where calculations are carried out modulo <M>x^n-1</M>.
Therefore, as polynomials in <M>x</M>, the elements always
have degree less than <M>n</M>. A cyclic code is an ideal in
the ring <M>F[x]/(x^n-1)</M> of polynomials modulo
<M>x^n - 1</M>. The unique monic polynomial
of least degree that generates <M>C</M>
is called the <E>generator polynomial</E> of <M>C</M>.
It is a divisor of the polynomial <M>x^n-1</M>.
<Index>generator polynomial</Index>
<Index>check polynomial</Index>
<P/>
The <E>check polynomial</E> is the polynomial <M>h(x)</M> with
<M>g(x)h(x)=x^n-1</M>. Therefore it is also a divisor of
<M>x^n-1</M>. The check polynomial has the property that
<Display>
c(x)h(x) \equiv 0 \pmod{x^n-1},
</Display>
for every codeword <M>c(x)\in C</M>.
<P/>
The first two functions described below
generate cyclic codes from a given generator or check
polynomial. All cyclic codes can be constructed using
these functions.
<P/>
Two of the Golay codes already described are cyclic
(see <Ref Func="BinaryGolayCode" Style="Number"/> and
<Ref Func="TernaryGolayCode" Style="Number"/>). For example,
the <Package>GUAVA</Package> record for a binary
Golay code contains the generator polynomial:
<Example>
gap> C := BinaryGolayCode();
a cyclic [23,12,7]3 binary Golay code over GF(2)
gap> NamesOfComponents(C);
[ "LeftActingDomain", "GeneratorsOfLeftOperatorAdditiveGroup", "WordLength",
"GeneratorMat", "GeneratorPol", "Dimension", "Redundancy", "Size", "name",
"lowerBoundMinimumDistance", "upperBoundMinimumDistance", "WeightDistribution",
"boundsCoveringRadius", "MinimumWeightOfGenerators",
"UpperBoundOptimalMinimumDistance" ]
gap> C!.GeneratorPol;
x_1^11+x_1^10+x_1^6+x_1^5+x_1^4+x_1^2+Z(2)^0
</Example>
<!--
C := BinaryGolayCode();
NamesOfComponents(C);
C!.GeneratorPol;
-->
Then functions that generate cyclic codes from a prescribed set of roots
of the generator polynomial are described, including the BCH codes (see
<Ref Func="RootsCode" Style="Number"/>,
<Ref Func="BCHCode" Style="Number"/>,
<Ref Func="ReedSolomonCode" Style="Number"/> and
<Ref Func="QRCode" Style="Number"/>).
<P/>
Finally we describe the trivial codes
(see <Ref Func="WholeSpaceCode" Style="Number"/>,
<Ref Func="NullCode" Style="Number"/>,
<Ref Func="RepetitionCode" Style="Number"/>), and
the command <C>CyclicCodes</C> which lists all
cyclic codes (<Ref Func="CyclicCodes" Style="Number"/>).
<ManSection Label="GeneratorPolCode">
<Func Name="GeneratorPolCode" Arg=" g n [name] F "/>
<Description>
<C>GeneratorPolCode</C> creates a cyclic code with a
generator polynomial <A>g</A>, word length <A>n</A>,
over <A>F</A>. <A>name</A> can contain a short
description of the code.
<P/>
If <A>g</A> is not a divisor of <M>x^n-1</M>, it cannot be
a generator polynomial. In that case, a code is created
with generator polynomial <M>gcd( g, x^n-1 )</M>,
i.e. the greatest common divisor of <A>g</A> and
<M>x^n-1</M>. This is a valid generator polynomial
that generates the ideal <M>(g)</M>.
See <Ref Func="Generating Cyclic Codes" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> x:= Indeterminate( GF(2) );; P:= x^2+1;
Z(2)^0+x^2
gap> C1 := GeneratorPolCode(P, 7, GF(2));
a cyclic [7,6,1..2]1 code defined by generator polynomial over GF(2)
gap> GeneratorPol( C1 );
Z(2)^0+x
gap> C2 := GeneratorPolCode( x+1, 7, GF(2));
a cyclic [7,6,1..2]1 code defined by generator polynomial over GF(2)
gap> GeneratorPol( C2 );
Z(2)^0+x
</Example>
<!--
x:= Indeterminate( GF(2) );; P:= x^2+1;
C1 := GeneratorPolCode(P, 7, GF(2));
GeneratorPol( C1 );
C2 := GeneratorPolCode( x+1, 7, GF(2));
GeneratorPol( C2 );
-->
<ManSection Label="CheckPolCode">
<Func Name="CheckPolCode" Arg=" h n [name] F "/>
<Description>
<C>CheckPolCode</C> creates a cyclic code with a check polynomial
<A>h</A>, word length <A>n</A>, over <A>F</A>. <A>name</A>
can contain a short description of the code (as a string).
<P/>
If <A>h</A> is not a divisor of <M>x^n-1</M>, it cannot be a
check polynomial. In that case, a code is created with check
polynomial <M>gcd( h, x^n-1 )</M>,
i.e. the greatest common divisor of <A>h</A> and
<M>x^n-1</M>. This is a valid check polynomial that yields
the same elements as the ideal <M>(h)</M>. See
<Ref Label="Generating Cyclic Codes" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> x:= Indeterminate( GF(3) );; P:= x^2+2;
-Z(3)^0+x_1^2
gap> H := CheckPolCode(P, 7, GF(3));
a cyclic [7,1,7]4 code defined by check polynomial over GF(3)
gap> CheckPol(H);
-Z(3)^0+x_1
gap> Gcd(P, X(GF(3))^7-1);
-Z(3)^0+x_1
</Example>
<!--
x:= Indeterminate( GF(3) );; P:= x^2+2;
H := CheckPolCode(P, 7, GF(3));
CheckPol(H);
Gcd(P, X(GF(3))^7-1);
-->
<ManSection Label="RootsCode">
<Func Name="RootsCode" Arg=" n list "/>
<Description>
This is the generalization of the BCH, Reed-Solomon and quadratic residue
codes (see
<Ref Func="BCHCode" Style="Number"/>,
<Ref Func="ReedSolomonCode" Style="Number"/> and
<Ref Func="QRCode" Style="Number"/>). The user can give
a length of the code <A>n</A> and a prescribed set of zeros. The argument
<A>list</A> must be a valid list of primitive <M>n^{th}</M>
roots of unity in a splitting field <M>GF(q^m)</M>.
The resulting code will be over the field
<M>GF(q)</M>. The function will return the largest possible cyclic code for
which the list <A>list</A> is a subset of the roots of the code. From this
list, <Package>GUAVA</Package> calculates the entire set of roots.
<P/>
This command can also be called with the syntax
<C>RootsCode( n, list, q )</C>.
In this second form, the second argument is a list of integers, ranging
from <M>0</M> to <M>n-1</M>.
The resulting code will be over a field <M>GF(q)</M>.
<Package>GUAVA</Package>
calculates a primitive <M>n^{th}</M> root of unity, <M>\alpha</M>, in the
extension field of <M>GF(q)</M>. It uses the set of the powers of
<M>\alpha</M> in the list as a prescribed set of zeros.
</Description>
</ManSection>
<Example>
gap> a := PrimitiveUnityRoot( 3, 14 );
Z(3^6)^52
gap> C1 := RootsCode( 14, [ a^0, a, a^3 ] );
a cyclic [14,7,3..6]3..7 code defined by roots over GF(3)
gap> MinimumDistance( C1 );
4
gap> b := PrimitiveUnityRoot( 2, 15 );
Z(2^4)
gap> C2 := RootsCode( 15, [ b, b^2, b^3, b^4 ] );
a cyclic [15,7,5]3..5 code defined by roots over GF(2)
gap> C2 = BCHCode( 15, 5, GF(2) );
true
C3 := RootsCode( 4, [ 1, 2 ], 5 );
RootsOfCode( C3 );
C3 = ReedSolomonCode( 4, 3 );
</Example>
<!--
a := PrimitiveUnityRoot( 3, 14 );
C1 := RootsCode( 14, [ a^0, a, a^3 ] );
MinimumDistance( C1 );
b := PrimitiveUnityRoot( 2, 15 );
C2 := RootsCode( 15, [ b, b^2, b^3, b^4 ] );
C2 = BCHCode( 15, 5, GF(2) );
C3 := RootsCode( 4, [ 1, 2 ], 5 );
RootsOfCode( C3 );
C3 = ReedSolomonCode( 4, 3 );
-->
<Index>
code, Bose-Chaudhuri-Hockenghem
</Index>
<ManSection Label="BCHCode">
<Func Name="BCHCode" Arg=" n [b] delta F "/>
<Description>
The function <C>BCHCode</C> returns a
'Bose-Chaudhuri-Hockenghem code' (or <E>BCH code</E> for short).
This is the largest possible cyclic code of length <A>n</A>
over field <A>F</A>, whose generator polynomial has zeros
<Display>
a^{b},a^{b+1}, ..., a^{b+delta-2},
</Display>
where <M>a</M> is a primitive <M>n^{th}</M> root of unity in
the splitting field <M>GF(q^m)</M>, <A>b</A> is an integer
<M>0\leq b\leq n-delta+1</M> and <M>m</M> is the
multiplicative order of <M>q</M> modulo <A>n</A>.
(The integers <M>\{b,...,b+delta-2\}</M>
typically lie in the range <M>\{1,...,n-1\}</M>.)
Default value for <A>b</A> is <M>1</M>, though the algorithm
allows <M>b=0</M>. The length <A>n</A> of the code and the size <M>q</M> of
the field must be relatively prime.
The generator polynomial is equal to the least common multiple of the
minimal polynomials of
<Display>
a^{b}, a^{b+1}, ..., a^{b+delta-2}.
</Display>
The set of zeroes of the generator polynomial is equal to the
union of the sets
<Display>
\{a^x\ |\ x \in C_k\},
</Display>
where <M>C_k</M> is the <M>k^{th}</M> cyclotomic coset of
<M>q</M> modulo <M>n</M>
and <M>b\leq k\leq b+delta-2</M> (see
<Ref Func="CyclotomicCosets" Style="Number"/>).
<P/>
Special cases are <M>b=1</M> (resulting codes are called 'narrow-sense'
BCH codes), and <M>n=q^m-1</M> (known as 'primitive' BCH codes).
<Package>GUAVA</Package>
calculates the largest value of <M>d</M> for which the BCH code with
designed distance <M>d</M> coincides with the BCH code with designed
distance <A>delta</A>. This distance <M>d</M> is called the
<E>Bose distance</E> of the code.
The true minimum distance of the code is greater than or equal to the
Bose distance.
<Index>Bose distance</Index>
<P/>
Printed are the designed distance (to be precise, the Bose distance)
<M>d</M>, and the starting power <M>b</M>.
<P/>
The Sugiyama decoding algorithm has been implemented for this code
(see <Ref Func="Decode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C1 := BCHCode( 15, 3, 5, GF(2) );
a cyclic [15,5,7]5 BCH code, delta=7, b=1 over GF(2)
gap> DesignedDistance( C1 );
7
gap> C2 := BCHCode( 23, 2, GF(2) );
a cyclic [23,12,5..7]3 BCH code, delta=5, b=1 over GF(2)
gap> DesignedDistance( C2 );
5
gap> MinimumDistance(C2);
7
</Example>
<!--
C1 := BCHCode( 15, 3, 5, GF(2) );
DesignedDistance( C1 );
C2 := BCHCode( 23, 2, GF(2) );
DesignedDistance( C2 );
MinimumDistance(C2);
-->
See <Ref Func="RootsCode" Style="Number"/>
for a more general construction.
<Index>
code, Reed-Solomon
</Index>
<ManSection Label="ReedSolomonCode">
<Func Name="ReedSolomonCode" Arg=" n d "/>
<Description>
<C>ReedSolomonCode</C> returns a 'Reed-Solomon code' of length
<A>n</A>, designed distance <A>d</A>.
This code is a primitive narrow-sense BCH code over the
field <M>GF(q)</M>, where <M>q=n+1</M>.
The dimension of an RS code is <M>n-d+1</M>.
According to the Singleton bound
(see <Ref Func="UpperBoundSingleton" Style="Number"/>)
the dimension cannot be greater than this, so the true minimum distance
of an RS code is equal to <A>d</A> and the code is maximum distance separable
(see <Ref Func="IsMDSCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C1 := ReedSolomonCode( 3, 2 );
a cyclic [3,2,2]1 Reed-Solomon code over GF(4)
gap> IsCyclicCode(C1);
true
gap> C2 := ReedSolomonCode( 4, 3 );
a cyclic [4,2,3]2 Reed-Solomon code over GF(5)
gap> RootsOfCode( C2 );
[ Z(5), Z(5)^2 ]
gap> IsMDSCode(C2);
true
</Example>
<!--
C1 := ReedSolomonCode( 3, 2 );
IsCyclicCode(C1);
C2 := ReedSolomonCode( 4, 3 );
RootsOfCode( C2 );
IsMDSCode(C2);
-->
See <Ref Func="GeneralizedReedSolomonCode" Style="Number"/>
for a more general construction.
<ManSection Label="ExtendedReedSolomonCode">
<Func Name="ExtendedReedSolomonCode" Arg=" n d "/>
<Description>
<C>ExtendedReedSolomonCode</C> creates a Reed-Solomon
code of length <M>n-1</M> with designed distance <M>d-1</M>
and then returns the code which is extended by adding an
overall parity-check symbol. The motivation for creating this
function is calling <Ref Func="ExtendedCode" Style="Number"/>
function over a Reed-Solomon code will take considerably long
time.
</Description>
</ManSection>
<Example>
gap> C := ExtendedReedSolomonCode(17, 13);
a linear [17,5,13]9..12 extended Reed Solomon code over GF(17)
gap> IsMDSCode(C);
true
</Example>
<!--
C := ExtendedReedSolomonCode(17, 13);
IsMDSCode(C);
-->
<ManSection Label="QRCode">
<Func Name="QRCode" Arg=" n F "/>
<Description>
<C>QRCode</C> returns a quadratic residue code. If <A>F</A>
is a field <M>GF(q)</M>, then <M>q</M> must be a quadratic residue
modulo <A>n</A>. That is, an <M>x</M> exists with
<M>x^2 \equiv q \pmod n</M>. Both <A>n</A> and <M>q</M> must
be primes. Its generator polynomial is the product of the
polynomials <M>x-a^i</M>. <M>a</M> is a primitive <M>n^{th}</M>
root of unity, and <M>i</M> is an integer in the set of
quadratic residues modulo <A>n</A>.
</Description>
</ManSection>
<Example>
gap> C1 := QRCode( 7, GF(2) );
a cyclic [7,4,3]1 quadratic residue code over GF(2)
gap> IsEquivalent( C1, HammingCode( 3, GF(2) ) );
true
gap> IsCyclicCode(C1);
true
gap> IsCyclicCode(HammingCode( 3, GF(2) ));
false
gap> C2 := QRCode( 11, GF(3) );
a cyclic [11,6,4..5]2 quadratic residue code over GF(3)
gap> C2 = TernaryGolayCode();
true
gap> Q1 := QRCode( 7, GF(2));
a cyclic [7,4,3]1 quadratic residue code over GF(2)
gap> P1:=AutomorphismGroup(Q1); IdGroup(P1);
Group([ (1,2)(5,7), (2,3)(4,7), (2,4)(5,6), (3,5)(6,7), (3,7)(5,6) ])
[ 168, 42 ]
</Example>
<!--
C1 := QRCode( 7, GF(2) );
IsEquivalent( C1, HammingCode( 3, GF(2) ) );
C2 := QRCode( 11, GF(3) );
C2 = TernaryGolayCode();
Q1 := QRCode( 7, GF(2));
P1:=AutomorphismGroup(Q1);
IdGroup(P1);
-->
<ManSection Label="QQRCodeNC">
<Func Name="QQRCodeNC" Arg=" p "/>
<Description>
<C>QQRCodeNC</C> is the same as <C>QQRCode</C>, except that
it uses <C>GeneratorMatCodeNC</C> instead of
<C>GeneratorMatCode</C>.
</Description>
</ManSection>
<ManSection Label="QQRCode">
<Func Name="QQRCode" Arg=" p "/>
<Description>
<C>QQRCode</C> returns a quasi-quadratic residue code, as defined by
Proposition 2.2 in Bazzi-Mittel <Cite Key="BM03"/>. The
parameter <A>p</A> must be a prime.
Its generator matrix has the block form <M>G=(Q,N)</M>.
Here <M>Q</M> is a <M>p\times </M> circulant matrix
whose top row is <M>(0,x_1,...,x_{p-1})</M>, where
<M>x_i=1</M> if and only if <M>i</M> is a quadratic residue mod <M>p</M>,
and <M>N</M> is a <M>p\times </M> circulant matrix
whose top row is <M>(0,y_1,...,y_{p-1})</M>, where
<M>x_i+y_i=1</M> for all <M>i</M>. (In fact, this matrix
can be recovered as the component <C>DoublyCirculant</C>
of the code.)
</Description>
</ManSection>
<Example>
gap> C1 := QQRCode( 7);
a linear [14,7,1..4]3..5 code defined by generator matrix over GF(2)
gap> G1:=GeneratorMat(C1);;
gap> Display(G1);
. 1 1 . 1 . . . . . 1 . 1 1
1 . 1 1 1 . . . . 1 1 1 . 1
. . . 1 1 . 1 . 1 1 . . . 1
. . 1 . 1 1 1 1 . 1 . . 1 1
. . . . . . . 1 . . 1 1 1 .
. . . . . . . . . 1 1 1 . 1
. . . . . . . . 1 . . 1 1 1
gap> Display(C1!.DoublyCirculant);
. 1 1 . 1 . . . . . 1 . 1 1
1 1 . 1 . . . . . 1 . 1 1 .
1 . 1 . . . 1 . 1 . 1 1 . .
. 1 . . . 1 1 1 . 1 1 . . .
1 . . . 1 1 . . 1 1 . . . 1
. . . 1 1 . 1 1 1 . . . 1 .
. . 1 1 . 1 . 1 . . . 1 . 1
gap> MinimumDistance(C1);
4
gap> C2 := QQRCode( 29); MinimumDistance(C2);
a linear [58,28,1..14]8..29 code defined by generator matrix over GF(2)
12
gap> Aut2:=AutomorphismGroup(C2); IdGroup(Aut2);
[ permutation group of size 812 with 4 generators ]
[ 812, 7 ]
</Example>
<!--
C1 := QQRCode( 7);
G1:=GeneratorMat(C1);;
Display(G1);
Display(C1!.DoublyCirculant);
MinimumDistance(C1);
C2 := QQRCode( 29); MinimumDistance(C2);
Aut2:=AutomorphismGroup(C2); IdGroup(Aut2);
-->
<Index>
code, Fire
</Index>
<ManSection Label="FireCode">
<Func Name="FireCode" Arg=" g b "/>
<Description>
<C>FireCode</C> constructs a (binary) Fire code.
<A>g</A> is a primitive polynomial of degree <M>m</M>,
and a factor of <M>x^r-1</M>. <A>b</A> an integer
<M>0 \leq b \leq m</M>
not divisible by <M>r</M>, that determines the burst length
of a single error burst that can be corrected.
The argument <A>g</A> can be a polynomial with base ring
<M>GF(2)</M>, or a list of coefficients in <M>GF(2)</M>.
The generator polynomial of the code is defined as the product of
<A>g</A> and <M>x^{2b-1}+1</M>.
<P/>
Here is the general definition of 'Fire code', named after
P. Fire, who introduced these codes in 1959 in order to
correct burst errors.
First, a definition. If <M>F=GF(q)</M> and
<M>f\in F[x]</M> then we say <M>f</M> has
<E>order</E> <M>e</M> if <M>f(x)|(x^e-1)</M>.
<Index>order of polynomial</Index>
A <E>Fire code</E> is a cyclic code over <M>F</M>
with generator polynomial <M>g(x)=
(x^{2t-1}-1)p(x)</M>, where <M>p(x)</M>
does not divide <M>x^{2t-1}-1</M> and satisfies
<M>deg(p(x))\geq t</M>. The length of such a code
is the order of <M>g(x)</M>.
<!--
If <M>p(x)</M> is an irreducible polynomial
in <M>F[x]</M> of degree <M>m</M>
and order <M>e</M> then the order of <M>g(x)</M>
is equal to <M>lcm(e,2t-1)</M>.
-->
Non-binary Fire codes have not been implemented.
</Description>
</ManSection>
.
<Example>
gap> x:= Indeterminate( GF(2) );; G:= x^3+x^2+1;
Z(2)^0+x^2+x^3
gap> Factors( G );
[ Z(2)^0+x^2+x^3 ]
gap> C := FireCode( G, 3 );
a cyclic [35,27,1..4]2..6 3 burst error correcting fire code over GF(2)
gap> MinimumDistance( C );
4 # Still it can correct bursts of length 3
</Example>
<!--
x:= Indeterminate( GF(2) );; G:= x^3+x^2+1;
Factors( G );
C := FireCode( G, 3 );
MinimumDistance( C );
-->
<ManSection Label="WholeSpaceCode">
<Func Name="WholeSpaceCode" Arg=" n F "/>
<Description>
<C>WholeSpaceCode</C> returns the cyclic whole space code of
length <A>n</A> over <A>F</A>. This code consists of all polynomials
of degree less than <A>n</A> and coefficients in <A>F</A>.
</Description>
</ManSection>
<Example>
gap> C := WholeSpaceCode( 5, GF(3) );
a cyclic [5,5,1]0 whole space code over GF(3)
</Example>
<!--
C := WholeSpaceCode( 5, GF(3) );
-->
<ManSection Label="NullCode">
<Func Name="NullCode" Arg=" n F "/>
<Description>
<C>NullCode</C> returns the zero-dimensional nullcode with length
<A>n</A> over <A>F</A>. This code has only one word: the all zero word.
It is cyclic though!
</Description>
</ManSection>
<Example>
gap> C := NullCode( 5, GF(3) );
a cyclic [5,0,5]5 nullcode over GF(3)
gap> AsSSortedList( C );
[ [ 0 0 0 0 0 ] ]
</Example>
<!--
-->
<ManSection Label="RepetitionCode">
<Func Name="RepetitionCode" Arg=" n F "/>
<Description>
<C>RepetitionCode</C> returns the cyclic repetition code of
length <A>n</A> over <A>F</A>. The code has as many elements as
<A>F</A>, because each codeword consists of a repetition of one of
these elements.
</Description>
</ManSection>
<Example>
gap> C := RepetitionCode( 3, GF(5) );
a cyclic [3,1,3]2 repetition code over GF(5)
gap> AsSSortedList( C );
[ [ 0 0 0 ], [ 1 1 1 ], [ 2 2 2 ], [ 4 4 4 ], [ 3 3 3 ] ]
gap> IsPerfectCode( C );
false
gap> IsMDSCode( C );
true
</Example>
<!--
C := RepetitionCode( 3, GF(5) );
AsSSortedList( C );
IsPerfectCode( C );
IsMDSCode( C );
-->
<ManSection Label="CyclicCodes">
<Func Name="CyclicCodes" Arg=" n F "/>
<Description>
<C>CyclicCodes</C> returns a list of all cyclic codes of length <A>n</A>
over <A>F</A>. It constructs all possible generator polynomials
from the factors of <M>x^n-1</M>. Each combination of these
factors yields a generator polynomial after multiplication.
</Description>
</ManSection>
<Example>
gap> CyclicCodes(3,GF(3));
[ a cyclic [3,3,1]0 enumerated code over GF(3),
a cyclic [3,2,1..2]1 enumerated code over GF(3),
a cyclic [3,1,3]2 enumerated code over GF(3),
a cyclic [3,0,3]3 enumerated code over GF(3) ]
</Example>
<!--
CyclicCodes(3,GF(3));
-->
<ManSection Label="NrCyclicCodes">
<Func Name="NrCyclicCodes" Arg=" n F "/>
<Description>
The function <C>NrCyclicCodes</C> calculates the number of
cyclic codes of length <A>n</A> over field <A>F</A>.
</Description>
</ManSection>
<Example>
gap> NrCyclicCodes( 23, GF(2) );
8
gap> codelist := CyclicCodes( 23, GF(2) );
[ a cyclic [23,23,1]0 enumerated code over GF(2),
a cyclic [23,22,1..2]1 enumerated code over GF(2),
a cyclic [23,11,1..8]4..7 enumerated code over GF(2),
a cyclic [23,0,23]23 enumerated code over GF(2),
a cyclic [23,11,1..8]4..7 enumerated code over GF(2),
a cyclic [23,12,1..7]3 enumerated code over GF(2),
a cyclic [23,1,23]11 enumerated code over GF(2),
a cyclic [23,12,1..7]3 enumerated code over GF(2) ]
gap> BinaryGolayCode() in codelist;
true
gap> RepetitionCode( 23, GF(2) ) in codelist;
true
gap> CordaroWagnerCode( 23 ) in codelist;
false # This code is not cyclic
</Example>
<!--
NrCyclicCodes( 23, GF(2) );
codelist := CyclicCodes( 23, GF(2) );
BinaryGolayCode() in codelist;
RepetitionCode( 23, GF(2) ) in codelist;
CordaroWagnerCode( 23 ) in codelist;
-->
<ManSection Label="QuasiCyclicCode">
<Func Name="QuasiCyclicCode" Arg=" G s F "/>
<Description>
<C>QuasiCyclicCode( G, k, F )</C> generates a rate <M>1/m</M>
quasi-cyclic code over field <A>F</A>. The input <A>G</A> is a list
of univariate polynomials and <M>m</M> is the cardinality of this
list. Note that <M>m</M> must be at least <M>2</M>.
The input <A>s</A> is the size of each circulant and it may not
necessarily be the same as the code dimension <M>k</M>, i.e.
<M>k \le s</M>.
<P/>
There also exists another version, <C>QuasiCyclicCode( G, s )</C>
which produces quasi-cyclic codes over <M>F_2</M> only. Here
the parameter <A>s</A> holds the same definition and the input
<A>G</A> is a list of integers, where each integer is
an octal representation of a binary univariate polynomial.
</Description>
</ManSection>
<Example>
gap> #
gap> # This example show the case for k = s
gap> #
gap> L1 := PolyCodeword( Codeword("10000000000", GF(4)) );
Z(2)^0
gap> L2 := PolyCodeword( Codeword("12223201000", GF(4)) );
x^7+Z(2^2)*x^5+Z(2^2)^2*x^4+Z(2^2)*x^3+Z(2^2)*x^2+Z(2^2)*x+Z(2)^0
gap> L3 := PolyCodeword( Codeword("31111220110", GF(4)) );
x^9+x^8+Z(2^2)*x^6+Z(2^2)*x^5+x^4+x^3+x^2+x+Z(2^2)^2
gap> L4 := PolyCodeword( Codeword("13320333010", GF(4)) );
x^9+Z(2^2)^2*x^7+Z(2^2)^2*x^6+Z(2^2)^2*x^5+Z(2^2)*x^3+Z(2^2)^2*x^2+Z(2^2)^2*x+\
Z(2)^0
gap> L5 := PolyCodeword( Codeword("20102211100", GF(4)) );
x^8+x^7+x^6+Z(2^2)*x^5+Z(2^2)*x^4+x^2+Z(2^2)
gap> C := QuasiCyclicCode( [L1, L2, L3, L4, L5], 11, GF(4) );
a linear [55,11,1..32]24..41 quasi-cyclic code over GF(4)
gap> MinimumDistance(C);
29
gap> Display(C);
a linear [55,11,29]24..41 quasi-cyclic code over GF(4)
gap> #
gap> # This example show the case for k < s
gap> #
gap> L1 := PolyCodeword( Codeword("02212201220120211002000",GF(3)) );
-x^19+x^16+x^15-x^14-x^12+x^11-x^9-x^8+x^7-x^5-x^4+x^3-x^2-x
gap> L2 := PolyCodeword( Codeword("00221100200120220001110",GF(3)) );
x^21+x^20+x^19-x^15-x^14-x^12+x^11-x^8+x^5+x^4-x^3-x^2
gap> L3 := PolyCodeword( Codeword("22021011202221111020021",GF(3)) );
x^22-x^21-x^18+x^16+x^15+x^14+x^13-x^12-x^11-x^10-x^8+x^7+x^6+x^4-x^3-x-Z(3)^0
gap> C := QuasiCyclicCode( [L1, L2, L3], 23, GF(3) );
a linear [69,12,1..37]27..46 quasi-cyclic code over GF(3)
gap> MinimumDistance(C);
34
gap> Display(C);
a linear [69,12,34]27..46 quasi-cyclic code over GF(3)
gap> #
gap> # This example show the binary case using octal representation
gap> #
gap> L1 := 001;; # 0 000 001
gap> L2 := 013;; # 0 001 011
gap> L3 := 015;; # 0 001 101
gap> L4 := 077;; # 0 111 111
gap> C := QuasiCyclicCode( [L1, L2, L3, L4], 7 );
a linear [28,7,1..12]8..14 quasi-cyclic code over GF(2)
gap> MinimumDistance(C);
12
gap> Display(C);
a linear [28,7,12]8..14 quasi-cyclic code over GF(2)
</Example>
<!--
#
# This example show the case for k = s
#
L1 := PolyCodeword( Codeword("10000000000", GF(4)) );
L2 := PolyCodeword( Codeword("12223201000", GF(4)) );
L3 := PolyCodeword( Codeword("31111220110", GF(4)) );
L4 := PolyCodeword( Codeword("13320333010", GF(4)) );
L5 := PolyCodeword( Codeword("20102211100", GF(4)) );
C := QuasiCyclicCode( [L1, L2, L3, L4, L5], 11, GF(4) );
MinimumDistance(C);
Display(C);
#
# This example show the case for k < s
#
L1 := PolyCodeword( Codeword("02212201220120211002000",GF(3)) );
L2 := PolyCodeword( Codeword("00221100200120220001110",GF(3)) );
L3 := PolyCodeword( Codeword("22021011202221111020021",GF(3)) );
C := QuasiCyclicCode( [L1, L2, L3], 23, GF(3) );
MinimumDistance(C);
Display(C);
#
# This example show the binary case using octal representation
#
L1 := 001;; # 0 000 001
L2 := 013;; # 0 001 011
L3 := 015;; # 0 001 101
L4 := 077;; # 0 111 111
C := QuasiCyclicCode( [L1, L2, L3, L4], 7 );
MinimumDistance(C);
Display(C);
-->
<ManSection Label="CyclicMDSCode">
<Func Name="CyclicMDSCode" Arg=" q m k "/>
<Description>
Given the input parameters <A>q</A>, <A>m</A> and <A>k</A>,
this function returns a <M>[q^m + 1, k, q^m - k + 2]</M>
cyclic MDS code over GF(<M>q^m</M>). If <M>q^m</M> is even,
any value of <M>k</M> can be used, otherwise only odd value
of <M>k</M> is accepted.
</Description>
</ManSection>
<Example>
gap> C:=CyclicMDSCode(2,6,24);
a cyclic [65,24,42]31..41 MDS code over GF(64)
gap> IsMDSCode(C);
true
gap> C:=CyclicMDSCode(5,3,77);
a cyclic [126,77,50]35..49 MDS code over GF(125)
gap> IsMDSCode(C);
true
gap> C:=CyclicMDSCode(3,3,25);
a cyclic [28,25,4]2..3 MDS code over GF(27)
gap> GeneratorPol(C);
x^3+Z(3^3)^7*x^2+Z(3^3)^20*x-Z(3)^0
gap>
</Example>
<!--
C:=CyclicMDSCode(2,6,24);
IsMDSCode(C);
C:=CyclicMDSCode(5,3,77);
IsMDSCode(C);
C:=CyclicMDSCode(3,3,25);
GeneratorPol(C);
-->
<Index>MDS</Index>
<Index>cyclic</Index>
<ManSection Label="FourNegacirculantSelfDualCode">
<Func Name="FourNegacirculantSelfDualCode" Arg=" ax bx k "/>
<Description>
A four-negacirculant self-dual code has a generator matrix
<M>G</M> of the the following form
<Verb>
- -
| | A | B |
G = | I_2k |-----+-----|
| | -B^T| A^T |
- -
</Verb>
where <M>AA^T + BB^T = -I_k</M> and <M>A</M>, <M>B</M> and
their transposed are all <M>k \times k</M> negacirculant matrices.
The generator matrix <M>G</M> returns a <M>[2k, k, d]_q</M>
self-dual code over GF(<M>q</M>). For discussion on four-negacirculant
self-dual codes, refer to <Cite Key="HHKK07"/>.
<P/>
The input parameters <A>ax</A> and <A>bx</A> are the defining
polynomials over GF(<M>q</M>) of negacirculant matrices <M>A</M>
and <M>B</M> respectively. The last parameter <A>k</A> is the
dimension of the code.
</Description>
</ManSection>
<Example>
gap> ax:=PolyCodeword(Codeword("1200200", GF(3)));
-x_1^4-x_1+Z(3)^0
gap> bx:=PolyCodeword(Codeword("2020221", GF(3)));
x_1^6-x_1^5-x_1^4-x_1^2-Z(3)^0
gap> C:=FourNegacirculantSelfDualCode(ax, bx, 14);;
gap> MinimumDistance(C);;
gap> CoveringRadius(C);;
gap> IsSelfDualCode(C);
true
gap> Display(C);
a linear [28,14,9]7 four-negacirculant self-dual code over GF(3)
gap> Display( GeneratorMat(C) );
1 . . . . . . . . . . . . . 1 2 . . 2 . . 2 . 2 . 2 2 1
. 1 . . . . . . . . . . . . . 1 2 . . 2 . 2 2 . 2 . 2 2
. . 1 . . . . . . . . . . . . . 1 2 . . 2 1 2 2 . 2 . 2
. . . 1 . . . . . . . . . . 1 . . 1 2 . . 1 1 2 2 . 2 .
. . . . 1 . . . . . . . . . . 1 . . 1 2 . . 1 1 2 2 . 2
. . . . . 1 . . . . . . . . . . 1 . . 1 2 1 . 1 1 2 2 .
. . . . . . 1 . . . . . . . 1 . . 1 . . 1 . 1 . 1 1 2 2
. . . . . . . 1 . . . . . . 1 1 2 2 . 2 . 1 . . 1 . . 1
. . . . . . . . 1 . . . . . . 1 1 2 2 . 2 2 1 . . 1 . .
. . . . . . . . . 1 . . . . 1 . 1 1 2 2 . . 2 1 . . 1 .
. . . . . . . . . . 1 . . . . 1 . 1 1 2 2 . . 2 1 . . 1
. . . . . . . . . . . 1 . . 1 . 1 . 1 1 2 2 . . 2 1 . .
. . . . . . . . . . . . 1 . 1 1 . 1 . 1 1 . 2 . . 2 1 .
. . . . . . . . . . . . . 1 2 1 1 . 1 . 1 . . 2 . . 2 1
gap> ax:=PolyCodeword(Codeword("013131000", GF(7)));
x_1^5+Z(7)*x_1^4+x_1^3+Z(7)*x_1^2+x_1
gap> bx:=PolyCodeword(Codeword("425435030", GF(7)));
Z(7)*x_1^7+Z(7)^5*x_1^5+Z(7)*x_1^4+Z(7)^4*x_1^3+Z(7)^5*x_1^2+Z(7)^2*x_1+Z(7)^4
gap> C:=FourNegacirculantSelfDualCodeNC(ax, bx, 18);
a linear [36,18,1..13]0..36 four-negacirculant self-dual code over GF(7)
gap> IsSelfDualCode(C);
true
</Example>
<!--
ax:=PolyCodeword(Codeword("1200200", GF(3)));
bx:=PolyCodeword(Codeword("2020221", GF(3)));
C:=FourNegacirculantSelfDualCode(ax, bx, 14);;
MinimumDistance(C);;
CoveringRadius(C);;
IsSelfDualCode(C);
Display(C);
Display( GeneratorMat(C) );
ax:=PolyCodeword(Codeword("013131000", GF(7)));
bx:=PolyCodeword(Codeword("425435030", GF(7)));
C:=FourNegacirculantSelfDualCodeNC(ax, bx, 18);
IsSelfDualCode(C);
-->
<Index>self-dual</Index>
<ManSection Label="FourNegacirculantSelfDualCodeNC">
<Func Name="FourNegacirculantSelfDualCodeNC" Arg=" ax bx k "/>
<Description>
This function is the same as <C>FourNegacirculantSelfDualCode</C>,
except this version is faster as it does not estimate the minimum
distance and covering radius of the code.
</Description>
</ManSection>
</Section>
<Section>
<Heading>
Evaluation Codes
</Heading>
<Label Name="Evaluation Codes"/>
<Index>
code, evaluation
</Index>
<ManSection Label="EvaluationCode">
<Func Name="EvaluationCode" Arg=" P L R "/>
<Description>
Input: <A>F</A> is a finite field,
<A>L</A> is a list of rational functions in
<M>R=F[x_1,...,x_r]</M>, <A>P</A> is a list of <M>n</M> points in
<M>F^r</M> at which all of the functions in <A>L</A>
are defined.
<Br/>
Output: The 'evaluation code' <M>C</M>, which is the image of the
evalation map
<Display>
Eval_P:span(L)\rightarrow F^n,
</Display> given by <M>f\longmapsto (f(p_1),...,f(p_n))</M>,
where <M>P=\{p_1,...,p_n\}</M> and <M>f \in L</M>.
The generator matrix of <M>C</M> is
<M>G=(f_i(p_j))_{f_i\in L,p_j\in P}</M>.
<P/>
This command returns a "record" object <C>C</C>
with several extra components (type <C>NamesOfComponents(C)</C>
to see them all): <C>C!.EvaluationMat</C> (not the same
as the generator matrix in general),
<C>C!.points</C> (namely <A>P</A>),
<C>C!.basis</C> (namely <A>L</A>), and
<C>C!.ring</C> (namely <A>R</A>).
</Description>
</ManSection>
<Example>
gap> F:=GF(11);
GF(11)
gap> R := PolynomialRing(F,2);;
gap> indets := IndeterminatesOfPolynomialRing(R);;
gap> x:=indets[1];; y:=indets[2];;
gap> L:=[x^2*y,x*y,x^5,x^4,x^3,x^2,x,x^0];;
gap> Pts:=[ [ Z(11)^9, Z(11) ], [ Z(11)^8, Z(11) ], [ Z(11)^7, 0*Z(11) ],
[ Z(11)^6, 0*Z(11) ], [ Z(11)^5, 0*Z(11) ], [ Z(11)^4, 0*Z(11) ],
[ Z(11)^3, Z(11) ], [ Z(11)^2, 0*Z(11) ], [ Z(11), 0*Z(11) ],
[ Z(11)^0, 0*Z(11) ], [ 0*Z(11), Z(11) ] ];;
gap> C:=EvaluationCode(Pts,L,R);
a linear [11,8,1..3]2..3 evaluation code over GF(11)
gap> MinimumDistance(C);
3
</Example>
<!--
F:=GF(11);
R := PolynomialRing(F,["x","y"]);
indets := IndeterminatesOfPolynomialRing(R);;
x:=indets[1];; y:=indets[2];;
L:=[x^2*y,x*y,x^5,x^4,x^3,x^2,x,x^0];;
Pts:=[ [ Z(11)^9, Z(11) ], [ Z(11)^8, Z(11) ], [ Z(11)^7, 0*Z(11) ],
[ Z(11)^6, 0*Z(11) ], [ Z(11)^5, 0*Z(11) ], [ Z(11)^4, 0*Z(11) ],
[ Z(11)^3, Z(11) ], [ Z(11)^2, 0*Z(11) ], [ Z(11), 0*Z(11) ],
[ Z(11)^0, 0*Z(11) ], [ 0*Z(11), Z(11) ] ];;
C:=EvaluationCode(P,L,R);
MinimumDistance(C);
-->
<ManSection Label="GeneralizedReedSolomonCode">
<Func Name="GeneralizedReedSolomonCode" Arg=" P k R "/>
<Description>
Input: R=F[x], where <A>F</A> is a finite field,
<A>k</A> is a positive integer,
<A>P</A> is a list of <M>n</M> points in <M>F</M>.
<Br/>
Output: The <M>C</M> which is the image of the
evaluation map
<Display>
Eval_P:F[x]_k\rightarrow F^n,
</Display>
given by <M>f\longmapsto (f(p_1),...,f(p_n))</M>,
where <M>P=\{p_1,...,p_n\}\subset F</M> and <M>f</M> ranges over the
space <M>F[x]_k</M> of all
polynomials of degree less than <M>k</M>.
<P/>
This command returns a "record" object <C>C</C>
with several extra components (type <C>NamesOfComponents(C)</C>
to see them all): <C>C!.points</C> (namely <A>P</A>),
<C>C!.degree</C> (namely <A>k</A>), and
<C>C!.ring</C> (namely <A>R</A>).
<P/>
This code can be decoded using <C>Decodeword</C>,
which applies the special decoder method (the
interpolation method), or using
<C>GeneralizedReedSolomonDecoderGao</C>
which applies an algorithm of S. Gao
(see <Ref Func="GeneralizedReedSolomonDecoderGao" Style="Number"/>).
This code has a special decoder record which implements
the interpolation algorithm described in section 5.2 of Justesen and Hoholdt
<Cite Key="JH04"/>. See
<Ref Func="Decode" Style="Number"/> and
<Ref Func="Decodeword" Style="Number"/> for more details.
<P/>
The weighted version has implemented with the option
<C>GeneralizedReedSolomonCode(P,k,R,wts)</C>,
where <M>wts = [v_1, ..., v_n]</M> is a sequence of <M>n</M>
non-zero elements from the base field <M>F</M> of <A>R</A>.
See also the generalized Reed--Solomon code <M>GRS_k(P, V)</M> described
in <Cite Key="MS83"/>, p.303.
<P/>
The list-decoding algorithm of Sudan-Guraswami
(described in section 12.1 of <Cite Key="JH04"/>) has
been implemented for generalized Reed-Solomon codes.
See <Ref Func="GeneralizedReedSolomonListDecoder" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> R:=PolynomialRing(GF(11),["t"]);
GF(11)[t]
gap> P:=List([1,3,4,5,7],i->Z(11)^i);
[ Z(11), Z(11)^3, Z(11)^4, Z(11)^5, Z(11)^7 ]
gap> C:=GeneralizedReedSolomonCode(P,3,R);
a linear [5,3,1..3]2 generalized Reed-Solomon code over GF(11)
gap> MinimumDistance(C);
3
gap> V:=[Z(11)^0,Z(11)^0,Z(11)^0,Z(11)^0,Z(11)];
[ Z(11)^0, Z(11)^0, Z(11)^0, Z(11)^0, Z(11) ]
gap> C:=GeneralizedReedSolomonCode(P,3,R,V);
a linear [5,3,1..3]2 weighted generalized Reed-Solomon code over GF(11)
gap> MinimumDistance(C);
3
</Example>
<!--
R:=PolynomialRing(GF(11),["t"]);
P:=List([1,3,4,5,7],i->Z(11)^i);
C:=GeneralizedReedSolomonCode(P,3,R);
MinimumDistance(C);
V:=[Z(11)^0,Z(11)^0,Z(11)^0,Z(11)^0,Z(11)];
C:=GeneralizedReedSolomonCode(P,3,R,V);
MinimumDistance(C);
-->
See <Ref Func="EvaluationCode" Style="Number"/>
for a more general construction.
<ManSection Label="GeneralizedReedMullerCode">
<Func Name="GeneralizedReedMullerCode" Arg=" Pts r F "/>
<Description>
<C>GeneralizedReedMullerCode</C> returns a 'Reed-Muller code'
<M>C</M> with length <M>|Pts|</M> and order <M>r</M>.
One considers (a) a basis of monomials
for the vector space over <M>F=GF(q)</M>
of all polynomials in <M>F[x_1,...,x_d]</M> of degree
at most <M>r</M>, and (b) a set <M>Pts</M> of points in
<M>F^d</M>. The generator matrix of the associated
<E>Reed-Muller code</E> <M>C</M> is <M>G=(f(p))_{f\in B,p \in Pts}</M>.
This code <M>C</M> is constructed using the command
<C>GeneralizedReedMullerCode(Pts,r,F)</C>.
When <M>Pts</M> is the set of all <M>q^d</M> points in <M>F^d</M>
then the command <C>GeneralizedReedMuller(d,r,F)</C> yields the code.
When <M>Pts</M> is the set of all <M>(q-1)^d</M> points with no
coordinate equal to <M>0</M> then this is can be constructed
using the <C>ToricCode</C> command (as a special case).
<P/>
This command returns a "record" object <C>C</C>
with several extra components (type <C>NamesOfComponents(C)</C>
to see them all): <C>C!.points</C> (namely <A>Pts</A>) and
<C>C!.degree</C> (namely <A>r</A>).
</Description>
</ManSection>
<Example>
gap> Pts:=ToricPoints(2,GF(5));
[ [ Z(5)^0, Z(5)^0 ], [ Z(5)^0, Z(5) ], [ Z(5)^0, Z(5)^2 ], [ Z(5)^0, Z(5)^3 ],
[ Z(5), Z(5)^0 ], [ Z(5), Z(5) ], [ Z(5), Z(5)^2 ], [ Z(5), Z(5)^3 ],
[ Z(5)^2, Z(5)^0 ], [ Z(5)^2, Z(5) ], [ Z(5)^2, Z(5)^2 ], [ Z(5)^2, Z(5)^3 ],
[ Z(5)^3, Z(5)^0 ], [ Z(5)^3, Z(5) ], [ Z(5)^3, Z(5)^2 ], [ Z(5)^3, Z(5)^3 ] ]
gap> C:=GeneralizedReedMullerCode(Pts,2,GF(5));
a linear [16,6,1..11]6..10 generalized Reed-Muller code over GF(5)
</Example>
See <Ref Func="EvaluationCode" Style="Number"/>
for a more general construction.
<ManSection Label="ToricPoints">
<Func Name="ToricPoints" Arg=" n F "/>
<Description>
<C>ToricPoints(n,F)</C> returns the points in <M>(F^{\times})^n</M>.
</Description>
</ManSection>
<Example>
gap> ToricPoints(2,GF(5));
[ [ Z(5)^0, Z(5)^0 ], [ Z(5)^0, Z(5) ], [ Z(5)^0, Z(5)^2 ],
[ Z(5)^0, Z(5)^3 ], [ Z(5), Z(5)^0 ], [ Z(5), Z(5) ], [ Z(5), Z(5)^2 ],
[ Z(5), Z(5)^3 ], [ Z(5)^2, Z(5)^0 ], [ Z(5)^2, Z(5) ], [ Z(5)^2, Z(5)^2 ],
[ Z(5)^2, Z(5)^3 ], [ Z(5)^3, Z(5)^0 ], [ Z(5)^3, Z(5) ],
[ Z(5)^3, Z(5)^2 ], [ Z(5)^3, Z(5)^3 ] ]
</Example>
<!--
ToricPoints(2,GF(5));
-->
<Index>
code, toric
</Index>
<ManSection Label="ToricCode">
<Func Name="ToricCode" Arg=" L F "/>
<Description>
This function returns the toric codes as in
D. Joyner <Cite Key="Jo04"/> (see also J. P. Hansen
<Cite Key="Han99"/>). This is a truncated (generalized) Reed-Muller code.
Here <A>L</A> is a list of integral vectors and <A>F</A>
is the finite field. The size of <A>F</A> must
be different from <M>2</M>.
<P/>
This command returns a record object <C>C</C>
with an extra component (type <C>NamesOfComponents(C)</C>
to see them all): <C>C!.exponents</C> (namely <A>L</A>).
</Description>
</ManSection>
<Example>
gap> C:=ToricCode([[1,0],[3,4]],GF(3));
a linear [4,1,4]2 toric code over GF(3)
gap> Display(GeneratorMat(C));
1 1 2 2
gap> Elements(C);
[ [ 0 0 0 0 ], [ 1 1 2 2 ], [ 2 2 1 1 ] ]
</Example>
<!--
C:=ToricCode([[1,0],[3,4]],GF(3));
Display(GeneratorMat(C));
Elements(C);
-->
See <Ref Func="EvaluationCode" Style="Number"/>
for a more general construction.
</Section>
<Section>
<Heading>
Algebraic geometric codes
</Heading>
<Label Name="Algebraic geometric codes"/>
<Index>
code, AG
</Index>
Certain <Package>GUAVA</Package> functions related
to algebraic geometric codes are described in this
section.
<ManSection>
<Func Name="AffineCurve" Arg ="poly, ring"/>
<Description>
This function simply defines the data structure of an affine plane
curve. In <Package>GUAVA</Package>, an affine curve is
a record <A>crv</A> having two components: a polynomial
<A>poly</A>, accessed in <Package>GUAVA</Package>
by <A>crv.polynomial</A>,
and a polynomial ring over a field <M>F</M> in two variables <A>ring</A>,
accessed in <Package>GUAVA</Package> by <A>crv.ring</A>,
containing <A>poly</A>.
You use this function to define a curve in
<Package>GUAVA</Package>.
<P/>
For example, for the ring, one could take
<M>{\mathbb{Q}}[x,y]</M>, and for the polynomial
one could take <M>f(x,y)=x^2+y^2-1</M>. For the affine
line, simply taking <M>{\mathbb{Q}}[x,y]</M> for the
ring and <M>f(x,y)=y</M> for the polynomial.
<P/>
(Not sure if <M>F</M> neeeds to be a field in fact ...)
<P/>
To compute its degree, simply use the
<Ref Func="DegreeMultivariatePolynomial" Style="Number"/>
command.
</Description>
</ManSection>
<Example>
gap>
gap> F:=GF(11);;
gap> R2:=PolynomialRing(F,2);
PolynomialRing(..., [ x_1, x_2 ])
gap> vars:=IndeterminatesOfPolynomialRing(R2);;
gap> x:=vars[1];; y:=vars[2];;
gap> poly:=y;; crvP1:=AffineCurve(poly,R2);
rec( ring := PolynomialRing(..., [ x_1, x_2 ]), polynomial := x_2 )
gap> degree_crv:=DegreeMultivariatePolynomial(poly,R2);
1
gap> poly:=y^2-x*(x^2-1);; ell_crv:=AffineCurve(poly,R2);
rec( ring := PolynomialRing(..., [ x_1, x_2 ]), polynomial := -x_1^3+x_2^2+x_1 )
gap> degree_crv:=DegreeMultivariatePolynomial(poly,R2);
3
gap> poly:=x^2+y^2-1;; circle:=AffineCurve(poly,R2);
rec( ring := PolynomialRing(..., [ x_1, x_2 ]), polynomial := x_1^2+x_2^2-Z(11)^0 )
gap> degree_crv:=DegreeMultivariatePolynomial(poly,R2);
2
gap> q:=3;;
gap> F:=GF(q^2);;
gap> R:=PolynomialRing(F,2);;
gap> vars:=IndeterminatesOfPolynomialRing(R);
[ x_1, x_2 ]
gap> x:=vars[1];
x_1
gap> y:=vars[2];
x_2
gap> crv:=AffineCurve(y^q+y-x^(q+1),R);
rec( ring := PolynomialRing(..., [ x_1, x_2 ]), polynomial := -x_1^4+x_2^3+x_2 )
gap>
</Example>
<!--
F:=GF(11);;
R2:=PolynomialRing(F,2);
vars:=IndeterminatesOfPolynomialRing(R2);;
x:=vars[1];; y:=vars[2];;
poly:=y;; crvP1:=AffineCurve(poly,R2);
degree_crv:=DegreeMultivariatePolynomial(poly,R2);
poly:=y^2-x*(x^2-1);; ell_crv:=AffineCurve(poly,R2);
degree_crv:=DegreeMultivariatePolynomial(poly,R2);
poly:=x^2+y^2-1;; circle:=AffineCurve(poly,R2);
degree_crv:=DegreeMultivariatePolynomial(poly,R2);
q:=3;
F:=GF(q^2);
R:=PolynomialRing(F,2);;
vars:=IndeterminatesOfPolynomialRing(R);
x:=vars[1];
y:=vars[2];
crv:=AffineCurve(y^q+y-x^(q+1),R);
-->
In GAP, a <E>point</E>
<Index>point</Index>
on a curve defined by <M>f(x,y)=0</M>
is simply a list <A>[a,b]</A> of elements of <M>F</M>
satisfying this polynomial equation.
<ManSection Label="AffinePointsOnCurve">
<Func Name="AffinePointsOnCurve" Arg=" f R E "/>
<Description>
<C>AffinePointsOnCurve(f,R,E)</C> returns the points
<M>(x,y) \in E^2</M> satisying <M>f(x,y)=0</M>,
where <A>f</A> is an element of <M>R=F[x,y]</M>.
</Description>
</ManSection>
<Example>
gap> F:=GF(11);;
gap> R := PolynomialRing(F,["x","y"]);
PolynomialRing(..., [ x, y ])
gap> indets := IndeterminatesOfPolynomialRing(R);;
gap> x:=indets[1];; y:=indets[2];;
gap> P:=AffinePointsOnCurve(y^2-x^11+x,R,F);
[ [ Z(11)^9, 0*Z(11) ], [ Z(11)^8, 0*Z(11) ], [ Z(11)^7, 0*Z(11) ],
[ Z(11)^6, 0*Z(11) ], [ Z(11)^5, 0*Z(11) ], [ Z(11)^4, 0*Z(11) ],
[ Z(11)^3, 0*Z(11) ], [ Z(11)^2, 0*Z(11) ], [ Z(11), 0*Z(11) ],
[ Z(11)^0, 0*Z(11) ], [ 0*Z(11), 0*Z(11) ] ]
</Example>
<!--
F:=GF(11);;
R := PolynomialRing(F,["x","y"]);
indets := IndeterminatesOfPolynomialRing(R);;
x:=indets[1];; y:=indets[2];;
P:=AffinePointsOnCurve(y^2-x^11+x,R,F);
-->
<ManSection>
<Func Name="GenusCurve" Arg ="crv"/>
<Description>
If <A>crv</A> represents <M>f(x,y)=0</M>, where
<M>f</M> is a polynomial of degree <M>d</M>,
then this function simply returns <M>(d-1)(d-2)/2</M>.
At the present, the function does not check if
the curve is singular (in which case the result
may be false).
</Description>
</ManSection>
<Example>
gap> q:=4;;
gap> F:=GF(q^2);;
gap> a:=X(F);;
gap> R1:=PolynomialRing(F,[a]);;
gap> var1:=IndeterminatesOfPolynomialRing(R1);;
gap> b:=X(F);;
gap> R2:=PolynomialRing(F,[a,b]);;
gap> var2:=IndeterminatesOfPolynomialRing(R2);;
gap> crv:=AffineCurve(b^q+b-a^(q+1),R2);;
gap> crv:=AffineCurve(b^q+b-a^(q+1),R2);
rec( ring := PolynomialRing(..., [ x_1, x_1 ]), polynomial := x_1^5+x_1^4+x_1 )
gap> GenusCurve(crv);
36
</Example>
<ManSection>
<Func Name="GOrbitPoint " Arg ="G,P "/>
<Description>
<A>P</A> must be a point in projective space <M>\mathbb{P}^n(F)</M>,
<A>G</A> must be a finite subgroup of <M>GL(n+1,F)</M>,
This function returns all (representatives of projective)
points in the orbit <M>G\cdot P</M>.
<P/>
The example below computes the orbit of the automorphism group
on the Klein quartic over the field
<M>GF(43)</M> on the ``point at infinity''.
</Description>
</ManSection>
<Example>
gap> R:= PolynomialRing( GF(43), 3 );;
gap> vars:= IndeterminatesOfPolynomialRing(R);;
gap> x:= vars[1];; y:= vars[2];; z:= vars[3];;
gap> zz:=Z(43)^6;
Z(43)^6
gap> zzz:=Z(43);
Z(43)
gap> rho1:=zz^0*[[zz^4,0,0],[0,zz^2,0],[0,0,zz]];
[ [ Z(43)^24, 0*Z(43), 0*Z(43) ],
[ 0*Z(43), Z(43)^12, 0*Z(43) ],
[ 0*Z(43), 0*Z(43), Z(43)^6 ] ]
gap> rho2:=zz^0*[[0,1,0],[0,0,1],[1,0,0]];
[ [ 0*Z(43), Z(43)^0, 0*Z(43) ],
[ 0*Z(43), 0*Z(43), Z(43)^0 ],
[ Z(43)^0, 0*Z(43), 0*Z(43) ] ]
gap> rho3:=(-1)*[[(zz-zz^6 )/zzz^7,( zz^2-zz^5 )/ zzz^7, ( zz^4-zz^3 )/ zzz^7],
> [( zz^2-zz^5 )/ zzz^7, ( zz^4-zz^3 )/ zzz^7, ( zz-zz^6 )/ zzz^7],
> [( zz^4-zz^3 )/ zzz^7, ( zz-zz^6 )/ zzz^7, ( zz^2-zz^5 )/ zzz^7]];
[ [ Z(43)^9, Z(43)^28, Z(43)^12 ],
[ Z(43)^28, Z(43)^12, Z(43)^9 ],
[ Z(43)^12, Z(43)^9, Z(43)^28 ] ]
gap> G:=Group([rho1,rho2,rho3]);; #PSL(2,7)
gap> Size(G);
168
gap> P:=[1,0,0]*zzz^0;
[ Z(43)^0, 0*Z(43), 0*Z(43) ]
gap> O:=GOrbitPoint(G,P);
[ [ Z(43)^0, 0*Z(43), 0*Z(43) ], [ 0*Z(43), Z(43)^0, 0*Z(43) ],
[ 0*Z(43), 0*Z(43), Z(43)^0 ], [ Z(43)^0, Z(43)^39, Z(43)^16 ],
[ Z(43)^0, Z(43)^33, Z(43)^28 ], [ Z(43)^0, Z(43)^27, Z(43)^40 ],
[ Z(43)^0, Z(43)^21, Z(43)^10 ], [ Z(43)^0, Z(43)^15, Z(43)^22 ],
[ Z(43)^0, Z(43)^9, Z(43)^34 ], [ Z(43)^0, Z(43)^3, Z(43)^4 ],
[ Z(43)^3, Z(43)^22, Z(43)^6 ], [ Z(43)^3, Z(43)^16, Z(43)^18 ],
[ Z(43)^3, Z(43)^10, Z(43)^30 ], [ Z(43)^3, Z(43)^4, Z(43)^0 ],
[ Z(43)^3, Z(43)^40, Z(43)^12 ], [ Z(43)^3, Z(43)^34, Z(43)^24 ],
[ Z(43)^3, Z(43)^28, Z(43)^36 ], [ Z(43)^4, Z(43)^30, Z(43)^27 ],
[ Z(43)^4, Z(43)^24, Z(43)^39 ], [ Z(43)^4, Z(43)^18, Z(43)^9 ],
[ Z(43)^4, Z(43)^12, Z(43)^21 ], [ Z(43)^4, Z(43)^6, Z(43)^33 ],
[ Z(43)^4, Z(43)^0, Z(43)^3 ], [ Z(43)^4, Z(43)^36, Z(43)^15 ] ]
gap> Length(O);
24
</Example>
Informally, a <E>divisor</E>
<Index>divisor</Index>
on a curve is a formal integer linear combination of points
on the curve, <M>D=m_1P_1+...+m_kP_k</M>,
where the <M>m_i</M> are integers (the ``multiplicity'' of
<M>P_i</M> in <M>D</M>) and <M>P_i</M> are (<M>F</M>-rational)
points on the affine plane curve.
In other words, a divisor is an element of the free
abelian group generated by the <M>F</M>-rational affine
points on the curve. The <E>support</E>
<Index>support</Index>
of a divisor <M>D</M> is simply the set of points
which occurs in the sum defining <M>D</M> with
non-zero ``multiplicity''.
The data structure for a divisor on an affine plane curve
is a record having the following components:
<List>
<Item>
the coefficients (the integer weights of the points in the support),
</Item>
<Item>
the support,
</Item>
<Item>
the curve, itself a record which has components:
polynomial and polynomial ring.
</Item>
</List>
<P/>
<P/>
<ManSection>
<Func Name="DivisorOnAffineCurve" Arg ="cdiv,sdiv,crv"/>
<Description>
This is the command you use to define a divisor in
<Package>GUAVA</Package>. Of course,
<A>crv</A> is the curve on which the divisor lives,
<A>cdiv</A> is the list of coefficients (or ``multiplicities''),
<A>sdiv</A> is the list of points on <A>crv</A> in the support.
<Example>
gap> q:=5;
5
gap> F:=GF(q);
GF(5)
gap> R:=PolynomialRing(F,2);;
gap> vars:=IndeterminatesOfPolynomialRing(R);
[ x_1, x_2 ]
gap> x:=vars[1];
x_1
gap> y:=vars[2];
x_2
gap> crv:=AffineCurve(y^3-x^3-x-1,R);
rec( ring := PolynomialRing(..., [ x_1, x_2 ]),
polynomial := -x_1^3+x_2^3-x_1-Z(5)^0 )
gap> Pts:=AffinePointsOnCurve(crv,R,F);;
gap> supp:=[Pts[1],Pts[2]];
[ [ 0*Z(5), Z(5)^0 ], [ Z(5)^0, Z(5) ] ]
gap> D:=DivisorOnAffineCurve([1,-1],supp,crv);
rec( coeffs := [ 1, -1 ],
support := [ [ 0*Z(5), Z(5)^0 ], [ Z(5)^0, Z(5) ] ],
curve := rec( ring := PolynomialRing(..., [ x_1, x_2 ]),
polynomial := -x_1^3+x_2^3-x_1-Z(5)^0 ) )
</Example>
<!--
q:=5;
F:=GF(q);
R:=PolynomialRing(F,2);;
vars:=IndeterminatesOfPolynomialRing(R);
x:=vars[1];
y:=vars[2];
crv:=AffineCurve(y^3-x^3-x-1,R);
Pts:=PointsOnAffineCurve(crv,F);;
supp:=[Pts[1],Pts[2]];
D:=DivisorOnAffineCurve([1,-1],supp,crv);
-->
</Description>
</ManSection>
<ManSection>
<Func Name="DivisorAddition " Arg ="D1,D2 "/>
<Description>
If <M>D_1=m_1P_1+...+m_kP_k</M>
and <M>D_2=n_1P_1+...+n_kP_k</M> are divisors then
<M>D_1+D_2=(m_1+n_1)P_1+...+(m_k+n_k)P_k</M>.
</Description>
</ManSection>
<ManSection>
<Func Name="DivisorDegree " Arg ="D "/>
<Description>
If <M>D=m_1P_1+...+m_kP_k</M> is a divisor then the <E>degree</E>
<Index>degree</Index>
is <M>m_1+...+m_k</M>.
</Description>
</ManSection>
<ManSection>
<Func Name="DivisorNegate " Arg ="D "/>
<Description>
Self-explanatory.
</Description>
</ManSection>
<ManSection>
<Func Name="DivisorIsZero " Arg ="D "/>
<Description>
Self-explanatory.
</Description>
</ManSection>
<ManSection>
<Func Name="DivisorsEqual " Arg ="D1,D2 "/>
<Description>
Self-explanatory.
</Description>
</ManSection>
<ManSection>
<Func Name="DivisorGCD " Arg ="D1,D2 "/>
<Description>
If <M>m=p_1^{e_1}...p_k^{e_k}</M>
and <M>n=p_1^{f_1}...p_k^{f_k}</M> are two integers then their
greatest common divisor is
<M>GCD(m,n)=p_1^{min(e_1,f_1)}...p_k^{min(e_k,f_k)}</M>.
A similar definition works for two divisors on a curve.
If <M>D_1=e_1P_1+...+e_kP_k</M>
and <M>D_2n=f_1P_1+...+f_kP_k</M> are two divisors on a curve then their
<E>greatest common divisor</E>
<Index>greatest common divisor</Index>
is <M>GCD(m,n)=min(e_1,f_1)P_1+...+min(e_k,f_k)P_k</M>.
This function computes this quantity.
</Description>
</ManSection>
<ManSection>
<Func Name="DivisorLCM " Arg ="D1,D2 "/>
<Description>
If <M>m=p_1^{e_1}...p_k^{e_k}</M>
and <M>n=p_1^{f_1}...p_k^{f_k}</M> are two integers then their
least common multiple is
<M>LCM(m,n)=p_1^{max(e_1,f_1)}...p_k^{max(e_k,f_k)}</M>.
A similar definition works for two divisors on a curve.
If <M>D_1=e_1P_1+...+e_kP_k</M>
and <M>D_2=f_1P_1+...+f_kP_k</M> are two divisors on a curve then their
<E>least common multiple</E>
<Index>least common multiple</Index>
is <M>LCM(m,n)=max(e_1,f_1)P_1+...+max(e_k,f_k)P_k</M>.
This function computes this quantity.
<Example>
gap> F:=GF(11);
GF(11)
gap> R1:=PolynomialRing(F,["a"]);;
gap> var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
gap> b:=X(F,"b",var1);
b
gap> var2:=Concatenation(var1,[b]);
[ a, b ]
gap> R2:=PolynomialRing(F,var2);
PolynomialRing(..., [ a, b ])
gap> crvP1:=AffineCurve(b,R2);
rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b )
gap> div1:=DivisorOnAffineCurve([1,2,3,4],[Z(11)^2,Z(11)^3,Z(11)^7,Z(11)],crvP1);
rec( coeffs := [ 1, 2, 3, 4 ],
support := [ Z(11)^2, Z(11)^3, Z(11)^7, Z(11) ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> DivisorDegree(div1);
10
gap> div2:=DivisorOnAffineCurve([1,2,3,4],[Z(11),Z(11)^2,Z(11)^3,Z(11)^4],crvP1);
rec( coeffs := [ 1, 2, 3, 4 ],
support := [ Z(11), Z(11)^2, Z(11)^3, Z(11)^4 ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> DivisorDegree(div2);
10
gap> div3:=DivisorAddition(div1,div2);
rec( coeffs := [ 5, 3, 5, 4, 3 ],
support := [ Z(11), Z(11)^2, Z(11)^3, Z(11)^4, Z(11)^7 ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> DivisorDegree(div3);
20
gap> DivisorIsEffective(div1);
true
gap> DivisorIsEffective(div2);
true
gap>
gap> ndiv1:=DivisorNegate(div1);
rec( coeffs := [ -1, -2, -3, -4 ],
support := [ Z(11)^2, Z(11)^3, Z(11)^7, Z(11) ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> zdiv:=DivisorAddition(div1,ndiv1);
rec( coeffs := [ 0, 0, 0, 0 ],
support := [ Z(11), Z(11)^2, Z(11)^3, Z(11)^7 ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> DivisorIsZero(zdiv);
true
gap> div_gcd:=DivisorGCD(div1,div2);
rec( coeffs := [ 1, 1, 2, 0, 0 ],
support := [ Z(11), Z(11)^2, Z(11)^3, Z(11)^4, Z(11)^7 ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> div_lcm:=DivisorLCM(div1,div2);
rec( coeffs := [ 4, 2, 3, 4, 3 ],
support := [ Z(11), Z(11)^2, Z(11)^3, Z(11)^4, Z(11)^7 ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> DivisorDegree(div_gcd);
4
gap> DivisorDegree(div_lcm);
16
gap> DivisorEqual(div3,DivisorAddition(div_gcd,div_lcm));
true
</Example>
<!--
F:=GF(11);
R1:=PolynomialRing(F,["a"]);;
var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
b:=X(F,"b",var1);
var2:=Concatenation(var1,[b]);
R2:=PolynomialRing(F,var2);
crvP1:=AffineCurve(b,R2);
div1:=DivisorOnAffineCurve([1,2,3,4],[Z(11)^2,Z(11)^3,Z(11)^7,Z(11)],crvP1);
DivisorDegree(div1);
div2:=DivisorOnAffineCurve([1,2,3,4],[Z(11),Z(11)^2,Z(11)^3,Z(11)^4],crvP1);
DivisorDegree(div2);
div3:=DivisorAddition(div1,div2);
DivisorDegree(div3);
DivisorIsEffective(div1);
DivisorIsEffective(div2);
ndiv1:=DivisorNegate(div1);
zdiv:=DivisorAddition(div1,ndiv1);
DivisorIsZero(zdiv);
div_gcd:=DivisorGCD(div1,div2);
div_lcm:=DivisorLCM(div1,div2);
DivisorDegree(div_gcd);
DivisorDegree(div_lcm);
DivisorEqual(div3,DivisorAddition(div_gcd,div_lcm));
-->
</Description>
</ManSection>
Let <M>G</M> denote a finite subgroup of <M>PGL(2,F)</M> and let
<M>D</M> denote a divisor on the projective line <M>\mathbb{P}^1(F)</M>.
If <M>G</M> leaves <M>D</M> unchanged (it may permute the
points in the support of <M>D</M> but must preserve
their sum in <M>D</M>) then the Riemann-Roch space
<M>L(D)</M> is a <M>G</M>-module. The commands in this section help explore
the <M>G</M>-module structure of <M>L(D)</M> in the case then the ground field
<M>F</M> is finite.
<P/>
<ManSection>
<Func Name="RiemannRochSpaceBasisFunctionP1 " Arg ="P,k,R2 "/>
<Description>
Input:
<A>R2</A> is a polynomial ring in two variables, say <M>F[x,y]</M>;
<A>P</A> is an element of the base field, say <M>F</M>;
<A>k</A> is an integer.
Output: <M>1/(x-P)^k</M>
</Description>
</ManSection>
<ManSection>
<Func Name="DivisorOfRationalFunctionP1 " Arg ="f, R "/>
<Description>
Here <M>R = F[x,y]</M> is a polynomial ring in
the variables <M>x,y</M> and <M>f</M> is a rational function of <M>x</M>.
Simply returns the principal divisor on <M>{\mathbb{P}}^1</M>
associated to <M>f</M>.
<Example>
gap> F:=GF(11);
GF(11)
gap> R1:=PolynomialRing(F,["a"]);;
gap> var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
gap> b:=X(F,"b",var1);
b
gap> var2:=Concatenation(var1,[b]);
[ a, b ]
gap> R2:=PolynomialRing(F,var2);
PolynomialRing(..., [ a, b ])
gap> pt:=Z(11);
Z(11)
gap> f:=RiemannRochSpaceBasisFunctionP1(pt,2,R2);
(Z(11)^0)/(a^2+Z(11)^7*a+Z(11)^2)
gap> Df:=DivisorOfRationalFunctionP1(f,R2);
rec( coeffs := [ -2 ], support := [ Z(11) ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := a )
)
gap> Df.support;
[ Z(11) ]
gap> F:=GF(11);;
gap> R:=PolynomialRing(F,2);;
gap> vars:=IndeterminatesOfPolynomialRing(R);;
gap> a:=vars[1];;
gap> b:=vars[2];;
gap> f:=(a^4+Z(11)^6*a^3-a^2+Z(11)^7*a+Z(11)^0)/(a^4+Z(11)*a^2+Z(11)^7*a+Z(11));;
gap> divf:=DivisorOfRationalFunctionP1(f,R);
rec( coeffs := [ 3, 1 ], support := [ Z(11), Z(11)^7 ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := a ) )
gap> denf:=DenominatorOfRationalFunction(f); RootsOfUPol(denf);
a^4+Z(11)*a^2+Z(11)^7*a+Z(11)
[ ]
gap> numf:=NumeratorOfRationalFunction(f); RootsOfUPol(numf);
a^4+Z(11)^6*a^3-a^2+Z(11)^7*a+Z(11)^0
[ Z(11)^7, Z(11), Z(11), Z(11) ]
</Example>
<!--
F:=GF(11);
R1:=PolynomialRing(F,["a"]);;
var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
b:=X(F,"b",var1);
var2:=Concatenation(var1,[b]);
R2:=PolynomialRing(F,var2);
pt:=Z(11);
f:=RiemannRochSpaceBasisFunctionP1(pt,2,R2);
Df:=DivisorOfRationalFunctionP1(f,R2);
Df.support;
F:=GF(11);;
R:=PolynomialRing(F,2);;
vars:=IndeterminatesOfPolynomialRing(R);;
a:=vars[1];;
b:=vars[2];;
f:=(a^4+Z(11)^6*a^3-a^2+Z(11)^7*a+Z(11)^0)/(a^4+Z(11)*a^2+Z(11)^7*a+Z(11));;
divf:=DivisorOfRationalFunctionP1(f,R);
denf:=DenominatorOfRationalFunction(f); RootsOfUPol(denf);
numf:=NumeratorOfRationalFunction(f); RootsOfUPol(numf);
-->
</Description>
</ManSection>
<ManSection>
<Func Name="RiemannRochSpaceBasisP1 " Arg ="D "/>
<Description>
This returns the basis of the Riemann-Roch space <M>L(D)</M>
associated to the divisor <A>D</A> on the projective line
<M>{\mathbb{P}}^1</M>.
</Description>
</ManSection>
<Example>
gap> F:=GF(11);
GF(11)
gap> R1:=PolynomialRing(F,["a"]);;
gap> var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
gap> b:=X(F,"b",var1);
b
gap> var2:=Concatenation(var1,[b]);
[ a, b ]
gap> R2:=PolynomialRing(F,var2);
PolynomialRing(..., [ a, b ])
gap> crvP1:=AffineCurve(b,R2);
rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b )
gap> D:=DivisorOnAffineCurve([1,2,3,4],[Z(11)^2,Z(11)^3,Z(11)^7,Z(11)],crvP1);
rec( coeffs := [ 1, 2, 3, 4 ],
support := [ Z(11)^2, Z(11)^3, Z(11)^7, Z(11) ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> B:=RiemannRochSpaceBasisP1(D);
[ Z(11)^0, (Z(11)^0)/(a+Z(11)^7), (Z(11)^0)/(a+Z(11)^8),
(Z(11)^0)/(a^2+Z(11)^9*a+Z(11)^6), (Z(11)^0)/(a+Z(11)^2),
(Z(11)^0)/(a^2+Z(11)^3*a+Z(11)^4), (Z(11)^0)/(a^3+a^2+Z(11)^2*a+Z(11)^6),
(Z(11)^0)/(a+Z(11)^6), (Z(11)^0)/(a^2+Z(11)^7*a+Z(11)^2),
(Z(11)^0)/(a^3+Z(11)^4*a^2+a+Z(11)^8),
(Z(11)^0)/(a^4+Z(11)^8*a^3+Z(11)*a^2+a+Z(11)^4) ]
gap> DivisorOfRationalFunctionP1(B[1],R2).support;
[ ]
gap> DivisorOfRationalFunctionP1(B[2],R2).support;
[ Z(11)^2 ]
gap> DivisorOfRationalFunctionP1(B[3],R2).support;
[ Z(11)^3 ]
gap> DivisorOfRationalFunctionP1(B[4],R2).support;
[ Z(11)^3 ]
gap> DivisorOfRationalFunctionP1(B[5],R2).support;
[ Z(11)^7 ]
gap> DivisorOfRationalFunctionP1(B[6],R2).support;
[ Z(11)^7 ]
gap> DivisorOfRationalFunctionP1(B[7],R2).support;
[ Z(11)^7 ]
gap> DivisorOfRationalFunctionP1(B[8],R2).support;
[ Z(11) ]
gap> DivisorOfRationalFunctionP1(B[9],R2).support;
[ Z(11) ]
gap> DivisorOfRationalFunctionP1(B[10],R2).support;
[ Z(11) ]
gap> DivisorOfRationalFunctionP1(B[11],R2).support;
[ Z(11) ]
</Example>
<!--
F:=GF(11);
R1:=PolynomialRing(F,["a"]);;
var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
b:=X(F,"b",var1);
var2:=Concatenation(var1,[b]);
R2:=PolynomialRing(F,var2);
crvP1:=AffineCurve(b,R2);
D:=DivisorOnAffineCurve([1,2,3,4],[Z(11)^2,Z(11)^3,Z(11)^7,Z(11)],crvP1);
B:=RiemannRochSpaceBasisP1(D);
DivisorOfRationalFunctionP1(B[1],R2).support;
DivisorOfRationalFunctionP1(B[2],R2).support;
DivisorOfRationalFunctionP1(B[3],R2).support;
DivisorOfRationalFunctionP1(B[4],R2).support;
DivisorOfRationalFunctionP1(B[5],R2).support;
DivisorOfRationalFunctionP1(B[6],R2).support;
DivisorOfRationalFunctionP1(B[7],R2).support;
DivisorOfRationalFunctionP1(B[8],R2).support;
DivisorOfRationalFunctionP1(B[9],R2).support;
DivisorOfRationalFunctionP1(B[10],R2).support;
DivisorOfRationalFunctionP1(B[11],R2).support;
-->
<ManSection>
<Func Name="MoebiusTransformation " Arg ="A,R "/>
<Description>
The arguments are a <M>2\times 2</M> matrix <M>A</M>
with entries in a field <M>F</M>
and a polynomial ring <A>R</A>of
one variable, say <M>F[x]</M>.
This function returns the linear fractional
transformatio associated to <A>A</A>.
These transformations can be composed with each other
using GAP's <C>Value</C> command.
</Description>
</ManSection>
<ManSection>
<Func Name="ActionMoebiusTransformationOnFunction " Arg ="A,f,R2 "/>
<Description>
The arguments are a <M>2\times 2</M> matrix <M>A</M>
with entries in a field <M>F</M>, a rational function
<A>f</A> of one variable, say in <M>F(x)</M>,
and a polynomial ring <A>R2</A>, say <M>F[x,y]</M>.
This function simply returns the composition of the
function <A>f</A> with the Möbius transformation
of <A>A</A>.
</Description>
</ManSection>
<ManSection>
<Func Name="ActionMoebiusTransformationOnDivisorP1 " Arg ="A,D "/>
<Description>
A Möbius transformation may be regarded as an automorphism
of the projective line <M>\mathbb{P}^1</M>. This function simply
returns the image of the divisor <A>D</A> under
the Möbius transformation defined by <A>A</A>,
provided that
<C>IsActionMoebiusTransformationOnDivisorDefinedP1(A,D)</C>
returns true.
</Description>
</ManSection>
<ManSection>
<Func Name="IsActionMoebiusTransformationOnDivisorDefinedP1 " Arg ="A,D "/>
<Description>
Returns true of none of the points in the support of the
divisor <A>D</A> is the pole of the Möbius transformation.
<Example>
gap> F:=GF(11);
GF(11)
gap> R1:=PolynomialRing(F,["a"]);;
gap> var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
gap> b:=X(F,"b",var1);
b
gap> var2:=Concatenation(var1,[b]);
[ a, b ]
gap> R2:=PolynomialRing(F,var2);
PolynomialRing(..., [ a, b ])
gap> crvP1:=AffineCurve(b,R2);
rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b )
gap> D:=DivisorOnAffineCurve([1,2,3,4],[Z(11)^2,Z(11)^3,Z(11)^7,Z(11)],crvP1);
rec( coeffs := [ 1, 2, 3, 4 ],
support := [ Z(11)^2, Z(11)^3, Z(11)^7, Z(11) ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> A:=Z(11)^0*[[1,2],[1,4]];
[ [ Z(11)^0, Z(11) ], [ Z(11)^0, Z(11)^2 ] ]
gap> ActionMoebiusTransformationOnDivisorDefinedP1(A,D);
false
gap> A:=Z(11)^0*[[1,2],[3,4]];
[ [ Z(11)^0, Z(11) ], [ Z(11)^8, Z(11)^2 ] ]
gap> ActionMoebiusTransformationOnDivisorDefinedP1(A,D);
true
gap> ActionMoebiusTransformationOnDivisorP1(A,D);
rec( coeffs := [ 1, 2, 3, 4 ],
support := [ Z(11)^5, Z(11)^6, Z(11)^8, Z(11)^7 ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> f:=MoebiusTransformation(A,R1);
(a+Z(11))/(Z(11)^8*a+Z(11)^2)
gap> ActionMoebiusTransformationOnFunction(A,f,R1);
-Z(11)^0+Z(11)^3*a^-1
</Example>
<!--
F:=GF(11);
R1:=PolynomialRing(F,["a"]);;
var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
b:=X(F,"b",var1);
var2:=Concatenation(var1,[b]);
R2:=PolynomialRing(F,var2);
crvP1:=AffineCurve(b,R2);
D:=DivisorOnAffineCurve([1,2,3,4],[Z(11)^2,Z(11)^3,Z(11)^7,Z(11)],crvP1);
A:=Z(11)^0*[[1,2],[1,4]];
ActionMoebiusTransformationOnDivisorDefinedP1(A,D);
A:=Z(11)^0*[[1,2],[3,4]];
ActionMoebiusTransformationOnDivisorDefinedP1(A,D);
ActionMoebiusTransformationOnDivisorP1(A,D);
f:=MoebiusTransformation(A,R1);
ActionMoebiusTransformationOnFunction(A,f,R1);
-->
</Description>
</ManSection>
<ManSection>
<Func Name="DivisorAutomorphismGroupP1 " Arg ="D "/>
<Description>
Input: A divisor <A>D</A> on <M>\mathbb{P}^1(F)</M>,
where <M>F</M> is a finite field.
Output: A subgroup <M>Aut(D)\subset Aut(\mathbb{P}^1)</M>
preserving <A>D</A>.
<P/>
Very slow.
<Example>
gap> F:=GF(11);
GF(11)
gap> R1:=PolynomialRing(F,["a"]);;
gap> var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
gap> b:=X(F,"b",var1);
b
gap> var2:=Concatenation(var1,[b]);
[ a, b ]
gap> R2:=PolynomialRing(F,var2);
PolynomialRing(..., [ a, b ])
gap> crvP1:=AffineCurve(b,R2);
rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b )
gap> D:=DivisorOnAffineCurve([1,2,3,4],[Z(11)^2,Z(11)^3,Z(11)^7,Z(11)],crvP1);
rec( coeffs := [ 1, 2, 3, 4 ],
support := [ Z(11)^2, Z(11)^3, Z(11)^7, Z(11) ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> agp:=DivisorAutomorphismGroupP1(D);; time;
7305
gap> IdGroup(agp);
[ 10, 2 ]
</Example>
<!--
F:=GF(11);
R1:=PolynomialRing(F,["a"]);;
var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
b:=X(F,"b",var1);
var2:=Concatenation(var1,[b]);
R2:=PolynomialRing(F,var2);
crvP1:=AffineCurve(b,R2);
D:=DivisorOnAffineCurve([1,2,3,4],[Z(11)^2,Z(11)^3,Z(11)^7,Z(11)],crvP1);
agp:=DivisorAutomorphismGroupP1(D);; time;
IdGroup(agp);
-->
</Description>
</ManSection>
<ManSection>
<Func Name="MatrixRepresentationOnRiemannRochSpaceP1 " Arg ="g,D "/>
<Description>
Input: An element <A>g</A> in <M>G</M>, a subgroup
of <M>Aut(D)\subset Aut(\mathbb{P}^1)</M>, and a divisor
<A>D</A> on <M>\mathbb{P}^1(F)</M>, where
<M>F</M> is a finite field.
Output: a <M>d\times d</M> matrix, where <M>d = dim\, L(D)</M>,
representing the action of <A>g</A> on <M>L(D)</M>.
<P/>
Note: <A>g</A> sends <M>L(D)</M> to <M>r\cdot L(D)</M>, where
<M>r</M> is a polynomial of degree <M>1</M> depending on
<A>g</A> and <A>D</A>.
<P/>
Also very slow.
<P/>
The GAP command <C>BrauerCharacterValue</C>
can be used to ``lift'' the eigenvalues of this
matrix to the complex numbers.
<P/>
<Example>
gap> F:=GF(11);
GF(11)
gap> R1:=PolynomialRing(F,["a"]);;
gap> var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
gap> b:=X(F,"b",var1);
b
gap> var2:=Concatenation(var1,[b]);
[ a, b ]
gap> R2:=PolynomialRing(F,var2);
PolynomialRing(..., [ a, b ])
gap> crvP1:=AffineCurve(b,R2);
rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b )
gap> D:=DivisorOnAffineCurve([1,1,1,4],[Z(11)^2,Z(11)^3,Z(11)^7,Z(11)],crvP1);
rec( coeffs := [ 1, 1, 1, 4 ],
support := [ Z(11)^2, Z(11)^3, Z(11)^7, Z(11) ],
curve := rec( ring := PolynomialRing(..., [ a, b ]), polynomial := b ) )
gap> agp:=DivisorAutomorphismGroupP1(D);; time;
7198
gap> IdGroup(agp);
[ 20, 5 ]
gap> g:=Random(agp);
[ [ Z(11)^4, Z(11)^9 ], [ Z(11)^0, Z(11)^9 ] ]
gap> rho:=MatrixRepresentationOnRiemannRochSpaceP1(g,D);
[ [ Z(11)^0, 0*Z(11), 0*Z(11), 0*Z(11), 0*Z(11), 0*Z(11), 0*Z(11), 0*Z(11) ],
[ Z(11)^0, 0*Z(11), 0*Z(11), Z(11), 0*Z(11), 0*Z(11), 0*Z(11), 0*Z(11) ],
[ Z(11)^7, 0*Z(11), Z(11)^5, 0*Z(11), 0*Z(11), 0*Z(11), 0*Z(11), 0*Z(11) ],
[ Z(11)^4, Z(11)^9, 0*Z(11), 0*Z(11), 0*Z(11), 0*Z(11), 0*Z(11), 0*Z(11) ],
[ Z(11)^2, 0*Z(11), 0*Z(11), 0*Z(11), Z(11)^5, 0*Z(11), 0*Z(11), 0*Z(11) ],
[ Z(11)^4, 0*Z(11), 0*Z(11), 0*Z(11), Z(11)^8, Z(11)^0, 0*Z(11), 0*Z(11) ],
[ Z(11)^6, 0*Z(11), 0*Z(11), 0*Z(11), Z(11)^7, Z(11)^0, Z(11)^5, 0*Z(11) ],
[ Z(11)^8, 0*Z(11), 0*Z(11), 0*Z(11), Z(11)^3, Z(11)^3, Z(11)^9, Z(11)^0 ] ]
gap> Display(rho);
1 . . . . . . .
1 . . 2 . . . .
7 . 10 . . . . .
5 6 . . . . . .
4 . . . 10 . . .
5 . . . 3 1 . .
9 . . . 7 1 10 .
3 . . . 8 8 6 1
</Example>
</Description>
</ManSection>
<!--
F:=GF(11);
R1:=PolynomialRing(F,["a"]);;
var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
b:=X(F,"b",var1);
var2:=Concatenation(var1,[b]);
R2:=PolynomialRing(F,var2);
crvP1:=AffineCurve(b,R2);
D:=DivisorOnAffineCurve([1,1,1,4],[Z(11)^2,Z(11)^3,Z(11)^7,Z(11)],crvP1);
agp:=DivisorAutomorphismGroupP1(D);; time;
IdGroup(agp);
g:=Random(agp);
rho:=MatrixRepresentationOnRiemannRochSpaceP1(g,D);
Display(rho);
Eigenvalues(F,rho);
charpoly:=CharacteristicPolynomail(rho);
Factors(charpoly);
JordanDecomposition(rho);
-->
<!--
<ManSection Label="XingLingCode">
<Func Name="XingLingCode" Arg=" k R "/>
<Description>
Input: An integer <M>k<M> and a polynomial ring in one
variable <M>R=F[x]<M>.
<Br/>
Output: The associated Xing-Ling code.
<P/>
For a reference, see .....
</Description>
</ManSection>
<Example>
F:=GF(11);;
R:=PolynomialRing(F,1);;
vars:=IndeterminatesOfPolynomialRing(R);;
a:=vars[1];;
C:=XingLingCode(25,R);
F:=GF(3);;
R:=PolynomialRing(F,1);;
vars:=IndeterminatesOfPolynomialRing(R);;
a:=vars[1];;
C:=XingLingCode(7,R);
MinimumDistance(C);
F:=GF(4);;
R:=PolynomialRing(F,1);;
vars:=IndeterminatesOfPolynomialRing(R);;
a:=vars[1];;
C:=XingLingCode(9,R);
MinimumDistance(C);
F:=GF(7);;
R:=PolynomialRing(F,1);;
vars:=IndeterminatesOfPolynomialRing(R);;
a:=vars[1];;
C:=XingLingCode(15,R);
MinimumDistance(C);
</Example>
-->
<ManSection Label="GoppaCodeClassical">
<Func Name="GoppaCodeClassical" Arg=" div pts "/>
<Description>
Input: A divisor <A>div</A> on the projective line
<M>{\mathbb{P}}^1(F)</M> over a finite field <M>F</M>
and a list <A>pts</A> of points <M>\{P_1,...,P_n\}\subset F</M>
disjoint from the support of <A>div</A>.
<Br/>
Output: The classical (evaluation) Goppa code associated
to this data. This is the code
<Display>
C=\{(f(P_1),...,f(P_n))\ |\ f\in L(D)_F\}.
</Display>
</Description>
</ManSection>
<Example>
gap> F:=GF(11);;
gap> R2:=PolynomialRing(F,2);;
gap> vars:=IndeterminatesOfPolynomialRing(R2);;
gap> a:=vars[1];;b:=vars[2];;
gap> cdiv:=[ 1, 2, -1, -2 ];
[ 1, 2, -1, -2 ]
gap> sdiv:=[ Z(11)^2, Z(11)^3, Z(11)^6, Z(11)^9 ];
[ Z(11)^2, Z(11)^3, Z(11)^6, Z(11)^9 ]
gap> crv:=rec(polynomial:=b,ring:=R2);
rec( polynomial := x_2, ring := PolynomialRing(..., [ x_1, x_2 ]) )
gap> div:=DivisorOnAffineCurve(cdiv,sdiv,crv);
rec( coeffs := [ 1, 2, -1, -2 ], support := [ Z(11)^2, Z(11)^3, Z(11)^6, Z(11)^9 ],
curve := rec( polynomial := x_2, ring := PolynomialRing(..., [ x_1, x_2 ]) ) )
gap> pts:=Difference(Elements(GF(11)),div.support);
[ 0*Z(11), Z(11)^0, Z(11), Z(11)^4, Z(11)^5, Z(11)^7, Z(11)^8 ]
gap> C:=GoppaCodeClassical(div,pts);
a linear [7,2,1..6]4..5 code defined by generator matrix over GF(11)
gap> MinimumDistance(C);
6
</Example>
<!--
F:=GF(11);;
R2:=PolynomialRing(F,2);;
vars:=IndeterminatesOfPolynomialRing(R2);;
a:=vars[1];;b:=vars[2];;
cdiv:=[ 1, 2, -1, -2 ];
sdiv:=[ Z(11)^2, Z(11)^3, Z(11)^6, Z(11)^9 ];
crv:=rec(polynomial:=b,ring:=R2);
div:=DivisorOnAffineCurve(cdiv,sdiv,crv);
pts:=Difference(Elements(GF(11)),div.support);
C:=GoppaCodeClassical(div,pts);
MinimumDistance(C);
-->
<ManSection Label="EvaluationBivariateCode">
<Func Name="EvaluationBivariateCode" Arg=" pts L crv"/>
<Description>
Input: <C>pts</C> is a set of affine points on <C>crv</C>,
<C>L</C> is a list of rational functions on <C>crv</C>.
<Br/>
Output: The evaluation code associated to the points
in <C>pts</C> and functions in <C>L</C>,
but specifically for affine plane curves
and this function
checks if points are "bad" (if so removes them
from the list <C>pts</C> automatically).
A point is ``bad'' if either it does not lie on the
set of non-singular <M>F</M>-rational points
(places of degree 1) on the curve.
<P/>
Very similar to <C>EvaluationCode</C>
(see <Ref Func="EvaluationCode" Style="Number"/>
for a more general construction).
</Description>
</ManSection>
<ManSection Label="EvaluationBivariateCodeNC">
<Func Name="EvaluationBivariateCodeNC" Arg=" pts L crv "/>
<Description>
As in <C>EvaluationBivariateCode</C> but does not
check if the points are ``bad''.
<P/>
Input: <C>pts</C> is a set of affine points on <C>crv</C>,
<C>L</C> is a list of rational functions on <C>crv</C>.
<Br/>
Output: The evaluation code associated to the points
in <C>pts</C> and functions in <C>L</C>.
</Description>
</ManSection>
<Example>
gap> q:=4;;
gap> F:=GF(q^2);;
gap> R:=PolynomialRing(F,2);;
gap> vars:=IndeterminatesOfPolynomialRing(R);;
gap> x:=vars[1];;
gap> y:=vars[2];;
gap> crv:=AffineCurve(y^q+y-x^(q+1),R);
rec( ring := PolynomialRing(..., [ x_1, x_2 ]), polynomial := x_1^5+x_2^4+x_2 )
gap> L:=[ x^0, x, x^2*y^-1 ];
[ Z(2)^0, x_1, x_1^2/x_2 ]
gap> Pts:=AffinePointsOnCurve(crv.polynomial,crv.ring,F);;
gap> C1:=EvaluationBivariateCode(Pts,L,crv); time;
Automatically removed the following 'bad' points (either a pole or not
on the curve):
[ [ 0*Z(2), 0*Z(2) ] ]
a linear [63,3,1..60]51..59 evaluation code over GF(16)
52
gap> P:=Difference(Pts,[[ 0*Z(2^4)^0, 0*Z(2)^0 ]]);;
gap> C2:=EvaluationBivariateCodeNC(P,L,crv); time;
a linear [63,3,1..60]51..59 evaluation code over GF(16)
48
gap> C3:=EvaluationCode(P,L,R); time;
a linear [63,3,1..56]51..59 evaluation code over GF(16)
58
gap> MinimumDistance(C1);
56
gap> MinimumDistance(C2);
56
gap> MinimumDistance(C3);
56
gap>
</Example>
<!--
q:=4;;
F:=GF(q^2);;
R:=PolynomialRing(F,2);;
vars:=IndeterminatesOfPolynomialRing(R);;
x:=vars[1];;
y:=vars[2];;
crv:=AffineCurve(y^q+y-x^(q+1),R);
L:=[ x^0, x, x^2*y^-1 ];
Pts:=AffinePointsOnCurve(crv.polynomial,crv.ring,F);;
C1:=EvaluationBivariateCode(Pts,L,crv); time;
P:=Difference(Pts,[[ 0*Z(2^4)^0, 0*Z(2)^0 ]]);;
C2:=EvaluationBivariateCodeNC(P,L,crv); time;
C3:=EvaluationCode(P,L,R); time;
MinimumDistance(C1);
MinimumDistance(C2);
MinimumDistance(C3);
-->
<ManSection Label="OnePointAGCode">
<Func Name="OnePointAGCode" Arg=" f P m R "/>
<Description>
Input: <A>f</A> is a polynomial in R=F[x,y], where
<A>F</A> is a finite field,
<A>m</A> is a positive integer (the multiplicity of the
`point at infinity' <M>\infty</M> on the curve <M>f(x,y)=0</M>),
<A>P</A> is a list of <M>n</M> points on the curve over <M>F</M>.
<Br/>
Output: The <M>C</M> which is the image of the
evaluation map
<Display>
Eval_P:L(m \cdot \infty)\rightarrow F^n,
</Display>
given by <M>f\longmapsto (f(p_1),...,f(p_n))</M>,
where <M>p_i \in P</M>.
Here <M>L(m \cdot \infty)</M> denotes the Riemann-Roch
space of the divisor <M>m \cdot \infty</M> on the curve.
This has a basis consisting of monomials
<M>x^iy^j</M>, where <M>(i,j)</M> range over a
polygon depending on <M>m</M> and <M>f(x,y)</M>.
For more details on the Riemann-Roch
space of the divisor <M>m \cdot \infty</M> see
Proposition III.10.5 in Stichtenoth <Cite Key="St93"/>.
<P/>
This command returns a "record" object <C>C</C>
with several extra components (type <C>NamesOfComponents(C)</C>
to see them all): <C>C!.points</C> (namely <A>P</A>),
<C>C!.multiplicity</C> (namely <A>m</A>),
<C>C!.curve</C> (namely <A>f</A>) and
<C>C!.ring</C> (namely <A>R</A>).
</Description>
</ManSection>
<Example>
gap> F:=GF(11);
GF(11)
gap> R := PolynomialRing(F,["x","y"]);
PolynomialRing(..., [ x, y ])
gap> indets := IndeterminatesOfPolynomialRing(R);
[ x, y ]
gap> x:=indets[1]; y:=indets[2];
x
y
gap> P:=AffinePointsOnCurve(y^2-x^11+x,R,F);;
gap> C:=OnePointAGCode(y^2-x^11+x,P,15,R);
a linear [11,8,1..0]2..3 one-point AG code over GF(11)
gap> MinimumDistance(C);
4
gap> Pts:=List([1,2,4,6,7,8,9,10,11],i->P[i]);;
gap> C:=OnePointAGCode(y^2-x^11+x,PT,10,R);
a linear [9,6,1..4]2..3 one-point AG code over GF(11)
gap> MinimumDistance(C);
4
</Example>
<!--
F:=GF(11);
R := PolynomialRing(F,["x","y"]);
indets := IndeterminatesOfPolynomialRing(R);
x:=indets[1]; y:=indets[2];
P:=AffinePointsOnCurve(y^2-x^11+x,R,F);;
C:=OnePointAGCode(y^2-x^11+x,P,15,R);
MinimumDistance(C);
Pts:=List([1,2,4,6,7,8,9,10,11],i->P[i]);;
C:=OnePointAGCode(y^2-x^11+x,Pts,10,R);
MinimumDistance(C);
-->
See <Ref Func="EvaluationCode" Style="Number"/>
for a more general construction.
</Section>
<Section>
<Heading>
Low-Density Parity-Check Codes
</Heading>
<Label Name="LDPC"/>
<Index>
LDPC
</Index>
Low-density parity-check (LDPC) codes form a class of linear
block codes whose parity-check matrix--as the name implies,
is sparse. LDPC codes were introduced by Robert Gallager
in 1962 <Cite Key="Gallager.1962"/> as his PhD work. Due to
the decoding complexity for the technology back then, these
codes were forgotten. Not until the late 1990s, these codes
were rediscovered and research results have shown that LDPC
codes can achieve near Shannon's capacity performance provided
that their block length is long enough and soft-decision
iterative decoder is employed. Note that the bit-flipping
decoder (see <C>BitFlipDecoder</C>) is a hard-decision
decoder and hence capacity achieving performance cannot
be achieved despite having a large block length.
<P/>
Based on the structure of their parity-check matrix, LDPC
codes may be categorised into two classes:
<List>
<Item>
Regular LDPC codes
<P/>
This class of codes has a fixed number of non zeros
per column and per row in their parity-check matrix.
These codes are usually denoted as <M>(n,j,k)</M>
codes where <M>n</M> is the block length, <M>j</M>
is the number of non zeros per column in their
parity-check matrix and <M>k</M> is the number of
non zeros per row in their parity-check matrix.
</Item>
<Item>
Irregular LDPC codes
<P/>
The irregular codes, on the other hand, do not have
a fixed number of non zeros per column and row in
their parity-check matrix. This class of codes are
commonly represented by two polynomials which denote
the distribution of the number of non zeros in the
columns and rows respectively of their parity-check
matrix.
</Item>
</List>
<ManSection Label="QCLDPCCodeFromGroup">
<Func Name="QCLDPCCodeFromGroup" Arg=" m j k "/>
<Description>
<C>QCLDCCodeFromGroup</C> produces an <M>(n,j,k)</M> regular
quasi-cyclic LDPC code over GF(2) of block length <M>n = mk</M>.
The term quasi-cyclic in the context of LDPC codes typically
refers to LDPC codes whose parity-check matrix <M>H</M> has
the following form
<Verb>
- -
| I_P(0,0) | I_P(0,1) | ... | I_P(0,k-1) |
| I_P(1,0) | I_P(1,1) | ... | I_P(1,k-1) |
H = | . | . | . | . |,
| . | . | . | . |
| I_P(j-1,0) | I_P(j-1,1) | ... | I_P(j-1,k-1) |
- -
</Verb>
where <M>I_{P(s,t)}</M> is an identity matrix of size
<M>m \times m</M> which has been shifted so that the
<M>1</M> on the first row starts at position <M>P(s,t)</M>.
<P/>
Let <M>F</M> be a multiplicative group of integers modulo
<M>m</M>. If <M>m</M> is a prime, <M>F=\{0,1,...,m-1\}</M>,
otherwise <M>F</M> contains a set of integers which are
relatively prime to <M>m</M>. In both cases, the order
of <M>F</M> is equal to <M>\phi(m)</M>. Let <M>a</M> and
<M>b</M> be non zeros of <M>F</M> such that the orders
of <M>a</M> and <M>b</M> are <M>k</M> and <M>j</M>
respectively. Note that the integers <M>a</M> and <M>b</M>
can always be found provided that <M>k</M> and <M>j</M>
respectively divide <M>\phi(m)</M>. Having obtain integers
<M>a</M> and <M>b</M>, construct the following <M>j \times k</M>
matrix <M>P</M> so that the element at row <M>s</M> and
column <M>t</M> is given by <M>P(s,t) = a^tb^s</M>, i.e.
<Verb>
- -
| 1 | a | . . . | a^{k-1} |
| b | ab | . . . | a^{k-1}b |
P = | . | . | . | . |.
| . | . | . | . |
| b^{j-1} | ab^{j-1} | . . . | a^{k-1}b^{j-1} |
- -
</Verb>
The parity-check matrix <M>H</M> of the LDPC code can be
obtained by expanding each element of matrix <M>P</M>, i.e.
<M>P(s,t)</M>, to an identity matrix <M>I_{P(s,t)}</M>
of size <M>m \times m</M>.
<P/>
The code rate <M>R</M> of the constructed code is given by
<Display>
R \geq 1 - \frac{j}{k}
</Display>
where the sign <M>\geq</M> is due to the possible
existence of some non linearly independent rows in <M>H</M>.
For more details to the paper by Tanner et al
<Cite Key="TSSFC04"/>.
</Description>
</ManSection>
<Example>
gap> C := QCLDPCCodeFromGroup(7,2,3);
a linear [21,8,1..6]5..10 low-density parity-check code over GF(2)
gap> MinimumWeight(C);
[21,8] linear code over GF(2) - minimum weight evaluation
Known lower-bound: 1
There are 3 generator matrices, ranks : 8 8 5
The weight of the minimum weight codeword satisfies 0 mod 2 congruence
Enumerating codewords with information weight 1 (w=1)
Found new minimum weight 6
Number of matrices required for codeword enumeration 2
Completed w= 1, 24 codewords enumerated, lower-bound 4, upper-bound 6
Termination expected with information weight 2 at matrix 1
-----------------------------------------------------------------------------
Enumerating codewords with information weight 2 (w=2) using 1 matrices
Completed w= 2, 28 codewords enumerated, lower-bound 6, upper-bound 6
-----------------------------------------------------------------------------
Minimum weight: 6
6
gap> # The quasi-cyclic structure is obvious from the check matrix
gap> Display( CheckMat(C) );
1 . . . . . . . 1 . . . . . . . . 1 . . .
. 1 . . . . . . . 1 . . . . . . . . 1 . .
. . 1 . . . . . . . 1 . . . . . . . . 1 .
. . . 1 . . . . . . . 1 . . . . . . . . 1
. . . . 1 . . . . . . . 1 . 1 . . . . . .
. . . . . 1 . . . . . . . 1 . 1 . . . . .
. . . . . . 1 1 . . . . . . . . 1 . . . .
. . . . . 1 . . . . . 1 . . . . 1 . . . .
. . . . . . 1 . . . . . 1 . . . . 1 . . .
1 . . . . . . . . . . . . 1 . . . . 1 . .
. 1 . . . . . 1 . . . . . . . . . . . 1 .
. . 1 . . . . . 1 . . . . . . . . . . . 1
. . . 1 . . . . . 1 . . . . 1 . . . . . .
. . . . 1 . . . . . 1 . . . . 1 . . . . .
gap> # This is the famous [155,64,20] quasi-cyclic LDPC codes
gap> C := QCLDPCCodeFromGroup(31,3,5);
a linear [155,64,1..24]24..77 low-density parity-check code over GF(2)
gap> # An example using non prime m, it may take a while to construct this code
gap> C := QCLDPCCodeFromGroup(356,4,8);
a linear [2848,1436,1..120]312..1412 low-density parity-check code over GF(2)
</Example>
<!--
C := QCLDPCCodeFromGroup(7,2,3);
MinimumWeight(C);
# The quasi-cyclic structure is obvious from the check matrix
Display( CheckMat(C) );
# This is the famous [155,64,20] quasi-cyclic LDPC codes
C := QCLDPCCodeFromGroup(31,3,5);
# An example using non prime m, it may take a while to construct this code
C := QCLDPCCodeFromGroup(356,4,8);
-->
</Section>
</Chapter>
<Chapter>
<Heading>Manipulating Codes</Heading>
<Label Name="Manipulating Codes"/>
In this chapter we describe several functions
<Package>GUAVA</Package> uses to manipulate
codes. Some of the best codes are obtained by starting with for example a
BCH code, and manipulating it.
<P/>
In some cases, it is faster to perform calculations with a manipulated
code than to use the original code. For example, if the dimension of the
code is larger than half the word length, it is generally faster to
compute the weight distribution by first calculating the weight
distribution of the dual code than by directly calculating the weight
distribution of the original code. The size of the dual code is smaller
in these cases.
<P/>
Because <Package>GUAVA</Package> keeps all information in a
code record, in some cases the information can be preserved
after manipulations. Therefore, computations do not always have
to start from scratch.
<P/>
In Section
<Ref Label="Functions that Generate a New Code from a Given Code" Style="Number"/>,
we describe functions that take a code with certain parameters, modify it in
some way and return a different code (see
<Ref Func="ExtendedCode" Style="Number"/>,
<Ref Func="PuncturedCode" Style="Number"/>,
<Ref Func="EvenWeightSubcode" Style="Number"/>,
<Ref Func="PermutedCode" Style="Number"/>,
<Ref Func="ExpurgatedCode" Style="Number"/>,
<Ref Func="AugmentedCode" Style="Number"/>,
<Ref Func="RemovedElementsCode" Style="Number"/>,
<Ref Func="AddedElementsCode" Style="Number"/>,
<Ref Func="ShortenedCode" Style="Number"/>,
<Ref Func="LengthenedCode" Style="Number"/>,
<Ref Func="ResidueCode" Style="Number"/>,
<Ref Func="ConstructionBCode" Style="Number"/>,
<Ref Func="DualCode" Style="Number"/>,
<Ref Func="ConversionFieldCode" Style="Number"/>,
<Ref Func="ConstantWeightSubcode" Style="Number"/>,
<Ref Func="StandardFormCode" Style="Number"/> and
<Ref Func="CosetCode" Style="Number"/>).
In Section
<Ref Label="Functions that Generate a New Code from Two or More Given Codes" Style="Number"/>,
we describe functions that generate a new code out of two codes (see
<Ref Func="DirectSumCode" Style="Number"/>,
<Ref Func="UUVCode" Style="Number"/>,
<Ref Func="DirectProductCode" Style="Number"/>,
<Ref Func="IntersectionCode" Style="Number"/> and
<Ref Func="UnionCode" Style="Number"/>).
<Section>
<Heading>
Functions that Generate a New Code from a Given Code
</Heading>
<Label Name="Functions that Generate a New Code from a Given Code"/>
<Index>
Parity check
</Index>
<ManSection Label="ExtendedCode">
<Func Name="ExtendedCode" Arg=" C [i] "/>
<Description>
<C>ExtendedCode</C> extends the code <A>C</A> <A>i</A> times and
returns the result. <A>i</A> is equal to <M>1</M> by default.
Extending is done by adding a parity check bit after the
last coordinate. The coordinates of all codewords now add up to zero.
In the binary case, each codeword has even weight.
<P/>
The word length increases by <A>i</A>. The size of the code remains the
same. In the binary case, the minimum distance increases by one if it was
odd. In other cases, that is not always true.
<P/>
A cyclic code in general is no longer cyclic after extending.
</Description>
</ManSection>
<Example>
gap> C1 := HammingCode( 3, GF(2) );
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> C2 := ExtendedCode( C1 );
a linear [8,4,4]2 extended code
gap> IsEquivalent( C2, ReedMullerCode( 1, 3 ) );
true
gap> List( AsSSortedList( C2 ), WeightCodeword );
[ 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8 ]
gap> C3 := EvenWeightSubcode( C1 );
a linear [7,3,4]2..3 even weight subcode
</Example>
<!--
C1 := HammingCode( 3, GF(2) );
C2 := ExtendedCode( C1 );
IsEquivalent( C2, ReedMullerCode( 1, 3 ) );
List( AsSSortedList( C2 ), WeightCodeword );
C3 := EvenWeightSubcode( C1 );
-->
To undo extending, call <C>PuncturedCode</C> (see
<Ref Func="PuncturedCode" Style="Number"/>). The
function <C>EvenWeightSubcode</C> (see
<Ref Func="EvenWeightSubcode" Style="Number"/>) also returns a
related code with only even weights, but without changing its word
length.
<ManSection Label="PuncturedCode">
<Func Name="PuncturedCode" Arg=" C "/>
<Description>
<C>PuncturedCode</C> punctures <A>C</A> in the last column,
and returns the result. Puncturing is done simply by cutting
off the last column from each codeword. This means the word length
decreases by one. The minimum distance in general also decrease by one.
<P/>
This command can also be called with the syntax
<C>PuncturedCode( C, L )</C>. In this case,
<C>PuncturedCode</C> punctures <A>C</A> in the columns
specified by <A>L</A>, a list of integers.
All columns specified by <A>L</A> are omitted from each codeword.
If <M>l</M> is the length of <A>L</A> (so the number of removed
columns), the word length decreases by <M>l</M>. The minimum
distance can also decrease by <M>l</M> or less.
<P/>
Puncturing a cyclic code in general results in a non-cyclic code. If the
code is punctured in all the columns where a word of minimal weight is
unequal to zero, the dimension of the resulting code decreases.
</Description>
</ManSection>
<Example>
gap> C1 := BCHCode( 15, 5, GF(2) );
a cyclic [15,7,5]3..5 BCH code, delta=5, b=1 over GF(2)
gap> C2 := PuncturedCode( C1 );
a linear [14,7,4]3..5 punctured code
gap> ExtendedCode( C2 ) = C1;
false
gap> PuncturedCode( C1, [1,2,3,4,5,6,7] );
a linear [8,7,1]1 punctured code
gap> PuncturedCode( WholeSpaceCode( 4, GF(5) ) );
a linear [3,3,1]0 punctured code # The dimension decreased from 4 to 3
</Example>
<!--
C1 := BCHCode( 15, 5, GF(2) );
C2 := PuncturedCode( C1 );
ExtendedCode( C2 ) = C1;
PuncturedCode( C1, [1,2,3,4,5,6,7] );
PuncturedCode( WholeSpaceCode( 4, GF(5) ) );
-->
<C>ExtendedCode</C> extends the code again (see
<Ref Func="ExtendedCode" Style="Number"/>),
although in general this does not result in the old code.
<ManSection Label="EvenWeightSubcode">
<Func Name="EvenWeightSubcode" Arg=" C "/>
<Description>
<C>EvenWeightSubcode</C> returns the even weight subcode
of <A>C</A>, consisting of all codewords of <A>C</A> with even
weight. If <A>C</A> is a linear code and
contains words of odd weight, the resulting code has a dimension of one
less. The minimum distance always increases with one if it was odd. If
<A>C</A> is a binary cyclic code, and <M>g(x)</M> is its
generator polynomial, the even weight subcode either has
generator polynomial <M>g(x)</M> (if <M>g(x)</M> is
divisible by <M>x-1</M>) or <M>g(x)\cdot (x-1)</M>
(if no factor <M>x-1</M> was present in <M>g(x)</M>).
So the even weight subcode is again cyclic.
<P/>
Of course, if all codewords of <A>C</A> are already of even weight,
the returned code is equal to <A>C</A>.
</Description>
</ManSection>
<Example>
gap> C1 := EvenWeightSubcode( BCHCode( 8, 4, GF(3) ) );
an (8,33,4..8)3..8 even weight subcode
gap> List( AsSSortedList( C1 ), WeightCodeword );
[ 0, 4, 4, 4, 4, 4, 4, 6, 4, 4, 4, 4, 6, 4, 4, 6, 4, 4, 8, 6, 4, 6, 8, 4, 4,
4, 6, 4, 6, 8, 4, 6, 8 ]
gap> EvenWeightSubcode( ReedMullerCode( 1, 3 ) );
a linear [8,4,4]2 Reed-Muller (1,3) code over GF(2)
</Example>
<!--
C1 := EvenWeightSubcode( BCHCode( 8, 4, GF(3) ) );
List( AsSSortedList( C1 ), WeightCodeword );
EvenWeightSubcode( ReedMullerCode( 1, 3 ) );
-->
<C>ExtendedCode</C> also returns a related code of only even weights, but
without reducing its dimension (see
<Ref Func="ExtendedCode" Style="Number"/>).
<ManSection Label="PermutedCode">
<Func Name="PermutedCode" Arg=" C L "/>
<Description>
<C>PermutedCode</C> returns <A>C</A> after column permutations.
<A>L</A> (in GAP disjoint cycle notation)
is the permutation to be executed on the columns of <A>C</A>.
If <A>C</A> is cyclic, the result in general is no
longer cyclic. If a permutation results in the same code as
<A>C</A>, this permutation belongs to the automorphism group of
<A>C</A> (see
<Ref Func="AutomorphismGroup" Style="Number"/>).
In any case, the returned code is
equivalent to <A>C</A>
(see <Ref Func="IsEquivalent" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C1 := PuncturedCode( ReedMullerCode( 1, 4 ) );
a linear [15,5,7]5 punctured code
gap> C2 := BCHCode( 15, 7, GF(2) );
a cyclic [15,5,7]5 BCH code, delta=7, b=1 over GF(2)
gap> C2 = C1;
false
gap> p := CodeIsomorphism( C1, C2 );
( 2, 4,14, 9,13, 7,11,10, 6, 8,12, 5)
gap> C3 := PermutedCode( C1, p );
a linear [15,5,7]5 permuted code
gap> C2 = C3;
true
</Example>
<!--
C1 := PuncturedCode( ReedMullerCode( 1, 4 ) );
C2 := BCHCode( 15, 7, GF(2) );
C2 = C1;
p := CodeIsomorphism( C1, C2 );
C3 := PermutedCode( C1, p );
C2 = C3;
-->
<ManSection Label="ExpurgatedCode">
<Func Name="ExpurgatedCode" Arg=" C L "/>
<Description>
<C>ExpurgatedCode</C> expurgates the code <A>C</A>> by throwing
away codewords in list <A>L</A>. <A>C</A> must be a linear code.
<A>L</A> must be a list of codeword input.
The generator matrix of the new code no longer is a basis for the
codewords specified by <A>L</A>. Since the returned code is
still linear, it is very likely that, besides the words of
<A>L</A>, more codewords of <A>C</A> are no longer in the
new code.
</Description>
</ManSection>
<Example>
gap> C1 := HammingCode( 4 );; WeightDistribution( C1 );
[ 1, 0, 0, 35, 105, 168, 280, 435, 435, 280, 168, 105, 35, 0, 0, 1 ]
gap> L := Filtered( AsSSortedList(C1), i -> WeightCodeword(i) = 3 );;
gap> C2 := ExpurgatedCode( C1, L );
a linear [15,4,3..4]5..11 code, expurgated with 7 word(s)
gap> WeightDistribution( C2 );
[ 1, 0, 0, 0, 14, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
</Example>
<!--
C1 := HammingCode( 4 );; WeightDistribution( C1 );
L := Filtered( AsSSortedList(C1), i -> WeightCodeword(i) = 3 );;
C2 := ExpurgatedCode( C1, L );
WeightDistribution( C2 );
-->
This function does not work on non-linear codes.
For removing words from a non-linear code, use
<C>RemovedElementsCode</C> (see
<Ref Func="RemovedElementsCode" Style="Number"/>).
For expurgating a code of all words of odd
weight, use `EvenWeightSubcode' (see
<Ref Func="EvenWeightSubcode" Style="Number"/>).
<ManSection Label="AugmentedCode">
<Func Name="AugmentedCode" Arg=" C L "/>
<Description>
<C>AugmentedCode</C> returns <A>C</A> after augmenting.
<A>C</A> must be a linear code, <A>L</A> must be a list of
codeword inputs. The generator matrix of the
new code is a basis for the codewords specified by <A>L</A>
as well as the words that were already in code <A>C</A>.
Note that the new code in general will consist of more
words than only the codewords of <A>C</A> and the words
<A>L</A>. The returned code is also a linear code.
<P/>
This command can also be called with the syntax
<C>AugmentedCode(C)</C>.
When called without a list of codewords,
<C>AugmentedCode</C> returns <A>C</A>
after adding the all-ones vector to the generator matrix.
<A>C</A> must be a linear code.
If the all-ones vector was already in the code, nothing
happens and a copy of the argument is returned. If <A>C</A>
is a binary code which does not contain the all-ones vector,
the complement of all codewords is added.
</Description>
</ManSection>
<Example>
gap> C31 := ReedMullerCode( 1, 3 );
a linear [8,4,4]2 Reed-Muller (1,3) code over GF(2)
gap> C32 := AugmentedCode(C31,["00000011","00000101","00010001"]);
a linear [8,7,1..2]1 code, augmented with 3 word(s)
gap> C32 = ReedMullerCode( 2, 3 );
true
gap> C1 := CordaroWagnerCode(6);
a linear [6,2,4]2..3 Cordaro-Wagner code over GF(2)
gap> Codeword( [0,0,1,1,1,1] ) in C1;
true
gap> C2 := AugmentedCode( C1 );
a linear [6,3,1..2]2..3 code, augmented with 1 word(s)
gap> Codeword( [1,1,0,0,0,0] ) in C2;
true
</Example>
<!--
C31 := ReedMullerCode( 1, 3 );
C32 := AugmentedCode(C31,["00000011","00000101","00010001"]);
C32 = ReedMullerCode( 2, 3 );
C1 := CordaroWagnerCode(6);
Codeword( [0,0,1,1,1,1] ) in C1;
C2 := AugmentedCode( C1 );
Codeword( [1,1,0,0,0,0] ) in C2;
-->
The function <C>AddedElementsCode</C> adds elements to the codewords instead
of adding them to the basis (see
<Ref Func="AddedElementsCode" Style="Number"/>).
<ManSection Label="RemovedElementsCode">
<Func Name="RemovedElementsCode" Arg=" C L "/>
<Description>
<C>RemovedElementsCode</C> returns code <A>C</A> after removing
a list of codewords <A>L</A> from its elements. <A>L</A> must be a
list of codeword input. The result is an unrestricted code.
</Description>
</ManSection>
<Example>
gap> C1 := HammingCode( 4 );; WeightDistribution( C1 );
[ 1, 0, 0, 35, 105, 168, 280, 435, 435, 280, 168, 105, 35, 0, 0, 1 ]
gap> L := Filtered( AsSSortedList(C1), i -> WeightCodeword(i) = 3 );;
gap> C2 := RemovedElementsCode( C1, L );
a (15,2013,3..15)2..15 code with 35 word(s) removed
gap> WeightDistribution( C2 );
[ 1, 0, 0, 0, 105, 168, 280, 435, 435, 280, 168, 105, 35, 0, 0, 1 ]
gap> MinimumDistance( C2 );
3 # C2 is not linear, so the minimum weight does not have to
# be equal to the minimum distance
</Example>
<!--
C1 := HammingCode( 4 );; WeightDistribution( C1 );
L := Filtered( AsSSortedList(C1), i -> WeightCodeword(i) = 3 );;
C2 := RemovedElementsCode( C1, L );
WeightDistribution( C2 );
MinimumDistance( C2 );
-->
Adding elements to a code is done by the function
<C>AddedElementsCode</C>
(see
<Ref Func="AddedElementsCode" Style="Number"/>).
To remove codewords from the base of a linear
code, use <C>ExpurgatedCode</C> (see
<Ref Func="ExpurgatedCode" Style="Number"/>).
<ManSection Label="AddedElementsCode">
<Func Name="AddedElementsCode" Arg=" C L "/>
<Description>
<C>AddedElementsCode</C> returns code <A>C</A> after adding a
list of codewords <A>L</A> to its elements.
<A>L</A> must be a list of codeword input. The result is an
unrestricted code.
</Description>
</ManSection>
<Example>
gap> C1 := NullCode( 6, GF(2) );
a cyclic [6,0,6]6 nullcode over GF(2)
gap> C2 := AddedElementsCode( C1, [ "111111" ] );
a (6,2,1..6)3 code with 1 word(s) added
gap> IsCyclicCode( C2 );
true
gap> C3 := AddedElementsCode( C2, [ "101010", "010101" ] );
a (6,4,1..6)2 code with 2 word(s) added
gap> IsCyclicCode( C3 );
true
</Example>
<!--
C1 := NullCode( 6, GF(2) );
C2 := AddedElementsCode( C1, [ "111111" ] );
IsCyclicCode( C2 );
C3 := AddedElementsCode( C2, [ "101010", "010101" ] );
IsCyclicCode( C3 );
-->
To remove elements from a code, use <C>RemovedElementsCode</C> (see
<Ref Func="RemovedElementsCode" Style="Number"/>).
To add elements to the base of a linear code, use
<C>AugmentedCode</C> (see
<Ref Func="AugmentedCode" Style="Number"/>).
<ManSection Label="ShortenedCode">
<Func Name="ShortenedCode" Arg=" C [L] "/>
<Description>
<C>ShortenedCode( C )</C> returns the code <A>C</A> shortened by
taking a cross section. If <A>C</A> is a linear code, this is done
by removing all codewords that start with a non-zero entry, after which
the first column is cut off. If <A>C</A>
was a <M>[n,k,d]</M> code, the shortened code generally is a
<M>[n-1,k-1,d]</M> code. It is possible that the dimension
remains the same; it is also possible that the minimum distance
increases.
<P/>
If <A>C</A> is a non-linear code, <C>ShortenedCode</C> first
checks which finite
field element occurs most often in the first column of the codewords. The
codewords not starting with this element are removed from the code, after
which the first column is cut off. The resulting shortened code has at
least the same minimum distance as <A>C</A>.
<P/>
This command can also be called using the syntax
<C>ShortenedCode(C,L)</C>.
When called in this format, <C>ShortenedCode</C> repeats the
shortening process on each of the columns specified by <A>L</A>.
<A>L</A> therefore is a list of integers. The column numbers in
<A>L</A> are the numbers as they are before the shortening process.
If <A>L</A> has <M>l</M> entries, the returned code has a word
length of <M>l</M> positions shorter than <A>C</A>.
</Description>
</ManSection>
<Example>
gap> C1 := HammingCode( 4 );
a linear [15,11,3]1 Hamming (4,2) code over GF(2)
gap> C2 := ShortenedCode( C1 );
a linear [14,10,3]2 shortened code
gap> C3 := ElementsCode( ["1000", "1101", "0011" ], GF(2) );
a (4,3,1..4)2 user defined unrestricted code over GF(2)
gap> MinimumDistance( C3 );
2
gap> C4 := ShortenedCode( C3 );
a (3,2,2..3)1..2 shortened code
gap> AsSSortedList( C4 );
[ [ 0 0 0 ], [ 1 0 1 ] ]
gap> C5 := HammingCode( 5, GF(2) );
a linear [31,26,3]1 Hamming (5,2) code over GF(2)
gap> C6 := ShortenedCode( C5, [ 1, 2, 3 ] );
a linear [28,23,3]2 shortened code
gap> OptimalityLinearCode( C6 );
0
</Example>
<!--
C1 := HammingCode( 4 );
C2 := ShortenedCode( C1 );
C3 := ElementsCode( ["1000", "1101", "0011" ], GF(2) );
MinimumDistance( C3 );
C4 := ShortenedCode( C3 );
AsSSortedList( C4 );
C5 := HammingCode( 5, GF(2) );
C6 := ShortenedCode( C5, [ 1, 2, 3 ] );
OptimalityLinearCode( C6 );
-->
The function <C>LengthenedCode</C> lengthens the code again (only for linear
codes), see
<Ref Func="LengthenedCode" Style="Number"/>.
In general, this is not exactly the inverse function.
<ManSection Label="LengthenedCode">
<Func Name="LengthenedCode" Arg=" C [i] "/>
<Description>
<C>LengthenedCode( C )</C> returns the code <A>C</A> lengthened.
<A>C</A> must be a linear code. First, the all-ones vector is
added to the generator matrix (see
<Ref Func="AugmentedCode" Style="Number"/>).
If the all-ones vector was already a codeword, nothing
happens to the code. Then, the code is extended <A>i</A> times (see
<Ref Func="ExtendedCode" Style="Number"/>). <A>i</A> is equal to
<M>1</M> by default. If <A>C</A> was an <M>[n,k]</M>
code, the new code generally is a <M>[n+i,k+1]</M> code.
</Description>
</ManSection>
<Example>
gap> C1 := CordaroWagnerCode( 5 );
a linear [5,2,3]2 Cordaro-Wagner code over GF(2)
gap> C2 := LengthenedCode( C1 );
a linear [6,3,2]2..3 code, lengthened with 1 column(s)
</Example>
<!--
C1 := CordaroWagnerCode( 5 );
C2 := LengthenedCode( C1 );
-->
<C>ShortenedCode</C>' shortens the code, see
<Ref Func="ShortenedCode" Style="Number"/>. In general, this
is not exactly the inverse function.
<ManSection Label="SubCode">
<Func Name="SubCode" Arg=" C [s] "/>
<Description>
This function <C>SubCode</C> returns a subcode of
<A>C</A> by taking the first <M>k - s</M> rows of
the generator matrix of <A>C</A>, where <M>k</M>
is the dimension of <A>C</A>. The interger <A>s</A>
may be omitted and in this case it is assumed as 1.
</Description>
</ManSection>
<Example>
gap> C := BCHCode(31,11);
a cyclic [31,11,11]7..11 BCH code, delta=11, b=1 over GF(2)
gap> S1:= SubCode(C);
a linear [31,10,11]7..13 subcode
gap> WeightDistribution(S1);
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 190, 0, 0, 272, 255, 0, 0, 120, 66,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
gap> S2:= SubCode(C, 8);
a linear [31,3,11]14..20 subcode
gap> History(S2);
[ "a linear [31,3,11]14..20 subcode of",
"a cyclic [31,11,11]7..11 BCH code, delta=11, b=1 over GF(2)" ]
gap> WeightDistribution(S2);
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0 ]
</Example>
<!--
C := BCHCode(31,11);
S1:= SubCode(C);
WeightDistribution(S1);
S2:= SubCode(C, 8);
History(S2);
WeightDistribution(S2);
-->
<ManSection Label="ResidueCode">
<Func Name="ResidueCode" Arg=" C [c] "/>
<Description>
The function <C>ResidueCode</C> takes a codeword <A>c</A>
of <A>C</A> (if <A>c</A> is omitted, a
codeword of minimal weight is used).
It removes this word and all its linear combinations from
the code and then punctures the code in the coordinates
where <A>c</A> is unequal to zero. The resulting code is an
<M>[n-w, k-1, d-\lfloor w*(q-1)/q \rfloor ]</M> code.
<A>C</A> must be a
linear code and <A>c</A> must be non-zero.
If <A>c</A> is not in <A></A> then no change is made to <A>C</A>.
</Description>
</ManSection>
<Example>
gap> C1 := BCHCode( 15, 7 );
a cyclic [15,5,7]5 BCH code, delta=7, b=1 over GF(2)
gap> C2 := ResidueCode( C1 );
a linear [8,4,4]2 residue code
gap> c := Codeword( [ 0,0,0,1,0,0,1,1,0,1,0,1,1,1,1 ], C1);;
gap> C3 := ResidueCode( C1, c );
a linear [7,4,3]1 residue code
</Example>
<!--
C1 := BCHCode( 15, 7 );
C2 := ResidueCode( C1 );
c := Codeword( [ 0,0,0,1,0,0,1,1,0,1,0,1,1,1,1 ], C1);;
C3 := ResidueCode( C1, c );
-->
<ManSection Label="ConstructionBCode">
<Func Name="ConstructionBCode" Arg=" C "/>
<Description>
The function <C>ConstructionBCode</C> takes a binary linear code
<A>C</A> and calculates the minimum distance of the dual of
<A>C</A> (see
<Ref Func="DualCode" Style="Number"/>). It
then removes the columns of the parity check matrix of
<A>C</A> where a codeword of the dual code of minimal weight
has coordinates unequal to zero.
The resulting matrix is a parity check matrix for an
<M>[n-dd, k-dd+1, \geq d]</M> code, where <M>dd</M> is the
minimum distance of the dual of <A>C</A>.
</Description>
</ManSection>
<Example>
gap> C1 := ReedMullerCode( 2, 5 );
a linear [32,16,8]6 Reed-Muller (2,5) code over GF(2)
gap> C2 := ConstructionBCode( C1 );
a linear [24,9,8]5..10 Construction B (8 coordinates)
gap> BoundsMinimumDistance( 24, 9, GF(2) );
rec( n := 24, k := 9, q := 2, references := rec( ),
construction := [ [ Operation "UUVCode" ],
[ [ [ Operation "UUVCode" ], [ [ [ Operation "DualCode" ],
[ [ [ Operation "RepetitionCode" ], [ 6, 2 ] ] ] ],
[ [ Operation "CordaroWagnerCode" ], [ 6 ] ] ] ],
[ [ Operation "CordaroWagnerCode" ], [ 12 ] ] ] ], lowerBound := 8,
lowerBoundExplanation := [ "Lb(24,9)=8, u u+v construction of C1 and C2:",
"Lb(12,7)=4, u u+v construction of C1 and C2:",
"Lb(6,5)=2, dual of the repetition code",
"Lb(6,2)=4, Cordaro-Wagner code", "Lb(12,2)=8, Cordaro-Wagner code" ],
upperBound := 8,
upperBoundExplanation := [ "Ub(24,9)=8, otherwise construction B would
contradict:", "Ub(18,4)=8, Griesmer bound" ] )
# so C2 is optimal
</Example>
<!--
C1 := ReedMullerCode( 2, 5 );
C2 := ConstructionBCode( C1 );
BoundsMinimumDistance( 24, 9, GF(2) );
-->
<ManSection Label="DualCode">
<Func Name="DualCode" Arg=" C "/>
<Description>
<C>DualCode</C> returns the dual code of <A>C</A>.
The dual code consists of all codewords that are orthogonal to the
codewords of <A>C</A>. If <A>C</A> is a linear code with generator
matrix <M>G</M>, the dual code has parity check matrix <M>G</M>
(or if <A>C</A> has parity check matrix <M>H</M>, the
dual code has generator matrix <M>H</M>). So if <A>C</A>
is a linear <M>[n, k]</M> code, the dual code of <A>C</A> is a
linear <M>[n, n-k]</M> code. If <A>C</A> is a cyclic code
with generator polynomial <M>g(x)</M>, the dual code has the
reciprocal polynomial of <M>g(x)</M> as check polynomial.
<P/>
The dual code is always a linear code, even if <A>C</A> is non-linear.
<P/>
If a code <A>C</A> is equal to its dual code, it is called
<E>self-dual</E>.
</Description>
</ManSection>
<Example>
gap> R := ReedMullerCode( 1, 3 );
a linear [8,4,4]2 Reed-Muller (1,3) code over GF(2)
gap> RD := DualCode( R );
a linear [8,4,4]2 Reed-Muller (1,3) code over GF(2)
gap> R = RD;
true
gap> N := WholeSpaceCode( 7, GF(4) );
a cyclic [7,7,1]0 whole space code over GF(4)
gap> DualCode( N ) = NullCode( 7, GF(4) );
true
</Example>
<!--
R := ReedMullerCode( 1, 3 );
RD := DualCode( R );
R = RD;
N := WholeSpaceCode( 7, GF(4) );
DualCode( N ) = NullCode( 7, GF(4) );
-->
<Index>
self-dual
</Index>
<ManSection Label="ConversionFieldCode">
<Func Name="ConversionFieldCode" Arg=" C "/>
<Description>
<C>ConversionFieldCode</C> returns the code obtained from
<A>C</A> after converting its field.
If the field of <A>C</A> is <M>GF(q^m)</M>,
the returned code has field <M>GF(q)</M>. Each
symbol of every codeword is replaced by a concatenation of <M>m</M> symbols
from <M>GF(q)</M>. If <A>C</A> is an <M>(n, M, d_1)</M> code,
the returned code is a <M>(n\cdot m, M, d_2)</M> code,
where <M>d_2 > d_1</M>.
<P/>
See also <Ref Func="HorizontalConversionFieldMat" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> R := RepetitionCode( 4, GF(4) );
a cyclic [4,1,4]3 repetition code over GF(4)
gap> R2 := ConversionFieldCode( R );
a linear [8,2,4]3..4 code, converted to basefield GF(2)
gap> Size( R ) = Size( R2 );
true
gap> GeneratorMat( R );
[ [ Z(2)^0, Z(2)^0, Z(2)^0, Z(2)^0 ] ]
gap> GeneratorMat( R2 );
[ [ Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2) ],
[ 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0 ] ]
</Example>
<!--
R := RepetitionCode( 4, GF(4) );
R2 := ConversionFieldCode( R );
Size( R ) = Size( R2 );
GeneratorMat( R );
GeneratorMat( R2 );
-->
<ManSection Label="TraceCode">
<Func Name="TraceCode" Arg=" C "/>
<Description>
Input: <A>C</A> is a linear code defined over an extension <M>E</M> of <A>F</A>
(<A>F</A> is the ``base field'')
<P/>
Output: The linear code generated by <M>Tr_{E/F}(c)</M>, for all <M>c \in C</M>.
<P/>
<C>TraceCode</C> returns the image of the code <A>C</A> under the
trace map. If the field of <A>C</A> is <M>GF(q^m)</M>,
the returned code has field <M>GF(q)</M>.
<P/>
Very slow. It does not seem to be easy to related the parameters of the
trace code to the original except in the ``Galois closed'' case.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,4,GF(4)); MinimumDistance(C);
a [10,4,?] randomly generated code over GF(4)
5
gap> trC:=TraceCode(C,GF(2)); MinimumDistance(trC);
a linear [10,7,1]1..3 user defined unrestricted code over GF(2)
1
</Example>
<!--
C:=RandomLinearCode(10,4,GF(4)); MinimumDistance(C);
trC:=TraceCode(C,GF(2)); MinimumDistance(trC);
-->
<ManSection Label="CosetCode">
<Func Name="CosetCode" Arg=" C w "/>
<Description>
<C>CosetCode</C> returns the coset of a code
<A>C</A> with respect to word <A>w</A>.
<A>w</A> must be of the codeword type. Then, <A>w</A> is
added to each codeword of <A>C</A>, yielding the elements of
the new code. If <A>C</A> is linear and <A>w</A> is
an element of <A>C</A>, the new code is equal to <A>C</A>,
otherwise the new code is an unrestricted code.
<P/>
Generating a coset is also possible by simply adding the word
<A>w</A> to <A>C</A>. See
<Ref Label="Operations for Codes" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> H := HammingCode(3, GF(2));
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> c := Codeword("1011011");; c in H;
false
gap> C := CosetCode(H, c);
a (7,16,3)1 coset code
gap> List(AsSSortedList(C), el-> Syndrome(H, el));
[ [ 1 1 1 ], [ 1 1 1 ], [ 1 1 1 ], [ 1 1 1 ], [ 1 1 1 ], [ 1 1 1 ],
[ 1 1 1 ], [ 1 1 1 ], [ 1 1 1 ], [ 1 1 1 ], [ 1 1 1 ], [ 1 1 1 ],
[ 1 1 1 ], [ 1 1 1 ], [ 1 1 1 ], [ 1 1 1 ] ]
# All elements of the coset have the same syndrome in H
</Example>
<!--
H := HammingCode(3, GF(2));
c := Codeword("1011011");; c in H;
C := CosetCode(H, c);
List(AsSSortedList(C), el-> Syndrome(H, el));
-->
<ManSection Label="ConstantWeightSubcode">
<Func Name="ConstantWeightSubcode" Arg=" C w "/>
<Description>
<C>ConstantWeightSubcode</C> returns the subcode of
<A>C</A> that only has codewords of weight <A>w</A>.
The resulting code is a non-linear code, because
it does not contain the all-zero vector.
<P/>
This command also can be called with the syntax
<C>ConstantWeightSubcode(C)</C>
In this format, <C>ConstantWeightSubcode</C> returns
the subcode of <A>C</A> consisting of all minimum weight
codewords of <A>C</A>.
<P/>
<C>ConstantWeightSubcode</C> first checks if Leon's binary
<C>wtdist</C> exists on your computer (in the default directory).
If it does, then this program is called. Otherwise,
the constant weight subcode is computed using a GAP program
which checks each codeword in <A>C</A> to see if it is of the
desired weight.
</Description>
</ManSection>
<Example>
gap> N := NordstromRobinsonCode();; WeightDistribution(N);
[ 1, 0, 0, 0, 0, 0, 112, 0, 30, 0, 112, 0, 0, 0, 0, 0, 1 ]
gap> C := ConstantWeightSubcode(N, 8);
a (16,30,6..16)5..8 code with codewords of weight 8
gap> WeightDistribution(C);
[ 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0 ]
gap> eg := ExtendedTernaryGolayCode();; WeightDistribution(eg);
[ 1, 0, 0, 0, 0, 0, 264, 0, 0, 440, 0, 0, 24 ]
gap> C := ConstantWeightSubcode(eg);
a (12,264,6..12)3..6 code with codewords of weight 6
gap> WeightDistribution(C);
[ 0, 0, 0, 0, 0, 0, 264, 0, 0, 0, 0, 0, 0 ]
</Example>
<!--
N := NordstromRobinsonCode();; WeightDistribution(N);
C := ConstantWeightSubcode(N, 8);
WeightDistribution(C);
eg := ExtendedTernaryGolayCode();; WeightDistribution(eg);
C := ConstantWeightSubcode(eg);
WeightDistribution(C);
-->
<ManSection Label="StandardFormCode">
<Func Name="StandardFormCode" Arg=" C "/>
<Description>
<C>StandardFormCode</C> returns <A>C</A> after putting it
in standard form. If <A>C</A> is a non-linear code, this means the
elements are organized using lexicographical order. This means they
form a legal GAP `Set'.
<P/>
If <A>C</A> is a linear code, the generator matrix and parity check matrix are
put in standard form. The generator matrix then has an identity matrix in
its left part, the parity check matrix has an identity matrix in its
right part. Although <Package>GUAVA</Package> always puts both
matrices in a standard form using <C>BaseMat</C>, this never
alters the code. <C>StandardFormCode</C> even
applies column permutations if unavoidable, and thereby changes the
code. The column permutations are recorded in the construction history of
the new code (see <Ref Func="Display" Style="Number"/>).
<A>C</A> and the new code are of course equivalent.
<P/>
If <A>C</A> is a cyclic code, its generator matrix cannot be
put in the usual upper triangular form, because then it would be
inconsistent with the generator polynomial. The reason is that
generating the elements from the generator matrix would result in a
different order than generating the elements from the generator
polynomial. This is an unwanted effect, and therefore
<C>StandardFormCode</C> just returns a copy of <A>C</A>
for cyclic codes.
</Description>
</ManSection>
<Example>
gap> G := GeneratorMatCode( Z(2) * [ [0,1,1,0], [0,1,0,1], [0,0,1,1] ],
"random form code", GF(2) );
a linear [4,2,1..2]1..2 random form code over GF(2)
gap> Codeword( GeneratorMat( G ) );
[ [ 0 1 0 1 ], [ 0 0 1 1 ] ]
gap> Codeword( GeneratorMat( StandardFormCode( G ) ) );
[ [ 1 0 0 1 ], [ 0 1 0 1 ] ]
</Example>
<!--
G := GeneratorMatCode( Z(2) * [ [0,1,1,0], [0,1,0,1], [0,0,1,1] ], "random form code", GF(2) );
Codeword( GeneratorMat( G ) );
Codeword( GeneratorMat( StandardFormCode( G ) ) );
-->
<ManSection Label="PiecewiseConstantCode">
<Func Name="PiecewiseConstantCode" Arg=" part wts [F] "/>
<Description>
<C>PiecewiseConstantCode</C> returns a code with length
<M>n = \sum n_i</M>, where
<A>part</A>=<M>[ n_1, \dots, n_k ]</M>. <A>wts</A> is a list of
<A>constraints</A> <M>w=(w_1,...,w_k)</M>, each of length <M>k</M>,
where <M>0 \leq w_i \leq n_i</M>.
The default field is <M>GF(2)</M>.
<P/>
A constraint is a list of integers, and
a word <M>c = ( c_1, \dots, c_k )</M>
(according to <A>part</A>, i.e., each <M>c_i</M> is a subword
of length <M>n_i</M>)
is in the resulting code if and only if,
for some constraint <M>w \in</M> <A>wts</A>,
<M>\|c_i\| = w_i</M> for all <M>1 \leq i \leq k</M>,
where <M>\| ...\|</M> denotes the Hamming weight.
<P/>
An example might make things clearer:
</Description>
</ManSection>
<Example>
gap> PiecewiseConstantCode( [ 2, 3 ],
[ [ 0, 0 ], [ 0, 3 ], [ 1, 0 ], [ 2, 2 ] ],GF(2) );
the C code programs are compiled, so using Leon's binary....
the C code programs are compiled, so using Leon's binary....
the C code programs are compiled, so using Leon's binary....
the C code programs are compiled, so using Leon's binary....
a (5,7,1..5)1..5 piecewise constant code over GF(2)
gap> AsSSortedList(last);
[ [ 0 0 0 0 0 ], [ 0 0 1 1 1 ], [ 0 1 0 0 0 ], [ 1 0 0 0 0 ],
[ 1 1 0 1 1 ], [ 1 1 1 0 1 ], [ 1 1 1 1 0 ] ]
gap>
</Example>
<!--
PiecewiseConstantCode( [ 2, 3 ],[ [ 0, 0 ], [ 0, 3 ], [ 1, 0 ], [ 2, 2 ] ],GF(2) );
AsSSortedList(last);
-->
The first constraint is satisfied by codeword 1,
the second by codeword 2,
the third by codewords 3 and 4,
and the fourth by codewords 5, 6 and 7.
</Section>
<Section>
<Heading>
Functions that Generate a New Code from Two or More Given Codes
</Heading>
<Label Name="Functions that Generate a New Code from Two or More Given Codes"/>
<ManSection Label="DirectSumCode">
<Func Name="DirectSumCode" Arg=" C1 C2 "/>
<Description>
<C>DirectSumCode</C> returns the direct sum of codes
<A>C1</A> and <A>C2</A>. The direct sum code consists of every
codeword of <A>C1</A> concatenated by every codeword of <A>C2</A>.
Therefore, if <A>Ci</A> was a <M>(n_i,M_i,d_i)</M>
code, the result is a <M>(n_1+n_2,M_1*M_2,min(d_1,d_2))</M> code.
<P/>
If both <A>C1</A> and <A>C2</A> are linear codes, the result
is also a linear code. If one of them is non-linear, the direct
sum is non-linear too. In general, a direct sum code is not cyclic.
<P/>
Performing a direct sum can also be done by adding two codes (see
Section <Ref Label="Operations for Codes" Style="Number"/>).
Another often used method is the `u, u+v'-construction,
described in <Ref Func="UUVCode" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> C1 := ElementsCode( [ [1,0], [4,5] ], GF(7) );;
gap> C2 := ElementsCode( [ [0,0,0], [3,3,3] ], GF(7) );;
gap> D := DirectSumCode(C1, C2);;
gap> AsSSortedList(D);
[ [ 1 0 0 0 0 ], [ 1 0 3 3 3 ], [ 4 5 0 0 0 ], [ 4 5 3 3 3 ] ]
gap> D = C1 + C2; # addition = direct sum
true
</Example>
<!--
C1 := ElementsCode( [ [1,0], [4,5] ], GF(7) );;
C2 := ElementsCode( [ [0,0,0], [3,3,3] ], GF(7) );;
D := DirectSumCode(C1, C2);;
AsSSortedList(D);
D = C1 + C2; # addition = direct sum
-->
<ManSection Label="UUVCode">
<Func Name="UUVCode" Arg=" C1 C2 "/>
<Description>
<C>UUVCode</C> returns the so-called <M>(u\|u+v)</M> construction
applied to <A>C1</A> and <A>C2</A>.
The resulting code consists of every codeword <M>u</M> of
<A>C1</A> concatenated by the sum of <M>u</M> and every codeword
<M>v</M> of <A>C2</A>. If <A>C1</A> and <A>C2</A> have different
word lengths, sufficient zeros are added to the shorter code to
make this sum possible. If <A>Ci</A> is a <M>(n_i,M_i,d_i)</M>
code, the result is an
<M>(n_1+max(n_1,n_2),M_1\cdot M_2,min(2\cdot d_1,d_2))</M> code.
<P/>
If both <A>C1</A> and <A>C2</A> are linear codes, the result is also a linear
code. If one of them is non-linear, the UUV sum is non-linear too.
In general, a UUV sum code is not cyclic.
<P/>
The function <C>DirectSumCode</C> returns another sum of codes (see
<Ref Func="DirectSumCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> C1 := EvenWeightSubcode(WholeSpaceCode(4, GF(2)));
a cyclic [4,3,2]1 even weight subcode
gap> C2 := RepetitionCode(4, GF(2));
a cyclic [4,1,4]2 repetition code over GF(2)
gap> R := UUVCode(C1, C2);
a linear [8,4,4]2 U U+V construction code
gap> R = ReedMullerCode(1,3);
true
</Example>
<!--
C1 := EvenWeightSubcode(WholeSpaceCode(4, GF(2)));
C2 := RepetitionCode(4, GF(2));
R := UUVCode(C1, C2);
R = ReedMullerCode(1,3);
-->
<ManSection Label="DirectProductCode">
<Func Name="DirectProductCode" Arg=" C1 C2 "/>
<Description>
<C>DirectProductCode</C> returns the direct product of codes
<A>C1</A> and <A>C2</A>. Both must be linear codes.
Suppose <A>Ci</A> has generator matrix <M>G_i</M>.
The direct product of <A>C1</A> and <A>C2</A>
then has the Kronecker product of <M>G_1</M>
and <M>G_2</M> as the generator matrix (see
the GAP command <C>KroneckerProduct</C>).
<P/>
If <A>Ci</A> is a <M>[n_i, k_i, d_i]</M> code,
the direct product then is an
<M>[n_1\cdot n_2,k_1\cdot k_2,d_1\cdot d_2]</M> code.
</Description>
</ManSection>
<Example>
gap> L1 := LexiCode(10, 4, GF(2));
a linear [10,5,4]2..4 lexicode over GF(2)
gap> L2 := LexiCode(8, 3, GF(2));
a linear [8,4,3]2..3 lexicode over GF(2)
gap> D := DirectProductCode(L1, L2);
a linear [80,20,12]20..45 direct product code
</Example>
<!--
L1 := LexiCode(10, 4, GF(2));
L2 := LexiCode(8, 3, GF(2));
D := DirectProductCode(L1, L2);
-->
<ManSection Label="IntersectionCode">
<Func Name="IntersectionCode" Arg=" C1 C2 "/>
<Description>
<C>IntersectionCode</C> returns the intersection of
codes <A>C1</A> and <A>C2</A>.
This code consists of all codewords that are both in
<A>C1</A> and <A>C2</A>.
If both codes are linear, the result is also linear.
If both are cyclic, the result is also cyclic.
</Description>
</ManSection>
<Example>
gap> C := CyclicCodes(7, GF(2));
[ a cyclic [7,7,1]0 enumerated code over GF(2),
a cyclic [7,6,1..2]1 enumerated code over GF(2),
a cyclic [7,3,1..4]2..3 enumerated code over GF(2),
a cyclic [7,0,7]7 enumerated code over GF(2),
a cyclic [7,3,1..4]2..3 enumerated code over GF(2),
a cyclic [7,4,1..3]1 enumerated code over GF(2),
a cyclic [7,1,7]3 enumerated code over GF(2),
a cyclic [7,4,1..3]1 enumerated code over GF(2) ]
gap> IntersectionCode(C[6], C[8]) = C[7];
true
</Example>
<Index>hull</Index>
The <E>hull</E> of a linear code is the
intersection of the code with its dual code. In other words,
the hull of <M>C</M> is
<C>IntersectionCode(C, DualCode(C))</C>.
<ManSection Label="UnionCode">
<Func Name="UnionCode" Arg=" C1 C2 "/>
<Description>
<C>UnionCode</C> returns the union of codes
<A>C1</A> and <A>C2</A>. This code consists of the union of
all codewords of <A>C1</A> and <A>C2</A> and all
linear combinations. Therefore this function works only for linear
codes. The function <C>AddedElementsCode</C> can be used for non-linear codes,
or if the resulting code should not include linear combinations. See
<Ref Func="AddedElementsCode" Style="Number"/>.
If both arguments are cyclic, the result is also
cyclic.
</Description>
</ManSection>
<Example>
gap> G := GeneratorMatCode([[1,0,1],[0,1,1]]*Z(2)^0, GF(2));
a linear [3,2,1..2]1 code defined by generator matrix over GF(2)
gap> H := GeneratorMatCode([[1,1,1]]*Z(2)^0, GF(2));
a linear [3,1,3]1 code defined by generator matrix over GF(2)
gap> U := UnionCode(G, H);
a linear [3,3,1]0 union code
gap> c := Codeword("010");; c in G;
false
gap> c in H;
false
gap> c in U;
true
</Example>
<!--
G := GeneratorMatCode([[1,0,1],[0,1,1]]*Z(2)^0, GF(2));
H := GeneratorMatCode([[1,1,1]]*Z(2)^0, GF(2));
U := UnionCode(G, H);
c := Codeword("010");; c in G;
c in H;
c in U;
-->
<ManSection Label="ExtendedDirectSumCode">
<Func Name="ExtendedDirectSumCode" Arg=" L B m "/>
<Description>
The extended direct sum construction is described in section V of Graham
and Sloane <Cite Key="GS85"/>.
The resulting code consists of <A>m</A> copies of <A>L</A>, extended by
repeating the codewords of <A>B</A> <A>m</A> times.
<P/>
Suppose <A>L</A> is an <M>[n_L, k_L]r_L</M> code, and <A>B</A>
is an <M>[n_L, k_B]r_B</M> code (non-linear codes are also permitted).
The length of <A>B</A> must be equal to the length of
<A>L</A>. The length of the new code is <M>n = m n_L</M>,
the dimension (in the case of linear codes) is
<M>k \leq m k_L + k_B</M>, and
the covering radius is <M>r \leq \lfloor m \Psi( L, B ) \rfloor</M>,
with
<Display>
\Psi( L, B ) = \max_{u \in F_2^{n_L}} \frac{1}{2^{k_B}}
\sum_{v \in B} {\rm d}( L, v + u ).
</Display>
However, this computation will not be executed, because it may be too
time consuming for large codes.
<P/>
If <M>L \subseteq B</M>, and <M>L</M> and <M>B</M> are linear codes,
the last copy of <A>L</A> is omitted. In this case the
dimension is <M>k = m k_L + (k_B - k_L)</M>.
</Description>
</ManSection>
<Example>
gap> c := HammingCode( 3, GF(2) );
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> d := WholeSpaceCode( 7, GF(2) );
a cyclic [7,7,1]0 whole space code over GF(2)
gap> e := ExtendedDirectSumCode( c, d, 3 );
a linear [21,15,1..3]2 3-fold extended direct sum code
</Example>
<!--
c := HammingCode( 3, GF(2) );
d := WholeSpaceCode( 7, GF(2) );
e := ExtendedDirectSumCode( c, d, 3 );
-->
<ManSection Label="AmalgamatedDirectSumCode">
<Func Name="AmalgamatedDirectSumCode" Arg=" c1 c2 [check] "/>
<Description>
<C>AmalgamatedDirectSumCode</C> returns the amalgamated direct
sum of the codes <A>c1</A> and <A>c2</A>. The amalgamated direct
sum code consists of all codewords of the form
<M>(u \, \| \,0 \, \| \, v)</M>
if
<M>(u \, \| \, 0) \in c_1</M>
and
<M>(0 \, \| \, v) \in c_2</M>
and all codewords of the form
<M>(u \, \| \, 1 \, \| \, v)</M>
if
<M>(u \, \| \, 1) \in c_1</M>
and
<M>(1 \, \| \, v) \in c_2</M>.
The result is a code with length
<M> n = n_1 + n_2 - 1 </M>
and size
<M> M \leq M_1 \cdot M_2 / 2 </M>.
<P/>
If both codes are linear, they will first be standardized, with
information symbols in the last and first coordinates of the first and
second code, respectively.
<P/>
If <A>c1</A> is a normal code (see
<Ref Func="IsNormalCode" Style="Number"/>)
with the last coordinate acceptable
(see
<Ref Func="IsCoordinateAcceptable" Style="Number"/>),
and <A>c2</A>
is a normal code with the first coordinate acceptable, then the covering
radius of the new code is <M>r \leq r_1 + r_2 </M>. However, checking whether
a code is normal or not is a lot of work, and almost all codes seem to be
normal. Therefore, an option <A>check</A> can be supplied.
If <A>check</A> is true,
then the codes will be checked for normality.
If <A>check</A> is false or omitted, then the codes will
not be checked. In this case it is assumed
that they are normal. Acceptability of the last and first coordinate of
the first and second code, respectively, is in the last case also assumed
to be done by the user.
</Description>
</ManSection>
<Example>
gap> c := HammingCode( 3, GF(2) );
a linear [7,4,3]1 Hamming (3,2) code over GF(2)
gap> d := ReedMullerCode( 1, 4 );
a linear [16,5,8]6 Reed-Muller (1,4) code over GF(2)
gap> e := DirectSumCode( c, d );
a linear [23,9,3]7 direct sum code
gap> f := AmalgamatedDirectSumCode( c, d );;
gap> MinimumDistance( f );;
gap> CoveringRadius( f );;
gap> f;
a linear [22,8,3]7 amalgamated direct sum code
</Example>
<!--
c := HammingCode( 3, GF(2) );
d := ReedMullerCode( 1, 4 );
e := DirectSumCode( c, d );
f := AmalgamatedDirectSumCode( c, d );;
MinimumDistance( f );;
CoveringRadius( f );; # takes some time
f;
-->
<ManSection Label="BlockwiseDirectSumCode">
<Func Name="BlockwiseDirectSumCode" Arg=" C1 L1 C2 L2 "/>
<Description>
<C>BlockwiseDirectSumCode</C> returns a subcode of the direct sum
of <A>C1</A> and <A>C2</A>. The fields of <A>C1</A> and
<A>C2</A> must be same. The lists <A>L1</A> and <A>L2</A>
are two equally long with elements from the ambient vector spaces
of <A>C1</A> and <A>C2</A>, respectively, <E>or</E>
<A>L1</A> and <A>L2</A> are two equally long lists containing codes.
The union of the codes in <A>L1</A> and <A>L2</A> must be
<A>C1</A> and <A>C2</A>, respectively.
<P/>
In the first case, the blockwise direct sum code is defined as
<Display>
bds = \bigcup_{1 \leq i \leq \ell} ( C_1 + (L_1)_i ) \oplus ( C_2 + (L_2)_i ),
</Display>
where <M>\ell</M> is the length of <A>L1</A> and <A>L2</A>,
and <M>\oplus</M> is the direct sum.
<P/>
In the second case, it is defined as
<Display>
bds = \bigcup_{1 \leq i \leq \ell} ( (L_1)_i \oplus (L_2)_i ).
</Display>
The length of the new code is <M>n = n_1 + n_2</M>.
</Description>
</ManSection>
<Example>
gap> C1 := HammingCode( 3, GF(2) );;
gap> C2 := EvenWeightSubcode( WholeSpaceCode( 6, GF(2) ) );;
gap> BlockwiseDirectSumCode( C1, [[ 0,0,0,0,0,0,0 ],[ 1,0,1,0,1,0,0 ]],
> C2, [[ 0,0,0,0,0,0 ],[ 1,0,1,0,1,0 ]] );
a (13,1024,1..13)1..2 blockwise direct sum code
</Example>
<!--
C1 := HammingCode( 3, GF(2) );;
C2 := EvenWeightSubcode( WholeSpaceCode( 6, GF(2) ) );;
BlockwiseDirectSumCode( C1, [[ 0,0,0,0,0,0,0 ],[ 1,0,1,0,1,0,0 ]], C2, [[ 0,0,0,0,0,0 ],[ 1,0,1,0,1,0 ]] );
-->
<ManSection Label="ConstructionXCode">
<Func Name="ConstructionXCode" Arg=" C A "/>
<Description>
Consider a list of <M>j</M> linear codes of the same length <M>N</M> over the same field <M>F</M>,
<M>C = \{ C_1, C_2, \ldots, C_j \}</M>, where the parameter of the <M>i</M>th code is
<M>C_i = [N, K_i, D_i]</M> and <M>C_j \subset C_{j-1} \subset \ldots \subset C_2 \subset C_1</M>.
Consider a list of <M>j-1</M> auxiliary linear codes of the same field <M>F</M>,
<M>A = \{ A_1, A_2, \ldots, A_{j-1} \}</M> where the parameter of the <M>i</M>th code <M>A_i</M>
is <M>[n_i, k_i=(K_i-K_{i+1}), d_i]</M>, an <M>[n, K_1, d]</M> linear code over field <M>F</M>
can be constructed where <M>n = N + \sum_{i=1}^{j-1} n_i</M>,
and <M>d = \min\{ D_j, D_{j-1} + d_{j-1}, D_{j-2} + d_{j-2} + d_{j-1}, \ldots,
D_1 + \sum_{i=1}^{j-1} d_i\}</M>.
<P/>
For more information on Construction X, refer to <Cite Key="Sloane72"/>.
</Description>
</ManSection>
<Example>
gap> C1 := BCHCode(127, 43);
a cyclic [127,29,43]31..59 BCH code, delta=43, b=1 over GF(2)
gap> C2 := BCHCode(127, 47);
a cyclic [127,22,47..51]36..63 BCH code, delta=47, b=1 over GF(2)
gap> C3 := BCHCode(127, 55);
a cyclic [127,15,55]41..62 BCH code, delta=55, b=1 over GF(2)
gap> G1 := ShallowCopy( GeneratorMat(C2) );;
gap> Append(G1, [ GeneratorMat(C1)[23] ]);;
gap> C1 := GeneratorMatCode(G1, GF(2));
a linear [127,23,1..43]35..63 code defined by generator matrix over GF(2)
gap> MinimumDistance(C1);
43
gap> C := [ C1, C2, C3 ];
[ a linear [127,23,43]35..63 code defined by generator matrix over GF(2),
a cyclic [127,22,47..51]36..63 BCH code, delta=47, b=1 over GF(2),
a cyclic [127,15,55]41..62 BCH code, delta=55, b=1 over GF(2) ]
gap> IsSubset(C[1], C[2]);
true
gap> IsSubset(C[2], C[3]);
true
gap> A := [ RepetitionCode(4, GF(2)), EvenWeightSubcode( QRCode(17, GF(2)) ) ];
[ a cyclic [4,1,4]2 repetition code over GF(2), a cyclic [17,8,6]3..6 even weight subcode ]
gap> CX := ConstructionXCode(C, A);
a linear [148,23,53]43..74 Construction X code
gap> History(CX);
[ "a linear [148,23,53]43..74 Construction X code of",
"Base codes: [ a cyclic [127,15,55]41..62 BCH code, delta=55, b=1 over GF(2)\
, a cyclic [127,22,47..51]36..63 BCH code, delta=47, b=1 over GF(2), a linear \
[127,23,43]35..63 code defined by generator matrix over GF(2) ]",
"Auxiliary codes: [ a cyclic [4,1,4]2 repetition code over GF(2), a cyclic [\
17,8,6]3..6 even weight subcode ]" ]
</Example>
<!--
C1 := BCHCode(127, 43);
C2 := BCHCode(127, 47);
C3 := BCHCode(127, 55);
G1 := ShallowCopy( GeneratorMat(C2) );;
Append(G1, [ GeneratorMat(C1)[23] ]);;
C1 := GeneratorMatCode(G1, GF(2));
MinimumDistance(C1);
C := [ C1, C2, C3 ];
IsSubset(C[1], C[2]);
IsSubset(C[2], C[3]);
A := [ RepetitionCode(4, GF(2)), EvenWeightSubcode( QRCode(17, GF(2)) ) ];
CX := ConstructionXCode(C, A);
History(CX);
-->
<ManSection Label="ConstructionXXCode">
<Func Name="ConstructionXXCode" Arg=" C1 C2 C3 A1 A2 "/>
<Description>
Consider a set of linear codes over field <M>F</M> of the same length,
<M>n</M>, <M>C_1=[n, k_1, d_1]</M>, <M>C_2=[n, k_2, d_2]</M> and <M>C_3=[n, k_3, d_3]</M>
such that <M>C_2 \subset C_1</M>, <M>C_3 \subset C_1</M> and <M>C_4 = C_2 \cap C_3</M>.
Given two auxiliary codes <M>A_1=[n_1, k_1-k_2, e_1]</M> and <M>A_2=[n_2, k_1-k_3, e_2]</M>
over the same field <M>F</M>, there exists an <M>[n+n_1+n_2, k_1, d]</M> linear code
<M>C_{XX}</M> over field <M>F</M>, where <M>d = \min\{d_4, d_3 + e_1, d_2 + e_2,
d_1 + e_1 + e_2\}</M>.
<P/>
The codewords of <M>C_{XX}</M> can be partitioned into three sections <M>( v\;\|\;a\;\|\;b )</M>
where <M>v</M> has length <M>n</M>, <M>a</M> has length <M>n_1</M> and <M>b</M> has length
<M>n_2</M>. A codeword from Construction XX takes the following form:
<List>
<Item>
<M>( v \; \| \; 0 \; \| \; 0 )</M> if <M>v \in C_4</M>
</Item>
<Item>
<M>( v \; \| \; a_1 \; \| \; 0 )</M> if <M>v \in C_3 \backslash C_4</M>
</Item>
<Item>
<M>( v \; \| \; 0 \; \| \; a_2 )</M> if <M>v \in C_2 \backslash C_4</M>
</Item>
<Item>
<M>( v \; \| \; a_1 \; \| \; a_2 )</M> otherwise
</Item>
</List>
For more information on Construction XX, refer to <Cite Key="Alltop84"/>.
</Description>
</ManSection>
<Example>
gap> a := PrimitiveRoot(GF(32));
Z(2^5)
gap> f0 := MinimalPolynomial( GF(2), a^0 );
x_1+Z(2)^0
gap> f1 := MinimalPolynomial( GF(2), a^1 );
x_1^5+x_1^2+Z(2)^0
gap> f5 := MinimalPolynomial( GF(2), a^5 );
x_1^5+x_1^4+x_1^2+x_1+Z(2)^0
gap> C2 := CheckPolCode( f0 * f1, 31, GF(2) );; MinimumDistance(C2);; Display(C2);
a cyclic [31,6,15]10..13 code defined by check polynomial over GF(2)
gap> C3 := CheckPolCode( f0 * f5, 31, GF(2) );; MinimumDistance(C3);; Display(C3);
a cyclic [31,6,15]10..13 code defined by check polynomial over GF(2)
gap> C1 := UnionCode(C2, C3);; MinimumDistance(C1);; Display(C1);
a linear [31,11,11]7..11 union code of
U: a cyclic [31,6,15]10..13 code defined by check polynomial over GF(2)
V: a cyclic [31,6,15]10..13 code defined by check polynomial over GF(2)
gap> A1 := BestKnownLinearCode( 10, 5, GF(2) );
a linear [10,5,4]2..4 shortened code
gap> A2 := DualCode( RepetitionCode(6, GF(2)) );
a cyclic [6,5,2]1 dual code
gap> CXX:= ConstructionXXCode(C1, C2, C3, A1, A2 );
a linear [47,11,15..17]13..23 Construction XX code
gap> MinimumDistance(CXX);
17
gap> History(CXX);
[ "a linear [47,11,17]13..23 Construction XX code of",
"C1: a cyclic [31,11,11]7..11 union code",
"C2: a cyclic [31,6,15]10..13 code defined by check polynomial over GF(2)",
"C3: a cyclic [31,6,15]10..13 code defined by check polynomial over GF(2)",
"A1: a linear [10,5,4]2..4 shortened code",
"A2: a cyclic [6,5,2]1 dual code" ]
</Example>
<!--
a := PrimitiveRoot(GF(32));
f0 := MinimalPolynomial( GF(2), a^0 );
f1 := MinimalPolynomial( GF(2), a^1 );
f5 := MinimalPolynomial( GF(2), a^5 );
C2 := CheckPolCode( f0 * f1, 31, GF(2) );; MinimumDistance(C2);; Display(C2);
C3 := CheckPolCode( f0 * f5, 31, GF(2) );; MinimumDistance(C3);; Display(C3);
C1 := UnionCode(C2, C3);; MinimumDistance(C1);; Display(C1);
A1 := BestKnownLinearCode( 10, 5, GF(2) );
A2 := DualCode( RepetitionCode(6, GF(2)) );
CXX:= ConstructionXXCode(C1, C2, C3, A1, A2 );
History(CXX);
-->
<ManSection Label="BZCode">
<Func Name="BZCode" Arg=" O I "/>
<Description>
Given a set of outer codes of the same length <M>O_i = [N, K_i, D_i]</M> over GF(<M>q^{e_i}</M>),
where <M>i=1,2,\ldots,t</M> and a set of inner codes of the same length
<M>I_i = [n, k_i, d_i]</M> over GF(<M>q</M>), <C>BZCode</C> returns a
Blokh-Zyablov multilevel concatenated code
with parameter <M>[ n \times N, \sum_{i=1}^t e_i \times K_i,
\min_{i=1,\ldots,t}\{d_i \times D_i\} ]</M> over GF(<M>q</M>).
<P/>
Note that the set of inner codes must satisfy chain condition, i.e.
<M>I_1 = [n, k_1, d_1] \subset I_2=[n, k_2, d_2] \subset \ldots \subset
I_t=[n, k_t, d_t]</M> where <M>0=k_0 < k_1 < k_2 < \ldots < k_t</M>.
The dimension of the inner codes must satisfy the condition <M>e_i = k_i - k_{i-1}</M>,
where GF(<M>q^{e_i}</M>) is the field of the <M>i</M>th outer code.
<P/>
For more information on Blokh-Zyablov multilevel concatenated code, refer to
<Cite Key="Brouwer98"/>.
</Description>
</ManSection>
<ManSection Label="BZCodeNC">
<Func Name="BZCodeNC" Arg=" O I "/>
<Description>
This function is the same as <C>BZCode</C>,
except this version is faster as it does not estimate the covering radius of the code.
Users are encouraged to use this version unless you are working on very small codes.
</Description>
</ManSection>
<Example>
gap> #
gap> # Binary code
gap> #
gap> O := [ CyclicMDSCode(2,3,7), BestKnownLinearCode(9,5,GF(2)), CyclicMDSCode(2,3,4) ];
[ a cyclic [9,7,3]1 MDS code over GF(8), a linear [9,5,3]2..3 shortened code,
a cyclic [9,4,6]4..5 MDS code over GF(8) ]
gap> A := ExtendedCode( HammingCode(3,GF(2)) );;
gap> I := [ SubCode(A), A, DualCode( RepetitionCode(8, GF(2)) ) ];
[ a linear [8,3,4]3..4 subcode, a linear [8,4,4]2 extended code, a cyclic [8,7,2]1 dual code ]
gap> C := BZCodeNC(O, I);
a linear [72,38,12]0..72 Blokh Zyablov concatenated code
gap> #
gap> # Non binary code
gap> #
gap> O2 := ExtendedCode(GoppaCode(ConwayPolynomial(5,2), Elements(GF(5))));;
gap> O3 := ExtendedCode(GoppaCode(ConwayPolynomial(5,3), Elements(GF(5))));;
gap> O1 := DualCode( O3 );;
gap> MinimumDistance(O1);; MinimumDistance(O2);; MinimumDistance(O3);;
gap> Cy := CyclicCodes(5, GF(5));;
gap> for i in [4, 5] do; MinimumDistance(Cy[i]);; od;
gap> O := [ O1, O2, O3 ];
[ a linear [6,4,3]1 dual code, a linear [6,3,4]2..3 extended code,
a linear [6,2,5]3..4 extended code ]
gap> I := [ Cy[5], Cy[4], Cy[3] ];
[ a cyclic [5,1,5]3..4 enumerated code over GF(5),
a cyclic [5,2,4]2..3 enumerated code over GF(5),
a cyclic [5,3,1..3]2 enumerated code over GF(5) ]
gap> C := BZCodeNC( O, I );
a linear [30,9,5..15]0..30 Blokh Zyablov concatenated code
gap> MinimumDistance(C);
15
gap> History(C);
[ "a linear [30,9,15]0..30 Blokh Zyablov concatenated code of",
"Inner codes: [ a cyclic [5,1,5]3..4 enumerated code over GF(5), a cyclic [5\
,2,4]2..3 enumerated code over GF(5), a cyclic [5,3,1..3]2 enumerated code ove\
r GF(5) ]",
"Outer codes: [ a linear [6,4,3]1 dual code, a linear [6,3,4]2..3 extended c\
ode, a linear [6,2,5]3..4 extended code ]" ]
</Example>
<!--
#
# Binary code
#
O := [ CyclicMDSCode(2,3,7), BestKnownLinearCode(9,5,GF(2)), CyclicMDSCode(2,3,4) ];
A := ExtendedCode( HammingCode(3,GF(2)) );;
I := [ SubCode(A), A, DualCode( RepetitionCode(8, GF(2)) ) ];
C := BZCodeNC(O, I);
#
# Non binary code
#
O2 := ExtendedCode( GoppaCode(ConwayPolynomial(5,2), Elements(GF(5))) );;
O3 := ExtendedCode( GoppaCode(ConwayPolynomial(5,3), Elements(GF(5))) );;
O1 := DualCode( O3 );;
MinimumDistance(O1);; MinimumDistance(O2);; MinimumDistance(O3);;
Cy := CyclicCodes(5, GF(5));;
for i in [4, 5] do; MinimumDistance(Cy[i]);; od;
O := [ O1, O2, O3 ];
I := [ Cy[5], Cy[4], Cy[3] ];
C := BZCodeNC( O, I );
MinimumDistance(C);
History(C);
-->
</Section>
</Chapter>
<Chapter>
<Heading>
Bounds on codes, special matrices and miscellaneous functions
</Heading>
In this chapter we describe functions that determine bounds on the size
and minimum distance of codes (Section
<Ref Label="Distance bounds on codes" Style="Number"/>),
functions that determine bounds on the size
and covering radius of codes (Section
<Ref Label="Covering radius bounds on codes" Style="Number"/>),
functions that
work with special matrices <Package>GUAVA</Package> needs for
several codes (see
Section <Ref Label="Special matrices in GUAVA" Style="Number"/>),
and constructing codes or performing calculations with codes
(see Section
<Ref Label="Miscellaneous functions" Style="Number"/>).
<Section>
<Heading>
Distance bounds on codes
</Heading>
<Label Name="Distance bounds on codes"/>
This section describes the functions that calculate estimates for upper
bounds on the size and minimum distance of codes. Several algorithms are
known to compute a largest number of words a code can have with given
length and minimum distance. It is important however to understand that
in some cases the true upper bound is unknown. A code which has a size
equalto the calculated upper bound may not have been found. However,
codes that have a larger size do not exist.
<P/>
A second way to obtain bounds is a table. In
<Package>GUAVA</Package>, an extensive table
is implemented for linear codes over <M>GF(2)</M>, <M>GF(3)</M>
and <M>GF(4)</M>. It contains bounds on the minimum distance for given
<!--word length and dimension. For binary codes, it contains entries for
word length less than or equal to <M>257</M>. For codes over <M>GF(3)</M>
and <M>GF(4)</M>, it contains entries for word length less than or
equal to <M>130</M>. These tables have not been maintained since 1998.-->
word length and dimension. It contains entries for word lengths less than
or equal to <M>257</M>, <M>243</M> and <M>256</M> for codes over <M>GF(2)</M>,
<M>GF(3)</M> and <M>GF(4)</M> respectively.
These entries were obtained from Brouwer's tables as of 11 May 2006.
For the latest information, please see
A. E. Brouwer's tables <Cite Key="Br"/> on the internet.
<P/>
Firstly, we describe functions that compute specific upper bounds
on the code size (see
<Ref Func="UpperBoundSingleton" Style="Number"/>,
<Ref Func="UpperBoundHamming" Style="Number"/>,
<Ref Func="UpperBoundJohnson" Style="Number"/>,
<Ref Func="UpperBoundPlotkin" Style="Number"/>,
<Ref Func="UpperBoundElias" Style="Number"/> and
<Ref Func="UpperBoundGriesmer" Style="Number"/>).
<P/>
Next we describe a function that computes
<Package>GUAVA</Package>'s best upper bound on
the code size (see
<Ref Func="UpperBound" Style="Number"/>).
<P/>
Then we describe two functions that compute a lower and upper bound on
the minimum distance of a code (see
<Ref Func="LowerBoundMinimumDistance" Style="Number"/> and
<Ref Func="UpperBoundMinimumDistance" Style="Number"/>).
<P/>
Finally, we describe a function that returns a lower and upper bound on
the minimum distance with given parameters and a description of how the
bounds were obtained (see
<Ref Func="BoundsMinimumDistance" Style="Number"/>).
<Index>
bounds, Singleton
</Index>
<ManSection Label="UpperBoundSingleton">
<Func Name="UpperBoundSingleton" Arg=" n d q "/>
<Description>
<C>UpperBoundSingleton</C> returns the Singleton bound for a code of
length <A>n</A>, minimum distance <A>d</A> over a field of size
<A>q</A>. This bound is based on the shortening of codes.
By shortening an <M>(n, M, d)</M> code <M>d-1</M> times,
an <M>(n-d+1,M,1)</M> code results, with <M>M \leq q^{n-d+1}</M>
(see
<Ref Func="ShortenedCode" Style="Number"/>). Thus
<Display>
M \leq q^{n-d+1}.
</Display>
<Index>
maximum distance separable
</Index>
Codes that meet this bound are called <E>maximum distance separable</E>
(see
<Ref Func="IsMDSCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> UpperBoundSingleton(4, 3, 5);
25
gap> C := ReedSolomonCode(4,3);; Size(C);
25
gap> IsMDSCode(C);
true
</Example>
<Index>
bounds, Hamming
</Index>
<Index>
bounds, sphere packing bound
</Index>
<Index>
perfect
</Index>
<ManSection Label="UpperBoundHamming">
<Func Name="UpperBoundHamming" Arg=" n d q "/>
<Description>
The Hamming bound (also known as the <E>sphere packing bound</E>)
returns an upper bound on the size of a code of length <A>n</A>,
minimum distance <A>d</A>, over a field of size <A>q</A>.
The Hamming bound is obtained by dividing the contents
of the entire space <M>GF(q)^n</M>
by the contents of a ball with radius
<M>\lfloor(d-1) / 2\rfloor</M>. As all these balls are disjoint,
they can never contain more than the whole vector space.
<Display>
M \leq {q^n \over V(n,e)},
</Display>
where <M>M</M> is the maxmimum number of codewords and
<M>V(n,e)</M>
is equal to the contents of a ball of radius <M>e</M> (see
<Ref Func="SphereContent" Style="Number"/>).
This bound is useful for small values of <A>d</A>.
Codes for which equality holds are called <E>perfect</E>
(see <Ref Func="IsPerfectCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> UpperBoundHamming( 15, 3, 2 );
2048
gap> C := HammingCode( 4, GF(2) );
a linear [15,11,3]1 Hamming (4,2) code over GF(2)
gap> Size( C );
2048
</Example>
<Index>bounds, Johnson
</Index>
<ManSection Label="UpperBoundJohnson">
<Func Name="UpperBoundJohnson" Arg=" n d "/>
<Description>
The Johnson bound is an improved version of the Hamming bound (see
<Ref Func="UpperBoundHamming" Style="Number"/>).
In addition to the Hamming bound, it takes into
account the elements of the space outside the balls of radius
<M>e</M> around the elements of the code.
The Johnson bound only works for binary codes.
</Description>
</ManSection>
<Example>
gap> UpperBoundJohnson( 13, 5 );
77
gap> UpperBoundHamming( 13, 5, 2);
89 # in this case the Johnson bound is better
</Example>
<Index>bounds, Plotkin
</Index>
<ManSection Label="UpperBoundPlotkin">
<Func Name="UpperBoundPlotkin" Arg=" n d q "/>
<Description>
The function <C>UpperBoundPlotkin</C> calculates the sum of the
distances of all ordered pairs of different codewords.
It is based on the fact that the minimum distance is at most
equal to the average distance. It is a
good bound if the weights of the codewords do not differ much. It results
in:
<Display>
M \leq {d \over {d-(1-1/q)n}},
</Display>
where <M>M</M> is the maximum number
of codewords. In this case, <A>d</A> must be larger than
<M>(1-1/q)n</M>, but by shortening the code, the
case <M>d \ \ \langle\ \ (1-1/q)n</M> is covered.
</Description>
</ManSection>
<Example>
gap> UpperBoundPlotkin( 15, 7, 2 );
32
gap> C := BCHCode( 15, 7, GF(2) );
a cyclic [15,5,7]5 BCH code, delta=7, b=1 over GF(2)
gap> Size(C);
32
gap> WeightDistribution(C);
[ 1, 0, 0, 0, 0, 0, 0, 15, 15, 0, 0, 0, 0, 0, 0, 1 ]
</Example>
<!--
UpperBoundPlotkin( 15, 7, 2 );
C := BCHCode( 15, 7, GF(2) );
Size(C);
WeightDistribution(C);
-->
<Index>
bounds, Elias
</Index>
<ManSection Label="UpperBoundElias">
<Func Name="UpperBoundElias" Arg=" n d q "/>
<Description>
The Elias bound is an improvement of the Plotkin bound (see
<Ref Func="UpperBoundPlotkin" Style="Number"/>)
for large codes. Subcodes are used to decrease the
size of the code, in this case the subcode of all codewords within a
certain ball. This bound is useful for large codes with relatively small
minimum distances.
</Description>
</ManSection>
<Example>
gap> UpperBoundPlotkin( 16, 3, 2 );
12288
gap> UpperBoundElias( 16, 3, 2 );
10280
gap> UpperBoundElias( 20, 10, 3 );
16255
</Example>
<Index>
bounds, Griesmer
</Index>
<ManSection Label="UpperBoundGriesmer">
<Func Name="UpperBoundGriesmer" Arg=" n d q "/>
<Description>
The Griesmer bound is valid only for linear codes. It is obtained by
counting the number of equal symbols in each row of the generator matrix
of the code. By omitting the coordinates in which all rows have a zero, a
smaller code results. The Griesmer bound is obtained by repeating this
proces until a trivial code is left in the end.
</Description>
</ManSection>
<Example>
gap> UpperBoundGriesmer( 13, 5, 2 );
64
gap> UpperBoundGriesmer( 18, 9, 2 );
8 # the maximum number of words for a linear code is 8
gap> Size( PuncturedCode( HadamardCode( 20, 1 ) ) );
20 # this non-linear code has 20 elements
</Example>
<!--
UpperBoundGriesmer( 13, 5, 2 );
UpperBoundGriesmer( 18, 9, 2 );
Size( PuncturedCode( HadamardCode( 20, 1 ) ) );
-->
<Index>
Griesmer code
</Index>
<ManSection Label="IsGriesmerCode">
<Func Name="IsGriesmerCode" Arg=" C "/>
<Description>
<C>IsGriesmerCode</C> returns `true' if a linear code <A>C</A>
is a Griesmer code, and `false' otherwise.
A code is called <E>Griesmer</E> if its length satisfies
<Display>
n = g[k,d] = \sum_{i=0}^{k-1} \lceil \frac{d}{q^i} \rceil.
</Display>
</Description>
</ManSection>
<Example>
gap> IsGriesmerCode( HammingCode( 3, GF(2) ) );
true
gap> IsGriesmerCode( BCHCode( 17, 2, GF(2) ) );
false
</Example>
<Index>
<M>A(n,d)</M>
</Index>
<ManSection Label="UpperBound">
<Func Name="UpperBound" Arg=" n d q "/>
<Description>
<C>UpperBound</C> returns the best known upper bound
<M>A(n,d)</M> for the size of a code of length <A>n</A>,
minimum distance <A>d</A> over a field of size <A>q</A>.
The function <C>UpperBound</C> first checks for
trivial cases (like <M>d=1</M> or <M>n=d</M>), and if the
value is in the built-in table. Then it calculates
the minimum value of the upper bound using the methods of Singleton (see
<Ref Func="UpperBoundSingleton" Style="Number"/>), Hamming (see
<Ref Func="UpperBoundHamming" Style="Number"/>), Johnson (see
<Ref Func="UpperBoundJohnson" Style="Number"/>), Plotkin (see
<Ref Func="UpperBoundPlotkin" Style="Number"/>) and Elias (see
<Ref Func="UpperBoundElias" Style="Number"/>). If the code is binary,
<M>A(n, 2\cdot \ell-1) = A(n+1,2\cdot \ell)</M>, so the
<C>UpperBound</C> takes the minimum of the values obtained from
all methods for the parameters
<M>(n, 2\cdot\ell-1)</M> and <M>(n+1, 2\cdot \ell)</M>.
</Description>
</ManSection>
<Example>
gap> UpperBound( 10, 3, 2 );
85
gap> UpperBound( 25, 9, 8 );
1211778792827540
</Example>
<ManSection Label="LowerBoundMinimumDistance">
<Func Name="LowerBoundMinimumDistance" Arg=" C "/>
<Description>
In this form, <C>LowerBoundMinimumDistance</C>
returns a lower bound for the minimum distance of code <A>C</A>.
<P/>
This command can also be called using the syntax
<C>LowerBoundMinimumDistance( n, k, F )</C>.
In this form, <C>LowerBoundMinimumDistance</C> returns a
lower bound for the minimum distance of the best known linear
code of length <A>n</A>, dimension <A>k</A> over field <A>F</A>.
It uses the mechanism explained in section
<Ref Label="BoundsMinimumDistance" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> C := BCHCode( 45, 7 );
a cyclic [45,23,7..9]6..16 BCH code, delta=7, b=1 over GF(2)
gap> LowerBoundMinimumDistance( C );
7 # designed distance is lower bound for minimum distance
gap> LowerBoundMinimumDistance( 45, 23, GF(2) );
10
</Example>
<!--
C := BCHCode( 45, 7 );
LowerBoundMinimumDistance( C );
LowerBoundMinimumDistance( 45, 23, GF(2) );
-->
<Index>
bound, Gilbert-Varshamov lower
</Index>
<ManSection Label="LowerBoundGilbertVarshamov">
<Func Name="LowerBoundGilbertVarshamov" Arg=" n d q "/>
<Description>
This is the lower bound due (independently) to
Gilbert and Varshamov. It says that for each
<A>n</A> and <A>d</A>, there exists a linear code
having length <M>n</M> and minimum distance <M>d</M> at least of size
<M>q^{n-1}/ SphereContent(n-1,d-2,GF(q))</M>.
</Description>
</ManSection>
<Example>
gap> LowerBoundGilbertVarshamov(3,2,2);
4
gap> LowerBoundGilbertVarshamov(3,3,2);
1
gap> LowerBoundMinimumDistance(3,3,2);
1
gap> LowerBoundMinimumDistance(3,2,2);
2
</Example>
<!--
LowerBoundGilbertVarshamov(3,2,2);
LowerBoundGilbertVarshamov(3,3,2);
LowerBoundMinimumDistance(3,3,2);
LowerBoundMinimumDistance(3,2,2);
-->
<Index>
bound, sphere packing lower
</Index>
<ManSection Label="LowerBoundSpherePacking">
<Func Name="LowerBoundSpherePacking" Arg=" n d q "/>
<Description>
This is the lower bound due (independently) to
Gilbert and Varshamov. It says that for each <A>n</A> and
<A>r</A>, there exists an unrestricted code at least of size
<M>q^n/ SphereContent(n,d,GF(q))</M>
minimum distance <M>d</M>.
</Description>
</ManSection>
<Example>
gap> LowerBoundSpherePacking(3,2,2);
2
gap> LowerBoundSpherePacking(3,3,2);
1
</Example>
<!--
LowerBoundSpherePacking(3,2,2);
LowerBoundSpherePacking(3,3,2);
-->
<ManSection Label="UpperBoundMinimumDistance">
<Func Name="UpperBoundMinimumDistance" Arg=" C "/>
<Description>
In this form, <C>UpperBoundMinimumDistance</C> returns an upper bound for the
minimum distance of code <A>C</A>. For unrestricted codes, it just returns the
word length. For linear codes, it takes the minimum of the possibly known
value from the method of construction, the weight of the generators, and
the value from the table (see
<Ref Label="BoundsMinimumDistance" Style="Number"/>).
<P/>
This command can also be called using the syntax
<C>UpperBoundMinimumDistance( n, k, F )</C>.
In this form, <C>UpperBoundMinimumDistance</C> returns an upper bound for the
minimum distance of the best known linear code of length
<A>n</A>, dimension <A>k</A> over field <A>F</A>.
It uses the mechanism explained in section
<Ref Label="BoundsMinimumDistance" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> C := BCHCode( 45, 7 );;
gap> UpperBoundMinimumDistance( C );
9
gap> UpperBoundMinimumDistance( 45, 23, GF(2) );
11
</Example>
<!--
C := BCHCode( 45, 7 );;
UpperBoundMinimumDistance( C );
UpperBoundMinimumDistance( 45, 23, GF(2) );
-->
<ManSection Label="BoundsMinimumDistance">
<Func Name="BoundsMinimumDistance" Arg=" n k F "/>
<Description>
The function <C>BoundsMinimumDistance</C> calculates a lower and upper bound
for the minimum distance of an optimal linear code with word length
<A>n</A>, dimension <A>k</A> over field <A>F</A>. The function
returns a record with the two bounds and an explanation for
each bound. The function <C>Display</C> can be
used to show the explanations.
<P/>
The values for the lower and upper bound are obtained from a
table. <Package>GUAVA</Package> has tables containing lower
and upper bounds for <M>q=2 (n \leq 257), <!--3, 4 (n \leq 130)</M>.
(Current as of 1998 - now out of date.)-->
3 (n \leq 243), 4 (n \leq 256)</M>. (Current as of 11 May 2006.)
These tables were derived from the table of Brouwer.
(See <Cite Key="Br"/>,
<URL>http://www.win.tue.nl/~aeb/voorlincod.html</URL> for the most
recent data.)
For codes over other fields and for larger
word lengths, trivial bounds are used.
<P/>
The resulting record can be used in the function
<C>BestKnownLinearCode</C>
(see <Ref Func="BestKnownLinearCode" Style="Number"/>)
to construct a code with minimum distance
equal to the lower bound.
</Description>
</ManSection>
<Example>
gap> bounds := BoundsMinimumDistance( 7, 3 );; DisplayBoundsInfo( bounds );
an optimal linear [7,3,d] code over GF(2) has d=4
------------------------------------------------------------------------------
Lb(7,3)=4, by shortening of:
Lb(8,4)=4, u u+v construction of C1 and C2:
Lb(4,3)=2, dual of the repetition code
Lb(4,1)=4, repetition code
------------------------------------------------------------------------------
Ub(7,3)=4, Griesmer bound
# The lower bound is equal to the upper bound, so a code with
# these parameters is optimal.
gap> C := BestKnownLinearCode( bounds );; Display( C );
a linear [7,3,4]2..3 shortened code of
a linear [8,4,4]2 U U+V construction code of
U: a cyclic [4,3,2]1 dual code of
a cyclic [4,1,4]2 repetition code over GF(2)
V: a cyclic [4,1,4]2 repetition code over GF(2)
</Example>
<!--
bounds := BoundsMinimumDistance( 7, 3 );;
DisplayBoundsInfo( bounds );
C := BestKnownLinearCode( bounds );;
Display( C );
-->
</Section>
<Section>
<Heading>
Covering radius bounds on codes
</Heading>
<Label Name="Covering radius bounds on codes"/>
<ManSection Label="BoundsCoveringRadius">
<Func Name="BoundsCoveringRadius" Arg=" C "/>
<Description>
<C>BoundsCoveringRadius</C> returns a list of integers.
The first entry of this list is the maximum of some lower bounds
for the covering radius of <A>C</A>,
the last entry the minimum of some upper bounds of <A>C</A>.
<P/>
If the covering radius of <A>C</A> is known, a list of length 1 is
returned.
<C>BoundsCoveringRadius</C> makes use of the functions
<C>GeneralLowerBoundCoveringRadius</C> and
<C>GeneralUpperBoundCoveringRadius</C>.
</Description>
</ManSection>
<Example>
gap> BoundsCoveringRadius( BCHCode( 17, 3, GF(2) ) );
[ 3 .. 4 ]
gap> BoundsCoveringRadius( HammingCode( 5, GF(2) ) );
[ 1 ]
</Example>
<ManSection Label="IncreaseCoveringRadiusLowerBound">
<Func Name="IncreaseCoveringRadiusLowerBound" Arg=" C [stopdist] [startword] "/>
<Description>
<C>IncreaseCoveringRadiusLowerBound</C> tries to increase the lower
bound of
the covering radius of <A>C</A>. It does this by means of a probabilistic
algorithm. This algorithm takes a random word in <M>GF(q)^n</M> (or
<A>startword</A> if it is specified), and, by changing random coordinates,
tries to get as far from <A>C</A> as possible. If changing a coordinate
finds a word that has a larger distance to the code than the previous
one, the change is made permanent, and the algorithm starts all over
again. If changing a coordinate does not find a coset leader that is
further away from the code, then the change is made permanent with a
chance of 1 in 100, if it gets the word closer to the code, or with a
chance of 1 in 10, if the word stays at the same distance. Otherwise, the
algorithm starts again with the same word as before.
<P/>
If the algorithm did not allow changes that decrease the distance to the
code, it might get stuck in a sub-optimal situation (the coset leader
corresponding to such a situation - i.e. no coordinate of this coset
leader can be changed in such a way that we get at a larger distance from
the code - is called an <E>orphan</E>).
<P/>
If the algorithm finds a word that has distance <A>stopdist</A> to the
code, it ends and returns that word, which can be used for further
investigations.
<P/>
The variable <A>InfoCoveringRadius</A> can be set to
<A>Print</A> to print the maximum distance reached so far every
1000 runs. The algorithm can be interrupted with <B>ctrl-C</B>,
allowing the user to look at the word that is
currently being examined (called `current'), or to change the chances
that the new word is made permanent (these are called
`staychance' and `downchance'). If one of these variables is
<M>i</M>, then it corresponds with
a <M>i</M> in 100 chance.
<P/>
At the moment, the algorithm is only useful for codes with small
dimension, where small means that the elements of the code fit in the
memory. It works with larger codes, however, but when you use it for
codes with large dimension, you should be <E>very</E> patient. If running the
algorithm quits GAP (due to memory problems), you can change the
global variable <A>CRMemSize</A> to a lower value. This might cause the
algorithm to run slower, but without quitting GAP. The only way to
find out the best value of <A>CRMemSize</A> is by experimenting.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,5,GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> IncreaseCoveringRadiusLowerBound(C,10);
Number of runs: 1000 best distance so far: 3
Number of runs: 2000 best distance so far: 3
Number of changes: 100
Number of runs: 3000 best distance so far: 3
Number of runs: 4000 best distance so far: 3
Number of runs: 5000 best distance so far: 3
Number of runs: 6000 best distance so far: 3
Number of runs: 7000 best distance so far: 3
Number of changes: 200
Number of runs: 8000 best distance so far: 3
Number of runs: 9000 best distance so far: 3
Number of runs: 10000 best distance so far: 3
Number of changes: 300
Number of runs: 11000 best distance so far: 3
Number of runs: 12000 best distance so far: 3
Number of runs: 13000 best distance so far: 3
Number of changes: 400
Number of runs: 14000 best distance so far: 3
user interrupt at...
#
# used ctrl-c to break out of execution
#
... called from
IncreaseCoveringRadiusLowerBound( code, -1, current ) called from
function( arguments ) called from read-eval-loop
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> current;
[ Z(2)^0, Z(2)^0, Z(2)^0, Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0 ]
brk>
gap> CoveringRadius(C);
3
</Example>
<!--
C:=RandomLinearCode(10,5,GF(2));
IncreaseCoveringRadiusLowerBound(C,10);
current;
CoveringRadius(C);
-->
<ManSection Label="ExhaustiveSearchCoveringRadius">
<Func Name="ExhaustiveSearchCoveringRadius" Arg=" C "/>
<Description>
<C>ExhaustiveSearchCoveringRadius</C> does an exhaustive search to find the
covering radius of <A>C</A>. Every time a coset leader of a coset with
weight <M>w</M> is found, the function tries to find a coset leader of a coset
with weight <M>w+1</M>. It does this by enumerating all words of
weight <M>w+1</M>,
and checking whether a word is a coset leader. The start weight is the
current known lower bound on the covering radius.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,5,GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> ExhaustiveSearchCoveringRadius(C);
Trying 3 ...
[ 3 .. 5 ]
gap> CoveringRadius(C);
3
</Example>
<!--
C:=RandomLinearCode(10,5,GF(2));
ExhaustiveSearchCoveringRadius(C);
CoveringRadius(C);
-->
<ManSection Label="GeneralLowerBoundCoveringRadius">
<Func Name="GeneralLowerBoundCoveringRadius" Arg=" C "/>
<Description>
<C>GeneralLowerBoundCoveringRadius</C> returns a lower bound on the covering
radius of <A>C</A>. It uses as many functions which names start with
<C>LowerBoundCoveringRadius</C> as possible to find the best known lower bound
(at least that <Package>GUAVA</Package> knows of)
together with tables for the covering
radius of binary linear codes with length not greater than <M>64</M>.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,5,GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> GeneralLowerBoundCoveringRadius(C);
2
gap> CoveringRadius(C);
3
</Example>
<!--
C:=RandomLinearCode(10,5,GF(2));
GeneralLowerBoundCoveringRadius(C);
CoveringRadius(C);
-->
<ManSection Label="GeneralUpperBoundCoveringRadius">
<Func Name="GeneralUpperBoundCoveringRadius" Arg=" C "/>
<Description>
<C>GeneralUpperBoundCoveringRadius</C> returns an upper bound on the
covering radius of <A>C</A>. It uses as many functions which
names start with <C>UpperBoundCoveringRadius</C>
as possible to find the best known upper bound
(at least that <Package>GUAVA</Package> knows of).
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,5,GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> GeneralUpperBoundCoveringRadius(C);
4
gap> CoveringRadius(C);
3
</Example>
<ManSection Label="LowerBoundCoveringRadiusSphereCovering">
<Func Name="LowerBoundCoveringRadiusSphereCovering" Arg=" n M [F] false "/>
<Description>
This command can also be called using the syntax
<C>LowerBoundCoveringRadiusSphereCovering( n, r, [F,] true )</C>.
If the last argument of <C>LowerBoundCoveringRadiusSphereCovering</C> is
<A>false</A>, then it returns a lower bound for the covering radius of a
code of size <A>M</A> and length <A>n</A>.
Otherwise, it returns a lower bound for the size of a code of length
<A>n</A> and covering radius <A>r</A>.
<P/>
<A>F</A> is the field over which the code is defined.
If <A>F</A> is omitted, it is
assumed that the code is over <M>GF(2)</M>.
The bound is computed according to the sphere covering bound:
<Display>
M \cdot V_q(n,r) \geq q^n
</Display>
where <M>V_q(n,r)</M> is the size of a sphere of radius
<M>r</M> in <M>GF(q)^n</M>.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,5,GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> Size(C);
32
gap> CoveringRadius(C);
3
gap> LowerBoundCoveringRadiusSphereCovering(10,32,GF(2),false);
2
gap> LowerBoundCoveringRadiusSphereCovering(10,3,GF(2),true);
6
</Example>
<!--
C:=RandomLinearCode(10,5,GF(2));
Size(C);
CoveringRadius(C);
LowerBoundCoveringRadiusSphereCovering(10,32,GF(2),false);
LowerBoundCoveringRadiusSphereCovering(10,3,GF(2),true);
-->
<ManSection Label="LowerBoundCoveringRadiusVanWee1">
<Func Name="LowerBoundCoveringRadiusVanWee1" Arg=" n M [F] false "/>
<Description>
This command can also be called using the syntax
<C>LowerBoundCoveringRadiusVanWee1( n, r, [F,] true )</C>.
If the last argument of <C>LowerBoundCoveringRadiusVanWee1</C> is
<A>false</A>, then it returns a lower bound for the covering radius of a
code of size <A>M</A> and length <A>n</A>.
Otherwise, it returns a lower bound for the size of a code of length
<A>n</A> and covering radius <A>r</A>.
<P/>
<A>F</A> is the field over which the code is defined.
If <A>F</A> is omitted, it is assumed that the code is over <M>GF(2)</M>.
<P/>
The Van Wee bound is an improvement of the sphere covering bound:
<Display>
M \cdot \left\{ V_q(n,r) -
\frac{{n \choose r}}{\lceil\frac{n-r}{r+1}\rceil}
\left(\left\lceil\frac{n+1}{r+1}\right\rceil - \frac{n+1}{r+1}\right)
\right\} \geq q^n
</Display>
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,5,GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> Size(C);
32
gap> CoveringRadius(C);
3
gap> LowerBoundCoveringRadiusVanWee1(10,32,GF(2),false);
2
gap> LowerBoundCoveringRadiusVanWee1(10,3,GF(2),true);
6
</Example>
<!--
C:=RandomLinearCode(10,5,GF(2));
Size(C);
CoveringRadius(C);
LowerBoundCoveringRadiusVanWee1(10,32,GF(2),false);
LowerBoundCoveringRadiusVanWee1(10,3,GF(2),true);
-->
<ManSection Label="LowerBoundCoveringRadiusVanWee2">
<Func Name="LowerBoundCoveringRadiusVanWee2" Arg=" n M false "/>
<Description>
This command can also be called using the syntax
<C>LowerBoundCoveringRadiusVanWee2( n, r [,true] )</C>.
If the last argument of <C>LowerBoundCoveringRadiusVanWee2</C>
is <A>false</A>,
then it returns a lower bound for the covering radius of a code of size
<A>M</A> and length <A>n</A>. Otherwise, it returns a lower
bound for the size of a code of length <A>n</A> and
covering radius <A>r</A>.
<P/>
This bound only works for binary codes. It is based on the following
inequality:
<Display>
M \cdot \frac{\left( \left( V_2(n,2) - \frac{1}{2}(r+2)(r-1) \right)
V_2(n,r) + \varepsilon
V_2(n,r-2) \right)}
{(V_2(n,2) - \frac{1}{2}(r+2)(r-1) + \varepsilon)}
\geq 2^n,
</Display>
where
<Display>
\varepsilon = {r+2 \choose 2} \left\lceil
{n-r+1 \choose 2} / {r+2 \choose 2} \right\rceil
- {n-r+1 \choose 2}.
</Display>
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,5,GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> Size(C);
32
gap> CoveringRadius(C);
3
gap> LowerBoundCoveringRadiusVanWee2(10,32,false);
2
gap> LowerBoundCoveringRadiusVanWee2(10,3,true);
7
</Example>
<!--
C:=RandomLinearCode(10,5,GF(2));
Size(C);
CoveringRadius(C);
LowerBoundCoveringRadiusVanWee2(10,32,false);
LowerBoundCoveringRadiusVanWee2(10,3,true);
-->
<ManSection Label="LowerBoundCoveringRadiusCountingExcess">
<Func Name="LowerBoundCoveringRadiusCountingExcess" Arg=" n M false "/>
<Description>
This command can also be called with
<C>LowerBoundCoveringRadiusCountingExcess( n, r [,true] )</C>.
If the last argument of <C>LowerBoundCoveringRadiusCountingExcess</C> is
<A>false</A>, then it returns a lower bound for the covering radius of a code
of size <A>M</A> and length <A>n</A>. Otherwise, it returns a
lower bound for the size of a code of length <A>n</A> and
covering radius <A>r</A>.
<P/>
This bound only works for binary codes. It is based on the following
inequality:
<Display>
M \cdot \left( \rho V_2(n,r) + \varepsilon V_2(n,r-1) \right) \geq
(\rho + \varepsilon) 2^n,
</Display>
where
<Display>
\varepsilon = (r+1) \left\lceil\frac{n+1}{r+1}\right\rceil - (n+1)
</Display>
and
<Display>
\rho = \left\{
\begin{array}{l}
n-3+\frac{2}{n}, \ \ \ \ \ \ {\rm if}\ r = 2\\
n-r-1 , \ \ \ \ \ \ {\rm if}\ r \geq 3 .
\end{array}
\right.
</Display>
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,5,GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> Size(C);
32
gap> CoveringRadius(C);
3
gap> LowerBoundCoveringRadiusCountingExcess(10,32,false);
0
gap> LowerBoundCoveringRadiusCountingExcess(10,3,true);
7
</Example>
<!--
C:=RandomLinearCode(10,5,GF(2));
Size(C);
CoveringRadius(C);
LowerBoundCoveringRadiusCountingExcess(10,32,false);
LowerBoundCoveringRadiusCountingExcess(10,3,true);
-->
<ManSection Label="LowerBoundCoveringRadiusEmbedded1">
<Func Name="LowerBoundCoveringRadiusEmbedded1" Arg=" n M false "/>
<Description>
This command can also be called with
<C>LowerBoundCoveringRadiusEmbedded1( n, r [,true] )</C>.
If the last argument of <C>LowerBoundCoveringRadiusEmbedded1</C>
is 'false', then it returns a lower bound for the
covering radius of a code of size <A>M</A> and length
<A>n</A>. Otherwise, it returns a lower bound for the size of a
code of length <A>n</A> and covering radius <A>r</A>.
<P/>
This bound only works for binary codes. It is based on the following
inequality:
<Display>
M \cdot \left( V_2(n,r) - {2r \choose r} \right) \geq
2^n - A( n, 2r+1 ) {2r \choose r},
</Display>
where <M>A(n,d)</M> denotes the maximal cardinality
of a (binary) code of length <M>n</M> and minimum distance
<M>d</M>. The function <C>UpperBound</C> is used to
compute this value.
<P/>
Sometimes <C>LowerBoundCoveringRadiusEmbedded1</C> is better than
<C>LowerBoundCoveringRadiusEmbedded2</C>, sometimes it is the
other way around.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(10,5,GF(2));
a [10,5,?] randomly generated code over GF(2)
gap> Size(C);
32
gap> CoveringRadius(C);
3
gap> LowerBoundCoveringRadiusEmbedded1(10,32,false);
2
gap> LowerBoundCoveringRadiusEmbedded1(10,3,true);
7
</Example>
<!--
C:=RandomLinearCode(10,5,GF(2));
Size(C);
CoveringRadius(C);
LowerBoundCoveringRadiusEmbedded1(10,32,false);
LowerBoundCoveringRadiusEmbedded1(10,3,true);
-->
<ManSection Label="LowerBoundCoveringRadiusEmbedded2">
<Func Name="LowerBoundCoveringRadiusEmbedded2" Arg=" n M false "/>
<Description>
This command can also be called with
<C>LowerBoundCoveringRadiusEmbedded2( n, r [,true] )</C>.
If the last argument of <C>LowerBoundCoveringRadiusEmbedded2</C>
is 'false',
then it returns a lower bound for the covering radius of a code of size
<A>M</A> and length <A>n</A>. Otherwise, it returns a
lower bound for the size of a code of length <A>n</A>
and covering radius <A>r</A>.
<P/>
This bound only works for binary codes. It is based on the following
inequality:
<Display>
M \cdot \left( V_2(n,r) - \frac{3}{2} {2r \choose r} \right) \geq
2^n - 2A( n, 2r+1 ) {2r \choose r},
</Display>
where <M>A(n,d)</M> denotes the maximal cardinality
of a (binary) code of length <M>n</M> and minimum distance
<M>d</M>. The function <C>UpperBound</C> is used to
compute this value.
<P/>
Sometimes <C>LowerBoundCoveringRadiusEmbedded1</C> is better than
<C>LowerBoundCoveringRadiusEmbedded2</C>, sometimes it is the
other way around.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(15,5,GF(2));
a [15,5,?] randomly generated code over GF(2)
gap> Size(C);
32
gap> CoveringRadius(C);
6
gap> LowerBoundCoveringRadiusEmbedded2(10,32,false);
2
gap> LowerBoundCoveringRadiusEmbedded2(10,3,true);
7
</Example>
<ManSection Label="LowerBoundCoveringRadiusInduction">
<Func Name="LowerBoundCoveringRadiusInduction" Arg=" n r "/>
<Description>
<C>LowerBoundCoveringRadiusInduction</C> returns a lower
bound for the size of a code with length <A>n</A> and
covering radius <A>r</A>.
<P/>
If <M>n = 2r+2</M> and <M>r \geq 1</M>, the returned
value is <M>4</M>.
<P/>
If <M>n = 2r+3</M> and <M>r \geq 1</M>, the returned
value is <M>7</M>.
<P/>
If <M>n = 2r+4</M> and <M>r \geq 4</M>, the returned
value is <M>8</M>.
<P/>
Otherwise, <M>0</M> is returned.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(15,5,GF(2));
a [15,5,?] randomly generated code over GF(2)
gap> CoveringRadius(C);
5
gap> LowerBoundCoveringRadiusInduction(15,6);
7
</Example>
<!--
C:=RandomLinearCode(15,5,GF(2));
CoveringRadius(C);
LowerBoundCoveringRadiusInduction(15,6);
-->
<ManSection Label="UpperBoundCoveringRadiusRedundancy">
<Func Name="UpperBoundCoveringRadiusRedundancy" Arg=" C "/>
<Description>
<C>UpperBoundCoveringRadiusRedundancy</C> returns the
redundancy of <A>C</A> as an upper bound for the covering
radius of <A>C</A>. <A>C</A> must be a linear code.
</Description>
</ManSection>
<Index>
external distance
</Index>
<Example>
gap> C:=RandomLinearCode(15,5,GF(2));
a [15,5,?] randomly generated code over GF(2)
gap> CoveringRadius(C);
5
gap> UpperBoundCoveringRadiusRedundancy(C);
10
</Example>
<!--
C:=RandomLinearCode(15,5,GF(2));
CoveringRadius(C);
UpperBoundCoveringRadiusRedundancy(C);
-->
<ManSection Label="UpperBoundCoveringRadiusDelsarte">
<Func Name="UpperBoundCoveringRadiusDelsarte" Arg=" C "/>
<Description>
<C>UpperBoundCoveringRadiusDelsarte</C> returns an upper bound
for the covering radius of <A>C</A>. This upper bound is equal
to the external distance of <A>C</A>, this is the minimum
distance of the dual code, if <A>C</A> is a linear code.
<P/>
This is described in Theorem 11.3.3 of <Cite Key="HP03"/>.
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(15,5,GF(2));
a [15,5,?] randomly generated code over GF(2)
gap> CoveringRadius(C);
5
gap> UpperBoundCoveringRadiusDelsarte(C);
13
</Example>
<!--
C:=RandomLinearCode(15,5,GF(2));
CoveringRadius(C);
UpperBoundCoveringRadiusDelsarte(C);
-->
<ManSection Label="UpperBoundCoveringRadiusStrength">
<Func Name="UpperBoundCoveringRadiusStrength" Arg=" C "/>
<Description>
<C>UpperBoundCoveringRadiusStrength</C> returns an upper bound
for the covering radius of <A>C</A>.
<P/>
First the code is punctured at the zero coordinates (i.e. the coordinates
where all codewords have a zero). If the remaining code has
<E>strength</E> 1
(i.e. each coordinate contains each element of the field an equal number
of times), then it returns <M>\frac{q-1}{q}m + (n-m)</M>
(where <M>q</M> is the size of the field and <M>m</M> is
the length of punctured code), otherwise it returns <M>n</M>.
This bound works for all codes.
</Description>
</ManSection>
<Index>
strength
</Index>
<Example>
gap> C:=RandomLinearCode(15,5,GF(2));
a [15,5,?] randomly generated code over GF(2)
gap> CoveringRadius(C);
5
gap> UpperBoundCoveringRadiusStrength(C);
7
</Example>
<!--
C:=RandomLinearCode(15,5,GF(2));
CoveringRadius(C);
UpperBoundCoveringRadiusStrength(C);
-->
<ManSection Label="UpperBoundCoveringRadiusGriesmerLike">
<Func Name="UpperBoundCoveringRadiusGriesmerLike" Arg=" C "/>
<Description>
This function returns an upper bound for the covering radius
of <A>C</A>, which must be linear, in a Griesmer-like fashion. It returns
<Display>
n - \sum_{i=1}^k \left\lceil \frac{d}{q^i} \right\rceil
</Display>
</Description>
</ManSection>
<Example>
gap> C:=RandomLinearCode(15,5,GF(2));
a [15,5,?] randomly generated code over GF(2)
gap> CoveringRadius(C);
5
gap> UpperBoundCoveringRadiusGriesmerLike(C);
9
</Example>
<!--
C:=RandomLinearCode(15,5,GF(2));
CoveringRadius(C);
UpperBoundCoveringRadiusGriesmerLike(C);
-->
<ManSection Label="UpperBoundCoveringRadiusCyclicCode">
<Func Name="UpperBoundCoveringRadiusCyclicCode" Arg=" C "/>
<Description>
This function returns an upper bound for the covering radius
of <A>C</A>, which must be a cyclic code. It returns
<Display>
n - k + 1 - \left\lceil \frac{w(g(x))}{2} \right\rceil,
</Display>
where <M>g(x)</M> is the generator polynomial of <A>C</A>.
</Description>
</ManSection>
<Example>
gap> C:=CyclicCodes(15,GF(2))[3];
a cyclic [15,12,1..2]1..3 enumerated code over GF(2)
gap> CoveringRadius(C);
3
gap> UpperBoundCoveringRadiusCyclicCode(C);
3
</Example>
<!--
C:=CyclicCodes(15,GF(2))[3];
CoveringRadius(C);
UpperBoundCoveringRadiusCyclicCode(C);
-->
</Section>
<Section>
<Heading>
Special matrices in <Package>GUAVA</Package>
</Heading>
<Label Name="Special matrices in GUAVA"/>
This section explains functions that work with special matrices
<Package>GUAVA</Package> needs for several codes.
<P/>
Firstly, we describe some matrix generating functions (see
<Ref Func="KrawtchoukMat" Style="Number"/>,
<Ref Func="GrayMat" Style="Number"/>,
<Ref Func="SylvesterMat" Style="Number"/>,
<Ref Func="HadamardMat" Style="Number"/> and
<Ref Func="MOLS" Style="Number"/>).
<P/>
Next we describe two functions regarding a standard form of matrices (see
<Ref Func="PutStandardForm" Style="Number"/> and
<Ref Func="IsInStandardForm" Style="Number"/>).
<P/>
Then we describe functions that return a matrix after a manipulation (see
<Ref Func="PermutedCols" Style="Number"/>,
<Ref Func="VerticalConversionFieldMat" Style="Number"/> and
<Ref Func="HorizontalConversionFieldMat" Style="Number"/>).
<P/>
Finally, we describe functions that do some tests on matrices (see
<Ref Func="IsLatinSquare" Style="Number"/> and
<Ref Func="AreMOLS" Style="Number"/>).
<ManSection Label="KrawtchoukMat">
<Func Name="KrawtchoukMat" Arg=" n q "/>
<Description>
<C>KrawtchoukMat</C> returns the <M>n+1</M> by <M>n+1</M> matrix
<M>K=(k_{ij})</M> defined by <M>k_{ij}=K_i(j)</M>
for <M>i,j=0,...,n</M>. <M>K_i(j)</M> is the Krawtchouk
number
(see <Ref Func="Krawtchouk" Style="Number"/>).
<A>n</A> must be a positive integer and <A>q</A> a prime
power. The Krawtchouk matrix is used in the
<E>MacWilliams identities</E>,
defining the relation between the weight distribution of a code of length
<A>n</A> over a field of size <A>q</A>, and its dual code.
Each call to <C>KrawtchoukMat</C> returns a new matrix, so it is
safe to modify the result.
</Description>
</ManSection>
<Example>
gap> PrintArray( KrawtchoukMat( 3, 2 ) );
[ [ 1, 1, 1, 1 ],
[ 3, 1, -1, -3 ],
[ 3, -1, -1, 3 ],
[ 1, -1, 1, -1 ] ]
gap> C := HammingCode( 3 );; a := WeightDistribution( C );
[ 1, 0, 0, 7, 7, 0, 0, 1 ]
gap> n := WordLength( C );; q := Size( LeftActingDomain( C ) );;
gap> k := Dimension( C );;
gap> q^( -k ) * KrawtchoukMat( n, q ) * a;
[ 1, 0, 0, 0, 7, 0, 0, 0 ]
gap> WeightDistribution( DualCode( C ) );
[ 1, 0, 0, 0, 7, 0, 0, 0 ]
</Example>
<!--
PrintArray( KrawtchoukMat( 3, 2 ) );
C := HammingCode( 3 );; a := WeightDistribution( C );
n := WordLength( C );; q := Size( LeftActingDomain( C ) );;
k := Dimension( C );;
q^( -k ) * KrawtchoukMat( n, q ) * a;
WeightDistribution( DualCode( C ) );
-->
<Index>
Gary code
</Index>
<ManSection Label="GrayMat">
<Func Name="GrayMat" Arg=" n F "/>
<Description>
<C>GrayMat</C> returns a list of all different vectors (see
GAP's <C>Vectors</C> command) of length <A>n</A> over the field <A>F</A>,
using Gray ordering. <A>n</A> must be a positive integer.
This order has the property that subsequent vectors
differ in exactly one coordinate. The first vector is always the null
vector. Each call to <C>GrayMat</C> returns a new matrix, so it is safe to
modify the result.
</Description>
</ManSection>
<Example>
gap> GrayMat(3);
[ [ 0*Z(2), 0*Z(2), 0*Z(2) ], [ 0*Z(2), 0*Z(2), Z(2)^0 ],
[ 0*Z(2), Z(2)^0, Z(2)^0 ], [ 0*Z(2), Z(2)^0, 0*Z(2) ],
[ Z(2)^0, Z(2)^0, 0*Z(2) ], [ Z(2)^0, Z(2)^0, Z(2)^0 ],
[ Z(2)^0, 0*Z(2), Z(2)^0 ], [ Z(2)^0, 0*Z(2), 0*Z(2) ] ]
gap> G := GrayMat( 4, GF(4) );; Length(G);
256 # the length of a GrayMat is always q^n
gap> G[101] - G[100];
[ 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2) ]
</Example>
<!--
GrayMat(3);
G := GrayMat( 4, GF(4) );; Length(G);
G[101] - G[100];
-->
<ManSection Label="SylvesterMat">
<Func Name="SylvesterMat" Arg=" n "/>
<Description>
<C>SylvesterMat</C> returns the <M>n\times n</M>
Sylvester matrix of order <A>n</A>. This
is a special case of the Hadamard matrices (see
<Ref Func="HadamardMat" Style="Number"/>). For this
construction, <A>n</A> must be a power of <M>2</M>. Each
call to <C>SylvesterMat</C> returns a new matrix, so it is
safe to modify the result.
</Description>
</ManSection>
<Example>
gap> PrintArray(SylvesterMat(2));
[ [ 1, 1 ],
[ 1, -1 ] ]
gap> PrintArray( SylvesterMat(4) );
[ [ 1, 1, 1, 1 ],
[ 1, -1, 1, -1 ],
[ 1, 1, -1, -1 ],
[ 1, -1, -1, 1 ] ]
</Example>
<Index>
Hadamard matrix
</Index>
<ManSection Label="HadamardMat">
<Func Name="HadamardMat" Arg=" n "/>
<Description>
<C>HadamardMat</C> returns a Hadamard matrix of order <A>n</A>.
This is an <M>n\times n</M> matrix with the property that
the matrix multiplied by its transpose
returns <A>n</A> times the identity matrix. This is only possible for
<M>n=1, n=2</M> or in cases where <A>n</A> is a multiple of <M>4</M>.
If the matrix does not exist or is not known (as of 1998),
<C>HadamardMat</C> returns an error. A large number of
construction methods is known to create these matrices for different
orders. <C>HadamardMat</C> makes use of two construction methods (the
Paley Type I and II constructions, and the Sylvester construction -- see
<Ref Func="SylvesterMat" Style="Number"/>). These methods cover
most of the possible Hadamard matrices, although some special algorithms
have not been implemented yet. The following orders less than
<M>100</M> do not yet have an implementation for a Hadamard
matrix in <Package>GUAVA</Package>: <M>52, 92</M>.
</Description>
</ManSection>
<Example>
gap> C := HadamardMat(8);; PrintArray(C);
[ [ 1, 1, 1, 1, 1, 1, 1, 1 ],
[ 1, -1, 1, -1, 1, -1, 1, -1 ],
[ 1, 1, -1, -1, 1, 1, -1, -1 ],
[ 1, -1, -1, 1, 1, -1, -1, 1 ],
[ 1, 1, 1, 1, -1, -1, -1, -1 ],
[ 1, -1, 1, -1, -1, 1, -1, 1 ],
[ 1, 1, -1, -1, -1, -1, 1, 1 ],
[ 1, -1, -1, 1, -1, 1, 1, -1 ] ]
gap> C * TransposedMat(C) = 8 * IdentityMat( 8, 8 );
true
</Example>
<ManSection Label="VandermondeMat">
<Func Name="VandermondeMat" Arg=" X a "/>
<Description>
The function <C>VandermondeMat</C> returns the
<M>(a+1)\times n</M> matrix of powers <M>x_i^j</M> where
<A>X</A> is a list of elements of a field,
<M>X=\{ x_1,...,x_n\}</M>, and <A>a</A> is a
non-negative integer.
</Description>
</ManSection>
<Example>
gap> M:=VandermondeMat([Z(5),Z(5)^2,Z(5)^0,Z(5)^3],2);
[ [ Z(5)^0, Z(5), Z(5)^2 ], [ Z(5)^0, Z(5)^2, Z(5)^0 ],
[ Z(5)^0, Z(5)^0, Z(5)^0 ], [ Z(5)^0, Z(5)^3, Z(5)^2 ] ]
gap> Display(M);
1 2 4
1 4 1
1 1 1
1 3 4
</Example>
<!--
M:=VandermondeMat([Z(5),Z(5)^2,Z(5)^0,Z(5)^3],2);
Display(M);
-->
<Index>
standard form
</Index>
<ManSection Label="PutStandardForm">
<Func Name="PutStandardForm" Arg=" M [idleft] "/>
<Description>
We say that a <M>k\times n</M> matrix is in <E>standard form</E>
if it is equal to the block matrix <M>(I\ |\ A)</M>, for
some <M>k\times (n-k)</M> matrix <M>A</M> and where
<M>I</M> is the <M>k\times k</M> identity matrix.
It follows from a basis result in linear algebra that,
after a possible permutation of the columns,
using elementary row operations, every matrix can be
reduced to standard form.
<C>PutStandardForm</C> puts a matrix <A>M</A> in standard form,
and returns the permutation needed to do so. <A>idleft</A>
is a boolean that sets the position of the identity matrix in
<A>M</A>. (The default for <A>idleft</A> is `true'.)
If <A>idleft</A> is set to `true', the identity
matrix is put on the left side of <A>M</A>.
Otherwise, it is put at the right side.
(This option is useful when putting a check matrix of a code
into standard form.)
The function <C>BaseMat</C> also returns a similar standard form, but does not
apply column permutations. The rows of the matrix still span the same
vector space after <C>BaseMat</C>, but after calling
<C>PutStandardForm</C>, this is not necessarily true.
</Description>
</ManSection>
<Example>
gap> M := Z(2)*[[1,0,0,1],[0,0,1,1]];; PrintArray(M);
[ [ Z(2), 0*Z(2), 0*Z(2), Z(2) ],
[ 0*Z(2), 0*Z(2), Z(2), Z(2) ] ]
gap> PutStandardForm(M); # identity at the left side
(2,3)
gap> PrintArray(M);
[ [ Z(2), 0*Z(2), 0*Z(2), Z(2) ],
[ 0*Z(2), Z(2), 0*Z(2), Z(2) ] ]
gap> PutStandardForm(M, false); # identity at the right side
(1,4,3)
gap> PrintArray(M);
[ [ 0*Z(2), Z(2), Z(2), 0*Z(2) ],
[ 0*Z(2), Z(2), 0*Z(2), Z(2) ] ]
gap> C := BestKnownLinearCode( 23, 12, GF(2) );
a linear [23,12,7]3 punctured code
gap> G:=MutableCopyMat(GeneratorMat(C));;
gap> PutStandardForm(G);
()
gap> Display(G);
1 . . . . . . . . . . . 1 . 1 . 1 1 1 . . . 1
. 1 . . . . . . . . . . 1 1 1 1 1 . . 1 . . .
. . 1 . . . . . . . . . 1 1 . 1 . . 1 . 1 . 1
. . . 1 . . . . . . . . 1 1 . . . 1 1 1 . 1 .
. . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1 . 1
. . . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1 1
. . . . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1
. . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 1 . .
. . . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 1 .
. . . . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 .
. . . . . . . . . . 1 . 1 . 1 1 1 . . . 1 1 1
. . . . . . . . . . . 1 . 1 . 1 1 1 . . . 1 1
</Example>
<ManSection Label="IsInStandardForm">
<Func Name="IsInStandardForm" Arg=" M [idleft] "/>
<Description>
<C>IsInStandardForm</C> determines if <A>M</A> is in standard form.
<A>idleft</A> is a boolean that indicates the position of the
identity matrix in <A>M</A>, as in <C>PutStandardForm</C> (see
<Ref Func="PutStandardForm" Style="Number"/>).
<C>IsInStandardForm</C> checks if the identity matrix is
at the left side of <A>M</A>, otherwise if it is at the
right side. The elements of <A>M</A> may be elements of
any field.
</Description>
</ManSection>
<Example>
gap> IsInStandardForm(IdentityMat(7, GF(2)));
true
gap> IsInStandardForm([[1, 1, 0], [1, 0, 1]], false);
true
gap> IsInStandardForm([[1, 3, 2, 7]]);
true
gap> IsInStandardForm(HadamardMat(4));
false
</Example>
<ManSection Label="PermutedCols">
<Func Name="PermutedCols" Arg=" M P "/>
<Description>
<C>PermutedCols</C> returns a matrix <A>M</A> with a permutation
<A>P</A> applied to its columns.
</Description>
</ManSection>
<Example>
gap> M := [[1,2,3,4],[1,2,3,4]];; PrintArray(M);
[ [ 1, 2, 3, 4 ],
[ 1, 2, 3, 4 ] ]
gap> PrintArray(PermutedCols(M, (1,2,3)));
[ [ 3, 1, 2, 4 ],
[ 3, 1, 2, 4 ] ]
</Example>
<ManSection Label="VerticalConversionFieldMat">
<Func Name="VerticalConversionFieldMat" Arg=" M F "/>
<Description>
<C>VerticalConversionFieldMat</C> returns the matrix
<A>M</A> with its elements converted from a field
<M>F=GF(q^m)</M>, <M>q</M> prime, to a field <M>GF(q)</M>. Each
element is replaced by its representation over the latter field, placed
vertically in the matrix, using the <M>GF(p)</M>-vector space
isomorphism
<Display>
[...] : GF(q)\rightarrow GF(p)^m,
</Display>
with <M>q=p^m</M>.
<P/>
If <A>M</A> is a <M>k</M> by <M>n</M> matrix, the result is
a <M>k\cdot m \times n</M> matrix,
since each element of <M>GF(q^m)</M> can be represented
in <M>GF(q)</M> using <M>m</M> elements.
</Description>
</ManSection>
<Example>
gap> M := Z(9)*[[1,2],[2,1]];; PrintArray(M);
[ [ Z(3^2), Z(3^2)^5 ],
[ Z(3^2)^5, Z(3^2) ] ]
gap> DefaultField( Flat(M) );
GF(3^2)
gap> VCFM := VerticalConversionFieldMat( M, GF(9) );; PrintArray(VCFM);
[ [ 0*Z(3), 0*Z(3) ],
[ Z(3)^0, Z(3) ],
[ 0*Z(3), 0*Z(3) ],
[ Z(3), Z(3)^0 ] ]
gap> DefaultField( Flat(VCFM) );
GF(3)
</Example>
A similar function is <C>HorizontalConversionFieldMat</C> (see
<Ref Func="HorizontalConversionFieldMat" Style="Number"/>).
<ManSection Label="HorizontalConversionFieldMat">
<Func Name="HorizontalConversionFieldMat" Arg=" M F "/>
<Description>
<C>HorizontalConversionFieldMat</C> returns the matrix <A>M</A>
with its elements converted from a field <M>F=GF(q^m)</M>,
<M>q</M> prime, to a field <M>GF(q)</M>.
Each element is replaced by its representation over the
latter field, placed horizontally in the matrix.
<P/>
If <A>M</A> is a <M>k \times n</M> matrix, the result is a
<M>k\times m\times n\cdot m</M> matrix.
The new word length of the resulting code is equal to
<M>n\cdot m</M>, because each element of <M>GF(q^m)</M>
can be represented in <M>GF(q)</M> using <M>m</M> elements.
The new dimension is equal to <M>k\times m</M>
because the new matrix should be a basis for the same number
of vectors as the old one.
<P/>
<C>ConversionFieldCode</C> uses horizontal conversion to
convert a code (see
<Ref Func="ConversionFieldCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> M := Z(9)*[[1,2],[2,1]];; PrintArray(M);
[ [ Z(3^2), Z(3^2)^5 ],
[ Z(3^2)^5, Z(3^2) ] ]
gap> DefaultField( Flat(M) );
GF(3^2)
gap> HCFM := HorizontalConversionFieldMat(M, GF(9));; PrintArray(HCFM);
[ [ 0*Z(3), Z(3)^0, 0*Z(3), Z(3) ],
[ Z(3)^0, Z(3)^0, Z(3), Z(3) ],
[ 0*Z(3), Z(3), 0*Z(3), Z(3)^0 ],
[ Z(3), Z(3), Z(3)^0, Z(3)^0 ] ]
gap> DefaultField( Flat(HCFM) );
GF(3)
</Example>
A similar function is <C>VerticalConversionFieldMat</C> (see
<Ref Func="VerticalConversionFieldMat" Style="Number"/>).
<Index>
mutually orthogonal Latin squares
</Index>
<Index>
Latin square
</Index>
<ManSection Label="MOLS">
<Func Name="MOLS" Arg=" q [n] "/>
<Description>
<C>MOLS</C> returns a list of <A>n</A> <E>Mutually Orthogonal
Latin Squares</E> (MOLS). A <E>Latin square</E>
of order <A>q</A> is a <M>q\times q</M> matrix whose
entries are from a set <M>F_{q}</M> of <A>q</A>
distinct symbols (<Package>GUAVA</Package> uses the
integers from <M>0</M> to <A>q</A>) such that each row
and each column of the matrix contains each symbol exactly once.
<P/>
A set of Latin squares is a set of MOLS if and only if for each pair of
Latin squares in this set, every ordered pair of elements that are in the
same position in these matrices occurs exactly once.
<P/>
<A>n</A> must be less than <A>q</A>. If <A>n</A> is omitted,
two MOLS are returned. If <A>q</A> is not a prime power,
at most <M>2</M> MOLS can be created. For all values
of <A>q</A> with <M>q > 2</M> and <M>q \neq 6</M>,
a list of MOLS can be constructed. However,
<Package>GUAVA</Package> does not yet construct MOLS for
<M>q\equiv 2 \pmod 4</M>. If it is not possible to construct
<A>n</A> MOLS, the function returns `false'.
<P/>
MOLS are used to create <A>q</A>-ary codes (see
<Ref Func="MOLSCode" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> M := MOLS( 4, 3 );;PrintArray( M[1] );
[ [ 0, 1, 2, 3 ],
[ 1, 0, 3, 2 ],
[ 2, 3, 0, 1 ],
[ 3, 2, 1, 0 ] ]
gap> PrintArray( M[2] );
[ [ 0, 2, 3, 1 ],
[ 1, 3, 2, 0 ],
[ 2, 0, 1, 3 ],
[ 3, 1, 0, 2 ] ]
gap> PrintArray( M[3] );
[ [ 0, 3, 1, 2 ],
[ 1, 2, 0, 3 ],
[ 2, 1, 3, 0 ],
[ 3, 0, 2, 1 ] ]
gap> MOLS( 12, 3 );
false
</Example>
<ManSection Label="IsLatinSquare">
<Func Name="IsLatinSquare" Arg=" M "/>
<Description>
<C>IsLatinSquare</C> determines if a matrix <A>M</A> is a
Latin square. For a Latin square of size <M>n\times n</M>,
each row and each column contains all the integers
<M>1,\dots,n</M> exactly once.
</Description>
</ManSection>
<Example>
gap> IsLatinSquare([[1,2],[2,1]]);
true
gap> IsLatinSquare([[1,2,3],[2,3,1],[1,3,2]]);
false
</Example>
<ManSection Label="AreMOLS">
<Func Name="AreMOLS" Arg=" L "/>
<Description>
<C>AreMOLS</C> determines if <A>L</A> is a list of mutually
orthogonal Latin squares (MOLS). For each pair of
Latin squares in this list, the function checks if each ordered
pair of elements that are in the same position in
these matrices occurs exactly once. The function <C>MOLS</C>
creates MOLS (see <Ref Func="MOLS" Style="Number"/>).
</Description>
</ManSection>
<Example>
gap> M := MOLS(4,2);
[ [ [ 0, 1, 2, 3 ], [ 1, 0, 3, 2 ], [ 2, 3, 0, 1 ], [ 3, 2, 1, 0 ] ],
[ [ 0, 2, 3, 1 ], [ 1, 3, 2, 0 ], [ 2, 0, 1, 3 ], [ 3, 1, 0, 2 ] ] ]
gap> AreMOLS(M);
true
</Example>
</Section>
<Section>
<Heading>
Some functions related to the norm of a code
</Heading>
<Label Name="Some functions related to the norm of a code"/>
In this section, some functions that can be used to compute the norm of a
code and to decide upon its normality are discussed.
Typically, these are applied to binary linear codes.
The definitions of this section were introduced in
Graham and Sloane <Cite Key="GS85"/>.
<ManSection Label="CoordinateNorm">
<Func Name="CoordinateNorm" Arg=" C coord "/>
<Description>
<C>CoordinateNorm</C> returns the norm of <A>C</A> with respect to
coordinate <A>coord</A>. If
<M>C_a = \{ c \in C \ |\ c_{coord} = a \}</M>,
then the norm of <A>C</A> with respect to <A>coord</A> is
defined as
<Display>
\max_{v \in GF(q)^n} \sum_{a=1}^q d(x,C_a),
</Display>
with the convention that <M>d(x,C_a) = n</M>
if <M>C_a</M> is empty.
</Description>
</ManSection>
<Example>
gap> CoordinateNorm( HammingCode( 3, GF(2) ), 3 );
3
</Example>
<Index>
norm of a code
</Index>
<ManSection Label="CodeNorm">
<Func Name="CodeNorm" Arg=" C "/>
<Description>
<C>CodeNorm</C> returns the norm of <A>C</A>.
The <E>norm</E> of a code is defined as
the minimum of the norms for the respective coordinates of the code. In
effect, for each coordinate <C>CoordinateNorm</C>
is called, and the minimum
of the calculated numbers is returned.
</Description>
</ManSection>
<Example>
gap> CodeNorm( HammingCode( 3, GF(2) ) );
3
</Example>
<Index>
acceptable coordinate
</Index>
<ManSection Label="IsCoordinateAcceptable">
<Func Name="IsCoordinateAcceptable" Arg=" C coord "/>
<Description>
<C>IsCoordinateAcceptable</C> returns `true' if
coordinate <A>coord</A> of <A>C</A> is acceptable.
A coordinate is called <E>acceptable</E> if the norm of
the code with respect to that coordinate is
not more than two times the covering radius of
the code plus one.
</Description>
</ManSection>
<Example>
gap> IsCoordinateAcceptable( HammingCode( 3, GF(2) ), 3 );
true
</Example>
<Index>
acceptable coordinate
</Index>
<ManSection Label="GeneralizedCodeNorm">
<Func Name="GeneralizedCodeNorm" Arg=" C subcode1 subscode2 ... subcodek "/>
<Description>
<C>GeneralizedCodeNorm</C> returns the <A>k</A>-norm of <A>C</A>
with respect to <A>k</A> subcodes.
</Description>
</ManSection>
<Example>
gap> c := RepetitionCode( 7, GF(2) );;
gap> ham := HammingCode( 3, GF(2) );;
gap> d := EvenWeightSubcode( ham );;
gap> e := ConstantWeightSubcode( ham, 3 );;
gap> GeneralizedCodeNorm( ham, c, d, e );
4
</Example>
<Index>
normal code
</Index>
<ManSection Label="IsNormalCode">
<Func Name="IsNormalCode" Arg=" C "/>
<Description>
<C>IsNormalCode</C> returns `true' if <A>C</A> is normal.
A code is called <E>normal</E> if the norm of the code is not
more than two times the covering radius of the code plus one.
Almost all codes are normal, however some
(non-linear) abnormal codes have been found.
<P/>
Often, it is difficult to find out whether a code is normal, because it
involves computing the covering radius. However,
<C>IsNormalCode</C> uses much
information from the literature (in particular,
<Cite Key="GS85"/>) about normality for certain code
parameters.
</Description>
</ManSection>
<Example>
gap> IsNormalCode( HammingCode( 3, GF(2) ) );
true
</Example>
</Section>
<Section>
<Heading>
Miscellaneous functions
</Heading>
<Label Name="Miscellaneous functions"/>
In this section we describe several vector space functions
<Package>GUAVA</Package> uses for
constructing codes or performing calculations with codes.
<P/>
In this section, some new miscellaneous functions are described,
including weight enumerators, the MacWilliams-transform and
affinity and almost affinity of codes.
<Index>
weight enumerator polynomial
</Index>
<ManSection Label="CodeWeightEnumerator">
<Func Name="CodeWeightEnumerator" Arg=" C "/>
<Description>
<C>CodeWeightEnumerator</C> returns a polynomial of the following form:
<Display>
f(x) = \sum_{i=0}^{n} A_i x^i,
</Display>
where <M>A_i</M> is the number of codewords in <A>C</A> with weight
<M>i</M>.
</Description>
</ManSection>
<Example>
gap> CodeWeightEnumerator( ElementsCode( [ [ 0,0,0 ], [ 0,0,1 ],
> [ 0,1,1 ], [ 1,1,1 ] ], GF(2) ) );
x^3 + x^2 + x + 1
gap> CodeWeightEnumerator( HammingCode( 3, GF(2) ) );
x^7 + 7*x^4 + 7*x^3 + 1
</Example>
<ManSection Label="CodeDistanceEnumerator">
<Func Name="CodeDistanceEnumerator" Arg=" C w "/>
<Description>
<C>CodeDistanceEnumerator</C> returns a polynomial of the following form:
<Display>
f(x) = \sum_{i=0}^{n} B_i x^i,
</Display>
where <M>B_i</M> is the number of codewords with distance
<M>i</M> to <A>w</A>.
<P/>
If <A>w</A> is a codeword, then <C>CodeDistanceEnumerator</C> returns the
same polynomial as <C>CodeWeightEnumerator</C>.
</Description>
</ManSection>
<Example>
gap> CodeDistanceEnumerator( HammingCode( 3, GF(2) ),[0,0,0,0,0,0,1] );
x^6 + 3*x^5 + 4*x^4 + 4*x^3 + 3*x^2 + x
gap> CodeDistanceEnumerator( HammingCode( 3, GF(2) ),[1,1,1,1,1,1,1] );
x^7 + 7*x^4 + 7*x^3 + 1 # `[1,1,1,1,1,1,1]' $\in$ `HammingCode( 3, GF(2 ) )'
</Example>
<Index>
MacWilliams transform
</Index>
<ManSection Label="CodeMacWilliamsTransform">
<Func Name="CodeMacWilliamsTransform" Arg=" C "/>
<Description>
<C>CodeMacWilliamsTransform</C> returns a polynomial of the following form:
<Display>
f(x) = \sum_{i=0}^{n} C_i x^i,
</Display>
where <M>C_i</M> is the number of codewords with weight <M>i</M>
in the <E>dual</E> code of <A>C</A>.
</Description>
</ManSection>
<Example>
gap> CodeMacWilliamsTransform( HammingCode( 3, GF(2) ) );
7*x^4 + 1
</Example>
<Index>
density of a code
</Index>
<ManSection Label="CodeDensity">
<Func Name="CodeDensity" Arg=" C "/>
<Description>
<C>CodeDensity</C> returns the <E>density</E> of <A>C</A>.
The density of a code is defined as
<Display>
\frac{M \cdot V_q(n,t)}{q^n},
</Display>
where <M>M</M> is the size of the code,
<M>V_q(n,t)</M> is the size of a sphere of
radius <M>t</M> in <M>GF(q^n)</M> (which may be
computed using <C>SphereContent</C>),
<M>t</M> is the covering radius of the code and
<M>n</M> is the length of the code.
</Description>
</ManSection>
<Example>
gap> CodeDensity( HammingCode( 3, GF(2) ) );
1
gap> CodeDensity( ReedMullerCode( 1, 4 ) );
14893/2048
</Example>
<Index>
perfect code
</Index>
<ManSection Label="SphereContent">
<Func Name="SphereContent" Arg=" n t F "/>
<Description>
<C>SphereContent</C> returns the content of a ball of radius
<A>t</A> around an arbitrary element of the vectorspace
<M>F^n</M>. This is the cardinality of the set of all elements
of <M>F^n</M> that are at distance (see
<Ref Func="DistanceCodeword" Style="Number"/>
less than or equal to <A>t</A> from an element of <M>F^n</M>.
<P/>
In the context of codes, the function is used to determine if a code is
perfect. A code is <E>perfect</E> if spheres of radius
<M>t</M> around all codewords
partition the whole ambient vector space, where
<E>t</E> is the number of errors the code can correct.
</Description>
</ManSection>
<Example>
gap> SphereContent( 15, 0, GF(2) );
1 # Only one word with distance 0, which is the word itself
gap> SphereContent( 11, 3, GF(4) );
4984
gap> C := HammingCode(5);
a linear [31,26,3]1 Hamming (5,2) code over GF(2)
#the minimum distance is 3, so the code can correct one error
gap> ( SphereContent( 31, 1, GF(2) ) * Size(C) ) = 2 ^ 31;
true
</Example>
<ManSection Label="Krawtchouk">
<Func Name="Krawtchouk" Arg=" k i n q "/>
<Description>
<C>Krawtchouk</C> returns the Krawtchouk number
<M>K_{k}(i)</M>. <A>q</A> must be a prime power, <A>n</A>
must be a positive integer, <A>k</A> must be a non-negative
integer less then or equal to <A>n</A> and <A>i</A> can be any
integer. (See
<Ref Func="KrawtchoukMat" Style="Number"/>).
This number is the value at <M>x=i</M> of the polynomial
<Display>
K_k^{n,q}(x)
=\sum_{j=0}^n (-1)^j(q-1)^{k-j}b(x,j)b(n-x,k-j),
</Display>
where $b(v,u)=u!/(v!(v-u)!)$ is the binomial coefficient if $u,v$ are
integers. For more properties of these polynomials,
see <Cite Key="MS83"/>.
</Description>
</ManSection>
<Example>
gap> Krawtchouk( 2, 0, 3, 2);
3
</Example>
<ManSection Label="PrimitiveUnityRoot">
<Func Name="PrimitiveUnityRoot" Arg=" F n "/>
<Description>
<C>PrimitiveUnityRoot</C> returns a primitive <A>n</A>-th
root of unity in an extension field of <A>F</A>.
This is a finite field element <M>a</M> with the
property <M>a^n=1</M> in <A>F</A>, and <A>n</A>
is the smallest integer such that this equality holds.
</Description>
</ManSection>
<Example>
gap> PrimitiveUnityRoot( GF(2), 15 );
Z(2^4)
gap> last^15;
Z(2)^0
gap> PrimitiveUnityRoot( GF(8), 21 );
Z(2^6)^3
</Example>
<ManSection Label="PrimitivePolynomialsNr">
<Func Name="PrimitivePolynomialsNr" Arg=" n F "/>
<Description>
<C>PrimitivePolynomialsNr</C> returns the number of irreducible
polynomials over <M>F=GF(q)</M> of degree <A>n</A>
with (maximum) period <M>q^n-1</M>.
(According to a theorem of S. Golomb, this is
<M>\phi(p^n-1)/n</M>.)
<P/>
See also the GAP function <C>RandomPrimitivePolynomial</C>,
<Ref Func="RandomPrimitivePolynomial" Style="Number"/>.
</Description>
</ManSection>
<Example>
gap> PrimitivePolynomialsNr(3,4);
12
</Example>
<ManSection Label="IrreduciblePolynomialsNr">
<Func Name="IrreduciblePolynomialsNr" Arg=" n F "/>
<Description>
<C>PrimitivePolynomialsNr</C> returns the number of irreducible
polynomials over <M>F=GF(q)</M> of degree <A>n</A>.
</Description>
</ManSection>
<Example>
gap> IrreduciblePolynomialsNr(3,4);
20
</Example>
<ManSection Label="MatrixRepresentationOfElement">
<Func Name="MatrixRepresentationOfElement" Arg=" a F "/>
<Description>
Here <A>F</A> is either a finite extension of
the ``base field'' <M>GF(p)</M> or of the rationals <M>{\mathbb{Q}}</M>,
and <M>a\in F</M>.
The command <C>MatrixRepresentationOfElement</C> returns a matrix
representation of <A>a</A> over the base field.
<P/>
If the element <A>a</A> is defined over the base field then it
returns the corresponding <M>1\times 1</M> matrix.
</Description>
</ManSection>
<Example>
gap> a:=Random(GF(4));
0*Z(2)
gap> M:=MatrixRepresentationOfElement(a,GF(4));; Display(M);
.
gap> a:=Random(GF(4));
Z(2^2)
gap> M:=MatrixRepresentationOfElement(a,GF(4));; Display(M);
. 1
1 1
gap>
</Example>
<!--
a:=Random(GF(4));
M:=MatrixRepresentationOfElement(a,GF(4));; Display(M);
a:=Random(GF(4));
M:=MatrixRepresentationOfElement(a,GF(4));; Display(M);
-->
<Index>
reciprocal polynomial
</Index>
<ManSection Label="ReciprocalPolynomial">
<Func Name="ReciprocalPolynomial" Arg=" P "/>
<Description>
<C>ReciprocalPolynomial</C> returns the <E>reciprocal</E> of
polynomial <A>P</A>. This is a polynomial with coefficients of
<A>P</A> in the reverse order. So if
<M>P=a_0 + a_1 X + ... + a_{n} X^{n}</M>,
the reciprocal polynomial is
<M>P'=a_{n} + a_{n-1} X + ... + a_0 X^{n}</M>.
<P/>
This command can also be called using the
syntax <C>ReciprocalPolynomial( P , n )</C>.
In this form, the number of coefficients of <A>P</A> is
assumed to be less than or equal to <M>n+1</M>
(with zero coefficients added in the highest
degrees, if necessary).
Therefore, the reciprocal polynomial also has degree
<M>n+1</M>.
</Description>
</ManSection>
<Example>
gap> P := UnivariatePolynomial( GF(3), Z(3)^0 * [1,0,1,2] );
Z(3)^0+x_1^2-x_1^3
gap> RecP := ReciprocalPolynomial( P );
-Z(3)^0+x_1+x_1^3
gap> ReciprocalPolynomial( RecP ) = P;
true
gap> P := UnivariatePolynomial( GF(3), Z(3)^0 * [1,0,1,2] );
Z(3)^0+x_1^2-x_1^3
gap> ReciprocalPolynomial( P, 6 );
-x_1^3+x_1^4+x_1^6
</Example>
<!--
P := UnivariatePolynomial( GF(3), Z(3)^0 * [1,0,1,2] );
RecP := ReciprocalPolynomial( P );
ReciprocalPolynomial( RecP ) = P;
P := UnivariatePolynomial( GF(3), Z(3)^0 * [1,0,1,2] );
ReciprocalPolynomial( P, 6 );
-->
<ManSection Label="CyclotomicCosets">
<Func Name="CyclotomicCosets" Arg=" q n "/>
<Description>
<C>CyclotomicCosets</C> returns the cyclotomic cosets of
<M>q \pmod n</M>. <A>q</A> and <A>n</A> must be relatively prime.
Each of the elements of the returned list is a list of integers
that belong to one cyclotomic coset.
A <M>q</M>-cyclotomic coset of <M>s \pmod n</M> is a set of the
form <M>\{s,sq,sq^2,...,sq^{r-1}\}</M>, where <M>r</M> is the
smallest positive integer such that
<M>sq^r-s</M> is <M>0 \pmod n</M>. In other words, each
coset contains all multiplications of the coset representative
by <M>q \pmod n</M>.
The coset representative is the smallest integer that isn't
in the previous cosets.
</Description>
</ManSection>
<Example>
gap> CyclotomicCosets( 2, 15 );
[ [ 0 ], [ 1, 2, 4, 8 ], [ 3, 6, 12, 9 ], [ 5, 10 ],
[ 7, 14, 13, 11 ] ]
gap> CyclotomicCosets( 7, 6 );
[ [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ] ]
</Example>
<ManSection Label="WeightHistogram">
<Func Name="WeightHistogram" Arg=" C [h] "/>
<Description>
The function <C>WeightHistogram</C> plots a histogram of weights in code
<A>C</A>. The maximum length of a column is <A>h</A>.
Default value for <A>h</A> is <M>1/3</M> of the size of the
screen. The number that appears at the top of
the histogram is the maximum value of the list of weights.
</Description>
</ManSection>
<Example>
gap> H := HammingCode(2, GF(5));
a linear [6,4,3]1 Hamming (2,5) code over GF(5)
gap> WeightDistribution(H);
[ 1, 0, 0, 80, 120, 264, 160 ]
gap> WeightHistogram(H);
264----------------
*
*
*
*
* *
* * *
* * * *
* * * *
+--------+--+--+--+--
0 1 2 3 4 5 6
</Example>
<!--
H := HammingCode(2, GF(5));
WeightDistribution(H);
WeightHistogram(H);
-->
<ManSection>
<Func Name="MultiplicityInList" Arg ="L, a"/>
<Description>
This is a very simple list command which
returns how many times a occurs in L.
It returns 0 if a is not in L.
(The GAP command <C>Collected</C> does not quite
handle this "extreme" case.)
</Description>
</ManSection>
<Example>
gap> L:=[1,2,3,4,3,2,1,5,4,3,2,1];;
gap> MultiplicityInList(L,1);
3
gap> MultiplicityInList(L,6);
0
</Example>
<!--
L:=[1,2,3,4,3,2,1,5,4,3,2,1];;
MultiplicityInList(L,1);
MultiplicityInList(L,6);
-->
<ManSection>
<Func Name="MostCommonInList" Arg =" L "/>
<Description>
Input: a list L
<P/>
Output: an a in L which occurs at least as much as any other in L
</Description>
</ManSection>
<Example>
gap> L:=[1,2,3,4,3,2,1,5,4,3,2,1];;
gap> MostCommonInList(L);
1
</Example>
<!--
L:=[1,2,3,4,3,2,1,5,4,3,2,1];;
MostCommonInList(L);
-->
<ManSection>
<Func Name="RotateList" Arg =" L "/>
<Description>
Input: a list L
<P/>
Output: a list L' which is the
cyclic rotation of L (to the right)
</Description>
</ManSection>
<Example>
gap> L:=[1,2,3,4];;
gap> RotateList(L);
[2,3,4,1]
</Example>
<!--
L:=[1,2,3,4];;
RotateList(L);
-->
<ManSection>
<Func Name="CirculantMatrix" Arg =" k L "/>
<Description>
Input: integer k, a list L of length n
<P/>
Output: kxn matrix whose rows are cyclic rotations of the list L
</Description>
</ManSection>
<Example>
gap> k:=3; L:=[1,2,3,4];;
gap> M:=CirculantMatrix(k,L);;
gap> Display(M);
</Example>
<!--
k:=3; L:=[1,2,3,4];;
M:=CirculantMatrix(k,L);;
Display(M);
-->
</Section>
<Section>
<Heading>
Miscellaneous polynomial functions
</Heading>
<Label Name="Miscellaneous polynomial functions"/>
In this section we describe several multivariate polynomial
GAP functions <Package>GUAVA</Package> uses for
constructing codes or performing calculations with codes.
<ManSection>
<Func Name="MatrixTransformationOnMultivariatePolynomial " Arg ="A,f,R "/>
<Description>
<A>A</A> is an <M>n\times n</M> matrix with entries in a field <M>F</M>,
<A>R</A> is a polynomial ring of <M>n</M> variables,
say <M>F[x_1,...,x_n]</M>, and <A>f</A> is a polynomial in <A>R</A>.
Returns the composition <M>f\circ A</M>.
</Description>
</ManSection>
<ManSection>
<Func Name="DegreeMultivariatePolynomial" Arg ="f, R"/>
<Description>
This command takes two arguments,
<A>f</A>, a multivariate polynomial,
and <A>R</A> a polynomial ring over
a field <M>F</M> containing <A>f</A>, say
<M>R=F[x_1,x_2,...,x_n]</M>.
The output is simply the maximum degrees of all the
monomials occurring in <A>f</A>.
<P/>
This command can be used to compute the degree of an
affine plane curve.
</Description>
</ManSection>
<Example>
gap> F:=GF(11);;
gap> R2:=PolynomialRing(F,2);
PolynomialRing(..., [ x_1, x_2 ])
gap> vars:=IndeterminatesOfPolynomialRing(R2);;
gap> x:=vars[1];; y:=vars[2];;
gap> poly:=y^2-x*(x^2-1);;
gap> DegreeMultivariatePolynomial(poly,R2);
3
</Example>
<!--
F:=GF(11);;
R2:=PolynomialRing(F,2);
vars:=IndeterminatesOfPolynomialRing(R2);;
x:=vars[1];; y:=vars[2];;
poly:=y^2-x*(x^2-1);;
DegreeMultivariatePolynomial(poly,R2);
-->
<ManSection>
<Func Name="DegreesMultivariatePolynomial" Arg ="f, R"/>
<Description>
Returns a list of information about the
multivariate polynomial <A>f</A>. Nice for other
programs but mostly unreadable by GAP users.
</Description>
</ManSection>
<Example>
gap> F:=GF(11);;
gap> R2:=PolynomialRing(F,2);
PolynomialRing(..., [ x_1, x_2 ])
gap> vars:=IndeterminatesOfPolynomialRing(R2);;
gap> x:=vars[1];; y:=vars[2];;
gap> poly:=y^2-x*(x^2-1);;
gap> DegreesMultivariatePolynomial(poly,R2);
[ [ [ x_1, x_1, 1 ], [ x_1, x_2, 0 ] ], [ [ x_2^2, x_1, 0 ], [ x_2^2, x_2, 2 ] ],
[ [ x_1^3, x_1, 3 ], [ x_1^3, x_2, 0 ] ] ]
gap>
</Example>
<!--
F:=GF(11);;
R2:=PolynomialRing(F,2);
vars:=IndeterminatesOfPolynomialRing(R2);;
x:=vars[1];; y:=vars[2];;
poly:=y^2-x*(x^2-1);;
DegreesMultivariatePolynomial(poly,R2);
-->
<ManSection>
<Func Name="CoefficientMultivariatePolynomial" Arg ="f, var, power, R"/>
<Description>
The command <C>CoefficientMultivariatePolynomial</C>
takes four arguments: a multivariant polynomial
<A>f</A>, a variable name <A>var</A>, an integer
<A>power</A>, and a polynomial ring <A>R</A> containing <A>f</A>.
For example, if <A>f</A> is a multivariate polynomial in
<M>R</M> = <M>F</M>[<M>x_1,x_2,...,x_n</M>] then <A>var</A> must be
one of the <M>x_i</M>.
The output is the coefficient of <M>x_i^{power}</M>
in <A>f</A>.
<P/>
(Not sure if <M>F</M> needs to be a field in fact ...)
<P/>
Related to the GAP command <C>PolynomialCoefficientsPolynomial</C>.
</Description>
</ManSection>
<Example>
gap> F:=GF(11);;
gap> R2:=PolynomialRing(F,2);
PolynomialRing(..., [ x_1, x_2 ])
gap> vars:=IndeterminatesOfPolynomialRing(R2);;
gap> x:=vars[1];; y:=vars[2];;
gap> poly:=y^2-x*(x^2-1);;
gap> PolynomialCoefficientsOfPolynomial(poly,x);
[ x_2^2, Z(11)^0, 0*Z(11), -Z(11)^0 ]
gap> PolynomialCoefficientsOfPolynomial(poly,y);
[ -x_1^3+x_1, 0*Z(11), Z(11)^0 ]
gap> CoefficientMultivariatePolynomial(poly,y,0,R2);
-x_1^3+x_1
gap> CoefficientMultivariatePolynomial(poly,y,1,R2);
0*Z(11)
gap> CoefficientMultivariatePolynomial(poly,y,2,R2);
Z(11)^0
gap> CoefficientMultivariatePolynomial(poly,x,0,R2);
x_2^2
gap> CoefficientMultivariatePolynomial(poly,x,1,R2);
Z(11)^0
gap> CoefficientMultivariatePolynomial(poly,x,2,R2);
0*Z(11)
gap> CoefficientMultivariatePolynomial(poly,x,3,R2);
-Z(11)^0
</Example>
<!--
F:=GF(11);;
R2:=PolynomialRing(F,2);
vars:=IndeterminatesOfPolynomialRing(R2);;
x:=vars[1];; y:=vars[2];;
poly:=y^2-x*(x^2-1);;
PolynomialCoefficientsOfPolynomial(poly,x);
PolynomialCoefficientsOfPolynomial(poly,y);
CoefficientMultivariatePolynomial(poly,y,0,R2);
CoefficientMultivariatePolynomial(poly,y,1,R2);
CoefficientMultivariatePolynomial(poly,y,2,R2);
CoefficientMultivariatePolynomial(poly,x,0,R2);
CoefficientMultivariatePolynomial(poly,x,1,R2);
CoefficientMultivariatePolynomial(poly,x,2,R2);
CoefficientMultivariatePolynomial(poly,x,3,R2);
-->
<ManSection>
<Func Name="SolveLinearSystem" Arg ="L, vars"/>
<Description>
Input:
<A>L</A> is a list of linear forms in the variables <A>vars</A>.
<P/>
Output:
the solution of the system, if its unique.
<P/>
The procedure is straightforward:
Find the associated matrix <M>A</M>,
find the "constant vector" <M>b</M>, and
solve <M>A*v=b</M>. No error checking is performed.
<P/>
Related to the GAP command <C>SolutionMat( A, b )</C>.
</Description>
</ManSection>
<Example>
gap> F:=GF(11);;
gap> R2:=PolynomialRing(F,2);
PolynomialRing(..., [ x_1, x_2 ])
gap> vars:=IndeterminatesOfPolynomialRing(R2);;
gap> x:=vars[1];; y:=vars[2];;
gap> f:=3*y-3*x+1;; g:=-5*y+2*x-7;;
gap> soln:=SolveLinearSystem([f,g],[x,y]);
[ Z(11)^3, Z(11)^2 ]
gap> Value(f,[x,y],soln); # checking okay
0*Z(11)
gap> Value(g,[x,y],col); # checking okay
0*Z(11)
</Example>
<!--
F:=GF(11);;
R2:=PolynomialRing(F,2);
vars:=IndeterminatesOfPolynomialRing(R2);;
x:=vars[1];; y:=vars[2];;
f:=3*y-3*x+1;; g:=-5*y+2*x-7;;
soln:=SolveLinearSystem([f,g],[x,y]);
Value(f,[x,y],soln); # checking okay
Value(g,[x,y],col); # checking okay
-->
<ManSection Label="GuavaVersion">
<Func Name="GuavaVersion" Arg=" "/>
<Description>
Returns the current version of Guava. Same as
<C>guava\_version()</C>.
</Description>
</ManSection>
<Example>
gap> GuavaVersion();
"2.7"
</Example>
<!--
-->
<ManSection Label="ZechLog">
<Func Name="ZechLog" Arg=" x b F "/>
<Description>
Returns the Zech log of x to base b, ie the i such that
$x+1=b^i$, so $y+z=y(1+z/y)=b^k$, where
k=Log(y,b)+ZechLog(z/y,b) and b must be a primitive element of F.
</Description>
</ManSection>
<Example>
gap> F:=GF(11);; l := One(F);;
gap> ZechLog(2*l,8*l,F);
-24
gap> 8*l+l;(2*l)^(-24);
Z(11)^6
Z(11)^6
</Example>
<!--
F:=GF(11);; l := One(F);;
ZechLog(2*l,8*l,F);
8*l+l;(2*l)^(-24);
-->
<ManSection Label="CoefficientToPolynomial">
<Func Name="CoefficientToPolynomial" Arg=" coeffs R "/>
<Description>
The function <C>CoefficientToPolynomial</C> returns the
degree <M>d-1</M> polynomial <M>c_0+c_1x+...+c_{d-1}x^{d-1}</M>, where
<A>coeffs</A> is a list of elements of a field,
<M>coeffs=\{ c_0,...,c_{d-1}\}</M>, and <A>R</A> is a
univariate polynomial ring.
</Description>
</ManSection>
<Example>
gap> F:=GF(11);
GF(11)
gap> R1:=PolynomialRing(F,["a"]);;
gap> var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
gap> coeffs:=Z(11)^0*[1,2,3,4];
[ Z(11)^0, Z(11), Z(11)^8, Z(11)^2 ]
gap> CoefficientToPolynomial(coeffs,R1);
Z(11)^2*a^3+Z(11)^8*a^2+Z(11)*a+Z(11)^0
</Example>
<!--
F:=GF(11);
R1:=PolynomialRing(F,["a"]);;
var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
coeffs:=Z(11)^0*[1,2,3,4];
CoefficientToPolynomial(coeffs,R1);
-->
<ManSection Label="DegreesMonomialTerm">
<Func Name="DegreesMonomialTerm" Arg=" m R "/>
<Description>
The function <C>DegreesMonomialTerm</C> returns the
list of degrees to which each variable in the
multivariate polynomial ring
<A>R</A> occurs in the monomial <A>m</A>, where
<A>coeffs</A> is a list of elements of a field.
</Description>
</ManSection>
<Example>
gap> F:=GF(11);
GF(11)
gap> R1:=PolynomialRing(F,["a"]);;
gap> var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
gap> b:=X(F,"b",var1);
b
gap> var2:=Concatenation(var1,[b]);
[ a, b ]
gap> R2:=PolynomialRing(F,var2);
PolynomialRing(..., [ a, b ])
gap> c:=X(F,"c",var2);
c
gap> var3:=Concatenation(var2,[c]);
[ a, b, c ]
gap> R3:=PolynomialRing(F,var3);
PolynomialRing(..., [ a, b, c ])
gap> m:=b^3*c^7;
b^3*c^7
gap> DegreesMonomialTerm(m,R3);
[ 0, 3, 7 ]
</Example>
<!--
F:=GF(11);
R1:=PolynomialRing(F,["a"]);;
var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;
b:=X(F,"b",var1);
var2:=Concatenation(var1,[b]);
R2:=PolynomialRing(F,var2);
c:=X(F,"c",var2);
var3:=Concatenation(var2,[c]);
R3:=PolynomialRing(F,var3);
m:=b^3*c^7;
DegreesMonomialTerm(m,R3);
-->
<ManSection Label="DivisorsMultivariatePolynomial">
<Func Name="DivisorsMultivariatePolynomial" Arg=" f R "/>
<Description>
The function <C>DivisorsMultivariatePolynomial</C> returns the
list of polynomial divisors of <A>f</A> in the
multivariate polynomial ring <A>R</A> with coefficients in a field.
This program uses a simple but slow algorithm
(see Joachim von zur Gathen, Jürgen Gerhard,
<Cite Key="GG03"/>, exercise 16.10) which first converts the
multivariate polynomial <A>f</A> to an associated
univariate polynomial <M>f^*</M>, then
<C>Factors</C> <M>f^*</M>, and finally converts these
univariate factors back into the multivariate polynomial
factors of <A>f</A>. Since <C>Factors</C> is non-deterministic,
<C>DivisorsMultivariatePolynomial</C> is non-deterministic
as well.
</Description>
</ManSection>
<Example>
gap> R2:=PolynomialRing(GF(3),["x1","x2"]);
PolynomialRing(..., [ x1, x2 ])
gap> vars:=IndeterminatesOfPolynomialRing(R2);
[ x1, x2 ]
gap> x2:=vars[2];
x2
gap> x1:=vars[1];
x1
gap> f:=x1^3+x2^3;;
gap> DivisorsMultivariatePolynomial(f,R2);
[ x1+x2, x1+x2, x1+x2 ]
</Example>
<!--
R2:=PolynomialRing(GF(3),["x1","x2"]);
vars:=IndeterminatesOfPolynomialRing(R2);
x2:=vars[2];
x1:=vars[1];
f:=x1^3+x2^3;;
DivisorsMultivariatePolynomial(f,R2);
-->
</Section>
<Section>
<Heading>
GNU Free Documentation License
</Heading>
GNU Free Documentation License
Version 1.2, November 2002
<P/>
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, 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.
<P/>
0. PREAMBLE
<P/>
The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
<P/>
This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
<P/>
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
<P/>
1. APPLICABILITY AND DEFINITIONS
<P/>
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The "Document", below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as "you". You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
<P/>
A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
<P/>
A "Secondary Section" is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall subject
(or to related matters) and contains nothing that could fall directly
within that overall subject. (Thus, if the Document is in part a
textbook of mathematics, a Secondary Section may not explain any
mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
<P/>
The "Invariant Sections" are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
<P/>
The "Cover Texts" are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
<P/>
A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not "Transparent" is called "Opaque".
<P/>
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML, PostScript or PDF designed for human modification. Examples of
transparent image formats include PNG, XCF and JPG. Opaque formats
include proprietary formats that can be read and edited only by
proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.
<P/>
The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, "Title Page" means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
<P/>
A section "Entitled XYZ" means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as "Acknowledgements",
"Dedications", "Endorsements", or "History".) To "Preserve the Title"
of such a section when you modify the Document means that it remains a
section "Entitled XYZ" according to this definition.
<P/>
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
<P/>
2. VERBATIM COPYING
<P/>
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
<P/>
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
<P/>
3. COPYING IN QUANTITY
<P/>
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
<P/>
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
<P/>
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
<P/>
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
<P/>
4. MODIFICATIONS
<P/>
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
<P/>
A. Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
<P/>
B. List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
<P/>
C. State on the Title page the name of the publisher of the
Modified Version, as the publisher.
<P/>
D. Preserve all the copyright notices of the Document.
<P/>
E. Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
<P/>
F. Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
<P/>
G. Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
<P/>
H. Include an unaltered copy of this License.
<P/>
I. Preserve the section Entitled "History", Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled "History" in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
<P/>
J. Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the "History" section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
<P/>
K. For any section Entitled "Acknowledgements" or "Dedications",
Preserve the Title of the section, and preserve in the section all
the substance and tone of each of the contributor acknowledgements
and/or dedications given therein.
<P/>
L. Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
<P/>
M. Delete any section Entitled "Endorsements". Such a section
may not be included in the Modified Version.
<P/>
N. Do not retitle any existing section to be Entitled "Endorsements"
or to conflict in title with any Invariant Section.
<P/>
O. Preserve any Warranty Disclaimers.
<P/>
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
<P/>
You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
<P/>
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
<P/>
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
<P/>
5. COMBINING DOCUMENTS
<P/>
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
<P/>
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
<P/>
In the combination, you must combine any sections Entitled "History"
in the various original documents, forming one section Entitled
"History"; likewise combine any sections Entitled "Acknowledgements",
and any sections Entitled "Dedications". You must delete all sections
Entitled "Endorsements".
<P/>
6. COLLECTIONS OF DOCUMENTS
<P/>
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
<P/>
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
<P/>
7. AGGREGATION WITH INDEPENDENT WORKS
<P/>
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an "aggregate" if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
<P/>
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
<P/>
8. TRANSLATION
<P/>
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
<P/>
If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
<P/>
9. TERMINATION
<P/>
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document 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.
<P/>
10. FUTURE REVISIONS OF THIS LICENSE
<P/>
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation 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. See
http://www.gnu.org/copyleft/.
<P/>
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
</Section>
</Chapter>
</Body>
<Bibliography Databases="guava"/>
<TheIndex/>
</Book>
|