File size: 168,668 Bytes
803451e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | {"text": "a := [85, 88, 75, 66, 25, 29, 83, 39, 97];\nb := [68, 41, 10, 49, 16, 65, 32, 92, 28, 98];\n\n# Compute a decimal approximation of a rational\nApprox := function(x, d)\n\tlocal neg, a, b, n, m, s;\n\tif x < 0 then\n\t\tx := -x;\n\t\tneg := true;\n\telse\n\t\tneg := false;\n\tfi;\n\ta := NumeratorRat(x);\n\tb := DenominatorRat(x);\n\tn := QuoInt(a, b);\n\ta := RemInt(a, b);\n\tm := 10^d;\n\ts := \"\";\n\tif neg then\n\t\tAppend(s, \"-\");\n\tfi;\n\tAppend(s, String(n));\n\tn := Size(s) + 1;\n\tAppend(s, String(m + QuoInt(a*m, b)));\n\ts[n] := '.';\n\treturn s;\nend;\n\nPermTest := function(a, b)\n\tlocal c, d, p, q, u, v, m, n, k, diff, all;\n\tp := Size(a);\n\tq := Size(b);\n\tv := Concatenation(a, b);\n\tn := p + q;\n\tm := Binomial(n, p);\n\tdiff := Sum(a)/p - Sum(b)/q;\n\tall := [1 .. n];\n\tk := 0;\n\tfor u in Combinations(all, p) do\n\t\tc := List(u, i -> v[i]);\n\t\td := List(Difference(all, u), i -> v[i]);\n\t\tif Sum(c)/p - Sum(d)/q > diff then\n\t\t\tk := k + 1;\n\t\tfi;\n\tod;\n\treturn [Approx((1 - k/m)*100, 3), Approx(k/m*100, 3)];\nend;\n\n# in order, % less or greater than original diff\nPermTest(a, b);\n[ \"87.197\", \"12.802\" ]\n", "meta": {"hexsha": "e750e7b37c6f5331463a98326b0111b507bd8d0b", "size": 1057, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Permutation-test/GAP/permutation-test.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/Permutation-test/GAP/permutation-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/Permutation-test/GAP/permutation-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.3269230769, "max_line_length": 55, "alphanum_fraction": 0.5108798486, "num_tokens": 425, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278726384089, "lm_q2_score": 0.7905303112671295, "lm_q1q2_score": 0.6975859808276323}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\nClass(MD_PRDFT, TaggedNonTerminal, rec(\n abbrevs := [ (dims) -> Checked(IsList(dims), ForAll(dims, IsPosIntSym), [dims, 1]), \n (dims,rot) -> Checked(IsList(dims), ForAll(dims, IsPosIntSym), IsIntSym(rot), [dims, rot]) \n ], \n \n terminate := self >> let(\n n := self.params[1], rot := self.params[2], \n n0 := DropLast(n, 1),\n lst := Last(n), \n res := RC(Tensor(MDDFT(n0), I(Rows(PRDFT(lst))/2))) * Tensor(I(Product(n0)), PRDFT(lst, rot)),\n When(self.transposed, res.transpose(), res)),\n\n toAMat := self >> self.terminate().toAMat(), \n\n isReal := True,\n\n normalizedArithCost := self >> let(n := Product(self.params[1]), \n IntDouble(2.5 * n * d_log(n) / d_log(2))),\n\n hashAs := self >> let(t:=ObjId(self)(self.params[1], 1).withTags(self.getTags()),\n When(self.transposed, t.transpose(), t)),\n\n dims := self >> let(\n n := self.params[1], \n n0 := DropLast(n, 1),\n lst := Last(n), \n d := [ Product(n0) * 2*(idiv(lst,2)+1), Product(n)], \n When(self.transposed, Reversed(d), d)),\n\n omega := (N,k,r,c) -> E(N)^(k*r*c),\n));\n\n\nNewRulesFor(MD_PRDFT, rec(\n MD_PRDFT_Base := rec(\n applicable := t -> true,\n freedoms := t -> [],\n child := (t, fr) -> let(\n n := t.params[1], rot := t.params[2], \n n0 := DropLast(n, 1),\n lst := Last(n), \n RC(\n GT(MDDFT(n0), GTVec, GTVec, [Rows(PRDFT(lst))/2]).withTags(t.getTags())\n ) *\n GT(PRDFT(lst, rot), GTPar, GTPar, [Product(n0)]).withTags(t.getTags())\n ),\n apply := (self, t, C, Nonterms) >> C[1]\n )\n));\n\n# tst := vec -> let(n := Length(vec), dim := Sqrt(n), cols := 2*(Int(dim/2)+1),\n# out := TransposedMat(MatSPL(MD_PRDFT([dim,dim], 1)) * TransposedMat([vec]))[1],\n# outmat := List([0..dim-1], x->out{[1 + x*cols .. cols + x * cols]}),\n# PrintMat(outmat),\n# outmat);\n\n# ctst := vec -> let(n := Length(vec), dim := Sqrt(n), \n# out := TransposedMat(MatSPL(MDDFT([dim,dim], 1)) * TransposedMat([vec]))[1],\n# outmat := List([0..dim-1], x->out{[1 + x*dim .. dim + x * dim]}),\n# PrintMat((outmat)),\n# outmat);\n\n# CX = X * RE\n# X^-1 = RE * CX^-1\n", "meta": {"hexsha": "2c1febc6a95553f7f6dc58df1ac77946d670d2b9", "size": 2333, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/realdft/multidim.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/realdft/multidim.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/realdft/multidim.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.8115942029, "max_line_length": 108, "alphanum_fraction": 0.5109301329, "num_tokens": 765, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467675095292, "lm_q2_score": 0.7931059585194573, "lm_q1q2_score": 0.6972565397249277}}
{"text": "# Matrix exponentiation is built-in\nA := [[0 , 1], [1, 1]];\nPrintArray(A);\n# [ [ 0, 1 ],\n# [ 1, 1 ] ]\nPrintArray(A^10);\n# [ [ 34, 55 ],\n# [ 55, 89 ] ]\n", "meta": {"hexsha": "af666d2939560c7e703ec2c0b941ee9b95856631", "size": 171, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Matrix-exponentiation-operator/GAP/matrix-exponentiation-operator.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-exponentiation-operator/GAP/matrix-exponentiation-operator.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-exponentiation-operator/GAP/matrix-exponentiation-operator.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.0, "max_line_length": 35, "alphanum_fraction": 0.4093567251, "num_tokens": 80, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032942119105695, "lm_q2_score": 0.7718435083355187, "lm_q1q2_score": 0.6972017735802215}}
{"text": "\n#\n# Read(\"~/Workspace/groupsSB/epi/A2/testRootGroup.gi\");\n#\n\ntype:=\"A\";\nrank:=2;\nnr_pos_roots:=3;\n\nL:= SimpleLieAlgebra(type,rank,Rationals);\ncb0:=CanonicalBasis(L);\nV:= HighestWeightModule( L, highest_weight );\nextA:=List([1..Dimension(V)],i->ExteriorPowerOfAlgebraModule( V, i ));\nextA_basis:=List(extA,i->Basis(i));\n\n#\n# change basis order of first exteriror power to match chevalley basis order\n#\nb:=extA_basis[1];\n#SetBasis(extA[1],bbb);\n#extA_basis[1]:=Basis(extA[1]);\n#extA_basis[1]:=\n#b:=[\n# b[7],\n# b[6],\n# b[8], # alpha + beta\n# b[3],\n# b[2],\n# b[1],\n# b[5],\n# b[4],\n# ];\n\n#plist:=[7,6,8,3,2,1,5,4];\nplist:=[3,2,1,6,7,8,4,5];\nbbb:=b{plist};\napply_plist:=function(mat)\n local result;\n result:=List(mat,i->i{plist});\n result:=TransposedMat(result);\n result:=List(result,i->i{plist});\n result:=TransposedMat(result);\n return result;\nend;\n\nsemne:=DiagonalMat([1,-1,1,-1, 1,1,-1,1]);\napply_signs:=function(mat)\n local result;\n result := semne*mat*semne;\n return result;\nend;\n\next1e:=function(e)\n\tlocal extb,result,v;\n extb:=extA_basis[1];\n\n\tresult:=[];\n\tfor v in extb do\n\t\tAppend(result,[Coefficients(extb,e^v)]);\n\tod;\n\tresult:=TransposedMat(result);\n\treturn result;\nend;\n\nade:=function(e)\n\tlocal result,v;\n\tresult:=[];\n\tfor v in cb0 do\n\t\tAppend(result,[Coefficients(cb0,e*v)]);\n\tod;\n\tresult:=TransposedMat(result);\n\treturn result;\nend;\n\n\next1_root_group:=function(index,t)\n\tlocal ee,tmp,result,i;\n\tee:=ext1e(cb0[index]);\n\ttmp:=ee;\n\tresult:=tmp^0;\n\ti:=1;\n\twhile Length(Set(Concatenation(tmp)))<>1 do\n\t\tresult:=result+t^i*tmp/Factorial(i);\n\t\ti:=i+1;\n\t\ttmp:=tmp*ee;\n\tod;\n\treturn result;\nend;\n\nad_root_group:=function(index,t)\n\tlocal ee,tmp,result,i;\n\tee:=ade(cb0[index]);\n\ttmp:=ee;\n\tresult:=tmp^0;\n\ti:=1;\n\twhile Length(Set(Concatenation(tmp)))<>1 do\n\t\tresult:=result+t^i*tmp/Factorial(i);\n\t\ti:=i+1;\n\t\ttmp:=tmp*ee;\n\tod;\n\treturn result;\nend;\n\n\n#\n# Test:\n#\n\n# ade1\nyyy:=ext1e(cb0[1]);\nyyy:=apply_plist(yyy);\nyyy:=apply_signs(yyy);\nxxx:=ade0(cb0[1]);\nDisplay(yyy);\nDisplay(xxx);\nDisplay(xxx=yyy);\n\n# root group 1\nyyy:=ext1_root_group(1,1);\nyyy:=apply_plist(yyy);\nyyy:=apply_signs(yyy);\nxxx:=ad_root_group(1,1);\nDisplay(yyy);\nDisplay(xxx);\nDisplay(xxx=yyy);\n\n# ade2 --------------------> Distinct\nyyy:=ext1e(cb0[2]);\nyyy:=apply_plist(yyy);\nyyy:=apply_signs(yyy);\nxxx:=ade0(cb0[2]);\nDisplay(yyy);\nDisplay(xxx);\nDisplay(xxx=yyy);\n\n# root group 2 --------------------> Distinct\nyyy:=ext1_root_group(2,1);\nyyy:=apply_plist(yyy);\nyyy:=apply_signs(yyy);\nxxx:=ad_root_group(2,1);\nDisplay(yyy);\nDisplay(xxx);\nDisplay(xxx=yyy);\n", "meta": {"hexsha": "d364dbfac59408615b484af82458d0f7a8cfd1c3", "size": 2577, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "epi/A2/testRootGroup.gi", "max_stars_repo_name": "iuliansimion/groupsSB", "max_stars_repo_head_hexsha": "db7494e81bb03f76c20fa181e358ba1cc2d28975", "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": "epi/A2/testRootGroup.gi", "max_issues_repo_name": "iuliansimion/groupsSB", "max_issues_repo_head_hexsha": "db7494e81bb03f76c20fa181e358ba1cc2d28975", "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": "epi/A2/testRootGroup.gi", "max_forks_repo_name": "iuliansimion/groupsSB", "max_forks_repo_head_hexsha": "db7494e81bb03f76c20fa181e358ba1cc2d28975", "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": 17.8958333333, "max_line_length": 76, "alphanum_fraction": 0.6422196352, "num_tokens": 892, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467738423873, "lm_q2_score": 0.7879311906630568, "lm_q1q2_score": 0.6927071642812174}}
{"text": "doors := function(n)\n local a,j,s;\n a := [ ];\n for j in [1 .. n] do\n a[j] := 0;\n od;\n for s in [1 .. n] do\n j := s;\n while j <= n do\n a[j] := 1 - a[j];\n j := j + s;\n od;\n od;\n return Filtered([1 .. n], j -> a[j] = 1);\nend;\n\ndoors(100);\n# [ 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 ]\n", "meta": {"hexsha": "3f41419f00b962260764cd9efc114688160be8d3", "size": 308, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/100-doors/GAP/100-doors.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/100-doors/GAP/100-doors.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/100-doors/GAP/100-doors.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.2105263158, "max_line_length": 43, "alphanum_fraction": 0.3896103896, "num_tokens": 141, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297807787537, "lm_q2_score": 0.76908023177796, "lm_q1q2_score": 0.6925796525242794}}
{"text": "# our deficient list\nL :=\n[ \"ABCD\", \"CABD\", \"ACDB\", \"DACB\", \"BCDA\",\n \"ACBD\", \"ADCB\", \"CDAB\", \"DABC\", \"BCAD\",\n \"CADB\", \"CDBA\", \"CBAD\", \"ABDC\", \"ADBC\",\n \"BDCA\", \"DCBA\", \"BACD\", \"BADC\", \"BDAC\",\n \"CBDA\", \"DBCA\", \"DCAB\" ];\n\n# convert L to permutations on 1..4\nu := List(L, s -> List([1..4], i -> Position(\"ABCD\", s[i])));\n\n# set difference (with all permutations)\nv := Difference(PermutationsList([1..4]), u);\n\n# convert back to letters\ns := \"ABCD\";\nList(v, p -> List(p, i -> s[i]));\n", "meta": {"hexsha": "d9dd0d5d782b8d5076efc24b8ef58bc2546d70e9", "size": 483, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Find-the-missing-permutation/GAP/find-the-missing-permutation.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/Find-the-missing-permutation/GAP/find-the-missing-permutation.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/Find-the-missing-permutation/GAP/find-the-missing-permutation.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.8333333333, "max_line_length": 61, "alphanum_fraction": 0.5465838509, "num_tokens": 190, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467675095294, "lm_q2_score": 0.785308580887758, "lm_q1q2_score": 0.6904015003849682}}
{"text": "# We keep only primitive pythagorean triples\npyth := n ->\n Filtered(Cartesian([1 .. n], [1 .. n], [1 .. n]),\n u -> u[3]^2 = u[1]^2 + u[2]^2 and u[1] < u[2]\n and GcdInt(u[1], u[2]) = 1);\n\npyth(100);\n# [ [ 3, 4, 5 ], [ 5, 12, 13 ], [ 7, 24, 25 ], [ 8, 15, 17 ], [ 9, 40, 41 ], [ 11, 60, 61 ], [ 12, 35, 37 ],\n# [ 13, 84, 85 ], [ 16, 63, 65 ], [ 20, 21, 29 ], [ 28, 45, 53 ], [ 33, 56, 65 ], [ 36, 77, 85 ], [ 39, 80, 89 ],\n# [ 48, 55, 73 ], [ 65, 72, 97 ] ]\n", "meta": {"hexsha": "d02cd6d0319459d17f93d6c9fe6382390df9f8f7", "size": 463, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/List-comprehensions/GAP/list-comprehensions.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/List-comprehensions/GAP/list-comprehensions.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/List-comprehensions/GAP/list-comprehensions.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": 42.0909090909, "max_line_length": 115, "alphanum_fraction": 0.4146868251, "num_tokens": 255, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.942506716354847, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.6861217388105905}}
{"text": "v := [1 .. 8];\n\nSum(v);\n# 36\n\nProduct(v);\n# 40320\n\n# You can sum or multiply the result of a function\n\nSum(v, n -> n^2);\n# 204\n\nProduct(v, n -> 1/n);\n# 1/40320\n", "meta": {"hexsha": "34231e703dcfaa5f2deb35619e433a8066f6eafa", "size": 160, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Sum-and-product-of-an-array/GAP/sum-and-product-of-an-array.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-and-product-of-an-array/GAP/sum-and-product-of-an-array.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-and-product-of-an-array/GAP/sum-and-product-of-an-array.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": 10.0, "max_line_length": 50, "alphanum_fraction": 0.55, "num_tokens": 64, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.914900950352329, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.6853406134250993}}
{"text": "\n## Copyright (c) 2018-2021, Carnegie Mellon University\n## See LICENSE for details\n\n# We are interested to see if\n# IMDPRDFT(l)*MDPRDFT(l) = Product(l)*MatSPL(Product(l));\n# because we want to see if we can recover the original REAL data.\n\nDeclare(MDPRDFT);\nDeclare(IMDPRDFT);\n\n# Same as (floor(n_t/2)+1)*2.\n# RClength := (n) -> (n + 1) mod 2 + n + 1;\nRClength := (n) -> PRDFT1(n).dims()[1];\n\nIJmatrix := (n) -> DirectSum(I(1), J(n-1));\n\ntensorIJmatrix := (l) -> When(Length(l) > 0,\n Tensor(IJmatrix(l[1]), tensorIJmatrix(Drop(l, 1))),\n Diag([1, -1]));\n\n#F MDPRDFT(<dims>, [<exp>]) - multi-dimensional PRDFT non-terminal\n#F dims = [ <n_1>,.., <n_t> ] list of (positive) dimensions\n#F exp = root of unity exponent scaling (see DFT for exact definition)\n#F\n#F Definition : multidimensional matrix of size M x N, where\n#F M = n_1*...*n_{t-1}*(floor(n_t/2)+1)*2\n#F N = n_1*..*n_t\n#F This matrix has real components, for an operator with\n#F N real inputs,\n#F M real outputs for interleaved real and imaginary components.\n#F\n#F Example (direct) : MDPRDFT([2,4,4])\n#F Example (inverse) : MDPRDFT([2,4,4], -1)\n#F\n#F In last dimension, t: real-to-complex DFT;\n#F then dimensions t-1, ..., 1: complex-to-complex DFT.\n#F\n\n# To verify that components of m are real:\n# Im(MatSPL(m)) = MatSPL(ApplyFunc(O, m.dims()));\n\nClass(MDPRDFT, TaggedNonTerminal, rec(\n a_lengths := self >> self.params[1],\n a_exp := self >> self.params[2],\n\n # Components of self.a_lengths() that are equal to 1 are removed.\n abbrevs := [\n P -> Checked(IsList(P),\n ForAll(P, IsPosInt),\n Product(P) > 1,\n [ RemoveOnes(P), 1 ]),\n (P,k) -> Checked(IsList(P),\n ForAll(P, IsPosInt),\n IsInt(k),\n Product(P) > 1,\n Gcd(Product(P), k) = 1,\n [ RemoveOnes(P), k mod Product(P) ])\n ],\n\n # dims() has 2 components, counting outputs and inputs:\n # dims()[1] is product of all but last dimension, and RClength on last.\n # dims()[2] is product of all dimensions given.\n dims := self >> let(a_lengths := self.a_lengths(),\n [Product(DropLast(a_lengths, 1)) *\n RClength(Last(a_lengths)),\n Product(a_lengths)\n ]),\n\nterminate := self >> let(\n a_lengths := self.a_lengths(),\n Ninputs := self.dims()[2], # number of scalar inputs\n Nlast := Last(a_lengths), # length of last dimension\n Nrest := DropLast(a_lengths, 1), # all dimension lengths but last\n rcNlast := RClength(Nlast),\n # interleave has a 2x1 matrix [1; 0] along diagonal for each input;\n # it is a block-diagonal matrix of size (2*Ninputs) x Ninputs\n # that takes real inputs and puts a 0 between each.\n interleave := Scat(fTensor(fId(Ninputs), fBase(2,0))),\n # Here we are defining mddft as multi-dimensional DFT that takes\n # input as interleaved real and imaginary data,\n # output as interleaved real and imaginary data.\n mddft := RC(ApplyFunc(MDDFT, self.params)),\n # gath is block-diagonal matrix consisting of Product(Nrest) blocks\n # of size rcNlast x (2*Nlast), so it has\n # input as Product(Nrest) blocks of length 2*Nlast,\n # output as Product(Nrest) blocks of length rcNlast.\n f := fAdd(2*Nlast, rcNlast, 0), # pad length rcNlast to 2*Nlast\n # could also set f := HStack(I(rcNlast), O(rcNlast, 2*Nlast-rcNlast))\n ff := fTensor(List(Nrest, N -> fId(N)), f),\n # could also set ff := Tensor(List(Nrest, N->I(N)), f), no Gath needed.\n gath := Gath(ff),\n # 1. interleave: take real input, put a 0 after each element.\n # 2. mddft: multi-dimensional DFT, interleaved complex input & output.\n # 3. gath: in last dimension, keep only rcNlast of the 2*Nlast components.\n mdprdft := gath * mddft * interleave,\n mdprdft), \n \n transpose := self >> IMDPRDFT(self.a_lengths(), -self.a_exp()),\n\n isReal := True,\n\n normalizedArithCost := (self) >> let(n := Product(self.a_lengths()),\n IntDouble(2 * n * d_log(n) / d_log(2)) )\n));\n\n\n# Conjugate in interleaved form: (a, b) maps to (a, -b).\n# That's multiplication by matrix [ [1, 0], [0, -1] ].\n# That's fBase(2, 0) above -fBase(2, 1).\n# Try adapting fId, replacing let(i := Ind(self.params[1]), Lambda(i,i)).\n# Or dLin or dOmega.\n\n#F IMDPRDFT(<dims>, [<exp>]) - multi-dimensional inverse PRDFT non-terminal\n#F dims = [ <n_1>,.., <n_t> ] list of (positive) dimensions\n#F exp = root of unity exponent scaling (see DFT for exact definition)\n#F\n#F Definition : multidimensional matrix of size N x M, where\n#F N = n_1*..*n_t\n#F M = n_1*...*n_{t-1}*(floor(n_t/2)+1)*2\n#F This matrix has real components, for an operator with\n#F M real inputs for interleaved real and imaginary components,\n#F N real outputs.\n#F\n#F Example (direct) : IMDPRDFT([2,4,4])\n#F Example (inverse) : IMDPRDFT([2,4,4], -1)\n#F\n#F In dimensions 1, .., t-1: complex-to-complex DFT;\n#F then in last dimension, t: complex-to-real DFT.\n#F\nClass(IMDPRDFT, TaggedNonTerminal, rec(\n a_lengths := self >> self.params[1],\n a_exp := self >> self.params[2],\n\n # Components of self.a_lengths() that are equal to 1 are removed.\n abbrevs := [\n P -> Checked(IsList(P),\n ForAll(P, IsPosInt),\n Product(P) > 1,\n [ RemoveOnes(P), 1 ]),\n (P,k) -> Checked(IsList(P),\n ForAll(P, IsPosInt),\n IsInt(k),\n Product(P) > 1,\n Gcd(Product(P), k) = 1,\n [ RemoveOnes(P), k mod Product(P) ])\n ],\n\n # dims() has 2 components, counting outputs and inputs:\n # dims()[1] is product of all dimensions given.\n # dims()[2] is product of all but last dimension, and RClength on last.\n dims := self >> let(a_lengths := self.a_lengths(),\n [Product(a_lengths),\n Product(DropLast(a_lengths, 1)) *\n RClength(Last(a_lengths))\n ]),\n\n terminate := self >> let(\n a_lengths := self.a_lengths(),\n Nlast := Last(a_lengths), # length of last dimension\n Nrest := DropLast(a_lengths, 1), # all dimension lengths but last\n rcNlast := RClength(Nlast),\n newcomplex := Nlast - rcNlast/2,\n Nallbutlast := Product(Nrest),\n shuffle := Tensor( L(Nallbutlast*rcNlast/2, rcNlast/2), I(2)),\n unshuffle := Tensor( L(Nallbutlast*Nlast, Nallbutlast), I(2)),\n # This is the basic conjugation matrix.\n flipper := tensorIJmatrix(Nrest),\n newrows := 2*newcomplex*Nallbutlast,\n nzeroleft := When(Nlast mod 2 = 0,\n Nallbutlast*(rcNlast - 2*newcomplex - 2),\n Nallbutlast*(rcNlast - 2*newcomplex)),\n hpart := When(newrows > 0,\n HStack(\n O(newrows, nzeroleft),\n Tensor(J(newcomplex), flipper),\n When(Nlast mod 2 = 0, O(newrows, 2*Nallbutlast), [ ])\n ),\n [ ]),\n stacker := VStack(I(rcNlast*Nallbutlast), hpart),\n # Here we are defining mddft as multi-dimensional DFT that takes\n # input as interleaved real and imaginary data,\n # output as interleaved real and imaginary data.\n imddft := RC(ApplyFunc(MDDFT, self.params)),\n # extract real has 1x2 matrix [1, 0] along diagonal for each input;\n # it is a block-diagonal matrix of size (2*Noutputs) x Noutputs\n # that extracts every other component of the input.\n extractreal := Gath(fTensor(List(a_lengths, N->fId(N)), fBase(2, 0))),\n extend := unshuffle * stacker * shuffle,\n # 1. extend: in last dimension, extend the rcNlast interleaved complex input to 2*Nlast.\n # 2. imddft: inverse multi-dimensional DFT, interleaved complex input & output.\n # 3. extractreal: return the real parts of interleaved complex data.\n imdprdft := extractreal * imddft * extend,\n imdprdft), \n \n transpose := self >> MDPRDFT(self.a_lengths(), -self.a_exp()),\n\n isReal := True,\n\n normalizedArithCost := (self) >> let(n := Product(self.a_lengths()),\n IntDouble(2 * n * d_log(n) / d_log(2)) )\n));\n", "meta": {"hexsha": "039a5c93f4fac6efe80a99f89e48d480c8dd97c6", "size": 8640, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "nonterms/mdprdft.gi", "max_stars_repo_name": "franzfranchetti/spiral-package-fftx", "max_stars_repo_head_hexsha": "3149606d3d60a9b50c225ec1e8450628d543698b", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-15T12:40:19.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-15T12:40:19.000Z", "max_issues_repo_path": "nonterms/mdprdft.gi", "max_issues_repo_name": "franzfranchetti/spiral-package-fftx", "max_issues_repo_head_hexsha": "3149606d3d60a9b50c225ec1e8450628d543698b", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 8, "max_issues_repo_issues_event_min_datetime": "2021-01-05T20:58:29.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-18T20:10:45.000Z", "max_forks_repo_path": "nonterms/mdprdft.gi", "max_forks_repo_name": "franzfranchetti/spiral-package-fftx", "max_forks_repo_head_hexsha": "3149606d3d60a9b50c225ec1e8450628d543698b", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2020-12-14T18:24:29.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-15T12:40:20.000Z", "avg_line_length": 42.5615763547, "max_line_length": 96, "alphanum_fraction": 0.568287037, "num_tokens": 2414, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9252299632771663, "lm_q2_score": 0.7371581741774411, "lm_q1q2_score": 0.6820408304236568}}
{"text": "Y := function(f)\n local u;\n u := x -> x(x);\n return u(y -> f(a -> y(y)(a)));\nend;\n\nfib := function(f)\n local u;\n u := function(n)\n if n < 2 then\n return n;\n else\n return f(n-1) + f(n-2);\n fi;\n end;\n return u;\nend;\n\nY(fib)(10);\n# 55\n\nfac := function(f)\n local u;\n u := function(n)\n if n < 2 then\n return 1;\n else\n return n*f(n-1);\n fi;\n end;\n return u;\nend;\n\nY(fac)(8);\n# 40320\n", "meta": {"hexsha": "317faa88d1c976d9811fc3f40d7c2ae63ec9851d", "size": 496, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Y-combinator/GAP/y-combinator.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/Y-combinator/GAP/y-combinator.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/Y-combinator/GAP/y-combinator.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": 13.7777777778, "max_line_length": 35, "alphanum_fraction": 0.4032258065, "num_tokens": 159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8824278788223264, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.6810962252121171}}
{"text": "# Function composition\nComposition := function(f, g)\n local h;\n h := function(x)\n return f(g(x));\n end;\n return h;\nend;\n\n# Apply each function in list u, to argument x\nApplyList := function(u, x)\n local i, n, v;\n n := Size(u);\n v := [ ];\n for i in [1 .. n] do\n v[i] := u[i](x);\n od;\n return v;\nend;\n\n# Inverse and Sqrt are in the built-in library. Note that GAP doesn't have real numbers nor floating point numbers. Therefore, Sqrt yields values in cyclotomic fields.\n# For example,\n# gap> Sqrt(7);\n# E(28)^3-E(28)^11-E(28)^15+E(28)^19-E(28)^23+E(28)^27\n# where E(n) is a primitive n-th root of unity\na := [ i -> i + 1, Inverse, Sqrt ];\n# [ function( i ) ... end, <Operation \"InverseImmutable\">, <Operation \"Sqrt\"> ]\nb := [ i -> i - 1, Inverse, x -> x*x ];\n# [ function( i ) ... end, <Operation \"InverseImmutable\">, function( x ) ... end ]\n\n# Compose each couple\nz := ListN(a, b, Composition);\n\n# Now a test\nApplyList(z, 3);\n[ 3, 3, 3 ]\n", "meta": {"hexsha": "22843d757dcbd33b4e30208875bbff6bf93c4680", "size": 959, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/First-class-functions/GAP/first-class-functions.gap", "max_stars_repo_name": "djgoku/RosettaCodeData", "max_stars_repo_head_hexsha": "91df62d46142e921b3eacdb52b0316c39ee236bc", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Task/First-class-functions/GAP/first-class-functions.gap", "max_issues_repo_name": "djgoku/RosettaCodeData", "max_issues_repo_head_hexsha": "91df62d46142e921b3eacdb52b0316c39ee236bc", "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/First-class-functions/GAP/first-class-functions.gap", "max_forks_repo_name": "djgoku/RosettaCodeData", "max_forks_repo_head_hexsha": "91df62d46142e921b3eacdb52b0316c39ee236bc", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.9189189189, "max_line_length": 167, "alphanum_fraction": 0.598540146, "num_tokens": 321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933093946927837, "lm_q2_score": 0.7606506526772884, "lm_q1q2_score": 0.6794963741158193}}
{"text": "#\n# Read(\"~/Workspace/groupsSB/epi/A2/adModule.gi\");\n#\n\ntype:=\"A\";\nrank:=2;\nnr_pos_roots:=3;\nL:= SimpleLieAlgebra(type,rank,Rationals);\ncb0:=CanonicalBasis(L);\n\nM:=AdjointModule(L);\nextM2:=ExteriorPowerOfAlgebraModule(M,2);\n\nade:=function(e)\n\tlocal mb,result,v;\n \n mb:=Basis(M);\n\n\tresult:=[];\n\tfor v in mb do\n\t\tAppend(result,[Coefficients(mb,e^v)]);\n\tod;\n\t#result:=TransposedMat(result);\n\treturn result;\nend;\n\nroot_group:=function(index,t)\n\tlocal e,tmp,result,i;\n\t\n e:=ade(cb0[index]);\n tmp:=ShallowCopy(e);\n\tresult:=tmp^0;\n\n\ti:=1;\n\twhile Length(Set(Concatenation(tmp)))<>1 do\n\t\tresult:=result+t^i*tmp/Factorial(i);\n\t\ti:=i+1;\n\t\ttmp:=tmp*e;\n\tod;\n\treturn result;\nend;\n\nad_nil_deg:=function(e)\n local ee,tmp;\n ee:=ade(e);\n tmp:=ShallowCopy(ee);\n i:=1;\n while Length(Set(Concatenation(tmp)))<>1 do;\n tmp:=tmp*ee;\n i:=i+1;\n od;\n return i;\nend;\n\nad_exp:=function(e,t,v)\n local result,ord_e,i,j,tmp;\n \n ord_e:=ad_nil_deg(e);\n\n result:=v;\n for i in [1..ord_e-1] do\n tmp:=ShallowCopy(v);\n for j in [1..i] do\n tmp:=e^tmp;\n od;\n result:=result+t^i*tmp/Factorial(i);\n od;\n return result;\nend;\n\ndiag_g:=function(e,wedge_sum)\n local fam_algmod,fam_wedge,o,result,new_wedge,i,bv,exp_term;\n fam_algmod:=FamilyObj(wedge_sum);\n o:=ExtRepOfObj(wedge_sum);\n fam_wedge:=FamilyObj(o);\n o:=ExtRepOfObj(o);\n\n result:=[];\n for i in [1,3..Length(o)-1] do\n new_wedge:=[];\n for bv in o[i] do\n exp_term:=ad_exp(e,1,bv);\n Add(new_wedge,exp_term);\n od;\n Add(result,new_wedge);\n Add(result,o[i+1]);\n od;\n\n result:=ObjByExtRep(fam_wedge,result);\n result:=ConvertToNormalFormMonomialElement(result);\n result:=ObjByExtRep(fam_algmod,result);\n \n return result;\nend;\n\nexp_action_mat_g:=function(e,M)\n local mb,v,result;\n mb:=Basis(M);\n\n result:=[];\n \tfor v in mb do\n\t\tAppend(result,[Coefficients(mb,e^v)]);\n\tod;\n\t#result:=TransposedMat(result);\n\treturn result;\nend;\n\nu1:=root_group(1,1);\n\nf:=LeftModuleHomomorphismByMatrix(Basis(M),u1,Basis(M));\ntest:=Image(f,Basis(M)[1]);\n\nbbb:=Basis(extM2);\ntmp:=ExtRepOfObj(ExtRepOfObj(bbb[1]));\ntmp:=ShallowCopy(tmp);\ntmp:=[[Image(f,tmp[1][1]),Image(f,tmp[1][2])],1];\n\nfam:=FamilyObj(ExtRepOfObj(bbb[1]));\ntmp:=ObjByExtRep(fam,tmp);\ntmp:=ConvertToNormalFormMonomialElement(tmp);\n\nfam2:=FamilyObj(bbb[1]);\ntmp:=ObjByExtRep(fam2,tmp);", "meta": {"hexsha": "0b48f5763f1fadd47768a924fd5922f30e43f49b", "size": 2445, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "epi/A2/adModule.gi", "max_stars_repo_name": "iuliansimion/groupsSB", "max_stars_repo_head_hexsha": "db7494e81bb03f76c20fa181e358ba1cc2d28975", "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": "epi/A2/adModule.gi", "max_issues_repo_name": "iuliansimion/groupsSB", "max_issues_repo_head_hexsha": "db7494e81bb03f76c20fa181e358ba1cc2d28975", "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": "epi/A2/adModule.gi", "max_forks_repo_name": "iuliansimion/groupsSB", "max_forks_repo_head_hexsha": "db7494e81bb03f76c20fa181e358ba1cc2d28975", "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": 19.8780487805, "max_line_length": 64, "alphanum_fraction": 0.6249488753, "num_tokens": 793, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797172476384, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.6771596211381192}}
{"text": "Filtered([2008 .. 2121], y -> WeekDay([25, 12, y]) = \"Sun\");\n# [ 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118 ]\n\n# A possible implementation of WeekDayAlt\n\ndays := [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"];;\n\nWeekDayAlt := function(args)\n local d, m, y, k;\n d := args[1];\n m := args[2];\n y := args[3];\n if m < 3 then\n m := m + 12;\n y := y - 1;\n fi;\n k := 1 + RemInt(d + QuoInt((m + 1)*26, 10) + y + QuoInt(y, 4)\n + 6*QuoInt(y, 100) + QuoInt(y, 400) + 5, 7);\n return days[k];\nend;\n\nFiltered([2008 .. 2121], y -> WeekDayAlt([25, 12, y]) = \"Sun\");\n# [ 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118 ]\n", "meta": {"hexsha": "16971bd0c86d9309a734efffab30c0567c764b02", "size": 751, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Day-of-the-week/GAP/day-of-the-week.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/Day-of-the-week/GAP/day-of-the-week.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/Day-of-the-week/GAP/day-of-the-week.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": 31.2916666667, "max_line_length": 106, "alphanum_fraction": 0.5272969374, "num_tokens": 360, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473879530491, "lm_q2_score": 0.7745833737577158, "lm_q1q2_score": 0.6757057828494037}}
{"text": "# Solution in '''RPN'''\ncheck := function(x, y, z)\n\tlocal r, c, s, i, j, k, a, b, p;\n\ti := 0;\n\tj := 0;\n\tk := 0;\n\ts := [ ];\n\tr := \"\";\n\tfor c in z do\n\t\tif c = 'x' then\n\t\t\ti := i + 1;\n\t\t\tk := k + 1;\n\t\t\ts[k] := x[i];\n\t\t\tAppend(r, String(x[i]));\n\t\telse\n\t\t\tj := j + 1;\n\t\t\tb := s[k];\n\t\t\tk := k - 1;\n\t\t\ta := s[k];\n\t\t\tp := y[j];\n\t\t\tr[Size(r) + 1] := p;\n\t\t\tif p = '+' then\n\t\t\t\ta := a + b;\n\t\t\telif p = '-' then\n\t\t\t\ta := a - b;\n\t\t\telif p = '*' then\n\t\t\t\ta := a * b;\n\t\t\telif p = '/' then\n\t\t\t\tif b = 0 then\n\t\t\t\t\tcontinue;\n\t\t\t\telse\n\t\t\t\t\ta := a / b;\n\t\t\t\tfi;\n\t\t\telse\n\t\t\t\treturn fail;\n\t\t\tfi;\n\t\t\ts[k] := a;\n\t\tfi;\n\tod;\n\tif s[1] = 24 then\n\t\treturn r;\n\telse\n\t\treturn fail;\n\tfi;\nend;\n\t\nPlayer24 := function(digits)\n\tlocal u, v, w, x, y, z, r;\n\tu := PermutationsList(digits);\n\tv := Tuples(\"+-*/\", 3);\n\tw := [\"xx*x*x*\", \"xx*xx**\", \"xxx**x*\", \"xxx*x**\", \"xxxx***\"];\n\tfor x in u do\n\t\tfor y in v do\n\t\t\tfor z in w do\n\t\t\t\tr := check(x, y, z);\n\t\t\t\tif r <> fail then\n\t\t\t\t\treturn r;\n\t\t\t\tfi;\n\t\t\tod;\n\t\tod;\n\tod;\n\treturn fail;\nend;\n\nPlayer24([1,2,7,7]);\n# \"77*1-2/\"\nPlayer24([9,8,7,6]);\n# \"68*97-/\"\nPlayer24([1,1,7,7]);\n# fail\n\n# Solutions with only one distinct digit are found only for 3, 4, 5, 6:\nPlayer24([3,3,3,3]);\n# \"33*3*3-\"\nPlayer24([4,4,4,4]);\n# \"44*4+4+\"\nPlayer24([5,5,5,5]);\n# \"55*55/-\"\nPlayer24([6,6,6,6]);\n# \"66*66+-\"\n\n# A tricky one:\nPlayer24([3,3,8,8]);\n\"8383/-/\"\n", "meta": {"hexsha": "ce34544bf66cd051bfa329de0f67d74717e805bf", "size": 1342, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/24-game-Solve/GAP/24-game-solve.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/24-game-Solve/GAP/24-game-solve.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/24-game-Solve/GAP/24-game-solve.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": 15.7882352941, "max_line_length": 71, "alphanum_fraction": 0.4456035768, "num_tokens": 573, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9416541626630935, "lm_q2_score": 0.7154239836484144, "lm_q1q2_score": 0.6736819722715424}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F DFT(<size>, [<exp>]) - Discrete Fourier Transform non-terminal\n#F gcd(size, exp) = 1\n#F Definition: (n x n)-matrix [ e^((2*pi*exp*i)*k*l/n) | k,l = 0...n-1 ],\n#F observe that canonical root e^(2*pi*i/n) is exponentiated to <exp>\n#F default exp=1,\n# i = sqrt(-1)\n#F Example, direct : DFT(8) ,\n#F inverse : DFT(8, -1)\n#F rotated : DFT(8, 3)\n#F\nClass(DFT_NonTerm, TaggedNonTerminal, rec(\n abbrevs := [\n (n) -> Checked(IsPosIntSym(n),\n [_unwrap(n), 1]),\n (n,k) -> Checked(IsPosIntSym(n), IsIntSym(k), AnySyms(n,k) or Gcd(_unwrap(n),_unwrap(k))=1,\n [_unwrap(n), When(AnySyms(n,k), k, k mod _unwrap(n))])\n ],\n\n hashAs := self >> ObjId(self)(self.params[1], 1).withTags(self.getTags()),\n\n dims := self >> When(self.isReal(), 2* [ self.params[1], self.params[1] ], [ self.params[1], self.params[1] ]),\n\n terminate := self >> let(N := self.params[1], K := self.params[2],\n t := List([0..N-1], r -> List([0..N-1], c -> E(4*N)^(K*self.omega4pow(r,c)))),\n When(self.isReal(), MatAMat(RC(Mat(t)).toAMat()), Mat(t))),\n\n isReal := self >> false,\n SmallRandom := () -> Random([2..16]),\n LargeRandom := () -> 2 ^ Random([6..15]),\n\n normalizedArithCost := self >> let(n := self.params[1],\n floor(5.0 * n * log(n) / log(2.0))),\n\n TType := T_Complex(TUnknown)\n));\n\nDeclare(DFT, DFT2, DFT3, DFT4);\n\nClass(DFT, DFT_NonTerm, rec(\n transpose := self >> DFT(self.params[1], self.params[2]).withTags(self.getTags()),\n conjTranspose := self >> DFT(self.params[1], -self.params[2]).withTags(self.getTags()),\n inverse := self >> self.conjTranspose(),\n omega4pow := (r,c) -> 4*r*c,\n printlatex := (self) >> Print(\" \\\\DFT_{\", self.params[1], \"} \")\n));\n\nDFT1 := DFT;\nIDFT := n -> DFT(n,-1);\n\n\nClass(DFT2, DFT_NonTerm, rec(\n abbrevs := [\n (n) -> Checked(IsPosIntSym(n),\n [_unwrap(n), 1]),\n (n,k) -> Checked(IsPosIntSym(n), IsIntSym(k), AnySyms(n,k) or Gcd(_unwrap(n),_unwrap(k))=1,\n [_unwrap(n), When(AnySyms(n,k), k, k mod (2*_unwrap(n)))]),\n ],\n\n transpose := self >> DFT3(self.params[1], self.params[2]).withTags(self.getTags()),\n conjTranspose := self >> DFT3(self.params[1], -self.params[2]).withTags(self.getTags()),\n inverse := self >> self.conjTranspose(),\n omega4pow := (r,c) -> 2*r*(2*c+1),\n));\n\nClass(DFT3, DFT_NonTerm, rec(\n abbrevs := [\n (n) -> Checked(IsPosIntSym(n),\n [_unwrap(n), 1]),\n (n,k) -> Checked(IsPosIntSym(n), IsIntSym(k), AnySyms(n,k) or Gcd(_unwrap(n),_unwrap(k))=1,\n [_unwrap(n), When(AnySyms(n,k), k, k mod (2*_unwrap(n)))]),\n ],\n\n transpose := self >> DFT2(self.params[1], self.params[2]).withTags(self.getTags()),\n conjTranspose := self >> DFT2(self.params[1], -self.params[2]).withTags(self.getTags()),\n inverse := self >> self.conjTranspose(),\n omega4pow := (r,c) -> (2*r+1)*2*c,\n));\n\nClass(DFT4, DFT_NonTerm, rec(\n abbrevs := [\n (n) -> Checked(IsPosIntSym(n),\n [_unwrap(n), 1]),\n (n,k) -> Checked(IsPosIntSym(n), IsIntSym(k), AnySyms(n,k) or Gcd(_unwrap(n),_unwrap(k))=1,\n [_unwrap(n), When(AnySyms(n,k), k, k mod (4*_unwrap(n)))]),\n ],\n\n transpose := self >> DFT4(self.params[1], self.params[2]).withTags(self.getTags()),\n conjTranspose := self >> DFT4(self.params[1], -self.params[2]).withTags(self.getTags()),\n inverse := self >> self.conjTranspose(),\n omega4pow := (r,c) -> (2*r+1)*(2*c+1),\n));\n\n\nparamFunc := function(i, m, f, n)\n local res;\n\n# res := List([0..m-1], e -> SubstBottomUp(Copy(f), i, g -> e));\n res := List([0..m-1], e -> f(e,m));\n res := diagDirsum(res);\n res := fCompose(res, fTensor(fBase(m, i), fId(n)));\n\n return res;\nend;\n\n#F -----------------------------------------------------------------------------\n#F Tw1(n, d)\n#F Tw1(n, d, k) : diagonal function for Cooley-Tukey FFT, namely\n#F <d> | <n> and\n#F Tw1(n, d, k) = direct_sum_(i = 1)^n/d diag(w_n^0, ..., w_n^(d-1)^i\n#F If the second version is used, w_n is replaced by w_n^k, gcd(<n>, <k>) = 1.\n#F\n#F -----------------------------------------------------------------------------\nTw1 := (n,d,k) -> Checked(\n IsPosIntSym(n), IsPosIntSym(d), IsIntSym(k),\n fCompose(dOmega(n,k),diagTensor(dLin(div(n,d), 1, 0, TInt), dLin(d, 1, 0, TInt))));\n\nTw2 := (n,d,k) -> Checked(\n IsPosIntSym(n), IsPosIntSym(d), IsIntSym(k),\n fCompose(dOmega(2*n,k),\n diagTensor(dLin(div(n,d), 2, 1, TInt), dLin(d, 1, 0, TInt))));\n\nTw3 := (n,d,k) -> Checked(\n IsPosIntSym(n), IsPosIntSym(d), IsIntSym(k),\n fCompose(dOmega(2*n,k),\n diagTensor(dLin(div(n,d), 1, 0, TInt), dLin(d, 2, 1, TInt))));\n\nTw4 := (n,d,k) -> Checked(\n IsPosIntSym(n), IsPosIntSym(d), IsIntSym(k),\n fCompose(dOmega(4*n,k),\n diagTensor(dLin(div(n,d), 2, 1, TInt), dLin(d, 2, 1, TInt))));\n\n# j-row, i-col\nClass(Twid, DiagFunc, rec(\n def := (N, n, rot, a, b, i) -> rec(size:=n),\n lambda := self >> let(\n N := self.params[1], n := self.size, rot := self.params[3],\n a := self.params[4], b := self.params[5], i := self.params[6],\n na := Numerator(a), nb := Numerator(b),\n da := Denominator(a), db := Denominator(b),\n j := Ind(n),\n Lambda(j, omega(N*da*db, rot*(i*da+na)*(j*db+nb)))),\n\n range := self >> TComplex,\n domain := self >> self.params[2]\n));\n\nClass(ScaledTwid, DiagFunc, rec(\n def := (N, n, k, a, b, i, scaling) -> rec(size:=n),\n lambda := self >> let(N:=self.params[1], n:=self.size, k:=self.params[3],\n a := self.params[4], b := self.params[5], i := self.params[6], scaling := self.params[7],\n na := Numerator(a), nb := Numerator(b),\n da := Denominator(a), db := Denominator(b),\n j := Ind(n),\n Lambda(j, scaling * omega(N*da*db, k*(i*da+na)*(j*db+nb)))),\n range := self >> TComplex\n));\n\n#F TC6(radix, iteration, exp) - diagonal generating function for Stockham algorithm\n#F\t\t\t\t\tgenerates the omega-matrix as described in Van Loin - radix 4 Stockham framework\n#F\t\t\t\t\tfirst parameter of dLin stands for the total dimension of returned function\nTC6 := (r, iter, exp) -> Checked(\n IsPosIntSym(r), IsInt(exp),\n\tfCompose(dOmegaPow(r^(iter+1), 1, exp), dLin(r^iter, 1, 0, TInt)));\n\n#F TC5(radix, iteration) - diagonal generating function for Stockham algorithm - generates a diagonal function\n#DP: IsInt(iter) can't be checked, because iter is calculated based on a free variable and not yet evaluated here\nTC5 := (r, iter) -> Checked(\n IsPosIntSym(r),\n diagDirsum(fConst(r^iter,1), fCompose(dOmega(r^(iter+1), 1), dLin(r^iter, 1, 0, TInt))));\n\n#F TC4(radix, iteration) - diagonal generating function for Stockham algorithm\n#F\t\t\t\t\tgenerates the omega-matrix as described in Van Loin - Stockham Autosort Network\nClass(TC4, DiagFunc, rec(\n abbrevs := [ (rdx, iter, exp) -> [rdx, iter, exp],\n\t (rdx, iter, exp) -> [rdx, iter, exp]],\n def := (rdx, iter, exp) -> rec(size := rdx^iter),\n\n lambda := self >> let(rdx:=self.params[1],\n\titer:=self.params[2], n:=rdx^(iter+1), i:=Ind(rdx^iter), exp:=self.params[3],\t#n = L (van Loin), i = L/rdx (van Loin)\n\tLambda(i, omega(n,i)^exp)),\n\n range := self >> TInt,\n));\n\n\nClass(Stockham_radix, DiagFunc, rec(\n gen := meth(self, rdx, j)\n\t\tlocal diag;\n\n if IsInt(rdx) and rdx=2 then\n\t\t\tdiag := diagDirsum(TC6(rdx, j, 0), TC6(rdx, j, 1));\n\t\telif rdx = 4 then\n\t\t\tdiag := diagDirsum(TC6(rdx, j, 0), TC6(rdx, j, 1), TC6(rdx, j, 2), TC6(rdx, j, 3));\n\t\telif rdx = 8 then\n\t\t\tdiag := diagDirsum(TC6(rdx, j, 0), TC6(rdx, j, 1), TC6(rdx, j, 2), TC6(rdx, j, 3), TC6(rdx, j, 4), TC6(rdx, j, 5), TC6(rdx, j, 6), TC6(rdx, j, 7));\n\t\telif rdx = 16 then\n\t\t\tdiag := diagDirsum(TC6(rdx, j, 0), TC6(rdx, j, 1), TC6(rdx, j, 2), TC6(rdx, j, 3), TC6(rdx, j, 4), TC6(rdx, j, 5), TC6(rdx, j, 6), TC6(rdx, j, 7),\n\t\t\t\t\t\t\t\tTC6(rdx, j, 8), TC6(rdx, j, 9), TC6(rdx, j, 10), TC6(rdx, j, 11), TC6(rdx, j, 12), TC6(rdx, j, 13), TC6(rdx, j, 14), TC6(rdx, j, 15));\n\t\telif rdx > 16 then\n Error(\"Radix > 16 not supported\");\n fi;\n\n return diag;\n end,\n\n extract := meth(self, list, elems)\n\t\tlocal i, lc, stride;\n\n\t\tlc := [];\n\t\tstride := Length(list)/elems;\n\n\t\tfor i in [0..elems-1] do\n\t\t\tlc[i+1] := list[1 + i*stride];\n\t\tod;\n\n\t\treturn lc;\n end,\n));\n\n\n#F TC2(size, radix, c, k) - diagonal generating function for Pease algorithm\n#F\n#F TC2 is (5) in Jeremy's Pease paper.\n#F\n#\n# Note: due to current limitations, Spiral is unable to evaluate the\n# dimensions of this function properly.\n#\n# example: TDiag(fPrecompute(TC(N, rdx, j, m)))\n#\nTC2 := (n, r, c, k) -> Checked(\n IsPosIntSym(n), IsPosIntSym(r), IsPosIntSym(k),\n fCompose(dOmega(n / r^c, k),\n\tdiagTensor(diagTensor(dLin(n/(r^(c+1)), 1, 0, TInt), fConst(r^c, 1)),\n\t\tdLin(r, 1, 0, TInt))));\n\t\n#F TC(size, radix, c, k) - diagonal generating function for Pease algorithm\n#F\n#F TC is (5) in Jeremy's Pease paper.\n#F\nClass(TC, DiagFunc, rec(\n abbrevs := [ (n, r, c) -> [n, r, c, 1],\n\t (n, r, c, k) -> [n, r, c, k]],\n def := (n, r, c, k) -> rec(size := n),\n lambda := self >> let(n:=self.params[1], r:=self.params[2],\n\tc:=self.params[3], k:=self.params[4], i:=Ind(n),\n\tLambda(i, omega(n/(r^c), k*idiv(i, r^(c+1)) * imod(i, r)))),\n \n domain := (self) >> self.params[1],\n range := self >> TComplex,\n));\n\n#F TCBase(size, radix, k) - diagonal base function for Pease algorithm.\n#F This is equivalent to:\n#F L(size,radix) * TC(size, radix, 0, k) * L(size, size/radix).\n#F\n#F TC is (5) in Jeremy's Pease paper.\n#F\nClass(TCBase, DiagFunc, rec(\n abbrevs := [ (n, r) -> [n, r, 0, 1],\n\t (n, r, k) -> [n, r, 0, k]],\n def := (n, r, c, k) -> rec(size := n-(n/r)),\n lambda := self >> let(n:=self.params[1], r:=self.params[2],\n\tc:=self.params[3], k:=self.params[4], i:=Ind(n - n/r),\n\tLambda(i, omega(n/(r^c), k*idiv(\n\t idiv((i+n/r), (r^c)), (n/r^(c+1))) *\n\t\timod(idiv((i+n/r), (r^c)), n/(r^(c+1)))))\n\t\t),\n\n range := self >> TComplex,\n\n));\n\n\n\n# TI(n, r, c) - Diagonal generating function for Iterative FFT algorithm\n# where r is the radix, n = size, and c is the iteration\nClass(TI, DiagFunc, rec(\n\n abbrevs := [ (n, r, c) -> [n, r, c, 1],\n (n, r, c, k) -> [n, r, c, k] ],\n\n def := (n, r, c, k) -> rec(size := n/(r^c)),\n lambda := self >> let(n:=self.params[1], r:=self.params[2],\n\tc := self.params[3], k:=self.params[4],\n\tTC(n/(r^c), r, 0, k).lambda()),\n\n range := self >> TComplex,\n domain := self >> self.params[1]/(self.params[2]^self.params[3]),\n));\n\n# TIFold(n, r, c) - Diagonal generating function for Iterative FFT algorithm\n# where r is the radix, n = size, and c is the iteration. This is\n# the same as TI, except we will implement it differently because the\n# surrounding structure is not wide enough to perform all the optimizations.\nClass(TIFold, DiagFunc, rec(\n\n abbrevs := [ (n,r,c) -> [n,r, c, 1],\n [ (n, r, c, k) -> [n, r, c, k]]],\n\n def := (n, r, c, k) -> rec(size := n/(r^c)),\n lambda := self >> let(n:=self.params[1], r:=self.params[2],\n\tc := self.params[3], k:=self.params[4],\n\tTC(n/(r^c), r, 0).lambda()),\n\n range := self >> TComplex,\n\t\n));\n\n\n\n#F ZDFT( <size>, <rshift>, <lshift> )\n#F Discrete Fourier Transform with a cyclic shift on\n#F one or both sides\nClass(ZDFT, NonTerminal, rec(\n abbrevs := [ (n,r,l) -> Checked(IsInt(n), n > 0, [n, r, l]) ],\n dims := self >> [ self.params[1], self.params[1] ],\n\n terminate := self >> let(N:=self.params[1], K:=self.params[2],\n Mat(List([0..N-1],\n r -> List([0..N-1], c -> E(N)^(K*r*c))))),\n\n transpose := self >> self.__bases__[1](self.params[1], self.params[3], self.params[2]),\n isReal := False,\n SmallRandom := () -> Random([2..16]),\n LargeRandom := () -> 2 ^ Random([6..15])\n));\n\n\n#\n# BRDFT(k) = BR(k)*DFT(k)\n# This is the same as DRDFT(k,2) = DR(k,2)*DRDFT(k,2)\nClass(BRDFT, NonTerminal, rec\n(\n abbrevs := [ (n) -> Checked(IsPosInt(n), [n, []]) ],\n#D (n, pv) -> Checked(IsPosInt(n), IsList(pv), [n, pv]) ],\n dims := self >> let(size := self.params[1], [size, size]),\n terminate := self >> Compose(DR(self.params[1], 2), DFT(self.params[1])),\n transpose := self >> Copy(self),\n isReal := self >> true,\n SmallRandom := () -> Random([2..5]),\n LargeRandom := () -> Random([6..15]),\n#D setpv := meth(self, pv)\n#D local s;\n#D s:= Copy(self);\n#D s.params[2] := pv;\n#D return s;\n#D end,\n#D tagpos := 2\n\n));\n\n#\n# DFTBR(k, r) = DFT(k)*BR(k, r)\n# This is the same as DFTDR(k,2) = DRDFT(k,2)*BR(k,2)\nClass(DFTBR, NonTerminal, rec(\n abbrevs := [ (n) -> Checked(IsPosInt(n), [n, []]) ],\n#D (n, pv) -> Checked(IsPosInt(n), IsList(pv), [n, pv]) ],\n dims := self >> let(size := self.params[1], [size, size]),\n terminate := self >> Compose(DFT(self.params[1]), DR(self.params[1], 2)),\n transpose := self >> Copy(self),\n isReal := self >> false,\n SmallRandom := () -> Random([2..5]),\n LargeRandom := () -> Random([6..15]),\n#D setpv := meth(self, pv)\n#D local s;\n#D s:= Copy(self);\n#D s.params[2] := pv;\n#D return s;\n#D end,\n#D tagpos := 2\n\n));\n\n\nClass(DRDFT_Base, TaggedNonTerminal, rec(\n abbrevs := [ (n,k, r) -> Checked(IsPosIntSym(n), IsPosIntSym(r), IsInt(k), [n, k, r]) ],\n#D (n, r, pv) -> Checked(IsPosIntSym(n), IsPosIntSym(r), IsList(pv), [n, r, pv]) ],\n dims := self >> let(size := self.params[1], [size, size]),\n isReal := self >> false,\n SmallRandom := () -> Random([2..5]),\n LargeRandom := () -> Random([6..15]),\n#D setpv := meth(self, pv)\n#D local s;\n#D s:= Copy(self);\n#D s.params[3] := pv;\n#D return s;\n#D end,\n#D tagpos := 3\n));\n\nDeclare(DFTDR);\n\n# DRDFT(n, k, r) = DR(n, r)*DFT(n, k)\n#\nClass(DRDFT, DRDFT_Base, rec(\n terminate := self >> Compose(DR(self.params[1], self.params[3]), DFT(self.params[1], self.params[2])),\n transpose := self >> ApplyFunc(DFTDR, self.params).withTags(self.getTags()),\n));\n\n#\n# DFTDR(n, k, r) = DFT(n,k)*DR(n, r)\nClass(DFTDR, DRDFT_Base, rec(\n terminate := self >> Compose(DFT(self.params[1], self.params[2]), DR(self.params[1], self.params[3])),\n transpose := self >> ApplyFunc(DRDFT, self.params).withTags(self.getTags()),\n));\n", "meta": {"hexsha": "fc015f528e43f529381237fe088bc1d20bc23d52", "size": 14354, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dft/dft.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/dft/dft.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/dft/dft.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": 34.8398058252, "max_line_length": 150, "alphanum_fraction": 0.5516232409, "num_tokens": 5064, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767906859264, "lm_q2_score": 0.7662936377487305, "lm_q1q2_score": 0.6724048819748}}
{"text": "for p in AlternatingGroup(4) do\n Print(p, \"\\n\");\nod;\n\n()\n(1,3,2)\n(1,2,3)\n(1,4,3)\n(2,4,3)\n(1,3)(2,4)\n(1,2,4)\n(1,4)(2,3)\n(2,3,4)\n(1,3,4)\n(1,2)(3,4)\n(1,4,2)\n", "meta": {"hexsha": "151e03690733d1b79e95e55e9bb21eb3e71cec61", "size": 157, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Loops-Foreach/GAP/loops-foreach.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/Loops-Foreach/GAP/loops-foreach.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/Loops-Foreach/GAP/loops-foreach.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": 9.2352941176, "max_line_length": 31, "alphanum_fraction": 0.4458598726, "num_tokens": 104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9149009642742805, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6716466683755872}}
{"text": "#######################################################################\n# Description: A function to calculate orbits, described in #\n# section 3.1. # \n# Input: - integer 0 < a <= n + 1 # \n# - list of generators S #\n# Output: - list of integers 'orbit' #\n#######################################################################\n\nOrbitSimple := function(a, S)\n local orbit, b, x;\n orbit := [a];\n for b in orbit do\n for x in S do\n if not b^x in orbit then\n Add(orbit, b^x);\n fi;\n od;\n od;\n return orbit;\nend;\n\n#######################################################################\n#######################################################################\n\n#######################################################################\n# Description: A function to calculate orbits and belonging Schreier- #\n# vectors, described in section 3.1. # \n# Input: - integer 0 < a <= n # \n# - list of generators S #\n# Output: - list of integers 'orbit' #\n# - belonging Schreier-vector 'sv' as list of integers #\n#######################################################################\n\nOrbitSV := function(a, S, n)\n local orbit, b, x, i, sv;\n orbit := [a]; sv := [1..n]*0; sv[a] := -1;\n for b in orbit do\n for i in [1..Length(S)] do\n if not b^S[i] in orbit then\n Add(orbit, b^S[i]); sv[b^S[i]] := i;\n fi;\n od;\n od;\n return [orbit, sv];\nend;\n\n#######################################################################\n#######################################################################\n\n#######################################################################\n# Description: A function to calculate transversal elements, described#\n# in section 3.1. # \n# Input: - orbit element b of type integer 0 < b <= n # \n# - Schreier-vector 'sv' as list of integers in range [1..n] #\n# - list of generators S #\n# Output: - transversal element of b w.r.t. a and <S> # \n#######################################################################\n\nTransversal := function(b, sv, S)\n local u, k;\n if sv[b] = 0 then\n return false;\n fi;\n u := (); k := sv[b];\n while not k = -1 do\n u := S[k]*u; b := b^(S[k]^-1); k := sv[b];\n od;\n return u;\nend; \n", "meta": {"hexsha": "ae407703ea876d1c7528daa8797c87a4934aa580", "size": 2799, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "src/Orbit.gi", "max_stars_repo_name": "AlexanderKlemps/parallel-schreier-sims", "max_stars_repo_head_hexsha": "7a2fc1637f85067ba8162aefbde3f26b1b6da12e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Orbit.gi", "max_issues_repo_name": "AlexanderKlemps/parallel-schreier-sims", "max_issues_repo_head_hexsha": "7a2fc1637f85067ba8162aefbde3f26b1b6da12e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Orbit.gi", "max_forks_repo_name": "AlexanderKlemps/parallel-schreier-sims", "max_forks_repo_head_hexsha": "7a2fc1637f85067ba8162aefbde3f26b1b6da12e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.9857142857, "max_line_length": 100, "alphanum_fraction": 0.297606288, "num_tokens": 543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314738181875, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.6711265507274728}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# Auxiliary Matrices\n# ==================\n#\n# This file contains useful matrices to be used in rules\n#\n\nIsRealMat := mat -> ForAll(mat, r -> ForAll(r, IsRealNumber)); \n\nReMat := mat -> MapMat(mat, e -> re(e));\n\n# Permutations\n# ------------\n\n#F\n#F GenPerm0(generator_func, size)\n#F returns a permutation generated by applying generator_func to\n#F list [0..size-1]\n#F\nGenPerm0 := function(size, generator_func) \n Constraint(IsInt(size) and size > 0);\n return PermList(List([0..size-1], generator_func) + 1);\nend;\n\n#F\n#F GenPerm1(generator_func, size)\n#F returns a permutation generated by applying generator_func to\n#F list [1..size]\n#F\nGenPerm1 := function(size, generator_func) \n Constraint(IsInt(size) and size > 0);\n return PermList(List([1..size], generator_func));\nend;\n\n#F \n#F LexMap(r,s)\n#F returns list of lexicographical ordering pairs\n#F\nLexMap := function(r,s)\n local i,j, result;\n result:=[];\n for i in [0..r-1] do\n for j in [0..s-1] do\n Append(result, [[i,j]]);\n od;\n od;\n return result;\nend;\n\n\n#F\n#F ToeplitzMat([..elements..])\n#F Returns a Toeplitz matrix given by element list\n#F\nToeplitzMat := function(elements)\n local i, j, n, Ls, mat;\n Constraint(IsList(elements));\n Constraint(Length(elements) > 0);\n Constraint(IsOddInt(Length(elements)));\n n := (Length(elements)+1)/2;\n mat := [ ];\n for i in [1..n] do\n Ls := List([1..n], k->0);\n\tfor j in [1..n] do\n\t Ls[j] := elements[n+i-j];\n\tod; \n\tAdd(mat,Ls);\n od;\n return mat;\nend;\n\n# -----------------------------------------------------------------------------\n# Matrices used in some breakdown rules\n# NOTE: these should be moved to transforms/*\n# -----------------------------------------------------------------------------\n\n# perm2( <n> )\n# (x_0, .., x_n-1) --> (x_0, x_n-1, x_1, x_n-2, ..)\n# For even <n> it is L(n,n/2) * IJ(n,n/2);\n# for odd <n> OddStride(n,(n+1)/2) * DirectSum(I((n+1)/2), J((n-1)/2))\n#\nperm2 := n -> When(IsEvenInt(n), M(n,n/2), LIJ(n));\n\n# perm3( <n> )\n# (x_0, .., x_n-1) --> (x_0, x_n/2, x_1, x_n/2+1, ..),\n# can be expressed by the previous two:\n# perm3(n) = perm2(n) * (I_n/2 dirsum J(n/2))\n# for 2|n it is the stride permutation L^n_n/2\nperm3 := n -> When(IsEvenInt(n), L(n, n/2), OS(n, (n+1)/2));\n\n# perm4( <n> )\n# permutes a direct sum of 2x2 blocks\n# into star form, first block outermost etc.\n# for n even it is equal to perm2\nperm4 := n -> When(IsEvenInt(n), LIJ(n), Z(n).transpose()*LIJ(n));\n\n# perm5( <n> )\n# reverse the odd indices:\n# (x_0, x_1, .., x_2k) --> (x_0, x_2k-1, x_2, x_2k-3, .., x_1, x_2k)\nperm5 := n -> LIJ(n) * L(n,2);\n\n# perm6( <n> )\n# a permutation for rule DCT4_Iterative.\nperm6 := SymFunc(\"perm6\", function ( n )\n local k, p, i;\n\n k := LogInt(n, 2);\n p := PermSPL(perm4(n));\n for i in [1..k - 2] do\n p := \n p *\n TensorProductPerm( \n [ 2^(i - 1), n/2^(i - 1) ],\n [ (), \n DirectSumPerm(\n [ n/2^i, n/2^i ],\n [ PermSPL(perm4(n/2^i)),\n PermSPL(perm4(n/2^i)) ^ PermSPL(J(n/2^i)) ]\n ) ]\n );\n od;\n\n return Perm(p, n);\nend);\n\n\n# perm7( <n> )\n# a permutation for converting an RDFT into a DCT2.\nperm7 := SymFunc(\"perm7\", function ( n )\n local k, L, i;\n\n k := (n-1)/2;\n L := [ ];\n for i in [0..k] do\n Add(L, (-1)^(i + k + 1)*i + k);\n od;\n for i in [k + 1..n - 1] do\n Add(L, (-1)^(i + k + 1)*(n - i) + k);\n od;\n\n return Perm(PermListList(L, [0..n-1]), n);\nend);\n\n\n# Block Matrices\n# --------------\n\n# blocks1( <n> )\n# returns an spl that represents a direct sum of \n# DFT_2's in star form. If n is odd then it contains\n# a 1x1 block in the middle.\nblocks1 := n -> When(IsEvenInt(n), \n Tensor(I(Int(n/2)), F(2)) ^ perm4(n),\n DirectSum(I(1), Tensor(I(Int(n/2)), F(2))) ^ perm4(n));\n\nblocks4 := (n, k) ->\n DirectSum(I(1), Tensor(I(Int(n/2)), F(2) * Diag([1, k*E(4)]))) ^ perm4(n);\n\n\n# Sum Matrices\n# ------------\n\n# n x n matrix\n# diagonal and upper diagonal 1's\nsums1 := SymFunc(\"sums1\", function ( n )\n local M, i;\n\n M := [ ];\n for i in [1..n] do\n Add(M, [i, i, 1]);\n od;\n for i in [1..n-1] do\n Add(M, [i, i+1, 1]);\n od;\n return Sparse(M);\nend);\n\n# n x 2n matrix\n# [ identity, opposite identity ]\nsums2 := SymFunc(\"sums2\", n -> HStack(I(n), J(n)));\n\n\n# n+1 x 3*n/2 matrix, e.g.,\n#[ [ 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ],\n# [ 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ],\n# [ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 ],\n# [ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 ],\n# [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ],\n# [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1 ],\n# [ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0 ],\n# [ 0, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0 ],\n# [ 1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0 ] ]\nsums3 := SymFunc(\"sums3\", function ( n )\n local M, i;\n\n M := [ ];\n for i in [1..n] do\n Add(M, [i, i, 1]);\n od;\n for i in [1..n/2] do\n Add(M, [i, n + i, 1]);\n Add(M, [n/2 + 1 + i, 3*n/2 - i + 1, -1]);\n od;\n Add(M, [n+1, 1, 1]);\n\n return Sparse(M);\nend);\n\n# n x 2n matrix\n# [ identity, -opposite identity ]\nsums4 := n -> HStack(I(n), -J(n));\n\n\n# 2n x n matrix\n# [ opposite lower diagonal 1;\n# identity\n# ]\n\n# n x 3n/2 matrix, e.g.,\n#[ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],\n# [ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ],\n# [ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 ],\n# [ 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0 ],\n# [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ],\n# [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 ],\n# [ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ],\n# [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 ] ]\nsums5 := SymFunc(\"sums5\", function ( n )\n local M, i;\n\n M := [ ];\n for i in [2..n/2] do\n Add(M, [i, i, 1]);\n Add(M, [i, 3*n/2 - i + 2, 1]);\n od;\n Add(M, [n/2 + 1, n + 1, 1]);\n for i in [1..n/2 - 1] do\n Add(M, [n/2 + 1 + i, n/2 + 1 + i, 1]);\n Add(M, [n/2 + 1 + i, n + i + 1, 1]);\n od;\n\n return Sparse(M);\nend);\n\n# a factorization of a matrix like\n# [ [ 1/2, 0, 0, 0, 0, 0, 0, 0 ],\n# [ -1/2, 1, 0, 0, 0, 0, 0, 0 ],\n# [ 1/2, -1, 1, 0, 0, 0, 0, 0 ],\n# [ -1/2, 1, -1, 1, 0, 0, 0, 0 ],\n# [ 1/2, -1, 1, -1, 1, 0, 0, 0 ],\n# [ -1/2, 1, -1, 1, -1, 1, 0, 0 ],\n# [ 1/2, -1, 1, -1, 1, -1, 1, 0 ],\n# [ -1/2, 1, -1, 1, -1, 1, -1, 1 ] ]\n# into 1 mult and n - 1 subs. If the first column is divided by 1/2,\n# then we obtain the transpose - inverse of sums1.\nsums6 := SymFunc(\"sums6\", function ( n )\n local T, M, M1, i;\n\n # small cases\n if n = 1 then\n return Diag([1/2]);\n fi;\n if n = 2 then\n return Mat([[1, 0], [-1, 1]]) * Diag([1/2, 1]);\n fi;\n\n T := List([1..n], i -> 1); \n T[1] := 1/2; \n T := Diag(T);\n M1 := Mat([[1, 0], [-1, 1]]);\n T := DirectSum(M1, I(n - 2)) * T;\n for i in [3..n - 1] do\n T := DirectSum(I(i - 2), M1, I(n - i)) * T;\n od;\n return DirectSum(I(n - 2), M1) * T;\nend);\n\n\n# sparse1( <n>, <r> )\n# returns an spl for the matrix\n# I_m -Z_m\n# D_m\n# where m = n/2, Z_m has ones on the lower opposite diagonal,\n# and D_m = cos(r*pi) * diag(1, 2, ..., 2)\n# This matrix occurs in Steidl's rule for DCT2/3.\nsparse1 := (n,r) -> CheckedD(IsInt(n), CanBeScalar(r) or IsScalar(r), n mod 2 = 0, \n let(m := n/2,\n\td := DirectSum(Diag(cospi(r)), Scale(2*cospi(r), I(n/2-1))),\n\n\tBlockMat(\n\t [ [I(m), DirectSum(O(1), -J(m-1))],\n\t [O(m), d ] ])));\n\n# Copy Matrices\n# -------------\n\n# 2n x n+1 matrix, e.g., \n#[ [ 1, 0, 0, 0, 0 ],\n# [ 0, 1, 0, 0, 0 ],\n# [ 0, 0, 1, 0, 0 ],\n# [ 0, 0, 0, 1, 0 ],\n# [ 0, 0, 0, 0, 1 ],\n# [ 0, 0, 0, 1, 0 ],\n# [ 0, 0, 1, 0, 0 ],\n# [ 0, 1, 0, 0, 0 ] ]\n\ncopy1 := SymFunc(\"copy1\", function ( n )\n local M, i;\n\n M := [ ];\n for i in [1..n + 1] do\n Add(M, [i, i, 1]);\n od;\n for i in [1..n - 1] do\n Add(M, [n + 1 + i, n - i + 1, 1]);\n od;\n\n return Sparse(M);\nend);\n\n\n# 2n x n matrix, e.g.,\n#[ [ 1, 0, 0, 0 ],\n# [ 0, 1, 0, 0 ],\n# [ 0, 0, 1, 0 ],\n# [ 0, 0, 0, 1 ],\n# [ 0, 0, 0, 0 ],\n# [ 0, 0, 0, -1 ],\n# [ 0, 0, -1, 0 ],\n# [ 0, -1, 0, 0 ] ]\n\ncopy2 := SymFunc(\"copy2\", function ( n )\n local M, i;\n\n M := [ ];\n for i in [1..n] do\n Add(M, [i, i, 1]);\n od;\n for i in [1..n - 1] do\n Add(M, [n + 1 + i, n - i + 1, -1]); \n od;\n\n return Sparse(M);\nend);\n\n\n# Monomial Matrices\n# -----------------\n\n# monomial1 ( <n> )\n# Let m = n/4. Then monomial1(<n>) returns an spl of type \"sparse\"\n# that represents\n# I_m+1 0 0 0\n# 0 0 J_m 0\n# 0 0 0 -J'_m\n# 0 I_m-1 0 0\n# where the prime indicates that the entry in the last row\n# has opposite sign\n\nmonomial1 := SymFunc(\"monomial1\", function ( n )\n local m, L, i;\n\n m := n/4;\n L := [ ];\n for i in [1..m+1] do\n Add(L, [i, i, 1]);\n od;\n for i in [1..m] do\n Add(L, [m+1+i, 3*m+1-i, 1]);\n od;\n for i in [1..m-1] do\n Add(L, [2*m+1+i, 4*m+1-i, -1]);\n od;\n\n # the exception\n Add(L, [3*m+1, 3*m+1, 1]);\n for i in [1..m-1] do\n Add(L, [3*m+1+i, m+1+i, 1]);\n od;\n\n return Sparse(L);\nend);\n", "meta": {"hexsha": "a883de3d1c6d7fb11261cd713a467288af404b1c", "size": 9595, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/matrices.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/spl/matrices.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/spl/matrices.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": 24.7932816537, "max_line_length": 83, "alphanum_fraction": 0.4376237624, "num_tokens": 4461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424334245618, "lm_q2_score": 0.793105941403651, "lm_q1q2_score": 0.6709219700344824}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F Random SPLs\n#F -----------\n#F\n\n#F RandomPermSPL ( <n> )\n#F returns a random spl of type \"perm\" or \"symbol\" representing\n#F a <n> x <n> permutation matrix.\n#F\n\nRandomPermSPL := function ( n )\n local type;\n\n type := Random([\"perm\", \"J\", \"L\"]);\n if type = \"perm\" then\n return Perm(Random(SymmetricGroup(n)), n);\n elif type = \"J\" then\n return SPLSymbol(\"J\", n);\n elif type = \"L\" then\n return SPLSymbol(\"L\", [n, Random(DivisorsInt(n))]);\n else\n Error(\"should not happen\");\n fi;\nend;\n\n\n#F RandomSymbolSPL ( <n> )\n#F returns a random spl of type \"symbol\" representing\n#F a <n> x <n> matrix.\n#F\n\nRandomSymbolSPL := function ( n )\n local type, d;\n\n if n = 1 then\n type := Random([\"I\", \"J\"]);\n elif n = 2 then\n type := Random([\"I\", \"J\", \"F\", \"Rot\"]);\n elif IsPrime(n) then\n type := Random([\"I\", \"J\"]);\n else\n type := Random([\"I\", \"J\", \"L\", \"T\"]);\n fi;\n if type in [\"I\", \"J\", \"F\"] then\n return SPLSymbol(type, n);\n elif type = \"Rot\" then\n return SPLSymbol(\"Rot\", Random(Rationals));\n elif type in [\"L\", \"T\"] then\n d := Random([2..Tau(n)-1]);\n return SPLSymbol(type, [n, DivisorsInt(n)[d]]);\n else\n Error(\"should not happen\");\n fi;\nend;\n\n\n#F RandomTerminalSPL ( <n> )\n#F returns a random terminal spl representing a <n> x <n> matrix.\n#F\n\nRandomTerminalSPL := function ( n )\n local type, randscalar, L, i, P, p;\n\n # function to return a somewhat random scalar <> 0\n randscalar := function ( ) \n local L, den;\n\n L := \n Concatenation(\n [-5..-1], [1..5], List([1/3,2/5,3/7], CosPi), List([2..5], E)\n );\n return Random(L)/Random([1..5]);\n end;\n\n # choose type, mats only for n <= 3, give better odds to\n # composed types\n if n <= 3 then\n type := \n Random( [\n\t\"mat\", \"sparse\", \"diag\", \"perm\", \"symbol\", \n \"compose\", \"directSum\", \"tensor\", \n \"compose\", \"directSum\", \"tensor\", \n \"scalarMultiple\", \"conjugate\"\n ] );\n else\n type := \n Random( [\n\t\"sparse\", \"diag\", \"perm\", \"symbol\", \n \"compose\", \"directSum\", \"tensor\", \n \"scalarMultiple\", \"conjugate\"\n ] );\n fi; \n\n # dispatch on types\n if type = \"mat\" then\n\n return Mat(List([1..n], i -> List([1..n], j -> randscalar())));\n\n elif type = \"sparse\" then\n \n # choose n entries\n # make sure there are no doubles\n L := [ ];\n P := [ ];\n for i in [1..n] do\n repeat\n p := [Random([1..n]), Random([1..n])];\n until not p in P;\n AddSet(P, p); \n Add(L, [p[1], p[2], randscalar()]);\n od;\n if ForAll(L, t -> t[1] <> n or t[2] <> n) then\n\n # add entry in lower right corner\n Add(L, [n, n, randscalar()]);\n fi;\n return Sparse(L);\n\n elif type = \"diag\" then\n\n return Diag(List([1..n], i -> randscalar()));\n\n elif type = \"perm\" then\n\n return RandomPermSPL(n);\n\n elif type = \"symbol\" then\n\n return RandomSymbolSPL(n);\n\n elif type = \"compose\" then\n\n # choose 2 factors\n i := Random([2]);\n return Compose(List([1..i], i -> RandomTerminalSPL(n)));\n\n elif type = \"directSum\" then\n\n if n <= 3 then\n return RandomTerminalSPL(n);\n fi;\n\n # choose partition into 2 summands\n i := Random([2]);\n return \n DirectSum(List(Random(OrderedPartitions(n, i)), RandomTerminalSPL));\n\n elif type = \"tensor\" then\n\n if IsPrime(n) or n = 1 then\n return RandomTerminalSPL(n);\n else\n i := Random(DivisorsInt(n));\n return Tensor(RandomTerminalSPL(i), RandomTerminalSPL(n/i));\n fi;\n\n elif type = \"scalarMultiple\" then\n\n return Scale(randscalar(), RandomTerminalSPL(n));\n\n elif type = \"conjugate\" then\n\n return Conjugate(RandomTerminalSPL(n), RandomPermSPL(n));\n\n else\n Error(\"should not happen\");\n fi;\nend;\n", "meta": {"hexsha": "692ec14441dbaccee1fb75f9e777a47e94cdc2f8", "size": 3793, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/random.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/spl/random.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/spl/random.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": 21.9248554913, "max_line_length": 74, "alphanum_fraction": 0.5639335618, "num_tokens": 1202, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094003735664, "lm_q2_score": 0.7490872075132153, "lm_q1q2_score": 0.6691666441711397}}
{"text": "# Using functions from 'RandomPerm.gi' and 'Orbit.gi'\nRead(\"RandomPerm.gi\"); Read(\"Orbit.gi\");\n\n#######################################################################\n# Description: A function to calculate the pointwise image of a list. #\n# Input: - list of integers B = [b_1,...,b_k] # \n# - permutation x as cycle #\n# Output: - list of integers [b_1^x,...,b_k^x] #\n#######################################################################\n\nBaseImage := function(B, x)\n local i, image;\n image := [];\n for i in [1..Length(B)] do\n Add(image, B[i]^x);\n od;\n return image;\nend;\n\n#######################################################################\n#######################################################################\n\n#######################################################################\n# Description: A function to setup partial generating sets of #\n# stabilizeres. #\n# Input: - list of integers B = [b_1,...,b_k] # \n# - generating system S as list of permutations #\n# Output: - list of generating system (lists of permutations), #\n# one generating system for each stabilizer in chain #\n#######################################################################\n\nGeneratingSets := function(B, S)\n local s, x, i, partialBase, sets;\n sets := [S]; \n for i in [1..Length(B)-1] do\n Add(sets, []);\n od;\n for x in S do\n for i in [1..Length(B)-1] do\n partialBase := B{[1..i]};\n if BaseImage(partialBase, x) = partialBase then\n Add(sets[i+1], x);\n else\n break;\n fi;\n od;\n od;\n return sets;\nend;\n\n#######################################################################\n#######################################################################\n\n#######################################################################\n# Description: A function to strip a permutation w.r.t. a base, #\n# described in section 3.2. # \n# Input: - permutation g as cycle #\n# - list of integers B = [b_1,...,b_k] # \n# - generating system S as list of permutations #\n# - data structure returned by 'GeneratingSets' function # \n# Output: - residue and dropout level of g #\n#######################################################################\n\nStrip := function(g, B, orbits, sgs)\n local m, i, u, b;\n m := g;\n for i in [1..Length(B)] do\n b := B[i]^m;\n if orbits[i][2][b] = 0 then \n return [m, i]; \n fi;\n u := Transversal(b, orbits[i][2], sgs[i]); m := m*(u^(-1)); \n od;\n return [m, Length(B)+1];\nend;\n\n#######################################################################\n#######################################################################\n\t\n#######################################################################\n# Description: The standard deterministic Schreier-Sims-Algorithm #\n# described in section 3.3. #\n# Input: - list B of base points (might be empty list [] first) # \n# - list S of given generators of group G #\n# - integer n specifying the degree of symmetric group the #\n# generated group G is embedded in #\n# Output: - list 'BSGS' with three entries including #\n# -- the calculated base B as list in BSGS[1] #\n# -- a strong generating set S as list of partial #\n# generating sets for each stabilizer in BSGS[2] #\n# -- a list of the sizes of the orbits belonging to B #\n# and S in BSGS[3] #\n#######################################################################\n\nSchreierSims := function(B, S, n)\n local x, u, y, h, b, i, j, k, t, orbits, sgs, sizes, stripped;\n \n # extending partial base so that no point of S \n # fixes all points\n for x in S do\n if BaseImage(B, x) = B then\n Add(B, MovedPoints(x)[1]);\n fi;\n od; \n # calculating generating sets for each stabilizer \n sgs := GeneratingSets(B, S);\n \n # calculate orbits and schreier vectors of base \n # points under action of generated stabilizers \n orbits := [];\n for i in [1..Length(B)] do\n Add(orbits, OrbitSV(B[i], sgs[i], n));\n od;\n i := Length(B);\n while i >= 1 do\n for b in orbits[i][1] do\n t := Transversal(b, orbits[i][2], sgs[i]); \n for x in sgs[i] do\n u := Transversal(b^x, orbits[i][2], sgs[i]); y := true;\n if not t*x = u then\n # check whether Schreier generator \n # belongs to H^(i+1)\n stripped := Strip(t*x*(u^(-1)), B, orbits, sgs);\n j := stripped[2]; h := stripped[1];\n \n # in case the Schreier generator does \n # not belong to H^(i+1) do ...\n if j <= Length(B) then\n y := false;\n elif not h = () then \n Add(B, MovedPoints(h)[1]);\n Add(sgs, []); y := false;\n fi;\n if y = false then\n # update generating sets, orbits \n # and Schreier vectors\n for k in [i+1..j] do\n Add(sgs[k], h);\n orbits[k] := OrbitSV(B[k], sgs[k], n); \n od; \n i := j; break;\n fi;\n fi;\n od;\n if y = false then\n break;\n fi;\n od; \n if y = false then\n continue;\n fi; \n i := i - 1; \n od; \n sizes := [];\n for i in [1..Length(B)] do\n Add(sizes, Length(orbits[i][1]));\n od;\n return [B, sgs, sizes];\nend;\n\n#######################################################################\n#######################################################################\n\n#######################################################################\n# Description: The randomized Schreier-Sims-Algorithm, #\n# described in section 4.2. # \n# Input: - list B of base points (might be empty list [] first) #\n# - list S of given generators of group G #\n# - an integer 'bound' capping the number of elements #\n# getting stripped #\n# with trivial residue in a row #\n# - integer n specifying the degree of symmetric group the #\n# generated group G is embedded in #\n# Output: - list 'BSGS' with three entries including # \n# -- the calculated base B as list in BSGS[1] #\n# -- a strong generating set S as list of partial #\n# generating sets for each stabilizer in BSGS[2] #\n# -- a list of the sizes of the orbits belonging to B #\n# and S in BSGS[3] #\n#######################################################################\n\nRandomSchreierSims := function(B, S, bound, n)\n local x, g, i, h, X, c, j, k, y, sgs, orbits, sizes, SGS, stripped;\n \n for x in S do\n if BaseImage(B, x) = B then\n Add(B, MovedPoints(x)[1]);\n fi;\n od;\n \n sgs := GeneratingSets(B, S); orbits := []; SGS := ShallowCopy(S);\n \n for i in [1..Length(B)] do\n Add(orbits, OrbitSV(B[i], sgs[i], n));\n od;\n \n X := InitGenerator(S); c := 0;\n while c < bound do\n g := RandomPerm(S, X);\n stripped := Strip(g, B, orbits, sgs);\n j := stripped[2]; h := stripped[1]; y := true;\n if j <= Length(B) then\n y := false;\n elif not h = () then\n y := false; Add(B, MovedPoints(h)[1]); Add(sgs, []);\n fi;\n if y = false then\n Add(SGS, h);\n for k in [2..j] do\n Add(sgs[k], h);\n orbits[k] := OrbitSV(B[k], sgs[k], n); \n od; \n c := 0; \n fi;\n c := c + 1; \n od;\n \n sizes := []; sgs[1] := SGS;\n for i in [1..Length(B)] do\n Add(sizes, Length(orbits[i][1]));\n od;\n Add(sgs, [()]);\n return [B, sgs, sizes];\nend;\n\n#######################################################################\n#######################################################################\n\n#######################################################################\n# Description: A function to remove redundant generators from # \n# a strong generating set, described in section 4.2. # \n# Input: - BSGS data structure returned by RandomSchreierSims # \n# - Generating set which defined the group. NOT the strong #\n# generating set returned by RandomSchreierSims! #\n# - integer n specifying the size of the set the group #\n# operates on\n#######################################################################\n\nRemoveRedundantGens := function(BSGS, initialGenSet, n)\n local orbits, i, g, newGenSys, removeGen;\n orbits := [];\n \n removeGen := function(SGS, gen, level)\n local j;\n for j in [1..level] do\n RemoveSet(SGS[j], gen);\n od;\n end; \n for i in [1..Length(BSGS[1])] do\n BSGS[2][i] := Set(BSGS[2][i]);\n Add(orbits, Set(OrbitSimple(BSGS[1][i], BSGS[2][i]))); \n od;\n for i in Reversed([1..Length(BSGS[1])-1]) do\n for g in BSGS[2][i] do\n if not g in BSGS[2][i+1] \n and not g in initialGenSet then\n newGenSys := Set(BSGS[2][i]); \n RemoveSet(newGenSys, g);\n if Set(OrbitSimple(BSGS[1][i], newGenSys)) = orbits[i] \n \tthen removeGen(BSGS[2], g, i);\n fi;\n fi;\n od;\n od;\n orbits := []; \n for i in [1..Length(BSGS[1])] do\n Add(orbits, OrbitSV(BSGS[1][i], BSGS[2][i], n));\n od;\n Add(BSGS, orbits); MakeImmutable(BSGS);\nend;\n\n#######################################################################\n#######################################################################\n\n#######################################################################\n# Description: The sequential deterministic verification, # \n# described in section 4.3 # \n# Input: - BSGS data structure returned by RandomSchreierSims # \n# - integer m specifying which layer H^{(m)}_{b_m} = H^{(m+1)} #\n# has to be verified #\n# Output: - boolean, true if H^{(m)}_{b_m} = H^{(m+1)} holds, #\n# else false #\n#######################################################################\n\nSimpleVerify := function(BSGS, m)\n local x, u, b, t, orbits, gen, stripped, sgs, B;\n \n B := BSGS[1]; sgs := BSGS[2]; orbits := BSGS[4];\n \n for b in orbits[m][1] do\n t := Transversal(b, orbits[m][2], sgs[m]);\n for x in sgs[m] do\n if not x in sgs[m+1] or orbits[m+1][2][b] = 0 then\n u := Transversal(b^x, orbits[m][2], sgs[m]);\n if not t*x = u then \n gen := t*x*(u^(-1));\n # check whether Schreier generator 'gen' \n # belongs to H^(i+1)\n stripped := Strip(gen, B, orbits, sgs); \n # if not, return \n if stripped[2] <= Length(B) then\n return false;\n elif not stripped[1] = () then\n return false;\n fi; \n fi;\n fi;\n od;\n od; \n return true;\nend;\n\n#######################################################################\n#######################################################################\n\n#######################################################################\n# Description: The deterministic verification, parallelized w.r.t. # \n# the length of the basic orbits, described as method 2 #\n# in section 5.1. # \n# Input: - BSGS data structure returned by RandomSchreierSims # \n# - integer m specifying which layer H^{(m)}_{b_m} = H^{(m+1)} #\n# has to be verified #\n# Output: - boolean, true if H^{(m)}_{b_m} = H^{(m+1)} holds, #\n# else false #\n#######################################################################\n\nParallelVerify := function(BSGS, m)\n local b, i, orbits, sgs, B, Verify, tasks, results, numOfTasks, \n remaining, partition, pointsPerTask;\n \n # the well-known deterministic verify routine\n Verify := function(B, sgs, orbits, m, partition)\n local x, u, i, stripped, gen, t;\n for b in partition do\n t := Transversal(b, orbits[m][2], sgs[m]);\n for x in sgs[m] do\n if not x in sgs[m+1] or orbits[m+1][2][b] = 0 then\n u := Transversal(b^x, orbits[m][2], sgs[m]);\n if not t*x = u then \n gen := t*x*(u^(-1));\n stripped := Strip(gen, B, orbits, sgs); \n \n if stripped[2] <= Length(B) then\n return false;\n elif not stripped[1] = () then\n return false;\n fi; \n fi;\n fi;\n od;\n od;\n return true;\n end;\n\n B := BSGS[1]; sgs := BSGS[2]; \n orbits := BSGS[4]; partition := [];\n \n pointsPerTask := Int(Length(orbits[m][1])*0.05) + 1;\n numOfTasks := Int(Length(orbits[m][1])/pointsPerTask) + 1;\n remaining := Length(orbits[m][1]) mod pointsPerTask;\n \n tasks := [1..numOfTasks]; results := [1..numOfTasks];\n \n # slice orbit into 'numOfTask' many nearly equally sized subsets\n for i in [1..numOfTasks-1] do\n Add(partition, orbits[m][1]{[(i-1)*pointsPerTask+1..\n i*pointsPerTask]});\n od;\n \n Add(partition, orbits[m][1]{[(numOfTasks-1)*pointsPerTask+1..\n ((numOfTasks-1)*pointsPerTask+remaining)]});\n \n # start several verifications ...\n for i in [1..numOfTasks] do\n tasks[i] := RunTask(Verify, B, sgs, orbits, m, partition[i]);\n od;\n \n # ... and evaluate their results afterwards\n for i in [1..numOfTasks] do\n results[i] := TaskResult(tasks[i]);\n od;\n if false in results then\n return false;\n \n else\n return true;\n fi; \nend;\n\n", "meta": {"hexsha": "8bcf23624581c670cd29630dd9d3d18eeb3192fc", "size": 16017, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "src/SchreierSims.gi", "max_stars_repo_name": "AlexanderKlemps/parallel-schreier-sims", "max_stars_repo_head_hexsha": "7a2fc1637f85067ba8162aefbde3f26b1b6da12e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/SchreierSims.gi", "max_issues_repo_name": "AlexanderKlemps/parallel-schreier-sims", "max_issues_repo_head_hexsha": "7a2fc1637f85067ba8162aefbde3f26b1b6da12e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/SchreierSims.gi", "max_forks_repo_name": "AlexanderKlemps/parallel-schreier-sims", "max_forks_repo_head_hexsha": "7a2fc1637f85067ba8162aefbde3f26b1b6da12e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.0692307692, "max_line_length": 120, "alphanum_fraction": 0.3724792408, "num_tokens": 3497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767906859264, "lm_q2_score": 0.7606506581031359, "lm_q1q2_score": 0.6674532983054776}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nImportAll(spiral);\n\nalphai := (n,i,a) -> Cond(\n i mod 2 = 0, ( a + Int(i/2)) / n, \n i mod 2 = 1, (1-a + Int(i/2)) / n);\n\n#alphai := (n,i,alpha) -> fr(n,i,2*alpha).ev()/2;\ncat := Concatenation;\ncos := x->CosPi(2*x);\nsin := x->SinPi(2*x);\n\nls := (n,f) -> List([0..n-1], f);\n\nMatRDFT1 := n -> cat(\n [ List([0..n-1], x->1), List([0..n-1], x->(-1)^x) ],\n cat(List([1..n/2-1], i->\n [ ls(n, j -> cos(j*i/n)), \n ls(n, j -> sin(j*i/n)) ])));\n\nMatRDFT3 := n -> \n cat(List([0..n/2-1], i->\n [ ls(n, j -> cos(j*(i+1/2)/n)), \n ls(n, j -> sin(j*(i+1/2)/n)) ]));\n\nMatRDFT := (N,a) -> let(n:=N/2,\n cat(ls(n, i-> let(aa := alphai(n,i,a), # 2 since we use 2pi*a\n [ ls(2*n, j -> cos(j*aa)), \n ls(2*n, j -> sin(j*aa)) ]))));\n\nMatrDFT := (N,a) -> let(n:=N/2,\n cat(ls(n, i-> let(aa := alphai(n,i,a),\n [ cat(ls(n, j->cos(j*aa)), (-1)^i*ls(n, j -> -sin(j*aa))),\n cat(ls(n, j->sin(j*aa)), (-1)^i*ls(n, j -> cos(j*aa))) ]))));\n\nMatBRDFT := (N,a) -> MatSPL(BlockMat(let(n:=N/2, \n ls(n, i->let(phi := [[0,-1],[1,2*cos(alphai(n,i,a))]],\n\t ls(n, j->Mat(phi^(2*j))))))));\n\n\n", "meta": {"hexsha": "9480c1a08e47eb1ce7512606cf44d0ddc06b205d", "size": 1318, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sym/rft/rft.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/sym/rft/rft.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/sym/rft/rft.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": 29.2888888889, "max_line_length": 84, "alphanum_fraction": 0.4006069803, "num_tokens": 518, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772286044095, "lm_q2_score": 0.7634837743174788, "lm_q1q2_score": 0.6673437815398563}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F DHT <size>)\n#F Definition: (n x n)-matrix [ cas(2*pi*i*k*l/n) | k,l = 0...n-1 ] or\n#F [ cos(2*pi*i*k*l/n) + sin(2*pi*i*k*l/n) | k,l = 0...n-1 ]\n#F Note: DHT_n = Re(DFT_n) + Im(DFT_n)\n#F Example: DHT(8)\n#F\nClass(DHT, NonTerminal, rec(\n abbrevs := [ n -> Checked(IsPosInt(n), [n]) ],\n dims := self >> [self.params[1], self.params[1]],\n terminate := self >> Mat(Sqrt(self.params[1]) * Global.DHT(self.params[1])),\n transpose := self >> Copy(self),\n isReal := self >> true,\n SmallRandom := ( ) -> Random([2, 4, 6, 8, 12, 16, 24, 32]),\n normalizedArithCost := self >> let(n := self.params[1], IntDouble(2.5 * n * d_log(n) / d_log(2)))\n));\n\n#F -----------------------------------------------------------------------------\n#F XH(size) : represents a matrix used in DHT radix-2 rule (temporary solution)\n#F -----------------------------------------------------------------------------\nClass(XH, Sym, rec(\n notSupported := true,\n abbrevs := [ n -> Checked(IsInt(n), n >= 4, n mod 4 = 0, n) ], \n\n def := N -> When(N = 4, I(4),\n\tDirectSum(\n\t I(N/2 + 1),\n\t DirectSum(\n\t\tI(1), \n\t\tList([1..N/4-1], i -> Rot(1/2-2*i/N) * J(2))) ^ \n\t perm4(N/2-1))),\n\n transpose := self >> self,\n\n isReal := True\n));\n\nRulesFor(DHT, rec(\n #F DHT_Base: DHT_2 = F_2\n #F\n DHT_Base := rec (\n\tinfo := \"DHT_2 -> F_2\",\n\tforTransposition := false,\n\tisApplicable := P -> P[1] = 2,\n\tallChildren := P -> [[ ]],\n\trule := (P, C) -> F(2)\n ),\n\n DHT_toPRDFT := rec(\n isApplicable := P -> P[1] > 2,\n allChildren := P -> [[ PRDFT(P[1]) ]],\n rule := (P, C) -> let(n := P[1], cut := Mat([[1,0]]), \n OS(n,-1) * # or set the rotation to -1\n LIJ(n).transpose() * \n Cond(IsEvenInt(n), DirectSum(cut, Tensor(I(n/2-1), F(2)), cut) * C[1],\n IsOddInt(n), DirectSum(cut, Tensor(I((n-1)/2), F(2))) * C[1]))\n ),\n\n #F DHT_DCT1andDST1:\n #F\n #F DHT_n = blocks * (DCT1_(n/2+1) dirsum DST1_(n/2-1)) * blocks\n #F\n #F Britanak/Rao:\n #F The fast generalized discrete Fourier transforms: A unified\n #F approach to the discrete sinusoidal transforms computation.\n #F Signal Processing 79, 1999, pp. 135--150\n #F\n DHT_DCT1andDST1 := rec (\n\tinfo := \"DHT_n -> DCT1_(n/2+1), DST1_(n/2-1)\",\n\tforTransposition := false,\n\tisApplicable := P -> P[1] mod 2 = 0 and P[1] > 2, \n\tallChildren := P -> [[ DCT1(P[1]/2+1), DST1(P[1]/2-1) ]],\n\trule := (P, C) -> let(n:=P[1], \n\t DirectSum(I(1), blocks1(n - 1)) *\n\t DirectSum(C[1], C[2] ^ J(n/2 - 1)) *\n\t DirectSum(I(1), blocks1(n - 1)))\n ),\n\n #F DHT_2:\n #F Radix-2 Cooley-Tukey\n #F\n DHT_Radix2 := rec (\n\tinfo := \"DHT_n -> DHT_n/2\",\n\tforTransposition := false,\n\tisApplicable := P -> P[1] mod 2 = 0 and IsPrimePowerInt(P[1]) and P[1] > 2,\n\tallChildren := P -> [[ DHT(P[1]/2) ]],\n\trule := (P, C) -> let(n:=P[1],\n\t Tensor(F(2), I(n/2)) *\n\t XH(n) *\n\t Tensor(I(2), C[1]) *\n\t L(n, 2))\n )\n));\n", "meta": {"hexsha": "6caecb1e26c3e2c2c90955ccf3e9bee9a379af54", "size": 3145, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/realdft/dht.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/realdft/dht.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/realdft/dht.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": 32.0918367347, "max_line_length": 101, "alphanum_fraction": 0.4772655008, "num_tokens": 1137, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9196425399873764, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.6666215364786396}}
{"text": "# The first two work with rationals or with floats\n# (but bear in mind that support of floating point is very poor in GAP)\nmean := v -> Sum(v) / Length(v);\nharmean := v -> Length(v) / Sum(v, Inverse);\ngeomean := v -> EXP_FLOAT(Sum(v, LOG_FLOAT) / Length(v));\n\nmean([1 .. 10]);\n# 11/2\nharmean([1 .. 10]);\n# 25200/7381\n\nv := List([1..10], FLOAT_INT);;\nmean(v);\n# 5.5\nharmean(v);\n# 3.41417\ngeomean(v);\n# 4.52873\n", "meta": {"hexsha": "baaa5d87a812c5302ca446610aefbe866e446c89", "size": 409, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Averages-Pythagorean-means/GAP/averages-pythagorean-means.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-Pythagorean-means/GAP/averages-pythagorean-means.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-Pythagorean-means/GAP/averages-pythagorean-means.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": 21.5263157895, "max_line_length": 71, "alphanum_fraction": 0.6210268949, "num_tokens": 149, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9399133515091156, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.6633767767759192}}
{"text": "# Complete multipartite graphs.\nBindGlobal(\"CompleteMultipartiteGraph\", function(arg)\n local sizes, dp, F, G, m, n;\n F := function(x, y) return x[1] <> y[1]; end;\n if Length(arg) = 0 then\n Error(\"at least one argument expected\");\n return fail;\n elif Length(arg) = 1 then\n sizes := arg[1];\n dp := DirectProduct(List(sizes, i -> SymmetricGroup(i)));\n return Graph(dp, Union(List([1..Length(sizes)],\n i -> List([1..sizes[i]], j -> [i, j]))),\n OnSum(dp), F, true);\n else\n m := arg[1];\n n := arg[2];\n return Graph(WreathProductSymmetricGroups(n, m),\n Cartesian([1..m], [1..n]),\n function(x, g)\n local y;\n y := (n*(x[1]-1)+x[2])^g - 1;\n return [Int(y/n)+1, y mod n + 1];\n end, F, true);\n fi;\nend);\n\n# Cycle graphs.\nBindGlobal(\"CycleGraph\", n -> Graph(DihedralGroup(IsPermGroup, 2*n), [1..n],\n OnPoints, function(x, y)\n return (x-y) mod n in [1,n-1];\n end, true));\n\n# Cocktail party graphs.\nBindGlobal(\"CocktailPartyGraph\",\n n -> CompleteMultipartiteGraph(n, 2)\n);\n\n# Paley graphs.\n# For q = 1 (mod 4) a prime power, the graph is strongly regular.\n# For q = 3 (mod 4) a prime power, the graph is directed.\nBindGlobal(\"PaleyGraph\", function(q)\n local dp;\n dp := DirectProduct(FieldAdditionPermutationGroup(q),\n Group(GeneratorsOfGroup(FieldMultiplicationPermutationGroup(q))[1]^2));\n return Graph(dp, Elements(GF(q)), OnPaley(q, dp),\n function(x, y)\n return IsOne((x-y)^((q-1)/2));\n end, true);\nend);\n\n# Latin square graphs.\nBindGlobal(\"LatinSquareGraph\", function(arg)\n local dim, dp, G, invt, vcs;\n if Length(arg) = 0 then\n Error(\"at least one argument expected\");\n return fail;\n fi;\n G := arg[1];\n if Length(arg) > 1 then\n invt := arg[2];\n else\n invt := true;\n fi;\n if IsGroup(G) then\n dp := DirectProduct(G, G);\n if invt then\n vcs := Cartesian(G, G);\n else\n vcs := [[One(G), One(G)]];\n fi;\n return Graph(dp, vcs, OnLatinSquare(dp),\n function(x, y)\n return x <> y and (x[1] = y[1] or x[2] = y[2]\n or x[1]*x[2] = y[1]*y[2]);\n end, invt);\n else\n dim := DimensionsMat(G);\n return AdjFunGraph(Cartesian([1..dim[1]], [1..dim[2]]),\n function(x, y)\n return x <> y and (x[1] = y[1] or x[2] = y[2]\n or G[x[1]][x[2]] = G[y[1]][y[2]]);\n end);\n fi;\nend);\n\n# Complete Taylor graphs, i.e. complete bipartite graphs minus a matching.\nBindGlobal(\"CompleteTaylorGraph\", function(n)\n local G;\n G := EdgeOrbitsGraph(Group([(1,2)(n+1,n+2),\n PermList(Concatenation([2..n], [1], [n+2..2*n], [n+1])),\n PermList(Concatenation([n+1..2*n], [1..n]))]), [1, n+2]);\n AssignVertexNames(G, Cartesian([1, 2], [1..n]));\n return G;\nend);\n", "meta": {"hexsha": "fb72be18f4329d70da2e0fa61fc479335df73494", "size": 3096, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/BasicGraphs.gap", "max_stars_repo_name": "jaanos/gap-graphs", "max_stars_repo_head_hexsha": "18dd56c9b90a12a717a0cc893fdd72c6343ee79b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-10-27T15:54:29.000Z", "max_stars_repo_stars_event_max_datetime": "2016-11-07T14:09:44.000Z", "max_issues_repo_path": "lib/BasicGraphs.gap", "max_issues_repo_name": "jaanos/gap-graphs", "max_issues_repo_head_hexsha": "18dd56c9b90a12a717a0cc893fdd72c6343ee79b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-04-20T23:13:11.000Z", "max_issues_repo_issues_event_max_datetime": "2015-04-20T23:13:11.000Z", "max_forks_repo_path": "lib/BasicGraphs.gap", "max_forks_repo_name": "jaanos/gap-graphs", "max_forks_repo_head_hexsha": "18dd56c9b90a12a717a0cc893fdd72c6343ee79b", "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": 32.5894736842, "max_line_length": 79, "alphanum_fraction": 0.507751938, "num_tokens": 913, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045877523147, "lm_q2_score": 0.7461389873857264, "lm_q1q2_score": 0.6619779327094829}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F --------------------------------------------------------------------------------\nRulesFor(DST1, rec(\n #F DST1_Base1: DST1_1 = I_1\n #F\n DST1_Base1 := rec (\n info := \"DST_1 -> I_1\",\n forTransposition := false,\n isApplicable := P -> P[1] = 1, \n rule := (P, C) -> I(1)\n ),\n\n #F DST1_Base2: DST1_2 = cos(pi/6) * F_2\n #F\n DST1_Base2 := rec (\n info := \"DST_2 -> c * F_2\",\n forTransposition := false,\n isApplicable := P -> P[1] = 2, \n rule := (P, C) -> CosPi(1/6) * F(2)\n ),\n\n #F DST1_DST3and1: 1984\n #F\n #F DST1_(n-1) = perm * (DST3_n/2 dirsum DST1_(n/2-1) ^ perm) * (1 tensor DFT_2)^perm\n #F\n #F Wang: \n #F Fast Algorithms for the Discrete W Transform and the\n #F Discrete Fourier Transform.\n #F IEEE Trans. on ASSP, 1984, pp. 803--814\n #F\n DST1_DST3and1 := rec (\n info := \"DST1_(n-1) --> DST3_n/2, DST1_(n/2-1)\",\n isApplicable := P -> (P[1] + 1) mod 2 = 0 and P[1] >= 2,\n allChildren := P -> [[ DST3((P[1] + 1)/2), DST1((P[1] - 1)/2) ]],\n rule := (P, C) -> # P is odd\n\t DirectSum(C[1], C[2]) ^ OS(P[1], 2) * \n\t DirectSum(I(1), Tensor(I((P[1] - 1)/2), F(2))) ^ Z(P[1],P[1]-1) *\n\t LIJ(P[1])\n #LIJ(P) *\n\t #DirectSum(C[1], C[2] ^ J((P - 1)/2)) *\n\t #DirectSum(I(1), Tensor(I((P - 1)/2), F(2))) ^ (Z(P,P-1) * LIJ(P))\n ),\n\n DST1_toDCT3 := rec( # this rule is probably numerically unstable\n isApplicable := P -> P[1] >= 3, \n allChildren := P -> [[ DCT3(P[1]+1) ]], \n rule := (P, C) -> let(n:=P[1], N := n+1,\n RowTensor(n, 1, Mat([[1,-1]])) * C[1] * \n VStack(RowVec(fConst(TReal, n, 0)), \n Diag(FList(TReal, List([1..n], i -> CosPi(i/(2*N)) / SinPi(i/N))))))\n )\n));\n\n#F --------------------------------------------------------------------------------\nRulesFor(DST2, rec(\n #F DST2_Base2: DST2_2 = diag(1/Sqrt(2), 1) * F_2\n #F\n DST2_Base2 := rec(\n\tinfo := \"DST_2 -> F_2\",\n\tisApplicable := P -> P[1] = 2, \n\trule := (P, C) -> Diag([Sqrt(1/2), 1]) * F(2)\n ),\n\n #F DST2_toDCT2: DST2_n = perm * DCT2_n * diag\n #F\n #F Wang: \n #F A Fast Algorithm for the Discrete Sine Transform by the\n #F Fast Cosine Transform, IEEE Trans. on ASSP, 1982, pp. 814--815\n #F\n DST2_toDCT2 := rec (\n\tinfo := \"DST2_n -> DCT2_n\",\n\tisApplicable := P -> P[1] > 2, \n\tallChildren := P -> [[ DCT2(P[1]) ]], \n\trule := (P, C) -> \n\t J(P[1]) * C[1] * Diag(List([0..P[1] - 1], i -> (-1)^i))\n ),\n\n #F DST2_DST2and4: 1982\n #F\n #F DST2'_n = perm * (DST4_n/2 dirsum DST2'_n/2^perm) * (1 tensor DFT_2)^perm\n #F\n #F Wang: \n #F Fast Algorithms for the Discrete W Transform and the\n #F Discrete Fourier Transform.\n #F IEEE Trans. on ASSP, 1984, pp. 803--814\n #F\n DST2_DST2and4 := rec(\n\tinfo := \"DST2_n --> DST4_n/2, DST2_n/2\",\n\tisApplicable := P -> P[1] > 2 and P[1] mod 2 = 0, \n\tallChildren := P -> [[ DST4(P[1]/2), DST2(P[1]/2) ]],\n\trule := (P, C) -> \n\t DirectSum(C[1], C[2]) ^ L(P[1],2) *\n\t Tensor(I(Int((P[1] / 2))), F(2)) *\n \t LIJ(P[1])\n )\n));\n\n#F --------------------------------------------------------------------------------\nRulesFor(DST4, rec(\n #F DST4_Base2: DST4_2 = (1,2) * R_15/8\n #F\n DST4_Base := rec (\n\tinfo := \"DST_4 -> R_15/8\",\n\tforTransposition := false,\n\tisApplicable := P -> P[1] = 2, \n\trule := (P, C) -> J(2) * Rot(15/8)\n ),\n\n #F DST4_1: 1984\n #F\n #F DST4_n = perm * DCT4_n * diag\n #F\n #F Wang: \n #F Fast Algorithms for the Discrete W Transform and the\n #F Discrete Fourier Transform.\n #F IEEE Trans. on ASSP, 1984, pp. 803--814\n #F Chan: \n #F Direct Methods for computing discrete sinusoidal transforms\n #F IEE Proceedings, Vol. 137, 1990, pp. 433--442\n #F\n DST4_toDCT4 := rec (\n\tinfo := \"DST4_n --> DCT4_n\",\n\tisApplicable := P -> P[1] > 2, \n\tallChildren := P -> [[ DCT4(P[1]) ]],\n\trule := (P, C) -> \n \t J(P[1]) * C[1] * Diag(List([0..P[1]-1], i -> (-1)^i))\n )\n));\n", "meta": {"hexsha": "f8101c5abb92e59ebbdb2e637324c359c972919e", "size": 4176, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dct_dst/dst_rules.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/dst_rules.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/dst_rules.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": 31.3984962406, "max_line_length": 88, "alphanum_fraction": 0.4607279693, "num_tokens": 1641, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032942014971871, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.6603609750312588}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# Auxiliary Functions for Symbols and Non-Terminals\n# =================================================\n# MP, from 08/17/00\n\n\n#F Stride Permutations\n#F -------------------\n#F\n\n# Let K a field and d | n. Then the stride permutation L_d^n is a\n# permutation of degree n defined by\n# L_d^n (e_i tensor e_j) = (e_j tensor e_i)\n# for all i, j\n# where e_i is the ith canonical base vector in K^d\n# and e_j the jth in K^(n/d).\n# Hence L_d^n exchanges the tensor components of dimension\n# d and n/d resp.\n# L_d^n can also be viewed the following way. Let x be \n# a (d x n/d)-matrix stored in row major order. L_d^n permutes\n# x such that it is stored in column major order \n# (i.e. transposes x).\n\n# Lemma: L_d^n is given as a permutation of 0..n-1 by\n# i -> i * d mod (n - 1), 0 <= i < n-1.\n#\n# Lemma: The following computation rules hold:\n# a) L_r^rst * L_s^rst = L_rs^rst.\n# b) L_t^rst = (L_t^rt tensor 1_s)(1_r tensor L_t^st).\n#\n# Lemma: L_2^(2i) has exactly 2 fixpoints.\n#\n# Lemma: (has to be proven)\n# p prime: ord(L_(p^i)^(p^n)) = n/gcd(n, i).\n\n\n#F StridePerm( <n>, <d> )\n#F returns the stride permutation L_d^n (see above)\n#F\n\nStridePerm := function ( n, d )\n local M;\n\n # check arguments\n if not ( IsInt(n) and IsInt(d) and n > 0 and d > 0 ) then\n Error(\"<n> and <d> must be positive integers\");\n fi;\n if not n mod d = 0 then\n Error(\"<d> must divide <n>\");\n fi;\n\n # create matrix and transpose\n M := List([1..d], i -> [(i-1)*n/d+1..i*n/d]);\n \n return \n MappingPermListList(\n Concatenation(TransposedMat(M)),\n [1..n]\n );\nend;\n\n# Computes the same thing, but slightly slower.\n\nStridePerm1 := function ( n, d )\n local L;\n\n # check arguments\n if not ( IsInt(n) and IsInt(d) and n > 0 and d > 0 ) then\n Error(\"<n> and <d> must be positive integers\");\n fi;\n if not n mod d = 0 then\n Error(\"<d> must divide <n>\");\n fi;\n\n # compute images according to lemma above\n L := List([1..n], i -> (i - 1) * d mod (n - 1) + 1);\n L[n] := n;\n\n # return permutation\n return MappingPermListList([1..n], L);\nend;\n\n# CycleTypeStridePerm( <n>, <d> )\n# computes the cycle type of L_d^n. The cycle type is a\n# list of pairs [ .., [c_i, n_i], .. ], which denotes\n# that the permutation contains exactly n_i cycles of\n# length c_i. \n# If c_i = 1, then n_i is the number of fixpoints.\n#\n\nCycleTypeStridePerm := function ( n, d )\n return Collected(CycleLengths(StridePerm(n, d), [1..n]));\nend;\n\n\n#F Twiddle Matrices\n#F ----------------\n#F\n\n# The twiddle factors appear in the Cooley-Tukey FFT, namely,\n# for d|n we have:\n# F_n = (F_n/d tensor I_d) * T(n, d) * (I_n/d tensor F_d) * L(n, n/d)\n# where F_n is a DFT of size n, and L denotes a stride permutation\n# defined as above\n\n\n#F TwiddleDiag( <n>, <d> [, <k> ] )\n#F TwiddleDiag( <list-of-n-d[-k]> )\n#F returns the twiddle factors for <d>|<n> as a list:\n#F T(n, d) = direct_sum_(i = 1)^n/d diag(w_n^0, ..., w_n^(d-1)^i\n#F If the optional parameter <k> is given then w_n is replaced by \n#F w_n^k, gcd(<n>, <k>) = 1.\n#F\n\nTwiddleDiag := function ( arg )\n local n, d, k;\n\n if Length(arg) = 1 and IsList(arg[1]) then\n arg := arg[1];\n fi;\n\n if Length(arg) = 2 then\n n := arg[1];\n d := arg[2];\n k := 1;\n elif Length(arg) = 3 then\n n := arg[1];\n d := arg[2];\n k := arg[3];\n else\n Error(\n \"usage:\\n\",\n \" TwiddleDiag( <n>, <d> [, <k> ] )\\n\",\n \" TwiddleDiag( <list-of-n-d[-k]> )\"\n );\n fi;\n\n # check arguments\n if not ( IsInt(n) and IsInt(d) and n > 0 and d > 0 ) then\n Error(\"<n> and <d> must be positive integers\");\n fi;\n if not n mod d = 0 then\n Error(\"<d> must divide <n>\");\n fi;\n if not Gcd(n, k) = 1 then\n Error(\"gcd(<n>, <k>) must be 1\");\n fi;\n \n return\n Concatenation(\n List([1..n/d], i -> List([1..d], j -> E(n)^(k*(j-1)*(i-1))))\n );\nend;\n", "meta": {"hexsha": "eb4e370d75b329ddc212d4b5a4f37972d9c663df", "size": 3909, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/auxil.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/spl/auxil.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/spl/auxil.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": 24.7405063291, "max_line_length": 71, "alphanum_fraction": 0.5766180609, "num_tokens": 1376, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.8244619263765707, "lm_q1q2_score": 0.660140078324598}}
{"text": "# Copyright 2018-2019, Carnegie Mellon University\n# See LICENSE for details\n#F\n#F SPL Objects for directly-implementable gates\n#F\n\n\n#F -----------------------------------------------------------------------------\n#F H - 2x2 Hadamard SPL object\n#F -----------------------------------------------------------------------------\nClass(qH, Sym, rec(\n def := () -> Sqrt(1/2) * Mat([[1,1], [1,-1]]),\n isReal := False,\n isPermutation := False,\n transpose := self >> self,\n conjTranspose := self >> self,\n inverse := self >> self,\n toAMat := self >> self.def(),\n));\n\n\n#F -----------------------------------------------------------------------------\n#F X - 2x2 180 degree rotation along the X axis of the bloch sphere\n#F Specific case of Rotx with theta = pi\n#F -----------------------------------------------------------------------------\nClass(qX, Sym, rec(\n def := () -> Mat( [[0, 1], [1, 0]] ),\n isReal := False,\n isPermutation := False,\n transpose := self >> self,\n conjTranspose := self >> self,\n inverse := self >> self,\n toAMat := self >> self.def(),\n));\n\n\n#F -----------------------------------------------------------------------------\n#F Y - 2x2 180 degree rotation along the Y axis of the bloch sphere\n#F Specific case of Roty with theta = pi\n#F -----------------------------------------------------------------------------\nClass(qY, Sym, rec(\n def := () -> Mat( [[0, E(2)], [-E(2), 0]] ), #Mat( [[0, Cplx(0, -1)], [Cplx(0, 1), 0]] ),\n isReal := False,\n isPermutation := False,\n transpose := self >> Mat( [[0, -E(2)], [E(2), 0]] ), #Mat( [[0, Cplx(0, 1)], [Cplx(0, -1), 0]] ),\n conjTranspose := self >> Mat( [[0, -E(2)], [E(2), 0]] ), #Mat( [[0, Cplx(0, 1)], [Cplx(0, -1), 0]] ),\n inverse := self >> self,\n toAMat := self >> self.def(),\n));\n\n\n#F -----------------------------------------------------------------------------\n#F Z - 2x2 180 degree rotation along the Z axis of the bloch sphere\n#F Specific case of Rotz with theta = pi\n#F -----------------------------------------------------------------------------\nClass(qZ, Sym, rec(\n def := () -> Mat( [[1, 0], [0, -1]] ),\n isReal := False,\n isPermutation := False,\n transpose := self >> self,\n conjTranspose := self >> self,\n inverse := self >> self,\n toAMat := self >> self.def(),\n));\n\n#F -----------------------------------------------------------------------------\n#F S - 2x2 90 degree rotation along the Z axis of the bloch sphere\n#F Specific case of Rotz with theta = pi/2, or commonly notated as sqrt(Z)\n#F -----------------------------------------------------------------------------\nClass(qS, Sym, rec(\n def := () -> Mat( [[1, 0], [0, -E(2)]] ), #Mat( [[1, 0], [0, Cplx(0, 1)]] ),\n isReal := False,\n isPermutation := False,\n transpose := self >> self,\n conjTranspose := self >> Mat( [[1, 0], [0, E(2)]] ), \n inverse := self >> Mat( [[1, 0], [0, E(2)]] ), \n toAMat := self >> self.def(),\n));\n\n#F -----------------------------------------------------------------------------\n#F Sdag - 2x2 -90 degree rotation along the Z axis of the bloch sphere\n#F Specific case of Rotz with theta = -pi/2, or commonly notated as -sqrt(Z)\n#F -----------------------------------------------------------------------------\nClass(qSdag, Sym, rec(\n def := () -> Mat( [[1, 0], [0, E(2)]] ), #Mat( [[1, 0], [0, Cplx(0, -1)]] ),\n isReal := False,\n isPermutation := False,\n transpose := self >> self,\n conjTranspose := self >> qS(), \n inverse := self >> qS(), \n toAMat := self >> self.def(),\n));\n\n\n#F -----------------------------------------------------------------------------\n#F T - 2x2 45 degree rotation along the Z axis of the bloch sphere\n#F Specific case of Rotz with theta = pi/4, or commonly notated as sqrt(S)\n#F -----------------------------------------------------------------------------\nClass(qT, Sym, rec(\n def := () -> Mat( [[1, 0], [0, E(8)]] ),\n isReal := False,\n isPermutation := False,\n transpose := self >> self,\n conjTranspose := self >> Mat( [[1, 0], [0, E(8)^3]] ), \n inverse := self >> Mat( [[1, 0], [0, E(8)^3]] ), \n toAMat := self >> self.def(),\n));\n\n#F -----------------------------------------------------------------------------\n#F Tdag - 2x2 -90 degree rotation along the Z axis of the bloch sphere\n#F Specific case of Rotz with theta = -pi/4, or commonly notated as sqrt(S)\n#F -----------------------------------------------------------------------------\nClass(qTdag, Sym, rec(\n def := () -> Mat( [[1, 0], [0, E(8)^3]] ),\n isReal := False,\n isPermutation := False,\n transpose := self >> self,\n conjTranspose := self >> qT(), \n inverse := self >> qT(), \n toAMat := self >> self.def(),\n));\n\n\n\n##\n#F GenSwapMat( <i>, <j>, <n> )\n## \n## Helper functioj to create a matrix swapping qubits i and j\nGenSwapMat := function (i, j, n)\n local mi, mj, swap, pre;\n mi := Minimum([i, j]);\n mj := Maximum([i, j]);\n if (i = j) then \n return I(2^(n));\n fi;\n pre := Tensor( Tensor(I(2^(mj-1)), L(4,2)), I(2^(n-mj-1)) );\n swap := pre * GenSwapMat(mi, mj-1, n) * pre;\n return swap;\nend;\n\n##\n#F PerfSwap( <target>, <l>, <n> )\n## \n## generates a 2^n by 2^n matrix that swaps the qubits in target with those in l\n## *Not* conscious of the architecture, just generates the equivalent matrix for terminate()\nPerfSwap := function (target, l, n)\n local swap, qub, e, a, ls, tmp_l, r, idx;\n swap := I(2^n);\n qub := 1;\n tmp_l := l;\n # Generate the forward swap matrix, \n for e in tmp_l do \n swap := swap * GenSwapMat(target[qub], e, n);\n ls := SplitAt(tmp_l, 1)[2];\n idx := 1;\n for r in ls do\n # if we affected another qubit in our list\n if r = qub then\n tmp_l[idx] := e;\n fi;\n idx := idx + 1;\n od;\n qub := qub + 1;\n od;\n return swap;\nend;\n\n##\n#F JuncTerm( <l>, <n>, <dir> )\n## \n## Terminate a Junction object into a permutation matrix\nJuncTerm := function (l, n, dir)\n local size, swap1, swap2, trans, tmp_l;\n size := Length(l);\n tmp_l := [1..Length(l)];\n tmp_l := Map(tmp_l, i -> l[i]);\n # Generate swap matrix\n swap1 := PerfSwap([0..size-1], tmp_l, n);\n # Generate the reverse swap matrix\n swap2 := PerfSwap(Reversed([0..size-1]), Reversed(tmp_l), n);\n if (dir >= 0) then \n return swap1;\n fi;\n return swap2;\nend;\n\n#F -----------------------------------------------------------------------------\n#F Junc - reordering of the logical qubit vector (l is the ordering, d is the direction)\n#F -----------------------------------------------------------------------------\nClass(Junc, Sym, rec(\n def := (l, d) -> JuncTerm(l, Length(l), d),\n isReal := False,\n isPermutation := False,\n inverse := self >> self.def(self.params[1], -self.params[2]), \n toAMat := self >> self.def(self.params[1], self.params[2]),\n));\n\n#F -----------------------------------------------------------------------------\n#F Reord - reordering of the physical qubit positions (l = ordering, arch = architecture, d = direction)\n#F -----------------------------------------------------------------------------\nClass(Reord, Sym, rec(\n def := (l, arch, d) -> JuncTerm(l, Length(l), d),\n isReal := False,\n isPermutation := False,\n inverse := self >> self.def(self.params[1], -self.params[2]), \n toAMat := self >> self.def(self.params[1], self.params[2]),\n));\n\n", "meta": {"hexsha": "e87270531cd5ecf40d29b9abdb2b3485d4ca124b", "size": 7461, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "qspl.gi", "max_stars_repo_name": "spiral-software/spiral-package-quantum", "max_stars_repo_head_hexsha": "dd2323983495adbbc6261c0cdf840320d19d099d", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "qspl.gi", "max_issues_repo_name": "spiral-software/spiral-package-quantum", "max_issues_repo_head_hexsha": "dd2323983495adbbc6261c0cdf840320d19d099d", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "qspl.gi", "max_forks_repo_name": "spiral-software/spiral-package-quantum", "max_forks_repo_head_hexsha": "dd2323983495adbbc6261c0cdf840320d19d099d", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6985645933, "max_line_length": 105, "alphanum_fraction": 0.4358665058, "num_tokens": 2002, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898279984214, "lm_q2_score": 0.7279754607093178, "lm_q1q2_score": 0.6595383624351064}}
{"text": "# GAP has an improved floating-point support since version 4.5\n\nPi := Acos(-1.0);\n\nr := Pi / 5.0;\nd := 36;\n\nDeg := x -> x * Pi / 180;\n\nSin(r); Asin(last);\nSin(Deg(d)); Asin(last);\nCos(r); Acos(last);\nCos(Deg(d)); Acos(last);\nTan(r); Atan(last);\nTan(Deg(d)); Atan(last);\n", "meta": {"hexsha": "f7c879c64ad8fd47dd074287d8b4ffb3bf62784c", "size": 303, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Trigonometric-functions/GAP/trigonometric-functions.gap", "max_stars_repo_name": "djgoku/RosettaCodeData", "max_stars_repo_head_hexsha": "91df62d46142e921b3eacdb52b0316c39ee236bc", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Task/Trigonometric-functions/GAP/trigonometric-functions.gap", "max_issues_repo_name": "djgoku/RosettaCodeData", "max_issues_repo_head_hexsha": "91df62d46142e921b3eacdb52b0316c39ee236bc", "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/Trigonometric-functions/GAP/trigonometric-functions.gap", "max_forks_repo_name": "djgoku/RosettaCodeData", "max_forks_repo_head_hexsha": "91df62d46142e921b3eacdb52b0316c39ee236bc", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.9375, "max_line_length": 62, "alphanum_fraction": 0.5181518152, "num_tokens": 103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9294403979493139, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.6589910258588948}}
{"text": "# The Hamming graph H(d, e) of vectors with d elements\n# over an alphabet with e elements.\nBindGlobal(\"HammingGraph\", function(d, e)\n return Graph(WreathProductSymmetricGroups(e, d),\n Elements(ZmodnZ(e)^d), OnZmodnZVectors(d, e),\n function(x, y) return WeightVecFFE(x-y) = 1; end, true);\nend);\n\n# The d-dimensional hypercube\nBindGlobal(\"HypercubeGraph\", d -> HammingGraph(d, 2));\n\n# The Shrikhande graph with parameters v = 16, k = 6, lm = 2, mu = 2,\n# i.e., the same as H(2, 4), but not isomorphic to it.\nBindGlobal(\"ShrikhandeGraph\",\n ComplementGraph(LatinSquareGraph(CyclicGroup(4))));\n \n# The Doob graph Doob(n, d) of diameter 2*n+d\n# as a box product of n copies of the Shrikhande graph and H(d, 4).\nBindGlobal(\"DoobGraph\", function(n, d)\n local l;\n l := ListWithIdenticalEntries(n, ShrikhandeGraph);\n if d > 0 then\n Add(l, HammingGraph(d, 4));\n fi;\n return BoxProductGraph(l);\nend);\n\n# The halved d-cube.\nBindGlobal(\"HalvedCubeGraph\",\n d -> HalvedGraph(HammingGraph(d, 2))\n);\n\n# The folded d-cube.\nBindGlobal(\"FoldedCubeGraph\",\n d -> AntipodalQuotientGraph(HammingGraph(d, 2))\n);\n\n# The folded halved 2d-cube.\nBindGlobal(\"FoldedHalvedCubeGraph\",\n d -> AntipodalQuotientGraph(HalvedGraph(HammingGraph(2*d, 2)))\n);\n\n# The Brouwer graph Br(q) of pairs of 3-dimensional vectors over F_q,\n# with two pairs being adjacent whenever the difference of the first vectors\n# equals the cross product of the second vectors.\nBindGlobal(\"BrouwerGraph\", function(q)\n return Graph(WreathProduct(FieldAdditionPermutationGroup(q),\n MatrixColumnEvenPermutationGroup(2, 3)), Elements(GF(q)^[2,3]),\n OnVectorPairs(q), function(x, y)\n return x <> y and x[1] - y[1] = VectorProduct(x[2], y[2]);\n end, true);\nend);\n\n# The Pasechnik graph Pa(q) as the extended bipartite double\n# of the Brouwer graph Br(q).\nBindGlobal(\"PasechnikGraph\",\n q -> ExtendedBipartiteDoubleGraph(BrouwerGraph(q))\n);\n\n# The additive symplectic cover of the complete graph on q^{2n} vertices.\nBindGlobal(\"AdditiveSymplecticCoverGraph\", function(arg)\n local B, F, G, K, V, h, m, q, dp;\n if Length(arg) < 2 then\n Error(\"at least two arguments expected\");\n return fail;\n fi;\n if Length(arg) > 2 then\n h := arg[3];\n else\n h := 0;\n fi;\n q := arg[1];\n F := GF(q);\n m := 2*arg[2];\n G := Sp(m, q);\n V := F^m;\n B := InvariantBilinearForm(G).matrix;\n dp := DirectProduct(Concatenation([G],\n ListWithIdenticalEntries(m+1, FieldAdditionPermutationGroup(q))));\n if h = 0 then\n K := AdditiveGroup(0*Z(q));\n else\n K := AdditiveGroup(BasisVectors(Basis(F)){[1..h]});\n fi;\n return Graph(dp, Cartesian(Unique(List(F, x -> x+K)), V),\n OnAdditiveSymplecticCover(q, m, B, dp),\n function(x, y)\n return x <> y and x[2]*B*y[2]+y[1]-Elements(x[1])[1] = K;\n end, true);\nend);\n\n# The multiplicative symplectic cover of the complete graph on q+1 vertices.\n# It is distance-regular when m divides q-1 and either q or m is even.\nBindGlobal(\"MultiplicativeSymplecticCoverGraph\", function(q, m)\n local B, F, G, K, dp;\n F := GF(q);\n K := Group(Z(q)^((q-1)/m));\n G := Sp(2, q);\n B := InvariantBilinearForm(G).matrix;\n dp := DirectProduct(G, Group((1,2)),\n FieldExponentiationPermutationGroup(q));\n return Graph(dp, Unique(List(Filtered(F^2, x -> x <> Zero(F^2)),\n v -> Set(List(K, g -> List(v, x -> g*x))))),\n OnMultiplicativeSymplecticCover(q, dp), function(x, y)\n return x <> y and x[1]*B*y[1] in K;\n end, true);\nend);\n\n# The affine polar graph VO^{(+/-)}(d, q)\n# with respect to a nondegenerate quadratic form.\nBindGlobal(\"AffinePolarGraphVO\", function(arg)\n local d, e, q, B, G, Q, V, dp;\n if Length(arg) < 2 then\n Error(\"at least two arguments expected\");\n return fail;\n elif Length(arg) = 2 then\n e := 0;\n d := arg[1];\n q := arg[2];\n else\n e := arg[1];\n d := arg[2];\n q := arg[3];\n fi;\n G := GO(e, d, q);\n dp := DirectProduct(Concatenation([G],\n ListWithIdenticalEntries(d, FieldAdditionPermutationGroup(q))));\n Q := InvariantQuadraticForm(G).matrix;\n return Graph(dp, Elements(GF(q)^d), OnAffine(q, d, dp), function(x, y)\n return x <> y and IsZero((x-y)*Q*(x-y));\n end, true);\nend);\n\n# The affine polar graph VNO^{(+/-)}(d, q)\n# with respect to a nondegenerate quadratic form.\nBindGlobal(\"AffinePolarGraphVNO\", function(arg)\n local d, e, q, B, G, H, Q, V, dp;\n if Length(arg) < 2 then\n Error(\"at least two arguments expected\");\n return fail;\n elif Length(arg) = 2 then\n e := 0;\n d := arg[1];\n q := arg[2];\n else\n e := arg[1];\n d := arg[2];\n q := arg[3];\n fi;\n G := GO(e, d, q);\n dp := DirectProduct(Concatenation([G],\n ListWithIdenticalEntries(d, FieldAdditionPermutationGroup(q))));\n Q := InvariantQuadraticForm(G).matrix;\n return Graph(dp, Elements(GF(q)^d), OnAffine(q, d, dp),\n function(x, y)\n return x <> y and IsOne(((x-y)*Q*(x-y))^((q-1)/2));\n end, true);\nend);\n", "meta": {"hexsha": "2736b8d3887d2b2c942d413025b6338c8fcdb657", "size": 5322, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/VectorGraphs.gap", "max_stars_repo_name": "jaanos/gap-graphs", "max_stars_repo_head_hexsha": "18dd56c9b90a12a717a0cc893fdd72c6343ee79b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-10-27T15:54:29.000Z", "max_stars_repo_stars_event_max_datetime": "2016-11-07T14:09:44.000Z", "max_issues_repo_path": "lib/VectorGraphs.gap", "max_issues_repo_name": "jaanos/gap-graphs", "max_issues_repo_head_hexsha": "18dd56c9b90a12a717a0cc893fdd72c6343ee79b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-04-20T23:13:11.000Z", "max_issues_repo_issues_event_max_datetime": "2015-04-20T23:13:11.000Z", "max_forks_repo_path": "lib/VectorGraphs.gap", "max_forks_repo_name": "jaanos/gap-graphs", "max_forks_repo_head_hexsha": "18dd56c9b90a12a717a0cc893fdd72c6343ee79b", "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": 33.4716981132, "max_line_length": 77, "alphanum_fraction": 0.5937617437, "num_tokens": 1607, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9086178870347122, "lm_q2_score": 0.72487026428967, "lm_q1q2_score": 0.6586300879131735}}
{"text": "gap>List(SymmetricGroup(4), p -> Permuted([1 .. 4], p));\nperms(4);\n[ [ 1, 2, 3, 4 ], [ 4, 2, 3, 1 ], [ 2, 4, 3, 1 ], [ 3, 2, 4, 1 ], [ 1, 4, 3, 2 ], [ 4, 1, 3, 2 ], [ 2, 1, 3, 4 ],\n [ 3, 1, 4, 2 ], [ 1, 3, 4, 2 ], [ 4, 3, 1, 2 ], [ 2, 3, 1, 4 ], [ 3, 4, 1, 2 ], [ 1, 2, 4, 3 ], [ 4, 2, 1, 3 ],\n [ 2, 4, 1, 3 ], [ 3, 2, 1, 4 ], [ 1, 4, 2, 3 ], [ 4, 1, 2, 3 ], [ 2, 1, 4, 3 ], [ 3, 1, 2, 4 ], [ 1, 3, 2, 4 ],\n [ 4, 3, 2, 1 ], [ 2, 3, 4, 1 ], [ 3, 4, 2, 1 ] ]\n", "meta": {"hexsha": "a230429eba3132809232fc2e1982d6d597b71483", "size": 460, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Permutations/GAP/permutations-1.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-1.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-1.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": 65.7142857143, "max_line_length": 113, "alphanum_fraction": 0.2956521739, "num_tokens": 341, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797075998823, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.657637758222855}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nBlocksInt := (n, min, max) ->\n List(Filtered([0..Log2Int(max)+1], i -> min <= (2^i) and (2^i) <= max and (2^i) < n), i->2^i);\n\n\n# ---------\nClass(divisorsIntNonTriv, AutoFoldExp, rec(\n ev := self >> DivisorsIntNonTriv(self.args[1].ev()),\n computeType := self >> TList(TInt)\n)); \n\nClass(oddDivisorsIntNonTriv, AutoFoldExp, rec(\n ev := self >> Filtered(DivisorsIntNonTriv(self.args[1].ev()), IsOddInt),\n computeType := self >> TList(TInt)\n)); \n\n\nClass(isPrime, AutoFoldExp, rec(\n ev := self >> let(a:=self.args[1].ev(), IsInt(a) and IsPrime(a)),\n computeType := self >> TBool\n));\n\nClass(hasOddDivisors, AutoFoldExp, rec(\n ev := self >> Filtered(DivisorsIntNonTriv(self.args[1].ev()), IsOddInt) <> [], \n computeType := self >> TBool\n));\n\nClass(divisorsIntNonSelf, AutoFoldExp, rec(\n ev := self >> [1] :: DivisorsIntNonTriv(self.args[1].ev()),\n computeType := self >> TList(TInt)\n)); \n\n#F integersBetween(<min>, <max>)\n#F returns a list min..max, as a code object\n#F\nClass(integersBetween, AutoFoldExp, rec(\n ev := self >> [self.args[1].ev() .. self.args[2].ev()],\n computeType := self >> TList(TInt)\n)); \n\n#F blocksInt(<n>, <min>, <max>)\n#F returns a list of possible block sizes min..max, as a code object\n#F block sizes is really any integers in the interval, that is less than <n>\n#F it should be defined in autolib .c files separately, depending on strategy, etc\n#F In Spiral, evaluation will use BlocksInt which will try 2-power sized blocks.\n#F This does not need to be consistent with autolib.c implementation.\n#F\nClass(blocksInt, AutoFoldExp, rec(\n ev := self >> BlocksInt(self.args[1].ev(), self.args[2].ev(), self.args[3].ev()),\n computeType := self >> TList(TInt)\n));\n\n# ---------------\n# YSV NOTE: Refactor below as above\n#\nClass(rpDivisorsIntNonTriv, Exp, rec(computeType := self>> TPtr(TInt))); \nClass(hasCoprimeFactors, Exp, rec(computeType := self >> TBool));\n\n# ---------------\n#DivisorsIntNonTrivSym := n ->\n# Cond(IsSymbolic(n), divisorsIntNonTriv(n), # inert form \n# DivisorsIntNonTriv(EvalScalar(n))); # computes divisors\n\n#DivisorsIntNonSelfSym := n ->\n# Cond(IsSymbolic(n), divisorsIntNonSelf(n), # inert form \n# Concatenation([1],DivisorsIntNonTriv(EvalScalar(n)))); # computes divisors\n\nRPDivisorsIntNonTrivSym := n ->\n Cond(IsSymbolic(n), rpDivisorsIntNonTriv(n), # inert form \n RPDivisorsIntNonTriv(EvalScalar(n))); # computes divisors\n", "meta": {"hexsha": "dacdfc9eb0da93f7c98343e324917185124a6451", "size": 2584, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/code/symdiv.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/code/symdiv.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/code/symdiv.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": 34.4533333333, "max_line_length": 99, "alphanum_fraction": 0.6400928793, "num_tokens": 772, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970654616712, "lm_q2_score": 0.7461389817407016, "lm_q1q2_score": 0.6571970255437695}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# Here I try to be very clean, when defining functions.\n# For example, no longer use .size since this often contains info from .params.\n# Instead have explicit .domain / .range\n# use checkParams instead of def, default def will just set .params\n#\n\n\n#F dLin(<N>, <a>, <b>, <t>) - interval -> diagonal linear scaling function\n#F f: i -> a*i + b,\n#F dom(f) = interval(0..N-1)\n#F range(f) = <t>, must be a type\n#F\n#F Example:\n#F spiral> dLin(8,1,1/2,TReal).tolist();\n#F [ 1/2, 3/2, 5/2, 7/2, 9/2, 11/2, 13/2, 15/2 ]\n#F\nClass(dLin, DiagFunc, rec(\n checkParams := (self, params) >> Checked(Length(params)=4,\n\tIsPosInt0Sym(params[1]), IsType(params[4]), params),\n lambda := self >> let(i:=Ind(self.params[1]), a := self.params[2], b := self.params[3],\n\tLambda(i, a*i+b).setRange(self.params[4])),\n range := self >> self.params[4],\n domain := self >> self.params[1]\n));\n\n#F dOmega(<N>, <k>) - N-th root of unity diagonal function\n#F f : TInt -> Tcomplex : i -> omega(N, k*i)\n#F\nClass(dOmega, DiagFunc, rec(\n checkParams := (self, params) >> Checked(Length(params)=2,\n\tIsPosIntSym(params[1]), IsIntSym(params[2]), params),\n lambda := self >> let(i:=Ind(), Lambda(i, omega(self.params[1], self.params[2]*i)).setRange(TComplex)),\n range := self >> TComplex,\n domain := self >> TInt\n));\n\nClass(dOmegaPow, DiagFunc, rec(\n checkParams := (self, params) >> Checked(Length(params)=3,\n\tIsPosIntSym(params[1]), IsIntSym(params[2]), IsInt(params[3]), params),\n lambda := self >> let(i:=Ind(), Lambda(i, omega(self.params[1], (self.params[2]*i))^self.params[3]).setRange(TComplex)),\n range := self >> TComplex,\n domain := self >> TInt\n));\n", "meta": {"hexsha": "0d69b4942c2ba4110778feaf61ce08539bda5a45", "size": 1751, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/diags2.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/spl/diags2.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/spl/diags2.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": 35.7346938776, "max_line_length": 124, "alphanum_fraction": 0.6299257567, "num_tokens": 568, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156293, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.6560161994357856}}
{"text": "# Checks whether the sum of two subspaces are hyperbolic\n# given a quadratic form.\nBindGlobal(\"IsHyperbolic\", function(Q)\n local s;\n s := (Size(BaseField(Q)) - 1)^2;\n return function(x, y)\n return Size(Filtered(x+y, z -> not IsZero(z*Q*z))) = s;\n end;\nend);\n\n# Checks whether two subspaces of F_{r^2} are orthogonal\n# given a sesquilinear form.\nBindGlobal(\"IsOrthogonal\", function(Q, r)\n local F;\n F := x -> List(x, y -> y^r);\n return function(x, y)\n return ForAll(Cartesian(x, y), z -> IsZero(z[1]*Q*F(z[2])));\n end;\nend);\n\n# The subset of isotropic spaces with respect to the quadratic form Q\n# of the collection V.\nBindGlobal(\"IsotropicSpacesQuadraticForm\",\n Q -> V -> Filtered(V, y -> ForAll(y, x -> IsZero(x*Q*x)))\n);\n\n# The subset of nonisotropic spaces with respect to the quadratic form Q\n# of the collection V for which the quadratic form evaluates to the same\n# quadratic residue class as z.\nBindGlobal(\"NonisotropicSpacesQuadraticForm\", function(Q, z)\n return V -> Filtered(V, y -> ForAny(y, x -> x*Q*x = z));\nend);\n\n# The subset of isotropic spaces with respect to the bilinear form Q\n# of the collection V.\nBindGlobal(\"IsotropicSpacesBilinearForm\",\n Q -> V -> Filtered(V,\n y -> ForAll(Cartesian(y, y), x -> IsZero(x[1]*Q*x[2])))\n);\n\n# The subset of isotropic spaces with respect to the scalar product with\n# conjugation map f of the collection V.\nBindGlobal(\"IsotropicSpacesSesquilinearForm\", function(Q, r)\n local O;\n O := IsOrthogonal(Q, r);\n return V -> Filtered(V, y -> O(y, y));\nend);\n", "meta": {"hexsha": "e0cd9711d86fe7ed0b014e6bbba884e2cb7a0dff", "size": 1574, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/FormFunctions.gap", "max_stars_repo_name": "jaanos/gap-graphs", "max_stars_repo_head_hexsha": "18dd56c9b90a12a717a0cc893fdd72c6343ee79b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-10-27T15:54:29.000Z", "max_stars_repo_stars_event_max_datetime": "2016-11-07T14:09:44.000Z", "max_issues_repo_path": "lib/FormFunctions.gap", "max_issues_repo_name": "jaanos/gap-graphs", "max_issues_repo_head_hexsha": "18dd56c9b90a12a717a0cc893fdd72c6343ee79b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-04-20T23:13:11.000Z", "max_issues_repo_issues_event_max_datetime": "2015-04-20T23:13:11.000Z", "max_forks_repo_path": "lib/FormFunctions.gap", "max_forks_repo_name": "jaanos/gap-graphs", "max_forks_repo_head_hexsha": "18dd56c9b90a12a717a0cc893fdd72c6343ee79b", "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": 32.7916666667, "max_line_length": 72, "alphanum_fraction": 0.6632782719, "num_tokens": 450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361652391385, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.6556715119197001}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F ExpandRotationsSPL33( <spl> )\n#F descends <spl> and replaces rotations by a product of three\n#F matrices such that multiplication with a vector requires\n#F 3 adds and 3 mults rather than 2 adds and 4 mults. More\n#F precisely:\n#F x y 1 1 0 1 0\n#F -y x --> 0 -1 1 * diag(x-y, y, x+y) * 1 1\n#F 0 1\n#F Exceptions are the cases y = x and y = -x (angles +-pi/4)\n#F which are replaced by (2 adds and 2 mults)\n#F\n#F x * F_2 * (1,2) # y = x\n#F x * (1,2) * F_2 # y = -x\n#F\nExpandRotationsSPL33 := S -> SubstTopDownNR(S, Rot, x->x.expandWinograd()); \n\n\n#F ExpandRotationsSPL33a( <spl> )\n#F descends <spl> and replaces rotations by a product of three\n#F matrices such that multiplication with a vector requires\n#F 3 adds and 3 mults rather than 2 adds and 4 mults. More\n#F precisely:\n#F x y 1 (1-x)/y 1 0 1 (1-x)/y\n#F -y x 0 1 y 1 0 1\n#F Exceptions are the cases y = x and y = -x (angles +-pi/4)\n#F which are replaced by (2 adds and 2 mults)\n#F\n#F x * F_2 * (1,2) # y = x\n#F x * (1,2) * F_2 # y = -x\n#F\nExpandRotationsSPL33a := S -> SubstTopDownNR(S, Rot, x->x.expandLifting()); \n\n\n#F ExpandRotationsSPL24( <spl> )\n#F descends <spl> and replaces rotations by the corresponding matrix,\n#F which requires (the maximum of) 2 additions and 4 multiplications.\n#F\nExpandRotationsSPL24 := S -> SubstTopDownNR(S, Rot, x->x.expandDef()); \n\nExpandRotationsSPLRandom := S -> SubstTopDownNR(S, Rot, x->x.expandRandom()); \n\n\n#F ExpandMonomialSPL( <spl> )\n#F descends <spl> and replaces monomials by products perm * diag.\n#F\nExpandMonomialSPL := \n S -> SubstTopDownNR(S, @.cond(s->ObjId(s)=Mon),\n\t\t s-> Perm(s.element.perm, Length(s.element.diag)) *\n Diag(s.element.diag));\n\n\n#F The Exporting Functions\n#F -----------------------\n#F\n\n#F ExpandRotationsSPL( <spl> )\n#F\nExpandRotationsSPL := function ( S )\n Constraint(IsSPL(S));\n\n # EXPAND_ROTATIONS is one of (see above)\n # - ExpandRotations33 sums * diag * sums\n # - ExpandRotations33a 3 lifting steps (fused mult/add)\n # - ExpandRotations24 by definition\n if EXPAND_ROTATIONS = 1 then S := ExpandRotationsSPL33(S);\n elif EXPAND_ROTATIONS = 2 then S := ExpandRotationsSPL33a(S);\n elif EXPAND_ROTATIONS = 3 then S := ExpandRotationsSPL24(S);\n elif EXPAND_ROTATIONS = 4 then S := ExpandRotationsSPLRandom(S);\n else Error(\"invalid value for EXPAND_ROTATIONS (see Doc(EXPAND_ROTATIONS))\");\n fi;\n \n return S;\nend;\n\n\n# PrintNumberToSPLNC( <x> )\n# prints the scalar <x> in SPL syntax.\n\nPrintNumberToSPLNC := function ( x )\n local precision, p, a, extra, c, n;\n\n precision := 16;\n\n # scalar case\n if IsScalar(x) then\n PrintScalarToSPLNC(x);\n return;\n # integers\n elif IsInt(x) then\n if x < 0 then Print(\"(\", x, \".0)\");\n else Print(x, \".0\");\n fi;\n return;\n # rationals\n elif IsRat(x) then\n if x < 0 then Print(\"(\", x, \")\");\n else Print(x);\n fi;\n return;\n # floats\n elif IsDouble(x) then\n if x < 0 then Print(StringDouble(\"(%.17e)\", x));\n else Print(StringDouble(\"%.17e\", x));\n fi;\n return;\n # complex numbers\n elif IsComplex(x) then\n Print(StringComplex(\"(%.17e, %.17e)\", x)); \n return;\n fi;\n\n # sqrt of a rational and real\n if x = GaloisCyc(x, -1) and IsRat(x^2) then\n if x = -Sqrt(x^2) then\n Print(\"(-sqrt(\");\n PrintNumberToSPLNC(x^2);\n Print(\"))\");\n else\n Print(\"sqrt(\");\n PrintNumberToSPLNC(x^2);\n Print(\")\");\n fi;\n return;\n fi;\n\n # x = a/b * cos(c*pi/d)\n p := RecognizeCosPi(x);\n if p <> false then\n extra := false;\n if p[1] < 0 then\n Print(\"(\");\n extra := true;\n fi;\n if p[1] = 1 then\n Print(\"cos(\");\n elif p[1] = -1 then\n Print(\"-cos(\");\n else\n Print(p[1], \"*cos(\");\n fi;\n\n a := Numerator(p[2]);\n if a = 1 then\n Print(\"pi/\", Denominator(p[2]), \")\");\n elif a = -1 then\n Print(\"-pi/\", Denominator(p[2]), \")\");\n else\n Print(Numerator(p[2]), \"*pi/\", Denominator(p[2]), \")\");\n fi;\n\n if extra then\n Print(\")\");\n fi;\n return;\n fi;\n\n # x = sqrt(2) * a/b * cos(c*pi/d)\n # this captures sum of two cosines/sines\n # the reason to include this is that the\n # substitution rule for rotations (see ExpandRotationsSPL33 or 24)\n # creates such numbers\n p := RecognizeCosPi(x/Sqrt(2));\n if p <> false then\n extra := false;\n if p[1] < 0 then\n Print(\"(\");\n extra := true;\n fi;\n\n a := Numerator(p[1]);\n if a = 1 then\n Print(\"sqrt(2)\");\n elif a = -1 then\n Print(\"-sqrt(2)\");\n else\n Print(a, \"*sqrt(2)\");\n fi;\n if not IsInt(p[1]) then\n Print(\"/\", Denominator(p[1]));\n fi;\n Print(\"*cos(\");\n\n a := Numerator(p[2]);\n if a = 1 then\n Print(\"pi/\", Denominator(p[2]), \")\");\n elif a = -1 then\n Print(\"-pi/\", Denominator(p[2]), \")\");\n else\n Print(Numerator(p[2]), \"*pi/\", Denominator(p[2]), \")\");\n fi;\n\n if extra then\n Print(\")\");\n fi;\n return;\n fi;\n\n # x = b/(a* CosPi(c/d))\n p := RecognizeCosPi(1/x);\n if p <> false then\n extra := false;\n if p[1] < 0 then\n Print(\"(-\");\n extra := true;\n fi;\n Print(Denominator(p[1]), \"/(\", AbsInt(Numerator(p[1])), \"*cos(\");\n\n a := Numerator(p[2]);\n if a = 1 then\n Print(\"pi/\", Denominator(p[2]), \")\");\n elif a = -1 then\n Print(\"-pi/\", Denominator(p[2]), \")\");\n else\n Print(Numerator(p[2]), \"*pi/\", Denominator(p[2]), \")\");\n fi;\n Print(\")\");\n\n if extra then\n Print(\")\");\n fi;\n return;\n fi;\n\n # x is a root of unity\n # note that w(n) (in spl) is E(n)^(n-1)\n a := NofCyc(x);\n if x^(2*a) = 1 then\n c := CoeffsCyc(x, a);\n n := PositionProperty(c, i -> i <> 0);\n if c[n] = 1 then\n if n = 2 then # x = E(a)\n Print(\"w(\", a, \")\");\n else\n Print(\"w(\", a, \", \", n - 1, \")\");\n fi;\n else # c[n] = -1\n if n = 2 then # x = -E(a)\n Print(\"(-w(\", a, \"))\");\n else\n Print(\"(-w(\", a, \", \", n - 1, \"))\");\n fi;\n fi;\n return;\n fi;\n\n # x is real\n if x = GaloisCyc(x, -1) then\n PrintNumberToSPLNC(ReComplex(Complex(x)));\n else \n PrintNumberToSPLNC(Complex(x));\n fi;\nend;\n", "meta": {"hexsha": "e0aef10f8d8f2a97427e556abcaf44e3a3b3c9d2", "size": 6421, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/export.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/spl/export.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/spl/export.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": 24.8875968992, "max_line_length": 81, "alphanum_fraction": 0.5396355708, "num_tokens": 2152, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901037, "lm_q2_score": 0.7577943712746406, "lm_q1q2_score": 0.6500118418204155}}
|