text:
Gm, Gn = 100, 100;
Gcolptr = [1, 21, 40, 66, 85, 101, 117, 134, 154, 169, 193, 211, 237, 255, 275, 299, 319, 341, 362, 385, 403, 428, 449, 469, 492, 514, 533, 547, 563, 579, 597, 625, 644, 662, 684, 700, 721, 743, 769, 789, 804, 820, 836, 862, 886, 906, 921, 938, 956, 981, 1002, 1015, 1040, 1065, 1081, 1100, 1124, 1136, 1155, 1180, 1200, 1218, 1243, 1266, 1282, 1295, 1313, 1337, 1345, 1368, 1383, 1404, 1417, 1443, 1459, 1480, 1499, 1526, 1552, 1582, 1609, 1624, 1651, 1664, 1680, 1697, 1716, 1740, 1756, 1771, 1788, 1802, 1821, 1850, 1872, 1889, 1907, 1920, 1940, 1955, 1981];
Growval = [3, 6, 8, 16, 18, 22, 36, 37, 42, 45, 51, 52, 59, 66, 87, 90, 93, 94, 97, 100, 4, 9, 10, 15, 26, 28, 35, 40, 42, 46, 47, 50, 52, 53, 77, 80, 85, 92, 94, 1, 8, 9, 10, 11, 15, 16, 17, 19, 21, 22, 32, 35, 39, 42, 49, 50, 56, 58, 61, 65, 66, 77, 80, 82, 98, 2, 6, 15, 19, 24, 25, 29, 36, 40, 47, 53, 59, 73, 78, 85, 87, 88, 89, 100, 6, 11, 13, 21, 28, 30, 36, 39, 43, 44, 47, 59, 77, 82, 93, 98, 1, 4, 5, 18, 22, 24, 50, 57, 63, 64, 75, 78, 87, 90, 91, 100, 13, 15, 19, 21, 25, 26, 34, 36, 38, 56, 57, 59, 60, 67, 70, 78, 90, 1, 3, 19, 20, 24, 30, 33, 35, 45, 56, 63, 69, 70, 73, 74, 80, 82, 89, 91, 94, 2, 3, 14, 22, 25, 36, 37, 40, 44, 48, 50, 56, 59, 75, 93, 2, 3, 11, 13, 16, 35, 38, 41, 43, 44, 46, 47, 55, 60, 61, 62, 63, 71, 81, 82, 83, 87, 92, 96, 3, 5, 10, 13, 23, 24, 27, 29, 38, 39, 47, 50, 52, 55, 73, 76, 89, 93, 20, 22, 24, 28, 32, 39, 47, 49, 50, 57, 63, 64, 67, 69, 70, 71, 72, 73, 78, 79, 86, 91, 93, 95, 98, 100, 5, 7, 10, 11, 16, 17, 22, 28, 34, 41, 43, 49, 54, 55, 67, 78, 79, 100, 9, 23, 27, 28, 32, 36, 37, 38, 40, 49, 54, 57, 65, 67, 69, 73, 77, 81, 88, 90, 2, 3, 4, 7, 20, 27, 30, 31, 38, 39, 43, 44, 47, 53, 62, 71, 75, 82, 87, 89, 95, 98, 99, 100, 1, 3, 10, 13, 19, 27, 31, 32, 38, 40, 42, 44, 46, 50, 55, 61, 73, 78, 94, 95, 3, 13, 17, 19, 21, 26, 29, 39, 52, 53, 55, 61, 62, 68, 70, 79, 80, 81, 83, 87, 92, 99, 1, 6, 19, 21, 26, 34, 37, 43, 46, 51, 52, 53, 64, 65, 78, 79, 82, 91, 93, 94, 96, 3, 4, 7, 8, 16, 17, 18, 33, 36, 43, 48, 51, 58, 60, 62, 67, 69, 73, 90, 93, 94, 95, 100, 8, 12, 15, 21, 22, 32, 55, 56, 61, 63, 69, 70, 73, 78, 85, 86, 91, 98, 3, 5, 7, 17, 18, 20, 28, 29, 31, 32, 35, 36, 43, 45, 48, 52, 53, 55, 60, 66, 74, 77, 81, 82, 87, 1, 3, 6, 9, 12, 13, 20, 23, 31, 38, 44, 48, 50, 53, 54, 63, 75, 76, 85, 89, 100, 11, 14, 22, 34, 38, 52, 53, 59, 69, 76, 78, 79, 84, 86, 91, 92, 93, 94, 95, 99, 4, 6, 8, 11, 12, 26, 31, 36, 37, 38, 39, 48, 50, 52, 53, 57, 74, 76, 82, 83, 89, 97, 98, 4, 7, 9, 30, 33, 34, 41, 43, 45, 46, 49, 51, 56, 62, 63, 64, 66, 69, 71, 77, 81, 87, 2, 7, 17, 18, 24, 29, 38, 46, 51, 55, 58, 67, 69, 71, 73, 76, 78, 79, 80, 11, 14, 15, 16, 31, 41, 43, 56, 60, 69, 71, 90, 93, 96, 2, 5, 12, 13, 14, 21, 31, 41, 42, 49, 52, 60, 62, 66, 75, 84, 4, 11, 17, 21, 26, 31, 33, 40, 46, 61, 72, 73, 79, 88, 96, 99, 5, 8, 15, 25, 34, 39, 41, 44, 49, 51, 59, 62, 63, 66, 73, 82, 83, 94, 15, 16, 21, 22, 24, 27, 28, 29, 32, 34, 36, 39, 45, 48, 50, 52, 53, 60, 71, 75, 77, 79, 80, 82, 86, 96, 98, 100, 3, 12, 14, 16, 20, 21, 31, 33, 34, 48, 49, 64, 65, 69, 73, 74, 76, 79, 81, 8, 19, 25, 29, 32, 40, 49, 67, 71, 73, 74, 79, 80, 82, 84, 85, 97, 98, 7, 13, 18, 23, 25, 30, 31, 32, 35, 50, 51, 58, 62, 63, 65, 66, 71, 73, 80, 87, 88, 99, 2, 3, 8, 10, 21, 34, 50, 58, 60, 62, 70, 75, 80, 84, 93, 96, 1, 4, 5, 7, 9, 14, 19, 21, 24, 31, 37, 53, 58, 61, 73, 74, 78, 83, 91, 93, 100, 1, 9, 14, 18, 24, 36, 38, 48, 50, 58, 59, 62, 66, 73, 74, 79, 86, 87, 89, 92, 93, 99, 7, 10, 11, 14, 15, 16, 22, 23, 24, 26, 37, 39, 42, 49, 59, 69, 71, 77, 79, 82, 84, 87, 95, 96, 98, 99, 3, 5, 11, 12, 15, 17, 24, 30, 31, 38, 45, 48, 59, 71, 74, 77, 78, 80, 92, 98, 2, 4, 9, 14, 16, 29, 33, 41, 49, 51, 76, 77, 78, 88, 93, 10, 13, 25, 27, 28, 30, 40, 54, 59, 67, 69, 71, 77, 79, 80, 94, 1, 2, 3, 16, 28, 38, 45, 55, 58, 61, 64, 67, 69, 76, 88, 93, 5, 10, 13, 15, 18, 19, 21, 25, 27, 43, 44, 46, 49, 53, 54, 55, 56, 59, 66, 71, 75, 80, 82, 85, 96, 99, 5, 9, 10, 15, 16, 22, 30, 43, 47, 49, 56, 58, 60, 64, 73, 79, 81, 82, 88, 90, 93, 94, 98, 100, 1, 8, 21, 25, 31, 39, 42, 48, 49, 52, 62, 63, 66, 72, 74, 81, 82, 84, 93, 97, 2, 10, 16, 18, 25, 26, 29, 43, 54, 72, 86, 88, 92, 94, 97, 2, 4, 5, 10, 11, 12, 15, 44, 50, 53, 55, 71, 72, 83, 90, 93, 97, 9, 19, 21, 22, 24, 31, 32, 37, 39, 45, 52, 56, 62, 75, 76, 77, 85, 86, 3, 12, 13, 14, 25, 28, 30, 32, 33, 38, 40, 43, 44, 45, 52, 53, 56, 59, 61, 75, 76, 84, 92, 93, 97, 2, 3, 6, 9, 11, 12, 16, 22, 24, 31, 34, 35, 37, 47, 57, 59, 83, 86, 87, 92, 94, 1, 18, 19, 25, 26, 30, 34, 40, 56, 59, 66, 96, 100, 1, 2, 11, 17, 18, 21, 23, 24, 28, 31, 45, 48, 49, 57, 58, 61, 76, 77, 78, 82, 85, 88, 95, 98, 100, 2, 4, 15, 17, 18, 21, 22, 23, 24, 31, 36, 43, 47, 49, 61, 64, 66, 73, 74, 75, 76, 79, 80, 87, 100, 13, 14, 22, 41, 43, 46, 59, 61, 62, 64, 67, 77, 79, 81, 88, 96, 10, 11, 13, 16, 17, 20, 21, 26, 42, 43, 47, 55, 59, 62, 67, 73, 78, 88, 89, 3, 7, 8, 9, 20, 25, 27, 43, 44, 48, 49, 51, 60, 62, 63, 65, 69, 73, 78, 79, 81, 84, 86, 87, 6, 7, 12, 14, 24, 50, 52, 64, 66, 73, 88, 93, 3, 19, 26, 34, 35, 36, 37, 42, 44, 52, 63, 70, 71, 77, 85, 86, 87, 91, 95, 1, 4, 5, 7, 9, 23, 30, 37, 38, 39, 41, 43, 49, 50, 51, 54, 55, 60, 63, 68, 69, 74, 81, 90, 93, 7, 10, 19, 21, 27, 28, 31, 35, 44, 56, 59, 61, 63, 76, 77, 80, 84, 92, 94, 100, 3, 10, 16, 17, 20, 29, 36, 42, 49, 52, 53, 54, 60, 72, 77, 78, 90, 100, 10, 15, 17, 19, 25, 28, 30, 34, 35, 37, 45, 48, 54, 55, 56, 70, 76, 78, 79, 80, 81, 82, 86, 97, 100, 6, 8, 10, 12, 20, 22, 25, 30, 34, 45, 56, 58, 59, 60, 63, 67, 75, 84, 86, 89, 91, 93, 96, 6, 12, 18, 25, 32, 42, 44, 53, 54, 57, 71, 78, 84, 85, 95, 98, 3, 14, 18, 32, 34, 56, 65, 78, 80, 86, 91, 93, 95, 1, 3, 21, 25, 28, 30, 34, 37, 43, 45, 51, 53, 57, 70, 72, 75, 82, 85, 7, 12, 13, 14, 19, 26, 33, 41, 42, 54, 55, 63, 67, 68, 70, 74, 77, 78, 79, 82, 87, 90, 92, 94, 17, 59, 67, 69, 70, 80, 94, 95, 8, 12, 14, 19, 20, 23, 25, 26, 27, 32, 38, 41, 42, 56, 59, 68, 71, 75, 87, 92, 96, 98, 100, 7, 8, 12, 17, 20, 35, 58, 62, 66, 67, 68, 73, 79, 81, 89, 10, 12, 15, 25, 26, 27, 31, 33, 34, 38, 39, 41, 43, 47, 58, 64, 69, 71, 77, 87, 93, 12, 29, 45, 46, 47, 61, 66, 74, 78, 79, 80, 97, 100, 4, 8, 11, 12, 14, 16, 19, 20, 26, 29, 30, 32, 33, 34, 36, 37, 44, 53, 55, 56, 57, 70, 82, 87, 89, 93, 8, 21, 24, 32, 33, 36, 37, 39, 45, 53, 59, 67, 72, 75, 80, 97, 6, 9, 15, 22, 28, 31, 35, 43, 48, 49, 53, 63, 66, 69, 74, 76, 82, 87, 91, 92, 100, 11, 22, 23, 24, 26, 32, 40, 42, 48, 49, 52, 53, 60, 62, 75, 77, 91, 94, 96, 2, 3, 5, 14, 21, 25, 31, 38, 39, 40, 41, 48, 52, 54, 58, 60, 61, 67, 71, 76, 77, 86, 88, 91, 92, 94, 96, 4, 6, 7, 12, 13, 16, 18, 20, 23, 26, 36, 39, 40, 52, 55, 56, 61, 62, 64, 65, 67, 72, 78, 83, 84, 90, 12, 13, 17, 18, 23, 26, 29, 31, 32, 33, 37, 38, 41, 44, 53, 54, 56, 62, 67, 70, 72, 82, 87, 90, 92, 93, 94, 97, 98, 99, 2, 3, 8, 17, 26, 31, 33, 34, 35, 39, 41, 43, 53, 60, 62, 65, 68, 72, 74, 80, 83, 84, 85, 93, 95, 96, 99, 10, 14, 17, 21, 25, 32, 44, 45, 54, 56, 59, 62, 70, 81, 99, 3, 5, 8, 10, 15, 18, 21, 24, 30, 31, 33, 38, 43, 44, 45, 52, 62, 66, 67, 73, 75, 79, 84, 89, 90, 92, 95, 10, 17, 24, 30, 36, 47, 50, 78, 80, 85, 88, 96, 100, 23, 28, 33, 35, 38, 45, 49, 56, 60, 63, 64, 78, 80, 82, 90, 94, 2, 4, 20, 22, 33, 43, 48, 52, 58, 64, 66, 80, 83, 95, 98, 99, 100, 12, 20, 23, 31, 37, 46, 48, 50, 56, 58, 62, 63, 65, 77, 89, 93, 94, 98, 99, 1, 4, 6, 10, 15, 17, 21, 25, 34, 37, 38, 50, 53, 56, 58, 67, 69, 71, 73, 75, 79, 87, 95, 99, 4, 14, 29, 34, 40, 42, 44, 46, 52, 54, 55, 57, 77, 83, 94, 96, 4, 8, 11, 15, 22, 24, 37, 55, 63, 70, 73, 82, 86, 90, 100, 1, 6, 7, 14, 19, 27, 44, 47, 59, 61, 67, 78, 79, 82, 84, 89, 91, 6, 8, 12, 18, 20, 23, 36, 58, 63, 65, 75, 76, 77, 90, 2, 10, 17, 23, 37, 39, 46, 49, 50, 60, 67, 69, 75, 77, 79, 82, 93, 95, 98, 1, 5, 9, 11, 12, 18, 19, 23, 27, 35, 36, 37, 40, 42, 44, 45, 47, 49, 57, 59, 63, 65, 71, 73, 79, 80, 86, 92, 98, 1, 2, 8, 16, 18, 19, 23, 30, 41, 44, 46, 50, 60, 67, 68, 76, 77, 79, 84, 86, 88, 97, 12, 15, 16, 19, 23, 38, 52, 58, 64, 65, 68, 80, 82, 85, 87, 92, 100, 10, 18, 27, 29, 31, 35, 38, 43, 51, 54, 63, 69, 76, 77, 80, 83, 88, 100, 1, 24, 33, 45, 46, 47, 49, 62, 72, 74, 79, 94, 97, 3, 5, 12, 15, 20, 24, 31, 33, 38, 39, 44, 52, 64, 69, 79, 85, 86, 92, 93, 98, 15, 17, 23, 29, 34, 37, 38, 43, 79, 80, 81, 85, 86, 87, 100, 1, 4, 6, 12, 13, 15, 19, 22, 31, 36, 44, 51, 52, 53, 60, 61, 62, 69, 72, 75, 83, 85, 89, 95, 96, 99];
Gnzval = [0.30570065342053154, 0.905803706195337, 0.5486462806827126, 0.8243213559107914, 0.31931103423222806, 0.46246587439931064, 0.9841769885098344, 0.37148886053422125, 0.4922975818753703, 0.22964450452196905, 0.5435252370432331, 0.30459684910568474, 0.5627975689918179, 0.9233829232762429, 0.8398922336727683, 0.7981145249934654, 0.5271617620078821, 0.14835492074074264, 0.9350401707195675, 0.022487222839689736, 0.7143926955231628, 0.8256989651858082, 0.6665603644974687, 0.6913841249203949, 0.9922967825341977, 0.30808223251073863, 0.6713716144909807, 0.7721536885543203, 0.22857680109305, 0.5510813864383033, 0.5524462919695232, 0.3053143382397816, 1.5457707675441692, 0.022583597275840805, 0.617003305800838, 0.32770581067592897, 0.6799216244119353, 0.8559009941050417, 0.36755326030160496, 0.30570065342053154, 0.5434753120551996, 0.11343498316350265, 0.14082776550421117, 0.01192461246804366, 0.9460972454534755, 0.9905040303409169, 0.04472615885203024, 0.8513254097009955, 0.034419356416512725, 0.8749394970204205, 0.9465584985068294, 0.080297733393774, 0.3495847159379961, 0.8313915731950678, 0.5239005971497637, 0.3843481311225281, 0.9297897296421593, 0.572451831535215, 0.6865246130144149, 0.04154217920172831, 0.10663551066273791, 0.03882329030859588, 0.8186557301057427, 0.3248196736347324, 0.8683375539628453, 0.7143926955231628, 0.4230602210666581, 1.1338612803176376, 0.8817576855470557, 0.05640515398514645, 0.6418161824184287, 0.6910501139205614, 0.5603246929611738, 0.08889372569112375, 0.5988507108501036, 0.8169604139190232, 0.08180873286415236, 1.3730673676708254, 0.22099015878050166, 0.7651513605979896, 0.637919830089438, 0.9943492161225798, 0.4082728512217113, 0.49107486405247136, 0.1250456151068069, 0.5410845503607156, 0.12422565343156133, 0.024147142462195736, 0.12468301140307081, 0.2580684969526328, 0.021895090464451705, 0.3038977454887539, 0.6394129974111553, 1.5240046691565643, 0.8279012959859486, 0.1278385178848085, 0.9220718502238312, 0.5516410414426027, 0.954391552129005, 0.5521420917971065, 0.905803706195337, 0.4230602210666581, 0.1250456151068069, 0.5872716724142355, 0.6678487952960217, 0.7998624991923358, 0.31688366347318575, 0.6713072290824307, 0.25626559986702313, 0.4768505020573308, 0.9070184044368812, 0.264911310717008, 0.5227425067314215, 0.22106143726159222, 0.45758297444788987, 0.403887191040305, 0.47165925978831624, 0.3969650395624289, 0.8195092963351773, 0.9934981630682629, 0.20032515342137258, 0.10681061642688716, 0.7182826898606698, 0.8951860999401184, 0.6613228765703683, 0.5558496451988013, 0.18989135832899962, 0.7668121880463186, 1.2477415369651164, 0.8534971586100903, 0.5935078507907501, 0.6622042314371697, 0.9044044672988854, 0.5486462806827126, 0.5434753120551996, 0.10979127065800554, 0.8384429740234149, 0.21485624956104643, 0.10932996770310255, 0.649922665665174, 0.9460509094346983, 0.5175755782668303, 0.20257139397450907, 0.4500054138219838, 0.2564708106494049, 0.97796779789206, 0.24495910867397375, 0.9636054262758076, 0.8520044849841384, 0.7425930531114051, 0.17854646291335197, 0.36642919784071104, 0.08063802687864108, 0.8256989651858082, 0.11343498316350265, 1.2039249928452818, 0.3276332486808824, 0.6804452698755388, 0.5251040465719641, 0.1116429064216573, 0.5720927686156287, 0.7830134201928025, 0.07519909733706176, 0.5345407426173243, 0.656357983582869, 0.9978004344209452, 0.057560643005053924, 0.6006062609106879, 0.6665603644974687, 0.14082776550421117, 0.6615110201397072, 0.16321876828513626, 0.001151951745084645, 0.3182212708570791, 0.36087764709333725, 0.4199989619367863, 0.22120106513824078, 0.08755063547457254, 0.11665893787030113, 0.5712185739700724, 0.12069224524660083, 0.06085931716484083, 0.527429723681659, 0.8476043151912853, 0.6205446202950187, 0.1791165172359801, 0.4748101508811371, 0.03932836265363937, 0.8199035803926842, 0.3240120030671727, 0.7179519497517932, 0.05725480919061554, 0.01192461246804366, 0.5410845503607156, 0.6615110201397072, 0.847313917156741, 0.36537648116817545, 0.09693233195470485, 0.8899698110006229, 0.44972910186733683, 0.681895830797288, 0.18225332539430195, 0.7614160970648216, 0.27520537132991785, 0.7730871536239041, 0.9481690743269224, 0.12914428954218837, 1.76846747041627, 0.3957493697675798, 0.7670628528498982, 0.7463230006241537, 0.203732253961469, 0.490221371669872, 0.3918539213731762, 0.6550460130374118, 0.9512131954088192, 0.8251170624667956, 0.5061287037151805, 0.4185082653337875, 0.8723385198267206, 0.7815462421607451, 0.3928700705877739, 0.18129536119261935, 0.7013813480094384, 0.1118859987483034, 0.13991874135332782, 0.30251736752343716, 0.473319464138362, 0.9923018049228953, 0.1424377352680326, 0.35602171313695496, 0.9722237677171546, 0.504966569994904, 0.2664719256186341, 0.27931623025521257, 0.9275835711795133, 0.12422565343156133, 0.47165925978831624, 0.16321876828513626, 0.847313917156741, 0.16688184693792518, 0.13194408301446692, 0.8291622972561545, 0.4678567699941558, 0.9114202239352542, 0.8700391990478351, 0.6465629803533945, 0.7699945477585401, 0.5662642734575563, 0.2619702847509826, 0.195519230175359, 0.7599425621729325, 0.6282796964620732, 0.05587490410692042, 1.2039249928452818, 0.9585857070040449, 0.40077503330261766, 0.2864174985553869, 0.37906308219118445, 0.9067446167441886, 0.8161143481015705, 0.33709844105885356, 0.008008628142579521, 0.04025363659833947, 0.08677187465481406, 0.7552855936291201, 0.7595402125829787, 0.8855933927248747, 0.3243272135191342, 0.20353497564344725, 0.5607046017126742, 0.0013444671182565315, 0.26145504882090886, 0.8657154425014815, 0.6913841249203949, 0.9460972454534755, 1.1338612803176376, 0.3969650395624289, 0.44919234484719994, 0.7368945481814069, 0.37502283520635005, 0.8054051625831287, 0.26210981647446285, 0.036387010210889636, 0.19479755978856184, 0.2747281351556192, 0.04932798215814782, 0.6936969138013196, 0.6708784320805292, 0.03160792090226949, 0.5438285403665997, 0.2296993036631163, 0.17347979416031123, 0.9459164683250751, 0.4297343125880855, 0.8391097592604597, 0.2919422115727788, 0.3901805234282545, 0.8243213559107914, 0.9905040303409169, 0.001151951745084645, 0.16688184693792518, 0.8817172875806134, 0.208879533247879, 0.7893620059380417, 0.38915075995643256, 0.6125984880859863, 0.4078993113088416, 0.4255237049179488, 0.009867795258318157, 0.16407794712371637, 0.1526945062022811, 0.2940902150216069, 0.33689098445081433, 0.24507063856995037, 0.5203417141275968, 0.6461289971578776, 0.9019985067880534, 0.04472615885203024, 0.13194408301446692, 0.24698874161987439, 0.09559045549386713, 0.07816655014263518, 0.8555962997802189, 0.020163641505229313, 0.5375284545574046, 0.33999113675759585, 0.18414470239910719, 0.07318437440546677, 0.5446212120838012, 0.9120839300830221, 0.19329991648173483, 0.2232595012298182, 0.013912838135412775, 0.24296151388645537, 0.4777307185881361, 0.5001132304901748, 0.55544712396171, 0.8830249290720291, 0.16750453639066376, 0.31931103423222806, 0.5872716724142355, 0.7417224395995572, 0.19416430997599843, 0.6196989980457792, 0.6439804248875531, 0.6449301277609898, 0.5018342155993363, 0.969235476535079, 0.25947151956590964, 0.29506619222364217, 0.8168382670319918, 0.6936178675892353, 0.7927951134386042, 0.15293201347807606, 0.603506319650142, 0.8744913699084358, 0.7892823340613053, 0.04384256656449437, 0.9141731616211415, 0.7899949901914345, 0.8513254097009955, 0.8817576855470557, 0.8195092963351773, 0.10979127065800554, 0.8817172875806134, 0.09559045549386713, 0.7417224395995572, 0.4449939577284543, 0.5441998434509558, 0.23752097518149595, 0.6658044138610562, 0.704629617887317, 1.1568801817078156, 0.5922792895889639, 0.28150900934964285, 0.6979596281543703, 0.9284998102962352, 0.6035311675240218, 0.10164627444268404, 0.8648116620377351, 0.8927641863671658, 0.6720862649167656, 0.9228969599943546, 0.8384429740234149, 0.7463230006241537, 0.44919234484719994, 0.14392009436140896, 0.1210960835861028, 0.31555339075870825, 0.10196186412350072, 0.5798649380140739, 0.9250862337531842, 0.9411806879655977, 0.7680072032824106, 0.8702984322509766, 0.6444918421024268, 0.05574872548255616, 0.2554747585202164, 0.47796321713668766, 0.08206460127090032, 0.7459679649704893, 0.034419356416512725, 0.024147142462195736, 0.9934981630682629, 0.07816655014263518, 0.19416430997599843, 0.14392009436140896, 0.11824424826631685, 0.3032084772440822, 0.651767712260664, 0.7167850878983919, 0.43708593012999897, 0.3807684566133518, 0.3592512207164684, 0.7392692147482314, 0.17773086289321838, 0.393231607740824, 0.6537495091003236, 0.6238538366759847, 0.8189640022579967, 1.075691221452822, 0.8982628680559843, 0.49268880608499543, 0.9697030405971934, 0.1883020983576198, 0.23834063672251937, 0.46246587439931064, 0.8749394970204205, 0.6678487952960217, 0.3276332486808824, 0.203732253961469, 0.8291622972561545, 0.1210960835861028, 0.7562381288540707, 0.6965146195012797, 0.9622411231921082, 0.24314086525162226, 0.7184565784357972, 0.8731777860813359, 0.9535368122004706, 0.8539089250025051, 0.8805319508228346, 0.2586840805353656, 0.6256795934166484, 0.9782308664848147, 0.45189660226998885, 0.9727236350283752, 0.36537648116817545, 0.9585857070040449, 0.7562381288540707, 0.4939842231338163, 0.4293790911257105, 0.5134198805385135, 0.21135141527612866, 0.17931628532697164, 0.11738339017674537, 0.6374437388890768, 0.977911111572237, 0.1850833824998659, 0.33613152898443266, 0.35755548533189563, 0.25614935915915793, 0.9933101940184865, 0.047343099390839916, 0.2373939964593581, 0.6922413302954813, 0.3054421604127602, 0.05640515398514645, 0.7998624991923358, 0.21485624956104643, 0.09693233195470485, 0.490221371669872, 0.8031106650968678, 0.9257841898448309, 0.8721690574259171, 0.2725785687235176, 0.854923216696402, 0.5083861565297865, 0.06146707632026982, 0.648098662710743, 0.8427281329892025, 0.6750412963204047, 0.9971534789959651, 0.2659963570027344, 0.027511185640656022, 0.9533492310119924, 0.3179695024945324, 0.6107340401662686, 0.827485278041241, 0.48518833185954935, 0.6418161824184287, 0.20032515342137258, 0.6804452698755388, 0.5673314704401973, 0.43994398514057886, 0.6420757318629053, 0.5964407929972335, 0.3991392056007088, 0.6123891255485969, 0.5468297182467701, 0.8454990015478323, 0.11730044014239582, 0.9880390097382523, 0.34472701899117975, 0.8052022924903093, 0.06807357023827776, 0.8384549679358853, 1.4267157766332097, 0.022102813898072338, 0.9175764902162105, 0.24319885334875235, 0.4948287769495232, 0.9922967825341977, 0.10681061642688716, 0.8555962997802189, 0.6196989980457792, 0.8031106650968678, 0.41188473416528093, 0.327811213232275, 0.40806841445669106, 0.7856578997376429, 0.19016006717931355, 0.8112432954571449, 0.13901944292708346, 0.41600700958167836, 0.9243880136220362, 0.5650512998981789, 0.12913942983313764, 0.3841390327551619, 0.6507971104239889, 0.5977757063227913, 0.8899698110006229, 0.40077503330261766, 0.7368945481814069, 0.208879533247879, 0.5000150215470842, 0.9541125075000254, 0.689522692342599, 0.8195594012995251, 0.5243482618232198, 0.9933418942509429, 0.999679998704398, 0.41911982248055524, 0.9081726300174722, 0.6350245834185881, 0.30808223251073863, 0.12468301140307081, 0.3918539213731762, 0.4678567699941558, 0.2864174985553869, 0.11824424826631685, 0.26719200827955847, 0.34797627991820845, 0.2388799704635538, 1.2484567947164569, 0.5914178376261763, 0.5561709156887298, 0.6532926465141342, 0.9848574215601498, 0.7454906726873369, 0.7737148819120725, 0.6910501139205614, 0.44972910186733683, 0.020163641505229313, 0.3032084772440822, 0.41188473416528093, 0.3066244218981531, 0.3121379723857436, 0.21447358421554275, 0.6606722040622683, 0.8655095412230072, 0.9361854086634398, 0.4731019333869735, 0.81390181947003, 0.9100425313491673, 0.7655386459702904, 0.12017809602207286, 0.2580684969526328, 0.10932996770310255, 0.37502283520635005, 0.5673314704401973, 0.9257381658496311, 0.4321754405996028, 1.3585480054567127, 0.5941416419724268, 0.707921191489812, 0.42144167085403583, 0.025176757587499488, 0.923774966211045, 0.25949695231450476, 0.9714304003104139, 0.1222037720143947, 0.7500976155763743, 0.9944386252678967, 0.9561123998695162, 0.8054051625831287, 0.7893620059380417, 0.651767712260664, 0.6965146195012797, 0.9257841898448309, 0.5000150215470842, 0.26719200827955847, 0.3066244218981531, 0.6023012252996598, 0.1331431956556648, 0.6033382386134358, 0.04203712793910719, 0.48529936854631583, 0.3771925659931743, 0.305833802475038, 0.7180880561370073, 0.9347945272342162, 0.467732105961137, 0.9679186820778418, 0.302456648543836, 0.3123054179289535, 0.01919901559187176, 0.16126731700918007, 0.41308371598256244, 0.32838823354784763, 0.3562725153103399, 0.06089155325573237, 0.33719912390286155, 0.9465584985068294, 0.6550460130374118, 0.37906308219118445, 0.38915075995643256, 0.31555339075870825, 0.7167850878983919, 0.6023012252996598, 0.0656522457367621, 0.14425359639402502, 0.15922087943628904, 0.5045206099801185, 0.5795697854651862, 0.9550029735477841, 0.5077604779042135, 0.7167887048485948, 0.05398656168242022, 0.9965691677751003, 0.958313958375463, 0.36566750086598865, 0.649922665665174, 0.4449939577284543, 0.43994398514057886, 0.3121379723857436, 0.0656522457367621, 0.5915116773222644, 0.7495407638307536, 0.5436273390960078, 0.9409308732581374, 0.3375159286897407, 0.7875401680900798, 0.379011220612518, 0.22545552849150985, 0.10735497645638614, 0.5194938393704118, 0.9992300825494427, 0.7038788766592174, 0.38398373314433343, 0.7182826898606698, 0.9114202239352542, 0.6439804248875531, 0.4939842231338163, 0.6420757318629053, 0.9257381658496311, 0.1331431956556648, 0.14425359639402502, 0.21508893280150154, 0.813066644670323, 0.667722147580442, 0.8156487233194982, 0.3209251786340577, 0.7461992195042368, 0.7021182893491835, 0.3267256101975138, 0.7129023446054965, 0.9299700766314636, 0.6396592859883623, 0.10989026284023073, 0.5657016816073326, 0.9891500013994039, 0.6713716144909807, 0.080297733393774, 0.9460509094346983, 0.3182212708570791, 0.43708593012999897, 0.21508893280150154, 0.7246654126541048, 0.16663293526589684, 1.0580399677165686, 0.12282823292368361, 0.22595618505340287, 0.9025467764252793, 0.7268280636664082, 0.0948773928697011, 0.9501915306489026, 0.29760177279608135, 0.9841769885098344, 0.5603246929611738, 0.021895090464451705, 0.8951860999401184, 0.5251040465719641, 0.9067446167441886, 0.5441998434509558, 0.3807684566133518, 0.8721690574259171, 0.6033382386134358, 0.8757043684156682, 0.27008484636960595, 0.37915745114767896, 0.3935805450220833, 0.4062099787185429, 0.548563593771904, 0.25650038050763313, 0.8931836707721248, 0.21774655958825373, 1.8819864639475046, 0.415358427338101, 0.37148886053422125, 0.1116429064216573, 0.8161143481015705, 0.6449301277609898, 0.2725785687235176, 0.8757043684156682, 0.46000541263760764, 0.5127368374554035, 0.05078608734569512, 0.5206678110963621, 0.6638750833609075, 0.4522816561092462, 0.661502716737584, 0.5833238345958078, 0.0380548689640694, 1.3714525194241796, 0.7015236152363729, 0.5401332649446173, 0.6731372698712614, 0.3707569265866897, 0.1738180776092173, 0.809329587160676, 0.6613228765703683, 0.36087764709333725, 0.681895830797288, 0.33709844105885356, 0.26210981647446285, 0.6125984880859863, 0.9622411231921082, 0.4293790911257105, 0.854923216696402, 0.327811213232275, 0.46000541263760764, 0.2586158459189638, 0.40734859654680156, 0.7856116468584462, 0.508107095700737, 0.821675913713954, 0.45759688688501865, 0.7090101180192818, 0.8866080943161159, 0.6624352107832201, 0.8838736299628374, 0.6176098541886701, 0.8828216032169565, 0.2691553052764686, 0.42542666758149683, 0.13590263787500034, 0.3495847159379961, 0.3038977454887539, 0.18225332539430195, 0.9512131954088192, 0.036387010210889636, 0.5375284545574046, 0.5083861565297865, 0.4321754405996028, 0.04203712793910719, 0.2586158459189638, 0.6549955132487466, 0.8758363630991788, 0.29745399276323337, 0.2114956095292635, 0.827388455259159, 0.05925518307237043, 0.9849768023447518, 0.919321373711989, 0.591128466305826, 0.13939320252880982, 0.7721536885543203, 0.08889372569112375, 0.5720927686156287, 0.008008628142579521, 0.4078993113088416, 0.21447358421554275, 0.5915116773222644, 0.8233045267960766, 0.9926104257295494, 0.2406666363181995, 0.2508014867915729, 0.8623498024241238, 0.9535671027782069, 0.8589581000145132, 0.49351794643597025, 0.4199989619367863, 0.8700391990478351, 0.5964407929972335, 0.9541125075000254, 0.34797627991820845, 1.3585480054567127, 0.8233045267960766, 0.846731415901818, 0.030583945173830784, 0.8234760829618897, 0.26552506428102385, 0.48912032319931, 0.3497629641499387, 0.03349994741046869, 0.7455594748307179, 0.02268839835932468, 0.4922975818753703, 0.22857680109305, 0.8313915731950678, 0.4255237049179488, 0.2388799704635538, 0.40734859654680156, 0.05374372191389276, 0.2677747648571114, 0.16562102744089047, 0.8792096350193037, 0.8178099465101074, 0.39997516426263746, 0.2076899218736563, 0.5445357536593562, 0.6473241578340836, 0.11347478664233934, 0.6394129974111553, 0.22120106513824078, 0.6465629803533945, 0.19479755978856184, 0.5018342155993363, 0.23752097518149595, 0.3592512207164684, 0.3991392056007088, 0.689522692342599, 1.3347309926475743, 0.4739761640119662, 0.6997435273012329, 0.7373905443968534, 0.7092210301094077, 0.47125274256306415, 0.9224565571981902, 0.8881790860921817, 0.7902476556340827, 0.24673404577072877, 0.7175100718324989, 0.5824252053727317, 0.031276495554763306, 0.5216957173829442, 0.4712583263162118, 0.8692555266234883, 0.07896079521569477, 1.5240046691565643, 0.7830134201928025, 0.08755063547457254, 0.2747281351556192, 0.009867795258318157, 0.24314086525162226, 0.5941416419724268, 0.4739761640119662, 0.5394317645939151, 0.9072951760164571, 0.7255189049897048, 0.053449927785429674, 0.3102695814911316, 0.5640311597396765, 0.49505782927253805, 0.8094552373927979, 0.3122481963493877, 0.11713061015608939, 0.4439055285783302, 0.3982853215552502, 0.5519315169259811, 0.793910138704949, 0.8704542016950014, 0.4262021236624105, 0.22964450452196905, 0.5175755782668303, 0.7392692147482314, 0.6123891255485969, 0.48529936854631583, 0.6549955132487466, 0.05374372191389276, 0.8389997884980509, 0.06165934003401907, 0.9143056100053031, 0.8093001399552857, 0.47381014543644584, 0.04611092728002264, 0.5241666213447769, 0.04102638045394058, 1.7366695935605267, 0.057844730035558234, 0.08508237949315811, 0.8736211075734264, 0.819557234507829, 0.5510813864383033, 0.11665893787030113, 0.16407794712371637, 0.969235476535079, 0.5468297182467701, 0.40806841445669106, 0.6606722040622683, 0.6997435273012329, 0.589067908777795, 0.3882112966088993, 0.08134217167984414, 0.17662739645038705, 0.8152865701329146, 0.45426276238657537, 0.24235598044148499, 0.5524462919695232, 0.5988507108501036, 0.8279012959859486, 0.5712185739700724, 0.7614160970648216, 0.8251170624667956, 0.04932798215814782, 0.5394317645939151, 0.8357009965160682, 0.14606889633644693, 0.1350007114766254, 0.7220671664780822, 0.20548721520043856, 0.6563993736998324, 0.5954279331495635, 0.9490765611667389, 0.7645910502083084, 0.07519909733706176, 0.6658044138610562, 0.17773086289321838, 0.7184565784357972, 0.06146707632026982, 0.3771925659931743, 0.15922087943628904, 0.5127368374554035, 0.8758363630991788, 0.8389997884980509, 0.4200397492578831, 0.3706781596650235, 0.9571081726878841, 0.9933410040284103, 0.5612078754071266, 0.3861508635481834, 0.22336995304314455, 0.9470156163956054, 0.5239005971497637, 0.5061287037151805, 0.7699945477585401, 0.04025363659833947, 0.8454990015478323, 1.2484567947164569, 0.707921191489812, 0.5045206099801185, 0.7495407638307536, 0.7856116468584462, 0.9926104257295494, 0.7373905443968534, 0.9072951760164571, 0.06165934003401907, 0.38698528607839844, 0.27328249512443503, 0.15611579997495273, 0.8282202959236682, 0.6685500588074829, 0.5928279548332942, 0.4968763777842553, 0.9626553306990575, 0.8842032951337915, 0.7650967874785879, 0.949706750182576, 0.3053143382397816, 0.3843481311225281, 0.31688366347318575, 0.5345407426173243, 0.27520537132991785, 0.4185082653337875, 0.1526945062022811, 0.8731777860813359, 0.648098662710743, 0.305833802475038, 0.813066644670323, 0.7246654126541048, 0.05078608734569512, 0.8357009965160682, 0.2700208836829696, 0.3560868551142413, 1.3104435167297623, 0.20955153916394686, 0.23190010357111834, 0.98545894788806, 0.8275162123351905, 0.5435252370432331, 0.25947151956590964, 0.704629617887317, 0.11730044014239582, 0.7856578997376429, 0.42144167085403583, 0.667722147580442, 0.2406666363181995, 0.9926667497829758, 0.9341276558254143, 0.9244373008629085, 0.4380646569066018, 0.40669867543191995, 0.30459684910568474, 1.5457707675441692, 0.7730871536239041, 0.33999113675759585, 0.29506619222364217, 0.393231607740824, 0.5134198805385135, 0.8427281329892025, 0.5914178376261763, 0.7180880561370073, 0.9143056100053031, 0.4200397492578831, 0.38698528607839844, 0.8346422797496875, 0.052290486388985924, 0.0786190273751175, 0.5538590116399038, 0.4050981491900736, 0.885712300608636, 0.07194834833952912, 0.3901816737984607, 0.9601569275007178, 0.7954057492904651, 0.6964104378114733, 0.6308236911248397, 0.022583597275840805, 0.8169604139190232, 0.6936969138013196, 0.18414470239910719, 0.8168382670319918, 0.6537495091003236, 0.9535368122004706, 0.21135141527612866, 0.6750412963204047, 0.9347945272342162, 0.27008484636960595, 0.7092210301094077, 0.14606889633644693, 0.27328249512443503, 0.9883695454442711, 0.31061106653721104, 0.9486214622420148, 1.0281066988949472, 0.93878711592619, 0.8266028242410084, 0.708573195884836, 0.816968218414319, 0.009733706438177059, 0.08447698820372063, 0.33693700040358876, 0.5662642734575563, 0.08677187465481406, 0.8539089250025051, 0.846731415901818, 0.47125274256306415, 0.589067908777795, 0.3872086351651858, 0.11375962292400343, 0.39372704458458707, 0.5930880580272853, 0.07352365831954111, 0.5425341130052295, 0.0364833055639755, 0.9489105332609129, 0.4829876526944967, 0.20949588408432884, 0.12069224524660083, 0.9481690743269224, 0.2619702847509826, 0.2940902150216069, 0.07318437440546677, 0.10196186412350072, 0.6238538366759847, 0.19016006717931355, 0.2677747648571114, 0.9224565571981902, 0.1350007114766254, 0.005261350527948849, 0.3734613954126238, 0.6465018698104177, 0.5065803151085138, 0.0058144177598056235, 0.9174315142150586, 0.30838307307180446, 0.356746268324595, 0.9297897296421593, 0.5558496451988013, 0.20257139397450907, 0.656357983582869, 0.5798649380140739, 0.9880390097382523, 0.8195594012995251, 0.8881790860921817, 0.7255189049897048, 0.3706781596650235, 0.15611579997495273, 0.9926667497829758, 0.6833536098448014, 0.4968878870085689, 0.07487476961763018, 0.47242210320594524, 0.7381232613196878, 0.35175941740245564, 0.8419334237717491, 0.9119681797507084, 0.840785179703543, 0.08897176871199708, 0.6768748614312903, 0.8327773419393756, 0.6713072290824307, 0.18989135832899962, 0.8723385198267206, 0.7552855936291201, 0.9971534789959651, 0.2700208836829696, 0.8346422797496875, 0.8009283721392819, 0.5102885813877145, 0.3054473247797549, 0.7607324019057775, 0.9551272764814103, 0.572451831535215, 1.1568801817078156, 0.8112432954571449, 0.8156487233194982, 0.16663293526589684, 0.37915745114767896, 0.5206678110963621, 0.16562102744089047, 0.053449927785429674, 0.052290486388985924, 0.5352811519566929, 0.3339641357304306, 0.4041577343782796, 0.08575814270773296, 0.5542319539355611, 0.7518436041296448, 0.12090324545613118, 0.8825680507240805, 0.6082542416427508, 0.5627975689918179, 0.08180873286415236, 0.1278385178848085, 0.7668121880463186, 0.9978004344209452, 0.17931628532697164, 0.025176757587499488, 0.6638750833609075, 0.508107095700737, 0.29745399276323337, 0.030583945173830784, 0.7902476556340827, 0.8282202959236682, 0.3560868551142413, 0.9341276558254143, 0.3872086351651858, 0.3734613954126238, 0.16021453378826234, 0.8506367696065344, 0.8951354499740645, 0.10248953927750737, 0.5252406305554451, 0.31904229942828843, 0.9477433990008648, 0.2611614049941906, 1.2477415369651164, 0.06085931716484083, 0.5922792895889639, 0.8189640022579967, 0.5243482618232198, 0.5561709156887298, 0.467732105961137, 1.0580399677165686, 0.3102695814911316, 0.6833536098448014, 0.16021453378826234, 0.38430306260307634, 0.36377193112408057, 0.4619607114239819, 0.7243434409375162, 0.5990688875954979, 0.23797469650360004, 0.3542692229166349, 0.30194859069497526, 0.8137783739453859, 0.6865246130144149, 0.527429723681659, 0.33689098445081433, 0.5446212120838012, 0.9250862337531842, 0.8655095412230072, 0.3935805450220833, 0.8792096350193037, 0.6685500588074829, 0.0786190273751175, 0.9883695454442711, 0.11375962292400343, 0.38430306260307634, 0.30011450804003426, 0.7162954432619286, 0.9926211442091528, 0.35231683029409666, 0.292017617588479, 0.8476043151912853, 0.6708784320805292, 0.9120839300830221, 0.28150900934964285, 0.34472701899117975, 0.6532926465141342, 0.923774966211045, 0.3209251786340577, 0.12282823292368361, 0.4522816561092462, 0.8093001399552857, 0.9571081726878841, 0.39372704458458707, 0.6465018698104177, 0.4968878870085689, 0.9042743484795264, 0.4184825265864407, 0.7430873443767347, 0.9311959297416645, 0.7142253682166626, 0.5839840367433586, 0.7300586653414614, 0.5033863049512775, 0.5581332314280845, 0.5819193969526073, 0.25626559986702313, 0.4500054138219838, 0.6205446202950187, 0.7815462421607451, 0.9411806879655977, 0.8805319508228346, 0.8052022924903093, 0.25949695231450476, 0.7461992195042368, 0.47381014543644584, 0.07487476961763018, 0.5352811519566929, 0.8506367696065344, 0.36377193112408057, 0.1093108714792339, 0.6311135057836059, 0.0046673095171478884, 0.311965965452196, 0.9093694710580416, 0.019852496194460834, 0.3347645581353962, 0.889001800055712, 0.6390073532303879, 0.4768505020573308, 0.3928700705877739, 0.6936178675892353, 0.06807357023827776, 0.5795697854651862, 0.8178099465101074, 0.5640311597396765, 0.31061106653721104, 0.5930880580272853, 0.8009283721392819, 0.1563824899607167, 0.8532106553699086, 0.4924581366432379, 0.46438036772074454, 0.9805071205563163, 0.8858025680164523, 0.04154217920172831, 0.7595402125829787, 0.7927951134386042, 0.9550029735477841, 0.7021182893491835, 0.47242210320594524, 1.8743194328034152, 0.16981471450049712, 0.10306059399889356, 0.9593126694002296, 0.5834948961866246, 1.2113843017373174, 0.4871268792863317, 0.9233829232762429, 0.10663551066273791, 1.075691221452822, 0.8384549679358853, 0.9848574215601498, 0.9714304003104139, 0.3267256101975138, 0.661502716737584, 0.24673404577072877, 0.04611092728002264, 0.9244373008629085, 0.9486214622420148, 0.5102885813877145, 0.6359328835598643, 0.27775565788517165, 0.42276646221944025, 0.5946617594617176, 0.4001188728136498, 0.8534971586100903, 0.18129536119261935, 0.195519230175359, 0.8855933927248747, 0.6979596281543703, 0.13901944292708346, 0.5436273390960078, 0.8234760829618897, 0.39997516426263746, 0.07352365831954111, 0.5065803151085138, 0.6311135057836059, 0.23218002558377027, 0.7788655916025229, 0.6492837012235602, 0.6396850514052452, 0.2162775776149639, 0.9616982751386449, 0.050003721609149565, 0.026644272428671067, 0.47310942491655905, 0.21204126520061028, 0.32291746063978843, 0.6598565415592574, 0.19329991648173483, 0.8951354499740645, 0.7788655916025229, 0.5775817595906021, 0.3035444610997904, 0.07004092250820593, 0.8193464812265749, 0.16352054372447955, 0.2564708106494049, 0.7013813480094384, 0.3243272135191342, 0.9284998102962352, 0.7680072032824106, 0.11738339017674537, 1.4267157766332097, 0.41600700958167836, 0.9933418942509429, 0.5077604779042135, 0.821675913713954, 0.26552506428102385, 0.2076899218736563, 0.7381232613196878, 0.10248953927750737, 0.5775817595906021, 0.2603556964119107, 0.060439418563272174, 0.10798192863435885, 0.5725696888508567, 0.9463628898166316, 0.6297101351941694, 0.7571153626501057, 0.5935078507907501, 0.97796779789206, 0.1118859987483034, 0.2232595012298182, 0.8702984322509766, 0.22595618505340287, 0.3339641357304306, 0.9042743484795264, 0.6359328835598643, 0.6492837012235602, 0.3035444610997904, 0.5923793686523335, 0.2812411480233674, 0.7784306878623337, 0.6490672037413827, 0.1791165172359801, 0.13991874135332782, 0.03160792090226949, 0.022102813898072338, 0.9243880136220362, 0.999679998704398, 0.9679186820778418, 0.9409308732581374, 0.7129023446054965, 0.45759688688501865, 0.2114956095292635, 0.48912032319931, 0.7175100718324989, 0.7220671664780822, 0.4041577343782796, 0.1563824899607167, 0.2603556964119107, 0.6199504760288437, 0.19467641349754805, 0.14593966516938783, 0.9356795689450672, 0.30251736752343716, 0.9361854086634398, 0.5241666213447769, 0.3882112966088993, 0.20548721520043856, 0.30011450804003426, 0.27775565788517165, 0.9746936104627897, 0.20649232045795496, 0.27289237817918277, 0.6651369743021611, 0.4965426690892041, 0.3819544040026519, 1.3730673676708254, 0.24495910867397375, 0.12914428954218837, 0.473319464138362, 0.20353497564344725, 0.24507063856995037, 0.6035311675240218, 0.6444918421024268, 0.5650512998981789, 0.4731019333869735, 0.1222037720143947, 0.7167887048485948, 0.3375159286897407, 0.9299700766314636, 0.4062099787185429, 0.5833238345958078, 0.49505782927253805, 1.0281066988949472, 0.0058144177598056235, 0.35175941740245564, 0.3054473247797549, 0.5923793686523335, 0.9100938717413407, 0.5799184259157477, 0.0397939562752323, 0.28625627586815616, 0.9636054262758076, 0.8982628680559843, 0.2659963570027344, 0.05398656168242022, 0.7875401680900798, 0.548563593771904, 0.0380548689640694, 0.827388455259159, 0.04102638045394058, 0.93878711592619, 0.5252406305554451, 0.6396850514052452, 0.9746936104627897, 0.006324173679747913, 0.8213246078326248, 0.6810505372885312, 0.9070184044368812, 0.057560643005053924, 0.5438285403665997, 0.2586840805353656, 0.7454906726873369, 0.302456648543836, 0.9025467764252793, 0.5824252053727317, 0.9933410040284103, 0.5928279548332942, 0.8266028242410084, 0.0046673095171478884, 0.42276646221944025, 0.060439418563272174, 0.006324173679747913, 0.19055069912650358, 0.210609869033892, 0.9386408480869344, 0.11177496400046816, 0.3017057013196258, 0.5681498899757371, 1.76846747041627, 0.6256795934166484, 0.6374437388890768, 0.027511185640656022, 0.12913942983313764, 0.9965691677751003, 0.2508014867915729, 0.5445357536593562, 0.5612078754071266, 0.4968763777842553, 0.5538590116399038, 0.708573195884836, 0.4619607114239819, 0.4184825265864407, 0.19055069912650358, 0.5455103215466353, 0.853018532616926, 0.40538754723620096, 0.4332087980287742, 0.617003305800838, 0.03882329030859588, 0.9220718502238312, 0.5607046017126742, 0.49268880608499543, 0.9175764902162105, 0.3123054179289535, 0.7090101180192818, 0.05925518307237043, 0.8623498024241238, 0.3497629641499387, 0.3861508635481834, 0.4050981491900736, 0.5425341130052295, 0.08575814270773296, 0.7243434409375162, 0.7162954432619286, 0.2162775776149639, 0.19467641349754805, 0.5455103215466353, 0.5185806383010765, 0.645947803518383, 0.7401420237895417, 0.17754891849364585, 0.06548030367007573, 0.3754666887334641, 0.7994357137172707, 0.22099015878050166, 0.264911310717008, 0.6622042314371697, 0.9923018049228953, 0.7599425621729325, 0.5203417141275968, 0.15293201347807606, 0.05574872548255616, 0.977911111572237, 0.3841390327551619, 0.25650038050763313, 0.9849768023447518, 0.9535671027782069, 0.885712300608636, 0.9174315142150586, 0.8419334237717491, 0.9926211442091528, 0.7430873443767347, 0.8532106553699086, 0.16981471450049712, 0.9616982751386449, 0.20649232045795496, 1.5775170233040274, 0.34333877636650745, 0.21049332948309818, 0.16287135422422372, 0.1424377352680326, 0.6282796964620732, 0.013912838135412775, 0.603506319650142, 0.1850833824998659, 0.6507971104239889, 0.81390181947003, 0.01919901559187176, 0.958313958375463, 0.379011220612518, 1.3714525194241796, 0.8866080943161159, 0.03349994741046869, 0.8094552373927979, 0.816968218414319, 0.0364833055639755, 0.9119681797507084, 0.9311959297416645, 0.050003721609149565, 0.2812411480233674, 0.27289237817918277, 0.4713040551955081, 0.11328730983742208, 0.27507446854149564, 0.6089604616677073, 0.1834798798969819, 0.914936705763602, 0.6986338016350093, 0.7022849102692317, 0.5629999921249755, 0.32770581067592897, 0.8186557301057427, 0.8520044849841384, 0.24296151388645537, 0.5977757063227913, 0.16126731700918007, 0.22545552849150985, 0.6396592859883623, 0.7268280636664082, 0.919321373711989, 0.7455594748307179, 0.031276495554763306, 0.009733706438177059, 0.5990688875954979, 0.7142253682166626, 0.10306059399889356, 0.07004092250820593, 0.6651369743021611, 0.8213246078326248, 0.23377458040776533, 0.18305838556854326, 0.2567172048150721, 0.5674977293368415, 0.1192942396786032, 0.7181238351677848, 0.3528152860292699, 0.9033761709576205, 0.4748101508811371, 0.0013444671182565315, 0.4777307185881361, 0.9697030405971934, 0.24319885334875235, 0.36566750086598865, 0.3122481963493877, 1.7366695935605267, 0.9489105332609129, 0.840785179703543, 0.31904229942828843, 0.5839840367433586, 0.7784306878623337, 0.25348978972410885, 0.7684991758941795, 0.3248196736347324, 0.5516410414426027, 0.7425930531114051, 0.03932836265363937, 0.2296993036631163, 0.8744913699084358, 0.1883020983576198, 0.9533492310119924, 0.7500976155763743, 0.41308371598256244, 0.10735497645638614, 0.6624352107832201, 0.5216957173829442, 0.11713061015608939, 0.057844730035558234, 0.07194834833952912, 0.7300586653414614, 0.5946617594617176, 0.026644272428671067, 0.9100938717413407, 0.210609869033892, 0.4713040551955081, 0.20716232475976892, 0.16315787566537354, 0.6530448124590265, 0.4511963709596065, 0.051116996424291905, 0.8199035803926842, 0.5001132304901748, 0.3179695024945324, 0.9944386252678967, 0.8931836707721248, 0.6563993736998324, 1.3104435167297623, 0.34333877636650745, 0.18305838556854326, 0.18778979483197222, 0.15995193691351384, 0.8003423870115542, 0.10019833598052252, 0.33613152898443266, 0.7737148819120725, 0.5194938393704118, 0.0948773928697011, 0.8838736299628374, 0.08508237949315811, 0.9626553306990575, 0.08897176871199708, 0.23797469650360004, 0.311965965452196, 0.4924581366432379, 0.21049332948309818, 0.2567172048150721, 0.20716232475976892, 0.32664533148053976, 0.43978124443895483, 0.6799216244119353, 0.7651513605979896, 0.2554747585202164, 0.9782308664848147, 0.9992300825494427, 0.4712583263162118, 0.22336995304314455, 0.3901816737984607, 0.5542319539355611, 0.46438036772074454, 0.4001188728136498, 0.5674977293368415, 0.18778979483197222, 0.371262431816354, 0.7287478307339641, 0.6330630505914558, 0.23398048453082398, 0.35602171313695496, 0.47796321713668766, 0.35755548533189563, 0.32838823354784763, 0.7015236152363729, 0.08134217167984414, 0.9470156163956054, 0.20955153916394686, 0.6768748614312903, 0.7518436041296448, 0.5033863049512775, 0.9093694710580416, 0.9593126694002296, 0.645947803518383, 0.6601724077892837, 0.026935692354183693, 0.53445490231167, 0.2972403143033666, 0.09166773111069904, 0.8398922336727683, 0.637919830089438, 0.5227425067314215, 0.3240120030671727, 0.17347979416031123, 0.55544712396171, 0.23834063672251937, 0.4948287769495232, 0.10989026284023073, 0.5401332649446173, 0.6176098541886701, 0.23190010357111834, 0.08447698820372063, 0.8327773419393756, 0.12090324545613118, 0.47310942491655905, 0.10798192863435885, 0.14593966516938783, 0.5799184259157477, 0.9386408480869344, 0.11328730983742208, 1.2471598271670774, 0.17845308479625133, 1.5167323958634216, 0.9943492161225798, 0.26145504882090886, 0.9100425313491673, 0.5657016816073326, 0.8589581000145132, 0.6473241578340836, 0.4439055285783302, 0.17662739645038705, 0.9601569275007178, 0.4829876526944967, 0.30838307307180446, 0.7607324019057775, 0.7401420237895417, 0.15995193691351384, 0.32587878023378725, 0.43013779534921337, 0.4082728512217113, 0.17854646291335197, 0.3957493697675798, 0.9459164683250751, 0.45189660226998885, 0.6107340401662686, 0.6731372698712614, 0.356746268324595, 0.019852496194460834, 0.6490672037413827, 0.0397939562752323, 0.16315787566537354, 0.6601724077892837, 0.9208982842641882, 0.1642536091328839, 0.7981145249934654, 0.22106143726159222, 0.9044044672988854, 0.8657154425014815, 0.10164627444268404, 0.41911982248055524, 0.3982853215552502, 0.5954279331495635, 0.9477433990008648, 0.35231683029409666, 0.21204126520061028, 0.16287135422422372, 0.27507446854149564, 0.6530448124590265, 0.32664533148053976, 0.9208982842641882, 0.8039263588383232, 0.45758297444788987, 0.36642919784071104, 0.9722237677171546, 0.7892823340613053, 0.08206460127090032, 0.25614935915915793, 0.21774655958825373, 0.8825680507240805, 0.3347645581353962, 0.5834948961866246, 0.11177496400046816, 0.853018532616926, 0.17754891849364585, 0.8039263588383232, 0.8559009941050417, 0.7179519497517932, 0.8830249290720291, 0.9933101940184865, 0.3707569265866897, 0.591128466305826, 0.8152865701329146, 0.8842032951337915, 0.98545894788806, 0.3542692229166349, 0.32291746063978843, 0.5725696888508567, 0.3017057013196258, 0.06548030367007573, 0.6089604616677073, 0.4511963709596065, 0.4815722394607893, 0.8200462260893338, 0.5764320766492841, 0.5271617620078821, 0.954391552129005, 0.6006062609106879, 0.7670628528498982, 0.504966569994904, 0.04384256656449437, 0.8648116620377351, 0.047343099390839916, 0.9081726300174722, 0.9501915306489026, 1.8819864639475046, 0.1738180776092173, 0.49351794643597025, 0.11347478664233934, 0.5519315169259811, 0.8736211075734264, 0.9490765611667389, 0.7650967874785879, 0.9551272764814103, 0.2611614049941906, 0.889001800055712, 1.2113843017373174, 0.9356795689450672, 0.28625627586815616, 0.1834798798969819, 0.1192942396786032, 0.026935692354183693, 0.4815722394607893, 0.6280756038493136, 0.14835492074074264, 0.36755326030160496, 0.08063802687864108, 0.6461289971578776, 0.9141731616211415, 0.8927641863671658, 0.2373939964593581, 0.9561123998695162, 0.02268839835932468, 0.793910138704949, 0.45426276238657537, 0.8275162123351905, 0.30194859069497526, 0.6598565415592574, 0.8193464812265749, 0.40538754723620096, 0.3754666887334641, 0.914936705763602, 0.43978124443895483, 0.53445490231167, 0.32587878023378725, 0.7767843093557023, 0.2664719256186341, 0.4297343125880855, 0.9019985067880534, 0.6720862649167656, 0.6922413302954813, 0.8828216032169565, 0.7954057492904651, 0.6082542416427508, 0.9805071205563163, 0.4871268792863317, 0.16352054372447955, 0.7181238351677848, 0.051116996424291905, 0.371262431816354, 0.17845308479625133, 0.8200462260893338, 0.3343542933438197, 0.05725480919061554, 0.7899949901914345, 0.6350245834185881, 0.7655386459702904, 0.3562725153103399, 0.29760177279608135, 0.2691553052764686, 0.8692555266234883, 0.4380646569066018, 0.20949588408432884, 0.6390073532303879, 0.9463628898166316, 0.4332087980287742, 0.7994357137172707, 0.3528152860292699, 0.8003423870115542, 0.43013779534921337, 0.2315998883848729, 0.9350401707195675, 0.827485278041241, 0.7038788766592174, 0.819557234507829, 0.24235598044148499, 0.7645910502083084, 0.949706750182576, 0.5581332314280845, 0.4965426690892041, 0.6810505372885312, 0.6986338016350093, 0.7767843093557023, 1.9102228834329997, 0.8683375539628453, 0.5521420917971065, 0.27931623025521257, 0.8391097592604597, 0.7459679649704893, 0.48518833185954935, 0.06089155325573237, 0.38398373314433343, 0.42542666758149683, 0.13939320252880982, 0.8704542016950014, 0.6964104378114733, 0.8858025680164523, 0.6297101351941694, 0.7022849102692317, 0.7287478307339641, 0.2972403143033666, 0.5764320766492841, 0.6280756038493136, 1.3633880069216655, 0.2919422115727788, 0.16750453639066376, 0.3054421604127602, 0.12017809602207286, 0.9891500013994039, 0.809329587160676, 0.13590263787500034, 0.07896079521569477, 0.5629999921249755, 0.9033761709576205, 0.7684991758941795, 0.6330630505914558, 0.09166773111069904, 1.5167323958634216, 0.6120687535706006, 0.022487222839689736, 0.49107486405247136, 0.403887191040305, 0.9275835711795133, 0.05587490410692042, 0.3901805234282545, 0.9228969599943546, 0.9727236350283752, 0.33719912390286155, 0.415358427338101, 0.4262021236624105, 0.40669867543191995, 0.6308236911248397, 0.33693700040358876, 0.8137783739453859, 0.292017617588479, 0.5819193969526073, 0.7571153626501057, 0.3819544040026519, 0.5681498899757371, 0.10019833598052252, 0.23398048453082398, 0.1642536091328839, 0.3343542933438197, 0.2315998883848729, 0.6120687535706006];
G = SparseMatrixCSC(Gm, Gn, Gcolptr, Growval, Gnzval);


