{"text": "Median := function(v)\n local n, w;\n w := SortedList(v);\n n := Length(v);\n return (w[QuoInt(n + 1, 2)] + w[QuoInt(n, 2) + 1]) / 2;\nend;\n\na := [41, 56, 72, 17, 93, 44, 32];\nb := [41, 72, 17, 93, 44, 32];\n\nMedian(a);\n# 44\nMedian(b);\n# 85/2\n", "meta": {"hexsha": "b4afcb0badcba6b8e2b811b258e0ecf159e645fb", "size": 241, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Averages-Median/GAP/averages-median.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Averages-Median/GAP/averages-median.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Averages-Median/GAP/averages-median.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 16.0666666667, "max_line_length": 57, "alphanum_fraction": 0.4937759336, "num_tokens": 120, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9591542840900507, "lm_q2_score": 0.7745833893685269, "lm_q1q2_score": 0.7429449762978143}} {"text": "# Return the list L after applying Knuth shuffle. GAP also has the function Shuffle, which does the same.\nShuffleAlt := function(a)\n local i, j, n, t;\n n := Length(a);\n for i in [n, n - 1 .. 2] do\n j := Random(1, i);\n t := a[i];\n a[i] := a[j];\n a[j] := t;\n od;\n return a;\nend;\n\n# Return a \"Permutation\" object (a permutation of 1 .. n).\n# They are printed in GAP, in cycle decomposition form.\nPermShuffle := n -> PermList(ShuffleAlt([1 .. n]));\n\nShuffleAlt([1 .. 10]);\n# [ 4, 7, 1, 5, 8, 2, 6, 9, 10, 3 ]\n\nPermShuffle(10);\n# (1,9)(2,3,6,4,5,10,8,7)\n\n# One may also call the built-in random generator on the symmetric group :\nRandom(SymmetricGroup(10));\n(1,8,2,5,9,6)(3,4,10,7)\n", "meta": {"hexsha": "12a0cf443af6d4baa7fabe1e6cf6cfb6c7a50c56", "size": 720, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Knuth-shuffle/GAP/knuth-shuffle.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Knuth-shuffle/GAP/knuth-shuffle.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Knuth-shuffle/GAP/knuth-shuffle.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 26.6666666667, "max_line_length": 105, "alphanum_fraction": 0.5777777778, "num_tokens": 260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037384317886, "lm_q2_score": 0.8006920092299292, "lm_q1q2_score": 0.7416840014821436}} {"text": "Pascal := function(n)\n\tlocal i, v;\n\tv := [1];\n\tfor i in [1 .. n] do\n\t\tDisplay(v);\n\t\tv := Concatenation([0], v) + Concatenation(v, [0]);\n\tod;\nend;\n\nPascal(9);\n# [ 1 ]\n# [ 1, 1 ]\n# [ 1, 2, 1 ]\n# [ 1, 3, 3, 1 ]\n# [ 1, 4, 6, 4, 1 ]\n# [ 1, 5, 10, 10, 5, 1 ]\n# [ 1, 6, 15, 20, 15, 6, 1 ]\n# [ 1, 7, 21, 35, 35, 21, 7, 1 ]\n# [ 1, 8, 28, 56, 70, 56, 28, 8, 1 ]\n", "meta": {"hexsha": "f257bbe0d6ff0a609236fa3a21df5a85f1fdf7c9", "size": 352, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Pascals-triangle/GAP/pascals-triangle.gap", "max_stars_repo_name": "mullikine/RosettaCodeData", "max_stars_repo_head_hexsha": "4f0027c6ce83daa36118ee8b67915a13cd23ab67", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Pascals-triangle/GAP/pascals-triangle.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Pascals-triangle/GAP/pascals-triangle.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 17.6, "max_line_length": 53, "alphanum_fraction": 0.4090909091, "num_tokens": 214, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.950410972802222, "lm_q2_score": 0.7799929002541068, "lm_q1q2_score": 0.7413138111093321}} {"text": "\nmerge_lists := function( list1, list2 )\n local i, j, merged_list;\n \n merged_list := [ ];\n \n i := 1;\n \n j := 1;\n \n while i <= Length( list1 ) and j <= Length( list2 ) do\n \n if list1[ i ] <= list2[ j ] then\n \n Add( merged_list, list1[ i ] );\n \n i := i + 1;\n \n else\n \n Add( merged_list, list2[ j ] );\n \n j := j + 1;\n \n fi;\n \n od;\n \n if i <= Length( list1 ) then\n \n Append( merged_list, list1{[ i .. Length( list1 ) ]} );\n \n else\n \n Append( merged_list, list2{[ j .. Length( list2 ) ]} );\n \n fi;\n \n return merged_list;\n \nend;\n\nmerge_sort := function( list )\n local lists_to_merge;\n \n if Length( list ) = 1 then\n \n return list;\n \n fi;\n \n lists_to_merge := [ ];\n \n lists_to_merge[ 1 ] := merge_sort( list{[ 1 .. Int( Length( list ) / 2 ) ]} );\n \n lists_to_merge[ 2 ] := merge_sort( list{[ Int( Length( list ) / 2 ) + 1 .. Length( list ) ]} );\n \n return merge_lists( lists_to_merge[ 1 ], lists_to_merge[ 2 ] );\n \nend;\n\n", "meta": {"hexsha": "8ea702af405cafd881099124bb63fe29026a6792", "size": 1103, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "Merge_Sort/GAP/sebasguts/merge_sort.gi", "max_stars_repo_name": "Mynogs/Algorithm-Implementations", "max_stars_repo_head_hexsha": "13a74821fc1f0f7becaa9fb63b98e94134936bdb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1184, "max_stars_repo_stars_event_min_datetime": "2015-01-01T14:11:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T19:40:47.000Z", "max_issues_repo_path": "Merge_Sort/GAP/sebasguts/merge_sort.gi", "max_issues_repo_name": "Mynogs/Algorithm-Implementations", "max_issues_repo_head_hexsha": "13a74821fc1f0f7becaa9fb63b98e94134936bdb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 89, "max_issues_repo_issues_event_min_datetime": "2015-01-01T15:49:17.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-05T19:11:38.000Z", "max_forks_repo_path": "Merge_Sort/GAP/sebasguts/merge_sort.gi", "max_forks_repo_name": "Mynogs/Algorithm-Implementations", "max_forks_repo_head_hexsha": "13a74821fc1f0f7becaa9fb63b98e94134936bdb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 388, "max_forks_repo_forks_event_min_datetime": "2015-01-02T03:26:17.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T14:36:10.000Z", "avg_line_length": 17.7903225806, "max_line_length": 97, "alphanum_fraction": 0.4641885766, "num_tokens": 336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637433190939, "lm_q2_score": 0.861538211208597, "lm_q1q2_score": 0.7406331636600186}} {"text": "LucasLehmer := function(n)\n local i, m, s;\n if n = 2 then\n return true;\n elif not IsPrime(n) then\n return false;\n else\n m := 2^n - 1;\n s := 4;\n for i in [3 .. n] do\n s := RemInt(s*s, m) - 2;\n od;\n return s = 0;\n fi;\nend;\n\nFiltered([1 .. 2000], LucasLehmer);\n[2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279]\n", "meta": {"hexsha": "e96e0c9fe56044d2243364da5f251090d6b39f2c", "size": 396, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Lucas-Lehmer-test/GAP/lucas-lehmer-test.gap", "max_stars_repo_name": "mullikine/RosettaCodeData", "max_stars_repo_head_hexsha": "4f0027c6ce83daa36118ee8b67915a13cd23ab67", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Lucas-Lehmer-test/GAP/lucas-lehmer-test.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Lucas-Lehmer-test/GAP/lucas-lehmer-test.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 20.8421052632, "max_line_length": 62, "alphanum_fraction": 0.4494949495, "num_tokens": 160, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9449947086083139, "lm_q2_score": 0.7772998611746912, "lm_q1q2_score": 0.7345442558120602}} {"text": "x := Indeterminate(Rationals, \"x\");\np := x^11 + 3*x^8 + 7*x^2 + 3;\nq := x^7 + 5*x^3 + 1;\nQuotientRemainder(p, q);\n# [ x^4+3*x-5, -16*x^4+25*x^3+7*x^2-3*x+8 ]\n", "meta": {"hexsha": "d8e9727af1c287967f1a55a52e22468c87bf79a5", "size": 158, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Polynomial-long-division/GAP/polynomial-long-division.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Polynomial-long-division/GAP/polynomial-long-division.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Polynomial-long-division/GAP/polynomial-long-division.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 26.3333333333, "max_line_length": 43, "alphanum_fraction": 0.5063291139, "num_tokens": 89, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897475985937, "lm_q2_score": 0.7799928951399099, "lm_q1q2_score": 0.7338093189473721}} {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F RHT( ) - Rationalized Haar Transform non-terminal\n#F\n#F Definition: RHT(n) represents the (2^n x 2^n)-matrix defined recursively as:\n#F RHT(1) := DFT_2\n#F RHT(n) := [[ RHT(n-1) tensor [1, 1] ], \n#F [ I_(n-1) tensor [1 -1] ]]\n#F Note: I_(n-1) denotes the (2^(n-1) x 2^(n-1)) identity matrix\n#F DFT_2 denotes the matrix [[1, 1], [1, -1]]\n#F Example: RHT(6) \n#F RHT(6).transpose()\nClass(RHT, NonTerminal, rec (\n abbrevs := [ n -> Checked(IsInt(n), n > 0, [n]) ],\n dims := self >> [ 2^self.params[1], 2^self.params[1] ],\n terminate := self >> Cond(\n\tself.params[1] = 1, F(2), \n\tself.transposed, Mat(RationalizedHaarTransform(2^self.params[1])).transpose(),\n\t Mat(RationalizedHaarTransform(2^self.params[1]))),\n isReal := True,\n SmallRandom := () -> [ Random([1..6]) ]\n));\n\nRulesFor(RHT, rec(\n #F RHT_Base: (base case) RHT_(2^1) = F_2\n #F\n RHT_Base := rec (\n\tinfo := \"RHT_(2^1) -> F_2\",\n\tforTransposition := false,\n\tisApplicable := P -> P[1] = 1, \n\trule := (P, C) -> F(2) \n ),\n\n #F RHT_CooleyTukey: RHT_2^(n+1) = (RHT_2^(n) dirsum I_2^n) * (DFT_2 tensor I_2^n) * L\n #F\n RHT_CooleyTukey := rec (\n\tinfo := \"RHT_2^(n+1) -> (RHT_2^n dirsum I_n) * (F_2 tensor I_n)\",\n\tisApplicable := P -> P[1] > 1,\n\tallChildren := P -> [[ RHT(P[1] - 1) ]], \n\trule := (P, C) -> \n\t Inplace(DirectSum(C[1], I(2 ^ (P[1]-1)))) *\n\t Tensor(F(2), I(2 ^ (P[1]-1))) *\n\t L(2^P[1], 2)\n )\n));\n", "meta": {"hexsha": "6b9173f21961233d9316d31b57f89fd9bae7b117", "size": 1641, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/rht.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/transforms/rht.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/transforms/rht.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 33.4897959184, "max_line_length": 89, "alphanum_fraction": 0.5161486898, "num_tokens": 629, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361557147439, "lm_q2_score": 0.8031737940012418, "lm_q1q2_score": 0.7328448089693187}} {"text": "MovingAverage := function(n)\n local sma, buffer, pos, sum, len;\n buffer := List([1 .. n], i -> 0);\n pos := 0;\n len := 0;\n sum := 0;\n sma := function(x)\n pos := RemInt(pos, n) + 1;\n sum := sum + x - buffer[pos];\n buffer[pos] := x;\n len := Minimum(len + 1, n);\n return sum/len;\n end;\n return sma;\nend;\n\nf := MovingAverage(3);\nf(1); # 1\nf(2); # 3/2\nf(3); # 2\nf(4); # 3\nf(5); # 4\nf(5); # 14/3\nf(4); # 14/3\nf(3); # 4\nf(2); # 3\nf(1); # 2\n", "meta": {"hexsha": "fca65c5ae804d5eb2a0800a1bc4a63edd2339a4d", "size": 475, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Averages-Simple-moving-average/GAP/averages-simple-moving-average.gap", "max_stars_repo_name": "mullikine/RosettaCodeData", "max_stars_repo_head_hexsha": "4f0027c6ce83daa36118ee8b67915a13cd23ab67", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Averages-Simple-moving-average/GAP/averages-simple-moving-average.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Averages-Simple-moving-average/GAP/averages-simple-moving-average.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 16.9642857143, "max_line_length": 35, "alphanum_fraction": 0.4526315789, "num_tokens": 228, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9425067147399244, "lm_q2_score": 0.7772998611746912, "lm_q1q2_score": 0.7326103385235575}} {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nClass(DTTBase, NonTerminal, rec(\n abbrevs := [ N -> Checked(IsInt(N), N >= 1, [N]) ],\n dims := self >> [self.params[1], self.params[1]],\n isReal := True,\n\n normalizedArithCost := self >> let(n:=Double(self.params[1]),\n 2.5*n*d_log(n)/d_log(2)),\n\n hashAs := self >> self\n));\n\nDeclare(DCT3, DCT7);\n\n#F DCT1() - Discrete Cosine Transform, Type I, non-terminal\n#F Definition: (n x n)-matrix [ cos(k*l*pi/(n-1)) | k,l = 0...n-1 ]\n#F Note: The natural size for a DCT1 is 2^k + 1\n#F Example: DCT1(9)\n#F \nClass(DCT1, DTTBase, rec(\n terminate := self >> Mat(DCT_Iunscaled(self.params[1])),\n transpose := self >> Copy(self), \n SmallRandom := () -> Random([3,4,5,7,9,13,17,25,33])\n));\n\n#F DCT2() - Discrete Cosine Transform, Type II, non-terminal\n#F Definition: (n x n)-matrix [ cos(k*(l+1/2)*pi/n) | k,l = 0...n-1 ]\n#F Note: DCT2 is the transpose of DCT3\n#F Example: DCT2(8)\nClass(DCT2, DTTBase, rec(\n terminate := self >> Mat(DCT_IIunscaled(self.params[1])),\n transpose := self >> DCT3(self.params[1]),\n SmallRandom := () -> Random([2,3,4,5,6,8,9,10,12,15,16,18,24,27,30,32])\n));\n\n#F DCT3() - Discrete Cosine Transform, Type III, non-terminal (unscaled)\n#F Definition: (n x n)-matrix [ cos((k+1/2)*l*pi/n) | k,l = 0...n-1 ]\n#F [scaled] (n x n)-matrix [ a_l*cos((k+1/2)*l*pi/n) | k,l = 0...n-1 ]\n#F a_j = 1/sqrt(2) for j = 0 and = 1 else\n#F Note: DCT3 is the transpose of DCT2, scaled NOT supported yet\n#F Example: DCT3(8)\nClass(DCT3, DTTBase, rec(\n terminate := self >> Mat(DCT_IIIunscaled(self.params[1])),\n transpose := self >> DCT2(self.params[1]),\n SmallRandom := () -> Random([2,3,4,5,6,8,9,10,12,15,16,18,24,27,30,32])\n));\n\n#F DCT4() - Discrete Cosine Transform, Type IV, non-terminal\n#F Definition: (n x n)-matrix [ cos((k+1/2)*(l+1/2)*pi/n) | k,l = 0...n-1 ]\n#F Note: DCT4 is symmetric\n#F Example: DCT4(8)\nClass(DCT4, DTTBase, rec(\n terminate := self >> Mat(DCT_IVunscaled(self.params[1])),\n transpose := self >> Copy(self),\n SmallRandom := () -> Random([2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32])\n));\n\n#F DCT5() - Discrete Cosine Transform, Type V, non-terminal\n#F Definition: (n x n)-matrix [ cos(k*l*pi/(n-1/2)) | k,l = 0...n-1 ]\n#F Note: DCT5 is symmetric\n#F Example: DCT5(8)\nClass(DCT5, DTTBase, rec(\n terminate := self >> Mat(DCT_Vunscaled(self.params[1])),\n transpose := self >> Copy(self),\n));\n\n#F DCT6() - Discrete Cosine Transform, Type VI, non-terminal\n#F Definition: (n x n)-matrix [ cos(k*(l+1/2)*pi/(n-1/2)) | k,l = 0...n-1 ]\n#F Note: The transpose of DCT6 is DCT7\n#F Example: DCT6(8)\nClass(DCT6, DTTBase, rec(\n terminate := self >> Mat(DCT_VIunscaled(self.params[1])),\n transpose := self >> DCT7(self.params[1]),\n));\n\n#F DCT7() - Discrete Cosine Transform, Type VII, non-terminal\n#F Definition: (n x n)-matrix [ cos((k+1/2)*l*pi/(n-1/2)) | k,l = 0...n-1 ]\n#F Note: The transpose of DCT7 is DCT6\n#F Example: DCT7(8)\nClass(DCT7, DTTBase, rec(\n terminate := self >> Mat(DCT_VIIunscaled(self.params[1])),\n transpose := self >> DCT6(self.params[1]),\n));\n\n#F DCT8() - Discrete Cosine Transform, Type VIII, non-terminal\n#F Definition: (n x n)-matrix [ cos((k+1/2)*(l+1/2)*pi/(n+1/2)) | k,l = 0...n-1 ]\n#F Note: DCT8 is symmetric\n#F Example: DCT8(8)\nClass(DCT8, DTTBase, rec(\n terminate := self >> Mat(DCT_VIIIunscaled(self.params[1])),\n transpose := self >> Copy(self)\n));\n", "meta": {"hexsha": "aa47f5ed4c2ed27495ee86db143dbd95dba19779", "size": 3595, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dct_dst/dct.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/transforms/dct_dst/dct.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/transforms/dct_dst/dct.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 37.0618556701, "max_line_length": 81, "alphanum_fraction": 0.59527121, "num_tokens": 1336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037262250327, "lm_q2_score": 0.7905303186696748, "lm_q1q2_score": 0.7322711798775823}} {"text": "# The idiomatic way to compute with polynomials\n\nx := Indeterminate(Rationals, \"x\");\n\n# This is a value in a polynomial ring, not a function\np := 6*x^3 - 4*x^2 + 7*x - 19;\n\nValue(p, 3);\n# 128\n\nu := CoefficientsOfUnivariatePolynomial(p);\n# [ -19, 7, -4, 6 ]\n\n# One may also create the polynomial from coefficients\nq := UnivariatePolynomial(Rationals, [-19, 7, -4, 6], x);\n# 6*x^3-4*x^2+7*x-19\n\np = q;\n# true\n\n# Now a Horner implementation\nHorner := function(coef, x)\n\tlocal v, c;\n\tv := 0;\n\tfor c in Reversed(coef) do\n\t\tv := x*v + c;\n\tod;\n\treturn v;\nend;\n\nHorner(u, 3);\n# 128\n", "meta": {"hexsha": "338800cae0236b041734ebcaf950bb8f26e558f9", "size": 574, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Horners-rule-for-polynomial-evaluation/GAP/horners-rule-for-polynomial-evaluation.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Horners-rule-for-polynomial-evaluation/GAP/horners-rule-for-polynomial-evaluation.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Horners-rule-for-polynomial-evaluation/GAP/horners-rule-for-polynomial-evaluation.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 17.3939393939, "max_line_length": 57, "alphanum_fraction": 0.6306620209, "num_tokens": 214, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026573249612, "lm_q2_score": 0.7931059487389966, "lm_q1q2_score": 0.727518194318516}} {"text": "NextPermutation := function(a)\n local i, j, k, n, t;\n n := Length(a);\n i := n - 1;\n while i > 0 and a[i] > a[i + 1] do\n i := i - 1;\n od;\n j := i + 1;\n k := n;\n while j < k do\n t := a[j];\n a[j] := a[k];\n a[k] := t;\n j := j + 1;\n k := k - 1;\n od;\n if i = 0 then\n return false;\n else\n j := i + 1;\n while a[j] < a[i] do\n j := j + 1;\n od;\n t := a[i];\n a[i] := a[j];\n a[j] := t;\n return true;\n fi;\nend;\n\nPermutations := function(n)\n local a, L;\n a := List([1 .. n], x -> x);\n L := [ ];\n repeat\n Add(L, ShallowCopy(a));\n until not NextPermutation(a);\n return L;\nend;\n\nPermutations(3);\n[ [ 1, 2, 3 ], [ 1, 3, 2 ],\n [ 2, 1, 3 ], [ 2, 3, 1 ],\n [ 3, 1, 2 ], [ 3, 2, 1 ] ]\n", "meta": {"hexsha": "3432a9446f05c78093a6a71447a4cb4748cce15f", "size": 782, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Permutations/GAP/permutations-3.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Permutations/GAP/permutations-3.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Permutations/GAP/permutations-3.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 17.3777777778, "max_line_length": 37, "alphanum_fraction": 0.3721227621, "num_tokens": 323, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797027760039, "lm_q2_score": 0.7981867825403177, "lm_q1q2_score": 0.7272915952748216}} {"text": "RandNGen := function(n)\n\tlocal v, rand;\n\tv := [1 .. n - 1]*0;\n\tAdd(v, 1);\n\trand := function()\n\t\treturn Random(v);\n\tend;\n\treturn rand;\nend;\n\nUnbiasedGen := function(rand)\n\tlocal unbiased;\n\tunbiased := function()\n\t\tlocal a, b;\n\t\twhile true do\n\t\t\ta := rand();\n\t\t\tb := rand();\n\t\t\tif a <> b then\n\t\t\t\tbreak;\n\t\t\tfi;\n\t\tod;\n\t\treturn a;\n\tend;\n\treturn unbiased;\nend;\n\nrange := [2 .. 6];\nv := List(range, RandNGen);\nw := List(v, UnbiasedGen);\napply := gen -> Sum([1 .. 1000000], n -> gen());\n\n# Some tests (2 is added as a witness, since in this case RandN is already unbiased)\nPrintArray(TransposedMat([range, List(v, apply), List(w, apply)]));\n# [ [ 2, 499991, 499041 ],\n# [ 3, 333310, 500044 ],\n# [ 4, 249851, 500663 ],\n# [ 5, 200532, 500448 ],\n# [ 6, 166746, 499859 ] ]\n", "meta": {"hexsha": "3d00a90d6a88d19e87bf5762f65127a8fe9e6d20", "size": 810, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Unbias-a-random-generator/GAP/unbias-a-random-generator.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Unbias-a-random-generator/GAP/unbias-a-random-generator.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Unbias-a-random-generator/GAP/unbias-a-random-generator.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 20.7692307692, "max_line_length": 84, "alphanum_fraction": 0.5481481481, "num_tokens": 281, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032941962904955, "lm_q2_score": 0.8006920020959544, "lm_q1q2_score": 0.7232604385094928}} {"text": "#############################################################################\n##\n#A toric.gi toric library David Joyner\n##\n## this file contains implementations for toric \n##\n## 3-6-2006, changed Star to ToricStar, as a method instead of a \n## global function\n##\n\n#############################################################################\n##\n#F InDualCone(,)\n##\n## returns true if v belongs to the dual of the code generated by\n## the vectors in L\n## \nInstallGlobalFunction(InDualCone,function(v,L)\n local numgens,dim,i,V;\n TORIC.consistent_vectors(L);\n dim:=Size(v); \n numgens:=Size(L); \n# V := Rationals^dim; \n for i in [1..numgens] do \n if TORIC.inner_product(v,L[i],IdentityMat(dim)) < 0 then return false; fi; \n od; \n return true; \nend);\n\n#############################################################################\n##\n#F DualSemigroupGenerators()\n##\n## Input: L is a list of integral n-vectors \n## generating a cone sigma \n## Output: the generators of S_sigma, \n##\n## Idea: let M be the max of the abs values of the \n## coords of the L[i]'s, for each vector v in \n## [1..M]^n, test if v in sigma^*. If so, \n## add to list of possible generators. \n## Once this for loop is finished, one can check \n## this list for redundant generators. The \n## trick below is to simply omit those elements \n## which are of the form d1+d2, where d1 and d2 \n## are \"small\" elements in the integral dual cone. \n## \nInstallGlobalFunction(DualSemigroupGenerators,\nfunction(L)\nlocal d,i,dim,V,D,max,v,I,b,DpD,d1,d2,Dgens;\n TORIC.consistent_vectors(L);\n dim:=Size(L[1]); \n V := Rationals^dim; \n max:=TORIC.max_vectors(L); \n D:=[]; \n I:= Cartesian(List([1..dim],i->[-max..max])); \n for v in I do \n if InDualCone(v,L) then \n Append(D,[v]); \n fi; \n od; \n DpD:=[]; \n for d1 in D do \n if TORIC.inner_product(d1,d1,IdentityMat(dim)) <> 0 then \n for d2 in D do \n if TORIC.inner_product(d2,d2,IdentityMat(dim)) <> 0 then \n Append(DpD,[d1+d2]); \n fi; \n od; \n fi; \n od; \n Dgens:=[]; \n for d in D do \n if not(d in DpD) then \n Append(Dgens,[d]); \n fi; \n od; \n return Dgens; \nend);\n\n#############################################################################\n##\n#F EmbeddingAffineToricVariety()\n##\n## Input: L is a list generating a cone \n## (as in dual_semigp_gens),\n## Output: the toroidal embedding of X=affine_toric_variety(L)\n## (given as a list of multinomials)\n## \nInstallGlobalFunction(EmbeddingAffineToricVariety,\nfunction(L)\nlocal map0,u,O,i,P1,P2,e,dim,V,R1,R2,hom;\n TORIC.consistent_vectors(L);\n u:=DualSemigroupGenerators(L);\n dim:=Size(u[1]);\n V:=Rationals^dim;\n O:=Zero(V);\n u:=Difference(u,[O]);\n map0:=[];\n for e in u do\n P1:=Filtered([1..dim],i->e[i] < 0);\n P2:=Filtered([1..dim],i->e[i] >= 0);\n if Size(P1) > 0 then \n Add(map0, Product(P2,i->X(Rationals,i)^(e[i]))/Product(P1,i->X(Rationals,i+dim)^(-e[i])));\n fi;\n if Size(P1) = 0 then \n Add(map0, Product(P2,i->X(Rationals,i)^(e[i])));\n fi;\n od;\n return map0;\nend);\n\n#############################################################################\n##\n#F DivisorPolytope(, )\n##\n## Input: D is the list of coeffs for the Weil divisor D\n## Rays is the list of vectors in the rays for the fan Delta\n## (Delta is determined by a list of generators L\n## but these are not explicitly needed here)\n## Output: the linear expressions in the affine coordinates of the\n## space of the cone which must be >0 for a point to be in the\n## desired polytope\n## \nInstallGlobalFunction(DivisorPolytope,\nfunction(D,Rays)\nlocal n,Inequalities,R,i,j;\n TORIC.consistent_vectors(Rays);\n n:=Size(Rays[1]);\n Inequalities:=[];\n R:=PolynomialRing(Rationals,n);\n for i in [1..Size(Rays)] do\n Add(Inequalities,D[i]+Sum([1..n],j->X(Rationals,j)*Rays[i][j]));\n od;\n return Inequalities;\nend);\n\n#############################################################################\n##\n#F PolytopeLatticePoints(, )\n##\n## Input: Perps=[v1,...,vk] is the list of \"inward normal\" \n## vectors perpendicular to the walls of the polytope P,\n## A=[a1,...,ak] is the amount wall is shifted from the \n## origin (ai>=0)\n## Eg, x=0, x=a, y=0, y=b has Perps=[[1,0],[-1,0],[0,1],[0,-1]] \n## and A=[0,a,0,b]\n## Output: the list of points in P \\cap L^\\perp\n## \nInstallGlobalFunction(PolytopeLatticePoints,\nfunction(A,Perps)\nlocal R,n,M,Pts,i,j,Inequalities,L0,L1,L2,v,ineq;\n TORIC.consistent_vectors(Perps);\n R:=ShallowCopy(Perps);\n n:=Size(R[1]);\n M:=Maximum(List([1..Size(A)],i->AbsoluteValue(A[i])));\n L0:=List([1..n],i->[-M..M]);\n Pts:=Cartesian(L0);\n L2:=[];\n for v in Pts do\n Inequalities:=[];\n for i in [1..Size(R)] do\n ineq:=A[i]+Sum([1..n],j->v[j]*R[i][j]);\n Add(Inequalities,ineq);\n od;\n if Minimum(Inequalities) >= 0 then Add(L2,v); fi;\n od;\n return L2;\nend);\n\n#############################################################################\n##\n#F DivisorPolytopeLatticePoints(, , )\n##\n## Input: Cones is the fan\n## Rays_ordered is the *ordered* list of rays for Cones\n## D is the list of coeffs for the Weil divisor D\n## Output: the list of points in P_D \\cap L^\\perp\n## which paramterize the elements in L(D)\n##\n## Caution: The set of rays do not determine the cones in a fan.\n##\nInstallGlobalFunction(DivisorPolytopeLatticePoints,\nfunction(D,Cones,Rays_ordered)\nlocal R,n,M,Pts,i,j,Inequalities,L0,L1,L2,v,ineq,Rays;\n TORIC.consistent_vectors(Rays_ordered);\n Rays:=Rays_ordered;\n R:=ShallowCopy(Rays);\n n:=Size(R[1]);\n M:=Maximum(List([1..Size(D)],i->AbsoluteValue(D[i])));\n L0:=List([1..n],i->[-M..M]);\n Pts:=Cartesian(L0);\n L2:=[];\n for v in Pts do\n Inequalities:=List([1..Size(R)],i->D[i]+Sum([1..n],j->v[j]*R[i][j])); \n if Minimum(Inequalities) >= 0 then Add(L2,v); fi;\n od;\n return L2;\nend);\n\n#############################################################################\n##\n#F RiemannRochBasis(, , )\n##\n## Input: Cones is the fan\n## Rays_ordered is the *ordered* list of rays for Cones\n## D is the list of coeffs for the Weil divisor D\n##\n## Output: computes a basis (a list of monomials)\n## for the RR space of the divisor represented by D\n##\n##\nInstallGlobalFunction(RiemannRochBasis,\nfunction(D,Cones,Rays)\nlocal P,map0,d,R,e,i,P1,P2;\n TORIC.consistent_vectors(Rays);\n P:=DivisorPolytopeLatticePoints(D,Cones,Rays);\n map0:=[];\n d:=Size(Rays[1]);\n R:=PolynomialRing(Rationals,d); \n for e in P do\n P1:=Filtered([1..d],i->e[i] < 0);\n P2:=Filtered([1..d],i->e[i] >= 0);\n if Size(P1) > 0 and Size(P2) > 0 then \n Add(map0, Product(P2,i->X(Rationals,i)^(e[i]))/Product(P1,i->X(Rationals,i)^(-e[i])));\n fi;\n if Size(P1)= 0 then \n Add(map0, Product(P2,i->X(Rationals,i)^(e[i])));\n fi;\n if Size(P2) = 0 then \n Add(map0, 1/Product(P1,i->X(Rationals,i)^(-e[i])));\n fi;\n od;\n return map0;\nend);\n\n#############################################################################\n##\n#F Faces( )\n##\n## Input: Rays is a list of rays for the fan Delta\n##\n## Output: all the normals to the faces (hyperplanes of the cone)\n##\n##\nInstallGlobalFunction(Faces,function(Rays)\nlocal i,normals,n0,N,m,R,dim_sets,dim,v,pos,neg,n1,v0,N0;\n TORIC.consistent_vectors(Rays);\n normals:=[];\n R:=ShallowCopy(Rays);\n dim:=Size(R[1]);\n if dim<=1 then return \n Error(\"\\n Dimension of ambient space for the rays must be >1.\\n\");\n fi;\n v:=Sum(R);\n dim_sets:=Combinations(R,dim-1); ##### must have dim>1 here!\n for m in dim_sets do\n n0:=TORIC.normal_to_hyperplane(m);\n if TORIC.inner_product(v,n0,IdentityMat(dim))>0 then Add(normals,n0);\n else\n Add(normals,-n0);\n fi;\n od;\n Sort(normals);\n N0:=ShallowCopy(normals);\n N:=ShallowCopy(normals);\n for n1 in N do \n if Minimum(List(Rays,v0->TORIC.inner_product(v0,n1,IdentityMat(dim))))<0 then\n N0:=Difference(N0,[n1]); \n fi;\n od; \n return Set(N0);\nend);\n\n#############################################################################\n##\n#F InsideCone(, )\n##\n## Input: Rays is a list of rays for the fan Delta\n##\n## Output: true if v is in the cone represented by Rays\n## (a cone is a list of vectors generating it),\n## false otherwise\n##\n## Idea: look at all dim-subsets of Rays and test if \n## there is a positive solns vector all the normals \n## to the faces (hyperplanes of the cone)\n##\n##\nInstallGlobalFunction(InsideCone,function(v,Rays)\nlocal w,F,dim,R;\n TORIC.consistent_vectors(Rays);\n R:=ShallowCopy(Rays);\n dim:=Size(R[1]);\n if Length(v)<>dim then\n Error(\"\\n The vector \",v,\" must have the same dimension as the fan.\\n\");\n fi;\n if dim<=1 then return false; fi;\n F:=Faces(R);\n if Minimum(List(F,w->TORIC.inner_product(v,w,IdentityMat(dim))))<=0 then \n return false; \n fi;\n return true;\nend);\n\n#############################################################################\n##\n#F NumberOfConesOfFan( , )\n##\n## Input: Delta is the fan of cones\n## k is the dimension of the cones counted\n## Output: number of k-diml cones in the fan\n## (each hyperplane of one cone should not form the face\n## of any other cone in the fan)\n##\n## Idea: the fan Delta is represented as a set of max cones.\n## for each max cone, look at the k-diml faces\n## obtained by taking n choose k subsets of the\n## rays describing the cone. \n## **Certain** of these k-subsets yield the\n## desired cones\n##\nInstallGlobalFunction(NumberOfConesOfFan,\nfunction(Cones,k)\nlocal sigma,R,Rays,n,i,j,C,C0,dim,ell,k_cones,sigma0,N,v0,v;\n if k=0 then return 1; fi;\n C0:=ShallowCopy(Cones);\n Rays:=TORIC.flatten(C0);\n R:=ShallowCopy(Rays);\n if k=1 then return Size(R); fi;\n k_cones:=[];\n dim:=Size(R[1]);\n if k>dim then Print(\"dimension error\\n\"); return 0; fi;\n N:=Size(C0);\n if k=dim then return N; fi;\n for i in [1..N] do\n C:=ShallowCopy(Cones[i]);\n sigma:= Combinations(C,k);\n for ell in [1..Size(sigma)] do\n v0:=Sum(sigma[ell]);\n if not(InsideCone(v0,C)) then Add(k_cones,sigma[ell]); fi;\n od;\n od;\n return Size(Set(k_cones));\nend);\n\n#############################################################################\n##\n#F ConesOfFan( , )\n##\n## Input: Delta is the fan of cones\n## k is the dimension of the cones taken\n## Output: the set of k-diml cones in the fan\n## (each hyperplane of one cone should not form the face\n## of any other cone in the fan, ie,\n## only takes those subcones which are *not* interior)\n##\n##\nInstallGlobalFunction(ConesOfFan,\nfunction(Cones,k)\nlocal sigma,R,Rays,n,x,i,j,C,C0,dim,ell,k_cones,sigma0,N,v0,v;\n C0:=ShallowCopy(Cones);\n if k=0 then return 0*C0[1][1]; fi;\n Rays:=TORIC.flatten(C0);\n R:=ShallowCopy(Rays);\n if k=1 then return List(R,x->[x]); fi;\n k_cones:=[];\n dim:=Size(R[1]);\n if k>dim then Print(\"dimension error\\n\"); return 0; fi;\n N:=Size(C0);\n if k=dim then return C0; fi;\n for i in [1..N] do\n C:=ShallowCopy(Cones[i]);\n sigma:= Combinations(C,k);\n for ell in [1..Size(sigma)] do\n v0:=Sum(sigma[ell]);\n if not(InsideCone(v0,C)) then Add(k_cones,sigma[ell]); fi;\n od; ##excludes the \"interior\" cones\n od;\n return Set(k_cones);\nend);\n\n#############################################################################\n##\n#F ToricStar( , )\n##\n## Input: Cones is the fan of cones\n## is a cone of \n## Output: the star of the cone in a fan\n## ie, the cones tau which have as a face\n##\n##\nInstallGlobalFunction(ToricStar,\nfunction(cone,Cones)\nlocal T,tau,Taus,i,j,sigma,C0,R,Rays,dim;\n sigma:=ShallowCopy(cone);\n C0:=ShallowCopy(Cones);\n Rays:=TORIC.flatten(C0);\n R:=ShallowCopy(Rays);\n dim:=Size(R[1]);\n Taus:=[];\n for j in [1..dim] do\n tau:=ConesOfFan(C0,j);\n Append(Taus,tau);\n od;\n T:=[];\n for tau in Taus do\n if TORIC.is_sublist(sigma,tau) then Append(T,[tau]); fi;\n od;\n return T;\nend);\n\n#############################################################################\n##\n#F BettiNumberToric( , )\n##\n## Input: Cones is the fan of cones\n## k is an integer\n## Output: the k-th betti number of the toric variety \n## X(Delta), where Delta is a fan defined by its maximal\n## cones, Cones\n##\n##\nInstallGlobalFunction(BettiNumberToric,\nfunction(Cones,k0)\nlocal i,j,n,a,C,k;\n if IsOddInt(k0) then return 0; fi;\n k:=Int(k0/2);\n C:=ShallowCopy(Cones)[1][1];\n n:=Size(C);\n a:=Sum( [k..n],i->(-1)^(i-k)*Binomial(i,k)*NumberOfConesOfFan(Cones,n-i));\n return a;\nend);\n\n#############################################################################\n##\n#F EulerCharacteristic( )\n##\n## Input: Cones is the fan of cones\n## Output: Euler char of X(Delta), where \n## Delta is a fan defined by its maximal cones, Cones\n##\n## Note: X(Delta) **must be non-singular***\n##\n## was InstallGlobalFunction(EulerCharacteristic,[IsList],\nInstallMethod(EulerCharacteristic,[IsList],\nfunction(Cones)\nlocal sigma,R,Rays,C0,dim;\n C0:=ShallowCopy(Cones);\n Rays:=TORIC.flatten(C0);\n R:=ShallowCopy(Rays);\n dim:=Size(R[1]);\n return NumberOfConesOfFan(Cones,dim);\nend);\n\n#############################################################################\n##\n#F CardinalityOfToricVariety( , )\n##\n## Input: Cones is the fan of cones\n## Output: the number of elements of X(Delta) over GF(q), where \n## Delta is a fan defined by its maximal cones, Cones,\n## and where q is a prime power\n##\n## Note: X(Delta) **must be non-singular***\n##\nInstallGlobalFunction(CardinalityOfToricVariety,\nfunction(Cones,q)\nlocal i,j,n,a;\n n:=Size(Cones[1][1]);\n a:=Sum([0..n],i->(q-1)^(i)*NumberOfConesOfFan(Cones,n-i));\n return a;\nend);\n", "meta": {"hexsha": "37f89f0bc50fc3a26b8e10b3698d244c0d6a9906", "size": 13745, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/toric.gi", "max_stars_repo_name": "jamesjer/toric", "max_stars_repo_head_hexsha": "3c86b59d64d26df3efa3368a9826f0711ba5366f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-09-01T16:51:43.000Z", "max_stars_repo_stars_event_max_datetime": "2017-09-01T16:51:43.000Z", "max_issues_repo_path": "lib/toric.gi", "max_issues_repo_name": "jamesjer/toric", "max_issues_repo_head_hexsha": "3c86b59d64d26df3efa3368a9826f0711ba5366f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2016-08-25T22:32:46.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T01:11:47.000Z", "max_forks_repo_path": "lib/toric.gi", "max_forks_repo_name": "jamesjer/toric", "max_forks_repo_head_hexsha": "3c86b59d64d26df3efa3368a9826f0711ba5366f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-12-28T02:46:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-15T20:27:15.000Z", "avg_line_length": 28.9978902954, "max_line_length": 94, "alphanum_fraction": 0.578028374, "num_tokens": 4126, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.89330940889474, "lm_q2_score": 0.8031737940012418, "lm_q1q2_score": 0.717482707158995}} {"text": "NrQueens := function(n)\n local a, up, down, m, sub;\n a := [1 .. n];\n up := ListWithIdenticalEntries(2*n - 1, true);\n down := ListWithIdenticalEntries(2*n - 1, true);\n m := 0;\n sub := function(i)\n local j, k, p, q;\n for k in [i .. n] do\n j := a[k];\n p := i + j - 1;\n q := i - j + n;\n if up[p] and down[q] then\n if i = n then\n m := m + 1;\n else\n up[p] := false;\n down[q] := false;\n a[k] := a[i];\n a[i] := j;\n sub(i + 1);\n up[p] := true;\n down[q] := true;\n a[i] := a[k];\n a[k] := j;\n fi;\n fi;\n od;\n end;\n sub(1);\n return m;\nend;\n\nQueens := function(n)\n local a, up, down, v, sub;\n a := [1 .. n];\n up := ListWithIdenticalEntries(2*n - 1, true);\n down := ListWithIdenticalEntries(2*n - 1, true);\n v := [];\n sub := function(i)\n local j, k, p, q;\n for k in [i .. n] do\n j := a[k];\n p := i + j - 1;\n q := i - j + n;\n if up[p] and down[q] then\n if i = n then\n Add(v, ShallowCopy(a));\n else\n up[p] := false;\n down[q] := false;\n a[k] := a[i];\n a[i] := j;\n sub(i + 1);\n up[p] := true;\n down[q] := true;\n a[i] := a[k];\n a[k] := j;\n fi;\n fi;\n od;\n end;\n sub(1);\n return v;\nend;\n\nNrQueens(8);\na := Queens(8);;\nPrintArray(PermutationMat(PermList(a[1]), 8));\n\n[ [ 1, 0, 0, 0, 0, 0, 0, 0 ],\n [ 0, 0, 0, 0, 1, 0, 0, 0 ],\n [ 0, 0, 0, 0, 0, 0, 0, 1 ],\n [ 0, 0, 0, 0, 0, 1, 0, 0 ],\n [ 0, 0, 1, 0, 0, 0, 0, 0 ],\n [ 0, 0, 0, 0, 0, 0, 1, 0 ],\n [ 0, 1, 0, 0, 0, 0, 0, 0 ],\n [ 0, 0, 0, 1, 0, 0, 0, 0 ] ]\n", "meta": {"hexsha": "617412ddf6c7fb737bd7d6e6dfc36c09275ff74c", "size": 2124, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/N-queens-problem/GAP/n-queens-problem.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/N-queens-problem/GAP/n-queens-problem.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/N-queens-problem/GAP/n-queens-problem.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 26.8860759494, "max_line_length": 52, "alphanum_fraction": 0.3003766478, "num_tokens": 771, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110511888303, "lm_q2_score": 0.8031738034238807, "lm_q1q2_score": 0.716279273918782}} {"text": "TanPlus := function(a, b)\n return (a + b) / (1 - a * b);\nend;\n\nTanTimes := function(n, a)\n local x;\n x := 0;\n while n > 0 do\n if IsOddInt(n) then\n x := TanPlus(x, a);\n fi;\n a := TanPlus(a, a);\n n := QuoInt(n, 2);\n od;\n return x;\nend;\n\nCheck := function(a)\n local x, p;\n x := 0;\n for p in a do\n x := TanPlus(x, SignInt(p[1]) * TanTimes(AbsInt(p[1]), p[2]));\n od;\n return x = 1;\nend;\n\nForAll([\n [[1, 1/2], [1, 1/3]],\n [[2, 1/3], [1, 1/7]],\n [[4, 1/5], [-1, 1/239]],\n [[5, 1/7], [2, 3/79]],\n [[5, 29/278], [7, 3/79]],\n [[1, 1/2], [1, 1/5], [1, 1/8]],\n [[5, 1/7], [4, 1/53], [2, 1/4443]],\n [[6, 1/8], [2, 1/57], [1, 1/239]],\n [[8, 1/10], [-1, 1/239], [-4, 1/515]],\n [[12, 1/18], [8, 1/57], [-5, 1/239]],\n [[16, 1/21], [3, 1/239], [4, 3/1042]],\n [[22, 1/28], [2, 1/443], [-5, 1/1393], [-10, 1/11018]],\n [[22, 1/38], [17, 7/601], [10, 7/8149]],\n [[44, 1/57], [7, 1/239], [-12, 1/682], [24, 1/12943]],\n [[88, 1/172], [51, 1/239], [32, 1/682], [44, 1/5357], [68, 1/12943]]], Check);\n\nCheck([[88, 1/172], [51, 1/239], [32, 1/682], [44, 1/5357], [68, 1/12944]]);\n", "meta": {"hexsha": "ec6df4afc7ab30b71ee8110d9abde18f756a69de", "size": 1177, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Check-Machin-like-formulas/GAP/check-machin-like-formulas.gap", "max_stars_repo_name": "mullikine/RosettaCodeData", "max_stars_repo_head_hexsha": "4f0027c6ce83daa36118ee8b67915a13cd23ab67", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Check-Machin-like-formulas/GAP/check-machin-like-formulas.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Check-Machin-like-formulas/GAP/check-machin-like-formulas.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 26.1555555556, "max_line_length": 82, "alphanum_fraction": 0.3976210705, "num_tokens": 588, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582574225517, "lm_q2_score": 0.7662936377487305, "lm_q1q2_score": 0.7130042428536719}} {"text": "roots := n -> List([0 .. n-1], k -> E(n)^k);\n\nr:=roots(7);\n# [ 1, E(7), E(7)^2, E(7)^3, E(7)^4, E(7)^5, E(7)^6 ]\n\nList(r, x -> x^7);\n# [ 1, 1, 1, 1, 1, 1, 1 ]\n", "meta": {"hexsha": "cd874964d12875c707d3091299ccd86d951621fd", "size": 159, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Roots-of-unity/GAP/roots-of-unity.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Roots-of-unity/GAP/roots-of-unity.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Roots-of-unity/GAP/roots-of-unity.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 19.875, "max_line_length": 53, "alphanum_fraction": 0.358490566, "num_tokens": 96, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107914029487, "lm_q2_score": 0.7606506581031359, "lm_q1q2_score": 0.7128900052620137}} {"text": "# Just multiplying a vector by itself yields the sum of squares (it's an inner product)\n# It's necessary to check for the empty vector though\nSumSq := function(v)\n\tif Size(v) = 0 then\n\t\treturn 0;\n\telse\n\t\treturn v*v;\n\tfi;\nend;\n", "meta": {"hexsha": "df2c779630061d051d8509374e178bfd2bd2f253", "size": 226, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Sum-of-squares/GAP/sum-of-squares.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Sum-of-squares/GAP/sum-of-squares.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Sum-of-squares/GAP/sum-of-squares.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 22.6, "max_line_length": 87, "alphanum_fraction": 0.7079646018, "num_tokens": 62, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8976952866333484, "lm_q2_score": 0.7905303137346446, "lm_q1q2_score": 0.7096553365803726}} {"text": "Mean := function(v)\n local n;\n n := Length(v);\n if n = 0 then\n return 0;\n else\n return Sum(v)/n;\n fi;\nend;\n\nMean([3, 1, 4, 1, 5, 9]);\n# 23/6\n", "meta": {"hexsha": "3e419b56cd9ba7fdb77417d1b64c84e39ebcb1ff", "size": 152, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Averages-Arithmetic-mean/GAP/averages-arithmetic-mean.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Averages-Arithmetic-mean/GAP/averages-arithmetic-mean.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Averages-Arithmetic-mean/GAP/averages-arithmetic-mean.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 11.6923076923, "max_line_length": 25, "alphanum_fraction": 0.4934210526, "num_tokens": 68, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9525741322079105, "lm_q2_score": 0.743168019989179, "lm_q1q2_score": 0.7079226317258633}} {"text": "# GAP knows gaussian integers, gaussian rationals (i.e. Q[i]), and cyclotomic fields. Here are some examples.\n# E(n) is an nth primitive root of 1\ni := Sqrt(-1);\n# E(4)\n(3 + 2*i)*(5 - 7*i);\n# 29-11*E(4)\n1/i;\n# -E(4)\nSqrt(-3);\n# E(3)-E(3)^2\n\ni in GaussianIntegers;\n# true\ni/2 in GaussianIntegers;\n# false\ni/2 in GaussianRationals;\n# true\nSqrt(-3) in Cyclotomics;\n# true\n", "meta": {"hexsha": "165525440d7c39d727fdfe5267399378e908924f", "size": 369, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Arithmetic-Complex/GAP/arithmetic-complex.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Arithmetic-Complex/GAP/arithmetic-complex.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Arithmetic-Complex/GAP/arithmetic-complex.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 18.45, "max_line_length": 109, "alphanum_fraction": 0.6422764228, "num_tokens": 145, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9518632247867714, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.7073942918217092}} {"text": "# Here an implementation with no optimization (O(n^2)).\n# In GAP, E(n) = exp(2*i*pi/n), a primitive root of the unity.\n\nFourier := function(a)\n\tlocal n, z;\n\tn := Size(a);\n\tz := E(n);\n\treturn List([0 .. n - 1], k -> Sum([0 .. n - 1], j -> a[j + 1]*z^(-k*j)));\nend;\n\nInverseFourier := function(a)\n\tlocal n, z;\n\tn := Size(a);\n\tz := E(n);\n\treturn List([0 .. n - 1], k -> Sum([0 .. n - 1], j -> a[j + 1]*z^(k*j)))/n;\nend;\n\nFourier([1, 1, 1, 1, 0, 0, 0, 0]);\n# [ 4, 1-E(8)-E(8)^2-E(8)^3, 0, 1-E(8)+E(8)^2-E(8)^3,\n# 0, 1+E(8)-E(8)^2+E(8)^3, 0, 1+E(8)+E(8)^2+E(8)^3 ]\n\nInverseFourier(last);\n# [ 1, 1, 1, 1, 0, 0, 0, 0 ]\n", "meta": {"hexsha": "6279554cca5f78b5fb430be6c00f254506938490", "size": 614, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Fast-Fourier-transform/GAP/fast-fourier-transform.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Fast-Fourier-transform/GAP/fast-fourier-transform.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Fast-Fourier-transform/GAP/fast-fourier-transform.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 25.5833333333, "max_line_length": 76, "alphanum_fraction": 0.4771986971, "num_tokens": 295, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9539661015270469, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.7061012506046294}} {"text": "originalMatrix := [[1, 1, 1, 1],\n [2, 4, 8, 16],\n [3, 9, 27, 81],\n [4, 16, 64, 256],\n [5, 25, 125, 625]];\ntransposedMatrix := TransposedMat(originalMatrix);\n", "meta": {"hexsha": "debe1afc6a40b0354090d7dac46ad2bd167e891d", "size": 229, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Matrix-transposition/GAP/matrix-transposition.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Matrix-transposition/GAP/matrix-transposition.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Matrix-transposition/GAP/matrix-transposition.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 32.7142857143, "max_line_length": 50, "alphanum_fraction": 0.3886462882, "num_tokens": 77, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9073122188543454, "lm_q2_score": 0.7772998663336157, "lm_q1q2_score": 0.705253666438339}} {"text": "#! @Title Skeletal vector spaces\n#! @Author Sebastian Gutsche and Sebastian Posur\n#! @Date 01/08/2018\n#! @Chapter HandsOn\n\n#! @Section Objects and morphisms\n\nLoadPackage( \"CAP\" );\n\nLoadPackage( \"MatricesForHomalg\" );\n\n#################################\n##\n## Technical declarations\n##\n#################################\n\n## Objects\nDeclareCategory( \"IsQVectorSpace\",\n IsCapCategoryObject );\n## Morphisms\nDeclareCategory( \"IsQVectorSpaceMorphism\",\n IsCapCategoryMorphism );\n\n#################################\n##\n## Attributes\n##\n#################################\n\n#! @Description\n#! The argument is an object $V$ in the category of rational vector spaces.\n#! The output is its dimension.\n#! @Returns a non-negative integer\n#! @Arguments V\nDeclareAttribute( \"Dimension\",\n IsQVectorSpace );\n\n#! @Description\n#! The argument is a morphism $\\alpha$ in the category of rational vector spaces.\n#! The output is its underlying matrix.\n#! @Returns a homalg matrix\n#! @Arguments alpha\nDeclareAttribute( \"UnderlyingMatrix\",\n IsQVectorSpaceMorphism );\n\n#################################\n##\n## Operations\n##\n#################################\n\n#! @Description\n#! The argument is a non-negative integer $d$.\n#! The output is a rational vector space of dimension $d$.\n#! @Returns an object\n#! @Arguments d\nDeclareOperation( \"QVectorSpace\",\n [ IsInt ] );\n\n#! @Description\n#! The first argument is a rational vector space $V$.\n#! The second argument $A$ is either a homalg matrix defined over the rationals\n#! or an input that can be used as the first argument in the HomalgMatrix constructor.\n#! The third argument is a rational vector space $W$.\n#! The output is vector space morphism from $V$ to $W$ defined by $A$.\n#! @Returns an morphism in $\\mathrm{Hom}(V,W)$\n#! @Arguments V,A,W\nDeclareOperation( \"QVectorSpaceMorphism\",\n [ IsQVectorSpace, IsObject, IsQVectorSpace ] );\n\n#################################\n##\n## Creation of category\n##\n#################################\n\nBindGlobal( \"vecspaces\", CreateCapCategory( \"QVectorSpaces\" ) );\n\nAddObjectRepresentation( vecspaces, IsQVectorSpace );\n\nAddMorphismRepresentation( vecspaces, IsQVectorSpaceMorphism );\n\nSetIsAbelianCategory( vecspaces, true );\n\n#################################\n##\n## Creation of Q\n##\n#################################\n\nBindGlobal( \"VECTORSPACES_FIELD\", HomalgFieldOfRationals( ) );\n\n#################################\n##\n## Constructors for objects and morphisms\n##\n#################################\n\n##\nInstallMethod( QVectorSpace,\n [ IsInt ],\n \n function( dim )\n local space;\n \n if dim < 0 then\n \n Error( \"the argument has to be a non-negative integer\" );\n \n fi;\n \n space := rec( );\n \n ObjectifyObjectForCAPWithAttributes( space, vecspaces,\n Dimension, dim \n );\n \n return space;\n \nend );\n\n##\nInstallMethod( QVectorSpaceMorphism,\n [ IsQVectorSpace, IsObject, IsQVectorSpace ],\n \n function( source, matrix, range )\n local morphism;\n \n if not IsHomalgMatrix( matrix ) then\n \n matrix := HomalgMatrix( matrix, Dimension( source ), Dimension( range ), VECTORSPACES_FIELD );\n \n fi;\n \n morphism := rec( );\n \n ObjectifyMorphismForCAPWithAttributes( morphism, vecspaces,\n Source, source,\n Range, range,\n UnderlyingMatrix, matrix\n );\n \n return morphism;\n \nend );\n\n#################################\n##\n## View\n##\n#################################\n\n##\nInstallMethod( ViewObj,\n [ IsQVectorSpace ],\n \n function( obj )\n \n Print( \"\" );\n \nend );\n\n##\nInstallMethod( ViewObj,\n [ IsQVectorSpaceMorphism ],\n \n function( mor )\n \n Print( \"A rational vector space homomorphism with matrix: \\n\" );\n \n Display( UnderlyingMatrix( mor ) );\n \nend );\n\n#################################\n##\n## Functions to be added to category\n##\n#################################\n\n##\nidentity_morphism := function( obj )\n \n return QVectorSpaceMorphism( obj, HomalgIdentityMatrix( Dimension( obj ), VECTORSPACES_FIELD ), obj );\n \nend;\n\nAddIdentityMorphism( vecspaces, identity_morphism );\n\n##\npre_compose := function( mor_left, mor_right )\n local composition;\n \n composition := UnderlyingMatrix( mor_left ) * UnderlyingMatrix( mor_right );\n \n return QVectorSpaceMorphism( Source( mor_left ), composition, Range( mor_right ) );\n \nend;\n\nAddPreCompose( vecspaces, pre_compose );\n\n##\nis_equal_for_objects := function( vecspace_1, vecspace_2 )\n \n return Dimension( vecspace_1 ) = Dimension( vecspace_2 );\n \nend;\n\nAddIsEqualForObjects( vecspaces, is_equal_for_objects );\n\n##\nis_equal_for_morphisms := function( a, b )\n \n return UnderlyingMatrix( a ) = UnderlyingMatrix( b );\n \nend;\n\nAddIsEqualForMorphisms( vecspaces, is_equal_for_morphisms );\n\n##\nkernel_emb := function( morphism )\n local syzygies, kernel_obj;\n \n syzygies := SyzygiesOfRows( UnderlyingMatrix( morphism ) );\n \n kernel_obj := QVectorSpace( NrRows( syzygies ) );\n \n return QVectorSpaceMorphism( kernel_obj, syzygies, Source( morphism ) );\n \nend;\n\nAddKernelEmbedding( vecspaces, kernel_emb );\n\n##\nlift := function( alpha, beta )\n local solution;\n \n solution := RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) );\n \n if solution = fail then\n \n return fail;\n \n fi;\n \n return QVectorSpaceMorphism( Source( alpha ),\n solution,\n Source( beta ) );\n \nend;\n\nAddLift( vecspaces, lift );\n\n##\ncokernel_proj := function( morphism )\n local syzygies, cokernel_obj;\n \n syzygies := SyzygiesOfColumns( UnderlyingMatrix( morphism ) );\n \n cokernel_obj := QVectorSpace( NrColumns( syzygies ) );\n \n return QVectorSpaceMorphism( Range( morphism ), \n syzygies, cokernel_obj );\n \nend;\n\nAddCokernelProjection( vecspaces, cokernel_proj );\n\n##\ncolift := function( alpha, beta )\n local solution;\n \n solution := LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) );\n \n if solution = fail then\n \n return fail;\n \n fi;\n \n return QVectorSpaceMorphism( Range( alpha ),\n solution,\n Range( beta ) );\n \nend;\n\nAddColift( vecspaces, colift );\n\n##\nzero_object := function( )\n \n return QVectorSpace( 0 );\n \nend;\n\nAddZeroObject( vecspaces, zero_object );\n\n##\nuniversal_morphism_into_zero_object := function( source )\n \n return QVectorSpaceMorphism( source,\n HomalgZeroMatrix( Dimension( source ), 0, VECTORSPACES_FIELD ),\n QVectorSpace( 0 ) );\n \nend;\n\nAddUniversalMorphismIntoZeroObject( vecspaces, universal_morphism_into_zero_object );\n\n##\nuniversal_morphism_into_zero_object_with_given_zero_object := function( source, terminal_object )\n \n return QVectorSpaceMorphism( source,\n HomalgZeroMatrix( Dimension( source ), 0, VECTORSPACES_FIELD ),\n terminal_object );\n \nend;\n\nAddUniversalMorphismIntoZeroObjectWithGivenZeroObject( vecspaces, universal_morphism_into_zero_object_with_given_zero_object );\n\n##\nuniversal_morphism_from_zero_object := function( sink )\n \n return QVectorSpaceMorphism( QVectorSpace( 0 ),\n HomalgZeroMatrix( 0, Dimension( sink ), VECTORSPACES_FIELD ),\n sink );\n \nend;\n\nAddUniversalMorphismFromZeroObject( vecspaces, universal_morphism_from_zero_object );\n\n##\nuniversal_morphism_from_zero_object_with_given_zero_object := function( sink, initial_object )\n \n return QVectorSpaceMorphism( initial_object,\n HomalgZeroMatrix( 0, Dimension( sink ), VECTORSPACES_FIELD ),\n sink );\n \nend;\n\nAddUniversalMorphismFromZeroObjectWithGivenZeroObject( vecspaces, universal_morphism_from_zero_object_with_given_zero_object );\n\n##\naddition_for_morphisms := function( a, b )\n \n return QVectorSpaceMorphism( Source( a ),\n UnderlyingMatrix( a ) + UnderlyingMatrix( b ),\n Range( a ) );\n \nend;\n\nAddAdditionForMorphisms( vecspaces, addition_for_morphisms );\n\n##\nadditive_inverse_for_morphisms := function( a )\n \n return QVectorSpaceMorphism( Source( a ),\n - UnderlyingMatrix( a ),\n Range( a ) );\n \nend;\n\nAddAdditiveInverseForMorphisms( vecspaces, additive_inverse_for_morphisms );\n\n##\ndirect_sum := function( object_product_list )\n local dim;\n \n dim := Sum( List( object_product_list, c -> Dimension( c ) ) );\n \n return QVectorSpace( dim );\n \nend;\n\nAddDirectSum( vecspaces, direct_sum );\n\n##\ninjection_of_cofactor_of_direct_sum := function( object_product_list, injection_number )\n local components, dim, dim_pre, dim_post, dim_cofactor, coproduct, number_of_objects, injection_of_cofactor;\n \n components := object_product_list;\n \n number_of_objects := Length( components );\n \n dim := Sum( components, c -> Dimension( c ) );\n \n dim_pre := Sum( components{ [ 1 .. injection_number - 1 ] }, c -> Dimension( c ) );\n \n dim_post := Sum( components{ [ injection_number + 1 .. number_of_objects ] }, c -> Dimension( c ) );\n \n dim_cofactor := Dimension( object_product_list[ injection_number ] );\n \n coproduct := QVectorSpace( dim );\n \n injection_of_cofactor := HomalgZeroMatrix( dim_cofactor, dim_pre ,VECTORSPACES_FIELD );\n \n injection_of_cofactor := UnionOfColumns( injection_of_cofactor, \n HomalgIdentityMatrix( dim_cofactor, VECTORSPACES_FIELD ) );\n \n injection_of_cofactor := UnionOfColumns( injection_of_cofactor, \n HomalgZeroMatrix( dim_cofactor, dim_post, VECTORSPACES_FIELD ) );\n \n return QVectorSpaceMorphism( object_product_list[ injection_number ], injection_of_cofactor, coproduct );\n \nend;\n\nAddInjectionOfCofactorOfDirectSum( vecspaces, injection_of_cofactor_of_direct_sum );\n\n##\nuniversal_morphism_from_direct_sum := function( diagram, sink )\n local dim, coproduct, components, universal_morphism, morphism;\n \n components := sink;\n \n dim := Sum( components, c -> Dimension( Source( c ) ) );\n \n coproduct := QVectorSpace( dim );\n \n universal_morphism := UnderlyingMatrix( sink[1] );\n \n for morphism in components{ [ 2 .. Length( components ) ] } do\n \n universal_morphism := UnionOfRows( universal_morphism, UnderlyingMatrix( morphism ) );\n \n od;\n \n return QVectorSpaceMorphism( coproduct, universal_morphism, Range( sink[1] ) );\n \nend;\n\nAddUniversalMorphismFromDirectSum( vecspaces, universal_morphism_from_direct_sum );\n\n##\nprojection_in_factor_of_direct_sum := function( object_product_list, projection_number )\n local components, dim, dim_pre, dim_post, dim_factor, direct_product, number_of_objects, projection_in_factor;\n \n components := object_product_list;\n \n number_of_objects := Length( components );\n \n dim := Sum( components, c -> Dimension( c ) );\n \n dim_pre := Sum( components{ [ 1 .. projection_number - 1 ] }, c -> Dimension( c ) );\n \n dim_post := Sum( components{ [ projection_number + 1 .. number_of_objects ] }, c -> Dimension( c ) );\n \n dim_factor := Dimension( object_product_list[ projection_number ] );\n \n direct_product := QVectorSpace( dim );\n \n projection_in_factor := HomalgZeroMatrix( dim_pre, dim_factor, VECTORSPACES_FIELD );\n \n projection_in_factor := UnionOfRows( projection_in_factor, \n HomalgIdentityMatrix( dim_factor, VECTORSPACES_FIELD ) );\n \n projection_in_factor := UnionOfRows( projection_in_factor, \n HomalgZeroMatrix( dim_post, dim_factor, VECTORSPACES_FIELD ) );\n \n return QVectorSpaceMorphism( direct_product, projection_in_factor, object_product_list[ projection_number ] );\n \nend;\n\nAddProjectionInFactorOfDirectSum( vecspaces, projection_in_factor_of_direct_sum );\n\n##\nuniversal_morphism_into_direct_sum := function( diagram, sink )\n local dim, direct_product, components, universal_morphism, morphism;\n \n components := sink;\n \n dim := Sum( components, c -> Dimension( Range( c ) ) );\n \n direct_product := QVectorSpace( dim );\n \n universal_morphism := UnderlyingMatrix( sink[1] );\n \n for morphism in components{ [ 2 .. Length( components ) ] } do\n \n universal_morphism := UnionOfColumns( universal_morphism, UnderlyingMatrix( morphism ) );\n \n od;\n \n return QVectorSpaceMorphism( Source( sink[1] ), universal_morphism, direct_product );\n \nend;\n\nAddUniversalMorphismIntoDirectSum( vecspaces, universal_morphism_into_direct_sum );\n\n#################################\n##\n## Finalize category\n##\n#################################\n\nFinalize( vecspaces );\n\n#################################\n##\n## Test the basic operations\n##\n#################################\n\n# Creating objects and morphisms\n\nV := QVectorSpace( 2 );\n\nCapCategory( V );\n\nDimension( V );\n\nW := QVectorSpace( 3 );\n\nalpha := QVectorSpaceMorphism( V, [ [ 1, 1, 1 ], [ -1, -1, -1 ] ], W );\n\nCapCategory( alpha );\n\nUnderlyingMatrix( alpha );\n\n# Testing the KernelEmbedding\n\nKernelEmbedding( alpha );\n\nKernelObject( alpha );\n\n# Computing an intersection\n\nM1 := QVectorSpace( 2 );\n\nM2 := QVectorSpace( 2 );\n\nN := QVectorSpace( 3 );\n\niota1 := QVectorSpaceMorphism( M1, [ [ 1, 0, 0 ], [ 0, 1, 1 ] ], N );\n\nIsMonomorphism( iota1 );\n\niota2 := QVectorSpaceMorphism( M2, [ [ 1, 1, 0 ], [ 0, 0, 1 ] ], N );\n\nIsMonomorphism( iota2 );\n\npi1 := ProjectionInFactorOfDirectSum( [ M1, M2 ], 1 );\n\npi2 := ProjectionInFactorOfDirectSum( [ M1, M2 ], 2 );\n\nlambda := PostCompose( iota1, pi1 );\n\nphi := lambda - PostCompose( iota2, pi2 );\n\nkappa := KernelEmbedding( phi );\n\nPostCompose( lambda, kappa );\n\nPreCompose( ProjectionInFactorOfFiberProduct( [ iota1, iota2 ], 1 ), iota1 );\n\n#################################\n##\n## A function for computing homology\n##\n#################################\n\nHomologyObject := function( alpha, beta )\n local iota, lambda;\n \n if not IsZero( PreCompose( alpha, beta ) ) then\n \n Error( \"the composition of the given morphisms has to be zero\" );\n \n fi;\n \n iota := ImageEmbedding( alpha );\n \n lambda := KernelLift( beta, iota );\n \n return CokernelObject( lambda );\n \nend;\n\nHomologyObject( alpha, CokernelProjection( alpha ) );\n\nHomologyObject( KernelEmbedding( alpha ), alpha );\n\npi1 := ProjectionInFactorOfDirectSum( [ V, V, V ], 1 );\n\niota1 := InjectionOfCofactorOfDirectSum( [ V, V, V ], 1 );\n\npi2 := ProjectionInFactorOfDirectSum( [ V, V, V ], 2 );\n\niota2 := InjectionOfCofactorOfDirectSum( [ V, V, V ], 2 );\n\nHomologyObject( PreCompose( pi1, iota1 ), PreCompose( pi2, iota2 ) );\n", "meta": {"hexsha": "0790bea6364832e223eda3b56f4657cb72aea081", "size": 15076, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "materials/session01/HandsOn.gi", "max_stars_repo_name": "homalg-project/capdays-2018", "max_stars_repo_head_hexsha": "248f9cd583970d2b345971f41407812ef4dba407", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "materials/session01/HandsOn.gi", "max_issues_repo_name": "homalg-project/capdays-2018", "max_issues_repo_head_hexsha": "248f9cd583970d2b345971f41407812ef4dba407", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "materials/session01/HandsOn.gi", "max_forks_repo_name": "homalg-project/capdays-2018", "max_forks_repo_head_hexsha": "248f9cd583970d2b345971f41407812ef4dba407", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.5093062606, "max_line_length": 127, "alphanum_fraction": 0.6222472804, "num_tokens": 3503, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8976952975813454, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.7049678157026223}} {"text": "cube := Group([(2, 3, 4, 5), (1, 2, 6, 4)]);\n\nPrint(\"Order(cube) = \", Order(cube), \"\\n\");\n\nPrint(\"Size(Orbit(cube, 1)) = \", Size(Orbit(cube, 1)), \"\\n\");\n\nstab := Stabilizer(cube, 1);\n\nPrint(\"IsCyclic(stab) = \", IsCyclic(stab), \"\\n\");\n\nPrint(\"Order(stab) = \", Order(stab), \"\\n\");", "meta": {"hexsha": "63b0d1ea130fc800c2f51335f601016dad06b599", "size": 278, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "code/Orbit-Stabilizer.gap", "max_stars_repo_name": "fifth-postulate/group-theory-with-gap", "max_stars_repo_head_hexsha": "284d4648a982cee696ffe7cb1e31c6942f1d3929", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "code/Orbit-Stabilizer.gap", "max_issues_repo_name": "fifth-postulate/group-theory-with-gap", "max_issues_repo_head_hexsha": "284d4648a982cee696ffe7cb1e31c6942f1d3929", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code/Orbit-Stabilizer.gap", "max_forks_repo_name": "fifth-postulate/group-theory-with-gap", "max_forks_repo_head_hexsha": "284d4648a982cee696ffe7cb1e31c6942f1d3929", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2727272727, "max_line_length": 61, "alphanum_fraction": 0.5323741007, "num_tokens": 110, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9353465170505205, "lm_q2_score": 0.7490872187162397, "lm_q1q2_score": 0.7006561209932963}}