AutoMathText / data /code /gap /0.60-0.65.jsonl
March07's picture
add batch 3/5 (200 files)
803451e verified
Raw
History Blame Contribute Delete
266 kB
{"text": "#\n# Read(\"~/Workspace/groupsSB/epi/A2/testLieAlgebraModuleBasis.gi\");\n#\n\ntype:=\"A\";\nrank:=2;\nnr_pos_roots:=3;\n\nRead(\"~/Workspace/groupsSB/epi/group.gi\");\n\nhighest_weight:=[1,1];# corresponding highest weight module is the Lie algebra\n\nRead(\"~/Workspace/groupsSB/epi/ext.gi\");\n\n\nVb:=Basis(V);\n\n#\n# action of elements in the chevalley basis cb0 on module\n#\non_module:=List(cb0,b->List(Vb,v->Coefficients(Vb,b^v)));\n\n#\n# action of elements in the chevalley basis cb0 on module\n#\non_algebra:=List(cb0,b->List(cb0,v->Coefficients(cb0,v*b)));\n\n\n#\n# Wights of torus cb0[7],cb0[8] on module\n#\nweights_module:=[];\nAdd(weights_module,[on_module[7][1][1],on_module[8][1][1]]);\nAdd(weights_module,[on_module[7][2][2],on_module[8][2][2]]);\nAdd(weights_module,[on_module[7][3][3],on_module[8][3][3]]);\n\nAdd(weights_module,[on_module[7][4][4],on_module[8][4][4]]);\nAdd(weights_module,[on_module[7][5][5],on_module[8][5][5]]);\n\nAdd(weights_module,[on_module[7][6][6],on_module[8][6][6]]);\nAdd(weights_module,[on_module[7][7][7],on_module[8][7][7]]);\nAdd(weights_module,[on_module[7][8][8],on_module[8][8][8]]);\n\n#\n# Let a=cb0[1] and b=cb0[2]\n#\n\n#\n# Vb[1] corrsponds to a+b (heighest root) ---> cb0[3]\n#\n\n#\n# Vb[2] and Vb[3] corrspond to a and b\n#\n\n#\n# In the internal notation\n# y1 = cb0[4] corrseponding to -a corresponding to cb0[7]\n# y2 = cb0[5] corresponding to -b corresponding to cb0[8]\n# y3 = cb0[6] corresponding to -a-b\n", "meta": {"hexsha": "0aa57b208a7d87cd70e0e1a9bffc599f5dec7fed", "size": 1419, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "epi/A2/testLieAlgebraModuleBasis.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/testLieAlgebraModuleBasis.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/testLieAlgebraModuleBasis.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": 23.262295082, "max_line_length": 78, "alphanum_fraction": 0.6715997181, "num_tokens": 504, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361604769414, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.649866393981739}}
{"text": "cube := Group([(1, 2, 3, 4)(5, 6, 7, 8), (1, 4, 8, 5)(2, 3, 7, 6)]);\n\nOrder(cube);\n\ndegree := 8;\ncolorings := Filtered(\n Combinations(Cartesian([1..degree], [\"b\",\"w\"]), degree)\n, \\c -> Size(Set(List(c, \\a -> a[1]))) = degree\n);\n\nSize(colorings);\n\nOnFunctions := function(omega, g)\n local result;\n result := List(omega, t -> [t[1]^g, t[2]]);\n SortBy(result, t -> t[1]);\n return result;\nend;\n\norbits := Orbits(cube, colorings, OnFunctions);\nSize(orbits);\n\nimage := OnFunctions([\n [1, \"w\"],\n [2, \"w\"],\n [3, \"w\"],\n [4, \"b\"],\n [5, \"b\"],\n [6, \"b\"],\n [7, \"b\"],\n [8, \"b\"],\n], cube.1);\n\nIsFixed := function(omega, g)\n return OnFunctions(omega, g) = omega;\nend;\n\nfixed := Filtered(colorings, \\c -> IsFixed(c, cube.1));\n\norbitCount := 1/Order(cube) * Sum(\n List(Elements(cube), \\g -> Size(Filtered(colorings, \\c -> IsFixed(c, g))))\n);\n", "meta": {"hexsha": "033067ec2c6fda6b2dacdaf817c0a1b7d88f862d", "size": 857, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "session.gap", "max_stars_repo_name": "dvberkel/burnside", "max_stars_repo_head_hexsha": "469ff7a02a13d0c3377a4d2c013632fdeede34cb", "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": "session.gap", "max_issues_repo_name": "dvberkel/burnside", "max_issues_repo_head_hexsha": "469ff7a02a13d0c3377a4d2c013632fdeede34cb", "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": "session.gap", "max_forks_repo_name": "dvberkel/burnside", "max_forks_repo_head_hexsha": "469ff7a02a13d0c3377a4d2c013632fdeede34cb", "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.9302325581, "max_line_length": 76, "alphanum_fraction": 0.5344224037, "num_tokens": 317, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513620489619, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6496659776592256}}
{"text": "#\n# Read(\"~/Workspace/groupsSB/epi/A2/actionFromExt1.gi\");\n#\n\ntype:=\"A\";\nrank:=2;\nnr_pos_roots:=3;\nhighest_weight:=[1,1];# corresponding highest weight module is the Lie algebra\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\nextA1:=extA[1];\nextA1b:=extA_basis[1];\n\n#extA:=List([1..Dimension(V)],i->ExteriorPower( i ,V ));\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\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\next1_coeff_comb:=function(coeffs)\n local result,extb;\n extb:=extA_basis[1];\n result:=List([1..Length(extb)],i->coeffs[i]*extb[i]);\n return Sum(result);\nend;\n\next1_root_group_basis_img:=function(index,t)\n local rg,result;\n rg:=ext1_root_group(index,t);\n rg:=TransposedMat(rg);\n result:=List(rg,l->ext1_coeff_comb(l));\n return result;\nend;\n\n\n# ObjByExtRep(FamilyObj(bbb[1]),ExtRepOfObj(bbb[1]));\n\nu1Bimg:=ext1_root_group_basis_img(1,1);\n\nqqq:=ExtRepOfObj(extA_basis[2][1]);\nIsWedgeElement(qqq);\nConvertToNormalFormMonomialElement(qqq);\n\nn:=2;\nfam:=FamilyObj(qqq);\ncombs:= Combinations( [1..Dimension(L)], n );\ngens:= List( combs, x -> Basis(L){x} );\nF:=LeftActingDomain(L);\ngens2:= List( gens, x -> ObjByExtRep( fam, [ x , One(F) ] ) );\n \nfor i in [1..Length(gens)] do\n gens2[i]![2]:= true;\nod;\n\ntest:=[2,2];\ntest:=Basis(L){test};\ntest:=ObjByExtRep( fam, [ test , One(F) ] );\ntest![2]:=true;\ntest:=ConvertToNormalFormMonomialElement(test);\n\n\nM:=AdjointModule(L);\nextA2:=ExteriorPowerOfAlgebraModule(M,2);\n\n\n#\n#\n#\nextA1:=extA[1];\nbv:=BasisVectors(Basis(extA1));\nbb:=ext1_root_group_basis_img(1,1);\nB:= Algebra( Rationals, bb, \"basis\" );\n#AlgebraHomomorphismByImages( extA1, extA1, bv, bb )\n\nLeftModuleGeneralMappingByImages( extA1, extA1, bv, bb );\nLeftModuleHomomorphismByImages( extA1, extA1, bv, bb );", "meta": {"hexsha": "2da3e0a4e566a7a72e079a8a8b8df8b8f3906999", "size": 2284, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "epi/A2/actionFromExt1.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/actionFromExt1.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/actionFromExt1.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": 22.1747572816, "max_line_length": 78, "alphanum_fraction": 0.6860770578, "num_tokens": 771, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110368115783, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6492165451253885}}
{"text": "\n## Copyright (c) 2018-2021, Carnegie Mellon University\n## See LICENSE for details\n\nNewRulesFor(MDPRDFT, rec(\n #F Rule MDPRDFT_Base: MDPRDFT -> PRDFT1\n #F\n #F Apply this rule when Length(a_lengths()) = 1.\n #F QUESTION: What do the tags mean?\n #F Note MDPRDFT.hasTags() = false = IMDPRDFT.hasTags().\n #F\n MDPRDFT_Base := rec(\n info := \"MDPRDFT -> PRDFT1\",\n applicable := nt -> Length(nt.a_lengths())=1,\n\n # Generally, children is list of ordered lists of all possible children.\n children := nt -> let(tags := nt.getTags(),\n a_lengths := nt.a_lengths(),\n a_exp := nt.a_exp(),\n [[ PRDFT1(a_lengths[1], a_exp).withTags(tags) ]]),\n\n # nonterminal, children, children non-terminals\n apply := (nt, C, Nonterms) -> C[1]\n ),\n\n #F MDPRDFT_RowCol1: MDPRDFT(n_1,n_2,...,n_t) = (RC(MDDFT(n_1,n_2,...,n_{t-1}) x I(.))) (I(n_1*n_2*...*n_{t-1}) x PRDFT1(n_t))\n #F\n #F Apply this rule when Length(a_lengths()) > 1 and no tags.\n #F QUESTION: What do the tags mean?\n #F I find MDPRDFT.hasTags() = IMDPRDFT.hasTags() = false.\n #F\n MDPRDFT_RowCol1 := rec(\n info :=\"MDDFT(n_1,n_2,...,n_t) = (RC(MDDFT(n_1,n_2,...,n_{t-1}) x I(.))) (I(n_1*n_2*...*n_{t-1}) x PRDFT1(n_t))\",\n applicable := nt -> Length(nt.a_lengths())>1 and not nt.hasTags(),\n # Generally, children is list of ordered lists of all possible children.\n # 2 children, both with same parameter a_exp():\n # [1] MDDFT on all but last dimension;\n # [2] PRDFT1 on last dimension, the fastest varying dimension.\n children := nt -> let(a_lengths := nt.a_lengths(),\n a_exp := nt.a_exp(),\n [[ MDDFT(DropLast(a_lengths, 1), a_exp),\n PRDFT1(Last(a_lengths), a_exp) ]]),\n\n # nonterminal, children, children non-terminals\n apply := (nt, C, cnt) -> let(a_lengths := nt.a_lengths(),\n Clast := C[2],\n Crest := C[1],\n Nlastcomplex := Clast.dims()[1]/2,\n Nrest := DropLast(a_lengths, 1),\n Nallbutlast := Product(Nrest),\n # Apply Clast on last dimension,\n # then Crest on all dimensions but last.\n RC(Tensor(Crest, I(Nlastcomplex))) *\n Tensor(I(Nallbutlast), Clast)\n )\n )\n));\n\n\nNewRulesFor(IMDPRDFT, rec(\n #F Rule IMDPRDFT_Base: IMDPRDFT -> IPRDFT1\n #F\n #F Apply this rule when Length(a_lengths()) = 1.\n #F QUESTION: What do the tags mean?\n #F Note MDPRDFT.hasTags() = false = IMDPRDFT.hasTags().\n #F\n IMDPRDFT_Base := rec(\n info := \"IMDPRDFT -> IPRDFT1\",\n applicable := nt -> Length(nt.a_lengths())=1,\n # Generally, children is list of ordered lists of all possible children.\n children := nt -> let(tags := nt.getTags(),\n a_lengths := nt.a_lengths(),\n a_exp := nt.a_exp(),\n [[ IPRDFT1(a_lengths[1], a_exp).withTags(tags) ]]),\n # nonterminal, children, children non-terminals\n apply := (nt, C, Nonterms) -> C[1]\n ),\n\n #F IMDPRDFT_RowCol1: IMDPRDFT(n_1,n_2,...,n_t) = (RC(IMDDFT(n_1,n_2,...,n_{t-1}) x I(.))) (I(n_1*n_2*...*n_{t-1}) x IPRDFT1(-n_t))\n #F\n #F Apply this rule when Length(a_lengths()) > 1 and no tags.\n #F QUESTION: What do the tags mean?\n #F I find MDPRDFT.hasTags() = IMDPRDFT.hasTags() = false.\n #F\n #F FIXME: This is not done yet.\n #F\n IMDPRDFT_RowCol1 := rec(\n info :=\"IMDDFT(n_1,n_2,...,n_t) = (RC(IMDDFT(n_1,n_2,...,n_{t-1}) x I(.))) (I(n_1*n_2*...*n_{t-1}) x PRDFT1(-n_t))\",\n applicable := nt -> Length(nt.a_lengths())>1 and not nt.hasTags(),\n # Generally, children is list of ordered lists of all possible children.\n # 2 children, both with same parameter a_exp():\n # [1] IMDDFT on all but last dimension;\n # [2] IPRDFT1 on last dimension, the fastest varying dimension.\n children := nt -> let(a_lengths := nt.a_lengths(),\n a_exp := nt.a_exp(),\n [[ MDDFT(DropLast(a_lengths, 1), a_exp),\n IPRDFT1(Last(a_lengths), a_exp) ]]),\n\n # nonterminal, children, children non-terminals\n apply := (nt, C, cnt) -> let(a_lengths := nt.a_lengths(),\n Clast := C[2],\n Crest := C[1],\n Nlastcomplex := Clast.dims()[2]/2,\n Nrest := DropLast(a_lengths, 1),\n Nallbutlast := Product(Nrest),\n # Apply Crest on all dimensions but last,\n # then Clast on last dimension.\n Tensor(I(Nallbutlast), Clast) *\n RC(Tensor(Crest, I(Nlastcomplex)))\n )\n )\n));\n", "meta": {"hexsha": "ad45b2ef51a4e554d691aa3002eb3b8bff171878", "size": 5437, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "breakdown/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": "breakdown/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": "breakdown/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": 48.1150442478, "max_line_length": 135, "alphanum_fraction": 0.4787566673, "num_tokens": 1444, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032942014971871, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.6491021534813692}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# This file contains code relevant to arbitrary bit matrices.\n# At some point, Marek and I should make one file of this sort that we can both use. (PM)\n\n\n## BitMatrixToInts(P) returns bit matrix converted into integers (0, 1).\n##\nBitMatrixToInts := meth(x)\n return List([1 .. Length(x)], i-> IntVecFFE(x[i]));\nend;\n\n\n## PrintBitMatrix(P) prints bit matrix P in a readable form.\n##\nPrintBitMatrix := meth(x)\n PrintMat(BitMatrixToInts(x));\nend;\n\n\n## NumberBitRep(x, b) returns a b-bit number, formed as a vector over GF(2),\n## corresponding to decimal number x.\n##\nNumberBitRep := meth(x, bits)\n return Reversed(List([1..bits], i -> [ Mod(QuoInt(x, 2^(i-1)), 2) * GF(2).one ] ));\nend;\n\n\n## BitsToNumber(x) returns the decimal number associated with bit vector x.\n##\nBitsToNumber := meth(x)\n return Sum(List([1..Length(x)], i -> 2^(i-1) * IntVecFFE(Reversed(x)[i])[1])); \nend;\n\n\n## BasisVecToNum(b) returns a number corresponding to given basis\n## vector b.\n##\nBasisVecToNum := meth(b)\n return Sum(List([1..Length(b)], i -> Cond(IsList(b[i]), b[i][1], b[i]) * (i-1)));\nend;\n\n\n## BitsToPermMatrix(P) returns the SPL permutation matrix corresponding\n## to bit matrix P.\n##\nBitsToPermMatrix := meth(P)\n local x, l;\n x := [];\n l := Dimensions(P)[1];\n\n x := List([1..2^l], i -> BasisVec(2^l, BitsToNumber(P * NumberBitRep(i-1, l))));\n\n return Transposed(x);\nend;\n\nDeclare(TransposeVector);\n\n## PermMatrixToBits(P) returns the bit matrix associated with\n## permutation matrix P.\n##\nPermMatrixToBits := function(perm)\n local length, res, i, logLength, pm;\n\n length := Length(perm);\n logLength := Log2Int(length);\n\n res := [];\n for i in [0..logLength-1] do\n res[logLength-i] := \n TransposeVector(\n\t NumberBitRep(\n\t BasisVecToNum(\n\t perm * TransposeVector(BasisVec(length, 2^i))\n\t ), logLength\n\t )\n\t );\n od;\n\n res := TransposedMat(res);\n\n pm := BitsToPermMatrix(res);\n\n if (Length(pm) <> Length(perm) or Maximum(Maximum(pm - perm)) <> 0) then\n# Print(\"ERROR: Given matrix is not a permutation or is not linear on the bits.\\n\");\n return -1;\n fi; \n\n return res;\n end;\n\n\n# ===============================================\n# A permutation represented as a linear mapping on the bits\n# LinearBits(matrix over GF(2), <SPL Permutation object>)\n# ===============================================\nClass(LinearBits, BaseMat, SumsBase, rec(\n\tnew := (self, m, p) >> \n\t SPL(WithBases(self, \n\t\t rec(\n\t\t dimensions := [2^Length(m), 2^Length(m)],\n\t\t _children := [m, p]\n\t\t )\n\t)),\n\n\trSetChild := meth(self, n, what) \n\t self._children[n] := what; \n\tend,\n\n\trChildren := self >> self._children,\n\tchild := (self, n) >> self._children[n],\n\tchildren := self >> self._children,\n\n\tcreateCode := self >> self,\n print := (self,i,is) >> Print(self.name, \"(\", self._children[1], \")\"),\n\n\ttoAMat := self >> AMatMat(BitsToPermMatrix(self.child(1))),\n\tdims := self >> [2^(Length(self._children[1])), 2^(Length(self._children[1]))],\n\n\tsums := self >> self\n));\n\n\nTL.permBits := \n meth(self)\n local stride, logStride, size, logSize, res, row, i, j, a, b;\n\tstride := self.params[2];\n\tlogStride := Log2Int(stride);\n\tsize := self.params[1];\n\tlogSize := Log2Int(size);\n\ta := Log2Int(self.params[3]);\n\tb := Log2Int(self.params[4]);\n\tres := [];\n\n\tfor i in [1 .. a] do\n\t row := Concatenation([ List([1 .. i-1], i -> 0*GF(2).one), \n\t\t [ GF(2).one ], \n\t\t\t\t List([i+1 .. a], i -> 0*GF(2).one),\n\t\t\t\t List([1 .. logSize], i -> 0*GF(2).one),\n\t\t\t\t List([1 .. b], i -> 0*GF(2).one) ]);\n\n\t Append(res, [row]);\n\tod;\n\n\tfor i in [logSize-logStride+1 .. logSize] do\n\t row := Concatenation([ List([1 .. a], i -> 0*GF(2).one),\n\t\t List([1 .. i-1], i -> 0*GF(2).one),\n\t\t\t\t [ GF(2).one ],\n\t\t\t\t List([i+1 .. logSize], i -> 0*GF(2).one),\n\t\t\t\t List([1 .. b], i -> 0*GF(2).one)]);\n\t \n\t Append(res, [row]);\n\tod;\n\t\n\tfor i in [1 .. logSize-logStride] do\n\t row := Concatenation([ List([1 .. a], i -> 0*GF(2).one),\n\t\t List([1 .. i-1], i -> 0*GF(2).one),\n\t\t\t\t [ GF(2).one ],\n\t\t\t\t List([i+1 .. logSize], i -> 0*GF(2).one),\n\t\t\t\t List([1 .. b], i -> 0*GF(2).one)]);\n\n\t Append(res, [row]);\n\tod;\n\n\tfor i in [1 .. b] do\n\t row := Concatenation([ List([1 .. a], i -> 0*GF(2).one),\n\t\t List([1 .. logSize], i -> 0*GF(2).one),\n\t\t\t\t List([1 .. i-1], i -> 0*GF(2).one),\n\t\t\t\t [ GF(2).one ],\n\t\t\t\t List([i+1 .. b], i -> 0*GF(2).one)]);\n\n\t Append(res, [row]);\n\tod;\n\n\treturn res;\nend;\n\nDR.permBits := meth(self)\n local k, n, res;\n k := LogInt(self.params[2], 2);\n n := LogInt(self.domain(), 2);\n return MatSPL(Tensor(J(n/k), I(k))) * GF(2).one;\nend;", "meta": {"hexsha": "54105ec0738dfba145430535f706a53c79433e99", "size": 4945, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/stream/bitperms.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/paradigms/stream/bitperms.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/paradigms/stream/bitperms.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": 26.5860215054, "max_line_length": 90, "alphanum_fraction": 0.5369059656, "num_tokens": 1538, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392756357327, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.6489904999333915}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n#s:=SPLRuleTree(ExpandSPL(PolyBDFT3(16))[1]);\n\n#s:=SPLRuleTree(ExpandSPL(BSkewDFT3(16))[1]);\n# Even1 -- Odd0\ns := K(16,4) * \n DirectSum(\n\t BSkewDFT3(4, 1/16), \n\t BSkewDFT3(4, 3/16), \n\t BSkewDFT3(4, 5/16), \n\t BSkewDFT3(4, 7/16)\n ) * \n L(16,8) *\n Tensor(I(2), PolyBDFT3(8, 1/4));\n L(16,2);\n\n\nleft := K(8,2) * \n DirectSum(\n\t SkewDTT(DCT3(2), 1/8), \n\t SkewDTT(DCT3(2), 3/8), \n\t SkewDTT(DCT3(2), 5/8), \n\t SkewDTT(DCT3(2), 7/8)\n );\n\n right:=MatSPL(left)^-1 * MatSPL(DCT3(8));\n\nspiral> ps(MatSPL(L(8,2))*right*MatSPL(L(8,4)));\n\n\nleft := K(8,4) * \n DirectSum(\n\t SkewDTT(DCT3(4), 1/4), \n\t SkewDTT(DCT3(4), 3/4)\n );\n\n right:=MatSPL(left)^-1 * MatSPL(DCT3(8));\n\nspiral> ps(MatSPL(L(8,4))*right*MatSPL(L(8,2)));\n\n# X * BRDFT * IJ = BRDFT, X = BRDFT * IJ * BRDFT^-1\n# Y * BRDFT * IJ = BRDFT * J, Y = BRDFT*J*IJ*BRDFT^-1\n# \nc3polyalgo := function(N,m,a) \n local k, left, right, zz, mid;\n k := N/2/m;\n zz := RulesDFTSymmetry(L(N, m) * GathExtend(N,Odd0));\n left := K(N/2,m) * DirectSum(List([0..k-1], i -> SkewDTT(DCT3(m), fr(k,i,a).ev())));\n right := DirectSum(\n\tSkewDTT(DCT3(k), a), \n\tList([1..(m-2)/2], i -> BRDFT3(2*k,a/2)*DirectSum(I(1), -J(2*k-1))), \n\tPolyDTT(SkewDTT(DCT4(k),a))\n ) * \n Compose(Drop(zz.children(), 1));\n\n mid := MatSPL(left)^-1 * MatSPL(SkewDTT(DCT3(N/2),a)) * MatSPL(right)^-1;\n #PrintMat(mid);\n VisualizeMat(mid, \", \");\n return mid;\nend;\n\n\n#N := 32; m := 4; k := N/2/m;\n\n#[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]\nmid := c3polyalgo(32,8);\np:=Prm(FList([0,2,3,6,7,10,11,14, 1,4,5,8,9,12,13, 15]).setRange(15));\n\nps(mid * MatSPL(p)^-1);", "meta": {"hexsha": "77d983589d4b09a597f168f5db4485899894f222", "size": 1717, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sym/proj3.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/proj3.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/proj3.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": 23.8472222222, "max_line_length": 88, "alphanum_fraction": 0.5428072219, "num_tokens": 828, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505351008906, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6472087060985301}}
{"text": "# The Loop function will apply some function to every tuple built by taking\n# the i-th element of each list. If one of them is exhausted before the others,\n# the loop continues at its begining. Only the longests lists will be precessed only once.\nLoop := function(a, f)\n local i, j, m, n, v;\n n := Length(a);\n v := List(a, Length);\n m := Maximum(v);\n for j in [1 .. m] do\n f(List([1 .. n], i -> a[i][1 + RemInt(j - 1, v[i])]));\n od;\nend;\n\n# Here we simply print each \"row\"\nf := function(u)\n Perform(u, Print);\n Print(\"\\n\");\nend;\n\nLoop([[\"a\", \"b\", \"c\"], [\"A\", \"B\", \"C\"], [1, 2, 3]], f);\n\naA1\nbB2\ncC3\n\nLoop([[\"a\", \"b\"], [\"A\", \"B\", \"C\", \"D\", \"E\"], [1, 2, 3]], f);\n\naA1\nbB2\naC3\nbD1\naE2\n", "meta": {"hexsha": "bbb7688238e73b53b659a02aaad4b5c79ca1ee5c", "size": 713, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Loop-over-multiple-arrays-simultaneously/GAP/loop-over-multiple-arrays-simultaneously.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/Loop-over-multiple-arrays-simultaneously/GAP/loop-over-multiple-arrays-simultaneously.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/Loop-over-multiple-arrays-simultaneously/GAP/loop-over-multiple-arrays-simultaneously.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": 21.6060606061, "max_line_length": 90, "alphanum_fraction": 0.5483870968, "num_tokens": 261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.8056321959813275, "lm_q1q2_score": 0.6470626693136702}}
{"text": "Anagrams := function(name)\n local f, p, L, line, word, words, swords, res, cur, r;\n words := [ ];\n swords := [ ];\n f := InputTextFile(name);\n while true do\n line := ReadLine(f);\n if line = fail then\n break;\n else\n word := Chomp(line);\n Add(words, word);\n Add(swords, SortedList(word));\n fi;\n od;\n CloseStream(f);\n p := SortingPerm(swords);\n L := Permuted(words, p);\n r := \"\";\n cur := [ ];\n res := [ ];\n for word in L do\n if SortedList(word) = r then\n Add(cur, word);\n else\n if Length(cur) > 0 then\n Add(res, cur);\n fi;\n r := SortedList(word);\n cur := [ word ];\n fi;\n od;\n if Length(cur) > 0 then\n Add(res, cur);\n fi;\n return Filtered(res, v -> Length(v) > 1);\nend;\n\n\nana := Anagrams(\"my/gap/unixdict.txt\");;\n\n# What is the longest anagram sequence ?\nMaximum(List(ana, Length));\n# 5\n\n# Which are they ?\nFiltered(ana, v -> Length(v) = 5);\n# [ [ \"abel\", \"able\", \"bale\", \"bela\", \"elba\" ],\n# [ \"caret\", \"carte\", \"cater\", \"crate\", \"trace\" ],\n# [ \"angel\", \"angle\", \"galen\", \"glean\", \"lange\" ],\n# [ \"alger\", \"glare\", \"lager\", \"large\", \"regal\" ],\n# [ \"elan\", \"lane\", \"lean\", \"lena\", \"neal\" ],\n# [ \"evil\", \"levi\", \"live\", \"veil\", \"vile\" ] ]\n", "meta": {"hexsha": "4d9f7776d5f35623106265aab1fbf19991d7479d", "size": 1234, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Anagrams/GAP/anagrams.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/Anagrams/GAP/anagrams.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/Anagrams/GAP/anagrams.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 22.8518518519, "max_line_length": 56, "alphanum_fraction": 0.5153970827, "num_tokens": 418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467611766711, "lm_q2_score": 0.734119526900183, "lm_q1q2_score": 0.645398804390846}}
{"text": "# Codes related to Rationality of Algebraic Tori.\n# This file contains all codes written by myself.\n\nSub_Matrix:= function(G,L,M)\n#Inputs: G as a finite group, L list with 2 entries showing the interval of desired rows, M list with 2 \n# entries showing the interval of desired columns. The output is a list containing extracted submatrices\n# from generators of group G. \nlocal g,H;\nH:= [];\n\tfor g in GeneratorsOfGroup(G) do \n\t\tAppend(H,[g{[L[1]..L[2]]}{[M[1]..M[2]]}]);\n\tod;\nreturn(H);\nend;\n\n\nGDual:= function(G)\n# this function returns the dual G-lattice, by transposing the generators of G.\n\n\tlocal i,L,n,T,Gp;\n\n\tT:= GeneratorsOfGroup(G);\n\n\tn:= Size(T);\n\n\tL:=[];\n\tfor i in [1..n] do \n\t\tL[i]:= TransposedMat(T[i]);\n\tod;\n\n\tGp:= GroupByGenerators(L);\n\treturn(Gp);\nend;\n\n\nRank1PermQuot:= function(G)\n\nlocal Denom,\t\t# List of all denominators of entries of a vector.\n\tSDenom,\t\t# Size of Denom.\n\tgens,\t\t# A generating list for the rank m-1 subgroup (sublattice\n\t\t\t# of the dual lattice).\n\tH,\t\t# The Corresponding group of the dual lattice.\n\tHH,\t\t# A list of Generators of H.\n\tI,\t\t# Identity matrix of size equal to rank of G\n\tK,\t\t# An appropriate conjugate of the dual group in which,\n\t\t\t# the invariant sublattice of rank m-1 is readable.\n\tL,\t\t# The record containing the vectors which extend\n\t\t\t# the sign vector to a basis fo lattice.\n\tLCM,\t\t# The least common multiple of Denom.\n\tm,\t\t# The rank of group\n\tW,\t\t# A list of vectors which is formed by bases of eigenspaces.\n\tR,\t\t# A mutable copy of extended basis.\n\tr,\t\t# A mutable copy of the basis for the invariant space.\n\tS,\t\t# GAP ID of the rank n-1 invariant for the original lattice.\n\tG1,\t\t# The group asocciated to an invariant subspace of rank m-1 in the original lattice.\n\tRes;\t\t# Record containing all the information of the reduction process.\n\tH:= GDual(G);\n\tHH:= GeneratorsOfGroup(H);\n\tm:= Size(HH[1]);\n\tI:= HH[1]^0;\n\tW:= BaseFixedSpace(HH);\n\t\n\tif Size(W)<>0 then\n\t\tif ForAll(W[1], IsInt) = false then\n\t\t\tDenom := List(W[1], w-> DenominatorRat(w));\n\t\t\tLCM:= Denom[1];\n\t\t\tSDenom:= Size(Denom);\n\t\t\tfor i in [2..SDenom] do\n\t\t\t\tLCM:= LcmInt(LCM,Denom[i]);\n\t\t\tod;\n\t\t\tW[1]:= LCM*W[1];\n\t\telse\n\t\t\tW[1]:= W[1];\n\t\tfi;\n\t\tL:= ComplementIntMat(I,[W[1]]);\n\t\tR:= ShallowCopy(L.complement);\n\t\tr:= ShallowCopy(L.sub);\n\t\tAppend(R,r);\n\t\tif IsInt(Determinant(R)) = true and AbsInt(Determinant(R))=1 then\n\t\t\tK:= ConjugateGroup(H,R^(-1));\n\t\t\tgens:= Sub_Matrix(K,[1,m-1],[1,m-1]);\n\t\t\tG1:= GDual(GroupByGenerators(gens));\n\t\t\tS:= CrystCatZClass(G1);\n\t\t\tRes:= rec(Structure:= StructureDescription(G), DualGens:= HH, Trans:= R^(-1), \t\t \t\t\t\tNewG:=GeneratorsOfGroup(GDual(K)),SubLatGens:= GeneratorsOfGroup(G1), ZClassSubLat:= S);\t\n\t\t\treturn(S);\n\t\telse\n\t\t\treturn(fail);\n\t\tfi;\n\telse\n\t\t#Print(\"No Permutation lattice of Rank 1\\n\");\n\t\treturn(fail);\n\t\t\n\tfi;\nend;\n\n###### For a given lattice (represented by finite number of unimodular matrices)\n# The function calculates intersections of Eigenspaces for eigenvalues one and \n# negative one. In Case that there is a nonzero intersection, it returns the basis.\n# Input: a finite subgroup of GL(n,Z).\n# Output: The conjugation element for the dual lattice which is a matrix in GL(n,Z).\n#\t An invariant sublattice of the corresponding lattice to G, of rank 4 where\n#\t the quotient of the original lattice and the output is a sign permutation. \n\nRank1SgnPermQuot:= function(G)\n\nlocal \n\tBEigSP,\t\t# Duplicate free list of bases of intersection of eigenspaces.\n\tEigSp,\t\t# List of all eigenspaces of all generators of G.\n\tEigSP,\t\t# List of Cartesian product of EigSp.\n\tDenom,\t\t# List of all denominators of entries of a vector.\n\tgens,\t\t# A generating list for the rank 4 subgroup (invariant sublattice\n\t\t\t# of the dual lattice).\n\tH,\t\t# The Corresponding group of the dual lattice.\n\tHH,\t\t# A list of Generators of H.\n\tI,\t\t# Identity Matrix of rank 5.\n\tInterEigSP,\t# A list of Intersections of eigenspaces.\t\t\n\tK,\t\t# An appropriate conjugate of the dual group in which,\n\t\t\t# the invariant sublattice of rank 4 is easily readable.\n\tl,\t\t# rank of lattice\n\tL,\t\t# The record containing the vectors which extend\n\t\t\t# the sign vector to a basis fo lattice.\n\tLCM,\t\t# The least common multiple of Denom.\n\tW,\t\t# A list of vectors which is formed by bases of eigenspaces.\n\tR,\t\t# A mutable copy of extended basis.\n\tRec,\n\tr,\t\t# A mutable copy of the basis for the sign invariant space.\n\tS,\t\t# GAP ID of the rank n-1 invariant for the original lattice.\n\tSgen,\t\t# The size of a generating set of H.\t\n\tG1;\t\t# An invariant subspace of rank 4 in the original lattice.\n\n\tH:= GDual(G);\n\tHH:= GeneratorsOfGroup(H);\n\tI:= HH[1]^0;\n\tl:= Size(I);\n\tSgen:= Size(HH);\n\tEigSp:= List([1..Sgen],x->[]);\n\tfor i in [1..Sgen] do\n\t\tAppend(EigSp[i],Eigenspaces(Rationals,HH[i]));\n\tod;\n\tEigSP:= Cartesian(EigSp);\n\tInterEigSP:= [];\n\tfor a in EigSP do \n\t\tn:= Size(a);\n\t\tS:= a[1];\n\t\tfor i in [2..n] do\n\t\t\tS:= Intersection(S,a[i]);\n\t\tod;\n\t\tAppend(InterEigSP,[S]);\n\tod;\n\tBEigSP:= Set(List(InterEigSP,t->GeneratorsOfVectorSpace(t)));\n\tRemove(BEigSP,Position(BEigSP,[])); \n\tif BEigSP <> [] then\n\t\tW:= ShallowCopy(BEigSP[1]);\n\n\t\tif Size(W)<>[] then\n\t\t\tif ForAll(W[1], IsInt) = false then\n\t\t\t\tDenom := List(W[1], w-> DenominatorRat(w));\n\t\t\t\tLCM:= Denom[1];\n\t\t\t\tfor i in [2..Size(Denom)] do\n\t\t\t\t\tLCM:= LcmInt(LCM,Denom[i]);\n\t\t\t\tod;\n\t\t\t\tW[1]:= LCM*W[1];\n\t\t\telse\n\t\t\t\tW[1]:= W[1];\n\t\t\tfi;\n\t\t\tL:= ComplementIntMat(I,W);\n\t\t\tR:= ShallowCopy(L.complement);\n\t\t\tr:= ShallowCopy(L.sub);\n\t\t\tAppend(R,r);\n\t\t\t\t\n\t\t\t\tK:= ConjugateGroup(H,R^(-1));\n\t\t\t\tgens:= Sub_Matrix(K,[1,l-1],[1,l-1]);\n\t\t\t\tG1:= GDual(GroupByGenerators(gens));\n\t\t\t\tS:= CrystCatZClass(G1);\n\t\t\t\tPrint(R^(-1),\"\\n\");\n\t\t\t\tRec:= rec(DualGens:= HH, Trans:= R^(-1), NewG:= GeneratorsOfGroup(GDual(K)),\n SubLatGens:= GeneratorsOfGroup(G1), ZClassSubLat:= S);\t\t\t\t\n\t\t\t\t\treturn(S);\n\t\telse\n\t\t\tPrint(\"No sign permutation lattice of rank 1\\n\");\n\t\t\n\t\tfi;\n\telse\n\t\tPrint(\"No sign permutation lattice of rank 1\\n\");\n\tfi;\nend;\n\n\n", "meta": {"hexsha": "1fb6c29ad690db5a6da3b314079c564acd10e822", "size": 5927, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "latred.gap", "max_stars_repo_name": "ajamshid/Algebraic-Tori", "max_stars_repo_head_hexsha": "6ba715a1fb604a7650e9ddf703b6ae55fd0499e1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-15T15:27:25.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-15T15:27:25.000Z", "max_issues_repo_path": "latred.gap", "max_issues_repo_name": "armin-jamshidpey/Algebraic-Tori", "max_issues_repo_head_hexsha": "6ba715a1fb604a7650e9ddf703b6ae55fd0499e1", "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": "latred.gap", "max_forks_repo_name": "armin-jamshidpey/Algebraic-Tori", "max_forks_repo_head_hexsha": "6ba715a1fb604a7650e9ddf703b6ae55fd0499e1", "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": 31.3597883598, "max_line_length": 177, "alphanum_fraction": 0.6605365278, "num_tokens": 1910, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8807970779778824, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.643914265048996}}
{"text": "\n# Copyright 2018-2019, Carnegie Mellon University\n# See LICENSE for details\n#\n# CNOT Base object\n#\n\n\n##\n#F GenCnotMat( <j>, <dir> )\n## \n## Expands into a 2^i by 2^i CNOT matrix. CNOT-ing between i and 0 depending on dir\n## if dir = 1 then i -> 0, if dir = 0 then 0 -> i\nGenCnotMat:= function (j, dir)\n local m1, m2;\n # if 0 controlling j\n if j = 0 then \n return I(1);\n fi;\n m1 := VStack( HStack(I(2^(j)), O(2^(j))), HStack(O(2^(j)), Tensor(I(2^(j-1)), qX())) );\n # if j controlling 0\n m2 := qHT(j+1) * m1 * qHT(j+1);\n return When(dir = 0, m1, m2);\nend;\n\n#F -----------------------------------------------------------------------------\n#F CNOT(j, a) - CNOT gate size j, swapping qubit index 0 and index j\n#F a takes on {0, 1} indicating which is the controlling qubit\n#F affected qubit is implicitly the other qubit. acts on a 2-qubit state vector\n#F -----------------------------------------------------------------------------\nClass(CNOT, Sym, rec(\n def := (j, a) -> GenCnotMat(j, a),\n isReal := False,\n isPermutation := False,\n transpose := self >> self,\n conjTranspose := self >> self,\n inverse := self >> self,\n toAMat := self >> self.def(self.params[1], self.params[2]),\n ));\n\n\n", "meta": {"hexsha": "2993273e9df35cb82da3ca4127268275b1db395b", "size": 1243, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "qspl_cnot.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_cnot.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_cnot.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": 29.5952380952, "max_line_length": 91, "alphanum_fraction": 0.5172968624, "num_tokens": 381, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933093946927837, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.6419271218571001}}
{"text": "# A hyperconic in a Desarguesian projective plane of order 2^s.\nBindGlobal(\"HyperconicProjectivePlane\",\n s -> rec(points := Set(List(Union([[0,1,0], [1,0,0]]*Z(2^s)^0,\n List(GF(2^s), t -> [t, t^2, 1]*Z(2^s)^0)),\n x -> Subspace(GF(2^s)^3, [x], \"basis\"))),\n group := HyperconicAutomorphismGroup(2^s), d := 2, q := 2^s)\n);\n\n# A classical conic in a Desarguesian projective plane of order q.\nBindGlobal(\"ClassicalConicProjectivePlane\",\n q -> rec(points := Set(List(Union([[0,1,0]]*Z(q)^0, List(GF(q),\n t -> [t, t^2, 1]*Z(q)^0)), x -> Subspace(GF(q)^3, [x], \"basis\"))),\n group := HyperconicAutomorphismGroup(q), d := 2, q := q)\n);\n\n# A nonclassical conic in a Desarguesian projective plane of order q.\nBindGlobal(\"NonclassicalConicProjectivePlane\",\n q -> rec(points := Set(List(Union([[1,0,0]]*Z(q)^0, List(GF(q),\n t -> [t, t^2, 1]*Z(q)^0)), x -> Subspace(GF(q)^3, [x], \"basis\"))),\n group := Group([DiagonalMat([Z(q), Z(q)^2, Z(q)^0]),\n Z(q)*IdentityMat(3, GF(q))]),\n d := 2, q := q)\n);\n\n# An elliptic quadric in a d-dimensional projective space of order q.\nBindGlobal(\"EllipticQuadricProjectiveSpace\", function(q)\n local G, V;\n G := GO(-1, 4, q);\n V := GF(q)^4;\n return rec(points := IsotropicSpacesQuadraticForm(\n InvariantQuadraticForm(G).matrix)(Subspaces(V, 1)),\n group := G, d := 3, q := q);\nend);\n", "meta": {"hexsha": "a61f15b7238caf8b49f87da5bbfe0e49b7dd1fee", "size": 1513, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/GeometricConfigurations.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/GeometricConfigurations.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/GeometricConfigurations.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": 44.5, "max_line_length": 78, "alphanum_fraction": 0.5366820886, "num_tokens": 498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361509525462, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.6410138328637057}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F SinDFT( <size> )\n#F\nClass(SinDFT, NonTerminal, rec(\n abbrevs := [ n -> Checked(IsInt(n), n > 0, n) ],\n dims := self >> [ self.params, self.params ],\n terminate := self >> Mat(Global.SinDFT(self.params)),\n transpose := self >> self,\n isReal := True\n));\n\n#F CosDFT( <size> )\n#F\nClass(CosDFT, NonTerminal, rec(\n abbrevs := [ n -> Checked(IsInt(n), n > 0, n) ],\n dims := self >> [ self.params, self.params ],\n terminate := self >> Mat(Global.CosDFT(self.params)),\n transpose := self >> self,\n isReal := True\n));\n\nRulesFor(CosDFT, rec(\n #F CosDFT_Base: (base case)\n #F\n #F CosDFT_2 = F_2\n #F CosDFT_4 = ... can be done in 5 instad of 7 adds\n #F\n CosDFT_Base := rec (\n\tinfo := \"CosDFT_2 -> F_2\",\n\tforTransposition := false,\n\tisApplicable := P -> P in [2,4], \n\trule := (P, C) -> When(P=2, F(2), \n\t Mat(MatSPL(copy1(2) * sums3(2))) *\n\t DirectSum(F(2), Mat([[1, 1]])) *\n\t Perm((2,3), 4))\n ),\n\n #F CosDFT_Trigonometric: 1984\n #F\n #F CosDFT_n = copy * sums * (CosDFT_n/2 dirsum DCT2_n/4) * sums * perm\n #F\n #F Vetterli/Nussbaumer: \n #F Simple FFT and DCT Algorithms with Reduced Number\n #F of Operations, Signal Processing, 1984, pp. 267--278\n #F\n CosDFT_Trigonometric := rec (\n\tinfo := \"CosDFT_n --> CosDFT_n/2, DCT2_n/4\",\n\tisApplicable := P -> P mod 4 = 0 and P > 4,\n\n\tallChildren := P -> [[ CosDFT(P/2), DCT2(P/4) ]],\n\n\trule := (P, C) -> \n\t copy1(P/2) * sums3(P/2) *\n\t DirectSum(C) *\n\t DirectSum(I(P/2), sums2(P/4)) *\n\t L(P, 2)\n )\n));\n\nRulesFor(SinDFT, rec(\n #F SinDFT_Base: (base case)\n #F\n #F SinDFT_2 = NullMat_2\n #F SinDFT_4 = (NullMat_2 dirsum block) ^ perm\n #F\n SinDFT_Base := rec (\n\tinfo := \"SinDFT_2 -> 0_2\",\n\tforTransposition := false,\n\tisApplicable := P -> P in [2,4], \n\trule := (self, P, C) >> When(P = 2, \n\t\tMat([[0,0],[0,0]]),\n\t\tDirectSum(Mat([[0, 0], [0, 0]]),\n\t\t Mat([[1], [-1]]) * Mat([[1, -1]])) ^ Perm((2,3), 4))\n ),\n\n #F SinDFT_Trigonometric: 1984\n #F\n #F SinDFT_n = copy * sums * (SinDFT_n/2 dirsum DCT2_n/4) * sums * perm\n #F\n #F Vetterli/Nussbaumer: \n #F Simple FFT and DCT Algorithms with Reduced Number\n #F of Operations, Signal Processing, 1984, pp. 267--278\n #F\n SinDFT_Trigonometric := rec(\n\tinfo := \"SinDFT_n --> SinDFT_n/2, DCT2_n/4\",\n\tisApplicable := P -> P mod 4 = 0 and P > 4, \n\n\tallChildren := P -> [[ SinDFT(P/2), DCT2(P/4) ]],\n\n\trule := (P, C) -> \n\t copy2(P/2) * sums5(P/2) *\n\t DirectSum(C) *\n\t DirectSum(I(P/2), sums4(P/4)) *\n\t L(P, 2)\n )\n));\n", "meta": {"hexsha": "a923eca4b181f9321aeda8bf7118011c93995d9c", "size": 2735, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dft/sincosdft.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/sincosdft.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/sincosdft.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": 27.0792079208, "max_line_length": 76, "alphanum_fraction": 0.5327239488, "num_tokens": 1037, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110368115783, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.6408503995365654}}
{"text": "#\n# Read(\"~/Workspace/Chevalley.gap/init.gi\"); Read(Filename(home_dir,\"load.gi\")); Read(Filename(test_dir,\"rsys.test.gi\"));\n#\n# Read(\"~/Workspace/Chevalley.gap/init.gi\"); Read(Filename(test_dir,\"rsys.test.init.gi\")); Read(Filename(test_dir,\"rsys.test.gi\"));\n#\n# Read(Filename(test_dir,\"rsys.test.gi\"));\n#\n\nsys:=RootSystem(\"F\",4);\nPrint(\"Created RootSystem \",sys,\"\\n\");\nPrint(\"\\t[\",IsRootSystem(sys)=true,\"] IsRootSystem(sys)=true\\n\");\n\npositiveRootTest:=[ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ], [ 1, 0, 1, 0 ], [ 0, 1, 0, 1 ], \n [ 0, 0, 1, 1 ], [ 1, 0, 1, 1 ], [ 0, 1, 1, 1 ], [ 0, 0, 2, 1 ], [ 1, 1, 1, 1 ], [ 1, 0, 2, 1 ], \n [ 0, 1, 2, 1 ], [ 1, 1, 2, 1 ], [ 2, 0, 2, 1 ], [ 0, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 2, 1, 2, 1 ], \n [ 1, 1, 3, 2 ], [ 2, 1, 2, 2 ], [ 2, 1, 3, 2 ], [ 2, 1, 4, 2 ], [ 2, 1, 4, 3 ], [ 2, 2, 4, 3 ] ]=positiveRoots(sys);\nPrint(\"\\t[\",positiveRootTest,\"] testing positiveRoots(sys)\\n\");\n\ntmp:=StringPrint(Cocharacters(UnderlyingLieAlgebra(sys)));\ntmp:=SubstitutionSublist(tmp,\"\\n \",\"\");\ncocharacterTest:=\"[ v.49, v.50, v.51, v.52, v.49+v.51, v.50+v.52, v.51+(2)*v.52, v.49+v.51+(2)*v.52, (2)*v.50+v.51+\\\n(2)*v.52, v.51+v.52, v.49+(2)*v.50+v.51+(2)*v.52, v.49+(2)*v.51+(2)*v.52, v.50+v.51+v.52, v.49+(2)\\\n*v.50+(2)*v.51+(2)*v.52, v.49+v.51+v.52, v.50+v.51+(2)*v.52, v.49+(2)*v.50+(2)*v.51+(4)*v.52, v.49\\\n+v.50+v.51+v.52, v.49+(2)*v.50+(3)*v.51+(4)*v.52, v.49+v.50+v.51+(2)*v.52, (2)*v.49+(2)*v.50+(3)*v\\\n.51+(4)*v.52, v.49+v.50+(2)*v.51+(2)*v.52, v.49+v.50+(2)*v.51+(3)*v.52, v.49+(2)*v.50+(2)*v.51+(3)\\\n*v.52 ]\"=tmp;\nPrint(\"\\t[\",positiveRootTest,\"] testing Cocharacters(UnderlyingLieAlgebra(sys))\\n\");\n\nPrint(\"\\t[TODO] testing TorusWeightOnRoot\\n\");\nPrint(\"\\t[TODO] testing RootReflections\\n\");\nPrint(\"\\t[TODO] testing PositiveTorusPermutation\\n\");\nPrint(\"\\t[TODO] testing PermutationMatrix\\n\");\nPrint(\"\\t[TODO] testing RootGraph\\n\");\nPrint(\"\\t[TODO] testing LatexRootGraph\\n\");", "meta": {"hexsha": "901a0c017649616efb93b5915bc919ea551c30d6", "size": 1927, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "test/rsys.test.gi", "max_stars_repo_name": "iuliansimion/Chevalley.gap", "max_stars_repo_head_hexsha": "dd237f36d69a42bcd6cb6a24c5e4bf7dfb3da186", "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": "test/rsys.test.gi", "max_issues_repo_name": "iuliansimion/Chevalley.gap", "max_issues_repo_head_hexsha": "dd237f36d69a42bcd6cb6a24c5e4bf7dfb3da186", "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": "test/rsys.test.gi", "max_forks_repo_name": "iuliansimion/Chevalley.gap", "max_forks_repo_head_hexsha": "dd237f36d69a42bcd6cb6a24c5e4bf7dfb3da186", "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": 56.6764705882, "max_line_length": 131, "alphanum_fraction": 0.5573430202, "num_tokens": 944, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127566694178, "lm_q2_score": 0.7490872187162397, "lm_q1q2_score": 0.6396551319198114}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n_B_dct1 := n -> let(j:=Ind(n), VStack(\n RowVec(diagDirsum(FList(TReal, [2,1]), fConst(TReal, n-2, 0.0))), \n HStack(ColVec(fConst(TReal, n-3, 0.0)), \n RowTensor(n-3, 1, Mat([[1,1]])), \n ColVec(fConst(TReal, n-3, 0.0))), \n RowVec(diagDirsum(fConst(TReal, n-2, 0.0), FList(TReal, [1, 2]))), \n RowVec(Lambda(j, cond(neq(imod(j, 2),0), -1, 1)))\n));\n\nRulesFor(DCT1, rec(\n #F DCT1_Base2: (base case for size 2)\n #F\n #F DCT1_2 = F_2 (scaled)\n #F\n DCT1_Base2 := rec(\n\tinfo := \"DCT_1 -> F_2\",\n\tforTransposition := false,\n\tisApplicable := P -> P[1]=2, \n\tallChildren := P -> [[]],\n\trule := (P, C) -> F(2)\n ),\n\n #F DCT1_Base4: DCT1_4 = (M tensor F_2) ^ P\n #F\n DCT1_Base4 := rec(\n\tinfo := \"DCT_1 -> (M tensor F_2)^P\",\n\tforTransposition := false,\n\tisApplicable := P -> P[1]=4, \n\tallChildren := P -> [[]],\n\trule := (P, C) -> \n\t Tensor(Mat([[1, 1], [1, -1/2]]), F(2)) ^ Perm((2,4), 4)\n ),\n\n #F DCT1_DCT1and3: 1984\n #F\n #F DCT1_(n+1) = perm * (DCT1_(n/2+1) dirsum DCT3_n/2 ^ perm) * \n #F (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 DCT1_DCT1and3 := rec (\n\tinfo := \"DCT1_n --> DCT1_n/2, DCT3_n/2\",\n\tisApplicable := P -> (P[1] - 1) mod 2 = 0,\n\tallChildren := P -> \n\t When(P[1]=3, [[ DCT1(2) ]],\n\t\t [[ DCT1((P[1]+1)/2), DCT3((P[1]-1)/2) ]]),\n\n\trule := (P, C) ->\n\t When(P[1]=3, \n\t\tperm2(3) *\n\t\tDirectSum(C[1], I(1)) *\n\t\tDirectSum(I(1), F(2)) ^ perm4(3),\n\n\t\tperm2(P[1]) *\n\t\tDirectSum(C[1], C[2] ^ J((P[1]-1)/2)) *\n\t\tDirectSum(I(1), Tensor(I((P[1]-1)/2), F(2))) ^ perm4(P[1]))\n ),\n\n DCT1_toDCT2 := rec(\n isApplicable := P -> P[1] > 5, \n allChildren := P -> [[DCT2(P[1]-1)]], \n rule := (P, C) -> let(\n n := P[1], j := Ind(n-1), nn := n-1, \n DirectSum(Diag(Lambda(j, 1/(2*cospi(fdiv(j, 2*nn))))) * \n C[1], I(1)) * \n _B_dct1(n)\n )\n )\n));\n", "meta": {"hexsha": "091d7b7213bae2e274c9afae586a1b6a5642a1e0", "size": 2233, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dct_dst/dct1rules.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/dct1rules.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/dct1rules.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": 28.6282051282, "max_line_length": 71, "alphanum_fraction": 0.4702194357, "num_tokens": 927, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094032139577, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.6390949827182795}}
{"text": "################################################################################\n##\n#W verlinde.gi GroupTheoretical Package\n##\n#W Paul Bruillard, Cesar Galindo, Siu-Hung Ng, Julia Plavnik, Eric Rowell, \n#W Zhenghan Wang\n##\n## Installation file for verlinde functions of the GroupTheoretical Package\n##\n#Y Copyright (C) 2016, Battelle Memorial Institute\n##\n################################################################################\n\n################################################################################\n##\n#F compute_fusion_rules(<list>,<number>). . . . . . . .use verlinde to compute N\n##\nInstallGlobalFunction(compute_fusion_rules, function(S,FPdimC)\n local N,r,i,j,k,m;\n r:=Length(S[1]);\n N:=List([1..r],i->NullMat(r,r));\n for i in [1..r] do\n for j in [1..r] do\n for k in [1..r] do\n for m in [1..r] do\n N[i][j][k]:=N[i][j][k]+S[i][m]*S[j][m]*ComplexConjugate(S[k][m])/S[1][m];\n od;\n N[i][j][k]:=N[i][j][k]/FPdimC;\n od;\n od;\n od;\n return N;\nend);\n\n################################################################################\n##\n#F display_fusion_rules(<list>). . . . . . . . . display the fusion rules\n##\nInstallGlobalFunction(display_fusion_rules, function(N)\n local x;\n for x in [1..Size(N)] do\n Print(\"\\nN_\",x,\"\\n\");\n Display(N[x]);\n od;\n Print(\"\\n\");\nend);\n\n#E verlinde.gi . . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here\n", "meta": {"hexsha": "388a519c8e087ac7e500fed5cb2571122581617c", "size": 1440, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/verlinde.gi", "max_stars_repo_name": "pnnl/GroupTheoretical", "max_stars_repo_head_hexsha": "d60aaec27d2ca98ec55b12b78213538a346eef27", "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": "lib/verlinde.gi", "max_issues_repo_name": "pnnl/GroupTheoretical", "max_issues_repo_head_hexsha": "d60aaec27d2ca98ec55b12b78213538a346eef27", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-05-20T21:43:28.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-20T21:43:28.000Z", "max_forks_repo_path": "lib/verlinde.gi", "max_forks_repo_name": "pnnl/GroupTheoretical", "max_forks_repo_head_hexsha": "d60aaec27d2ca98ec55b12b78213538a346eef27", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-12-07T13:46:25.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-12T22:39:35.000Z", "avg_line_length": 29.387755102, "max_line_length": 83, "alphanum_fraction": 0.4347222222, "num_tokens": 399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467770088162, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.6372673722756228}}
{"text": "mode := function(v)\n local c, m;\n c := Collected(SortedList(v));\n m := Maximum(List(c, x -> x[2]));\n return List(Filtered(c, x -> x[2] = m), y -> y[1]);\nend;\n\nmode([ 7, 5, 6, 1, 5, 5, 7, 12, 17, 6, 6, 5, 12, 3, 6 ]);\n# [ 5, 6 ]\n", "meta": {"hexsha": "14397cc90e0adde9c06e7ee0bcb0ccc34602a315", "size": 232, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Averages-Mode/GAP/averages-mode.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-Mode/GAP/averages-mode.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-Mode/GAP/averages-mode.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": 23.2, "max_line_length": 57, "alphanum_fraction": 0.474137931, "num_tokens": 113, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213718636754, "lm_q2_score": 0.7057850402140659, "lm_q1q2_score": 0.6345864135981302}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nRulesFor(DCT3, rec(\n #F DCT3_Base2: DCT2_2 = F_2 * diag(1, 1/sqrt(2))\n #F\n DCT3_Base2 := rec (\n\tinfo := \"DCT3_2 -> F_2\",\n\tisApplicable := P -> P[1] = 2,\n\trule := (P, C) -> F(2) * Diag(1, Sqrt(1/2))\n ),\n\n #F DCT3_Base3: DCT3_3 = (I_1 dirsum F_2)^P * (M dirsum c) * Q\n #F well-known, e.g.,\n #F Pueschel/Moura: Discrete Cosine and Sine Transforms (in preparation)\n DCT3_Base3 := rec (\n\tinfo := \"DCT3_3 = (I_1 dirsum F_2)^P * (M dirsum c) * Q\",\n\tisApplicable := P -> P[1]=3, \n\trule := (P, C) -> \n (DirectSum(I(1), F(2)) ^ Perm((1,2), 3)) * \n\t DirectSum(Mat([[1, 1/2], [1, -1]]),\n\t\t Diag(CosPi(1/6))) *\n\t Perm((2,3), 3)\n ),\n\n #F DCT3_Base5: (possible base case for size 3)\n #F\n #F DCT3_5 = P * (I_1 dirsum (SkewDCT3_2's * (pDCT8_2 tensor I_2) * B \n #F\n #F Pueschel/Moura: Discrete Cosine and Sine Transforms, in preparation\n #F\n DCT3_Base5 := rec (\n\tinfo := \"DCT3_5 -> SkewDCT3_2's, pDCT8_2\",\n\tisApplicable := P -> P[1]=5,\n\tallChildren := P -> [[ SkewDTT(DCT3(2), 1/5), \n\t\t SkewDTT(DCT3(2), 3/5), \n\t\t\t PolyDTT(DCT8(2)) ]],\n\trule := (P, C) -> \n\t Perm((1,2,4,5,3), 5) *\n\t DirectSum(I(1), \n\t\t DirectSum(C[1], C[2]) * Tensor(C[3], I(2))) *\n\t Mat([ [ 1, 0, -1, 0, 1 ],\n\t\t [ 1, 0, 1/2, 0, 0 ],\n\t\t [ 0, 1, 0, 0, 0 ],\n\t\t [ 0, 0, 1/2, 0, 1/2 ],\n\t\t [ 0, 0, 0, 1, 0 ] ])\n ),\n\n #F DCT3_Orth9: DCT3_9 = hand-derived radix-3 Cooley-Tukey for RDFT\n #F\n DCT3_Orth9 := rec (\n\tinfo := \"DCT3_9 -> TRDFT_3's\",\n\tisApplicable := P -> P[1] = 9,\n\tallChildren := P -> [ [ RDFT(3).transpose() ] ],\n\trule := (P, C) ->\n\t Perm( (1,5)(2,7,8,4,9,6), 9 ) *\n\t Tensor(C[1],\tI(3)) *\n\t DirectSum(\n\t I(3),\n\t (DirectSum(I(2), Rot(2/9), Rot(4/9))) ^ Perm((2,4,5,3), 6)) *\n\t Tensor(I(3), C[1]) *\n\t DirectSum(\n\t I(3),\n\t Mat([ [ 1, 0, 0, 0, 0, 0 ], \n\t\t [ 0, 1, 0, 0, 0, 1 ], \n\t\t [ 0, 0, 1, 0, 1, 0 ],\n\t\t [ 0, 0, 0, 1, 0, 0 ], \n\t\t [ 0, 0, -1, 0, 1, 0 ], \n\t\t [ 0, -1, 0, 0, 0, 1 ] ])) *\n\t Diag(1, -1, 1, -1, 1, -1, 1, -1, 1) *\n\t Perm( (2,7,8)(3,4)(5,9), 9 )\n ),\n\n #F DCT3_toSkewDCT3: DCT3_n = DCT3_n(1/2)\n #F\n DCT3_toSkewDCT3 := rec (\n\tinfo := \"DCT3_n -> SkewDCT3_n(1/2)\",\n\tforTransposition := false,\n\tisApplicable := P -> IsPrimePowerInt(P[1]) and P[1] mod 2 = 0 and P[1] > 2,\n\tallChildren := P -> [ [ SkewDTT(DCT3(P[1]), 1/2) ] ],\n\trule := (P, C) -> C[1]\n )\n));\n", "meta": {"hexsha": "2ba9324e46f19db549fe2fcad04058ee3c705212", "size": 2637, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dct_dst/dct3rules.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/dct3rules.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/dct3rules.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": 30.6627906977, "max_line_length": 80, "alphanum_fraction": 0.4497535078, "num_tokens": 1248, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9073122163480667, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.6344420899349092}}
{"text": "# The Grassmann graph J_q(n, d) of d-dimensional subspaces of F_q^n.\nBindGlobal(\"GrassmannGraph\", function(q, n, d)\n local G;\n G := SubspaceGraph(GL(n, q), Elements, GF(q)^n, d, true);\n G.duality := GrassmannDualityFunction;\n G.primality := GrassmannDualityFunction;\n return G;\nend);\n\n# The doubled Grassmann graph 2J_q(2d+1, d) of d- and (d+1)-dimensional\n# subspaces of F_q^{2d+1}.\nBindGlobal(\"DoubledGrassmannGraph\", function(q, d)\n local n, G, V, dp;\n n := 2*d+1;\n V := GF(q)^n;\n dp := DirectProduct(GL(n, q), Group((1, 2)));\n G := Graph(dp, Union(Subspaces(V, d), Subspaces(V, d+1)),\n OnDoubledGrassmann(V, dp), SymmetrizedInclusion, true);\n G.halfDuality := GrassmannDualityFunction;\n G.halfPrimality := GrassmannDualityFunction;\n return G;\nend);\n\n# The twisted Grassmann graph TG_d(q) of (d+1)-dimensional subspaces of\n# F_q^{2d+1} which are not subspaces of a hyperplane H, and (d-1)-dimensional\n# subspaces of H.\nBindGlobal(\"TwistedGrassmannGraph\", function(d, q)\n local F, H, S, V, n;\n n := 2*d+1;\n F := GF(q)^n;\n H := Subspace(F, CanonicalBasis(F){[1..n-1]}, \"basis\");\n V := Union(Filtered(Subspaces(F, d+1), x -> not IsSubset(H, x)),\n Subspaces(H, d-1));\n S := OnSubspaces(F);\n return Graph(Stabilizer(GL(n, q), H, S), V, S, function(x, y)\n local dx;\n dx := Dimension(x);\n if dx = Dimension(y) then\n return Dimension(Intersection(x, y)) = dx-1;\n else\n return IsSubset(x, y) or IsSubset(y, x);\n fi;\n end, true);\nend);\n\n# The polar graph O^{(+/-)}(d, q) of isotropic lines of F_q^d\n# with respect to a nondegenerate quadratic form.\nBindGlobal(\"PolarGraphO\", function(arg)\n local d, e, q, B, G, H, Q, V;\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 Q := InvariantQuadraticForm(G).matrix;\n B := Q + TransposedMat(Q);\n V := GF(q)^d;\n H := Graph(G, IsotropicSpacesQuadraticForm(Q)(Subspaces(V, 1)),\n OnSubspaces(V), function(x, y)\n return x <> y and IsZero(Elements(x)[2]*B*Elements(y)[2]);\n end, true);\n H.duality := Sum;\n H.primality := Intersection;\n return H;\nend);\n\n# The polar graph NO^{+/-}orth(d, q) of nonisotropic lines of F_q^d\n# with respect to a nondegenerate quadratic form.\nBindGlobal(\"PolarGraphNOorth\", function(e, d, q)\n local f, z, B, G, H, Q, V;\n if d mod 2 = 1 then\n f := 0;\n if q mod 4 = 3 and d mod 4 = 1 then\n e := -e;\n fi;\n else\n f := e;\n fi;\n G := GO(f, d, q);\n Q := InvariantQuadraticForm(G).matrix;\n B := Q + TransposedMat(Q);\n V := GF(q)^d;\n z := Z(q)^((1-e)/2);\n H := Graph(G, NonisotropicSpacesQuadraticForm(Q, z)(Subspaces(V, 1)),\n OnSubspaces(V), function(x, y)\n return x <> y and IsZero(Elements(x)[2]*B*Elements(y)[2]);\n end, true);\n return H;\nend);\n\n# The polar graph Sp(d, q) of isotropic lines of F_q^d\n# with respect to a nondegenerate symplectic form.\nBindGlobal(\"PolarGraphSp\", function(d, q)\n local G, H, Q, V;\n G := Sp(d, q);\n Q := InvariantBilinearForm(G).matrix;\n V := GF(q)^d;\n H := Graph(G, IsotropicSpacesQuadraticForm(Q)(Subspaces(V, 1)),\n OnSubspaces(V), function(x, y)\n return x <> y and IsZero(Elements(x)[2]*Q*Elements(y)[2]);\n end, true);\n H.duality := Sum;\n H.primality := Intersection;\n return H;\nend);\n\n# The polar graph U(d, r) of isotropic lines of F_{r^2}^d\n# with respect to a nondegenerate Hermitean form.\nBindGlobal(\"PolarGraphU\", function(d, r)\n local c, B, F, G, H, Q, V;\n G := GU(d, r);\n Q := InvariantSesquilinearForm(G).matrix;\n V := GF(r^2)^d;\n B := Elements(CanonicalBasis(V));\n c := Conjugates(GF(r^2), GF(r), Z(r^2));\n F := x -> List(x, y -> y^r);\n H := Graph(G, IsotropicSpacesSesquilinearForm(Q, r)(Subspaces(V, 1)),\n OnSubspaces(V), function(x, y)\n return x <> y and IsZero(Elements(x)[2]*Q*F(Elements(y)[2]));\n end, true);\n H.duality := Sum;\n H.primality := Intersection;\n return H;\nend);\n\n# The dual polar graph B_d(q) of isotropic d-dimensional subspaces of\n# F_q^{2d+1} with respect to a nondegenerate quadratic form.\nBindGlobal(\"DualPolarGraphB\", function(d, q)\n local F, G, S, e, z, invt;\n e := 2*d+1;\n F := GF(q)^e;\n G := GO(e, q);\n if q mod 2 = 1 then\n invt := true;\n S := IsotropicSpacesQuadraticForm(InvariantQuadraticForm(G).matrix);\n else\n invt := false;\n S := [Subspace(F, Elements(CanonicalBasis(F)){[2..d+1]}, \"basis\")];\n fi;\n return SubspaceGraph(G, S, F, d, invt);\nend);\n\n# The dual polar graph C_d(q) of isotropic d-dimensional subspaces of\n# F_q^{2d} with respect to a nondegenerate symplectic form.\nBindGlobal(\"DualPolarGraphC\", function(d, q)\n local F, e;\n e := 2*d;\n F := GF(q)^e;\n return SubspaceGraph(Sp(e, q),\n [Subspace(F, Elements(CanonicalBasis(F)){[1..d]}, \"basis\")],\n F, d, false);\nend);\n\n# The dual polar graph D_d(q) of isotropic d-dimensional subspaces of\n# F_q^{2d} with respect to a nondegenerate quadratic form of Witt index d.\nBindGlobal(\"DualPolarGraphD\", function(d, q)\n local F, G, S, e, invt;\n e := 2*d;\n F := GF(q)^e;\n G := GO(1, e, q);\n if q mod 2 = 1 then\n invt := true;\n S := IsotropicSpacesQuadraticForm(InvariantQuadraticForm(G).matrix);\n else\n invt := false;\n S := [Subspace(F, Elements(CanonicalBasis(F)){[1,3..e-1]}, \"basis\")];\n fi;\n return SubspaceGraph(G, S, F, d, invt);\nend);\n\n# The dual polar graph ^2D_{d+1}(q) of isotropic d-dimensional subspaces of\n# F_q^{2d+2} with respect to a nondegenerate quadratic form of Witt index d.\nBindGlobal(\"DualPolarGraph2D\", function(d, q)\n local G, e;\n e := 2*d+2;\n G := GO(-1, e, q);\n return SubspaceGraph(G,\n IsotropicSpacesQuadraticForm(InvariantQuadraticForm(G).matrix),\n GF(q)^e, d);\nend);\n\n# The dual polar graph ^2A_{e-1}(r) of isotropic [e/2]-dimensional\n# subspaces of F_{r^2}^e with respect to a nondegenerate Hermitean form.\nBindGlobal(\"DualPolarGraph2A\", function(e, r)\n local B, F, c, d;\n F := GF(r^2)^e;\n B := Elements(CanonicalBasis(F));\n c := Conjugates(GF(r^2), GF(r), Z(r^2));\n d := Int(e/2);\n return SubspaceGraph(GU(e, r),\n [Subspace(F, B{[1..d]} + (c[1]-c[2])*B{e+1-[1..d]}, \"basis\")],\n F, d, false);\nend);\n\n# The Doro graph of nonisotropic 1-dimensional subspaces of F_q^4 with respect\n# to a nondegenerate quadratic form. It is distance-regular for q = 4, 5.\nBindGlobal(\"DoroGraph\", function(q)\n local G, V;\n V := GF(q)^4;\n G := GO(-1, 4, q);\n return Graph(G, [Subspace(V, BasisVectors(Basis(V)){[4]}, \"basis\")],\n OnSubspaces(V), IsHyperbolic(InvariantQuadraticForm(G).matrix));\nend);\n\n# The unitary nonisotropics graph of 1-dimensional subspaces of F_(r^2)^3 with\n# respect to a nondegenerate sesquilinear form.\nBindGlobal(\"UnitaryNonisotropicsGraph\", function(r)\n local G, V;\n V := GF(r^2)^3;\n G := GU(3, r);\n return Graph(G, [Subspace(V, BasisVectors(Basis(V)){[2]}, \"basis\")],\n OnSubspaces(V), IsOrthogonal(InvariantSesquilinearForm(G).matrix, r));\nend);\n", "meta": {"hexsha": "deb53d470e370cdd6203ced8dc57d25c8c6bdda5", "size": 7508, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/SpacesGraphs.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/SpacesGraphs.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/SpacesGraphs.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.8198198198, "max_line_length": 78, "alphanum_fraction": 0.5879062334, "num_tokens": 2447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587875995482, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.6330026234110341}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nDCTDiag := n -> Diag(diagDirsum(fConst(1,1/Sqrt(n)), fConst(n-1, Sqrt(2/n))));\nDCTDiag2 := n -> Diag(diagDirsum(fConst(1,1/n), fConst(n-1, 2/n)));\n\n#ForwardDCT := DCT2;\n\nClass(InverseDCT, DTTBase, rec(\n terminate := self >> DCT3(self.params[1]).terminate() * DCTDiag2(self.params[1]),\n# transpose := self >> DCTDiag2(self.params[1]) * DCT2(self.params[1]),\n));\n\nRulesFor(InverseDCT, rec(\n InverseDCT_toDCT3 := rec(\n\t isApplicable := P -> true,\n\t allChildren := P -> [[ DCT3(P[1]) ]],\n\t rule := (P, C) -> C[1] * DCTDiag2(P[1])\n )\n));\n\n", "meta": {"hexsha": "d4f457174d9f365f4c429bfb8a57eac8fd73b84c", "size": 641, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dct_dst/canonic.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/canonic.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/canonic.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": 26.7083333333, "max_line_length": 85, "alphanum_fraction": 0.6068642746, "num_tokens": 238, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9086178870347122, "lm_q2_score": 0.6959583187272712, "lm_q1q2_score": 0.632360177026204}}
{"text": "# The field addition group as a permutation group.\nBindGlobal(\"FieldAdditionPermutationGroup\",\n q -> Group(List(Elements(Basis(GF(q))),\n g -> Permutation(g, GF(q), function(x, y) return x+y; end)))\n);\n\n# The field multiplication group as a permutation group.\nBindGlobal(\"FieldMultiplicationPermutationGroup\",\n q -> CyclicGroup(IsPermGroup, q-1)\n);\n\n# The field exponentiation group as a permutation group.\nBindGlobal(\"FieldExponentiationPermutationGroup\",\n q -> Action(Group(FrobeniusAutomorphism(GF(q))), GF(q))\n);\n\n# The group of even permutations of columns of a matrix\n# as a permutation group over matrix elements.\nBindGlobal(\"MatrixColumnEvenPermutationGroup\", function(d, e)\n return Action(AlternatingGroup(e), Cartesian([1..d], [1..e]),\n function(x, g)\n return [x[1], OnPoints(x[2], g)];\n end);\nend);\n\n# The group of permutations of columns of a matrix\n# as a permutation group over matrix elements.\nBindGlobal(\"MatrixColumnPermutationGroup\", function(d, e)\n return Action(SymmetricGroup(e), Cartesian([1..d], [1..e]),\n function(x, g)\n return [x[1], OnPoints(x[2], g)];\n end);\nend);\n\n# The group of simultaneous permutations of rows and columns\n# of a square matrix as a permutation group over matrix elements.\nBindGlobal(\"MatrixRowColumnPermutationGroup\", function(d)\n return Action(SymmetricGroup(d), Cartesian([1..d], [1..d]), OnTuples);\nend);\n\n# The wreath product of two symmetric groups.\nBindGlobal(\"WreathProductSymmetricGroups\", function(m, n)\n local g;\n if not (IsInt(m) and IsInt(n) and m >= 0 and n >= 0) then\n Error(\"m or n not a nonnegative integer\");\n return fail;\n fi;\n if m <= 1 then\n return SymmetricGroup(n);\n elif n <= 1 then\n return SymmetricGroup(m);\n fi;\n g := Concatenation(GeneratorsOfGroup(SymmetricGroup(m)),\n [PermList(Concatenation([m+1..2*m], [1..m]))]);\n if n > 2 then\n Add(g, PermList(Concatenation([m+1..n*m], [1..m])));\n fi;\n return Group(g);\nend);\n\n# The automorphism group of a (hyper)conic\n# in a Desarguesian projective plane of order q.\nBindGlobal(\"HyperconicAutomorphismGroup\", q -> Group([\n [[-Z(q)^0, 0*Z(q), 0*Z(q)],\n [ 0*Z(q), 0*Z(q), Z(q)^0],\n [ 0*Z(q), Z(q)^0, 0*Z(q)]],\n [[-Z(q)^0, 0*Z(q), -2*Z(q)^0],\n [ Z(q)^0, Z(q)^0, Z(q)^0],\n [ 0*Z(q), 0*Z(q), Z(q)^0]],\n [[-Z(q), 0*Z(q), -2*Z(q)^0],\n [ Z(q), Z(q)^2, Z(q)^0],\n [ 0*Z(q), 0*Z(q), Z(q)^0]],\n Z(q)*IdentityMat(3, GF(q))\n]));\n", "meta": {"hexsha": "b741fef32e190511000c4e83fd7dbf91843575f5", "size": 2542, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/AuxiliaryGroups.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/AuxiliaryGroups.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/AuxiliaryGroups.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.8933333333, "max_line_length": 74, "alphanum_fraction": 0.6180173092, "num_tokens": 772, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736772, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.6311807565787677}}
{"text": "# The Kneser graph on k-subsets of a set with n elements.\nBindGlobal(\"KneserGraph\", function(arg)\n local n, k, invt, vcs;\n if Length(arg) < 2 then\n Error(\"at least two arguments expected\");\n return fail;\n else\n n := arg[1];\n k := arg[2];\n if Length(arg) > 2 then\n invt := arg[3];\n else\n invt := true;\n fi;\n fi;\n if invt then\n vcs := Combinations([1..n], k);\n else\n vcs := [[1..k]];\n fi;\n return Graph(SymmetricGroup(n), vcs, OnSets, DisjointSets);\nend);\n\n# The Odd graph of diameter d on 2*d+1 points.\nBindGlobal(\"OddGraph\", d -> KneserGraph(2*d+1, d, false));\n\n# The doubled Odd graph on 2*d+1 points.\nBindGlobal(\"DoubledOddGraph\", function(d)\n local n, dp;\n n := 2*d+1;\n dp := DirectProduct(SymmetricGroup(n), SymmetricGroup(2));\n return Graph(dp, Union(Combinations([1..n], d), Combinations([1..n], d+1)),\n OnDoubledOdd(n, dp), SymmetrizedInclusion, true);\nend);\n\n# The folded Johnson graph.\nBindGlobal(\"FoldedJohnsonGraph\",\n d -> AntipodalQuotientGraph(JohnsonGraph(2*d, d))\n);\n\n# The three Chang graphs with v=28, k=12, lm=6, mu=4\nBindGlobal(\"ChangGraph\", function(j)\n local J, S, Ss;\n Ss := [List([1..4], i -> [i, i+4]),\n Set(List([1..8], i -> Set([i, (i mod 8)+1]))),\n Union(List([1..3], i -> Set([i, (i mod 3)+1])),\n List([1..5], i -> Set([i+3, (i mod 5)+4])))];\n J := JohnsonGraph(8, 2);\n S := List(Ss[j], x -> Position(J.names, x));\n return SwitchedGraph(J, S, Stabilizer(J.group, S, OnSets));\nend);\n", "meta": {"hexsha": "010dbedbc9e97199d43d783d8b24630b33f9d5d5", "size": 1604, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/SetGraphs.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/SetGraphs.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/SetGraphs.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": 30.8461538462, "max_line_length": 79, "alphanum_fraction": 0.5554862843, "num_tokens": 521, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297914570319, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.629699426683564}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nNewRulesFor(DFT, rec(\n\n DFT_PD := rec(\n forTransposition := false,\n maxSize := 13,\n \n core := meth(self, N, k, root, is_real)\n local coeffs, l1, l2, n, circ, toep;\n coeffs := List([0..N-2], x->E(N)^(k*root^(-x) mod N));\n n := N-1;\n l1 := coeffs{[1..n/2]};\n l2 := coeffs{[n/2+1..n]};\n circ := 1/2 * (l1 + l2);\n toep := Reversed(1/2 * Concat(Drop(l2 - l1, 1), l1 - l2));\n if is_real then toep := toep / E(4); fi;\n return\n DirectSum(I(1),\n transforms.filtering.Circulant(circ).terminate(),\n transforms.filtering.Toeplitz(toep).terminate());\n end,\n \n A := N -> let(nn := (N-1)/2, ones := m -> fConst(m, 1),\n VStack(HStack(RowVec(ones(nn+1)), O(1, nn)),\n HStack(VStack(-2*ColVec(ones(nn)), O(nn, 1)), I(2*nn)))),\n \n applicable := (self, nt) >> nt.params[1] > 2 and nt.params[1] <= self.maxSize and IsPrime(nt.params[1]) and not nt.hasTags(),\n \n apply := (self,nt,C,cnt) >> let(N := nt.params[1], k := nt.params[2], root := PrimitiveRootMod(N),\n Scat(RR(N, 1, root)) *\n DirectSum(I(1), Tensor(F(2), I((N-1)/2))) *\n Mat(MatSPL(\n self.core(N, k, root, false) *\n self.A(N))) *\n DirectSum(I(1), Tensor(F(2), I((N-1)/2))) *\n # DirectSum(I(1), OS(N-1, -1)) *\n Gath(RR(N, 1, 1/root mod N))\n )\n#D isApplicable := (self, P) >> P[1] > 2 and P[1] <= self.maxSize and IsPrime(P[1]) and P[3] = [],\n#D\n#D rule := (self,P,C) >> let(N := P[1], k := P[2], root := PrimitiveRootMod(N),\n#D Scat(RR(N, 1, root)) *\n#D DirectSum(I(1), Tensor(F(2), I((N-1)/2))) *\n#D Mat(MatSPL(\n#D self.core(N, k, root, false) *\n#D self.A(N))) *\n#D DirectSum(I(1), Tensor(F(2), I((N-1)/2))) *\n#D# DirectSum(I(1), OS(N-1, -1)) *\n#D Gath(RR(N, 1, 1/root mod N))\n#D )\n )\n));\n", "meta": {"hexsha": "59745fd1ef39d44a759992b69101889c52f48b1f", "size": 2139, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dft/pd.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/pd.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/pd.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 37.5263157895, "max_line_length": 137, "alphanum_fraction": 0.453482936, "num_tokens": 725, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767874818409, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.6277679548316204}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# Convention: N - range\n# n - domain\n\n## H(<N>,<n>,<base>,<stride>) \n## Stride index mapping: i -> base + stride * i\n#\nClass(H, FuncClass, rec(\n def := (N,n,base,stride) -> rec(),\n domain := self >> self.params[2],\n range := self >> self.params[1], \n lambda := self >> let(\n\tbase := self.params[3], str := self.params[4], i := Ind(self.params[2]),\n\tLambda(i, base + str * i))\n)); \n\n# HZ(<N>,<n>,<base>,<stride>) \n## Mod-stride index mapping: i -> (base + stride * i) mod N\n##\nClass(HZ, FuncClass, rec(\n isCyclic := true,\n\n def := (N,n,base,str) -> rec(), \n domain := self >> self.params[2],\n range := self >> self.params[1], \n\n lambda := self >> let(\n\tn := self.params[2], N := self.params[1], base := self.params[3], str := self.params[4],\n\ti := Ind(n), \n\tii := When(str * n = N, no_mod(i), i), # condition to omit the mod is str*n = N\n\tLambda(i, imod(base + str * ii, N)))\n)); \n\n#F RM(<N>,<n>,<phi>,<g>) \n## Exponential index mapping: i -> (phi * g^i) mod N\n## <g> - generating element for integers mod <N>.\n## <phi> - \"phase\"\n##\nClass(RM, FuncClass, rec(\n isCyclic := true,\n abbrevs := [ N -> [N, N-1, 1, PrimitiveRootMod(N)],\n\t (N,n) -> [N, n, 1, PrimitiveRootMod(N)] ],\n\n domain := self >> self.params[2],\n range := self >> self.params[1], \n def := (N,n,phi,g) -> Checked(IsPosIntSym(N), IsPosIntSym(n), n <= N, rec()),\n\n lambda := self >> let(\n\tphi := self.params[3], g := self.params[4], i := Ind(self.params[2]),\n\tLambda(i, powmod(phi, g, i, self.params[1]))),\n));\n\n#F RR(<N>,<phi>,<g>) \n## Rader permutation: i -> { 0, if i = 0 }\n## { RM(i-1), if i > 0 }\n## <phi> and <g> are parameters to RM\n##\nClass(RR, PermClass, rec(\n isCyclic := true,\n\n abbrevs := [ N -> [N,1,PrimitiveRootMod(N)] ],\n\n def := (N,phi,g) -> Checked(IsPosInt(N), IsPrime(N), rec()),\n\n domain := self >> self.params[1],\n range := self >> self.params[1], \n\n # alternatively cond(i, imod(phi * pow(g, i-1), N), 0) we do g^-1 for easier poweropt\n lambda := self >> let(\n\tN := self.params[1], phi := self.params[2], g := self.params[3], i:= Ind(N),\n\tWhen(not self.transposed,\n\t Lambda(i, cond(i, powmod(phi*(g^-1 mod N) mod N, g, i, N), 0)),\n\t Lambda(i, cond(i, 1+ilogmod(cond(i,i,1)/phi mod N, g, N), 0)))\n )\n));\n\n", "meta": {"hexsha": "b4e88d1783cede7507c2c3f928cc3e51ab58204a", "size": 2428, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/hfunc.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/hfunc.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/hfunc.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.975308642, "max_line_length": 89, "alphanum_fraction": 0.5308896211, "num_tokens": 819, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392756357326, "lm_q2_score": 0.705785040214066, "lm_q1q2_score": 0.6239416957053793}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nLocal.qmat := Mat(\n [[1,1,1],\n [1,-1,0],\n [1,0,-1]]\n);\nLocal.wmat := Mat(\n [[1,0,1],\n [0,1,0],\n [0,0,1]]);\n\n## C3 = DCT-3\n## C4 = DCT-4\n## S3 = DST-3\n## S4 = DST-4\n\nRulesFor(DTT, rec(\n #\n # DCT-3\n #\n DTT_C3_Base2 := SimpleRule(\n\t[ DTT_C3, 2, @, @ ], \n\t(P, C) -> F(2) * Diag(1, cospi(P[3]))\n ),\n DTT_IC3_Base2 := SimpleRule(\n\t[ DTT_IC3, 2, @, @ ], \n\t(P, C) -> Diag(1, 1/(2*cospi(P[3]))) * F(2)\n ),\n DTT_C3_Base3 := SimpleRule(\n\t[ DTT_C3, 3, @, @ ], \n\t(P, C) -> let(r:=P[3],\n\t qmat * DirectSum(I(1), Mat([[ cospi((1+r)/3), cospi((1-2*r)/3) ],\n\t\t\t [ cospi((1-r)/3), cospi((1+2*r)/3) ]])))\n ),\n DTT_C3_Base3 := SimpleRule(\n\t[ DTT_C3, 3, @, @ ], \n\t(P, C) -> let(r:=P[3],\n\t DirectSum(I(1), \n\t\t 1/sinpi(r) *\n\t\t Mat([[ cospi(( 1-2*r)/6), sinpi((-1+2*r)/3) ],\n\t\t\t [ cospi((-1+2*r)/6), cospi(( 1-2*r)/3) ]]) *\n\t\t Mat([[0, sqrt(3)/2],\n\t\t\t [1, -1/2]]))\n\t * qmat)\n ),\n\n #\n # DST-3\n #\n DTT_S3_Base2 := SimpleRule(\n\t[ DTT_S3, 2, @, false ], \n\t(P, C) -> let(r:=P[3], F(2) * Diag(sinpi(r/2), sinpi(r)))\n ),\n DTT_S3Poly_Base2 := SimpleRule(\n\t[ DTT_S3, 2, @, true ], \n\t(P, C) -> let(r:=P[3], F(2) * Diag(1, 2*cospi(r/2)))\n ),\n DTT_S3Poly_Base3 := SimpleRule(\n\t[ DTT_S3, 3, @, true ], \n\t(P, C) -> let(r:=P[3], \n\t qmat * DirectSum(I(1), 2* Mat([[ cospi((1+r)/3), cospi((1-2*r)/3) ],\n\t \t [ cospi((1-r)/3), cospi((1+2*r)/3) ]]) * wmat))\n ),\n DTT_S3_Base2 := SimpleRule(\n\t[ DTT_S3, 2, @, false ], \n\t(P, C) -> let(r:=P[3], F(2) * Diag(sinpi(r/2), sinpi(r)))\n ),\n\n #\n # DCT-4\n #\n DTT_C4_Base2 := SimpleRule(\n\t[ DTT_C4, 2, @, false ], \n\t(P, C) -> let(r:=P[3], Mat([[cospi(r/4), cospi(3*r/4)], \n\t\t [sinpi(r/4), -sinpi(3*r/4)]]))\n ),\n DTT_C4_Base2_LS := SimpleRule(\n\t[ DTT_C4, 2, @, false ], \n\t(P, C) -> let(r:=P[3], Diag(cospi(r/4), sinpi(r/4)) * F(2) * Mat([[1,-1],[0,2*cospi(r/2)]]))\n ),\n DTT_C4Poly_Base2 := SimpleRule(\n\t[ DTT_C4, 2, @, true ], \n\t(P, C) -> let(r:=P[3], F(2) * Mat([[1,-1],[0,2*cospi(r/2)]]))\n ),\n\n #\n # DST-4\n #\n DTT_S4_Base2 := SimpleRule(\n\t[ DTT_S4, 2, @, false ], \n\t(P, C) -> let(r:=P[3], Mat([[sinpi(r/4), sinpi(3*r/4)], \n\t\t [cospi(r/4), -cospi(3*r/4)]]))\n ),\n DTT_S4_Base2_LS := SimpleRule(\n\t[ DTT_S4, 2, @, false ], \n\t(P, C) -> let(r:=P[3], Diag(sinpi(r/4), cospi(r/4)) * F(2) * Mat([[1,1],[0,2*cospi(r/2)]]))\n ),\n DTT_S4Poly_Base2 := SimpleRule(\n\t[ DTT_S4, 2, @, true ], \n\t(P, C) -> let(r:=P[3], F(2) * Mat([[1,1],[0,2*cospi(r/2)]]))\n ),\n\n #\n # Recursive rules\n #\n DTT_DIF_T := rec(\n\tisApplicable := P -> not IsPrime(P[2]) and P[2] > 2,\n\tforTransposition := false,\n\n\tbaseChange := (self, P, m) >> let(t := P[1], mn := P[2], \n\t Cond(Same(t, DTT_C3), B_DCT3_U(mn, m),\n\t\t Same(t, DTT_C4), B_DCT4_U(mn, m),\n\t\t Same(t, DTT_S3), B_DST3_U(mn, m),\n\t\t Same(t, DTT_S4), B_DST4_U(mn, m))),\n\n\trecursType := (self, t) >> \n\t Cond(Same(t, DTT_C3), DTT_S3,\n\t\t Same(t, DTT_C4), DTT_S3,\n\t\t Same(t, DTT_S3), DTT_S3,\n\t\t Same(t, DTT_S4), DTT_S3),\n\n\tallChildren := (self,P) >> let(\n\t type := P[1], MN := P[2], r := P[3], poly := P[4],\n\t divs := DivisorPairs(MN),\n\t List(divs, d -> let(j := Ind(d[2]),\n\t\t[ DTT(type, d[1], fr(d[2], j, r), poly), \n\t\t DTT(self.recursType(type), d[2], r, true) ]))),\n\t\n\trule := (self, P, C, Nonterms) >> let(MN := P[2], N := Rows(C[1]), M := Rows(C[2]), \n\t j := Nonterms[1].params[3].args[2],\n\t K(MN, N) * \n\t IterDirectSum(j, j.range, C[1]) *\n\t Tensor(C[2], I(N)) *\n\t self.baseChange(P, M)\n\t)\n )\n));\n\n", "meta": {"hexsha": "bbb6a14ef71a64fe500ddb047c3f017a0cc2d3aa", "size": 3768, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dtt/dttrules.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/dtt/dttrules.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/dtt/dttrules.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": 26.3496503497, "max_line_length": 94, "alphanum_fraction": 0.446656051, "num_tokens": 1665, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513786759491, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.6237536139641598}}
{"text": "# Built-in\nCombinations([1 .. n], m);\n\nCombinations([1 .. 5], 3);\n# [ [ 1, 2, 3 ], [ 1, 2, 4 ], [ 1, 2, 5 ], [ 1, 3, 4 ], [ 1, 3, 5 ],\n# [ 1, 4, 5 ], [ 2, 3, 4 ], [ 2, 3, 5 ], [ 2, 4, 5 ], [ 3, 4, 5 ] ]\n", "meta": {"hexsha": "c34163ec919caef084e8469a0e563e222a1eaa3a", "size": 205, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Combinations/GAP/combinations.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/Combinations/GAP/combinations.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/Combinations/GAP/combinations.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": 29.2857142857, "max_line_length": 69, "alphanum_fraction": 0.3268292683, "num_tokens": 129, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8479677660619633, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.6225096903153367}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# assuming the angles 2pi*a\nalpha2pi := (n,i,a) -> Cond(i mod 2 = 0, (a + Int(i/2))/n, (1-a + Int(i/2))/n);\n \nMat_rDFT := (N,a,k) -> let(n:=N/2,\n ConcatList([0..n-1], i -> let(aa := alpha2pi(n,i,a), [ \n Concatenation( List([0..n-1], j -> cospi(k*2*j*aa)), \n (-1)^i*List([0..n-1], j -> -sinpi(k*2*j*aa))),\n Concatenation( List([0..n-1], j -> sinpi(k*2*j*aa)), \n (-1)^i*List([0..n-1], j -> cospi(k*2*j*aa))) ])));\n\nMat_nrDFT := (N,a,k) -> let(n:=N/2,\n ConcatList([0..n-1], i -> let(\n raw := (i+a)/n,\n sign := When(raw > 1/2, -1, 1) * When(a > 1/2, -1, 1),\n aa := When(raw > 1/2, 1-raw, raw), [ \n Concatenation( List([0..n-1], j -> cospi(k*2*j*aa)), \n sign*List([0..n-1], j -> -sinpi(k*2*j*aa))),\n Concatenation( List([0..n-1], j -> sinpi(k*2*j*aa)), \n sign*List([0..n-1], j -> cospi(k*2*j*aa))) ])));\n\n_row_BRDFT_13 := (n,u,k) -> let(s := 1/sinpi(k*2*u),\n [ List([0..n-1], j -> -s*sinpi(k*2*u*(j-1))),\n List([0..n-1], j -> s*sinpi(k*2*u*j)) ]);\n\n# scaled = 2*cospi(u) * unscaled\n# since 2*cospi(u) / sinpi(2*u) = 1/sinpi(u)\n#\n_row_BRDFT_24 := (n,u, k,scaled) -> let(s := When(scaled, 1/sinpi(k*u), 1/sinpi(k*2*u)),\n [ List([0..n-1], j -> -s*sinpi(k*2*u*(j-1/2))),\n List([0..n-1], j -> s*sinpi(k*2*u*(j+1/2))) ]);\n\n# F.T. for the polynomial algebra below, basis in time = (1, x, ..., x^(n-1))\n# R[x] / x^n - 1\n#\nMat_BRDFT1 := (n,k) -> When(IsEvenInt(n),\n Concatenation(\n [List([0..n-1], i-> 1)],\n [List([0..n-1], i-> (-1)^i)],\n ConcatList([1..n/2-1], i -> _row_BRDFT_13(n, i/n, k))),\n Concatenation(\n [List([0..n-1], i-> 1)],\n ConcatList([1..(n-1)/2], i -> _row_BRDFT_13(n, i/n, k)))\n);\n\nMat_BRDFT1U := (n,k) -> When(IsOddInt(n), Mat_BRDFT1(n), \n Concatenation(\n [List([0..n-1], i-> When(IsEvenInt(i), 1, 0))],\n [List([0..n-1], i-> When(IsEvenInt(i), 0, 1))],\n ConcatList([1..n/2-1], i -> _row_BRDFT_13(n, i/n, k))));\n\n# -- i1 dst1 / dst1 i1\n# -- i1 dst5 / dst5\n\n\n# F.T. for the polynomial algebra below, basis in time = (x^(1/2),x^(3/2),..., x^(n-1/2))\n# R[x] / x^n - 1\n#\nMat_BRDFT2 := (n,k,scaled) -> When(IsEvenInt(n),\n Concatenation(\n [List([0..n-1], i-> 1)],\n [List([0..n-1], i-> (-1)^i)],\n ConcatList([1..n/2-1], i -> _row_BRDFT_24(n, i/n, k, scaled))),\n Concatenation(\n [List([0..n-1], i-> 1)],\n ConcatList([1..(n-1)/2], i -> _row_BRDFT_24(n, i/n, k, scaled))));\n# - dct2/dst2 dst2/dst2 - breaks?\n# - i1 dst6 dst6 -- ok\n# - i1 dst5 dst5 -- ok\n\n# F.T. for the polynomial algebras below, basis in time = (1,x,..., x^(n-1))\n# u = 1/4, n - even or odd\n# R[x] / x^n + 1\n#\n# u <> 1/4, n - even (\"skew\" BRDFT3)\n# R[x] / x^n - 2cos(2*pi*u) x^(n/2) + 1\n#\nMat_BRDFT3 := (n, u, k) -> When(IsEvenInt(n),\n ConcatList([0..n/2-1], i -> _row_BRDFT_13(n, 2*alpha2pi(n, i, u), k)),\n Concatenation(\n ConcatList([0..(n-3)/2], i -> _row_BRDFT_13(n, 2*alpha2pi(n, i, u), k)),\n [List([0..n-1], i-> (-1)^i)])\n);\n# dst3/dst3\n\n# F.T. for the polynomial algebras below, basis in time = (x^(1/2),x^(3/2),..., x^(n-1/2))\n# u = 1/4, n - even or odd\n# R[x] / x^n + 1\n#\n# u <> 1/4, n - even (\"skew\" BRDFT4)\n# R[x] / x^n - 2cos(2*pi*u) x^(n/2) + 1\n#\nMat_BRDFT4 := (n, u, k, scaled) -> When(IsEvenInt(n),\n ConcatList([0..n/2-1], i -> _row_BRDFT_24(n, 2*alpha2pi(n, i, u), k, scaled)),\n Concatenation(\n ConcatList([0..(n-3)/2], i -> _row_BRDFT_24(n, 2*alpha2pi(n, i, u), k, scaled)),\n [List([0..n-1], i-> (-1)^i)])\n);\n# dst4/dst4 -- scale(brdft4)\n\n# spiral> $ * scale(Mat_BRDFT4(16,1/4));\n# [ [ 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],\n# [ 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1 ],\n# [ 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 ],\n# [ 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0 ],\n# [ 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0 ],\n# [ 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0 ],\n# [ 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0 ],\n# [ 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0 ],\n# [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ],\n# [ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ],\n# [ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ],\n# [ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ],\n# [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ],\n# [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ],\n# [ 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0 ],\n# [ 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0 ] ]\n\nClass(Base_BRDFT, NonTerminal, TaggedObjectMixin, rec(\n isReal := True,\n dims := self >> let(n:=self.params[1], [n, n]),\n print := (self, i, is) >> let(base_print := NonTerminal.print, \n Print(base_print(self, i, is), \n When(IsBound(self.tags), Print(\".withTags(\", self.tags, \")\"))))\n));\n\nClass(rDFT, Base_BRDFT, rec(\n abbrevs := [ (n) -> Checked(IsPosIntSym(n), [n, 1/4, 1]),\n (n,a,rot) -> Checked(IsPosIntSym(n), IsRatSym(a), IsIntSym(rot), \n IsSymbolic(rot) or Gcd(n,rot)=1,\n let(aa := When(IsRat(a) and a>1/2, 1-a,a), [n, aa, rot])) ],\n\n terminate := self >> Mat(Mat_rDFT(self.params[1], EvalScalar(self.params[2]), self.params[3])),\n hashAs := self >> ObjId(self)(self.params[1]).withTags(self.getTags()),\n HashId := self >> Concatenation([self.params[1]], self.getTags())\n));\n\n# BRDFT1(<n>) - real DFT of type 1 non-terminal\n# Freq. basis :\n# (1), (1,x)*, (1)\n# Time basis :\n# (1, x, ..., x^(n-1))\n# Polynomial algebra :\n# R[x] / x^n - 1\n#\nClass(BRDFT1, Base_BRDFT, rec(\n abbrevs := [ (n) -> Checked(IsPosIntSym(n), [n, 1]),\n (n,rot) -> Checked(IsPosIntSym(n), IsIntSym(rot), [n, rot]) ],\n terminate := self >> let(mat := Mat(Mat_BRDFT1(self.params[1], EvalScalar(self.params[2]))),\n When(self.transposed, mat.transpose(), mat))\n));\n\n# Same as BRDFT1 but does not decompose polynomial algebra completely,\n# keeping 1D spectral components fused (ie first spectral component is \n# R[x]/x^2-1), with basis (1,x) as in all other components.\n#\nClass(UBRDFT1, Base_BRDFT, rec(\n abbrevs := [ (n) -> Checked(IsPosIntSym(n), [n, 1]),\n (n,rot) -> Checked(IsPosIntSym(n), IsIntSym(rot), [n, rot]) ],\n terminate := self >> Mat(Mat_BRDFT1U(self.params[1], EvalScalar(self.params[2])))\n));\n\n\n# BRDFT3(<n>) - real DFT of type 3 non-terminal\n# Freq. basis :\n# (1), (1,x)*, (1)\n# Time basis :\n# (1, x, ..., x^(n-1))\n# Polynomial algebra :\n# R[x] / x^n + 1\n#\nClass(BRDFT3, Base_BRDFT, rec(\n abbrevs := [ (n) -> Checked(IsPosIntSym(n), [n, 1/4, 1]),\n (n,a) -> Checked(IsPosIntSym(n), IsRatSym(a),\n let(aa := When(IsRat(a) and a>1/2, 1-a,a), [n, aa, 1])),\n (n,a, rot) -> Checked(IsPosIntSym(n), IsRatSym(a), IsIntSym(rot), \n let(aa := When(IsRat(a) and a>1/2, 1-a,a), [n, aa, rot])) ],\n\n terminate := self >> Mat(Mat_BRDFT3(self.params[1], EvalScalar(self.params[2]), EvalScalar(self.params[3]))),\n hashAs := self >> ObjId(self)(self.params[1]),\n));\n\n# -----------------------------------\n# Base changes and older misc stuff\n# -----------------------------------\n\nbblock := a -> let(aa := -2*cospi(2*a), [[-1, aa], [-aa, aa^2-1]]);\n\nbruun2 := (m,a) -> Checked((m mod 4)=0, let(\n a12 := When(a <= 1/2,\n [a/2, (a+1)/2],\n [(1-a)/2, (1-a+1)/2]),\n BlockMat([[I(m/2), Tensor(Mat(bblock(a12[1])), I(m/4))],\n [I(m/2), Tensor(Mat(bblock(a12[2])), I(m/4))]])));\n\n_omega := a -> E(Denominator(a))^Numerator(a);\n_shift := lst -> Concatenation(lst{[2..Length(lst)]}, [lst[1]]);\n_shift2 := lst -> Concatenation(lst{[2..Length(lst)]}, [-lst[1]]);\n\n# Polynomial transform for p(x)\n# P_{b,a} = [p_l(a_k)]_{k,l}\n# where b = {p_0, ...} is basis, typically {1,x,x^2,...}\n# and a = {a_0, ...} are roots of p(x)\n#\n# 2nd col is column of roots\n#\n# roots of x^n - omega{2pi*a} (==omega( (a+i)/n ))\nCycRoots := (n, a) -> List([0..n-1], i -> _omega((a+i)/n));\n\n# roots of x^2n - 2 x^n cos(2*pi*f) + 1\n# roots are ordered CCW on the unit circle\nPhiRoots := (N, f) -> let(n:=Numerator(f), d:=Denominator(f),\n ConcatList([0..N-1], i -> [E(N*d)^(n+d*i), E(N*d)^(-n-d*(N-1-i))]));\n\nPhiRoots2 := (N, f) -> let(n:=Numerator(f), d:=Denominator(f),\n Concatenation(\n List([0..N-1], i -> [E(2*N*d)^(n+d*i), E(2*N*d)^(-n-d*(2*N-1-i))])));\n\nphiRootsNewOrder := (n, a) -> # first omega will have negative angle, we have to make it last => _shift\n _shift(ConcatList([0..n-1], i -> [_omega((-a+i)/n), _omega((a+i)/n)]));\n\nphiRoots2NewOrder := (n, a) -> # first omega will have negative angle, we have to make it last and negate => _shift2\n _shift2(ConcatList([0..n-1], i -> [_omega((-a+i)/(2*n)), _omega((a+i)/(2*n))]));\n\nMat_BDFT := (n, a, rot) -> let(\n roots := phiRootsNewOrder(n/2, a),\n List([1..n], r -> List([0..n-1], c -> roots[r]^(rot*c))));\n\nMat_BDFT2 := (n, a, rot) -> let(\n roots := phiRoots2NewOrder(n/2, a),\n List([1..n], r -> List([0..n-1], c -> roots[r]^(rot*c))));\n\nalphai := (n,i,a) -> Cond(i mod 2 = 0, (a + Int(i/2))/n, (1-a + Int(i/2))/n);\n\ntime_r := a -> [[1, -cospi(2*a)/sinpi(2*a)],\n [0, 1/sinpi(2*a)]];\n\nr_time := a -> [[1, cospi(2*a)],\n [0, sinpi(2*a)]];\n\nB1_time_r := n -> DirectSum(I(1), List([1..Int((n-1)/2)], i-> Mat(time_r(i/n))), I(_even(n)));\nB3_time_r := n -> DirectSum(List([0..Int(n/2)-1], i -> Mat(time_r((i+1/2)/n))), I(_odd(n)));\n\nB3_r_time := (n,a) -> DirectSum(List([0..Int(n/2)-1], i -> Mat(r_time(alphai(n,i,a)))), I(_odd(n)));\n\n#ls := (n,func) -> List([0..n-1], func);\n\n#MatBRDFT3 := (N,a) -> MatSPL(BlockMat(let(n:=N/2,\n# ls(n, i->let(phi := [[0,-1],[1,2*cospi(2*alphai(n,i,a))]],\n# ls(n, j->Mat(phi^(2*j))))))));\n\n#MatBRDFT33 := (N,a) -> MatSPL(BlockMat(let(n:=N/2,\n# ls(n, i->let(phi := [[0,1],[1,-2*E(4)*sinpi(2*alphai(n,i,a))]],\n# ls(n, j->Mat(phi^(2*j))))))));\n\n\n#r:=MatSPL(B3_time_r(7)*SRDFT3(7));\n\n#MatBRDFT4 := (N,a) -> MatSPL(BlockMat(let(n:=N/2,\n# ls(n, i->let(start:=MatSPL(BRDFT4(2,alphai(n,i,a))), phi := [[0,-1],[1,2*cospi(2*alphai(n,i,a))]],\n# ls(n, j->Mat(start*phi^(2*j))))))));\n\n# roots := List(PhiRoots(100, 1/(4*23)), ComplexCyc);\n# DoForAll(last, x->AppendTo(\"roots\", ReComplex(x), \" \", ImComplex(x), \"\\n\"));\n# PrintTo(\"tmp.gnuplot\", \"plot 'roots' with lp\");\n# SYS_EXEC(\"gnuplot tmp.gnuplot -\");\n\n# m88:=MatSPL(M(16,2))*MatSPL(DFT3(16))*MatSPL(bruun2(16,1/4))^-1;\nscale := mat -> List(mat, x->x/x[1]);\n# Note:\n# GathExtend(n, Even1).transpose() * BSkewDFT3(n, a) * VStack(I(n/2), O(n/2)) == SkewDTT(DCT3(n/2), 2*a)\n# GathExtend(n, Odd1).transpose() * BSkewDFT4(n, a) * VStack(I(n/2), O(n/2)) == SkewDTT(DCT4(n/2), 2*a)\n#\n# BRDFT3 supports Odd0 input symmetry\n# BRDFT4 supports Odd1 input symmetry (incorrectly defined in Spiral)\n#\n# x3 := n -> MatSPL(Gath(H(n, n/2, 0, 2)) * BRDFT3(n) * GathExtend(n, Odd0)); == PolyDTT(DCT3(n/2)) == DCT3(n/2), other half=zero\n# x33 := n -> MatSPL(Gath(H(n, n/2, 1, 2)) * BRDFT3(n) * GathExtend(n, Even00)); == PolyDTT(DST3(n/2)), other half=first half * cospi( (2*i+1) / m), eg 1/8, 3/8, 5/8, 7/8 for n=8\n# y3 := n -> 2*MatSPL(Gath(H(n, n/2, 0, 2)) * BRDFT3(n) * DirectSum(I(1), -J(n-1))\n# 1/2* * GathExtend(n, Odd1))); == PolyDTT(DCT4(n/2)), other half=same\n# y33 := n -> 2*MatSPL(Gath(H(n, n/2, 0, 2)) * BRDFT3(n) * DirectSum(I(1), -J(n-1)) *\n# GathExtend(n, Even1)); == PolyDTT(DST4(n/2)), other half=neg\n#\n# z3 := n -> MatSPL(Gath(H(n, n/2, 1, 2)) * BRDFT4(n) * GathExtend(n, Odd1)); == PolyDTT(DCT4(n/2)), !new def\n# z33 := n -> scale(MatSPL(Gath(H(n, n/2, 0, 2)) * BRDFT4(n) * GathExtend(n, Even1))); == PolyDTT(DST4(n/2)), !new def\n#\n# x44 := n -> scale((-E(4)) * MatSPL(Gath(H(n, n/2, 1, 2)) * BRDFT4(n) * GathExtend(n, Odd1))); == PolyDTT(DCT4(n/2))\n# x4 := n -> (-E(4)) * MatSPL(Gath(H(n, n/2, 0, 2)) * BRDFT4(n) * GathExtend(n, Even1)); == DST4(n/2)\n# x4 := n -> scale(-E(4)) * MatSPL(Gath(H(n, n/2, 0, 2)) * BRDFT4(n) * GathExtend(n, Even1)); == PolyDTT(DST4(n/2))\n\n# spiral> pm(Gath(H(16,8,0,2))*BRDFT3(16)*GathExtend(16, Odd0));\n#\n# y := (n,a) -> MatSPL(Gath(H(n, n/2, 0, 2)) * BRDFT3(n,a) * DirectSum(I(1), -VStack(O(2,n/2-1), RI(n/2,n/2-1), O(n/2-3, n/2-1))));\n# == PolyDTT(SkewDTT(DST3(n/2), 2*a))\n#\n\n\n# # Decomposes C[x]/phi(.) or R[x]/phi(.) into 2-dim spectral\n# # components with basis 1,x\n# #\n# Class(BRDFT3, NonTerminal, rec(\n# abbrevs := [ (n) -> Checked(IsPosInt(n), [n, 1/4]),\n# (n,a) -> Checked(IsPosInt(n), IsRatSym(a),\n# let(aa := When(IsRat(a) and a>1/2, 1-a,a), [n, aa])) ],\n\n# terminate := self >> let(n:=self.params[1], a:=self.params[2],\n# M(n,n/2) * self.xmat() * BSkewDFT3(n, a).terminate()),\n\n# xmat := self >> let(n:=self.params[1], a:=self.params[2],\n# roots := Take(PhiRoots(n/2,a),n/2), cc := Global.Conjugate,\n# DirectSum(List(roots, r->Mat([[1,r],[1,cc(r)]]^-1)))^LIJ(n)),\n\n# isReal := True,\n# dims := self >> let(n:=self.params[1], [n, n]),\n# HashId := self >> self.params[1]\n# ));\n\n# Class(BRDFT4, BRDFT3, rec(\n# terminate := self >> let(n:=self.params[1], a:=self.params[2],\n# M(n,n/2) * self.xmat() * BSkewDFT4(n, a).terminate()),\n# # xmat := self >> let(n:=self.params[1], a:=self.params[2],\n# # roots := Take(PhiRoots2(n/2,a),n/2), cc := Global.Conjugate,\n# # DirectSum(List(roots, r->Mat([[r,r^3],[-cc(r),-cc(r)^3]]^-1)))^LIJ(n)),\n# ));\n\n#Class(BRDFT4, BRDFT3, rec(\n# terminate := self >> let(n:=self.params[1], a:=self.params[2],\n# Mat(scale(MatSPL(M(n,n/2) * self.xmat() * BSkewDFT4(n, a))))),\n## xmat := self >> let(n:=self.params[1], a:=self.params[2],\n## roots := Take(PhiRoots2(n/2,a),n/2), cc := Global.Conjugate,\n## DirectSum(List(roots, r->Mat([[r,r^3],[-cc(r),-cc(r)^3]]^-1)))^LIJ(n)),\n#));\n\n# -------------------------------------------------------------\n# Other transforms\n# -------------------------------------------------------------\n\n# roots of BSkewDFT3(2*n, u)\n# { E(n)^(2u+i) } union { E(n)^(-2u-i) }\n#\nClass(BSkewDFT3, NonTerminal, TaggedObjectMixin, rec(\n abbrevs := [ (n) -> Checked(IsPosIntSym(n), [n, 1/4, 1]),\n (n,a) -> Checked(IsPosIntSym(n), IsRatSym(a),\n let(aa := When(IsRat(a) and a>1/2, 1-a,a), [n, aa, 1])),\n (n,a,rot) -> Checked(IsPosIntSym(n), IsRatSym(a), IsIntSym(rot), \n let(aa := When(IsRat(a) and a>1/2, 1-a,a), [n, aa, rot])) ],\n\n terminate := self >> let(N := self.params[1], a := self.params[2], rot := self.params[3],\n roots := PhiRoots(N/2, EvalScalar(a)),\n Mat(List([1..N], r ->\n List([0..N-1], c -> roots[r]^(rot*c))))),\n\n isReal := False,\n dims := self >> let(n:=self.params[1], [n, n]),\n hashAs := self >> ObjId(self)(self.params[1]),\n));\n\nClass(PSkewDFT3, NonTerminal, TaggedObjectMixin, rec(\n abbrevs := [ (n) -> Checked(IsPosInt(n), [n, 1/4, 1]),\n (n,a) -> Checked(IsPosInt(n), IsRatSym(a), \n let(aa := When(IsRat(a) and a>1/2, 1-a,a), [n, aa, 1])),\n (n,a,rot) -> Checked(IsPosInt(n), IsRatSym(a), IsIntSym(rot), \n let(aa := When(IsRat(a) and a>1/2, 1-a,a), [n, aa, rot])) ],\n\n terminate := self >> let(N := self.params[1], a := EvalScalar(self.params[2]),\n rot := EvalScalar(self.params[3]), \n roots := PhiRoots(N/2, a),\n Mat(List([1..N], r ->\n Concatenation(\n List([0..N/2-1], c -> roots[r]^(rot*c)), \n List([N/2..N-1], c -> (roots[r]^(rot*c) - roots[r]^(rot*(c-N/2))*cospi(2*a*rot))/sinpi(2*a*rot)))))),\n\n isReal := False,\n dims := self >> let(n:=self.params[1], [n, n]),\n hashAs := self >> ObjId(self)(self.params[1]),\n));\n\nClass(BSkewDFT4, BSkewDFT3, rec(\n terminate := self >> let(N := self.params[1], a := EvalScalar(self.params[2]), rot := EvalScalar(self.params[3]), \n\troots := PhiRoots2(N/2, a),\n Mat(List([1..N], r -> \n\t List([0..N-1], c -> roots[r]^(rot*(2*c+1)))))),\n hashAs := self >> ObjId(self)(self.params[1]),\n));\n\n# NOTE: rot is missing\nClass(BSkewPRDFT, PRDFT3, TaggedObjectMixin, rec(\n abbrevs := [ (n) -> Checked(IsPosInt(n), [n, 1/4]),\n (n,a) -> Checked(IsPosInt(n), IsRatSym(a),\n let(aa := When(IsRat(a) and a>1/2, 1-a,a), [n, aa])) ],\n\n terminate := self >> let(N := self.params[1], a := EvalScalar(self.params[2]),\n\troots := PhiRoots(N/2, a),\n Mat(List([0..N-1], r -> \n\t When(r mod 2 = 0, \n\t\t List([0..N-1], c -> self.projRe(roots[1+r/2]^c)),\n\t\t List([0..N-1], c -> self.projIm(roots[1+(r-1)/2]^c)))))),\n hashAs := self >> ObjId(self)(self.params[1]),\n));\n# NOTE: rot is missing\nClass(BSkewRDFT, PRDFT3, TaggedObjectMixin, rec(\n abbrevs := [ (n) -> Checked(IsPosInt(n), [n, 1/4]),\n (n,a) -> Checked(IsPosInt(n), IsRatSym(a),\n let(aa := When(IsRat(a) and a>1/2, 1-a,a), [n, aa])) ],\n\n terminate := self >> let(N := self.params[1], a := EvalScalar(self.params[2]),\n\tK(N,2) * BSkewPRDFT(N,a).terminate()),\n\n hashAs := self >> ObjId(self)(self.params[1]),\n));\n", "meta": {"hexsha": "d4926328320ac102042050bd30ed36d892173e13", "size": 17510, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sym/brdft.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/brdft.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/brdft.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": 42.1927710843, "max_line_length": 186, "alphanum_fraction": 0.4940034266, "num_tokens": 7279, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9161096181702032, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.6222021387709046}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nnormCos := normalizeCosine;\ndnormCos := x -> When(IsDelay(x) and Type(x)=T_FUNCCALL and x[1] = D(normCos), \n\t x, PEV(normCos(x)));\n\ndnormCos := x -> When(IsRat(x), normCos(x), x);\n\n#F SkewDTT(<non-terminal for DCT/DST type 3/4>, <rat>)\n#F Parameters: [ <transform for DCT or dst type 3 or 4>, <rat> ]\n#F Definition: Let t be dct or dst type 3 or 4 as non-terminal spl.\n#F Transform( \"SkewDTT\", [t, r] ) represents the (n x n)-matrix\n#F [ cos(r_k*l*pi/n) | k,l = 0...n-1 ]\n#F [ sin(r_k*(l+1)*pi/n) | k,l = 0...n-1 ]\n#F [ cos(r_k*(l+1/2)*pi/n) | k,l = 0...n-1 ]\n#F [ sin(r_k*(l+1/2)*pi/n) | k,l = 0...n-1 ]\n#F for dct3, dst3, dct4, dst4, respectively\n#F where the list L of the r_k arises from the list\n#F [ (r + 2k)/n | 0 <= k < n ]\n#F by\n#F 1. normalizing the entries to lie in [0, 1] such\n#F \t\t that their cosine does not change\n#F 2. ordering the values increasing by size\n#F Note: for r = 1/2, the skew DCT3 reduces to the ordinary DCT3.\n#F The transpose is provided by the transform TSkewDTT\n#F Example: SkewDTT( DCT3(8), 1/3 )\n#F\nClass(SkewDTT, NonTerminal, rec(\n _short_print := true,\n abbrevs := [ (nt, r) -> Checked(IsNonTerminal(nt), IsRatSym(r), \n\t ObjId(nt) in [DCT3, DST3, DCT4, DST4],\n\t\t\t\t [Copy(nt), dnormCos(r)]) ],\n\n dims := self >> self.params[1].dimensions,\n\n terminate := self >> let(\n\tS := ObjId(self.params[1]),\n\tN := self.params[1].dimensions[1],\n\tr := EvalScalar(self.params[2]), \n\tCond(S = DCT3, Mat(SkewDCT_IIIunscaled(N, r)),\n\t S = DST3, Mat(SkewDST_IIIunscaled(N, r)),\n\t S = DCT4, Mat(SkewDCT_IVunscaled(N, r)),\n\t S = DST4, Mat(SkewDST_IVunscaled(N, r)),\n\t Error(\"Unrecognized <self.params[1].symbol>\"))),\n\n isReal := True\n\n# HashId := self >> self.params[1]\n));\n\nRulesFor(SkewDTT, rec(\n SkewDTT_Base2 := rec(\n info := \"DTT_2(r) -> F_2\",\n isApplicable := P -> P[1].dimensions[1] = 2,\n allChildren := P -> [ [ ] ],\n rule := (P,C) -> \n\t let(S := ObjId(P[1]),\n\t\tr := P[2],\n\t\tCond(\n\t\t S = DCT3, F(2) * Diag([1, CosPi(r/2)]),\n\n\t\t S = DST3, F(2) * Diag([SinPi(r/2), SinPi(r)]),\n\n\t\t S = DCT4, Diag([CosPi(r/4), SinPi(r/4)]) * F(2) *\n\t\t\t\t Mat([[1, -1], [0, 2*CosPi(r/2)]]),\n\n\t\t S = DST4, Diag([SinPi(r/4), CosPi(r/4)]) * F(2) *\n\t\t\t\t Mat([[1, 1], [0, 2*CosPi(r/2)]])))\n ),\n\n SkewDCT3_VarSteidl := rec(\n info := \"SkewDCT3_n -> IterDirectSum(SkewDCT3_n/2)\",\n\tswitch := true,\n\tforTransposition := false,\n isApplicable := P -> let(S := ObjId(P[1]), n := Rows(P[1]), \n\t S = DCT3 and IsPrimePowerInt(n) and n mod 2 = 0 and n > 2),\n\n\t# create one parametrized SkewDTT, use SampledVar() to make timing possible\n allChildren := P -> let(n := Rows(P[1]), r := P[2],\n\t [[ SkewDTT(DCT3(n/2), r/2), \n\t SkewDTT(DCT3(n/2), 1 - r/2) ]]), \n\n rule := (P,C) -> let(n := Rows(P[1]), r := P[2], \n\t K(n, n/2) *\n\t DirectSum(C[1], C[2]) * \n\t Tensor(F(2), I(n/2)) *\n\t sparse1(n, r/2))\n ),\n\n # NOTE: We need to be able to time SkewDTT(n, r) where r is free variable\n # otherwise DP does not work\n SkewDCT3_VarSteidlIterative := rec(\n info := \"SkewDCT3_n -> IterDirectSum(SkewDCT3_n/2)\",\n\tswitch := false,\n\tforTransposition := false, \n isApplicable := P -> let(S := ObjId(P[1]), n := Rows(P[1]), \n\t S = DCT3 and IsPrimePowerInt(n) and n mod 2 = 0 and n > 2),\n\n\t# create one parametrized SkewDTT, use SampledVar() to make timing possible\n allChildren := P -> let(n := Rows(P[1]), r := P[2], i:=Ind(2),\n\t [[ SkewDTT(DCT3(n/2), cond(i,1,0) + cond(i,-1,1)*r/2) ]]),\n\n rule := (P,C, Nonterms) -> let(\n\t n := Rows(P[1]), \n\t r := P[2], \n\t ivar := Nonterms[1].params[2].args[1].args[1],\n\n\t K(n, n/2) *\n\t IterDirectSum(ivar, 2, C[1]) * \n\t Tensor(F(2), I(n/2)) *\n\t sparse1(n, r/2))\n )\n));\n\n", "meta": {"hexsha": "36c1c5df3addcf6d9932221532e318667de7fcf4", "size": 4258, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dtt/skewdtt.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/dtt/skewdtt.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/dtt/skewdtt.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": 36.0847457627, "max_line_length": 81, "alphanum_fraction": 0.505636449, "num_tokens": 1516, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9019206659843132, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.6216989752012888}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n## extractP3(P, k) takes a bit matrix P and a boundary k, and returns \n## submatrix P3 where P is partitioned as \n##\n## P4 | P3\n## -------\n## P2 | P1\n## \n## If P is of size N by N, P3 is size N-k by k.\n##\nextractP3 := meth(P, k)\n local dim, row, i, j, res;\n dim := Length(P);\n res := [];\n for i in [1..dim-k] do\n row := [];\n for j in [dim-k+1..dim] do\n Append(row, [P[i][j]]);\n od;\n Append(res, [row]);\n od;\n return res;\nend;\n\n\n## extractP1(P, k) takes a bit matrix P and a boundary k, and returns \n## submatrix P1 where P is partitioned as \n##\n## P4 | P3\n## -------\n## P2 | P1\n## \n## P1 is size k by k.\n##\nextractP1 := meth(P, k)\n local dim, row, i, j, res;\n dim := Length(P);\n res := [];\n for i in [dim-k+1..dim] do\n row := [];\n for j in [dim-k+1..dim] do\n Append(row, [P[i][j]]);\n od;\n Append(res, [row]);\n od;\n return res;\nend;\n\n\n\n## NonZeroRows(P) determines which rows of P are not all-zero. It returns a \n## vector (indexed starting from 1) that indicates these rows.\n##\nNonZeroRows := meth(P2)\n local i, l, t, res;\n res := [];\n\n for i in [1..Length(P2)] do\n t := 0;\n\n for l in [1..Length(P2[i])] do\n if (P2[i][l] <> 0 * GF(2).one) then t := t + 1; fi;\n od;\n\n if (t <> 0) then Append(res, [i]); fi;\n\n od;\n return res;\nend;\n\n## ZeroRows(P) determines which rows of P are all zero. It returns a \n## vector (indexed starting from 1) that indicates these rows.\n##\nZeroRows := meth(P1)\n local i, l, t, res;\n res := [];\n\n for i in [1..Length(P1)] do\n t := 0;\n\n for l in [1..Length(P1[i])] do\n if (P1[i][l] <> 0 * GF(2).one) then t := t + 1; fi;\n od;\n\n if (t = 0) then Append(res, [i]); fi;\n\n od;\n return res;\nend;\n\n\n## buildH2(i, j, n, k) builds matrix H2 given i, j, n, and k as in\n## Algorithm 5.2, Case 1, Line 3, in the Streaming Permutation\n## paper.\n##\nbuildH2 := meth(i, j, n, k)\n local res, l, c;\n res := [];\n c := 1;\n for l in [1..n-k] do\n if l in j then\n Append(res, [BasisVec(k, i[c]-1) * GF(2).one]);\n\t c := c+1;\n else\n\t Append(res, [ List([1..k], x -> 0 * GF(2).one) ]);\n fi;\n od;\n\n return TransposedMat(res);\nend;\n\n\n## buildH(n, k, H2) constructs matrix H given size n, partition\n## location k, and submatrix H2.\n##\n## I(n-k) | 0\n## -------|-----\n## H2 | I(k)\n##\nbuildH := meth(n, k, H2)\n local res, i;\n res := [];\n for i in [1..n-k] do\n Append(res, [BasisVec(n, i-1) * GF(2).one]);\n od;\n for i in [n-k+1..n] do\n Append(res, [Concatenation(H2[i-(n-k)], BasisVec(k, i-(n-k)-1) * GF(2).one )]);\n od;\n \n return res;\nend;\n\n\n## GetTopLeftOnes(P, k) counts the number of ones in the top \n## left corner. \n##\nGetTopLeftOnes := meth(P, k)\n\n# local count, x, size;\n\n# size := Length(P);\n# count := 1;\n\n# repeat x := P[count][count]; count := count+1; until x <> GF(2).one;\n\n# return Min2(count-2, size-k); \n \n local size, count, x, y, Pt;\n\n Pt := TransposedMat(P);\n size := Length(P);\n count := 0;\n\n\n repeat \n\tcount := count+1;\n x := P[count];\n\ty := Pt[count];\n until ((x <> BasisVec(size, count-1) * GF(2).one) or (y <> BasisVec(size, count-1) * GF(2).one) or (count = size));\n\n return Min2(count-1, size-k);\n\n\nend;\n\n## AddTopLeftOnes(P, l) adds l ones to the top left corner. \n##\nAddTopLeftOnes := meth(P, l)\n local size, res, i, t;\n size := Length(P);\n res := [];\n\n for i in [1..l] do\n Append(res, [BasisVec(size+l, i-1)]*GF(2).one);\n od;\n\n t := List([1..l], e->0*GF(2).one);\n \n for i in [1..size] do\n Append(res, [Concatenation(t, P[i])]);\n od;\n\n return res;\n\nend;\n\n\n## TransposeVector(x) transposes 1d 'horizontal' vector x into\n## a 2d 'vertical' vector.\n##\nTransposeVector := meth(x)\n local i, res;\n res := [];\n if IsList(x[1]) then\n for i in [1 .. Length(x)] do res[i] := x[i][1]; od;\n else\n for i in [1 .. Length(x)] do res[i] := [x[i]]; od;\n fi;\n return res;\nend;\n\n\n\n## CheckPerm(P) returns 1 if P is a permutation matrix, \n## and 0 otherwise.\n##\nCheckPerm := meth(P)\n local i, j, t, row;\n P := BitMatrixToInts(P);\n\n for i in [1 .. Length(P)] do\n if ( Sum( P[i]{ [ 1..Length(P[i]) ] } ) <> 1) then\n\t return 0;\n fi; \n od;\n\n return 1;\nend;\n\n\nswitchCols := meth(P, a, b)\n local ptrans, row;\n ptrans := TransposedMat(P);\n row := ptrans[a];\n ptrans[a] := ptrans[b];\n ptrans[b] := row;\n\n return TransposedMat(ptrans);\nend;\n\nDeclare(BRAMPerm);\nDeclare(STensor);\nDeclare(MyTriangulizeMat);\n#Declare(BRAMPermStreamOne);\nDeclare(PermMatrixRowVals);\n\n# ===============================================\n# A container for a streaming permutation\n# StreamPermBit(<SPL>, <q>)\n# where <SPL> is the permutation as an SPL object, and <q> \n# is the streaming width.\n# ===============================================\nClass(StreamPermBit, BaseMat, SumsBase, rec(\n\tabbrevs := [(s, q) -> [s, q]], \n\n\tnew := (self, prm, ss) >> SPL(WithBases(self, rec(\n\t _children := [prm],\n\t streamSize := ss, \n\n\t dimensions := prm.dims(),\n\t ))),\n\n\trChildren := self >> self._children,\n\trSetChild := meth(self, n, what) self._children[n] := what; end,\n\tchild := (self, n) >> self._children[1],\n\tchildren := self >> self._children,\n\n\tcreateCode := meth(self) \n\t local res, p3, p1, r, k, M, N, P, x, i, j, l, K, size, count, ptrans, z, G, q1, q3, q3b, p1b, G;\n\n # if (self.streamSize = 1) then\n# return BRAMPermStreamOne(PermMatrixRowVals(MatSPL(self.child(1))), \n# self.child(1));\n# fi; \n\n\t k := Log2Int(self.streamSize);\n\t P := self._children[1]._children[1];\n\t size := Log2Int(self.dimensions[1]);\n\n # If our streaming width is 1, then we are done. P = I*P.\n # We no longer do this, because we use the general version above.\n\t if (self.streamSize = 1) then\n\t #return BRAMPerm(P, MatSPL(I(size))*GF(2).one, 1);\n return BRAMPerm(MatSPL(I(size))*GF(2).one, P, 1);\n\t fi;\n\n\t # if P is the bit form of I tensor P',\n\t # we can remove the top-left corner bits\n\t # (up to (size-k) bits, and replace them\n\t # with a streaming tensor product of a \n\t # smaller permutation\n\t count := GetTopLeftOnes(P,k);\n\t P := P{[count+1..Length(P)]}{[count+1..Length(P)]};\n\n\t size := size-count;\n\t \n\t p3 := extractP3(P, k);\n\t p1 := extractP1(P, k);\n\n\t r := Rank(p1);\n\n\t if (r = k) then\n\t M := P;\n\t N := MatSPL(I(Length(M))) * GF(2).one;\n\t else \n if (CheckPerm(P) = 1) then\t\n\t j := NonZeroRows(p3);\n\t i := ZeroRows(p1);\n\t else\n\t\t p1b := TransposedMat(Copy(p1));\n\t\t G := MyTriangulizeMat(p1b);\n\t\t G := TransposedMat(G);\n\t\t q1 := p1 * G;\n\t\t q3 := p3 * G;\n\t\t \n \t\t z := LinearIndependentColumns(TransposedMat(q1));\n \t\t i := [];\n \n \t\t for l in [1 .. k] do\n \t\t if (l in z) then\n \t\t ;\n else\n \t\t Add(i, l);\n \t\t fi;\n \t\t od;\n \n \t\t q3b := [];\n\t\t \n \t\t for l in [1 .. k] do\n \t\t Append(q3b, q3{[r+1..k]});\n \t\t od;\n \n \t\t j := LinearIndependentColumns(TransposedMat(q3b));\n fi;\n \n\t K := buildH2(i, j, size, k);\n \n\t N := buildH(size, k, K) * GF(2).one; \n\t M := N*P;\t \n\t fi;\n\t \n\t if (Maximum(Maximum(N * M - P)) <> 0 * GF(2).one) then\n\t Print(\"ERROR: Could not factor permutation matrix.\\n\");\n\t fi;\n\n\t if (count = 0) then\n\t return BRAMPerm(N, M, self.streamSize);\n\t else\n\t return STensor(BRAMPerm(N,M,self.streamSize), 2^count, self.streamSize);\n\t fi;\n end,\n \n\tprint := (self,i,is) >> Print(self.name, \"(\", self._children[1], \", \", self.streamSize, \")\"),\n\n\ttoAMat := self >> AMatMat(BitsToPermMatrix(self._children[1]._children[1])),\n\tdims := self >> self._children[1].dims(),\n\n\tsums := self >> self,\n\n));\n\n\n# ===============================================\n# A streaming permutation that has been factored into reading and writing \n# into a dual-ported RAM\n# BRAMPerm(M, N)\n# where M and N are bit representations of the factorized perm\n# \n# (see Pueschel, Milder, and Hoe. \"Permuting Streaming Data Using RAMs.\")\n# ===============================================\nClass(BRAMPerm, BaseMat, SumsBase, rec(\n\tabbrevs := [(m,n,q)-> [m,n,q]], \n\n\tnew := (self, m, n,q) >> SPL(WithBases(self, rec(\n\t\t _children := [m,n],\n\t\t dimensions := [2^Length(m), 2^Length(m)],\n\t\t streamSize := q\n\t ))),\n\n\trChildren := self >> self._children,\n\trSetChild := meth(self, n, what) self._children[n] := what; end,\n\tchild := (self, n) >> self._children[n],\n\tchildren := self >> self._children,\n\n\tcreateCode := self >> self,\n print := (self,i,is) >> Print(self.name, \"(\", BitMatrixToInts(self._children[1]), \", \", BitMatrixToInts(self._children[2]), \", \", self.streamSize, \")\"), \n\n\ttoAMat := self >> AMatMat(BitsToPermMatrix(self.child(1)) * BitsToPermMatrix(self.child(2))),\n\tdims := self >> [2^(Length(self._children[1])), 2^(Length(self._children[1]))],\n\n\tsums := self >> self\n));\n\n## PermMatrixRowVals(p) takes permutation matrix p and returns a list\n## of the '1' location in each row of the matrix.\nPermMatrixRowVals := meth(x)\n local length, i, res;\n\n res := [];\n length := Length(x);\n for i in [1 .. length] do\n res[i] := BasisVecToNum(x[i]);\n od;\n return res;\nend;\n\n\n#############################################################################\n##\n#F MyTriangulizeMat( <mat> ) . . . . . bring a matrix in upper triangular form\n##\n## This is a modified version of TriangulizeMat included with Gap.\n## I have modified it to keep track of the elementary row\n## operations performed, and return their product.\nMyTriangulizeMat := function ( mat )\n local m, n, i, j, k, row, row2, zero, G;\n\n if mat <> [] then \n\n # get the size of the matrix\n m := Length(mat);\n n := Length(mat[1]);\n zero := 0*mat[1][1];\n G := MatSPL(I(Length(mat)));\n \n # run through all columns of the matrix\n i := 0;\n for k in [1..n] do\n \n # find a nonzero entry in this column\n j := i + 1;\n while j <= m and mat[j][k] = zero do j := j + 1; od;\n \n # if there is a nonzero entry\n if j <= m then\n \n # increment the rank\n InfoMatrix2(k,\" \\c\");\n i := i + 1;\n \n # make its row the current row and normalize it\n row := mat[j]; mat[j] := mat[i]; mat[i] := row[k]^-1 * row;\n\t row2 := G[j]; G[j] := G[i]; G[i] := row[k]^-1 * row2;\n\t # Print(\"aG = \", G, \"\\n\");\n\t # Print(\"amat = \", mat, \"\\n\");\n\n # clear all entries in this column\n for j in [1..m] do\n if i <> j and mat[j][k] <> zero then\n\t\t G[j] := G[j] - mat[j][k] * G[i];\n mat[j] := mat[j] - mat[j][k] * mat[i];\n\t\t # Print(\"bG = \", G, \"\\n\");\n\t\t # Print(\"G[i] = \", G[i], \"\\n\");\n\t\t # Print(\"mat[j][k] = \", mat[j][k], \"\\n\");\n\t\t # Print(\"bmat = \", mat, \"\\n\");\n fi;\n od;\n \n fi;\n \n od;\n\n fi;\n\n return G;\n\nend;\n", "meta": {"hexsha": "0ce32da8826ee9d57dc48d99d9e76776ad162793", "size": 11520, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/stream/streambitperms.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/paradigms/stream/streambitperms.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/paradigms/stream/streambitperms.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.9350649351, "max_line_length": 166, "alphanum_fraction": 0.4996527778, "num_tokens": 3613, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.831143031127974, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.6201482290021756}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nprocessCRP := meth(partA, partB)\n local size, switches, next, modA, modB, loc, setA, choice;\n size := Length(partA);\n \n modA := List([1..size], i-> Mod(partA[i], size));\n modB := List([1..size], i-> Mod(partB[i], size));\n \n setA := [];\n\n switches := List([1..size], i->-1);\n next := -1;\n \n while (-1 in switches) do\n \n # if next = -1, then we can make an arbitrary decision.\n if (next < 0) then\n # find the next switch that isn't set.\n choice := PositionProperty(modA, i-> i <> -1);\n \n switches[choice] := 0;\n Append(setA, [modA[choice]]);\n\n # We just assigned modA[choice] to partition A.\n # Thus, we precluded modB[choice] from being in parition A.\n # So, we need to check. If modB[choice] is not already in \n # partition A, then we need to make it our next choice.\n \n if (modB[choice] in setA) then\n next := -1;\n else\n next := modB[choice];\n fi; \n modA[choice] := -1; modB[choice] := -1;\n \n else\n # if next >= 0, then it represents the 'mod' number we must\n # assign to partition A.\n \n # the next value must be in the set of unchosen values in one\n # of the two partitions.\n if (next in modA) then\n choice := Position(modA, next);\n switches[choice] := 0;\n Append(setA, [modA[choice]]);\n\n if (modB[choice] in setA) then\n next := -1;\n else\n next := modB[choice];\n fi;\n \n else\n choice := Position(modB, next);\n switches[choice] := 1;\n Append(setA, [modB[choice]]);\n \n if (modA[choice] in setA) then\n next := -1;\n else\n next := modA[choice];\n fi;\n fi;\n modA[choice] := -1; modB[choice] := -1;\n fi;\n \n od;\n\n return switches;\nend;\n\n# Given a permutation permIn, determine the switch settings for the\n# un-simplified \\Omega\\Omega^{-1} network. \n#\n# See: K. Y. Lee. On the rearrangeability of 2(\\log_2n)-1 stage\n# permutation networks. IEEE Transactions on Computers,\n# C-34(5):412-425, May 1985.\n\n# We do not simplify the network, because my network generation code\n# will simplify all unneeded switches.\n\nroutePerm := meth(permIn)\n local n, ss, ns, p, p2, col, numP, partSize, partA, partB, i, j, k, partStride, tmpSw, swCol, tmp;\n \n# Print(\"Routing perm: \", permIn, \"\\n\");\n\n n := Length(permIn);\n\n # The perm comes in as row values. I.e., PermRowVals[i] -> i.\n # We need to transpose this. \n p := List([1..n], i->0);\n for i in [0..n-1] do p[permIn[i+1]+1] := i; od;\n \n # This is suboptimal. For now, I will simply let the unnecessary\n # switches be all-zero.\n ns := n/2 * (LogInt(n,2) + LogInt(n,2)-1);\n \n ss := [];\n \n for k in [0..LogInt(n,2)-2] do\n col := LogInt(n,2)-1-k;\n \n # Permute output values by L(n,n/2)\n p2 := List([1..n], i -> p[L(n,n/2).at(i-1).ev()+1]);\n\n # Now we need to set the switches for the E^{col}_{R} column. \n numP := 2^k;\n partSize := n/(2*numP);\n partStride := 2*numP;\n \n swCol := List([1..n/2], i -> -1);\n tmpSw := [];\n for i in [0..numP-1] do\n partA := [];\n partB := [];\n for j in [1..partSize] do\n Append(partA, [p2[partStride*(j-1)+1+(2*i)]]);\n Append(partB, [p2[partStride*(j-1)+2+(2*i)]]); \n od;\n\n Append(tmpSw, processCRP(partA, partB));\n \n od;\n \n swCol := List([1..n/2], i -> tmpSw[L(n/2,n/(2^(k+1))).at(i-1).ev()+1]);\n Append(ss, swCol);\n \n # Now we have to perform the permutation based on the\n # switches we set.\n for i in [0..n/2-1] do\n if (swCol[i+1] = 1) then\n p[i*2+1] := p2[i*2+2];\n p[i*2+2] := p2[i*2+1];\n else\n p[i*2+1] := p2[i*2+1];\n p[i*2+2] := p2[i*2+2];\n fi;\n od;\n od;\n\n # Permute output values by L(n,n/2)\n p2 := List([1..n], i -> p[L(n,n/2).at(i-1).ev()+1]); \n\n for k in [0..LogInt(n,2)-1] do\n\n swCol := [];\n # go through the n/2 switches. at each switch, if the top input's value\n # has a 1 in bit k.\n for i in [0..n/2-1] do\n if (imod(idiv(p2[2*i+1], 2^k), 2).ev() = 1) then\n Append(swCol, [1]);\n else\n Append(swCol, [0]);\n fi;\n od;\n\n Append(ss, swCol);\n\n # Now we have to perform the permutation based on the\n # switches we set.\n for i in [0..n/2-1] do\n if (swCol[i+1] = 1) then\n p[i*2+1] := p2[i*2+2];\n p[i*2+2] := p2[i*2+1];\n else\n p[i*2+1] := p2[i*2+1];\n p[i*2+2] := p2[i*2+2];\n fi;\n od;\n\n # Permute output values by L(n,2)\n p2 := List([1..n], i -> p[L(n,2).at(i-1).ev()+1]); \n\n od;\n\n p := List([0..n-1], i->i);\n if (p <> p2) then\n Error(\"Failed at configuring switching network.\");\n fi;\n\n# Print(\"Configuration: \", ss, \"\\n\");\n\n return ss;\nend;\n\n\n\n# Given a permutation permIn, determine the switch settings for the\n# \\Omega^{-1} network. \n#\n# We will return -1 if the permutation cannot be mapped to that network.\n# In this case, then, you should use routePerm to map it to the\n# \\Omega\\Omega^{-1} network.\n\n# For now, we will cheat and use the \\Omega\\Omega^{-1} routing algorithm.\n# It appears that when we use this algorithm on a permutation that can be\n# permformed on the \\Omega^{-1}, then the configuration bits are simply\n# all zero for the first \\Omega portion of the network. However, I haven't \n# verified this and I haven't looked at the routePerm code in many years.\n\n# I have not proven this will be the case, but it seems to work on the\n# circular shift permutations I am currently using.\n\n# All circular shifts will be Omega^{-1} passable by Theorems 3 and 13 of \"Access\n# and Alignment of Data in an Array Processor,\" Duncan H. Lawrie, IEEE Tr.\n# on Computers, C-24 (12), 1975.\n#\n# Theorem 3: Duncan says that if you can represent your mapping as:\n# P_N(a, b, c, d, e) = {(ax+b, cx+d) | 0 \\leq x < e}\n# where ax+b represents the source (mod N) and cx+d represents the\n# destination (mod N),\n# then your mapping is \\Omega passable if gcd(a,N) \\leq gcd(c,N) and\n# e \\leq N/(gcd(c,N).\n# For a cyclic shift, a and c will always = 1, b=0, d equals the number\n# of positions to shift, and e=N.\n# Since a and c are 1, gcd(a,N) and gcd(c,N) are both 1 and hence equal.\n# Further, N/gcd(c,N) = N, and therefore e = N/gcd(c,N).\n\n# Lastly we note that Theorem 13 says that if a mapping is \\Omega passable\n# it must be \\Omega^{-1} passable.\n\nroutePermOmegaInv := meth(permIn)\n local full, n, ns, numSwitchesZero;\n\n full := routePerm(permIn);\n n := Length(permIn);\n ns := n/2 * (LogInt(n,2) + LogInt(n,2)-1);\n \n # If this permutation is Omega^{-1} routable, then the first numSwitchesZero\n # must be configured to zero.\n numSwitchesZero := n/2 * (LogInt(n,2)-1);\n \n if (Sum(full{[1..numSwitchesZero]}) <> 0) then\n\treturn -1;\n fi;\n\t\n return full{[numSwitchesZero+1 .. ns]};\nend;\n\ncyclicShiftList := meth(size, shift)\n local t, res, t2;\n t := [0..size-1];\n shift := Mod(shift, size);\n res := t{[shift+1..size]};\n if (shift = 1) then\n\tt2 := [0];\n else\n\tt2 := t{[1..shift]};\n fi;\n\n Append(res, t2);\n return res;\nend;\n\n\nClass(omegaInvNetwork, BaseMat, SumsBase, rec(\n\n abbrevs := [(n, p, it) -> [n, p, it]],\n\n new := (self, n, perms) >> SPL(WithBases(self, rec(\n\t\t dimensions := [n, n],\n\t\t _children := [n, perms]\n\t ))),\n rChildren := self >> self._children,\n rSetChild := meth(self, n, what) self._children[n] := what; end,\n child := (self, n) >> self._children[n],\n children := self >> self._children,\n\n \n print := (self,i,is) >> Print(self.name, \"(\", self.child(1), \", \", self.child(2), \")\"),\n\n dims := self >> [self._children[1], self._children[1]],\n\n));\n\noverlapAddCyclicShifts := meth(num_points, step_size, num_steps)\n local res, i, it;\n \n res := [];\n for i in [0 .. num_steps-1] do\n Append(res, [[routePermOmegaInv(cyclicShiftList(num_points, step_size*i))]]);\n od;\n\n return omegaInvNetwork(num_points, res);\n\nend;\n\n# generage Verilog for Inverse Omega network for a family of cyclic shift permutation, \n# given by C_n^(s*l), where l = 0 .. k.\n# In code below, n is \"num_points\", s is \"step_size\", k is \"num_steps\".\n#\n# \"bits\" gives the number of bits per word.\n# \"name\" gives the output filename, which will be created in /tmp/spiral/[PID] where \n# [PID] is Spiral's process ID. You can find the current PID in Spiral by typing\n# getPid();\n#\n# If you want to change this diretory, it is easy to do\n# so; just edit the file hacks.gi in spiral/paradigms/stream/hacks.gi\n#\n# To generate an 8 point network that will perform C_8^0, C_8^1, ..., C_8^7, and\n# store it in file.v, run:\n# genOverlapAddShift(8, 1, 8, 16, \"file\");\ngenOverlapAddShift := function(num_points, step_size, num_steps, bits, name)\n local opts;\n opts := InitStreamUnrollHw();\n HDLGen(overlapAddCyclicShifts(num_points, step_size, num_steps), 1, 0, bits, 0, 0, name);\nend;", "meta": {"hexsha": "63c7cebfd39db200ba7b8dba31ef9909dc6cf0d9", "size": 9782, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/stream/permnetwork.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/paradigms/stream/permnetwork.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/paradigms/stream/permnetwork.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.4533762058, "max_line_length": 102, "alphanum_fraction": 0.5368022899, "num_tokens": 2966, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267898240861, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.6188064075486973}}
{"text": "IsKaprekar := function(n)\n\tlocal a, b, p, q;\n\tif n = 1 then\n\t\treturn true;\n\tfi;\n\tq := n*n;\n\tp := 10;\n\twhile p < q do\n\t\ta := RemInt(q, p);\n\t\tb := QuoInt(q, p);\n\t\tif a > 0 and a + b = n then\n\t\t\treturn true;\n\t\tfi;\n\t\tp := p*10;\n\tod;\n\treturn false;\nend;\n\nFiltered([1 .. 10000], IsKaprekar);\n# [ 1, 9, 45, 55, 99, 297, 703, 999, 2223, 2728, 4879, 4950, 5050, 5292, 7272,\n# 7777, 9999 ]\n\nSize(last);\n# 17\n\nFiltered([1 .. 1000000], IsKaprekar);\n# [ 1, 9, 45, 55, 99, 297, 703, 999, 2223, 2728, 4879, 4950, 5050, 5292, 7272,\n# 7777, 9999, 17344, 22222, 38962, 77778, 82656, 95121, 99999, 142857,\n# 148149, 181819, 187110, 208495, 318682, 329967, 351352, 356643, 390313,\n# 461539, 466830, 499500, 500500, 533170, 538461, 609687, 627615, 643357,\n# 648648, 670033, 681318, 791505, 812890, 818181, 851851, 857143, 961038,\n# 994708, 999999 ]\n\nSize(last);\n# 54\n\n\nIsKaprekarAndHow := function(n, base)\n\tlocal a, b, p, q;\n\tif n = 1 then\n\t\treturn true;\n\tfi;\n\tq := n*n;\n\tp := base;\n\twhile p < q do\n\t\ta := RemInt(q, p);\n\t\tb := QuoInt(q, p);\n\t\tif a > 0 and a + b = n then\n\t\t\treturn [a, b];\n\t\tfi;\n\t\tp := p*base;\n\tod;\n\treturn false;\nend;\n\nIntegerToBaseRep := function(n, base)\n\tlocal s, digit;\n\tif base > 36 then\n\t\treturn fail;\n\telif n = 0 then\n\t\treturn \"0\";\n\telse\n\t\ts := \"\";\n\t\tdigit := \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\t\twhile n <> 0 do\n\t\t\tAdd(s, digit[RemInt(n, base) + 1]);\n\t\t\tn := QuoInt(n, base);\n\t\tod;\n\t\treturn Reversed(s);\n\tfi;\nend;\n\nPrintIfKaprekar := function(n, base)\n\tlocal v;\n\tv := IsKaprekarAndHow(n, base);\n\tif IsList(v) then\n\t\tPrint(n, \"(10) or in base \", base, \", \",\n\t\t\tIntegerToBaseRep(n, base), \"^2 = \",\n\t\t\tIntegerToBaseRep(n^2, base), \" and \",\n\t\t\tIntegerToBaseRep(v[2], base), \" + \",\n\t\t\tIntegerToBaseRep(v[1], base), \" = \",\n\t\t\tIntegerToBaseRep(n, base), \"\\n\");\n\tfi;\n\treturn fail;\nend;\n\n# In base 17...\nPerform([1 .. 1000000], n -> PrintIfKaprekar(n, 17));\n# 16(10) or in base 17, G^2 = F1 and F + 1 = G\n# 64(10) or in base 17, 3D^2 = E2G and E + 2G = 3D\n# 225(10) or in base 17, D4^2 = A52G and A5 + 2G = D4\n# 288(10) or in base 17, GG^2 = GF01 and GF + 1 = GG\n# 1536(10) or in base 17, 556^2 = 1B43B2 and 1B4 + 3B2 = 556\n# 3377(10) or in base 17, BBB^2 = 8093B2 and 809 + 3B2 = BBB\n# 4912(10) or in base 17, GGG^2 = GGF001 and GGF + 1 = GGG\n# 7425(10) or in base 17, 18BD^2 = 24E166G and 24E + 166G = 18BD\n# 9280(10) or in base 17, 1F1F^2 = 39B1B94 and 39B + 1B94 = 1F1F\n# 16705(10) or in base 17, 36DB^2 = B992C42 and B99 + 2C42 = 36DB\n# 20736(10) or in base 17, 43CD^2 = 10DE32FG and 10DE + 32FG = 43CD\n# 30016(10) or in base 17, 61EB^2 = 23593F92 and 2359 + 3F92 = 61EB\n# 36801(10) or in base 17, 785D^2 = 351E433G and 351E + 433G = 785D\n# 37440(10) or in base 17, 7A96^2 = 37144382 and 3714 + 4382 = 7A96\n# 46081(10) or in base 17, 967B^2 = 52G94382 and 52G9 + 4382 = 967B\n# 46720(10) or in base 17, 98B4^2 = 5575433G and 5575 + 433G = 98B4\n# 53505(10) or in base 17, AF26^2 = 6GA43F92 and 6GA4 + 3F92 = AF26\n# 62785(10) or in base 17, CD44^2 = 9A5532FG and 9A55 + 32FG = CD44\n# 66816(10) or in base 17, DA36^2 = AEG42C42 and AEG4 + 2C42 = DA36\n# 74241(10) or in base 17, F1F2^2 = D75F1B94 and D75F + 1B94 = F1F2\n# 76096(10) or in base 17, F854^2 = E1F5166G and E1F5 + 166G = F854\n# 83520(10) or in base 17, GGGG^2 = GGGF0001 and GGGF + 1 = GGGG\n# 266224(10) or in base 17, 33334^2 = A2C52A07G and A2C5 + 2A07G = 33334\n", "meta": {"hexsha": "40c9d467adfbe24cb542097dd05040a0d16f7b0d", "size": 3339, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Kaprekar-numbers/GAP/kaprekar-numbers.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/Kaprekar-numbers/GAP/kaprekar-numbers.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/Kaprekar-numbers/GAP/kaprekar-numbers.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": 29.8125, "max_line_length": 78, "alphanum_fraction": 0.6121593291, "num_tokens": 1619, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952921073469, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.6187864127410454}}
{"text": "# Creating an array of 0\na := NullMat(2, 2);\n# [ [ 0, 0 ], [ 0, 0 ] ]\n\n# Some assignments\na[1][1] := 4;\na[1][2] := 5;\na[2][1] := 3;\na[2][2] := 4;\n\na\n# [ [ 4, 5 ], [ 3, 4 ] ]\n\nDeterminant(a);\n# 1\n", "meta": {"hexsha": "89bd294f5d52b213f68f04c368aa68bcb57c0cd5", "size": 195, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Create-a-two-dimensional-array-at-runtime/GAP/create-a-two-dimensional-array-at-runtime.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/Create-a-two-dimensional-array-at-runtime/GAP/create-a-two-dimensional-array-at-runtime.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/Create-a-two-dimensional-array-at-runtime/GAP/create-a-two-dimensional-array-at-runtime.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": 12.1875, "max_line_length": 24, "alphanum_fraction": 0.4153846154, "num_tokens": 106, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.7905303236047049, "lm_q1q2_score": 0.6187184227599262}}
{"text": "# Copyright (c) 2018-2020, Carnegie Mellon University\n# See LICENSE for details\n#\n# Quantum Hadamard transform\n#\n\n\n#F qHT( n ) - Hadamard Gate non-terminal\n#F Definition: (2^n x 2^n)-matrix that applies an n-point Hadamard Transform to the target qubits\n#F Note: qHT(1) denotes the matrix 1/sqrt(2)* [[1, 1], [1, -1]],\n#F qHT(_) is symmetric.\n#F\n#F qHT( n ) -> an n-qubit Hadamard transform\nClass(qHT, TaggedNonTerminal, rec(\n abbrevs := [ n -> Checked(IsPosInt(n), [n]) ],\n dims := self >> let(size := 2^self.params[1], [size, size]),\n terminate := self >> Tensor(Replicate(self.params[1], qH())),\n isReal := self >> true,\n groups := self >> [Replicate(self.params[1], 1)],\n connected := self >> false,\n rChildren := self >> self.params,\n from_rChildren := (self, rch) >> self.__bases__[1](rch[1]),\n recursive_def := (self, arch) >> self.__bases__[1](self.params[1]),\n SmallRandom := () -> Random([2..5]),\n LargeRandom := () -> Random([6..15]),\n normalizedArithCost := self >> Error(\"ArithCost not implemented\"),\n TType := T_Real(64)\n));\n\n\n##\n#F qHT Breakdown Rules\n## \nNewRulesFor(qHT, rec(\n\n # qHT_BinSplit rule\n # qHT_BinSplit qHT_(k) -> (qHT_(k1) tensor I) (I tensor qHT_(k2))\n # k1 + k2 = k\n qHT_BinSplit := rec (\n forTransposition := false,\n minSize := 2, \n applicable := (self, nt) >> nt.params[1] > 1,\n children := nt -> List( [1..nt.params[1] - 1], i -> [ Tensor(qHT(i), qHT(nt.params[1]-i)).withTags(nt.getTags()) ] ), \n apply := (nt, c, cnt) -> c[1],\n switch := true,\n ),\n\n #F qHT_Base: qHT(1) = qH() SPL object\n #F Directly represent as an implementable gate\n qHT_Base := rec(\n info := \"qHT_(1) -> qH()\",\n forTransposition := false,\n applicable := (self, nt) >> nt.params[1]=1,\n apply := (nt, c, cnt) -> qH(),\n )\n\n\n));", "meta": {"hexsha": "0e5a5b9fd9670f383d8135adb844aa3e5f59b62f", "size": 1938, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "qht.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": "qht.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": "qht.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": 33.4137931034, "max_line_length": 136, "alphanum_fraction": 0.5557275542, "num_tokens": 620, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772286044094, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.6169106211222607}}
{"text": "LookAndSay := function(s)\n local c, r, cur, ncur, v;\n v := \"123\";\n r := \"\";\n cur := 0;\n ncur := 0;\n for c in s do\n if c = cur then\n ncur := ncur + 1;\n else\n if ncur > 0 then\n Add(r, v[ncur]);\n Add(r, cur);\n fi;\n cur := c;\n ncur := 1;\n fi;\n od;\n Add(r, v[ncur]);\n Add(r, cur);\n return r;\nend;\n\nLookAndSay(\"1\"); # \"11\"\nLookAndSay(last); # \"21\"\nLookAndSay(last); # \"1211\"\nLookAndSay(last); # \"111221\"\nLookAndSay(last); # \"312211\"\nLookAndSay(last); # \"13112221\"\nLookAndSay(last); # \"1113213211\"\nLookAndSay(last); # \"31131211131221\"\nLookAndSay(last); # \"13211311123113112211\"\nLookAndSay(last); # \"11131221133112132113212221\"\nLookAndSay(last); # \"3113112221232112111312211312113211\"\nLookAndSay(last); # \"1321132132111213122112311311222113111221131221\"\nLookAndSay(last); # \"11131221131211131231121113112221121321132132211331222113112211\"\nLookAndSay(last); # \"311311222113111231131112132112311321322112111312211312111322212311322113212221\"\n", "meta": {"hexsha": "1edd3feadf05c08795d7da1db9f22de9a3c21dfc", "size": 1033, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Look-and-say-sequence/GAP/look-and-say-sequence.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/Look-and-say-sequence/GAP/look-and-say-sequence.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/Look-and-say-sequence/GAP/look-and-say-sequence.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": 27.1842105263, "max_line_length": 103, "alphanum_fraction": 0.6379477251, "num_tokens": 374, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.7905303162021596, "lm_q1q2_score": 0.6166080340733187}}
{"text": "Find := function(v, x)\n local low, high, mid;\n low := 1;\n high := Length(v);\n while low <= high do\n mid := QuoInt(low + high, 2);\n if v[mid] > x then\n high := mid - 1;\n elif v[mid] < x then\n low := mid + 1;\n else\n return mid;\n fi;\n od;\n return fail;\nend;\n\nu := [1..10]*7;\n# [ 7, 14, 21, 28, 35, 42, 49, 56, 63, 70 ]\nFind(u, 34);\n# fail\nFind(u, 35);\n# 5\n", "meta": {"hexsha": "1af13f88ce8fb5ac36c8fe4f7a3a414d374bdb04", "size": 389, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Binary-search/GAP/binary-search.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/Binary-search/GAP/binary-search.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/Binary-search/GAP/binary-search.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.2083333333, "max_line_length": 43, "alphanum_fraction": 0.4807197943, "num_tokens": 160, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8104789178257654, "lm_q2_score": 0.7606506472514406, "lm_q1q2_score": 0.6164913134278156}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n\nDeclare(CodeBlock, BRAMPermStreamOne, TPrmMulti);\n\n\n\nClass(TPrmMulti, Tagged_tSPL_Container, rec(\n abbrevs := [ (tspl_list, which) -> [tspl_list, which] ],\n dims := self >> Cond(IsBound(self.params[1][1].domain), [self.params[1][1].domain(), self.params[1][1].range()], self.params[1][1].dims()),\n\n terminate := meth(self)\n local prms, res, len, p, i;\n prms := self.params[1];\n len := Length(prms);\n res := prms[len];\n for i in Reversed([1..len-1]) do\n p := Cond(IsBound(prms[i].terminate), prms[i].terminate(), Prm(prms[i]));\n res := COND(eq(self.params[2], (i-1)), p, res);\n od;\n\n return res.terminate();\n end,\n\n transpose := self >> TPrmMulti(List(self.params[1], i->i.transpose()), self.params[2]).withTags(self.getTags()),\n\n isReal := True,\n doNotMeasure := true,\n noCodelet := true,\n normalizedArithCost := self >> 0\n));\n\n\n\n#F PermutationModMatrix ( <perm>, <n>, <m> )\n#F constructs for the permutation <perm> on <n> points an\n#F <m> x <m> matrix M. The (i,j) entry of M contains the number\n#F of pairs (k, k^<perm>) with k mod m = i and k^{perm> mod m = j.\n#F <m> has to divide <n>.\n#F We view <perm> as a permutation of the points {0,.., n-1} even\n#F though in gap it is represented as permutation on {1,..,n} \n#F (i.e shifted by 1).\n#F\n\nPermutationModMatrix := function ( p, n, m)\n local M, i;\n\n # error checking\n if not IsPerm(p) then\n Error(\"<p> is not a permutation\");\n fi;\n if not ( IsInt(n) and IsInt(m) ) then\n Error(\"<n> and <m> must be integers\");\n fi;\n if not n mod m = 0 then\n Error(\"<m> must divide <n>\");\n fi;\n if not ( p = () or LargestMovedPointPerm(p) <= n ) then\n Error(\"<n> is not a valid degree for <perm>\");\n fi;\n\n # initialize m x m matrix M\n M := List([1..m], r -> List([1..m], c -> 0));\n\n # construct M\n for i in [1..n] do\n M[(i-1) mod m + 1][(i^p-1) mod m + 1] := \n M[(i-1) mod m + 1][(i^p-1) mod m + 1] + 1;\n od;\n\n return M;\nend;\n\n## ============================================================\n##\n## PermMatrixRowVals(p) takes permutation matrix p and returns a list\n## of the '1' location in each row of the matrix.\n##\n## Thus, the value a in list element b means that the input in \n## location b will be permuted to location a in the output.\n##\n## ============================================================\nPermMatrixRowVals := meth(x)\n\n\n\n\n return List(Prm(FPerm(x)).func.lambda().tolist(), i->i.ev());\nend;\n\n## ============================================================\n##\n## PermMatrixRowVals(p) takes permutation matrix p and returns a list\n## of the '1' location in each row of the matrix.\n##\n## Thus, the value a in list element b means that the input in \n## location b will be permuted to location a in the output.\n##\n## ============================================================\nPermMatrixRowValsOld := meth(x)\n local length, i, res;\n\n res := [];\n length := Length(x);\n for i in [1 .. length] do\n res[i] := BasisVecToNum(x[i]);\n od;\n return res;\nend;\n\n\n## ============================================================\n##\n## min_list(l) returns the smallest value in l, a list of lists.\n##\n## ============================================================\nmin_list := meth(l)\n local t, i; \n t := []; \n for i in [1 .. Length(l)] do \n t[i] := Minimum(l[i]); \n od; \n return Minimum(t);\nend;\n\n\n## ============================================================\n##\n## max_list(l) returns the largest value in l, a list of lists.\n##\n## ============================================================\nmax_list := meth(l) \n local t, i;\n t := [];\n for i in [1 .. Length(l)] do\n t[i] := Maximum(l[i]);\n od;\n return Maximum(t);\nend;\n\n\n## ============================================================\n##\n## RandomPerm(n) returns a random permutation on n points.\n##\n## RandomPermSPL(n) is not used becuase 1/3 of the time it\n## returns a stride permutation, and 1/3 of the time it \n## returns J(n). \n##\n## ============================================================\nRandomPerm := meth(n)\n return Perm(Random(SymmetricGroup(n)), n);\nend;\n\n## ============================================================\n##\n## IsPermMult(p) returns 1 if matrix p is a permutation of a\n## constant multiple of a permutation, and 0 otherwise.\n##\n## ============================================================\n\nIsPermMult := meth(p)\n local n, i, j, total;\n n := Length(p);\n for i in [1..n] do\n total := 0;\n for j in [1..n] do\n if (p[i][j] <> 0) then\n total := total+1;\n\t if (total > 1) then\n\t\treturn 0;\n\t fi;\n fi;\n od;\n od;\n return 1;\nend; \n\n\n## ============================================================\n## OnesVector(n)\n## Returns a vector of 1s of length n\n## ============================================================\nOnesVector := meth(n)\n local res, i;\n res := [];\n for i in [1..n] do\n res[i] := 1;\n od;\n return res;\nend;\n\n\n## ============================================================\n## Given the mux addresses, i.e., the multiplexor settings\n## that say \"given an output location, where does it get its\n## input from on each cycle,\" determine the inverse, i.e.,\n## \"given an input location, determine where its output will \n## go for each cycle.\n##\n## This function is intended as a helper function, used in\n## StreamPermGen.createCode().\n## ============================================================\nPermHelperFindPortAddresses := meth(muxaddr)\n local ports, i, row, j, rowres;\n ports := [];\n for i in [1..Length(muxaddr)] do\n rowres := [];\n row := muxaddr[i]; \n for j in [1..Length(row)] do\n rowres[row[j]+1] := j-1;\n od;\n Append(ports, [rowres]);\n od;\n return ports;\nend;\n\n\n_optsInColumn := meth(col, rows_left)\n local res, i, size;\n size := Length(col);\n res := [];\n for i in [1..size] do\n if ((rows_left[i] = 1) and (col[i] > 0)) then\n Append(res, [i]);\n fi;\n od;\n return res;\nend;\n\n# Used in debugging.\n#_findPermBacktracks := 0;\n\ntry_column := meth(whichCol, board, rows_left)\n local size, col, options, i, spec_rows_left, tres;\n \n\n size := Length(board[1]);\n\n col := TransposedMat(board)[whichCol];\n\n options := _optsInColumn(col, rows_left);\n\n for i in options do\n if (whichCol = size) then\n return [i];\n fi;\n\n rows_left[i] := 0;\n tres := try_column(whichCol+1, board, rows_left);\n if (tres <> [-1]) then\n Append(tres, [i]); # backwards\n return tres; \n fi;\n rows_left[i] := 1;\n od;\n\n # Debugging\n #_findPermBacktracks := _findPermBacktracks+1;\n return [-1]; \n\nend;\n\n_randomPermGood := meth(board)\n local rows_left, permVec, size, permMat, col, row, choices, failed, choice, i;\n size := Length(board[1]);\n rows_left := List([1..size], i->1);\n permVec := [];\n\n failed := false;\n col := 1;\n while ((col <= size) and (not failed)) do \n\n # Collect list of choices in this column.\n choices := []; \n for row in [1..size] do\n if ((rows_left[row] <> 0) and (board[row][col] > 0)) then\n Append(choices, [row]);\n fi;\n od;\n \n if (Length(choices) = 0) then\n failed := true;\n else\n choice := Random(choices);\n rows_left[choice] := 0;\n Append(permVec, [choice]);\n fi;\n\n col := col + 1;\n od;\n \n if (failed) then\n # If we fail, then we can assume that the square contains at least one 0 entry. So,\n # we can send back the all 1 matrix, and be guaranteed that P - [1] < 0 for some value.\n return(List([1..size], r -> List([1..size], c -> 1)));\n else\n permMat := [];\n for i in [1..size] do\n permMat[i] := BasisVec(size, permVec[i]-1);\n od;\n \n permMat := TransposedMat(permMat);\n\n return permMat;\n fi;\nend;\n\n\n\n_findPerm := meth(board)\n local rows_left, permVec, size, permMat, i;\n size := Length(board[1]);\n rows_left := List([1..size], i->1);\n permVec := Reversed(try_column(1, board, rows_left));\n permMat := [];\n \n for i in [1..size] do\n permMat[i] := BasisVec(size, permVec[i]-1);\n od;\n\n permMat := TransposedMat(permMat);\n\n return permMat;\nend;\n\n_minisat_path := \"\";\n\n_findPermUsingSat := meth(board)\n local size, r, c, zeros, dir, i, zerofile, outfile, res, permmat;\n \n size := Length(board[1]);\n zeros := [];\n\n for r in [1..size] do\n for c in [1..size] do\n if (board[r][c] = 0) then\n Append(zeros, [ (r-1)*size + c ]);\n fi;\n od;\n od;\n \n dir := Concat(\"/tmp/spiral/\", String(GetPid()));\n MakeDir(dir);\n zerofile := Concat(dir, \"/zeros\");\n outfile := Concat(dir, \"/out\");\n PrintTo(zerofile, \"\");\n\n for i in [1..Length(zeros)] do\n AppendTo(zerofile, zeros[i], \"\\n\");\n od;\n\n if (_minisat_path = \"\") then\n Error(\"Error: path to SAT solver not set: paradigms.stream._minisat_path is not bound.\");\n fi;\n\n# IntExec(Concat(\"/Users/pam/minisat/core/minisat \", String(size), \" \", zerofile, \" \", outfile));\n IntExec(Concat(_minisat_path, \" \", String(size), \" \", zerofile, \" \", outfile));\n\n res := ReadVal(outfile);\n \n permmat := [];\n for i in [1..size] do\n permmat[i] := BasisVec(size, res[i]);\n od;\n\n return permmat;\nend;\n\n_SumList := meth(m)\n local res, i;\n res := 0;\n for i in [1..Length(m)] do\n res := res + m[i];\n od;\n return res;\nend;\n\n_whichMeth := 1;\n\nDeclare(routePerm);\n\n## ============================================================\n## listofperms = FactorSemiMagicSquare(square)\n##\n## Given a semi-magic square of size n, find a (non-unique) \n## decomposition into a sum of permutations. Returns the \n## decomposition as a list of permutations (with each perm\n## being represented in the \"row value\" form).\n##\n## Each semi-magic square can be decomposed into at most\n## (n-1)^2 + 1 different permutations. See:\n## Leep et al. Marriage, Magic, and Solitaire. The American \n## Mathematical Monthly (1999) vol. 106 (5) pp. 419-429.\n## \n## This method uses randomly generated permutations. A better\n## method would construct them based upon the square. A more\n## realistic approach would be a hybrid of the two.\n##\n## This function is intended as a helper function, used in\n## StreamPermGen.createCode().\n## ============================================================\nFactorSemiMagicSquare := meth(square)\n local length, multplr, rndprm, j, res, rows_left, cols_left, startTime, endTime, tries, which, ct;\n length := Length(square);\n res := [];\n\n # Debugging\n startTime := TimeInSecs();\n tries := 0;\n\n ct := 0;\n\n which := stream._whichMeth;\n\n ## While the semi-magic square is not all zero...\n while (max_list(square) > 0) do\n\n\t ## What is left? Is it a multiple of a permutation matrix?\n\t ## (This step not needed for correctness, but is a performance\n\t ## optimization.)\n\t if (IsPermMult(square) = 1) then\n\n\t ## If what is left is a constant times a perm matrix,\n\t ## set that perm as the random step, and complete the \n\t ## final step.\n\t rndprm := square / max_list(square);\n\t multplr := 0;\n\t while (min_list(square - multplr*rndprm) >= 0) do\n\t multplr := multplr+1;\n\t od;\n\t multplr := multplr-1;\n\t square := square - multplr*rndprm;\t\t \n\t for j in [1..multplr] do\n#! fails sometimes\t Append(res, [routePerm(PermMatrixRowValsOld(rndprm))]); \n\t Append(res, [PermMatrixRowValsOld(rndprm)]);\n\t od;\n\n ct := ct + 1;\n\n else\n \n ## Generate a random permutation.\n # set 'which' as: paradigms.stream.whichMeth := 0;\n\n# rndprm := _randomPermGood(square);\n tries := tries+1;\n\n# if (which = 0) then\n# rndprm := MatSPL(RandomPerm(length));\n# #tries := tries + 1;\n# else\n# if (which = 1) then\n# rndprm := _findPerm(square);\n# else\n rndprm := _findPermUsingSat(square);\n# fi;\n# \t fi;\n fi;\n\n\n ## How many times can this permutation be \n ## subtracted from the square?\n multplr := 0;\n while (min_list(square - multplr*rndprm) >= 0) do\n multplr := multplr+1;\n od;\n multplr := multplr-1;\n\n ## If this permutation has been subtracted from the square,\n ## record the decision, and check if we are done.\n if (multplr > 0) then\n\n ## Subtract the permutation the correct number of times.\n square := square - multplr*rndprm;\n\n \t ## Record the decision\n\t for j in [1..multplr] do\n\t Append(res, [PermMatrixRowValsOld(rndprm)]);\n\t od;\n \n endTime := TimeInSecs();\n# Print(which, \", \", (endTime - startTime), \", \", tries, \"\\n\");\n startTime := endTime;\n tries := 0;\n ct := ct + 1;\n\n fi;\n od;\n\n return res;\nend;\n\n\n## ============================================================\n## row = PermHelperFindRow(permrows, x (readdport), \n## y (writeport), streaming-width)\n##\n## Given a permutation as a set of row values, and a selected\n## read and write port (x, y), find which permutation word can \n## be scheduled that will lead to a read from port x to a \n## write in port y.\n##\n## As the algorithm progresses, words that have been scheduled\n## are removed from permrows and replaced with -1.\n##\n## This function is intended as a helper function, used in\n## StreamPermGen.createCode().\n## ============================================================\nPermHelperFindRow := meth(p, x, y, w)\n local a, b;\n\n for b in [1 .. Length(p)] do\n a := p[b];\n \n # The a <> -1 isn't needed for correctness but it makes the\n # code more clear.\n if ((a <> -1) and (Mod(a,w) = x) and (Mod(b-1,w) = y)) then\n return b;\n fi;\n od;\n\n Error(\"Cannot find a word to schedule.\");\nend;\n\n\n## ============================================================\n## [rd_addr, wr_addr] = PermHelperFindAddresses(permrows, \n## muxaddr, w);\n##\n## Given a permutation as a set of row values and a cycle-by-\n## cycle read/write port mapping (muxaddr), and streaming width \n## w, determine the assoicated memory read and write addresses.\n##\n## This function is intended as a helper function, used in\n## StreamPermGen.createCode().\n## ============================================================\nPermHelperFindAddresses := meth(permrows, muxaddr, w)\n local rd_addr, wr_addr, i, x, y, b, a, rdcyc, wrcyc, wrcyc2, ports;\n\n ports := PermHelperFindPortAddresses(muxaddr);\n rd_addr := []; wr_addr := [];\n\n for i in [1..Length(permrows)/w] do\n rdcyc := []; wrcyc := []; wrcyc2 := [];\n\n for x in [1..w] do\n y := ports[i][x]+1;\n\t b := PermHelperFindRow(permrows, x-1, y-1, w);\n\t a := permrows[b];\n\t Append(rdcyc, [floor(a/w).v]);\n\t Append(wrcyc, [floor((b-1)/w).v]);\n\t Append(wrcyc2, []);\n\t permrows[b] := -1;\n od;\n Append(rd_addr, [rdcyc]);\n\n # Here, wrcyc tells the write address for each *read port* at this\n # time. I need to permute these values so it tells the write address\n # for each *write port* at this time.\n # So, I just need to assign wrcyc to wrcyc2 based upon this mapping.\n for x in [1..w] do \n wrcyc2[x] := wrcyc[muxaddr[i][x]+1]; \n od;\n\n Append(wr_addr, [wrcyc2]);\n od;\n return [rd_addr, wr_addr];\nend;\n \n\n\n## ==================================================================\n## BRAMPermGeneral([rdaddr], [swnetctrl], [wraddr], [perm], it)\n## where rdaddr is the set of read addresses, swnetctrl is the \n## control bits for the \\Omega^{-1}\\Omega network, wraddr is the \n## set of write addresses, and perm is the permutation as an SPL \n## object. it is the iteration variable that specifies which perm \n## to perform.\n##\n## This represents a streaming multi-permutation structure that has \n## been factored using our \"general\" method.\n## \n## This is not ideal for permutations that are linear on the bits. \n##\n## Do not attempt to build this object by hand. Instead use \n## StreamPerm(perm, streamsize) to build a generic streaming \n## perm. Then, StreamPerm.createCode() will construct the\n## BRAMPermGeneral given the permutation and streaming width.\n## ==================================================================\nClass(BRAMPermGeneral, BaseMat, SumsBase, rec(\n\tabbrevs := [(r,m,w,p,it)-> [r,m,w,p,it]], \n\n\tnew := (self, r, m, w, p, it) >> SPL(WithBases(self, rec(\n\t\t _children := [r, m, w, p, it],\n\t\t dimensions := [ Length(r[1])*Length(r[1][1]), Length(r[1])*Length(r[1][1])],\n\t\t streamSize := Length(r[1][1]),\n\t ))),\n\n\trChildren := self >> self._children,\n\trSetChild := meth(self, n, what) self._children[n] := what; end,\n\tchild := (self, n) >> self._children[n],\n\tchildren := self >> self._children,\n\n\tcreateCode := self >> self,\n print := (self,i,is) >> Print(self.name, \"(\", self.dims()[1], \n\t \", \", self.streamSize, \", \", self.child(1), \", \", self.child(2), \n\t \", \", self.child(3), \", \", self.child(5), \")\"),\n\n\n toAMat := meth(self)\n local prms, len, it, i, res;\n prms := self.child(4);\n len := Length(prms);\n it := self.child(5);\n res := prms[len];\n\n for i in Reversed([1..len-1]) do\n res := COND(eq(it, i-1), prms[i], res);\n od;\n \n return res.toAMat();\n end,\n\n\tdims := self >> [Length(self._children[1][1])*Length(self._children[1][1][1]), \n\t Length(self._children[1][1])*Length(self._children[1][1][1])],\n\n\tsums := self >> self\n));\n\n\nPadToTwoPowSize := meth(muxaddr)\n local n, n2p, i, res, dif, line;\n n := Length(muxaddr[1]);\n \n if (2^Log2Int(n) = n) then\n return muxaddr;\n fi;\n\n n2p := 2^(Log2Int(n)+1);\n dif := n2p-n;\n\n\n res := [];\n\n for i in [1..Length(muxaddr)] do\n line := Concatenation(muxaddr[i], [n..n2p-1]); \n Append(res, [line]);\n od;\n\n return res;\nend;\n\n\nRandomVectorVector := meth(domain, inner, outer)\n local res, i, j;\n res := [];\n for i in [1..outer] do\n res[i] := [];\n for j in [1..inner] do\n res[i][j] := RandomList([0..domain-1]);\n od;\n od;\n return res;\nend;\n\n## ======================================================\n## A container for a streaming multi-permutation structure\n##\n## StreamPerm([<SPL>], <m>, <w>, <i>)\n##\n## where the permutations are I(<M>) x <SPL>, <SPL> is \n## the permutation as an SPL object, <w> is the \n## streaming width, and <i> selects between the <SPL>.\n## ======================================================\n\nClass(StreamPerm, BaseMat, SumsBase, rec(\n\tabbrevs := [(s, m, w, i) -> [s, m, w, i]], \n\n\tnew := (self, prm, m, ss, i) >> SPL(WithBases(self, rec(\n\t _children := [prm, m, ss, i],\n\t streamSize := ss, \n par := m,\n it := i,\n\t dimensions := Cond(IsBound(prm[1].domain), [m * prm[1].domain(), m * prm[1].range()], m * prm[1].dims()),\n\t ))),\n\n\trChildren := self >> self._children,\n\trSetChild := meth(self, n, what) self._children[n] := what; end,\n\tchild := (self, n) >> self._children[n],\n\tchildren := self >> self._children,\n \n createCode := meth(self)\n local lin, prm, w, P, length, permobj, permrows, modmatrix, muxaddr, muxaddr2, ports, addrs, \n rdaddr, wraddr, network, res, p3, p1, r, k, M, N, P, x, i, j, l, K, size, count, ptrans, \n z, G, q1, q3, q3b, p1b, G, dm, plist, bitlist, prms, Pt, thisPerm, thisPrm, prmCode, it,\n prmTens, dm_no_tens, prm_no_tens;\n\n prm := List(self.child(1), p->Tensor(I(self.child(2)), p));\n prm_no_tens := self.child(1);\n w := self.child(3);\n it := self.child(4);\n\n P := [];\n\n # If the permutation is a composition of multiple perms, it is more efficient to\n # compute the bit representation of each individually, and then combine them.\n for i in [1..Length(self.child(1))] do\n thisPerm := self.child(1)[i];\n thisPrm := prm[i];\n\n\t if (ObjId(thisPrm) = L) then\n\t\tthisPrm := TL(thisPerm.params[1], thisPerm.params[2]);\n\t fi;\n\n\t if (ObjId(thisPrm) = Tensor and ObjId(thisPrm.child(1)) = I and ObjId(thisPrm.child(2)) = L) then\n\t\tthisPrm := TL(thisPrm.child(2).params[1], thisPrm.child(2).params[2], thisPrm.child(1).params[1], 1);\n\t fi;\n\n if (ObjId(thisPerm) = Compose) then\n plist := thisPerm.children();\n\n\t\t# If we just have an L, turn it into a TL so we can use its .permBits() function\n\t\tplist := List(plist, i -> Cond(ObjId(i) = L, TL(i.params[1], i.params[2]), i));\n\n\t\t# If we have I x L, turn it into TL\n\t\tplist := List(plist, i -> Cond(ObjId(i) = Tensor and ObjId(i.child(1)) = I and ObjId(i.child(2)) = L, TL(i.child(2).params[1], i.child(2).params[2], i.child(1).params[1], 1), i));\n\n bitlist := List(plist, i -> \n\t\t Cond(IsBound(i.permBits), \n\t\t\ti.permBits(), \n\t\t\tCond(ObjId(i) = Tensor and ObjId(i.child(1)) = I and IsBound(i.child(2).permBits), \n\t\t\t\tDirectSumMat(MatSPL(I(Log2Int(i.child(1).params[1])))*GF(2).one, i.child(2).permBits()),\n\t\t\t\tPermMatrixToBits(MatSPL(i))\n\t\t\t\t\n\t\t\t)\n\t\t )\n\t\t);\n\n if (-1 in bitlist) then\n Pt := -1;\n else\n Pt := Product(bitlist);\n if (self.child(2) > 1) then\n Pt := DirectSumMat(MatSPL(I(Log2Int(self.child(2))))*GF(2).one, Pt);\n fi;\n fi;\n else\n\t\tPt := Cond(IsBound(thisPrm.permBits),\n # If P.permBits defined, use it\n\t\t thisPrm.permBits(), \n\t # If P = Tensor(I, Q) and Q.permBits defined, use it. \n\t\t Cond(ObjId(thisPrm) = Tensor and ObjId(thisPrm.child(1)) = I and IsBound(thisPrm.child(2).permBits),\n\t\t\tDirectSumMat(MatSPL(I(Log2Int(thisPrm.child(1).params[1])))*GF(2).one, thisPrm.child(2).permBits()),\n\n\t\t\t# Otherise, use PermMatrixToBits function (slow)\n\t\t\tPermMatrixToBits(MatSPL(thisPrm))\n\t\t )\n\t\t);\n fi;\n\n Append(P, [Pt]);\n od;\n\n # so, Make a list of Ps, one for each perm. then set lin if all are <> -1.\n lin := Cond(ForAny(P, i->i=-1) or 2^Log2Int(w) <> w or Length(prm) > 1, 0, 1);\n\n # Find the overall dimensions and the dimension of the \"non-tensor\" part \n dm := Cond(IsBound(prm[1].domain), prm[1].domain(), prm[1].dims()[1]);\n\n\t# PM: This is not very robust.\n dm_no_tens := Cond(IsBound(self.child(1)[1].domain), self.child(1)[1].domain(), self.child(1)[1].dims()[1]);\n\n\n # If the permutations are on w words, then we can generate code.\n if (self.child(3) = dm_no_tens) then\n \n ## If this perm is multiple permutation functions composed, separate them to make the\n ## code generation work as expected.\n \n prmCode := List(prm_no_tens, j ->\n Cond(ObjId(j) = Compose,\n Compose(List(j.children(), i->Prm(FPerm(i)))),\n Prm(FPerm(j))\n )\n );\n \n res := prmCode[Length(prmCode)];\n \n for i in Reversed([1..Length(prmCode)-1]) do\n res := COND(eq(it, (i-1)), prmCode[i], res);\n od;\n \n if (self.child(2) > 1) then \n return STensor(CodeBlock(res).createCode(), self.child(2), self.child(3));\n fi;\n\n return CodeBlock(res).createCode();\n \n fi;\n\n \n # If our perm is not linear on the bits, or if we have multiple permutations, or\n # if we have manually overridden this to avoid the patented permutations:\n if ((lin = 0) or (stream.avoidPermPatent = 1)) then\n\n\n # We want to ignore the tensor product until the end\n prm := self.child(1);\n prmTens := List(self.child(1), p->Tensor(I(self.child(2)), p));\n\n it := self.child(4);\n\n if (self.child(3) = 1) then\n return BRAMPermStreamOne(\n# List(prmTens, i->PermMatrixRowValsOld(MatSPL(i))),\n List(prmTens, i->PermMatrixRowVals(i)),\n prmTens,\n it);\n fi;\n\n\n\t length := self._children[1][1].dims()[1];\n\n\t permobj := List(self._children[1], i -> PermSPL(i));\n\t permrows := List(permobj, i -> PermMatrixRowValsOld(MatPerm(i, length)));\n\t modmatrix := List(permobj, i -> PermutationModMatrix(i, length, self.child(3)));\n\t muxaddr := List(modmatrix, i -> FactorSemiMagicSquare(i));\n \n muxaddr2 := List(muxaddr, i -> PadToTwoPowSize(i));\n\n\n network := List(muxaddr2, j -> List([1..Length(j)], i -> routePerm(j[i])));\n \n\t addrs := List([1..Length(permobj)], i -> PermHelperFindAddresses(permrows[i], muxaddr[i], self.child(3)));\n\t rdaddr := List(addrs, i -> i[1]);\n\t wraddr := List(addrs, i -> i[2]);\n\n if (self.child(2) > 1) then\n return STensor(BRAMPermGeneral(rdaddr, network, wraddr, self._children[1], it), self.child(2), w);\n else\n return BRAMPermGeneral(rdaddr, network, wraddr, self._children[1], it);\n fi;\n \n else\n # If we are here, we only have one permutation\n P := P[1];\n \n\n\t k := Log2Int(self.child(3));\n\t size := Log2Int(self.dimensions[1]);\n \n # If our streaming width is 1, then we are done. P = I*P.\n\t if (self.child(3) = 1) then\n return BRAMPerm(MatSPL(I(size))*GF(2).one, P, 1);\n\t fi;\n\n\t # if P is the bit form of I tensor P', we can remove the top-left corner bits\n\t # (up to (size-k) bits, and replace them with a streaming tensor product of a \n\t # smaller permutation\n\t count := GetTopLeftOnes(P,k);\n\n\t P := P{[count+1..Length(P)]}{[count+1..Length(P)]};\n\t\t\n\t size := size-count;\t \n\n\t p3 := extractP3(P, k);\n\t p1 := extractP1(P, k);\n\n\t r := Rank(p1);\n \n\t if (r = k) then\n\t M := P;\n\t N := MatSPL(I(Length(M))) * GF(2).one;\n\n\t else # This is algorithm 5.2 of J. ACM 2009 paper.\n\n # Is P a permutation matrix?\n if (CheckPerm(P) = 1) then\t\n\t j := NonZeroRows(p3);\n\t i := ZeroRows(p1);\n\t else\n\t\t p1b := TransposedMat(Copy(p1));\n\t\t G := MyTriangulizeMat(p1b);\n\t\t G := TransposedMat(G);\n\t\t G := G * GF(2).one;\n\t\t q1 := p1 * G;\n\t\t q3 := p3 * G;\n\t\t \n \t\t z := LinearIndependentColumns(TransposedMat(q1));\n \t\t i := [];\n \n \t\t for l in [1 .. k] do\n \t\t if l in z then\n \t\t ;\n else\n \t\t Add(i, l);\n \t\t fi;\n \t\t od;\n \n \t\t q3b := [];\n\t\t \n \t\t for l in [1 .. Length(q3)] do\n \t\t Append(q3b, [q3[l]{[r+1..k]}]);\n \t\t od;\n \n \t\t j := LinearIndependentColumns(TransposedMat(q3b));\n fi; \n \n\t K := buildH2(i, j, size, k);\n \n\t N := buildH(size, k, K) * GF(2).one; \n\t M := N*P;\t \n\t fi;\n\t \n\t if (Maximum(Maximum(N * M - P)) <> 0 * GF(2).one) then\n\t Print(\"ERROR: Could not factor permutation matrix.\\n\");\n\t fi;\n\n\t if (count = 0) then\n\t return BRAMPerm(N, M, self.child(3));\n\t else\n\t return STensor(BRAMPerm(N,M,self.child(3)), 2^count, self.child(3));\n\t fi; \n fi;\n end,\n\n print := (self,i,is) >> Print(self.name, \"(\", self._children[1], \", \", self.child(2), \", \", self.child(3), \", \", self._children[4], \")\"),\n\n toAMat := meth(self)\n local prms, len, it, i, res;\n prms := self._children[1];\n len := Length(prms);\n it := self._children[4];\n res := Tensor(I(self.child(2)), prms[len]);\n \n\n for i in Reversed([1..len-1]) do\n res := COND(eq(it, (i-1)), Tensor(I(self.child(2)), prms[i]), res);\n od;\n\n return res.toAMat();\n end,\n\n\tdims := self >> self.child(2) * self._children[1][1].dims(),\n\tsums := self >> self\n \n));\n\n\n\n## ======================================================\n## A container for a streaming RC(permutation)\n##\n## RCStreamPerm([<SPL>], <m>, <w>, <i>)\n##\n## where the permutations is I(<M>) x [<SPL>] x I(2), [<SPL>] is \n## list of permutations as SPL objects, <w> is the \n## streaming width, and <i> selects which of the perms.\n## ======================================================\nClass(RCStreamPerm, BaseMat, SumsBase, rec(\n\tabbrevs := [(s, m, w, i) -> [s, m, w, i]], \n\n\tnew := (self, prm, m, ss, i) >> SPL(WithBases(self, rec(\n\t _children := [prm, m, ss, i],\n\t streamSize := ss, \n par := m,\n it := i,\n\t dimensions := Cond(IsBound(prm[1].domain), [2 * m * prm[1].domain(), 2 * m * prm[1].range()], 2 * m * prm[1].dims()),\n\t ))),\n\n\trChildren := self >> self._children,\n\trSetChild := meth(self, n, what) self._children[n] := what; end,\n\tchild := (self, n) >> self._children[n],\n\tchildren := self >> self._children,\n \n createCode := meth(self)\n local r;\n r := StreamPerm(self.child(1), self.par, self.streamSize, self.it).createCode(); \n if (ObjId(r) = STensor) then\n return STensor(RC(r.child(1)), r.p, r.bs*2);\n else\n return RC(r);\n fi;\n end,\n\n print := (self,i,is) >> Print(self.name, \"(\", self._children[1], \", \", self.par, \", \", self.streamSize, \", \", self._children[4], \")\"),\n\n\ttoAMat := self >> RC(StreamPerm(self._children[1], self.par, self.streamSize, self.it)).toAMat(),\n\n\tdims := self >> 2 * self.par * self._children[1][1].dims(),\n\tsums := self >> self\n\n \n));\n\n\n\n## ======================================================\n## A container for a general streaming permutation (not \n## necessarily linear on the bits)\n##\n## StreamPermGen(<SPL>, <q>)\n##\n## where <SPL> is the permutation as an SPL object, and \n## <q> is the streaming width.\n## ======================================================\n## NB: Deprecated. Use StreamPerm, which covers all cases\n# Class(StreamPermGen, BaseMat, SumsBase, rec(\n# \tabbrevs := [(s, q) -> [s, q]], \n\n# \tnew := (self, prm, ss) >> SPL(WithBases(self, rec(\n# \t _children := [prm],\n# \t streamSize := ss, \n\n\n# \t dimensions := Cond(IsBound(prm.domain), [prm.domain(), prm.range()], prm.dims()),\n\n# \t ))),\n\n# \trChildren := self >> self._children,\n# \trSetChild := meth(self, n, what) self._children[n] := what; end,\n# \tchild := (self, n) >> self._children[1],\n# \tchildren := self >> self._children,\n\n# \tcreateCode := meth(self) \n# \t local length, permobj, permrows, modmatrix, muxaddr, muxaddr2, ports, \n# addrs, rdaddr, wraddr, network, dms, prms;\n \n# dms := Cond(IsBound(self.child(1).domain), [self.child(1).domain(), self.child(1).range()], self.child(1).dims());\n\n# if (self.streamSize = 1) then\n# return BRAMPermStreamOne(\n# [PermMatrixRowVals(MatSPL(self._children[1]))],\n# [self._children[1]], 0);\n# fi;\n\n# if (self.streamSize = dms[1]) then\n\n# ## If this perm is multiple permutation functions composed, separate them to make the\n# ## code generation work as expected.\n# if (ObjId(self.child(1)) = Compose) then\n# prms := Compose(List(self.child(1).children(), i->Prm(FPerm(i))));\n# else\n# prms := Prm(FPerm(self.child(1)));\n# fi;\n \n# return CodeBlock(prms).createCode();\n\n# fi;\n\n# \t length := self._children[1].dims()[1];\n# \t permobj := PermSPL(self._children[1]);\n# \t permrows := PermMatrixRowVals(MatPerm(permobj, length));\n# \t modmatrix := PermutationModMatrix(permobj, length, self.streamSize);\n# \t muxaddr := FactorSemiMagicSquare(modmatrix);\n\n# muxaddr2 := PadToTwoPowSize(muxaddr);\n\n# # Print(\"muxaddr = \", muxaddr, \"\\nmuxaddr2 = \", muxaddr2);\n\n# network := List([1..Length(muxaddr2)], i -> routePerm(muxaddr2[i]));\n\n# \t addrs := PermHelperFindAddresses(permrows, muxaddr, \n# \t self.streamSize);\n# \t rdaddr := addrs[1];\n# \t wraddr := addrs[2];\n\n# #!\t rdaddr := RandomVectorVector(length/self.streamSize, self.streamSize, length/self.streamSize);\n# #!\t wraddr := RandomVectorVector(length/self.streamSize, self.streamSize, length/self.streamSize);\n# #!\t muxaddr := RandomVectorVector(self.streamSize, self.streamSize, length/self.streamSize);\n\n# # Previously, we used 'muxaddr.'\n# #\t return BRAMPermGeneral(rdaddr, muxaddr, wraddr, self._children[1]);\n# # Now I am switching to the omega^-1 omega network control bits\n# return BRAMPermGeneral(rdaddr, network, wraddr, self._children[1]);\n\n# end,\n \n# \tprint := (self,i,is) >> Print(self.name, \"(\", self._children[1], \", \", \n# \t self.streamSize, \")\"),\n\n# \ttoAMat := self >> self._children[1].toAMat(),\n# \tdims := self >> self._children[1].dims(),\n# \tsums := self >> self\n\n# ));\n\n\n\n\n## ======================================================\n## A container for a streaming multi-permutation structure\n##\n## StreamPermGen(<l>, <i>, <q>)\n##\n## where <l> is a list of permutations as SPL objects, \n## <i> is a variable that selects which permutation to \n## perform, and <q> is the streaming width.\n## ======================================================\n## Deprecated. Use StreamPerm, which supports multiple perms (or will soon!)\n\n## !!!!!!!!!!! IMPORTANT !!!!!!!!\n# Do not delete this code until I have successfully rolled its multiple perm\n# support into StreamPermGen.\n## !!!!!!!!!!! IMPORTANT !!!!!!!!\n\n# Class(StreamPermGenMult, BaseMat, SumsBase, rec(\n# \tabbrevs := [(s, i, q) -> [s, i, q]], \n\n# \tnew := (self, prm, i, ss) >> SPL(WithBases(self, rec(\n# \t _children := [prm, i],\n# \t streamSize := ss, \n\n# \t dimensions := Cond(IsBound(prm[1].domain), [prm[1].domain(), prm[1].range()], prm[1].dims()),\n\n# \t ))),\n\n# \trChildren := self >> self._children,\n# \trSetChild := meth(self, n, what) self._children[n] := what; end,\n# \tchild := (self, n) >> self._children[n],\n# \tchildren := self >> self._children,\n\n# \tcreateCode := meth(self) \n# \t local length, permobj, permrows, modmatrix, muxaddr, muxaddr2, ports, \n# addrs, rdaddr, wraddr, network, dms, prms, it, prmcode, i, res;\n \n# dms := Cond(IsBound(self.child(1)[1].domain), [self.child(1)[1].domain(), self.child(1)[1].range()], self.child(1)[1].dims());\n\n# it := self.child(2);\n# prms := self.child(1);\n\n# if (self.streamSize = 1) then\n# return BRAMPermStreamOne(List(prms, i->PermMatrixRowVals(MatSPL(i))),\n# prms,\n# it);\n# fi;\n\n# if (self.streamSize = dms[1]) then\n\n# ## If this perm is multiple permutation functions composed, separate them to make the\n# ## code generation work as expected.\n\n# prmcode := List(self.child(1), j -> \n# Cond(ObjId(j)=Compose,\n# Compose(List(self.child(1).children(), i->Prm(FPerm(i)))),\n# Prm(FPerm(j))\n# )\n# );\n\n# res := prmcode[Length(prmcode)];\n\n# for i in Reversed([1..Length(prmcode)-1]) do\n# res := COND(eq(it, i), prmcode[i], res);\n# od;\n \n# return CodeBlock(res).createCode();\n\n# fi;\n\n# \t length := self._children[1].dims()[1];\n# \t permobj := PermSPL(self._children[1]);\n# \t permrows := PermMatrixRowVals(MatPerm(permobj, length));\n# \t modmatrix := PermutationModMatrix(permobj, length, self.streamSize);\n# \t muxaddr := FactorSemiMagicSquare(modmatrix);\n\n# muxaddr2 := PadToTwoPowSize(muxaddr);\n\n# network := List([1..Length(muxaddr2)], i -> routePerm(muxaddr2[i]));\n\n# \t addrs := PermHelperFindAddresses(permrows, muxaddr, \n# \t self.streamSize);\n# \t rdaddr := addrs[1];\n# \t wraddr := addrs[2];\n\n\n# # Previously, we used 'muxaddr.'\n# #\t return BRAMPermGeneral(rdaddr, muxaddr, wraddr, self._children[1]);\n# # Now I am switching to the omega^-1 omega network control bits\n# return BRAMPermGeneral(rdaddr, network, wraddr, self._children[1]);\n\n# end,\n \n# \tprint := (self,i,is) >> Print(self.name, \"(\", self._children[1], \", \", self._children[2], \", \", \n# \t self.streamSize, \")\"),\n\n# toAMat := meth(self)\n# local prms, len, it, i, res;\n\n# prms := self._children[1];\n# len := Length(prms);\n# it := self._children[2];\n# res := prms[len];\n\n# for i in Reversed([1..len-1]) do\n# res := COND(eq(it, i), prms[i], res);\n# od;\n\n# return res.toAMat();\n# end,\n\n# # toAMat := self >> COND(eq(self._children[2], 0), self._children[1][1], self._children[1][2]).toAMat(),\n# \tdims := self >> self._children[1][1].dims(),\n# \tsums := self >> self\n\n# ));\n\n\n## ==================================================================\n## BRAMPermStreamOne([rd-addr, ...], [<SPL>, ... ], i)\n## A container for a streaming multi-permutation structure where width = 1.\n## This merits its own class because the hardware implementation\n## is greatly simplified.\n## \n## The permutations are given as a list of vectors of read addresses, and\n## as a list of SPL objects.\n##\n## i is the variable that selects which permutation to perform\n## ==================================================================\nClass(BRAMPermStreamOne, BaseMat, SumsBase, rec(\n\tabbrevs := [(r, p, i)-> [r, p, i]], \n\n\tnew := (self, r, p, i) >> SPL(WithBases(self, rec(\n\t\t _children := [r, p, i],\n\t\t dimensions := [ Length(r[1]), Length(r[1])]\n\t ))),\n\n\trChildren := self >> self._children,\n\trSetChild := meth(self, n, what) self._children[n] := what; end,\n\tchild := (self, n) >> self._children[n],\n\tchildren := self >> self._children,\n\n\tcreateCode := self >> self,\n \n print := (self,i,is) >> Print(self.name, \"(\", self.child(1), \", \", self.child(3), \")\"), \n\n#\ttoAMat := self >> self.child(2).toAMat(),\n\n toAMat := meth(self)\n local prms, len, it, i, res;\n\n prms := self._children[2];\n len := Length(prms);\n it := self._children[3];\n res := prms[len];\n\n for i in Reversed([1..len-1]) do\n res := COND(eq(it, i-1), prms[i], res);\n od;\n\n return res.toAMat();\n end,\n\n\n\tdims := self >> [Length(self._children[1][1]), \n\t Length(self._children[1][1])],\n\n\tsums := self >> self\n));\n\nDeclare(InitStreamUnrollHw, SumStreamStrategy, StreamStrategy);\n\n\n# CountPermSwitches(t)\n# Returns number of switches needed for permutation t.\n# We assume t is a TPrm().withTags([AStream(w)]);\nCountPermSwitches := function (t)\n local i, M, M2, M2_t, N, N2, N2_t, n, k, r, s, s2, s3, s_m, s_n, opts;\n\n opts := InitStreamUnrollHw();\n r := RandomRuleTree(t, opts);\n s := SumsRuleTreeStrategy(r, SumStreamStrategy, opts);\n s2 := ApplyStrategy(s, StreamStrategy, UntilDone, opts);\n s3 := s2.createCode();\n\n k := Log2Int(s3.streamSize);\n M := s3.child(2);\n n := Length(M);\n\n # Extract M2. First just get the bottom k rows.\n M2_t := Sublist(M, [n-k+1 .. n]);\n \n M2 := [];\n # Now get the first n-k columns\n for i in [1..k] do\n Append(M2, [Sublist(M2_t[i], [1..k])]);\n od;\n\n s_m := Rank(M2);\n\n N := s3.child(1);\n # Extract N2. First just get the bottom k rows.\n N2_t := Sublist(N, [n-k+1 .. n]);\n \n N2 := [];\n # Now get the first n-k columns\n for i in [1..k] do\n Append(N2, [Sublist(N2_t[i], [1..k])]);\n od;\n\n s_n := Rank(N2);\n\n return (s_m + s_n) * s3.streamSize/2;\nend;\n", "meta": {"hexsha": "9fb0f46185fe6d309798ffb37aed5f1a6591924c", "size": 40839, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/stream/streampermsnonbit.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/paradigms/stream/streampermsnonbit.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/paradigms/stream/streampermsnonbit.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.2224770642, "max_line_length": 181, "alphanum_fraction": 0.5165160753, "num_tokens": 11420, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424256566558, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.6158253170660154}}
{"text": "# This file is a script for GAP and tests a list of polynomials in hexadecimal\n# for irreducibility over F_2\n\n# create x over F_2 = GF(2)\nx := Indeterminate(GF(2), \"x\");\n\n# test if polynomial is irreducible, i.e. the number of factors is one\nIrredPoly := function (poly)\n return (Length(Factors(poly)) = 1);\nend;;\n\n# create a polynomial in x from the hexadecimal representation of the\n# coefficients\nHex2Poly := function (s)\n return ValuePol(CoefficientsQadic(IntHexString(s), 2), x);\nend;;\n\n# list of candidates, in hex\ncandidates := [ \"3DA3358B4DC173\" ];\n\n# create real polynomials\nL := List(candidates, Hex2Poly);\n\n# filter and display the list of irreducible polynomials contained in L\nDisplay(Filtered(L, x -> (IrredPoly(x))));\n", "meta": {"hexsha": "22b2ae3a4ef040005d5e9625d6afb09a56f8c520", "size": 739, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "doc/test_irreducibility.gap", "max_stars_repo_name": "swaitw/restic", "max_stars_repo_head_hexsha": "daea461f1575e860424bcbbae8cc7292ce3fb919", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 16863, "max_stars_repo_stars_event_min_datetime": "2015-01-17T15:38:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T20:42:18.000Z", "max_issues_repo_path": "doc/test_irreducibility.gap", "max_issues_repo_name": "LCYLYM/restic", "max_issues_repo_head_hexsha": "ecc2458de8f94a2a0fe8300c74057ab77680d713", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 3243, "max_issues_repo_issues_event_min_datetime": "2015-01-01T12:11:13.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T23:57:27.000Z", "max_forks_repo_path": "doc/test_irreducibility.gap", "max_forks_repo_name": "LCYLYM/restic", "max_forks_repo_head_hexsha": "ecc2458de8f94a2a0fe8300c74057ab77680d713", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 1380, "max_forks_repo_forks_event_min_datetime": "2015-01-31T21:49:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T17:54:08.000Z", "avg_line_length": 28.4230769231, "max_line_length": 78, "alphanum_fraction": 0.7212449256, "num_tokens": 202, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8947894745194281, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.6137803581383063}}
{"text": "# Copyright (c) 2018-2020, Carnegie Mellon University\n# See LICENSE for details\n#\n# n-qubit T and Tdag transforms\n#\n\n\n#F qTT( n, i ) - T Gate non-terminal\n#F Definition: (2^n x 2^n)-matrix that applies an n-point T Transform to the target qubits\n#F Note: qTT(1, 1) denotes the matrix[[1, 0], [0, e^(-ipi/4)]], and qTT(1, -1) denotes the matrix[[1, 0], [0, e^(ipi/4)]]\n#F qTT(_) is symmetric.\n#F\n#F qTT(n , i) -> an n-qubit T transform, or Tdag transform if i = -1\nClass(qTT, TaggedNonTerminal, rec(\n abbrevs := [ (n, i) -> Checked(IsPosInt(n), [n, When(i <= -1, -1, 1)]) ],\n dims := self >> let(size := 2^self.params[1], [size, size]),\n terminate := self >> When(self.params[2] = -1, Tensor(Replicate(self.params[1], qTdag())), Tensor(Replicate(self.params[1], qT()))),\n isReal := self >> false,\n rChildren := self >> self.params,\n from_rChildren := (self, rch) >> self.__bases__[1](rch[1], rch[2]),\n groups := self >> [Replicate(self.params[1], 1)],\n recursive_def := (self, arch) >> self.__bases__[1](self.params[1], self.params[2]),\n SmallRandom := () -> Random([2..5]),\n LargeRandom := () -> Random([6..15]),\n normalizedArithCost := self >> Error(\"ArithCost not implemented\"),\n TType := T_Complex(64),\n));\n\n\nNewRulesFor(qTT, rec(\n\n # qTT_BinSplit rule\n # qTT_BinSplit qTT_(k) -> (qTT_(k1) tensor I) (I tensor qTT_(k2))\n # k1 + k2 = k\n qTT_BinSplit := rec (\n forTransposition := false,\n minSize := 2, \n applicable := (self, nt) >> nt.params[1] > 1,\n children := nt -> List( [1..nt.params[1] - 1], i -> [ Tensor(qTT(i, nt.params[2]), qTT(nt.params[1]-i, nt.params[2])).withTags(nt.getTags()) ] ), \n apply := (nt, c, cnt) -> c[1],\n switch := true,\n ),\n\n #F qTT_Base: qTT(1, _) = qT() or qT().inverse() (i.e. qTdag) SPL object\n #F Directly represent as an implementable gate\n qTT_Base := rec(\n info := \"qTT_(1, _) -> qT()\",\n forTransposition := false,\n applicable := (self, nt) >> nt.params[1]=1,\n apply := (nt, c, cnt) -> When(nt.params[2] = -1, qTdag(), qT()),\n )\n\n));", "meta": {"hexsha": "50eaf71869bfa9f1cbb658bd9db45c31e47acd77", "size": 2176, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "qtt.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": "qtt.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": "qtt.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": 41.0566037736, "max_line_length": 164, "alphanum_fraction": 0.5533088235, "num_tokens": 732, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127603871312, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.6136169213588936}}
{"text": "# First position is built-in\nhaystack := Eratosthenes(10000);;\nneedle := 8999;;\nPosition(haystack, needle);\n# 1117\n\nLastPosition := function(L, x)\n local old, new;\n old := 0;\n new := 0;\n while new <> fail do\n new := Position(L, x, old);\n if new <> fail then\n old := new;\n fi;\n od;\n return old;\nend;\n\na := Shuffle(List([1 .. 100], x -> x mod 10));\n# [ 0, 2, 4, 5, 3, 1, 0, 4, 8, 8, 2, 7, 6, 3, 3, 6, 4, 4, 3, 0, 7, 1, 8, 7, 2, 4, 7, 9, 4, 9, 4, 5, 9, 9, 6, 7, 8, 2, 3,\n# 5, 1, 5, 4, 2, 0, 9, 6, 1, 1, 2, 2, 0, 5, 7, 6, 8, 8, 3, 1, 9, 5, 1, 9, 6, 8, 9, 2, 0, 6, 2, 1, 6, 1, 1, 2, 5, 3, 3,\n# 0, 3, 5, 7, 5, 4, 6, 8, 0, 9, 8, 3, 7, 8, 0, 4, 9, 7, 0, 6, 5, 7 ]\nPosition(a, 0);\n# 1\nLastPosition(a, 0);\n# 97\n", "meta": {"hexsha": "acce85c1c11bb5e8337d1b363490f5de9a0c2be4", "size": 725, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Search-a-list/GAP/search-a-list.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/Search-a-list/GAP/search-a-list.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/Search-a-list/GAP/search-a-list.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 25.8928571429, "max_line_length": 120, "alphanum_fraction": 0.4675862069, "num_tokens": 448, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.7799929002541067, "lm_q1q2_score": 0.6125351176010793}}
{"text": "RequirePackage(\"grape\");\n\n# bilinear forms graph: vozlišča so matrike,\n# dve vozlišči sta sosednji, ko je njuna razlika ranga 1\nGB := AdjFunGraph(Elements(GF(2)^[2, 3]),\n function(x,y) return RankMat(x-y) = 1; end);;\n\n# OA(8, 3): vozlišča so vnosi v latinskem kvadratu (Z_8)^2,\n# dve vozlišči sta sosednji, če sta v isti vrstici, v istem stolpcu,\n# ali pa imata isto vrednost\nGZ8 := AdjFunGraph(Elements(ZmodnZ(8)^2), function(x,y) return x <> y and\n (x[1] = y[1] or x[2] = y[2] or x[1]+x[2] = y[1]+y[2]); end);;\n\n# OA(8, 3) za latinski kvadrat (Z_2 × Z_4)^2\nA := Elements(AbelianGroup([2, 4]));;\nA2 := Cartesian(A, A);;\nGZ24 := AdjFunGraph(A2, function(x,y) return x <> y and\n (x[1] = y[1] or x[2] = y[2] or x[1]*x[2] = y[1]*y[2]); end);;\n\n# OA(8, 3) za latinski kvadrat (Dih(8))^2\nD := Elements(DihedralGroup(8));;\nD2 := Cartesian(D, D);;\nGD8 := AdjFunGraph(D2, function(x,y) return x <> y and\n (x[1] = y[1] or x[2] = y[2] or x[1]*x[2] = y[1]*y[2]); end);;\n\n# OA(8, 3) za latinski kvadrat (Q_8)^2\nQ := Elements(SmallGroup(8, 4));;\nQ2 := Cartesian(Q, Q);;\nGQ8 := AdjFunGraph(Q2, function(x,y) return x <> y and\n (x[1] = y[1] or x[2] = y[2] or x[1]*x[2] = y[1]*y[2]); end);;\n\n# iz [21, 6; 8:21, 12:42]_2 kode\nM := [\n [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],\n [1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0],\n [1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0],\n [1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0],\n [1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0],\n [1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1]\n]*Z(2);\n\n# vozlišča so kodne besede,\n# dve vozlišči sta sosednji, ko je razdalja med njima minimalna\nGC := AdjFunGraph(Elements(Subspace(GF(2)^21, M)),\n function(x, y) return WeightVecFFE(x+y) = 8; end);;\nlGC := DistanceSetInduced(GC, 1, 1);;\n", "meta": {"hexsha": "90c381464485ca451d5b271210d3af6c3a657800", "size": 1906, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/srg64.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/srg64.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/srg64.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": 40.5531914894, "max_line_length": 73, "alphanum_fraction": 0.5356768101, "num_tokens": 1046, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045847699186, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.6115551091823462}}
{"text": "Composition := function(f, g)\n return x -> f(g(x));\nend;\n\nh := Composition(x -> x+1, x -> x*x);\nh(5);\n# 26\n", "meta": {"hexsha": "7ee68ea407643ea0a8c3c5a59c6f6f7c0e797fe7", "size": 110, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Function-composition/GAP/function-composition.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/Function-composition/GAP/function-composition.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/Function-composition/GAP/function-composition.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.75, "max_line_length": 37, "alphanum_fraction": 0.5090909091, "num_tokens": 39, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772482857833, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.6112023747325521}}
{"text": "# Copyright (c) 2018-2020, Carnegie Mellon University\n# See LICENSE for details\n#\n# n-qubit S transform\n#\n\n\n#F qST( n, i ) - S Gate non-terminal\n#F Definition: (2^n x 2^n)-matrix that applies an n-point S Transform to the target qubits\n#F Note: qST(1) denotes the matrix[[1, 0], [0, e^(-ipi/2)]], or [[1,0], [0, -i]]\n#F qZT(_) is symmetric.\n#F\n#F qST(n , i) -> an n-qubit S transform, or Sdag transform if i = -1\nClass(qST, TaggedNonTerminal, rec(\n abbrevs := [ (n, i) -> Checked(IsPosInt(n), [n, When(i <= -1, -1, 1)]) ],\n dims := self >> let(size := 2^self.params[1], [size, size]),\n terminate := self >> When(self.params[2] = -1, Tensor(Replicate(self.params[1], qSdag())), Tensor(Replicate(self.params[1], qS()))),\n isReal := self >> false,\n rChildren := self >> self.params,\n from_rChildren := (self, rch) >> self.__bases__[1](rch[1], rch[2]),\n groups := self >> [Replicate(self.params[1], 1)],\n recursive_def := (self, arch) >> self.__bases__[1](self.params[1], self.params[2]),\n SmallRandom := () -> Random([2..5]),\n LargeRandom := () -> Random([6..15]),\n normalizedArithCost := self >> Error(\"ArithCost not implemented\"),\n TType := T_Complex(64),\n));\n\n\nNewRulesFor(qST, rec(\n\n # qST_BinSplit rule\n # qST_BinSplit qST_(k) -> (qST_(k1) tensor I) (I tensor qST_(k2))\n # k1 + k2 = k\n qST_BinSplit := rec (\n forTransposition := false,\n minSize := 2, \n applicable := (self, nt) >> nt.params[1] > 1,\n children := nt -> List( [1..nt.params[1] - 1], i -> [ Tensor(qST(i, nt.params[2]), qST(nt.params[1]-i, nt.params[2])).withTags(nt.getTags()) ] ), \n apply := (nt, c, cnt) -> c[1],\n switch := true,\n ),\n\n #F qST_Base: qST(1, _) = qS() or qS().inverse() SPL object\n #F Directly represent as an implementable gate\n qST_Base := rec(\n info := \"qST_(1, _) -> qS()\",\n forTransposition := false,\n applicable := (self, nt) >> nt.params[1]=1,\n apply := (nt, c, cnt) -> When(nt.params[2] = -1, qSdag(), qS()),\n )\n\n));", "meta": {"hexsha": "b4a317c5ad9293d2fedd4a70da9ee8b7bb2fab42", "size": 2112, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "qst.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": "qst.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": "qst.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": 39.8490566038, "max_line_length": 164, "alphanum_fraction": 0.5501893939, "num_tokens": 703, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681195338728, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.6109300508672895}}
{"text": "# Solution in '''RPN'''\nPlay24 := function()\n\tlocal input, digits, line, c, chars, stack, stackptr, cur, p, q, ok, a, b, run;\n\tinput := InputTextUser();\n\trun := true;\n\twhile run do\n\t\tdigits := List([1 .. 4], n -> Random(1, 9));\n\t\twhile true do\n\t\t\tDisplay(digits);\n\t\t\tline := ReadLine(input);\n\t\t\tline := Chomp(line);\n\t\t\tif line = \"end\" then\n\t\t\t\trun := false;\n\t\t\t\tbreak;\n\t\t\telif line = \"next\" then\n\t\t\t\tbreak;\n\t\t\telse\n\t\t\t\tok := true;\n\t\t\t\tstack := [ ];\n\t\t\t\tstackptr := 0;\n\t\t\t\tchars := \"123456789+-*/ \";\n\t\t\t\tcur := ShallowCopy(digits);\n\t\t\t\tfor c in line do\n\t\t\t\t\tif c = ' ' then\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tfi;\n\t\t\t\t\tp := Position(chars, c);\n\t\t\t\t\tif p = fail then\n\t\t\t\t\t\tok := false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tfi;\n\t\t\t\t\tif p < 10 then\n\t\t\t\t\t\tq := Position(cur, p);\n\t\t\t\t\t\tif q = fail then\n\t\t\t\t\t\t\tok := false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tfi;\n\t\t\t\t\t\tUnbind(cur[q]);\n\t\t\t\t\t\tstackptr := stackptr + 1;\n\t\t\t\t\t\tstack[stackptr] := p;\n\t\t\t\t\telse\n\t\t\t\t\t\tif stackptr < 2 then\n\t\t\t\t\t\t\tok := false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tfi;\n\t\t\t\t\t\tb := stack[stackptr];\n\t\t\t\t\t\ta := stack[stackptr - 1];\n\t\t\t\t\t\tstackptr := stackptr - 1;\n\t\t\t\t\t\tif c = '+' then\n\t\t\t\t\t\t\ta := a + b;\n\t\t\t\t\t\telif c = '-' then\n\t\t\t\t\t\t\ta := a - b;\n\t\t\t\t\t\telif c = '*' then\n\t\t\t\t\t\t\ta := a * b;\n\t\t\t\t\t\telif c = '/' then\n\t\t\t\t\t\t\tif b = 0 then\n\t\t\t\t\t\t\t\tok := false;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tfi;\n\t\t\t\t\t\t\ta := a / b;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tok := false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tfi;\n\t\t\t\t\t\tstack[stackptr] := a;\n\t\t\t\t\tfi;\n\t\t\t\tod;\n\t\t\t\tif ok and stackptr = 1 and Size(cur) = 0 then\n\t\t\t\t\tif stack[1] = 24 then\n\t\t\t\t\t\tPrint(\"Good !\\n\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\telse\n\t\t\t\t\t\tPrint(\"Bad value: \", stack[1], \"\\n\");\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tfi;\n\t\t\t\tfi;\n\t\t\t\tPrint(\"Invalid expression\\n\");\n\t\t\tfi;\n\t\tod;\n\tod;\n\tCloseStream(input);\nend;\n\n# example session\n# type \"end\" to quit the game, \"next\" to try another list of digits\ngap> Play24();\n[ 7, 6, 8, 5 ]\n86*75-/\nGood !\n[ 5, 9, 2, 7 ]\nend\ngap>\n", "meta": {"hexsha": "d2941990cfe5b5d7a7dee3b5b08672960e0ec7c2", "size": 1837, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/24-game/GAP/24-game.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/24-game/GAP/24-game.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/24-game/GAP/24-game.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": 19.752688172, "max_line_length": 80, "alphanum_fraction": 0.473598258, "num_tokens": 587, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.872347368040789, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.6099927647361221}}
{"text": "# Copyright (c) 2018-2020, Carnegie Mellon University\n# See LICENSE for details\n#\n# n-qubit X transforms\n#\n\n\n#F qXT( n ) - X Gate non-terminal\n#F Definition: (2^n x 2^n)-matrix that applies an n-point X Transform to the target qubits\n#F Note: qXT(1) denotes the matrix[[0, 1], [1, 0]],\n#F qXT(_) is symmetric.\n#F\n#F qXT( n ) -> an n-qubit X transform\nClass(qXT, TaggedNonTerminal, rec(\n abbrevs := [ n -> Checked(IsPosInt(n), [n]) ],\n dims := self >> let(size := 2^self.params[1], [size, size]),\n terminate := self >> Tensor(Replicate(self.params[1], qX())),\n isReal := self >> true,\n groups := self >> [Replicate(self.params[1], 1)],\n rChildren := self >> self.params,\n from_rChildren := (self, rch) >> self.__bases__[1](rch[1]),\n recursive_def := (self, arch) >> self.__bases__[1](self.params[1]),\n connected := self >> true,\n SmallRandom := () -> Random([2..5]),\n LargeRandom := () -> Random([6..15]),\n normalizedArithCost := self >> Error(\"ArithCost not implemented\"),\n TType := T_Complex(64),\n));\n\n\nNewRulesFor(qXT, rec(\n\n # qXT_BinSplit rule\n # qXT_BinSplit qXT_(k) -> (qXT_(k1) tensor I) (I tensor qXT_(k2))\n # k1 + k2 = k\n qXT_BinSplit := rec (\n forTransposition := false,\n minSize := 2, \n applicable := (self, nt) >> nt.params[1] > 1,\n children := nt -> List( [1..nt.params[1] - 1], i -> [ Tensor(qXT(i), qXT(nt.params[1]-i)).withTags(nt.getTags()) ] ), \n apply := (nt, c, cnt) -> c[1],\n switch := true,\n ),\n\n #F qXT_Base: qXT(1) = qX() SPL object\n #F Directly represent as an implementable gate\n qXT_Base := rec(\n info := \"qXT_(1) -> qX()\",\n forTransposition := false,\n applicable := (self, nt) >> nt.params[1]=1,\n apply := (nt, c, cnt) -> qX(),\n )\n\n));", "meta": {"hexsha": "710d4cae50bd2f876fd838fbb6194f69569664d6", "size": 1870, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "qxt.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": "qxt.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": "qxt.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": 34.6296296296, "max_line_length": 136, "alphanum_fraction": 0.549197861, "num_tokens": 597, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511469672594, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.609564726560181}}
{"text": "leftOf :=function(setA, vA, setB, vB)\nlocal i;\nfor i in [1..4] do\n if ( setA[i] = vA) and (setB[i+1] = vB) then return true ;fi;\nod;\n return false;\nend;\n\nnextTo :=function(setA, vA, setB, vB)\nlocal i;\nfor i in [1..4] do\n if ( setA[i] = vA) and (setB[i+1] = vB) then return true ;fi;\n if ( setB[i] = vB) and (setA[i+1] = vA) then return true ;fi;\nod;\nreturn false;\nend;\n\n\nrequires := function(setA, vA, setB, vB)\n local i;\n for i in [1..5] do\n if ( setA[i] = vA) and (setB[i] = vB) then return true ;fi;\n od;\n return false;\nend;\n\n\npcolors :=PermutationsList([\"white\" ,\"yellow\" ,\"blue\" ,\"red\" ,\"green\"]);\npcigars :=PermutationsList([\"blends\", \"pall_mall\", \"prince\", \"bluemasters\", \"dunhill\"]);\npnats:=PermutationsList([\"german\", \"swedish\", \"british\", \"norwegian\", \"danish\"]);\npdrinks :=PermutationsList([\"beer\", \"water\", \"tea\", \"milk\", \"coffee\"]);\nppets :=PermutationsList([\"birds\", \"cats\", \"horses\", \"fish\", \"dogs\"]);\n\n\nfor colors in pcolors do\nif not (leftOf(colors,\"green\",colors,\"white\")) then continue ;fi;\nfor nats in pnats do\nif not (requires(nats,\"british\",colors,\"red\")) then continue ;fi;\nif not (nats[1]=\"norwegian\") then continue ;fi;\nif not (nextTo(nats,\"norwegian\",colors,\"blue\")) then continue ;fi;\nfor pets in ppets do\nif not (requires(nats,\"swedish\",pets,\"dogs\")) then continue ;fi;\nfor drinks in pdrinks do\nif not (drinks[3]=\"milk\") then continue ;fi;\nif not (requires(colors,\"green\",drinks,\"coffee\")) then continue ;fi;\nif not (requires(nats,\"danish\",drinks,\"tea\")) then continue ;fi;\nfor cigars in pcigars do\nif not (nextTo(pets,\"horses\",cigars,\"dunhill\")) then continue ;fi;\nif not (requires(cigars,\"pall_mall\",pets,\"birds\")) then continue ;fi;\nif not (nextTo(cigars,\"blends\",drinks,\"water\")) then continue ;fi;\nif not (nextTo(cigars,\"blends\",pets,\"cats\")) then continue ;fi;\nif not (requires(nats,\"german\",cigars,\"prince\")) then continue ;fi;\nif not (requires(colors,\"yellow\",cigars,\"dunhill\")) then continue ;fi;\nif not (requires(cigars,\"bluemasters\",drinks,\"beer\")) then continue ;fi;\nPrint(colors,\"\\n\");\nPrint(nats,\"\\n\");\nPrint(drinks,\"\\n\");\nPrint(pets,\"\\n\");\nPrint(cigars,\"\\n\");\nod;od;od;od;od;\n", "meta": {"hexsha": "1236497757b708bda0a378301c2771c6abf0c334", "size": 2160, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Zebra-puzzle/GAP/zebra-puzzle.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": "2021-06-15T00:56:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-15T00:56:39.000Z", "max_issues_repo_path": "Task/Zebra-puzzle/GAP/zebra-puzzle.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/Zebra-puzzle/GAP/zebra-puzzle.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "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": 35.4098360656, "max_line_length": 88, "alphanum_fraction": 0.6592592593, "num_tokens": 741, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677660619634, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.609344886883258}}
{"text": "\n#\n# Read(\"~/Workspace/groupsSB/epi/A2/case.2.gi\");\n#\n\ntype:=\"A\";\nrank:=2;\nnr_pos_roots:=3;\n\nRead(\"~/Workspace/groupsSB/epi/group.gi\");\n\nhighest_weight:=[1,1];# corresponding highest weight module is the Lie algebra\n\nRead(\"~/Workspace/groupsSB/epi/ext.gi\");\n\n#\n# p>2\n#\n\ngetRep:=function(k,t)\n local u,ua,ub,uab;\n ua:=ext_root_group(k,1,t);\n #ub:=ext_root_group(k,2,t);\n uab:=ext_root_group(k,3,t); \n u:=ua*uab;\n\n return u; \nend;\n\n#\n# k:=3; # power of exterior algebra\n#\nhandle:=function(k)\n local id_mat,u,e,h,h1,h2,ese,evh1,esh1,evh2,esh2,esh01,index_ev01,esh02,index_ev02,si,si1,si2,inter;\n u:=getRep(k,1);\n id_mat:=u^0;\n e:=u-id_mat;\n ese:=Eigenspaces(Rationals,e)[1]; #eigenvalues 0, centralizer\n \n # torus\n # centralizer of T1\n h1:=ext_e(k,cb0[7]);\n esh1:=Eigenspaces(Rationals,h1);\n evh1:=Eigenvalues(Rationals,h1);\n esh01:=[];\n index_ev01:=Position(evh1,0);\n esh01:=esh1[index_ev01];\n\n # centralizer of T2\n h2:=ext_e(k,cb0[8]);\n esh2:=Eigenspaces(Rationals,h2);\n evh2:=Eigenvalues(Rationals,h2);\n esh02:=[];\n index_ev02:=Position(evh2,0);\n esh02:=esh2[index_ev02];\n\n #\n # sum and intersection\n #\n #return [ese,esh01,esh02];\n si1:=SumIntersectionMat(Basis(ese),Basis(esh01));\n si2:=SumIntersectionMat(Basis(ese),Basis(esh02));\n si:=SumIntersectionMat(si1[2],si2[2]);\n inter:=si[2];\n return inter;\n #return [inter,esh01,esh02];\nend;\n\ntestFixedPointsTrous:=function(k)\n local result1,result2,h1,esh1,evh1,esh01,index_ev01,h2,esh2,evh2,esh02,index_ev02;\n # torus\n # centralizer of T1\n h1:=ext_e(k,cb0[7]);\n esh1:=Eigenspaces(Rationals,h1);\n evh1:=Eigenvalues(Rationals,h1);\n esh01:=[];\n index_ev01:=Position(evh1,0);\n esh01:=esh1[index_ev01];\n \n result1:=List(Basis(esh01),b->ext_lin_comb(k,b));\n result1:=List(result1,i->cb0[7]^i);\n\n # centralizer of T2\n h2:=ext_e(k,cb0[8]);\n esh2:=Eigenspaces(Rationals,h2);\n evh2:=Eigenvalues(Rationals,h2);\n esh02:=[];\n index_ev02:=Position(evh2,0);\n esh02:=esh2[index_ev02];\n\n result2:=List(Basis(esh02),b->ext_lin_comb(k,b));\n result2:=List(result2,i->cb0[8]^i);\n\n return [result1,result2];\nend;", "meta": {"hexsha": "aa9ae2559a2c88ce3c2e34140468b4b89e79d6c4", "size": 2217, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "epi/A2/case.2.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/case.2.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/case.2.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": 23.3368421053, "max_line_length": 104, "alphanum_fraction": 0.6391520072, "num_tokens": 813, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357598021707, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.6091186766974974}}
{"text": "# Checks whether a graph is an antipodal cover.\nBindGlobal(\"IsAntipodalCover\", function(G)\n local d, k, ia, i, ci, cj;\n if not IsSimpleGraph(G) then\n Error(\"not a simple graph\");\n return fail;\n fi;\n if not IsConnectedGraph(G) then\n Error(\"not a connected graph\");\n return fail;\n fi;\n d := Diameter(G);\n ia := GlobalParameters(G);\n k := ia[1][3];\n if k = -1 or ia[d+1][1] <> k then\n return false;\n fi;\n for i in [1..Length(G.representatives)] do\n ci := DistanceSet(G, 1, DistanceSet(G, [0, d], G.representatives[i]));\n cj := Union(List(Adjacency(G, G.representatives[i]),\n x -> DistanceSet(G, [0, d], x)));\n if ci <> cj then\n return false;\n fi;\n od;\n return true;\nend);\n\n# Covering index of an antipodal cover.\nBindGlobal(\"AntipodalCoveringIndex\", function(G)\n if not IsAntipodalCover(G) then\n Error(\"not an antipodal cover\");\n return fail;\n fi;\n return Length(DistanceSet(G, [0, Diameter(G)], 1));\nend);\n\n# Parameters of a generalized polygon.\n# Does not check whether G actually is a generalized polygon\n# (for d = 2 this is not guaranteed).\nBindGlobal(\"GeneralizedPolygonParameters\", function(G)\n local d, s, t, ia;\n if not IsSimpleGraph(G) then\n Error(\"not a simple graph\");\n return fail;\n fi;\n if not IsConnectedGraph(G) then\n Error(\"not a connected graph\");\n return fail;\n fi;\n d := Diameter(G);\n ia := GlobalParameters(G);\n t := ia[d+1][1] - 1;\n s := ia[1][3] / ia[d+1][1];\n if not IsInt(s) or ForAny(ia{[2..d]}, x -> x[1] <> 1 or x[3] <> s*t) then\n return fail;\n fi;\n return [2*d, s, t];\nend);\n\n# Check whether two vertices of a generalized quadrangle with parameter t\n# are either equal, or make a regular pair.\nBindGlobal(\"IsRegularPair\", function(G, x, y, t)\n return x = y or y in Adjacency(G, x) or\n Size(Intersection(List(Intersection(Adjacency(G, x), Adjacency(G, y)),\n z -> Adjacency(G, z)))) = t+1;\nend);\n\n# Find regular points in a generalized quadrangle.\nBindGlobal(\"RegularPoints\", function(G)\n local l, t, P, orb, par;\n par := GeneralizedPolygonParameters(G);\n if par = fail then\n return fail;\n fi;\n t := par[3];\n l := [1..Length(G.representatives)];\n P := [1..G.order];\n orb := List(l, i -> OrbitsDomain(Stabilizer(G.group,\n G.representatives[i]), P));\n return G.representatives{Filtered(l, i -> ForAll(orb[i][1],\n x -> IsRegularPair(G, G.representatives[i], x, t)))};\nend);\n", "meta": {"hexsha": "e0530a67a3abaf897dc88c00dfecf35592c88249", "size": 2646, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/GraphInfo.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/GraphInfo.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/GraphInfo.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": 31.5, "max_line_length": 79, "alphanum_fraction": 0.5789871504, "num_tokens": 746, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127492339909, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.6081841529681652}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nDeclare(DST3, DST7);\n\n#F DST1(<n>) - Discrete Sine Transform, Type I, non-terminal\n#F Definition: (n x n)-matrix [ sin((k+1)*(l+1)*pi/(n+1)) | k,l = 0...n-1 ]\n#F Note: The natural size for a DST1 is 2^k - 1\n#F Note: DST4 is symmetric\n#F Example: DST1(7)\n#F \nClass(DST1, DTTBase, rec(\n terminate := self >> When(self.params[1] > 1, Mat(DST_Iunscaled(self.params[1])), I(1)),\n transpose := self >> Copy(self), \n SmallRandom := () -> Random([2,3,5,7,11,15,23,31])\n));\n\n#F DST2(<n>) - Discrete Sine Transform, Type II, non-terminal\n#F Definition: (n x n)-matrix [ sin(k*(l+1/2)*pi/n) | k,l = 0...n-1 ]\n#F Note: DST2 is the transpose of DST3\n#F Example: DST2(8)\nClass(DST2, DTTBase, rec(\n terminate := self >> Mat(DST_IIunscaled(self.params[1])),\n transpose := self >> DST3(self.params[1]),\n SmallRandom := () -> Random([2,3,4,6,8,9,12,16,18,24,27,32])\n));\n\n#F DST3(<n>) - Discrete Sine Transform, Type III, non-terminal\n#F Definition: (n x n)-matrix [ sin((k-1/2)*l*pi/n) | k,l = 1...n ]\n#F Note: DST3 is the transpose of DST2\n#F Example: DST3(8)\n#F Scaled variant (not supported) is:\n#F [ a_l*sin(k*(l-1/2)*pi/n) | k,l = 1...n ]\n#F with a_j = 1/sqrt(2) for j = n and = 1 else.\nClass(DST3, DTTBase, rec(\n terminate := self >> Mat(DST_IIIunscaled(self.params[1])),\n transpose := self >> DST2(self.params[1]),\n SmallRandom := () -> Random([2,3,4,6,8,9,12,16,18,24,27,32])\n));\n\n#F DST4(<n>) - Discrete Sine Transform, Type IV, non-terminal\n#F Definition: (n x n)-matrix [ sin((k-1/2)*(l-1/2)*pi/n) | k,l = 1...n ]\n#F Note: DST4 is symmetric\n#F Example: DST4(8)\nClass(DST4, DTTBase, rec(\n terminate := self >> Mat(DST_IVunscaled(self.params[1])),\n transpose := self >> Copy(self), \n SmallRandom := () -> Random([2,3,4,6,8,9,12,16,18,24,27,32])\n));\n\n#F DST5(<n>) - Discrete Sine Transform, Type V, non-terminal\n#F Definition: (n x n)-matrix [ sin((k+1)*(l+1)*pi/(n+1/2)) | k,l = 0...n-1 ]\n#F Note: DST5 is symmetric\n#F Example: DST5(8)\nClass(DST5, DTTBase, rec(\n terminate := self >> Mat(DST_Vunscaled(self.params[1])),\n transpose := self >> Copy(self), \n));\n\n\n#F DST6(<n>) - Discrete Sine Transform, Type VI, non-terminal\n#F Definition: (n x n)-matrix [ sin((k+1)*(l+1/2)*pi/(n+1/2)) | k,l = 0...n-1 ]\n#F Note: The transpose of DST6 is DST7\n#F Example: DST6(8)\nClass(DST6, DTTBase, rec(\n terminate := self >> Mat(DST_VIunscaled(self.params[1])),\n transpose := self >> DST7(self.params[1])\n));\n\n#F DST7(<n>) - Discrete Sine Transform, Type VII, non-terminal\n#F Definition: (n x n)-matrix [ sin((k+1/2)*(l+1)*pi/(n+1/2)) | k,l = 0...n-1 ]\n#F Note: The transpose of DST7 is DST6\n#F Example: DST7(8)\nClass(DST7, DTTBase, rec(\n terminate := self >> Mat(DST_VIIunscaled(self.params[1])),\n transpose := self >> DST6(self.params[1]) \n));\n\n#F DST8(<n>) - Discrete Sine Transform, Type VIII, non-terminal\n#F Definition: (n x n)-matrix [ sin((k+1/2)*(l+1/2)*pi/(n-1/2)) | k,l = 0...n-1 ]\n#F Note: DST8 is symmetric\n#F Example: DST8(8)\nClass(DST8, DTTBase, rec(\n terminate := self >> Mat(DST_VIIIunscaled(self.params[1])),\n transpose := self >> Copy(self), \n));\n", "meta": {"hexsha": "2c30682db03b431e61f5cf3a7410296f2f33f016", "size": 3293, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dct_dst/dst.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.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.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 37.0, "max_line_length": 92, "alphanum_fraction": 0.5952019435, "num_tokens": 1214, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382236515259, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.6080607844941943}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# ==========================================================================\n# Mon(<perm-func>, <value-diag>, <structural-diag>) = perm * diag \n# ==========================================================================\nClass(Mon, BaseMat, SumsBase, rec(\n new := (self, perm, vdiag, sdiag) >> Checked(\n domain(perm) = domain(vdiag) and domain(perm) = domain(sdiag),\n SPL(WithBases(self, \n\t\trec( perm := perm,\n\t\t vdiag := vdiag,\n\t\t sdiag := sdiag ))).setDims()),\n\n #-----------------------------------------------------------------------\n dims := self >> [self.perm.domain(), self.perm.range()],\n setDims := meth(self) self.dimensions := self.dims(); return self; end,\n #-----------------------------------------------------------------------\n sums := self >> self,\n rChildren := self >> [self.perm, self.vdiag, self.sdiag],\n rSetChild := rSetChildFields(\"perm\", \"vdiag\", \"sdiag\"),\n\n children := ~.rChildren,\n setChild := ~.rSetChild,\n child := (self, n) >> Cond(n=1, self.perm, n=2, self.vdiag, n=3, self.sdiag,\n\tError(\"<n> must be in [1..3]\")),\n #-----------------------------------------------------------------------\n isPermutation := False, \n #-----------------------------------------------------------------------\n isReal := self >> self.vdiag.isReal(),\n #-----------------------------------------------------------------------\n toAMat := self >> AMatSPL( Gath(self.perm) * Diag(self.vdiag) * Diag(self.sdiag) ),\n #-----------------------------------------------------------------------\n transpose := self >> # we use inherit to copy all fields of self\n Inherit(self, rec(\n\t\tperm := self.perm.transpose(),\n\t\tvdiag := fCompose(self.vdiag, self.perm),\n\t\tsdiag := fCompose(self.sdiag, self.perm),\n\t\tdimensions := Reversed(self.dimensions))),\n #-----------------------------------------------------------------------\n print := (self, i, is) >>\n Print(self.name, \"(\", self.perm, \", \", self.vdiag, \", \", self.sdiag, \")\"),\n #-----------------------------------------------------------------------\n arithmeticCost := (self, costMul, costAddMul) >> Sum(self.vdiag.tolist(), costMul)\n));\n\nDeclare(SMon, GMon, SGMon);\n\n# ==========================================================================\n# GMon(<gath-func>, <value-diag>, <structural-diag>) = diag * gath\n# ==========================================================================\nClass(GMon, Mon, rec(\n #-----------------------------------------------------------------------\n dims := self >> [domain(self.perm), range(self.perm)],\n #-----------------------------------------------------------------------\n toAMat := self >> AMatSPL( self.vdiag * self.sdiag * Gath(self.perm) ),\n #-----------------------------------------------------------------------\n transpose := self >> SMon(self.perm, self.vdiag, self.sdiag)\n #-----------------------------------------------------------------------\n));\n\n# ==========================================================================\n# SMon(<scat-func>, <value-diag>, <structural-diag>) = scat * diag \n# ==========================================================================\nClass(SMon, Mon, rec(\n #-----------------------------------------------------------------------\n dims := self >> [range(self.perm), domain(self.perm)],\n #-----------------------------------------------------------------------\n toAMat := self >> AMatSPL( Scat(self.perm) * self.vdiag * self.sdiag ),\n #-----------------------------------------------------------------------\n transpose := self >> GMon(self.perm, self.vdiag, self.sdiag)\n #-----------------------------------------------------------------------\n));\n\n# ==========================================================================\n# SGMon(<scat-func>, <gath-func>, <value-diag>, <structural-diag>) = scat * diag * gath\n# ==========================================================================\nClass(SGMon, Mon, rec(\n new := (self, scat, gath, vdiag, sdiag) >> Checked(\n domain(scat) = domain(vdiag) and domain(vdiag) = domain(sdiag) and\n domain(sdiag) = domain(gath),\n SPL(WithBases(self, \n\t\trec( scat := scat, \n\t\t gath := gath, \n\t\t vdiag := vdiag,\n\t\t sdiag := sdiag ))).setDims()),\n\n rChildren := self >> [self.scat, self.gath, self.vdiag, self.sdiag],\n rSetChild := rSetChildFields(\"scat\", \"gath\", \"vdiag\", \"sdiag\"),\n child := (self, n) >> Cond(n=1, self.scat, n=2, self.gath, \n\t n=3, self.vdiag, n=4, self.sdiag,\n\t\t\t Error(\"<n> must be in [1..3]\")),\n #-----------------------------------------------------------------------\n dims := self >> [range(self.scat), range(self.gath)],\n #-----------------------------------------------------------------------\n toAMat := self >> AMatSPL(Scat(self.scat) * self.vdiag * self.sdiag * \n\t Gath(self.gath)),\n #-----------------------------------------------------------------------\n transpose := self >> SGMon(self.gath, self.scat, self.vdiag, self.sdiag),\n #-----------------------------------------------------------------------\n print := (self, i, is) >>\n Print(self.name, \"(\", self.scat, \", \", self.gath, \", \", self.vdiag, \", \", self.sdiag, \")\")\n ));\n", "meta": {"hexsha": "3aa9db7e0bdedccd5836f44ab6c45b05202af257", "size": 5381, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/Mon.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/Mon.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/Mon.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": 50.7641509434, "max_line_length": 97, "alphanum_fraction": 0.3523508642, "num_tokens": 1120, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.6076767050347212}}
{"text": "# Adjacency function for Kneser-type graphs.\nBindGlobal(\"DisjointSets\", function(x, y)\n return Intersection(x, y) = [];\nend);\n\n# Adjacency function for doubled Odd and Grassmann graphs.\nBindGlobal(\"SymmetrizedInclusion\", function(x, y)\n return x <> y and (IsSubset(x, y) or IsSubset(y, x));\nend);\n\n# Adjacency function for roots of E_8.\nBindGlobal(\"RootAdjacency\", function(x, y)\n return x*y = 8;\nend);\n\n# Adjacency function for forms graphs.\nBindGlobal(\"RankAdjacency\",\n r -> function(x, y)\n return RankMat(x-y) in r;\n end);\n\n# Adjacency function for adjacency matrices.\nBindGlobal(\"MatrixAdjacency\",\n M -> function(x, y)\n return M[x][y] = 1;\n end);\n\n# Adjacency function for adjacency lists.\nBindGlobal(\"ListAdjacency\",\n L -> function(x, y)\n return y in L[x];\n end);\n\n# Point-line incidence\nBindGlobal(\"PointLineIncidence\", function(x, y)\n return x in y or y in x;\nend);\n", "meta": {"hexsha": "10a7a94ba98ee51c34e96e53615524727e77b423", "size": 924, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/AdjacencyFunctions.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/AdjacencyFunctions.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/AdjacencyFunctions.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": 24.3157894737, "max_line_length": 58, "alphanum_fraction": 0.6699134199, "num_tokens": 252, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.877476793890012, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.6048496714261629}}
{"text": "\nlocal reps,tori,labels,I,II,ords;\n\n# Permutation from standard to gap\n# / 1 2 3 4 \\\n# \\ 2 4 3 1 /\n# Position(pr,Permuted([2,3,4,2],(2,4,1)))=24;\n\n\n#......Ross Jordan Block Sizes........Donna & Ross nilpotents........(in GAP notation)\nreps:=[[[2,1],[4,1],[3,1],[1,1]], # F_4\n [[2,1],[4,1],[7,1],[5,1]], # F_4(a_1) [[2,1],[4,1],[10,1],[1,1]],\n [[6,1],[10,1],[1,1],[5,1]], # F_4(a_2) [[9,1],[1,1],[10,1],[4,1]],\n [[4,1],[3,1],[1,1]], # C_3 [[1,1],[3,1],[4,1]],\n [[2,1],[4,1],[3,1]], # B_3 the same\n [[4,1],[6,1],[10,1],[18,1]], # F_4(a_3) [[4,1],[13,1],[11,1],[12,1]],\n [[4,1],[1,1],[10,1]], # C_3(a_1) [[1,1],[10,1],[4,1]],\n [[2,1],[3,1],[1,1]], # sA_2A_1 [[3,1],[1,1],[2,1]],\n [[4,1],[3,1]], # B_2 the same\n [[2,1],[4,1],[1,1]], # A_2sA_1 the same\n [[3,1],[1,1]], # sA_2 the same\n [[2,1],[4,1]], # A_2 the same\n [[2,1],[3,1]], # A_1sA_1 [[2,1],[1,1]],\n [[3,1]], # sA_1 [[1,1]],\n [[2,1]]]; # A_1 [[2,1]]\n\nI:=[[],[3],[2,3],[],[],[2,3,1],[3],[],[],[],[],[],[],[],[]];\n\n#\n# The parabolic where the representative is distinguished\n#\nII:=[[1,2,3,4],\n [1,2,3,4],\n [1,2,3,4],\n [4,3,1],\n [2,4,3],\n [1,2,3,4],\n [4,3,1],\n [3,1,2],\n [4,3],\n [2,4,1],\n [3,1],\n [2,4],\n [2,1],\n [1],\n [2]];\n\nlabels:=[\"F_4\",\"F_4(a_1)\",\"F_4(a_2)\",\"C_3\",\"B_3\",\"F_4(a_3)\",\"C_3(a_1)\",\"\\\\tilde A_2A_1\",\"B_2\",\"A_2\\\\tilde A_1\",\"\\\\tilde A_2\",\"A_2\",\"A_1\\\\tilde A_1\",\"\\\\tilde A_1\",\"A_1\"];\n\ntori:=[\n [2,2,2,2],\n [2,2,0,2],\n [2,0,0,2],\n [2,1,1,0],\n [0,2,0,2],\n [0,0,0,2],\n [0,1,1,0],\n [1,0,0,1],\n [1,2,0,0],\n [0,0,1,0],\n [2,0,0,0],\n [0,2,0,0],\n [0,0,0,1],\n [1,0,0,0],\n [0,1,0,0]\n ];\n\nords:=[];\n\nreturn [reps,tori,labels,I,II,ords];\n", "meta": {"hexsha": "6bc9282a38f82fd859cbe260312e4b7540db249e", "size": 2010, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/data/dataF4.gi", "max_stars_repo_name": "iuliansimion/Chevalley.gap", "max_stars_repo_head_hexsha": "dd237f36d69a42bcd6cb6a24c5e4bf7dfb3da186", "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": "lib/data/dataF4.gi", "max_issues_repo_name": "iuliansimion/Chevalley.gap", "max_issues_repo_head_hexsha": "dd237f36d69a42bcd6cb6a24c5e4bf7dfb3da186", "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": "lib/data/dataF4.gi", "max_forks_repo_name": "iuliansimion/Chevalley.gap", "max_forks_repo_head_hexsha": "dd237f36d69a42bcd6cb6a24c5e4bf7dfb3da186", "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": 28.3098591549, "max_line_length": 169, "alphanum_fraction": 0.3407960199, "num_tokens": 956, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527944504227, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.6012955214746778}}