text:
@enum Launch begin
	Aerotow
    Winch
end

function Launch(str::AbstractString)
	if str == "W"
		Winch
	elseif str == "F"
		Aerotow
	else
		ArgumentError(str, "Invalid launch method string") |> throw
	end
end

function Base.convert(::Type{String}, l::Launch)
	if l == Winch
		return "W"
	else
		return "F"
	end
end

Base.convert(::Type{Launch}, str::AbstractString) = Launch(str)

ext: jl

max_stars_repo_name: julianschick/flugbuch

max_issues_repo_name: julianschick/flugbuch

max_forks_repo_name: julianschick/flugbuch


text:
module PilotSCAConst

export PenConflict, PenMinSep, PenCloseness, PenAction, StdDist, MinSepSq, InvVar
export DT, DTI, G, Xmin, Xmax, Ymin, Ymax, Bearingmin, Bearingmax, Speedmin, Speedmax
export Xdim, Ydim, Bearingdim, Speeddim, COCdim, NStates, NActions
export Xs, Ys, Bearings, Speeds, Actions
export SigmaSpeed, SigmaBank, SigmaBankCOC
export SigmaDim, SigmaWeightNominal, SigmaWeightOffNominal
export Responses, MeanResponseTime, RespondingProb, NonRespondingProb

