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
|
/***** Autogenerated from runtime.in; changes will be overwritten *****/
#line 1 "runtime.in"
/*****
* runtime.in
* Tom Prince 2005/4/15
*
* Generate the runtime functions used by the vm::stack machine.
*
*****/
/* Autogenerated routines are specified like this (separated by a formfeed):
type asyname:cname(cparams)
{
C code
}
*/
// Use Void f() instead of void f() to force an explicit Stack argument.
#line 63 "runtime.in"
#include <cfloat>
#include <iostream>
#include <fstream>
#include <time.h>
#include <sys/times.h>
#include <locale.h>
#include "angle.h"
#include "pair.h"
#include "triple.h"
#include "transform.h"
#include "path.h"
#include "path3.h"
#include "pen.h"
#include "guide.h"
#include "picture.h"
#include "drawpath.h"
#include "drawpath3.h"
#include "drawsurface.h"
#include "drawfill.h"
#include "drawclipbegin.h"
#include "drawclipend.h"
#include "drawlabel.h"
#include "drawverbatim.h"
#include "drawgsave.h"
#include "drawgrestore.h"
#include "drawlayer.h"
#include "drawimage.h"
#include "drawgroup.h"
#include "fileio.h"
#include "genv.h"
#include "builtin.h"
#include "texfile.h"
#include "pipestream.h"
#include "parser.h"
#include "stack.h"
#include "util.h"
#include "locate.h"
#include "mathop.h"
#include "callable.h"
#include "stm.h"
#include "lexical.h"
#include "process.h"
#include "arrayop.h"
#include "predicates.h"
#include "Delaunay.h"
#ifdef HAVE_LIBFFTW3
#include "fftw++.h"
#endif
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
#include <readline/readline.h>
#include <readline/history.h>
#endif
#if defined(USEGC) && defined(GC_DEBUG) && defined(GC_BACKTRACE)
extern "C" {
void *GC_generate_random_valid_address(void);
void GC_debug_print_heap_obj_proc(void *);
}
#endif
using namespace vm;
using namespace camp;
using namespace settings;
namespace run {
using camp::pair;
using vm::array;
using vm::frame;
using vm::stack;
using camp::transform;
using absyntax::runnable;
typedef double real;
#define CURRENTPEN processData().currentpen
typedef array boolarray;
typedef array Intarray;
typedef array Intarray2;
typedef array realarray;
typedef array realarray2;
typedef array pairarray;
typedef array pairarray2;
typedef array triplearray;
typedef array triplearray2;
typedef array patharray;
typedef array patharray2;
typedef array guidearray;
typedef array transformarray;
typedef array penarray;
typedef array penarray2;
typedef array stringarray;
typedef array stringarray2;
typedef callable callableBp;
typedef callable callableReal;
typedef callable callableTransform;
}
using vm::array;
using types::function;
#define PRIMITIVE(name,Name,asyName) using types::prim##Name;
#include <primitives.h>
#undef PRIMITIVE
using types::boolArray;
using types::IntArray;
using types::IntArray2;
using types::realArray;
using types::realArray2;
using types::pairArray;
using types::pairArray2;
using types::tripleArray;
using types::tripleArray2;
using types::pathArray;
using types::pathArray2;
using types::guideArray;
using types::transformArray;
using types::penArray;
using types::penArray2;
using types::stringArray;
using types::stringArray2;
using types::formal;
function *voidFunction()
{
return new function(primVoid());
}
function *breakpointFunction()
{
return new function(primString(),primString(),primInt(),primInt(),
primCode());
}
function *realRealFunction()
{
return new function(primReal(),primReal());
}
function *transformFunction()
{
return new function(primTransform());
}
function *realTripleFunction()
{
return new function(primReal(),primTriple());
}
const size_t camp::ColorComponents[]={0,0,1,3,4,0};
namespace vm {
}
namespace run {
const char *invalidargument="invalid argument";
const char *arrayempty="cannot take min or max of empty array";
// Return the factorial of a non-negative integer using a lookup table.
Int factorial(Int n)
{
static Int *table;
static Int size=0;
if(size == 0) {
Int f=1;
size=2;
while(f <= Int_MAX/size)
f *= (size++);
table=new Int[size];
table[0]=f=1;
for(Int i=1; i < size; ++i) {
f *= i;
table[i]=f;
}
}
if(n >= size) integeroverflow(0);
return table[n];
}
static inline Int Round(double x)
{
return Int(x+((x >= 0) ? 0.5 : -0.5));
}
inline Int sgn(double x)
{
return (x > 0.0 ? 1 : (x < 0.0 ? -1 : 0));
}
void outOfBounds(const char *op, size_t len, Int n)
{
ostringstream buf;
buf << op << " array of length " << len << " with out-of-bounds index " << n;
error(buf);
}
inline item& arrayRead(array *a, Int n)
{
size_t len=checkArray(a);
bool cyclic=a->cyclic();
if(cyclic && len > 0) n=imod(n,len);
else if(n < 0 || n >= (Int) len) outOfBounds("reading",len,n);
return (*a)[(unsigned) n];
}
// Helper function to create deep arrays.
static array* deepArray(Int depth, Int *dims)
{
assert(depth > 0);
if (depth == 1) {
return new array(dims[0]);
} else {
Int length = dims[0];
depth--; dims++;
array *a = new array(length);
for (Int index = 0; index < length; index++) {
(*a)[index] = deepArray(depth, dims);
}
return a;
}
}
array *nop(array *a)
{
return a;
}
array *Identity(Int n)
{
size_t N=(size_t) n;
array *c=new array(N);
for(size_t i=0; i < N; ++i) {
array *ci=new array(N);
(*c)[i]=ci;
for(size_t j=0; j < N; ++j)
(*ci)[j]=0.0;
(*ci)[i]=1.0;
}
return c;
}
array *copyArray(array *a)
{
size_t size=checkArray(a);
array *c=new array(size);
for(size_t i=0; i < size; i++)
(*c)[i]=(*a)[i];
return c;
}
inline size_t checkdimension(array *a, size_t dim)
{
size_t size=checkArray(a);
if(dim && size != dim) {
ostringstream buf;
buf << "array of length " << dim << " expected" << endl;
error(buf);
}
return size;
}
double *copyArrayC(array *a, size_t dim=0)
{
size_t size=checkdimension(a,dim);
double *c=new double[size];
for(size_t i=0; i < size; i++)
c[i]=read<double>(a,i);
return c;
}
triple *copyTripleArrayC(array *a, size_t dim=0)
{
size_t size=checkdimension(a,dim);
triple *c=new triple[size];
for(size_t i=0; i < size; i++)
c[i]=read<triple>(a,i);
return c;
}
array *copyArray2(array *a)
{
size_t size=checkArray(a);
array *c=new array(size);
for(size_t i=0; i < size; i++) {
array *ai=read<array*>(a,i);
size_t aisize=checkArray(ai);
array *ci=new array(aisize);
(*c)[i]=ci;
for(size_t j=0; j < aisize; j++)
(*ci)[j]=(*ai)[j];
}
return c;
}
array *copyArray3(array *a)
{
size_t size=checkArray(a);
array *c=new array(size);
for(size_t i=0; i < size; i++) {
array *ai=read<array*>(a,i);
size_t aisize=checkArray(ai);
array *ci=new array(aisize);
(*c)[i]=ci;
for(size_t j=0; j < aisize; j++) {
array *aij=read<array*>(ai,j);
size_t aijsize=checkArray(aij);
array *cij=new array(aijsize);
(*ci)[j]=cij;
for(size_t k=0; k < aijsize; k++)
(*cij)[k]=(*aij)[k];
}
}
return c;
}
double *copyArray2C(array *a, bool square=true, size_t dim2=0)
{
size_t n=checkArray(a);
size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0));
if(n > 0 && dim2 && m != dim2) {
ostringstream buf;
buf << "second matrix dimension must be " << dim2 << endl;
error(buf);
}
double *c=new double[n*m];
for(size_t i=0; i < n; i++) {
array *ai=read<array*>(a,i);
size_t aisize=checkArray(ai);
if(aisize == m) {
double *ci=c+i*m;
for(size_t j=0; j < m; j++)
ci[j]=read<double>(ai,j);
} else
error(square ? "matrix must be square" : "matrix must be rectangular");
}
return c;
}
triple *copyTripleArray2C(array *a, bool square=true, size_t dim2=0)
{
size_t n=checkArray(a);
size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0));
if(n > 0 && dim2 && m != dim2) {
ostringstream buf;
buf << "second matrix dimension must be " << dim2 << endl;
error(buf);
}
triple *c=new triple[n*m];
for(size_t i=0; i < n; i++) {
array *ai=read<array*>(a,i);
size_t aisize=checkArray(ai);
if(aisize == m) {
triple *ci=c+i*m;
for(size_t j=0; j < m; j++)
ci[j]=read<triple>(ai,j);
} else
error(square ? "matrix must be square" : "matrix must be rectangular");
}
return c;
}
double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0)
{
size_t n=checkArray(a);
size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0));
if(n > 0 && dim2 && m != dim2) {
ostringstream buf;
buf << "second matrix dimension must be " << dim2 << endl;
error(buf);
}
size_t nm=n*m;
double *cx=new double[3*nm];
double *cy=cx+nm;
double *cz=cx+2*nm;
for(size_t i=0; i < n; i++) {
array *ai=read<array*>(a,i);
size_t aisize=checkArray(ai);
if(aisize == m) {
double *xi=cx+i*m;
double *yi=cy+i*m;
double *zi=cz+i*m;
for(size_t j=0; j < m; j++) {
triple v=read<triple>(ai,j);
xi[j]=v.getx();
yi[j]=v.gety();
zi[j]=v.getz();
}
} else
error(square ? "matrix must be square" : "matrix must be rectangular");
}
return cx;
}
double norm(double *a, size_t n)
{
if(n == 0) return 0.0;
double M=fabs(a[0]);
for(size_t i=1; i < n; ++i)
M=::max(M,fabs(a[i]));
return M;
}
double norm(triple *a, size_t n)
{
if(n == 0) return 0.0;
double M=a[0].abs2();
for(size_t i=1; i < n; ++i)
M=::max(M,a[i].abs2());
return sqrt(M);
}
static const char *incommensurate="Incommensurate matrices";
static const char *singular="Singular matrix";
static size_t *pivot,*Row,*Col;
triple operator *(const array& t, const triple& v)
{
size_t n=checkArray(&t);
if(n != 4) error(incommensurate);
array *t0=read<array*>(t,0);
array *t1=read<array*>(t,1);
array *t2=read<array*>(t,2);
array *t3=read<array*>(t,3);
if(checkArray(t0) != 4 || checkArray(t1) != 4 ||
checkArray(t2) != 4 || checkArray(t3) != 4)
error(incommensurate);
double x=v.getx();
double y=v.gety();
double z=v.getz();
double f=read<real>(t3,0)*x+read<real>(t3,1)*y+read<real>(t3,2)*z+
read<real>(t3,3);
if(f == 0.0) run::dividebyzero();
f=1.0/f;
return triple((read<real>(t0,0)*x+read<real>(t0,1)*y+read<real>(t0,2)*z+
read<real>(t0,3))*f,
(read<real>(t1,0)*x+read<real>(t1,1)*y+read<real>(t1,2)*z+
read<real>(t1,3))*f,
(read<real>(t2,0)*x+read<real>(t2,1)*y+read<real>(t2,2)*z+
read<real>(t2,3))*f);
}
triple multshiftless(const array& t, const triple& v)
{
size_t n=checkArray(&t);
if(n != 4) error(incommensurate);
array *t0=read<array*>(t,0);
array *t1=read<array*>(t,1);
array *t2=read<array*>(t,2);
array *t3=read<array*>(t,3);
if(checkArray(t0) != 4 || checkArray(t1) != 4 ||
checkArray(t2) != 4 || checkArray(t3) != 4)
error(incommensurate);
double x=v.getx();
double y=v.gety();
double z=v.getz();
double f=read<real>(t3,0)*x+read<real>(t3,1)*y+read<real>(t3,2)*z+
read<real>(t3,3);
if(f == 0.0) run::dividebyzero();
f=1.0/f;
return triple((read<real>(t0,0)*x+read<real>(t0,1)*y+read<real>(t0,2)*z)*f,
(read<real>(t1,0)*x+read<real>(t1,1)*y+read<real>(t1,2)*z)*f,
(read<real>(t2,0)*x+read<real>(t2,1)*y+read<real>(t2,2)*z)*f);
}
static inline void inverseAllocate(size_t n)
{
pivot=new size_t[n];
Row=new size_t[n];
Col=new size_t[n];
}
static inline void inverseDeallocate()
{
delete[] pivot;
delete[] Row;
delete[] Col;
}
void writestring(stack *s)
{
callable *suffix=pop<callable *>(s,NULL);
string S=pop<string>(s);
vm::item it=pop(s);
bool defaultfile=isdefault(it);
camp::file *f=defaultfile ? &camp::Stdout : vm::get<camp::file*>(it);
if(!f->isOpen()) return;
if(S != "") f->write(S);
if(f->text()) {
if(suffix) {
s->push(f);
suffix->call(s);
} else if(defaultfile) f->writeline();
}
}
void checkSquare(array *a)
{
size_t n=checkArray(a);
for(size_t i=0; i < n; i++)
if(checkArray(read<array*>(a,i)) != n)
error("matrix a must be square");
}
// Crout's algorithm for computing the LU decomposition of a square matrix.
// cf. routine ludcmp (Press et al., Numerical Recipes, 1991).
Int LUdecompose(double *a, size_t n, size_t* index, bool warn=true)
{
double *vv=new double[n];
Int swap=1;
for(size_t i=0; i < n; ++i) {
double big=0.0;
double *ai=a+i*n;
for(size_t j=0; j < n; ++j) {
double temp=fabs(ai[j]);
if(temp > big) big=temp;
}
if(big == 0.0) {
delete[] vv;
if(warn) error(singular);
else return 0;
}
vv[i]=1.0/big;
}
for(size_t j=0; j < n; ++j) {
for(size_t i=0; i < j; ++i) {
double *ai=a+i*n;
double sum=ai[j];
for(size_t k=0; k < i; ++k) {
sum -= ai[k]*a[k*n+j];
}
ai[j]=sum;
}
double big=0.0;
size_t imax=j;
for(size_t i=j; i < n; ++i) {
double *ai=a+i*n;
double sum=ai[j];
for(size_t k=0; k < j; ++k)
sum -= ai[k]*a[k*n+j];
ai[j]=sum;
double temp=vv[i]*fabs(sum);
if(temp >= big) {
big=temp;
imax=i;
}
}
double *aj=a+j*n;
double *aimax=a+imax*n;
if(j != imax) {
for(size_t k=0; k < n; ++k) {
double temp=aimax[k];
aimax[k]=aj[k];
aj[k]=temp;
}
swap *= -1;
vv[imax]=vv[j];
}
if(index)
index[j]=imax;
if(j != n) {
double denom=aj[j];
if(denom == 0.0) {
delete[] vv;
if(warn) error(singular);
else return 0;
}
for(size_t i=j+1; i < n; ++i)
a[i*n+j] /= denom;
}
}
delete[] vv;
return swap;
}
void dividebyzero(size_t i)
{
ostringstream buf;
if(i > 0) buf << "array element " << i << ": ";
buf << "Divide by zero";
error(buf);
}
void integeroverflow(size_t i)
{
ostringstream buf;
if(i > 0) buf << "array element " << i << ": ";
buf << "Integer overflow";
error(buf);
}
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
struct historyState {
bool store;
HISTORY_STATE state;
};
typedef mem::map<CONST string, historyState> historyMap_t;
historyMap_t historyMap;
static HISTORY_STATE history_save;
// Store a deep copy of the current readline history in dest.
void store_history(HISTORY_STATE *dest)
{
HISTORY_STATE *src=history_get_history_state();
if(src) {
*dest=*src;
for(Int i=0; i < src->length; ++i)
dest->entries[i]=src->entries[i];
free(src);
}
}
stringarray* get_history(Int n)
{
int N=intcast(n);
if(N <= 0) N=history_length;
else N=Min(N,history_length);
array *a=new array((size_t) N);
int offset=history_length-N+1;
for(int i=0; i < N; ++i) {
HIST_ENTRY *last=history_get(offset+i);
string s=last ? last->line : "";
(*a)[i]=s;
}
return a;
}
string historyfilename(const string &name)
{
return historyname+"_"+name;
}
#endif
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
int readline_startup_hook()
{
#ifdef __CYGWIN__
rl_set_key("\\M-[3~",rl_delete,rl_get_keymap());
rl_set_key("\\M-[2~",rl_overwrite_mode,rl_get_keymap());
#endif
return 0;
}
void init_readline(bool tabcompletion=true)
{
static bool first=true;
if(first) {
first=false;
#ifdef __CYGWIN__
rl_startup_hook=readline_startup_hook;
#endif
}
rl_bind_key('\t',tabcompletion ? rl_complete : rl_insert);
}
#endif
void cleanup()
{
processDataStruct &pd=processData();
pd.atExitFunction=NULL;
pd.atUpdateFunction=NULL;
pd.atBreakpointFunction=NULL;
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
store_history(&history_save);
int nlines=intcast(getSetting<Int>("historylines"));
for(historyMap_t::iterator h=historyMap.begin(); h != historyMap.end();
++h) {
history_set_history_state(&h->second.state);
stifle_history(nlines);
if(h->second.store) write_history(historyfilename(h->first).c_str());
}
history_set_history_state(&history_save);
#endif
}
void purge(Int divisor=0)
{
#ifdef USEGC
if(divisor > 0) GC_set_free_space_divisor((GC_word) divisor);
GC_gcollect();
#endif
}
void updateFunction(stack *Stack)
{
callable *atUpdateFunction=processData().atUpdateFunction;
if(atUpdateFunction && !nullfunc::instance()->compare(atUpdateFunction))
atUpdateFunction->call(Stack);
}
void exitFunction(stack *Stack)
{
callable *atExitFunction=processData().atExitFunction;
if(atExitFunction && !nullfunc::instance()->compare(atExitFunction))
atExitFunction->call(Stack);
cleanup();
}
default_t def;
string emptystring;
array *emptyarray=new array(0);
string commentchar="#";
pair zero;
void breakpoint(stack *Stack, runnable *r)
{
callable *atBreakpointFunction=processData().atBreakpointFunction;
if(atBreakpointFunction &&
!nullfunc::instance()->compare(atBreakpointFunction)) {
position curPos=getPos();
Stack->push<string>(curPos.filename());
Stack->push<Int>((Int) curPos.Line());
Stack->push<Int>((Int) curPos.Column());
Stack->push(r ? r : item(def));
atBreakpointFunction->call(Stack); // returns a string
} else Stack->push<string>("");
}
}
namespace types {
extern const char *names[];
}
void checkformat(const char *ptr, bool intformat)
{
while(*ptr != '\0') {
if(*ptr != '%') /* While we have regular characters, print them. */
ptr++;
else { /* We've got a format specifier. */
ptr++;
while(*ptr && strchr ("-+ #0'I", *ptr)) /* Move past flags. */
*ptr++;
if(*ptr == '*')
ptr++;
else while(isdigit(*ptr)) /* Handle explicit numeric value. */
ptr++;
if(*ptr == '.') {
*ptr++; /* Go past the period. */
if(*ptr == '*') {
ptr++;
} else
while(isdigit(*ptr)) /* Handle explicit numeric value. */
*ptr++;
}
while(*ptr && strchr ("hlL", *ptr))
*ptr++;
if(*ptr == '%') ++ptr;
else if(*ptr != '\0') {
if(intformat) {
switch(*ptr) {
case 'd':
case 'i':
case 'o':
case 'u':
case 'x':
case 'X':
case 'c':
break;
default:
ostringstream buf;
buf << "Invalid format '" << *ptr << "' for type "
<< types::names[types::ty_Int];
error(buf);
break;
}
} else {
switch(*ptr) {
case 'f':
case 'F':
case 'e':
case 'E':
case 'g':
case 'G':
break;
default:
ostringstream buf;
buf << "Invalid format '" << *ptr << "' for type "
<< types::names[types::ty_real];
error(buf);
break;
}
}
}
} /* End of else statement */
}
}
// Return an angle in the interval [0,360).
inline double principalBranch(double deg)
{
if(deg < 0) deg += 360;
return deg;
}
static string defaulttransparency=string("Compatible");
static const string defaulttimeformat=string("%a %b %d %T %Z %Y");
#ifdef HAVE_STRFTIME
static const size_t nTime=256;
static char Time[nTime];
#endif
void clear(string file, Int line, bool warn=false)
{
bpinfo bp(file,line);
for(mem::list<bpinfo>::iterator p=bplist.begin(); p != bplist.end(); ++p) {
if(*p == bp) {
cout << "cleared breakpoint at " << file << ": " << line << endl;
bplist.remove(bp);
return;
}
}
if(warn)
cout << "No such breakpoint at " << file << ": " << line << endl;
}
Int windingnumber(array *p, camp::pair z)
{
size_t size=checkArray(p);
Int count=0;
for(size_t i=0; i < size; i++)
count += read<path *>(p,i)->windingnumber(z);
return count;
}
string convertname(string name, const string& format, bool check=true)
{
if(name.empty())
return buildname(outname(),format,"");
else
if(check) checkLocal(name);
return format.empty() ? name : format+":"+name;
}
callable *Func;
stack *FuncStack;
double wrapFunction(double x)
{
FuncStack->push(x);
Func->call(FuncStack);
return pop<double>(FuncStack);
}
callable *compareFunc;
bool compareFunction(const vm::item& i, const vm::item& j)
{
FuncStack->push(i);
FuncStack->push(j);
compareFunc->call(FuncStack);
return pop<bool>(FuncStack);
}
void unused(void *)
{
}
static const double twelvepercent=0.12;
static const double tenpercent=0.1;
pair readpair(stringstream& s, double hscale=1.0, double vscale=1.0)
{
double x,y;
s >> y;
s >> x;
return pair(hscale*x,vscale*y);
}
// Ignore unclosed begingroups but not spurious endgroups.
const char *nobegin="endgroup without matching begingroup";
// Return the component of vector v perpendicular to a unit vector u.
inline triple perp(triple v, triple u)
{
return v-dot(v,u)*u;
}
string ASYx="/ASYx {( ) print ASYX sub 12 string cvs print} bind def";
string ASYy="/ASYy {( ) print ASYY sub 12 string cvs print} bind def";
string pathforall="{(M) print ASYy ASYx} {(L) print ASYy ASYx} {(C) print ASYy ASYx ASYy ASYx ASYy ASYx} {(c) print} pathforall";
string currentpoint="print currentpoint ASYy ASYx ";
string ASYinit="/ASYX currentpoint pop def /ASYY currentpoint exch pop def ";
string ASY1="ASY1 {"+ASYinit+"/ASY1 false def} if ";
void showpath(std::ofstream& ps)
{
ps << ASYx << newl
<< ASYy << newl
<< "/ASY1 true def" << newl
<< "/fill {" << ASY1
<< pathforall << " (M) " << currentpoint
<< "currentpoint newpath moveto } bind def" << newl
<< "/stroke {" << ASY1 << "strokepath "
<< pathforall << " (M) " << currentpoint
<< "currentpoint newpath moveto } bind def" << endl;
}
array *readpath(const string& psname, bool keep,
double hscale=1.0, double vscale=1.0)
{
array *P=new array(0);
ostringstream pipe;
pipe << "'" << getSetting<string>("gs")
<< "' -q -dNOPAUSE -dBATCH";
if(safe) pipe << " -dSAFER";
#ifdef __CYGWIN__
const string null="NUL";
#else
const string null="/dev/null";
#endif
pipe << " -sDEVICE=epswrite -sOutputFile="+null+" '" << psname << "'";
iopipestream gs(pipe.str().c_str(),"gs","Ghostscript");
stringstream buf;
while(true) {
string out;
gs >> out;
if(out.empty() && !gs.running()) break;
buf << out;
}
if(verbose > 2) cout << endl;
mem::vector<solvedKnot> nodes;
solvedKnot node;
bool cyclic=false;
bool active=false;
while(!buf.eof()) {
char c;
buf >> c;
switch(c) {
case 'M':
{
if(active) {
if(cyclic) {
if(node.point == nodes[0].point)
nodes[0].pre=node.pre;
else {
pair delta=(nodes[0].point-node.point)*third;
node.post=node.point+delta;
nodes[0].pre=nodes[0].point-delta;
node.straight=true;
nodes.push_back(node);
}
} else {
node.post=node.point;
node.straight=false;
nodes.push_back(node);
}
P->push(path(nodes,nodes.size(),cyclic));
nodes.clear();
}
active=false;
cyclic=false;
node.pre=node.point=readpair(buf,hscale,vscale);
node.straight=false;
break;
}
case 'L':
{
pair point=readpair(buf,hscale,vscale);
pair delta=(point-node.point)*third;
node.post=node.point+delta;
node.straight=true;
nodes.push_back(node);
active=true;
node.pre=point-delta;
node.point=point;
break;
}
case 'C':
{
pair point=readpair(buf,hscale,vscale);
pair pre=readpair(buf,hscale,vscale);
node.post=readpair(buf,hscale,vscale);
node.straight=false;
nodes.push_back(node);
active=true;
node.pre=pre;
node.point=point;
break;
}
case 'c':
{
cyclic=true;
break;
}
}
}
if(!keep)
unlink(psname.c_str());
return P;
}
pair sin(pair z)
{
return pair(sin(z.getx())*cosh(z.gety()),cos(z.getx())*sinh(z.gety()));
}
pair exp(pair z)
{
return exp(z.getx())*expi(z.gety());
}
pair gamma(pair z)
{
static double p[]={0.99999999999980993,676.5203681218851,-1259.1392167224028,
771.32342877765313,-176.61502916214059,12.507343278686905,
-0.13857109526572012,9.9843695780195716e-6,
1.5056327351493116e-7};
static int n=sizeof(p)/sizeof(double);
static double root2pi=sqrt(2*PI);
if(z.getx() < 0.5)
return PI/(sin(PI*z)*gamma(1.0-z));
z -= 1.0;
pair x=p[0];
for(int i=1; i < n; ++i)
x += p[i]/(z+i);
pair t=n-1.5+z;
return root2pi*pow(t,z+0.5)*exp(-t)*x;
}
void cannotread(const string& s)
{
ostringstream buf;
buf << "Cannot read from " << s << endl;
error(buf);
}
void cannotwrite(const string& s)
{
ostringstream buf;
buf << "Cannot write to " << s << endl;
error(buf);
}
// Autogenerated routines:
namespace run {
// Initializers
#line 1129 "runtime.in"
void IntZero(stack *Stack)
{
#line 1130 "runtime.in"
{Stack->push<Int>(0); return;}
}
#line 1135 "runtime.in"
void realZero(stack *Stack)
{
#line 1136 "runtime.in"
{Stack->push<real>(0.0); return;}
}
#line 1140 "runtime.in"
void boolFalse(stack *Stack)
{
#line 1141 "runtime.in"
{Stack->push<bool>(false); return;}
}
#line 1145 "runtime.in"
void pushNullArray(stack *Stack)
{
#line 1146 "runtime.in"
{Stack->push<array*>(0); return;}
}
#line 1150 "runtime.in"
void pushNullRecord(stack *Stack)
{
#line 1151 "runtime.in"
{Stack->push<frame*>(0); return;}
}
#line 1155 "runtime.in"
void pushNullFunction(stack *Stack)
{
#line 1156 "runtime.in"
{Stack->push(nullfunc::instance()); return;}
}
// Default operations
// Put the default value token on the stack (in place of an argument when
// making a function call).
#line 1165 "runtime.in"
void pushDefault(stack *Stack)
{
#line 1166 "runtime.in"
{Stack->push(def); return;}
}
// Test if the value on the stack is the default value token.
#line 1172 "runtime.in"
void isDefault(stack *Stack)
{
item i=vm::pop(Stack);
#line 1173 "runtime.in"
{Stack->push<bool>(isdefault(i)); return;}
}
// Logical operations
#line 1179 "runtime.in"
// bool !(bool b);
void gen8(stack *Stack)
{
bool b=vm::pop<bool>(Stack);
#line 1180 "runtime.in"
{Stack->push<bool>(!b); return;}
}
#line 1185 "runtime.in"
void boolMemEq(stack *Stack)
{
frame * b=vm::pop<frame *>(Stack);
frame * a=vm::pop<frame *>(Stack);
#line 1186 "runtime.in"
{Stack->push<bool>(a == b); return;}
}
#line 1190 "runtime.in"
void boolMemNeq(stack *Stack)
{
frame * b=vm::pop<frame *>(Stack);
frame * a=vm::pop<frame *>(Stack);
#line 1191 "runtime.in"
{Stack->push<bool>(a != b); return;}
}
#line 1195 "runtime.in"
void boolFuncEq(stack *Stack)
{
callable * b=vm::pop<callable *>(Stack);
callable * a=vm::pop<callable *>(Stack);
#line 1196 "runtime.in"
{Stack->push<bool>(a->compare(b)); return;}
}
#line 1200 "runtime.in"
void boolFuncNeq(stack *Stack)
{
callable * b=vm::pop<callable *>(Stack);
callable * a=vm::pop<callable *>(Stack);
#line 1201 "runtime.in"
{Stack->push<bool>(!(a->compare(b))); return;}
}
// Bit operations
#line 1207 "runtime.in"
// Int AND(Int a, Int b);
void gen13(stack *Stack)
{
Int b=vm::pop<Int>(Stack);
Int a=vm::pop<Int>(Stack);
#line 1208 "runtime.in"
{Stack->push<Int>(a & b); return;}
}
#line 1213 "runtime.in"
// Int OR(Int a, Int b);
void gen14(stack *Stack)
{
Int b=vm::pop<Int>(Stack);
Int a=vm::pop<Int>(Stack);
#line 1214 "runtime.in"
{Stack->push<Int>(a | b); return;}
}
#line 1218 "runtime.in"
// Int XOR(Int a, Int b);
void gen15(stack *Stack)
{
Int b=vm::pop<Int>(Stack);
Int a=vm::pop<Int>(Stack);
#line 1219 "runtime.in"
{Stack->push<Int>(a ^ b); return;}
}
#line 1223 "runtime.in"
// Int NOT(Int a);
void gen16(stack *Stack)
{
Int a=vm::pop<Int>(Stack);
#line 1224 "runtime.in"
{Stack->push<Int>(~a); return;}
}
// Casts
#line 1230 "runtime.in"
void pairToGuide(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 1231 "runtime.in"
{Stack->push<guide*>(new pairguide(z)); return;}
}
#line 1236 "runtime.in"
void pathToGuide(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 1237 "runtime.in"
{Stack->push<guide*>(new pathguide(p)); return;}
}
#line 1241 "runtime.in"
void guideToPath(stack *Stack)
{
guide * g=vm::pop<guide *>(Stack);
#line 1242 "runtime.in"
{Stack->push<path>(g->solve()); return;}
}
// Picture operations
#line 1248 "runtime.in"
void newPicture(stack *Stack)
{
#line 1249 "runtime.in"
{Stack->push<picture*>(new picture()); return;}
}
#line 1254 "runtime.in"
// bool empty(picture *f);
void gen21(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1255 "runtime.in"
{Stack->push<bool>(f->null()); return;}
}
#line 1259 "runtime.in"
// void erase(picture *f);
void gen22(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1260 "runtime.in"
f->nodes.clear();
}
#line 1264 "runtime.in"
// pair min(picture *f);
void gen23(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1265 "runtime.in"
{Stack->push<pair>(f->bounds().Min()); return;}
}
#line 1269 "runtime.in"
// pair max(picture *f);
void gen24(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1270 "runtime.in"
{Stack->push<pair>(f->bounds().Max()); return;}
}
#line 1274 "runtime.in"
// void label(picture *f, string *s, string *size, transform t, pair position, pair align, pen p);
void gen25(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
pair align=vm::pop<pair>(Stack);
pair position=vm::pop<pair>(Stack);
transform t=vm::pop<transform>(Stack);
string * size=vm::pop<string *>(Stack);
string * s=vm::pop<string *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1276 "runtime.in"
f->append(new drawLabel(*s,*size,t,position,align,p));
}
#line 1280 "runtime.in"
// bool labels(picture *f);
void gen26(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1281 "runtime.in"
{Stack->push<bool>(f->havelabels()); return;}
}
#line 1285 "runtime.in"
// realarray* texsize(string *s, pen p=CURRENTPEN);
void gen27(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
string * s=vm::pop<string *>(Stack);
#line 1286 "runtime.in"
texinit();
processDataStruct &pd=processData();
string texengine=getSetting<string>("tex");
const char **abort=texabort(texengine);
setpen(pd.tex,texengine,p);
double width,height,depth;
if(!texbounds(width,height,depth,pd.tex,*s,abort,false,true))
{Stack->push<realarray*>(new array(0)); return;}
array *t=new array(3);
(*t)[0]=width;
(*t)[1]=height;
(*t)[2]=depth;
{Stack->push<realarray*>(t); return;}
}
#line 1305 "runtime.in"
// patharray* _texpath(string *s, pen p=CURRENTPEN);
void gen28(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
string * s=vm::pop<string *>(Stack);
#line 1306 "runtime.in"
array *P=new array(0);
if(s->empty()) {Stack->push<patharray*>(P); return;}
string prefix=outname();
spaceToUnderscore(prefix);
string psname=auxname(prefix,"ps");
string texname=auxname(prefix,"tex");
string dviname=auxname(prefix,"dvi");
bbox b;
bool pdf=settings::pdf(getSetting<string>("tex"));
texfile tex(texname,b,true);
tex.miniprologue();
tex.setfont(p);
if(!pdf) {
tex.verbatimline("\\special{ps:");
tex.verbatimline(ASYx);
tex.verbatimline(ASYy);
tex.verbatimline("/ASY1 true def");
tex.verbatimline("/v {neg exch 4 copy 4 2 roll 2 copy 6 2 roll 2 copy (M) print ASYy ASYx (L) print ASYy add ASYx (L) print add ASYy add ASYx (L) print add ASYy ASYx (c) print} bind def");
tex.verbatimline("/show {"+ASY1+
"currentpoint newpath moveto false charpath "+
pathforall+"} bind def}");
}
tex.verbatimline(*s+"%");
tex.epilogue(true);
tex.close();
// TODO: Put in common subproutine (cf. texprocess).
string aux=auxname(prefix,"aux");
unlink(aux.c_str());
string program=texprogram();
ostringstream cmd;
bool context=settings::context(getSetting<string>("tex"));
cmd << program << (context ? " --nonstopmode '" :
" \\nonstopmode\\input '") << texname << "'";
bool quiet=verbose <= 2;
int status=System(cmd,quiet ? 1 : 0,true,"texpath",texpathmessage());
if(!status && getSetting<bool>("twice"))
status=System(cmd,quiet ? 1 : 0,true,"texpath",texpathmessage());
if(status) {
if(quiet) {
ostringstream cmd;
cmd << program << (context ? " --scrollmode '" :
" \\scrollmode\\input '") << texname << "'";
System(cmd,0);
}
}
string pdfname;
if(!status) {
if(pdf) {
pdfname=auxname(prefix,"pdf");
std::ofstream ps(psname.c_str());
if(!ps) cannotwrite(psname);
showpath(ps);
ostringstream cmd;
cmd << "'" << getSetting<string>("gs")
<< "' -q -dNOCACHE -dNOPAUSE -dBATCH";
if(safe) cmd << " -dSAFER";
cmd << " -sDEVICE=epswrite -sOutputFile=- '" << pdfname << "'";
iopipestream gs(cmd.str().c_str(),"gs","Ghostscript");
gs.block(false);
while(true) {
string line;
gs >> line;
if(line.empty() && !gs.running()) break;
ps << line;
}
ps.close();
} else {
ostringstream cmd;
cmd << "'" << getSetting<string>("dvips") << "' -R -Pdownload35 -D600 "
<< getSetting<string>("dvipsOptions");
if(verbose <= 2) cmd << " -q";
cmd << " -o '" << psname << "' '" << dviname << "'";
status=System(cmd,0,true,"dvips");
}
}
if(status != 0)
error("texpath failed");
bool keep=getSetting<bool>("keep");
if(!keep) { // Delete temporary files.
unlink(texname.c_str());
if(!getSetting<bool>("keepaux"))
unlink(aux.c_str());
unlink(auxname(prefix,"log").c_str());
if(pdf)
unlink(pdfname.c_str());
else
unlink(dviname.c_str());
if(context) {
unlink(auxname(prefix,"top").c_str());
unlink(auxname(prefix,"tua").c_str());
unlink(auxname(prefix,"tui").c_str());
}
}
{Stack->push<patharray*>(readpath(psname,keep,twelvepercent,
pdf ? twelvepercent : -twelvepercent)); return;}
}
#line 1413 "runtime.in"
// patharray* textpath(string *s, pen p=CURRENTPEN);
void gen29(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
string * s=vm::pop<string *>(Stack);
#line 1414 "runtime.in"
array *P=new array(0);
if(s->empty()) {Stack->push<patharray*>(P); return;}
string prefix=outname();
spaceToUnderscore(prefix);
string outputname=auxname(prefix,getSetting<string>("textoutformat"));
string textname=auxname(prefix,getSetting<string>("textextension"));
std::ofstream text(textname.c_str());
if(!text) cannotwrite(textname);
text << getSetting<string>("textprologue") << newl
<< p.Font() << newl
<< *s << newl
<< getSetting<string>("textepilogue") << endl;
text.close();
string psname=auxname(prefix,"ps");
std::ofstream ps(psname.c_str());
if(!ps) cannotwrite(psname);
showpath(ps);
ostringstream pipe;
pipe << getSetting<string>("textcommand") << " '" << textname << "'";
iopipestream typesetter(pipe.str().c_str());
ostringstream pipe2;
pipe2 << "'" << getSetting<string>("gs")
<< "' -q -dNOCACHE -dNOPAUSE -dBATCH";
if(safe) pipe2 << " -dSAFER";
pipe2 << " -sDEVICE=epswrite -sOutputFile=- -";
iopipestream gs(pipe2.str().c_str(),"gs","Ghostscript");
gs.block(false);
// TODO: Simplify by connecting the pipes directly.
while(true) {
string out;
if(typesetter.isopen()) {
typesetter >> out;
if(!out.empty()) gs << out;
else if(!typesetter.running()) {
typesetter.pipeclose();
gs.eof();
}
}
string out2;
gs >> out2;
if(out2.empty() && !gs.running()) break;
ps << out2;
}
ps.close();
if(verbose > 2) cout << endl;
bool keep=getSetting<bool>("keep");
if(!keep) // Delete temporary files.
unlink(textname.c_str());
{Stack->push<patharray*>(readpath(psname,keep,tenpercent,tenpercent)); return;}
}
#line 1477 "runtime.in"
// patharray* _strokepath(path g, pen p=CURRENTPEN);
void gen30(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
path g=vm::pop<path>(Stack);
#line 1478 "runtime.in"
array *P=new array(0);
if(g.size() == 0) {Stack->push<patharray*>(P); return;}
string prefix=outname();
spaceToUnderscore(prefix);
string psname=auxname(prefix,"ps");
bbox b;
psfile ps(psname,false);
ps.prologue(b);
ps.verbatimline(ASYx);
ps.verbatimline(ASYy);
ps.verbatimline("/stroke {"+ASYinit+pathforall+"} bind def");
ps.resetpen();
ps.setpen(p);
ps.write(g);
ps.strokepath();
ps.stroke();
ps.verbatimline("(M) "+currentpoint);
ps.epilogue();
ps.close();
{Stack->push<patharray*>(readpath(psname,getSetting<bool>("keep"))); return;}
}
#line 1502 "runtime.in"
// void _draw(picture *f, path g, pen p);
void gen31(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
path g=vm::pop<path>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1503 "runtime.in"
f->append(new drawPath(g,p));
}
#line 1507 "runtime.in"
// void fill(picture *f, patharray *g, pen p=CURRENTPEN, bool copy=true);
void gen32(stack *Stack)
{
bool copy=vm::pop<bool>(Stack,true);
pen p=vm::pop<pen>(Stack,CURRENTPEN);
patharray * g=vm::pop<patharray *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1508 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
f->append(new drawFill(*copyarray(g),false,p));
}
#line 1513 "runtime.in"
// void latticeshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray2 *p, bool copy=true);
void gen33(stack *Stack)
{
bool copy=vm::pop<bool>(Stack,true);
penarray2 * p=vm::pop<penarray2 *>(Stack);
pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
bool stroke=vm::pop<bool>(Stack,false);
patharray * g=vm::pop<patharray *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1515 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
f->append(new drawLatticeShade(*copyarray(g),stroke,fillrule,*copyarray(p)));
}
#line 1520 "runtime.in"
// void axialshade(picture *f, patharray *g, bool stroke=false, pen pena, pair a, pen penb, pair b, bool copy=true);
void gen34(stack *Stack)
{
bool copy=vm::pop<bool>(Stack,true);
pair b=vm::pop<pair>(Stack);
pen penb=vm::pop<pen>(Stack);
pair a=vm::pop<pair>(Stack);
pen pena=vm::pop<pen>(Stack);
bool stroke=vm::pop<bool>(Stack,false);
patharray * g=vm::pop<patharray *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1522 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
f->append(new drawAxialShade(*copyarray(g),stroke,pena,a,penb,b));
}
#line 1527 "runtime.in"
// void radialshade(picture *f, patharray *g, bool stroke=false, pen pena, pair a, real ra, pen penb, pair b, real rb, bool copy=true);
void gen35(stack *Stack)
{
bool copy=vm::pop<bool>(Stack,true);
real rb=vm::pop<real>(Stack);
pair b=vm::pop<pair>(Stack);
pen penb=vm::pop<pen>(Stack);
real ra=vm::pop<real>(Stack);
pair a=vm::pop<pair>(Stack);
pen pena=vm::pop<pen>(Stack);
bool stroke=vm::pop<bool>(Stack,false);
patharray * g=vm::pop<patharray *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1529 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
f->append(new drawRadialShade(*copyarray(g),stroke,pena,a,ra,penb,b,rb));
}
#line 1534 "runtime.in"
// void gouraudshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray *p, pairarray *z, Intarray *edges, bool copy=true);
void gen36(stack *Stack)
{
bool copy=vm::pop<bool>(Stack,true);
Intarray * edges=vm::pop<Intarray *>(Stack);
pairarray * z=vm::pop<pairarray *>(Stack);
penarray * p=vm::pop<penarray *>(Stack);
pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
bool stroke=vm::pop<bool>(Stack,false);
patharray * g=vm::pop<patharray *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1537 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
checkArrays(p,z);
checkArrays(z,edges);
f->append(new drawGouraudShade(*copyarray(g),stroke,fillrule,*copyarray(p),
*copyarray(z),*copyarray(edges)));
}
#line 1545 "runtime.in"
// void gouraudshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray *p, Intarray *edges, bool copy=true);
void gen37(stack *Stack)
{
bool copy=vm::pop<bool>(Stack,true);
Intarray * edges=vm::pop<Intarray *>(Stack);
penarray * p=vm::pop<penarray *>(Stack);
pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
bool stroke=vm::pop<bool>(Stack,false);
patharray * g=vm::pop<patharray *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1548 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
size_t n=checkArrays(p,edges);
size_t m=checkArray(g);
array *z=new array(n);
Int k=0;
Int in=(Int) n;
for(size_t j=0; j < m; ++j) {
path *P=read<path *>(g,j);
assert(P);
Int stop=Min(P->size(),in-k);
mem::vector<solvedKnot>& nodes=P->Nodes();
for(Int i=0; i < stop; ++i)
(*z)[k++]=nodes[i].point;
}
checkArrays(p,z);
f->append(new drawGouraudShade(*copyarray(g),stroke,fillrule,*copyarray(p),
*z,*copyarray(edges)));
}
#line 1569 "runtime.in"
// void tensorshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, penarray2 *p, patharray *b=NULL, pairarray2 *z=emptyarray, bool copy=true);
void gen38(stack *Stack)
{
bool copy=vm::pop<bool>(Stack,true);
pairarray2 * z=vm::pop<pairarray2 *>(Stack,emptyarray);
patharray * b=vm::pop<patharray *>(Stack,NULL);
penarray2 * p=vm::pop<penarray2 *>(Stack);
pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
bool stroke=vm::pop<bool>(Stack,false);
patharray * g=vm::pop<patharray *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1572 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
array *(*copyarray2)(array *a)=copy ? copyArray2: nop;
if(b == NULL) b=g;
size_t n=checkArrays(p,b);
size_t nz=checkArray(z);
if(nz != 0)
checkEqual(nz,n);
f->append(new drawTensorShade(*copyarray(g),stroke,fillrule,*copyarray2(p),
*copyarray(b),*copyarray2(z)));
}
#line 1584 "runtime.in"
// void functionshade(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, string shader=emptystring, bool copy=true);
void gen39(stack *Stack)
{
bool copy=vm::pop<bool>(Stack,true);
string shader=vm::pop<string>(Stack,emptystring);
pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
bool stroke=vm::pop<bool>(Stack,false);
patharray * g=vm::pop<patharray *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1587 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
f->append(new drawFunctionShade(*copyarray(g),stroke,fillrule,shader));
}
// Clip a picture to a superpath using the given fill rule.
// Subsequent additions to the picture will not be affected by the clipping.
#line 1594 "runtime.in"
// void clip(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, bool copy=true);
void gen40(stack *Stack)
{
bool copy=vm::pop<bool>(Stack,true);
pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
bool stroke=vm::pop<bool>(Stack,false);
patharray * g=vm::pop<patharray *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1596 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
drawClipBegin *begin=new drawClipBegin(*copyarray(g),stroke,fillrule,true);
f->enclose(begin,new drawClipEnd(true,begin));
}
#line 1602 "runtime.in"
// void beginclip(picture *f, patharray *g, bool stroke=false, pen fillrule=CURRENTPEN, bool copy=true);
void gen41(stack *Stack)
{
bool copy=vm::pop<bool>(Stack,true);
pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
bool stroke=vm::pop<bool>(Stack,false);
patharray * g=vm::pop<patharray *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1604 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
f->append(new drawClipBegin(*copyarray(g),stroke,fillrule,false));
}
#line 1609 "runtime.in"
// void endclip(picture *f);
void gen42(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1610 "runtime.in"
f->append(new drawClipEnd(false));
}
#line 1614 "runtime.in"
// void gsave(picture *f);
void gen43(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1615 "runtime.in"
f->append(new drawGsave());
}
#line 1619 "runtime.in"
// void grestore(picture *f);
void gen44(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1620 "runtime.in"
f->append(new drawGrestore());
}
#line 1624 "runtime.in"
// void begingroup(picture *f);
void gen45(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1625 "runtime.in"
f->append(new drawBegin());
}
#line 1629 "runtime.in"
// void endgroup(picture *f);
void gen46(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1630 "runtime.in"
f->append(new drawEnd());
}
#line 1634 "runtime.in"
// void add(picture *dest, picture *src);
void gen47(stack *Stack)
{
picture * src=vm::pop<picture *>(Stack);
picture * dest=vm::pop<picture *>(Stack);
#line 1635 "runtime.in"
dest->add(*src);
}
#line 1639 "runtime.in"
// void prepend(picture *dest, picture *src);
void gen48(stack *Stack)
{
picture * src=vm::pop<picture *>(Stack);
picture * dest=vm::pop<picture *>(Stack);
#line 1640 "runtime.in"
dest->prepend(*src);
}
#line 1644 "runtime.in"
// void postscript(picture *f, string s);
void gen49(stack *Stack)
{
string s=vm::pop<string>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1645 "runtime.in"
f->append(new drawVerbatim(PostScript,s));
}
#line 1649 "runtime.in"
// void tex(picture *f, string s);
void gen50(stack *Stack)
{
string s=vm::pop<string>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1650 "runtime.in"
f->append(new drawVerbatim(TeX,s));
}
#line 1654 "runtime.in"
// void postscript(picture *f, string s, pair min, pair max);
void gen51(stack *Stack)
{
pair max=vm::pop<pair>(Stack);
pair min=vm::pop<pair>(Stack);
string s=vm::pop<string>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1655 "runtime.in"
f->append(new drawVerbatim(PostScript,s,min,max));
}
#line 1659 "runtime.in"
// void tex(picture *f, string s, pair min, pair max);
void gen52(stack *Stack)
{
pair max=vm::pop<pair>(Stack);
pair min=vm::pop<pair>(Stack);
string s=vm::pop<string>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1660 "runtime.in"
f->append(new drawVerbatim(TeX,s,min,max));
}
#line 1664 "runtime.in"
// void texpreamble(string s);
void gen53(stack *Stack)
{
string s=vm::pop<string>(Stack);
#line 1665 "runtime.in"
string t=s+"\n";
processDataStruct &pd=processData();
pd.TeXpipepreamble.push_back(t);
pd.TeXpreamble.push_back(t);
}
#line 1672 "runtime.in"
// void deletepreamble();
void gen54(stack *)
{
#line 1673 "runtime.in"
if(getSetting<bool>("inlinetex")) {
unlink(auxname(outname(),"pre").c_str());
}
}
#line 1679 "runtime.in"
// void _labelpath(picture *f, string s, string size, path g, string justify, pair offset, pen p);
void gen55(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
pair offset=vm::pop<pair>(Stack);
string justify=vm::pop<string>(Stack);
path g=vm::pop<path>(Stack);
string size=vm::pop<string>(Stack);
string s=vm::pop<string>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1681 "runtime.in"
f->append(new drawLabelPath(s,size,g,justify,offset,p));
}
#line 1685 "runtime.in"
// void texreset();
void gen56(stack *)
{
#line 1686 "runtime.in"
processDataStruct &pd=processData();
pd.TeXpipepreamble.clear();
pd.TeXpreamble.clear();
pd.tex.pipeclose();
}
#line 1693 "runtime.in"
// void layer(picture *f);
void gen57(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1694 "runtime.in"
f->append(new drawLayer());
}
#line 1698 "runtime.in"
// void newpage(picture *f);
void gen58(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 1699 "runtime.in"
f->append(new drawNewPage());
}
#line 1703 "runtime.in"
// void _image(picture *f, realarray2 *data, pair initial, pair final, penarray *palette=NULL, transform t=identity, bool copy=true, bool antialias=false);
void gen59(stack *Stack)
{
bool antialias=vm::pop<bool>(Stack,false);
bool copy=vm::pop<bool>(Stack,true);
transform t=vm::pop<transform>(Stack,identity);
penarray * palette=vm::pop<penarray *>(Stack,NULL);
pair final=vm::pop<pair>(Stack);
pair initial=vm::pop<pair>(Stack);
realarray2 * data=vm::pop<realarray2 *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1706 "runtime.in"
array *(*copyarray)(array *a)=copy ? copyArray: nop;
array *(*copyarray2)(array *a)=copy ? copyArray2: nop;
f->append(new drawImage(*copyarray2(data),*copyarray(palette),
t*matrix(initial,final),antialias));
}
#line 1713 "runtime.in"
// void _image(picture *f, penarray2 *data, pair initial, pair final, transform t=identity, bool copy=true, bool antialias=false);
void gen60(stack *Stack)
{
bool antialias=vm::pop<bool>(Stack,false);
bool copy=vm::pop<bool>(Stack,true);
transform t=vm::pop<transform>(Stack,identity);
pair final=vm::pop<pair>(Stack);
pair initial=vm::pop<pair>(Stack);
penarray2 * data=vm::pop<penarray2 *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 1715 "runtime.in"
array *(*copyarray2)(array *a)=copy ? copyArray2: nop;
f->append(new drawImage(*copyarray2(data),t*matrix(initial,final),antialias));
}
#line 1720 "runtime.in"
// string nativeformat();
void gen61(stack *Stack)
{
#line 1721 "runtime.in"
{Stack->push<string>(nativeformat()); return;}
}
#line 1725 "runtime.in"
// bool latex();
void gen62(stack *Stack)
{
#line 1726 "runtime.in"
{Stack->push<bool>(latex(getSetting<string>("tex"))); return;}
}
#line 1730 "runtime.in"
// bool pdf();
void gen63(stack *Stack)
{
#line 1731 "runtime.in"
{Stack->push<bool>(pdf(getSetting<string>("tex"))); return;}
}
#line 1735 "runtime.in"
// void shipout(string prefix=emptystring, picture *f, picture *preamble=NULL, string format=emptystring, bool wait=false, bool view=true, callableTransform *xform);
void gen64(stack *Stack)
{
callableTransform * xform=vm::pop<callableTransform *>(Stack);
bool view=vm::pop<bool>(Stack,true);
bool wait=vm::pop<bool>(Stack,false);
string format=vm::pop<string>(Stack,emptystring);
picture * preamble=vm::pop<picture *>(Stack,NULL);
picture * f=vm::pop<picture *>(Stack);
string prefix=vm::pop<string>(Stack,emptystring);
#line 1738 "runtime.in"
if(prefix.empty()) prefix=outname();
picture *result=new picture;
unsigned level=0;
picture::nodelist::iterator p;
for(p = f->nodes.begin(); p != f->nodes.end(); ++p) {
xform->call(Stack);
transform t=pop<transform>(Stack);
static transform Zero=transform(0.0,0.0,0.0,0.0,0.0,0.0);
bool Delete=(t == Zero);
picture *group=new picture;
assert(*p);
if((*p)->endgroup()) error(nobegin);
if((*p)->begingroup()) {
++level;
while(p != f->nodes.end() && level) {
if(!Delete) {
drawElement *e=t.isIdentity() ? *p : (*p)->transformed(t);
group->append(e);
}
++p;
if(p == f->nodes.end()) break;
assert(*p);
if((*p)->begingroup()) ++level;
if((*p)->endgroup()) {
if(level) --level;
else error(nobegin);
}
}
}
if(p == f->nodes.end()) break;
assert(*p);
if(!Delete) {
drawElement *e=t.isIdentity() ? *p : (*p)->transformed(t);
group->append(e);
result->add(*group);
}
}
result->shipout(preamble,prefix,format,0.0,wait,view);
}
#line 1781 "runtime.in"
// void shipout3(string prefix, picture *f, string format=emptystring, real width, real height, real angle, real zoom, triple m, triple M, pair shift, realarray2 *t, realarray *background, triplearray *lights, realarray2 *diffuse, realarray2 *ambient, realarray2 *specular, bool viewportlighting, bool view=true);
void gen65(stack *Stack)
{
bool view=vm::pop<bool>(Stack,true);
bool viewportlighting=vm::pop<bool>(Stack);
realarray2 * specular=vm::pop<realarray2 *>(Stack);
realarray2 * ambient=vm::pop<realarray2 *>(Stack);
realarray2 * diffuse=vm::pop<realarray2 *>(Stack);
triplearray * lights=vm::pop<triplearray *>(Stack);
realarray * background=vm::pop<realarray *>(Stack);
realarray2 * t=vm::pop<realarray2 *>(Stack);
pair shift=vm::pop<pair>(Stack);
triple M=vm::pop<triple>(Stack);
triple m=vm::pop<triple>(Stack);
real zoom=vm::pop<real>(Stack);
real angle=vm::pop<real>(Stack);
real height=vm::pop<real>(Stack);
real width=vm::pop<real>(Stack);
string format=vm::pop<string>(Stack,emptystring);
picture * f=vm::pop<picture *>(Stack);
string prefix=vm::pop<string>(Stack);
#line 1787 "runtime.in"
size_t n=checkArrays(lights,diffuse);
checkEqual(n,checkArray(ambient));
checkEqual(n,checkArray(specular));
f->shipout3(prefix,format,width,height,angle,zoom,m,M,shift,
copyArray2C(t,true,4),
copyArrayC(background),n,copyTripleArrayC(lights),
copyArray2C(diffuse,false,4),copyArray2C(ambient,false,4),
copyArray2C(specular,false,4),viewportlighting,view);
}
#line 1799 "runtime.in"
// void shipout3(string prefix, picture *f);
void gen66(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
string prefix=vm::pop<string>(Stack);
#line 1800 "runtime.in"
f->shipout3(prefix);
}
#line 1804 "runtime.in"
// void deconstruct(picture *f, picture *preamble=NULL, real magnification=1, callableTransform *xform);
void gen67(stack *Stack)
{
callableTransform * xform=vm::pop<callableTransform *>(Stack);
real magnification=vm::pop<real>(Stack,1);
picture * preamble=vm::pop<picture *>(Stack,NULL);
picture * f=vm::pop<picture *>(Stack);
#line 1806 "runtime.in"
unsigned level=0;
unsigned n=0;
string prefix=outname();
string xformat=getSetting<string>("xformat");
static long arg_max=sysconf(_SC_ARG_MAX);
const unsigned maxargs=::min(arg_max/(prefix.size()+xformat.size()+25ul),
256ul);
cout << xformat << newl;
cout << maxargs << newl;
string preformat=nativeformat();
const string Done="Done";
const string Error="Error";
ostringstream cmd;
// Enforce ghostscript limitations.
magnification=::max(magnification,0.0001);
real res=::min(::max(magnification*72.0,2.0),8192.0);
const char *converter=NULL, *hint=NULL;
bool png=xformat == "png";
if(magnification > 0.0) {
mem::list<string> nameStack;
string outname;
unsigned arg=0;
unsigned batch=0;
for(picture::nodelist::iterator p=f->nodes.begin();;) {
if(p == f->nodes.end()) break;
if(arg == 0) {
cmd.str("");
ostringstream buf;
buf << batch << "_";
outname=buildname(prefix+buf.str()+"%d",xformat,"");
if(png) {
cmd << "'" << getSetting<string>("gs")
<< "' -q -dNOPAUSE -dBATCH -sDEVICE=pngalpha -dEPSCrop";
if(safe)
cmd << " -dSAFER";
cmd << " -r" << res << "x" << res
<< " -sOutputFile='" << outname << "'";
converter="gs";
hint="Ghostscript";
} else {
cmd << "'" << getSetting<string>("convert")
<< "' -density " << res << "x" << res
<< " -transparent white";
hint=converter="convert";
}
}
picture *group=new picture;
xform->call(Stack);
transform t=pop<transform>(Stack);
assert(*p);
if((*p)->endgroup()) {
cout << Error << endl;
error(nobegin);
}
if((*p)->begingroup()) {
++level;
while(p != f->nodes.end() && level) {
drawElement *e=t.isIdentity() ? *p : (*p)->transformed(t);
group->append(e);
++p;
if(p == f->nodes.end()) break;
assert(*p);
if((*p)->begingroup()) ++level;
if((*p)->endgroup()) {
if(level) --level;
else {
cout << Error << endl;
error(nobegin);
}
}
}
}
if(p != f->nodes.end()) {
assert(*p);
drawElement *e=t.isIdentity() ? *p : (*p)->transformed(t);
group->append(e);
bbox b;
ostringstream buf;
buf << prefix << "_" << n;
group->shipout(preamble,buf.str(),preformat,magnification,false,false);
string Preformat=png && group->Transparency() ? "pdf" : preformat;
string name=buildname(buf.str(),Preformat);
nameStack.push_back(name);
cmd << " '";
if(!png) cmd << preformat+":";
cmd << name << "'";
b=group->bounds();
b *= magnification;
cout << b << newl;
++n;
++p;
++arg;
}
if(p == f->nodes.end() || arg >= maxargs) {
arg=0;
++batch;
cout.flush();
if(!png)
cmd << " -scene 1 '" << xformat << ":" << outname << "'";
int status=System(cmd,0,true,converter,hint);
if(status) {
cout << Error << endl;
error("deconstruct failed");
}
}
}
if(!getSetting<bool>("keep")) {
for(mem::list<string>::iterator p=nameStack.begin();
p != nameStack.end(); ++p)
unlink(p->c_str());
}
cout << Done << endl;
}
}
#line 1937 "runtime.in"
// void purge(Int divisor=0);
void gen68(stack *Stack)
{
Int divisor=vm::pop<Int>(Stack,0);
#line 1938 "runtime.in"
purge(divisor);
}
// Pen operations
#line 1944 "runtime.in"
void newPen(stack *Stack)
{
#line 1945 "runtime.in"
{Stack->push<pen>(pen()); return;}
}
#line 1950 "runtime.in"
// bool ==(pen a, pen b);
void gen70(stack *Stack)
{
pen b=vm::pop<pen>(Stack);
pen a=vm::pop<pen>(Stack);
#line 1951 "runtime.in"
{Stack->push<bool>(a == b); return;}
}
#line 1955 "runtime.in"
// bool !=(pen a, pen b);
void gen71(stack *Stack)
{
pen b=vm::pop<pen>(Stack);
pen a=vm::pop<pen>(Stack);
#line 1956 "runtime.in"
{Stack->push<bool>(a != b); return;}
}
#line 1960 "runtime.in"
// pen +(pen a, pen b);
void gen72(stack *Stack)
{
pen b=vm::pop<pen>(Stack);
pen a=vm::pop<pen>(Stack);
#line 1961 "runtime.in"
{Stack->push<pen>(a+b); return;}
}
#line 1965 "runtime.in"
// pen *(real a, pen b);
void gen73(stack *Stack)
{
pen b=vm::pop<pen>(Stack);
real a=vm::pop<real>(Stack);
#line 1966 "runtime.in"
{Stack->push<pen>(a*b); return;}
}
#line 1970 "runtime.in"
// pen *(pen a, real b);
void gen74(stack *Stack)
{
real b=vm::pop<real>(Stack);
pen a=vm::pop<pen>(Stack);
#line 1971 "runtime.in"
{Stack->push<pen>(b*a); return;}
}
#line 1975 "runtime.in"
// pair max(pen p);
void gen75(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 1976 "runtime.in"
{Stack->push<pair>(p.bounds().Max()); return;}
}
#line 1980 "runtime.in"
// pair min(pen p);
void gen76(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 1981 "runtime.in"
{Stack->push<pair>(p.bounds().Min()); return;}
}
// Reset the meaning of pen default attributes.
#line 1986 "runtime.in"
// void resetdefaultpen();
void gen77(stack *)
{
#line 1987 "runtime.in"
processData().defaultpen=camp::pen::initialpen();
}
#line 1991 "runtime.in"
// void defaultpen(pen p);
void gen78(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 1992 "runtime.in"
processData().defaultpen=pen(resolvepen,p);
}
#line 1996 "runtime.in"
// pen defaultpen();
void gen79(stack *Stack)
{
#line 1997 "runtime.in"
{Stack->push<pen>(processData().defaultpen); return;}
}
#line 2001 "runtime.in"
// bool invisible(pen p);
void gen80(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2002 "runtime.in"
{Stack->push<bool>(p.invisible()); return;}
}
#line 2006 "runtime.in"
// pen invisible();
void gen81(stack *Stack)
{
#line 2007 "runtime.in"
{Stack->push<pen>(pen(invisiblepen)); return;}
}
#line 2011 "runtime.in"
// pen gray(pen p);
void gen82(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2012 "runtime.in"
p.togrey();
{Stack->push<pen>(p); return;}
}
#line 2017 "runtime.in"
// pen rgb(pen p);
void gen83(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2018 "runtime.in"
p.torgb();
{Stack->push<pen>(p); return;}
}
#line 2023 "runtime.in"
// pen cmyk(pen p);
void gen84(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2024 "runtime.in"
p.tocmyk();
{Stack->push<pen>(p); return;}
}
#line 2029 "runtime.in"
// pen interp(pen a, pen b, real t);
void gen85(stack *Stack)
{
real t=vm::pop<real>(Stack);
pen b=vm::pop<pen>(Stack);
pen a=vm::pop<pen>(Stack);
#line 2030 "runtime.in"
{Stack->push<pen>(interpolate(a,b,t)); return;}
}
#line 2034 "runtime.in"
// pen rgb(real r, real g, real b);
void gen86(stack *Stack)
{
real b=vm::pop<real>(Stack);
real g=vm::pop<real>(Stack);
real r=vm::pop<real>(Stack);
#line 2035 "runtime.in"
{Stack->push<pen>(pen(r,g,b)); return;}
}
#line 2039 "runtime.in"
// pen cmyk(real c, real m, real y, real k);
void gen87(stack *Stack)
{
real k=vm::pop<real>(Stack);
real y=vm::pop<real>(Stack);
real m=vm::pop<real>(Stack);
real c=vm::pop<real>(Stack);
#line 2040 "runtime.in"
{Stack->push<pen>(pen(c,m,y,k)); return;}
}
#line 2044 "runtime.in"
// pen gray(real gray);
void gen88(stack *Stack)
{
real gray=vm::pop<real>(Stack);
#line 2045 "runtime.in"
{Stack->push<pen>(pen(gray)); return;}
}
#line 2049 "runtime.in"
// realarray* colors(pen p);
void gen89(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2050 "runtime.in"
size_t n=ColorComponents[p.colorspace()];
array *a=new array(n);
switch(n) {
case 0:
break;
case 1:
(*a)[0]=p.gray();
break;
case 3:
(*a)[0]=p.red();
(*a)[1]=p.green();
(*a)[2]=p.blue();
break;
case 4:
(*a)[0]=p.cyan();
(*a)[1]=p.magenta();
(*a)[2]=p.yellow();
(*a)[3]=p.black();
break;
default:
break;
}
{Stack->push<realarray*>(a); return;}
}
#line 2077 "runtime.in"
// string colorspace(pen p);
void gen90(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2078 "runtime.in"
string s=ColorDeviceSuffix[p.colorspace()];
std::transform(s.begin(),s.end(),s.begin(),tolower);
{Stack->push<string>(s); return;}
}
#line 2084 "runtime.in"
// pen pattern(string *s);
void gen91(stack *Stack)
{
string * s=vm::pop<string *>(Stack);
#line 2085 "runtime.in"
{Stack->push<pen>(pen(setpattern,*s)); return;}
}
#line 2089 "runtime.in"
// string pattern(pen p);
void gen92(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2090 "runtime.in"
{Stack->push<string>(p.fillpattern()); return;}
}
#line 2094 "runtime.in"
// pen fillrule(Int n);
void gen93(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
#line 2095 "runtime.in"
{Stack->push<pen>(pen(n >= 0 && n < nFill ? (FillRule) n : DEFFILL)); return;}
}
#line 2099 "runtime.in"
// Int fillrule(pen p);
void gen94(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2100 "runtime.in"
{Stack->push<Int>(p.Fillrule()); return;}
}
#line 2104 "runtime.in"
// pen opacity(real opacity=1.0, string blend=defaulttransparency);
void gen95(stack *Stack)
{
string blend=vm::pop<string>(Stack,defaulttransparency);
real opacity=vm::pop<real>(Stack,1.0);
#line 2105 "runtime.in"
for(Int i=0; i < nBlendMode; ++i)
if(blend == BlendMode[i]) {Stack->push<pen>(pen(Transparency(blend,opacity))); return;}
ostringstream buf;
buf << "Unknown blend mode: " << "'" << blend << "'";
error(buf);
}
#line 2114 "runtime.in"
// real opacity(pen p);
void gen96(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2115 "runtime.in"
{Stack->push<real>(p.opacity()); return;}
}
#line 2119 "runtime.in"
// string blend(pen p);
void gen97(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2120 "runtime.in"
{Stack->push<string>(p.blend()); return;}
}
#line 2124 "runtime.in"
// pen linetype(string *s, real offset=0, bool scale=true, bool adjust=true);
void gen98(stack *Stack)
{
bool adjust=vm::pop<bool>(Stack,true);
bool scale=vm::pop<bool>(Stack,true);
real offset=vm::pop<real>(Stack,0);
string * s=vm::pop<string *>(Stack);
#line 2125 "runtime.in"
{Stack->push<pen>(pen(LineType(*s,offset,scale,adjust))); return;}
}
#line 2129 "runtime.in"
// string linetype(pen p=CURRENTPEN);
void gen99(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 2130 "runtime.in"
{Stack->push<string>(p.stroke()); return;}
}
#line 2134 "runtime.in"
// real offset(pen p);
void gen100(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2135 "runtime.in"
{Stack->push<real>(p.linetype().offset); return;}
}
#line 2139 "runtime.in"
// bool scale(pen p);
void gen101(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2140 "runtime.in"
{Stack->push<bool>(p.linetype().scale); return;}
}
#line 2144 "runtime.in"
// bool adjust(pen p);
void gen102(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2145 "runtime.in"
{Stack->push<bool>(p.linetype().adjust); return;}
}
#line 2149 "runtime.in"
// pen adjust(pen p, real arclength, bool cyclic);
void gen103(stack *Stack)
{
bool cyclic=vm::pop<bool>(Stack);
real arclength=vm::pop<real>(Stack);
pen p=vm::pop<pen>(Stack);
#line 2150 "runtime.in"
{Stack->push<pen>(adjustdash(p,arclength,cyclic)); return;}
}
#line 2154 "runtime.in"
// pen linecap(Int n);
void gen104(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
#line 2155 "runtime.in"
{Stack->push<pen>(pen(setlinecap,n >= 0 && n < nCap ? n : DEFCAP)); return;}
}
#line 2159 "runtime.in"
// Int linecap(pen p=CURRENTPEN);
void gen105(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 2160 "runtime.in"
{Stack->push<Int>(p.cap()); return;}
}
#line 2164 "runtime.in"
// pen linejoin(Int n);
void gen106(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
#line 2165 "runtime.in"
{Stack->push<pen>(pen(setlinejoin,n >= 0 && n < nJoin ? n : DEFJOIN)); return;}
}
#line 2169 "runtime.in"
// Int linejoin(pen p=CURRENTPEN);
void gen107(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 2170 "runtime.in"
{Stack->push<Int>(p.join()); return;}
}
#line 2174 "runtime.in"
// pen miterlimit(real x);
void gen108(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 2175 "runtime.in"
{Stack->push<pen>(pen(setmiterlimit,x >= 1.0 ? x : DEFJOIN)); return;}
}
#line 2179 "runtime.in"
// real miterlimit(pen p=CURRENTPEN);
void gen109(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 2180 "runtime.in"
{Stack->push<real>(p.miter()); return;}
}
#line 2184 "runtime.in"
// pen linewidth(real x);
void gen110(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 2185 "runtime.in"
{Stack->push<pen>(pen(setlinewidth,x >= 0.0 ? x : DEFWIDTH)); return;}
}
#line 2189 "runtime.in"
// real linewidth(pen p=CURRENTPEN);
void gen111(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 2190 "runtime.in"
{Stack->push<real>(p.width()); return;}
}
#line 2194 "runtime.in"
// pen fontcommand(string *s);
void gen112(stack *Stack)
{
string * s=vm::pop<string *>(Stack);
#line 2195 "runtime.in"
{Stack->push<pen>(pen(setfont,*s)); return;}
}
#line 2199 "runtime.in"
// string font(pen p=CURRENTPEN);
void gen113(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 2200 "runtime.in"
{Stack->push<string>(p.Font()); return;}
}
#line 2204 "runtime.in"
// pen fontsize(real size, real lineskip);
void gen114(stack *Stack)
{
real lineskip=vm::pop<real>(Stack);
real size=vm::pop<real>(Stack);
#line 2205 "runtime.in"
{Stack->push<pen>(pen(setfontsize,size > 0.0 ? size : 0.0,
lineskip > 0.0 ? lineskip : 0.0)); return;}
}
#line 2210 "runtime.in"
// real fontsize(pen p=CURRENTPEN);
void gen115(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 2211 "runtime.in"
{Stack->push<real>(p.size()); return;}
}
#line 2215 "runtime.in"
// real lineskip(pen p=CURRENTPEN);
void gen116(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 2216 "runtime.in"
{Stack->push<real>(p.Lineskip()); return;}
}
#line 2220 "runtime.in"
// pen overwrite(Int n);
void gen117(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
#line 2221 "runtime.in"
{Stack->push<pen>(pen(setoverwrite,n >= 0 && n < nOverwrite ? (overwrite_t) n :
DEFWRITE)); return;}
}
#line 2226 "runtime.in"
// Int overwrite(pen p=CURRENTPEN);
void gen118(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 2227 "runtime.in"
{Stack->push<Int>(p.Overwrite()); return;}
}
#line 2231 "runtime.in"
// pen basealign(Int n);
void gen119(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
#line 2232 "runtime.in"
{Stack->push<pen>(pen(n >= 0 && n < nBaseLine ? (BaseLine) n : DEFBASE)); return;}
}
#line 2236 "runtime.in"
// Int basealign(pen p=CURRENTPEN);
void gen120(stack *Stack)
{
pen p=vm::pop<pen>(Stack,CURRENTPEN);
#line 2237 "runtime.in"
{Stack->push<Int>(p.Baseline()); return;}
}
#line 2241 "runtime.in"
// transform transform(pen p);
void gen121(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2242 "runtime.in"
{Stack->push<transform>(p.getTransform()); return;}
}
#line 2246 "runtime.in"
// path nib(pen p);
void gen122(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2247 "runtime.in"
{Stack->push<path>(p.Path()); return;}
}
#line 2251 "runtime.in"
// pen makepen(path p);
void gen123(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2252 "runtime.in"
{Stack->push<pen>(pen(p)); return;}
}
#line 2256 "runtime.in"
// pen colorless(pen p);
void gen124(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
#line 2257 "runtime.in"
p.colorless();
{Stack->push<pen>(p); return;}
}
// Interactive mode
#line 2263 "runtime.in"
// bool interactive();
void gen125(stack *Stack)
{
#line 2264 "runtime.in"
{Stack->push<bool>(interact::interactive); return;}
}
#line 2269 "runtime.in"
// bool uptodate();
void gen126(stack *Stack)
{
#line 2270 "runtime.in"
{Stack->push<bool>(interact::uptodate); return;}
}
// System commands
#line 2276 "runtime.in"
// Int system(string s);
void gen127(stack *Stack)
{
string s=vm::pop<string>(Stack);
#line 2277 "runtime.in"
if(safe) error("system() call disabled; override with option -nosafe");
if(s.empty()) {Stack->push<Int>(0); return;}
else {Stack->push<Int>(System(s.c_str())); return;}
}
#line 2284 "runtime.in"
// bool view();
void gen128(stack *Stack)
{
#line 2285 "runtime.in"
{Stack->push<bool>(view()); return;}
}
#line 2289 "runtime.in"
// string asydir();
void gen129(stack *Stack)
{
#line 2290 "runtime.in"
{Stack->push<string>(systemDir); return;}
}
#line 2294 "runtime.in"
// string locale(string s=emptystring);
void gen130(stack *Stack)
{
string s=vm::pop<string>(Stack,emptystring);
#line 2295 "runtime.in"
char *L=setlocale(LC_ALL,s.empty() ? NULL : s.c_str());
{Stack->push<string>(L != NULL ? string(L) : ""); return;}
}
#line 2300 "runtime.in"
// void abort(string s=emptystring);
void gen131(stack *Stack)
{
string s=vm::pop<string>(Stack,emptystring);
#line 2301 "runtime.in"
if(s.empty()) throw handled_error();
error(s.c_str());
}
#line 2306 "runtime.in"
// void exit();
void gen132(stack *)
{
#line 2307 "runtime.in"
throw quit();
}
#line 2311 "runtime.in"
// void assert(bool b, string s=emptystring);
void gen133(stack *Stack)
{
string s=vm::pop<string>(Stack,emptystring);
bool b=vm::pop<bool>(Stack);
#line 2312 "runtime.in"
flush(cout);
if(!b) {
ostringstream buf;
buf << "assert FAILED";
if(s != "") buf << ": " << s << endl;
error(buf);
}
}
#line 2322 "runtime.in"
// void sleep(Int seconds);
void gen134(stack *Stack)
{
Int seconds=vm::pop<Int>(Stack);
#line 2323 "runtime.in"
if(seconds <= 0) return;
sleep(seconds);
}
#line 2328 "runtime.in"
// void usleep(Int microseconds);
void gen135(stack *Stack)
{
Int microseconds=vm::pop<Int>(Stack);
#line 2329 "runtime.in"
if(microseconds <= 0) return;
usleep((unsigned long) microseconds);
}
#line 2334 "runtime.in"
// void _eval(string *s, bool embedded, bool interactiveWrite=false);
void gen136(stack *Stack)
{
bool interactiveWrite=vm::pop<bool>(Stack,false);
bool embedded=vm::pop<bool>(Stack);
string * s=vm::pop<string *>(Stack);
#line 2335 "runtime.in"
if (embedded) {
trans::coenv *e=Stack->getEnvironment();
vm::interactiveStack *is=dynamic_cast<vm::interactiveStack *>(Stack);
if (e && is) {
runStringEmbedded(*s, *e, *is);
} else {
cerr << "no runtime environment for embedded eval" << endl;
}
} else {
runString(*s,interactiveWrite);
}
}
#line 2349 "runtime.in"
// void _eval(runnable *s, bool embedded);
void gen137(stack *Stack)
{
bool embedded=vm::pop<bool>(Stack);
runnable * s=vm::pop<runnable *>(Stack);
#line 2350 "runtime.in"
absyntax::block *ast=new absyntax::block(s->getPos(), false);
ast->add(s);
if (embedded) {
trans::coenv *e=Stack->getEnvironment();
vm::interactiveStack *is=dynamic_cast<vm::interactiveStack *>(Stack);
if (e && is) {
runCodeEmbedded(ast, *e, *is);
} else {
cerr << "no runtime environment for embedded eval" << endl;
}
} else {
runCode(ast);
}
}
#line 2367 "runtime.in"
// string location();
void gen138(stack *Stack)
{
#line 2368 "runtime.in"
ostringstream buf;
buf << getPos();
{Stack->push<string>(buf.str()); return;}
}
// Wrapper for the stack::load() method.
#line 2374 "runtime.in"
void loadModule(stack *Stack)
{
string * index=vm::pop<string *>(Stack);
#line 2375 "runtime.in"
Stack->load(*index);
}
#line 2379 "runtime.in"
// string cd(string s=emptystring);
void gen140(stack *Stack)
{
string s=vm::pop<string>(Stack,emptystring);
#line 2380 "runtime.in"
if(!s.empty() && !globalwrite()) writeDisabled();
{Stack->push<string>(setPath(s.c_str())); return;}
}
#line 2385 "runtime.in"
// void list(string *s, bool imports=false);
void gen141(stack *Stack)
{
bool imports=vm::pop<bool>(Stack,false);
string * s=vm::pop<string *>(Stack);
#line 2386 "runtime.in"
if(*s == "-") return;
trans::genv ge;
symbol *name=symbol::trans(*s);
record *r=ge.getModule(name,*s);
r->e.list(imports ? 0 : r);
}
// Path operations
#line 2396 "runtime.in"
void nullPath(stack *Stack)
{
#line 2397 "runtime.in"
{Stack->push<path>(nullpath); return;}
}
#line 2402 "runtime.in"
// bool ==(path a, path b);
void gen143(stack *Stack)
{
path b=vm::pop<path>(Stack);
path a=vm::pop<path>(Stack);
#line 2403 "runtime.in"
{Stack->push<bool>(a == b); return;}
}
#line 2407 "runtime.in"
// bool !=(path a, path b);
void gen144(stack *Stack)
{
path b=vm::pop<path>(Stack);
path a=vm::pop<path>(Stack);
#line 2408 "runtime.in"
{Stack->push<bool>(!(a == b)); return;}
}
#line 2412 "runtime.in"
// pair point(path p, Int t);
void gen145(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
path p=vm::pop<path>(Stack);
#line 2413 "runtime.in"
{Stack->push<pair>(p.point((Int) t)); return;}
}
#line 2417 "runtime.in"
// pair point(path p, real t);
void gen146(stack *Stack)
{
real t=vm::pop<real>(Stack);
path p=vm::pop<path>(Stack);
#line 2418 "runtime.in"
{Stack->push<pair>(p.point(t)); return;}
}
#line 2422 "runtime.in"
// pair precontrol(path p, Int t);
void gen147(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
path p=vm::pop<path>(Stack);
#line 2423 "runtime.in"
{Stack->push<pair>(p.precontrol((Int) t)); return;}
}
#line 2427 "runtime.in"
// pair precontrol(path p, real t);
void gen148(stack *Stack)
{
real t=vm::pop<real>(Stack);
path p=vm::pop<path>(Stack);
#line 2428 "runtime.in"
{Stack->push<pair>(p.precontrol(t)); return;}
}
#line 2432 "runtime.in"
// pair postcontrol(path p, Int t);
void gen149(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
path p=vm::pop<path>(Stack);
#line 2433 "runtime.in"
{Stack->push<pair>(p.postcontrol((Int) t)); return;}
}
#line 2437 "runtime.in"
// pair postcontrol(path p, real t);
void gen150(stack *Stack)
{
real t=vm::pop<real>(Stack);
path p=vm::pop<path>(Stack);
#line 2438 "runtime.in"
{Stack->push<pair>(p.postcontrol(t)); return;}
}
#line 2442 "runtime.in"
// pair dir(path p, Int t, Int sign=0, bool normalize=true);
void gen151(stack *Stack)
{
bool normalize=vm::pop<bool>(Stack,true);
Int sign=vm::pop<Int>(Stack,0);
Int t=vm::pop<Int>(Stack);
path p=vm::pop<path>(Stack);
#line 2443 "runtime.in"
{Stack->push<pair>(p.dir(t,sign,normalize)); return;}
}
#line 2447 "runtime.in"
// pair dir(path p, real t, bool normalize=true);
void gen152(stack *Stack)
{
bool normalize=vm::pop<bool>(Stack,true);
real t=vm::pop<real>(Stack);
path p=vm::pop<path>(Stack);
#line 2448 "runtime.in"
{Stack->push<pair>(p.dir(t,normalize)); return;}
}
#line 2452 "runtime.in"
// pair accel(path p, Int t, Int sign=0);
void gen153(stack *Stack)
{
Int sign=vm::pop<Int>(Stack,0);
Int t=vm::pop<Int>(Stack);
path p=vm::pop<path>(Stack);
#line 2453 "runtime.in"
{Stack->push<pair>(p.accel(t,sign)); return;}
}
#line 2457 "runtime.in"
// pair accel(path p, real t);
void gen154(stack *Stack)
{
real t=vm::pop<real>(Stack);
path p=vm::pop<path>(Stack);
#line 2458 "runtime.in"
{Stack->push<pair>(p.accel(t)); return;}
}
#line 2462 "runtime.in"
// real radius(path p, real t);
void gen155(stack *Stack)
{
real t=vm::pop<real>(Stack);
path p=vm::pop<path>(Stack);
#line 2463 "runtime.in"
pair v=p.dir(t,false);
pair a=p.accel(t);
real d=dot(a,v);
real v2=v.abs2();
real a2=a.abs2();
real denom=v2*a2-d*d;
real r=v2*sqrt(v2);
{Stack->push<real>(denom > 0 ? r/sqrt(denom) : 0.0); return;}
}
#line 2474 "runtime.in"
// path reverse(path p);
void gen156(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2475 "runtime.in"
{Stack->push<path>(p.reverse()); return;}
}
#line 2479 "runtime.in"
// path subpath(path p, Int a, Int b);
void gen157(stack *Stack)
{
Int b=vm::pop<Int>(Stack);
Int a=vm::pop<Int>(Stack);
path p=vm::pop<path>(Stack);
#line 2480 "runtime.in"
{Stack->push<path>(p.subpath((Int) a, (Int) b)); return;}
}
#line 2484 "runtime.in"
// path subpath(path p, real a, real b);
void gen158(stack *Stack)
{
real b=vm::pop<real>(Stack);
real a=vm::pop<real>(Stack);
path p=vm::pop<path>(Stack);
#line 2485 "runtime.in"
{Stack->push<path>(p.subpath(a,b)); return;}
}
#line 2489 "runtime.in"
// path nurb(pair z0, pair z1, pair z2, pair z3, real w0, real w1, real w2, real w3, Int m);
void gen159(stack *Stack)
{
Int m=vm::pop<Int>(Stack);
real w3=vm::pop<real>(Stack);
real w2=vm::pop<real>(Stack);
real w1=vm::pop<real>(Stack);
real w0=vm::pop<real>(Stack);
pair z3=vm::pop<pair>(Stack);
pair z2=vm::pop<pair>(Stack);
pair z1=vm::pop<pair>(Stack);
pair z0=vm::pop<pair>(Stack);
#line 2491 "runtime.in"
{Stack->push<path>(nurb(z0,z1,z2,z3,w0,w1,w2,w3,m)); return;}
}
#line 2495 "runtime.in"
// Int length(path p);
void gen160(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2496 "runtime.in"
{Stack->push<Int>(p.length()); return;}
}
#line 2500 "runtime.in"
// bool cyclic(path p);
void gen161(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2501 "runtime.in"
{Stack->push<bool>(p.cyclic()); return;}
}
#line 2505 "runtime.in"
// bool straight(path p, Int t);
void gen162(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
path p=vm::pop<path>(Stack);
#line 2506 "runtime.in"
{Stack->push<bool>(p.straight(t)); return;}
}
#line 2510 "runtime.in"
// path unstraighten(path p);
void gen163(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2511 "runtime.in"
{Stack->push<path>(p.unstraighten()); return;}
}
#line 2515 "runtime.in"
// bool piecewisestraight(path p);
void gen164(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2516 "runtime.in"
{Stack->push<bool>(p.piecewisestraight()); return;}
}
#line 2520 "runtime.in"
// real arclength(path p);
void gen165(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2521 "runtime.in"
{Stack->push<real>(p.arclength()); return;}
}
#line 2525 "runtime.in"
// real arctime(path p, real dval);
void gen166(stack *Stack)
{
real dval=vm::pop<real>(Stack);
path p=vm::pop<path>(Stack);
#line 2526 "runtime.in"
{Stack->push<real>(p.arctime(dval)); return;}
}
#line 2530 "runtime.in"
// real dirtime(path p, pair z);
void gen167(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
path p=vm::pop<path>(Stack);
#line 2531 "runtime.in"
{Stack->push<real>(p.directiontime(z)); return;}
}
#line 2535 "runtime.in"
// realarray* intersect(path p, path q, real fuzz=-1);
void gen168(stack *Stack)
{
real fuzz=vm::pop<real>(Stack,-1);
path q=vm::pop<path>(Stack);
path p=vm::pop<path>(Stack);
#line 2536 "runtime.in"
bool exact=fuzz <= 0.0;
if(fuzz < 0)
fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
::max(length(q.max()),length(q.min())));
std::vector<real> S,T;
real s,t;
if(intersections(s,t,S,T,p,q,fuzz,true,exact)) {
array *V=new array(2);
(*V)[0]=s;
(*V)[1]=t;
{Stack->push<realarray*>(V); return;}
}
{Stack->push<realarray*>(new array(0)); return;}
}
#line 2552 "runtime.in"
// realarray2* intersections(path p, path q, real fuzz=-1);
void gen169(stack *Stack)
{
real fuzz=vm::pop<real>(Stack,-1);
path q=vm::pop<path>(Stack);
path p=vm::pop<path>(Stack);
#line 2553 "runtime.in"
bool exact=fuzz <= 0.0;
if(fuzz < 0.0)
fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
::max(length(q.max()),length(q.min())));
real s,t;
std::vector<real> S,T;
intersections(s,t,S,T,p,q,fuzz,false,true);
size_t n=S.size();
if(n == 0 && !exact) {
if(intersections(s,t,S,T,p,q,fuzz,true,false)) {
array *V=new array(1);
array *Vi=new array(2);
(*V)[0]=Vi;
(*Vi)[0]=s;
(*Vi)[1]=t;
{Stack->push<realarray2*>(V); return;}
}
}
array *V=new array(n);
for(size_t i=0; i < n; ++i) {
array *Vi=new array(2);
(*V)[i]=Vi;
(*Vi)[0]=S[i];
(*Vi)[1]=T[i];
}
stable_sort(V->begin(),V->end(),run::compare2<real>());
{Stack->push<realarray2*>(V); return;}
}
#line 2583 "runtime.in"
// realarray* intersections(path p, explicit pair a, explicit pair b, real fuzz=-1);
void gen170(stack *Stack)
{
real fuzz=vm::pop<real>(Stack,-1);
pair b=vm::pop<pair>(Stack);
pair a=vm::pop<pair>(Stack);
path p=vm::pop<path>(Stack);
#line 2584 "runtime.in"
if(fuzz < 0)
fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
::max(length(a),length(b)));
std::vector<real> S;
intersections(S,p,a,b,fuzz);
sort(S.begin(),S.end());
size_t n=S.size();
array *V=new array(n);
for(size_t i=0; i < n; ++i)
(*V)[i]=S[i];
{Stack->push<realarray*>(V); return;}
}
// Return the intersection point of the extensions of the line segments
// PQ and pq.
#line 2600 "runtime.in"
// pair extension(pair P, pair Q, pair p, pair q);
void gen171(stack *Stack)
{
pair q=vm::pop<pair>(Stack);
pair p=vm::pop<pair>(Stack);
pair Q=vm::pop<pair>(Stack);
pair P=vm::pop<pair>(Stack);
#line 2601 "runtime.in"
pair ac=P-Q;
pair bd=q-p;
real det=ac.getx()*bd.gety()-ac.gety()*bd.getx();
if(det == 0) {Stack->push<pair>(pair(infinity,infinity)); return;}
{Stack->push<pair>(P+((p.getx()-P.getx())*bd.gety()-(p.gety()-P.gety())*bd.getx())*ac/det); return;}
}
#line 2609 "runtime.in"
// Int size(path p);
void gen172(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2610 "runtime.in"
{Stack->push<Int>(p.size()); return;}
}
#line 2614 "runtime.in"
// path &(path p, path q);
void gen173(stack *Stack)
{
path q=vm::pop<path>(Stack);
path p=vm::pop<path>(Stack);
#line 2615 "runtime.in"
{Stack->push<path>(camp::concat(p,q)); return;}
}
#line 2619 "runtime.in"
// pair min(path p);
void gen174(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2620 "runtime.in"
{Stack->push<pair>(p.min()); return;}
}
#line 2624 "runtime.in"
// pair max(path p);
void gen175(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2625 "runtime.in"
{Stack->push<pair>(p.max()); return;}
}
#line 2629 "runtime.in"
// realarray* mintimes(path p);
void gen176(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2630 "runtime.in"
array *V=new array(2);
pair z=p.mintimes();
(*V)[0]=z.getx();
(*V)[1]=z.gety();
{Stack->push<realarray*>(V); return;}
}
#line 2638 "runtime.in"
// realarray* maxtimes(path p);
void gen177(stack *Stack)
{
path p=vm::pop<path>(Stack);
#line 2639 "runtime.in"
array *V=new array(2);
pair z=p.maxtimes();
(*V)[0]=z.getx();
(*V)[1]=z.gety();
{Stack->push<realarray*>(V); return;}
}
#line 2647 "runtime.in"
// real relativedistance(real theta, real phi, real t, bool atleast);
void gen178(stack *Stack)
{
bool atleast=vm::pop<bool>(Stack);
real t=vm::pop<real>(Stack);
real phi=vm::pop<real>(Stack);
real theta=vm::pop<real>(Stack);
#line 2648 "runtime.in"
{Stack->push<real>(camp::velocity(theta,phi,tension(t,atleast))); return;}
}
#line 2652 "runtime.in"
// Int windingnumber(patharray *p, pair z);
void gen179(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
patharray * p=vm::pop<patharray *>(Stack);
#line 2653 "runtime.in"
{Stack->push<Int>(windingnumber(p,z)); return;}
}
#line 2657 "runtime.in"
// bool inside(explicit patharray *g, pair z, pen fillrule=CURRENTPEN);
void gen180(stack *Stack)
{
pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
pair z=vm::pop<pair>(Stack);
patharray * g=vm::pop<patharray *>(Stack);
#line 2658 "runtime.in"
{Stack->push<bool>(fillrule.inside(windingnumber(g,z))); return;}
}
#line 2662 "runtime.in"
// bool inside(path g, pair z, pen fillrule=CURRENTPEN);
void gen181(stack *Stack)
{
pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
pair z=vm::pop<pair>(Stack);
path g=vm::pop<path>(Stack);
#line 2663 "runtime.in"
{Stack->push<bool>(fillrule.inside(g.windingnumber(z))); return;}
}
// Determine the side of a--b that c lies on
// (negative=left, zero=on line, positive=right).
#line 2669 "runtime.in"
// real side(pair a, pair b, pair c);
void gen182(stack *Stack)
{
pair c=vm::pop<pair>(Stack);
pair b=vm::pop<pair>(Stack);
pair a=vm::pop<pair>(Stack);
#line 2670 "runtime.in"
{Stack->push<real>(orient2d(a,b,c)); return;}
}
// Determine the side of the counterclockwise circle through a,b,c that d
// lies on (negative=inside, 0=on circle, positive=right).
#line 2676 "runtime.in"
// real incircle(pair a, pair b, pair c, pair d);
void gen183(stack *Stack)
{
pair d=vm::pop<pair>(Stack);
pair c=vm::pop<pair>(Stack);
pair b=vm::pop<pair>(Stack);
pair a=vm::pop<pair>(Stack);
#line 2677 "runtime.in"
{Stack->push<real>(incircle(a.getx(),a.gety(),b.getx(),b.gety(),c.getx(),c.gety(),
d.getx(),d.gety())); return;}
}
// Path3 operations
#line 2684 "runtime.in"
// path3 path3(triplearray *pre, triplearray *point, triplearray *post, boolarray *straight, bool cyclic);
void gen184(stack *Stack)
{
bool cyclic=vm::pop<bool>(Stack);
boolarray * straight=vm::pop<boolarray *>(Stack);
triplearray * post=vm::pop<triplearray *>(Stack);
triplearray * point=vm::pop<triplearray *>(Stack);
triplearray * pre=vm::pop<triplearray *>(Stack);
#line 2686 "runtime.in"
size_t n=checkArrays(pre,point);
checkEqual(n,checkArray(post));
checkEqual(n,checkArray(straight));
mem::vector<solvedKnot3> nodes(n);
for(size_t i=0; i < n; ++i) {
nodes[i].pre=read<triple>(pre,i);
nodes[i].point=read<triple>(point,i);
nodes[i].post=read<triple>(post,i);
nodes[i].straight=read<bool>(straight,i);
}
{Stack->push<path3>(path3(nodes,(Int) n,cyclic)); return;}
}
#line 2702 "runtime.in"
void nullPath3(stack *Stack)
{
#line 2703 "runtime.in"
{Stack->push<path3>(nullpath3); return;}
}
#line 2707 "runtime.in"
// bool ==(path3 a, path3 b);
void gen186(stack *Stack)
{
path3 b=vm::pop<path3>(Stack);
path3 a=vm::pop<path3>(Stack);
#line 2708 "runtime.in"
{Stack->push<bool>(a == b); return;}
}
#line 2712 "runtime.in"
// bool !=(path3 a, path3 b);
void gen187(stack *Stack)
{
path3 b=vm::pop<path3>(Stack);
path3 a=vm::pop<path3>(Stack);
#line 2713 "runtime.in"
{Stack->push<bool>(!(a == b)); return;}
}
#line 2717 "runtime.in"
// triple point(path3 p, Int t);
void gen188(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2718 "runtime.in"
{Stack->push<triple>(p.point((Int) t)); return;}
}
#line 2722 "runtime.in"
// triple point(path3 p, real t);
void gen189(stack *Stack)
{
real t=vm::pop<real>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2723 "runtime.in"
{Stack->push<triple>(p.point(t)); return;}
}
#line 2727 "runtime.in"
// triple precontrol(path3 p, Int t);
void gen190(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2728 "runtime.in"
{Stack->push<triple>(p.precontrol((Int) t)); return;}
}
#line 2732 "runtime.in"
// triple precontrol(path3 p, real t);
void gen191(stack *Stack)
{
real t=vm::pop<real>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2733 "runtime.in"
{Stack->push<triple>(p.precontrol(t)); return;}
}
#line 2737 "runtime.in"
// triple postcontrol(path3 p, Int t);
void gen192(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2738 "runtime.in"
{Stack->push<triple>(p.postcontrol((Int) t)); return;}
}
#line 2742 "runtime.in"
// triple postcontrol(path3 p, real t);
void gen193(stack *Stack)
{
real t=vm::pop<real>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2743 "runtime.in"
{Stack->push<triple>(p.postcontrol(t)); return;}
}
#line 2747 "runtime.in"
// triple dir(path3 p, Int t, Int sign=0, bool normalize=true);
void gen194(stack *Stack)
{
bool normalize=vm::pop<bool>(Stack,true);
Int sign=vm::pop<Int>(Stack,0);
Int t=vm::pop<Int>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2748 "runtime.in"
{Stack->push<triple>(p.dir(t,sign,normalize)); return;}
}
#line 2752 "runtime.in"
// triple dir(path3 p, real t, bool normalize=true);
void gen195(stack *Stack)
{
bool normalize=vm::pop<bool>(Stack,true);
real t=vm::pop<real>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2753 "runtime.in"
{Stack->push<triple>(p.dir(t,normalize)); return;}
}
#line 2757 "runtime.in"
// triple accel(path3 p, Int t, Int sign=0);
void gen196(stack *Stack)
{
Int sign=vm::pop<Int>(Stack,0);
Int t=vm::pop<Int>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2758 "runtime.in"
{Stack->push<triple>(p.accel(t,sign)); return;}
}
#line 2762 "runtime.in"
// triple accel(path3 p, real t);
void gen197(stack *Stack)
{
real t=vm::pop<real>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2763 "runtime.in"
{Stack->push<triple>(p.accel(t)); return;}
}
#line 2767 "runtime.in"
// real radius(path3 p, real t);
void gen198(stack *Stack)
{
real t=vm::pop<real>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2768 "runtime.in"
triple v=p.dir(t,false);
triple a=p.accel(t);
real d=dot(a,v);
real v2=v.abs2();
real a2=a.abs2();
real denom=v2*a2-d*d;
real r=v2*sqrt(v2);
{Stack->push<real>(denom > 0 ? r/sqrt(denom) : 0.0); return;}
}
#line 2779 "runtime.in"
// real radius(triple z0, triple c0, triple c1, triple z1, real t);
void gen199(stack *Stack)
{
real t=vm::pop<real>(Stack);
triple z1=vm::pop<triple>(Stack);
triple c1=vm::pop<triple>(Stack);
triple c0=vm::pop<triple>(Stack);
triple z0=vm::pop<triple>(Stack);
#line 2780 "runtime.in"
triple v=(3.0*(z1-z0)+9.0*(c0-c1))*t*t+(6.0*(z0+c1)-12.0*c0)*t+3.0*(c0-z0);
triple a=6.0*(z1-z0+3.0*(c0-c1))*t+6.0*(z0+c1)-12.0*c0;
real d=dot(a,v);
real v2=v.abs2();
real a2=a.abs2();
real denom=v2*a2-d*d;
real r=v2*sqrt(v2);
{Stack->push<real>(denom > 0 ? r/sqrt(denom) : 0.0); return;}
}
#line 2791 "runtime.in"
// path3 reverse(path3 p);
void gen200(stack *Stack)
{
path3 p=vm::pop<path3>(Stack);
#line 2792 "runtime.in"
{Stack->push<path3>(p.reverse()); return;}
}
#line 2796 "runtime.in"
// path3 subpath(path3 p, Int a, Int b);
void gen201(stack *Stack)
{
Int b=vm::pop<Int>(Stack);
Int a=vm::pop<Int>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2797 "runtime.in"
{Stack->push<path3>(p.subpath((Int) a, (Int) b)); return;}
}
#line 2801 "runtime.in"
// path3 subpath(path3 p, real a, real b);
void gen202(stack *Stack)
{
real b=vm::pop<real>(Stack);
real a=vm::pop<real>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2802 "runtime.in"
{Stack->push<path3>(p.subpath(a,b)); return;}
}
#line 2806 "runtime.in"
// Int length(path3 p);
void gen203(stack *Stack)
{
path3 p=vm::pop<path3>(Stack);
#line 2807 "runtime.in"
{Stack->push<Int>(p.length()); return;}
}
#line 2811 "runtime.in"
// bool cyclic(path3 p);
void gen204(stack *Stack)
{
path3 p=vm::pop<path3>(Stack);
#line 2812 "runtime.in"
{Stack->push<bool>(p.cyclic()); return;}
}
#line 2816 "runtime.in"
// bool straight(path3 p, Int t);
void gen205(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2817 "runtime.in"
{Stack->push<bool>(p.straight(t)); return;}
}
// Return the component of vector v perpendicular to a unit vector u.
#line 2822 "runtime.in"
// triple perp(triple v, triple u);
void gen206(stack *Stack)
{
triple u=vm::pop<triple>(Stack);
triple v=vm::pop<triple>(Stack);
#line 2823 "runtime.in"
{Stack->push<triple>(v-dot(v,u)*u); return;}
}
// Return the maximum perpendicular deviation of segment i of path3 g
// from a straight line.
#line 2829 "runtime.in"
// real straightness(path3 p, Int t);
void gen207(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2830 "runtime.in"
if(p.straight(t)) {Stack->push<real>(0); return;}
triple z0=p.point(t);
triple u=unit(p.point(t+1)-z0);
{Stack->push<real>(::max(length(perp(p.postcontrol(t)-z0,u)),
length(perp(p.precontrol(t+1)-z0,u)))); return;}
}
// Return the maximum perpendicular deviation of z0..controls c0 and c1..z1
// from a straight line.
#line 2840 "runtime.in"
// real straightness(triple z0, triple c0, triple c1, triple z1);
void gen208(stack *Stack)
{
triple z1=vm::pop<triple>(Stack);
triple c1=vm::pop<triple>(Stack);
triple c0=vm::pop<triple>(Stack);
triple z0=vm::pop<triple>(Stack);
#line 2841 "runtime.in"
triple u=unit(z1-z0);
{Stack->push<real>(::max(length(perp(c0-z0,u)),length(perp(c1-z0,u)))); return;}
}
#line 2846 "runtime.in"
// bool piecewisestraight(path3 p);
void gen209(stack *Stack)
{
path3 p=vm::pop<path3>(Stack);
#line 2847 "runtime.in"
{Stack->push<bool>(p.piecewisestraight()); return;}
}
#line 2851 "runtime.in"
// real arclength(path3 p);
void gen210(stack *Stack)
{
path3 p=vm::pop<path3>(Stack);
#line 2852 "runtime.in"
{Stack->push<real>(p.arclength()); return;}
}
#line 2856 "runtime.in"
// real arctime(path3 p, real dval);
void gen211(stack *Stack)
{
real dval=vm::pop<real>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2857 "runtime.in"
{Stack->push<real>(p.arctime(dval)); return;}
}
#line 2861 "runtime.in"
// realarray* intersect(path3 p, path3 q, real fuzz=-1);
void gen212(stack *Stack)
{
real fuzz=vm::pop<real>(Stack,-1);
path3 q=vm::pop<path3>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2862 "runtime.in"
bool exact=fuzz <= 0.0;
if(fuzz < 0)
fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
::max(length(q.max()),length(q.min())));
std::vector<real> S,T;
real s,t;
if(intersections(s,t,S,T,p,q,fuzz,true,exact)) {
array *V=new array(2);
(*V)[0]=s;
(*V)[1]=t;
{Stack->push<realarray*>(V); return;}
} else
{Stack->push<realarray*>(new array(0)); return;}
}
#line 2879 "runtime.in"
// realarray2* intersections(path3 p, path3 q, real fuzz=-1);
void gen213(stack *Stack)
{
real fuzz=vm::pop<real>(Stack,-1);
path3 q=vm::pop<path3>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2880 "runtime.in"
bool exact=fuzz <= 0.0;
if(fuzz < 0)
fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
::max(length(q.max()),length(q.min())));
bool single=!exact;
real s,t;
std::vector<real> S,T;
bool found=intersections(s,t,S,T,p,q,fuzz,single,exact);
if(!found) {Stack->push<realarray2*>(new array(0)); return;}
array *V;
if(single) {
V=new array(1);
array *Vi=new array(2);
(*V)[0]=Vi;
(*Vi)[0]=s;
(*Vi)[1]=t;
} else {
size_t n=S.size();
V=new array(n);
for(size_t i=0; i < n; ++i) {
array *Vi=new array(2);
(*V)[i]=Vi;
(*Vi)[0]=S[i];
(*Vi)[1]=T[i];
}
}
stable_sort(V->begin(),V->end(),run::compare2<real>());
{Stack->push<realarray2*>(V); return;}
}
#line 2912 "runtime.in"
// realarray2* intersections(path3 p, triplearray2 *P, real fuzz=-1);
void gen214(stack *Stack)
{
real fuzz=vm::pop<real>(Stack,-1);
triplearray2 * P=vm::pop<triplearray2 *>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2913 "runtime.in"
triple *A=copyTripleArray2C(P,true,4);
if(fuzz <= 0) fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
norm(A,16));
std::vector<real> T,U,V;
intersections(T,U,V,p,A,fuzz);
delete[] A;
size_t n=T.size();
array *W=new array(n);
for(size_t i=0; i < n; ++i) {
array *Wi=new array(3);
(*W)[i]=Wi;
(*Wi)[0]=T[i];
(*Wi)[1]=U[i];
(*Wi)[2]=V[i];
}
{Stack->push<realarray2*>(W); return;} // Sorting will done in asy.
}
#line 2932 "runtime.in"
// Int size(path3 p);
void gen215(stack *Stack)
{
path3 p=vm::pop<path3>(Stack);
#line 2933 "runtime.in"
{Stack->push<Int>(p.size()); return;}
}
#line 2937 "runtime.in"
// path3 &(path3 p, path3 q);
void gen216(stack *Stack)
{
path3 q=vm::pop<path3>(Stack);
path3 p=vm::pop<path3>(Stack);
#line 2938 "runtime.in"
{Stack->push<path3>(camp::concat(p,q)); return;}
}
#line 2942 "runtime.in"
// triple min(path3 p);
void gen217(stack *Stack)
{
path3 p=vm::pop<path3>(Stack);
#line 2943 "runtime.in"
{Stack->push<triple>(p.min()); return;}
}
#line 2947 "runtime.in"
// triple max(path3 p);
void gen218(stack *Stack)
{
path3 p=vm::pop<path3>(Stack);
#line 2948 "runtime.in"
{Stack->push<triple>(p.max()); return;}
}
#line 2952 "runtime.in"
// realarray* mintimes(path3 p);
void gen219(stack *Stack)
{
path3 p=vm::pop<path3>(Stack);
#line 2953 "runtime.in"
array *V=new array(3);
triple v=p.mintimes();
(*V)[0]=v.getx();
(*V)[1]=v.gety();
(*V)[2]=v.getz();
{Stack->push<realarray*>(V); return;}
}
#line 2962 "runtime.in"
// realarray* maxtimes(path3 p);
void gen220(stack *Stack)
{
path3 p=vm::pop<path3>(Stack);
#line 2963 "runtime.in"
array *V=new array(3);
triple v=p.maxtimes();
(*V)[0]=v.getx();
(*V)[1]=v.gety();
(*V)[2]=v.getz();
{Stack->push<realarray*>(V); return;}
}
#line 2972 "runtime.in"
// path3 *(realarray2 *t, path3 g);
void gen221(stack *Stack)
{
path3 g=vm::pop<path3>(Stack);
realarray2 * t=vm::pop<realarray2 *>(Stack);
#line 2973 "runtime.in"
{Stack->push<path3>(transformed(*t,g)); return;}
}
// Guide operations
#line 2979 "runtime.in"
void nullGuide(stack *Stack)
{
#line 2980 "runtime.in"
{Stack->push<guide*>(new pathguide(path())); return;}
}
#line 2985 "runtime.in"
void dotsGuide(stack *Stack)
{
guidearray * a=vm::pop<guidearray *>(Stack);
#line 2986 "runtime.in"
guidevector v;
size_t size=checkArray(a);
for (size_t i=0; i < size; ++i)
v.push_back(a->read<guide*>(i));
{Stack->push<guide*>(new multiguide(v)); return;}
}
#line 2995 "runtime.in"
void dashesGuide(stack *Stack)
{
guidearray * a=vm::pop<guidearray *>(Stack);
#line 2996 "runtime.in"
static camp::curlSpec curly;
static specguide curlout(&curly, camp::OUT);
static specguide curlin(&curly, camp::IN);
size_t n=checkArray(a);
// a--b is equivalent to a{curl 1}..{curl 1}b
guidevector v;
if (n > 0)
v.push_back(a->read<guide*>(0));
if (n==1) {
v.push_back(&curlout);
v.push_back(&curlin);
}
else
for (size_t i=1; i<n; ++i) {
v.push_back(&curlout);
v.push_back(&curlin);
v.push_back(a->read<guide*>(i));
}
{Stack->push<guide*>(new multiguide(v)); return;}
}
#line 3022 "runtime.in"
void newCycleToken(stack *Stack)
{
#line 3023 "runtime.in"
{Stack->push<cycleToken>(cycleToken()); return;}
}
#line 3027 "runtime.in"
// guide* operator cast(cycleToken tok);
void gen226(stack *Stack)
{
cycleToken tok=vm::pop<cycleToken>(Stack);
#line 3028 "runtime.in"
// Avoid unused variable warning messages.
unused(&tok);
{Stack->push<guide*>(new cycletokguide()); return;}
}
#line 3034 "runtime.in"
// guide* operator spec(pair z, Int p);
void gen227(stack *Stack)
{
Int p=vm::pop<Int>(Stack);
pair z=vm::pop<pair>(Stack);
#line 3035 "runtime.in"
camp::side d=(camp::side) p;
camp::dirSpec *sp=new camp::dirSpec(z);
{Stack->push<guide*>(new specguide(sp,d)); return;}
}
#line 3042 "runtime.in"
// curlSpecifier operator curl(real gamma, Int p);
void gen228(stack *Stack)
{
Int p=vm::pop<Int>(Stack);
real gamma=vm::pop<real>(Stack);
#line 3043 "runtime.in"
camp::side s=(camp::side) p;
{Stack->push<curlSpecifier>(curlSpecifier(gamma,s)); return;}
}
#line 3048 "runtime.in"
void curlSpecifierValuePart(stack *Stack)
{
curlSpecifier spec=vm::pop<curlSpecifier>(Stack);
#line 3049 "runtime.in"
{Stack->push<real>(spec.getValue()); return;}
}
#line 3053 "runtime.in"
void curlSpecifierSidePart(stack *Stack)
{
curlSpecifier spec=vm::pop<curlSpecifier>(Stack);
#line 3054 "runtime.in"
{Stack->push<Int>(spec.getSide()); return;}
}
#line 3058 "runtime.in"
// guide* operator cast(curlSpecifier spec);
void gen231(stack *Stack)
{
curlSpecifier spec=vm::pop<curlSpecifier>(Stack);
#line 3059 "runtime.in"
{Stack->push<guide*>(new specguide(spec)); return;}
}
#line 3063 "runtime.in"
// tensionSpecifier operator tension(real tout, real tin, bool atleast);
void gen232(stack *Stack)
{
bool atleast=vm::pop<bool>(Stack);
real tin=vm::pop<real>(Stack);
real tout=vm::pop<real>(Stack);
#line 3064 "runtime.in"
{Stack->push<tensionSpecifier>(tensionSpecifier(tout, tin, atleast)); return;}
}
#line 3068 "runtime.in"
void tensionSpecifierOutPart(stack *Stack)
{
tensionSpecifier t=vm::pop<tensionSpecifier>(Stack);
#line 3069 "runtime.in"
{Stack->push<real>(t.getOut()); return;}
}
#line 3073 "runtime.in"
void tensionSpecifierInPart(stack *Stack)
{
tensionSpecifier t=vm::pop<tensionSpecifier>(Stack);
#line 3074 "runtime.in"
{Stack->push<real>(t.getIn()); return;}
}
#line 3078 "runtime.in"
void tensionSpecifierAtleastPart(stack *Stack)
{
tensionSpecifier t=vm::pop<tensionSpecifier>(Stack);
#line 3079 "runtime.in"
{Stack->push<bool>(t.getAtleast()); return;}
}
#line 3083 "runtime.in"
// guide* operator cast(tensionSpecifier t);
void gen236(stack *Stack)
{
tensionSpecifier t=vm::pop<tensionSpecifier>(Stack);
#line 3084 "runtime.in"
{Stack->push<guide*>(new tensionguide(t)); return;}
}
#line 3088 "runtime.in"
// guide* operator controls(pair zout, pair zin);
void gen237(stack *Stack)
{
pair zin=vm::pop<pair>(Stack);
pair zout=vm::pop<pair>(Stack);
#line 3089 "runtime.in"
{Stack->push<guide*>(new controlguide(zout, zin)); return;}
}
#line 3093 "runtime.in"
// Int size(guide *g);
void gen238(stack *Stack)
{
guide * g=vm::pop<guide *>(Stack);
#line 3094 "runtime.in"
flatguide f;
g->flatten(f,false);
{Stack->push<Int>(f.size()); return;}
}
#line 3100 "runtime.in"
// Int length(guide *g);
void gen239(stack *Stack)
{
guide * g=vm::pop<guide *>(Stack);
#line 3101 "runtime.in"
flatguide f;
g->flatten(f,false);
{Stack->push<Int>(g->cyclic() ? f.size() : f.size()-1); return;}
}
#line 3107 "runtime.in"
// bool cyclic(guide *g);
void gen240(stack *Stack)
{
guide * g=vm::pop<guide *>(Stack);
#line 3108 "runtime.in"
flatguide f;
g->flatten(f,false);
{Stack->push<bool>(g->cyclic()); return;}
}
#line 3114 "runtime.in"
// pair point(guide *g, Int t);
void gen241(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
guide * g=vm::pop<guide *>(Stack);
#line 3115 "runtime.in"
flatguide f;
g->flatten(f,false);
{Stack->push<pair>(f.Nodes(adjustedIndex(t,f.size(),g->cyclic())).z); return;}
}
#line 3121 "runtime.in"
// pairarray* dirSpecifier(guide *g, Int t);
void gen242(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
guide * g=vm::pop<guide *>(Stack);
#line 3122 "runtime.in"
flatguide f;
g->flatten(f,false);
Int n=f.size();
if(!g->cyclic() && (t < 0 || t >= n-1)) {Stack->push<pairarray*>(new array(0)); return;}
array *c=new array(2);
(*c)[0]=f.Nodes(t).out->dir();
(*c)[1]=f.Nodes(t+1).in->dir();
{Stack->push<pairarray*>(c); return;}
}
#line 3133 "runtime.in"
// pairarray* controlSpecifier(guide *g, Int t);
void gen243(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
guide * g=vm::pop<guide *>(Stack);
#line 3134 "runtime.in"
flatguide f;
g->flatten(f,false);
Int n=f.size();
if(!g->cyclic() && (t < 0 || t >= n-1)) {Stack->push<pairarray*>(new array(0)); return;}
knot curr=f.Nodes(t);
knot next=f.Nodes(t+1);
if(curr.out->controlled()) {
assert(next.in->controlled());
array *c=new array(2);
(*c)[0]=curr.out->control();
(*c)[1]=next.in->control();
{Stack->push<pairarray*>(c); return;}
} else {Stack->push<pairarray*>(new array(0)); return;}
}
#line 3150 "runtime.in"
// tensionSpecifier tensionSpecifier(guide *g, Int t);
void gen244(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
guide * g=vm::pop<guide *>(Stack);
#line 3151 "runtime.in"
flatguide f;
g->flatten(f,false);
Int n=f.size();
if(!g->cyclic() && (t < 0 || t >= n-1)) {Stack->push<tensionSpecifier>(tensionSpecifier(1.0,1.0,false)); return;}
knot curr=f.Nodes(t);
{Stack->push<tensionSpecifier>(tensionSpecifier(curr.tout.val,f.Nodes(t+1).tin.val,curr.tout.atleast)); return;}
}
#line 3160 "runtime.in"
// realarray* curlSpecifier(guide *g, Int t);
void gen245(stack *Stack)
{
Int t=vm::pop<Int>(Stack);
guide * g=vm::pop<guide *>(Stack);
#line 3161 "runtime.in"
flatguide f;
g->flatten(f,false);
Int n=f.size();
if(!g->cyclic() && (t < 0 || t >= n-1)) {Stack->push<realarray*>(new array(0)); return;}
array *c=new array(2);
real c0=f.Nodes(t).out->curl();
real c1=f.Nodes(t+1).in->curl();
(*c)[0]=c0 >= 0.0 ? c0 : 1.0;
(*c)[1]=c1 >= 0.0 ? c1 : 1.0;
{Stack->push<realarray*>(c); return;}
}
#line 3174 "runtime.in"
// guide* reverse(guide *g);
void gen246(stack *Stack)
{
guide * g=vm::pop<guide *>(Stack);
#line 3175 "runtime.in"
flatguide f;
g->flatten(f,false);
if(f.precyclic())
{Stack->push<guide*>(new pathguide(g->solve().reverse())); return;}
size_t n=f.size();
bool cyclic=g->cyclic();
guidevector v;
if(n >= 0) {
size_t start=cyclic ? n : n-1;
knot curr=f.Nodes(start);
knot next;
for(size_t i=start; i > 0; --i) {
next=f.Nodes(i-1);
v.push_back(new pairguide(curr.z));
if(next.out->controlled()) {
assert(curr.in->controlled());
v.push_back(new controlguide(curr.in->control(),next.out->control()));
} else {
pair d=curr.in->dir();
if(d != zero)
v.push_back(new specguide(new dirSpec(-d),camp::OUT));
else {
real C=curr.in->curl();
if(C >= 0.0)
v.push_back(new specguide(new curlSpec(C),camp::OUT));
}
real tout=curr.tin.val;
real tin=next.tout.val;
bool atleast=next.tout.atleast;
if(tout != 1.0 || tin != 1.0 || next.tout.atleast)
v.push_back(new tensionguide(tensionSpecifier(tout,tin,atleast)));
d=next.out->dir();
if(d != zero)
v.push_back(new specguide(new dirSpec(-d),camp::IN));
else {
real C=next.out->curl();
if(C >= 0.0)
v.push_back(new specguide(new curlSpec(C),camp::IN));
}
}
curr=next;
}
if(cyclic)
v.push_back(new cycletokguide());
else
v.push_back(new pairguide(next.z));
}
{Stack->push<guide*>(new multiguide(v)); return;}
}
// Three-dimensional picture and surface operations
#line 3230 "runtime.in"
// void _draw(picture *f, path3 g, pen p);
void gen247(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
path3 g=vm::pop<path3>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 3231 "runtime.in"
if(g.size() > 0)
f->append(new drawPath3(g,p));
}
#line 3237 "runtime.in"
// void draw(picture *f, triplearray2 *g, bool straight, penarray *p, real opacity, real shininess, real granularity, triple normal, bool lighton, penarray *colors);
void gen248(stack *Stack)
{
penarray * colors=vm::pop<penarray *>(Stack);
bool lighton=vm::pop<bool>(Stack);
triple normal=vm::pop<triple>(Stack);
real granularity=vm::pop<real>(Stack);
real shininess=vm::pop<real>(Stack);
real opacity=vm::pop<real>(Stack);
penarray * p=vm::pop<penarray *>(Stack);
bool straight=vm::pop<bool>(Stack);
triplearray2 * g=vm::pop<triplearray2 *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 3240 "runtime.in"
f->append(new drawSurface(*g,straight,*p,opacity,shininess,granularity,
normal,lighton,*colors));
}
#line 3245 "runtime.in"
// triple min3(picture *f);
void gen249(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 3246 "runtime.in"
{Stack->push<triple>(f->bounds3().Min()); return;}
}
#line 3250 "runtime.in"
// triple max3(picture *f);
void gen250(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 3251 "runtime.in"
{Stack->push<triple>(f->bounds3().Max()); return;}
}
#line 3255 "runtime.in"
// pair min(picture *f, realarray2 *t);
void gen251(stack *Stack)
{
realarray2 * t=vm::pop<realarray2 *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 3256 "runtime.in"
real *T=copyArray2C(t,4);
pair m=f->bounds(::min,xproject,yproject,T);
delete[] T;
{Stack->push<pair>(m); return;}
}
#line 3263 "runtime.in"
// pair max(picture *f, realarray2 *t);
void gen252(stack *Stack)
{
realarray2 * t=vm::pop<realarray2 *>(Stack);
picture * f=vm::pop<picture *>(Stack);
#line 3264 "runtime.in"
real *T=copyArray2C(t,4);
pair M=f->bounds(::max,xproject,yproject,T);
delete[] T;
{Stack->push<pair>(M); return;}
}
#line 3271 "runtime.in"
// pair minratio(picture *f);
void gen253(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 3272 "runtime.in"
{Stack->push<pair>(f->bounds(::min,xratio,yratio)); return;}
}
#line 3276 "runtime.in"
// pair maxratio(picture *f);
void gen254(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 3277 "runtime.in"
{Stack->push<pair>(f->bounds(::max,xratio,yratio)); return;}
}
#line 3281 "runtime.in"
// triple minbound(triplearray2 *P, triple b);
void gen255(stack *Stack)
{
triple b=vm::pop<triple>(Stack);
triplearray2 * P=vm::pop<triplearray2 *>(Stack);
#line 3282 "runtime.in"
real *A=copyTripleArray2Components(P,true,4);
b=triple(bound(A,::min,b.getx(),sqrtFuzz*norm(A,16)),
bound(A+16,::min,b.gety(),sqrtFuzz*norm(A+16,16)),
bound(A+32,::min,b.getz(),sqrtFuzz*norm(A+32,16)));
delete[] A;
{Stack->push<triple>(b); return;}
}
#line 3291 "runtime.in"
// triple maxbound(triplearray2 *P, triple b);
void gen256(stack *Stack)
{
triple b=vm::pop<triple>(Stack);
triplearray2 * P=vm::pop<triplearray2 *>(Stack);
#line 3292 "runtime.in"
real *A=copyTripleArray2Components(P,true,4);
b=triple(bound(A,::max,b.getx(),sqrtFuzz*norm(A,16)),
bound(A+16,::max,b.gety(),sqrtFuzz*norm(A+16,16)),
bound(A+32,::max,b.getz(),sqrtFuzz*norm(A+32,16)));
delete[] A;
{Stack->push<triple>(b); return;}
}
#line 3301 "runtime.in"
// pair minbound(triplearray2 *P, realarray2 *t, pair b);
void gen257(stack *Stack)
{
pair b=vm::pop<pair>(Stack);
realarray2 * t=vm::pop<realarray2 *>(Stack);
triplearray2 * P=vm::pop<triplearray2 *>(Stack);
#line 3302 "runtime.in"
triple *A=copyTripleArray2C(P,true,4);
real *T=copyArray2C(t,4);
real fuzz=sqrtFuzz*norm(A,16);
b=pair(bound(A,::min,xproject,T,b.getx(),fuzz),
bound(A,::min,yproject,T,b.gety(),fuzz));
delete[] T;
delete[] A;
{Stack->push<pair>(b); return;}
}
#line 3313 "runtime.in"
// pair maxbound(triplearray2 *P, realarray2 *t, pair b);
void gen258(stack *Stack)
{
pair b=vm::pop<pair>(Stack);
realarray2 * t=vm::pop<realarray2 *>(Stack);
triplearray2 * P=vm::pop<triplearray2 *>(Stack);
#line 3314 "runtime.in"
triple *A=copyTripleArray2C(P,true,4);
real *T=copyArray2C(t,4);
real fuzz=sqrtFuzz*norm(A,16);
b=pair(bound(A,::max,xproject,T,b.getx(),fuzz),
bound(A,::max,yproject,T,b.gety(),fuzz));
delete[] T;
delete[] A;
{Stack->push<pair>(b); return;}
}
#line 3325 "runtime.in"
// pair max(path3 g, realarray2 *t);
void gen259(stack *Stack)
{
realarray2 * t=vm::pop<realarray2 *>(Stack);
path3 g=vm::pop<path3>(Stack);
#line 3326 "runtime.in"
real *T=copyArray2C(t,4);
pair b=g.bounds(::max,xproject,yproject,T);
delete[] T;
{Stack->push<pair>(b); return;}
}
#line 3333 "runtime.in"
// pair min(path3 g, realarray2 *t);
void gen260(stack *Stack)
{
realarray2 * t=vm::pop<realarray2 *>(Stack);
path3 g=vm::pop<path3>(Stack);
#line 3334 "runtime.in"
real *T=copyArray2C(t,4);
pair b=g.bounds(::min,xproject,yproject,T);
delete[] T;
{Stack->push<pair>(b); return;}
}
#line 3341 "runtime.in"
// real change2(triplearray2 *a);
void gen261(stack *Stack)
{
triplearray2 * a=vm::pop<triplearray2 *>(Stack);
#line 3342 "runtime.in"
size_t n=checkArray(a);
if(n == 0) {Stack->push<real>(0.0); return;}
vm::array *a0=vm::read<vm::array*>(a,0);
size_t m=checkArray(a0);
if(m == 0) {Stack->push<real>(0.0); return;}
triple a00=vm::read<triple>(a0,0);
real M=0.0;
for(size_t i=0; i < n; ++i) {
vm::array *ai=vm::read<vm::array*>(a,i);
size_t m=checkArray(ai);
for(size_t j=0; j < m; ++j) {
real a=(vm::read<triple>(ai,j)-a00).abs2();
if(a > M) M=a;
}
}
{Stack->push<real>(M); return;}
}
#line 3363 "runtime.in"
// bool is3D(picture *f);
void gen262(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
#line 3364 "runtime.in"
{Stack->push<bool>(f->have3D()); return;}
}
#line 3368 "runtime.in"
// pair bezier(pair a, pair b, pair c, pair d, real t);
void gen263(stack *Stack)
{
real t=vm::pop<real>(Stack);
pair d=vm::pop<pair>(Stack);
pair c=vm::pop<pair>(Stack);
pair b=vm::pop<pair>(Stack);
pair a=vm::pop<pair>(Stack);
#line 3369 "runtime.in"
real onemt=1-t;
real onemt2=onemt*onemt;
{Stack->push<pair>(onemt2*onemt*a+t*(3.0*(onemt2*b+t*onemt*c)+t*t*d)); return;}
}
#line 3375 "runtime.in"
// pair bezierP(pair a, pair b, pair c, pair d, real t);
void gen264(stack *Stack)
{
real t=vm::pop<real>(Stack);
pair d=vm::pop<pair>(Stack);
pair c=vm::pop<pair>(Stack);
pair b=vm::pop<pair>(Stack);
pair a=vm::pop<pair>(Stack);
#line 3376 "runtime.in"
{Stack->push<pair>(3.0*(t*t*(d-a+3.0*(b-c))+t*(2.0*(a+c)-4.0*b)+b-a)); return;}
}
#line 3380 "runtime.in"
// pair bezierPP(pair a, pair b, pair c, pair d, real t);
void gen265(stack *Stack)
{
real t=vm::pop<real>(Stack);
pair d=vm::pop<pair>(Stack);
pair c=vm::pop<pair>(Stack);
pair b=vm::pop<pair>(Stack);
pair a=vm::pop<pair>(Stack);
#line 3381 "runtime.in"
{Stack->push<pair>(6.0*(t*(d-a+3.0*(b-c))+a+c-2.0*b)); return;}
}
#line 3385 "runtime.in"
// pair bezierPPP(pair a, pair b, pair c, pair d);
void gen266(stack *Stack)
{
pair d=vm::pop<pair>(Stack);
pair c=vm::pop<pair>(Stack);
pair b=vm::pop<pair>(Stack);
pair a=vm::pop<pair>(Stack);
#line 3386 "runtime.in"
{Stack->push<pair>(6.0*(d-a+3.0*(b-c))); return;}
}
#line 3390 "runtime.in"
// triple bezier(triple a, triple b, triple c, triple d, real t);
void gen267(stack *Stack)
{
real t=vm::pop<real>(Stack);
triple d=vm::pop<triple>(Stack);
triple c=vm::pop<triple>(Stack);
triple b=vm::pop<triple>(Stack);
triple a=vm::pop<triple>(Stack);
#line 3391 "runtime.in"
real onemt=1-t;
real onemt2=onemt*onemt;
{Stack->push<triple>(onemt2*onemt*a+t*(3.0*(onemt2*b+t*onemt*c)+t*t*d)); return;}
}
#line 3397 "runtime.in"
// triple bezierP(triple a, triple b, triple c, triple d, real t);
void gen268(stack *Stack)
{
real t=vm::pop<real>(Stack);
triple d=vm::pop<triple>(Stack);
triple c=vm::pop<triple>(Stack);
triple b=vm::pop<triple>(Stack);
triple a=vm::pop<triple>(Stack);
#line 3398 "runtime.in"
{Stack->push<triple>(3.0*(t*t*(d-a+3.0*(b-c))+t*(2.0*(a+c)-4.0*b)+b-a)); return;}
}
#line 3402 "runtime.in"
// triple bezierPP(triple a, triple b, triple c, triple d, real t);
void gen269(stack *Stack)
{
real t=vm::pop<real>(Stack);
triple d=vm::pop<triple>(Stack);
triple c=vm::pop<triple>(Stack);
triple b=vm::pop<triple>(Stack);
triple a=vm::pop<triple>(Stack);
#line 3403 "runtime.in"
{Stack->push<triple>(6.0*(t*(d-a+3.0*(b-c))+a+c-2.0*b)); return;}
}
#line 3407 "runtime.in"
// triple bezierPPP(triple a, triple b, triple c, triple d);
void gen270(stack *Stack)
{
triple d=vm::pop<triple>(Stack);
triple c=vm::pop<triple>(Stack);
triple b=vm::pop<triple>(Stack);
triple a=vm::pop<triple>(Stack);
#line 3408 "runtime.in"
{Stack->push<triple>(6.0*(d-a+3.0*(b-c))); return;}
}
// String operations
#line 3414 "runtime.in"
void emptyString(stack *Stack)
{
#line 3415 "runtime.in"
{Stack->push<string>(emptystring); return;}
}
#line 3420 "runtime.in"
// Int length(string *s);
void gen272(stack *Stack)
{
string * s=vm::pop<string *>(Stack);
#line 3421 "runtime.in"
{Stack->push<Int>((Int) s->length()); return;}
}
#line 3425 "runtime.in"
// Int find(string *s, string t, Int pos=0);
void gen273(stack *Stack)
{
Int pos=vm::pop<Int>(Stack,0);
string t=vm::pop<string>(Stack);
string * s=vm::pop<string *>(Stack);
#line 3426 "runtime.in"
size_t n=s->find(t,pos);
{Stack->push<Int>(n == string::npos ? (Int) -1 : (Int) n); return;}
}
#line 3431 "runtime.in"
// Int rfind(string *s, string t, Int pos=-1);
void gen274(stack *Stack)
{
Int pos=vm::pop<Int>(Stack,-1);
string t=vm::pop<string>(Stack);
string * s=vm::pop<string *>(Stack);
#line 3432 "runtime.in"
size_t n=s->rfind(t,pos);
{Stack->push<Int>(n == string::npos ? (Int) -1 : (Int) n); return;}
}
#line 3437 "runtime.in"
// string reverse(string s);
void gen275(stack *Stack)
{
string s=vm::pop<string>(Stack);
#line 3438 "runtime.in"
reverse(s.begin(),s.end());
{Stack->push<string>(s); return;}
}
#line 3443 "runtime.in"
// string insert(string s, Int pos, string t);
void gen276(stack *Stack)
{
string t=vm::pop<string>(Stack);
Int pos=vm::pop<Int>(Stack);
string s=vm::pop<string>(Stack);
#line 3444 "runtime.in"
if ((size_t) pos < s.length())
{Stack->push<string>(s.insert(pos,t)); return;}
{Stack->push<string>(s); return;}
}
#line 3450 "runtime.in"
// string substr(string* s, Int pos, Int n=-1);
void gen277(stack *Stack)
{
Int n=vm::pop<Int>(Stack,-1);
Int pos=vm::pop<Int>(Stack);
string* s=vm::pop<string*>(Stack);
#line 3451 "runtime.in"
if ((size_t) pos < s->length())
{Stack->push<string>(s->substr(pos,n)); return;}
{Stack->push<string>(emptystring); return;}
}
#line 3457 "runtime.in"
// string erase(string s, Int pos, Int n);
void gen278(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
Int pos=vm::pop<Int>(Stack);
string s=vm::pop<string>(Stack);
#line 3458 "runtime.in"
if ((size_t) pos < s.length())
{Stack->push<string>(s.erase(pos,n)); return;}
{Stack->push<string>(s); return;}
}
#line 3464 "runtime.in"
// string downcase(string s);
void gen279(stack *Stack)
{
string s=vm::pop<string>(Stack);
#line 3465 "runtime.in"
std::transform(s.begin(),s.end(),s.begin(),tolower);
{Stack->push<string>(s); return;}
}
#line 3470 "runtime.in"
// string upcase(string s);
void gen280(stack *Stack)
{
string s=vm::pop<string>(Stack);
#line 3471 "runtime.in"
std::transform(s.begin(),s.end(),s.begin(),toupper);
{Stack->push<string>(s); return;}
}
// returns a string constructed by translating all occurrences of the string
// from in an array of string pairs {from,to} to the string to in string s.
#line 3478 "runtime.in"
// string replace(string *S, stringarray2 *translate);
void gen281(stack *Stack)
{
stringarray2 * translate=vm::pop<stringarray2 *>(Stack);
string * S=vm::pop<string *>(Stack);
#line 3479 "runtime.in"
size_t size=checkArray(translate);
for(size_t i=0; i < size; i++) {
array *a=read<array*>(translate,i);
checkArray(a);
}
const char *p=S->c_str();
ostringstream buf;
while(*p) {
for(size_t i=0; i < size;) {
array *a=read<array*>(translate,i);
string* from=read<string*>(a,0);
size_t len=from->length();
if(strncmp(p,from->c_str(),len) != 0) {i++; continue;}
buf << read<string>(a,1);
p += len;
if(*p == 0) {Stack->push<string>(buf.str()); return;}
i=0;
}
buf << *(p++);
}
{Stack->push<string>(buf.str()); return;}
}
#line 3503 "runtime.in"
// string format(string *format, Int x);
void gen282(stack *Stack)
{
Int x=vm::pop<Int>(Stack);
string * format=vm::pop<string *>(Stack);
#line 3504 "runtime.in"
const char *f=format->c_str();
checkformat(f,true);
Int size=snprintf(NULL,0,f,x)+1;
if(size < 1) size=255; // Workaround for non-C99 compliant systems.
char *buf=new char[size];
snprintf(buf,size,f,x);
string s=string(buf);
delete[] buf;
{Stack->push<string>(s); return;}
}
#line 3518 "runtime.in"
// string format(string *format, real x, string locale=emptystring);
void gen283(stack *Stack)
{
string locale=vm::pop<string>(Stack,emptystring);
real x=vm::pop<real>(Stack);
string * format=vm::pop<string *>(Stack);
#line 3519 "runtime.in"
bool tex=getSetting<string>("tex") != "none";
bool texify=false;
ostringstream out;
checkformat(format->c_str(),false);
const char *phantom="\\phantom{+}";
const char *p0=format->c_str();
const char *p=p0;
const char *start=NULL;
char prev=0;
while(*p != 0) {
char curr=*p;
if(tex && curr == '$' && prev != '\\') texify=true;
prev=curr;
if(curr == '%') {
p++;
if(*p != '%') {start=p-1; break;}
}
out << *(p++);
}
if(!start) {Stack->push<string>(out.str()); return;}
// Allow at most 1 argument
while(*p != 0) {
if(*p == '*' || *p == '$') {Stack->push<string>(out.str()); return;}
if(isupper(*p) || islower(*p)) {p++; break;}
p++;
}
const char *tail=p;
string f=format->substr(start-p0,tail-start);
const char *oldlocale=NULL;
if(!locale.empty()) {
oldlocale=setlocale(LC_ALL,NULL);
if(oldlocale) oldlocale=StrdupNoGC(oldlocale);
setlocale(LC_ALL,locale.c_str());
}
Int size=snprintf(NULL,0,f.c_str(),x)+1;
if(size < 1) size=255; // Workaround for non-C99 compliant systems.
char *buf=new char[size];
snprintf(buf,size,f.c_str(),x);
if(oldlocale) {
setlocale(LC_ALL,oldlocale);
delete[] oldlocale;
}
bool trailingzero=f.find("#") < string::npos;
bool plus=f.find("+") < string::npos;
bool space=f.find(" ") < string::npos;
char *q=buf; // beginning of formatted number
if(*q == ' ') {
out << phantom;
q++;
}
const char decimal=*(localeconv()->decimal_point);
// Remove any spurious sign
if(*q == '-' || *q == '+') {
p=q+1;
bool zero=true;
while(*p != 0) {
if(!isdigit(*p) && *p != decimal) break;
if(isdigit(*p) && *p != '0') {zero=false; break;}
p++;
}
if(zero) {
q++;
if(plus || space) out << phantom;
}
}
const char *r=p=q;
bool dp=false;
while(*r != 0 && (isdigit(*r) || *r == decimal || *r == '+' || *r == '-')) {
if(*r == decimal) dp=true;
r++;
}
if(dp) { // Remove trailing zeros and/or decimal point
r--;
unsigned n=0;
while(r > q && *r == '0') {r--; n++;}
if(*r == decimal) {r--; n++;}
while(q <= r) out << *(q++);
if(!trailingzero) q += n;
}
bool zero=(r == p && *r == '0') && !trailingzero;
// Translate "E+/E-/e+/e-" exponential notation to TeX
while(*q != 0) {
if(texify && (*q == 'E' || *q == 'e') &&
(*(q+1) == '+' || *(q+1) == '-')) {
if(!zero) out << "\\!\\times\\!10^{";
bool plus=(*(q+1) == '+');
q++;
if(plus) q++;
if(*q == '-') out << *(q++);
while(*q == '0' && (zero || isdigit(*(q+1)))) q++;
while(isdigit(*q)) out << *(q++);
if(!zero)
out << "}";
break;
}
out << *(q++);
}
while(*tail != 0)
out << *(tail++);
delete[] buf;
{Stack->push<string>(out.str()); return;}
}
#line 3643 "runtime.in"
// Int hex(string s);
void gen284(stack *Stack)
{
string s=vm::pop<string>(Stack);
#line 3644 "runtime.in"
istringstream is(s);
is.setf(std::ios::hex,std::ios::basefield);
Int value;
if(is && is >> value && ((is >> std::ws).eof())) {Stack->push<Int>(value); return;}
ostringstream buf;
buf << "invalid hexidecimal cast from string \"" << s << "\"";
error(buf);
}
#line 3654 "runtime.in"
// string string(Int x);
void gen285(stack *Stack)
{
Int x=vm::pop<Int>(Stack);
#line 3655 "runtime.in"
ostringstream buf;
buf << x;
{Stack->push<string>(buf.str()); return;}
}
#line 3661 "runtime.in"
// string string(real x, Int digits=DBL_DIG);
void gen286(stack *Stack)
{
Int digits=vm::pop<Int>(Stack,DBL_DIG);
real x=vm::pop<real>(Stack);
#line 3662 "runtime.in"
ostringstream buf;
buf.precision(digits);
buf << x;
{Stack->push<string>(buf.str()); return;}
}
#line 3669 "runtime.in"
// string time(string format=defaulttimeformat);
void gen287(stack *Stack)
{
string format=vm::pop<string>(Stack,defaulttimeformat);
#line 3670 "runtime.in"
#ifdef HAVE_STRFTIME
const time_t bintime=time(NULL);
if(!strftime(Time,nTime,format.c_str(),localtime(&bintime))) {Stack->push<string>(""); return;}
{Stack->push<string>(Time); return;}
#else
{Stack->push<string>(format); return;}
#endif
}
#line 3680 "runtime.in"
// string time(Int seconds, string format=defaulttimeformat);
void gen288(stack *Stack)
{
string format=vm::pop<string>(Stack,defaulttimeformat);
Int seconds=vm::pop<Int>(Stack);
#line 3681 "runtime.in"
#ifdef HAVE_STRFTIME
const time_t bintime=seconds;
if(!strftime(Time,nTime,format.c_str(),localtime(&bintime))) {Stack->push<string>(""); return;}
{Stack->push<string>(Time); return;}
#else
// Avoid unused variable warning messages
unused(&seconds);
{Stack->push<string>(format); return;}
#endif
}
#line 3693 "runtime.in"
// Int seconds(string t=emptystring, string format=emptystring);
void gen289(stack *Stack)
{
string format=vm::pop<string>(Stack,emptystring);
string t=vm::pop<string>(Stack,emptystring);
#line 3694 "runtime.in"
#if defined(HAVE_STRPTIME)
const time_t bintime=time(NULL);
tm tm=*localtime(&bintime);
if(t != "" && !strptime(t.c_str(),format.c_str(),&tm)) {Stack->push<Int>(-1); return;}
{Stack->push<Int>((Int) mktime(&tm)); return;}
#else
{Stack->push<Int>(-1); return;}
#endif
}
#line 3705 "runtime.in"
// realarray* _cputime();
void gen290(stack *Stack)
{
#line 3706 "runtime.in"
static const real ticktime=1.0/sysconf(_SC_CLK_TCK);
struct tms buf;
::times(&buf);
array *t=new array(4);
(*t)[0] = ((real) buf.tms_utime)*ticktime;
(*t)[1] = ((real) buf.tms_stime)*ticktime;
(*t)[2] = ((real) buf.tms_cutime)*ticktime;
(*t)[3] = ((real) buf.tms_cstime)*ticktime;
{Stack->push<realarray*>(t); return;}
}
// Math
#line 3721 "runtime.in"
// real ^(real x, Int y);
void gen291(stack *Stack)
{
Int y=vm::pop<Int>(Stack);
real x=vm::pop<real>(Stack);
#line 3722 "runtime.in"
{Stack->push<real>(pow(x,y)); return;}
}
#line 3727 "runtime.in"
// pair ^(pair z, Int y);
void gen292(stack *Stack)
{
Int y=vm::pop<Int>(Stack);
pair z=vm::pop<pair>(Stack);
#line 3728 "runtime.in"
{Stack->push<pair>(pow(z,y)); return;}
}
#line 3732 "runtime.in"
// Int quotient(Int x, Int y);
void gen293(stack *Stack)
{
Int y=vm::pop<Int>(Stack);
Int x=vm::pop<Int>(Stack);
#line 3733 "runtime.in"
if(y == 0) dividebyzero();
if(y == -1) {Stack->push<Int>(Negate(x)); return;}
// Implementation-independent definition of integer division: round down
{Stack->push<Int>((x-portableMod(x,y))/y); return;}
}
#line 3740 "runtime.in"
// Int abs(Int x);
void gen294(stack *Stack)
{
Int x=vm::pop<Int>(Stack);
#line 3741 "runtime.in"
{Stack->push<Int>(Abs(x)); return;}
}
#line 3745 "runtime.in"
// Int sgn(real x);
void gen295(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 3746 "runtime.in"
{Stack->push<Int>(sgn(x)); return;}
}
#line 3750 "runtime.in"
// Int rand();
void gen296(stack *Stack)
{
#line 3751 "runtime.in"
{Stack->push<Int>(rand()); return;}
}
#line 3755 "runtime.in"
// void srand(Int seed);
void gen297(stack *Stack)
{
Int seed=vm::pop<Int>(Stack);
#line 3756 "runtime.in"
srand(intcast(seed));
}
// a random number uniformly distributed in the interval [0,1]
#line 3761 "runtime.in"
// real unitrand();
void gen298(stack *Stack)
{
#line 3762 "runtime.in"
{Stack->push<real>(((real) rand())/RAND_MAX); return;}
}
#line 3766 "runtime.in"
// Int ceil(real x);
void gen299(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 3767 "runtime.in"
{Stack->push<Int>(Intcast(ceil(x))); return;}
}
#line 3771 "runtime.in"
// Int floor(real x);
void gen300(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 3772 "runtime.in"
{Stack->push<Int>(Intcast(floor(x))); return;}
}
#line 3776 "runtime.in"
// Int round(real x);
void gen301(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 3777 "runtime.in"
if(validInt(x)) {Stack->push<Int>(Round(x)); return;}
integeroverflow(0);
}
#line 3782 "runtime.in"
// Int Ceil(real x);
void gen302(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 3783 "runtime.in"
{Stack->push<Int>(Ceil(x)); return;}
}
#line 3787 "runtime.in"
// Int Floor(real x);
void gen303(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 3788 "runtime.in"
{Stack->push<Int>(Floor(x)); return;}
}
#line 3792 "runtime.in"
// Int Round(real x);
void gen304(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 3793 "runtime.in"
{Stack->push<Int>(Round(Intcap(x))); return;}
}
#line 3797 "runtime.in"
// real fmod(real x, real y);
void gen305(stack *Stack)
{
real y=vm::pop<real>(Stack);
real x=vm::pop<real>(Stack);
#line 3798 "runtime.in"
if (y == 0.0) dividebyzero();
{Stack->push<real>(fmod(x,y)); return;}
}
#line 3803 "runtime.in"
// real atan2(real y, real x);
void gen306(stack *Stack)
{
real x=vm::pop<real>(Stack);
real y=vm::pop<real>(Stack);
#line 3804 "runtime.in"
{Stack->push<real>(atan2(y,x)); return;}
}
#line 3808 "runtime.in"
// real hypot(real x, real y);
void gen307(stack *Stack)
{
real y=vm::pop<real>(Stack);
real x=vm::pop<real>(Stack);
#line 3809 "runtime.in"
{Stack->push<real>(hypot(x,y)); return;}
}
#line 3813 "runtime.in"
// real remainder(real x, real y);
void gen308(stack *Stack)
{
real y=vm::pop<real>(Stack);
real x=vm::pop<real>(Stack);
#line 3814 "runtime.in"
{Stack->push<real>(remainder(x,y)); return;}
}
#line 3818 "runtime.in"
// real J(Int n, real x);
void gen309(stack *Stack)
{
real x=vm::pop<real>(Stack);
Int n=vm::pop<Int>(Stack);
#line 3819 "runtime.in"
{Stack->push<real>(jn(n,x)); return;}
}
#line 3823 "runtime.in"
// real Y(Int n, real x);
void gen310(stack *Stack)
{
real x=vm::pop<real>(Stack);
Int n=vm::pop<Int>(Stack);
#line 3824 "runtime.in"
{Stack->push<real>(yn(n,x)); return;}
}
#line 3828 "runtime.in"
// real erf(real x);
void gen311(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 3829 "runtime.in"
{Stack->push<real>(erf(x)); return;}
}
#line 3833 "runtime.in"
// real erfc(real x);
void gen312(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 3834 "runtime.in"
{Stack->push<real>(erfc(x)); return;}
}
#line 3838 "runtime.in"
// Int factorial(Int n);
void gen313(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
#line 3839 "runtime.in"
if(n < 0) error(invalidargument);
{Stack->push<Int>(factorial(n)); return;}
}
#line 3843 "runtime.in"
// Int choose(Int n, Int k);
void gen314(stack *Stack)
{
Int k=vm::pop<Int>(Stack);
Int n=vm::pop<Int>(Stack);
#line 3844 "runtime.in"
if(n < 0 || k < 0 || k > n) error(invalidargument);
Int f=1;
Int r=n-k;
for(Int i=n; i > r; --i) {
if(f > Int_MAX/i) integeroverflow(0);
f=(f*i)/(n-i+1);
}
{Stack->push<Int>(f); return;}
}
#line 3854 "runtime.in"
// real gamma(real x);
void gen315(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 3855 "runtime.in"
#ifdef HAVE_TGAMMA
{Stack->push<real>(tgamma(x)); return;}
#else
real lg = lgamma(x);
{Stack->push<real>(signgam*exp(lg)); return;}
#endif
}
// Complex Gamma function
#line 3865 "runtime.in"
// pair gamma(explicit pair z);
void gen316(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 3866 "runtime.in"
{Stack->push<pair>(gamma(z)); return;}
}
#line 3870 "runtime.in"
// realarray* quadraticroots(real a, real b, real c);
void gen317(stack *Stack)
{
real c=vm::pop<real>(Stack);
real b=vm::pop<real>(Stack);
real a=vm::pop<real>(Stack);
#line 3871 "runtime.in"
quadraticroots q(a,b,c);
array *roots=new array(q.roots);
if(q.roots >= 1) (*roots)[0]=q.t1;
if(q.roots == 2) (*roots)[1]=q.t2;
{Stack->push<realarray*>(roots); return;}
}
#line 3879 "runtime.in"
// pairarray* quadraticroots(explicit pair a, explicit pair b, explicit pair c);
void gen318(stack *Stack)
{
pair c=vm::pop<pair>(Stack);
pair b=vm::pop<pair>(Stack);
pair a=vm::pop<pair>(Stack);
#line 3880 "runtime.in"
Quadraticroots q(a,b,c);
array *roots=new array(q.roots);
if(q.roots >= 1) (*roots)[0]=q.z1;
if(q.roots == 2) (*roots)[1]=q.z2;
{Stack->push<pairarray*>(roots); return;}
}
#line 3888 "runtime.in"
// realarray* cubicroots(real a, real b, real c, real d);
void gen319(stack *Stack)
{
real d=vm::pop<real>(Stack);
real c=vm::pop<real>(Stack);
real b=vm::pop<real>(Stack);
real a=vm::pop<real>(Stack);
#line 3889 "runtime.in"
cubicroots q(a,b,c,d);
array *roots=new array(q.roots);
if(q.roots >= 1) (*roots)[0]=q.t1;
if(q.roots >= 2) (*roots)[1]=q.t2;
if(q.roots == 3) (*roots)[2]=q.t3;
{Stack->push<realarray*>(roots); return;}
}
// Transforms
#line 3900 "runtime.in"
// bool ==(transform a, transform b);
void gen320(stack *Stack)
{
transform b=vm::pop<transform>(Stack);
transform a=vm::pop<transform>(Stack);
#line 3901 "runtime.in"
{Stack->push<bool>(a == b); return;}
}
#line 3906 "runtime.in"
// bool !=(transform a, transform b);
void gen321(stack *Stack)
{
transform b=vm::pop<transform>(Stack);
transform a=vm::pop<transform>(Stack);
#line 3907 "runtime.in"
{Stack->push<bool>(a != b); return;}
}
#line 3911 "runtime.in"
// transform +(transform a, transform b);
void gen322(stack *Stack)
{
transform b=vm::pop<transform>(Stack);
transform a=vm::pop<transform>(Stack);
#line 3912 "runtime.in"
{Stack->push<transform>(a+b); return;}
}
#line 3916 "runtime.in"
// transform *(transform a, transform b);
void gen323(stack *Stack)
{
transform b=vm::pop<transform>(Stack);
transform a=vm::pop<transform>(Stack);
#line 3917 "runtime.in"
{Stack->push<transform>(a*b); return;}
}
#line 3921 "runtime.in"
// pair *(transform t, pair z);
void gen324(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
transform t=vm::pop<transform>(Stack);
#line 3922 "runtime.in"
{Stack->push<pair>(t*z); return;}
}
#line 3926 "runtime.in"
// path *(transform t, path g);
void gen325(stack *Stack)
{
path g=vm::pop<path>(Stack);
transform t=vm::pop<transform>(Stack);
#line 3927 "runtime.in"
{Stack->push<path>(transformed(t,g)); return;}
}
#line 3931 "runtime.in"
// pen *(transform t, pen p);
void gen326(stack *Stack)
{
pen p=vm::pop<pen>(Stack);
transform t=vm::pop<transform>(Stack);
#line 3932 "runtime.in"
{Stack->push<pen>(transformed(t,p)); return;}
}
#line 3936 "runtime.in"
// picture* *(transform t, picture *f);
void gen327(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
transform t=vm::pop<transform>(Stack);
#line 3937 "runtime.in"
{Stack->push<picture*>(transformed(t,f)); return;}
}
#line 3941 "runtime.in"
// picture* *(realarray2 *t, picture *f);
void gen328(stack *Stack)
{
picture * f=vm::pop<picture *>(Stack);
realarray2 * t=vm::pop<realarray2 *>(Stack);
#line 3942 "runtime.in"
{Stack->push<picture*>(transformed(*t,f)); return;}
}
#line 3946 "runtime.in"
// transform ^(transform t, Int n);
void gen329(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
transform t=vm::pop<transform>(Stack);
#line 3947 "runtime.in"
transform T;
if(n < 0) {
n=-n;
t=inverse(t);
}
for(Int i=0; i < n; i++) T=T*t;
{Stack->push<transform>(T); return;}
}
#line 3957 "runtime.in"
void transformXPart(stack *Stack)
{
transform t=vm::pop<transform>(Stack);
#line 3958 "runtime.in"
{Stack->push<real>(t.getx()); return;}
}
#line 3962 "runtime.in"
void transformYPart(stack *Stack)
{
transform t=vm::pop<transform>(Stack);
#line 3963 "runtime.in"
{Stack->push<real>(t.gety()); return;}
}
#line 3967 "runtime.in"
void transformXXPart(stack *Stack)
{
transform t=vm::pop<transform>(Stack);
#line 3968 "runtime.in"
{Stack->push<real>(t.getxx()); return;}
}
#line 3972 "runtime.in"
void transformXYPart(stack *Stack)
{
transform t=vm::pop<transform>(Stack);
#line 3973 "runtime.in"
{Stack->push<real>(t.getxy()); return;}
}
#line 3977 "runtime.in"
void transformYXPart(stack *Stack)
{
transform t=vm::pop<transform>(Stack);
#line 3978 "runtime.in"
{Stack->push<real>(t.getyx()); return;}
}
#line 3982 "runtime.in"
void transformYYPart(stack *Stack)
{
transform t=vm::pop<transform>(Stack);
#line 3983 "runtime.in"
{Stack->push<real>(t.getyy()); return;}
}
#line 3987 "runtime.in"
void real6ToTransform(stack *Stack)
{
real yy=vm::pop<real>(Stack);
real yx=vm::pop<real>(Stack);
real xy=vm::pop<real>(Stack);
real xx=vm::pop<real>(Stack);
real y=vm::pop<real>(Stack);
real x=vm::pop<real>(Stack);
#line 3989 "runtime.in"
{Stack->push<transform>(transform(x,y,xx,xy,yx,yy)); return;}
}
#line 3993 "runtime.in"
// transform shift(transform t);
void gen337(stack *Stack)
{
transform t=vm::pop<transform>(Stack);
#line 3994 "runtime.in"
{Stack->push<transform>(transform(t.getx(),t.gety(),0,0,0,0)); return;}
}
#line 3998 "runtime.in"
// transform shiftless(transform t);
void gen338(stack *Stack)
{
transform t=vm::pop<transform>(Stack);
#line 3999 "runtime.in"
{Stack->push<transform>(transform(0,0,t.getxx(),t.getxy(),t.getyx(),t.getyy())); return;}
}
#line 4003 "runtime.in"
// transform identity();
void transformIdentity(stack *Stack)
{
#line 4004 "runtime.in"
{Stack->push<transform>(identity); return;}
}
#line 4008 "runtime.in"
// transform inverse(transform t);
void gen340(stack *Stack)
{
transform t=vm::pop<transform>(Stack);
#line 4009 "runtime.in"
{Stack->push<transform>(inverse(t)); return;}
}
#line 4013 "runtime.in"
// transform shift(pair z);
void gen341(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4014 "runtime.in"
{Stack->push<transform>(shift(z)); return;}
}
#line 4018 "runtime.in"
// transform shift(real x, real y);
void gen342(stack *Stack)
{
real y=vm::pop<real>(Stack);
real x=vm::pop<real>(Stack);
#line 4019 "runtime.in"
{Stack->push<transform>(shift(pair(x,y))); return;}
}
#line 4023 "runtime.in"
// transform xscale(real x);
void gen343(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 4024 "runtime.in"
{Stack->push<transform>(xscale(x)); return;}
}
#line 4028 "runtime.in"
// transform yscale(real y);
void gen344(stack *Stack)
{
real y=vm::pop<real>(Stack);
#line 4029 "runtime.in"
{Stack->push<transform>(yscale(y)); return;}
}
#line 4033 "runtime.in"
// transform scale(real x);
void gen345(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 4034 "runtime.in"
{Stack->push<transform>(scale(x)); return;}
}
#line 4038 "runtime.in"
// transform scale(real x, real y);
void gen346(stack *Stack)
{
real y=vm::pop<real>(Stack);
real x=vm::pop<real>(Stack);
#line 4039 "runtime.in"
{Stack->push<transform>(xscale(x)*yscale(y)); return;}
}
#line 4043 "runtime.in"
// transform slant(real s);
void gen347(stack *Stack)
{
real s=vm::pop<real>(Stack);
#line 4044 "runtime.in"
{Stack->push<transform>(slant(s)); return;}
}
#line 4048 "runtime.in"
// transform rotate(real angle, pair z=0);
void gen348(stack *Stack)
{
pair z=vm::pop<pair>(Stack,0);
real angle=vm::pop<real>(Stack);
#line 4049 "runtime.in"
{Stack->push<transform>(rotatearound(z,radians(angle))); return;}
}
#line 4053 "runtime.in"
// transform reflect(pair a, pair b);
void gen349(stack *Stack)
{
pair b=vm::pop<pair>(Stack);
pair a=vm::pop<pair>(Stack);
#line 4054 "runtime.in"
{Stack->push<transform>(reflectabout(a,b)); return;}
}
// Pair operations
#line 4060 "runtime.in"
void pairZero(stack *Stack)
{
#line 4061 "runtime.in"
{Stack->push<pair>(zero); return;}
}
#line 4066 "runtime.in"
void realRealToPair(stack *Stack)
{
real y=vm::pop<real>(Stack);
real x=vm::pop<real>(Stack);
#line 4067 "runtime.in"
{Stack->push<pair>(pair(x,y)); return;}
}
#line 4071 "runtime.in"
void pairNegate(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4072 "runtime.in"
{Stack->push<pair>(-z); return;}
}
#line 4076 "runtime.in"
// real xpart(pair z);
void pairXPart(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4077 "runtime.in"
{Stack->push<real>(z.getx()); return;}
}
#line 4081 "runtime.in"
// real ypart(pair z);
void pairYPart(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4082 "runtime.in"
{Stack->push<real>(z.gety()); return;}
}
#line 4086 "runtime.in"
// real length(pair z);
void gen355(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4087 "runtime.in"
{Stack->push<real>(z.length()); return;}
}
#line 4091 "runtime.in"
// real abs(pair z);
void gen356(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4092 "runtime.in"
{Stack->push<real>(z.length()); return;}
}
#line 4096 "runtime.in"
// pair sqrt(explicit pair z);
void gen357(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4097 "runtime.in"
{Stack->push<pair>(Sqrt(z)); return;}
}
// Return the angle of z in radians.
#line 4102 "runtime.in"
// real angle(pair z, bool warn=true);
void gen358(stack *Stack)
{
bool warn=vm::pop<bool>(Stack,true);
pair z=vm::pop<pair>(Stack);
#line 4103 "runtime.in"
if(!warn && z.getx() == 0.0 && z.gety() == 0.0) {Stack->push<real>(0.0); return;}
{Stack->push<real>(z.angle()); return;}
}
// Return the angle of z in degrees in the interval [0,360).
#line 4109 "runtime.in"
// real degrees(pair z, bool warn=true);
void gen359(stack *Stack)
{
bool warn=vm::pop<bool>(Stack,true);
pair z=vm::pop<pair>(Stack);
#line 4110 "runtime.in"
if(!warn && z.getx() == 0.0 && z.gety() == 0.0) {Stack->push<real>(0.0); return;}
{Stack->push<real>(principalBranch(degrees(z.angle()))); return;}
}
// Convert degrees to radians.
#line 4116 "runtime.in"
// real radians(real degrees);
void gen360(stack *Stack)
{
real degrees=vm::pop<real>(Stack);
#line 4117 "runtime.in"
{Stack->push<real>(radians(degrees)); return;}
}
// Convert radians to degrees.
#line 4122 "runtime.in"
// real degrees(real radians);
void gen361(stack *Stack)
{
real radians=vm::pop<real>(Stack);
#line 4123 "runtime.in"
{Stack->push<real>(degrees(radians)); return;}
}
// Convert radians to degrees in [0,360).
#line 4128 "runtime.in"
// real Degrees(real radians);
void gen362(stack *Stack)
{
real radians=vm::pop<real>(Stack);
#line 4129 "runtime.in"
{Stack->push<real>(principalBranch(degrees(radians))); return;}
}
#line 4133 "runtime.in"
// real Sin(real deg);
void gen363(stack *Stack)
{
real deg=vm::pop<real>(Stack);
#line 4134 "runtime.in"
{Stack->push<real>(sin(radians(deg))); return;}
}
#line 4138 "runtime.in"
// real Cos(real deg);
void gen364(stack *Stack)
{
real deg=vm::pop<real>(Stack);
#line 4139 "runtime.in"
{Stack->push<real>(cos(radians(deg))); return;}
}
#line 4143 "runtime.in"
// real Tan(real deg);
void gen365(stack *Stack)
{
real deg=vm::pop<real>(Stack);
#line 4144 "runtime.in"
{Stack->push<real>(tan(radians(deg))); return;}
}
#line 4148 "runtime.in"
// real aSin(real x);
void gen366(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 4149 "runtime.in"
{Stack->push<real>(degrees(asin(x))); return;}
}
#line 4153 "runtime.in"
// real aCos(real x);
void gen367(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 4154 "runtime.in"
{Stack->push<real>(degrees(acos(x))); return;}
}
#line 4158 "runtime.in"
// real aTan(real x);
void gen368(stack *Stack)
{
real x=vm::pop<real>(Stack);
#line 4159 "runtime.in"
{Stack->push<real>(degrees(atan(x))); return;}
}
#line 4163 "runtime.in"
// pair unit(pair z);
void gen369(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4164 "runtime.in"
{Stack->push<pair>(unit(z)); return;}
}
#line 4168 "runtime.in"
// pair dir(real degrees);
void gen370(stack *Stack)
{
real degrees=vm::pop<real>(Stack);
#line 4169 "runtime.in"
{Stack->push<pair>(expi(radians(degrees))); return;}
}
#line 4173 "runtime.in"
// pair dir(explicit pair z);
void gen371(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4174 "runtime.in"
{Stack->push<pair>(unit(z)); return;}
}
#line 4178 "runtime.in"
// pair expi(real angle);
void gen372(stack *Stack)
{
real angle=vm::pop<real>(Stack);
#line 4179 "runtime.in"
{Stack->push<pair>(expi(angle)); return;}
}
#line 4183 "runtime.in"
// pair exp(explicit pair z);
void gen373(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4184 "runtime.in"
{Stack->push<pair>(exp(z)); return;}
}
#line 4188 "runtime.in"
// pair log(explicit pair z);
void gen374(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4189 "runtime.in"
{Stack->push<pair>(pair(log(z.length()),z.angle())); return;}
}
#line 4193 "runtime.in"
// pair sin(explicit pair z);
void gen375(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4194 "runtime.in"
{Stack->push<pair>(sin(z)); return;}
}
#line 4198 "runtime.in"
// pair cos(explicit pair z);
void gen376(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4199 "runtime.in"
{Stack->push<pair>(pair(cos(z.getx())*cosh(z.gety()),-sin(z.getx())*sinh(z.gety()))); return;}
}
#line 4203 "runtime.in"
// pair conj(pair z);
void gen377(stack *Stack)
{
pair z=vm::pop<pair>(Stack);
#line 4204 "runtime.in"
{Stack->push<pair>(conj(z)); return;}
}
#line 4208 "runtime.in"
// pair realmult(pair z, pair w);
void gen378(stack *Stack)
{
pair w=vm::pop<pair>(Stack);
pair z=vm::pop<pair>(Stack);
#line 4209 "runtime.in"
{Stack->push<pair>(pair (z.getx()*w.getx(),z.gety()*w.gety())); return;}
}
#line 4213 "runtime.in"
// triple realmult(triple u, triple v);
void gen379(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
triple u=vm::pop<triple>(Stack);
#line 4214 "runtime.in"
{Stack->push<triple>(triple (u.getx()*v.getx(),u.gety()*v.gety(),u.getz()*v.getz())); return;}
}
// To avoid confusion, a dot product requires explicit pair arguments.
#line 4219 "runtime.in"
// real dot(explicit pair z, explicit pair w);
void gen380(stack *Stack)
{
pair w=vm::pop<pair>(Stack);
pair z=vm::pop<pair>(Stack);
#line 4220 "runtime.in"
{Stack->push<real>(dot(z,w)); return;}
}
// Triple operations
#line 4226 "runtime.in"
void tripleZero(stack *Stack)
{
#line 4227 "runtime.in"
static triple zero;
{Stack->push<triple>(zero); return;}
}
#line 4233 "runtime.in"
void realRealRealToTriple(stack *Stack)
{
real z=vm::pop<real>(Stack);
real y=vm::pop<real>(Stack);
real x=vm::pop<real>(Stack);
#line 4234 "runtime.in"
{Stack->push<triple>(triple(x,y,z)); return;}
}
#line 4238 "runtime.in"
// real xpart(triple v);
void tripleXPart(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
#line 4239 "runtime.in"
{Stack->push<real>(v.getx()); return;}
}
#line 4243 "runtime.in"
// real ypart(triple v);
void tripleYPart(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
#line 4244 "runtime.in"
{Stack->push<real>(v.gety()); return;}
}
#line 4248 "runtime.in"
// real zpart(triple v);
void tripleZPart(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
#line 4249 "runtime.in"
{Stack->push<real>(v.getz()); return;}
}
#line 4253 "runtime.in"
// triple *(real x, triple v);
void gen386(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
real x=vm::pop<real>(Stack);
#line 4254 "runtime.in"
{Stack->push<triple>(x*v); return;}
}
#line 4258 "runtime.in"
// triple *(triple v, real x);
void gen387(stack *Stack)
{
real x=vm::pop<real>(Stack);
triple v=vm::pop<triple>(Stack);
#line 4259 "runtime.in"
{Stack->push<triple>(v*x); return;}
}
#line 4263 "runtime.in"
// triple /(triple v, real x);
void gen388(stack *Stack)
{
real x=vm::pop<real>(Stack);
triple v=vm::pop<triple>(Stack);
#line 4264 "runtime.in"
{Stack->push<triple>(v/x); return;}
}
#line 4268 "runtime.in"
// real length(triple v);
void gen389(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
#line 4269 "runtime.in"
{Stack->push<real>(v.length()); return;}
}
#line 4273 "runtime.in"
// real abs(triple v);
void gen390(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
#line 4274 "runtime.in"
{Stack->push<real>(v.length()); return;}
}
#line 4278 "runtime.in"
// real polar(triple v, bool warn=true);
void gen391(stack *Stack)
{
bool warn=vm::pop<bool>(Stack,true);
triple v=vm::pop<triple>(Stack);
#line 4279 "runtime.in"
if(!warn && v.getx() == 0.0 && v.gety() == 0.0 && v.getz() == 0.0) {Stack->push<real>(0.0); return;}
{Stack->push<real>(v.polar()); return;}
}
#line 4284 "runtime.in"
// real azimuth(triple v, bool warn=true);
void gen392(stack *Stack)
{
bool warn=vm::pop<bool>(Stack,true);
triple v=vm::pop<triple>(Stack);
#line 4285 "runtime.in"
if(!warn && v.getx() == 0.0 && v.gety() == 0.0) {Stack->push<real>(0.0); return;}
{Stack->push<real>(v.azimuth()); return;}
}
#line 4290 "runtime.in"
// real colatitude(triple v, bool warn=true);
void gen393(stack *Stack)
{
bool warn=vm::pop<bool>(Stack,true);
triple v=vm::pop<triple>(Stack);
#line 4291 "runtime.in"
if(!warn && v.getx() == 0.0 && v.gety() == 0.0 && v.getz() == 0.0) {Stack->push<real>(0.0); return;}
{Stack->push<real>(degrees(v.polar())); return;}
}
#line 4296 "runtime.in"
// real latitude(triple v, bool warn=true);
void gen394(stack *Stack)
{
bool warn=vm::pop<bool>(Stack,true);
triple v=vm::pop<triple>(Stack);
#line 4297 "runtime.in"
if(!warn && v.getx() == 0.0 && v.gety() == 0.0 && v.getz() == 0.0) {Stack->push<real>(0.0); return;}
{Stack->push<real>(90.0-degrees(v.polar())); return;}
}
// Return the longitude of v in [0,360).
#line 4303 "runtime.in"
// real longitude(triple v, bool warn=true);
void gen395(stack *Stack)
{
bool warn=vm::pop<bool>(Stack,true);
triple v=vm::pop<triple>(Stack);
#line 4304 "runtime.in"
if(!warn && v.getx() == 0.0 && v.gety() == 0.0) {Stack->push<real>(0.0); return;}
{Stack->push<real>(principalBranch(degrees(v.azimuth()))); return;}
}
#line 4309 "runtime.in"
// triple unit(triple v);
void gen396(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
#line 4310 "runtime.in"
{Stack->push<triple>(unit(v)); return;}
}
#line 4314 "runtime.in"
// real dot(triple u, triple v);
void gen397(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
triple u=vm::pop<triple>(Stack);
#line 4315 "runtime.in"
{Stack->push<real>(dot(u,v)); return;}
}
#line 4319 "runtime.in"
// triple cross(triple u, triple v);
void gen398(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
triple u=vm::pop<triple>(Stack);
#line 4320 "runtime.in"
{Stack->push<triple>(cross(u,v)); return;}
}
#line 4324 "runtime.in"
// triple expi(real polar, real azimuth);
void gen399(stack *Stack)
{
real azimuth=vm::pop<real>(Stack);
real polar=vm::pop<real>(Stack);
#line 4325 "runtime.in"
{Stack->push<triple>(expi(polar,azimuth)); return;}
}
#line 4329 "runtime.in"
// triple dir(real colatitude, real longitude);
void gen400(stack *Stack)
{
real longitude=vm::pop<real>(Stack);
real colatitude=vm::pop<real>(Stack);
#line 4330 "runtime.in"
{Stack->push<triple>(expi(radians(colatitude),radians(longitude))); return;}
}
// System routines
#line 4336 "runtime.in"
// void atupdate(callable *f);
void gen401(stack *Stack)
{
callable * f=vm::pop<callable *>(Stack);
#line 4337 "runtime.in"
processData().atUpdateFunction=f;
}
#line 4342 "runtime.in"
// callable* atupdate();
void gen402(stack *Stack)
{
#line 4343 "runtime.in"
{Stack->push<callable*>(processData().atUpdateFunction); return;}
}
#line 4347 "runtime.in"
// void atexit(callable *f);
void gen403(stack *Stack)
{
callable * f=vm::pop<callable *>(Stack);
#line 4348 "runtime.in"
processData().atExitFunction=f;
}
#line 4352 "runtime.in"
// callable* atexit();
void gen404(stack *Stack)
{
#line 4353 "runtime.in"
{Stack->push<callable*>(processData().atExitFunction); return;}
}
#line 4357 "runtime.in"
// void atbreakpoint(callableBp *f);
void gen405(stack *Stack)
{
callableBp * f=vm::pop<callableBp *>(Stack);
#line 4358 "runtime.in"
processData().atBreakpointFunction=f;
}
#line 4362 "runtime.in"
// void breakpoint(runnable *s=NULL);
void gen406(stack *Stack)
{
runnable * s=vm::pop<runnable *>(Stack,NULL);
#line 4363 "runtime.in"
breakpoint(Stack,s);
}
#line 4367 "runtime.in"
// string locatefile(string file);
void gen407(stack *Stack)
{
string file=vm::pop<string>(Stack);
#line 4368 "runtime.in"
{Stack->push<string>(locateFile(file)); return;}
}
#line 4372 "runtime.in"
// void stop(string file, Int line, runnable *s=NULL);
void gen408(stack *Stack)
{
runnable * s=vm::pop<runnable *>(Stack,NULL);
Int line=vm::pop<Int>(Stack);
string file=vm::pop<string>(Stack);
#line 4373 "runtime.in"
file=locateFile(file);
clear(file,line);
cout << "setting breakpoint at " << file << ": " << line << endl;
bplist.push_back(bpinfo(file,line,s));
}
#line 4380 "runtime.in"
// void breakpoints();
void gen409(stack *)
{
#line 4381 "runtime.in"
for(mem::list<bpinfo>::iterator p=bplist.begin(); p != bplist.end(); ++p)
cout << p->f.name() << ": " << p->f.line() << endl;
}
#line 4386 "runtime.in"
// void clear(string file, Int line);
void gen410(stack *Stack)
{
Int line=vm::pop<Int>(Stack);
string file=vm::pop<string>(Stack);
#line 4387 "runtime.in"
file=locateFile(file);
clear(file,line,true);
}
#line 4392 "runtime.in"
// void clear();
void gen411(stack *)
{
#line 4393 "runtime.in"
bplist.clear();
}
#line 4397 "runtime.in"
// void warn(string s);
void gen412(stack *Stack)
{
string s=vm::pop<string>(Stack);
#line 4398 "runtime.in"
Warn(s);
}
#line 4402 "runtime.in"
// void nowarn(string s);
void gen413(stack *Stack)
{
string s=vm::pop<string>(Stack);
#line 4403 "runtime.in"
noWarn(s);
}
// Strip directory from string
#line 4408 "runtime.in"
// string stripdirectory(string *s);
void gen414(stack *Stack)
{
string * s=vm::pop<string *>(Stack);
#line 4409 "runtime.in"
{Stack->push<string>(stripDir(*s)); return;}
}
// Strip directory from string
#line 4414 "runtime.in"
// string stripfile(string *s);
void gen415(stack *Stack)
{
string * s=vm::pop<string *>(Stack);
#line 4415 "runtime.in"
{Stack->push<string>(stripFile(*s)); return;}
}
// Strip file extension from string
#line 4420 "runtime.in"
// string stripextension(string *s);
void gen416(stack *Stack)
{
string * s=vm::pop<string *>(Stack);
#line 4421 "runtime.in"
{Stack->push<string>(stripExt(*s)); return;}
}
// Call ImageMagick convert.
#line 4426 "runtime.in"
// Int convert(string args=emptystring, string file=emptystring, string format=emptystring);
void gen417(stack *Stack)
{
string format=vm::pop<string>(Stack,emptystring);
string file=vm::pop<string>(Stack,emptystring);
string args=vm::pop<string>(Stack,emptystring);
#line 4428 "runtime.in"
ostringstream cmd;
string name=convertname(file,format);
cmd << "'" << getSetting<string>("convert") << "' " << args
<< " '" << name << "'";
bool quiet=verbose <= 1;
Int ret=System(cmd,quiet ? 1 : 0,true,"convert","your ImageMagick convert utility");
if(ret == 0 && verbose > 0)
cout << "Wrote " << ((file.empty()) ? name : file) << endl;
{Stack->push<Int>(ret); return;}
}
// Call ImageMagick animate.
#line 4444 "runtime.in"
// Int animate(string args=emptystring, string file=emptystring, string format=emptystring);
void gen418(stack *Stack)
{
string format=vm::pop<string>(Stack,emptystring);
string file=vm::pop<string>(Stack,emptystring);
string args=vm::pop<string>(Stack,emptystring);
#line 4446 "runtime.in"
#ifndef __CYGWIN__
string name=convertname(file,format,false);
if(view()) {
ostringstream cmd;
cmd << "'" << getSetting<string>("animate") << "' " << args
<< " '" << name << "'";
{Stack->push<Int>(System(cmd,0,false,"animate","your animated GIF viewer")); return;}
}
#endif
{Stack->push<Int>(0); return;}
}
// Delete file named s.
#line 4460 "runtime.in"
// Int delete(string *s);
void gen419(stack *Stack)
{
string * s=vm::pop<string *>(Stack);
#line 4461 "runtime.in"
checkLocal(*s);
Int rc=unlink(s->c_str());
if(rc == 0 && verbose > 0)
cout << "Deleted " << *s << endl;
{Stack->push<Int>(rc); return;}
}
// Rename file "from" to file "to".
#line 4470 "runtime.in"
// Int rename(string *from, string *to);
void gen420(stack *Stack)
{
string * to=vm::pop<string *>(Stack);
string * from=vm::pop<string *>(Stack);
#line 4471 "runtime.in"
checkLocal(*from);
checkLocal(*to);
Int rc=rename(from->c_str(),to->c_str());
if(rc == 0 && verbose > 0)
cout << "Renamed " << *from << " to " << *to << endl;
{Stack->push<Int>(rc); return;}
}
// Array operations
// Create an empty array.
#line 4484 "runtime.in"
void emptyArray(stack *Stack)
{
#line 4485 "runtime.in"
{Stack->push<array*>(new array(0)); return;}
}
// Create a new array (technically a vector).
// This array will be multidimensional. First the number of dimensions
// is popped off the stack, followed by each dimension in reverse order.
// The array itself is technically a one dimensional array of one
// dimension arrays and so on.
#line 4494 "runtime.in"
void newDeepArray(stack *Stack)
{
Int depth=vm::pop<Int>(Stack);
#line 4495 "runtime.in"
assert(depth > 0);
Int *dims = new Int[depth];
for (Int index = depth-1; index >= 0; index--) {
Int i=pop<Int>(Stack);
if(i < 0) error("cannot create a negative length array");
dims[index]=i;
}
array *a=deepArray(depth, dims);
delete[] dims;
{Stack->push<array*>(a); return;}
}
// Creates an array with elements already specified. First, the number
// of elements is popped off the stack, followed by each element in
// reverse order.
#line 4514 "runtime.in"
void newInitializedArray(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
#line 4515 "runtime.in"
assert(n >= 0);
array *a = new array(n);
for (Int index = n-1; index >= 0; index--)
(*a)[index] = pop(Stack);
{Stack->push<array*>(a); return;}
}
// Similar to newInitializedArray, but after the n elements, append another
// array to it.
#line 4528 "runtime.in"
void newAppendedArray(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
array* tail=vm::pop<array*>(Stack);
#line 4529 "runtime.in"
assert(n >= 0);
array *a = new array(n);
for (Int index = n-1; index >= 0; index--)
(*a)[index] = pop(Stack);
copy(tail->begin(), tail->end(), back_inserter(*a));
{Stack->push<array*>(a); return;}
}
// The function T[] array(int n, T value, int depth=0) produces a array of n
// copies of x, where each copy is copied up to depth.
#line 4544 "runtime.in"
void newDuplicateArray(stack *Stack)
{
Int depth=vm::pop<Int>(Stack,Int_MAX);
item value=vm::pop(Stack);
Int n=vm::pop<Int>(Stack);
#line 4545 "runtime.in"
if(n < 0) error("cannot create a negative length array");
if(depth < 0) error("cannot copy to a negative depth");
{Stack->push<array*>(new array(n, value, depth)); return;}
}
// Read an element from an array. Checks for initialization & bounds.
#line 4553 "runtime.in"
void arrayRead(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
array * a=vm::pop<array *>(Stack);
#line 4554 "runtime.in"
item& i=arrayRead(a,n);
if (i.empty()) {
ostringstream buf;
buf << "read uninitialized value from array at index " << n;
error(buf);
}
{Stack->push(i); return;}
}
// Slice a substring from an array.
#line 4565 "runtime.in"
void arraySliceRead(stack *Stack)
{
Int right=vm::pop<Int>(Stack);
Int left=vm::pop<Int>(Stack);
array * a=vm::pop<array *>(Stack);
#line 4566 "runtime.in"
checkArray(a);
{Stack->push(a->slice(left, right)); return;}
}
// Slice a substring from an array. This implements the cases a[i:] and a[:]
// where the endpoint is not given, and assumed to be the length of the array.
#line 4573 "runtime.in"
void arraySliceReadToEnd(stack *Stack)
{
Int left=vm::pop<Int>(Stack);
array * a=vm::pop<array *>(Stack);
#line 4574 "runtime.in"
size_t len=checkArray(a);
{Stack->push(a->slice(left, (Int)len)); return;}
}
// Read an element from an array of arrays. Check bounds and initialize
// as necessary.
#line 4581 "runtime.in"
void arrayArrayRead(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
array * a=vm::pop<array *>(Stack);
#line 4582 "runtime.in"
item& i=arrayRead(a,n);
if (i.empty()) i=new array(0);
{Stack->push(i); return;}
}
// Write an element to an array. Increase size if necessary.
#line 4589 "runtime.in"
void arrayWrite(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
array * a=vm::pop<array *>(Stack);
item value=vm::pop(Stack);
#line 4590 "runtime.in"
size_t len=checkArray(a);
bool cyclic=a->cyclic();
if(cyclic && len > 0) n=imod(n,len);
else {
if(cyclic) outOfBounds("writing cyclic",len,n);
if(n < 0) outOfBounds("writing",len,n);
if(len <= (size_t) n)
a->resize(n+1);
}
(*a)[n] = value;
{Stack->push(value); return;}
}
#line 4604 "runtime.in"
void arraySliceWrite(stack *Stack)
{
Int right=vm::pop<Int>(Stack);
Int left=vm::pop<Int>(Stack);
array * dest=vm::pop<array *>(Stack);
array * src=vm::pop<array *>(Stack);
#line 4605 "runtime.in"
checkArray(src);
checkArray(dest);
dest->setSlice(left, right, src);
{Stack->push<array*>(src); return;}
}
#line 4612 "runtime.in"
void arraySliceWriteToEnd(stack *Stack)
{
Int left=vm::pop<Int>(Stack);
array * dest=vm::pop<array *>(Stack);
array * src=vm::pop<array *>(Stack);
#line 4613 "runtime.in"
checkArray(src);
size_t len=checkArray(dest);
dest->setSlice(left, (Int) len, src);
{Stack->push<array*>(src); return;}
}
// Returns the length of an array.
#line 4621 "runtime.in"
void arrayLength(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4622 "runtime.in"
{Stack->push<Int>((Int) checkArray(a)); return;}
}
// Returns an array of integers representing the keys of the array.
#line 4627 "runtime.in"
void arrayKeys(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4628 "runtime.in"
size_t size=checkArray(a);
array *keys=new array();
for (size_t i=0; i<size; ++i) {
item& cell = (*a)[i];
if (!cell.empty())
keys->push((Int)i);
}
{Stack->push<array*>(keys); return;}
}
// Return the cyclic flag for an array.
#line 4642 "runtime.in"
void arrayCyclicFlag(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4643 "runtime.in"
checkArray(a);
{Stack->push<bool>(a->cyclic()); return;}
}
// Check to see if an array element is initialized.
#line 4649 "runtime.in"
void arrayInitializedHelper(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
Int n=vm::pop<Int>(Stack);
#line 4650 "runtime.in"
size_t len=checkArray(a);
bool cyclic=a->cyclic();
if(cyclic && len > 0) n=imod(n,len);
else if(n < 0 || n >= (Int) len) {Stack->push<bool>(false); return;}
item&i=(*a)[(unsigned) n];
{Stack->push<bool>(!i.empty()); return;}
}
// Returns the initialize method for an array.
#line 4660 "runtime.in"
void arrayInitialized(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4661 "runtime.in"
{Stack->push<callable*>(new thunk(new bfunc(arrayInitializedHelper),a)); return;}
}
// The helper function for the cyclic method that sets the cyclic flag.
#line 4666 "runtime.in"
void arrayCyclicHelper(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
bool b=vm::pop<bool>(Stack);
#line 4667 "runtime.in"
checkArray(a);
a->cyclic(b);
}
// Set the cyclic flag for an array.
#line 4673 "runtime.in"
void arrayCyclic(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4674 "runtime.in"
{Stack->push<callable*>(new thunk(new bfunc(arrayCyclicHelper),a)); return;}
}
// The helper function for the push method that does the actual operation.
#line 4679 "runtime.in"
void arrayPushHelper(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
item x=vm::pop(Stack);
#line 4680 "runtime.in"
checkArray(a);
a->push(x);
{Stack->push(x); return;}
}
// Returns the push method for an array.
#line 4687 "runtime.in"
void arrayPush(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4688 "runtime.in"
{Stack->push<callable*>(new thunk(new bfunc(arrayPushHelper),a)); return;}
}
// The helper function for the append method that appends b to a.
#line 4693 "runtime.in"
void arrayAppendHelper(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
array * b=vm::pop<array *>(Stack);
#line 4694 "runtime.in"
checkArray(a);
size_t size=checkArray(b);
for(size_t i=0; i < size; i++)
a->push((*b)[i]);
}
// Returns the append method for an array.
#line 4702 "runtime.in"
void arrayAppend(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4703 "runtime.in"
{Stack->push<callable*>(new thunk(new bfunc(arrayAppendHelper),a)); return;}
}
// The helper function for the pop method.
#line 4708 "runtime.in"
void arrayPopHelper(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4709 "runtime.in"
size_t asize=checkArray(a);
if(asize == 0)
error("cannot pop element from empty array");
{Stack->push(a->pop()); return;}
}
// Returns the pop method for an array.
#line 4717 "runtime.in"
void arrayPop(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4718 "runtime.in"
{Stack->push<callable*>(new thunk(new bfunc(arrayPopHelper),a)); return;}
}
// The helper function for the insert method.
#line 4723 "runtime.in"
void arrayInsertHelper(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
array * x=vm::pop<array *>(Stack);
Int i=vm::pop<Int>(Stack);
#line 4724 "runtime.in"
size_t asize=checkArray(a);
checkArray(x);
if(a->cyclic() && asize > 0) i=imod(i,asize);
if(i < 0 || i > (Int) asize)
outOfBounds("inserting",asize,i);
(*a).insert((*a).begin()+i,(*x).begin(),(*x).end());
}
// Returns the insert method for an array.
#line 4734 "runtime.in"
void arrayInsert(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4735 "runtime.in"
{Stack->push<callable*>(new thunk(new bfunc(arrayInsertHelper),a)); return;}
}
// Returns the delete method for an array.
#line 4740 "runtime.in"
void arrayDelete(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4741 "runtime.in"
{Stack->push<callable*>(new thunk(new bfunc(arrayDeleteHelper),a)); return;}
}
#line 4745 "runtime.in"
void arrayAlias(stack *Stack)
{
array * b=vm::pop<array *>(Stack);
array * a=vm::pop<array *>(Stack);
#line 4746 "runtime.in"
{Stack->push<bool>(a==b); return;}
}
// Return array formed by indexing array a with elements of integer array b
#line 4751 "runtime.in"
void arrayIntArray(stack *Stack)
{
array * b=vm::pop<array *>(Stack);
array * a=vm::pop<array *>(Stack);
#line 4752 "runtime.in"
size_t asize=checkArray(a);
size_t bsize=checkArray(b);
array *r=new array(bsize);
bool cyclic=a->cyclic();
for(size_t i=0; i < bsize; i++) {
Int index=read<Int>(b,i);
if(cyclic && asize > 0) index=imod(index,asize);
else
if(index < 0 || index >= (Int) asize)
outOfBounds("reading",asize,index);
(*r)[i]=(*a)[index];
}
{Stack->push<array*>(r); return;}
}
// returns the complement of the integer array a in {0,2,...,n-1},
// so that b[complement(a,b.length)] yields the complement of b[a].
#line 4770 "runtime.in"
// Intarray* complement(Intarray *a, Int n);
void gen451(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
Intarray * a=vm::pop<Intarray *>(Stack);
#line 4771 "runtime.in"
size_t asize=checkArray(a);
array *r=new array(0);
bool *keep=new bool[n];
for(Int i=0; i < n; ++i) keep[i]=true;
for(size_t i=0; i < asize; ++i) {
Int j=read<Int>(a,i);
if(j >= 0 && j < n) keep[j]=false;
}
for(Int i=0; i < n; i++)
if(keep[i]) r->push(i);
delete[] keep;
{Stack->push<Intarray*>(r); return;}
}
// Generate the sequence {f(i) : i=0,1,...n-1} given a function f and integer n
#line 4788 "runtime.in"
void arraySequence(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
callable * f=vm::pop<callable *>(Stack);
#line 4789 "runtime.in"
if(n < 0) n=0;
array *a=new array(n);
for(Int i=0; i < n; ++i) {
Stack->push(i);
f->call(Stack);
(*a)[i]=pop(Stack);
}
{Stack->push<Intarray*>(a); return;}
}
// Return the array {0,1,...n-1}
#line 4801 "runtime.in"
// Intarray* sequence(Int n);
void gen453(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
#line 4802 "runtime.in"
if(n < 0) n=0;
array *a=new array(n);
for(Int i=0; i < n; ++i) {
(*a)[i]=i;
}
{Stack->push<Intarray*>(a); return;}
}
// Apply a function to each element of an array
#line 4812 "runtime.in"
void arrayFunction(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
callable * f=vm::pop<callable *>(Stack);
#line 4813 "runtime.in"
size_t size=checkArray(a);
array *b=new array(size);
for(size_t i=0; i < size; ++i) {
Stack->push((*a)[i]);
f->call(Stack);
(*b)[i]=pop(Stack);
}
{Stack->push<array*>(b); return;}
}
#line 4824 "runtime.in"
void arraySort(stack *Stack)
{
callable * f=vm::pop<callable *>(Stack);
array * a=vm::pop<array *>(Stack);
#line 4825 "runtime.in"
array *c=copyArray(a);
compareFunc=f;
FuncStack=Stack;
stable_sort(c->begin(),c->end(),compareFunction);
{Stack->push<array*>(c); return;}
}
#line 4833 "runtime.in"
// bool all(boolarray *a);
void gen456(stack *Stack)
{
boolarray * a=vm::pop<boolarray *>(Stack);
#line 4834 "runtime.in"
size_t size=checkArray(a);
bool c=true;
for(size_t i=0; i < size; i++)
if(!get<bool>((*a)[i])) {c=false; break;}
{Stack->push<bool>(c); return;}
}
#line 4842 "runtime.in"
// boolarray* !(boolarray* a);
void gen457(stack *Stack)
{
boolarray* a=vm::pop<boolarray*>(Stack);
#line 4843 "runtime.in"
size_t size=checkArray(a);
array *c=new array(size);
for(size_t i=0; i < size; i++)
(*c)[i]=!read<bool>(a,i);
{Stack->push<boolarray*>(c); return;}
}
#line 4851 "runtime.in"
// Int sum(boolarray *a);
void gen458(stack *Stack)
{
boolarray * a=vm::pop<boolarray *>(Stack);
#line 4852 "runtime.in"
size_t size=checkArray(a);
Int sum=0;
for(size_t i=0; i < size; i++)
sum += read<bool>(a,i) ? 1 : 0;
{Stack->push<Int>(sum); return;}
}
#line 4860 "runtime.in"
void arrayCopy(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4861 "runtime.in"
{Stack->push<array*>(copyArray(a)); return;}
}
#line 4865 "runtime.in"
void arrayConcat(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4866 "runtime.in"
// a is an array of arrays to be concatenated together.
// The signature is
// T[] concat(... T[][] a);
size_t numArgs=checkArray(a);
size_t resultSize=0;
for (size_t i=0; i < numArgs; ++i) {
resultSize += checkArray(a->read<array *>(i));
}
array *result=new array(resultSize);
size_t ri=0;
for (size_t i=0; i < numArgs; ++i) {
array *arg=a->read<array *>(i);
size_t size=checkArray(arg);
for (size_t j=0; j < size; ++j) {
(*result)[ri]=(*arg)[j];
++ri;
}
}
{Stack->push<array*>(result); return;}
}
#line 4893 "runtime.in"
void array2Copy(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4894 "runtime.in"
{Stack->push<array*>(copyArray2(a)); return;}
}
#line 4898 "runtime.in"
void array3Copy(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4899 "runtime.in"
{Stack->push<array*>(copyArray3(a)); return;}
}
#line 4903 "runtime.in"
void array2Transpose(stack *Stack)
{
array * a=vm::pop<array *>(Stack);
#line 4904 "runtime.in"
size_t asize=checkArray(a);
array *c=new array(0);
for(size_t i=0; i < asize; i++) {
size_t ip=i+1;
array *ai=read<array*>(a,i);
size_t aisize=checkArray(ai);
size_t csize=checkArray(c);
if(csize < aisize) {
c->resize(aisize);
for(size_t j=csize; j < aisize; j++) {
(*c)[j]=new array(ip);
}
}
for(size_t j=0; j < aisize; j++) {
array *cj=read<array*>(c,j);
if(checkArray(cj) < ip) cj->resize(ip);
(*cj)[i]=(*ai)[j];
}
}
{Stack->push<array*>(c); return;}
}
// a is a rectangular 3D array; perm is an Int array indicating the type of
// permutation (021 or 120, etc; original is 012).
// Transpose by sending respective members to the permutated locations:
// return the array obtained by putting a[i][j][k] into position perm{ijk}.
#line 4931 "runtime.in"
void array3Transpose(stack *Stack)
{
array * perm=vm::pop<array *>(Stack);
array * a=vm::pop<array *>(Stack);
#line 4932 "runtime.in"
const size_t DIM=3;
if(checkArray(perm) != DIM) {
ostringstream buf;
buf << "permutation array must have length " << DIM;
error(buf);
}
size_t* size=new size_t[DIM];
for(size_t i=0; i < DIM; ++i) size[i]=DIM;
for(size_t i=0; i < DIM; ++i) {
Int p=read<Int>(perm,i);
size_t P=(size_t) p;
if(p < 0 || P >= DIM) {
ostringstream buf;
buf << "permutation index out of range: " << p;
error(buf);
}
size[P]=P;
}
for(size_t i=0; i < DIM; ++i)
if(size[i] == DIM) error("permutation indices must be distinct");
static const char *rectangular=
"3D transpose implemented for rectangular matrices only";
size_t isize=size[0]=checkArray(a);
array *a0=read<array*>(a,0);
size[1]=checkArray(a0);
array *a00=read<array*>(a0,0);
size[2]=checkArray(a00);
for(size_t i=0; i < isize; i++) {
array *ai=read<array*>(a,i);
size_t jsize=checkArray(ai);
if(jsize != size[1]) error(rectangular);
for(size_t j=0; j < jsize; j++) {
array *aij=read<array*>(ai,j);
if(checkArray(aij) != size[2]) error(rectangular);
}
}
size_t perm0=(size_t) read<Int>(perm,0);
size_t perm1=(size_t) read<Int>(perm,1);
size_t perm2=(size_t) read<Int>(perm,2);
size_t sizep0=size[perm0];
size_t sizep1=size[perm1];
size_t sizep2=size[perm2];
array *c=new array(sizep0);
for(size_t i=0; i < sizep0; ++i) {
array *ci=new array(sizep1);
(*c)[i]=ci;
for(size_t j=0; j < sizep1; ++j) {
array *cij=new array(sizep2);
(*ci)[j]=cij;
}
}
size_t* i=new size_t[DIM];
for(i[0]=0; i[0] < size[0]; ++i[0]) {
array *a0=read<array*>(a,i[0]);
for(i[1]=0; i[1] < size[1]; ++i[1]) {
array *a1=read<array*>(a0,i[1]);
for(i[2]=0; i[2] < size[2]; ++i[2]) {
array *c0=read<array*>(c,i[perm0]);
array *c1=read<array*>(c0,i[perm1]);
(*c1)[i[perm2]]=read<real>(a1,i[2]);
}
}
}
delete [] i;
delete [] size;
{Stack->push<array*>(c); return;}
}
// In a boolean array, find the index of the nth true value or -1 if not found
// If n is negative, search backwards.
#line 5016 "runtime.in"
// Int find(boolarray *a, Int n=1);
void gen465(stack *Stack)
{
Int n=vm::pop<Int>(Stack,1);
boolarray * a=vm::pop<boolarray *>(Stack);
#line 5017 "runtime.in"
size_t size=checkArray(a);
Int j=-1;
if(n > 0)
for(size_t i=0; i < size; i++)
if(read<bool>(a,i)) {
n--; if(n == 0) {j=(Int) i; break;}
}
if(n < 0)
for(size_t i=size; i > 0;)
if(read<bool>(a,--i)) {
n++; if(n == 0) {j=(Int) i; break;}
}
{Stack->push<Int>(j); return;}
}
// construct vector obtained by replacing those elements of b for which the
// corresponding elements of a are false by the corresponding element of c.
#line 5035 "runtime.in"
void arrayConditional(stack *Stack)
{
array * c=vm::pop<array *>(Stack);
array * b=vm::pop<array *>(Stack);
array * a=vm::pop<array *>(Stack);
#line 5036 "runtime.in"
size_t size=checkArray(a);
array *r=new array(size);
if(b && c) {
checkArrays(a,b);
checkArrays(b,c);
for(size_t i=0; i < size; i++)
(*r)[i]=read<bool>(a,i) ? (*b)[i] : (*c)[i];
} else {
r->clear();
if(b) {
checkArrays(a,b);
for(size_t i=0; i < size; i++)
if(read<bool>(a,i)) r->push((*b)[i]);
} else if(c) {
checkArrays(a,c);
for(size_t i=0; i < size; i++)
if(!read<bool>(a,i)) r->push((*c)[i]);
}
}
{Stack->push<array*>(r); return;}
}
// Return an n x n identity matrix.
#line 5060 "runtime.in"
// realarray2* identity(Int n);
void gen467(stack *Stack)
{
Int n=vm::pop<Int>(Stack);
#line 5061 "runtime.in"
{Stack->push<realarray2*>(Identity(n)); return;}
}
// Return the diagonal matrix with diagonal entries given by a.
#line 5066 "runtime.in"
void diagonal(stack *Stack)
{
realarray * a=vm::pop<realarray *>(Stack);
#line 5067 "runtime.in"
size_t n=checkArray(a);
array *c=new array(n);
for(size_t i=0; i < n; ++i) {
array *ci=new array(n);
(*c)[i]=ci;
for(size_t j=0; j < i; ++j)
(*ci)[j]=0.0;
(*ci)[i]=read<real>(a,i);
for(size_t j=i+1; j < n; ++j)
(*ci)[j]=0.0;
}
{Stack->push<realarray2*>(c); return;}
}
// Return the inverse of an n x n matrix a using Gauss-Jordan elimination.
#line 5083 "runtime.in"
// realarray2* inverse(realarray2 *a);
void gen469(stack *Stack)
{
realarray2 * a=vm::pop<realarray2 *>(Stack);
#line 5084 "runtime.in"
a=copyArray2(a);
size_t n=checkArray(a);
checkSquare(a);
inverseAllocate(n);
for(size_t i=0; i < n; i++)
pivot[i]=0;
size_t col=0, row=0;
// This is the main loop over the columns to be reduced.
for(size_t i=0; i < n; i++) {
real big=0.0;
// This is the outer loop of the search for a pivot element.
for(size_t j=0; j < n; j++) {
array *aj=read<array*>(a,j);
if(pivot[j] != 1) {
for(size_t k=0; k < n; k++) {
if(pivot[k] == 0) {
real temp=fabs(read<real>(aj,k));
if(temp >= big) {
big=temp;
row=j;
col=k;
}
} else if(pivot[k] > 1) {
inverseDeallocate();
error(singular);
}
}
}
}
++(pivot[col]);
// Interchange rows, if needed, to put the pivot element on the diagonal.
array *acol=read<array*>(a,col);
if(row != col) {
array *arow=read<array*>(a,row);
for(size_t l=0; l < n; l++) {
real temp=read<real>(arow,l);
(*arow)[l]=read<real>(acol,l);
(*acol)[l]=temp;
}
}
Row[i]=row;
Col[i]=col;
// Divide the pivot row by the pivot element.
real denom=read<real>(acol,col);
if(denom == 0.0) {
inverseDeallocate();
error(singular);
}
real pivinv=1.0/denom;
(*acol)[col]=1.0;
for(size_t l=0; l < n; l++)
(*acol)[l]=read<real>(acol,l)*pivinv;
// Reduce all rows except for the pivoted one.
for(size_t k=0; k < n; k++) {
if(k != col) {
array *ak=read<array*>(a,k);
real akcol=read<real>(ak,col);
(*ak)[col]=0.0;
for(size_t l=0; l < n; l++)
(*ak)[l]=read<real>(ak,l)-read<real>(acol,l)*akcol;
}
}
}
// Unscramble the inverse matrix in view of the column interchanges.
for(size_t l=n; l > 0;) {
l--;
size_t r=Row[l];
size_t c=Col[l];
if(r != c) {
for(size_t k=0; k < n; k++) {
array *ak=read<array*>(a,k);
real temp=read<real>(ak,r);
(*ak)[r]=read<real>(ak,c);
(*ak)[c]=temp;
}
}
}
inverseDeallocate();
{Stack->push<realarray2*>(a); return;}
}
// Solve the linear equation ax=b by LU decomposition, returning the
// solution x, where a is an n x n matrix and b is an array of length n.
// If no solution exists, return an empty array.
#line 5177 "runtime.in"
// realarray* solve(realarray2 *a, realarray *b, bool warn=true);
void gen470(stack *Stack)
{
bool warn=vm::pop<bool>(Stack,true);
realarray * b=vm::pop<realarray *>(Stack);
realarray2 * a=vm::pop<realarray2 *>(Stack);
#line 5178 "runtime.in"
size_t n=checkArray(a);
if(n == 0) {Stack->push<realarray*>(new array(0)); return;}
size_t m=checkArray(b);
if(m != n) error(incommensurate);
real *A=copyArray2C(a);
size_t *index=new size_t[n];
if(LUdecompose(A,n,index,warn) == 0)
{Stack->push<realarray*>(new array(0)); return;}
array *x=new array(n);
real *B=copyArrayC(b);
for(size_t i=0; i < n; ++i) {
size_t ip=index[i];
real sum=B[ip];
B[ip]=B[i];
real *Ai=A+i*n;
for(size_t j=0; j < i; ++j)
sum -= Ai[j]*B[j];
B[i]=sum;
}
for(size_t i=n; i > 0;) {
--i;
real sum=B[i];
real *Ai=A+i*n;
for(size_t j=i+1; j < n; ++j)
sum -= Ai[j]*B[j];
B[i]=sum/Ai[i];
}
for(size_t i=0; i < n; ++i)
(*x)[i]=B[i];
delete[] index;
delete[] B;
delete[] A;
{Stack->push<realarray*>(x); return;}
}
// Solve the linear equation ax=b by LU decomposition, returning the
// solution x, where a is an n x n matrix and b is an n x m matrix.
// If no solution exists, return an empty array.
#line 5228 "runtime.in"
// realarray2* solve(realarray2 *a, realarray2 *b, bool warn=true);
void gen471(stack *Stack)
{
bool warn=vm::pop<bool>(Stack,true);
realarray2 * b=vm::pop<realarray2 *>(Stack);
realarray2 * a=vm::pop<realarray2 *>(Stack);
#line 5229 "runtime.in"
size_t n=checkArray(a);
if(n == 0) {Stack->push<realarray2*>(new array(0)); return;}
if(checkArray(b) != n) error(incommensurate);
size_t m=checkArray(read<array*>(b,0));
real *A=copyArray2C(a);
real *B=copyArray2C(b,false);
size_t *index=new size_t[n];
if(LUdecompose(A,n,index,warn) == 0)
{Stack->push<realarray2*>(new array(0)); return;}
array *x=new array(n);
for(size_t i=0; i < n; ++i) {
real *Ai=A+i*n;
real *Bi=B+i*m;
real *Bip=B+index[i]*m;
for(size_t k=0; k < m; ++k) {
real sum=Bip[k];
Bip[k]=Bi[k];
size_t jk=k;
for(size_t j=0; j < i; ++j, jk += m)
sum -= Ai[j]*B[jk];
Bi[k]=sum;
}
}
for(size_t i=n; i > 0;) {
--i;
real *Ai=A+i*n;
real *Bi=B+i*m;
for(size_t k=0; k < m; ++k) {
real sum=Bi[k];
size_t jk=(i+1)*m+k;
for(size_t j=i+1; j < n; ++j, jk += m)
sum -= Ai[j]*B[jk];
Bi[k]=sum/Ai[i];
}
}
for(size_t i=0; i < n; ++i) {
real *Bi=B+i*m;
array *xi=new array(m);
(*x)[i]=xi;
for(size_t j=0; j < m; ++j)
(*xi)[j]=Bi[j];
}
delete[] index;
delete[] B;
delete[] A;
{Stack->push<realarray2*>(x); return;}
}
// Compute the determinant of an n x n matrix.
#line 5290 "runtime.in"
// real determinant(realarray2 *a);
void gen472(stack *Stack)
{
realarray2 * a=vm::pop<realarray2 *>(Stack);
#line 5291 "runtime.in"
real *A=copyArray2C(a);
size_t n=checkArray(a);
real det=LUdecompose(A,n,NULL,false);
size_t n1=n+1;
for(size_t i=0; i < n; ++i)
det *= A[i*n1];
delete[] A;
{Stack->push<real>(det); return;}
}
#line 5305 "runtime.in"
// realarray* *(realarray2 *a, realarray *b);
void gen473(stack *Stack)
{
realarray * b=vm::pop<realarray *>(Stack);
realarray2 * a=vm::pop<realarray2 *>(Stack);
#line 5306 "runtime.in"
size_t n=checkArray(a);
size_t m=checkArray(b);
array *c=new array(n);
real *B=copyArrayC(b);
for(size_t i=0; i < n; ++i) {
array *ai=read<array*>(a,i);
if(checkArray(ai) != m) error(incommensurate);
real sum=0.0;
for(size_t j=0; j < m; ++j)
sum += read<real>(ai,j)*B[j];
(*c)[i]=sum;
}
delete[] B;
{Stack->push<realarray*>(c); return;}
}
#line 5323 "runtime.in"
// realarray* *(realarray *a, realarray2 *b);
void gen474(stack *Stack)
{
realarray2 * b=vm::pop<realarray2 *>(Stack);
realarray * a=vm::pop<realarray *>(Stack);
#line 5324 "runtime.in"
size_t n=checkArray(a);
if(n != checkArray(b)) error(incommensurate);
real *A=copyArrayC(a);
array **B=new array*[n];
array *bk=read<array *>(b,0);
B[0]=bk;
size_t m=bk->size();
for(size_t k=1; k < n; k++) {
array *bk=read<array *>(b,k);
if(bk->size() != m) error(incommensurate);
B[k]=bk;
}
array *c=new array(m);
for(size_t i=0; i < m; ++i) {
real sum=0.0;
for(size_t k=0; k < n; ++k)
sum += A[k]*read<real>(B[k],i);
(*c)[i]=sum;
}
delete[] B;
delete[] A;
{Stack->push<realarray*>(c); return;}
}
#line 5351 "runtime.in"
// realarray2* *(realarray2 *a, realarray2 *b);
void gen475(stack *Stack)
{
realarray2 * b=vm::pop<realarray2 *>(Stack);
realarray2 * a=vm::pop<realarray2 *>(Stack);
#line 5352 "runtime.in"
size_t n=checkArray(a);
size_t nb=checkArray(b);
size_t na0=n == 0 ? 0 : checkArray(read<array*>(a,0));
if(na0 != nb)
error(incommensurate);
size_t nb0=nb == 0 ? 0 : checkArray(read<array*>(b,0));
array *c=new array(n);
real *A=copyArray2C(a,false);
real *B=copyArray2C(b,false);
for(size_t i=0; i < n; ++i) {
real *Ai=A+i*nb;
array *ci=new array(nb0);
(*c)[i]=ci;
for(size_t j=0; j < nb0; ++j) {
real sum=0.0;
size_t kj=j;
for(size_t k=0; k < nb; ++k, kj += nb0)
sum += Ai[k]*B[kj];
(*ci)[j]=sum;
}
}
delete[] B;
delete[] A;
{Stack->push<realarray2*>(c); return;}
}
#line 5386 "runtime.in"
// triple *(realarray2 *t, triple v);
void gen476(stack *Stack)
{
triple v=vm::pop<triple>(Stack);
realarray2 * t=vm::pop<realarray2 *>(Stack);
#line 5387 "runtime.in"
{Stack->push<triple>(*t*v); return;}
}
#line 5391 "runtime.in"
// pair project(triple v, realarray2 *t);
void gen477(stack *Stack)
{
realarray2 * t=vm::pop<realarray2 *>(Stack);
triple v=vm::pop<triple>(Stack);
#line 5392 "runtime.in"
size_t n=checkArray(t);
if(n != 4) error(incommensurate);
array *t0=read<array*>(t,0);
array *t1=read<array*>(t,1);
array *t3=read<array*>(t,3);
if(checkArray(t0) != 4 || checkArray(t1) != 4 || checkArray(t3) != 4)
error(incommensurate);
real x=v.getx();
real y=v.gety();
real z=v.getz();
real f=read<real>(t3,0)*x+read<real>(t3,1)*y+read<real>(t3,2)*z+
read<real>(t3,3);
if(f == 0.0) dividebyzero();
f=1.0/f;
{Stack->push<pair>(pair((read<real>(t0,0)*x+read<real>(t0,1)*y+read<real>(t0,2)*z+
read<real>(t0,3))*f,
(read<real>(t1,0)*x+read<real>(t1,1)*y+read<real>(t1,2)*z+
read<real>(t1,3))*f)); return;}
}
// Compute the dot product of vectors a and b.
#line 5417 "runtime.in"
// real dot(realarray *a, realarray *b);
void gen478(stack *Stack)
{
realarray * b=vm::pop<realarray *>(Stack);
realarray * a=vm::pop<realarray *>(Stack);
#line 5418 "runtime.in"
size_t n=checkArrays(a,b);
real sum=0.0;
for(size_t i=0; i < n; ++i)
sum += read<real>(a,i)*read<real>(b,i);
{Stack->push<real>(sum); return;}
}
// Solve the problem L\inv f, where f is an n vector and L is the n x n matrix
//
// [ b[0] c[0] a[0] ]
// [ a[1] b[1] c[1] ]
// [ a[2] b[2] c[2] ]
// [ ... ]
// [ c[n-1] a[n-1] b[n-1] ]
#line 5433 "runtime.in"
// realarray* tridiagonal(realarray *a, realarray *b, realarray *c, realarray *f);
void gen479(stack *Stack)
{
realarray * f=vm::pop<realarray *>(Stack);
realarray * c=vm::pop<realarray *>(Stack);
realarray * b=vm::pop<realarray *>(Stack);
realarray * a=vm::pop<realarray *>(Stack);
#line 5434 "runtime.in"
size_t n=checkArrays(a,b);
checkEqual(n,checkArray(c));
checkEqual(n,checkArray(f));
array *up=new array(n);
array& u=*up;
if(n == 0) {Stack->push<realarray*>(up); return;}
// Special case: zero Dirichlet boundary conditions
if(read<real>(a,0) == 0.0 && read<real>(c,n-1) == 0.0) {
real temp=read<real>(b,0);
if(temp == 0.0) dividebyzero();
temp=1.0/temp;
real *work=new real[n];
u[0]=read<real>(f,0)*temp;
work[0]=-read<real>(c,0)*temp;
for(size_t i=1; i < n; i++) {
real temp=(read<real>(b,i)+read<real>(a,i)*work[i-1]);
if(temp == 0.0) {delete[] work; dividebyzero();}
temp=1.0/temp;
u[i]=(read<real>(f,i)-read<real>(a,i)*read<real>(u,i-1))*temp;
work[i]=-read<real>(c,i)*temp;
}
for(size_t i=n-1; i >= 1; i--)
u[i-1]=read<real>(u,i-1)+work[i-1]*read<real>(u,i);
delete[] work;
{Stack->push<realarray*>(up); return;}
}
real binv=read<real>(b,0);
if(binv == 0.0) dividebyzero();
binv=1.0/binv;
if(n == 1) {u[0]=read<real>(f,0)*binv; {Stack->push<realarray*>(up); return;}}
if(n == 2) {
real factor=(read<real>(b,0)*read<real>(b,1)-
read<real>(a,0)*read<real>(c,1));
if(factor== 0.0) dividebyzero();
factor=1.0/factor;
real temp=(read<real>(b,0)*read<real>(f,1)-
read<real>(c,1)*read<real>(f,0))*factor;
u[0]=(read<real>(b,1)*read<real>(f,0)-
read<real>(a,0)*read<real>(f,1))*factor;
u[1]=temp;
{Stack->push<realarray*>(up); return;}
}
real *gamma=new real[n-2];
real *delta=new real[n-2];
gamma[0]=read<real>(c,0)*binv;
delta[0]=read<real>(a,0)*binv;
u[0]=read<real>(f,0)*binv;
real beta=read<real>(c,n-1);
real fn=read<real>(f,n-1)-beta*read<real>(u,0);
real alpha=read<real>(b,n-1)-beta*delta[0];
for(size_t i=1; i <= n-3; i++) {
real alphainv=read<real>(b,i)-read<real>(a,i)*gamma[i-1];
if(alphainv == 0.0) {delete[] gamma; delete[] delta; dividebyzero();}
alphainv=1.0/alphainv;
beta *= -gamma[i-1];
gamma[i]=read<real>(c,i)*alphainv;
u[i]=(read<real>(f,i)-read<real>(a,i)*read<real>(u,i-1))*alphainv;
fn -= beta*read<real>(u,i);
delta[i]=-read<real>(a,i)*delta[i-1]*alphainv;
alpha -= beta*delta[i];
}
real alphainv=read<real>(b,n-2)-read<real>(a,n-2)*gamma[n-3];
if(alphainv == 0.0) {delete[] gamma; delete[] delta; dividebyzero();}
alphainv=1.0/alphainv;
u[n-2]=(read<real>(f,n-2)-read<real>(a,n-2)*read<real>(u,n-3))
*alphainv;
beta=read<real>(a,n-1)-beta*gamma[n-3];
real dnm1=(read<real>(c,n-2)-read<real>(a,n-2)*delta[n-3])*alphainv;
real temp=alpha-beta*dnm1;
if(temp == 0.0) {delete[] gamma; delete[] delta; dividebyzero();}
u[n-1]=temp=(fn-beta*read<real>(u,n-2))/temp;
u[n-2]=read<real>(u,n-2)-dnm1*temp;
for(size_t i=n-2; i >= 1; i--)
u[i-1]=read<real>(u,i-1)-gamma[i-1]*read<real>(u,i)-delta[i-1]*temp;
delete[] delta;
delete[] gamma;
{Stack->push<realarray*>(up); return;}
}
// Root solve by Newton-Raphson
#line 5531 "runtime.in"
// real newton(Int iterations=100, callableReal *f, callableReal *fprime, real x, bool verbose=false);
void gen480(stack *Stack)
{
bool verbose=vm::pop<bool>(Stack,false);
real x=vm::pop<real>(Stack);
callableReal * fprime=vm::pop<callableReal *>(Stack);
callableReal * f=vm::pop<callableReal *>(Stack);
Int iterations=vm::pop<Int>(Stack,100);
#line 5533 "runtime.in"
static const real fuzz=1000.0*DBL_EPSILON;
Int i=0;
size_t oldPrec=0;
if(verbose)
oldPrec=cout.precision(DBL_DIG);
real diff=DBL_MAX;
real lastdiff;
do {
real x0=x;
Stack->push(x);
fprime->call(Stack);
real dfdx=pop<real>(Stack);
if(dfdx == 0.0) {
x=DBL_MAX;
break;
}
Stack->push(x);
f->call(Stack);
real fx=pop<real>(Stack);
x -= fx/dfdx;
lastdiff=diff;
if(verbose)
cout << "Newton-Raphson: " << x << endl;
diff=fabs(x-x0);
if(++i == iterations) {
x=DBL_MAX;
break;
}
} while (diff != 0.0 && (diff < lastdiff || diff > fuzz*fabs(x)));
if(verbose)
cout.precision(oldPrec);
{Stack->push<real>(x); return;}
}
// Root solve by Newton-Raphson bisection
// cf. routine rtsafe (Press et al., Numerical Recipes, 1991).
#line 5579 "runtime.in"
// real newton(Int iterations=100, callableReal *f, callableReal *fprime, real x1, real x2, bool verbose=false);
void gen481(stack *Stack)
{
bool verbose=vm::pop<bool>(Stack,false);
real x2=vm::pop<real>(Stack);
real x1=vm::pop<real>(Stack);
callableReal * fprime=vm::pop<callableReal *>(Stack);
callableReal * f=vm::pop<callableReal *>(Stack);
Int iterations=vm::pop<Int>(Stack,100);
#line 5581 "runtime.in"
static const real fuzz=1000.0*DBL_EPSILON;
size_t oldPrec=0;
if(verbose)
oldPrec=cout.precision(DBL_DIG);
Stack->push(x1);
f->call(Stack);
real f1=pop<real>(Stack);
if(f1 == 0.0) {Stack->push<real>(x1); return;}
Stack->push(x2);
f->call(Stack);
real f2=pop<real>(Stack);
if(f2 == 0.0) {Stack->push<real>(x2); return;}
if((f1 > 0.0 && f2 > 0.0) || (f1 < 0.0 && f2 < 0.0)) {
ostringstream buf;
buf << "root not bracketed, f(x1)=" << f1 << ", f(x2)=" << f2 << endl;
error(buf);
}
real x=0.5*(x1+x2);
real dxold=fabs(x2-x1);
if(f1 > 0.0) {
real temp=x1;
x1=x2;
x2=temp;
}
if(verbose)
cout << "midpoint: " << x << endl;
real dx=dxold;
Stack->push(x);
f->call(Stack);
real y=pop<real>(Stack);
Stack->push(x);
fprime->call(Stack);
real dy=pop<real>(Stack);
Int j;
for(j=0; j < iterations; j++) {
if(((x-x2)*dy-y)*((x-x1)*dy-y) >= 0.0 || fabs(2.0*y) > fabs(dxold*dy)) {
dxold=dx;
dx=0.5*(x2-x1);
x=x1+dx;
if(verbose)
cout << "bisection: " << x << endl;
if(x1 == x) {Stack->push<real>(x); return;}
} else {
dxold=dx;
dx=y/dy;
real temp=x;
x -= dx;
if(verbose)
cout << "Newton-Raphson: " << x << endl;
if(temp == x) {Stack->push<real>(x); return;}
}
if(fabs(dx) < fuzz*fabs(x)) {Stack->push<real>(x); return;}
Stack->push(x);
f->call(Stack);
y=pop<real>(Stack);
Stack->push(x);
fprime->call(Stack);
dy=pop<real>(Stack);
if(y < 0.0) x1=x;
else x2=x;
}
if(verbose)
cout.precision(oldPrec);
{Stack->push<real>((j == iterations) ? DBL_MAX : x); return;}
}
#line 5659 "runtime.in"
// real simpson(callableReal *f, real a, real b, real acc=DBL_EPSILON, real dxmax=0);
void gen482(stack *Stack)
{
real dxmax=vm::pop<real>(Stack,0);
real acc=vm::pop<real>(Stack,DBL_EPSILON);
real b=vm::pop<real>(Stack);
real a=vm::pop<real>(Stack);
callableReal * f=vm::pop<callableReal *>(Stack);
#line 5661 "runtime.in"
real integral;
if(dxmax == 0) dxmax=b-a;
Func=f;
FuncStack=Stack;
if(!simpson(integral,wrapFunction,a,b,acc,dxmax))
error("nesting capacity exceeded in simpson");
{Stack->push<real>(integral); return;}
}
// Compute the fast Fourier transform of a pair array
#line 5672 "runtime.in"
void pairArrayFFT(stack *Stack)
{
Int sign=vm::pop<Int>(Stack,1);
pairarray * a=vm::pop<pairarray *>(Stack);
#line 5673 "runtime.in"
unsigned n=(unsigned) checkArray(a);
#ifdef HAVE_LIBFFTW3
array *c=new array(n);
if(n) {
Complex *f=FFTWComplex(n);
fft1d Forward(n,intcast(sign),f);
for(size_t i=0; i < n; i++) {
pair z=read<pair>(a,i);
f[i]=Complex(z.getx(),z.gety());
}
Forward.fft(f);
for(size_t i=0; i < n; i++) {
Complex z=f[i];
(*c)[i]=pair(z.real(),z.imag());
}
FFTWdelete(f);
}
#else
unused(&n);
unused(&sign);
array *c=new array(0);
#endif // HAVE_LIBFFTW3
{Stack->push<pairarray*>(c); return;}
}
#line 5701 "runtime.in"
// Intarray2* triangulate(pairarray *z);
void gen484(stack *Stack)
{
pairarray * z=vm::pop<pairarray *>(Stack);
#line 5702 "runtime.in"
size_t nv=checkArray(z);
// Call robust version of Gilles Dumoulin's port of Paul Bourke's
// triangulation code.
XYZ *pxyz=new XYZ[nv+3];
ITRIANGLE *V=new ITRIANGLE[4*nv];
for(size_t i=0; i < nv; ++i) {
pair w=read<pair>(z,i);
pxyz[i].p[0]=w.getx();
pxyz[i].p[1]=w.gety();
pxyz[i].i=(Int) i;
}
Int ntri;
Triangulate((Int) nv,pxyz,V,ntri,true,false);
size_t nt=(size_t) ntri;
array *t=new array(nt);
for(size_t i=0; i < nt; ++i) {
array *ti=new array(3);
(*t)[i]=ti;
ITRIANGLE *Vi=V+i;
(*ti)[0]=pxyz[Vi->p1].i;
(*ti)[1]=pxyz[Vi->p2].i;
(*ti)[2]=pxyz[Vi->p3].i;
}
delete[] V;
delete[] pxyz;
{Stack->push<Intarray2*>(t); return;}
}
// File operations
#line 5738 "runtime.in"
// bool ==(file *a, file *b);
void gen485(stack *Stack)
{
file * b=vm::pop<file *>(Stack);
file * a=vm::pop<file *>(Stack);
#line 5739 "runtime.in"
{Stack->push<bool>(a == b); return;}
}
#line 5744 "runtime.in"
// bool !=(file *a, file *b);
void gen486(stack *Stack)
{
file * b=vm::pop<file *>(Stack);
file * a=vm::pop<file *>(Stack);
#line 5745 "runtime.in"
{Stack->push<bool>(a != b); return;}
}
#line 5749 "runtime.in"
void nullFile(stack *Stack)
{
#line 5750 "runtime.in"
{Stack->push<file*>(&camp::nullfile); return;}
}
#line 5754 "runtime.in"
// file* input(string name, bool check=true, string comment=commentchar);
void gen488(stack *Stack)
{
string comment=vm::pop<string>(Stack,commentchar);
bool check=vm::pop<bool>(Stack,true);
string name=vm::pop<string>(Stack);
#line 5755 "runtime.in"
char c=comment.empty() ? (char) 0 : comment[0];
file *f=new ifile(name,c,check);
f->open();
{Stack->push<file*>(f); return;}
}
#line 5762 "runtime.in"
// file* output(string name, bool update=false, string comment=commentchar);
void gen489(stack *Stack)
{
string comment=vm::pop<string>(Stack,commentchar);
bool update=vm::pop<bool>(Stack,false);
string name=vm::pop<string>(Stack);
#line 5763 "runtime.in"
file *f;
if(update) {
char c=comment.empty() ? (char) 0 : comment[0];
f=new iofile(name,c);
} else f=new ofile(name);
f->open();
if(update) f->seek(0,false);
{Stack->push<file*>(f); return;}
}
#line 5774 "runtime.in"
// file* xinput(string name, bool check=true);
void gen490(stack *Stack)
{
bool check=vm::pop<bool>(Stack,true);
string name=vm::pop<string>(Stack);
#line 5775 "runtime.in"
#ifdef HAVE_RPC_RPC_H
file *f=new ixfile(name,check);
f->open();
{Stack->push<file*>(f); return;}
#else
ostringstream buf;
buf << name << ": XDR read support not enabled";
error(buf);
unused(&check); // Suppress unused variable warning
#endif
}
#line 5788 "runtime.in"
// file* xoutput(string name, bool update=false);
void gen491(stack *Stack)
{
bool update=vm::pop<bool>(Stack,false);
string name=vm::pop<string>(Stack);
#line 5789 "runtime.in"
#ifdef HAVE_RPC_RPC_H
file *f;
if(update)
f=new ioxfile(name);
else f=new oxfile(name);
f->open();
if(update) f->seek(0,false);
{Stack->push<file*>(f); return;}
#else
ostringstream buf;
buf << name << ": XDR write support not enabled";
error(buf);
unused(&update); // Suppress unused variable warning
#endif
}
#line 5806 "runtime.in"
// file* binput(string name, bool check=true);
void gen492(stack *Stack)
{
bool check=vm::pop<bool>(Stack,true);
string name=vm::pop<string>(Stack);
#line 5807 "runtime.in"
file *f=new ibfile(name,check);
f->open();
{Stack->push<file*>(f); return;}
}
#line 5813 "runtime.in"
// file* boutput(string name, bool update=false);
void gen493(stack *Stack)
{
bool update=vm::pop<bool>(Stack,false);
string name=vm::pop<string>(Stack);
#line 5814 "runtime.in"
file *f;
if(update) f=new iobfile(name);
else f=new obfile(name);
f->open();
if(update) f->seek(0,false);
{Stack->push<file*>(f); return;}
}
#line 5823 "runtime.in"
// bool eof(file *f);
void gen494(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5824 "runtime.in"
{Stack->push<bool>(f->eof()); return;}
}
#line 5828 "runtime.in"
// bool eol(file *f);
void gen495(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5829 "runtime.in"
{Stack->push<bool>(f->eol()); return;}
}
#line 5833 "runtime.in"
// bool error(file *f);
void gen496(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5834 "runtime.in"
{Stack->push<bool>(f->error()); return;}
}
#line 5838 "runtime.in"
// void clear(file *f);
void gen497(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5839 "runtime.in"
f->clear();
}
#line 5843 "runtime.in"
// void close(file *f);
void gen498(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5844 "runtime.in"
f->close();
}
#line 5848 "runtime.in"
// Int precision(file *f=NULL, Int digits=0);
void gen499(stack *Stack)
{
Int digits=vm::pop<Int>(Stack,0);
file * f=vm::pop<file *>(Stack,NULL);
#line 5849 "runtime.in"
if(f == 0) f=&camp::Stdout;
{Stack->push<Int>(f->precision(digits)); return;}
}
#line 5854 "runtime.in"
// void flush(file *f);
void gen500(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5855 "runtime.in"
f->flush();
}
#line 5859 "runtime.in"
// string getc(file *f);
void gen501(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5860 "runtime.in"
char c=0;
if(f->isOpen()) f->read(c);
static char str[1];
str[0]=c;
{Stack->push<string>(string(str)); return;}
}
#line 5868 "runtime.in"
// Int tell(file *f);
void gen502(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5869 "runtime.in"
{Stack->push<Int>(f->tell()); return;}
}
#line 5873 "runtime.in"
// void seek(file *f, Int pos);
void gen503(stack *Stack)
{
Int pos=vm::pop<Int>(Stack);
file * f=vm::pop<file *>(Stack);
#line 5874 "runtime.in"
f->seek(pos,pos >= 0);
}
#line 5878 "runtime.in"
// void seekeof(file *f);
void gen504(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5879 "runtime.in"
f->seek(0,false);
}
// Set file dimensions
#line 5884 "runtime.in"
// file* dimension(file *f, Int nx);
void gen505(stack *Stack)
{
Int nx=vm::pop<Int>(Stack);
file * f=vm::pop<file *>(Stack);
#line 5885 "runtime.in"
f->dimension(nx);
{Stack->push<file*>(f); return;}
}
#line 5890 "runtime.in"
// file* dimension(file *f, Int nx, Int ny);
void gen506(stack *Stack)
{
Int ny=vm::pop<Int>(Stack);
Int nx=vm::pop<Int>(Stack);
file * f=vm::pop<file *>(Stack);
#line 5891 "runtime.in"
f->dimension(nx,ny);
{Stack->push<file*>(f); return;}
}
#line 5896 "runtime.in"
// file* dimension(file *f, Int nx, Int ny, Int nz);
void gen507(stack *Stack)
{
Int nz=vm::pop<Int>(Stack);
Int ny=vm::pop<Int>(Stack);
Int nx=vm::pop<Int>(Stack);
file * f=vm::pop<file *>(Stack);
#line 5897 "runtime.in"
f->dimension(nx,ny,nz);
{Stack->push<file*>(f); return;}
}
// Set file to read comma-separated values
#line 5903 "runtime.in"
// file* csv(file *f, bool b=true);
void gen508(stack *Stack)
{
bool b=vm::pop<bool>(Stack,true);
file * f=vm::pop<file *>(Stack);
#line 5904 "runtime.in"
f->CSVMode(b);
{Stack->push<file*>(f); return;}
}
// Set file to read whitespace-separated values
#line 5910 "runtime.in"
// file* word(file *f, bool b=true);
void gen509(stack *Stack)
{
bool b=vm::pop<bool>(Stack,true);
file * f=vm::pop<file *>(Stack);
#line 5911 "runtime.in"
f->WordMode(b);
{Stack->push<file*>(f); return;}
}
// Set file to read arrays in line-at-a-time mode
#line 5917 "runtime.in"
// file* line(file *f, bool b=true);
void gen510(stack *Stack)
{
bool b=vm::pop<bool>(Stack,true);
file * f=vm::pop<file *>(Stack);
#line 5918 "runtime.in"
f->LineMode(b);
{Stack->push<file*>(f); return;}
}
// Set file to read/write signed int XDR values.
#line 5924 "runtime.in"
// file* signed(file *f, bool b=true);
void gen511(stack *Stack)
{
bool b=vm::pop<bool>(Stack,true);
file * f=vm::pop<file *>(Stack);
#line 5925 "runtime.in"
f->SignedInt(b);
{Stack->push<file*>(f); return;}
}
#line 5930 "runtime.in"
void namePart(stack *Stack)
{
file f=vm::pop<file>(Stack);
#line 5931 "runtime.in"
{Stack->push<string>(f.filename()); return;}
}
#line 5935 "runtime.in"
void modePart(stack *Stack)
{
file f=vm::pop<file>(Stack);
#line 5936 "runtime.in"
{Stack->push<string>(f.FileMode()); return;}
}
#line 5940 "runtime.in"
void dimensionPart(stack *Stack)
{
file f=vm::pop<file>(Stack);
#line 5941 "runtime.in"
array *a=new array(3);
(*a)[0]=f.Nx();
(*a)[1]=f.Ny();
(*a)[2]=f.Nz();
{Stack->push<array*>(a); return;}
}
#line 5949 "runtime.in"
void lineModePart(stack *Stack)
{
file f=vm::pop<file>(Stack);
#line 5950 "runtime.in"
{Stack->push<bool>(f.LineMode()); return;}
}
#line 5954 "runtime.in"
void csvModePart(stack *Stack)
{
file f=vm::pop<file>(Stack);
#line 5955 "runtime.in"
{Stack->push<bool>(f.CSVMode()); return;}
}
#line 5959 "runtime.in"
void wordModePart(stack *Stack)
{
file f=vm::pop<file>(Stack);
#line 5960 "runtime.in"
{Stack->push<bool>(f.WordMode()); return;}
}
#line 5964 "runtime.in"
void singleRealModePart(stack *Stack)
{
file f=vm::pop<file>(Stack);
#line 5965 "runtime.in"
{Stack->push<bool>(f.SingleReal()); return;}
}
#line 5969 "runtime.in"
void singleIntModePart(stack *Stack)
{
file f=vm::pop<file>(Stack);
#line 5970 "runtime.in"
{Stack->push<bool>(f.SingleInt()); return;}
}
#line 5974 "runtime.in"
void signedIntModePart(stack *Stack)
{
file f=vm::pop<file>(Stack);
#line 5975 "runtime.in"
{Stack->push<bool>(f.SignedInt()); return;}
}
// Set file to read an array1 (1 int size followed by a 1d array)
#line 5980 "runtime.in"
// file* read1(file *f);
void gen521(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5981 "runtime.in"
f->dimension(-2);
{Stack->push<file*>(f); return;}
}
// Set file to read an array2 (2 int sizes followed by a 2d array)
#line 5987 "runtime.in"
// file* read2(file *f);
void gen522(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5988 "runtime.in"
f->dimension(-2,-2);
{Stack->push<file*>(f); return;}
}
// Set file to read an array3 (3 int sizes followed by a 3d array)
#line 5994 "runtime.in"
// file* read3(file *f);
void gen523(stack *Stack)
{
file * f=vm::pop<file *>(Stack);
#line 5995 "runtime.in"
f->dimension(-2,-2,-2);
{Stack->push<file*>(f); return;}
}
// Return the last n lines of the history named name.
#line 6001 "runtime.in"
// stringarray* history(string name, Int n=1);
void gen524(stack *Stack)
{
Int n=vm::pop<Int>(Stack,1);
string name=vm::pop<string>(Stack);
#line 6002 "runtime.in"
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
bool newhistory=historyMap.find(name) == historyMap.end();
string filename;
if(newhistory) {
filename=historyfilename(name);
std::ifstream exists(filename.c_str());
if(!exists) {Stack->push<stringarray*>(new array(0)); return;}
}
store_history(&history_save);
HISTORY_STATE& history=historyMap[name].state;
history_set_history_state(&history);
if(newhistory)
read_history(filename.c_str());
array *a=get_history(n);
store_history(&history);
history_set_history_state(&history_save);
{Stack->push<stringarray*>(a); return;}
#else
unused(&n);
{Stack->push<stringarray*>(new array(0)); return;}
#endif
}
// Return the last n lines of the interactive history.
#line 6034 "runtime.in"
// stringarray* history(Int n=0);
void gen525(stack *Stack)
{
Int n=vm::pop<Int>(Stack,0);
#line 6035 "runtime.in"
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
{Stack->push<stringarray*>(get_history(n)); return;}
#else
unused(&n);
{Stack->push<stringarray*>(new array(0)); return;}
#endif
}
// Prompt for a string using prompt, the GNU readline library, and a
// local history named name.
#line 6046 "runtime.in"
// string readline(string prompt=emptystring, string name=emptystring, bool tabcompletion=false);
void gen526(stack *Stack)
{
bool tabcompletion=vm::pop<bool>(Stack,false);
string name=vm::pop<string>(Stack,emptystring);
string prompt=vm::pop<string>(Stack,emptystring);
#line 6048 "runtime.in"
if(!isatty(STDIN_FILENO))
{Stack->push<string>(emptystring); return;}
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
init_readline(tabcompletion);
store_history(&history_save);
bool newhistory=historyMap.find(name) == historyMap.end();
historyState& h=historyMap[name];
HISTORY_STATE& history=h.state;
history_set_history_state(&history);
if(newhistory)
read_history(historyfilename(name).c_str());
static char *line=NULL;
/* Return the memory to the free pool
if the buffer has already been allocated. */
if(line) {
free(line);
line=NULL;
}
/* Get a line from the user. */
line=readline(prompt.c_str());
if(!line) cout << endl;
history_set_history_state(&history_save);
{Stack->push<string>(line ? string(line) : emptystring); return;}
#else
cout << prompt;
string s;
getline(cin,s);
unused(&tabcompletion); // Avoid unused variable warning message.
{Stack->push<string>(s); return;}
#endif
}
// Save a string in a local history named name.
// If store=true, store the local history in the file historyfilename(name).
#line 6090 "runtime.in"
// void saveline(string name, string value, bool store=true);
void gen527(stack *Stack)
{
bool store=vm::pop<bool>(Stack,true);
string value=vm::pop<string>(Stack);
string name=vm::pop<string>(Stack);
#line 6091 "runtime.in"
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
store_history(&history_save);
bool newhistory=historyMap.find(name) == historyMap.end();
historyState& h=historyMap[name];
h.store=store;
HISTORY_STATE& history=h.state;
history_set_history_state(&history);
if(newhistory)
read_history(historyfilename(name).c_str());
if(value != "") {
add_history(value.c_str());
if(store) {
std::ofstream hout(historyfilename(name).c_str(),std::ios::app);
hout << value << endl;
}
}
store_history(&history);
history_set_history_state(&history_save);
#else
unused(&store);
#endif
}
#line 6118 "runtime.in"
// void generate_random_backtrace();
void gen528(stack *)
{
#line 6119 "runtime.in"
#if defined(USEGC) && defined(GC_DEBUG) && defined(GC_BACKTRACE)
GC_generate_random_backtrace();
#else
error("generate_random_backtrace() requires ./configure --enable-gc-debug");
#endif
}
#line 6127 "runtime.in"
// void print_random_addresses(Int n=1);
void gen529(stack *Stack)
{
Int n=vm::pop<Int>(Stack,1);
#line 6128 "runtime.in"
#if defined(USEGC) && defined(GC_DEBUG) && defined(GC_BACKTRACE)
GC_gcollect();
for (Int i=0; i < n; ++i)
GC_debug_print_heap_obj_proc(GC_base(GC_generate_random_valid_address()));
#else
error("print_random_addresses() requires ./configure --enable-gc-debug");
unused(&n); // Avoid unused variable warning message.
#endif
}
} // namespace run
namespace trans {
void gen_base_venv(venv &ve)
{
#line 1177 "runtime.in"
addFunc(ve, run::gen8, primBoolean(), "!", formal(primBoolean(), "b", false, false));
#line 1205 "runtime.in"
addFunc(ve, run::gen13, primInt(), "AND", formal(primInt(), "a", false, false), formal(primInt(), "b", false, false));
#line 1213 "runtime.in"
addFunc(ve, run::gen14, primInt(), "OR", formal(primInt(), "a", false, false), formal(primInt(), "b", false, false));
#line 1218 "runtime.in"
addFunc(ve, run::gen15, primInt(), "XOR", formal(primInt(), "a", false, false), formal(primInt(), "b", false, false));
#line 1223 "runtime.in"
addFunc(ve, run::gen16, primInt(), "NOT", formal(primInt(), "a", false, false));
#line 1254 "runtime.in"
addFunc(ve, run::gen21, primBoolean(), "empty", formal(primPicture(), "f", false, false));
#line 1259 "runtime.in"
addFunc(ve, run::gen22, primVoid(), "erase", formal(primPicture(), "f", false, false));
#line 1264 "runtime.in"
addFunc(ve, run::gen23, primPair(), "min", formal(primPicture(), "f", false, false));
#line 1269 "runtime.in"
addFunc(ve, run::gen24, primPair(), "max", formal(primPicture(), "f", false, false));
#line 1274 "runtime.in"
addFunc(ve, run::gen25, primVoid(), "label", formal(primPicture(), "f", false, false), formal(primString(), "s", false, false), formal(primString(), "size", false, false), formal(primTransform(), "t", false, false), formal(primPair(), "position", false, false), formal(primPair(), "align", false, false), formal(primPen(), "p", false, false));
#line 1280 "runtime.in"
addFunc(ve, run::gen26, primBoolean(), "labels", formal(primPicture(), "f", false, false));
#line 1285 "runtime.in"
addFunc(ve, run::gen27, realArray(), "texsize", formal(primString(), "s", false, false), formal(primPen(), "p", true, false));
#line 1305 "runtime.in"
addFunc(ve, run::gen28, pathArray() , "_texpath", formal(primString(), "s", false, false), formal(primPen(), "p", true, false));
#line 1413 "runtime.in"
addFunc(ve, run::gen29, pathArray() , "textpath", formal(primString(), "s", false, false), formal(primPen(), "p", true, false));
#line 1477 "runtime.in"
addFunc(ve, run::gen30, pathArray() , "_strokepath", formal(primPath(), "g", false, false), formal(primPen(), "p", true, false));
#line 1502 "runtime.in"
addFunc(ve, run::gen31, primVoid(), "_draw", formal(primPicture(), "f", false, false), formal(primPath(), "g", false, false), formal(primPen(), "p", false, false));
#line 1507 "runtime.in"
addFunc(ve, run::gen32, primVoid(), "fill", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primPen(), "p", true, false), formal(primBoolean(), "copy", true, false));
#line 1513 "runtime.in"
addFunc(ve, run::gen33, primVoid(), "latticeshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray2() , "p", false, false), formal(primBoolean(), "copy", true, false));
#line 1520 "runtime.in"
addFunc(ve, run::gen34, primVoid(), "axialshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "pena", false, false), formal(primPair(), "a", false, false), formal(primPen(), "penb", false, false), formal(primPair(), "b", false, false), formal(primBoolean(), "copy", true, false));
#line 1527 "runtime.in"
addFunc(ve, run::gen35, primVoid(), "radialshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "pena", false, false), formal(primPair(), "a", false, false), formal(primReal(), "ra", false, false), formal(primPen(), "penb", false, false), formal(primPair(), "b", false, false), formal(primReal(), "rb", false, false), formal(primBoolean(), "copy", true, false));
#line 1534 "runtime.in"
addFunc(ve, run::gen36, primVoid(), "gouraudshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray() , "p", false, false), formal(pairArray(), "z", false, false), formal(IntArray(), "edges", false, false), formal(primBoolean(), "copy", true, false));
#line 1545 "runtime.in"
addFunc(ve, run::gen37, primVoid(), "gouraudshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray() , "p", false, false), formal(IntArray(), "edges", false, false), formal(primBoolean(), "copy", true, false));
#line 1569 "runtime.in"
addFunc(ve, run::gen38, primVoid(), "tensorshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(penArray2() , "p", false, false), formal(pathArray() , "b", true, false), formal(pairArray2(), "z", true, false), formal(primBoolean(), "copy", true, false));
#line 1584 "runtime.in"
addFunc(ve, run::gen39, primVoid(), "functionshade", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(primString() , "shader", true, false), formal(primBoolean(), "copy", true, false));
#line 1592 "runtime.in"
addFunc(ve, run::gen40, primVoid(), "clip", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(primBoolean(), "copy", true, false));
#line 1602 "runtime.in"
addFunc(ve, run::gen41, primVoid(), "beginclip", formal(primPicture(), "f", false, false), formal(pathArray() , "g", false, false), formal(primBoolean(), "stroke", true, false), formal(primPen(), "fillrule", true, false), formal(primBoolean(), "copy", true, false));
#line 1609 "runtime.in"
addFunc(ve, run::gen42, primVoid(), "endclip", formal(primPicture(), "f", false, false));
#line 1614 "runtime.in"
addFunc(ve, run::gen43, primVoid(), "gsave", formal(primPicture(), "f", false, false));
#line 1619 "runtime.in"
addFunc(ve, run::gen44, primVoid(), "grestore", formal(primPicture(), "f", false, false));
#line 1624 "runtime.in"
addFunc(ve, run::gen45, primVoid(), "begingroup", formal(primPicture(), "f", false, false));
#line 1629 "runtime.in"
addFunc(ve, run::gen46, primVoid(), "endgroup", formal(primPicture(), "f", false, false));
#line 1634 "runtime.in"
addFunc(ve, run::gen47, primVoid(), "add", formal(primPicture(), "dest", false, false), formal(primPicture(), "src", false, false));
#line 1639 "runtime.in"
addFunc(ve, run::gen48, primVoid(), "prepend", formal(primPicture(), "dest", false, false), formal(primPicture(), "src", false, false));
#line 1644 "runtime.in"
addFunc(ve, run::gen49, primVoid(), "postscript", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false));
#line 1649 "runtime.in"
addFunc(ve, run::gen50, primVoid(), "tex", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false));
#line 1654 "runtime.in"
addFunc(ve, run::gen51, primVoid(), "postscript", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false), formal(primPair(), "min", false, false), formal(primPair(), "max", false, false));
#line 1659 "runtime.in"
addFunc(ve, run::gen52, primVoid(), "tex", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false), formal(primPair(), "min", false, false), formal(primPair(), "max", false, false));
#line 1664 "runtime.in"
addFunc(ve, run::gen53, primVoid(), "texpreamble", formal(primString() , "s", false, false));
#line 1672 "runtime.in"
addFunc(ve, run::gen54, primVoid(), "deletepreamble");
#line 1679 "runtime.in"
addFunc(ve, run::gen55, primVoid(), "_labelpath", formal(primPicture(), "f", false, false), formal(primString() , "s", false, false), formal(primString() , "size", false, false), formal(primPath(), "g", false, false), formal(primString() , "justify", false, false), formal(primPair(), "offset", false, false), formal(primPen(), "p", false, false));
#line 1685 "runtime.in"
addFunc(ve, run::gen56, primVoid(), "texreset");
#line 1693 "runtime.in"
addFunc(ve, run::gen57, primVoid(), "layer", formal(primPicture(), "f", false, false));
#line 1698 "runtime.in"
addFunc(ve, run::gen58, primVoid(), "newpage", formal(primPicture(), "f", false, false));
#line 1703 "runtime.in"
addFunc(ve, run::gen59, primVoid(), "_image", formal(primPicture(), "f", false, false), formal(realArray2(), "data", false, false), formal(primPair(), "initial", false, false), formal(primPair(), "final", false, false), formal(penArray() , "palette", true, false), formal(primTransform(), "t", true, false), formal(primBoolean(), "copy", true, false), formal(primBoolean(), "antialias", true, false));
#line 1713 "runtime.in"
addFunc(ve, run::gen60, primVoid(), "_image", formal(primPicture(), "f", false, false), formal(penArray2() , "data", false, false), formal(primPair(), "initial", false, false), formal(primPair(), "final", false, false), formal(primTransform(), "t", true, false), formal(primBoolean(), "copy", true, false), formal(primBoolean(), "antialias", true, false));
#line 1720 "runtime.in"
addFunc(ve, run::gen61, primString() , "nativeformat");
#line 1725 "runtime.in"
addFunc(ve, run::gen62, primBoolean(), "latex");
#line 1730 "runtime.in"
addFunc(ve, run::gen63, primBoolean(), "pdf");
#line 1735 "runtime.in"
addFunc(ve, run::gen64, primVoid(), "shipout", formal(primString() , "prefix", true, false), formal(primPicture(), "f", false, false), formal(primPicture(), "preamble", true, false), formal(primString() , "format", true, false), formal(primBoolean(), "wait", true, false), formal(primBoolean(), "view", true, false), formal(transformFunction(), "xform", false, false));
#line 1781 "runtime.in"
addFunc(ve, run::gen65, primVoid(), "shipout3", formal(primString() , "prefix", false, false), formal(primPicture(), "f", false, false), formal(primString() , "format", true, false), formal(primReal(), "width", false, false), formal(primReal(), "height", false, false), formal(primReal(), "angle", false, false), formal(primReal(), "zoom", false, false), formal(primTriple(), "m", false, false), formal(primTriple(), "m", false, false), formal(primPair(), "shift", false, false), formal(realArray2(), "t", false, false), formal(realArray(), "background", false, false), formal(tripleArray(), "lights", false, false), formal(realArray2(), "diffuse", false, false), formal(realArray2(), "ambient", false, false), formal(realArray2(), "specular", false, false), formal(primBoolean(), "viewportlighting", false, false), formal(primBoolean(), "view", true, false));
#line 1799 "runtime.in"
addFunc(ve, run::gen66, primVoid(), "shipout3", formal(primString() , "prefix", false, false), formal(primPicture(), "f", false, false));
#line 1804 "runtime.in"
addFunc(ve, run::gen67, primVoid(), "deconstruct", formal(primPicture(), "f", false, false), formal(primPicture(), "preamble", true, false), formal(primReal(), "magnification", true, false), formal(transformFunction(), "xform", false, false));
#line 1937 "runtime.in"
addFunc(ve, run::gen68, primVoid(), "purge", formal(primInt(), "divisor", true, false));
#line 1950 "runtime.in"
addFunc(ve, run::gen70, primBoolean(), "==", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false));
#line 1955 "runtime.in"
addFunc(ve, run::gen71, primBoolean(), "!=", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false));
#line 1960 "runtime.in"
addFunc(ve, run::gen72, primPen(), "+", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false));
#line 1965 "runtime.in"
addFunc(ve, run::gen73, primPen(), "*", formal(primReal(), "a", false, false), formal(primPen(), "b", false, false));
#line 1970 "runtime.in"
addFunc(ve, run::gen74, primPen(), "*", formal(primPen(), "a", false, false), formal(primReal(), "b", false, false));
#line 1975 "runtime.in"
addFunc(ve, run::gen75, primPair(), "max", formal(primPen(), "p", false, false));
#line 1980 "runtime.in"
addFunc(ve, run::gen76, primPair(), "min", formal(primPen(), "p", false, false));
#line 1985 "runtime.in"
addFunc(ve, run::gen77, primVoid(), "resetdefaultpen");
#line 1991 "runtime.in"
addFunc(ve, run::gen78, primVoid(), "defaultpen", formal(primPen(), "p", false, false));
#line 1996 "runtime.in"
addFunc(ve, run::gen79, primPen(), "defaultpen");
#line 2001 "runtime.in"
addFunc(ve, run::gen80, primBoolean(), "invisible", formal(primPen(), "p", false, false));
#line 2006 "runtime.in"
addFunc(ve, run::gen81, primPen(), "invisible");
#line 2011 "runtime.in"
addFunc(ve, run::gen82, primPen(), "gray", formal(primPen(), "p", false, false));
#line 2017 "runtime.in"
addFunc(ve, run::gen83, primPen(), "rgb", formal(primPen(), "p", false, false));
#line 2023 "runtime.in"
addFunc(ve, run::gen84, primPen(), "cmyk", formal(primPen(), "p", false, false));
#line 2029 "runtime.in"
addFunc(ve, run::gen85, primPen(), "interp", formal(primPen(), "a", false, false), formal(primPen(), "b", false, false), formal(primReal(), "t", false, false));
#line 2034 "runtime.in"
addFunc(ve, run::gen86, primPen(), "rgb", formal(primReal(), "r", false, false), formal(primReal(), "g", false, false), formal(primReal(), "b", false, false));
#line 2039 "runtime.in"
addFunc(ve, run::gen87, primPen(), "cmyk", formal(primReal(), "c", false, false), formal(primReal(), "m", false, false), formal(primReal(), "y", false, false), formal(primReal(), "k", false, false));
#line 2044 "runtime.in"
addFunc(ve, run::gen88, primPen(), "gray", formal(primReal(), "gray", false, false));
#line 2049 "runtime.in"
addFunc(ve, run::gen89, realArray(), "colors", formal(primPen(), "p", false, false));
#line 2077 "runtime.in"
addFunc(ve, run::gen90, primString() , "colorspace", formal(primPen(), "p", false, false));
#line 2084 "runtime.in"
addFunc(ve, run::gen91, primPen(), "pattern", formal(primString(), "s", false, false));
#line 2089 "runtime.in"
addFunc(ve, run::gen92, primString() , "pattern", formal(primPen(), "p", false, false));
#line 2094 "runtime.in"
addFunc(ve, run::gen93, primPen(), "fillrule", formal(primInt(), "n", false, false));
#line 2099 "runtime.in"
addFunc(ve, run::gen94, primInt(), "fillrule", formal(primPen(), "p", false, false));
#line 2104 "runtime.in"
addFunc(ve, run::gen95, primPen(), "opacity", formal(primReal(), "opacity", true, false), formal(primString() , "blend", true, false));
#line 2114 "runtime.in"
addFunc(ve, run::gen96, primReal(), "opacity", formal(primPen(), "p", false, false));
#line 2119 "runtime.in"
addFunc(ve, run::gen97, primString() , "blend", formal(primPen(), "p", false, false));
#line 2124 "runtime.in"
addFunc(ve, run::gen98, primPen(), "linetype", formal(primString(), "s", false, false), formal(primReal(), "offset", true, false), formal(primBoolean(), "scale", true, false), formal(primBoolean(), "adjust", true, false));
#line 2129 "runtime.in"
addFunc(ve, run::gen99, primString() , "linetype", formal(primPen(), "p", true, false));
#line 2134 "runtime.in"
addFunc(ve, run::gen100, primReal(), "offset", formal(primPen(), "p", false, false));
#line 2139 "runtime.in"
addFunc(ve, run::gen101, primBoolean(), "scale", formal(primPen(), "p", false, false));
#line 2144 "runtime.in"
addFunc(ve, run::gen102, primBoolean(), "adjust", formal(primPen(), "p", false, false));
#line 2149 "runtime.in"
addFunc(ve, run::gen103, primPen(), "adjust", formal(primPen(), "p", false, false), formal(primReal(), "arclength", false, false), formal(primBoolean(), "cyclic", false, false));
#line 2154 "runtime.in"
addFunc(ve, run::gen104, primPen(), "linecap", formal(primInt(), "n", false, false));
#line 2159 "runtime.in"
addFunc(ve, run::gen105, primInt(), "linecap", formal(primPen(), "p", true, false));
#line 2164 "runtime.in"
addFunc(ve, run::gen106, primPen(), "linejoin", formal(primInt(), "n", false, false));
#line 2169 "runtime.in"
addFunc(ve, run::gen107, primInt(), "linejoin", formal(primPen(), "p", true, false));
#line 2174 "runtime.in"
addFunc(ve, run::gen108, primPen(), "miterlimit", formal(primReal(), "x", false, false));
#line 2179 "runtime.in"
addFunc(ve, run::gen109, primReal(), "miterlimit", formal(primPen(), "p", true, false));
#line 2184 "runtime.in"
addFunc(ve, run::gen110, primPen(), "linewidth", formal(primReal(), "x", false, false));
#line 2189 "runtime.in"
addFunc(ve, run::gen111, primReal(), "linewidth", formal(primPen(), "p", true, false));
#line 2194 "runtime.in"
addFunc(ve, run::gen112, primPen(), "fontcommand", formal(primString(), "s", false, false));
#line 2199 "runtime.in"
addFunc(ve, run::gen113, primString() , "font", formal(primPen(), "p", true, false));
#line 2204 "runtime.in"
addFunc(ve, run::gen114, primPen(), "fontsize", formal(primReal(), "size", false, false), formal(primReal(), "lineskip", false, false));
#line 2210 "runtime.in"
addFunc(ve, run::gen115, primReal(), "fontsize", formal(primPen(), "p", true, false));
#line 2215 "runtime.in"
addFunc(ve, run::gen116, primReal(), "lineskip", formal(primPen(), "p", true, false));
#line 2220 "runtime.in"
addFunc(ve, run::gen117, primPen(), "overwrite", formal(primInt(), "n", false, false));
#line 2226 "runtime.in"
addFunc(ve, run::gen118, primInt(), "overwrite", formal(primPen(), "p", true, false));
#line 2231 "runtime.in"
addFunc(ve, run::gen119, primPen(), "basealign", formal(primInt(), "n", false, false));
#line 2236 "runtime.in"
addFunc(ve, run::gen120, primInt(), "basealign", formal(primPen(), "p", true, false));
#line 2241 "runtime.in"
addFunc(ve, run::gen121, primTransform(), "transform", formal(primPen(), "p", false, false));
#line 2246 "runtime.in"
addFunc(ve, run::gen122, primPath(), "nib", formal(primPen(), "p", false, false));
#line 2251 "runtime.in"
addFunc(ve, run::gen123, primPen(), "makepen", formal(primPath(), "p", false, false));
#line 2256 "runtime.in"
addFunc(ve, run::gen124, primPen(), "colorless", formal(primPen(), "p", false, false));
#line 2262 "runtime.in"
addFunc(ve, run::gen125, primBoolean(), "interactive");
#line 2269 "runtime.in"
addFunc(ve, run::gen126, primBoolean(), "uptodate");
#line 2274 "runtime.in"
addFunc(ve, run::gen127, primInt(), "system", formal(primString() , "s", false, false));
#line 2284 "runtime.in"
addFunc(ve, run::gen128, primBoolean(), "view");
#line 2289 "runtime.in"
addFunc(ve, run::gen129, primString() , "asydir");
#line 2294 "runtime.in"
addFunc(ve, run::gen130, primString() , "locale", formal(primString() , "s", true, false));
#line 2300 "runtime.in"
addFunc(ve, run::gen131, primVoid(), "abort", formal(primString() , "s", true, false));
#line 2306 "runtime.in"
addFunc(ve, run::gen132, primVoid(), "exit");
#line 2311 "runtime.in"
addFunc(ve, run::gen133, primVoid(), "assert", formal(primBoolean(), "b", false, false), formal(primString() , "s", true, false));
#line 2322 "runtime.in"
addFunc(ve, run::gen134, primVoid(), "sleep", formal(primInt(), "seconds", false, false));
#line 2328 "runtime.in"
addFunc(ve, run::gen135, primVoid(), "usleep", formal(primInt(), "microseconds", false, false));
#line 2334 "runtime.in"
addFunc(ve, run::gen136, primVoid(), "_eval", formal(primString(), "s", false, false), formal(primBoolean(), "embedded", false, false), formal(primBoolean(), "interactivewrite", true, false));
#line 2349 "runtime.in"
addFunc(ve, run::gen137, primVoid(), "_eval", formal(primCode(), "s", false, false), formal(primBoolean(), "embedded", false, false));
#line 2367 "runtime.in"
addFunc(ve, run::gen138, primString() , "location");
#line 2379 "runtime.in"
addFunc(ve, run::gen140, primString() , "cd", formal(primString() , "s", true, false));
#line 2385 "runtime.in"
addFunc(ve, run::gen141, primVoid(), "list", formal(primString(), "s", false, false), formal(primBoolean(), "imports", true, false));
#line 2402 "runtime.in"
addFunc(ve, run::gen143, primBoolean(), "==", formal(primPath(), "a", false, false), formal(primPath(), "b", false, false));
#line 2407 "runtime.in"
addFunc(ve, run::gen144, primBoolean(), "!=", formal(primPath(), "a", false, false), formal(primPath(), "b", false, false));
#line 2412 "runtime.in"
addFunc(ve, run::gen145, primPair(), "point", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false));
#line 2417 "runtime.in"
addFunc(ve, run::gen146, primPair(), "point", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false));
#line 2422 "runtime.in"
addFunc(ve, run::gen147, primPair(), "precontrol", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false));
#line 2427 "runtime.in"
addFunc(ve, run::gen148, primPair(), "precontrol", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false));
#line 2432 "runtime.in"
addFunc(ve, run::gen149, primPair(), "postcontrol", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false));
#line 2437 "runtime.in"
addFunc(ve, run::gen150, primPair(), "postcontrol", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false));
#line 2442 "runtime.in"
addFunc(ve, run::gen151, primPair(), "dir", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false), formal(primBoolean(), "normalize", true, false));
#line 2447 "runtime.in"
addFunc(ve, run::gen152, primPair(), "dir", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false), formal(primBoolean(), "normalize", true, false));
#line 2452 "runtime.in"
addFunc(ve, run::gen153, primPair(), "accel", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false));
#line 2457 "runtime.in"
addFunc(ve, run::gen154, primPair(), "accel", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false));
#line 2462 "runtime.in"
addFunc(ve, run::gen155, primReal(), "radius", formal(primPath(), "p", false, false), formal(primReal(), "t", false, false));
#line 2474 "runtime.in"
addFunc(ve, run::gen156, primPath(), "reverse", formal(primPath(), "p", false, false));
#line 2479 "runtime.in"
addFunc(ve, run::gen157, primPath(), "subpath", formal(primPath(), "p", false, false), formal(primInt(), "a", false, false), formal(primInt(), "b", false, false));
#line 2484 "runtime.in"
addFunc(ve, run::gen158, primPath(), "subpath", formal(primPath(), "p", false, false), formal(primReal(), "a", false, false), formal(primReal(), "b", false, false));
#line 2489 "runtime.in"
addFunc(ve, run::gen159, primPath(), "nurb", formal(primPair(), "z0", false, false), formal(primPair(), "z1", false, false), formal(primPair(), "z2", false, false), formal(primPair(), "z3", false, false), formal(primReal(), "w0", false, false), formal(primReal(), "w1", false, false), formal(primReal(), "w2", false, false), formal(primReal(), "w3", false, false), formal(primInt(), "m", false, false));
#line 2495 "runtime.in"
addFunc(ve, run::gen160, primInt(), "length", formal(primPath(), "p", false, false));
#line 2500 "runtime.in"
addFunc(ve, run::gen161, primBoolean(), "cyclic", formal(primPath(), "p", false, false));
#line 2505 "runtime.in"
addFunc(ve, run::gen162, primBoolean(), "straight", formal(primPath(), "p", false, false), formal(primInt(), "t", false, false));
#line 2510 "runtime.in"
addFunc(ve, run::gen163, primPath(), "unstraighten", formal(primPath(), "p", false, false));
#line 2515 "runtime.in"
addFunc(ve, run::gen164, primBoolean(), "piecewisestraight", formal(primPath(), "p", false, false));
#line 2520 "runtime.in"
addFunc(ve, run::gen165, primReal(), "arclength", formal(primPath(), "p", false, false));
#line 2525 "runtime.in"
addFunc(ve, run::gen166, primReal(), "arctime", formal(primPath(), "p", false, false), formal(primReal(), "dval", false, false));
#line 2530 "runtime.in"
addFunc(ve, run::gen167, primReal(), "dirtime", formal(primPath(), "p", false, false), formal(primPair(), "z", false, false));
#line 2535 "runtime.in"
addFunc(ve, run::gen168, realArray(), "intersect", formal(primPath(), "p", false, false), formal(primPath(), "q", false, false), formal(primReal(), "fuzz", true, false));
#line 2552 "runtime.in"
addFunc(ve, run::gen169, realArray2(), "intersections", formal(primPath(), "p", false, false), formal(primPath(), "q", false, false), formal(primReal(), "fuzz", true, false));
#line 2583 "runtime.in"
addFunc(ve, run::gen170, realArray(), "intersections", formal(primPath(), "p", false, false), formal(primPair(), "a", false, true), formal(primPair(), "b", false, true), formal(primReal(), "fuzz", true, false));
#line 2598 "runtime.in"
addFunc(ve, run::gen171, primPair(), "extension", formal(primPair(), "p", false, false), formal(primPair(), "q", false, false), formal(primPair(), "p", false, false), formal(primPair(), "q", false, false));
#line 2609 "runtime.in"
addFunc(ve, run::gen172, primInt(), "size", formal(primPath(), "p", false, false));
#line 2614 "runtime.in"
addFunc(ve, run::gen173, primPath(), "&", formal(primPath(), "p", false, false), formal(primPath(), "q", false, false));
#line 2619 "runtime.in"
addFunc(ve, run::gen174, primPair(), "min", formal(primPath(), "p", false, false));
#line 2624 "runtime.in"
addFunc(ve, run::gen175, primPair(), "max", formal(primPath(), "p", false, false));
#line 2629 "runtime.in"
addFunc(ve, run::gen176, realArray(), "mintimes", formal(primPath(), "p", false, false));
#line 2638 "runtime.in"
addFunc(ve, run::gen177, realArray(), "maxtimes", formal(primPath(), "p", false, false));
#line 2647 "runtime.in"
addFunc(ve, run::gen178, primReal(), "relativedistance", formal(primReal(), "theta", false, false), formal(primReal(), "phi", false, false), formal(primReal(), "t", false, false), formal(primBoolean(), "atleast", false, false));
#line 2652 "runtime.in"
addFunc(ve, run::gen179, primInt(), "windingnumber", formal(pathArray() , "p", false, false), formal(primPair(), "z", false, false));
#line 2657 "runtime.in"
addFunc(ve, run::gen180, primBoolean(), "inside", formal(pathArray() , "g", false, true), formal(primPair(), "z", false, false), formal(primPen(), "fillrule", true, false));
#line 2662 "runtime.in"
addFunc(ve, run::gen181, primBoolean(), "inside", formal(primPath(), "g", false, false), formal(primPair(), "z", false, false), formal(primPen(), "fillrule", true, false));
#line 2667 "runtime.in"
addFunc(ve, run::gen182, primReal(), "side", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false));
#line 2674 "runtime.in"
addFunc(ve, run::gen183, primReal(), "incircle", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false));
#line 2682 "runtime.in"
addFunc(ve, run::gen184, primPath3(), "path3", formal(tripleArray(), "pre", false, false), formal(tripleArray(), "point", false, false), formal(tripleArray(), "post", false, false), formal(boolArray(), "straight", false, false), formal(primBoolean(), "cyclic", false, false));
#line 2707 "runtime.in"
addFunc(ve, run::gen186, primBoolean(), "==", formal(primPath3(), "a", false, false), formal(primPath3(), "b", false, false));
#line 2712 "runtime.in"
addFunc(ve, run::gen187, primBoolean(), "!=", formal(primPath3(), "a", false, false), formal(primPath3(), "b", false, false));
#line 2717 "runtime.in"
addFunc(ve, run::gen188, primTriple(), "point", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false));
#line 2722 "runtime.in"
addFunc(ve, run::gen189, primTriple(), "point", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false));
#line 2727 "runtime.in"
addFunc(ve, run::gen190, primTriple(), "precontrol", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false));
#line 2732 "runtime.in"
addFunc(ve, run::gen191, primTriple(), "precontrol", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false));
#line 2737 "runtime.in"
addFunc(ve, run::gen192, primTriple(), "postcontrol", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false));
#line 2742 "runtime.in"
addFunc(ve, run::gen193, primTriple(), "postcontrol", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false));
#line 2747 "runtime.in"
addFunc(ve, run::gen194, primTriple(), "dir", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false), formal(primBoolean(), "normalize", true, false));
#line 2752 "runtime.in"
addFunc(ve, run::gen195, primTriple(), "dir", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false), formal(primBoolean(), "normalize", true, false));
#line 2757 "runtime.in"
addFunc(ve, run::gen196, primTriple(), "accel", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false), formal(primInt(), "sign", true, false));
#line 2762 "runtime.in"
addFunc(ve, run::gen197, primTriple(), "accel", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false));
#line 2767 "runtime.in"
addFunc(ve, run::gen198, primReal(), "radius", formal(primPath3(), "p", false, false), formal(primReal(), "t", false, false));
#line 2779 "runtime.in"
addFunc(ve, run::gen199, primReal(), "radius", formal(primTriple(), "z0", false, false), formal(primTriple(), "c0", false, false), formal(primTriple(), "c1", false, false), formal(primTriple(), "z1", false, false), formal(primReal(), "t", false, false));
#line 2791 "runtime.in"
addFunc(ve, run::gen200, primPath3(), "reverse", formal(primPath3(), "p", false, false));
#line 2796 "runtime.in"
addFunc(ve, run::gen201, primPath3(), "subpath", formal(primPath3(), "p", false, false), formal(primInt(), "a", false, false), formal(primInt(), "b", false, false));
#line 2801 "runtime.in"
addFunc(ve, run::gen202, primPath3(), "subpath", formal(primPath3(), "p", false, false), formal(primReal(), "a", false, false), formal(primReal(), "b", false, false));
#line 2806 "runtime.in"
addFunc(ve, run::gen203, primInt(), "length", formal(primPath3(), "p", false, false));
#line 2811 "runtime.in"
addFunc(ve, run::gen204, primBoolean(), "cyclic", formal(primPath3(), "p", false, false));
#line 2816 "runtime.in"
addFunc(ve, run::gen205, primBoolean(), "straight", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false));
#line 2821 "runtime.in"
addFunc(ve, run::gen206, primTriple(), "perp", formal(primTriple(), "v", false, false), formal(primTriple(), "u", false, false));
#line 2827 "runtime.in"
addFunc(ve, run::gen207, primReal(), "straightness", formal(primPath3(), "p", false, false), formal(primInt(), "t", false, false));
#line 2838 "runtime.in"
addFunc(ve, run::gen208, primReal(), "straightness", formal(primTriple(), "z0", false, false), formal(primTriple(), "c0", false, false), formal(primTriple(), "c1", false, false), formal(primTriple(), "z1", false, false));
#line 2846 "runtime.in"
addFunc(ve, run::gen209, primBoolean(), "piecewisestraight", formal(primPath3(), "p", false, false));
#line 2851 "runtime.in"
addFunc(ve, run::gen210, primReal(), "arclength", formal(primPath3(), "p", false, false));
#line 2856 "runtime.in"
addFunc(ve, run::gen211, primReal(), "arctime", formal(primPath3(), "p", false, false), formal(primReal(), "dval", false, false));
#line 2861 "runtime.in"
addFunc(ve, run::gen212, realArray(), "intersect", formal(primPath3(), "p", false, false), formal(primPath3(), "q", false, false), formal(primReal(), "fuzz", true, false));
#line 2879 "runtime.in"
addFunc(ve, run::gen213, realArray2(), "intersections", formal(primPath3(), "p", false, false), formal(primPath3(), "q", false, false), formal(primReal(), "fuzz", true, false));
#line 2912 "runtime.in"
addFunc(ve, run::gen214, realArray2(), "intersections", formal(primPath3(), "p", false, false), formal(tripleArray2(), "p", false, false), formal(primReal(), "fuzz", true, false));
#line 2932 "runtime.in"
addFunc(ve, run::gen215, primInt(), "size", formal(primPath3(), "p", false, false));
#line 2937 "runtime.in"
addFunc(ve, run::gen216, primPath3(), "&", formal(primPath3(), "p", false, false), formal(primPath3(), "q", false, false));
#line 2942 "runtime.in"
addFunc(ve, run::gen217, primTriple(), "min", formal(primPath3(), "p", false, false));
#line 2947 "runtime.in"
addFunc(ve, run::gen218, primTriple(), "max", formal(primPath3(), "p", false, false));
#line 2952 "runtime.in"
addFunc(ve, run::gen219, realArray(), "mintimes", formal(primPath3(), "p", false, false));
#line 2962 "runtime.in"
addFunc(ve, run::gen220, realArray(), "maxtimes", formal(primPath3(), "p", false, false));
#line 2972 "runtime.in"
addFunc(ve, run::gen221, primPath3(), "*", formal(realArray2(), "t", false, false), formal(primPath3(), "g", false, false));
#line 3027 "runtime.in"
addFunc(ve, run::gen226, primGuide(), "operator cast", formal(primCycleToken(), "tok", false, false));
#line 3034 "runtime.in"
addFunc(ve, run::gen227, primGuide(), "operator spec", formal(primPair(), "z", false, false), formal(primInt(), "p", false, false));
#line 3042 "runtime.in"
addFunc(ve, run::gen228, primCurlSpecifier(), "operator curl", formal(primReal(), "gamma", false, false), formal(primInt(), "p", false, false));
#line 3058 "runtime.in"
addFunc(ve, run::gen231, primGuide(), "operator cast", formal(primCurlSpecifier(), "spec", false, false));
#line 3063 "runtime.in"
addFunc(ve, run::gen232, primTensionSpecifier(), "operator tension", formal(primReal(), "tout", false, false), formal(primReal(), "tin", false, false), formal(primBoolean(), "atleast", false, false));
#line 3083 "runtime.in"
addFunc(ve, run::gen236, primGuide(), "operator cast", formal(primTensionSpecifier(), "t", false, false));
#line 3088 "runtime.in"
addFunc(ve, run::gen237, primGuide(), "operator controls", formal(primPair(), "zout", false, false), formal(primPair(), "zin", false, false));
#line 3093 "runtime.in"
addFunc(ve, run::gen238, primInt(), "size", formal(primGuide(), "g", false, false));
#line 3100 "runtime.in"
addFunc(ve, run::gen239, primInt(), "length", formal(primGuide(), "g", false, false));
#line 3107 "runtime.in"
addFunc(ve, run::gen240, primBoolean(), "cyclic", formal(primGuide(), "g", false, false));
#line 3114 "runtime.in"
addFunc(ve, run::gen241, primPair(), "point", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false));
#line 3121 "runtime.in"
addFunc(ve, run::gen242, pairArray(), "dirSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false));
#line 3133 "runtime.in"
addFunc(ve, run::gen243, pairArray(), "controlSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false));
#line 3150 "runtime.in"
addFunc(ve, run::gen244, primTensionSpecifier(), "tensionSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false));
#line 3160 "runtime.in"
addFunc(ve, run::gen245, realArray(), "curlSpecifier", formal(primGuide(), "g", false, false), formal(primInt(), "t", false, false));
#line 3174 "runtime.in"
addFunc(ve, run::gen246, primGuide(), "reverse", formal(primGuide(), "g", false, false));
#line 3228 "runtime.in"
addFunc(ve, run::gen247, primVoid(), "_draw", formal(primPicture(), "f", false, false), formal(primPath3(), "g", false, false), formal(primPen(), "p", false, false));
#line 3237 "runtime.in"
addFunc(ve, run::gen248, primVoid(), "draw", formal(primPicture(), "f", false, false), formal(tripleArray2(), "g", false, false), formal(primBoolean(), "straight", false, false), formal(penArray() , "p", false, false), formal(primReal(), "opacity", false, false), formal(primReal(), "shininess", false, false), formal(primReal(), "granularity", false, false), formal(primTriple(), "normal", false, false), formal(primBoolean(), "lighton", false, false), formal(penArray() , "colors", false, false));
#line 3245 "runtime.in"
addFunc(ve, run::gen249, primTriple(), "min3", formal(primPicture(), "f", false, false));
#line 3250 "runtime.in"
addFunc(ve, run::gen250, primTriple(), "max3", formal(primPicture(), "f", false, false));
#line 3255 "runtime.in"
addFunc(ve, run::gen251, primPair(), "min", formal(primPicture(), "f", false, false), formal(realArray2(), "t", false, false));
#line 3263 "runtime.in"
addFunc(ve, run::gen252, primPair(), "max", formal(primPicture(), "f", false, false), formal(realArray2(), "t", false, false));
#line 3271 "runtime.in"
addFunc(ve, run::gen253, primPair(), "minratio", formal(primPicture(), "f", false, false));
#line 3276 "runtime.in"
addFunc(ve, run::gen254, primPair(), "maxratio", formal(primPicture(), "f", false, false));
#line 3281 "runtime.in"
addFunc(ve, run::gen255, primTriple(), "minbound", formal(tripleArray2(), "p", false, false), formal(primTriple(), "b", false, false));
#line 3291 "runtime.in"
addFunc(ve, run::gen256, primTriple(), "maxbound", formal(tripleArray2(), "p", false, false), formal(primTriple(), "b", false, false));
#line 3301 "runtime.in"
addFunc(ve, run::gen257, primPair(), "minbound", formal(tripleArray2(), "p", false, false), formal(realArray2(), "t", false, false), formal(primPair(), "b", false, false));
#line 3313 "runtime.in"
addFunc(ve, run::gen258, primPair(), "maxbound", formal(tripleArray2(), "p", false, false), formal(realArray2(), "t", false, false), formal(primPair(), "b", false, false));
#line 3325 "runtime.in"
addFunc(ve, run::gen259, primPair(), "max", formal(primPath3(), "g", false, false), formal(realArray2(), "t", false, false));
#line 3333 "runtime.in"
addFunc(ve, run::gen260, primPair(), "min", formal(primPath3(), "g", false, false), formal(realArray2(), "t", false, false));
#line 3341 "runtime.in"
addFunc(ve, run::gen261, primReal(), "change2", formal(tripleArray2(), "a", false, false));
#line 3363 "runtime.in"
addFunc(ve, run::gen262, primBoolean(), "is3D", formal(primPicture(), "f", false, false));
#line 3368 "runtime.in"
addFunc(ve, run::gen263, primPair(), "bezier", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false), formal(primReal(), "t", false, false));
#line 3375 "runtime.in"
addFunc(ve, run::gen264, primPair(), "bezierP", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false), formal(primReal(), "t", false, false));
#line 3380 "runtime.in"
addFunc(ve, run::gen265, primPair(), "bezierPP", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false), formal(primReal(), "t", false, false));
#line 3385 "runtime.in"
addFunc(ve, run::gen266, primPair(), "bezierPPP", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false), formal(primPair(), "c", false, false), formal(primPair(), "d", false, false));
#line 3390 "runtime.in"
addFunc(ve, run::gen267, primTriple(), "bezier", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false), formal(primReal(), "t", false, false));
#line 3397 "runtime.in"
addFunc(ve, run::gen268, primTriple(), "bezierP", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false), formal(primReal(), "t", false, false));
#line 3402 "runtime.in"
addFunc(ve, run::gen269, primTriple(), "bezierPP", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false), formal(primReal(), "t", false, false));
#line 3407 "runtime.in"
addFunc(ve, run::gen270, primTriple(), "bezierPPP", formal(primTriple(), "a", false, false), formal(primTriple(), "b", false, false), formal(primTriple(), "c", false, false), formal(primTriple(), "d", false, false));
#line 3420 "runtime.in"
addFunc(ve, run::gen272, primInt(), "length", formal(primString(), "s", false, false));
#line 3425 "runtime.in"
addFunc(ve, run::gen273, primInt(), "find", formal(primString(), "s", false, false), formal(primString() , "t", false, false), formal(primInt(), "pos", true, false));
#line 3431 "runtime.in"
addFunc(ve, run::gen274, primInt(), "rfind", formal(primString(), "s", false, false), formal(primString() , "t", false, false), formal(primInt(), "pos", true, false));
#line 3437 "runtime.in"
addFunc(ve, run::gen275, primString() , "reverse", formal(primString() , "s", false, false));
#line 3443 "runtime.in"
addFunc(ve, run::gen276, primString() , "insert", formal(primString() , "s", false, false), formal(primInt(), "pos", false, false), formal(primString() , "t", false, false));
#line 3450 "runtime.in"
addFunc(ve, run::gen277, primString() , "substr", formal(primString(), "s", false, false), formal(primInt(), "pos", false, false), formal(primInt(), "n", true, false));
#line 3457 "runtime.in"
addFunc(ve, run::gen278, primString() , "erase", formal(primString() , "s", false, false), formal(primInt(), "pos", false, false), formal(primInt(), "n", false, false));
#line 3464 "runtime.in"
addFunc(ve, run::gen279, primString() , "downcase", formal(primString() , "s", false, false));
#line 3470 "runtime.in"
addFunc(ve, run::gen280, primString() , "upcase", formal(primString() , "s", false, false));
#line 3476 "runtime.in"
addFunc(ve, run::gen281, primString() , "replace", formal(primString(), "s", false, false), formal(stringArray2(), "translate", false, false));
#line 3503 "runtime.in"
addFunc(ve, run::gen282, primString() , "format", formal(primString(), "format", false, false), formal(primInt(), "x", false, false));
#line 3518 "runtime.in"
addFunc(ve, run::gen283, primString() , "format", formal(primString(), "format", false, false), formal(primReal(), "x", false, false), formal(primString() , "locale", true, false));
#line 3643 "runtime.in"
addFunc(ve, run::gen284, primInt(), "hex", formal(primString() , "s", false, false));
#line 3654 "runtime.in"
addFunc(ve, run::gen285, primString() , "string", formal(primInt(), "x", false, false));
#line 3661 "runtime.in"
addFunc(ve, run::gen286, primString() , "string", formal(primReal(), "x", false, false), formal(primInt(), "digits", true, false));
#line 3669 "runtime.in"
addFunc(ve, run::gen287, primString() , "time", formal(primString() , "format", true, false));
#line 3680 "runtime.in"
addFunc(ve, run::gen288, primString() , "time", formal(primInt(), "seconds", false, false), formal(primString() , "format", true, false));
#line 3693 "runtime.in"
addFunc(ve, run::gen289, primInt(), "seconds", formal(primString() , "t", true, false), formal(primString() , "format", true, false));
#line 3705 "runtime.in"
addFunc(ve, run::gen290, realArray(), "_cputime");
#line 3719 "runtime.in"
addFunc(ve, run::gen291, primReal(), "^", formal(primReal(), "x", false, false), formal(primInt(), "y", false, false));
#line 3727 "runtime.in"
addFunc(ve, run::gen292, primPair(), "^", formal(primPair(), "z", false, false), formal(primInt(), "y", false, false));
#line 3732 "runtime.in"
addFunc(ve, run::gen293, primInt(), "quotient", formal(primInt(), "x", false, false), formal(primInt(), "y", false, false));
#line 3740 "runtime.in"
addFunc(ve, run::gen294, primInt(), "abs", formal(primInt(), "x", false, false));
#line 3745 "runtime.in"
addFunc(ve, run::gen295, primInt(), "sgn", formal(primReal(), "x", false, false));
#line 3750 "runtime.in"
addFunc(ve, run::gen296, primInt(), "rand");
#line 3755 "runtime.in"
addFunc(ve, run::gen297, primVoid(), "srand", formal(primInt(), "seed", false, false));
#line 3760 "runtime.in"
addFunc(ve, run::gen298, primReal(), "unitrand");
#line 3766 "runtime.in"
addFunc(ve, run::gen299, primInt(), "ceil", formal(primReal(), "x", false, false));
#line 3771 "runtime.in"
addFunc(ve, run::gen300, primInt(), "floor", formal(primReal(), "x", false, false));
#line 3776 "runtime.in"
addFunc(ve, run::gen301, primInt(), "round", formal(primReal(), "x", false, false));
#line 3782 "runtime.in"
addFunc(ve, run::gen302, primInt(), "Ceil", formal(primReal(), "x", false, false));
#line 3787 "runtime.in"
addFunc(ve, run::gen303, primInt(), "Floor", formal(primReal(), "x", false, false));
#line 3792 "runtime.in"
addFunc(ve, run::gen304, primInt(), "Round", formal(primReal(), "x", false, false));
#line 3797 "runtime.in"
addFunc(ve, run::gen305, primReal(), "fmod", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false));
#line 3803 "runtime.in"
addFunc(ve, run::gen306, primReal(), "atan2", formal(primReal(), "y", false, false), formal(primReal(), "x", false, false));
#line 3808 "runtime.in"
addFunc(ve, run::gen307, primReal(), "hypot", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false));
#line 3813 "runtime.in"
addFunc(ve, run::gen308, primReal(), "remainder", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false));
#line 3818 "runtime.in"
addFunc(ve, run::gen309, primReal(), "J", formal(primInt(), "n", false, false), formal(primReal(), "x", false, false));
#line 3823 "runtime.in"
addFunc(ve, run::gen310, primReal(), "Y", formal(primInt(), "n", false, false), formal(primReal(), "x", false, false));
#line 3828 "runtime.in"
addFunc(ve, run::gen311, primReal(), "erf", formal(primReal(), "x", false, false));
#line 3833 "runtime.in"
addFunc(ve, run::gen312, primReal(), "erfc", formal(primReal(), "x", false, false));
#line 3838 "runtime.in"
addFunc(ve, run::gen313, primInt(), "factorial", formal(primInt(), "n", false, false));
#line 3843 "runtime.in"
addFunc(ve, run::gen314, primInt(), "choose", formal(primInt(), "n", false, false), formal(primInt(), "k", false, false));
#line 3854 "runtime.in"
addFunc(ve, run::gen315, primReal(), "gamma", formal(primReal(), "x", false, false));
#line 3864 "runtime.in"
addFunc(ve, run::gen316, primPair(), "gamma", formal(primPair(), "z", false, true));
#line 3870 "runtime.in"
addFunc(ve, run::gen317, realArray(), "quadraticroots", formal(primReal(), "a", false, false), formal(primReal(), "b", false, false), formal(primReal(), "c", false, false));
#line 3879 "runtime.in"
addFunc(ve, run::gen318, pairArray(), "quadraticroots", formal(primPair(), "a", false, true), formal(primPair(), "b", false, true), formal(primPair(), "c", false, true));
#line 3888 "runtime.in"
addFunc(ve, run::gen319, realArray(), "cubicroots", formal(primReal(), "a", false, false), formal(primReal(), "b", false, false), formal(primReal(), "c", false, false), formal(primReal(), "d", false, false));
#line 3898 "runtime.in"
addFunc(ve, run::gen320, primBoolean(), "==", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false));
#line 3906 "runtime.in"
addFunc(ve, run::gen321, primBoolean(), "!=", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false));
#line 3911 "runtime.in"
addFunc(ve, run::gen322, primTransform(), "+", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false));
#line 3916 "runtime.in"
addFunc(ve, run::gen323, primTransform(), "*", formal(primTransform(), "a", false, false), formal(primTransform(), "b", false, false));
#line 3921 "runtime.in"
addFunc(ve, run::gen324, primPair(), "*", formal(primTransform(), "t", false, false), formal(primPair(), "z", false, false));
#line 3926 "runtime.in"
addFunc(ve, run::gen325, primPath(), "*", formal(primTransform(), "t", false, false), formal(primPath(), "g", false, false));
#line 3931 "runtime.in"
addFunc(ve, run::gen326, primPen(), "*", formal(primTransform(), "t", false, false), formal(primPen(), "p", false, false));
#line 3936 "runtime.in"
addFunc(ve, run::gen327, primPicture(), "*", formal(primTransform(), "t", false, false), formal(primPicture(), "f", false, false));
#line 3941 "runtime.in"
addFunc(ve, run::gen328, primPicture(), "*", formal(realArray2(), "t", false, false), formal(primPicture(), "f", false, false));
#line 3946 "runtime.in"
addFunc(ve, run::gen329, primTransform(), "^", formal(primTransform(), "t", false, false), formal(primInt(), "n", false, false));
#line 3993 "runtime.in"
addFunc(ve, run::gen337, primTransform(), "shift", formal(primTransform(), "t", false, false));
#line 3998 "runtime.in"
addFunc(ve, run::gen338, primTransform(), "shiftless", formal(primTransform(), "t", false, false));
#line 4003 "runtime.in"
addFunc(ve, run::transformIdentity, primTransform(), "identity");
#line 4008 "runtime.in"
addFunc(ve, run::gen340, primTransform(), "inverse", formal(primTransform(), "t", false, false));
#line 4013 "runtime.in"
addFunc(ve, run::gen341, primTransform(), "shift", formal(primPair(), "z", false, false));
#line 4018 "runtime.in"
addFunc(ve, run::gen342, primTransform(), "shift", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false));
#line 4023 "runtime.in"
addFunc(ve, run::gen343, primTransform(), "xscale", formal(primReal(), "x", false, false));
#line 4028 "runtime.in"
addFunc(ve, run::gen344, primTransform(), "yscale", formal(primReal(), "y", false, false));
#line 4033 "runtime.in"
addFunc(ve, run::gen345, primTransform(), "scale", formal(primReal(), "x", false, false));
#line 4038 "runtime.in"
addFunc(ve, run::gen346, primTransform(), "scale", formal(primReal(), "x", false, false), formal(primReal(), "y", false, false));
#line 4043 "runtime.in"
addFunc(ve, run::gen347, primTransform(), "slant", formal(primReal(), "s", false, false));
#line 4048 "runtime.in"
addFunc(ve, run::gen348, primTransform(), "rotate", formal(primReal(), "angle", false, false), formal(primPair(), "z", true, false));
#line 4053 "runtime.in"
addFunc(ve, run::gen349, primTransform(), "reflect", formal(primPair(), "a", false, false), formal(primPair(), "b", false, false));
#line 4076 "runtime.in"
addFunc(ve, run::pairXPart, primReal(), "xpart", formal(primPair(), "z", false, false));
#line 4081 "runtime.in"
addFunc(ve, run::pairYPart, primReal(), "ypart", formal(primPair(), "z", false, false));
#line 4086 "runtime.in"
addFunc(ve, run::gen355, primReal(), "length", formal(primPair(), "z", false, false));
#line 4091 "runtime.in"
addFunc(ve, run::gen356, primReal(), "abs", formal(primPair(), "z", false, false));
#line 4096 "runtime.in"
addFunc(ve, run::gen357, primPair(), "sqrt", formal(primPair(), "z", false, true));
#line 4101 "runtime.in"
addFunc(ve, run::gen358, primReal(), "angle", formal(primPair(), "z", false, false), formal(primBoolean(), "warn", true, false));
#line 4108 "runtime.in"
addFunc(ve, run::gen359, primReal(), "degrees", formal(primPair(), "z", false, false), formal(primBoolean(), "warn", true, false));
#line 4115 "runtime.in"
addFunc(ve, run::gen360, primReal(), "radians", formal(primReal(), "degrees", false, false));
#line 4121 "runtime.in"
addFunc(ve, run::gen361, primReal(), "degrees", formal(primReal(), "radians", false, false));
#line 4127 "runtime.in"
addFunc(ve, run::gen362, primReal(), "Degrees", formal(primReal(), "radians", false, false));
#line 4133 "runtime.in"
addFunc(ve, run::gen363, primReal(), "Sin", formal(primReal(), "deg", false, false));
#line 4138 "runtime.in"
addFunc(ve, run::gen364, primReal(), "Cos", formal(primReal(), "deg", false, false));
#line 4143 "runtime.in"
addFunc(ve, run::gen365, primReal(), "Tan", formal(primReal(), "deg", false, false));
#line 4148 "runtime.in"
addFunc(ve, run::gen366, primReal(), "aSin", formal(primReal(), "x", false, false));
#line 4153 "runtime.in"
addFunc(ve, run::gen367, primReal(), "aCos", formal(primReal(), "x", false, false));
#line 4158 "runtime.in"
addFunc(ve, run::gen368, primReal(), "aTan", formal(primReal(), "x", false, false));
#line 4163 "runtime.in"
addFunc(ve, run::gen369, primPair(), "unit", formal(primPair(), "z", false, false));
#line 4168 "runtime.in"
addFunc(ve, run::gen370, primPair(), "dir", formal(primReal(), "degrees", false, false));
#line 4173 "runtime.in"
addFunc(ve, run::gen371, primPair(), "dir", formal(primPair(), "z", false, true));
#line 4178 "runtime.in"
addFunc(ve, run::gen372, primPair(), "expi", formal(primReal(), "angle", false, false));
#line 4183 "runtime.in"
addFunc(ve, run::gen373, primPair(), "exp", formal(primPair(), "z", false, true));
#line 4188 "runtime.in"
addFunc(ve, run::gen374, primPair(), "log", formal(primPair(), "z", false, true));
#line 4193 "runtime.in"
addFunc(ve, run::gen375, primPair(), "sin", formal(primPair(), "z", false, true));
#line 4198 "runtime.in"
addFunc(ve, run::gen376, primPair(), "cos", formal(primPair(), "z", false, true));
#line 4203 "runtime.in"
addFunc(ve, run::gen377, primPair(), "conj", formal(primPair(), "z", false, false));
#line 4208 "runtime.in"
addFunc(ve, run::gen378, primPair(), "realmult", formal(primPair(), "z", false, false), formal(primPair(), "w", false, false));
#line 4213 "runtime.in"
addFunc(ve, run::gen379, primTriple(), "realmult", formal(primTriple(), "u", false, false), formal(primTriple(), "v", false, false));
#line 4218 "runtime.in"
addFunc(ve, run::gen380, primReal(), "dot", formal(primPair(), "z", false, true), formal(primPair(), "w", false, true));
#line 4238 "runtime.in"
addFunc(ve, run::tripleXPart, primReal(), "xpart", formal(primTriple(), "v", false, false));
#line 4243 "runtime.in"
addFunc(ve, run::tripleYPart, primReal(), "ypart", formal(primTriple(), "v", false, false));
#line 4248 "runtime.in"
addFunc(ve, run::tripleZPart, primReal(), "zpart", formal(primTriple(), "v", false, false));
#line 4253 "runtime.in"
addFunc(ve, run::gen386, primTriple(), "*", formal(primReal(), "x", false, false), formal(primTriple(), "v", false, false));
#line 4258 "runtime.in"
addFunc(ve, run::gen387, primTriple(), "*", formal(primTriple(), "v", false, false), formal(primReal(), "x", false, false));
#line 4263 "runtime.in"
addFunc(ve, run::gen388, primTriple(), "/", formal(primTriple(), "v", false, false), formal(primReal(), "x", false, false));
#line 4268 "runtime.in"
addFunc(ve, run::gen389, primReal(), "length", formal(primTriple(), "v", false, false));
#line 4273 "runtime.in"
addFunc(ve, run::gen390, primReal(), "abs", formal(primTriple(), "v", false, false));
#line 4278 "runtime.in"
addFunc(ve, run::gen391, primReal(), "polar", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false));
#line 4284 "runtime.in"
addFunc(ve, run::gen392, primReal(), "azimuth", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false));
#line 4290 "runtime.in"
addFunc(ve, run::gen393, primReal(), "colatitude", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false));
#line 4296 "runtime.in"
addFunc(ve, run::gen394, primReal(), "latitude", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false));
#line 4302 "runtime.in"
addFunc(ve, run::gen395, primReal(), "longitude", formal(primTriple(), "v", false, false), formal(primBoolean(), "warn", true, false));
#line 4309 "runtime.in"
addFunc(ve, run::gen396, primTriple(), "unit", formal(primTriple(), "v", false, false));
#line 4314 "runtime.in"
addFunc(ve, run::gen397, primReal(), "dot", formal(primTriple(), "u", false, false), formal(primTriple(), "v", false, false));
#line 4319 "runtime.in"
addFunc(ve, run::gen398, primTriple(), "cross", formal(primTriple(), "u", false, false), formal(primTriple(), "v", false, false));
#line 4324 "runtime.in"
addFunc(ve, run::gen399, primTriple(), "expi", formal(primReal(), "polar", false, false), formal(primReal(), "azimuth", false, false));
#line 4329 "runtime.in"
addFunc(ve, run::gen400, primTriple(), "dir", formal(primReal(), "colatitude", false, false), formal(primReal(), "longitude", false, false));
#line 4334 "runtime.in"
addFunc(ve, run::gen401, primVoid(), "atupdate", formal(voidFunction(), "f", false, false));
#line 4342 "runtime.in"
addFunc(ve, run::gen402, voidFunction(), "atupdate");
#line 4347 "runtime.in"
addFunc(ve, run::gen403, primVoid(), "atexit", formal(voidFunction(), "f", false, false));
#line 4352 "runtime.in"
addFunc(ve, run::gen404, voidFunction(), "atexit");
#line 4357 "runtime.in"
addFunc(ve, run::gen405, primVoid(), "atbreakpoint", formal(breakpointFunction(), "f", false, false));
#line 4362 "runtime.in"
addFunc(ve, run::gen406, primVoid(), "breakpoint", formal(primCode(), "s", true, false));
#line 4367 "runtime.in"
addFunc(ve, run::gen407, primString() , "locatefile", formal(primString() , "file", false, false));
#line 4372 "runtime.in"
addFunc(ve, run::gen408, primVoid(), "stop", formal(primString() , "file", false, false), formal(primInt(), "line", false, false), formal(primCode(), "s", true, false));
#line 4380 "runtime.in"
addFunc(ve, run::gen409, primVoid(), "breakpoints");
#line 4386 "runtime.in"
addFunc(ve, run::gen410, primVoid(), "clear", formal(primString() , "file", false, false), formal(primInt(), "line", false, false));
#line 4392 "runtime.in"
addFunc(ve, run::gen411, primVoid(), "clear");
#line 4397 "runtime.in"
addFunc(ve, run::gen412, primVoid(), "warn", formal(primString() , "s", false, false));
#line 4402 "runtime.in"
addFunc(ve, run::gen413, primVoid(), "nowarn", formal(primString() , "s", false, false));
#line 4407 "runtime.in"
addFunc(ve, run::gen414, primString() , "stripdirectory", formal(primString(), "s", false, false));
#line 4413 "runtime.in"
addFunc(ve, run::gen415, primString() , "stripfile", formal(primString(), "s", false, false));
#line 4419 "runtime.in"
addFunc(ve, run::gen416, primString() , "stripextension", formal(primString(), "s", false, false));
#line 4425 "runtime.in"
addFunc(ve, run::gen417, primInt(), "convert", formal(primString() , "args", true, false), formal(primString() , "file", true, false), formal(primString() , "format", true, false));
#line 4443 "runtime.in"
addFunc(ve, run::gen418, primInt(), "animate", formal(primString() , "args", true, false), formal(primString() , "file", true, false), formal(primString() , "format", true, false));
#line 4459 "runtime.in"
addFunc(ve, run::gen419, primInt(), "delete", formal(primString(), "s", false, false));
#line 4469 "runtime.in"
addFunc(ve, run::gen420, primInt(), "rename", formal(primString(), "from", false, false), formal(primString(), "to", false, false));
#line 4768 "runtime.in"
addFunc(ve, run::gen451, IntArray(), "complement", formal(IntArray(), "a", false, false), formal(primInt(), "n", false, false));
#line 4800 "runtime.in"
addFunc(ve, run::gen453, IntArray(), "sequence", formal(primInt(), "n", false, false));
#line 4833 "runtime.in"
addFunc(ve, run::gen456, primBoolean(), "all", formal(boolArray(), "a", false, false));
#line 4842 "runtime.in"
addFunc(ve, run::gen457, boolArray(), "!", formal(boolArray(), "a", false, false));
#line 4851 "runtime.in"
addFunc(ve, run::gen458, primInt(), "sum", formal(boolArray(), "a", false, false));
#line 5014 "runtime.in"
addFunc(ve, run::gen465, primInt(), "find", formal(boolArray(), "a", false, false), formal(primInt(), "n", true, false));
#line 5059 "runtime.in"
addFunc(ve, run::gen467, realArray2(), "identity", formal(primInt(), "n", false, false));
#line 5082 "runtime.in"
addFunc(ve, run::gen469, realArray2(), "inverse", formal(realArray2(), "a", false, false));
#line 5174 "runtime.in"
addFunc(ve, run::gen470, realArray(), "solve", formal(realArray2(), "a", false, false), formal(realArray(), "b", false, false), formal(primBoolean(), "warn", true, false));
#line 5225 "runtime.in"
addFunc(ve, run::gen471, realArray2(), "solve", formal(realArray2(), "a", false, false), formal(realArray2(), "b", false, false), formal(primBoolean(), "warn", true, false));
#line 5289 "runtime.in"
addFunc(ve, run::gen472, primReal(), "determinant", formal(realArray2(), "a", false, false));
#line 5305 "runtime.in"
addFunc(ve, run::gen473, realArray(), "*", formal(realArray2(), "a", false, false), formal(realArray(), "b", false, false));
#line 5323 "runtime.in"
addFunc(ve, run::gen474, realArray(), "*", formal(realArray(), "a", false, false), formal(realArray2(), "b", false, false));
#line 5351 "runtime.in"
addFunc(ve, run::gen475, realArray2(), "*", formal(realArray2(), "a", false, false), formal(realArray2(), "b", false, false));
#line 5386 "runtime.in"
addFunc(ve, run::gen476, primTriple(), "*", formal(realArray2(), "t", false, false), formal(primTriple(), "v", false, false));
#line 5391 "runtime.in"
addFunc(ve, run::gen477, primPair(), "project", formal(primTriple(), "v", false, false), formal(realArray2(), "t", false, false));
#line 5416 "runtime.in"
addFunc(ve, run::gen478, primReal(), "dot", formal(realArray(), "a", false, false), formal(realArray(), "b", false, false));
#line 5426 "runtime.in"
addFunc(ve, run::gen479, realArray(), "tridiagonal", formal(realArray(), "a", false, false), formal(realArray(), "b", false, false), formal(realArray(), "c", false, false), formal(realArray(), "f", false, false));
#line 5530 "runtime.in"
addFunc(ve, run::gen480, primReal(), "newton", formal(primInt(), "iterations", true, false), formal(realRealFunction(), "f", false, false), formal(realRealFunction(), "fprime", false, false), formal(primReal(), "x", false, false), formal(primBoolean(), "verbose", true, false));
#line 5577 "runtime.in"
addFunc(ve, run::gen481, primReal(), "newton", formal(primInt(), "iterations", true, false), formal(realRealFunction(), "f", false, false), formal(realRealFunction(), "fprime", false, false), formal(primReal(), "x1", false, false), formal(primReal(), "x2", false, false), formal(primBoolean(), "verbose", true, false));
#line 5659 "runtime.in"
addFunc(ve, run::gen482, primReal(), "simpson", formal(realRealFunction(), "f", false, false), formal(primReal(), "a", false, false), formal(primReal(), "b", false, false), formal(primReal(), "acc", true, false), formal(primReal(), "dxmax", true, false));
#line 5701 "runtime.in"
addFunc(ve, run::gen484, IntArray2(), "triangulate", formal(pairArray(), "z", false, false));
#line 5736 "runtime.in"
addFunc(ve, run::gen485, primBoolean(), "==", formal(primFile(), "a", false, false), formal(primFile(), "b", false, false));
#line 5744 "runtime.in"
addFunc(ve, run::gen486, primBoolean(), "!=", formal(primFile(), "a", false, false), formal(primFile(), "b", false, false));
#line 5754 "runtime.in"
addFunc(ve, run::gen488, primFile(), "input", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false), formal(primString() , "comment", true, false));
#line 5762 "runtime.in"
addFunc(ve, run::gen489, primFile(), "output", formal(primString() , "name", false, false), formal(primBoolean(), "update", true, false), formal(primString() , "comment", true, false));
#line 5774 "runtime.in"
addFunc(ve, run::gen490, primFile(), "xinput", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false));
#line 5788 "runtime.in"
addFunc(ve, run::gen491, primFile(), "xoutput", formal(primString() , "name", false, false), formal(primBoolean(), "update", true, false));
#line 5806 "runtime.in"
addFunc(ve, run::gen492, primFile(), "binput", formal(primString() , "name", false, false), formal(primBoolean(), "check", true, false));
#line 5813 "runtime.in"
addFunc(ve, run::gen493, primFile(), "boutput", formal(primString() , "name", false, false), formal(primBoolean(), "update", true, false));
#line 5823 "runtime.in"
addFunc(ve, run::gen494, primBoolean(), "eof", formal(primFile(), "f", false, false));
#line 5828 "runtime.in"
addFunc(ve, run::gen495, primBoolean(), "eol", formal(primFile(), "f", false, false));
#line 5833 "runtime.in"
addFunc(ve, run::gen496, primBoolean(), "error", formal(primFile(), "f", false, false));
#line 5838 "runtime.in"
addFunc(ve, run::gen497, primVoid(), "clear", formal(primFile(), "f", false, false));
#line 5843 "runtime.in"
addFunc(ve, run::gen498, primVoid(), "close", formal(primFile(), "f", false, false));
#line 5848 "runtime.in"
addFunc(ve, run::gen499, primInt(), "precision", formal(primFile(), "f", true, false), formal(primInt(), "digits", true, false));
#line 5854 "runtime.in"
addFunc(ve, run::gen500, primVoid(), "flush", formal(primFile(), "f", false, false));
#line 5859 "runtime.in"
addFunc(ve, run::gen501, primString() , "getc", formal(primFile(), "f", false, false));
#line 5868 "runtime.in"
addFunc(ve, run::gen502, primInt(), "tell", formal(primFile(), "f", false, false));
#line 5873 "runtime.in"
addFunc(ve, run::gen503, primVoid(), "seek", formal(primFile(), "f", false, false), formal(primInt(), "pos", false, false));
#line 5878 "runtime.in"
addFunc(ve, run::gen504, primVoid(), "seekeof", formal(primFile(), "f", false, false));
#line 5883 "runtime.in"
addFunc(ve, run::gen505, primFile(), "dimension", formal(primFile(), "f", false, false), formal(primInt(), "nx", false, false));
#line 5890 "runtime.in"
addFunc(ve, run::gen506, primFile(), "dimension", formal(primFile(), "f", false, false), formal(primInt(), "nx", false, false), formal(primInt(), "ny", false, false));
#line 5896 "runtime.in"
addFunc(ve, run::gen507, primFile(), "dimension", formal(primFile(), "f", false, false), formal(primInt(), "nx", false, false), formal(primInt(), "ny", false, false), formal(primInt(), "nz", false, false));
#line 5902 "runtime.in"
addFunc(ve, run::gen508, primFile(), "csv", formal(primFile(), "f", false, false), formal(primBoolean(), "b", true, false));
#line 5909 "runtime.in"
addFunc(ve, run::gen509, primFile(), "word", formal(primFile(), "f", false, false), formal(primBoolean(), "b", true, false));
#line 5916 "runtime.in"
addFunc(ve, run::gen510, primFile(), "line", formal(primFile(), "f", false, false), formal(primBoolean(), "b", true, false));
#line 5923 "runtime.in"
addFunc(ve, run::gen511, primFile(), "signed", formal(primFile(), "f", false, false), formal(primBoolean(), "b", true, false));
#line 5979 "runtime.in"
addFunc(ve, run::gen521, primFile(), "read1", formal(primFile(), "f", false, false));
#line 5986 "runtime.in"
addFunc(ve, run::gen522, primFile(), "read2", formal(primFile(), "f", false, false));
#line 5993 "runtime.in"
addFunc(ve, run::gen523, primFile(), "read3", formal(primFile(), "f", false, false));
#line 6000 "runtime.in"
addFunc(ve, run::gen524, stringArray(), "history", formal(primString() , "name", false, false), formal(primInt(), "n", true, false));
#line 6033 "runtime.in"
addFunc(ve, run::gen525, stringArray(), "history", formal(primInt(), "n", true, false));
#line 6044 "runtime.in"
addFunc(ve, run::gen526, primString() , "readline", formal(primString() , "prompt", true, false), formal(primString() , "name", true, false), formal(primBoolean(), "tabcompletion", true, false));
#line 6088 "runtime.in"
addFunc(ve, run::gen527, primVoid(), "saveline", formal(primString() , "name", false, false), formal(primString() , "value", false, false), formal(primBoolean(), "store", true, false));
#line 6118 "runtime.in"
addFunc(ve, run::gen528, primVoid(), "generate_random_backtrace");
#line 6127 "runtime.in"
addFunc(ve, run::gen529, primVoid(), "print_random_addresses", formal(primInt(), "n", true, false));
}
} // namespace trans
|