const PenConflict = 1.0
const PenMinSep = 1000.0
const PenCloseness = 10.0
const PenAction = 0.02

const StdDist = 500.0  # [m]
const MinSepSq = StdDist^2  # [m^2]
const InvVar = 1 / MinSepSq  # [1/m^2]

const DT = 5.0  # [s]
const DTI = 1.0  # [s]
const G = 9.8  # [m/s^2]

const Xmin = -3000.0  # [m]
const Xmax = 3000.0  # [m]
const Ymin = -3000.0  # [m]
const Ymax = 3000.0  # [m]
const Bearingmin = 0.0  # [rad]
const Bearingmax = 2 * pi  # [rad]
const Speedmin = 10.0  # [m/s]
const Speedmax = 20.0  # [m/s]

const Xdim = 51  # 11
const Ydim = 51  # 11
const Bearingdim = 37  # 5
const Speeddim = 3  # 5

const Responsedim = 2

const NStates = Xdim * Ydim * Bearingdim * Speeddim^2 * Responsedim^2 + 1
const NActions = 36

const Xs = linspace(Xmin, Xmax, Xdim)
const Ys = linspace(Ymin, Ymax, Ydim)
const Bearings = linspace(Bearingmin, Bearingmax, Bearingdim)
const Speeds = linspace(Speedmin, Speedmax, Speeddim)

const Responses = [0.0, 1.0]  # indicator values: false == 0, true == 1

const MeanResponseTime = 5.0  # [s]
const RespondingProb = DT / (DT + MeanResponseTime)
const NonRespondingProb = 1.0 - RespondingProb

const Actions = [:right20, :right10, :straight, :left10, :left20, :clearOfConflict]

const SigmaSpeed = 2.0  # [m/s]
const SigmaBank = deg2rad(4.0)  # [rad]
const SigmaBankCOC = deg2rad(10.0)  # [rad]

const SigmaDim = 4  # number of dimensions for sigma-point sampling
const SigmaWeightNominal = 1 / 3
const SigmaWeightOffNominal = (1 - SigmaWeightNominal) / (2 * SigmaDim)

end # module PilotSCAConst


text:
# Load packages

using Polynomials: roots, Polynomial # For finding roots
using StatsBase: fit, Histogram # For binning the roots
using ColorSchemes: viridis
using Images: save # For saving the histogram to an image

# Create every combination of -1 and 1

polynomials = Iterators.product(repeat([[1, -1]], 2)...) |> collect |> vec .|> Polynomial;

# Solve the polynomials

complex_roots =
    polynomials .|>
    roots |>
    Iterators.flatten |>
    collect |>
    (Z -> filter(z -> imag(z) != 0, Z));

# Bin the roots

heatmap = fit(Histogram, (imag.(complex_roots), real.(complex_roots)), nbins = 2000).weights;

# Normalise

heatmap_normalised = log.(1 .+ heatmap);

# Apply a colour scheme

heatmap_coloured = get(viridis, heatmap_normalised, :extrema);

# Save the histogram to a file

save(joinpath("images", "littlewood.png"), heatmap_coloured);

# ![The Littlewood fractal](images/littlewood.png)

max_stars_repo_name: Hasnep/littlewood-julia

max_issues_repo_name: Hasnep/littlewood-julia

max_forks_repo_name: Hasnep/littlewood-julia


text:
export NDMSymm

struct NDMSymm{T,T2,T4} <: MatrixNeuralNetwork
    bare_net::T
    symm_net::T

    ∇b_mat::T2
    ∇h_mat::T2
    ∇d_mat::T2
    ∇w_mat::T2
    ∇u_mat::T2

    symm_map::T4
end
@functor NDMSymm

NDMSymm(n_in::Int, args...) = NDMSymm(STD_REAL_PREC, args...)
NDMSymm(T::Type, hilb::AbstractHilbert, args...) =
    NDMSymm(T, nsites(hilb), args...)
function NDMSymm(T::Type{<:Real}, n_in::Int, αh, αa, permutations, σ::Function=logℒ)
    n_symm = length(permutations)
    @assert length(first(permutations)) == n_in

    symm_net = NDM(T, n_in, αh//n_in, αa//n_in, σ)
    bare_net = NDM(T, n_in, αh//n_in*n_symm, αa//n_in*n_symm, σ)
    set_bare_params!(bare_net, symm_net, permutations)
    ∇b_mat, ∇h_mat, ∇d_mat, ∇w_mat, ∇u_mat = construct_∇matrices(bare_net, symm_net, n_in, αh, αa, permutations)

    NDMSymm(bare_net, symm_net, ∇b_mat, ∇h_mat, ∇d_mat, ∇w_mat, ∇u_mat, permutations)
end

out_type(net::NDMSymm)           = out_type(net.bare_net)
is_analytic(net::NDMSymm)        = is_analytic(net.bare_net)
#weights(cnet::NDMSymm)           = cnet.symm_net

grad_cache(net::NDMSymm)         = grad_cache(net.symm_net)
trainable(net::NDMSymm)          = trainable(net.symm_net)
update!(opt, cnet::NDMSymm, Δ, state=nothing) = (res = update!(opt, weights(cnet), weights(Δ), state);
                                            set_bare_params!(cnet.bare_net, cnet.symm_net, cnet.symm_map);
                                            res)

Base.show(io::IO, m::NDMSymm) = print(io,
    "NDMSymm{$(eltype(m.bare_net.b_μ))}, n=$(length(m.symm_net.b_μ)), αₕ=$(length(m.symm_net.h_μ)), αₐ=$(length(m.symm_net.d_λ)), f=$(m.symm_net.f))")

@inline (net::NDMSymm)(args...) = net.bare_net(args...)
function logψ_and_∇logψ!(∇lnψ_symm, net::NDMSymm, args...)
    lnψ, ∇lnψ = logψ_and_∇logψ(net.bare_net, args...)

    symmetrize_∇logψ_NDM!(∇lnψ_symm, ∇lnψ, net)
    lnψ, ∇lnψ_symm
end

struct NDMSymmCache{BC,BD} <: NNCache{NDMSymm}
    bare_cache::BC
    bare_∇logψ::BD
end

cache(net::NDMSymm)              =
    NDMSymmCache(cache(net.bare_net),
                 grad_cache(net.bare_net))

@inline (net::NDMSymm)(c::NDMSymmCache, args...) = net.bare_net(c.bare_cache, args...)

function logψ_and_∇logψ!(∇lnψ_symm, net::NDMSymm, c::NDMSymmCache, args...)
    lnψ = logψ_and_∇logψ!(c.bare_∇logψ, net.bare_net, c.bare_cache, args...)

    symmetrize_∇logψ_NDM!(∇lnψ_symm, c.bare_∇logψ, net)
    return lnψ
end

#
function symmetrize_∇logψ_NDM!(∇lnψ_symm, ∇lnψ, net)
    mul!(∇lnψ_symm.b_μ, net.∇b_mat, ∇lnψ.b_μ)
    mul!(∇lnψ_symm.b_λ, net.∇b_mat, ∇lnψ.b_λ)
    mul!(∇lnψ_symm.h_μ, net.∇h_mat, ∇lnψ.h_μ)
    mul!(∇lnψ_symm.h_λ, net.∇h_mat, ∇lnψ.h_λ)
    mul!(∇lnψ_symm.d_λ, net.∇d_mat, ∇lnψ.d_λ)
    mul!(vec(∇lnψ_symm.w_μ), net.∇w_mat, vec(∇lnψ.w_μ))
    mul!(vec(∇lnψ_symm.w_λ), net.∇w_mat, vec(∇lnψ.w_λ))
    mul!(vec(∇lnψ_symm.u_μ), net.∇u_mat, vec(∇lnψ.u_μ))
    mul!(vec(∇lnψ_symm.u_λ), net.∇u_mat, vec(∇lnψ.u_λ))
    ∇lnψ_symm
end

function set_bare_params!(bare_net, symm_net, permutations)
    # Load a bit
    n_symm = length(permutations)
    n_in   = length(symm_net.b_μ)
    αh   = size(symm_net.w_μ,1)
    αa   = size(symm_net.u_μ,1)

    # Local bias
    symm_net.b_μ .= sum(symm_net.b_μ)/length(symm_net.b_μ)
    symm_net.b_λ .= sum(symm_net.b_λ)/length(symm_net.b_λ)
    bare_net.b_μ .=  symm_net.b_μ
    bare_net.b_λ .=  symm_net.b_λ

    # Hidden biases
    for (i, (h_μ_i, h_λ_i)) = enumerate(zip(symm_net.h_μ, symm_net.h_λ))
        bare_net.h_μ[((i-1)*n_symm+1):(i*n_symm)] .=  h_μ_i
        bare_net.h_λ[((i-1)*n_symm+1):(i*n_symm)] .=  h_λ_i
    end

    # Ancilla biases
    for (i, d_λ_i) = enumerate(symm_net.d_λ)
        bare_net.d_λ[((i-1)*n_symm+1):(i*n_symm)] .=  d_λ_i
    end

    # Hidden connections
    for f=1:αh
        for (j,perm)=enumerate(permutations)
            for (i, i_p)=enumerate(perm)
                bare_net.w_μ[j + (f-1)*n_symm, i_p] = symm_net.w_μ[f,i]
                bare_net.w_λ[j + (f-1)*n_symm, i_p] = symm_net.w_λ[f,i]
            end
        end
    end

    # Ancilla connections
    for f=1:αa
        for (j,perm)=enumerate(permutations)
            for (i, i_p)=enumerate(perm)
                bare_net.u_μ[j + (f-1)*n_symm, i_p] = symm_net.u_μ[f,i]
                bare_net.u_λ[j + (f-1)*n_symm, i_p] = symm_net.u_λ[f,i]
            end
        end
    end
    bare_net
end

function construct_∇matrices(bare_net, symm_net, n_in, αh, αa, permutations)
    # Load a bit
    n_symm = length(permutations)

    # Local bias matrix
    ∇b_mat   = ones(eltype(bare_net.u_λ), n_in, n_in)./n_in

    # Hidden bias matrix
    ∇h_mat   = zeros(eltype(bare_net.h_λ), αh, αh*n_symm)
    for s=1:αh
        ∇h_mat[s, (s-1)*n_symm+1:s*n_symm] .= 1
    end

    # Ancillary bias matrix
    ∇d_mat   = zeros(eltype(bare_net.d_λ), αa, αa*n_symm)
    for s=1:αa
        ∇d_mat[s, (s-1)*n_symm+1:s*n_symm] .= 1
    end

    ∇w_mat   = zeros(eltype(bare_net.w_λ), αh*n_in, αh*n_symm*n_in)
    lin_ind_bare  = LinearIndices(bare_net.w_λ)
    lin_ind_symm  = LinearIndices(symm_net.w_λ)
    for f=1:αh
        for (j,perm)=enumerate(permutations)
            for (i, i_p)=enumerate(perm)
                row = lin_ind_symm[f,i]
                col = lin_ind_bare[j + (f-1)*n_symm, i_p]
                ∇w_mat[row,col] = 1
            end
        end
    end

    ∇u_mat   = zeros(eltype(bare_net.u_λ), αa*n_in, αa*n_symm*n_in)
    lin_ind_bare  = LinearIndices(bare_net.u_λ)
    lin_ind_symm  = LinearIndices(symm_net.u_λ)
    for f=1:αa
        for (j,perm)=enumerate(permutations)
            for (i, i_p)=enumerate(perm)
                row = lin_ind_symm[f,i]
                col = lin_ind_bare[j + (f-1)*n_symm, i_p]
                ∇u_mat[row,col] = 1
            end
        end
    end
    ∇b_mat, ∇h_mat, ∇d_mat, ∇w_mat, ∇u_mat
end

######


text:
# Exercise 1

function factorial2(n)
    k=1
    for i ∈ 1:n
        k = k * i
    end
    return k
end

factorial2(3)

# Exercise 2

function binomial_rv(n,p)
    count = 0
    U = rand(n)
    for i ∈ 1:n
        if U[i] < p
            count += 1
        end
    end
    return count
end

n=60
p=0.7

binomial_rv(n,p)

# Exercise 3

n = 10000
count = 0

for i ∈ 1:n
    x, y = rand(2)
    r = ((x-0.5)^2 + (y-0.5)^2)^(0.5) # distance from center of circle
    if r < 0.5 # radius
        count+=1
    end
end

pi_estimate = (count/n)/0.5^2

println("Estimated pi = $pi_estimate")

# Exercise 4

function flipcoin(n)
    payoff = 0
    count = 0
    x = rand(n)
    for i ∈ eachindex(x)
        if x[i] <= 0.5
            count += 1
        else
            count = 0
        end
        print(count)
        if count >= 3
            payoff = 1
        end
    end
    return (count,payoff)
end

# parameters
n = 10
flipcoin(n)

# Exercise 5

# parameters
n = 200
α = 0.9

x = zeros(n)

for i ∈ 1:n
    x[i+1] = α * x[i] + randn()
end
plot(x)

# Exercise 6

αs = [0.0, 0.8, 0.98]
n = 200
p = plot() # naming a plot to add to

for α in αs
    x = zeros(n + 1)
    x[1] = 0.0
    for t in 1:n
        x[t+1] = α * x[t] + randn()
    end
    plot!(p, x, label = "alpha = $α") # add to plot p
end
p # display plot

# Exercise 7
function firstpassage(threshold; tmax=100, α = 1.0, σ =0.2)
    x = zeros(tmax)
    x[1] = 1.0
    x[tmax] = 0.0
    for i in 2:tmax
        x[i] = α * x[i-1] + σ * randn()
        if x[i] < threshold # checks threshold
            return i # leaves function, returning draw number
        end
    end
    return tmax # if here, reached maxdraws
end

# parameters
tmax = 200
σ = 0.2
αs = [0.8, 1.0, 1.2]
threshold = 0.0

# sample using firstpassage
nsamp = 100
averages = zeros(0)

for α ∈ αs
    draws = zeros(nsamp)
    for i ∈ 1:100
        draws[i] = firstpassage(threshold, tmax=tmax, α = α, σ = σ)
    end
    average = mean(draws)
    push!(averages,average)
#    histogram!(h, draws, labels = "alpha = $α", bins= 20) # add to histogram h
end
averages
# h

# Exercise 8a

function f_prime(f; x0 = 2)

    # intialise loop
    crit = 1
    iter = 1
    del = 0.1
    normdiff = Inf

    fd_initial = (f(x0+del)-f(x0))/del
    fd_old = fd_initial

    while crit > 1.0E-8 && iter < 1000

        del = del/2 # shrink change
        fd_new = (f(x0+del)-f(x0))/del #calculate derivative

        crit =  norm(fd_new - fd_old) #how large is the change in derivative?

        # continuation
        iter = iter + 1
        fd_old = fd_new
    end
    return fd_old
end

# test with polynomial function
f(x) = (x-1)^3
x0 = 2

derivative = f_prime(f,x0=2)

# Newton Raphson algorithm

function NewtonRaphson(f, f_prime; x0 = 2, tolerance =1.0E-8 , maxiter = 1000)

    #initialise loop
    iter = 1
    normdiff = Inf

    x_old = x0 # starting point
    f_old = f(x0)

    while normdiff > tolerance && iter < maxiter

        fd = f_prime(f, x0 = x_old) # get derivative

        step = f(x_old)/fd # compute step

        x_new = x_old - step # compute expression to iterate over

        normdiff = norm(x_new - x_old)# do we converge?

        # continuation
        iter = iter+1
        x_old = x_new
    end
    return (root = x_old, normdiff = normdiff, iter = iter )
end

# peform Newton Raphson algorithm
f(x) = (x-1)^3
x0 = 2

sol = NewtonRaphson(f,f_prime, x0 = x0, tolerance =1.0E-8 , maxiter = 1000 )

println("root = $(sol.root), and |f(x) - x| = $(sol.normdiff) in $(sol.iter) iterations")

max_stars_repo_name: shanemcmiken/quantecon-notebooks-julia

max_issues_repo_name: shanemcmiken/quantecon-notebooks-julia

max_forks_repo_name: shanemcmiken/quantecon-notebooks-julia


text:
# Automatically generated using Clang.jl
# all Ptr replaced with Ref, with a few marked exceptions

const VI_SPEC_VERSION = UInt32(0x00500800)
const VI_ATTR_RSRC_CLASS = UInt32(0xbfff0001)
const VI_ATTR_RSRC_NAME = UInt32(0xbfff0002)
const VI_ATTR_RSRC_IMPL_VERSION = UInt32(0x3fff0003)
const VI_ATTR_RSRC_LOCK_STATE = UInt32(0x3fff0004)
const VI_ATTR_MAX_QUEUE_LENGTH = UInt32(0x3fff0005)
const VI_ATTR_USER_DATA_32 = UInt32(0x3fff0007)
const VI_ATTR_FDC_CHNL = UInt32(0x3fff000d)
const VI_ATTR_FDC_MODE = UInt32(0x3fff000f)
const VI_ATTR_FDC_GEN_SIGNAL_EN = UInt32(0x3fff0011)
const VI_ATTR_FDC_USE_PAIR = UInt32(0x3fff0013)
const VI_ATTR_SEND_END_EN = UInt32(0x3fff0016)
const VI_ATTR_TERMCHAR = UInt32(0x3fff0018)
const VI_ATTR_TMO_VALUE = UInt32(0x3fff001a)
const VI_ATTR_GPIB_READDR_EN = UInt32(0x3fff001b)
const VI_ATTR_IO_PROT = UInt32(0x3fff001c)
const VI_ATTR_DMA_ALLOW_EN = UInt32(0x3fff001e)
const VI_ATTR_ASRL_BAUD = UInt32(0x3fff0021)
const VI_ATTR_ASRL_DATA_BITS = UInt32(0x3fff0022)
const VI_ATTR_ASRL_PARITY = UInt32(0x3fff0023)
const VI_ATTR_ASRL_STOP_BITS = UInt32(0x3fff0024)
const VI_ATTR_ASRL_FLOW_CNTRL = UInt32(0x3fff0025)
const VI_ATTR_RD_BUF_OPER_MODE = UInt32(0x3fff002a)
const VI_ATTR_RD_BUF_SIZE = UInt32(0x3fff002b)
const VI_ATTR_WR_BUF_OPER_MODE = UInt32(0x3fff002d)
const VI_ATTR_WR_BUF_SIZE = UInt32(0x3fff002e)
const VI_ATTR_SUPPRESS_END_EN = UInt32(0x3fff0036)
const VI_ATTR_TERMCHAR_EN = UInt32(0x3fff0038)
const VI_ATTR_DEST_ACCESS_PRIV = UInt32(0x3fff0039)
const VI_ATTR_DEST_BYTE_ORDER = UInt32(0x3fff003a)
const VI_ATTR_SRC_ACCESS_PRIV = UInt32(0x3fff003c)
const VI_ATTR_SRC_BYTE_ORDER = UInt32(0x3fff003d)
const VI_ATTR_SRC_INCREMENT = UInt32(0x3fff0040)
const VI_ATTR_DEST_INCREMENT = UInt32(0x3fff0041)
const VI_ATTR_WIN_ACCESS_PRIV = UInt32(0x3fff0045)
const VI_ATTR_WIN_BYTE_ORDER = UInt32(0x3fff0047)
const VI_ATTR_GPIB_ATN_STATE = UInt32(0x3fff0057)
const VI_ATTR_GPIB_ADDR_STATE = UInt32(0x3fff005c)
const VI_ATTR_GPIB_CIC_STATE = UInt32(0x3fff005e)
const VI_ATTR_GPIB_NDAC_STATE = UInt32(0x3fff0062)
const VI_ATTR_GPIB_SRQ_STATE = UInt32(0x3fff0067)
const VI_ATTR_GPIB_SYS_CNTRL_STATE = UInt32(0x3fff0068)
const VI_ATTR_GPIB_HS488_CBL_LEN = UInt32(0x3fff0069)
const VI_ATTR_CMDR_LA = UInt32(0x3fff006b)
const VI_ATTR_VXI_DEV_CLASS = UInt32(0x3fff006c)
const VI_ATTR_MAINFRAME_LA = UInt32(0x3fff0070)
const VI_ATTR_MANF_NAME = UInt32(0xbfff0072)
const VI_ATTR_MODEL_NAME = UInt32(0xbfff0077)
const VI_ATTR_VXI_VME_INTR_STATUS = UInt32(0x3fff008b)
const VI_ATTR_VXI_TRIG_STATUS = UInt32(0x3fff008d)
const VI_ATTR_VXI_VME_SYSFAIL_STATE = UInt32(0x3fff0094)
const VI_ATTR_WIN_BASE_ADDR_32 = UInt32(0x3fff0098)
const VI_ATTR_WIN_SIZE_32 = UInt32(0x3fff009a)
const VI_ATTR_ASRL_AVAIL_NUM = UInt32(0x3fff00ac)
const VI_ATTR_MEM_BASE_32 = UInt32(0x3fff00ad)
const VI_ATTR_ASRL_CTS_STATE = UInt32(0x3fff00ae)
const VI_ATTR_ASRL_DCD_STATE = UInt32(0x3fff00af)
const VI_ATTR_ASRL_DSR_STATE = UInt32(0x3fff00b1)
const VI_ATTR_ASRL_DTR_STATE = UInt32(0x3fff00b2)
const VI_ATTR_ASRL_END_IN = UInt32(0x3fff00b3)
const VI_ATTR_ASRL_END_OUT = UInt32(0x3fff00b4)
const VI_ATTR_ASRL_REPLACE_CHAR = UInt32(0x3fff00be)
const VI_ATTR_ASRL_RI_STATE = UInt32(0x3fff00bf)
const VI_ATTR_ASRL_RTS_STATE = UInt32(0x3fff00c0)
const VI_ATTR_ASRL_XON_CHAR = UInt32(0x3fff00c1)
const VI_ATTR_ASRL_XOFF_CHAR = UInt32(0x3fff00c2)
const VI_ATTR_WIN_ACCESS = UInt32(0x3fff00c3)
const VI_ATTR_RM_SESSION = UInt32(0x3fff00c4)
const VI_ATTR_VXI_LA = UInt32(0x3fff00d5)
const VI_ATTR_MANF_ID = UInt32(0x3fff00d9)
const VI_ATTR_MEM_SIZE_32 = UInt32(0x3fff00dd)
const VI_ATTR_MEM_SPACE = UInt32(0x3fff00de)
const VI_ATTR_MODEL_CODE = UInt32(0x3fff00df)
const VI_ATTR_SLOT = UInt32(0x3fff00e8)
const VI_ATTR_INTF_INST_NAME = UInt32(0xbfff00e9)
const VI_ATTR_IMMEDIATE_SERV = UInt32(0x3fff0100)
const VI_ATTR_INTF_PARENT_NUM = UInt32(0x3fff0101)
const VI_ATTR_RSRC_SPEC_VERSION = UInt32(0x3fff0170)
const VI_ATTR_INTF_TYPE = UInt32(0x3fff0171)
const VI_ATTR_GPIB_PRIMARY_ADDR = UInt32(0x3fff0172)
const VI_ATTR_GPIB_SECONDARY_ADDR = UInt32(0x3fff0173)
const VI_ATTR_RSRC_MANF_NAME = UInt32(0xbfff0174)
const VI_ATTR_RSRC_MANF_ID = UInt32(0x3fff0175)
const VI_ATTR_INTF_NUM = UInt32(0x3fff0176)
const VI_ATTR_TRIG_ID = UInt32(0x3fff0177)
const VI_ATTR_GPIB_REN_STATE = UInt32(0x3fff0181)
const VI_ATTR_GPIB_UNADDR_EN = UInt32(0x3fff0184)
const VI_ATTR_DEV_STATUS_BYTE = UInt32(0x3fff0189)
const VI_ATTR_FILE_APPEND_EN = UInt32(0x3fff0192)
const VI_ATTR_VXI_TRIG_SUPPORT = UInt32(0x3fff0194)
const VI_ATTR_TCPIP_ADDR = UInt32(0xbfff0195)
const VI_ATTR_TCPIP_HOSTNAME = UInt32(0xbfff0196)
const VI_ATTR_TCPIP_PORT = UInt32(0x3fff0197)
const VI_ATTR_TCPIP_DEVICE_NAME = UInt32(0xbfff0199)
const VI_ATTR_TCPIP_NODELAY = UInt32(0x3fff019a)
const VI_ATTR_TCPIP_KEEPALIVE = UInt32(0x3fff019b)
const VI_ATTR_4882_COMPLIANT = UInt32(0x3fff019f)
const VI_ATTR_USB_SERIAL_NUM = UInt32(0xbfff01a0)
const VI_ATTR_USB_INTFC_NUM = UInt32(0x3fff01a1)
const VI_ATTR_USB_PROTOCOL = UInt32(0x3fff01a7)
const VI_ATTR_USB_MAX_INTR_SIZE = UInt32(0x3fff01af)
const VI_ATTR_PXI_DEV_NUM = UInt32(0x3fff0201)
const VI_ATTR_PXI_FUNC_NUM = UInt32(0x3fff0202)
const VI_ATTR_PXI_BUS_NUM = UInt32(0x3fff0205)
const VI_ATTR_PXI_CHASSIS = UInt32(0x3fff0206)
const VI_ATTR_PXI_SLOTPATH = UInt32(0xbfff0207)
const VI_ATTR_PXI_SLOT_LBUS_LEFT = UInt32(0x3fff0208)
const VI_ATTR_PXI_SLOT_LBUS_RIGHT = UInt32(0x3fff0209)
const VI_ATTR_PXI_TRIG_BUS = UInt32(0x3fff020a)
const VI_ATTR_PXI_STAR_TRIG_BUS = UInt32(0x3fff020b)
const VI_ATTR_PXI_STAR_TRIG_LINE = UInt32(0x3fff020c)
const VI_ATTR_PXI_SRC_TRIG_BUS = UInt32(0x3fff020d)
const VI_ATTR_PXI_DEST_TRIG_BUS = UInt32(0x3fff020e)
const VI_ATTR_PXI_MEM_TYPE_BAR0 = UInt32(0x3fff0211)
const VI_ATTR_PXI_MEM_TYPE_BAR1 = UInt32(0x3fff0212)
const VI_ATTR_PXI_MEM_TYPE_BAR2 = UInt32(0x3fff0213)
const VI_ATTR_PXI_MEM_TYPE_BAR3 = UInt32(0x3fff0214)
const VI_ATTR_PXI_MEM_TYPE_BAR4 = UInt32(0x3fff0215)
const VI_ATTR_PXI_MEM_TYPE_BAR5 = UInt32(0x3fff0216)
const VI_ATTR_PXI_MEM_BASE_BAR0_32 = UInt32(0x3fff0221)
const VI_ATTR_PXI_MEM_BASE_BAR1_32 = UInt32(0x3fff0222)
const VI_ATTR_PXI_MEM_BASE_BAR2_32 = UInt32(0x3fff0223)
const VI_ATTR_PXI_MEM_BASE_BAR3_32 = UInt32(0x3fff0224)
const VI_ATTR_PXI_MEM_BASE_BAR4_32 = UInt32(0x3fff0225)
const VI_ATTR_PXI_MEM_BASE_BAR5_32 = UInt32(0x3fff0226)
const VI_ATTR_PXI_MEM_BASE_BAR0_64 = UInt32(0x3fff0228)
const VI_ATTR_PXI_MEM_BASE_BAR1_64 = UInt32(0x3fff0229)
const VI_ATTR_PXI_MEM_BASE_BAR2_64 = UInt32(0x3fff022a)
const VI_ATTR_PXI_MEM_BASE_BAR3_64 = UInt32(0x3fff022b)
const VI_ATTR_PXI_MEM_BASE_BAR4_64 = UInt32(0x3fff022c)
const VI_ATTR_PXI_MEM_BASE_BAR5_64 = UInt32(0x3fff022d)
const VI_ATTR_PXI_MEM_SIZE_BAR0_32 = UInt32(0x3fff0231)
const VI_ATTR_PXI_MEM_SIZE_BAR1_32 = UInt32(0x3fff0232)
const VI_ATTR_PXI_MEM_SIZE_BAR2_32 = UInt32(0x3fff0233)
const VI_ATTR_PXI_MEM_SIZE_BAR3_32 = UInt32(0x3fff0234)
const VI_ATTR_PXI_MEM_SIZE_BAR4_32 = UInt32(0x3fff0235)
const VI_ATTR_PXI_MEM_SIZE_BAR5_32 = UInt32(0x3fff0236)
const VI_ATTR_PXI_MEM_SIZE_BAR0_64 = UInt32(0x3fff0238)
const VI_ATTR_PXI_MEM_SIZE_BAR1_64 = UInt32(0x3fff0239)
const VI_ATTR_PXI_MEM_SIZE_BAR2_64 = UInt32(0x3fff023a)
const VI_ATTR_PXI_MEM_SIZE_BAR3_64 = UInt32(0x3fff023b)
const VI_ATTR_PXI_MEM_SIZE_BAR4_64 = UInt32(0x3fff023c)
const VI_ATTR_PXI_MEM_SIZE_BAR5_64 = UInt32(0x3fff023d)
const VI_ATTR_PXI_IS_EXPRESS = UInt32(0x3fff0240)
const VI_ATTR_PXI_SLOT_LWIDTH = UInt32(0x3fff0241)
const VI_ATTR_PXI_MAX_LWIDTH = UInt32(0x3fff0242)
const VI_ATTR_PXI_ACTUAL_LWIDTH = UInt32(0x3fff0243)
const VI_ATTR_PXI_DSTAR_BUS = UInt32(0x3fff0244)
const VI_ATTR_PXI_DSTAR_SET = UInt32(0x3fff0245)
const VI_ATTR_PXI_ALLOW_WRITE_COMBINE = UInt32(0x3fff0246)
const VI_ATTR_TCPIP_HISLIP_OVERLAP_EN = UInt32(0x3fff0300)
const VI_ATTR_TCPIP_HISLIP_VERSION = UInt32(0x3fff0301)
const VI_ATTR_TCPIP_HISLIP_MAX_MESSAGE_KB = UInt32(0x3fff0302)
const VI_ATTR_TCPIP_IS_HISLIP = UInt32(0x3fff0303)
const VI_ATTR_JOB_ID = UInt32(0x3fff4006)
const VI_ATTR_EVENT_TYPE = UInt32(0x3fff4010)
const VI_ATTR_SIGP_STATUS_ID = UInt32(0x3fff4011)
const VI_ATTR_RECV_TRIG_ID = UInt32(0x3fff4012)
const VI_ATTR_INTR_STATUS_ID = UInt32(0x3fff4023)
const VI_ATTR_STATUS = UInt32(0x3fff4025)
const VI_ATTR_RET_COUNT_32 = UInt32(0x3fff4026)
const VI_ATTR_BUFFER = UInt32(0x3fff4027)
const VI_ATTR_RECV_INTR_LEVEL = UInt32(0x3fff4041)
const VI_ATTR_OPER_NAME = UInt32(0xbfff4042)
const VI_ATTR_GPIB_RECV_CIC_STATE = UInt32(0x3fff4193)
const VI_ATTR_RECV_TCPIP_ADDR = UInt32(0xbfff4198)
const VI_ATTR_USB_RECV_INTR_SIZE = UInt32(0x3fff41b0)
const VI_ATTR_USB_RECV_INTR_DATA = UInt32(0xbfff41b1)
const VI_ATTR_PXI_RECV_INTR_SEQ = UInt32(0x3fff4240)
const VI_ATTR_PXI_RECV_INTR_DATA = UInt32(0x3fff4241)
const VI_ATTR_USER_DATA_64 = UInt32(0x3fff000a)
const VI_ATTR_RET_COUNT_64 = UInt32(0x3fff4028)
const VI_ATTR_USER_DATA = VI_ATTR_USER_DATA_64
const VI_ATTR_RET_COUNT = VI_ATTR_RET_COUNT_64
const VI_ATTR_WIN_BASE_ADDR_64 = UInt32(0x3fff009b)
const VI_ATTR_WIN_SIZE_64 = UInt32(0x3fff009c)
const VI_ATTR_MEM_BASE_64 = UInt32(0x3fff00d0)
const VI_ATTR_MEM_SIZE_64 = UInt32(0x3fff00d1)
const VI_ATTR_WIN_BASE_ADDR = VI_ATTR_WIN_BASE_ADDR_64
const VI_ATTR_WIN_SIZE = VI_ATTR_WIN_SIZE_64
const VI_ATTR_MEM_BASE = VI_ATTR_MEM_BASE_64
const VI_ATTR_MEM_SIZE = VI_ATTR_MEM_SIZE_64
const VI_ATTR_PXI_MEM_BASE_BAR0 = VI_ATTR_PXI_MEM_BASE_BAR0_64
const VI_ATTR_PXI_MEM_BASE_BAR1 = VI_ATTR_PXI_MEM_BASE_BAR1_64
const VI_ATTR_PXI_MEM_BASE_BAR2 = VI_ATTR_PXI_MEM_BASE_BAR2_64
const VI_ATTR_PXI_MEM_BASE_BAR3 = VI_ATTR_PXI_MEM_BASE_BAR3_64
const VI_ATTR_PXI_MEM_BASE_BAR4 = VI_ATTR_PXI_MEM_BASE_BAR4_64
const VI_ATTR_PXI_MEM_BASE_BAR5 = VI_ATTR_PXI_MEM_BASE_BAR5_64
const VI_ATTR_PXI_MEM_SIZE_BAR0 = VI_ATTR_PXI_MEM_SIZE_BAR0_64
const VI_ATTR_PXI_MEM_SIZE_BAR1 = VI_ATTR_PXI_MEM_SIZE_BAR1_64
const VI_ATTR_PXI_MEM_SIZE_BAR2 = VI_ATTR_PXI_MEM_SIZE_BAR2_64
const VI_ATTR_PXI_MEM_SIZE_BAR3 = VI_ATTR_PXI_MEM_SIZE_BAR3_64
const VI_ATTR_PXI_MEM_SIZE_BAR4 = VI_ATTR_PXI_MEM_SIZE_BAR4_64
const VI_ATTR_PXI_MEM_SIZE_BAR5 = VI_ATTR_PXI_MEM_SIZE_BAR5_64
const VI_EVENT_IO_COMPLETION = UInt32(0x3fff2009)
const VI_EVENT_TRIG = UInt32(0xbfff200a)
const VI_EVENT_SERVICE_REQ = UInt32(0x3fff200b)
const VI_EVENT_CLEAR = UInt32(0x3fff200d)
const VI_EVENT_EXCEPTION = UInt32(0xbfff200e)
const VI_EVENT_GPIB_CIC = UInt32(0x3fff2012)
const VI_EVENT_GPIB_TALK = UInt32(0x3fff2013)
const VI_EVENT_GPIB_LISTEN = UInt32(0x3fff2014)
const VI_EVENT_VXI_VME_SYSFAIL = UInt32(0x3fff201d)
const VI_EVENT_VXI_VME_SYSRESET = UInt32(0x3fff201e)
const VI_EVENT_VXI_SIGP = UInt32(0x3fff2020)
const VI_EVENT_VXI_VME_INTR = UInt32(0xbfff2021)
const VI_EVENT_PXI_INTR = UInt32(0x3fff2022)
const VI_EVENT_TCPIP_CONNECT = UInt32(0x3fff2036)
const VI_EVENT_USB_INTR = UInt32(0x3fff2037)
const VI_ALL_ENABLED_EVENTS = UInt32(0x3fff7fff)
const VI_SUCCESS_EVENT_EN = Int32(0x3fff0002)
const VI_SUCCESS_EVENT_DIS = Int32(0x3fff0003)
const VI_SUCCESS_QUEUE_EMPTY = Int32(0x3fff0004)
const VI_SUCCESS_TERM_CHAR = Int32(0x3fff0005)
const VI_SUCCESS_MAX_CNT = Int32(0x3fff0006)
const VI_SUCCESS_DEV_NPRESENT = Int32(0x3fff007d)
const VI_SUCCESS_TRIG_MAPPED = Int32(0x3fff007e)
const VI_SUCCESS_QUEUE_NEMPTY = Int32(0x3fff0080)
const VI_SUCCESS_NCHAIN = Int32(0x3fff0098)
const VI_SUCCESS_NESTED_SHARED = Int32(0x3fff0099)
const VI_SUCCESS_NESTED_EXCLUSIVE = Int32(0x3fff009a)
const VI_SUCCESS_SYNC = Int32(0x3fff009b)
const VI_WARN_QUEUE_OVERFLOW = Int32(0x3fff000c)
const VI_WARN_CONFIG_NLOADED = Int32(0x3fff0077)
const VI_WARN_NULL_OBJECT = Int32(0x3fff0082)
const VI_WARN_NSUP_ATTR_STATE = Int32(0x3fff0084)
const VI_WARN_UNKNOWN_STATUS = Int32(0x3fff0085)
const VI_WARN_NSUP_BUF = Int32(0x3fff0088)
const VI_WARN_EXT_FUNC_NIMPL = Int32(0x3fff00a9)
const VI_ERROR = -(Int32(2147483647)) - 1
const VI_ERROR_SYSTEM_ERROR = VI_ERROR + Int32(0x3fff0000)
const VI_ERROR_INV_OBJECT = VI_ERROR + Int32(0x3fff000e)
const VI_ERROR_RSRC_LOCKED = VI_ERROR + Int32(0x3fff000f)
const VI_ERROR_INV_EXPR = VI_ERROR + Int32(0x3fff0010)
const VI_ERROR_RSRC_NFOUND = VI_ERROR + Int32(0x3fff0011)
const VI_ERROR_INV_RSRC_NAME = VI_ERROR + Int32(0x3fff0012)
const VI_ERROR_INV_ACC_MODE = VI_ERROR + Int32(0x3fff0013)
const VI_ERROR_TMO = VI_ERROR + Int32(0x3fff0015)
const VI_ERROR_CLOSING_FAILED = VI_ERROR + Int32(0x3fff0016)
const VI_ERROR_INV_DEGREE = VI_ERROR + Int32(0x3fff001b)
const VI_ERROR_INV_JOB_ID = VI_ERROR + Int32(0x3fff001c)
const VI_ERROR_NSUP_ATTR = VI_ERROR + Int32(0x3fff001d)
const VI_ERROR_NSUP_ATTR_STATE = VI_ERROR + Int32(0x3fff001e)
const VI_ERROR_ATTR_READONLY = VI_ERROR + Int32(0x3fff001f)
const VI_ERROR_INV_LOCK_TYPE = VI_ERROR + Int32(0x3fff0020)
const VI_ERROR_INV_ACCESS_KEY = VI_ERROR + Int32(0x3fff0021)
const VI_ERROR_INV_EVENT = VI_ERROR + Int32(0x3fff0026)
const VI_ERROR_INV_MECH = VI_ERROR + Int32(0x3fff0027)
const VI_ERROR_HNDLR_NINSTALLED = VI_ERROR + Int32(0x3fff0028)
const VI_ERROR_INV_HNDLR_REF = VI_ERROR + Int32(0x3fff0029)
const VI_ERROR_INV_CONTEXT = VI_ERROR + Int32(0x3fff002a)
const VI_ERROR_QUEUE_OVERFLOW = VI_ERROR + Int32(0x3fff002d)
const VI_ERROR_NENABLED = VI_ERROR + Int32(0x3fff002f)
const VI_ERROR_ABORT = VI_ERROR + Int32(0x3fff0030)
const VI_ERROR_RAW_WR_PROT_VIOL = VI_ERROR + Int32(0x3fff0034)
const VI_ERROR_RAW_RD_PROT_VIOL = VI_ERROR + Int32(0x3fff0035)
const VI_ERROR_OUTP_PROT_VIOL = VI_ERROR + Int32(0x3fff0036)
const VI_ERROR_INP_PROT_VIOL = VI_ERROR + Int32(0x3fff0037)
const VI_ERROR_BERR = VI_ERROR + Int32(0x3fff0038)
const VI_ERROR_IN_PROGRESS = VI_ERROR + Int32(0x3fff0039)
const VI_ERROR_INV_SETUP = VI_ERROR + Int32(0x3fff003a)
const VI_ERROR_QUEUE_ERROR = VI_ERROR + Int32(0x3fff003b)
const VI_ERROR_ALLOC = VI_ERROR + Int32(0x3fff003c)
const VI_ERROR_INV_MASK = VI_ERROR + Int32(0x3fff003d)
const VI_ERROR_IO = VI_ERROR + Int32(0x3fff003e)
const VI_ERROR_INV_FMT = VI_ERROR + Int32(0x3fff003f)
const VI_ERROR_NSUP_FMT = VI_ERROR + Int32(0x3fff0041)
const VI_ERROR_LINE_IN_USE = VI_ERROR + Int32(0x3fff0042)
const VI_ERROR_LINE_NRESERVED = VI_ERROR + Int32(0x3fff0043)
const VI_ERROR_NSUP_MODE = VI_ERROR + Int32(0x3fff0046)
const VI_ERROR_SRQ_NOCCURRED = VI_ERROR + Int32(0x3fff004a)
const VI_ERROR_INV_SPACE = VI_ERROR + Int32(0x3fff004e)
const VI_ERROR_INV_OFFSET = VI_ERROR + Int32(0x3fff0051)
const VI_ERROR_INV_WIDTH = VI_ERROR + Int32(0x3fff0052)
const VI_ERROR_NSUP_OFFSET = VI_ERROR + Int32(0x3fff0054)
const VI_ERROR_NSUP_VAR_WIDTH = VI_ERROR + Int32(0x3fff0055)
const VI_ERROR_WINDOW_NMAPPED = VI_ERROR + Int32(0x3fff0057)
const VI_ERROR_RESP_PENDING = VI_ERROR + Int32(0x3fff0059)
const VI_ERROR_NLISTENERS = VI_ERROR + Int32(0x3fff005f)
const VI_ERROR_NCIC = VI_ERROR + Int32(0x3fff0060)
const VI_ERROR_NSYS_CNTLR = VI_ERROR + Int32(0x3fff0061)
const VI_ERROR_NSUP_OPER = VI_ERROR + Int32(0x3fff0067)
const VI_ERROR_INTR_PENDING = VI_ERROR + Int32(0x3fff0068)
const VI_ERROR_ASRL_PARITY = VI_ERROR + Int32(0x3fff006a)
const VI_ERROR_ASRL_FRAMING = VI_ERROR + Int32(0x3fff006b)
const VI_ERROR_ASRL_OVERRUN = VI_ERROR + Int32(0x3fff006c)
const VI_ERROR_TRIG_NMAPPED = VI_ERROR + Int32(0x3fff006e)
const VI_ERROR_NSUP_ALIGN_OFFSET = VI_ERROR + Int32(0x3fff0070)
const VI_ERROR_USER_BUF = VI_ERROR + Int32(0x3fff0071)
const VI_ERROR_RSRC_BUSY = VI_ERROR + Int32(0x3fff0072)
const VI_ERROR_NSUP_WIDTH = VI_ERROR + Int32(0x3fff0076)
const VI_ERROR_INV_PARAMETER = VI_ERROR + Int32(0x3fff0078)
const VI_ERROR_INV_PROT = VI_ERROR + Int32(0x3fff0079)
const VI_ERROR_INV_SIZE = VI_ERROR + Int32(0x3fff007b)
const VI_ERROR_WINDOW_MAPPED = VI_ERROR + Int32(0x3fff0080)
const VI_ERROR_NIMPL_OPER = VI_ERROR + Int32(0x3fff0081)
const VI_ERROR_INV_LENGTH = VI_ERROR + Int32(0x3fff0083)
const VI_ERROR_INV_MODE = VI_ERROR + Int32(0x3fff0091)
const VI_ERROR_SESN_NLOCKED = VI_ERROR + Int32(0x3fff009c)
const VI_ERROR_MEM_NSHARED = VI_ERROR + Int32(0x3fff009d)
const VI_ERROR_LIBRARY_NFOUND = VI_ERROR + Int32(0x3fff009e)
const VI_ERROR_NSUP_INTR = VI_ERROR + Int32(0x3fff009f)
const VI_ERROR_INV_LINE = VI_ERROR + Int32(0x3fff00a0)
const VI_ERROR_FILE_ACCESS = VI_ERROR + Int32(0x3fff00a1)
const VI_ERROR_FILE_IO = VI_ERROR + Int32(0x3fff00a2)
const VI_ERROR_NSUP_LINE = VI_ERROR + Int32(0x3fff00a3)
const VI_ERROR_NSUP_MECH = VI_ERROR + Int32(0x3fff00a4)
const VI_ERROR_INTF_NUM_NCONFIG = VI_ERROR + Int32(0x3fff00a5)
const VI_ERROR_CONN_LOST = VI_ERROR + Int32(0x3fff00a6)
const VI_ERROR_MACHINE_NAVAIL = VI_ERROR + Int32(0x3fff00a7)
const VI_ERROR_NPERMISSION = VI_ERROR + Int32(0x3fff00a8)

# Skipping MacroDefinition: VI_VERSION_MAJOR ( ver ) ( ( ( ( ViVersion ) ver ) & 0xFFF00000UL ) >> 20 )
# Skipping MacroDefinition: VI_VERSION_MINOR ( ver ) ( ( ( ( ViVersion ) ver ) & 0x000FFF00UL ) >> 8 )
# Skipping MacroDefinition: VI_VERSION_SUBMINOR ( ver ) ( ( ( ( ViVersion ) ver ) & 0x000000FFUL ) )

const VI_FIND_BUFLEN = 256
const VI_INTF_GPIB = 1
const VI_INTF_VXI = 2
const VI_INTF_GPIB_VXI = 3
const VI_INTF_ASRL = 4
const VI_INTF_PXI = 5
const VI_INTF_TCPIP = 6
const VI_INTF_USB = 7
const VI_PROT_NORMAL = 1
const VI_PROT_FDC = 2
const VI_PROT_HS488 = 3
const VI_PROT_4882_STRS = 4
const VI_PROT_USBTMC_VENDOR = 5
const VI_FDC_NORMAL = 1
const VI_FDC_STREAM = 2
const VI_LOCAL_SPACE = 0
const VI_A16_SPACE = 1
const VI_A24_SPACE = 2
const VI_A32_SPACE = 3
const VI_A64_SPACE = 4
const VI_PXI_ALLOC_SPACE = 9
const VI_PXI_CFG_SPACE = 10
const VI_PXI_BAR0_SPACE = 11
const VI_PXI_BAR1_SPACE = 12
const VI_PXI_BAR2_SPACE = 13
const VI_PXI_BAR3_SPACE = 14
const VI_PXI_BAR4_SPACE = 15
const VI_PXI_BAR5_SPACE = 16
const VI_OPAQUE_SPACE = Float32(0x0fff)
const VI_UNKNOWN_LA = -1
const VI_UNKNOWN_SLOT = -1
const VI_UNKNOWN_LEVEL = -1
const VI_UNKNOWN_CHASSIS = -1
const VI_QUEUE = 1
const VI_HNDLR = 2
const VI_SUSPEND_HNDLR = 4
const VI_ALL_MECH = Float32(0x0fff)
const VI_ANY_HNDLR = 0
const VI_TRIG_ALL = -2
const VI_TRIG_SW = -1
const VI_TRIG_TTL0 = 0
const VI_TRIG_TTL1 = 1
const VI_TRIG_TTL2 = 2
const VI_TRIG_TTL3 = 3
const VI_TRIG_TTL4 = 4
const VI_TRIG_TTL5 = 5
const VI_TRIG_TTL6 = 6
const VI_TRIG_TTL7 = 7
const VI_TRIG_ECL0 = 8
const VI_TRIG_ECL1 = 9
const VI_TRIG_ECL2 = 10
const VI_TRIG_ECL3 = 11
const VI_TRIG_ECL4 = 12
const VI_TRIG_ECL5 = 13
const VI_TRIG_STAR_SLOT1 = 14
const VI_TRIG_STAR_SLOT2 = 15
const VI_TRIG_STAR_SLOT3 = 16
const VI_TRIG_STAR_SLOT4 = 17
const VI_TRIG_STAR_SLOT5 = 18
const VI_TRIG_STAR_SLOT6 = 19
const VI_TRIG_STAR_SLOT7 = 20
const VI_TRIG_STAR_SLOT8 = 21
const VI_TRIG_STAR_SLOT9 = 22
const VI_TRIG_STAR_SLOT10 = 23
const VI_TRIG_STAR_SLOT11 = 24
const VI_TRIG_STAR_SLOT12 = 25
const VI_TRIG_STAR_INSTR = 26
const VI_TRIG_PANEL_IN = 27
const VI_TRIG_PANEL_OUT = 28
const VI_TRIG_STAR_VXI0 = 29
const VI_TRIG_STAR_VXI1 = 30
const VI_TRIG_STAR_VXI2 = 31
const VI_TRIG_TTL8 = 32
const VI_TRIG_TTL9 = 33
const VI_TRIG_TTL10 = 34
const VI_TRIG_TTL11 = 35
const VI_TRIG_PROT_DEFAULT = 0
const VI_TRIG_PROT_ON = 1
const VI_TRIG_PROT_OFF = 2
const VI_TRIG_PROT_SYNC = 5
const VI_TRIG_PROT_RESERVE = 6
const VI_TRIG_PROT_UNRESERVE = 7
const VI_READ_BUF = 1
const VI_WRITE_BUF = 2
const VI_READ_BUF_DISCARD = 4
const VI_WRITE_BUF_DISCARD = 8
const VI_IO_IN_BUF = 16
const VI_IO_OUT_BUF = 32
const VI_IO_IN_BUF_DISCARD = 64
const VI_IO_OUT_BUF_DISCARD = 128
const VI_FLUSH_ON_ACCESS = 1
const VI_FLUSH_WHEN_FULL = 2
const VI_FLUSH_DISABLE = 3
const VI_NMAPPED = 1
const VI_USE_OPERS = 2
const VI_DEREF_ADDR = 3
const VI_DEREF_ADDR_BYTE_SWAP = 4
const VI_TMO_IMMEDIATE = Int32(0)
const VI_TMO_INFINITE = UInt32(0xffffffff)
const VI_NO_LOCK = 0
const VI_EXCLUSIVE_LOCK = 1
const VI_SHARED_LOCK = 2
const VI_LOAD_CONFIG = 4
const VI_NO_SEC_ADDR = Float32(0x0fff)
const VI_ASRL_PAR_NONE = 0
const VI_ASRL_PAR_ODD = 1
const VI_ASRL_PAR_EVEN = 2
const VI_ASRL_PAR_MARK = 3
const VI_ASRL_PAR_SPACE = 4
const VI_ASRL_STOP_ONE = 10
const VI_ASRL_STOP_ONE5 = 15
const VI_ASRL_STOP_TWO = 20
const VI_ASRL_FLOW_NONE = 0
const VI_ASRL_FLOW_XON_XOFF = 1
const VI_ASRL_FLOW_RTS_CTS = 2
const VI_ASRL_FLOW_DTR_DSR = 4
const VI_ASRL_END_NONE = 0
const VI_ASRL_END_LAST_BIT = 1
const VI_ASRL_END_TERMCHAR = 2
const VI_ASRL_END_BREAK = 3
const VI_STATE_ASSERTED = 1
const VI_STATE_UNASSERTED = 0
const VI_STATE_UNKNOWN = -1
const VI_BIG_ENDIAN = 0
const VI_LITTLE_ENDIAN = 1
const VI_DATA_PRIV = 0
const VI_DATA_NPRIV = 1
const VI_PROG_PRIV = 2
const VI_PROG_NPRIV = 3
const VI_BLCK_PRIV = 4
const VI_BLCK_NPRIV = 5
const VI_D64_PRIV = 6
const VI_D64_NPRIV = 7
const VI_D64_2EVME = 8
const VI_D64_SST160 = 9
const VI_D64_SST267 = 10
const VI_D64_SST320 = 11
const VI_WIDTH_8 = 1
const VI_WIDTH_16 = 2
const VI_WIDTH_32 = 4
const VI_WIDTH_64 = 8
const VI_GPIB_REN_DEASSERT = 0
const VI_GPIB_REN_ASSERT = 1
const VI_GPIB_REN_DEASSERT_GTL = 2
const VI_GPIB_REN_ASSERT_ADDRESS = 3
const VI_GPIB_REN_ASSERT_LLO = 4
const VI_GPIB_REN_ASSERT_ADDRESS_LLO = 5
const VI_GPIB_REN_ADDRESS_GTL = 6
const VI_GPIB_ATN_DEASSERT = 0
const VI_GPIB_ATN_ASSERT = 1
const VI_GPIB_ATN_DEASSERT_HANDSHAKE = 2
const VI_GPIB_ATN_ASSERT_IMMEDIATE = 3
const VI_GPIB_HS488_DISABLED = 0
const VI_GPIB_HS488_NIMPL = -1
const VI_GPIB_UNADDRESSED = 0
const VI_GPIB_TALKER = 1
const VI_GPIB_LISTENER = 2
const VI_VXI_CMD16 = 0x0200
const VI_VXI_CMD16_RESP16 = 0x0202
const VI_VXI_RESP16 = 0x0002
const VI_VXI_CMD32 = 0x0400
const VI_VXI_CMD32_RESP16 = 0x0402
const VI_VXI_CMD32_RESP32 = 0x0404
const VI_VXI_RESP32 = 0x0004
const VI_ASSERT_SIGNAL = -1
const VI_ASSERT_USE_ASSIGNED = 0
const VI_ASSERT_IRQ1 = 1
const VI_ASSERT_IRQ2 = 2
const VI_ASSERT_IRQ3 = 3
const VI_ASSERT_IRQ4 = 4
const VI_ASSERT_IRQ5 = 5
const VI_ASSERT_IRQ6 = 6
const VI_ASSERT_IRQ7 = 7
const VI_UTIL_ASSERT_SYSRESET = 1
const VI_UTIL_ASSERT_SYSFAIL = 2
const VI_UTIL_DEASSERT_SYSFAIL = 3
const VI_VXI_CLASS_MEMORY = 0
const VI_VXI_CLASS_EXTENDED = 1
const VI_VXI_CLASS_MESSAGE = 2
const VI_VXI_CLASS_REGISTER = 3
const VI_VXI_CLASS_OTHER = 4
const VI_PXI_ADDR_NONE = 0
const VI_PXI_ADDR_MEM = 1
const VI_PXI_ADDR_IO = 2
const VI_PXI_ADDR_CFG = 3
const VI_TRIG_UNKNOWN = -1
const VI_PXI_LBUS_UNKNOWN = -1
const VI_PXI_LBUS_NONE = 0
const VI_PXI_LBUS_STAR_TRIG_BUS_0 = 1000
const VI_PXI_LBUS_STAR_TRIG_BUS_1 = 1001
const VI_PXI_LBUS_STAR_TRIG_BUS_2 = 1002
const VI_PXI_LBUS_STAR_TRIG_BUS_3 = 1003
const VI_PXI_LBUS_STAR_TRIG_BUS_4 = 1004
const VI_PXI_LBUS_STAR_TRIG_BUS_5 = 1005
const VI_PXI_LBUS_STAR_TRIG_BUS_6 = 1006
const VI_PXI_LBUS_STAR_TRIG_BUS_7 = 1007
const VI_PXI_LBUS_STAR_TRIG_BUS_8 = 1008
const VI_PXI_LBUS_STAR_TRIG_BUS_9 = 1009
const VI_PXI_STAR_TRIG_CONTROLLER = 1413

# Skipping MacroDefinition: viGetDefaultRM ( vi ) viOpenDefaultRM ( vi )

const VI_ERROR_INV_SESSION = VI_ERROR_INV_OBJECT
const VI_INFINITE = VI_TMO_INFINITE
const VI_NORMAL = VI_PROT_NORMAL
const VI_FDC = VI_PROT_FDC
const VI_HS488 = VI_PROT_HS488
const VI_ASRL488 = VI_PROT_4882_STRS
const VI_ASRL_IN_BUF = VI_IO_IN_BUF
const VI_ASRL_OUT_BUF = VI_IO_OUT_BUF
const VI_ASRL_IN_BUF_DISCARD = VI_IO_IN_BUF_DISCARD
const VI_ASRL_OUT_BUF_DISCARD = VI_IO_OUT_BUF_DISCARD
const VI_ERROR_HW_NGENUINE = VI_ERROR + Int32(0x3fff00aa)
const VI_INTF_RIO = 8
const VI_INTF_FIREWIRE = 9
const VI_ATTR_SYNC_MXI_ALLOW_EN = UInt32(0x3fff0161)
const VI_EVENT_VXI_DEV_CMD = UInt32(0xbfff200f)
const VI_ATTR_VXI_DEV_CMD_TYPE = UInt32(0x3fff4037)
const VI_ATTR_VXI_DEV_CMD_VALUE = UInt32(0x3fff4038)
const VI_VXI_DEV_CMD_TYPE_16 = 16
const VI_VXI_DEV_CMD_TYPE_32 = 32
const VI_VXI_RESP_NONE = 0
const VI_VXI_RESP_PROT_ERROR = -1
const VI_ATTR_VXI_TRIG_LINES_EN = UInt32(0x3fff4043)
const VI_ATTR_VXI_TRIG_DIR = UInt32(0x3fff4044)
const VI_ATTR_ASRL_DISCARD_NULL = UInt32(0x3fff00b0)
const VI_ATTR_ASRL_CONNECTED = UInt32(0x3fff01bb)
const VI_ATTR_ASRL_BREAK_STATE = UInt32(0x3fff01bc)
const VI_ATTR_ASRL_BREAK_LEN = UInt32(0x3fff01bd)
const VI_ATTR_ASRL_ALLOW_TRANSMIT = UInt32(0x3fff01be)
const VI_ATTR_ASRL_WIRE_MODE = UInt32(0x3fff01bf)
const VI_ASRL_WIRE_485_4 = 0
const VI_ASRL_WIRE_485_2_DTR_ECHO = 1
const VI_ASRL_WIRE_485_2_DTR_CTRL = 2
const VI_ASRL_WIRE_485_2_AUTO = 3
const VI_ASRL_WIRE_232_DTE = 128
const VI_ASRL_WIRE_232_DCE = 129
const VI_ASRL_WIRE_232_AUTO = 130
const VI_EVENT_ASRL_BREAK = UInt32(0x3fff2023)
const VI_EVENT_ASRL_CTS = UInt32(0x3fff2029)
const VI_EVENT_ASRL_DSR = UInt32(0x3fff202a)
const VI_EVENT_ASRL_DCD = UInt32(0x3fff202c)
const VI_EVENT_ASRL_RI = UInt32(0x3fff202e)
const VI_EVENT_ASRL_CHAR = UInt32(0x3fff2035)
const VI_EVENT_ASRL_TERMCHAR = UInt32(0x3fff2024)
const VI_ATTR_FIREWIRE_DEST_UPPER_OFFSET = UInt32(0x3fff01f0)
const VI_ATTR_FIREWIRE_SRC_UPPER_OFFSET = UInt32(0x3fff01f1)
const VI_ATTR_FIREWIRE_WIN_UPPER_OFFSET = UInt32(0x3fff01f2)
const VI_ATTR_FIREWIRE_VENDOR_ID = UInt32(0x3fff01f3)
const VI_ATTR_FIREWIRE_LOWER_CHIP_ID = UInt32(0x3fff01f4)
const VI_ATTR_FIREWIRE_UPPER_CHIP_ID = UInt32(0x3fff01f5)
const VI_FIREWIRE_DFLT_SPACE = 5
const ViUInt32 = Culong
const ViObject = ViUInt32
const ViEvent = ViObject
const ViPEvent = Ref{ViEvent}
const ViFindList = ViObject
const ViPFindList = Ref{ViFindList}
const ViUInt64 = Culonglong
const ViBusAddress = ViUInt64
const ViBusSize = ViUInt64
const ViAttrState = ViUInt64
const ViBusAddress64 = ViUInt64
const ViPBusAddress64 = Ref{ViBusAddress64}
const ViEventType = ViUInt32
const ViPEventType = Ref{ViEventType}
const ViAEventType = Ref{ViEventType}
const ViPAttrState = Ref{Cvoid}
const ViAttr = ViUInt32
const ViPAttr = Ref{ViAttr}
const ViAAttr = Ref{ViAttr}
const ViChar = UInt8
const ViPChar = Ptr{ViChar} # kept as Ptr
const ViString = ViPChar
const ViKeyId = ViString
const ViConstString = Ptr{ViChar}  # kept as Ptr
const ViConstKeyId = ViConstString
const ViPString = ViPChar
const ViPKeyId = ViPString
const ViJobId = ViUInt32
const ViPJobId = Ref{ViJobId}
const ViAccessMode = ViUInt32
const ViPAccessMode = Ref{ViAccessMode}
const ViPBusAddress = Ref{ViBusAddress}
const ViEventFilter = ViUInt32
const ViVAList = Cint
const ViHndlr = Ref{Cvoid}
const VI_SUCCESS = Int32(0)
const VI_NULL = 0
const VI_TRUE = 1
const VI_FALSE = 0
const ViInt64 = Clonglong
const ViPUInt64 = Ref{ViUInt64}
const ViAUInt64 = Ref{ViUInt64}
const ViPInt64 = Ref{ViInt64}
const ViAInt64 = Ref{ViInt64}
const ViInt32 = Clong
const ViPUInt32 = Ref{ViUInt32}
const ViAUInt32 = Ref{ViUInt32}
const ViPInt32 = Ref{ViInt32}
const ViAInt32 = Ref{ViInt32}
const ViUInt16 = UInt16
const ViPUInt16 = Ref{ViUInt16}
const ViAUInt16 = Ref{ViUInt16}
const ViInt16 = Int16
const ViPInt16 = Ref{ViInt16}
const ViAInt16 = Ref{ViInt16}
const ViUInt8 = Cuchar
const ViPUInt8 = Ref{ViUInt8}
const ViAUInt8 = Ref{ViUInt8}
const ViInt8 = UInt8
const ViPInt8 = Ref{ViInt8}
const ViAInt8 = Ref{ViInt8}
const ViAChar = Ref{ViChar}
const ViByte = Cuchar
const ViPByte = Ref{ViByte}
const ViAByte = Ref{ViByte}
const ViAddr = Ref{Cvoid}
const ViPAddr = Ref{ViAddr}
const ViAAddr = Ref{ViAddr}
const ViReal32 = Cfloat
const ViPReal32 = Ref{ViReal32}
const ViAReal32 = Ref{ViReal32}
const ViReal64 = Cdouble
const ViPReal64 = Ref{ViReal64}
const ViAReal64 = Ref{ViReal64}
const ViBuf = ViPByte
const ViConstBuf = Ref{ViByte}
const ViPBuf = ViPByte
const ViABuf = Ref{ViPByte}
const ViAString = Ref{ViPChar}
const ViRsrc = ViString
const ViConstRsrc = ViConstString
const ViPRsrc = ViString
const ViARsrc = Ref{ViString}
const ViBoolean = ViUInt16
const ViPBoolean = Ref{ViBoolean}
const ViABoolean = Ref{ViBoolean}
const ViStatus = ViInt32
const ViPStatus = Ref{ViStatus}
const ViAStatus = Ref{ViStatus}
const ViVersion = ViUInt32
const ViPVersion = Ref{ViVersion}
const ViAVersion = Ref{ViVersion}
const ViPObject = Ref{ViObject}
const ViAObject = Ref{ViObject}
const ViSession = ViObject
const ViPSession = Ref{ViSession}
const ViASession = Ref{ViSession}
const VI_WARN_NSUP_ID_QUERY = Int32(0x3ffc0101)
const VI_WARN_NSUP_RESET = Int32(0x3ffc0102)
const VI_WARN_NSUP_SELF_TEST = Int32(0x3ffc0103)
const VI_WARN_NSUP_ERROR_QUERY = Int32(0x3ffc0104)
const VI_WARN_NSUP_REV_QUERY = Int32(0x3ffc0105)
const VI_ERROR_PARAMETER1 = VI_ERROR + Int32(0x3ffc0001)
const VI_ERROR_PARAMETER2 = VI_ERROR + Int32(0x3ffc0002)
const VI_ERROR_PARAMETER3 = VI_ERROR + Int32(0x3ffc0003)
const VI_ERROR_PARAMETER4 = VI_ERROR + Int32(0x3ffc0004)
const VI_ERROR_PARAMETER5 = VI_ERROR + Int32(0x3ffc0005)
const VI_ERROR_PARAMETER6 = VI_ERROR + Int32(0x3ffc0006)
const VI_ERROR_PARAMETER7 = VI_ERROR + Int32(0x3ffc0007)
const VI_ERROR_PARAMETER8 = VI_ERROR + Int32(0x3ffc0008)
const VI_ERROR_FAIL_ID_QUERY = VI_ERROR + Int32(0x3ffc0011)
const VI_ERROR_INV_RESPONSE = VI_ERROR + Int32(0x3ffc0012)
const VI_ON = 1
const VI_OFF = 0


text:
#InspectDR: Store/manipulate info about graph bounds, scales, ...
#-------------------------------------------------------------------------------

#TODO: Move Plot2D here from base.jl, and rename?

#==Main types
===============================================================================#

#TODO: deprecate Plot2DInfo & stick with Graph2DInfo (despite redundancy)???
#Maybe Plot2DInfo just stores array of Graph2DInfo?

#"Evaluated" information about all strips:
#(Cache for bounds, current extents, text formatting, transforms, etc)
mutable struct StripInfo
	graphbb::BoundingBox #Location of graph (device units)
	ext::PExtents2D #Current extents of graph
	yfmt::TickLabelFormatting #y tick label formatting
	yixf::InputXfrm1DSpec #Input transform for y-values
	xf::Transform2D #Transform used to render data
	grid::PlotGrid #Real, displayed ("_eval"-uated) grid - not "coordinate grid"
	#TODO: axis scaling, ...?
end

#"Evaluated" information about all graphs on a plot:
#(Cache for bounds, current extents, text formatting, transforms, etc)
mutable struct Plot2DInfo
#TODO: store BoundingBox for entire plot??
#TODO: store extents???
	xfmt::TickLabelFormatting #x tick label formatting
	xixf::InputXfrm1DSpec #Input transform for x-values
	strips::Vector{StripInfo}
end
Plot2DInfo() = Plot2DInfo(
	TickLabelFormatting(NoRangeDisplayInfo()), InputXfrm1DSpec(:lin), []
)

#Graph-specific version of Plot2DInfo/StripInfo
mutable struct Graph2DInfo
	graphbb::BoundingBox #Location of graph (device units)
	ext::PExtents2D #Current extents of graph

	xfmt::TickLabelFormatting #x tick label formatting
	yfmt::TickLabelFormatting #y tick label formatting

	ixf::InputXfrm2D #Input transform for y-values
	xf::Transform2D #Transform used to render data

	grid::PlotGrid #Real, displayed ("_eval"-uated) grid - not "coordinate grid"
end

#==Accessors
===============================================================================#
Transform2D(pinfo::Plot2DInfo, istrip::Int) = pinfo.strips[istrip].xf
InputXfrm2D(pinfo::Plot2DInfo, istrip::Int) =
	InputXfrm2D(pinfo.xixf, pinfo.strips[istrip].yixf)

#==Constructor-like functions
===============================================================================#
function Graph2DInfo(pinfo::Plot2DInfo, istrip::Int)
	graphbb = pinfo.strips[istrip].graphbb
	ext = pinfo.strips[istrip].ext
	xfmt = pinfo.xfmt
	yfmt = pinfo.strips[istrip].yfmt
	ixf = InputXfrm2D(pinfo, istrip)
	xf = Transform2D(pinfo, istrip)
	grid = pinfo.strips[istrip].grid
	return Graph2DInfo(graphbb, ext, xfmt, yfmt, ixf, xf, grid)
end

function Plot2DInfo(plot::Plot2D)
	xfmt = TickLabelFormatting(NoRangeDisplayInfo())
	if length(plot.strips) > 0
		istrip = 1
		strip = plot.strips[istrip]
		ext = getextents_axis(plot, istrip)
		#Get the rectangular coordinate grid:
		grid = coord_grid(strip.grid, plot.xscale, strip.yscale, ext)
		if !isa(grid.xlines, UndefinedGridLines)
			xfmt = TickLabelFormatting(plot.layout.values.format_xtick, grid.xlines.rnginfo)
		end
	end
	return Plot2DInfo(xfmt, InputXfrm1DSpec(plot.xscale), [])
end

#bb: bounding box of entire plot
function Plot2DInfo(plot::Plot2D, bb::BoundingBox)
	dfltfmt = TickLabelFormatting(NoRangeDisplayInfo()) #WANTCONST
	result = Plot2DInfo(plot)
	databb = databounds(bb, plot.layout.values, grid1(plot))
	nstrips = length(plot.strips)
	graphbblist = graphbounds_list(databb, plot.layout.values, nstrips)
	resize!(result.strips, nstrips)

	for istrip in 1:nstrips #Compute x/y label formats:
		strip = plot.strips[istrip]
		graphbb = graphbblist[istrip]
		ext = getextents_axis(plot, istrip)
		grid = _eval(strip.grid, plot.xscale, strip.yscale, ext)
		cgrid = coord_grid(strip.grid, plot.xscale, strip.yscale, ext)
		yfmt = dfltfmt
		if !isa(cgrid.ylines, UndefinedGridLines)
			yfmt = TickLabelFormatting(plot.layout.values.format_ytick, cgrid.ylines.rnginfo)
		end
		result.strips[istrip] = StripInfo(graphbb, ext, yfmt,
			InputXfrm1DSpec(strip.yscale), Transform2D(ext, graphbb), grid
		)
	end
	return result
end
#Want to define/use coord_grid when displaying coordinates???
#Or maybe we deprecate coord_grid???

#==Helper functions
===============================================================================#
#Get numeric formatting/precision with mouse hover:
function hoverfmt(fmt::TickLabelFormatting)
	result = deepcopy(fmt.fmt)
	#Display a bit more precision than tick labels:
	result.ndigits += 2 #TODO: Better algorithm?
	return result
end

#==Main functions
===============================================================================#
#TODO: move some of the computations from base.jl here?

#Last line


text:
# only need to be run once to install packages
#Pkg.clone("https://github.com/JuliaData/SplitApplyCombine.jl.git")
#Pkg.clone("https://github.com/xiaodaigh/FastGroupBy.jl.git")

using FastGroupBy, PooledArrays

const N = 100_000_000
# const N = Int(2^31-1) # 368 seconds to run
const K = UInt(100)

using Base.Threads
nthreads()

const id6 = rand(Int32(1):Int32(round(N/K)), N);
const v1 =  rand(Int32(1):Int32(5), N);

function bench_sumby_multi_rs(id6,v1)
    srand(1);
    # id6 = rand(Int32(1):Int32(round(N/K)), N);
    # v1 =  rand(Int32(1):Int32(5), N);
    gc()
    @elapsed sumby_multi_rs(id6, v1)
end

function bench_sumby_radixgroup()
    srand(1)
    id6 = rand(Int32(1):Int32(round(N/K)), N)
    # v1 =  rand(Int32(1):Int32(5), N)
    # radix sort method
    gc()
    @elapsed sumby_radixgroup(id6,v1);
end

function bench_sumby_radixsort()
    srand(1)
    id6 = rand(Int32(1):Int32(round(N/K)), N)
    # v1 =  rand(Int32(1):Int32(5), N)
    # radix sort method
    gc()
    @elapsed sumby_radixsort(id6,v1);
end

function bench_sumby_radixsort_extra()
    srand(1)
    id6 = rand(Int32(1):Int32(round(N/K)), N)
    # v1 =  rand(Int32(1):Int32(5), N)
    # radix sort method
    gc()
    @elapsed sumby_radixsort_extra(id6,v1);
end

function bench_sumby_dict(id6, v1)
    #srand(1)
    # id6 = rand(Int32(1):Int32(round(N/K)), N)
    gc()
    @elapsed sumby_dict(id6,v1);
end

@time bench_d = [bench_sumby_dict(id6, v1) for i = 1:5]
@time bench_mrs = [bench_sumby_multi_rs(id6, v1) for i = 1:3]
# @time bench_rg = [bench_sumby_radixgroup() for i = 1:3]
@time bench_rs = [bench_sumby_radixsort() for i = 1:5]
@time bench_rse = [bench_sumby_radixsort_extra() for i = 1:5]

const grp4 = rand(Int8(1):Int8(4), N);
@time bench_d = [bench_sumby_dict(grp4, v1) for i = 1:3]
@time bench_mrs = [bench_sumby_multi_rs(grp4, v1) for i = 1:3]

using HypothesisTests
p1 = pvalue(EqualVarianceTTest(bench_rs, bench_rse))
p2 = pvalue(UnequalVarianceTTest(bench_rs, bench_rse))
while (p1 >= 0.05) | (p2 >= 0.05)
    @time bench_rs = vcat(bench_rs, [bench_sumby_radixsort()])
    @time bench_rse =  vcat(bench_rse, [bench_sumby_radixsort_extra()])
    p1 = pvalue(EqualVarianceTTest(bench_rs, bench_rse))
    p2 = pvalue(UnequalVarianceTTest(bench_rs, bench_rse))
end
mean(bench_rs[2:end]) #19.2
mean(bench_rse[2:end])
p1 = pvalue(EqualVarianceTTest(bench_rs, bench_rse))
p2 = pvalue(UnequalVarianceTTest(bench_rs, bench_rse))

1 - mean(bench_rs)/mean(bench_rse) # the new version is faster
1 - mean(bench_mrs)/mean(bench_rs) #49.6% faster radixsort
# 1 - mean(bench_mrs)/mean(bench_rg) #37.2% faster radixgroup

mean(bench_mrs[2:end]) #9.87
# mean(bench_rg[2:end]) #15.5
mean(bench_rs[2:end]) #19.2
mean(bench_rse[2:end])

# generate string ids
function randstrarray1(pool, N)
    K = length(pool)
    PooledArray(PooledArrays.RefArray(rand(1:K, N)), pool)
end

srand(1)
const pool1 = [@sprintf "id%010d" k for k in 1:(N/K)]
const id3 = randstrarray1(pool1, N)
v1 =  rand(Int32(1):Int32(5), N)

# treat it as Pooledarray
@time sumby(id3, v1)

# treat by as strings and use dictionary method; REALLY SLOW
const id3_str = rand(pool1, N)
@time sumby_dict(id3_str, v1)

# parallelized sum
# @time addprocs() # create Julia workers
# @time using FastGroupBy
# @everywhere using FastGroupBy
# @everywhere using SplitApplyCombine
# @time psumby(id6,v1) # 35 seconds

srand(1)
x = rand(100_000_000)
cx = copy(x)
i = collect(1:length(cx))
@time sorttwo!(cx, i, 1, length(x), RadixSort, Base.Forward);
@time x[i]

cx = copy(x)
@time (cx,i) = fsortandperm_radix!(cx);
@time issorted(x[i])
# cx = copy(x)
# @time sortperm(cx, alg= RadixSort)

cx = copy(x)
@time sort!(cx, 1, length(cx), RadixSort, Base.Forward)

N  = 100_000_000;
K = 100;
by = nothing;
val = nothing;
gc();
srand(1);
by = rand(Int32(1):Int32(round(N/K)), N);
val = rand(Int32(1):Int32(5), N);

using FastGroupBy
function abc(by, val)
    sorttwo!(by, val)
    sumby_contiguous(by, val)
end

srand(1);
by = rand(Int32(1):Int32(round(N/K)), N);
val = rand(Int32(1):Int32(5), N);
@time abc(by, val)

srand(1);
by = rand(Int32(1):Int32(round(N/K)), N);
val = rand(Int32(1):Int32(5), N);
@time sumby_radixsort(by, val)

srand(1);
by = rand(Int32(1):Int32(round(N/K)), N);
val = rand(Int32(1):Int32(5), N);
@time sumby_multi_rs(by, val)


text:
using BenchmarkProfiles
using Plots
using Base.Test

unicodeplots()
T = 10 * rand(25, 3)
performance_profile(T, ["a", "b", "c"], title="Test Profile")
H = rand(25, 4, 3)
data_profile(H, ones(10), ["a", "b", "c"], title="Test Profile")


text:
module FlowFarm
using Geodesy; const gd = Geodesy
using ForwardDiff

# using CCBlade
# using PyPlot
using FLOWMath: linear,trapz,Akima
# using Statistics
using Distributed

include("io.jl")
include("utilities.jl")
include("turbines.jl")
include("windfarms.jl")
include("wind_resources.jl")
include("wind_shear_models.jl")
include("wake_combination_models.jl")
include("wake_deficit_models.jl")
include("wake_deflection_models.jl")
include("thrust_coefficient_models.jl")
include("local_turbulence_intensity_models.jl")
include("general_models.jl")
include("power_models.jl")
include("user_functions.jl")
include("optimization_functions.jl")
include("fatigue_model.jl")
include("tip.jl")
include("cost_models.jl")
end # module