{"text": "\nlocal reps,tori,labels,I,II,ords,blocks;\n\nreps:=[[[1,1],[2,1]],\n       [[2,1],[5,1]],\n       [[1,1]],\n       [[2,1]]];\n\nI:=[[],[1],[],[]];\n\n#\n# The parabolic where the representative is distinguished\n#\nII:=[[1,2],\n     [1,2],\n     [1],\n     [2]];\n\nlabels:=[\"G_2\",\"G_2(a_1)\",\"\\\\tilde A_1\",\"A_1\"];\n\ntori:=[\n    [2,2],\n    [0,2],\n    [2,-3],\n    [-1,2]\n    ];\n\nblocks:=[];\n\nords:=[];\n\nreturn [reps,tori,labels,I,II,ords,blocks];", "meta": {"hexsha": "672eef1a9d5e4cb526223180975a5d3559c5723e", "size": 426, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/data/dataG2.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/dataG2.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/dataG2.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": 13.3125, "max_line_length": 57, "alphanum_fraction": 0.441314554, "num_tokens": 173, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.49994302411917135}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F WHT( <log2(size)> ) - Walsh Hadamard Transform non-terminal\n#F Definition: (2^n x 2^n)-matrix  DFT_2 tensor ... tensor DFT_2 (n-fold)\n#F Note:       DFT_2 denotes the matrix [[1, 1], [1, -1]],\n#F             WHT is symmetric.\n#F Example:    WHT(3)\n#F\n#F Tweakable parameters: WHT_GeneralSplit.maxSize,\n#F                       WHT_BinSplit.minSize\n#F                       WHT_DDL.minSize\n#F\n#F WHT_GeneralSplit is a generalization of BinSplit, so it only makes\n#F sense to have WHT_BinSplit.minSize := WHT_GeneralSplit.maxSize + 1\n#F (not to have 2 rules enabled at the same time)\n#F\n#F By default, WHT_GeneralSplit is disabled.\n#\nClass(WHT, TaggedNonTerminal, rec(\n  abbrevs   := [ n -> Checked(IsPosInt(n), [n]) ],\n  dims      := self >> let(size := 2^self.params[1], [size, size]),\n  terminate := self >> When(self.params[1] = 1, F(2), Tensor(Replicate(self.params[1], F(2)))),\n  transpose := self >> Copy(self),\n  isReal    := self >> true,\n  SmallRandom := () -> Random([2..5]),\n  LargeRandom := () -> Random([6..15]),\n  normalizedArithCost := self >> self.params[1]*2^self.params[1],\n  TType := T_Real(64)\n));\n\n# NOTE: A lot of WHT rules were moved to paradigms/common/wht.g, UGLY!\n#\nNewRulesFor(WHT, rec(\n    #F WHT_Base: WHT_(2^1) = F_2\n    #F\n    WHT_Base := rec(\n        info             := \"WHT_(2^1) -> F_2\",\n        forTransposition := false,\n        applicable       := (self, nt) >> nt.params[1]=1 and not nt.hasTags(),\n        apply            := (nt, c, cnt) -> F(2),\n    ),\n\n    #F WHT_Base2: WHT_(2^1) = F_2\n    # Added by Kyle 7-11-07\n    # Need a better way to represent base cases for WHT so it is not fully expanded.\n    WHT_Base2 := rec(\n        info             := \"WHT_(2^2) -> F_2\",\n        forTransposition := false,\n        switch           := false,\n        applicable       := (self, nt) >> nt.params[1]=2 and not nt.hasTags(),\n        apply            := (nt, c, cnt) -> WHT(2),\n\n    ),\n\n    #F WHT_GeneralSplit: follows from definition\n    #F\n    #F   WHT_(2^k) =\n    #F                        WHT_(2^k1) tensor I_(2^(k-k1)) *\n    #F     I_(2^k1)    tensor WHT_(2^k2) tensor I_(2^(k-k1-k2)) *\n    #F       ...\n    #F       ...\n    #F     I_(2^(k-kr)) tensor WHT_(2^kr)\n    #F\n    #F This rule has been restricted to small sizes\n    #F\n    WHT_GeneralSplit := rec (\n        info             := \"WHT_(2^k) -> (WHT_(2^k1) tensor I) .. (I tensor WHT_(2^kr))\",\n        forTransposition := false,\n        switch           := false,\n        maxSize          := 7,\n        applicable       := (self, nt) >> nt.params[1] <> 1 and nt.params[1] <= self.maxSize,\n\n        children := nt -> let(C := DropLast(OrderedPartitions(nt.params[1]), 1),\n            List(C, p -> List(p, WHT))),\n\n        # MRT 10-2007: .randomChildren does appear to be called in a certain case during RandomRuleTree()\n        # but is it necessary? It only appears here!\n        randomChildren := function ( Pin )\n            local C, sum, rand, P;\n            P := Pin[1];\n            C := [];\n            sum := 0;\n            while sum < P do\n                if sum = 0 then  rand := RandomList( [1..(P-1)] );\n                else             rand := RandomList( [1..(P-sum)] );\n                fi;\n                Add( C, rand );\n                sum := sum + rand;\n            od;\n            When(not (Sum(C)=P and Length(C) > 1),\n                Error( \"WHT_GeneralSplit.randomChildren has a bug\"));\n            return List(C, WHT);\n        end,\n\n        rule := function ( P, C )\n            local P, left, right, i;\n            right := 2^P / C[1].dimensions[1];\n            left  := 1;\n            P := [ Tensor(C[1], I(right)) ];\n\n            # list of factors\n            for i in [2..Length(C)-1] do\n                left  := left * C[i-1].dimensions[1];\n                right := right/C[i].dimensions[1];\n                Add(P, Tensor(I(left), C[i], I(right)));\n            od;\n            left := left * C[Length(C)-1].dimensions[1];\n            Add(P, Tensor(I(left), C[Length(C)]));\n        \n            return Compose(P); # return product\n        end\n    ),\n\n    WHT_BinSplit_binloops := rec (\n        info             := \"WHT_(2^k) -> (WHT_(2^k1) tensor I) (I tensor WHT_(2^k2))\",\n        forTransposition := false,\n        minSize          := 2,\n        applicable       := (self, nt) >> nt.params[1] >= self.minSize and not nt.hasTags(),\n\n        children := nt -> List([1..nt.params[1]-1], i -> [ WHT(i), WHT(nt.params[1]-i) ] ),\n\n        apply := function(nt, c, cnt)\n            local r1, r2, a, i, b;\n\n            r1 := Rows(c[1]);\n            r2 := Rows(c[2]);\n\n            a := c[1];\n            for i in [1..Log2Int(r2)] do\n                a := Grp(Tensor(I(2), a));\n            od;\n            a := Grp(L(r1 * r2, r1) * a * L(r1 * r2, r2));\n\n            b := c[2];\n            for i in [1..Log2Int(r1)] do\n                b := Grp(Tensor(I(2), b));\n            od;\n\n            return a * b;\n        end,\n\n        switch := true,\n    )\n));\n", "meta": {"hexsha": "72d1c0bfba2237846ff47d51e27185a690138ff3", "size": 5050, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/wht/wht.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/wht/wht.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/wht/wht.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 34.1216216216, "max_line_length": 105, "alphanum_fraction": 0.483960396, "num_tokens": 1539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430645886583, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4988423922459654}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n########################################################################\n#   (A x B) rules\nNewRulesFor(TTensor, rec(\n#   (A x B) -> L (B x I)(L(A x I))\n    splitL_BxI__L_AxI := rec(\n        info := \"(A x B) -> L (B x I)(L(A x I))\",\n        forTransposition := false,\n        applicable := nt -> let(P := nt.params,\n            Rows(P[1]) = Cols(P[1])\n            and Rows(P[2]) = Cols(P[2])\n        ),\n        children := nt -> let(P := nt.params,\n            [[TCompose([TTensorI(P[2], P[1].dims()[1], AVec, AVec), TTensorI(P[1], P[2].dims()[2], APar, AVec)]).withTags(nt.getTags())]]\n        ),\n        apply := (t, C, nt) -> let(\n            p:=nt[1].params[1][1],\n            mn := Rows(nt[1]),\n            n := p.params[2],\n            DelayedPrm(L(mn, n)) * C[1]\n        )\n\n#D        isApplicable := P -> Rows(P[1]) = Cols(P[1]) and Rows(P[2]) = Cols(P[2]),\n#D        allChildren := P -> [[TCompose([TTensorI(P[2], P[1].dims()[1], AVec, AVec), TTensorI(P[1], P[2].dims()[2], APar, AVec)], P[3])]],\n#D        rule := (P, C, nt) -> let(p:=nt[1].params[1][1], mn := Rows(nt[1]), n := p.params[2], DelayedPrm(L(mn, n)) * C[1])\n    ),\n#   (A x B) -> ((A x I)L)(B x I) L\n    AxI_L__BxI_splitL := rec(\n        info := \"(A x B) -> ((A x I)L)(B x I) L\",\n        forTransposition := false,\n\n        applicable := nt -> let(P := nt.params,\n            Rows(P[1]) = Cols(P[1])\n            and Rows(P[2]) = Cols(P[2])\n        ),\n\n        children := nt -> let(P := nt.params,\n            [[TCompose([TTensorI(P[1], P[2].dims()[1], AVec, APar), TTensorI(P[2], P[1].dims()[2], AVec, AVec)]).withTags(nt.getTags())]]\n        ),\n\n        apply := (t, C, nt) -> let(\n            p := nt[1].params[1][1],\n            mn := Rows(nt[1]),\n            n := Rows(p.params[1]),\n            C[1] * DelayedPrm(L(mn, n))\n        )\n#D        isApplicable := P -> Rows(P[1]) = Cols(P[1]) and Rows(P[2]) = Cols(P[2]),\n#D        allChildren := P -> [[TCompose([TTensorI(P[1], P[2].dims()[1], AVec, APar), TTensorI(P[2], P[1].dims()[2], AVec, AVec)], P[3])]],\n#D        rule := (P, C, nt) -> let(p:=nt[1].params[1][1], mn := Rows(nt[1]), n := Rows(p.params[1]), C[1] * DelayedPrm(L(mn, n)))\n    ),\n));\n", "meta": {"hexsha": "9af6702c8387d6fe697989ec5bd757538b5affdb", "size": 2258, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/vector/breakdown/ttensor.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/vector/breakdown/ttensor.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/vector/breakdown/ttensor.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": 40.3214285714, "max_line_length": 139, "alphanum_fraction": 0.4379982285, "num_tokens": 803, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.782662489091802, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.4985801018428417}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nImportAll(spiral);\n\nSkewRDFT := BSkewPRDFT;\nBRDFT := PolyBDFT;\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 -> Cond(IsOddInt(n), \n    DirectSum(I(1), List([1..(n-1)/2], i-> Mat(time_r(i/n)))),\n    DirectSum(I(1), List([1..n/2-1], i-> Mat(time_r(i/n))), I(1)));\n\nRDFT1 := SymFunc(\"RDFT1\", n -> Cond(\n\tn=2,F(2), \n\tIsEvenInt(n), VStack(Gath(H(n+2,1,0,1)), Gath(H(n+2,n-2,2,1)), Gath(H(n+2,1,n,1))) * PRDFT1(n),\n\tIsOddInt(n), VStack(Gath(H(n+1,1,0,1)), Gath(H(n+1,n-1,2,1))) * PRDFT1(n)));\n\nRDFT3 := SymFunc(\"RDFT3\", n -> Cond(\n\tn=2,I(2), \n\tIsEvenInt(n), PRDFT3(n),\n\tIsOddInt(n), VStack(Gath(H(n+1,n-1,0,1)), Gath(H(n+1,1,n-1,1))) * PRDFT3(n)));\n\nBRDFT1 := SymFunc(\"BRDFT1\", n -> B1_time_r(n) * RDFT1(n));\n \nrdft1 := (k,m) -> \n   Perm(PermFunc(rP(2*k*m, 2*k), 2*k*m), 2*k*m).transpose() * \n   DirectSum(RDFT1(m), List([1..k-1], i->Mat(MatrDFT(2*m,i/(2*k)))), RDFT3(m)) * \n   Tensor(RDFT1(2*k), I(m)); \n\nrdft1odd := (k,m) -> \n   Perm(PermFunc(rPhat((2*k-1)*m, 2*k-1), (2*k-1)*m), (2*k-1)*m).transpose() * \n   DirectSum(RDFT1(m), List([1..k-1], i->Mat(MatrDFT(2*m,i/(2*k-1))))) * \n   Tensor(RDFT1(2*k-1), I(m)); \n\ntest_rdft1 := (k,m) -> PrintLine(inf_norm(MatSPL(rdft1(k,m)) - MatSPL(RDFT1(2*k*m))));\ntest_rdft1odd := (k,m) -> PrintLine(inf_norm(MatSPL(rdft1odd(k,m)) - MatSPL(RDFT1((2*k-1)*m))));\ndo_test_rdft1 := function()\n   test_rdft1(4,4);\n   test_rdft1(4,8);\n   test_rdft1(6,8);\n   test_rdft1(6,2);\n   test_rdft1(6,5);\n   test_rdft1(11,5);\nend;\ndo_test_rdft1odd := function()\n   test_rdft1odd(4,4);\n   test_rdft1odd(4,8);\n   test_rdft1odd(6,8);\n   test_rdft1odd(6,2);\n   test_rdft1odd(6,5);\n   test_rdft1odd(5,5);\n   test_rdft1odd(11,5);\nend;\n\nrdft3 := (k,m) -> \n   RC(K(k*m, m)) *\n   DirectSum(List([0..k-1], i->Mat(MatrDFT(2*m,(i+1/2)/(2*k))))) * #alphai(k,i,1/4))))) *\n   Tensor(RDFT3(2*k),I(m));\n\nrdft3odd := (k,m) -> \n   Perm(PermFunc(rQhat((2*k-1)*m, 2*k-1), (2*k-1)*m), (2*k-1)*m).transpose() * \n   DirectSum(List([0..k-2], i->Mat(MatrDFT(2*m,(i+1/2)/(2*k-1)))), RDFT3(m)) * #alphai(k,i,1/4))))) *\n   Tensor(RDFT3(2*k-1),I(m));\n\ntest_rdft3 := (k,m) -> PrintLine(inf_norm(MatSPL(rdft3(k,m)) - MatSPL(RDFT3(2*k*m))));\ntest_rdft3odd := (k,m) -> PrintLine(inf_norm(MatSPL(rdft3odd(k,m)) - MatSPL(RDFT3((2*k-1)*m))));\ndo_test_rdft3 := function()\n   test_rdft3(4,4);\n   test_rdft3(4,8);\n   test_rdft3(6,8);\n   test_rdft3(6,2);\n   test_rdft3(6,5);\n   test_rdft3(11,5);\nend;\ndo_test_rdft3odd := function()\n   test_rdft3odd(4,4);\n   test_rdft3odd(4,8);\n   test_rdft3odd(6,8);\n   test_rdft3odd(6,2);\n   test_rdft3odd(6,5);\n   test_rdft3odd(5,5);\n   test_rdft3odd(11,5);\nend;\n\nrrdft := (k,m,a) -> \n   RC(K(k*m, m)) *\n   DirectSum(List([0..k-1], i->Mat(MatrDFT(2*m,(i+a)/(2*k))))) *\n   Tensor(Mat(MatrDFT(2*k,a)),I(m));\n\nbrdft := (k,m,a) -> \n   RC(K(k*m, m)) *\n   DirectSum(List([0..k-1], i->BRDFT(2*m,alphai(k,i,a)))) * \n   Tensor(BRDFT(2*k, a), I(m));\n\nbruun_rdft3 := (k,m) -> \n   RC(K(k*m, m)) *\n   DirectSum(List([0..k-1], i->SkewRDFT(2*m,alphai(k,i,a)))) * \n   Tensor(BRDFT(2*k,1/4),I(m));\n\nbruun_rdft1 := (k,m) -> \n   DirectSum(RDFT1(m), List([1..k-1], i->SkewRDFT(2*m,i/(2*k))), RDFT3(m)) * \n   Tensor(BRDFT1(2*k), I(m)); \n\nrcred := mat -> List(mat{[0..Length(mat)/2-1]*2+1}, row -> row{[0..Length(row)/2-1]*2+1});\n", "meta": {"hexsha": "56f84d91ca4828356f3e038eeffb13b9c823e30a", "size": 3503, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sym/rft/rftalg.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/sym/rft/rftalg.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/sym/rft/rftalg.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.4608695652, "max_line_length": 101, "alphanum_fraction": 0.5555238367, "num_tokens": 1608, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104788995148792, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.49851572824362855}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\nClass(InterpolateDFT, TaggedNonTerminal, rec(\n    abbrevs := [ (dsfunc,usfunc) -> [dsfunc, usfunc] ],\n    dims      := self >> [self.params[1].domain(), self.params[2].domain()],\n    terminate := self >> let(n:=self.params[2].domain(), N := self.params[1].range(), \n        Downsample(self.params[1]).terminate() * \n        DFT(N, 1).terminate() * \n        Upsample(self.params[2]).terminate() *\n        Scale(1/n, DFT(n, -1).terminate())),\n    isReal    := False,\n    normalizedArithCost := self >> let(n:=self.params[2].domain(), N := self.params[1].range(), \n        n + IntDouble(5 * n * d_log(n) / d_log(2)) + IntDouble(5 * N * d_log(N) / d_log(2))),\n    TType := T_Complex(T_Real(64))\n));\n\n\nNewRulesFor(InterpolateDFT, rec(\n    InterpolateDFT_base := rec(\n        applicable := (self, nt) >> not nt.hasTags(),\n        children := nt -> let(n:=nt.params[2].domain(), N := nt.params[1].range(), \n            [[ Downsample(nt.params[1]), DFT(N, 1), Upsample(nt.params[2]), DFT(n, -1) ]]),\n        apply := (nt, C, cnt) -> C[1] * C[2] * C[3] * Scale(1/nt.params[2].domain(), C[4]) \n    ),\n    InterpolateDFT_PrunedDFT := rec(\n        applicable := (self, nt) >> not nt.hasTags() and ObjId(nt.params[2]) = fZeroPadMiddle,\n        children := nt -> let(n:=nt.params[2].domain(), N := nt.params[1].range(), us := N/n, blk := n/2, \n            [[ PrunedDFT(N, 1, blk, [0, 2*us-1]), DFT(n, -1) ]]),\n        apply := (nt, C, cnt) -> let(n:=nt.params[2].domain(), N := nt.params[1].range(), us := N/n, blk := n/2,\n                Gath(nt.params[1]) * C[1] * Scale(1/n, C[2]) \n       )\n    )\n));\n\n\n\n", "meta": {"hexsha": "4a83bb5538e11cba1e724887f66f6ef7f2d02ad0", "size": 1675, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/interpolate/dft.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/transforms/interpolate/dft.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/transforms/interpolate/dft.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 42.9487179487, "max_line_length": 112, "alphanum_fraction": 0.5420895522, "num_tokens": 555, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324983301568, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4984184535226119}}
{"text": "\n\nhandle:=function(alg)\n    local orbs,centralizers,centres;\n    orbs:=UnipotentClasses(alg,\"\");\n    centralizers:=List(Classes(orbs),i->UnipotentCentralizer(BorelRep(i)));\n\n    return centralizers;\nend;\n\nhandleClass:=function(orb)\n    local rep,dist_par,co_dist_par,centralizer,center,sys,w,decomp,supp_roots,\n    in_borel,not_in_borel,k,\n    p,dimensions;\n\n    Print(Label(orb),\"\\n\");\n#    orb:=Classes(orbs)[i];\n    dist_par:=DistinguishedParabolic(orb);\n    rep:=BorelRep(orb);\n    centralizer:=UnipotentCentralizer(rep);\n    center:=Zentrum(centralizer[1]);\n    sys:=chevalleyAdj(rep);\n    w:=Witt(LogInt(Order(rep),Characteristic(sys)),sys);\n    decomp:=WittDecomposition(center,w);\n    supp_roots:=List(decomp,i->List(coefficients(i),j->j[1]));\n    dist_par:=ToPositiveBorel(orb,0Level(dist_par));\n    co_dist_par:=Filtered([1..Length(positiveRoots(sys))],i->not i in dist_par);\n\n    in_borel:=[];\n    not_in_borel:=[];\n    for k in [1..Length(decomp)] do\n        if IsSubset(dist_par,supp_roots[k]) then Add(in_borel,k);\n        elif IsSubset(co_dist_par,supp_roots[k]) then Add(not_in_borel,k);\n        else Print(\"handleClass: the centre is skew !!!\\n\"); fi;\n    od;\n\n    #p:=Characteristic(sys);\n\n    return [centralizer,center,decomp,[in_borel,not_in_borel],dist_par];\nend;\n\nhandleClassShort:=function(orb)\n    local rep,dist_par,co_dist_par,centralizer,center,sys,w,decomp,supp_roots,\n    in_borel,not_in_borel,k,\n    p,dimensions;\n\n    Print(Label(orb),\"\\n\");\n#    orb:=Classes(orbs)[i];\n    dist_par:=DistinguishedParabolic(orb);\n    rep:=BorelRep(orb);\n    centralizer:=UnipotentCentralizer(rep);\n    center:=Zentrum(centralizer[1]);\n\n    decomp:=ParameterPieces(center);\n    sys:=chevalleyAdj(rep);\n    supp_roots:=List(decomp,i->List(coefficients(i),j->j[1]));\n    dist_par:=ToPositiveBorel(orb,0Level(dist_par));\n    co_dist_par:=Filtered([1..Length(positiveRoots(sys))],i->not i in dist_par);\n\n    #in_borel:=[];\n    #not_in_borel:=[];\n    #Error(\"1\");\n    for k in [1..Length(decomp)] do\n        if not IsSubset(dist_par,supp_roots[k]) and not IsSubset(co_dist_par,supp_roots[k]) then\n            Print(\"handleClass: the centre is skew !!!\\n\");\n        fi;\n    od;\n\n    return [centralizer[1],Subword(center,dist_par),center];\n#    return [Dimension(centralizer[1]),Dimension(Subword(center,dist_par))];\nend;\n\n\n\nhandleClassesShort:=function(orb)\n    local o,info,fis_tmp;\n    \n    fis_tmp:=Concatenation(\"~/Workspace/ChevalleyAdj/short\",String(Characteristic(algebraicU(orb))),\".txt\");\n\n    PrintTo(fis_tmp,\"\");\n\n    for o in Classes(orb) do\n        Print(Label(o),\"\\n\");\n        info:=handleClassShort(o);\n        latexClassShort(o,info);\n        #AppendTo(fis_tmp,Label(o),\" \",info[1],\" \",info[2],\"\\n\");\n    od;\nend;\n\n\n\n\n#-------------------------------------------------------------------------------\n\n\n\n#\"reflect unipotent element by w_root's: w_r*x_s*w_r^-1\",\nApplyRootsReflections:=function(u,roots)\n              local result,\n              sys,perm_mat,R,pr,eta,W,ref_mats,ref_mat,root,sign,i,coeffs,check;\n\n              sys:=chevalleyAdj(u);\n              #R:=rootSystem(chevalleyAdj(u));\n              pr:=positiveRoots(sys);\n              #eta:=Eta(R);\n              #W:=weylGroup(sys);\n              #ref_mats:=RootReflections(W);\n              #ref_mat:=Product(ref_mats{roots});\n              #perm_matrix:=Inverse(PermutationMatrix(weylGroup(sys),perm));\n\n              #??perm_mat:=Inverse(PermutationMatrix(weylGroup(sys),roots)); ? De ce am inversat aiciasta?\n              perm_mat:=PermutationMatrix(weylGroup(sys),roots);\n\n              result:=[];\n              coeffs:=coefficients(u);\n              for i in coeffs do\n                  root:=Position(pr,pr[i[1]]*perm_mat);\n                  sign:=PermutationSign(sys,roots,i[1]);\n                  result:=Concatenation(result,[[root,sign*i[2]]]);\n              od;\n#              result:=List([1..Length(result)],i->[Position(pr,ref_mats[root]*pr[result[i][1]]),\n#                                                   eta[root][result[i][1]]*result[i][2]]);\n\n#return result;\n\n              check:=[];\n              for i in [1..Length(result)] do\n                  if result[i][1]=fail then\n                      check:=Concatenation(check,[coeffs[i][1]]);\n                  fi;\n              od;\n\n              if check<>[] then return Concatenation(String(check),\" nu ramane pozitiv\\n\");\n              else\n                  result:=Unipotent(sys,result,Ordering(u));\n                  if HasOrder(u) then SetOrder(result,Order(u)); fi;\n                  return result;\n              fi;\nend;\n\nConjugateByTorus:=function(u,root,t)\n    local result,coeffs,sys,A_rs;\n    sys:=chevalleyAdj(u);\n    A_rs:=A(sys);\n    coeffs:=coefficients(u);\n    coeffs:=List([1..Length(coeffs)],i->[coeffs[i][1],t^A_rs[root][coeffs[i][1]]*coeffs[i][2]]);\n    result:=Unipotent(sys,coeffs,Ordering(u));\n    if HasOrder(u) then SetOrder(result,Order(u)); fi;\n    return result;\nend;\n\nConjugateByTori:=function(u,roots,ts)\n    local result,coeffs,sys,A_rs,j;\n    sys:=chevalleyAdj(u);\n    A_rs:=A(sys);\n    coeffs:=coefficients(u);\n    for j in [1..Length(roots)] do\n        coeffs:=List([1..Length(coeffs)],i->[coeffs[i][1],ts[j]^A_rs[roots[j]][coeffs[i][1]]*coeffs[i][2]]);\n    od;\n    result:=Unipotent(sys,coeffs,Ordering(u));\n    if HasOrder(u) then SetOrder(result,Order(u)); fi;\n    return result;\nend;\n\nTorusWeight:=function(u,root)\n    local result,coeffs,sys,A_rs;\n    sys:=chevalleyAdj(u);\n    A_rs:=A(sys);\n    coeffs:=coefficients(u);\n    result:=List([1..Length(coeffs)],i->A_rs[root][coeffs[i][1]]);#???\n    return result;\nend;\n\nTorusWeight:=function(sys,ts,root)\n    local result,A_rs,i;\n    A_rs:=A(sys);\n    result:=List([1..Length(ts)],i->A_rs[ts[i]][root]);\n#    result:=[];\n#    for i in [1..Length(ts)] do\n#        if ts[i]=0 then Add(result,0);\n#        else Add(result,A_rs[ts[i]][root]); #Add(result,A_rs[ts[i]][root]);\n#        fi;\n#    od;\n    return result;\nend;\n\nTorusWeights:=function(ts_pow,u)\n    local result,u_roots,sys,r,ts;\n    sys:=chevalleyAdj(u);\n    u_roots:=List(coefficients(u),i->i[1]);\n    ts:=Concatenation(List([1..Length(ts_pow)],i->List([1..ts_pow[i]],j->i)));\n    Print(ts);\n\n    result:=[];\n    for r in u_roots do\n        #Add(result,List([1..Length(roots)],i->A_rs[roots[i]][coeffs[j][1]])); !!! gresit\n        Add(result,TorusWeight(sys,ts,r));\n    od;\n    return result;\nend;\n\nSubsystem:=function(u)\n    local result,roots,flag,i,j,pos,AA;\n\n    roots:=allRoots(chevalleyAdj(u));\n    AA:=A(chevalleyAdj(u));\n    result:=List(coefficients(u),i->roots[i[1]]);\n    result:=Concatenation(result,-result);\n    result:=List(result,i->Position(roots,i));\n\n    flag:=true;\n    while flag do\n        flag:=false;\n        for i in result do\n            for j in result do\n                pos:=Position(roots,roots[i]+roots[j]);\n                if pos<>fail and not pos in result then #and AA[i][j]<> 0 then\n                    Add(result,pos);\n                    flag:=true;\n                fi;\n#                pos:=Position(roots,roots[i]-roots[j]);\n#                if pos<>fail and not pos in result then\n#                    Add(result,pos);\n#                    flag:=true;\n#                fi;\n            od;\n        od;\n    od;\n\n    return result;\nend;\n\n\nConjNegUa:=function(u,root,t)\n    local result,Cijrs,sys,neg_root,roots,\n    suma,param,k,i,cc;\n\n    sys:=chevalleyAdj(u);\n    Cijrs:=C(sys);\n    neg_root:=root+Length(positiveRoots(sys));\n    roots:=allRoots(sys);\n\n    result:=ShallowCopy(coefficients(u));\n    i:=1;\n    #for i in [1..Length(result)] do\n    while i<=Length(result) do\n        #aici r si s sunt neg_root si repsectiv i\n        k:=1;\n        if Cijrs[neg_root][result[i][1]]=fail then return fail; fi;\n        \n        for cc in Cijrs[neg_root][result[i][1]] do\n            suma:=cc[1]*roots[neg_root]+cc[2]*roots[result[i][1]];\n            param:=cc[3]*((-1)^cc[1])*(t^cc[1])*(result[i][2]^cc[2]);\n            Add(result,[Position(roots,suma),param],i+k);\n            k:=k+1;\n        od;\n        i:=i+k;\n    od;\n\n#    Print(result,\"\\n\");\n    result:=Unipotent(sys,result,Ordering(u));\n    return result;\nend;\n\n#-------------------------------------------------------------------------------\n\n\n\nCoroot:=function(R,root)\n    local bil,pr;\n    pr:=positiveRoots(R);\n    bil:=BilinearFormMat(R);\n    return 2*pr[root]/(pr[root]*bil*pr[root]);\nend;\n\nInFundamentalChamber:=function(R,roots)\n    local result,\n    pr,r,bil,rang,fs,a,flag;\n    \n    pr:=positiveRoots(R);\n    bil:=BilinearFormMat(R);\n    rang:=Length(CanonicalGenerators(R)[1]);\n    fs:=pr{[1..rang]};\n    \n    result:=[];\n    for r in roots do\n        flag:=true;\n        for a in fs do\n        if a*bil*r<0 then flag:=false; fi;\n        od;\n        if flag then Add(result,r); fi;\n    od;\n\n    return result;\nend;\n", "meta": {"hexsha": "03a42d913b1667d9c04b1d4101332a6dd3a9aa58", "size": 8823, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "handle.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": "handle.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": "handle.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": 29.8074324324, "max_line_length": 108, "alphanum_fraction": 0.5746344781, "num_tokens": 2528, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388252252041, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.49751943343899707}}
{"text": "#############################################################################\n##\n#W  treeaut.gi                 automgrp package                Yevgen Muntyan\n#W                                                             Dmytro Savchuk\n##\n#Y  Copyright (C) 2003 - 2018 Yevgen Muntyan, Dmytro Savchuk\n##\n\n\n###############################################################################\n##\n#R  IsTreeAutomorphismRep\n##\n## XXX remove it, use IsTreeHomomorphismRep\nDeclareRepresentation(\"IsTreeAutomorphismRep\",\n                      IsComponentObjectRep and IsAttributeStoringRep,\n                      [\"states\", \"perm\", \"deg\"]);\n\n\n###############################################################################\n##\n#R  IsTreeAutomorphismFamilyRep\n##\nDeclareRepresentation(\"IsTreeAutomorphismFamilyRep\",\n                      IsComponentObjectRep and IsAttributeStoringRep,\n                      [\"spher_index\"]);\n\n\n###############################################################################\n##\n##  AG_CreatedTreeAutomorphismFamilies\n##\nBindGlobal(\"AG_CreatedTreeAutomorphismFamilies\", []);\n\n\n###############################################################################\n##\n#M  TreeAutomorphismFamily(<sph_ind>)\n##\nInstallMethod(TreeAutomorphismFamily, [IsRecord],\nfunction(sph_ind)\n  local p, red_ind, fam;\n  red_ind := AG_ReducedSphericalIndex(sph_ind);\n  for p in AG_CreatedTreeAutomorphismFamilies do\n    if p[1] = red_ind then\n      return p[2]; fi;\n  od;\n  fam := NewFamily( Concatenation(\"Automorphisms of \",\n                      red_ind.start, \", (\", red_ind.period, \")-tree\"),\n                    IsTreeAutomorphism,\n                    IsTreeAutomorphism,\n                    IsTreeAutomorphismFamily and IsTreeAutomorphismFamilyRep);\n  fam!.spher_index := red_ind;\n  AddSet(AG_CreatedTreeAutomorphismFamilies, [red_ind, fam]);\n  return fam;\nend);\n\n\nBindGlobal(\"AG_TreeAutomorphism\",\nfunction(list_states, permutation)\n  local top_deg, bot_deg, ind, fam, s, Orbs, orb;\n\n  if Length(list_states)=0 then\n    Error(\"The list of states can not be empty\");\n  fi;\n\n  top_deg := Length(list_states);\n  if not IsOne(permutation) and\n      top_deg < Maximum(MovedPoints(permutation)) then\n    Error(\"The root permutation \", permutation, \" must move only points from 1 to the degree \", top_deg, \" of the tree\");\n  fi;\n\n  Orbs := OrbitsPerms([permutation], [1..Length(list_states)]);\n\n  for orb in Orbs do\n    for s in [2..Length(orb)] do\n      if list_states[orb[s]]!.deg<>list_states[orb[1]]!.deg then\n        Error(\"Sections in one orbit are acting on different trees\");\n      fi;\n    od;\n  od;\n\n  bot_deg := DegreeOfTree(list_states[1]);\n  ind := rec(start := [top_deg], period := [bot_deg]);\n  fam := TreeAutomorphismFamily(ind);\n\n  return Objectify( NewType(fam, IsTreeAutomorphism and IsTreeAutomorphismRep),\n                    rec(states := list_states,\n                        perm := permutation,\n                        deg := top_deg));\nend);\n\n###############################################################################\n##\n#M  TreeAutomorphism(<states_list>, <perm>)\n##\nInstallMethod(TreeAutomorphism, \"for [IsList, IsPerm]\", [IsList, IsPerm],\nfunction(states, perm)\n  local autom, nstates, s;\n\n  autom := fail;\n\n  for s in states do\n    if IsTreeAutomorphism(s) then\n      autom := s;\n    elif not IsOne(s) then\n      Error(\"Invalid state `\", s, \"'\");\n    fi;\n  od;\n\n  if autom = fail then\n    # XXX homogenous tree, stupid!\n    Error(\"Can't create an automaton with all trivial states \",\n          \"without information about the tree\");\n  fi;\n\n\n  nstates := List(states, function(x)\n                            if IsInt(x) and IsOne(x) then\n                              return One(autom);\n                            else\n                              return x;\n                            fi;\n                          end);\n\n  return AG_TreeAutomorphism(nstates, perm);\nend);\n\n\n###############################################################################\n##\n#M  TreeAutomorphism(<state_1>, <state_2>, ..., <state_n>, <perm>)\n##\nInstallMethod(TreeAutomorphism, [IsObject, IsObject, IsPerm],\n  function(a1, a2, perm) return TreeAutomorphism([a1, a2], perm); end);\nInstallMethod(TreeAutomorphism, [IsObject, IsObject, IsObject, IsPerm],\n  function(a1, a2, a3, perm) return TreeAutomorphism([a1, a2, a3], perm); end);\nInstallMethod(TreeAutomorphism, [IsObject, IsObject, IsObject, IsObject, IsPerm],\n  function(a1, a2, a3, a4, perm) return TreeAutomorphism([a1, a2, a3, a4], perm); end);\nInstallMethod(TreeAutomorphism, [IsObject, IsObject, IsObject, IsObject, IsObject, IsPerm],\n  function(a1, a2, a3, a4, a5, perm) return TreeAutomorphism([a1, a2, a3, a4, a5], perm); end);\n#InstallMethod(TreeAutomorphism, [IsObject, IsObject, IsObject, IsObject, IsObject, IsObject, IsPerm],\n#  function(a1, a2, a3, a4, a5, a6, perm) return TreeAutomorphism([a1, a2, a3, a4, a5, a6], perm); end);\n\n\n###############################################################################\n##\n#M  ViewObj(<a>)\n##\nInstallMethod(ViewObj, [IsTreeAutomorphism],\nfunction (a)\n    local deg, printword, i;\n\n    deg := AG_TopDegreeInSphericalIndex(FamilyObj(a)!.spher_index);\n    Print(\"(\");\n    for i in [1..deg] do\n        View(a!.states[i]);\n        if i <> deg then Print(\", \"); fi;\n    od;\n    Print(\")\");\n    if not IsOne(a!.perm) then Print(a!.perm); fi;\nend);\n\n\n###############################################################################\n##\n#M  PrintObj(<a>)\n##\nInstallMethod(PrintObj, \"for [IsTreeAutomorphism and IsTreeAutomorphismRep]\",\n                             [IsTreeAutomorphism and IsTreeAutomorphismRep],\nfunction (a)\n    local deg, printword, i;\n\n    deg := AG_TopDegreeInSphericalIndex(FamilyObj(a)!.spher_index);\n    Print(\"(\");\n    for i in [1..deg] do\n      if IsAutom(a!.states[i]) then\n        View(a!.states[i]);\n      else\n        Print(a!.states[i]);\n      fi;\n      if i <> deg then Print(\", \"); fi;\n    od;\n    Print(\")\");\n    if not IsOne(a!.perm) then Print(a!.perm); fi;\nend);\n\n\n###############################################################################\n##\n#M  String(<a>)\n##\nInstallMethod(String, \"for [IsTreeAutomorphism]\", [IsTreeAutomorphism],\nfunction (a)\n    local deg, printword, i, perm, states, str;\n\n    states := Sections(a);\n    deg := Length(states);\n    perm := PermOnLevel(a, 1);\n    str:= \"(\";\n\n    for i in [1..deg] do\n        Append(str, String(states[i]));\n        if i <> deg then Append(str, \", \"); fi;\n    od;\n    Append(str, \")\");\n    if not IsOne(perm) then\n      Append(str, AG_TransformationString(perm));\n    fi;\n    return str;\nend);\n\n\n###############################################################################\n##\n#M  SphericalIndex(<a>)\n##\nInstallMethod(SphericalIndex, [IsTreeAutomorphism and IsTreeAutomorphismRep],\nfunction(a)\n  return FamilyObj(a)!.spher_index;\nend);\n\n\n###############################################################################\n##\n#M  Perm(<a>)\n##\nInstallMethod(Perm, \"for [IsTreeAutomorphism and IsTreeAutomorphismRep]\",\n              [IsTreeAutomorphism and IsTreeAutomorphismRep],\nfunction(a)\n  return a!.perm;\nend);\n\n\n###############################################################################\n##\n#M  Perm (<a>, <k>)\n##\nInstallMethod(Perm, \"for [IsTreeAutomorphism, IsPosInt]\",\n              [IsTreeAutomorphism, IsPosInt],\nfunction(a, k)\n  return PermOnLevel(a, k);\nend);\n\n\n###############################################################################\n##\n#M  PermOnLevel (<a>, <k>)\n##\nInstallMethod(PermOnLevelOp, \"for [IsTreeAutomorphism, IsPosInt]\",\n              [IsTreeAutomorphism, IsPosInt],\nfunction(a, k)\n  local states, top, first_level, i, j, d1, d2, permuted, p;\n\n  if k = 1 then\n    return Perm(a);\n  fi;\n\n  # XXX test this function\n\n  # TODO: it goes through all vertices of the second level, it may be\n  # unnecessary for sparse actions\n  d1 := a!.deg;\n  d2 := 1;\n  for i in [2 .. k] do\n    d2 := d2 * DegreeOfLevel(a, i);\n  od;\n  states := Sections(a);\n  top := Perm(a);\n  first_level := List(states, s -> PermOnLevel(s, k-1));\n  permuted := [];\n  for i in [1..d1] do\n    for j in [1..d2] do\n      permuted[d2*(i-1) + j] := d2*(i^top - 1) + j^first_level[i];\n    od;\n  od;\n\n  p := PermList(permuted);\n  if p<>fail then\n    return p;\n  else\n    Error(\"An element \",a,\" does not induce a permutation on the level \",k);\n  fi;\nend);\n\n\n###############################################################################\n##\n#M  k ^ a\n##\nInstallMethod(\\^, \"for [IsPosInt, IsTreeAutomorphism]\",\n                   [IsPosInt, IsTreeAutomorphism],\nfunction(k, a)\n    return k ^ Perm(a);\nend);\n\n\n###############################################################################\n##\n#M  seq ^ a\n##\nInstallMethod(\\^, \"for [IsList, IsTreeAutomorphism]\",\n                   [IsList, IsTreeAutomorphism],\nfunction(seq, a)\n  if Length(seq) = 0 then return []; fi;\n  if Length(seq) = 1 then return [seq[1]^Perm(a)]; fi;\n  return Concatenation([seq[1]^Perm(a)], seq{[2..Length(seq)]}^Section(a, seq[1]));\nend);\n\n\n###############################################################################\n##\n#M  FixesLevel(<a>, <k>)\n##\nInstallMethod(FixesLevel, \"for [IsTreeAutomorphism, IsPosInt]\",\n              [IsTreeAutomorphism, IsPosInt],\nfunction(a, k)\n  if HasIsSphericallyTransitive(a) then\n    if IsSphericallyTransitive(a) then\n      return false; fi; fi;\n\n  if IsOne(PermOnLevel(a, k)) then\n    Info(InfoAutomGrp, 3, \"IsSphericallyTransitive(a): false\");\n    Info(InfoAutomGrp, 3, \"  a is not transitive on level\", k);\n    Info(InfoAutomGrp, 3, \"  a = \", a);\n    SetIsSphericallyTransitive(a, false);\n    return true;\n  else\n    return false;\n  fi;\nend);\n\n\n###############################################################################\n##\n#M  FixesVertex(<a>, <v>)\n##\nInstallMethod(FixesVertex,  \"for [IsTreeAutomorphism, IsObject]\",\n                   [IsTreeAutomorphism, IsObject],\nfunction(a, v)\n  if HasIsSphericallyTransitive(a) then\n    if IsSphericallyTransitive(a) then\n      Info(InfoAutomGrp, 3, \"FixesVertex(a, v): false\");\n      Info(InfoAutomGrp, 3, \"  IsSphericallyTransitive(a)\");\n      Info(InfoAutomGrp, 3, \"  a = \", a);\n      return false;\n    fi;\n  fi;\n\n  if v^a = v then\n    Info(InfoAutomGrp, 3, \"IsSphericallyTransitive(a): false\");\n    Info(InfoAutomGrp, 3, \"  a fixes vertex \", v);\n    Info(InfoAutomGrp, 3, \"  a = \", a);\n    SetIsSphericallyTransitive(a, false);\n    return true;\n  else\n    return false;\n  fi;\nend);\n\n\n###############################################################################\n##\n#M  IsSphericallyTransitive (<a>)\n##\nInstallMethod(IsSphericallyTransitive,\n              \"for [IsTreeAutomorphism and IsActingOnBinaryTree]\",\n              [IsTreeAutomorphism and IsActingOnBinaryTree],\nfunction(a)\n  local ab;\n  Info(InfoAutomGrp, 4, \"IsSphericallyTransitive(a): using AbelImage\");\n  Info(InfoAutomGrp, 4, \"  a = \", a);\n  ab := AbelImage(a);\n  return ab = One(ab)/(One(ab)+IndeterminateOfUnivariateRationalFunction(ab));\nend);\n\nRedispatchOnCondition(IsSphericallyTransitive, true, [IsTreeAutomorphism],\n                      [IsTreeAutomorphism and IsActingOnBinaryTree], 0);\n\nInstallMethod(IsSphericallyTransitive, \"for [IsTreeAutomorphism]\",\n              [IsTreeAutomorphism],\nfunction(a)\n  if not IsTransitive(Group(PermOnLevel(a, 1)), [1..Degree(a)]) then\n    Info(InfoAutomGrp, 4, \"IsSphericallyTransitive(a): false\");\n    Info(InfoAutomGrp, 4, \"  PermOnLevel(a, 1) isn't transitive\");\n    Info(InfoAutomGrp, 4, \"  a = \", a);\n    return false;\n  fi;\n  TryNextMethod();\nend);\n\nInstallMethod(IsSphericallyTransitive,\n              \"for [IsTreeAutomorphism and HasOrder]\",\n              [IsTreeAutomorphism and HasOrder],\nfunction(a)\n  if Order(a) < infinity then\n    Info(InfoAutomGrp, 4, \"IsSphericallyTransitive(a): false\");\n    Info(InfoAutomGrp, 4, \"  Order(a) < infinity\");\n    Info(InfoAutomGrp, 4, \"  a = \", a);\n    return false;\n  fi;\n  TryNextMethod();\nend);\n\n\n###############################################################################\n##\n#M  Order (<a>)\n##\nInstallImmediateMethod(Order, IsTreeAutomorphism and HasIsSphericallyTransitive, 0,\nfunction(a)\n  if IsSphericallyTransitive(a) then return infinity; fi;\n  TryNextMethod();\nend);\n\n\n###############################################################################\n##\n#M  Order(<a>)\n##\nInstallMethod(Order, \"for [IsTreeAutomorphism]\", [IsTreeAutomorphism],\nfunction(a)\n  local i, perm, stab, stab_order, ord, exp, states;\n\n  perm := Perm(a);\n  if IsOne(perm) then\n    exp := 1;\n    stab := a;\n  else\n    exp := Order(perm);\n    stab := a^exp;\n  fi;\n\n  if IsOne(stab) then\n    return exp;\n  fi;\n\n  states := Sections(stab);\n  stab_order := 1;\n\n  for i in [1..Length(states)] do\n    ord := Order(states[i]);\n    if ord = infinity then\n      return infinity;\n    else\n      stab_order := Lcm(stab_order, ord);\n    fi;\n  od;\n\n  return exp * stab_order;\nend);\n\n\n###############################################################################\n##\n#M  Section(<a>, <k>)\n##\n\nInstallMethod(Section, [IsTreeAutomorphism and IsTreeAutomorphismRep, IsPosInt],\nfunction(a, k)\n  return a!.states[k];\nend);\n\n###############################################################################\n##\n#M  Sections(<a>)\n##\nInstallMethod(Sections, [IsTreeAutomorphism and IsTreeAutomorphismRep],\nfunction(a)\n  return a!.states;\nend);\n\n\n\n###############################################################################\n##\n#M  Decompose(<a>, <k>)\n##\nInstallMethod(Decompose, \"for [IsTreeAutomorphism, IsPosInt]\",\n              [IsTreeAutomorphism, IsPosInt],\nfunction(a, level)\n  return TreeAutomorphism(Sections(a, level), PermOnLevel(a, level));\nend);\n\n\n\n###############################################################################\n##\n#M  Decompose(<a>)\n##\nInstallMethod(Decompose, \"for [IsTreeAutomorphism]\", [IsTreeAutomorphism],\nfunction(a)\n  return Decompose(a, 1);\nend);\n\n\n###############################################################################\n##\n#M  IsOne(<a>)\n##\nInstallMethod(IsOne, \"for [IsTreeAutomorphism and IsTreeAutomorphismRep]\",\n                   [IsTreeAutomorphism and IsTreeAutomorphismRep],\nfunction(a)\n  local i;\n  if a!.perm <> () then return false; fi;\n  for i in [1..a!.deg] do\n    if not IsOne(a!.states[i]) then return false; fi;\n  od;\n  return true;\nend);\n\n\n###############################################################################\n##\n#M  IsOne(<a>)\n##\nInstallMethod(IsOne, [IsTreeAutomorphism],\nfunction(a)\n  local i;\n  if not IsOne(Perm(a)) then return false; fi;\n  for i in [1..TopDegreeOfTree(a)] do\n    if not IsOne(Section(a, i)) then return false; fi;\n  od;\n  return true;\nend);\n\n\n###############################################################################\n##\n#M  \\=(<a1>, <a2>)\n##\n# TODO: can lead to infinite recursion\nInstallMethod(\\=, \"for [IsTreeAutomorphism, IsTreeAutomorphism]\", ReturnTrue,\n              [IsTreeAutomorphism, IsTreeAutomorphism],\nfunction(a1, a2)\n  return Perm(a1) = Perm(a2) and Sections(a1) = Sections(a2);\nend);\n\n\n###############################################################################\n##\n#M  \\<(<a1>, <a2>)\n##\nInstallMethod(\\<, [IsTreeAutomorphism and IsTreeAutomorphismRep,\n                   IsTreeAutomorphism and IsTreeAutomorphismRep],\nfunction(a1, a2)\n  return AG_TreeHomomorphismCmp(a1, a2) < 0;\nend);\n\n\n###############################################################################\n##\n#M  OneOp(<a>)\n##\nInstallMethod(OneOp, [IsTreeAutomorphism and IsTreeAutomorphismRep],\nfunction(a)\n  return Objectify( NewType(FamilyObj(a), IsTreeAutomorphism and IsTreeAutomorphismRep),\n                    rec(states := List([1..a!.deg], i -> One(a!.states[1])),\n                        perm := (),\n                        deg := a!.deg));\nend);\n\n\n###############################################################################\n##\n#M  \\*(<a1>, <a2>)\n##\nInstallMethod(\\*, [IsTreeAutomorphism and IsTreeAutomorphismRep,\n                   IsTreeAutomorphism and IsTreeAutomorphismRep],\nfunction(a1, a2)\n  local a;\n  a := Objectify(NewType(FamilyObj(a1), IsTreeAutomorphism and IsTreeAutomorphismRep),\n        rec(states := List([1..a1!.deg], i -> a1!.states[i] * a2!.states[i^(a1!.perm)]),\n            perm := a1!.perm * a2!.perm,\n            deg := a1!.deg));\n  SetIsActingOnBinaryTree(a, IsActingOnBinaryTree(a1));\n  SetIsActingOnRegularTree(a, IsActingOnRegularTree(a1));\n  return a;\nend);\n\n\n###############################################################################\n##\n#M  \\*(<a1>, <a2>)\n##\nInstallMethod(\\*, [IsTreeAutomorphism, IsTreeAutomorphism],\nfunction(a1, a2)\n  local s1, s2, p1, p2, states, perm, d, a;\n  s1 := Sections(a1); p1 := Perm(a1);\n  s2 := Sections(a2); p2 := Perm(a2);\n  states := List([1..Length(s1)], i -> s1[i] * s2[i^p1]);\n  return TreeAutomorphism(states, p1*p2);\nend);\n\n\n###############################################################################\n##\n#M  \\[\\](<a1>, <a2>)\n##\nInstallOtherMethod(\\[\\], [IsTreeAutomorphism, IsPosInt],\nfunction(a, k)\n  return Section(a, k);\nend);\n\n\n###############################################################################\n##\n#M  InverseOp(<a>)\n##\nInstallMethod(InverseOp, \"for [IsTreeAutomorphism and IsTreeAutomorphismRep]\",\n              [IsTreeAutomorphism and IsTreeAutomorphismRep],\nfunction(a)\n  local inv;\n  inv := Objectify(NewType(FamilyObj(a), IsTreeAutomorphism and IsTreeAutomorphismRep),\n            rec(states := List([1..a!.deg], i -> a!.states[i^(a!.perm^-1)]^-1),\n                perm := a!.perm ^ -1,\n                deg := a!.deg) );\n  SetIsActingOnBinaryTree(inv, IsActingOnBinaryTree(a));\n  SetIsActingOnRegularTree(inv, IsActingOnRegularTree(a));\n  return inv;\nend);\n\nInstallMethod(InverseOp, \"for [IsTreeAutomorphism]\", [IsTreeAutomorphism],\nfunction(a)\n  local states, inv_states, perm;\n  states := Sections(a);\n  perm := Inverse(Perm(a));\n  inv_states := List([1..Length(states)], i -> Inverse(states[i^perm]));\n  return TreeAutomorphism(inv_states, perm);\nend);\n\n\n###############################################################################\n##\n#M  AbelImage(<a>)\n##\n##  XXX  Works for IsAutom or IsSelfSim only !!!!\n##\nInstallMethod(AbelImage, \"for [IsTreeAutomorphism]\",\n              [IsTreeAutomorphism],\nfunction(a)\n  local abels, w, i;\n  w := LetterRepAssocWord(Word(a));\n  for i in [1..Length(w)] do\n    if w[i] < 0 then w[i] := -w[i]+FamilyObj(a)!.numstates; fi;\n  od;\n  abels := AG_AbelImagesGenerators(FamilyObj(a));\n  if not IsEmpty(w) then\n    return Sum(List(w, x -> abels[x]));\n  else\n    return Zero(abels[1]);\n  fi;\nend);\n\n\n#E\n", "meta": {"hexsha": "a53e673257c41fa7d97105858322bc082dd4385e", "size": 18522, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "gap/treeaut.gi", "max_stars_repo_name": "gap-packages/automgrp", "max_stars_repo_head_hexsha": "1beb0cbc96c9748cf912433c27c661e1f87ef5dc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-02T15:00:11.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-02T15:00:11.000Z", "max_issues_repo_path": "gap/treeaut.gi", "max_issues_repo_name": "gap-packages/automgrp", "max_issues_repo_head_hexsha": "1beb0cbc96c9748cf912433c27c661e1f87ef5dc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2019-09-21T22:10:40.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-26T23:51:41.000Z", "max_forks_repo_path": "gap/treeaut.gi", "max_forks_repo_name": "gap-packages/automgrp", "max_forks_repo_head_hexsha": "1beb0cbc96c9748cf912433c27c661e1f87ef5dc", "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.1917808219, "max_line_length": 121, "alphanum_fraction": 0.5335276968, "num_tokens": 4703, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.6442250996557035, "lm_q1q2_score": 0.49724096107605736}}
{"text": "\n#\n# Read(\"~/Workspace/groupsSB/epi/A2/generic.UU.gi\");\n#\n\ntype:=\"A\";\nrank:=2;\nnr_pos_roots:=3;\n\nRead(\"~/Workspace/groupsSB/epi/group.gi\");\n\nhandleUaUbUc:=function()\n\tlocal rels, vals,i,v;\n\t# UaUb=Uc = U(a1+b1,a2+b2,a3+b3+a2*b1)\n\trels:=Set(Concatenation(Ua*Ub-Uc));\n\t\n\tvals:=[];\n\tAppend(vals,[[[vars[22]],[vars[2]+vars[12]]]]);\n\tAppend(vals,[[[vars[21]],[vars[1]+vars[11]]]]);\n\tAppend(vals,[[[vars[23]],[vars[3]+vars[13]+vars[2]*vars[11]]]]);\n\n\n\tfor i in [1..Length(rels)] do\n\t\tfor v in vals do\n\t\t\tPrint(rels[i],\"\\n\");\n\t\t\trels[i]:=One(APR)*Value(rels[i],v[1],v[2]);\n\t\tod;\n\tod;\n\treturn vals;\nend;\n", "meta": {"hexsha": "0d56ccee00944999cb161d55e753cf7feca3e531", "size": 596, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "epi/A2/generic.UU.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/generic.UU.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/generic.UU.gi", "max_forks_repo_name": "iuliansimion/groupsSB", "max_forks_repo_head_hexsha": "db7494e81bb03f76c20fa181e358ba1cc2d28975", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.2258064516, "max_line_length": 65, "alphanum_fraction": 0.5956375839, "num_tokens": 244, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.4962258778302312}}
{"text": "#############################################################################\n##\n#W  vspc.gi                     GAP library                     Thomas Breuer\n##\n##\n#Y  Copyright (C)  1997,  Lehrstuhl D f\u00fcr Mathematik,  RWTH Aachen,  Germany\n#Y  (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland\n#Y  Copyright (C) 2002 The GAP Group\n##\n##  This file contains generic methods for vector spaces.\n##\n\n\n#############################################################################\n##\n#M  SetLeftActingDomain( <extL>, <D> )\n##\n##  check whether the left acting domain <D> of the external left set <extL>\n##  knows that it is a division ring.\n##  This is used, e.g.,  to tell a free module over a division ring\n##  that it is a vector space.\n##\nInstallOtherMethod( SetLeftActingDomain,\n    \"method to set also 'IsLeftActedOnByDivisionRing'\",\n    [ IsAttributeStoringRep and IsLeftActedOnByRing, IsObject ],0,\n    function( extL, D )\n    if HasIsDivisionRing( D ) and IsDivisionRing( D ) then\n      SetIsLeftActedOnByDivisionRing( extL, true );\n    fi;\n    TryNextMethod();\n    end );\n\n\n#############################################################################\n##\n#M  IsLeftActedOnByDivisionRing( <M> )\n##\nInstallMethod( IsLeftActedOnByDivisionRing,\n    \"method for external left set that is left acted on by a ring\",\n    [ IsExtLSet and IsLeftActedOnByRing ],\n    function( M )\n    if IsIdenticalObj( M, LeftActingDomain( M ) ) then\n      TryNextMethod();\n    else\n      return IsDivisionRing( LeftActingDomain( M ) );\n    fi;\n    end );\n\n\n#############################################################################\n##\n#F  VectorSpace( <F>, <gens>[, <zero>][, \"basis\"] )\n##\n##  The only difference between `VectorSpace' and `FreeLeftModule' shall be\n##  that the left acting domain of a vector space must be a division ring.\n##\nInstallGlobalFunction( VectorSpace, function( arg )\n    if Length( arg ) = 0 or not IsDivisionRing( arg[1] ) then\n      Error( \"usage: VectorSpace( <F>, <gens>[, <zero>][, \\\"basis\\\"] )\" );\n    fi;\n    return CallFuncList( FreeLeftModule, arg );\n    end );\n\n\n#############################################################################\n##\n#M  AsSubspace( <V>, <C> )  . . . . . . . for a vector space and a collection\n##\nInstallMethod( AsSubspace,\n    \"for a vector space and a collection\",\n    [ IsVectorSpace, IsCollection ],\n    function( V, C )\n    local newC;\n\n    if not IsSubset( V, C ) then\n      return fail;\n    fi;\n    newC:= AsVectorSpace( LeftActingDomain( V ), C );\n    if newC = fail then\n      return fail;\n    fi;\n    SetParent( newC, V );\n    UseIsomorphismRelation( C, newC );\n    UseSubsetRelation( C, newC );\n\n    return newC;\n    end );\n\n\n#############################################################################\n##\n#M  AsLeftModule( <F>, <V> )  . . . . . .  for division ring and vector space\n##\n##  View the vector space <V> as a vector space over the division ring <F>.\n##\nInstallMethod( AsLeftModule,\n    \"method for a division ring and a vector space\",\n    [ IsDivisionRing, IsVectorSpace ],\n    function( F, V )\n\n    local W,        # the space, result\n          base,     # basis vectors of field extension\n          gen,      # loop over generators of 'V'\n          b,        # loop over 'base'\n          gens,     # generators of 'V'\n          newgens;  # extended list of generators\n\n    if Characteristic( F ) <> Characteristic( LeftActingDomain( V ) ) then\n\n      # This is impossible.\n      return fail;\n\n    elif F = LeftActingDomain( V ) then\n\n      # No change of the left acting domain is necessary.\n      return V;\n\n    elif IsSubset( F, LeftActingDomain( V ) ) then\n\n      # Check whether 'V' is really a space over the bigger field,\n      # that is, whether the set of elements does not change.\n      base:= BasisVectors( Basis( AsField( LeftActingDomain( V ), F ) ) );\n      for gen in GeneratorsOfLeftModule( V ) do\n        for b in base do\n          if not b * gen in V then\n\n            # The field extension would change the set of elements.\n            return fail;\n\n          fi;\n        od;\n      od;\n\n      # Construct the space.\n      W:= LeftModuleByGenerators( F, GeneratorsOfLeftModule(V), Zero(V) );\n\n    elif IsSubset( LeftActingDomain( V ), F ) then\n\n      # View 'V' as a space over a smaller field.\n      # For that, the list of generators must be extended.\n      gens:= GeneratorsOfLeftModule( V );\n      if IsEmpty( gens ) then\n        W:= LeftModuleByGenerators( F, [], Zero( V ) );\n      else\n\n        base:= BasisVectors( Basis( AsField( F, LeftActingDomain( V ) ) ) );\n        newgens:= [];\n        for b in base do\n          for gen in gens do\n            Add( newgens, b * gen );\n          od;\n        od;\n        W:= LeftModuleByGenerators( F, newgens );\n\n      fi;\n\n    else\n\n      # View 'V' first as space over the intersection of fields,\n      # and then over the desired field.\n      return AsLeftModule( F,\n                 AsLeftModule( Intersection( F,\n                     LeftActingDomain( V ) ), V ) );\n\n    fi;\n\n    UseIsomorphismRelation( V, W );\n    UseSubsetRelation( V, W );\n    return W;\n    end );\n\n\n#############################################################################\n##\n#M  ViewObj( <V> )  . . . . . . . . . . . . . . . . . . . view a vector space\n##\n##  print left acting domain, if known also dimension or no. of generators\n##\nInstallMethod( ViewObj,\n    \"for vector space with known generators\",\n    [ IsVectorSpace and HasGeneratorsOfLeftModule ],\n    function( V )\n    Print( \"<vector space over \", LeftActingDomain( V ), \", with \",\n           Length( GeneratorsOfLeftModule( V ) ), \" generators>\" );\n    end );\n\nInstallMethod( ViewObj,\n    \"for vector space with known dimension\",\n    [ IsVectorSpace and HasDimension ],\n    1, # override method for known generators\n    function( V )\n    Print( \"<vector space of dimension \", Dimension( V ),\n           \" over \", LeftActingDomain( V ), \">\" );\n    end );\n\nInstallMethod( ViewObj,\n    \"for vector space\",\n    [ IsVectorSpace ],\n    function( V )\n    Print( \"<vector space over \", LeftActingDomain( V ), \">\" );\n    end );\n\n\n#############################################################################\n##\n#M  PrintObj( <V> ) . . . . . . . . . . . . . . . . . . .  for a vector space\n##\nInstallMethod( PrintObj,\n    \"method for vector space with left module generators\",\n    [ IsVectorSpace and HasGeneratorsOfLeftModule ],\n    function( V )\n    Print( \"VectorSpace( \", LeftActingDomain( V ), \", \",\n           GeneratorsOfLeftModule( V ) );\n    if IsEmpty( GeneratorsOfLeftModule( V ) ) and HasZero( V ) then\n      Print( \", \", Zero( V ), \" )\" );\n    else\n      Print( \" )\" );\n    fi;\n    end );\n\nInstallMethod( PrintObj,\n    \"method for vector space\",\n    [ IsVectorSpace ],\n    function( V )\n    Print( \"VectorSpace( \", LeftActingDomain( V ), \", ... )\" );\n    end );\n\n\n#############################################################################\n##\n#M  \\/( <V>, <W> )  . . . . . . . . .  factor of a vector space by a subspace\n#M  \\/( <V>, <vectors> )  . . . . . .  factor of a vector space by a subspace\n##\nInstallOtherMethod( \\/,\n    \"method for vector space and collection\",\n    IsIdenticalObj,\n    [ IsVectorSpace, IsCollection ],\n    function( V, vectors )\n    if IsVectorSpace( vectors ) then\n      TryNextMethod();\n    else\n      return V / Subspace( V, vectors );\n    fi;\n    end );\n\nInstallOtherMethod( \\/,\n    \"generic method for two vector spaces\",\n    IsIdenticalObj,\n    [ IsVectorSpace, IsVectorSpace ],\n    function( V, W )\n    return ImagesSource( NaturalHomomorphismBySubspace( V, W ) );\n    end );\n\n\n#############################################################################\n##\n#M  Intersection2Spaces( <AsStruct>, <Substruct>, <Struct> )\n##\nInstallGlobalFunction( Intersection2Spaces,\n    function( AsStructure, Substructure, Structure )\n    return function( V, W )\n    local inters,  # intersection, result\n          F,       # coefficients field\n          gensV,   # list of generators of 'V'\n          gensW,   # list of generators of 'W'\n          VW,      # sum of 'V' and 'W'\n          B;       # basis of 'VW'\n\n    if LeftActingDomain( V ) <> LeftActingDomain( W ) then\n\n      # Compute the intersection as vector space over the intersection\n      # of the coefficients fields.\n      # (Note that the characteristic is the same.)\n      F:= Intersection2( LeftActingDomain( V ), LeftActingDomain( W ) );\n      return Intersection2( AsStructure( F, V ), AsStructure( F, W ) );\n\n    elif IsFiniteDimensional( V ) and IsFiniteDimensional( W ) then\n\n      # Compute the intersection of two spaces over the same field.\n      gensV:= GeneratorsOfLeftModule( V );\n      gensW:= GeneratorsOfLeftModule( W );\n      if   IsEmpty( gensV ) then\n        if Zero( V ) in W then\n          inters:= V;\n        else\n          inters:= [];\n        fi;\n      elif IsEmpty( gensW ) then\n        if Zero( V ) in W then\n          inters:= W;\n        else\n          inters:= [];\n        fi;\n      else\n        # Compute a common coefficient space.\n        VW:= LeftModuleByGenerators( LeftActingDomain( V ),\n                                     Concatenation( gensV, gensW ) );\n        B:= Basis( VW );\n\n        # Construct the coefficient subspaces corresponding to 'V' and 'W'.\n        gensV:= List( gensV, x -> Coefficients( B, x ) );\n        gensW:= List( gensW, x -> Coefficients( B, x ) );\n\n        # Construct the intersection of row spaces, and carry back to VW.\n        inters:= List( SumIntersectionMat( gensV, gensW )[2],\n                       x -> LinearCombination( B, x ) );\n\n        # Construct the intersection space, if possible with a parent.\n        if     HasParent( V ) and HasParent( W )\n           and IsIdenticalObj( Parent( V ), Parent( W ) ) then\n          inters:= Substructure( Parent( V ), inters, \"basis\" );\n        elif IsEmpty( inters ) then\n          inters:= Substructure( V, inters, \"basis\" );\n          SetIsTrivial( inters, true );\n        else\n          inters:= Structure( LeftActingDomain( V ), inters, \"basis\" );\n        fi;\n\n        # Run implications by the subset relation.\n        UseSubsetRelation( V, inters );\n        UseSubsetRelation( W, inters );\n      fi;\n\n      # Return the result.\n      return inters;\n\n    else\n      TryNextMethod();\n    fi;\n    end;\nend );\n\n\n#############################################################################\n##\n#M  Intersection2( <V>, <W> ) . . . . . . . . . . . . . for two vector spaces\n##\nInstallMethod( Intersection2,\n    \"method for two vector spaces\",\n    IsIdenticalObj,\n    [ IsVectorSpace, IsVectorSpace ],\n    Intersection2Spaces( AsLeftModule, SubspaceNC, VectorSpace ) );\n\n\n#############################################################################\n##\n#M  ClosureLeftModule( <V>, <a> ) . . . . . . . . . closure of a vector space\n##\nInstallMethod( ClosureLeftModule,\n    \"method for a vector space with basis, and a vector\",\n    IsCollsElms,\n    [ IsVectorSpace and HasBasis, IsVector ],\n    function( V, w )\n    local   B; # basis of 'V'\n\n    # We can test membership easily.\n    B:= Basis( V );\n#T why easily?\n    if Coefficients( B, w ) = fail then\n\n      # In the case of a vector space, we know a basis of the closure.\n      B:= Concatenation( BasisVectors( B ), [ w ] );\n      V:= LeftModuleByGenerators( LeftActingDomain( V ), B );\n      UseBasis( V, B );\n\n    fi;\n    return V;\n    end );\n\n\n#############################################################################\n##\n##  Methods for collections of subspaces of a vector space\n##\n\n\n#############################################################################\n##\n#R  IsSubspacesVectorSpaceDefaultRep( <D> )\n##\n##  is the representation of domains of subspaces of a vector space <V>,\n##  with the components 'structure' (with value <V>) and 'dimension'\n##  (with value either the dimension of the subspaces in the domain\n##  or the string '\\\"all\\\"', which means that the domain contains all\n##  subspaces of <V>).\n##\nDeclareRepresentation(\n    \"IsSubspacesVectorSpaceDefaultRep\",\n    IsComponentObjectRep,\n    [ \"dimension\", \"structure\" ] );\n#T not IsAttributeStoringRep?\n\n\n#############################################################################\n##\n#M  PrintObj( <D> )  . . . . . . . . . . . . . . . . . for a subspaces domain\n##\nInstallMethod( PrintObj,\n    \"method for a subspaces domain\",\n    [ IsSubspacesVectorSpace and IsSubspacesVectorSpaceDefaultRep ],\n    function( D )\n    if IsInt( D!.dimension ) then\n      Print( \"Subspaces( \", D!.structure, \", \", D!.dimension, \" )\" );\n    else\n      Print( \"Subspaces( \", D!.structure, \" )\" );\n    fi;\n    end );\n\n\n#############################################################################\n##\n#M  Size( <D> ) . . . . . . . . . . . . . . . . . . .  for a subspaces domain\n##\n##  The number of $k$-dimensional subspaces in a $n$-dimensional space over\n##  the field with $q$ elements is\n##  $$\n##  a(n,k) = \\prod_{i=0}^{k-1} \\frac{q^n-q^i}{q^k-q^i} =\n##           \\prod_{i=0}^{k-1} \\frac{q^{n-i}-1}{q^{k-i}-1}.\n##  $$\n##  We have the recursion\n##  $$\n##  a(n,k+1) = a(n,k) \\frac{q^{n-i}-1}{q^{i+1}-1}.\n##  $$\n##\n##  (The number of all subspaces is $\\sum_{k=0}^n a(n,k)$.)\n##\nInstallMethod( Size,\n    \"method for a subspaces domain\",\n    [ IsSubspacesVectorSpace and IsSubspacesVectorSpaceDefaultRep ],\n    function( D )\n\n    local k,\n          n,\n          q,\n          size,\n          qn,\n          qd,\n          ank,\n          i;\n\n    if D!.dimension = \"all\" then\n\n      # all subspaces of the space\n      n:= Dimension( D!.structure );\n\n      q:= Size( LeftActingDomain( D!.structure ) );\n      size:= 1;\n      qn:= q^n;\n      qd:= q;\n\n      # $a(n,0)$\n      ank:= 1;\n\n      for k in [ 1 .. Int( (n-1)/2 ) ] do\n\n        # Compute $a(n,k)$.\n        ank:= ank * ( qn - 1 ) / ( qd - 1 );\n        qn:= qn / q;\n        qd:= qd * q;\n\n        size:= size + ank;\n\n      od;\n\n      size:= 2 * size;\n\n      if n mod 2 = 0 then\n\n        # Add the number of spaces of dimension $n/2$.\n        size:= size + ank * ( qn - 1 ) / ( qd - 1 );\n      fi;\n\n    else\n\n      # number of spaces of dimension 'k' only\n      n:= Dimension( D!.structure );\n      if   D!.dimension < 0 or\n           n < D!.dimension then\n        return 0;\n      elif n / 2 < D!.dimension then\n        k:= n - D!.dimension;\n      else\n        k:= D!.dimension;\n      fi;\n\n      q:= Size( LeftActingDomain( D!.structure ) );\n      size:= 1;\n\n      qn:= q^n;\n      qd:= q;\n      for i in [ 1 .. k ] do\n        size:= size * ( qn - 1 ) / ( qd - 1 );\n        qn:= qn / q;\n        qd:= qd * q;\n      od;\n\n    fi;\n\n    # Return the result.\n    return size;\n    end );\n\n\n#############################################################################\n##\n#M  Enumerator( <D> ) . . . . . . . . . . . . . . . .  for a subspaces domain\n##\n##  Use the iterator to compute the elements list.\n#T This is not allowed!\n##\nInstallMethod( Enumerator,\n    \"method for a subspaces domain\",\n    [ IsSubspacesVectorSpace and IsSubspacesVectorSpaceDefaultRep ],\n    function( D )\n    local iter,    # iterator for 'D'\n          elms;    # elements list, result\n\n    iter:= Iterator( D );\n    elms:= [];\n    while not IsDoneIterator( iter ) do\n      Add( elms, NextIterator( iter ) );\n    od;\n    return elms;\n    end );\n#T necessary?\n\n\n#############################################################################\n##\n#M  Iterator( <D> ) . . . . . . . . . . . . . . . . .  for a subspaces domain\n##\n##  uses the subspaces iterator for full row spaces and the mechanism of\n##  associated row spaces.\n##\nBindGlobal( \"IsDoneIterator_Subspaces\",\n    iter -> IsDoneIterator( iter!.associatedIterator ) );\n\nBindGlobal( \"NextIterator_Subspaces\", function( iter )\n    local next;\n    next:= NextIterator( iter!.associatedIterator );\n    next:= List( GeneratorsOfLeftModule( next ),\n                 x -> LinearCombination( iter!.basis, x ) );\n    return Subspace( iter!.structure, next, \"basis\" );\n    end );\n\nBindGlobal( \"ShallowCopy_Subspaces\",\n    iter -> rec( structure          := iter!.structure,\n                 basis              := iter!.basis,\n                 associatedIterator := ShallowCopy(\n                                           iter!.associatedIterator ) ) );\n\nInstallMethod( Iterator,\n    \"for a subspaces domain\",\n    [ IsSubspacesVectorSpace and IsSubspacesVectorSpaceDefaultRep ],\n    function( D )\n    local V;      # the vector space\n\n    V:= D!.structure;\n    return IteratorByFunctions( rec(\n               IsDoneIterator     := IsDoneIterator_Subspaces,\n               NextIterator       := NextIterator_Subspaces,\n               ShallowCopy        := ShallowCopy_Subspaces,\n               structure          := V,\n               basis              := Basis( V ),\n               associatedIterator := Iterator(\n                      Subspaces( FullRowSpace( LeftActingDomain( V ),\n                                               Dimension( V ) ),\n                                 D!.dimension ) ) ) );\n    end );\n\n\n#############################################################################\n##\n#M  Subspaces( <V>, <dim> )\n##\nInstallMethod( Subspaces,\n    \"for a vector space, and an integer\",\n    [ IsVectorSpace, IsInt ],\n    function( V, dim )\n    if IsFinite( V ) then\n      return Objectify( NewType( CollectionsFamily( FamilyObj( V ) ),\n                                     IsSubspacesVectorSpace\n                                 and IsSubspacesVectorSpaceDefaultRep ),\n                        rec(\n                             structure  := V,\n                             dimension  := dim\n                           )\n                      );\n    else\n      TryNextMethod();\n    fi;\n    end );\n\n\n#############################################################################\n##\n#M  Subspaces( <V> )\n##\nInstallMethod( Subspaces,\n    \"for a vector space\",\n    [ IsVectorSpace ],\n    function( V )\n    if IsFinite( V ) then\n      return Objectify( NewType( CollectionsFamily( FamilyObj( V ) ),\n                                     IsSubspacesVectorSpace\n                                 and IsSubspacesVectorSpaceDefaultRep ),\n                        rec(\n                             structure  := V,\n                             dimension  := \"all\"\n                           )\n                      );\n    else\n      TryNextMethod();\n    fi;\n    end );\n\n\n#############################################################################\n##\n#F  IsSubspace( <V>, <U> ) . . . . . . . . . . . . . . . . . check <U> <= <V>\n##\nInstallGlobalFunction( IsSubspace, function( V, U )\n    return IsVectorSpace( U ) and IsSubset( V, U );\nend );\n\n\n#############################################################################\n##\n#M  IsVectorSpaceHomomorphism( <map> )\n##\nInstallMethod( IsVectorSpaceHomomorphism,\n    [ IsGeneralMapping ],\n    function( map )\n    local S, R, F;\n    S:= Source( map );\n    if not IsVectorSpace( S ) then\n      return false;\n    fi;\n    R:= Range( map );\n    if not IsVectorSpace( R ) then\n      return false;\n    fi;\n    F:= LeftActingDomain( S );\n    return ( F = LeftActingDomain( R ) ) and IsLinearMapping( F, map );\n    end );\n\n\n#############################################################################\n##\n#E\n\n", "meta": {"hexsha": "b7a88871148ffdb24e49e263473a54a603ffd174", "size": 19226, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "src/test/resources/samples/langs/GAP/vspc.gi", "max_stars_repo_name": "JavascriptID/sourcerer-app", "max_stars_repo_head_hexsha": "9ad05f7c6a18c03793c8b0295a2cb318118f6245", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8271, "max_stars_repo_stars_event_min_datetime": "2015-01-01T15:04:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T06:18:14.000Z", "max_issues_repo_path": "src/test/resources/samples/langs/GAP/vspc.gi", "max_issues_repo_name": "JavascriptID/sourcerer-app", "max_issues_repo_head_hexsha": "9ad05f7c6a18c03793c8b0295a2cb318118f6245", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3238, "max_issues_repo_issues_event_min_datetime": "2015-01-01T14:25:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T17:37:51.000Z", "max_forks_repo_path": "src/test/resources/samples/langs/GAP/vspc.gi", "max_forks_repo_name": "JavascriptID/sourcerer-app", "max_forks_repo_head_hexsha": "9ad05f7c6a18c03793c8b0295a2cb318118f6245", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4070, "max_forks_repo_forks_event_min_datetime": "2015-01-01T11:40:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T13:45:53.000Z", "avg_line_length": 29.4877300613, "max_line_length": 77, "alphanum_fraction": 0.5063975866, "num_tokens": 4811, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879312056025699, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.4962190601949736}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F RDFT(<size>) -  Discrete Fourier Transform of a real sequence, non-terminal\n#F This is an obsolete real DFT, please use PRDFT\n#F\n#F Definition: (n x n)-matrix\n#F              [ cos(2*pi*k*l/n) | k = 0...Int(n/2), l = 0...n-1 ]\n#F              [-sin(2*pi*k*l/n) | k = Int(n/2)+1...n, l = 0...n-1 ]\n#F              k and l are row and column indices, respectively.\n#F Note:      RDFT is obtained using symmetry of  DFT on a real-valued input\n#F Example:   RDFT(8)\nClass(RDFT, NonTerminal, rec(\n    abbrevs := [ N -> Checked(IsInt(N), N > 1, [N]) ],\n    terminate := self >> When(self.params[1]=2, F(2), \n\tMat(ApplyFunc(Global.RDFT, self.params))),\n    isReal := True,\n    dims := self >> [self.params[1], self.params[1]],\n    SmallRandom := () -> Random([2, 3, 4, 6, 8, 12, 16, 24, 32])\n));\n\nRulesFor(RDFT, rec(\n    #F RuleRDFT_Base: RDFT_2 = F_2\n    #F\n    RDFT_Base := rec (\n\tinfo             := \"RDFT_2 -> F_2\",\n\tisApplicable     := L -> L[1] = 2, \n\tallChildren      := L -> [ [ ] ], \n\trule            := (L, C) -> F(2)\n    ), \n\n    #F RDFT_Trigonometric: 1984 \n    #F\n    #F   RDFT_n = (DCT1_(n/2+1) dirsum DST1_(n/2-1)) * blocks\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   Britanak/Rao:\n    #F     The fast generalized discrete Fourier transforms: A unified\n    #F     approach to the discrete sinusoidal transforms computation.\n    #F     Signal Processing 79, 1999, pp. 135--150\n    #F\n    RDFT_Trigonometric := rec (\n\tinfo             := \"RDFT_n -> DCT1_(n/2+1), DST1_(n/2-1)\",\n        # 3 can occur only once\n\tisApplicable     := L -> L[1] >= 4 and \n\t    (Is2Power(L[1]) or (L[1] mod 3 = 0 and Is2Power(L[1]/3))),\n\t       \n        allChildren := L -> [[ DCT1(L[1]/2 + 1), DST1(L[1]/2 - 1) ]], \n\n\trule := (L, C) -> let(N := L[1], exp := 1, \n\t   DirectSum(C[1], exp * C[2] ^ J(N/2 - 1)) *\n\t   DirectSum(I(1), blocks1(N - 1)))\n    ), \n\n\n    #F RDFT_CT_Radix2  : Cooley-Tukey Radix-2\n    #F\n    #F   RDFT_n = M * (F_2 tensor)' * (I_n/2 dirsum rots^(L^n/2_n/4)) * \n    #F            (I_2 tensor RDFT_n/2) * L^n_2\n    #F\n    #F   derived by hand; the prime denotes that one F_2 is missing in the\n    #F   tensor product.\n    #F\n    RDFT_CT_Radix2 := rec (\n\tinfo             := \"RDFT_n -> RDFT_n/2\",\n\tisApplicable     := L -> let(N := L[1], exp := 1,\n\t    N mod 4 = 0 and exp = 1 and\n\t    (IsPrimePowerInt(N) or       # 3 or 5 can occur only once\n\t\t(N mod 3 = 0 and IsPrimePowerInt(N/3)) or\n\t\t(N mod 5 = 0 and IsPrimePowerInt(N/5)))),\n      \n\tallChildren := L -> [[ RDFT(L[1]/2) ]], \n\n\trule := (P, C) -> let(N := P[1], i := Ind(N/4-1),\n\t    When(N=4, \n\t\tConjugate(DirectSum(F(2),I(2)), L(4, 2)) *\n\t\tTensor(I(2), C[1]) * L(4, 2), \n\n\t\tmonomial1(N) *\n\t\tDirectSum(Tensor(I(N/4), F(2)), I(2), Tensor(I(N/4 - 1), F(2))) ^ L(N, N/2) *\n\t\tDirectSum(\n\t\t    I(N/2),\n\t\t    DirectSum(I(1), IterDirectSum(i, Rot(fdiv(i+1, N/2))), I(1)*(-1)^(N/2)) \n\t\t       ^ M(N/2,N/4)) *\n\t\tTensor(I(2), C[1]) * L(N, 2)))\n    ),\n\n    #F RDFT_toDCT2: 1989 \n    #F\n    #F   RDFT_n = M * DCT2_n * P,   n odd\n    #F\n    #F   Chan/Ho: Efficient Index-Mapping for Computing the Discrete Cosine Transform\n    #F     Electronics Letters, 1989\n    #F   see also:\n    #F   Heideman: Computation of an Odd-Length DCT from a Real-Valued DFT of\n    #F     the same Length, IEEE Trans. Sig. Proc. 40(1), 1992\n    #F\n    RDFT_toDCT2 := rec(\n\tinfo             := \"RDFT_n -> DCT2_n\",\n\tswitch           := false,\n\tisApplicable     := L -> \n            # we block odd sizes larger than 3 for now\n\t    L[1] mod 2 = 1 and L[1] >= 3, \n\n        allChildren := L ->  [[ DCT2(L[1]) ]], \n\n\trule := (L, C) -> let(N := L[1], \n\t    Diag(LambdaList([0..N-1], i -> (-1)^i)) *\n\t    OS(N, 2) *\n\t    C[1] *\n\t    perm7(N))\n    )\n));\n", "meta": {"hexsha": "40df33efae8d80170faa97ed022896dec1ad5a59", "size": 3896, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/realdft/old_rdft.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/transforms/realdft/old_rdft.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/transforms/realdft/old_rdft.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 32.7394957983, "max_line_length": 85, "alphanum_fraction": 0.523100616, "num_tokens": 1498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117855317474, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.49618279013937394}}
{"text": "#############################################################################\n##\n##  Matroid.gi                  alcove package                  Martin Leuner\n##\n##  Copyright 2012 Lehrstuhl B f\u00fcr Mathematik, RWTH Aachen\n##\n##  Matroid methods for alcove.\n##\n#############################################################################\n\n####################################\n##\n## Representations\n##\n####################################\n\nDeclareRepresentation( \"IsAbstractMatroidRep\",\n                IsMatroid and IsAttributeStoringRep,\n                [ ]\n);\n\nDeclareRepresentation( \"IsVectorMatroidRep\",\n                IsMatroid and IsAttributeStoringRep,\n                [ \"generatingMatrix\" ]\n);\n\nDeclareRepresentation( \"IsRepresentationMatroidRep\",\n                IsMatroid and IsAttributeStoringRep,\n                [ \"representation\", \"baseColumn\" ]\n);\n\n#DeclareRepresentation( \"IsGraphicMatroidRep\",\n#\tIsMatroid and IsAttributeStoringRep,\n#\t[ \"incidenceMatrix\" ]\n#);\n\n\n####################################\n##\n## Types and Families\n##\n####################################\n\nBindGlobal( \"TheFamilyOfMatroids\",\n                NewFamily( \"TheFamilyOfMatroids\", IsMatroid )\n);\n\nBindGlobal( \"TheTypeAbstractMatroid\",\n                NewType( TheFamilyOfMatroids,\n                IsAbstractMatroidRep )\n);\n\nBindGlobal( \"TheTypeMinorOfAbstractMatroid\",\n                NewType( TheFamilyOfMatroids,\n                IsAbstractMatroidRep and IsMinorOfMatroid )\n);\n\nBindGlobal( \"TheTypeVectorMatroid\",\n                NewType( TheFamilyOfMatroids,\n                IsVectorMatroidRep )\n);\n\nBindGlobal( \"TheTypeMinorOfVectorMatroid\",\n                NewType( TheFamilyOfMatroids,\n                IsVectorMatroidRep and IsMinorOfMatroid )\n);\n\nBindGlobal( \"TheTypeRepresentationMatroid\",\n                NewType( TheFamilyOfMatroids,\n                IsRepresentationMatroidRep )\n);\n\nBindGlobal( \"TheTypeMinorOfRepresentationMatroid\",\n                NewType( TheFamilyOfMatroids,\n                IsRepresentationMatroidRep and IsMinorOfMatroid )\n);\n\n#BindGlobal( \"TheTypeGraphicMatroid\",\n#\tNewType( TheFamilyOfMatroids,\n#\t\tIsGraphicMatroidRep )\n#);\n\n#BindGlobal( \"TheTypeMinorOfGraphicMatroid\",\n#\tNewType( TheFamilyOfMatroids,\n#\t\tIsGraphicMatroidRep and IsMinorOfMatroid )\n#);\n\n\n####################################\n##\n## Attributes\n##\n####################################\n\n\n##############\n## DualMatroid\n\n##\nInstallMethod( DualMatroid,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid ],\n                50,\n\n  function( matroid )\n    local dual;\n\n    dual := UniformMatroid( Size(matroid) - RankOfMatroid(matroid), Size(matroid) );\n\n    SetDualMatroid( dual, matroid );\n\n    return dual;\n  end\n\n);\n\n##\nInstallMethod( DualMatroid,\n                \"for matroids with bases\",\n                [ IsAbstractMatroidRep and HasBases ],\n                30,\n\n  function( matroid )\n    local dualbases, dual;\n\n    dualbases := Set( List( Bases( matroid ), b -> Difference( GroundSet( matroid ), b ) ) );\n\n    dual := MatroidByBasesNCL( GroundSet( matroid ), dualbases );\n    SetDualMatroid( dual, matroid );\n    _alcove_MatroidStandardImplications( dual );\n\n    return dual;\n  end\n\n);\n\n##\nInstallMethod( DualMatroid,\n                \"for matroids with a rank function\",\n                [ IsAbstractMatroidRep and HasRankFunction ],\n                20,\n\n  function( matroid )\n    local dualRkFunc, dual, corank, rkFunc, gset;\n\n    gset := GroundSet( matroid );\n    rkFunc := RankFunction( matroid );\n    corank := Size( gset ) - RankOfMatroid( matroid );\n\n    dualRkFunc :=\n                function( x )\n                  local compl;\n\n                  compl := Difference( gset, x );\n\n                  return corank + rkFunc( compl ) - Size( compl );\n                end;\n\n    dual := MatroidByRankFunctionNCL( gset, dualRkFunc );\n    SetDualMatroid( dual, matroid );\n    _alcove_MatroidStandardImplications( dual );\n\n    return dual;\n  end\n\n);\n\n##\nInstallMethod( DualMatroid,\n                \"for connected vector matroids\",\n                [ IsVectorMatroidRep and IsConnectedMatroid ],\n                30,\n\n  function( matroid )\n    local dualmatrix, dual, mat;\n    mat := MatrixOfVectorMatroid( matroid );\n\n    dualmatrix := SyzygiesOfRows( Involution( mat ) );\n\n    dual := Matroid( dualmatrix );\n    SetDualMatroid( dual, matroid );\n\n    return dual;\n  end\n\n);\n\n##\nInstallMethod( DualMatroid,\n                \"for disconnected matroids\",\n                [ IsMatroid and HasDirectSumDecomposition ],\n                0,\n\n  function( matroid )\n    local dual;\n\n    if HasIsConnectedMatroid( matroid ) and IsConnectedMatroid( matroid ) and IsIdenticalObj( matroid, DirectSumDecomposition(matroid)[1][2] ) then\n      TryNextMethod( );\n    fi;\n\n    dual := rec( );\n    ObjectifyWithAttributes( dual, TheTypeAbstractMatroid,\n                          Size, Size( matroid ),\n                          DirectSumDecomposition, List( DirectSumDecomposition(matroid), s -> [ s[1], DualMatroid(s[2]) ] ),\n                          DualMatroid, matroid );\n    _alcove_MatroidStandardImplications( dual );\n\n    return dual;\n  end\n\n);\n\n##\nInstallMethod( DualMatroid,\n                \"fallback method for connected matroids\",\n                [ IsMatroid and IsConnectedMatroid ],\n                0,\n\n  function( matroid )\n\n    RankFunction( matroid );\n\n    return DualMatroid( matroid );\n\n  end\n\n);\n\n##\nInstallMethod( DualMatroid,\n                \"fallback method\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n\n    DirectSumDecomposition( matroid );\n\n    return DualMatroid( matroid );\n\n  end\n\n);\n\n\n#################\n## Simplification\n\n##\nInstallMethod( Simplification,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n    local pcs, elt, del;\n\n    pcs := ShallowCopy( NonTrivialParallelClasses( matroid ) );\n\n    del := Union( Loops( matroid ), Union( List( pcs, x -> x{[2..Size(x)]} ) ) );\n\n    if IsEmpty( del ) then\n      return [ matroid, GroundSet( matroid ) ];\n    fi;\n\n    for elt in Difference( GroundSet( matroid ), Union( pcs ) ) do\n      AddSet( pcs, [ elt ] );\n    od;\n\n    MakeImmutable( pcs );\n\n    return [ Deletion( matroid, del ), pcs ];\n  end\n\n);\n\n\n################################\n## StandardMatrixOfVectorMatroid\n\n##\nInstallMethod( StandardMatrixOfVectorMatroid,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n\n  function( matroid )\n    local nf, posOfNonUnitCols;\n\n    nf := BasisOfRows( MatrixOfVectorMatroid( matroid ) );\n    posOfNonUnitCols := Difference( GroundSet( matroid ), PositionOfFirstNonZeroEntryPerRow( nf ) );\n\n    return [ CertainColumns( nf, posOfNonUnitCols ), posOfNonUnitCols ];\n  end\n\n);\n\n\n############\n## GroundSet\n\n##\nInstallMethod( GroundSet,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return [ 1 .. Size( matroid ) ];\n\n  end\n\n);\n\n\n#######\n## Size\n\n##\nInstallMethod( Size,\n                \"for abstract matroids\",\n                [ IsAbstractMatroidRep ],\n\n  function( matroid )\n\n    return Size( GroundSet( matroid ) );\n\n  end\n\n);\n\n##\nInstallMethod( Size,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n\n  function( matroid )\n\n      return NrColumns( MatrixOfVectorMatroid( matroid ) );\n\n  end\n\n);\n\n\n###################\n## NominalGroundSet\n\n##\nInstallMethod( NominalGroundSet,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return GroundSet( matroid );\n\n  end\n\n);\n\n\n################\n## RankOfMatroid\n\n##\nInstallMethod( RankOfMatroid,\n                \"for matroids with bases\",\n                [ IsAbstractMatroidRep and HasBases ],\n                40,\n\n  function( matroid )\n\n    return Size( Bases(matroid)[1] );\n\n  end\n\n);\n\n##\nInstallMethod( RankOfMatroid,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n                20,\n\n  function( matroid )\n\n    return RowRankOfMatrix( MatrixOfVectorMatroid(matroid) );\n\n  end\n\n);\n\n##\nInstallMethod( RankOfMatroid,\n                \"for disconnected matroids\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n\n    if HasIsConnectedMatroid( matroid ) and IsConnectedMatroid( matroid ) and IsIdenticalObj( matroid, DirectSumDecomposition(matroid)[1][2] ) then\n      TryNextMethod( );\n    fi;\n\n    return Sum( DirectSumDecomposition(matroid), s -> RankOfMatroid(s[2]) );\n\n  end\n\n);\n\n##\nInstallMethod( RankOfMatroid,\n                \"fallback method for connected matroids\",\n                [ IsMatroid and IsConnectedMatroid ],\n                10,\n\n  function( matroid )\n\n    return Size( SomeBasis( matroid ) );\n\n  end\n\n);\n\n##\nInstallMethod( Rank,\n                \"alias for Rank for matroids\",\n                [ IsMatroid ],\n\n  RankOfMatroid\n\n);\n\n\n###############\n## RankFunction\n\n##\nInstallMethod( RankFunction,\n                \"for matroids with bases\",\n                [ IsAbstractMatroidRep and HasBases ],\n                10,\n\n  function( matroid )\n    return\n                function( x )\n                  local b, max, s;\n\n                  max := 0;\n\n                  for b in Bases( matroid ) do\n\n                    s := Size( Intersection2( b, x ) );\n                    if s > max then\n\n                      max := s;\n                      if max = Size( x ) then return max; fi;\n\n                    fi;\n\n                  od;\n\n                  return max;\n                end;\n  end\n\n);\n\n##\nInstallMethod( RankFunction,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n                30,\n\n  function( matroid )\n\n    return function( x ) return RowRankOfMatrix( CertainColumns( MatrixOfVectorMatroid( matroid ), x ) ); end;\n\n  end\n\n);\n\n##\nInstallMethod( RankFunction,\n                \"for disconnected matroids\",\n                [ IsMatroid and HasDirectSumDecomposition ],\n                30,\n\n  function( matroid )\n\n    if HasIsConnectedMatroid( matroid ) and IsConnectedMatroid( matroid ) and IsIdenticalObj( matroid, DirectSumDecomposition(matroid)[1][2] ) then\n      TryNextMethod( );\n    elif IsConnectedMatroid( matroid ) then\n      return RankFunction( DirectSumDecomposition(matroid)[1][2] );\n    fi;\n\n    return\n           function( x ) return Sum( DirectSumDecomposition( matroid ),\n                                     s -> RankFunction(s[2])(\n                                                              List( Intersection2( x, s[1] ), i -> Position( s[1], i ) )\n                                                            )\n                                   );\n           end;\n\n  end\n\n);\n\n##\nInstallMethod( RankFunction,\n                \"for 2-sums of matroids\",\n                [ IsMatroid and HasTwoSumDecomposition ],\n                30,\n\n  function( matroid )\n\n    if HasIs3Connected( matroid ) and Is3Connected( matroid ) then TryNextMethod( ); fi;\n\n    return function( x )\n                  local two, res1, res2, rk1, rk2, r1x, r2x;\n\n                  two := TwoSumDecomposition( matroid );\n                  res1 := Intersection2( two[3], x );\n                  res2 := Intersection2( two[6], x );\n                  rk1 := RankFunction( two[1] );\n                  rk2 := RankFunction( two[4] );\n\n                  r1x := rk1( res1 );\n                  r2x := rk2( res2 );\n\n                  if r1x = rk1( Union2( res1, [two[2]] ) ) and\n                     r2x = rk2( Union2( res2, [two[5]] ) ) then\n\n                    return r1x + r2x - 1;\n\n                  else\n\n                    return r1x + r2x;\n\n                  fi;\n                end;\n\n  end\n\n);\n\n##\nInstallMethod( RankFunction,\n                \"fallback method for matroids with known rank\",\n                [ IsMatroid and HasRankOfMatroid ],\n\n  function( matroid )\n    local isIndep, bound;\n\n    isIndep := IndependenceOracle( matroid );\n\n    bound := RankOfMatroid( matroid );\n\n    return\n                function( x )\n                  local maxIndep, i, tmp, ctr;\n\n                  maxIndep := [ ];\n                  ctr := 0;\n                  for i in x do\n\n                    tmp := Union2( maxIndep, [i] );\n\n                    if isIndep( tmp ) then\n                      maxIndep := tmp;\n                      ctr := ctr + 1;\n                    fi;\n\n                    if ctr = bound then break; fi;\n\n                  od;\n\n                  return ctr;\n                end;\n  end\n\n);\n\n##\nInstallMethod( RankFunction,\n                \"fallback method\",\n                [ IsMatroid ],\n\n  function( matroid )\n    local isIndep, bound;\n\n    isIndep := IndependenceOracle( matroid );\n\n    return\n                function( x )\n                  local maxIndep, i, tmp;\n\n                  maxIndep := [ ];\n                  for i in x do\n\n                    tmp := Union2( maxIndep, [i] );\n\n                    if isIndep( tmp ) then\n                      maxIndep := tmp;\n                    fi;\n\n                  od;\n\n                  return Size( maxIndep );\n                end;\n  end\n\n);\n\n\n##################\n## ClosureOperator\n\n##\nInstallMethod( ClosureOperator,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n    return\n                function( x )\n                  local loopsOfMinor, minor;\n\n                  minor := MinorNL( matroid, [ ], x );\n\n                  loopsOfMinor := List( Loops( minor ), l -> ParentAttr(minor)[2][l] );\n\n                  return Union2( x, loopsOfMinor );\n                end;\n  end\n\n);\n\n\n#######################\n## EssentialityOperator\n\n##\nInstallMethod( EssentialityOperator,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n    return\n                function( x )\n                  local minor, coloopsOfMinor;\n\n                  minor := MinorNL( matroid, Difference( GroundSet(matroid), x ), [ ] );\n\n                  coloopsOfMinor := List( Coloops( minor ), l -> ParentAttr(minor)[2][l] );\n\n                  return Difference( x, coloopsOfMinor );\n                end;\n  end\n\n);\n\n\n#####################\n## IndependenceOracle\n\n##\nInstallMethod( IndependenceOracle,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n                40,\n\n  function( matroid )\n    return\n                function( x )\n                  local nf, unitVecLabels, otherLabels, checkMat, unitVecsInX, nrCols;\n\n                  nf := StandardMatrixOfVectorMatroid( matroid );\n                  otherLabels := nf[2];\n                  unitVecLabels := Difference( GroundSet( matroid ), otherLabels );\n\n                  checkMat := CertainColumns( nf[1], List( Intersection2( x, otherLabels ), col -> Position( otherLabels, col ) ) );\n\n                  nrCols := NrColumns( checkMat );\n                  if nrCols = 0 then return true; fi;\n\n                  unitVecsInX := Intersection2( x, unitVecLabels );\n                  checkMat := CertainRows( checkMat, Difference( [ 1 .. NrRows( checkMat ) ], List( unitVecsInX, row -> Position( unitVecLabels, row ) ) ) );\n\n                  if NrRows( checkMat ) < nrCols then return false; fi;\n\n                  return ColumnRankOfMatrix( checkMat ) = nrCols;\n                end;\n  end\n\n);\n\n##\nInstallMethod( IndependenceOracle,\n                \"for matroids with bases\",\n                [ IsMatroid and HasBases ],\n                0,\n\n  function( matroid )\n    return\n                function( x )\n                  return ForAny( Bases( matroid ), b -> IsSubset( b, x ) );\n                end;\n  end\n\n);\n\n##\nInstallMethod( IndependenceOracle,\n                \"for matroids with circuits\",\n                [ IsMatroid and HasCircuits ],\n                10,\n\n  function( matroid )\n    return\n                function( x )\n                  return ForAll( Circuits( matroid ), c -> not IsSubset( x, c ) );\n                end;\n  end\n\n);\n\n##\nInstallMethod( IndependenceOracle,\n                \"for matroids with a rank function\",\n                [ IsMatroid and HasRankFunction ],\n                30,\n\n  function( matroid )\n    return\n                function( x )\n                  return RankFunction(matroid)(x) = Size(x);\n                end;\n  end\n\n);\n\n##\nInstallMethod( IndependenceOracle,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid ],\n                50,\n\n  function( matroid )\n    return\n                function( x )\n                  return Size(x) <= RankOfMatroid( matroid );\n                end;\n  end\n\n);\n\n##\nInstallMethod( IndependenceOracle,\n                \"for disconnected matroids\",\n                [ IsMatroid and HasDirectSumDecomposition ],\n                20,\n\n  function( matroid )\n\n    if HasIsConnectedMatroid( matroid ) and IsConnectedMatroid( matroid ) and IsIdenticalObj( matroid, DirectSumDecomposition(matroid)[1][2] ) then\n      TryNextMethod( );\n    fi;\n\n    return\n           function( x ) return ForAll( DirectSumDecomposition( matroid ),\n                                        s -> IndependenceOracle(s[2])(\n                                                                        List( Intersection2( s[1], x ), i -> Position( s[1], i ) )\n                                                                     )\n                                      );\n           end;\n\n\n  end\n\n);\n\n##\nInstallMethod( IndependenceOracle,\n                \"fallback method\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n\n    RankFunction( matroid );\n    return IndependenceOracle( matroid );\n\n  end\n\n);\n\n\n################\n## CircuitOracle\n\n##\nInstallMethod( CircuitOracle,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid ],\n                50,\n\n  function( matroid )\n    return\n           function(x)\n             return Size(x) = RankOfMatroid(matroid)+1;\n           end;\n  end\n\n);\n\n##\nInstallMethod( CircuitOracle,\n                \"for matroids with known circuits\",\n                [ IsMatroid and HasCircuits ],\n                40,\n\n  function( matroid )\n    return\n           function(x)\n             return x in Circuits( matroid );\n           end;\n  end\n\n);\n\n##\nInstallMethod( CircuitOracle,\n                \"fallback method\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n    return function(x)\n                local isIndep;\n\n                isIndep := IndependenceOracle( matroid );\n\n                return not isIndep(x) and ForAll( x, i -> isIndep( Difference( x, [i] ) ) );\n           end;\n  end\n\n);\n\n\n########\n## Bases\n\n##\nInstallMethod( Bases,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid ],\n                50,\n\n  function( matroid )\n\n    return Combinations( GroundSet( matroid ), RankOfMatroid( matroid ) );\n\n  end\n\n);\n\n##\nInstallMethod( Bases,                # THIS IS AN EXTREMELY NAIVE APPROACH\n                \"for vector matroids\",\n                [ IsVectorMatroidRep and IsConnectedMatroid ],\n\n  function( matroid )\n\n    return Filtered( Combinations( [ 1 .. Size( matroid ) ], RankOfMatroid( matroid ) ),\n                b -> RowRankOfMatrix( CertainColumns( MatrixOfVectorMatroid(matroid), b ) ) = RankOfMatroid( matroid ) );\n\n  end\n\n);\n\n##\nInstallMethod( Bases,\n                \"for disconnected matroids\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n\n    if HasIsConnectedMatroid( matroid ) and IsConnectedMatroid( matroid ) and IsIdenticalObj( matroid, DirectSumDecomposition(matroid)[1][2] ) then\n      TryNextMethod( );\n    fi;\n\n    return Set( List( Cartesian( List( DirectSumDecomposition(matroid), s -> List( Bases(s[2]), b -> List( b, i -> s[1][i] ) ) ) ), Union ) );\n\n  end\n\n);\n\n##\nInstallMethod( Bases,\n                \"for 2-sums of matroids\",\n                [ IsMatroid and IsConnectedMatroid ],\n                0,\n\n  function( matroid )\n    local twosum;\n\n    if Is3Connected( matroid ) then TryNextMethod( ); fi;\n\n    twosum := TwoSumDecomposition( matroid );\n\n    return Union2(\n                List(   Cartesian(\n                                List(\n                                        Filtered( Bases( twosum[1] ), b -> not twosum[2] in b ),\n                                        b -> List( b, i -> twosum[3][i] )\n                                ),\n                                List(\n                                        Filtered( Bases( twosum[4] ), b -> twosum[5] in b ),\n                                        b -> List( Difference(b,[twosum[5]]), i -> twosum[6][i] )\n                                )\n                        ), Union ),\n\n                List(   Cartesian(\n                                List(\n                                        Filtered( Bases( twosum[1] ), b -> twosum[2] in b ),\n                                        b -> List( Difference(b,[twosum[2]]), i -> twosum[3][i] )\n                                ),\n                                List(\n                                        Filtered( Bases( twosum[4] ), b -> not twosum[5] in b ),\n                                        b -> List( b, i -> twosum[6][i] )\n                                )\n                        ), Union )\n                );\n\n  end\n\n);\n\n\n#############\n## KnownBases\n\n##\nInstallMethod( KnownBases,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return [ ];\n\n  end\n\n);\n\n\n###########\n## Circuits\n\n##\nInstallMethod( Circuits,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid ],\n                50,\n\n  function( matroid )\n\n    return Combinations( GroundSet( matroid ), RankOfMatroid( matroid ) + 1 );\n\n  end\n\n);\n\n##\nInstallMethod( Circuits,                ## incremental polynomial time method\n                \"for connected matroids\",\n                [ IsMatroid and IsConnectedMatroid ],\n                20,\n\n  function( matroid )\n    local corank, rank, i, j, isIndependent, superSet, ReduceDependentSetToCircuit,\n          newCircuits, oldCircuits, union, intersection, currentCircuit, otherCircuit;\n\n# Local function to find a circuit contained in a given set:\n\n    ReduceDependentSetToCircuit := function( dependentSet )\n      local element, furtherReduction, reducedSet;\n\n      repeat\n\n        furtherReduction := false;\n        for element in dependentSet do\n\n          reducedSet := Difference( dependentSet, [ element ] );\n\n          if not isIndependent( reducedSet ) then                        # smaller dependent set found, start over\n            dependentSet := reducedSet;\n            furtherReduction := true;\n            break;\n          fi;\n\n        od;        # for element in dependentSet\n\n      until not furtherReduction;\n\n      return dependentSet;\n    end;\n\n# Initialise variables:\n\n    rank := RankOfMatroid( matroid );\n    corank := Size( matroid ) - rank;\n\n    isIndependent := IndependenceOracle( matroid );\n\n    newCircuits := FundamentalCircuitsWithBasis( matroid )[1];\n    oldCircuits := [ ];\n\n# Treat loops separately:\n\n    newCircuits := Filtered( newCircuits, circ -> Size(circ) > 1 );\n\n# Check circuit axiom on new circuits until no more new circuits are found:\n\n    while not IsEmpty( newCircuits ) do\n\n      currentCircuit := Remove( newCircuits );\n\n      for otherCircuit in oldCircuits do\n\n        union := Union2( currentCircuit, otherCircuit );\n        intersection := Intersection2( currentCircuit, otherCircuit );\n\n        for i in intersection do\n\n          superSet := Difference( union, [ i ] );\n\n          if not ForAny( newCircuits, circ -> IsSubset( superSet, circ ) ) and not ForAny( oldCircuits, circ -> IsSubset( superSet, circ ) ) then\n            Add( newCircuits, ReduceDependentSetToCircuit( superSet ) );\n          fi;\n\n        od; # for i in intersection\n\n      od; # for otherCircuit in oldCircuits\n\n      Add( oldCircuits, currentCircuit );\n\n    od; # while not IsEmpty( newCircuits )\n\n    return Union2( oldCircuits, List( Loops( matroid ), loop -> [ loop ] ) );\n  end\n\n);\n\n##\nInstallMethod( Circuits,\n                \"for disconnected matroids\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n\n    if HasIsConnectedMatroid( matroid ) and IsConnectedMatroid( matroid ) and IsIdenticalObj( matroid, DirectSumDecomposition(matroid)[1][2] ) then\n      TryNextMethod( );\n    fi;\n\n    return Union( List( DirectSumDecomposition(matroid), s -> List( Circuits(s[2]), c -> List( c, i -> s[1][i] ) ) ) );\n\n  end\n\n);\n\n##\nInstallMethod( Circuits,\n                \"for 2-sums of matroids\",\n                [ IsMatroid and IsConnectedMatroid ],\n                0,\n\n  function( matroid )\n    local two, c1base, c1nobase, c2base, c2nobase, i;\n\n# Check whether this is the appropriate method:\n\n    if HasIs3Connected( matroid ) then\n\n      if Is3Connected( matroid ) then\n        TryNextMethod( );\n      fi;\n\n    else\n\n      if Is3Connected( matroid ) then\n        return Circuits( matroid );\n      fi;\n\n    fi;\n\n# Construct circuits from circuits of decomposition:\n\n    two := TwoSumDecomposition( matroid );\n    c1nobase := [ ];\n    c1base := Circuits( two[1] );\n    c2nobase := [ ];\n    c2base := Circuits( two[4] );\n\n    for i in Reversed( [ 1 .. Size(c1base) ] ) do\n      if not two[2] in c1base[i] then\n\n        AddSet( c1nobase, Remove( c1base, i ) );\n\n      fi;\n    od;\n\n    for i in Reversed( [ 1 .. Size(c2base) ] ) do\n      if not two[5] in c2base[i] then\n\n        AddSet( c2nobase, Remove( c2base, i ) );\n\n      fi;\n    od;\n\n    c1base := List( c1base, c -> Difference( c, two[2] ) );\n    c2base := List( c2base, c -> Difference( c, two[5] ) );\n\n    return Union(\n                  List( c1nobase, c -> List( c, i -> two[3][i] ) ),\n                  List( c2nobase, c -> List( c, i -> two[6][i] ) ),\n                  List( Cartesian( c1base, c2base ), Union )\n                );\n\n  end\n\n);\n\n\n###############################\n## FundamentalCircuitsWithBasis\n\n##\nInstallMethod( FundamentalCircuitsWithBasis,\n                \"for abstract matroids\",\n                [ IsAbstractMatroidRep ],\n\n  function( matroid )\n    local basis, reduceDependentSetToCircuit, isIndependent, circs, known;\n\n    reduceDependentSetToCircuit := function( dependentSet )\n      local element, furtherReduction, reducedSet;\n\n      repeat\n\n        furtherReduction := false;\n        for element in dependentSet do\n\n          reducedSet := Difference( dependentSet, [ element ] );\n\n          if not isIndependent( reducedSet ) then                        # smaller dependent set found, start over\n            dependentSet := reducedSet;\n            furtherReduction := true;\n            break;\n          fi;\n\n        od;        # for element in dependentSet\n\n      until not furtherReduction;\n\n      return dependentSet;\n    end;\n\n    basis := SomeBasis( matroid );\n    isIndependent := IndependenceOracle( matroid );\n\n    circs := List( Difference( GroundSet( matroid ), basis ), i -> reduceDependentSetToCircuit( Union2( basis, [i] ) ) );\n\n    SetKnownCircuits( matroid, Union2( KnownCircuits( matroid ), circs ) );\n\n    return [ circs, basis ];\n  end\n\n);\n\n##\nInstallMethod( FundamentalCircuitsWithBasis,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n\n  function( matroid )\n    local nf, otherLabels, unitVecLabels, rank, corank, circs, currentCircuit, i, j;\n\n    nf := StandardMatrixOfVectorMatroid( matroid )[1];\n    otherLabels := StandardMatrixOfVectorMatroid( matroid )[2];\n    unitVecLabels := Difference( GroundSet( matroid ), otherLabels );\n\n    rank := RankOfMatroid( matroid );\n    corank := Size( matroid ) - rank;\n\n    circs := [ ];\n\n    for j in [ 1 .. corank ] do\n\n      currentCircuit := [ ];\n      for i in [ 1 .. rank ] do\n\n        if not IsZero( MatElm( nf, i, j ) ) then Add( currentCircuit, unitVecLabels[i] ); fi;\n\n      od;\n      AddSet( currentCircuit, otherLabels[j] );\n\n      circs[j] := currentCircuit;\n\n    od;\n\n    SetKnownCircuits( matroid, Union2( KnownCircuits( matroid ), circs ) );\n\n    return [ circs, unitVecLabels ];\n  end\n\n);\n\n\n################\n## KnownCircuits\n\n##\nInstallMethod( KnownCircuits,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return [ ];\n\n  end\n\n);\n\n\n#############\n## Cocircuits\n\n##\nInstallMethod( Cocircuits,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return Circuits( DualMatroid( matroid ) );\n\n  end\n\n);\n\n\n#####################\n## MatroidHyperplanes\n\n##\nInstallMethod( MatroidHyperplanes,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return Set( List( Cocircuits( matroid ), c -> Difference( GroundSet( matroid ), c ) ) );\n\n  end\n\n);\n\n##\nInstallMethod( Hyperplanes,\n               \"for matroids\",\n               [ IsMatroid ],\n\n  function( matroid )\n\n    return MatroidHyperplanes(matroid);\n\n  end\n\n);\n\n##################\n## TuttePolynomial\n\n##\nInstallGlobalFunction( IndeterminatesOfTuttePolynomial,\n\n  function( )\n    local x, y;\n\n    if not IsBound( HOMALG_MATRICES.IndeterminatesOfTuttePolynomial ) then\n\n      x := Indeterminate( Integers, \"x\" );\n      y := Indeterminate( Integers, \"y\" );\n\n      HOMALG_MATRICES.IndeterminatesOfTuttePolynomial := [ x, y ];\n\n    fi;\n\n    return HOMALG_MATRICES.IndeterminatesOfTuttePolynomial;\n\n  end\n\n);\n\n##\nInstallMethod( TuttePolynomial,\n                \"convenience method which calls the standard indeterminates\",\n                [ IsMatroid ],\n\n  function( matroid )\n    local xy;\n\n    xy := IndeterminatesOfTuttePolynomial( );\n\n    return TuttePolynomial( matroid, xy[1], xy[2] );\n  end\n\n);\n\n##\nInstallMethod( TuttePolynomial,\n                \"check dual matroid first\",\n                [ IsMatroid and HasDualMatroid ],\n                50,\n\n  function( matroid )\n    local xy;\n\n    if not HasTuttePolynomial( DualMatroid( matroid ) ) then TryNextMethod( ); fi;\n\n    xy := IndeterminatesOfTuttePolynomial( );\n\n    return Value( TuttePolynomial( DualMatroid( matroid ) ), xy, Reversed( xy ) );\n\n  end\n\n);\n\n##\nInstallMethod( TuttePolynomial,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid, IsRingElement, IsRingElement ],\n                30,\n\n  function( matroid, x, y )\n    local k, n, T, xy;\n\n    n := Size( matroid );\n    k := RankOfMatroid( matroid );\n\n    T := Sum( [ 0 .. k ], i -> Binomial( n, i ) * (x-1)^(k-i) ) + Sum( [ k+1 .. n ], i -> Binomial( n, i ) * (y-1)^(i-k) );\n\n    xy := IndeterminatesOfTuttePolynomial( );\n\n    if IsIdenticalObj( x, xy[1] ) and IsIdenticalObj( y, xy[2] ) then\n      SetTuttePolynomial( matroid, T );\n    fi;\n\n    return T;\n  end\n\n);\n\n##\nInstallMethod( TuttePolynomial,\n                \"for disconnected matroids\",\n                [ IsMatroid, IsRingElement, IsRingElement ],\n                0,\n\n  function( matroid, x, y )\n    local T, xy;\n\n    if HasIsConnectedMatroid( matroid ) and IsConnectedMatroid( matroid ) and IsIdenticalObj( matroid, DirectSumDecomposition(matroid)[1][2] ) then\n      TryNextMethod( );\n    fi;\n\n    T := Product( DirectSumDecomposition( matroid ), comp -> TuttePolynomial( comp[2], x, y ) );\n\n    xy := IndeterminatesOfTuttePolynomial( );\n\n    if IsIdenticalObj( x, xy[1] ) and IsIdenticalObj( y, xy[2] ) then\n      SetTuttePolynomial( matroid, T );\n    fi;\n\n    return T;\n  end\n\n);\n\n##\nInstallMethod( TuttePolynomial,\n                \"generic method for connected matroids\",\n                [ IsMatroid and IsConnectedMatroid, IsRingElement, IsRingElement ],\n                10,\n\n  function( matroid, x, y )\n    local xy, loopNum, coloopNum, loopsColoops, p, min, n;\n\n    xy := IndeterminatesOfTuttePolynomial( );\n\n    loopNum := Size( Loops( matroid ) );\n    coloopNum := Size( Coloops( matroid ) );\n\n    p := x^coloopNum * y^loopNum;\n\n    n := Size( matroid );\n\n# Termination case:\n\n    if loopNum + coloopNum = n then\n      if IsIdenticalObj( x, xy[1] ) and IsIdenticalObj( y, xy[2] ) then\n        SetTuttePolynomial( matroid, p );\n      fi;\n      return p;\n    fi;\n\n# Recursion:\n\n    loopsColoops := Union2( Loops( matroid ), Coloops( matroid ) );\n\n    min := MinorNL( matroid, loopsColoops, [ ] );\n\n    n := GroundSet( min )[1];\n\n    p := p * ( TuttePolynomial( MinorNL( min, [n], [ ] ), x, y ) + TuttePolynomial( MinorNL( min, [ ], [n] ), x, y ) );\n\n    if IsIdenticalObj( x, xy[1] ) and IsIdenticalObj( y, xy[2] ) then\n      SetTuttePolynomial( matroid, p );\n    fi;\n\n    return p;\n  end\n\n);\n\n##\nInstallMethod( TuttePolynomial,\n                \"for connected vector matroids\",\n                [ IsVectorMatroidRep and IsConnectedMatroid, IsRingElement, IsRingElement ],\n                20,\n\n  function( matroid, x, y )\n    local xy, T, matrix, recursContract, recursDelete, generalRecursion, components, updateParallelClasses, ring, one, zero, pcs;\n\n    xy := IndeterminatesOfTuttePolynomial( );\n\n    matrix := StandardMatrixOfVectorMatroid( matroid )[1];\n    ring := HomalgRing( matrix );\n    one := One( ring );\n    zero := Zero( ring );\n\n    if not ( HasIsFieldForHomalg(ring) and IsFieldForHomalg(ring) ) then\n      TryNextMethod();\n    fi;\n\n# Avoid calculating with bigger matrices than absolutely necessary:\n    if Size( matroid ) - RankOfMatroid( matroid ) < RankOfMatroid( matroid ) then\n\n      T := TuttePolynomial( DualMatroid( matroid ), y, x );\n\n      if IsIdenticalObj( x, xy[1] ) and IsIdenticalObj( y, xy[2] ) then\n        SetTuttePolynomial( matroid, T );\n      fi;\n\n      return T;\n    fi;\n\n####\n# Local functions\n##\n\n##\n# Refine parallel classes for new matrix:\n\n    updateParallelClasses := function( matrix, parClasses )\n      local n, i, newParClasses, tmpMat, c, mem, r, nzRows, j, tmp;\n\n      n := NrColumns( matrix );\n      r := NrRows( matrix );\n\n      if n = 0 then return [ ]; fi;\n\n      tmpMat := EntriesOfHomalgMatrixAsListList( Involution( matrix ) );\n\n      newParClasses := [ ];\n      nzRows := [ ];\n      nzRows[n] := 0;\n\n# Normalize matrix columns:\n      for i in [ 1 .. n ] do\n\n        tmp := tmpMat[i];\n\n        for j in [ 1 .. r ] do\n\n          if not IsZero( tmp[j] ) then\n\n            if ForAll( [ j+1 .. r ], x -> IsZero( tmp[x] ) ) then\n\n              nzRows[i] := j;\n\n            else\n\n              nzRows[i] := 0;\n\n            fi;\n\n            c := tmp[j];\n            break;\n\n          fi;\n\n        od;\n\n        if not IsOne( c ) then\n\n          tmpMat[i] := (1/c) * tmp;\n\n        fi;\n\n      od;\n\n# Sort out unit vectors:\n      for i in [ 1 .. r ] do\n\n        tmp := Positions( nzRows, i );\n        Add( tmp, n+i );\n\n        Add( newParClasses, Set( tmp ) );\n\n      od;\n\n      parClasses := Filtered( parClasses, c -> c[ Size(c) ] <= n and nzRows[ c[1] ] = 0 );\n\n# Look for other fusing parallel classes:\n      while not IsEmpty( parClasses ) do\n\n        tmp := Remove( parClasses );\n\n        c := tmpMat[ tmp[1] ];\n\n        for i in ShallowCopy( parClasses ) do\n\n          if tmpMat[ i[1] ] = c then\n\n# Parallel classes fused:\n            for mem in i do\n              AddSet( tmp, mem );\n            od;\n\n            Remove( parClasses, Position( parClasses, i ) );\n\n          fi;\n\n        od;\n\n        Add( newParClasses, tmp );\n\n      od;\n\n      SortBy( newParClasses, Size );\n\n      return newParClasses;\n    end;    # updateParallelClasses\n\n\n\n##\n# Fast computation of connected components:\n\n    components := function( matrix )\n      local r, n, found, todo, unusedRows, tmp, j, i, comps, notFound;\n\n      r := NrRows( matrix );\n      n := NrColumns( matrix );\n\n      unusedRows := [ 1 .. r ];\n      notFound := [ 1 .. n ];\n      comps := [ ];\n\n      while not IsEmpty( notFound ) do\n\n        todo := [ Remove( notFound ) ];\n        found := [ todo[1] ];\n\n        while not IsEmpty( todo ) and not IsEmpty( notFound ) do\n\n          j := Remove( todo );\n\n          for i in ShallowCopy( unusedRows ) do\n\n            if not IsZero( MatElm( matrix, i, j ) ) then\n\n              RemoveSet( unusedRows, i );\n\n              tmp := Filtered( notFound, c -> not IsZero( MatElm( matrix, i, c ) ) );\n              todo := Union2( todo, tmp );\n              found := Union2( found, tmp );\n              notFound := Difference( notFound, tmp );\n\n            fi;\n\n          od;\n\n        od;\n\n        Add( comps, found );\n\n      od;\n\n      return comps;\n    end;    # components\n\n\n##\n# Deleted a parallel class, watch out for new coloops:\n\n    recursDelete := function( matrix, parClasses )\n      local nonColoops, z, comps, xFac, matrices, newParClasses, n;\n\n      n := NrColumns( matrix );\n\n      nonColoops := NonZeroRows( matrix );\n\n      xFac := NrRows( matrix ) - Size( nonColoops );\n\n      for z in ZeroRows( matrix ) do\n        Remove( parClasses, Position( parClasses, [ n + z ] ) );\n      od;\n\n      parClasses := List( parClasses, c -> List( c, function(x) if x > n then return x - Number( ZeroRows( matrix ), z -> n+z < x ); else return x; fi; end ) );\n\n      matrix := CertainRows( matrix, nonColoops );\n\n# Check whether the current minor is still connected:\n      comps := components( matrix );\n\n      if Size( comps ) > 1 then\n\n        matrices := List( comps, c -> CertainColumns( matrix, c ) );\n        matrices := List( matrices, m -> CertainRows( m, NonZeroRows( m ) ) );\n\n        newParClasses := List( matrices, m -> updateParallelClasses( m, List( [ 1 .. NrColumns(m) + NrRows(m) ], i -> [i] ) ) );      # possible TODO: suboptimal, could use parClasses\n\n        return x^xFac * Product( [ 1 .. Size( comps ) ], i -> generalRecursion( matrices[i], newParClasses[i] ) );\n\n      fi;\n\n      return x^xFac * generalRecursion( matrix, parClasses );\n    end;    # recursDelete\n\n\n##\n# Contracted a parallel class, check other classes (they may fuse!):\n\n    recursContract := function( matrix, parClasses )\n      local newParClasses, comps, matrices;\n\n# Also check whether the current minor is still connected:\n      comps := components( matrix );\n\n      if Size( comps ) > 1 then\n\n        matrices := List( comps, c -> CertainColumns( matrix, c ) );\n        matrices := List( matrices, m -> CertainRows( m, NonZeroRows( m ) ) );\n\n        newParClasses := List( matrices, m -> updateParallelClasses( m, List( [ 1 .. NrColumns(m) + NrRows(m) ], i -> [i] ) ) );      # possible TODO: suboptimal, could use parClasses\n\n        return Product( [ 1 .. Size( comps ) ], i -> generalRecursion( matrices[i], newParClasses[i] ) );\n\n      fi;\n\n      newParClasses := updateParallelClasses( matrix, parClasses );\n\n      return generalRecursion( matrix, newParClasses );\n    end;    # recursContract\n\n\n##\n# General recursion step. Find a class to reduce and compute the corresponding matrix.\n\n    generalRecursion := function( matrix, parClasses )\n      local rdim, cdim, containsUnitVec, nonZeroEntry, firstNZIndex, i, j, reduceColumn, newMat, gaussRows, conClasses, delClasses, tmp, largePC, lower, upper, gaussCols;\n\n      if not Set( Flat( parClasses ) ) = [ 1 .. NrColumns( matrix ) + NrRows( matrix ) ] then Error( ); fi;\n      if not ForAll( parClasses, IsSet ) then Error( ); fi;\n\n# Termination case:\n      rdim := NrRows( matrix );\n      cdim := NrColumns( matrix );\n\n      if rdim = 1 then\n        return x - 1 + Sum( [ 1 .. cdim + 1 ], j -> Binomial(cdim+1,j) * (y-1)^(j-1) );\n      elif cdim = 1 then\n        return y - 1 + Sum( [ 0 .. rdim ], j -> Binomial(rdim+1,j) * (x-1)^(rdim-j) );\n      elif rdim = 0 then\n        return y^cdim;\n      elif cdim = 0 then\n        return x^rdim;\n      fi;\n\n# Choose largest parallel class:\n      largePC := Remove( parClasses );\n\n      containsUnitVec := largePC[ Size(largePC) ] > cdim;\n\n# Find vector to reduce:\n      if containsUnitVec then     # choose a vector with a non-zero entry in the corresponding row to become the new unit vector for the deletion matrix\n\n        firstNZIndex := largePC[ Size(largePC) ] - cdim;\n\n        for i in Difference( [ 1 .. cdim ], largePC ) do\n\n          nonZeroEntry := MatElm( matrix, firstNZIndex, i );\n\n          if not IsZero( nonZeroEntry ) then\n\n            reduceColumn := i;\n\n            break;\n\n          fi;\n\n        od;\n\n        newMat := CertainColumns( matrix, Difference( [ 1 .. cdim ], Union2( largePC, [ reduceColumn ] ) ) );\n\n        gaussRows := [ 1 .. rdim ];\n        RemoveSet( gaussRows, firstNZIndex );\n\n# Adjust parallel classes:\n        conClasses := List( parClasses, c -> List( c, x -> x - Number( largePC, i -> i < x ) ) );\n\n        lower := reduceColumn - Number( largePC, i -> i < reduceColumn );\n        upper := cdim + firstNZIndex - Size( largePC );\n\n        delClasses := List( conClasses, c -> Set( List( c, function(x)\n                                                                  if x = lower then\n                                                                    return upper;\n                                                                  elif x > lower and x <= upper then\n                                                                    return x - 1;\n                                                                  else\n                                                                    return x;\n                                                                  fi;\n                                                           end\n                          )                     )     );\n\n      else                        # switch in a unit vector and gauss the matrix to find the contraction matrix\n\n        firstNZIndex := First( [ 1 .. rdim ], i -> not IsZero( MatElm( matrix, i, largePC[1] ) ) );\n\n        reduceColumn := largePC[1];\n\n        nonZeroEntry := MatElm( matrix, firstNZIndex, largePC[1] );\n\n\n        newMat := CertainColumns( matrix, Difference( [ 1 .. cdim ], largePC ) );\n        newMat := UnionOfColumns( newMat, HomalgMatrix( List( [ 1 .. rdim ],\n                                                              function(i)\n                                                                if i = firstNZIndex then\n                                                                  return [ one ];\n                                                                else\n                                                                  return [ zero ];\n                                                                fi;\n                                                              end ),\n                                                        ring )\n                                );\n\n        gaussRows := [ firstNZIndex + 1 .. rdim ];\n\n# Adjust parallel classes:\n        delClasses := List( parClasses, c -> List( c, x -> x - Number( largePC, i -> i < x ) ) );\n\n        lower := cdim + 1 - Size( largePC );\n        upper := cdim + firstNZIndex - Size( largePC );\n\n        conClasses := List( delClasses, c -> Set( List( c, function(x) if x = upper then\n                                                                    return lower;\n                                                                  elif x >= lower and x < upper then\n                                                                    return x + 1;\n                                                                  else\n                                                                    return x;\n                                                                  fi;\n                                                           end\n                          )                     )     );\n\n      fi;\n\n# Compute matrix for one of the minors:\n      gaussCols := Filtered( [ 1 .. NrColumns( newMat ) ], j -> not IsZero( MatElm( newMat, firstNZIndex, j ) ) );\n\n      newMat := EntriesOfHomalgMatrixAsListList( newMat );\n\n      for i in gaussRows do\n\n        tmp := MatElm( matrix, i, reduceColumn );\n\n        if not IsZero( tmp ) then\n\n          tmp := -tmp/nonZeroEntry;\n\n          for j in gaussCols do\n\n            newMat[i][j] := newMat[i][j] + tmp * newMat[firstNZIndex][j];\n\n          od;\n\n        fi;\n\n      od;\n\n      newMat := HomalgMatrix( newMat, ring );\n\n# Fire up the recursion.\n      if containsUnitVec then\n\n        return recursDelete( newMat, delClasses ) +\n               Sum( [ 0 .. Size( largePC )-1 ], i -> y^i ) *\n               recursContract( CertainRows( CertainColumns( matrix,\n                                                            Difference( [ 1 .. cdim ], largePC )\n                                                          ),\n                                            Difference( [ 1 .. rdim ], [ firstNZIndex ] )\n                                          ),\n                               conClasses\n                             );\n\n      else\n\n        return Sum( [ 0 .. Size( largePC )-1 ], i -> y^i ) * recursContract( CertainRows( newMat,\n                                                                                        Concatenation( [ 1 .. firstNZIndex - 1 ],\n                                                                                                       [ firstNZIndex + 1 .. rdim ]\n                                                                                                     )\n                                                                                      ),\n                                                                           conClasses\n                                                                         ) +\n               recursDelete( CertainColumns( matrix, Difference( [ 1 .. cdim ], largePC ) ), delClasses );\n\n      fi;\n\n    end;    # generalRecursion\n\n####\n# End of local functions. Initialisation:\n##\n\n    matrix := CertainRows( CertainColumns( matrix, NonZeroColumns( matrix ) ), NonZeroRows( matrix ) );\n\n    pcs := updateParallelClasses( matrix, List( [ 1 .. NrColumns(matrix) + NrRows(matrix) ], i -> [i] ) );\n\n    T := x^Size( Coloops( matroid ) ) * y^Size( Loops( matroid ) ) * generalRecursion( matrix, pcs );\n\n    if IsIdenticalObj( x, xy[1] ) and IsIdenticalObj( y, xy[2] ) then\n      SetTuttePolynomial( matroid, T );\n    fi;\n\n    return T;\n  end\n\n);\n\n## for calls of dual matroids\nInstallMethod( TuttePolynomial,\n                \"for matroids\",\n                [ IsMatroid, IsRingElement, IsRingElement ],\n                90,\n\n  function( matroid, y, x )\n    local xy;\n\n    xy := IndeterminatesOfTuttePolynomial( );\n\n    if not ( IsIdenticalObj( x, xy[1] ) and IsIdenticalObj( y, xy[2] ) ) then TryNextMethod( ); fi;\n\n    return Value( TuttePolynomial( matroid ), xy, [ y, x ] );\n  end\n\n);\n\n##\nInstallMethod( TuttePolynomial,\n                \"for matroids with Tutte polynomial\",\n                [ IsMatroid and HasTuttePolynomial, IsRingElement, IsRingElement ],\n                100,\n\n  function( matroid, x, y )\n    local T, xy;\n\n    T := TuttePolynomial( matroid );\n\n    xy := IndeterminatesOfTuttePolynomial( );\n\n    if IsIdenticalObj( x, xy[1] ) and IsIdenticalObj( y, xy[2] ) then\n      return T;\n    fi;\n\n    return Value( T, xy, [ x, y ] );\n  end\n\n);\n\n\n###########################\n## RankGeneratingPolynomial\n\n##\nInstallMethod( RankGeneratingPolynomial,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n    local xy, x, y;\n    xy := IndeterminatesOfTuttePolynomial( );\n    x := xy[1];\n    y := xy[2];\n    return Value( TuttePolynomial( matroid ), [ x, y ], [ x+1, y+1 ] );\n  end\n\n);\n\n\n###########################\n## CharacteristicPolynomial\n\n##\nInstallGlobalFunction( IndeterminateOfCharacteristicPolynomial,\n  function( arg )\n    local t;\n\n    if not IsBound( HOMALG_MATRICES.IndeterminateOfCharacteristicPolynomial ) then\n\n      if Length( arg ) > 0 and IsString( arg[1] ) then\n        t := arg[1];\n      else\n        t := \"t\";\n      fi;\n\n      t := Indeterminate( Integers, t );\n\n      HOMALG_MATRICES.IndeterminateOfCharacteristicPolynomial := t;\n    fi;\n\n    return HOMALG_MATRICES.IndeterminateOfCharacteristicPolynomial;\n\n  end\n\n);\n\n##\nInstallMethod( CharacteristicPolynomial,\n                \"for a matroid and a ring element\",\n                [ IsMatroid, IsRingElement ],\n\n  function( matroid, t )\n\n    return (-1)^RankOfMatroid( matroid ) * TuttePolynomial( matroid, 1 - t, 0 );\n\n  end\n\n);\n\n##\nInstallMethod( CharacteristicPolynomial,\n        \"for a matroid\",\n        [ IsMatroid ],\n\n  function( M )\n    local t;\n\n    t := IndeterminateOfCharacteristicPolynomial( );\n\n    return CharacteristicPolynomial( M, t );\n  end\n\n);\n\n\n#####################\n## PoincarePolynomial\n\n##\nInstallMethod( PoincarePolynomial,\n                \"for a matroid and a ring element\",\n                [ IsMatroid, IsRingElement ],\n\n  function( matroid, t )\n\n    return (-t)^RankOfMatroid( matroid ) * CharacteristicPolynomial( matroid, -t^-1 );\n\n  end\n\n);\n\n##\nInstallMethod( PoincarePolynomial,\n        \"for a matroid\",\n        [ IsMatroid ],\n\n  function( M )\n    local t;\n\n    t := IndeterminateOfCharacteristicPolynomial( );\n\n    return PoincarePolynomial( M, t );\n  end\n\n);\n\n##\nInstallMethod( LeadingCoefficientOfPoincarePolynomial,\n        \"for a matroid\",\n        [ IsMatroid ],\n\n  function( M )\n\n    return TuttePolynomial( M, 1, 0 );\n\n  end\n\n);\n\n\n########\n## Loops\n\n##\nInstallMethod( Loops,\n                \"for matroids with bases\",\n                [ IsAbstractMatroidRep and HasBases ],\n                40,\n\n  function( matroid )\n\n    return Coloops( DualMatroid( matroid ) );\n\n  end\n\n);\n\n##\nInstallMethod( Loops,\n                \"for matroids with circuits\",\n                [ IsAbstractMatroidRep and HasCircuits ],\n                30,\n\n  function( matroid )\n\n    return Union( Filtered( Circuits( matroid ), c -> Size(c) = 1 ) );\n\n  end\n\n);\n\n##\nInstallMethod( Loops,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n                30,\n\n  function( matroid )\n\n    return ZeroColumns( MatrixOfVectorMatroid( matroid ) );\n\n  end\n\n);\n\n##\nInstallMethod( Loops,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid ],\n                50,\n\n  function( matroid )\n\n    if RankOfMatroid( matroid ) = 0 then\n\n      return GroundSet( matroid );\n\n    else\n\n      return [ ];\n\n    fi;\n\n  end\n\n);\n\n##\nInstallMethod( Loops,\n                \"fallback method\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n    local isIndep;\n\n    isIndep := IndependenceOracle( matroid );\n\n    return Filtered( GroundSet( matroid ), l -> not isIndep( [l] ) );\n  end\n\n);\n\n\n##########\n## Coloops\n\n##\nInstallMethod( Coloops,\n                \"for matroids with bases\",\n                [ IsAbstractMatroidRep and HasBases ],\n                30,\n\n  function( matroid )\n    local is, b;\n\n    is := GroundSet( matroid );\n    for b in Bases( matroid ) do\n      is := Intersection2( is, b );\n      if IsEmpty( is ) then break; fi;\n    od;\n\n    return is;\n  end\n\n);\n\n##\nInstallMethod( Coloops,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n                40,\n\n  function( matroid )\n\n    if HasStandardMatrixOfVectorMatroid( matroid ) then\n\n      if IsEmpty( StandardMatrixOfVectorMatroid( matroid )[2] ) then\n\n        return GroundSet( matroid );\n\n      else\n\n        return List( ZeroRows( StandardMatrixOfVectorMatroid( matroid )[1] ), i -> Difference( GroundSet( matroid ), StandardMatrixOfVectorMatroid( matroid )[2] )[i] );\n\n      fi;\n\n    else\n\n      return Loops( DualMatroid( matroid ) );\n\n    fi;\n\n  end\n\n);\n\n##\nInstallMethod( Coloops,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid ],\n                50,\n\n  function( matroid )\n\n    if RankOfMatroid( matroid ) = Size( matroid ) then\n\n      return GroundSet( matroid );\n\n    else\n\n      return [ ];\n\n    fi;\n\n  end\n\n);\n\n##\nInstallMethod( Coloops,\n                \"for matroids with known dual\",\n                [ IsMatroid and HasDualMatroid ],\n                10,\n\n  function( matroid )\n\n    return Loops( DualMatroid( matroid ) );\n\n  end\n\n);\n\n##\nInstallMethod( Coloops,\n                \"fallback method\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n\n    return Difference( GroundSet( matroid ), Union( FundamentalCircuitsWithBasis( matroid )[1] ) );\n\n  end\n\n);\n\n\n####################\n## AutomorphismGroup\n\n##\nInstallMethod( AutomorphismGroup,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid ],\n                30,\n\n  function( matroid )\n\n    return SymmetricGroup( Size( matroid ) );\n\n  end\n\n);\n\n##\nInstallMethod( AutomorphismGroup,        # this is a HORRIBLE method\n                \"fallback method\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return Stabiliser( SymmetricGroup( Size(matroid) ), Bases(matroid), OnSetsSets );\n\n  end\n\n);\n\n\n#####################\n## KnownAutomorphisms\n\n##\nInstallMethod( KnownAutomorphisms,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return [ () ];\n\n  end\n\n);\n\n\n#########################\n## DirectSumDecomposition\n\n##\nInstallMethod( DirectSumDecomposition,\n                \"for connected matroids\",\n                [ IsMatroid and IsConnectedMatroid ],\n                30,\n\n  function( matroid )\n\n    return [ [ GroundSet(matroid), matroid ] ];\n\n  end\n\n);\n\n##\nInstallMethod( DirectSumDecomposition,\n                \"for matroids\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n    local fundcircs, circ, i, j, currentComponent, components, section;\n\n    fundcircs := ShallowCopy( FundamentalCircuitsWithBasis( matroid )[1] );\n    components := [ ];\n\n# Determine partition of ground set by fundamental circuits:\n\n    while not IsEmpty( fundcircs ) do\n\n      circ := Remove( fundcircs );\n      i := 1;\n      currentComponent := [ circ ];\n\n      while i <= Size( currentComponent ) do\n\n        circ := currentComponent[i];\n        j := 1;\n\n        while j <= Size( fundcircs ) do\n\n          section := Intersection2( fundcircs[j], circ );\n\n          if not IsEmpty( section ) then\n\n            Add( currentComponent, Remove(fundcircs,j) );\n\n          else\n\n            j := j + 1;\n\n          fi;\n\n        od;\n\n        i := i+1;\n\n      od;\n\n      AddSet( components, Union( currentComponent ) );\n\n    od;\n\n# Add components consisting of coloops:\n\n    components := Union2( components, List( Coloops(matroid), l -> [l] ) );\n\n# Check whether we found a non-trivial decomposition:\n\n    if Size( components ) = 1 then\n      SetIsConnectedMatroid( matroid, true );\n      return DirectSumDecomposition( matroid );\n    fi;\n\n# Otherwise, compute minors:\n\n    components := List( components, comp -> [ comp, RestrictionToComponentNC( matroid, comp ) ] );\n\n    return components;\n  end\n\n);\n\n\n######################\n## TwoSumDecomposition\n\n##\nInstallMethod( TwoSumDecomposition,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    # DO SOMETHING HERE\n\n  end\n\n);\n\n\n########\n## Flats\n\n##\nInstallMethod( Flats,\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return List( [ 0 .. RankOfMatroid( matroid ) ], r -> FlatsOfRank( matroid, r ) );\n\n  end\n\n);\n\n\n##\nInstallMethod( KnownCompleteRankSetsOfFlatsUpToColoops,\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return [ ];\n\n  end\n\n);\n\n\n############################\n## NonTrivialParallelClasses\n\n##\nInstallMethod( NonTrivialParallelClasses,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n    local parClasses, gSet, newClass, cl;\n\n    parClasses := [ ];\n    gSet := Difference( GroundSet( matroid ), Loops( matroid ) );\n    cl := ClosureOperator( matroid );\n\n    while not IsEmpty( gSet ) do\n      newClass := cl( [gSet[1]] );\n\n      gSet := Difference( gSet, newClass );\n\n      if Size( newClass ) > 1 then Add( parClasses, newClass ); fi;\n    od;\n\n    return parClasses;\n  end\n\n);\n\n\n####################################\n##\n## Properties\n##\n####################################\n\n###################\n## IsUniformMatroid\n\n##\nInstallMethod( IsUniformMatroid,\n                \"for matroids with bases\",\n                [ IsMatroid and HasBases ],\n                30,\n\n  function( matroid )\n    return Size( Bases( matroid ) ) = Binomial( Size( matroid ), RankOfMatroid( matroid ) );\n  end\n\n);\n\n##\nInstallMethod( IsUniformMatroid,\n                \"fallback method\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n    local k, isIndep, n, potIter, x;\n\n    n := Size( matroid );\n    k := RankOfMatroid( matroid );\n\n    if k = 0 or k = n then return true; fi;\n\n    isIndep := IndependenceOracle( matroid );\n\n    potIter := IteratorOfCombinations( [ 1 .. n ], k );\n\n    for x in potIter do\n      if not isIndep(x) then return false; fi;\n    od;\n\n    return true;\n  end\n\n);\n\n##\nInstallMethod( IsUniform,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return IsUniformMatroid( matroid );\n\n  end\n\n);\n\n\n##################\n## IsSimpleMatroid\n\n##\nInstallMethod( IsSimpleMatroid,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n    return IsEmpty( Loops( matroid ) ) and\n                  IsEmpty( NonTrivialParallelClasses( matroid ) );\n  end\n\n);\n\n##\nInstallMethod( IsSimple, \"for matroids\", [ IsMatroid ], IsSimpleMatroid );\n\n\n############\n## IsGraphic\n\n##\nInstallMethod( IsGraphic,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n  end\n\n);\n\n\n############\n## IsRegular\n\n##\nInstallMethod( IsRegular,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n  end\n\n);\n\n\n#####################\n## IsConnectedMatroid\n\n##\nInstallMethod( IsConnectedMatroid,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return Size( DirectSumDecomposition( matroid ) ) = 1;\n\n  end\n\n);\n\n##\nInstallMethod( IsConnected,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    return IsConnectedMatroid( matroid );\n\n  end\n\n);\n\n\n###############\n## Is3Connected\n\n##\nInstallMethod( Is3Connected,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n      return Size( TwoSumDecomposition( matroid ) ) = 1;\n\n  end\n\n);\n\n\n####################################\n##\n## Methods\n##\n####################################\n\n############\n## SomeBasis\n\n##\nInstallMethod( SomeBasis,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid ],\n                30,\n\n  function( matroid )\n\n    return [1..RankOfMatroid(matroid)];\n\n  end\n\n);\n\n##\nInstallMethod( SomeBasis,\n                \"for matroids with bases\",\n                [ IsMatroid and HasBases ],\n                30,\n\n  function( matroid )\n\n    return Bases( matroid )[1];\n\n  end\n\n);\n\n##\nInstallMethod( SomeBasis,\n                \"for matroids with known bases\",\n                [ IsMatroid and HasKnownBases ],\n                20,\n\n  function( matroid )\n\n    if not IsEmpty( KnownBases( matroid ) ) then\n      return KnownBases( matroid )[1];\n    else\n      TryNextMethod( );\n    fi;\n\n  end\n\n);\n\n##\nInstallMethod( SomeBasis,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n                10, \n\n  function( matroid )\n    local basis;\n\n    basis := Difference( GroundSet( matroid ), StandardMatrixOfVectorMatroid( matroid )[2] );\n    AddSet( KnownBases( matroid ), basis );\n\n    return basis;\n  end\n\n);\n\n##\nInstallMethod( SomeBasis,\n                \"fallback method\",\n                [ IsMatroid ],\n                0,\n\n  function( matroid )\n    local indep, tmp, i, isIndep;\n\n    isIndep := IndependenceOracle( matroid );\n    indep := [ ];\n    i := 1;\n\n    while i <= Size( matroid ) do\n\n      tmp := Union2( indep, [i] );\n\n      if isIndep( tmp ) then indep := tmp; fi;\n\n      i := i + 1;\n\n    od;\n\n    AddSet( KnownBases( matroid ), indep );\n\n    return indep;\n  end\n\n);\n\n\n########################\n## MatrixOfVectorMatroid\n\n##\nInstallMethod( MatrixOfVectorMatroid,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n\n  function( matroid )\n\n    if IsBound( matroid!.generatingMatrix ) then\n      return matroid!.generatingMatrix;\n    else\n      Error( \"this vector matroid apparently lost its matrix, this shouldn't happen\" );\n    fi;\n\n  end\n\n);\n\n\n#############\n## HomalgRing\n\n##\nInstallMethod( HomalgRing,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n\n  function( matroid )\n\n    return HomalgRing( MatrixOfVectorMatroid( matroid ) );\n\n  end\n\n);\n\n\n##############\n## FlatsOfRank\n\n##\nInstallMethod( FlatsOfRank,\n                \"for matroids\",\n                [ IsMatroid, IsInt ],\n\n  function( matroid, targetrank )\n    local loops, coloops, gset, cl, knownrank, n, pf, actualFlats, prospectiveFlats, lastlevel, i, col;\n\n    n := Size( matroid );\n\n    loops := ShallowCopy( Loops( matroid ) );\n    coloops := Coloops( matroid );\n\n    gset := Difference( GroundSet( matroid ), Union2( loops, coloops ) );\n\n    cl := ClosureOperator( matroid );\n\n    if targetrank = 0 then return [ loops ]; fi;\n\n    knownrank := Size( KnownCompleteRankSetsOfFlatsUpToColoops( matroid ) );\n\n    if knownrank = 0 then\n      KnownCompleteRankSetsOfFlatsUpToColoops( matroid )[1] := List( gset, x -> cl([x]) );\n      knownrank := 1;\n    fi;\n\n    # extend known flats by taking each known flat of the last level and combining it with rank 1 flats\n    while knownrank < targetrank do\n\n      lastlevel := KnownCompleteRankSetsOfFlatsUpToColoops( matroid )[ knownrank ];\n\n      prospectiveFlats := Union( List( lastlevel, f -> List( Intersection2( gset, [ Maximum(Difference(f,loops))+1 .. n ] ), i -> Concatenation( f, [i] ) ) ) );\n\n      actualFlats := [ ];\n\n      for pf in prospectiveFlats do\n\n        # this check should be much faster than closure computation for large matroids\n        if ForAny( actualFlats, f -> IsSubset(f,pf) ) then\n          continue;\n        fi;\n\n        Add( actualFlats, cl(pf) );\n\n      od;\n\n      Add( KnownCompleteRankSetsOfFlatsUpToColoops( matroid ), actualFlats );\n\n      knownrank := knownrank + 1;\n\n    od;\n\n    # return value will be actualFlats\n    # get correct layer in case no computation was necessary\n    actualFlats := StructuralCopy( KnownCompleteRankSetsOfFlatsUpToColoops( matroid )[ targetrank ] );\n\n    # now we need to take coloops into consideration\n    for i in [ 1 .. Minimum( targetrank - 1, Size( coloops ) ) ] do\n      for col in Combinations( coloops, i ) do\n\n        actualFlats := Union2( actualFlats, List(\n                                                  KnownCompleteRankSetsOfFlatsUpToColoops(matroid)[ targetrank - i ],\n                                                  f -> Union2( f, col )\n                                                ) );\n\n      od;\n    od;\n\n    if Size( coloops ) >= targetrank then\n      for col in Combinations( coloops, targetrank ) do\n        Add( actualFlats, Union2( loops, col ) );\n      od;\n    fi;\n\n    return actualFlats;\n  end\n\n);\n\n\n##########\n## MinorNL\n\n##\nInstallMethod( MinorNL,\n                \"for empty arguments\",\n                [ IsMatroid, IsList and IsEmpty, IsList and IsEmpty ],\n                50,\n\n  function( matroid, del, contr )\n\n    SetParentAttr( matroid, [ matroid, GroundSet( matroid ) ] );\n\n    return matroid;\n\n  end\n\n);\n\n##\nInstallMethod( MinorNL,\n                \"fallback method for connected matroids\",\n                [ IsMatroid and IsConnectedMatroid, IsList, IsList ],\n                0,\n\n  function( matroid, del, contr )\n\n    Bases( matroid );\n\n    return MinorNL( matroid, del, contr );\n\n  end\n\n);\n\n##\nInstallMethod( MinorNL,\n                \"for disconnected matroids\",\n                [ IsMatroid and HasDirectSumDecomposition, IsList, IsList ],\n                30,\n\n  function( matroid, del, contr )\n    local minor, newGroundS, dsd;\n\n    if HasIsConnectedMatroid( matroid ) and IsConnectedMatroid( matroid ) and IsIdenticalObj( matroid, DirectSumDecomposition(matroid)[1][2] ) then\n      TryNextMethod( );\n    fi;\n\n    dsd := DirectSumDecomposition( matroid );\n    newGroundS := Difference( GroundSet(matroid), Union2(del,contr) );\n\n    minor := Iterated( List( dsd, s -> MinorNL( s[2],\n                                                List( Intersection2(del,s[1]), i -> Position(s[1],i) ),\n                                                List( Intersection2(contr,s[1]), i -> Position(s[1],i) ) )\n                           ),\n                       DirectSumOfMatroidsNL\n                     );\n\n    # make sure ParentAttr contains the correct indices:\n\n    ObjectifyWithAttributes( minor, TheTypeMinorOfAbstractMatroid,\n                             ParentAttr, [ matroid, Concatenation( List( dsd, s -> Intersection2( s[1], newGroundS ) ) ) ] );\n\n    return minor;\n  end\n\n);\n\n##\nInstallMethod( MinorNL,\n                \"for uniform matroids\",\n                [ IsMatroid and IsUniformMatroid, IsList, IsList ],\n                30,\n\n  function( matroid, del, contr )\n    local minor, minSize, minRank;\n\n    minSize := Size(matroid) - Size(del) - Size(contr);\n    minRank := Maximum( Minimum( RankOfMatroid(matroid) - Size(contr), minSize ), 0 );\n\n    minor := UniformMatroid( minRank, minSize );\n\n    ObjectifyWithAttributes( minor, TheTypeMinorOfAbstractMatroid,\n                        ParentAttr, [ matroid, Difference( GroundSet(matroid), Union2(del,contr) ) ] );\n\n    return minor;\n  end\n\n);\n\n##\nInstallMethod( MinorNL,\n                \"for matroids with bases\",\n                [ IsAbstractMatroidRep and HasBases, IsList, IsList ],\n                10,\n\n  function( matroid, del, contr )\n    local minorBases, t, sdel, scontr, minor, loopsColoops, groundSetInParent;\n\n    sdel := Set( del );\n    scontr := Set( contr );\n    if not IsEmpty( Intersection2( sdel, scontr ) ) then Error( \"<del> and <contr> must not meet\" ); fi;\n\n# If loops or coloops will be deleted or contracted, delete rather than contract:\n\n    loopsColoops := Intersection2( Union2( Loops( matroid ), Coloops( matroid ) ), scontr );\n    scontr := Difference( scontr, loopsColoops );\n    sdel := Union2( sdel, loopsColoops );\n\n    minorBases := ShallowCopy( Bases( matroid ) );\n\n# Deletion:\n\n    for t in sdel do\n      if ForAll( minorBases, b -> t in b ) then\t\t# t is a coloop in the current minor\n        minorBases := List( minorBases, b -> Difference(b,[t]) );\n      else\n        minorBases := Filtered( minorBases, b -> not t in b );\n      fi;\n    od;\n\n# Contraction:\n\n    for t in scontr do\n      if ForAny( minorBases, b -> t in b ) then\t\t# t is not a loop in the current minor\n        minorBases := List( Filtered( minorBases, b -> t in b ), b -> Difference(b,[t]) );\n      fi;\n    od;\n\n# Map bases to canonical ground set:\n\n    groundSetInParent := Difference( GroundSet( matroid ), Union2( sdel, scontr ) );\n    minorBases := List( minorBases, b -> List( b, i -> Position( groundSetInParent, i ) ) );\n\n# Construct minor:\n\n    minor := rec( );\n\n    ObjectifyWithAttributes( minor, TheTypeMinorOfAbstractMatroid,\n                             Size, Size( groundSetInParent ),\n                             Bases, minorBases,\n                             ParentAttr, [ matroid, groundSetInParent ]\n                           );\n\n    return minor;\n  end\n\n);\n\n##\nInstallMethod( MinorNL,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep, IsList, IsList ],\n                12,\n\n  function( matroid, del, contr )\n    local loopsColoops, sdel, scontr, minorMat, minor, col, row, actRows, actCols, foundRow, foundCoeff, rowCoeff, calcCol, t, mat, ring;\n\n    ring := HomalgRing( matroid );\n\n    if not ( HasIsFieldForHomalg(ring) and IsFieldForHomalg(ring) ) then\n      TryNextMethod();\n    fi;\n\n    sdel := Set( del );\n    scontr := Set( contr );\n\n    if not IsEmpty( Intersection2( sdel, scontr ) ) then Error( \"<del> and <contr> must not meet\" ); fi;\n    if not IsSubset( [ 1 .. Size( matroid ) ], Union2( sdel, scontr ) ) then Error( \"<del> and <contr> must be subsets of the column labels of <matroid>\" ); fi;\n\n# If loops or coloops will be deleted or contracted, delete rather than contract:\n\n    loopsColoops := Intersection2( Union2( Loops( matroid ), Coloops( matroid ) ), scontr );\n    scontr := Difference( scontr, loopsColoops );\n    sdel := Union2( sdel, loopsColoops );\n\n# Delete columns and prepare matrix for contraction:\n\n    mat := MatrixOfVectorMatroid( matroid );\n    minorMat := EntriesOfHomalgMatrixAsListList( mat );\n    actCols := Difference( GroundSet( matroid ), sdel );\n\n# Contraction:\n\n    if NrRows(mat) > 0 then\n\n      actRows := [ 1 .. DimensionsMat( minorMat )[1] ];\n      for col in scontr do\n\n        actCols := Difference( actCols, [ col ] );\n        foundRow := 0;\n        for row in actRows do\n\n          rowCoeff := minorMat[row][col];\n          if not IsZero( rowCoeff ) then\n\n            if foundRow = 0 then\n\n              foundRow := row;\n              foundCoeff := rowCoeff;\n\n            else\n\n              rowCoeff := rowCoeff/foundCoeff;\n              for calcCol in actCols do\n                minorMat[row][calcCol] := minorMat[row][calcCol] - rowCoeff * minorMat[foundRow][calcCol];\n              od;\n\n            fi;\n\n          fi;\n\n        od;\n        actRows := Difference( actRows, [ foundRow ] );\n\n      od;\n\n    else\n\n      actRows := [ ];\n\n    fi;\n\n    if IsEmpty( actRows ) then\n      minorMat := HomalgMatrix( [ ], 0, Size( actCols ), HomalgRing( mat ) );\n    else\n      minorMat := CertainColumns( CertainRows( HomalgMatrix( minorMat, HomalgRing( mat ) ), actRows ), actCols );\n    fi;\n\n    minor := rec( generatingMatrix := Immutable( minorMat ) );\n    ObjectifyWithAttributes( minor, TheTypeMinorOfVectorMatroid,\n                           ParentAttr, [ matroid, Difference( GroundSet( matroid ), Union2( sdel, scontr ) ) ]\n                         );\n\n    return minor;\n  end\n\n);\n\n\n########\n## Minor\n\n##\nInstallMethod( Minor,\n                \"for abstract matroids\",\n                [ IsMatroid, IsList, IsList ],\n\n  function( mat, del, con )\n    local min;\n\n    min := MinorNL( mat, del, con );\n    _alcove_MatroidStandardImplications( min );\n\n    return min;\n  end\n\n);\n\n##\nInstallMethod( Minor,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep, IsList, IsList ],\n                10,\n\n  function( mat, del, con )\n    local min;\n\n    min := MinorNL( mat, del, con );\n    _alcove_MatroidStandardImplications( min );\n    _alcove_VectorMatroidImplications( min );\n\n    return min;\n  end\n\n);\n\n\n##############\n## Restriction\n\n##\nInstallMethod( Restriction,\n                \"for matroids\",\n                [ IsMatroid, IsList ],\n\n  function( matroid, res )\n\n    return Deletion( matroid, Difference( GroundSet(matroid), res ) );\n\n  end\n\n);\n\n\n###########\n## Deletion\n\n##\nInstallMethod( Deletion,\n                \"for matroids\",\n                [ IsMatroid, IsList ],\n\n  function( matroid, del )\n\n    return Minor( matroid, del, [ ] );\n\n  end\n\n);\n\n\n##############\n## Contraction\n\n##\nInstallMethod( Contraction,\n                \"for matroids\",\n                [ IsMatroid, IsList ],\n\n  function( matroid, contr )\n\n    return Minor( matroid, [ ], contr );\n\n  end\n\n);\n\n\n###########################\n## RestrictionToComponentNC\n\n##\nInstallMethod( RestrictionToComponentNC,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep, IsList ],\n                50,\n\n  function( matroid, component )\n    local minor;\n\n    minor := Deletion( matroid, Difference( GroundSet( matroid ), component ) );\n    SetIsConnectedMatroid( minor, true );\n\n    return minor;\n  end\n\n);\n\n##\nInstallMethod( RestrictionToComponentNC,\n                \"for matroids with bases\",\n                [ IsMatroid and HasBases, IsList ],\n                30,\n\n  function( matroid, component )\n    local bases, rank, minor;\n\n    component := Set( component );\n\n    bases := Set( List( Bases( matroid ), b -> Intersection2( b, component ) ) );\n\n    rank := Maximum( List( bases, Size ) );\n\n    bases := Filtered( bases, b -> Size(b) = rank );\n\n    bases := List( bases, b -> List( b, i -> Position( component, i ) ) );\n\n    minor := rec( );\n\n    ObjectifyWithAttributes( minor, TheTypeMinorOfAbstractMatroid,\n                             Size, Size( component ),\n                             Bases, bases,\n                             RankOfMatroid, rank,\n                             ParentAttr, [ matroid, component ],\n                             IsConnectedMatroid, true\n                           );\n\n    return minor;\n  end\n\n);\n\n##\nInstallMethod( RestrictionToComponentNC,\n                \"for matroids with circuits\",\n                [ IsMatroid and HasCircuits, IsList ],\n                40,\n\n  function( matroid, component )\n    local circs, minor;\n\n    component := Set( component );\n\n    circs := Filtered( Circuits( matroid ), c -> IsSubset( component, c ) );\n\n    circs := List( circs, c -> List( c, i -> Position( component, i ) ) );\n\n    minor := rec( );\n\n    ObjectifyWithAttributes( minor, TheTypeMinorOfAbstractMatroid,\n                             Size, Size( component ),\n                             Circuits, circs,\n                             ParentAttr, [ matroid, component ],\n                             IsConnectedMatroid, true\n                           );\n\n    return minor;\n  end\n\n);\n\n##\nInstallMethod( RestrictionToComponentNC,\n                \"for matroids with a rank function\",\n                [ IsMatroid and HasRankFunction, IsList ],\n\n  function( matroid, component )\n    local matRkFun, rkFun, minor;\n\n    matRkFun := RankFunction( matroid );\n\n    rkFun := subset -> matRkFun( List( subset, i -> component[i] ) );\n\n    minor := rec( );\n\n    ObjectifyWithAttributes( minor, TheTypeMinorOfAbstractMatroid,\n                             Size, Size( component ),\n                             RankFunction, rkFun,\n                             ParentAttr, [ matroid, component ],\n                             IsConnectedMatroid, true\n                           );\n\n    return minor;\n  end\n\n);\n\n##\nInstallMethod( RestrictionToComponentNC,\n                \"for matroids with an independence oracle\",\n                [ IsMatroid and HasIndependenceOracle, IsList ],\n\n  function( matroid, component )\n    local matIsIndep, isIndep, minor;\n\n    matIsIndep := IndependenceOracle( matroid );\n\n    isIndep := subset -> matIsIndep( List( subset, i -> component[i] ) );\n\n    minor := rec( );\n\n    ObjectifyWithAttributes( minor, TheTypeMinorOfAbstractMatroid,\n                             Size, Size( component ),\n                             IndependenceOracle, isIndep,\n                             ParentAttr, [ matroid, component ],\n                             IsConnectedMatroid, true\n                           );\n\n    return minor;\n  end\n\n);\n\n\n##########\n## IsMinor\n\n##\nInstallMethod( IsMinor,\n                \"for matroids\",\n                [ IsMatroid, IsMinorOfMatroid ],\n\n  function( matroid, minor )\n    local parent;\n\n    parent := ParentAttr( minor )[1];\n    if IsMinorOfMatroid( parent ) then\n      return IsMinor( matroid, parent );\n    else\n      return IsIdenticalObj( matroid, parent );\n    fi;\n\n  end\n\n);\n\n\n######################\n## DirectSumOfMatroids\n\n##\nInstallMethod( DirectSumOfMatroidsNL,\n                \"for matroids\",\n                [ IsMatroid, IsMatroid ],\n\n  function( m1, m2 )\n    local sum, size1, size2, subs;\n\n    size1 := Size(m1);\n    size2 := Size(m2);\n    subs := List( GroundSet(m2), i -> i+size1 );\n\n    sum := rec( );\n    ObjectifyWithAttributes( sum, TheTypeAbstractMatroid,\n                             Size, size1 + size2,\n                             RankOfMatroid, RankOfMatroid(m1) + RankOfMatroid(m2),\n                             DirectSumDecomposition, Concatenation( DirectSumDecomposition(m1),\n                                                                    List( DirectSumDecomposition(m2), tup -> [ List(tup[1],j->subs[j]), tup[2] ] ) ),\n                             IsConnectedMatroid, IsConnectedMatroid(m1) and IsConnectedMatroid(m2) and ( size1 = 0 ) or ( size2 = 0 )\n                           );\n\n    return sum;\n  end\n\n);\n\n##\nInstallMethod( DirectSumOfMatroids,\n                \"for matroids\",\n                [ IsMatroid, IsMatroid ],\n\n  function( m1, m2 )\n    local sum;\n\n    sum := DirectSumOfMatroidsNL(m1,m2);\n\n    _alcove_MatroidStandardImplications( sum );\n\n    return sum;\n  end\n\n);\n\n\n###################\n## TwoSumOfMatroids\n\n##\nInstallMethod( TwoSumOfMatroidsNL,\n                \"for matroids\",\n                [ IsMatroid, IsInt, IsMatroid, IsInt ],\n\n  function( m1, p1, m2, p2 )\n    local sum, size1, size2;\n\n    size1 := Size( m1 );\n    size2 := Size( m2 );\n\n    if size1 < 3 or size2 < 3 then\n      Error( \"both matroids must have at least 3 elements\" );\n    fi;\n\n    if p1 in Loops( m1 ) or p1 in Coloops( m1 ) or p2 in Loops( m2 ) or p2 in Coloops( m2 ) then\n      Error( \"base points must be neither loops nor coloops in their respective matroids\" );\n    fi;\n\n    sum := rec( );\n    ObjectifyWithAttributes( sum, TheTypeAbstractMatroid,\n                             Size, size1 + size2 - 2,\n                             RankOfMatroid, RankOfMatroid(m1) + RankOfMatroid(m2) - 1,\n                             TwoSumDecomposition, [ m1, p1, Concatenation( [ 1 .. p1-1 ], [0], [ p1 .. size1-1 ] ),\n                                                    m2, p2, Concatenation( [ size1 .. size1+p2-2 ], [0], [ size1+p2-1 .. size1+size2-2 ] ) ],\n                             Is3Connected, false\n                           );\n\n    return sum;\n  end\n\n);\n\n##\nInstallMethod( TwoSumOfMatroidsNL,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep, IsInt, IsVectorMatroidRep, IsInt ],\n\n  function( m1, p1, m2, p2 )\n    local sum, size1, size2, ring, mat1, mat2, source, r0, r, c;\n\n    ring := HomalgRing( m1 );\n    if not IsIdenticalObj( ring, HomalgRing( m2 ) ) then\t\t\t\t\t## FIGURE OUT HOW TO SOLVE THIS PROPERLY\n      Error( \"please make sure that the underlying rings of the matroids' matrices are identical\" );\n#   TryNextMethod( );\n    fi;\n\n    if not ( HasIsFieldForHomalg(ring) and IsFieldForHomalg(ring) ) then\n      TryNextMethod();\n    fi;\n\n    size1 := Size( m1 );\n    size2 := Size( m2 );\n\n    if size1 < 3 or size2 < 3 then\n      Error( \"both matroids must have at least 3 elements\" );\n    fi;\n\n    if p1 in Loops( m1 ) or p1 in Coloops( m1 ) or p2 in Loops( m2 ) or p2 in Coloops( m2 ) then\n      Error( \"base points must be neither loops nor coloops in their respective matroids\" );\n    fi;\n\n# Compute equivalent matrix for m1 having p1 as unit vector:\n\n    source := MatrixOfVectorMatroid( m1 );\n    mat1 := EntriesOfHomalgMatrixAsListList( CertainColumns( source, Difference( [1..size1], [p1] ) ) );\n\n    r0 := 0;\n    for r in Reversed( [ 1 .. Size( mat1 ) ] ) do\n\n      c := MatElm( source, r, p1 );\n\n      if not IsZero( c ) then\n\n        if r0 = 0 then\n          r0 := r;\n          mat1[r] := 1/c * mat1[r];\n        else\n          mat1[r] := mat1[r] - c * mat1[r0];\n        fi;\n\n      fi;\n\n    od;\n\n# Swap rows:\n\n    if r0 <> Size(mat1) then\n      r := mat1[Size(mat1)];\n      mat1[Size(mat1)] := mat1[r0];\n      mat1[r0] := r;\n    fi;\n\n    mat1 := HomalgMatrix( mat1, ring );\n\n# Compute equivalent matrix for m2 having p2 as unit vector:\n\n    source := MatrixOfVectorMatroid( m2 );\n    mat2 := EntriesOfHomalgMatrixAsListList( CertainColumns( source, Difference( [1..size2], [p2] ) ) );\n\n    r0 := 0;\n    for r in [ 1 .. Size( mat2 ) ] do\n\n      c := MatElm( source, r, p2 );\n\n      if not IsZero( c ) then\n\n        if r0 = 0 then\n          r0 := r;\n          mat2[r] := 1/c * mat2[r];\n        else\n          mat2[r] := mat2[r] - c * mat2[r0];\n        fi;\n\n      fi;\n\n    od;\n\n# Swap rows:\n\n    if r0 <> 1 then\n      r := mat2[1];\n      mat2[1] := mat2[r0];\n      mat2[r0] := r;\n    fi;\n\n    mat2 := HomalgMatrix( mat2, ring );\n\n# Build new matrix and create object:\n\n    sum := rec( generatingMatrix := UnionOfColumns(\n                                      UnionOfRows( mat1, HomalgZeroMatrix( NrRows(mat2)-1, NrColumns(mat1), ring ) ),\n                                      UnionOfRows( HomalgZeroMatrix( NrRows(mat1)-1, NrColumns(mat2), ring ), mat2 ) )\n              );\n\n    ObjectifyWithAttributes( sum, TheTypeVectorMatroid,\n                             Size, size1 + size2 - 2,\n                             RankOfMatroid, RankOfMatroid(m1) + RankOfMatroid(m2) - 1,\n                             TwoSumDecomposition, [ m1, p1, Concatenation( [ 1 .. p1-1 ], [0], [ p1 .. size1-1 ] ),\n                                                    m2, p2, Concatenation( [ size1 .. size1+p2-2 ], [0], [ size1+p2-1 .. size1+size2-2 ] ) ],\n                             Is3Connected, false\n                           );\n\n    return sum;\n  end\n\n);\n\n##\nInstallMethod( TwoSumOfMatroids,\n                \"for matroids\",\n                [ IsMatroid, IsInt, IsMatroid, IsInt ],\n\n  function( m1, p1, m2, p2 )\n    local sum;\n\n    sum := TwoSumOfMatroidsNL( m1, p1, m2, p2 );\n\n    _alcove_MatroidStandardImplications( sum );\n\n    return sum;\n  end\n\n);\n\n##\nInstallMethod( TwoSum,\n                \"for matroids\",\n                [ IsMatroid, IsInt, IsMatroid, IsInt ],\n\n  TwoSumOfMatroids\n\n);\n\n##\nInstallMethod( TwoSumNL,\n                \"for matroids\",\n                [ IsMatroid, IsInt, IsMatroid, IsInt ],\n\n  TwoSumOfMatroidsNL\n\n);\n\n\n####################################\n##\n## Operators\n##\n####################################\n\n############\n## Addition:\n\n##\nInstallMethod( \\+,\n                \"direct sum of matroids\",\n                [ IsMatroid, IsMatroid ],\n\n  DirectSumOfMatroids\n\n);\n\n\n#########\n## Equal:\n\n##\nInstallMethod( \\=,\n                \"for matroids with bases\",\n                [ IsMatroid and IsConnectedMatroid and HasBases, IsMatroid and IsConnectedMatroid and HasBases ],\n                20,\n\n  function( m1, m2 )\n\n    return Size(m1) = Size(m2) and Bases(m1) = Bases(m2);\n\n  end\n\n);\n\n##\nInstallMethod( \\=,\n                \"for matroids with circuits\",\n                [ IsMatroid and IsConnectedMatroid and HasCircuits, IsMatroid and IsConnectedMatroid and HasCircuits ],\n                30,\n\n  function( m1, m2 )\n\n    return Size(m1) = Size(m2) and Circuits(m1) = Circuits(m2);\n\n  end\n\n);\n\n##                                                                                                        ## NAIVE METHOD\nInstallMethod( \\=,\n                \"fallback method\",\n                [ IsMatroid and IsConnectedMatroid, IsMatroid and IsConnectedMatroid ],\n                10,\n\n  function( m1, m2 )\n\n    if Size(m1) <> Size(m2) then return false; fi;\n    if RankOfMatroid(m1) <> RankOfMatroid(m2) then return false; fi;\n\n    return Circuits(m1) = Circuits(m2);\n\n  end\n\n);\n\n##\nInstallMethod( \\=,\n                \"for disconnected matroids\",\n                [ IsMatroid, IsMatroid ],\n                0,\n\n  function( m1, m2 )\n\n    return DirectSumDecomposition( m1 ) = DirectSumDecomposition( m2 );\n\n  end\n\n);\n\n\n####################################\n##\n## Constructors\n##\n####################################\n\n########\n## Copy:\n\n##\nInstallMethod( Matroid,\n                \"copy constructor\",\n                [ IsMatroid ],\n\n  IdFunc\n\n);\n\n\n###################\n## Vector matroids:\n\n##\nInstallMethod( Matroid,\n                \"by empty matrix\",\n                [ IsGeneralizedRowVector and IsNearAdditiveElementWithInverse and IsAdditiveElement ],\n\n  function( mat )\n    local matroid;\n\n    if not IsEmpty( mat[1] ) then Error( \"constructor for empty vector matroids called on non-empty matrix\" ); fi;\n\n    matroid := rec( generatingMatrix := Immutable( HomalgMatrix(mat,HomalgRingOfIntegers(2)) ) );\n    ObjectifyWithAttributes( matroid, TheTypeVectorMatroid,\n                             Size, 0,\n                             RankOfMatroid, 0\n                           );\n\n    _alcove_MatroidStandardImplications( matroid );\n    _alcove_VectorMatroidImplications( matroid );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidNL,\n                \"by homalg matrix, no logical implications\",\n                [ IsHomalgMatrix ],\n                30,\n\n  function( matobj )\n    local matroid, ring;\n\n    ring := HomalgRing( matobj );\n\n    if not ( HasIsFieldForHomalg(ring) and IsFieldForHomalg(ring) ) then\n      Info( InfoWarning, 1, \"Trying to define a representable matroid over a ring which is not a FieldForHomalg.\" );\n      Info( InfoWarning, 1, \"This feature is experimental and may force alcove to use less efficient algorithms,\" );\n      Info( InfoWarning, 1, \"possibly leading to tremendous performance losses.\" );\n    fi;\n\n    matroid := Objectify( TheTypeVectorMatroid, rec( generatingMatrix := Immutable(matobj) ) );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( Matroid,\n                \"by homalg matrix\",\n                [ IsHomalgMatrix ],\n                30,\n\n  function( matobj )\n    local matroid;\n\n    matroid := MatroidNL( matobj );\n\n    _alcove_MatroidStandardImplications( matroid );\n    _alcove_VectorMatroidImplications( matroid );\n\n    return matroid;\n  end\n\n);\n\n\n#####################\n## Abstract matroids:\n\n##\nInstallMethod( MatroidByBases,\n                \"by size of ground set and list of bases\",\n                [ IsInt, IsList ],\n\n  function( deg, baselist  )\n    local matroid;\n\n# Convert lists to sets if necessary:\n    baselist := Set( List( baselist, Set ) );\n\n    if IsEmpty( baselist ) then Error( \"the list of bases must be non-empty\" ); fi;\n\n    if ForAny( baselist, i -> not IsSubset( [1..deg], i ) ) then\n      Error( \"elements of <baselist> must be subsets of [1..<deg>]\" );\n    fi;\n\n# Check basis exchange axiom:\n    if ForAny( baselist, b1 -> ForAny( baselist, b2 ->\n                ForAny( Difference(b1,b2), e -> ForAll( Difference(b2,b1), f ->\n                                                  not Union2( Difference( b1, [e] ), [f] ) in baselist\n                ) )\n    ) ) then Error( \"bases must satisfy the exchange axiom\" ); fi;\n\n    matroid := MatroidByBasesNCL( deg, baselist );\n\n    _alcove_MatroidStandardImplications( matroid );\n\n    return matroid;\n\n  end\n\n);\n\n##\nInstallMethod( MatroidByBasesNC,\n                \"by size of ground set and list of bases, no checks\",\n                [ IsInt, IsList ],\n\n  function( deg, baselist )\n    local matroid;\n\n    matroid := MatroidByBasesNCL( deg, baselist );\n\n    _alcove_MatroidStandardImplications( matroid );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByBasesNCL,\n                \"by size of ground set and list of bases, no checks or logical implications\",\n                [ IsInt, IsList ],\n\n  function( deg, baselist  )\n    local matroid;\n\n    matroid := rec( );\n    ObjectifyWithAttributes( matroid, TheTypeAbstractMatroid,\n                        Bases, baselist,\n                        Size, deg );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByBases,\n                \"by ground set and list of bases\",\n                [ IsList, IsList ],\n\n  function( groundSet, bases )\n    local m;\n\n    m := MatroidByBases( Size( groundSet ), List( bases, b -> List( b, e -> Position( groundSet, e ) ) ) );\n\n    SetNominalGroundSet( m, groundSet );\n\n    return m;\n  end\n\n);\n\n##\nInstallMethod( MatroidByBasesNC,\n                \"by ground set and list of bases, no checks\",\n                [ IsList, IsList ],\n\n  function( groundSet, bases )\n    local m;\n\n    m := MatroidByBasesNC( Size( groundSet ), List( bases, b -> List( b, e -> Position( groundSet, e ) ) ) );\n\n    SetNominalGroundSet( m, groundSet );\n\n    return m;\n  end\n\n);\n\n##\nInstallMethod( MatroidByBasesNCL,\n                \"by ground set and list of bases, no checks or logical implications\",\n                [ IsList, IsList ],\n\n  function( groundSet, bases )\n    local m;\n\n    m := MatroidByBasesNCL( Size( groundSet ), List( bases, b -> List( b, e -> Position( groundSet, e ) ) ) );\n\n    SetNominalGroundSet( m, groundSet );\n\n    return m;\n  end\n\n);\n\n###\n#InstallMethod( MatroidByIndependenceOracle,\n#                \"given size of ground set and boolean function deciding independence of subsets\",\n#                [ IsInt, IsFunction ],\n#\n# function( size, isIndep )\n#  local matroid;\n#\n#  #####\n#  ## Checks go here!\n#  #####\n#\n#  matroid := MatroidByIndependenceOracleNCL( size, isIndep );\n#\n#  _alcove_MatroidStandardImplications( matroid );\n#\n#  return matroid;\n# end\n#\n#);\n\n##\nInstallMethod( MatroidByIndependenceOracleNC,\n                \"given size of ground set and boolean function deciding independence of subsets, no checks\",\n                [ IsInt, IsFunction ],\n\n  function( size, isIndep )\n    local matroid;\n\n    matroid := MatroidByIndependenceOracleNCL( size, isIndep );\n\n    _alcove_MatroidStandardImplications( matroid );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByIndependenceOracleNCL,\n                \"given size of ground set and boolean function deciding independence of subsets, no checks or logical implications\",\n                [ IsInt, IsFunction ],\n\n  function( size, isIndep )\n    local matroid;\n\n    matroid := rec( );\n    ObjectifyWithAttributes( matroid, TheTypeAbstractMatroid,\n                        Size, size,\n                        IndependenceOracle, isIndep );\n\n    return matroid;\n  end\n\n);\n\n###\n#InstallMethod( MatroidByIndependenceOracle,\n#                \"given ground set and boolean function deciding independence of subsets\",\n#                [ IsList, IsFunction ],\n#\n# function( groundSet, isIndep )\n#\n#  if groundSet = [ 1 .. Size( groundSet ) ] then\n#\n#   return MatroidByIndependenceOracle( Size( groundSet ), isIndep );\n#\n#  else\n#\n#   return MatroidByIndependenceOracle( Size( groundSet ), function(subset) return isIndep( List( subset, i -> groundSet[i] ) ); end );\n#\n#  fi;\n#\n# end\n#\n#);\n\n##\nInstallMethod( MatroidByIndependenceOracleNC,\n                \"given ground set and boolean function deciding independence of subsets, no checks\",\n                [ IsList, IsFunction ],\n\n  function( gset, isIndep )\n    local matroid;\n\n    matroid := MatroidByIndependenceOracleNCL( gset, isIndep );\n\n    _alcove_MatroidStandardImplications( matroid );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByIndependenceOracleNCL,\n                \"given ground set and boolean function deciding independence of subsets, no checks or logical implications\",\n                [ IsList, IsFunction ],\n\n  function( groundSet, isIndep )\n    local m;\n\n    if groundSet = [ 1 .. Size( groundSet ) ] then\n\n      return MatroidByIndependenceOracleNCL( Size( groundSet ), isIndep );\n\n    else\n\n      m := MatroidByIndependenceOracleNCL( Size( groundSet ), function(subset) return isIndep( List( subset, i -> groundSet[i] ) ); end );\n\n      SetNominalGroundSet( m, groundSet );\n\n      return m;\n\n    fi;\n\n  end\n\n);\n\n##\nInstallMethod( MatroidByCircuits,\n                \"given size of ground set and list of circuits\",\n                [ IsInt, IsList ],\n\n  function( size, circs )\n    local matroid;\n\n# Convert lists to sets if necessary:\n    circs := Set( List( circs, Set ) );\n\n# Check circuit axioms:\n    if [ ] in circs then Error( \"the empty set must not be a circuit\" ); fi;\n\n    if ForAny( circs, c1 -> ForAny( circs, c2 -> c1 <> c2 and IsSubset( c1, c2 ) ) ) then\n      Error( \"circuits must not contain each other\" );\n    fi;\n\n    if ForAny( circs, c1 ->\n                ForAny( circs, c2 -> c1 <> c2 and\n                        ForAny( Intersection2( c1, c2 ), i ->\n                                ForAll( circs, c3 -> not IsSubset( Difference( Union2( c1, c2 ), [i] ), c3 ) )\n                        )\n                )\n             ) then\n      Error( \"circuits must satisfy the circuit elimination axiom\" );\n    fi;\n\n    matroid := MatroidByCircuitsNCL( size, circs );\n\n    _alcove_MatroidStandardImplications( matroid );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByCircuitsNC,\n                \"given size of ground set and list of circuits, no checks\",\n                [ IsInt, IsList ],\n\n  function( size, circs )\n    local matroid;\n\n    matroid := MatroidByCircuitsNCL( size, circs );\n\n    _alcove_MatroidStandardImplications( matroid );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByCircuitsNCL,\n                \"given size of ground set and list of circuits, no checks or logical implications\",\n                [ IsInt, IsList ],\n\n  function( size, circs )\n    local matroid;\n\n    matroid := rec( );\n    ObjectifyWithAttributes( matroid, TheTypeAbstractMatroid,\n                             Size, size,\n                             Circuits, circs\n                           );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByCircuits,\n                \"given ground set and list of circuits\",\n                [ IsList, IsList ],\n\n  function( groundSet, circs )\n    local m;\n\n    m := MatroidByCircuits( Size( groundSet ), List( circs, b -> List( b, e -> Position( groundSet, e ) ) ) );\n\n    SetNominalGroundSet( m, groundSet );\n\n    return m;\n  end\n\n);\n\n##\nInstallMethod( MatroidByCircuitsNC,\n                \"given ground set and list of circuits, no checks\",\n                [ IsList, IsList ],\n\n  function( groundSet, circs )\n    local m;\n\n    m := MatroidByCircuitsNC( Size( groundSet ), List( circs, b -> List( b, e -> Position( groundSet, e ) ) ) );\n\n    SetNominalGroundSet( m, groundSet );\n\n    return m;\n  end\n\n);\n\n##\nInstallMethod( MatroidByCircuitsNCL,\n                \"given ground set and list of circuits, no checks or logical implications\",\n                [ IsList, IsList ],\n\n  function( groundSet, circs )\n    local m;\n\n    m := MatroidByCircuitsNCL( Size( groundSet ), List( circs, b -> List( b, e -> Position( groundSet, e ) ) ) );\n\n    SetNominalGroundSet( m, groundSet );\n\n    return m;\n  end\n\n);\n\n##\nInstallMethod( MatroidByRankFunction,\n                \"given size of ground set and integer valued function\",\n                [ IsInt, IsFunction ],\n\n  function( size, rankFunc )\n    local x, xIter, rx, y, yIter, ry, matroid;\n\n    if rankFunc( [ ] ) <> 0 then Error( \"the empty set must have rank 0\" ); fi;\n\n# Naive check for sane rank function:\n\n    xIter := IteratorOfCombinations( [1..size] );\n    for x in xIter do\n\n      rx := rankFunc(x);\n      if rx > Size(x) then Error( \"the rank of a set must not exceed its size\" ); fi;\n\n      yIter := ShallowCopy(xIter);                # do not test both (x,y) and (y,x)\n      for y in yIter do\n\n        ry := rankFunc(y);\n\n        if ( rx > ry and IsSubset( y, x ) ) or ( rx < ry and IsSubset( x, y ) ) then        # the iterator will probably never produce\n                                                                                            # the case IsSubset( x, y ), but this is not guaranteed\n          Error( \"for sets x \\subset y the rank of x must be at most the rank of y\" );\n        fi;\n\n        if rankFunc( Union2( x, y ) ) + rankFunc( Intersection2( x, y ) ) > rx + ry then\n          Error( \"<rankFunc> is not submodular\" );\n        fi;\n\n      od;\n\n    od;\n\n# Construction:\n\n    matroid := MatroidByRankFunctionNCL( size, rankFunc );\n\n    _alcove_MatroidStandardImplications( matroid );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByRankFunctionNC,\n                \"given size of ground set and integer valued function, no checks\",\n                [ IsInt, IsFunction ],\n\n  function( size, rankFunc )\n    local matroid;\n\n    matroid := MatroidByRankFunctionNCL( size, rankFunc );\n\n    _alcove_MatroidStandardImplications( matroid );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByRankFunctionNCL,\n                \"given size of ground set and integer valued function, no checks or logical implications\",\n                [ IsInt, IsFunction ],\n\n  function( size, rankFunc )\n    local matroid;\n\n    matroid := rec( );\n    ObjectifyWithAttributes( matroid, TheTypeAbstractMatroid,\n                             Size, size,\n                             RankFunction, rankFunc\n                           );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByRankFunction,\n                \"given ground set and integer valued function\",\n                [ IsList, IsFunction ],\n\n  function( groundSet, rankFunc )\n    local m;\n\n    if groundSet = [ 1 .. Size( groundSet ) ] then\n\n      return MatroidByRankFunction( Size( groundSet ), rankFunc );\n\n    else\n\n      m := MatroidByRankFunction( Size( groundSet ), function(subset) return rankFunc( List( subset, i -> groundSet[i] ) ); end );\n\n      SetNominalGroundSet( m, groundSet );\n\n      return m;\n\n    fi;\n\n  end\n\n);\n\n##\nInstallMethod( MatroidByRankFunctionNC,\n                \"given ground set and integer valued function, no checks\",\n                [ IsList, IsFunction ],\n\n  function( gset, rankFunc )\n    local matroid;\n\n    matroid := MatroidByRankFunctionNCL( gset, rankFunc );\n\n    _alcove_MatroidStandardImplications( matroid );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( MatroidByRankFunctionNCL,\n                \"given ground set and integer valued function, no checks or logical implications\",\n                [ IsList, IsFunction ],\n\n  function( groundSet, rankFunc )\n    local m;\n\n    if groundSet = [ 1 .. Size( groundSet ) ] then\n\n      return MatroidByRankFunctionNCL( Size( groundSet ), rankFunc );\n\n    else\n\n      m := MatroidByRankFunctionNCL( Size( groundSet ), function(subset) return rankFunc( List( subset, i -> groundSet[i] ) ); end );\n\n      SetNominalGroundSet( m, groundSet );\n\n      return m;\n\n    fi;\n\n  end\n\n);\n\n\n####################\n## Graphic matroids:\n\n###\n#InstallMethod( MatroidOfGraph,\n#                \"given an incidence matrix\",\n#                [ IsMatrix ],\n#\n# function( incidencemat )\n#\n# end\n#\n#);\n\n\n########################\n## Special constructors:\n\n##\nInstallMethod( RandomVectorMatroidOverPrimeField,\n                \"of certain dimensions over a prime field\",\n                [ IsInt, IsInt, IsInt ],\n\n  function( k, n, p )\n    local R;\n\n    if not ( IsPrimeInt(p) or p = 0 ) or k < 0 or n < 0 then\n      Error( \"usage: RandomVectorMatroidOverPrimeField( <rows>, <cols>, <char> )\" );\n    fi;\n\n    if p = 0 then\n      return Matroid( HomalgMatrix( RandomMat( k, n, Rationals ), HomalgFieldOfRationals( ) ) );\n    else\n      R := HomalgRingOfIntegers( p );\n      return Matroid( HomalgMatrix( One( R ) * RandomMat( k, n, [ 0 .. p - 1 ] ), R ) );\n    fi;\n\n  end\n\n);\n\n##\nInstallMethod( UniformMatroid,\n                \"as an abstract matroid\",\n                [ IsInt, IsInt ],\n\n  function( k, n )\n    local matroid;\n\n    if k > n then Error( \"rank cannot be greater than number of elements\" ); fi;\n\n    matroid := MatroidByRankFunctionNCL( n, function( x ) if Size(x) < k then return Size(x); else return k; fi; end );\n    SetRankOfMatroid( matroid, k );\n\n    _alcove_MatroidStandardImplications( matroid );\n\n    SetIsUniformMatroid( matroid, true );\n\n    return matroid;\n  end\n\n);\n\n##\nInstallMethod( UniformMatroidNL,\n                \"as an abstract matroid, no logical implications\",\n                [ IsInt, IsInt ],\n\n  function( k, n )\n    local matroid;\n\n    if k > n then Error( \"rank cannot be greater than number of elements\" ); fi;\n\n    matroid := MatroidByRankFunctionNCL( n, function( x ) if Size(x) < k then return Size(x); else return k; fi; end );\n    SetRankOfMatroid( matroid, k );\n\n    SetIsUniformMatroid( matroid, true );\n\n    return matroid;\n  end\n\n);\n\n\n####################################\n##\n## Display Methods\n##\n####################################\n\n##\nInstallMethod( PrintObj,\n                \"for matroids\",\n                [ IsMatroid ],\n\n  function( matroid )\n\n    if Size( matroid ) = 0 then\n\n      Print( \"<The boring matroid>\" );\n\n    else\n\n      Print( \"<A\" );\n\n      if HasRankOfMatroid( matroid ) then\n        Print( \" rank \", RankOfMatroid(matroid) );\n      fi;\n\n      if HasIsUniformMatroid( matroid ) and IsUniformMatroid( matroid ) then\n        Print( \" uniform\" );\n      elif HasIsSimpleMatroid( matroid ) and IsSimpleMatroid( matroid ) then\n        Print( \" simple\" );\n      fi;\n\n      if IsVectorMatroidRep( matroid ) then\n        Print( \" vector\" );\n      fi;\n\n      Print( \" matroid>\" );\n\n    fi;\n\n  end\n\n);\n\n##\nInstallMethod( Display,\n                \"for abstract matroids\",\n                [ IsAbstractMatroidRep ],\n\n  function( matroid )\n    local printList, i, pSize;\n\n    if HasDirectSumDecomposition(matroid) and Size(DirectSumDecomposition(matroid)) = 1 and not IsIdenticalObj( matroid, DirectSumDecomposition(matroid)[1][2] ) then\n\n      Display( DirectSumDecomposition(matroid)[1][2] );\n\n    else\n\n      Print( \"A rank \", RankOfMatroid(matroid), \" abstract matroid on \", Size(matroid), \" elements.\\n\" );\n      printList := [ ];\n      if HasBases(matroid) then Add(printList,\"bases\"); fi;\n      if HasCircuits(matroid) then Add(printList,\"circuits\"); fi;\n      if HasMatroidHyperplanes(matroid) then Add(printList,\"hyperplanes\"); fi;\n      if HasRankFunction(matroid) then Add(printList,\"rank function\"); fi;\n      if HasIndependenceOracle(matroid) then Add(printList,\"independence oracle\"); fi;\n\n      if HasDirectSumDecomposition( matroid ) and not IsConnectedMatroid( matroid ) then\n\n        Print( \"It is the direct sum of \", Size(DirectSumDecomposition(matroid)), \" connected components.\\n\" );\n\n      elif HasTwoSumDecomposition( matroid ) and not Is3Connected( matroid ) then\n\n        Print( \"It is a 2-sum of two known minors.\\n\" );\n\n      elif IsEmpty( printList ) then\n\n        Print( \"It is pretty much an empty prototype of a matroid, knowing neither its bases, nor its circuits, nor its hyperplanes, nor its rank function, nor an independence oracle.\\n\" );\n\n      else\n\n        pSize := Size(printList);\n\n        Print( \"Its \" );\n\n        Print( printList[1] );\n\n        for i in [2..pSize-1] do\n          Print( \", \", printList[i] );\n        od;\n\n        if pSize > 1 then\n          Print( \" and \", printList[pSize] );\n        fi;\n\n        if pSize = 1 and printList[1][1] = 'r' or printList[1][1] = 'i' then\n          Print( \" is known.\\n\" );\n        else\n          Print( \" are known.\\n\" );\n        fi;\n\n      fi;\n\n    fi;\n\n  end\n\n);\n\n##\nInstallMethod( Display,\n                \"for vector matroids\",\n                [ IsVectorMatroidRep ],\n\n  function( matroid )\n    local mat;\n\n    if Size( matroid ) = 0 then\n\n      Print( \"The vector matroid of the empty matrix.\" );\n\n    else\n\n      mat := MatrixOfVectorMatroid( matroid );\n\n      Print( \"The vector matroid of this matrix over \" );\n      View( HomalgRing(mat) );\n      Print( \":\\n\" );\n      Display( mat );\n\n    fi;\n\n  end\n\n);\n", "meta": {"hexsha": "36aeccaa7870a58c9f584d31ed61f134f374530a", "size": 101989, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "data/github.com/martin-leuner/alcove/4abaded6c04b3b6005a1ed46bfb5c138f4f3fab9/gap/Matroid.gi", "max_stars_repo_name": "ajnavarro/language-dataset", "max_stars_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-08-07T11:54:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T09:48:45.000Z", "max_issues_repo_path": "data/github.com/martin-leuner/alcove/4abaded6c04b3b6005a1ed46bfb5c138f4f3fab9/gap/Matroid.gi", "max_issues_repo_name": "ajnavarro/language-dataset", "max_issues_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 91, "max_issues_repo_issues_event_min_datetime": "2019-11-11T15:41:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T04:17:18.000Z", "max_forks_repo_path": "data/github.com/martin-leuner/alcove/4abaded6c04b3b6005a1ed46bfb5c138f4f3fab9/gap/Matroid.gi", "max_forks_repo_name": "ajnavarro/language-dataset", "max_forks_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-11-13T12:44:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-06T19:34:26.000Z", "avg_line_length": 22.9860265945, "max_line_length": 189, "alphanum_fraction": 0.5384894449, "num_tokens": 25468, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.49438984872190644}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nDeclare(ISRDFT, ISRDFT2, ISRDFT3, ISRDFT4);\n\nClass(SRDFT, PRDFT, rec(\n    dims := self >> [self.params[1], self.params[1]],\n    inverse := self >> ISRDFT(self.params[1], -self.params[2]).setTransposed(self.transposed),\n    inverseViaDiag := self >> self.transpose() * ISRDFT.diag(self.params[1]),\n    terminate := self >> let(N := self.params[1], k := self.params[2],\n\tm  := MatSPL(PRDFT(N,k)),\n\tsm := Mat(Cond(IsOddInt(N), \n\t         Concatenation([m[1]], m{[3..Length(m)]}),\n\t         Concatenation([m[1]], m{[3..Length(m)-2]}, [m[Length(m)-1]]))),\n\tCond(self.transposed, sm.transpose(), sm)),\n));\nSRDFT1 := SRDFT;\nClass(SRDFT2, PRDFT2, rec(\n    dims := self >> [self.params[1], self.params[1]],\n    inverse := self >> ISRDFT3(self.params[1], -self.params[2]).setTransposed(self.transposed),\n    terminate := self >> let(N := self.params[1], k := self.params[2],\n\tm  := MatSPL(PRDFT2(N,k)),\n\tsm := Mat(Cond(IsOddInt(N), \n\t         Concatenation([m[1]], m{[3..Length(m)]}),\n\t         Concatenation([m[1]], m{[3..Length(m)-2]}, [m[Length(m)]]))),\n\tCond(self.transposed, sm.transpose(), sm)),\n));\nClass(SRDFT3, PRDFT3, rec(\n    dims := self >> [self.params[1], self.params[1]],\n    inverse := self >> ISRDFT2(self.params[1], -self.params[2]).setTransposed(self.transposed),\n    terminate := self >> let(N := self.params[1], k := self.params[2],\n\tm  := MatSPL(PRDFT3(N,k)),\n\tsm := Mat(Cond(IsOddInt(N), \n\t         m{[1..Length(m)-1]},\n\t         m)),\n\tCond(self.transposed, sm.transpose(), sm)),\n));\nClass(SRDFT4, PRDFT4, rec(\n    dims := self >> [self.params[1], self.params[1]],\n    inverse := self >> ISRDFT4(self.params[1], -self.params[2]).setTransposed(self.transposed),\n    terminate := self >> let(N := self.params[1], k := self.params[2],\n\tm  := MatSPL(PRDFT4(N,k)),\n\tsm := Mat(Cond(IsOddInt(N), \n\t         Concatenation(m{[1..Length(m)-2]}, [m[Length(m)]]),\n\t         m)),\n\tCond(self.transposed, sm.transpose(), sm)),\n));\n\nClass(ISRDFT, IPRDFT, rec(\n    dims := self >> [self.params[1], self.params[1]],\n    diag := n -> When(n=2, I(2), \n        Diag(diagDirsum(fConst(TReal, 1, 1), fConst(TReal, 2*Int((n-1)/2), 2), \n                When(IsEvenInt(n), fConst(TReal, 1, 1), [])))), \n\n    terminate := self >> let(N := self.params[1], k := self.params[2],\n\tm  := MatSPL(IPRDFT(N,k)),\n\tsm := Mat(Cond(IsOddInt(N), \n\t         List(m, r->Concatenation([r[1]], r{[3..Length(r)]})),\n\t         List(m, r->Concatenation([r[1]], r{[3..Length(r)-2]}, [r[Length(r)-1]])))),\n\tCond(self.transposed, sm.transpose(), sm)),\n));\nClass(ISRDFT2, IPRDFT2, rec(\n    dims := self >> [self.params[1], self.params[1]],\n    terminate := self >> let(N := self.params[1], k := self.params[2],\n\tm  := MatSPL(IPRDFT2(N,k)),\n\tsm := Mat(Cond(IsOddInt(N), \n\t         List(m, r->r{[1..Length(r)-1]}),\n\t         m)),\n\tCond(self.transposed, sm.transpose(), sm)),\n));\nClass(ISRDFT3, IPRDFT3, rec(\n    dims := self >> [self.params[1], self.params[1]],\n    terminate := self >> let(N := self.params[1], k := self.params[2],\n\tm  := MatSPL(IPRDFT3(N,k)),\n\tsm := Mat(Cond(IsOddInt(N), \n\t         List(m, r->Concatenation([r[1]], r{[3..Length(r)]})),\n\t         List(m, r->Concatenation([r[1]], r{[3..Length(r)-2]}, [r[Length(r)]])))),\n\tCond(self.transposed, sm.transpose(), sm)),\n));\nClass(ISRDFT4, IPRDFT4, rec(\n    dims := self >> [self.params[1], self.params[1]],\n    terminate := self >> let(N := self.params[1], k := self.params[2],\n\tm  := MatSPL(IPRDFT4(N,k)),\n\tsm := Mat(Cond(IsOddInt(N), \n\t         List(m, r->Concatenation(r{[1..Length(r)-2]}, [r[Length(r)]])),\n\t         m)),\n\tCond(self.transposed, sm.transpose(), sm)),\n));\n\nRulesFor(SRDFT1, rec(\n    SRDFT1_toPRDFT1 := rec(\n\tisApplicable := P -> true,\n\tallChildren := P -> [[ PRDFT1(P[1], P[2]) ]],\n\trule := (P, C) -> Pack_CCS(P[1]) * C[1]\n    )\n));\n\nRulesFor(SRDFT3, rec(\n    SRDFT3_toPRDFT3 := rec(\n\tisApplicable := P -> true,\n\tallChildren := P -> [[ PRDFT3(P[1], P[2]) ]],\n\trule := (P, C) -> Pack_CCS3(P[1]) * C[1]\n    )\n));\n", "meta": {"hexsha": "550417ebc726991e91a10117a6989c6e8d9fbf69", "size": 4038, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/realdft/square.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/transforms/realdft/square.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/transforms/realdft/square.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.738317757, "max_line_length": 95, "alphanum_fraction": 0.5663694898, "num_tokens": 1376, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4927003818977513}}
{"text": "#\n# usage:\n# Read(\"~/Workspace/Chevalley.gap/init.gi\"); Read(Filename(home_dir,\"load.gi\")); Read(Filename(f4_dir_char3,\"_init_char3.gi\")); Read(Filename(f4_dir_char3,\"F4(a3).gi\"));\n#\n# Read(Filename(f4_dir_char3,\"F4(a3).gi\"));\n#\n\n\nlabel:=\"F_4(a_3)\";\norb_nr:=Position(labels,label);\n#orb:=AllClasses(orbs)[6];\norb:=AllClasses(orbs)[orb_nr];\ninfo:=infos[orb_nr];\n\n\n#\n# ------------------------------------------------------------------------\n#\n\nPrint(\"Consider the class \",Label(orb),\" in characteristic \",Characteristic(ring(sys)),\":\\n\");\nPrint(\"\\tBorel representative \\n\\t\",coefficients(BorelRep(orb)),\"\\n\");\nPrint(\"\\tconnected C_U(u) \\n\\t\",coefficients(info[1]),\"\\n\");\nPrint(\"\\tconnected double C_U(u) in Levi \\n\\t\",coefficients(info[2]),\"\\n\");\nPrint(\"\\tconnected double C_U(u) \\n\\t\",coefficients(info[3]),\"\\n\");\n\nZ0:=info[2];\n# move Z0 to match the representative\nZ0:=FromPositiveBorel(orb,Z0);\n# adjust ordering of roots\nZ0:=Unipotent(chevalleyAdj(Z0),coefficients(Z0),[1..Length(positiveRoots(sys))]);\nPrint(\"Z0 in position of Representative:\\n\\tZ0=\",coefficients(Z0),\"\\n\");\n\nPrint(\"Component group is S_4.\\n\");\nPrint(\"On Z0:\\n\");\nn1:=[3];\na1Z0:=ApplyRootsReflections(Z0,n1);\nu1:=Unipotent(chevalleyAdj(Z0),[[2,-1],[6,1]]);\na1Z0:=Conj(a1Z0,u1);\n#a1Z0:=ConjugateByTori(a1Z0,[2,4],[-1,-1]);\n# need to convert to gap numbering, see dataF4 file\na1Z0:=ConjugateByTori(a1Z0,[1,4],[-1,-1]);\nPrint(\"\\ta^Z0=\",coefficients(a1Z0),\"\\n\");\nPrint(\"\\th_3 has weights \",TorusWeights([3],a1Z0),\"\\n\");\n\nPrint(\"\\ta^Z0=\",coefficients(a1Z0),\"\\n\");\n\n\n#\n# ------------------------------------------------------------------------\n#\n\n\ntmp:=handle6char3();\nPrint(\"\\nComponent group check:\\n\");\nPrint(\"\\ta^u= \\n\",coefficients(tmp[1]),\"\\n\");\nPrint(\"\\tconnected center= \\n\",coefficients(tmp[2]),\"\\n\");\n", "meta": {"hexsha": "503f86ad5b5a92ed709044ae509acce9c636023a", "size": 1776, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/cases/f4/char3/F4(a3).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/cases/f4/char3/F4(a3).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/cases/f4/char3/F4(a3).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": 31.1578947368, "max_line_length": 169, "alphanum_fraction": 0.6188063063, "num_tokens": 579, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812554, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.49254899744864644}}
{"text": "CaesarCipher := function(s, n)\n\tlocal r, c, i, lower, upper;\n\tlower := \"abcdefghijklmnopqrstuvwxyz\";\n\tupper := \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\tr := \"\";\n\tfor c in s do\n\t\ti := Position(lower, c);\n\t\tif i <> fail then\n\t\t\tAdd(r, lower[RemInt(i + n - 1, 26) + 1]);\n\t\telse\n\t\t\ti := Position(upper, c);\n\t\t\tif i <> fail then\n\t\t\t\tAdd(r, upper[RemInt(i + n - 1, 26) + 1]);\n\t\t\telse\n\t\t\t\tAdd(r, c);\n\t\t\tfi;\n\t\tfi;\n\tod;\n\treturn r;\nend;\n\nCaesarCipher(\"IBM\", 25);\n# \"HAL\"\n\nCaesarCipher(\"Vgg cphvi wzdibn vmz wjmi amzz viy zlpvg di ydbidot viy mdbcon.\", 5);\n# \"All human beings are born free and equal in dignity and rights.\"\n", "meta": {"hexsha": "0a3b660ca38f9997fc4e426b5781942ee31e9ef6", "size": 604, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Caesar-cipher/GAP/caesar-cipher.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/Caesar-cipher/GAP/caesar-cipher.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/Caesar-cipher/GAP/caesar-cipher.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.3703703704, "max_line_length": 83, "alphanum_fraction": 0.6125827815, "num_tokens": 207, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4909151830967535}}
{"text": "\n#\n# ---------- Group Arithmetics ----------\n#\n\nInstallMethod(Subword,\n              \"Subword of a unipotent element by total degree of coefficients\",\n              [IsUnipotent,IsPosInt],\n              function(u,degree)\n              local sys,\n              coeffs,poly_degree;\n\n              sys:=chevalleyAdj(u);\n              if not IsPolynomialRing(ring(sys)) then\n                  Error(\"Subword: The ring is not a polynomial ring to evaluate!\\n\");\n              fi;\n              \n              coeffs:=Filtered(coefficients(u),i->TotalDegree(i[2])=degree);\n              \n              return Unipotent(sys,coeffs,Ordering(u));\nend);\n\n#\n# ---------- Algebraic Operations ----------\n#\n\nInstallMethod(Value,\n              \"Evaluation of the parameter polynomials\",\n              [IsUnipotent,IsList,IsList],\n              function(u,vars,vals)\n              local sys,\n              lista,i,len;\n\n              sys:=chevalleyAdj(u);\n              if not IsPolynomialRing(ring(sys)) then\n                  Error(\"Value: The ring is not a polynomial ring to evaluate.\");\n              fi;\n              \n              lista:=List(coefficients(u),i->[i[1],One(ring(sys))*Value(i[2],vars,vals)]);\n              i:=1;\n              len:=Length(lista);\n              while i <= len do\n                  if lista[i][2]=Zero(ring(sys)) then\n                      Remove(lista,i);\n                      len:=len-1;\n                  else i:=i+1; fi;\n              od;\n\n              return Unipotent(sys,lista,Ordering(u));\n              #return Unipotent(chevalleyAdj(sys),lista,Ordering(u)); # which one is better? I multiply by One(ring(sys))\nend);\n\nInstallMethod(Descend,\n              \"Changes the parameters from the polynomial ring to the coefficients ring\",\n              [IsUnipotent],\n              function(u)\n              local sys,\n              check;\n\n              sys:=chevalleyAdj(u);\n              if not IsPolynomialRing(ring(sys)) then\n                  Error(\"The ring is not a polynomial ring to evaluate.\");\n              fi;\n\n              if IsAlgebraicU(sys) then sys:=chevalleyAdj(u);\n              else sys:=ChevalleyAdj(sys,CoefficientsRing(ring(sys))); fi;\n\n              check:=List(coefficients(u),i->LeadingMonomial(i[2]));\n              check:=List(check,i->Sum(i{2*[1..Length(i)/2]}));\n              check:=Filtered(check,i->i<>0);\n              if check=[] then\n                  return Unipotent(sys,\n                                   List(coefficients(u),i->[i[1],LeadingCoefficient(i[2])]),\n                                   Ordering(u),\n                                   Order(u));\n              fi;\n\n              return fail;\nend);\n\nInstallMethod(Descend,\n              \"If possible changes the parameters from the polynomial ring to the coefficients ring\",\n              [IsUnipotent,IsChevalleyAdj],\n              function(u,sys)\n              local sysu,\n              check;\n\n              sysu:=chevalleyAdj(u);\n\n              if not IsPolynomialRing(ring(sysu)) then\n                  Error(\"The ring is not a polynomial ring to evaluate.\");\n              elif CoefficientsRing(ring(sysu))<>ring(sys) then\n                  Error(\"Cannot descend unipotent to given simple adjoint system\");\n              fi;\n              \n              check:=List(coefficients(u),i->LeadingMonomial(i[2]));\n              check:=List(check,i->Sum(i{2*[1..Length(i)/2]}));\n              check:=Filtered(check,i->i<>0);\n              if check=[] then\n                  return Unipotent(sys,\n                                   List(coefficients(u),i->[i[1],LeadingCoefficient(i[2])]),\n                                   Ordering(u),\n                                   Order(u));\n              fi;\n\n              return u;\nend);\n\nInstallMethod(Ascend,\n              \"If possible embed Unipotent into AlgebraicU\",\n              [IsUnipotent,IsAlgebraicU],\n              function(u,sys)\n              local sysu,\n              check;\n\n              if chevalleyAdj(u)<>chevalleyAdj(sys) then\n                  Error(\"Cannot ascend Unipotent to AlgebraicU: different chevalleyAdj!\\n\");\n              fi;\n              \n              return Unipotent(sys,\n                               List(coefficients(u),i->[i[1],One(ring(sys))*i[2]]),\n                               Ordering(u),\n                               Order(u));\nend);\n\nInstallMethod(Ascend,\n              \"If possible embed the parameters in a polynomial ring with coefficients ring the base ring\",\n              [IsUnipotent,IsChevalleyAdj],\n              function(u,sys)\n              local sysu,\n              check;\n\n              sysu:=chevalleyAdj(u);\n\n              if not IsPolynomialRing(ring(sys)) then\n                  Error(\"The new ring is not a polynomial ring to embed in.\");\n              elif CoefficientsRing(ring(sys))<>ring(sysu) then\n                  Error(\"CoefficientsRing and ring(sysu) do not coincide.\");\n              fi;\n              \n              return Unipotent(sys,\n                               List(coefficients(u),i->[i[1],One(ring(sys))*i[2]]),\n                               Ordering(u),\n                               Order(u));\nend);\n\nInstallMethod(Ascend,\n              \"If possible embed the parameters in a polynomial ring with coefficients ring the base ring\",\n              [IsUnipotent,IsPolynomialRing],\n              function(u,inel)\n              local sys,\n              check;\n\n              sys:=chevalleyAdj(u);\n\n              if not IsPolynomialRing(inel) then\n                  Error(\"The new ring is not a polynomial ring to embed in.\");\n              elif CoefficientsRing(inel)<>ring(sys) then\n                  Error(\"CoefficientsRing and ring(sys) do not coincide.\");\n              fi;\n              \n              return Unipotent(ChevalleyAdj(sys,inel),\n                               List(coefficients(u),i->[i[1],One(inel)*i[2]]),\n                               Ordering(u),\n                               Order(u));\nend);\n\n\n\nInstallMethod(UnipotentCentralizer,\n              \"Centralizer of unipotent element in algebraicU\",\n              [IsUnipotent],\n              function(u)\n              local result,\n              sys,pr,pr_len,uu,\n              APR,avars,avars_free,generic,\n              relations,sol,torsion,\n              i,new_indices;\n\n              sys:=chevalleyAdj(u);\n              if not IsAlgebraicU(sys) then\n                  sys:=AlgebraicU(sys);\n                  u:=Ascend(u,sys);\n              fi;\n              pr:=positiveRoots(sys);\n              pr_len:=Length(pr);\n              APR:=ring(sys);\n              avars:=IndeterminatesOfPolynomialRing(APR){[1..pr_len]};\n\n              generic:=Unipotent(sys,List([1..pr_len],i->[i,avars[pr_len-i+1]]),[1..pr_len],0);\n\n              result:=List([1..pr_len],i->avars[i]);\n\n              torsion:=[];\n              for i in [2..pr_len] do\n                  #relations:=coefficients(CommMod(generic,u,i));\n              relations:=coefficients(CommMod(u,generic,i));   #!!!ATENTIE CommMod(a,b,i) foloseste Ordering lui b care tre sa fie [1..pr_len]\n                  relations:=List(relations,i->i[2]);\n              #Print(\"\\nsolving \",i,\": \",relations,\"\\n\");\n              #if i=8 then Error(\"!\"); fi;\n                  sol:=SolveRelations(relations,avars,result,APR);\n                  if sol[2]<>[] then Print(\" >>>\",i,\" UnipotentCentralizer: could not solve all relations!\",relations,\"\\n\"); fi;\n                  Add(torsion,sol[3]);\n                  result:=sol[1];\n                  result:=List(result,i->i*One(APR));\n              #Print(\"result :\",result,\"\\n\");\n                  generic:=Unipotent(sys,List([1..pr_len],i->[i,result[pr_len-i+1]]),[1..pr_len],0);\n              od;\n\n              avars_free:=result{Filtered([1..pr_len],i->result[i] in avars)};\n              avars_free:=avars_free{Filtered([1..Length(avars_free)],i->not avars_free[i] in avars_free{[1..i-1]})};\n\n              new_indices:=Reversed([1..Length(avars_free)]);\n              result:=List(result,i->Value(i,avars_free,avars{new_indices})*One(APR));\n              generic:=Unipotent(sys,List([1..pr_len],i->[i,result[pr_len-i+1]]),[1..pr_len],0);\n    \n              return [generic,u,Concatenation(torsion),relations];\nend);\n\n\n#\n#\n#  THIS DOES NOT WORK\n#\n#\nInstallMethod(UnipotentCentralizer2,\n              \"Centralizer of unipotent element in algebraicU\",\n              [IsUnipotent],\n              function(u)\n              local result,\n              sys,pr,pr_len,uu,\n              APR,avars,avars_free,generic,\n              relations,sol,torsion,\n              root_support,other_roots,\n              i,new_indices;\n\n              sys:=chevalleyAdj(u);\n              if not IsAlgebraicU(sys) then\n                  sys:=AlgebraicU(sys);\n                  u:=Ascend(u,sys);\n              fi;\n              pr:=positiveRoots(sys);\n              pr_len:=Length(pr);\n              APR:=ring(sys);\n              avars:=IndeterminatesOfPolynomialRing(APR){[1..pr_len]};\n\n              root_support:=[];\n              for i in [1..pr_len] do\n                  generic:=Unipotent(sys,[[i,avars[1]]]);\n                  generic:=Conj(generic,u);\n                  if Length(coefficients(generic))=1 and coefficients(generic)[1][2]=avars[1] then Add(root_support,i); fi;\n              od;\n              other_roots:=Difference([1..pr_len],root_support);\n\n              #generic:=Unipotent(sys,List([1..pr_len],i->[i,avars[pr_len-i+1]]),[1..pr_len],0);\n              #generic:=Subword(generic,other_roots);\n              generic:=Unipotent(sys,List(other_roots,i->[i,avars[pr_len-i+1]]),[1..pr_len],0);\n\n              result:=List([1..pr_len],i->avars[i]);\n              for i in root_support do result[pr_len-i+1]:=Zero(APR); od;\n\n              torsion:=[];\n              for i in [2..pr_len] do\n                  #relations:=coefficients(CommMod(generic,u,i));\n              relations:=coefficients(CommMod(u,generic,i));   #!!!ATENTIE CommMod(a,b,i) foloseste Ordering lui b care tre sa fie [1..pr_len]\n                  relations:=List(relations,i->i[2]);\n              #Print(\"\\nsolving \",i,\": \",relations,\"\\n\");\n              #if i=8 then Error(\"!\"); fi;\n                  sol:=SolveRelations(relations,avars,result,APR);\n                  if sol[2]<>[] then Print(\" >>>\",i,\" UnipotentCentralizer: could not solve all relations!\",relations,\"\\n\"); fi;\n                  Add(torsion,sol[3]);\n                  result:=sol[1];\n                  result:=List(result,i->i*One(APR));\n              #Print(\"result :\",result,\"\\n\");\n                  generic:=Unipotent(sys,List([1..pr_len],i->[i,result[pr_len-i+1]]),[1..pr_len],0);\n              od;\n              Error(\"!\");\n              for i in root_support do result[pr_len-i+1]:=avars[pr_len-i+1]; od;\n\n              avars_free:=result{Filtered([1..pr_len],i->result[i] in avars)};\n              avars_free:=avars_free{Filtered([1..Length(avars_free)],i->not avars_free[i] in avars_free{[1..i-1]})};\n\n              new_indices:=Reversed([1..Length(avars_free)]);\n              result:=List(result,i->Value(i,avars_free,avars{new_indices})*One(APR));\n              generic:=Unipotent(sys,List([1..pr_len],i->[i,result[pr_len-i+1]]),[1..pr_len],0);\n    \n              return [generic,u,Concatenation(torsion),relations];\nend);\n\nInstallMethod(TangentSpace,\n              \"Returns a basis of Nilpotents representing for the tangent space\",\n              [IsUnipotent],\n              function(u)\n              local result,\n              sysAPR,APR,avars,\n              dim,BPR,xvars,\n              order,exp,vals,tmp,tmp_len,i,j,monoms;\n\n              sysAPR:=chevalleyAdj(u);\n              APR:=ring(sysAPR);\n              avars:=IndeterminatesOfPolynomialRing(APR){[1..Length(positiveRoots(sysAPR))]};\n              dim:=Length(Set(List(Filtered(coefficients(u),i->i[2] in avars),j->j[2])));\n              avars:=avars{[1..dim]};\n\n              vals:=List([1..dim],i->Zero(APR));\n              result:=[];\n              for i in [1..dim] do\n                  vals[i]:=avars[1];\n                  tmp:=Value(u,avars,vals);\n                  #SetOrder(tmp,Order(u));\n                  tmp:=ShallowCopy(coefficients(tmp));\n                  tmp_len:=Length(tmp);\n                  j:=1;\n                  while j <= tmp_len do\n                       monoms:=ExtRepPolynomialRatFun(tmp[j][2]);\n                       monoms:=List(2*[1..Length(monoms)/2]-1,i->[monoms[i],monoms[i+1]]);\n                       monoms:=Filtered(monoms,i->i[1][2]=1);\n                       if monoms<>[] then\n                          tmp[j]:=[tmp[j][1],monoms[1][2]*One(APR)];\n                          j:=j+1;\n                      else\n                          Remove(tmp,j);\n                          tmp_len:=tmp_len-1;\n                      fi;\n                  od;\n                  Add(result,tmp);\n                  vals[i]:=Zero(APR);\n              od;\n\n              result:=List(result,i->NilpotentChv(sysAPR,i));\n              return result;\nend);\n\nInstallMethod(Zentrum,\n              \"Centre of connected unipotent algebraic group\",\n              [IsUnipotent],\n              function(u)\n              local result,\n              APR,avars,\n              relations,\n              tang,adu_res,unu;\n\n              APR:=ring(chevalleyAdj(u));\n              avars:=IndeterminatesOfPolynomialRing(APR);\n              avars:=Filtered(coefficients(u),i->i[2] in avars);\n              avars:=Set(List(avars,i->i[2]));\n\n              tang:=TangentSpace(u);\n              #Error(\"!\");\n              adu_res:=RestrictedAdu(u,tang);\n              \n              unu:=DiagonalMat(List([1..Length(avars)],i->One(APR)));\n\n              relations:=Concatenation(adu_res-unu);\n              relations:=Filtered(relations,i->i<>Zero(APR));\n\n#return relations;\n\n              #Print(avars,\" with \",relations,\"\\n\");\n\n              result:=SolveRelations(relations,avars,avars,APR);\n\n              if result[2]<>[] then Print(\"Zentrum: could not solve all relations! \",result[2],\"\\n\"); fi;\n    \n              return Value(u,avars,result[1]);\nend);\n\nInstallMethod(ParameterPieces,\n              \"Subvarieties for each parameter\",\n              [IsUnipotent],\n              function(u)\n              local result,\n              sysAPR,APR,avars,avar,\n              dim,BPR,xvars,\n              order,exp,vals,tmp,tmp_len,i,j,monoms;\n\n              sysAPR:=chevalleyAdj(u);\n              APR:=ring(sysAPR);\n              avars:=IndeterminatesOfPolynomialRing(APR){[1..Length(positiveRoots(sysAPR))]};\n              avar:=avars[1];\n              avars:=Set(List(Filtered(coefficients(u),i->i[2] in avars),j->j[2]));\n              Sort(avars,function(a,b) return ExtRepPolynomialRatFun(a)[1][1]<ExtRepPolynomialRatFun(b)[1][1]; end);\n              dim:=Length(avars);\n              #avars:=avars{[1..dim]};\n\n              vals:=List([1..dim],i->Zero(APR));\n              result:=[];\n              for i in [1..dim] do\n                  vals[i]:=avar;#avars[1];\n                  tmp:=Value(u,avars,vals);\n                  #Print(coefficients(tmp));\n                  #SetOrder(tmp,Order(u));\n                  tmp:=ShallowCopy(coefficients(tmp));\n                  tmp_len:=Length(tmp);\n                  Add(result,tmp);\n                  vals[i]:=Zero(APR);\n              od;\n\n              result:=List(result,i->Unipotent(sysAPR,i,Ordering(u),-2));\n              return result;\nend);\n\nInstallMethod(Dimension,\n              \"Dimension of subvariety in unipotent group\",\n              [IsUnipotent],\n              function(u)\n              local avars_free;\n\n              avars_free:=List(coefficients(u),i->i[2]);\n              avars_free:=List(avars_free,i->ExtRepPolynomialRatFun(i));\n              avars_free:=Concatenation(avars_free);\n              avars_free:=avars_free{2*[1..Length(avars_free)/2]-1};\n              avars_free:=Concatenation(avars_free);\n              avars_free:=avars_free{2*[1..Length(avars_free)/2]-1};\n\n              return Length(Set(avars_free));\nend);\n\n#\n# ---------- Witt Group Operations ----------\n#\n\nInstallMethod(GenericWittGroup,\n              \"Witt group with generic polynomials along the unipotent group gr\",\n              [IsUnipotent,IsWitt,IsList],\n              function(gr,w,values)\n              local result,\n              coeffs,\n              APR,avars,avars_free,avars_free_len,avars_ext,\n              BPR,bvars,\n              CPR,cvarnames,cvars,\n              poly,monom,i,j,k,pos;\n\n              coeffs:=coefficients(gr);\n\n              # APR's\n              APR:=ring(chevalleyAdj(gr));\n              avars:=IndeterminatesOfPolynomialRing(APR);\n              avars_free:=Filtered(coeffs,i->i[2] in avars);\n              avars_free:=Set(List(avars_free,i->i[2]));\n              Sort(avars_free,function(a,b) return ExtRepPolynomialRatFun(a)[1][1]<ExtRepPolynomialRatFun(b)[1][1]; end);\n              avars_free_len:=Length(avars_free);\n              avars_ext:=List(avars_free,i->ExtRepPolynomialRatFun(i));\n              avars_ext:=List(avars_ext,i->i[1][1]);\n\n              # BPR's\n              BPR:=ring(chevalleyAdjBPR(w));\n\n              # CPR's\n              cvarnames:=List([1..avars_free_len],i->Concatenation(\"c_\",String(i)));\n              CPR:=PolynomialRing(BPR,cvarnames);\n              cvars:=IndeterminatesOfPolynomialRing(CPR);\n\n\n              coeffs:=List(coeffs,i->[i[1],List(ExtRepPolynomialRatFun(i[2]))]);\n              result:=[];\n              for i in [1..Length(coeffs)] do\n                  poly:=Zero(CPR);\n                  for j in [1..Length(coeffs[i][2])/2] do\n                      monom:=One(CPR);\n                      for k in [1..Length(coeffs[i][2][2*j-1])/2] do\n                          pos:=Position(avars_ext,coeffs[i][2][2*j-1][2*k-1]);\n                          monom:=monom*cvars[pos]^coeffs[i][2][2*j-1][2*k];\n                      od;\n                      monom:=monom*((coeffs[i][2][2*j]*One(APR))*One(BPR));\n                      poly:=poly+monom;\n                  od;\n                  Add(result,[coeffs[i][1],poly]);\n              od;\n\n              result:=List(result,i->[i[1],Value(i[2],cvars,values)]);\n\n              return Unipotent(chevalleyAdjBPR(w),result,Ordering(gr),-2);\nend);\n\nInstallMethod(SolveWittRoot,\n              \"Solution for witt group construction at certain root\",\n              [IsUnipotent,IsWitt,IsPosInt,IsList,IsInt],\n              function(wx,w,root,values,step)\n              local result,\n              APR,avars,avars_free,avars_free_len,\n              BPR,dim,xvar,yvar,wy,\n              gws,gen_poly,gen_poly_len,xy_poly,total_degree,relations,i;\n\n              gws:=GenericSum(w);\n\n              # BPR's\n              BPR:=ring(chevalleyAdjBPR(w));\n              dim:=Dimension(w);\n              xvar:=IndeterminatesOfPolynomialRing(BPR){[1..dim]};\n              yvar:=IndeterminatesOfPolynomialRing(BPR){dim+[1..dim]};\n\n              wy:=Value(wx,xvar,yvar);\n              xy_poly:=coefficients(Subword(wx*wy,[root]));\n              if xy_poly=[] then\n                  return [Zero(BPR),values,step];\n              else\n                  xy_poly:=xy_poly[1][2];\n              fi;\n\n              # APR's\n              APR:=ring(algebraicU(w));\n              avars:=IndeterminatesOfPolynomialRing(APR);\n\n              result:=ShallowCopy(values);\n\n              # construct generic polynomial\n              total_degree:=TotalDegree(xy_poly);\n              gen_poly:=Concatenation(GenericLevelPolynomials(w){[1..total_degree]});\n              gen_poly_len:=Length(gen_poly);\n              gen_poly:=Sum(List([1..gen_poly_len],i->result[step+i]*gen_poly[i]));\n\n              # contruct relations\n              relations:=Value(gen_poly,xvar,gws)-gen_poly-Value(gen_poly,xvar,yvar)-xy_poly;\n              relations:=ExtRepPolynomialRatFun(relations);\n              relations:=relations{2*[1..Length(relations)/2]};\n\n              # solve relations\n              result:=SolveRelations(relations,avars,result,APR);\n              if result[2]<>[] then Error(\"SolveWittRoot: coulde not solve all relations!\"); return fail; fi;\n              result:=result[1];\n\n              # rearrange free variables \n              avars_free:=Filtered([1..gen_poly_len+step],i->result[i] in avars);\n              avars_free:=result{avars_free};\n              avars_free_len:=Length(avars_free);\n#    result:=List(result,i->i*One(APR));\n#    result:=List(result,i->Value(i,avars_free,avars{[1..avars_free_len]})*One(APR));\n    \n              gen_poly:=Concatenation(GenericLevelPolynomials(w){[1..total_degree]});\n              gen_poly:=Sum(List([1..Length(gen_poly)],i->result[i+step]*gen_poly[i]));\n\n              return [gen_poly,result,step+gen_poly_len];\nend);\n\nInstallMethod(WittGroup,\n              \"Witt group of unipotent inside group\",\n              [IsUnipotent,IsUnipotent,IsWitt],\n              function(u,centralizer,w)\n              local result,u_ordered,\n              APR,avars,avars_free,avars_ext,\n              BPR,dim,xvars,xvars_ext,\n              coeffs,\n              i,j,k,pos,sol,step,values,update_poly,monom,\n              wg;\n\n              # APR's\n              #APR:=ring(algebraicU(w)); asta de ce nu merge?\n              APR:=ring(chevalleyAdj(u));\n              avars:=IndeterminatesOfPolynomialRing(APR);\n\n              # BPR's\n              BPR:=ring(chevalleyAdjBPR(w));\n              dim:=Dimension(w);\n              xvars:=IndeterminatesOfPolynomialRing(BPR){[1..dim]};\n\n              # centralizer\n              #centralizer:=UnipotentCentralizer(algebraicAdj(w),u,distP);\n              avars_free:=Set(List(Filtered(coefficients(centralizer),i->i[2] in avars),j->j[2]));\n              Sort(avars_free,function(a,b) return ExtRepPolynomialRatFun(a)[1][1]<ExtRepPolynomialRatFun(b)[1][1]; end);\n              avars_ext:=List(avars_free,i->ExtRepPolynomialRatFun(i));\n              avars_ext:=List(avars_ext,i->i[1][1]);\n\n              result:=List(avars_free,i->Zero(BPR));\n              coeffs:=coefficients(centralizer);\n              u_ordered:=Unipotent(chevalleyAdj(u),#algebraicU(w), asta de ce nu merge?\n                                   coefficients(u),#coefficients(Ascend(u,simpleAdjAPR(algebraicAdj(w)))),\n                                   [1..Length(positiveRoots(chevalleyAdjBPR(w)))],\n                                   -2);\n              for i in coefficients(u_ordered) do\n                  k:=Filtered(coeffs,j->j[1]=i[1]);\n                  if k = [] then return fail; fi;\n                  k:=k[1];\n                  if k[2] in avars_free then\n                      pos:=Position(avars_free,k[2]);\n                      result[pos]:=xvars[1];\n                  fi;\n              od;\n              wg:=GenericWittGroup(centralizer,w,result);\n\n\n              # function for handeling free variables udpate\n              xvars_ext:=List(xvars,i->ExtRepPolynomialRatFun(i));\n              xvars_ext:=List(xvars_ext,i->i[1][1]);\n              update_poly:=function(poly,values)\n                  local result,\n                  monom,ext,j,k,pos;\n                  result:=Zero(BPR);\n                  ext:=ExtRepPolynomialRatFun(poly);\n                  for j in [1..Length(ext)/2] do\n                      monom:=One(BPR);\n                      for k in [1..Length(ext[2*j-1])/2] do\n                          pos:=Position(xvars_ext,ext[2*j-1][2*k-1]);\n                          monom:=monom*xvars[pos]^ext[2*j-1][2*k];\n                      od;\n                      monom:=monom*(Value(ext[2*j],avars,values)*One(APR));\n                      result:=result+monom;\n                  od;\n                  return result;\n              end;\n\n\n              values:=ShallowCopy(avars);\n              step:=0;\n              for i in coeffs do\n                  if i[2] in avars_free then\n                      pos:=Position(avars_free,i[2]);\n                      if result[pos]=Zero(BPR) then\n                          # value of free variable\n                          sol:=SolveWittRoot(wg,w,i[1],values,step);\n                          #if sol=fail then return fail; fi;\n                          values:=sol[2];\n                          step:=sol[3];\n                          # update the construction made so far\n                          result:=List(result,i->update_poly(i,values));\n                          # set free variable\n                          result[pos]:=sol[1];\n                          # rebuild group\n                          wg:=GenericWittGroup(centralizer,w,result);\n                      fi;\n                  fi;\n              od;\n    \n              return wg;\nend);\n\nInstallMethod(TestWittGroup,\n              \"Test if the given unipotent element has the structure of a given witt group\",\n              [IsUnipotent,IsWitt],\n              function(ux,w)\n              local dim,p,BPR,xvar,yvar,\n              uy,uxy,xcoeff,xycoeff,\n              gws,i;\n\n              dim:=Dimension(w);\n              BPR:=ring(chevalleyAdjBPR(w));\n              xvar:=IndeterminatesOfPolynomialRing(BPR){[1..dim]};\n              yvar:=IndeterminatesOfPolynomialRing(BPR){dim+[1..dim]};\n\n              uy:=Value(ux,xvar,yvar);\n              gws:=GenericSum(w);\n\n              uxy:=ux*uy;\n              for i in [1..Length(positiveRoots(chevalleyAdj(ux)))] do\n                  xcoeff:=coefficients(Subword(ux,[i]));\n                  xycoeff:=coefficients(Subword(uxy,[i]));\n                  if xcoeff=[] and xycoeff<>[] then return i;\n                  elif xcoeff<>[] and xycoeff=[] then return i;\n                  elif xcoeff<>[] and xycoeff<>[] and Value(xcoeff[1][2],xvar,gws)<>xycoeff[1][2] then return i;\n                  fi;\n              od;\n              \n              return true;\nend);\n\nInstallMethod(WittDecomposition,\n              \"Decomposition of abelian algebraic group into witt group factors\",\n              [IsUnipotent,IsWitt],\n              function(abelian,w)\n              local result,\n              APR,avars,p,vals,i,tmp,dim,exp,\n              handled,support;\n\n              APR:=ring(chevalleyAdj(abelian));\n              avars:=IndeterminatesOfPolynomialRing(APR);\n              avars:=Filtered(coefficients(abelian),i->i[2] in avars);\n              avars:=Set(List(avars,i->i[2]));\n              Sort(avars,function(a,b) return ExtRepPolynomialRatFun(a)[1][1]<ExtRepPolynomialRatFun(b)[1][1]; end);\n              dim:=Length(avars);\n              #    Print(\"dim=\",dim,\"\\n\");\n\n              p:=Characteristic(APR);\n              exp:=Maximum(List(ParameterPieces(abelian),i->OrderOp(i)));\n              exp:=LogInt(exp,p);\n\n              vals:=List([1..dim],i->Zero(APR));\n              result:=[];\n              handled:=[];\n              for i in [1..dim] do\n                  vals[i]:=One(APR);#avars[1];\n                  tmp:=Value(abelian,avars,vals);\n                  support:=List(coefficients(tmp),i->i[1]);\n                  if not IsSubset(handled,support) then\n                      #tmp:=WittGr(tmp,abelian,w[LogInt(OrderOp(tmp),p)]);\n                      tmp:=WittGroup(tmp,abelian,w);\n                      Add(result,tmp);\n                      support:=List(coefficients(tmp),i->i[1]);\n                      handled:=Concatenation(handled,support);\n                  fi;\n                  vals[i]:=Zero(APR);\n              od;\n\n#    result:=List(result,i->UnipotentLieElement(sysAPR,i,0,ordering(u),1));\n              return result;\nend);\n", "meta": {"hexsha": "53add63ead070a0e0690f25591262d9f4a6edd61", "size": 27443, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/unialg.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/unialg.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/unialg.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": 39.4295977011, "max_line_length": 142, "alphanum_fraction": 0.4947345407, "num_tokens": 6597, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.48952371600351813}}
{"text": "ITER_POLY_WARN:=false;\nRead(Filename(home_dir,\"lib/io.gi\"));\nRead(Filename(home_dir,\"handle.gi\"));\n\n\nsys:=ChevalleyAdj(\"E\",6,GF(3));\nalg:=AlgebraicU(sys);\norbs:=UnipotentClasses(alg,\"\");\ninfos:=List(AllClasses(orbs),o->handleClassShort(o));\nlabels:=List(AllClasses(orbs),x->Label(x));\n\nAPR:=ring(alg);\navars:=IndeterminatesOfPolynomialRing(APR);\nvals:=ShallowCopy(avars);\npr:=positiveRoots(alg);\ngeneric:=Unipotent(alg,List([1..Length(pr)],i->[i,avars[i]]));\n\nRead(Filename(components_dir,\"E6char3.gi\"));", "meta": {"hexsha": "08a6d63559786b6f61312ae233b29d26cdfc6973", "size": 504, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/cases/e6/char3/_init_char3.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/cases/e6/char3/_init_char3.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/cases/e6/char3/_init_char3.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.0, "max_line_length": 62, "alphanum_fraction": 0.7261904762, "num_tokens": 165, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104788995148791, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.48947400798021756}}
{"text": "SymmetricDifference := function(a, b)\n  return Union(Difference(a, b), Difference(b, a));\nend;\n\na := [\"John\", \"Serena\", \"Bob\", \"Mary\", \"Serena\"];\nb := [\"Jim\", \"Mary\", \"John\", \"Jim\", \"Bob\"];\nSymmetricDifference(a,b);\n[ \"Jim\", \"Serena\" ]\n", "meta": {"hexsha": "ad073d72a85f802c2cdf3ab5b2e115b888129323", "size": 236, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Symmetric-difference/GAP/symmetric-difference.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/Symmetric-difference/GAP/symmetric-difference.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/Symmetric-difference/GAP/symmetric-difference.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 26.2222222222, "max_line_length": 51, "alphanum_fraction": 0.5889830508, "num_tokens": 76, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.4889567322227837}}
{"text": "# Some small pregroups\n\n\n\n# The lists of small pregroups were generated by\n# Chris Jefferson <caj21@st-andrews.ac.uk> and\n# Richard Parker.\nANATPH_small_pregroups[1] :=\n   [ [ [ 1 ] ] ];\n\nANATPH_small_pregroups[2] :=\n   [ [ [1, 2],\n       [2, 1] ] ];\n\nANATPH_small_pregroups[3] :=\n   [ [ [1, 2, 3],\n       [2, 1, 0],\n       [3, 0, 1] ] ];\n# missing: Cyclic group of order 3\n\nANATPH_small_pregroups[4] :=\n [ [ [1, 2, 3, 4],\n     [2, 1, 0, 0],\n     [3, 0, 1, 0],\n     [4, 0, 0, 1] ],\n   [ [1, 2, 3, 4],\n     [2, 1, 4, 3],\n     [3, 4, 1, 2],\n     [4, 3, 2, 1] ],\n   [ [1, 2, 3, 4],\n     [2, 1, 0, 0],\n     [3, 0, 0, 1],\n     [4, 0, 1, 0] ],\n   [ [1, 2, 3, 4],\n     [2, 1, 0, 0],\n     [3, 0, 4, 1],\n     [4, 0, 1, 3] ],\n   [ [1, 2, 3, 4],\n     [2, 1, 4, 3],\n     [3, 4, 2, 1],\n     [4, 3, 1, 2] ] ];\n\nANATPH_small_pregroups[5] :=\n   [ [ [1, 2, 3, 4, 5],\n       [2, 1, 0, 0, 0],\n       [3, 0, 1, 0, 0],\n       [4, 0, 0, 1, 0],\n       [5, 0, 0, 0, 1] ],\n     [ [1, 2, 3, 4, 5],\n       [2, 1, 4, 3, 0],\n       [3, 4, 1, 2, 0],\n       [4, 3, 2, 1, 0],\n       [5, 0, 0, 0, 1]],\n     [ [1, 2, 3, 4, 5],\n       [2, 1, 0, 0, 0],\n       [3, 0, 1, 0, 0],\n       [4, 0, 0, 0, 1],\n       [5, 0, 0, 1, 0]],\n     [ [1, 2, 3, 4, 5],\n       [2, 1, 0, 0, 0],\n       [3, 0, 1, 0, 0],\n       [4, 0, 0, 5, 1],\n       [5, 0, 0, 1, 4]],\n     [ [1, 2, 3, 4, 5],\n       [2, 1, 4, 3, 0],\n       [3, 4, 2, 1, 0],\n       [4, 3, 1, 2, 0],\n       [5, 0, 0, 0, 1]],\n     [ [1, 2, 3, 4, 5],\n       [2, 0, 1, 0, 0],\n       [3, 1, 0, 0, 0],\n       [4, 0, 0, 0, 1],\n       [5, 0, 0, 1, 0]],\n     [ [1, 2, 3, 4, 5],\n       [2, 3, 1, 0, 0],\n       [3, 1, 2, 0, 0],\n       [4, 0, 0, 0, 1],\n       [5, 0, 0, 1, 0]],\n     [ [1, 2, 3, 4, 5],\n       [2, 3, 1, 0, 0],\n       [3, 1, 2, 0, 0],\n       [4, 0, 0, 5, 1],\n       [5, 0, 0, 1, 4]],\n     [ [1, 2, 3, 4, 5],\n       [2, 3, 4, 5, 1],\n       [3, 4, 5, 1, 2],\n       [4, 5, 1, 2, 3],\n       [5, 1, 2, 3, 4]]];\n\nANATPH_small_pregroups[6] :=\n    [ [ [1,2,3,4,5,6],\n        [2,1,0,5,4,0],\n        [3,6,0,1,0,0],\n        [4,0,1,0,0,2],\n        [5,0,2,0,0,1],\n        [6,3,0,0,1,0] ],\n      [ [1,2,3,4,5,6],\n        [2,1,5,0,3,0],\n        [3,0,0,1,0,2],\n        [4,6,1,0,0,0],\n        [5,0,0,2,0,1],\n        [6,4,0,0,1,0] ],\n      [ [1,2,3,4,5,6],\n        [2,1,0,6,0,4],\n        [3,5,0,1,0,0],\n        [4,0,1,0,2,0],\n        [5,3,0,0,0,1],\n        [6,0,2,0,1,0] ],\n      [ [1,2,3,4,5,6],\n        [2,1,5,6,3,4],\n        [3,5,0,1,0,2],\n        [4,6,1,0,2,0],\n        [5,3,0,2,0,1],\n        [6,4,2,0,1,0] ],\n      [ [1,2,3,4,5,6],\n        [2,1,6,0,0,3],\n        [3,0,0,1,2,0],\n        [4,5,1,0,0,0],\n        [5,4,0,0,0,1],\n        [6,0,0,2,1,0] ],\n      [ [1,2,3,4,5,6],\n        [2,1,6,5,4,3],\n        [3,6,0,1,2,0],\n        [4,5,1,0,0,2],\n        [5,4,2,0,0,1],\n        [6,3,0,2,1,0] ],\n      [ [1,2,3,4,5,6],\n        [2,1,5,6,3,4],\n        [3,6,1,0,0,2],\n        [4,5,0,1,2,0],\n        [5,4,2,0,0,1],\n        [6,3,0,2,1,0] ],\n      [ [1,2,3,4,5,6],\n        [2,1,0,6,0,4],\n        [3,0,1,5,4,0],\n        [4,5,6,1,2,3],\n        [5,4,0,3,0,1],\n        [6,0,4,2,1,0] ],\n      [ [1,2,3,4,5,6],\n        [2,1,0,5,4,0],\n        [3,0,1,6,0,4],\n        [4,6,5,1,3,2],\n        [5,0,4,2,0,1],\n        [6,4,0,3,1,0] ],\n      [ [1,2,3,4,5,6],\n        [2,1,6,0,0,3],\n        [3,5,1,6,2,4],\n        [4,0,5,1,3,0],\n        [5,3,4,0,0,1],\n        [6,0,2,3,1,0] ],\n      [ [1,2,3,4,5,6],\n        [2,1,4,3,6,5],\n        [3,4,1,2,0,0],\n        [4,3,2,1,0,0],\n        [5,6,0,0,2,1],\n        [6,5,0,0,1,2] ],\n      [ [1,2,3,4,5,6],\n        [2,1,4,3,0,0],\n        [3,4,1,2,6,5],\n        [4,3,2,1,0,0],\n        [5,0,6,0,3,1],\n        [6,0,5,0,1,3] ],\n      [ [1,2,3,4,5,6],\n        [2,1,4,3,0,0],\n        [3,4,1,2,0,0],\n        [4,3,2,1,6,5],\n        [5,0,0,6,4,1],\n        [6,0,0,5,1,4] ],\n      [ [1,2,3,4,5,6],\n        [2,1,6,5,4,3],\n        [3,6,1,0,0,2],\n        [4,5,0,1,2,0],\n        [5,4,0,2,1,0],\n        [6,3,2,0,0,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,6,0,0,3],\n        [3,6,1,5,4,2],\n        [4,0,5,1,3,0],\n        [5,0,4,3,1,0],\n        [6,3,2,0,0,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,5,6,3,4],\n        [3,5,1,0,2,0],\n        [4,6,0,1,0,2],\n        [5,3,2,0,1,0],\n        [6,4,0,2,0,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,0,6,0,4],\n        [3,0,1,5,4,0],\n        [4,6,5,1,3,2],\n        [5,0,4,3,1,0],\n        [6,4,0,2,0,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,5,0,3,0],\n        [3,5,1,6,2,4],\n        [4,0,6,1,0,3],\n        [5,3,2,0,1,0],\n        [6,0,4,3,0,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,0,5,4,0],\n        [3,0,1,6,0,4],\n        [4,5,6,1,2,3],\n        [5,4,0,2,1,0],\n        [6,0,4,3,0,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,4,3,6,5],\n        [3,4,1,2,0,0],\n        [4,3,2,1,0,0],\n        [5,6,0,0,1,2],\n        [6,5,0,0,2,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,0,0,6,5],\n        [3,0,1,5,4,0],\n        [4,0,5,1,3,0],\n        [5,6,4,3,1,2],\n        [6,5,0,0,2,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,0,0,6,5],\n        [3,0,1,6,0,4],\n        [4,0,6,1,0,3],\n        [5,6,0,0,1,2],\n        [6,5,4,3,2,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,4,3,0,0],\n        [3,4,1,2,6,5],\n        [4,3,2,1,0,0],\n        [5,0,6,0,1,3],\n        [6,0,5,0,3,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,0,5,4,0],\n        [3,0,1,0,6,5],\n        [4,5,0,1,2,0],\n        [5,4,6,2,1,3],\n        [6,0,5,0,3,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,0,6,0,4],\n        [3,0,1,0,6,5],\n        [4,6,0,1,0,2],\n        [5,0,6,0,1,3],\n        [6,4,5,2,3,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,4,3,0,0],\n        [3,4,1,2,0,0],\n        [4,3,2,1,6,5],\n        [5,0,0,6,1,4],\n        [6,0,0,5,4,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,5,0,3,0],\n        [3,5,1,0,2,0],\n        [4,0,0,1,6,5],\n        [5,3,2,6,1,4],\n        [6,0,0,5,4,1] ],\n      [ [1,2,3,4,5,6],\n        [2,1,6,0,0,3],\n        [3,6,1,0,0,2],\n        [4,0,0,1,6,5],\n        [5,0,0,6,1,4],\n        [6,3,2,5,4,1] ]\n    ];\n\nANATPH_small_pregroups[7] :=\n    [ [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 0, 0, 0, 0, 0],\n        [3, 0, 1, 0, 0, 0, 0],\n        [4, 0, 0, 1, 0, 0, 0],\n        [5, 0, 0, 0, 1, 0, 0],\n        [6, 0, 0, 0, 0, 1, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 4, 1, 2, 0, 0, 0],\n        [4, 3, 2, 1, 0, 0, 0],\n        [5, 0, 0, 0, 1, 0, 0],\n        [6, 0, 0, 0, 0, 1, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 4, 1, 2, 0, 0, 0],\n        [4, 3, 2, 1, 0, 0, 0],\n        [5, 0, 0, 0, 1, 7, 6],\n        [6, 0, 0, 0, 7, 1, 5],\n        [7, 0, 0, 0, 6, 5, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 6, 5, 0],\n        [3, 4, 1, 2, 0, 0, 0],\n        [4, 3, 2, 1, 0, 0, 0],\n        [5, 6, 0, 0, 1, 2, 0],\n        [6, 5, 0, 0, 2, 1, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 0, 0, 0, 0, 0],\n        [3, 0, 1, 0, 0, 0, 0],\n        [4, 0, 0, 1, 0, 0, 0],\n        [5, 0, 0, 0, 1, 0, 0],\n        [6, 0, 0, 0, 0, 0, 1],\n        [7, 0, 0, 0, 0, 1, 0] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 0, 0, 0, 0, 0],\n        [3, 0, 1, 0, 0, 0, 0],\n        [4, 0, 0, 1, 0, 0, 0],\n        [5, 0, 0, 0, 1, 0, 0],\n        [6, 0, 0, 0, 0, 7, 1],\n        [7, 0, 0, 0, 0, 1, 6] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 4, 1, 2, 0, 0, 0],\n        [4, 3, 2, 1, 0, 0, 0],\n        [5, 0, 0, 0, 1, 0, 0],\n        [6, 0, 0, 0, 0, 0, 1],\n        [7, 0, 0, 0, 0, 1, 0] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 4, 1, 2, 0, 0, 0],\n        [4, 3, 2, 1, 0, 0, 0],\n        [5, 0, 0, 0, 1, 0, 0],\n        [6, 0, 0, 0, 0, 7, 1],\n        [7, 0, 0, 0, 0, 1, 6] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 4, 1, 2, 0, 0, 0],\n        [4, 3, 2, 1, 0, 0, 0],\n        [5, 0, 0, 0, 1, 7, 6],\n        [6, 0, 0, 0, 7, 5, 1],\n        [7, 0, 0, 0, 6, 1, 5] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 6, 5, 0],\n        [3, 4, 1, 2, 0, 0, 0],\n        [4, 3, 2, 1, 0, 0, 0],\n        [5, 6, 0, 0, 2, 1, 0],\n        [6, 5, 0, 0, 1, 2, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 6, 5, 0],\n        [3, 5, 1, 0, 2, 0, 0],\n        [4, 6, 2, 0, 1, 0, 0],\n        [5, 3, 0, 1, 0, 2, 0],\n        [6, 4, 0, 2, 0, 1, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 6, 5, 0],\n        [3, 5, 1, 6, 2, 4, 0],\n        [4, 6, 2, 5, 1, 3, 0],\n        [5, 3, 6, 1, 4, 2, 0],\n        [6, 4, 5, 2, 3, 1, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 0, 0, 0, 0, 0],\n        [3, 0, 1, 0, 0, 0, 0],\n        [4, 0, 0, 0, 1, 0, 0],\n        [5, 0, 0, 1, 0, 0, 0],\n        [6, 0, 0, 0, 0, 0, 1],\n        [7, 0, 0, 0, 0, 1, 0] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 0, 0, 0, 0, 0],\n        [3, 0, 1, 0, 0, 0, 0],\n        [4, 0, 0, 5, 1, 0, 0],\n        [5, 0, 0, 1, 4, 0, 0],\n        [6, 0, 0, 0, 0, 0, 1],\n        [7, 0, 0, 0, 0, 1, 0] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 0, 0, 0, 0, 0],\n        [3, 0, 1, 0, 0, 0, 0],\n        [4, 0, 0, 5, 1, 0, 0],\n        [5, 0, 0, 1, 4, 0, 0],\n        [6, 0, 0, 0, 0, 7, 1],\n        [7, 0, 0, 0, 0, 1, 6] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 0, 0, 0, 0, 0],\n        [3, 0, 1, 0, 0, 0, 0],\n        [4, 0, 0, 5, 6, 7, 1],\n        [5, 0, 0, 6, 7, 1, 4],\n        [6, 0, 0, 7, 1, 4, 5],\n        [7, 0, 0, 1, 4, 5, 6] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 4, 2, 1, 0, 0, 0],\n        [4, 3, 1, 2, 0, 0, 0],\n        [5, 0, 0, 0, 1, 0, 0],\n        [6, 0, 0, 0, 0, 1, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 4, 2, 1, 0, 0, 0],\n        [4, 3, 1, 2, 0, 0, 0],\n        [5, 0, 0, 0, 1, 0, 0],\n        [6, 0, 0, 0, 0, 0, 1],\n        [7, 0, 0, 0, 0, 1, 0] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 4, 2, 1, 0, 0, 0],\n        [4, 3, 1, 2, 0, 0, 0],\n        [5, 0, 0, 0, 1, 0, 0],\n        [6, 0, 0, 0, 0, 7, 1],\n        [7, 0, 0, 0, 0, 1, 6] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 4, 2, 1, 0, 0, 0],\n        [4, 3, 1, 2, 0, 0, 0],\n        [5, 0, 0, 0, 1, 7, 6],\n        [6, 0, 0, 0, 7, 5, 1],\n        [7, 0, 0, 0, 6, 1, 5] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 6, 5, 0],\n        [3, 4, 2, 1, 0, 0, 0],\n        [4, 3, 1, 2, 0, 0, 0],\n        [5, 6, 0, 0, 2, 1, 0],\n        [6, 5, 0, 0, 1, 2, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 0, 0, 0, 1, 2, 0],\n        [4, 0, 0, 0, 2, 1, 0],\n        [5, 6, 1, 0, 0, 0, 0],\n        [6, 5, 0, 1, 0, 0, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 0, 0, 0],\n        [3, 0, 0, 0, 1, 2, 4],\n        [4, 0, 0, 0, 2, 1, 3],\n        [5, 6, 1, 7, 0, 0, 0],\n        [6, 5, 7, 1, 0, 0, 0],\n        [7, 0, 0, 0, 6, 5, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 6, 5, 0],\n        [3, 4, 0, 0, 1, 2, 0],\n        [4, 3, 0, 0, 2, 1, 0],\n        [5, 6, 1, 2, 0, 0, 0],\n        [6, 5, 2, 1, 0, 0, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 1, 4, 3, 6, 5, 0],\n        [3, 4, 5, 6, 1, 2, 0],\n        [4, 3, 6, 5, 2, 1, 0],\n        [5, 6, 1, 2, 3, 4, 0],\n        [6, 5, 2, 1, 4, 3, 0],\n        [7, 0, 0, 0, 0, 0, 1] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 0, 1, 0, 0, 0, 0],\n        [3, 1, 0, 0, 0, 0, 0],\n        [4, 0, 0, 0, 1, 0, 0],\n        [5, 0, 0, 1, 0, 0, 0],\n        [6, 0, 0, 0, 0, 0, 1],\n        [7, 0, 0, 0, 0, 1, 0] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 3, 1, 0, 0, 0, 0],\n        [3, 1, 2, 0, 0, 0, 0],\n        [4, 0, 0, 0, 1, 0, 0],\n        [5, 0, 0, 1, 0, 0, 0],\n        [6, 0, 0, 0, 0, 0, 1],\n        [7, 0, 0, 0, 0, 1, 0] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 3, 1, 0, 0, 0, 0],\n        [3, 1, 2, 0, 0, 0, 0],\n        [4, 0, 0, 5, 1, 0, 0],\n        [5, 0, 0, 1, 4, 0, 0],\n        [6, 0, 0, 0, 0, 0, 1],\n        [7, 0, 0, 0, 0, 1, 0] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 3, 1, 0, 0, 0, 0],\n        [3, 1, 2, 0, 0, 0, 0],\n        [4, 0, 0, 5, 1, 0, 0],\n        [5, 0, 0, 1, 4, 0, 0],\n        [6, 0, 0, 0, 0, 7, 1],\n        [7, 0, 0, 0, 0, 1, 6] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 0, 1, 5, 0, 0, 0],\n        [3, 1, 0, 0, 4, 0, 0],\n        [4, 0, 0, 0, 0, 1, 3],\n        [5, 0, 0, 0, 0, 2, 1],\n        [6, 0, 7, 1, 0, 0, 0],\n        [7, 6, 0, 0, 1, 0, 0] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 3, 1, 0, 0, 0, 0],\n        [3, 1, 2, 0, 0, 0, 0],\n        [4, 0, 0, 5, 6, 7, 1],\n        [5, 0, 0, 6, 7, 1, 4],\n        [6, 0, 0, 7, 1, 4, 5],\n        [7, 0, 0, 1, 4, 5, 6] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 3, 4, 5, 1, 0, 0],\n        [3, 4, 5, 1, 2, 0, 0],\n        [4, 5, 1, 2, 3, 0, 0],\n        [5, 1, 2, 3, 4, 0, 0],\n        [6, 0, 0, 0, 0, 0, 1],\n        [7, 0, 0, 0, 0, 1, 0] ],\n      [ [1, 2, 3, 4, 5, 6, 7],\n        [2, 3, 4, 5, 6, 7, 1],\n        [3, 4, 5, 6, 7, 1, 2],\n        [4, 5, 6, 7, 1, 2, 3],\n        [5, 6, 7, 1, 2, 3, 4],\n        [6, 7, 1, 2, 3, 4, 5],\n        [7, 1, 2, 3, 4, 5, 6] ]\n    ];\n\nInstallGlobalFunction(\"NrSmallPregroups\",\nfunction(n)\n    if not IsPosInt(n) then\n        Error(\"n has to be a positive integer\");\n    fi;\n\n    if IsBound(ANATPH_small_pregroups[n]) then\n        return Length(ANATPH_small_pregroups[n]);\n    fi;\n    return fail;\nend);\n\nInstallGlobalFunction(\"SmallPregroup\",\nfunction(n,i)\n    local names;\n    if not IsPosInt(n) then\n        Error(\"n has to be a positive integer\");\n    fi;\n\n    if IsPosInt(i) and\n       IsBound(ANATPH_small_pregroups[n]) and\n       IsBound(ANATPH_small_pregroups[n][i]) then\n        names := Concatenation( [\"1\"]\n                              , List([2..n], y -> Concatenation(\"p\", String(y-1))));\n        return PregroupByTable(names, ANATPH_small_pregroups[n][i]);\n    else\n        Error(\"small pregroup of size \", n, \" with index \", i, \" not available\");\n    fi;\nend);\n", "meta": {"hexsha": "4f8013a153820804a0e15b91ece0eeb56779dabd", "size": 13978, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "gap/small_pregroups.gi", "max_stars_repo_name": "RussWoodroofe/walrus", "max_stars_repo_head_hexsha": "f7a4e3597f288c6d9518aaa39091826dadc864b8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-02T14:55:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-02T14:55:52.000Z", "max_issues_repo_path": "gap/small_pregroups.gi", "max_issues_repo_name": "RussWoodroofe/walrus", "max_issues_repo_head_hexsha": "f7a4e3597f288c6d9518aaa39091826dadc864b8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 26, "max_issues_repo_issues_event_min_datetime": "2018-11-22T11:15:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-21T13:31:01.000Z", "max_forks_repo_path": "gap/small_pregroups.gi", "max_forks_repo_name": "RussWoodroofe/walrus", "max_forks_repo_head_hexsha": "f7a4e3597f288c6d9518aaa39091826dadc864b8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2019-02-11T14:47:47.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-20T10:22:09.000Z", "avg_line_length": 26.6755725191, "max_line_length": 84, "alphanum_fraction": 0.2687079697, "num_tokens": 8989, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765706, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.48863104669718466}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# mn=16, m=4, n=4, h=3\nImportAll(spiral);\n\n# even k, P permutation on pairs\n P := (km,k) -> (i -> let(m := km/k, h := Int((m+2)/2), mc:=Int((m+1)/2),\n\t Cond(\n\t     i < h, k*i, \n\t     i >= km/2-mc+1, k/2 + k*(i-(km/2-mc+1)), \n\t     ((i-h) mod m) mod 2 = 0, k*((i-h) mod m)/2 + 1 + Int((i-h)/m),\n\t\t              k*((i-h) mod m)/2 + 1 + Int(k/2-1-(i-h)/m)\n\t )));\n\n# even k, P permutation on single el-s\n rP := (km,k) -> (i -> let(m := km/k, \n\t Cond(\n\t     i = 0, 0,\n\t     1 <= i and i < m, -1 + 2*k*Int((i+1)/2) + ((i-1) mod 2),\n\t     i >= km-m, k + 2*k*Int((i-(km-m))/2) - 1 + ((i-m) mod 2), \n\t     (Int((i-m)/2) mod m) mod 2 = 0, k*(Int((i-m)/2) mod m) + 1 + 2*Int((i-m)/(2*m)) + (i-m) mod 2,\n\t                                     k*(Int((i-m)/2) mod m) + 1 + 2*Int((km-m-i)/(2*m)) + (i-m) mod 2\n\t )));\n\n# odd k, \\hat{P} permutation on pairs\n Phat := (km,k) -> (i -> let(m := km/k, h := Int((m+2)/2),\n\t Cond(\n\t     i < h, k*i, \n\t     ((i-h) mod m) mod 2 = 0, Int(k*((i-h) mod m)/2) + 1 + Int((i-h)/m),\n\t\t                      Int(k*((i-h) mod m)/2) +  Int((k+1)/2-(i-h)/m)\n\t )));\n\n# odd k\n rPhat := (km,k) -> (i -> let(m := km/k,\n\t Cond(\n\t     i = 0, 0,\n\t     1 <= i and i < m, -1 + 2*k*Int((i+1)/2) + ((i-1) mod 2),\n\t     (Int((i-m)/2) mod m) mod 2 = 0, k*(Int((i-m)/2) mod m) + 1 + 2*Int((i-m)/(2*m)) + (i-m) mod 2,\n\t\t                             k*(Int((i-m)/2) mod m) +     2*Int((km-i)/(2*m)) + (i-m) mod 2\n\t )));\n\n# odd k\n rQhat := (km,k) -> (i -> let(m := km/k,\n\t Cond(\n\t     i >= km-m, k-1 + 2*k*Int((i-(km-m))/2) + (i-(km-m)) mod 2, \n\t     (Int(i/2) mod m) mod 2 = 0, k*(Int(i/2) mod m) +     2*Int(i/(2*m)) + i mod 2,\n\t                                 k*(Int(i/2) mod m) + 1 + 2*Int((km-m-i)/(2*m)) + i mod 2\n\t )));\n\n# Pshow := (km,k)->let(N := Int(km/2)+1, pm(Perm(PermFunc(P(km,k),N),N)));\n# rPshow := (km,k)->let(N := km, pm(Perm(PermFunc(rP(km,k),N),N)));\n# Phatshow := (km,k)->let(N := Int((km+2)/2), pm(Perm(PermFunc(Phat(km,k),N),N)));\n\nPermP := (m, k) -> Checked(IsEvenInt(k), PermFunc(rP(k*m,k),k*m)^-1);\nPermPhat := (m, k) -> Checked(IsOddInt(k), PermFunc(rPhat(k*m,k),k*m)^-1);\nPermQhat := (m, k) -> Checked(IsOddInt(k), PermFunc(rQhat(k*m,k),k*m)^-1);\n\np_4_4 := PermP(4,4);\np_4_8 := PermP(4,8);\np_8_4 := PermP(8,4);\np_8_8 := PermP(8,8);\n\np_3_4 := PermP(3,4);\np_5_4 := PermP(5,4);\np_5_8 := PermP(5,8);\n\nphat_4_3 := PermPhat(4,3);\nphat_4_5 := PermPhat(4,5);\nphat_8_5 := PermPhat(8,5);\nphat_8_7 := PermPhat(8,7);\nphat_7_7 := PermPhat(7,7);\n\nqhat_4_3 := PermQhat(4,3);\nqhat_4_5 := PermQhat(4,5);\nqhat_8_5 := PermQhat(8,5);\nqhat_8_7 := PermQhat(8,7);\nqhat_7_7 := PermQhat(7,7);\n", "meta": {"hexsha": "962de68b597eb54f4b99a2a13c53da42794796db", "size": 2677, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sym/rft/perms.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/sym/rft/perms.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/sym/rft/perms.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 33.049382716, "max_line_length": 102, "alphanum_fraction": 0.4531191632, "num_tokens": 1260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388252252041, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4881530642465783}}
{"text": "# Copyright (c) 2018-2020, Carnegie Mellon University\n# See LICENSE for details\n#\n# Utility functions for checking properties of the adjacency matrix NISQ topology\n#\n\n##\n#F GetEdges( <arch>, <q> )\n## \n## Gets a list of edges in arch for a target qubit q\nGetEdges := function(arch, q)\n    local row, inqub, edges, e, edges;\n    row := arch[q+1];\n    inqub := 0;\n    edges := [];\n    for e in row do \n        if e = 1 then\n            Add(edges, inqub);\n        fi;\n        inqub := inqub + 1;\n    od;\n    # now have a list of adjacent qubits to the chosen qubit\n    return edges;\nend;\n\n##\n#F HasEdge( <i>, <j>, <arch> )\n## \n#F Checks if there is an edge between qubits i and j in arch\nHasEdge:= function (i, j, arch)\n    local row;\n    row := arch[i+1];\n    return row[j+1];\nend;\n\n##\n#F GetDist( <i>, <j>, <arch> )\n## \n#F Returns the minimum distance in the architecture from qubit i to qubit j\nGetDist := function (i, j, arch)\n    local es, distances, dist, adjmat, n, inc;\n    if (i = j) then\n        return 0;\n    fi;\n    adjmat := arch;\n    n := Length(arch);\n    dist := 1;\n    inc := 0;\n    while (adjmat[i+1][j+1] <= 0 and inc <= n) do \n        adjmat := adjmat * adjmat;\n        dist := dist + 1;\n        inc := inc + 1;\n    od;\n    if inc > n then # not possible, maybe do something better than returning null\n        return n+2; #psuedo-null\n    fi;\n    return dist;\nend;\n\n##\n#F Best_Move( <i>, <j>, <arch> )\n## \n#F Returns the most straightforward swap to perform to bring i and j closer\nBest_Move := function (i, j, arch)\n    local es, distances, shortest_path, e, best_move, l, tes;\n    es := GetEdges(arch, i);\n    tes := GetEdges(arch, j);\n    if ContainsElement(es, j) then # if immediate neighbors\n        return j;\n    fi;\n    l := Filtered(es, (e)-> ContainsElement(tes, e)); # find the immediate children they share, see if any match\n    if l <> [] then \n        return l[1];\n    fi;\n    # have to calculate distances\n    distances := Map(es, e -> (GetDist(e, j, arch)));\n    shortest_path := Minimum(distances);\n    shortest_path := PositionProperty(distances, (e) -> (e = shortest_path));\n    best_move := es[shortest_path];\n    return best_move;\nend;\n\n##\n#F VerifyPath( <target>, <source>, <arch> )\n## \n#F verifies that target and source are connected in arch\nVerifyPath := function (target, source, arch)\n    local i, q;\n    i := 1;\n    for q in target do \n        if(GetDist(target[i], source[i], arch) > Length(arch)) then \n            return false;\n        fi;\n        i := i + 1;\n    od;\n    return true;\nend;", "meta": {"hexsha": "36a500204cb730325c7e3af330fa078268cec28f", "size": 2536, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "nisq.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": "nisq.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": "nisq.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": 26.1443298969, "max_line_length": 112, "alphanum_fraction": 0.5879337539, "num_tokens": 758, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.48801750847178366}}
{"text": "\n#\n# Read(\"~/Workspace/groupsSB/epi/B2/generic.UU.gi\");\n#\n\ntype:=\"B\";\nrank:=2;\nnr_pos_roots:=4;\n\nRead(\"~/Workspace/groupsSB/epi/group.gi\");\n\n\nhandleUaUbUc:=function()\n\tlocal rels, vals,i,v;\n\t# UaUb=Uc = U(a1+b1,a2+b2,a3+b3+a2*b1)\n\trels:=Set(Concatenation(Ua*Ub-Uc));\n\t\n\tvals:=[];\n\tAppend(vals,[[[vars[22]],[vars[2]+vars[12]]]]);\n\tAppend(vals,[[[vars[21]],[vars[1]+vars[11]]]]);\n\tAppend(vals,[[[vars[23]],[vars[3]+vars[13]-vars[2]*vars[11]]]]);\n#a_{2}^2*b_{1}+2*a_{2}*b_{1}*b_{2}-2*a_{3}*b_{2}-a_{4}-b_{4}\n\tAppend(vals,[[[vars[24]],[-vars[2]^2*vars[11]-2*vars[2]*vars[11]*vars[12]+2*vars[3]*vars[12]+vars[4]+vars[14]]]]);\n\n\n\tfor i in [1..Length(rels)] do\n\t\tfor v in vals do\n\t\t\tPrint(rels[i],\"\\n\");\n\t\t\trels[i]:=One(APR)*Value(rels[i],v[1],v[2]);\n\t\tod;\n\tod;\n\treturn [vals,rels];\nend;\n", "meta": {"hexsha": "64f876b547021f28ca651b0367847c34a33d36f5", "size": 781, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "epi/B2/generic.UU.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/B2/generic.UU.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/B2/generic.UU.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.9705882353, "max_line_length": 115, "alphanum_fraction": 0.5864276569, "num_tokens": 342, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.4866862251920037}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nImport(paradigms.vector, platforms.sse);\n\n#\tTests SIMD functionality\nTestSIMD := function()\n\tif SSE_4x32f.active then\n\t\tdoSimdDft(5, SSE_4x32f);\n\t\tdoSimdDft(5, SSE_4x32f, rec(oddSizes:=false, svct:=false));\n\t\tdoSimdDft([2..20], SSE_4x32f);\n\tfi;\nend;", "meta": {"hexsha": "c3fa0236ef181edc4f0d13318c72f8622aaaca50", "size": 332, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/testsimd.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/testsimd.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/testsimd.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": 22.1333333333, "max_line_length": 61, "alphanum_fraction": 0.7319277108, "num_tokens": 122, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.48645101928408635}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nNewRulesFor(DFT, rec(\n    DFT_PRDFT := rec(\n    switch := false,\n    applicable := t -> Rows(t) >= 3 and t.getTags()=[],\n    children := t -> [[ PRDFT1(Rows(t),t.params[2]) ]],\n    apply := (t, ch, nonterms) -> let(n := Rows(t),\n        bc := Mat([[1, E(4)], [1, -E(4)]]),\n        DirectSum(\n        Mat([[1,0]]),\n        LIJ(n-1).transpose() * Cond(IsEvenInt(n),\n            DirectSum(Tensor(I((n-2)/2), bc), Mat([[1,0]])),\n            Tensor(I((n-1)/2), bc))) *\n        ch[1])\n\n    )\n));\n\nNewRulesFor(DFT2, rec(\n    DFT2_PRDFT2 := rec(\n    switch := false,\n    applicable := t -> Rows(t) >= 3,\n    children := t -> [[ PRDFT2(Rows(t), t.params[2]) ]],\n    apply := (t, ch, nonterms) -> let(n := Rows(t), sgn := (-1)^t.params[2],\n        bc := Mat([[1, E(4)], sgn*[1, -E(4)]]),\n        DirectSum(\n        Mat([[1,0]]),\n        LIJ(n-1).transpose() * Cond(IsEvenInt(n),\n            DirectSum(Tensor(I((n-2)/2), bc), Mat([[0,E(4)]])),\n            Tensor(I((n-1)/2), bc))) *\n        ch[1])\n\n    )\n));\n\nNewRulesFor(DFT3, rec(\n    DFT3_PRDFT3 := rec(\n    switch := false,\n    applicable := t -> Rows(t) >= 3,\n    children := t -> [[ PRDFT3(Rows(t), t.params[2]) ]],\n    apply := (t, ch, nonterms) -> let(n := Rows(t),\n        bc := Mat([[1, E(4)], [1, -E(4)]]),\n        LIJ(n).transpose() *\n        Cond(IsEvenInt(n),\n         Tensor(I(n/2), bc),\n         DirectSum(Tensor(I((n-1)/2), bc), Mat([[1,0]]))) *\n        ch[1])\n\n    )\n));\n\n\nNewRulesFor(DFT4, rec(\n    DFT4_PRDFT4 := rec(\n    switch := false,\n    applicable := t -> Rows(t) >= 3,\n    children := t -> [[ PRDFT4(Rows(t),t.params[2]) ]],\n    apply := (t, ch, nonterms) -> let(n := Rows(t), sgn := (-1)^t.params[2], jj := E(4)^t.params[2],\n        bc := Mat([[1, E(4)], sgn*[1, -E(4)]]),\n        LIJ(n).transpose() *\n        Cond(IsEvenInt(n),\n         Tensor(I(n/2), bc),\n                 # last element could be real or imaginary based on\n                 # rotation (t.params[2]) (but not both), so we scale both slots\n         DirectSum(Tensor(I((n-1)/2), bc), Mat([[jj,jj]]))) *\n        ch[1])\n\n    )\n));\n", "meta": {"hexsha": "8b239990647801f515fd860814fec9a58f44174a", "size": 2145, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/realdft/dft.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/transforms/realdft/dft.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/transforms/realdft/dft.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 28.9864864865, "max_line_length": 100, "alphanum_fraction": 0.4638694639, "num_tokens": 737, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4860874358292524}}
{"text": "############################################################################\n##\n##  matmeths.gi                  IRREDSOL                   Burkhard H\u00f6fling\n##\n##  Copyright \u00a9 2003\u20132016 Burkhard H\u00f6fling\n##\n\n\n############################################################################\n##\n#M  Degree(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(Degree, \"for matrix group\", true, [IsMatrixGroup], 0,\n    DegreeOfMatrixGroup);\n    \n        \n############################################################################\n##\n#M  DegreeOfMatrixGroup(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(DegreeOfMatrixGroup, \"for matrix group with dimension\", true, \n    [IsMatrixGroup and HasDimension], 0,\n    Dimension);\n\n\n############################################################################\n##\n#M  IsIrreducible(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(IsIrreducible, \"for matrix group\", true, [IsMatrixGroup], 0,\n    function(G)\n        return IsIrreducibleMatrixGroup(G, FieldOfMatrixGroup(G));\n    end);\n    \n    \n############################################################################\n##\n#M  IsIrreducible(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(IsIrreducible, \"for matrix group and field\", IsMatGroupOverFieldFam, \n    [IsMatrixGroup, IsField], 0,\n    function(G, F)\n        return IsIrreducibleMatrixGroup(G, F);\n    end);\n    \n    \n############################################################################\n##\n#M  IsIrreducibleMatrixGroup(<G>)\n##\n##  \nInstallOtherMethod(IsIrreducibleMatrixGroup, \"for matrix group\", true, [IsMatrixGroup], 0,\n    function(G)\n        return IsIrreducibleMatrixGroup(G, FieldOfMatrixGroup(G));\n    end);\n\n\n############################################################################\n##\n#M  IsIrreducibleMatrixGroup(<G>, <F>)\n##  \nInstallMethod(IsIrreducibleMatrixGroupOp, \"for matrix group and finite field - use MeatAxe\",\n    IsMatGroupOverFieldFam, [IsFFEMatrixGroup, IsField and IsFinite], 0,    \n    function(G, F)\n\n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        if DegreeOfMatrixGroup(G) = 1 then\n            return true;\n        elif IsTrivial(G) then\n            return false;\n        elif IsSubset(F, FieldOfMatrixGroup(G)) then\n            return MTX.IsIrreducible (GModuleByMats (GeneratorsOfGroup(G), F));\n        else\n            Error(\"G must be a matrix group over F\");\n        fi;\n    end);\n    \n\n############################################################################\n##\n#M  IsIrreducibleMatrixGroup(<G>, <F>)\n##  \nInstallMethod(IsIrreducibleMatrixGroupOp, \"for matrix group and finite field - test attr IsIrreducibleMatrixGroup\",\n    IsMatGroupOverFieldFam, [IsFFEMatrixGroup and HasIsIrreducibleMatrixGroup, \n        IsField and IsFinite], 0,    \n    function(G, F)\n\n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        if IsIrreducibleMatrixGroup(G) then\n            if F = FieldOfMatrixGroup(G) then\n                return true;\n            fi;\n        elif IsSubset(F, FieldOfMatrixGroup(G)) then\n            return false;\n        fi;\n        TryNextMethod();\n    end);\n\n\n############################################################################\n##\n#M  IsIrreducibleMatrixGroup(<G>, <F>)\n##  \nInstallMethod(IsIrreducibleMatrixGroupOp, \"for matrix group and finite field - for absolutely irreducible matrix group\",\n    IsMatGroupOverFieldFam, [IsFFEMatrixGroup and IsAbsolutelyIrreducibleMatrixGroup, \n        IsField and IsFinite], RankFilter(HasIsIrreducibleMatrixGroup),    \n    function(G, F)\n\n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        return true;\n    end);\n\n\n############################################################################\n##\n#M  IsAbsolutelyIrreducible(<G>)\n##  \nInstallMethod(IsAbsolutelyIrreducible, \"for matrix group\", true, [IsMatrixGroup], 0,\n    function(G)\n        return IsAbsolutelyIrreducibleMatrixGroup(G);\n    end);\n\n\n############################################################################\n##\n#M  IsAbsolutelyIrreducibleMatrixGroup(<G>)\n##  \n##  we use `InstallOtherMethod' because otherwise there will be a warning\n##  generated by KeyDependentOperation\n##\nInstallOtherMethod(IsAbsolutelyIrreducibleMatrixGroup, \"for mat group over finite field\", true,\n    [IsFFEMatrixGroup], 0,\n    \n    function(G)\n    \n    local M;\n\n    if DegreeOfMatrixGroup(G) = 1 then\n        return true;\n    elif IsTrivial(G) then\n        return false;\n    else\n        M := GModuleByMats (GeneratorsOfGroup(G), DefaultFieldOfMatrixGroup(G));\n        return MTX.IsIrreducible (M) and MTX.IsAbsolutelyIrreducible (M);\n    fi;\nend);\n\n\n############################################################################\n##\n#M  IsPrimitive(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(IsPrimitive, \"for matrix group\", true, [IsMatrixGroup], 0,\n    function(G)\n        return IsPrimitiveMatrixGroup(G,  FieldOfMatrixGroup(G));\n    end);\n    \n    \n############################################################################\n##\n#M  IsPrimitiveMatrixGroup(<G>)\n##\n##  we need an OtherMethod to avoid the warning generated by\n##  KeyDependentOperation\n##  \nInstallOtherMethod(IsPrimitiveMatrixGroup, \"for matrix group\", true, [IsMatrixGroup], 0,\n    function(G)\n        return IsPrimitiveMatrixGroup(G, FieldOfMatrixGroup(G));\n    end);\n\n\n############################################################################\n##\n#M  IsPrimitive(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(IsPrimitive, \"for matrix group over field\", \n    IsMatGroupOverFieldFam, [IsMatrixGroup, IsField], 0,\n    function(G, F)\n\n        return IsPrimitiveMatrixGroup(G, F);\n    end);\n    \n\n############################################################################\n##\n#M  IsPrimitiveMatrixGroupOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(IsPrimitiveMatrixGroupOp, \"for matrix group over finite field, construct IsomorphismPcGroup\", \n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and IsSolvableGroup, IsField and IsFinite], 0,\n\n    function(G, F)    \n        local iso, inv;\n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        iso := IsomorphismPcGroup(G);\n        inv := InverseGeneralMapping (iso);\n        SetIsBijective (inv, true);\n        SetIsGroupHomomorphism (inv, true);\n        return SmallBlockDimensionOfRepresentation (ImagesSource (iso), inv, F, DegreeOfMatrixGroup(G)) = DegreeOfMatrixGroup(G);        \n    end);\n\n\n############################################################################\n##\n#M  IsPrimitiveMatrixGroupOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(IsPrimitiveMatrixGroupOp, \"for matrix group over finite field, use RepresentationIsomorphism\", \n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and HasRepresentationIsomorphism, IsField and IsFinite], \n    RankFilter (IsHandledByNiceMonomorphism) + 1, # rank higher than the nice mono. method\n\n    function(G, F)    \n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        return SmallBlockDimensionOfRepresentation (\n            Source (RepresentationIsomorphism (G)), RepresentationIsomorphism (G), F, DegreeOfMatrixGroup(G)) = DegreeOfMatrixGroup(G);        \n    end);\n\n\n############################################################################\n##\n#M  IsPrimitiveMatrixGroupOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(IsPrimitiveMatrixGroupOp, \"for matrix group over finite field, use nice monomorphism\", \n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and IsHandledByNiceMonomorphism, IsField and IsFinite], \n    0,\n\n    function(G, F)    \n        local iso, inv;\n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        iso := NiceMonomorphism (G);\n        inv := GroupHomomorphismByFunction(NiceObject (G), G, \n            h -> PreImagesRepresentative(iso, h),\n            g -> ImageElm(iso, g));\n        SetIsBijective (inv, true);\n        return SmallBlockDimensionOfRepresentation (NiceObject (G), inv, F, DegreeOfMatrixGroup(G)) = DegreeOfMatrixGroup(G);        \n    end);\n\n\n############################################################################\n##\n#M  IsPrimitiveMatrixGroupOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(IsPrimitiveMatrixGroupOp, \"for matrix group over finite field, try if IsPrimitive is set\", \n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and HasIsPrimitive, IsField and IsFinite], \n    RankFilter (IsHandledByNiceMonomorphism) + 3, # rank higher than the nice mono. method\n\n    function(G, F)    \n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        if IsPrimitive(G) then\n            if FieldOfMatrixGroup(G) = F then\n                return true;\n            fi;\n        else\n            return false;\n        fi;\n        TryNextMethod();            \n    end);\n\n\n############################################################################\n##\n#F  SmallBlockDimensionOfRepresentation(G, hom, F, limit)\n##\n##  hom must be a homomorphism G -> GL(n, F), where G is a group and F a finite \n##  field such that Image(hom, G) is irreducible over F. limit is an integer\n##  The function returns an integer k such that Im hom has a block system \n##  of block dimension k, where k < limit, or k >= limit and G has no\n##  block system of block dimesnion < limit\n##  \nInstallGlobalFunction(SmallBlockDimensionOfRepresentation, function(G, hom, F, limit)\n\n    # computes a block dimension smaller than limit, if it exists,\n    # or the smallest block dimension otherwise\n    local max, min, dim, M, m, cf, i;\n            \n    max := AttributeValueNotSet(MaximalSubgroupClassReps, G);\n    min := DegreeOfMatrixGroup(Range (hom));\n    for M in max do\n        if not IsTrivial(M) then\n            m := GModuleByMats (List(GeneratorsOfGroup(M), x -> ImageElm(hom, x)), F);\n            if not MTX.IsIrreducible (m) then\n                cf := First (MTX.CompositionFactors(m),\n                    cf -> MTX.Dimension (cf) * IndexNC(G, M) = DegreeOfMatrixGroup(Range (hom)) \n                            and Length(MTX.Homomorphisms (cf, m)) > 0);\n                if cf <> fail then\n                    dim := SmallBlockDimensionOfRepresentation (M, \n                        GroupHomomorphismByImagesNC(M, GL(MTX.Dimension (cf), Size(F)),\n                        GeneratorsOfGroup(M), MTX.Generators (cf)),\n                        F, limit);\n                    if dim < min then\n                        min := dim;\n                        if min < limit then\n                            return min;\n                        fi;\n                    fi;\n                fi;\n            fi;\n        fi;\n    od;\n    return min;\nend);\n\n\n############################################################################\n##\n#M  MinimalBlockDimension(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(MinimalBlockDimension, \"for matrix group\", true, [IsMatrixGroup], 0,\n    function(G)\n        return MinimalBlockDimensionOfMatrixGroup(G);\n    end);\n    \n\n############################################################################\n##\n#M  MinimalBlockDimension(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(MinimalBlockDimension, \"for matrix group and field\", \n    IsMatGroupOverFieldFam, [IsMatrixGroup, IsField], 0,\n    function(G, F)\n\n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        return MinimalBlockDimensionOfMatrixGroup(G, F);\n    end);\n\n\n############################################################################\n##\n#M  MinimalBlockDimensionOfMatrixGroup(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallOtherMethod(MinimalBlockDimensionOfMatrixGroup, \"for matrix group\", true, \n    [IsMatrixGroup], 0,\n    function(G)\n        return MinimalBlockDimensionOfMatrixGroup(G, FieldOfMatrixGroup(G));\n    end);\n    \n    \n############################################################################\n##\n#M  MinimalBlockDimensionOfMatrixGroupOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(MinimalBlockDimensionOfMatrixGroupOp, \"for matrix group over finite field\", \n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and IsSolvableGroup, IsField and IsFinite], 0,\n\n    function(G, F)    \n        local iso, inv;\n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        \n        if not IsIrreducibleMatrixGroup(G, F) then\n            TryNextMethod();\n        fi;\n        \n        iso := IsomorphismPcGroup(G);\n        inv := InverseGeneralMapping (iso);\n        SetIsBijective (inv, true);\n        SetIsGroupHomomorphism (inv, true);\n        return SmallBlockDimensionOfRepresentation (ImagesSource (iso), inv, F, 2);        \n    end);\n\n\n############################################################################\n##\n#M  MinimalBlockDimensionOfMatrixGroupOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(MinimalBlockDimensionOfMatrixGroupOp, \n    \"for matrix group over finite field with representation homomorphism\", \n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and HasRepresentationIsomorphism, IsField and IsFinite], \n        RankFilter (IsHandledByNiceMonomorphism) + 1, # rank higher than the nice mono. method\n\n    function(G, F)    \n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        if not IsIrreducibleMatrixGroup(G, F) then\n            TryNextMethod();\n        fi;\n        return SmallBlockDimensionOfRepresentation (\n            Source (RepresentationIsomorphism (G)), RepresentationIsomorphism (G), F, 2) ;        \n    end);\n\n\n############################################################################\n##\n#M  MinimalBlockDimensionOfMatrixGroupOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(MinimalBlockDimensionOfMatrixGroupOp, \"for matrix group over finite field, use NiceMonomorphism\", \n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and IsHandledByNiceMonomorphism, IsField and IsFinite], \n    0,\n\n    function(G, F)    \n        local iso, inv;\n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        if not IsIrreducibleMatrixGroup(G, F) then\n            TryNextMethod();\n        fi;\n        iso := NiceMonomorphism (G);\n        inv := GroupHomomorphismByFunction(NiceObject (G), G, \n            h -> PreImagesRepresentative(iso, h),\n            g -> ImageElm(iso, g));\n        SetIsBijective (inv, true);\n        return SmallBlockDimensionOfRepresentation (NiceObject (G), inv, F, 2);        \n    end);\n    \n    \n############################################################################\n##\n#M  MinimalBlockDimensionOfMatrixGroupOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(MinimalBlockDimensionOfMatrixGroupOp, \n    \"for matrix group over finite field which has MinimalBlockDimension\", \n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and HasMinimalBlockDimension, IsField and IsFinite], \n        RankFilter (IsHandledByNiceMonomorphism) + 1, # rank higher than the nice mono. method\n\n    function(G, F)    \n        if not IsSubset(F, FieldOfMatrixGroup(G)) then\n            Error(\"G must be a matrix group over F\");\n        fi;\n        if F = FieldOfMatrixGroup(G) then\n            return MinimalBlockDimension (G);\n        elif MinimalBlockDimension (G) = 1 then\n            return 1;\n        fi;\n        TryNextMethod();\n    end);\n\n\n############################################################################\n##\n#M  CharacteristicOfField(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(CharacteristicOfField, \"for matrix group\", true, [IsMatrixGroup], 0,\n    M -> Characteristic (DefaultFieldOfMatrixGroup(M)));\n\n\n############################################################################\n##\n#M  Characteristic(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(Characteristic, \"for matrix group\", true, [IsMatrixGroup], 0,\n    CharacteristicOfField);\n\n\n############################################################################\n##\n#M  RepresentationIsomorphism(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(RepresentationIsomorphism, \"for mat group handled by nice mono.\", true,\n    [IsMatrixGroup and IsHandledByNiceMonomorphism], 0,\n    function(G)\n\n        local nice, H;\n        \n        nice := NiceMonomorphism (G);\n        H := NiceObject(G);\n        \n        if IsSolvableGroup(H) then\n            nice := IsomorphismPcGroup(G);\n            H := Range (nice);\n        fi;\n        \n        return GroupHomomorphismByFunction(H, G, \n            x -> PreImagesRepresentative(nice, x),\n            x -> ImageElm(nice, x));\n    end);\n    \n\n############################################################################\n##\n#M  RepresentationIsomorphism(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(RepresentationIsomorphism, \"soluble group: inverse of IsomorphismPcGroup\", true,\n    [IsMatrixGroup], 0,\n    function(G)\n\n        local nice;\n        \n        nice := IsomorphismPcGroup(G);\n        return GroupHomomorphismByFunction(Range(nice), G, \n            x -> PreImagesRepresentative(nice, x),\n            x -> ImageElm(nice, x));\n    end);\n    \n\n############################################################################\n##\n#F  ImprimitivitySystemsForRepresentation(G, rep, F, limit)\n##  \n##  G is a group, F a finite field, rep: G -> GL(n, F)\n##  \n##  If G has no block system with block dimension <= limit, the function \n##  computes a list of all imprimitivity systems of Im rep as a \n##  subgroup of GL(n, F). Otherwise, the function computes systems of imprimitivity,\n##  one of which will have block dimension <= limit.\n##\n##  Each imprimitivity system is represented by a record with the following entries:\n##  bases: a list of lists of vectors, each list of vectors being a basis of a block \n##            in the imprimitivity system\n##  stab1: the stabilizer in G of the first block (i. e., the block with basis bases[1])\n##  min:    true if the block system is a minimal block system amongst the systems returned\n##\nInstallGlobalFunction(ImprimitivitySystemsForRepresentation, function(G, rep, F, limit)\n\n    local systems, max, M, gens, m, c, cf, hom, subsys, sys, newsys, homBasis, homSpace, bas, bas2, newbasis, pos, orb;\n    \n    if DegreeOfMatrixGroup(Range (rep))< limit then\n        return     [rec(bases := [IdentityMat (DegreeOfMatrixGroup(Range (rep)), F)], stab1 := G, min := true)];\n    fi;\n    systems := [];\n    max := AttributeValueNotSet(MaximalSubgroupClassReps, G);\n    for M in max do\n        if not IsTrivial(M) then # inducing up from the trivial rep gives a reducible representation\n            gens := List(GeneratorsOfGroup(M), x -> ImageElm(rep, x));\n            m := GModuleByMats (gens, F);\n            if not MTX.IsIrreducible (m) then\n                for c in MTX.CollectedFactors(m) do\n                    cf := c[1];\n                    if MTX.Dimension (cf) * IndexNC(G, M) = Degree (Range (rep)) then\n                        homBasis := MTX.Homomorphisms (cf, m);\n                        if Length(homBasis) > 0 then # submodule isomorphic with cf\n                            \n                            # get imprimitivity systems for cf\n                            \n                            hom := GroupHomomorphismByImagesNC(M, GL(MTX.Dimension (cf), Size(F)), \n                                GeneratorsOfGroup(M), MTX.Generators (cf));    \n                            subsys := ImprimitivitySystemsForRepresentation (M, hom, F, limit);\n                            Add(subsys, rec(bases := [IdentityMat (MTX.Dimension (cf), F)], stab1 := M,\n                                min := Length(subsys) = 0));\n                            \n                            # translate result back\n                            \n                            homSpace := VectorSpace(F, homBasis{[2..Length(homBasis)]}, 0*homBasis[1], \"basis\");\n                            for bas2 in Enumerator(homSpace) do\n                                bas := homBasis[1] + bas2;\n                                  for sys in subsys do\n                                    newbasis := List(sys.bases[1]*bas, ShallowCopy);\n                                    TriangulizeMat (newbasis);\n                                    if ForAll (systems, sys -> not newbasis in sys.bases) then\n                                        orb := Orbit (ImagesSet(rep, G), newbasis, OnSubspacesByCanonicalBasis);\n                                        Assert(1, Length(orb) * Length(newbasis) = Degree (Range (rep)));\n                                        Assert(1, Length(orb) = IndexNC(G, sys.stab1));\n                                        if orb[1] <> newbasis then\n                                            pos := Position (orb, newbasis);\n                                            orb{[1, pos]} := orb{[pos, 1]};\n                                        fi;\n                                        Add(systems, rec(bases := orb, stab1 := sys.stab1, min := sys.min)); \n                                    fi;\n                                od;\n                            od;\n                        fi;\n                    fi;\n                od;\n            fi;\n        fi;\n    od;\n    \n    # add trivial system\n    \n    Add(systems, rec(bases := [IdentityMat (Degree (Range (rep)), F)], stab1 := G, min := Length(systems) = 0));\n    return systems;\nend);\n\n\n############################################################################\n##\n#A  ImprimitivitySystemsOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(ImprimitivitySystemsOp, \"for matrix group handled by nice mono. and finite field\", \n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and IsHandledByNiceMonomorphism, IsField and IsFinite], 0, \n    function(G, F)\n        local rep;\n        rep := RepresentationIsomorphism (G);\n        return ImprimitivitySystemsForRepresentation (Source (rep), rep, F, 0);\n    end);\n    \n    \n############################################################################\n##\n#M  ImprimitivitySystemsOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(ImprimitivitySystemsOp, \"for matrix group handled by nice mono. and finite field\", \n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and IsHandledByNiceMonomorphism, IsField and IsFinite], 0, \n    function(G, F)\n        local rep;\n        rep := RepresentationIsomorphism (G);\n        return ImprimitivitySystemsForRepresentation (Source (rep), rep, F, 0);\n    end);\n    \n    \n############################################################################\n##\n#M  ImprimitivitySystems(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallOtherMethod(ImprimitivitySystems, \"for matrix group: use FieldOfMatrixGroup\", true,\n    [IsFFEMatrixGroup], 0,\n    function(G)\n        return ImprimitivitySystems (G, FieldOfMatrixGroup(G));\n    end);\n    \n    \n############################################################################\n##\n#M  MinimalBlockDimensionOfMatrixGroupOp(<G>, <F>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(MinimalBlockDimensionOfMatrixGroupOp, \"for matrix group having imprimitivity systems\",\n    IsMatGroupOverFieldFam,\n    [IsFFEMatrixGroup and HasComputedImprimitivitySystemss, IsField],\n    0,\n    function(G, F)\n    \n        local known, i, sys, d, l;\n        \n        known := ComputedImprimitivitySystemss (G);\n        for i in [1,3..Length(known)-1] do\n            if known[i] = F then\n                d := DegreeOfMatrixGroup(G);\n                for sys in known[i+1] do\n                    l := Length(sys.bases[1]);\n                    if l < d then\n                        d := l;\n                    fi;\n                od;\n                return d;\n            fi;\n        od;\n        TryNextMethod();\n    end);\n    \n    \n    \n############################################################################\n##\n#M  TraceField(<G>)\n##\n##  see IRREDSOL documentation\n##  \nInstallMethod(TraceField, \"for irreducible matrix group over finite field\", true,\n    [IsFFEMatrixGroup and IsFinite], 1,\n\n    function(G)\n\n    local ext, gens, q, q0, module, module2, gens2, c, i, p;\n    \n    q := Size(FieldOfMatrixGroup(G));\n    Info(InfoIrredsol, 3, \"TraceField: matrix group is over GF(\",q,\")\");\n    \n    if IsTrivial(G) then\n        Info(InfoIrredsol, 4, \"TraceField: trivial group case\");\n        return FieldOfMatrixGroup(G);\n    fi;\n    \n    # guess a field contained in the smallest field over which module can be realised\n    \n    \n    q0 := Size( Field (List([1..LogInt(Size(G), 2) + 10], i -> TraceMat(PseudoRandom(G)))));\n    \n    \n    if q = q0 then\n        Info(InfoIrredsol, 3, \"TraceField: trace field is GF(\", q0, \")\");\n        return FieldOfMatrixGroup(G);\n    fi;\n    \n    Info(InfoIrredsol, 3, \"TraceField: trace field contains GF(\",q0, \")\");\n\n    module := GModuleByMats (GeneratorsOfGroup(G), FieldOfMatrixGroup(G));\n    \n    if not MTX.IsIrreducible (module) then\n        Info(InfoIrredsol, 3, \"TraceField: trace field contains GF(\",q0, \")\");\n        TryNextMethod();\n    fi;\n    \n    for c in Collected (Factors(LogInt(q, q0))) do\n        p := c[1];\n        for i in [1..c[2]] do\n        \n            Info(InfoIrredsol, 1, \"TraceField: trying if trace field is GF(\",q0, \")\");\n            # compute Galois conjugate of module\n            gens2 := List(MTX.Generators (module), g -> List(g, row -> List(row, a -> a^q0)));    \n            module2 := GModuleByMats (gens2, MTX.Field (module));\n                         \n            # If module1 and module2 are conjugate, their traces are the same, and thus\n            # invariant under the Galois automorphism. Therefore the traces must belong to GF(q0).\n            # Thus by a theorem of Brauer, module1 (and module2) can be written over GF(q0).\n            # Conversely, if module1^x is over GF(q0) for some matrix x, \n            # then module1^x = (module1^x)^q0 = (module1^q0)^(x^q0) = module2^(x^q0)\n            # which shows that module1 and module2 are conjugate.\n\n            # see also S. P. Glasby, R. B. Howlett, Writing representations over mnimal fields,\n            # Comm. Alg. 25 (1997), 1703--1711\n            \n             if MTX.Isomorphism (module, module2) <> fail then\n                Info(InfoIrredsol, 1, \"TraceField: trace field is GF(\",q0, \")\");\n                return GF(q0);\n            fi;\n    \n            q0 := q0^p; # size of minimal superfield of GF(q0)\n        od;\n    od;\n    \n    Info(InfoIrredsol, 1, \"TraceField: not rewritable over subfield: trace field is GF(\",q0, \")\");\n    \n    return GF(q0);\nend);\n\n\n\n############################################################################\n##\n#M  TraceField(<G>)\n##\nInstallMethod(TraceField, \"generic method for finite matrix groups via conjugacy classes\", true,\n    [IsMatrixGroup and IsFinite], 0,\n    function(G)\n    \n        local F, rep;\n        \n        F := FieldOfMatrixGroup(G);\n        if IsPrimeField (F) then\n            return F;\n        elif F = Field (List(GeneratorsOfGroup(G), TraceMat)) then\n            return F;\n        else\n            rep := RepresentationIsomorphism (G);\n            return Field (List(ConjugacyClasses (Source (rep)), cl -> TraceMat(ImageElm(rep, Representative(cl)))));\n        fi;\n    end);\n    \n\nRedispatchOnCondition (TraceField, true, [IsMatrixGroup], [IsFinite], 0);\n\n\n############################################################################\n##\n#M  SplittingField(<G>)\n##\nInstallMethod(SplittingField, \"use MeatAxe\", true,\n    [IsFFEMatrixGroup], 0,\n    function(G)\n    \n        local F, module;\n        \n        F := FieldOfMatrixGroup(G);\n        module := GModuleByMats (GeneratorsOfGroup(G), F);\n        if MTX.IsIrreducible (module) then\n            return GF(Characteristic (F)^MTX.DegreeSplittingField (module));\n        else\n            Error(\"G must be irreducible over FieldOfMatrixGroup(G)\");\n        fi;\n    end);\n    \n\n############################################################################\n##\n#M  ConjugatingMatTraceField(<G>)\n##\n##  returns a matrix x such that the matrix entries of G^x lie in the\n##  trace field of G.\n##  \n##  The absolutely irreducible case is an impelemntation of an algorithm by\n##  S. P. Glasby, R. B. Howlett, Writing representations over mnimal fields,\n##  Comm. Alg. 25 (1997), 1703--1711\n##\nInstallMethod(ConjugatingMatTraceField, \"for irreducible FFE matrix group\",     \n    true,\n    [IsFFEMatrixGroup], 0,\n    \n    function(G)\n    \n        local ext, q, q1, t, C, CC, D, Y, A, i, j, mu, nu, \n            basis, moduleG, module, module2, module3, absirred;\n\n        if Length(GeneratorsOfGroup(G)) = 0 or TraceField(G) = FieldOfMatrixGroup(G) then\n            return One(G);\n        fi;\n\n        q := Size(TraceField (G));\n\n        moduleG := GModuleByMats (GeneratorsOfGroup(G), FieldOfMatrixGroup(G));\n\n        # reduce to the absolutely irreducible case\n        \n        if not MTX.IsIrreducible (moduleG) then\n            TryNextMethod();\n        fi;\n        \n        absirred := MTX.IsAbsolutelyIrreducible (moduleG);\n        if absirred then\n            module := moduleG;\n            ext := FieldOfMatrixGroup(G);\n        else\n            ext := GF(CharacteristicOfField (G)^MTX.DegreeSplittingField (moduleG));\n            module := GModuleByMats (GeneratorsOfGroup(G), ext);\n            repeat\n                basis := MTX.ProperSubmoduleBasis (module);\n                module := MTX.InducedActionSubmodule (module, basis);\n            until MTX.IsIrreducible (module);\n            Assert(1, MTX.IsAbsolutelyIrreducible (module));\n        fi;\n        \n        # moduleG can be rewritten over TraceField(G) but over no proper subfield\n        # let GF(q1) be the trace field of module, then over GF(q1),\n        # moduleG has block diagonal matrices which are conjugate via\n        # a Galois automorphism of GF(q1) of order Deg(G)/Dim(module)\n        # so GF(q1) has dimension Dim(moduleG)/Dim(module) over TraceField(G).\n        \n        # Thus, taking q1-th powers is a generator of Gal (MTX.Field(module)/GF(q1))\n        \n        q1 := q^(MTX.Dimension (moduleG)/MTX.Dimension(module));\n        t := LogInt(Size(ext), q1);\n    \n        module2 := GModuleByMats (List(MTX.Generators (module), \n            A -> List(A, row -> List(row, x -> x^q1))), ext);\n    \n        C := MTX.Isomorphism (module, module2);\n    \n        if C = fail then\n            Error(\"panic: cannot rewrite matrix group over trace field!\");\n        fi;\n    \n        CC := C;\n        D := C;\n        for i in [1..t-1] do\n            CC := List(CC, row -> List(row, x -> x^q1));\n            D := D*CC;\n        od;\n    \n        mu := D[1][1];\n\n        repeat\n            nu := Random(ext);\n        until Norm(ext, GF(q1), nu) = mu;\n    \n        C := nu^-1 * C;\n    \n        repeat \n            Y := RandomMat(MTX.Dimension(module), MTX.Dimension(module), ext);\n            A := Y;\n            for i in [2..t] do\n                A := Y + C * List(A, row -> List(row, x -> x^q1));\n            od;\n        until Length(NullspaceMat(A)) = 0;\n    \n        Assert(1, ForAll(MTX.Generators(module), g -> IsSubset(GF(q1), Field(Flat(g^A)))));\n        \n        # now we have a solution for the absolutely irreducible case\n        \n        if absirred then\n            MakeImmutable(A);\n            ConvertToMatrixRep(A, ext);\n            return A;\n        fi;\n        \n        basis := CanonicalBasis(AsVectorSpace(GF(q), GF(q1)));\n        \n        module3 := GModuleByMats(List(MTX.Generators(module), x -> BlownUpMat(basis, x^A)), MTX.Field(moduleG));\n        \n        A := Immutable(MTX.Isomorphism(moduleG, module3));\n        \n        if A = fail then\n            Error(\"could not find conjugating matrix\");\n        fi;\n        Assert(1, ForAll(GeneratorsOfGroup(G), g -> IsSubset(GF(q), Field(Flat(g^A)))));\n        ConvertToMatrixRep(A, FieldOfMatrixGroup(G));\n        \n        return A;\n        \n    end);    \n\n\n############################################################################\n##\n#E\n##\n", "meta": {"hexsha": "b6517e55b09ab7438d0c4683b6c72d954199ddb0", "size": 32513, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/matmeths.gi", "max_stars_repo_name": "bh11/irredsol", "max_stars_repo_head_hexsha": "82868a8c644397077d7e2f926b309ec064b0ff58", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-09-01T16:53:11.000Z", "max_stars_repo_stars_event_max_datetime": "2017-09-01T16:53:11.000Z", "max_issues_repo_path": "lib/matmeths.gi", "max_issues_repo_name": "bh11/irredsol", "max_issues_repo_head_hexsha": "82868a8c644397077d7e2f926b309ec064b0ff58", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2017-08-02T16:19:58.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-01T08:57:23.000Z", "max_forks_repo_path": "lib/matmeths.gi", "max_forks_repo_name": "bh11/irredsol", "max_forks_repo_head_hexsha": "82868a8c644397077d7e2f926b309ec064b0ff58", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-02-17T18:26:09.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-02T10:40:35.000Z", "avg_line_length": 34.1882229232, "max_line_length": 143, "alphanum_fraction": 0.5384922954, "num_tokens": 7741, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4859007470569545}}
{"text": "# Built-in\n\nL := List([1 .. 100], n -> Random(1, 10));\n\nMaximumList(L);\n# 10\n", "meta": {"hexsha": "eabda1c83690694cd90972c175578abab3fcfca3", "size": 77, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Greatest-element-of-a-list/GAP/greatest-element-of-a-list.gap", "max_stars_repo_name": "mullikine/RosettaCodeData", "max_stars_repo_head_hexsha": "4f0027c6ce83daa36118ee8b67915a13cd23ab67", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Greatest-element-of-a-list/GAP/greatest-element-of-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/Greatest-element-of-a-list/GAP/greatest-element-of-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": 11.0, "max_line_length": 42, "alphanum_fraction": 0.5194805195, "num_tokens": 30, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7520125848754471, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.484465387570475}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nfId.canTensorSplit := (self, div) >> self.domain() mod div = 0;\nfId.tensorSplit    := (self, div) >> [fId(div), fId(self.size/div)];\nfBase.canTensorSplit := (self, div) >> self.range() mod div = 0;\nfBase.tensorSplit := (self, div) >> [ fBase(div,        idiv(self.params[2], self.range()/div)), \n                                      fBase(self.range()/div, imod(self.params[2], self.range()/div)) ]; \n\n\nCanTensorSplit := (what, div) -> When(not IsRec(what) or not IsBound(what.canTensorSplit), false, \n                                      what.canTensorSplit(div));\n\nTensorSplit    := (what, div) -> what.tensorSplit(div);\n\n\ntry_split := function(i, flist, fdim, N)\n    local ffrun, next, len, split;\n    len := Length(flist);\n    ffrun := fdim(flist[i]);\n    while i < len and ffrun < N do\n        next := flist[i+1];\n\tif ffrun * fdim(next) > N then\n            if N mod ffrun <> 0 or not CanTensorSplit(next, N/ffrun) then\n\t\treturn false;\n        #Error(\"can't merge incompatible tensor chains (could not split)\",\n         #     \"N=\", N, \" ffrun=\", ffrun, \" next=\", next);\n            else \n\t\tsplit := TensorSplit(next, N/ffrun);\n\t\tflist := Concat(flist{[1..i]}, split, flist{[i+2..len]});\n\t\tffrun := ffrun * N/ffrun; # = N\n            fi;\n\telse \n            ffrun := ffrun * fdim(next);\n\tfi;\n\ti := i+1;\n    od;\n    #Print([i, flist], \"\\n\");\n    return [i, flist];\nend;\n\nfull_merge_tensor_chains := function(target, ff, gg, compose, ftensor, gtensor, fid, gid, fdom, gran) \n   local i, j, nf, ng, res, ffrun, ggrun, ibegin, jbegin, split;\n   nf := Length(ff);    ng := Length(gg);\n   res := []; i:=1; j:=1;\n\n   while i <= nf or j <= ng do\n       # handle domain=1 or range=1, which are always mergeable\n       if (i<=nf and fdom(ff[i])=1) or (j<=ng and gran(gg[j])=1) then\n\t   if i<=nf and fdom(ff[i]) = 1 then\n               Add(res, fid(ff[i]));\n               i := i + 1; \n\t   fi;\n\t   if j<=ng and gran(gg[j]) = 1 then\n               Add(res, gid(gg[j]));\n               j := j + 1;\n\t   fi;\n\n       # try to combine terms to get a match\n       elif (i <= nf and j <= ng) then\n\t   if AnySyms(fdom(ff[i]), gran(gg[j])) then\n               return false;\n           elif fdom(ff[i]) = gran(gg[j]) then\n               Add(res, compose(ff[i], gg[j]));\n\t   else \n               ibegin := i;\n               jbegin := j;\n               if fdom(ff[i]) < gran(gg[j]) then\n\t\t   if CanTensorSplit(gg[j], fdom(ff[i])) then\n\t\t       split := TensorSplit(gg[j], fdom(ff[i]));\n\t\t       gg := Concat(gg{[1..j-1]}, split, gg{[j+1..ng]});\n\t\t       ng := ng + 1;\n\t\t   else \n\t\t       split := try_split(i, ff, fdom, gran(gg[j]));\n\t\t       if split=false then return false; fi;\n\t\t       i := split[1];\n\t\t       ff := split[2]; nf := Length(ff);\n\t\t   fi;\n               else\n\t\t   if CanTensorSplit(ff[i], gran(gg[j])) then\n\t\t       split := TensorSplit(ff[i], gran(gg[j]));\n\t\t       if split=false then return false; fi;\n\t\t       ff := Concat(ff{[1..i-1]}, split, ff{[i+1..nf]});\n\t\t       nf := nf + 1;\n\t\t   else \n\t\t       split := try_split(j, gg, gran, fdom(ff[i]));\n\t\t       if split=false then return false; fi;\n\t\t       j := split[1];\n\t\t       gg := split[2]; ng := Length(gg);\n\t\t   fi;\n               fi;\n               Add(res, compose(ftensor(ff{[ibegin..i]}), gtensor(gg{[jbegin..j]})));\n\t   fi;\n\t   i := i+1;\n\t   j := j+1;\n       else \n\t   return false;\n       fi;\n   od;\n   target.val := res;\n   return res;\nend;\n\n\n# *******************************************************************\n# make sure ff[i] is not a diag function, where merging chains doesn't make sense (does it?)\nfully_compat_tensor_chains := (ff,gg,fdom,gran) -> \n    Length(ff) = Length(gg) and\n    ForAll([1..Length(ff)], i -> ff[i].range()<>false and\n                             fdom(ff[i])=gran(gg[i]));\n\nmerge_fc_tensor_chains := (ff,gg,combine) -> \n   List([1..Length(ff)], i -> combine(ff[i], gg[i]));\n\n# this assumes compat_domain_range compatibility\ncompat_tensor_chains := (f,g,fdom,gran) -> let(\n    ff := Filtered(f, c->let(d:=fdom(c), IsSymbolic(d) or d > 1)),\n    gg := Filtered(g, c->let(r:=gran(c), IsSymbolic(r) or r > 1)), \n    fully_compat_tensor_chains(ff, gg, fdom, gran));\n\n# this assumes compat_domain_range compatibility\nmerge_tensor_chains := function(ff, gg, compose, fidentity, gidentity, fdom, gran) \n   local i, j, nf, ng, res;\n   nf := Length(ff);    ng := Length(gg);\n   res := []; i:=1; j:=1;\n\n   while i <= nf or j <= ng do\n       if (i <= nf and j <= ng) and fdom(ff[i]) = gran(gg[j]) then\n       Add(res, compose(ff[i], gg[j]));\n       i := i+1;\n       j := j+1;\n       else\n       if i<=nf and fdom(ff[i]) = 1 then\n           Add(res, fidentity(ff[i]));\n           i := i + 1;\n       elif j<=ng and gran(gg[j]) = 1 then\n           Add(res, gidentity(gg[j]));\n           j := j + 1;\n       else Error(\"can't merge incompatible tensor chains\");\n       fi;\n       fi;\n   od;\n   return res;\nend;\n", "meta": {"hexsha": "a1be3c01f60a1f9c4e012a235d28c21a2bb39cf3", "size": 4972, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sigma/merge_tensors.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/sigma/merge_tensors.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/sigma/merge_tensors.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 33.8231292517, "max_line_length": 105, "alphanum_fraction": 0.5128720837, "num_tokens": 1511, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6926419958239132, "lm_q1q2_score": 0.4843329777908334}}
{"text": "accu := function(n)\n  local f, v;\n  v := n;\n  f := function(a)\n    v := v + a;\n    return v;\n  end;\n  return f;\nend;\n\na := accu(0);\n# function( a ) ... end\nb := accu(100);\n# function( a ) ... end\na(6);\n# 6\nb(6);\n# 106\na(1);\n# 7\nb(1);\n# 107\n# These functions also accept other types, as long as addition is meaningful\nb(1/FLOAT_INT(3))\n# 107.333\na(2/3);\n# 23/3\na([1, 2, 3]);\n# [ 26/3, 29/3, 32/3 ]\n", "meta": {"hexsha": "777986bdd77101ce6413d5b6b841288b5cb4283b", "size": 397, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Accumulator-factory/GAP/accumulator-factory.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/Accumulator-factory/GAP/accumulator-factory.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/Accumulator-factory/GAP/accumulator-factory.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": 13.2333333333, "max_line_length": 76, "alphanum_fraction": 0.523929471, "num_tokens": 174, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.48425791023002734}}
{"text": "#\n# Read(\"~/Workspace/Chevalley.gap/init.gi\"); Read(Filename(home_dir,\"load.gi\")); Read(Filename(test_dir,\"unicls.test.gi\"));\n#\n# Read(\"~/Workspace/Chevalley.gap/init.gi\"); Read(Filename(test_dir,\"unicls.test.init.gi\")); Read(Filename(test_dir,\"unicls.test.gi\"));\n#\n# Read(Filename(test_dir,\"unicls.test.gi\"));\n#\n\nsys:=AlgebraicU(ChevalleyAdj(\"F\",4,GF(2)));\norbs:=UnipotentClasses(sys,\"\");\nPrint(\"Created AlgebraicU \",orbs,\"\\n\");\nPrint(\"\\t[\",IsUnipotentClasses(orbs)=true,\"] IsUnipotentClasses(orbs)=true\\n\");\n\n\n", "meta": {"hexsha": "b2a0a9b259aaa651a9459707531b2cbbe4da4392", "size": 512, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "test/unicls.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/unicls.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/unicls.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": 34.1333333333, "max_line_length": 135, "alphanum_fraction": 0.701171875, "num_tokens": 161, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956580903722561, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4834921172987905}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nDeclare(Compose);\nDeclare(ComposeDists);\nDeclare(ComposeStreams);\n\nccFunc := function(list)\n      local i, l;\n      l := [];\n      for i in list do\n          Cond(IsBound(i.createCode), Append(l, [i.createCode()]), Append(l, [i]));\n      od;\n      return Flat(l);\nend;\n\n\n# ==========================================================================\n# Compose\n# ==========================================================================\nClass(Compose, BaseOperation, rec(\n    # flatten by associativity\n    abbrevs := [ arg ->\n    [ Flat(List(Flat(arg),\n            s -> When(IsSPL(s) and ObjId(s)=Compose, s.children(), s))) ]\n    ],\n\n    withTags := (self, tags) >> ApplyFunc(\n\tObjId(self),\n\tList(self.children(), x -> x.withTags(tags))).takeAobj(self),\n\n    checkDims := children -> let(chdims := List(children, c->c.dims()),\n        DoForAll([1..Length(chdims)-1], i ->\n            DoForAll(Zip2(chdims[i][2],chdims[i+1][1]), x->\n        When( not(IsSymbolic(x[1]) or IsSymbolic(x[2])) and (x[1] <> x[2]),\n            Error(\"Dimensions of children \",i,\" and \",i+1,\" do not match (\",x[1],\" <> \",x[2],\") in \", children), 0)))),\n\n    new := meth(self, L)\n        local dim;\n        Constraint(IsList(L) and L<>[]);\n        #ForAll(L, x -> Constraint(IsSPL(x)));\n        if Length(L) = 1 then return L[1]; fi;\n\n        dim := Rows(L[1]);\n        self.checkDims(L);\n        L := Filtered(L, x -> not IsIdentityObj(x));\n        if L = [] then   # all factors are identities\n            return I(dim);\n        elif Length(L) = 1 then \n            return L[1]; \n        else\n            return SPL(WithBases(self, rec(\n                         _children := L,\n                         dimensions := [L[1].dims()[1], L[Length(L)].dims()[2]])));\n        fi;\n    end,\n\n     rng:= self>>let(c := self._children, c[1].rng()),\n     dmn:= self>>let(c := self._children, Last(c).dmn()),\n    #-----------------------------------------------------------------------\n #   dims := self >> let(c := self._children, [Rows(c[1]), Cols(Last(c))]),\n     advdims := self >> [self._children[1].advdims()[1], Last(self._children).advdims()[2]],\n    #-----------------------------------------------------------------------\n    isPermutation := self >> ForAll(self._children, IsPermutationSPL),\n    #-----------------------------------------------------------------------\n    toAMat := self >> Product(List(self._children, AMatSPL)),\n    #-----------------------------------------------------------------------\n    transpose := self >>\n        CopyFields(self, rec(\n        _children := Reversed(List(self._children, x -> x.transpose())),\n        dimensions := Reversed(self.dimensions))),\n    conjTranspose := self >>\n        CopyFields(self, rec(\n        _children := Reversed(List(self._children, x -> x.conjTranspose())),\n        dimensions := Reversed(self.dimensions))),\n    inverse := self >>\n        CopyFields(self, rec(\n        _children := Reversed(List(self._children, x -> x.inverse())),\n        dimensions := Reversed(self.dimensions))),\n    #-----------------------------------------------------------------------\n    printSeparationChar := \" * \",\n    print := meth(self, indent, indentStep)\n        local s, newline;\n\n    s := self.children();\n    if Length(s) = 2 and ((IsBound(s[1]._sym) and IsBound(s[2]._mat))\n                       or (IsBound(s[2]._sym) and IsBound(s[1]._mat)))\n       or ForAll(s, x->IsBound(x._sym))\n        then newline := Ignore;\n    else newline := self._newline; fi;\n\n        DoForAllButLast(s, c->Chain(SPLOps.Print(c, indent, indentStep),\n                                Print(self.printSeparationChar),\n                    newline(indent)));\n\n    Last(s).print(indent, indentStep);\n\n    end,\n    #-----------------------------------------------------------------------\n    arithmeticCost := (self, costMul, costAddMul) >>\n        Sum(List(self.children(), x -> x.arithmeticCost(costMul, costAddMul))),\n\n    createCode := self >> let (l := self._children, l2 := ccFunc(List(l)),\n          Compose(l2)),\n\n    normalizedArithCost := self >> Sum(List(self.children(), i->i.normalizedArithCost())),\n    latexSymbol := \"\\\\cdot\"\n\n ));\n\nClass(ComposeDists, Compose, rec(\n    printSeparationChar := \" |*| \",\n    leftMostParScat := self >> self._children[1].leftMostParScat(),\n    rightMostParGath := self >> self._children[Length(self._children)].rightMostParGath(),\n));\n\nClass(ComposeStreams, Compose, rec(\n    printSeparationChar := \" -*- \",\n    leftMostParScat := self >> self._children[1].leftMostParScat(),\n    rightMostParGath := self >> self._children[Length(self._children)].rightMostParGath(),\n));\n", "meta": {"hexsha": "a60e0a8d189a4fdb9cd2c32221d486588c999d55", "size": 4701, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/Compose.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/Compose.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/Compose.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.9112903226, "max_line_length": 119, "alphanum_fraction": 0.4969155499, "num_tokens": 1132, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.48334750495647877}}
{"text": "IsEvenInt(n);\nIsOddInt(n);\n", "meta": {"hexsha": "5a0bad373bec4bc3bb5f149f4ed25badd2c3476b", "size": 27, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Even-or-odd/GAP/even-or-odd.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/Even-or-odd/GAP/even-or-odd.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/Even-or-odd/GAP/even-or-odd.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 9.0, "max_line_length": 13, "alphanum_fraction": 0.7037037037, "num_tokens": 10, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4832698816055838}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nDeclare(DirectSum);\n# ==========================================================================\n# DirectSum\n# ==========================================================================\nClass(DirectSum, BaseOperation, rec(\n    _spl_name := \"direct_sum\",\n\n    abbrevs := [ arg ->\n    [ Filtered(\n        Flat(List(Flat(arg),\n            s -> When(IsSPL(s) and ObjId(s)=DirectSum, s.children(), s))), x->x.dimensions<>[0,0]) ]\n    ],\n\n    new := meth(self, L)\n        #ForAll(L, x -> Constraint(IsSPL(x)));\n    if ForAll(L, IsIdentitySPL)\n        then return I(Sum(L, Rows));\n    else\n        return SPL(WithBases( self,\n        rec( _children := L,\n        dimensions := [ Sum(L, t -> t.dimensions[1]),\n                        Sum(L, t -> t.dimensions[2]) ] )));\n    fi;\n    end,\n    #-----------------------------------------------------------------------\n    dims := self >> [ Sum(self._children, t -> t.dimensions[1]),\n                  Sum(self._children, t -> t.dimensions[2]) ],\n    area := self >> Sum(self._children, t -> t.area()),\n    #-----------------------------------------------------------------------\n    isPermutation := self >> ForAll(self._children, IsPermutationSPL),\n    #-----------------------------------------------------------------------\n    toAMat := self >> DirectSumAMat(List(self._children, AMatSPL)),\n    #-----------------------------------------------------------------------\n    transpose := self >> CopyFields(self, rec(\n        _children := List(self._children, x->x.transpose()),\n        dimensions := Reversed(self.dimensions))),\n    conjTranspose := self >> CopyFields(self, rec(\n        _children := List(self._children, x->x.conjTranspose()),\n        dimensions := Reversed(self.dimensions))),\n    inverse := self >> CopyFields(self, rec(\n        _children := List(self._children, x->x.inverse()),\n        dimensions := Reversed(self.dimensions))),\n    #-----------------------------------------------------------------------\n    arithmeticCost := (self, costMul, costAddMul) >>\n        Sum(List(self.children(), x -> x.arithmeticCost(costMul, costAddMul)))\n));\n\nClass(DelayedDirectSum, DirectSum, rec(sums := self >> self));\n", "meta": {"hexsha": "54cbd728845f4e1a9c423e10324790bef66e1469", "size": 2251, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/DirectSum.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/DirectSum.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/DirectSum.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": 41.6851851852, "max_line_length": 100, "alphanum_fraction": 0.4509107064, "num_tokens": 472, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.6261241702517975, "lm_q1q2_score": 0.48326987622081297}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n#F   tSPL Twiddle factors\nClass(TTwiddle, Tagged_tSPL_Container, rec(\n    abbrevs :=  [ \n        (mn, n) -> [mn, n, 1],\n        (mn, n, k) -> [mn, n, k]\n     ],\n    dims := self >> let(n:=self.params[1], [n,n]),\n    terminate := self >> Diag(Tw1(self.params[1], self.params[2], self.params[3])),\n    transpose := self >> Copy(self),\n    isReal := False,\n    doNotMeasure := true,\n    noCodelet := true,\n    normalizedArithCost := self >> 6*Rows(self)\n));\n\nClass(TTwiddle_Stockham, Tagged_tSPL_Container, rec(\n    abbrevs :=  [ \n        (n, blocksize, rdx, j) -> [n, blocksize, rdx, j]\n     ],\n    dims := self >> let(n:=self.params[1], [n,n]),\n    #params := self >> let(params := [self.params[1], self.params[2], self.params[3], self.params[4]]),\n    terminate := self >> Tw1(self.params[1], self.params[1]/self.params[3], 1),\n#F \tD tensor I has to be done in the TTwiddle_St rule, not here\n#F    terminate := self >> diagTensor(Tw1(self.params[1], self.params[2], self.params[3]), fConst(TComplex, self.params[2], 1)),\n#F    terminate := self >> fCompose(dOmega(self.params[1],1), fId(self.params[1]/self.params[2])),\n    transpose := self >> Copy(self),\n    isReal := False,\n    doNotMeasure := true,\n    noCodelet := true,\n    domain := self >> TComplex,\n    normalizedArithCost := self >> 6*Rows(self)\n));\n\nNewRulesFor(TTwiddle_Stockham, rec(\n    TTwiddle_St := rec(\n        minSize := false,\n        maxSize := false,\n        applicable := (self, nt) >> ((IsBool(self.minSize) and not self.minSize) or nt.params[1] >= self.minSize) and \n            ((IsBool(self.maxSize) and not self.maxSize) or nt.params[1] <= self.maxSize),\n        forTransposition := false,\n        apply := function(t, C, Nonterms)\n            local access, blocksize, i, i1, j, n, d, k, rdx, stride, t;\n\n\t\t\tn := t.params[1];\n\t\t\tblocksize := t.params[2];\n\t\t\trdx := t.params[3];\n\t\t\tj := t.params[4];\n\t\t\tt := LogInt(n, rdx);\n\t\t\ti := Ind(n);\n\t\t\ti1 := Ind(n/(rdx^j));\n\t\t\tstride := rdx^j;\n\t\t\taccess := Lambda(i1, i1 * stride);\n\n#F\tOlder versions, not using an access function, but returning the full matrix\n#F\t\t\tTDiag(fPrecompute(diagTensor(fConst(TComplex, rdx^j, 1), Stockham_radix.gen(rdx, LogInt(N, rdx)-j-1))))\n#F\t\t\tomega := fCompose(FData(fCompose(dOmega(n,1),diagTensor(dLin(div(n,blocksize), 1, 0, TInt), dLin(blocksize, 1, 0, TInt))).tolist()), Lambda(i, i));\n#F\t\t\tomega := fCompose(fPrecompute(fCompose(dOmega(n,1),diagTensor(dLin(div(n,blocksize), 1, 0, TInt), dLin(blocksize, 1, 0, TInt))).tolist()), Lambda(i, i));\n\n\t\t\tomega := fCompose(fPrecompute(Tw1(n, n/rdx,1)), access);\n\t\t\tomega := diagTensor(omega, fConst(TComplex, rdx^j, 1));\n\n        \treturn Diag(omega);\n       \t\n\t\tend\n    ),\n));\n\nNewRulesFor(TTwiddle, rec(\n    TTwiddle_Tw1 := rec(\n        minSize := false,\n        maxSize := false,\n        applicable := (self, nt) >> ((IsBool(self.minSize) and not self.minSize) or nt.params[1] >= self.minSize) and \n            ((IsBool(self.maxSize) and not self.maxSize) or nt.params[1] <= self.maxSize),\n        forTransposition := false,\n        apply := (t, C, Nonterms) -> Diag(fPrecompute(Tw1(t.params[1], t.params[2], t.params[3])))\n    ),\n\n    TTwiddle_TwoTables := rec(\n        minSize := false,\n        maxSize := false,\n        applicable := (self, nt) >> ((IsBool(self.minSize) and not self.minSize) or nt.params[1] >= self.minSize) and \n            ((IsBool(self.maxSize) and not self.maxSize) or nt.params[1] <= self.maxSize),\n        forTransposition := false,\n        apply := function(t, C, Nonterms)\n            local mn, n, _k, rdx, dp, i, i1, i2, j, k, f, omega_1, omega_2;\n            \n            #t in this case is the TTwiddle(mn,n,k) function, so the t.params[1]  = first parameter of TTwiddle() = mn\n            mn := t.params[1];\n            n := t.params[2];\n            _k := t.params[3];\n            dp := DivisorPairs(mn);\n            rdx := Maximum(dp[Int(Length(dp)/2+1)]);\n            \n            i := Ind(mn);\n            i1 := Ind(mn);\n            i2 := Ind(mn);\n            j := Ind(mn/rdx);\n            k := Ind(rdx);\n\n            f := Lambda(i, idiv(i, n) * imod(i, n));\t# -> guarantees contiguous access\n            \n#   NOTE: fPrecompute does not work, so I have to force table generation through FData()\n#            omega_1 := fCompose(fPrecompute(dOmega(mn/rdx, _k)), fComputeOnline(Lambda(i1, idiv(f.at(i1), rdx))));\n#            omega_2 := fCompose(fPrecompute(dOmega(mn, _k)), fComputeOnline(Lambda(i2, imod(f.at(i2), rdx))));\n#            omega_1 := fCompose(fPrecompute(fCompose(dOmega(mn/rdx, _k), fId(mn/rdx))), fComputeOnline(Lambda(i1, idiv(f.at(i1), rdx))));\n#            omega_2 := fCompose(fPrecompute(fCompose(dOmega(mn, _k), fId(rdx))), fComputeOnline(Lambda(i2, imod(f.at(i2), rdx))));\n\n#   NOTE: the domain of dOmega cannot be set to an integer, so I need to compose with fId()...\n            omega_1 := fCompose(FData(fCompose(dOmega(mn/rdx, _k), fId(mn/rdx)).tolist()), Lambda(i1, idiv(f.at(i1), rdx)));\n            omega_2 := fCompose(FData(fCompose(dOmega(mn, _k), fId(rdx)).tolist()), Lambda(i2, imod(f.at(i2), rdx)));\n\n            return Diag(omega_1) * Diag(omega_2);\n\n# old version with FData without fCompose\n#            omega_1 := FData(Lambda(j, omega(mn/rdx, j*imod(_k, mn/rdx))).tolist());\n#            omega_2 := FData(Lambda(k, omega(mn, k*_k)).tolist());\n#            return Diag(Lambda(i1, omega_1.at(idiv(f.at(i1), rdx)))) * Diag(Lambda(i2, omega_2.at(imod(f.at(i2), rdx))));\n        end\n    ),\n));\n", "meta": {"hexsha": "af0b8ffec525aa194208aa5f5249d3268a81d9d9", "size": 5548, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/common/twiddle.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/common/twiddle.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/common/twiddle.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": 44.384, "max_line_length": 158, "alphanum_fraction": 0.5832732516, "num_tokens": 1757, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799928900257126, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.48264433880722957}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nDeclare(GathRecv);\nDeclare(ScatSend);\nDeclare(GathDist);\nDeclare(ScatDist);\nDeclare(Comm_Cell);\nDeclare(PTensor);\n\nDeclare(DistSum);\nDeclare(DistSumLoop);\n\n#F GathRecv(func, pkSize, P, i).\n#F Gather Receive, for parallel code.\nClass(GathRecv, BaseMat, SumsBase, rec(\n    sums := self >> self,\n    isReal := self >> true,\n    dims := self >> self.dimensions,\n    needInterleavedLeft := self >> false,\n    needInterleavedRight := self >> false,\n    cannotChangeDataFormat := self >> true,\n    totallyCannotChangeDataFormat := self >> true,\n    #-----------------------------------------------------------------------\n    # NOTE: we should have 2 children, not 1!\n    rChildren := self >> [self.func, self.pkSize, self.P, self.i],\n    rSetChild := rSetChildFields(\"func\", \"pkSize\", \"P\", \"i\"),\n    #-----------------------------------------------------------------------\n    new := (self, func, pkSize, P, i) >> SPL(WithBases(self,\n        rec(func       := FF(func),\n            pkSize     := pkSize,\n            i          := i,\n            P          := P,\n            dimensions := When(func.__name__ = \"FData\",\n                  [pkSize*func.domain()/P, pkSize*func.domain()],\n                  [pkSize*func.domain(), pkSize*func.range()] )\n            ))),\n    #-----------------------------------------------------------------------\n    area := self >> When(func.__name__ = \"FData\",\n                    self.pkSize * self.func.domain()/self.P,\n                    self.pkSize * self.func.domain()),\n\n    transpose := self >> ScatSend(self.func, self.pkSize, self.P, self.i),\n    #-----------------------------------------------------------------------\n    print := (self,i,is) >> Print(self.name, \"(\", self.func, \", \", self.pkSize, \", \", self.P, \", \", self.i,\")\"),\n    #-----------------------------------------------------------------------\n    toAMat := self >> \n       Cond(self.func.__name__ = \"FData\",\n\n          # NOTE Problem: The following considers self.i with FData, but not\n          # otherwise! (So in the otherwise case, func contains this info).\n\n          # This is if we've already converted to FData. Don't change the func below!\n          let(pkSize   := self.pkSize, \n              n        := pkSize*(self.func.domain()/self.P),\n              N        := pkSize*self.func.domain(),\n              func     := fTensor(\n                            fCompose(self.func, fTensor( fBase(self.P, self.i), fId(self.func.domain()/self.P) )),\n                            fId(pkSize)\n                          ).lambda(),\n              AMatMat(List([0..n-1], row -> BasisVec(N, func.at(row).ev())))\n          ),\n          # This is if we haven't converted to FData yet\n          let(pkSize   := self.pkSize, \n              n        := pkSize*self.func.domain(),\n              N        := pkSize*self.func.range(),\n              func     := fTensor(self.func, fId(pkSize)).lambda(),\n              AMatMat(List([0..n-1], row -> BasisVec(N, func.at(row).ev())))\n          )\n       )\n));\n\n#F ScatSend(func, pkSize, P, i).\n# For now, ScatSend will specify the target explicitly. GathRecv will just put\n# things in place\nClass(ScatSend, BaseMat, rec(\n    sums := self >> self,\n    dims := self >> self.dimensions,\n    isReal := self >> true,\n    needInterleavedLeft := self >> false,\n    needInterleavedRight := self >> false,\n    cannotChangeDataFormat := self >> true,\n    totallyCannotChangeDataFormat := self >> true,\n    area := self >> self.transpose().area(),\n    toAMat := self >> TransposedAMat(self.transpose().toAMat()),\n    #-----------------------------------------------------------------------\n    rChildren := self >> [self.func, self.pkSize, self.P, self.i],\n    rSetChild := rSetChildFields(\"func\", \"pkSize\", \"P\", \"i\"),\n    #-----------------------------------------------------------------------\n    new := (self, func, pkSize, P, i) >> SPL(WithBases(self,\n        rec(func       := FF(func),\n            pkSize     := pkSize,\n            P          := P,\n            i          := i,\n            dimensions := When(func.__name__ = \"FData\",\n                  [pkSize*func.domain(), pkSize*func.domain()/P],\n                  [pkSize*func.range(), pkSize*func.domain()] )\n            ))),\n    #-----------------------------------------------------------------------\n    transpose := self >> GathRecv(self.func, self.pkSize, self.P, self.i),\n    #-----------------------------------------------------------------------\n    print := (self,i,is) >> Print(self.name, \"(\", self.func, \", \", self.pkSize, \", \", self.P, \", \", self.i,\")\"),\n));\n\n#F GathDist(N, pkSize, P, i)\n#F Distributed Gather, for parallel code.\n#F N=Vector length. pkSize = packetSize P=Number of processors i=processor#\n#F Gathers (N/P)*pkSize elements corresponding to the ones to be processed by processor i.\nClass(GathDist, BaseMat, SumsBase, rec(\n    sums := self >> self,\n    dims := self >> self.dimensions,\n    isReal := self >> true,\n    needInterleavedLeft := self >> false,\n    needInterleavedRight := self >> false,\n    cannotChangeDataFormat := self >> true,\n    totallyCannotChangeDataFormat := self >> true,\n    #-----------------------------------------------------------------------\n    rChildren := self >> [self.N, self.pkSize, self.P, self.i],\n    rSetChild := rSetChildFields(\"N\", \"pkSize\", \"P\", \"i\"),\n    #-----------------------------------------------------------------------\n    new := (self, N, pkSize, P, i) >> SPL(WithBases(self,\n        rec(N          := N,\n            pkSize     := pkSize,\n            P          := P,\n            i          := i,\n            func       := FF( fAdd(N, N/P, i*(N/P))  ),\n            dimensions := [pkSize*(N/P), pkSize*N]))),\n    #-----------------------------------------------------------------------\n    area := self >> self.func.domain() * self.func.range(),\n    transpose := self >> ScatDist(self.N, self.pkSize, self.P, self.i),\n    #-----------------------------------------------------------------------\n    print := (self,i,is) >> Print(self.name, \"(\", self.N, \", \", self.pkSize, \", \", self.P, \", \", self.i, \")\"),\n    #-----------------------------------------------------------------------\n    toAMat := self >> let(\n             pkSize:=self.pkSize,\n             n:=pkSize*(self.N/self.P),\n             N:=pkSize*self.N,\n             i:=self.i,\n             P:=self.P,\n             func := FF( fAdd(N, N/P, i*(N/P))  ).lambda(),\n             AMatMat(List([0..n-1], row -> BasisVec(N, func.at(row).ev())))\n    ),\n));\n\n#F ScatDist(N, pkSize, P, i)\n#F Distributed Scatter. See Doc(GathDist) for more info.\nClass(ScatDist, BaseMat, rec(\n    sums := self >> self,\n    dims := self >> self.dimensions,\n    isReal := self >> true,\n    needInterleavedLeft := self >> false,\n    needInterleavedRight := self >> false,\n    cannotChangeDataFormat := self >> true,\n    totallyCannotChangeDataFormat := self >> true,\n    #-----------------------------------------------------------------------\n    rChildren := self >> [self.N, self.pkSize, self.P, self.i],\n    rSetChild := rSetChildFields(\"N\", \"pkSize\", \"P\", \"i\"),\n    #-----------------------------------------------------------------------\n    new := (self, N, pkSize, P, i) >> SPL(WithBases(self,\n        rec(N           := N,\n            pkSize      := pkSize,\n            P           := P,\n            i           := i,\n            func        := FF( fAdd(N, N/P, i*(N/P))  ),\n            dimensions  := [pkSize*N, pkSize*(N/P)]))),\n    #-----------------------------------------------------------------------\n    area := self >> self.transpose().area(),\n    transpose := self >> GathDist(self.N, self.pkSize, self.P, self.i),\n    #-----------------------------------------------------------------------\n    print := (self,i,is) >> Print(self.name, \"(\", self.N, \", \", self.pkSize, \", \", self.P, \", \", self.i, \")\"),\n    #-----------------------------------------------------------------------\n    toAMat := self >> TransposedAMat(self.transpose().toAMat()),\n));\n\n#NOTE: P and domain are the same thing, and are redundant for DistSum. Remove\n#one of them. Assign P to domain or something like that.\n\n#F ==========================================================================\n#F DistSum(<P>, <var>, <domain>, <spl>) - as ISum but makes parallel loop in the code\n#F ==========================================================================\n\nClass(DistSum, ISum, rec(\n\n    doNotMarkBB := true,\n    new := meth(self, P, var, domain, expr)\n        local res;\n        Constraint(IsSPL(expr)); \n        # if domain is an integer (not symbolic) it must be non-zero\n        Constraint(not IsInt(domain) or domain > 0);\n        var.isParallelLoopIndex := true;\n        res := SPL(WithBases(self, rec(P:=P, _children := [expr], var := var, domain := domain)));\n        res.dimensions := res.dims();\n        return res;\n    end,\n    \n    rChildren := self >> Concatenation([self.P], self._children),\n    rSetChild := meth(self, n, newChild) \n        if n=1 then self.P := newChild;\n          else self._children[n-1] := newChild;\n        fi;\n    end,\n\n    from_rChildren := (self, rch) >> ApplyFunc(ObjId(self), [rch[1], self.var, self.domain, rch[2]]),\n\n    leftMostParScat  := self >> Collect(self._children[1], @(1,[ScatSend, ScatDist]))[1],\n    rightMostParGath := self >> Collect(self._children[1], @(1,[GathRecv, GathDist]))[1],\n\n    print := meth(self, indent, indentStep)\n        Print(self.name, \"(\", self.P, \", \", self.var, \", \", self.domain, \",\");\n        self._newline(indent + indentStep);\n        SPLOps.Print(self._children[1], indent+indentStep, indentStep); #, \", \", self.nt_maps);\n        self._newline(indent);\n        Print(\")\");\n    end,\n\n));\n\nClass(DistSumLoop, DistSum, rec(\n\n    dims := (self) >> self._children[1].dims()*self.domain\n\n));\n\n#F Comm_Cell(p, pkSize)\n#F All-to-all communication, specifically implementing L(p^2, p), where p=# of procs\n\nClass(Comm_Cell, BaseMat, rec(\n    cannotChangeDataFormat :=  self >> true,\n    totallyCannotChangeDataFormat := self >> true,\n    sums := self >> self,\n    dims := self >> self.dimensions,\n    isReal := self >> true,\n    #-----------------------------------------------------------------------\n    rChildren := self >> [self.P, self.pkSize],\n    rSetChild := rSetChildFields(\"P\", \"pkSize\"),\n    #-----------------------------------------------------------------------\n    new := (self, P, pkSize) >> SPL(WithBases(self,\n        rec(P           := P,\n            pkSize      := pkSize,\n            dimensions  := [P*P*pkSize, P*P*pkSize]))),\n    #-----------------------------------------------------------------------\n    area := self >> self.P*self.P*self.pkSize*self.P*self.P*self.pkSize,\n    #NOTE: check.\n    transpose := self >> self,\n    #-----------------------------------------------------------------------\n    print := (self,i,is) >> Print(self.name, \"(\", self.P, \", \", self.pkSize, \")\"),\n    #-----------------------------------------------------------------------\n    toAMat := self >> let(\n             pkSize := self.pkSize,\n             P      := self.P,\n             func   := FF( fTensor(L(P*P, P), fId(pkSize))  ).lambda(),\n             AMatMat(List([0..(P*P*pkSize)-1], row -> BasisVec((P*P*pkSize), func.at(row).ev())))\n          ),\n));\n\n\n\nClass(PTensor, BaseMat, SumsBase, rec(\n    cannotChangeDataFormat :=  self >> true,\n    totallyCannotChangeDataFormat := self >> true,\n    sums := self >> PTensor(self.L.sums(), self.P),\n    dims := self >> self.L.dims() * self.P,\n    isReal := self >> true,\n    #-----------------------------------------------------------------------\n    rChildren := self >> [self.L, self.P],\n    rSetChild := rSetChildFields(\"L\", \"P\"),\n    #-----------------------------------------------------------------------\n    new := (self, L, P) >> SPL(WithBases(self,\n        rec(L   := L,\n            P   := P,\n            dimensions := L.dims()*P)\n    )),\n\n    #-----------------------------------------------------------------------\n    #area := self >> self.L.dimen\n    transpose := self >> PTensor(self.L.transpose(), self.P),\n    #-----------------------------------------------------------------------\n\n    print := (self,i,is) >> Print(self.name, \"(\",\n        self.L.print(i+is,is), \", \", self.P, \")\"),\n    #-----------------------------------------------------------------------\n    toAMat := self >> Tensor(I(self.P), self.L).toAMat(),\n    #-----------------------------------------------------------------------\n    isPermutation := False,\n    needInterleavedLeft := true,\n    needInterleavedRight := true,\n    #NOTE: We should be able to stuff data format change into the PTensor\n));\n\n\n#Class(DontTouchMe, Buf, rec(\n#    totallyCannotChangeDataFormat := self >> true,\n#    cannotChangeDataFormat := self >> true\n#));\n", "meta": {"hexsha": "382bfa692401be9c6179b2c4f4cec7a66e2870f2", "size": 12822, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/distributed/sigmaspl.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/distributed/sigmaspl.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/distributed/sigmaspl.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": 43.1717171717, "max_line_length": 114, "alphanum_fraction": 0.4443144595, "num_tokens": 2994, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388167733099, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4818646961453652}}
{"text": "#############################################################################\n##\n#W    pcpgrp.gi                                                  Bettina Eick\n##\n##    This file contains the header functions to handle the 3- and \n##    4-dimensional almost crystallographic pcp groups.\n##\n\n#############################################################################\n##\n#F IsAlmostCrystallographic( <G> )\n##\nInstallMethod( IsAlmostCrystallographic, \"for pcp groups\", true,\n    [IsPcpGroup ], 0,\nfunction( G )\n    if HasAlmostCrystallographicInfo( G ) then return true; fi;\n    return (IsInt(Index(G,FittingSubgroup(G))) and \n            Size(NormalTorsionSubgroup(G)) = 1); \nend );\n\n#############################################################################\n##\n#F IsAlmostBieberbachGroup( <G> )\n##\nInstallMethod( IsAlmostBieberbachGroup, \"for pcp groups\", true,\n    [IsPcpGroup ], 0,\nfunction( G )\n    return IsInt(Index(G,FittingSubgroup(G))) and IsTorsionFree(G);\nend );\n\n#############################################################################\n##\n#F IsolatorSubgroup( G, N )\n##\nInstallGlobalFunction( IsolatorSubgroup, function( G, N )\n    local nat, F, T;\n    if not IsNormal( G, N ) then return fail; fi;\n    nat := NaturalHomomorphismByNormalSubgroup( G, N );\n    F := Image( nat );\n    T := TorsionSubgroup( F );\n    if IsBool( T ) then return fail; fi;\n    return PreImage( nat, T );\nend);\n\n#############################################################################\n##\n#F AlmostCrystallographicPcpDim3( type, param )\n##\nInstallGlobalFunction( AlmostCrystallographicPcpDim3,\nfunction( type, param )\n    local g, G, info;\n  \n    # type is integer or string\n    if IsString( type ) then \n        g := Int( type );\n    elif IsInt( type ) then\n        g := type;\n    else \n        g := false;\n    fi;\n    if not g in [1..17] then \n        Error(\"type does not define a valid ac-group type\");\n    fi;\n\n    # check parameters\n    if IsBool( param ) then\n        param := List( [1..ACDim3Param[g]], x -> Random(Integers) );\n        if param[1] = 0 then param[1] := Random(Integers)^2+1; fi;\n    elif IsInt( param ) then \n        param := List( [1..ACDim3Param[g]], x -> param );\n    elif Length( param ) <> ACDim3Param[g] then \n        Error(\"parameter should be a list of length \", ACDim3Param[g] );\n    fi;\n\n    # get group\n    if Length( param ) = 4 then \n        G := ACPcpDim3Funcs[g](param[1], param[2], param[3], param[4]);\n    elif Length(param) = 2 then\n        G := ACPcpDim3Funcs[g](param[1], param[2] );\n    elif Length(param) = 1 then \n        G := ACPcpDim3Funcs[g](param[1]);\n    fi;\n\n    # set some information\n    info := rec( dim := 3, type := g, param := param );\n    SetAlmostCrystallographicInfo( G, info );\n    SetIsAlmostCrystallographic( G, true );\n    SetSize( G, infinity );\n    return G;\nend );\n \n#############################################################################\n##\n#F AlmostCrystallographicPcpDim4( type, param )\n##\nInstallGlobalFunction( AlmostCrystallographicPcpDim4,\nfunction( type, param )\n    local g, G, info;\n\n    # type is integer or string\n    if IsString( type ) then\n        g := Position( ACDim4Types, type );\n    elif IsInt( type ) then\n        g := type;\n    else \n        g := false;\n    fi;\n    if not g in [1..95] then \n        Error(\"type does not define a valid ac-group type\");\n    fi;\n\n    # check parameters\n    if IsBool( param ) then\n        param := List( [1..ACDim4Param[g]], x -> Random(Integers) );\n        if param[1] = 0 then param[1] := Random(Integers)^2+1; fi;\n    elif IsInt( param ) then \n        param := List( [1..ACDim4Param[g]], x -> param );\n    elif Length( param ) <> ACDim4Param[g] then\n        Error(\"parameter should be a list of length \", ACDim4Param[g] );\n    fi;\n\n    # get group\n    if Length(param) = 7 then\n        G := ACPcpDim4Funcs[g]( param[1], param[2], param[3], param[4], \n                                param[5], param[6], param[7]);\n    elif Length(param) = 6 then\n        G := ACPcpDim4Funcs[g]( param[1], param[2], param[3], param[4], \n                                param[5], param[6]);\n    elif Length(param) = 5 then\n        G := ACPcpDim4Funcs[g]( param[1], param[2], param[3], param[4], \n                                param[5]);\n    elif Length(param) = 4 then\n        G := ACPcpDim4Funcs[g]( param[1], param[2], param[3], param[4]);\n    elif Length(param) = 3 then\n        G := ACPcpDim4Funcs[g]( param[1], param[2], param[3]);\n    fi;\n\n    # set some information\n    info := rec( dim := 4, type := g, param := param );\n    SetAlmostCrystallographicInfo( G, info );\n    SetIsAlmostCrystallographic( G, true );\n    SetSize( G, infinity );\n    return G;\nend );\n\n#############################################################################\n##\n#F AlmostCrystallographicPcpGroup( dim, type, param )\n##\nInstallGlobalFunction( AlmostCrystallographicPcpGroup,\nfunction( dim, type, param )\n    if dim = 3 then \n        return AlmostCrystallographicPcpDim3( type, param );\n    elif dim = 4 then \n        return AlmostCrystallographicPcpDim4( type, param );\n    else\n        Error(\"dimension must be 3 or 4\");\n    fi;\nend );\n\n#############################################################################\n##\n#A  FittingSubgroup( < G > )\n##\nInstallMethod( FittingSubgroup, \"for ac pcp groups\", true, \n      [IsPcpGroup and HasAlmostCrystallographicInfo], 0, \nfunction( G )\n    local pcp, rel, sub, F;\n    pcp := Pcp( G );\n    rel := RelativeOrdersOfPcp( pcp );\n    sub := Filtered( [1..Length(pcp)], x -> rel[x] = 0 );\n    F := Subgroup( G, pcp{sub} );\n    SetIsNilpotentGroup( F, true );\n    return F;\nend );\n\n#############################################################################\n##\n#F  NaturalHomomorphismOnHolonomyGroup( < G > )\n#F  HolonomyGroup( < G > )\n##\nInstallMethod( NaturalHomomorphismOnHolonomyGroup, \"for ac pcp groups\", true,\n    [IsPcpGroup and IsAlmostCrystallographic], 0, \nfunction( G )\n    return NaturalHomomorphismByNormalSubgroup(G,FittingSubgroup(G));\nend );\n\nInstallMethod( HolonomyGroup, \"for ac pcp groups\", true,\n    [IsPcpGroup and IsAlmostCrystallographic], 0, \nfunction( G )\n    return Image( NaturalHomomorphismOnHolonomyGroup(G) );\nend );\n\n#############################################################################\n##\n#F IsomorphismPcpGroup( <G> )\n##\nInstallMethod( IsomorphismPcpGroup, \"for ac groups\", true,\n    [IsMatrixGroup and HasAlmostCrystallographicInfo], 0,\nfunction( G )\n    local info, H, gensH, gensG, l, d, newsG, hom;\n\n    # get the corresponding pcp group\n    info := AlmostCrystallographicInfo( G );\n    H := AlmostCrystallographicPcpGroup( info.dim, info.type, info.param );\n    gensH := GeneratorsOfGroup(H);\n    gensG := GeneratorsOfGroup(G);\n\n    # sort the generators of G according to the generators of H\n    l := Length( gensG );\n    d := info.dim;\n    newsG := Concatenation( Reversed( gensG{[d+1..l]} ), gensG{[1..d]} );\n    hom := GroupHomomorphismByImagesNC( G, H, newsG, gensH );\n    SetIsInjective( hom, true );\n    SetIsSurjective( hom, true );\n    return hom;\nend );\n\n\n", "meta": {"hexsha": "5f1811e486f9442356558db10048f24026eb7519", "size": 7056, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "gap/pcpgrp.gi", "max_stars_repo_name": "alex-konovalov/aclib", "max_stars_repo_head_hexsha": "d1afb020805bfd60a8bbb0a9a4adac77fe9b44f1", "max_stars_repo_licenses": ["Artistic-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "gap/pcpgrp.gi", "max_issues_repo_name": "alex-konovalov/aclib", "max_issues_repo_head_hexsha": "d1afb020805bfd60a8bbb0a9a4adac77fe9b44f1", "max_issues_repo_licenses": ["Artistic-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2018-03-07T16:35:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-26T23:51:07.000Z", "max_forks_repo_path": "gap/pcpgrp.gi", "max_forks_repo_name": "alex-konovalov/aclib", "max_forks_repo_head_hexsha": "d1afb020805bfd60a8bbb0a9a4adac77fe9b44f1", "max_forks_repo_licenses": ["Artistic-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-03-10T19:58:42.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-10T19:58:42.000Z", "avg_line_length": 32.0727272727, "max_line_length": 77, "alphanum_fraction": 0.5423752834, "num_tokens": 1921, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.640635847978761, "lm_q1q2_score": 0.4817662128812983}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n;; This buffer is for notes you don't want to save, and for Lisp evaluation.\n;; If you want to create a file, visit that file with C-x C-f,\n;; then enter the text in that file's own buffer.\n\nn := 20;\n\nopts := CopyFields(PRDFTDefaults, rec(\n    globalUnrolling := 1000,\n    compileStrategy := NoCSE,\n    compflags := \"-O1\"\n));\n\nr  := RandomRuleTree(BRDFT3(4,1/16), opts);\nrr := RandomRuleTree(RC(SkewDFT(2,1/16)), opts);\ns  := SumsSPL(Tensor(I(n), SumsRuleTree(r, opts)), opts);\nss := SumsSPL(Tensor(I(n), SumsRuleTree(rr, opts)), opts);\nc  := CodeSums(1000, s, opts);;\ncc := CodeSums(1000, ss, opts);;\nCMeasure(c, opts);\nCMeasure(cc, opts);\n\n\nr  := RandomRuleTree(BRDFT1(4), opts);\nrr := RandomRuleTree(SRDFT1(4), opts);\ns  := SumsSPL(Tensor(I(n), SumsRuleTree(r, opts)), opts);\nss := SumsSPL(Tensor(I(n), SumsRuleTree(rr, opts)), opts);\nc  := CodeSums(1000, s, opts);;\ncc := CodeSums(1000, ss, opts);;\nCMeasure(c, opts);\nCMeasure(cc, opts);\n\n\ncopts := CopyFields(opts, rec(\n   generateComplexCode := true,\n   XType := TComplex,\n   YType := TComplex,\n   dataType := \"complex\",\n   unparser := CMacroUnparser,\n   includes := [\"<include/complex_gcc_sse3.h>\"]\n));\n\nopts := copts;\n\nr  := RandomRuleTree(Tensor(I(n), BRDFT3(4,1/16)), opts);\nrr := RandomRuleTree(Tensor(I(n), RC(SkewDFT(2,1/16))), opts);\n\nc  := CodeRuleTree(r, opts);;\ncc := CodeRuleTree(rr, opts);;\n", "meta": {"hexsha": "10cfdc054b884dc09488404e407b2021b614affe", "size": 1442, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sym/kernel_example.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/kernel_example.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/kernel_example.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.2075471698, "max_line_length": 76, "alphanum_fraction": 0.6539528433, "num_tokens": 481, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.48172692921217275}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# -----------------------------\n# Special extension definitions\n# ------------------------------\n\n# periodic\nClass(per, rec(\n    __call__ := (self, k) >> WithBases(self, rec(n:=k, operations:=PrintOps)),\n    print := self >> Print(self.name, \"(\", self.n, \")\"),\n    left  := (self, N) >> fAdd(N, self.n, N - self.n),\n    right := (self, N) >> fAdd(N, self.n, 0),\n));\n\n# half-point symmetric\nClass(hs, rec(\n    __call__ := (self, k) >> WithBases(self, rec(n:=k, operations:=PrintOps)),\n    print := self >> Print(self.name, \"(\", self.n, \")\"),\n\n    left  := (self, N) >> fCompose(fAdd(N, self.n, 0), J(self.n)),\n    right := (self, N) >> fCompose(fAdd(N, self.n, N-self.n),J(self.n))\n));\n\n# whole-point symmetric\nClass(ws, rec(\n    __call__ := (self, k) >> WithBases(self, rec(n:=k, operations:=PrintOps)),\n    print := self >> Print(self.name, \"(\", self.n, \")\"),\n\n    left  := (self, N) >> fCompose(fAdd(N, self.n, 1), J(self.n)),\n    right := (self, N) >> fCompose(fAdd(N, self.n, N-self.n-1),J(self.n))\n));\n\n# zero padding - doing nothing, just returning the extension length\nClass(zer, rec(\n    __call__ := (self, k) >> WithBases(self, rec(n:=k, operations:=PrintOps)),\n    print := self >> Print(self.name, \"(\", self.n, \")\"),\n    left  := (self, N) >> self.n,\n    right := (self, N) >> self.n,\n));\n\n\n\n# ******************************\n#  Operations on polynomials\n# ******************************\n\nListPoly := (p) -> [p.coefficients, p.valuation];\n\nListSum := function(l1,l2)\n  local i, d1, d2, dm, l;\n\n  l := [];\n  d1 := Length(l1);\n  d2 := Length(l2);\n  dm := Minimum(d1,d2);\n  for i in [1..dm] do \n     l[i] := l1[i]+l2[i];od;\n  if d2 > dm then Append(l,l2{[dm+1..d2]});\n  else Append(l,l1{[dm+1..d1]});\n  fi;\n  return l;\nend; \n\n\nListPolyMat := function(M) \n   local S,L,V;\n   S:=List(M, j-> ListPoly(j));\n   L:=List(S, i->i[1]);\n   V:=List(S, i->i[2]);\n\n  return [L,V];\nend;\n\nShift := function(h, sh)\nlocal g;\n\nif IsPolynomial(h) then\ng := ShallowCopy(h);\ng.valuation := h.valuation + sh;\nreturn g;\nelse \nreturn [h[1],h[2]+sh];\nfi;\nend;\n\nUpsample := function(h)\nlocal i, L, g;\nL:=[];\n g:=ShallowCopy(h);\n if Length(h.coefficients)=1 then\n  Add(L,h.coefficients[1]);\n elif Length(h.coefficients)>1 then\n  for i in [1..Length(h.coefficients)-1] do\n    Add(L, h.coefficients[i]);\n    Add(L, h.baseRing.zero);\n  od;\n  Add(L, h.coefficients[i+1]);\n fi;\n  g.coefficients := L;\n  g.valuation := h.valuation * 2;\n  return g;\nend;\n\n\n\n# Downsample creates apolynomial of even coefficients\n# h_e(z^2) =1/2*( h(z)+h(-z) )\n\nDownsample := function(h)\nlocal i, L, g, even, odd, v, l, k, coef;\n\n if IsPolynomial(h) then L:= ListPoly(h); coef:=L[1]; l:=L[2];\n else coef:=h[1]; l:=h[2]; fi;\n L:=[];\n k := l mod 2;\n    even := Filtered([1..Length(coef)], i-> i mod 2 = 0);\n    odd := Filtered([1..Length(coef)], i-> i mod 2 = 1);    \n\n  if (k=0) then \n    L:= Sublist(coef,odd);\n    v := l/2;\n  else \n    L := Sublist(coef,even);\n    v := Int((l+1)/2);\n  fi;\n\n \n  #g.coefficients := L;\n  #g.valuation :=v;\n  return [L,v];\nend;\n\n\nDownsampleTwo := function(h)\nlocal he, ho;\n\nif IsPolynomial(h) then h:=ListPoly(h); fi;\nhe:=Downsample(h);\nho:=Downsample(Shift(h,1));\nif h[2] mod 2 = 0 then\nho:=Shift(ho,-1);\nfi;\n\nreturn[he,ho];\nend;\n\nDownsampleTwoNeg := function(h)\nlocal he, ho;\n\nhe:=Downsample(h);\nho:=Downsample(Shift(h,-1));\nif h[2] mod 2 = 0 then\nho:=Shift(ho,1);\nfi;\n\nreturn[he,ho];\nend;\n\n\n\nPosInt := (int) -> (int + AbsInt(int))/2;\n\n\n#F Positive(n)\n#F returns positive value of n thresholded at 0\n#F\nPositive := (n) -> When(n>0, n, 0);\n\n#F Poly(L,v)\n#F Creates a polynomial L[1]*z^(v+k-1) + ... + L[k]*z^v\n#F\n\nPoly := function(arg)\nlocal z,L,v;\nz:=Indeterminate(Cyclotomics);\nz.name:=\"z\";\nL := When(IsList(arg[1]),arg[1],[arg[1]]);\nv := When(Length(arg)<2,0,arg[2]); \nreturn Polynomial(Cyclotomics, L, v);\nend;\n\n#F PolyMat(L,V)\n#F Creates a polynomial matrix out of coefficient and valuation matrices\n#F\n\nPolyMat := function(L,V)\nlocal M,dim;\ndim:=Dimensions(V);\nM := List([1..dim[1]],i->List([1..dim[2]],j->Poly(L[i][j],V[i][j])));\nreturn M;\nend;\n\n\n\n#F PolyExtension(p(z)) \n#F Computes extension lengths for poynomial p(z)\n#F \nPolyExtension := p -> let(\n    l := Positive(-p.valuation),\n    r := Positive(LaurentDegree(p)+p.valuation),\n    [l, r]\n);\n\n#F FillZeros := function(L,v)\n#F fills zeros in the list of polynomial coefficients up to z^0\n#F \nFillZeros := function(p)\nlocal w,Ls,L,v;\nif IsList(p) then\nL:=p[1];\nv:=p[2];\nelse\nL:= p.coefficients;\nv:= p.valuation;\nfi;\n\nw:= v+Length(L)-1;\nLs:= L;\nif w<=0 then \n  Ls := Concat(L,List([1..-w], i->0));\n  #k := -w;\nelif v>=0 then\n  Ls := Concat(List([1..v], i->0), L);\n  #k := v;\nfi;\nreturn [Ls,-Positive(-v)];\nend;\n\n#F FillZerosMat := function(L,v)\n#F fills zeros in the list of polynomial coefficients up to z^0\n#F \n\nFillZerosMat := function(p)\nlocal S,L,V,dim;\n\ndim := Dimensions(p);\nL:=List(p, i->List(i, j->  j.coefficients));\nV:=List(p, i->List(i, j->  j.valuation));\n\nS:=List([1..dim[1]],i->List([1..dim[2]],j-> FillZeros([L[i][j],V[i][j]])));\nL:=List(S, i->List(i, j-> j[1])); \nV:=List(S, i->List(i, j-> j[2])); \n\nreturn [L,V];\nend;\n\n\nTimeReverse := (L,v) -> let(\n               deg := Length(L),\n               [Reversed(L),-(v+deg)+1]);\n\n\nTimeReverseMat := function(arg) \n   local S,L,V,Ls,Vs,deg;\n\nif Length(arg)=1 then L:=arg[1][1]; V:=arg[1][2]; \nelse L:=arg[1]; V:=arg[2]; fi;\n\ndeg := Length(V);\nS:=List([1..deg],i->TimeReverse(L[i],V[i]));\nLs:=List(S,i->i[1]);\nVs:=List(S,i->i[2]);\nreturn [Ls,Vs];\nend;\n\n\nAlternate := (L) -> [List([1..Length(L[1])], i->(-1)^(L[2]+i-1)*L[1][i]),L[2]];\n \n\n                         \nSynth2AnalFilts := function(L,V) \n \n local ht,gt,h,g;\n\n h:=TimeReverse(L[1],V[1]);\n g:=TimeReverse(L[2],V[2]);\n\n h:=Alternate(h);\n g:=Alternate(g); \n\n ht:=[];\n gt:=[];\n\n ht[1] := g[1];\n ht[2] := g[2]+1;\n gt[1] := -h[1];\n gt[2] := h[2]+1;\n\n return [[ht[1],gt[1]],[ht[2],gt[2]]];\n\nend;\n\n\nAnal2SynthFilts := function(L,V) \n \n local ht,gt,g,h;                \n h:=TimeReverse(L[1],V[1]);\n g:=TimeReverse(L[2],V[2]);\n \n h:=Alternate(h);\n g:=Alternate(g); \n\n ht:=[];\n gt:=[];\n\n ht[1] := g[1];\n ht[2] := g[2]+1;\n gt[1] := -h[1];\n gt[2] := h[2]+1;\n\n return [[ht[1],gt[1]],[ht[2],gt[2]]];\n\nend;\n\n# wraps a polynomial given as Poly or as List+valuation periodically\n# for circulants\nCircularWrap := function(arg)\nlocal L,v,l,r,n;\nif (Length(arg) = 2) then \nif IsPolynomial(arg[1]) then\nl:=ListPoly(arg[1]); \nelse l:=arg[1];fi;\nL:=l[1]; \nv:=l[2];\nn:=arg[2]; \nelse \nL:=arg[1]; \nv:=arg[2];\nn:=arg[3];\nfi;\n\nr:= Length(L)+v-1;\nif v>0 then L:=Concat(Replicate(v,0),L);fi;\n\nif r <n then \nL:=Concat(L, Replicate(n-r-1,0));\nL:=L*MatSPL(Ext(n,per(PosInt(-v)),per(0)));\nelse\nL:=L*MatSPL(Ext(n,per(PosInt(-v)),per(r-n+1)));\nfi;\n\n# Circulant needs first column as param instead of first row (need to be changed)\n\nl:= Reversed(L{[2..Length(L)]});\nL:=Concat([L[1]],l);\n\nreturn L;\nend;\n\n\n\n# \n# Helper functions for non-terminal arguments \n#\ntoSize := o -> Cond(\n    IsPosInt(o), o,\n    IsList(o), Length(o),\n    IsPolynomial(o), Length(o.coefficients),\n    IsFunction(o), o.domain(),\n    Error(\"List, polynomial, or generating function expected\"));\n    \ntoFunc := o -> Cond(\n    IsPosInt(o), FUnk(o),\n    IsList(o), Checked(o<>[], FList(UnifyTypesV(o), o)),\n    IsPolynomial(o), FList(UnifyTypesV(o.coefficients), o.coefficients),\n    IsFunction(o),   o,\n    Error(\"List, polynomial, or generating function expected\"));\n\ntoValuation := o -> Cond(\n    IsPosInt(o), 0,\n    IsList(o), 0,\n    IsPolynomial(o), o.valuation,\n    IsFunction(o), 0,\n    Error(\"List, polynomial, or generating function expected\"));\n\nQuantizeQuarters := rat -> Cond(0  <= rat and rat <= 3/8, 1/4,\n                                3/8 < rat and rat <= 5/8, 1/2,\n                                5/8 < rat and rat <= 7/8, 3/4,\n\t\t\t\t1);\n\n\ntoFiltFunc := o -> Cond(\n    IsPosInt(o), \n        [ fUnk(TReal, o), -o+1],\n    IsList(o), Checked(o<>[], \n\t[ toFunc(o), -Length(o)+1 ]),\n    IsPolynomial(o), let(zp := FillZeros(o),\n        [ toFunc(zp[1]), zp[2] ]), \n    IsFunction(o) or IsFuncExp(o), \n        [ o, -o.domain()+1 ],\n    Error(\"List, polynomial, or generating function expected\"));\n\ntoFiltFuncV := (o,v) -> Cond(\n    IsPosInt(o), let(w := v+o-1,\n\tWhen(w < 0 or v > 0, \n\t    Error(\"Valuation does not match domain of <o>, can't zero-pad a gener. function\"),\n        [ fUnk(TReal, o), v])),\n    IsList(o), Checked(o<>[], let(zp := FillZeros([o,v]),\n\t[ toFunc(zp[1]), zp[2] ])),\n    IsFunction(o) or IsFuncExp(o), let(dom := o.domain(), w := v+dom-1,\n\tWhen(w < 0 or v > 0, \n\t    Error(\"Valuation does not match domain of <o>, can't zero-pad a gener. function\"),\n\t    [ o, -o.domain()+1 ])),\n    Error(\"Only list or generating function can be specified with separate valuation\"));\n", "meta": {"hexsha": "2a89b83746cb29c11218c13dccfb81bd00cefeff", "size": 8778, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/filtering/auxil.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/transforms/filtering/auxil.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/transforms/filtering/auxil.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 21.5147058824, "max_line_length": 88, "alphanum_fraction": 0.5606060606, "num_tokens": 3074, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6477982247516796, "lm_q1q2_score": 0.4814229166714062}}
{"text": "\n# Copyright 2018-2019, Carnegie Mellon University\n# See LICENSE for details\n\nClass(arctan, AutoFoldExp, rec(\n  ev := self >> self._ev(self.args).ev(),  \n  computeType := self >> TReal, \n));\n\n\nClass(TArcTan, Tagged_tSPL_Container, rec(\n    abbrevs :=  [ () -> []],\n    dims := self >> [1, 2],\n    transpose := self >> CopyFields(self, rec(transposed := not self.transposed)),\n    isReal := True\n));\n\n\nNewRulesFor(TArcTan, rec(\n    TArcTan_Base := rec(\n        applicable := True,\n        forTransposition := false,\n        apply := (t, C, Nonterms) -> let( x := var.fresh_t(\"r\", TDouble), y := var.fresh_t(\"r\", TDouble),\n            OLCompose(BinOp(1, Lambda([x,y], arctan(x,y)))))\n    )\n));\n\n", "meta": {"hexsha": "20a6e90c6d34eda2aba4a19f57df48e47b912e0b", "size": 693, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "arctan.gi", "max_stars_repo_name": "spiral-software/spiral-package-hcol", "max_stars_repo_head_hexsha": "b4a0118382e3bba91ecd82a6c667f2cdb6389ceb", "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": "arctan.gi", "max_issues_repo_name": "spiral-software/spiral-package-hcol", "max_issues_repo_head_hexsha": "b4a0118382e3bba91ecd82a6c667f2cdb6389ceb", "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": "arctan.gi", "max_forks_repo_name": "spiral-software/spiral-package-hcol", "max_forks_repo_head_hexsha": "b4a0118382e3bba91ecd82a6c667f2cdb6389ceb", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-11-26T05:21:02.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-26T05:21:02.000Z", "avg_line_length": 24.75, "max_line_length": 105, "alphanum_fraction": 0.5873015873, "num_tokens": 207, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.754914975839675, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4809040868242874}}
{"text": "############################################################################\n##\n##  util.gi                       IRREDSOL                  Burkhard H\u00f6fling\n##\n##  Copyright \u00a9 2003\u20132016 Burkhard H\u00f6fling\n##\n\n\n############################################################################\n##\n#I  TestFlag(<n>, <i>)\n##\n##  tests if the i-th bit is set in binary representation the nonnegative \n##  integer n\n##  \nInstallGlobalFunction(TestFlag,\n    function(n, i)\n        return QuoInt(n, 2^i) mod 2 = 1;\n    end);\n    \n\n############################################################################\n##\n#F  CodeCharacteristicPolynomial(<mat>, <q>)\n##\n##  given a matrix mat over GF(q), this computes a number which uniquely\n##  identifies the characteristic polynomial of mat.\n##  \nInstallGlobalFunction(CodeCharacteristicPolynomial,\n    function(mat, q)\n\n        local cf, z, sum, c;\n\n        z := Z(q);\n        if Length(mat) = 2 then\n            cf := [ mat[1][1]*mat[2][2] - mat[1][2]*mat[2][1],\n                    - mat[1][1] - mat[2][2],\n                    z^0];\n        elif Length(mat) = 3 then\n            cf := [ - mat[1][1]*mat[2][2]*mat[3][3] - mat[1][2]*mat[2][3]*mat[3][1] - mat[1][3]*mat[2][1]*mat[3][2]\n                    + mat[1][1]*mat[2][3]*mat[3][2] + mat[2][2]*mat[1][3]*mat[3][1] + mat[3][3]*mat[2][1]*mat[1][2],\n                    mat[1][1]*mat[2][2] + mat[2][2]*mat[3][3] + mat[1][1]*mat[3][3]\n                        - mat[1][2]*mat[2][1] - mat[2][3]*mat[3][2] - mat[1][3]*mat[3][1],\n                    - mat[1][1] - mat[2][2] - mat[3][3],\n                    z^0];\n        else\n            cf := CoefficientsOfUnivariatePolynomial(CharacteristicPolynomial(mat, 1));\n        fi;\n\n        sum := 0;\n        for c in cf do\n            if c = 0*z then\n                sum := sum * q;\n            else \n                sum := sum * q + LogFFE(c, z) + 1;\n            fi;\n        od;\n\n        return sum;\n    end);\n\n\n############################################################################\n##\n#F  FFMatrixByNumber(n, d, q)\n##\n##  computes a d x d matrix over GF(q) represented by the integer n\n##  \nInstallGlobalFunction(FFMatrixByNumber,\n    function(n, d, q)\n    \n        local z, m, i, j, k;\n        \n        z := Z(q);\n        m := NullMat(d,d, GF(q));\n    \n        for i in [d, d-1..1] do\n            for j in [d, d-1..1] do\n                k := RemInt(n, q);\n                n := QuoInt(n, q);\n                if k > 0 then\n                    m[i][j] := z^(k-1);\n                fi;\n            od;\n        od;\n        ConvertToMatrixRep(m, q);\n        return m;\n    end);\n    \n    \n############################################################################\n##\n#F  CanonicalPcgsByNumber(<pcgs>, <n>)\n##\n##  computes the canonical pcgs wrt. pcgs represented by the integer n\n##  \nInstallGlobalFunction(CanonicalPcgsByNumber,\n    function(pcgs, n)\n    \n        local gens, cpcgs;\n        \n        gens := List(ExponentsCanonicalPcgsByNumber(RelativeOrders(pcgs), n), \n            exp -> PcElementByExponents(pcgs, exp));\n        cpcgs := InducedPcgsByPcSequenceNC(pcgs, gens);\n        SetIsCanonicalPcgs(cpcgs, true);\n        return cpcgs;\n    end);\n\n\n############################################################################\n##\n#F  OrderGroupByCanonicalPcgsByNumber(<pcgs>, <n>)\n##\n##  computes Order(Group(CanonicalPcgsByNumber(<pcgs>, <n>))) without \n##  actually constructing the canonical pcgs or the group\n##  \nInstallGlobalFunction(OrderGroupByCanonicalPcgsByNumber,\n    function(pcgs, n)\n    \n        local ros, order, j;\n        \n        order := 1;\n        ros := RelativeOrders(pcgs);\n        n := RemInt(n, 2^Length(ros));\n        for j in [1..Length(ros)] do\n            if RemInt(n, 2) > 0 then\n                order := order * ros[j];\n            fi;\n            n := QuoInt(n, 2);\n        od;\n        return order;\n    end);\n\n\n############################################################################\n##\n#F  ExponentsCanonicalPcgsByNumber(<ros>, <n>)\n##\n##  computes the list of exponent vectors of the \n##  elements of CanonicalPcgsByNumber(<pcgs>, <n>)) without actually\n##  constructing the canonical pcgs itself - it is enough to know the \n##  relative orders of the pc elements\n##  \nInstallGlobalFunction(ExponentsCanonicalPcgsByNumber,\n    function(ros, n)\n    \n        local depths, len, d, exps, exp, j, cpcgs;\n        depths := [];\n        len := Length(ros);\n        for j in [1..len] do\n            d := RemInt(n, 2);\n            n := QuoInt(n, 2);\n            if d > 0 then\n                Add(depths, j);\n            fi;\n        od;\n    \n        exps := [];\n        for d in depths do\n            exp := ListWithIdenticalEntries(len, 0);\n            exp[d] := 1;\n            for j in [d+1..len] do\n                if not j in depths then\n                    exp[j] := RemInt(n, ros[j]);\n                    n := QuoInt(n, ros[j]);\n                fi;\n            od;\n            Add(exps, exp);\n        od;\n        \n        return exps;\n    end);\n\n\n############################################################################\n##\n#F  IsMatGroupOverFieldFam(famG, famF)\n##\n##  tests whether famG is the collections family of matrices over the field\n##  whose family is famF\n##  \nInstallGlobalFunction(IsMatGroupOverFieldFam, function(famG, famF)\n    return CollectionsFamily(CollectionsFamily(famF)) = famG;\nend);\n\n\n############################################################################\n##\n#V  IRREDSOL_DATA.PRIME_POWERS\n##\n##  cache of proper prime powers, preset to all prime powers <= 65535\n##  \nIRREDSOL_DATA.PRIME_POWERS := \n[ 4, 8, 9, 16, 25, 27, 32, 49, 64, 81, 121, 125, 128, 169, 243, 256, 289, \n  343, 361, 512, 529, 625, 729, 841, 961, 1024, 1331, 1369, 1681, 1849, 2048, \n  2187, 2197, 2209, 2401, 2809, 3125, 3481, 3721, 4096, 4489, 4913, 5041, \n  5329, 6241, 6561, 6859, 6889, 7921, 8192, 9409, 10201, 10609, 11449, 11881, \n  12167, 12769, 14641, 15625, 16129, 16384, 16807, 17161, 18769, 19321, \n  19683, 22201, 22801, 24389, 24649, 26569, 27889, 28561, 29791, 29929, \n  32041, 32761, 32768, 36481, 37249, 38809, 39601, 44521, 49729, 50653, \n  51529, 52441, 54289, 57121, 58081, 59049, 63001 ];\n\n\n############################################################################\n##\n#F  IsPPowerInt(q)\n##\n##  tests whether q is a positive prime power, caching new prime powers\n##  \nInstallGlobalFunction(IsPPowerInt, \n    function(q)\n        if not IsPosInt(q) then\n            return false;\n        elif IsPrimeInt(q) then\n            return true;\n        elif q in IRREDSOL_DATA.PRIME_POWERS then\n            return true;\n        elif IsPrimePowerInt(q) then\n            AddSet(IRREDSOL_DATA.PRIME_POWERS, q);\n            return true;\n        else\n            return false;\n        fi;\n    end);\n\n\n############################################################################\n##\n#E\n##\n", "meta": {"hexsha": "30a70ee58db2cc06b22db7e66f75043eefb5cb96", "size": 6862, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/util.gi", "max_stars_repo_name": "fingolfin/irredsol", "max_stars_repo_head_hexsha": "c7ab06f5123650049142a5ae3a1c1e05a38d2151", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-09-01T16:53:11.000Z", "max_stars_repo_stars_event_max_datetime": "2017-09-01T16:53:11.000Z", "max_issues_repo_path": "lib/util.gi", "max_issues_repo_name": "fingolfin/irredsol", "max_issues_repo_head_hexsha": "c7ab06f5123650049142a5ae3a1c1e05a38d2151", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2017-08-02T16:19:58.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-01T08:57:23.000Z", "max_forks_repo_path": "lib/util.gi", "max_forks_repo_name": "fingolfin/irredsol", "max_forks_repo_head_hexsha": "c7ab06f5123650049142a5ae3a1c1e05a38d2151", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-02-17T18:26:09.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-02T10:40:35.000Z", "avg_line_length": 29.7056277056, "max_line_length": 116, "alphanum_fraction": 0.4609443311, "num_tokens": 1995, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.63341027751814, "lm_q1q2_score": 0.4799947360812717}}
{"text": "#############################################################################\n##\n#W  smlinfo.gi               GAP group library             Hans Ulrich Besche\n##                                               Bettina Eick, Eamonn O'Brien\n##\n##  This file contains the ...\n##\n\n#############################################################################\n##\n#F  SMALL_GROUPS_INFORMATION\n##\n##  ...\nSMALL_GROUPS_INFORMATION := [ ];\n\n#############################################################################\n##\n#F  SmallGroupsInformation( size )\n##\n##  ...\nInstallGlobalFunction( SmallGroupsInformation, function( size )\n    local smav, idav, num, lib, t;\n\n    if not IsPosInt(size) then\n      ErrorNoReturn(\"usage: SmallGroupsInformation( size )\"); \n    fi;\n\n    smav := SMALL_AVAILABLE( size );\n    idav := ID_AVAILABLE( size );\n\n    if size = 1024 then\n        Print( \"The groups of size 1024 are not available. \\n\");\n        return;\n    fi;\n\n    if smav = fail then\n        Print( \"The groups of size \", size, \" are not available. \\n\");\n        return;\n    fi; \n\n    lib := 1;\n    if IsBound( smav.lib ) then\n        lib := smav.lib;\n    fi;\n    \n    if IsBound( smav.number ) then\n        num := smav.number;\n    else\n        num := NUMBER_SMALL_GROUPS_FUNCS[ smav.func ]( size, smav ).number;\n    fi;\n    if num = 1 then \n        Print(\"\\n  There is 1 group of order \",size,\".\\n\");\n    else\n        Print(\"\\n  There are \",num,\" groups of order \",size,\".\\n\" );\n    fi;\n \n    SMALL_GROUPS_INFORMATION[ smav.func ]( size, smav, num );\n\n    Print(\"\\n  This size belongs to layer \",lib,\n          \" of the SmallGroups library. \\n\");\n\n    if idav <> fail then \n        Print(\"  IdSmallGroup is available for this size. \\n \\n\");\n    else        \n        Print(\"  IdSmallGroup is not available for this size. \\n \\n\");\n    fi;\nend );\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 1 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 1 ] := function( size, smav, num )\n    Print(\"\\n\");\n    Print(\"  The groups whose order factorises in at most 3 primes \\n\");\n    Print(\"  have been classified by O. Hoelder. This classification is \\n\");\n    Print(\"  used in the SmallGroups library. \\n\");\nend;\n\nSMALL_GROUPS_INFORMATION[ 2 ] := SMALL_GROUPS_INFORMATION[ 1 ];\nSMALL_GROUPS_INFORMATION[ 3 ] := SMALL_GROUPS_INFORMATION[ 1 ];\nSMALL_GROUPS_INFORMATION[ 4 ] := SMALL_GROUPS_INFORMATION[ 1 ];\nSMALL_GROUPS_INFORMATION[ 5 ] := SMALL_GROUPS_INFORMATION[ 1 ];\nSMALL_GROUPS_INFORMATION[ 6 ] := SMALL_GROUPS_INFORMATION[ 1 ];\nSMALL_GROUPS_INFORMATION[ 7 ] := SMALL_GROUPS_INFORMATION[ 1 ];\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 8 .. 10 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 8 ] := function( size, smav, num )\n    local ffid, prop, i, l;\n\n    ffid := IdGroup( OneSmallGroup( size, FrattinifactorSize, size ) );\n    prop := PROPERTIES_SMALL_GROUPS[ size ].frattFacs;\n\n    if not IsPrimePowerInt( size ) then\n        Print(\"  They are sorted by their Frattini factors. \\n\");\n        i := 1;\n        if ffid[ 2 ] > 1 then\n            repeat \n                if prop.pos[ i ][ 1 ] = -prop.pos[ i ][ 2 ] then\n                    Print( \"     \", prop.pos[ i ][ 1 ],\n                       \" has Frattini factor \", prop.frattFacs[ i ], \".\\n\"  );\n                else\n                    Print( \"     \", prop.pos[ i ][ 1 ], \" - \",\n                       -prop.pos[ i ][ 2 ], \" have Frattini factor \",\n                       prop.frattFacs[ i ], \".\\n\"  );\n                fi;\n                i := i + 1;\n            until prop.frattFacs[ i ] = ffid;\n        fi;\n        Print(\"     \", ffid[2], \" - \", num, \n              \" have trivial Frattini subgroup.\\n\");\n    else\n        Print(\"  They are sorted by their ranks. \\n\");\n        Print(\"     \", 1, \" is cyclic. \\n\");\n        i := 2;\n        repeat \n            l := Length( Factors( prop.frattFacs[ i ][1] ) );\n            if prop.pos[ i ][ 1 ] = -prop.pos[ i ][ 2 ] then\n                Print( \"     \", prop.pos[ i ][ 1 ], \" has rank \", l, \".\\n\"  );\n            else\n                Print( \"     \", prop.pos[ i ][ 1 ], \" - \",\n                       -prop.pos[ i ][ 2 ], \" have rank \", l, \".\\n\"  );\n            fi;\n            i := i + 1;\n        until prop.frattFacs[ i ] = ffid;\n        Print(\"     \", ffid[2], \" is elementary abelian. \\n\");\n    fi;\n\n    Print( \"\\n  For the selection functions the values of the \",\n           \"following attributes \\n  are precomputed and stored:\\n \");\n    if IsPrimePowerInt( size ) then\n        Print( \"    IsAbelian, PClassPGroup, RankPGroup,\",\n               \" FrattinifactorSize and \\n     FrattinifactorId. \\n\");\n    else\n        Print( \"    IsAbelian, IsNilpotentGroup,\", \n               \" IsSupersolvableGroup, IsSolvableGroup, \\n     LGLength,\",\n               \" FrattinifactorSize and FrattinifactorId. \\n\");\n    fi;\nend;\nSMALL_GROUPS_INFORMATION[ 9 ] := SMALL_GROUPS_INFORMATION[ 8 ];\nSMALL_GROUPS_INFORMATION[ 10 ] := SMALL_GROUPS_INFORMATION[ 8 ];\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 11, 17 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 11 ] := function( size, smav, num )\n    local i, q;\n\n    q := 2;\n    if IsBound( smav.q ) then q := smav.q; fi;\n\n    Print(\"  They are sorted by normal Sylow subgroups. \\n\");\n    Print( \"     1 - \", smav.pos[ 2 ], \" are the nilpotent groups.\\n\" );\n    for i in [ 2 .. Length( smav.types ) ] do\n        Print( \"     \", smav.pos[i] + 1, \" - \", smav.pos[i+1] );\n        if smav.types[ i ] = \"p-autos\" then \n            Print( \" have a normal Sylow \", q,\"-subgroup. \\n\");\n        elif smav.types[ i ] = \"none-p-nil\" then \n            Print( \" have no normal Sylow subgroup. \\n\");\n        elif IsInt( smav.types[ i ] ) then\n            Print( \" have a normal Sylow \", smav.p, \"-subgroup \\n\");\n            Print( \"                     with centralizer of index \");\n            Print( q^smav.types[i],\".\\n\");\n        fi;\n    od;\nend;\nSMALL_GROUPS_INFORMATION[ 17 ] := SMALL_GROUPS_INFORMATION[ 11 ];\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 12 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 12 ] := function( size, smav, num )\n\n    if size = 1152 then\n        Print(\"  They are sorted using Sylow subgroups. \\n\");\n        Print(\"     1 - 2328 are nilpotent with Sylow 3-subgroup c9.\\n\" );\n        Print(\"     2329 - 4656 are nilpotent with Sylow 3-subgroup 3^2.\\n\");\n        Print(\"     4657 - 153312 are non-nilpotent with normal \");\n        Print(\"Sylow 3-subgroup.\\n\");\n        Print(\"     153313 - 157877 have no normal Sylow 3-subgroup.\\n\");\n        return;\n    fi;\n\n    Print(\"  They are sorted using Hall subgroups. \\n\");\n    Print( \"     1 - 2328 are the nilpotent groups.\\n\" );\n    Print( \"     2329 - 236344 have a normal Hall (3,5)-subgroup.\\n\");\n    Print( \"     236345 - 240416 are solvable without normal Hall\",\n           \" (3,5)-subgroup.\\n\");\n    Print( \"     240417 - 241004 are not solvable.\\n\" );\nend;\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 14 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 14 ] := function( size, smav, num )\n\n    Print( \"     1 - 10494213 are the nilpotent groups.\\n\" );\n    Print( \"     10494214 - 408526597 have a normal Sylow 3-subgroup.\\n\" );\n    Print( \"     408526598 - 408544625 have a normal Sylow 2-subgroup.\\n\" );\n    Print( \"     408544626 - 408641062 have no normal Sylow subgroup.\\n\" );\nend;\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 18 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 18 ] := function( size, smav, num )\n\n    Print( \"     1 is cyclic. \\n\");\n    Print( \"     2 - 10 have rank 2 and p-class 3.\\n\" );\n    Print( \"     11 - 386 have rank 2 and p-class 4.\\n\" );\n    Print( \"     387 - 1698 have rank 2 and p-class 5.\\n\" );\n    Print( \"     1699 - 2008 have rank 2 and p-class 6.\\n\" );\n    Print( \"     2009 - 2039 have rank 2 and p-class 7.\\n\" );\n    Print( \"     2040 - 2044 have rank 2 and p-class 8.\\n\" );\n    Print( \"     2045 has rank 3 and p-class 2.\\n\" );\n    Print( \"     2046 - 29398 have rank 3 and p-class 3.\\n\" );\n    Print( \"     29399 - 30617 have rank 3 and p-class 4.\\n\" );\n    Print( \"     30618 - 31239 have rank 3 and p-class 3.\\n\" );\n    Print( \"     31240 - 56685 have rank 3 and p-class 4.\\n\" );\n    Print( \"     56686 - 60615 have rank 3 and p-class 5.\\n\" );\n    Print( \"     60616 - 60894 have rank 3 and p-class 6.\\n\" );\n    Print( \"     60895 - 60903 have rank 3 and p-class 7.\\n\" );\n    Print( \"     60904 - 67612 have rank 4 and \", \"p-class 2.\\n\" );\n    Print( \"     67613 - 387088 have rank 4 and \", \"p-class 3.\\n\" );\n    Print( \"     387089 - 419734 have rank 4 and \", \"p-class 4.\\n\" );\n    Print( \"     419735 - 420500 have rank 4 and \", \"p-class 5.\\n\" );\n    Print( \"     420501 - 420514 have rank 4 and \", \"p-class 6.\\n\" );\n    Print( \"     420515 - 6249623 have rank 5 and \", \"p-class 2.\\n\" );\n    Print( \"     6249624 - 7529606 have rank 5 and \", \"p-class 3.\\n\" );\n    Print( \"     7529607 - 7532374 have rank 5 and \", \"p-class 4.\\n\" );\n    Print( \"     7532375 - 7532392 have rank 5 and \", \"p-class 5.\\n\" );\n    Print( \"     7532393 - 10481221 have rank 6 and \", \"p-class 2.\\n\" );\n    Print( \"     10481222 - 10493038 have rank 6 and \", \"p-class 3.\\n\" );\n    Print( \"     10493039 - 10493061 have rank 6 and \", \"p-class 4.\\n\" );\n    Print( \"     10493062 - 10494173 have rank 7 \", \"and p-class 2.\\n\" );\n    Print( \"     10494174 - 10494200 have rank 7 \", \"and p-class 3.\\n\" );\n    Print( \"     10494201 - 10494212 have rank 8 \", \"and p-class 2.\\n\" );\n    Print( \"     10494213 is elementary abelian.\\n\");\nend;\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 19 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 19 ] := function( size, smav, num )\n\n  Print(\"  They are sorted by their ranks. \\n\");\n  Print( \"     1 is cyclic. \\n\");\n  Print( \"     2 - 10 have rank 2. \\n\");\n  Print( \"     11 - 14 have rank 3. \\n\");\n  Print( \"     15 is elementary abelian. \\n\");\nend;\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 20 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 20 ] := function( size, smav, num )\n    local p, a, b, c;\n\n    p := Factors(size)[1];\n    a:=27 + p   + 2*GcdInt(p-1,3) + GcdInt(p-1,4);\n    b:=54 + 2*p + 2*GcdInt(p-1,3) + GcdInt(p-1,4);\n    c:=60 + 2*p + 2*GcdInt(p-1,3) + GcdInt(p-1,4);\n\n    Print( \"  They are sorted by their ranks.\\n\" );\n    Print( \"     1 is cyclic.\\n\");\n    Print( \"     2 - \",a,\" have rank 2. \\n\");\n    Print( \"     \",a+1,\" - \",b,\" have rank 3. \\n\");\n    Print( \"     \",b+1,\" - \",c,\" have rank 4. \\n\");\n    Print( \"     \",c+1,\" is elementary abelian. \\n\");\nend;\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 21 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 21 ] := function( size, smav, num )\n\n   Print( \" \\n\");\n   Print( \"      Easterfield (1940) constructed a list of the groups of\\n\");\n   Print( \"      order p^6 for p >= 5.\\n \\n\");\n\n   Print( \"      The database of parametrised presentations for the groups \\n\");\n   Print( \"      with order p^6 for p >= 5 is based on the Easterfield \\n\");\n   Print( \"      list, corrected by Newman, O'Brien and Vaughan-Lee (2004).\\n\");\n   Print( \"      It differs only in the addition of groups in isoclinism \\n\"); \n   Print( \"      family $\\\\Phi_{13}$, in using the James (1980) presentations \\n\");\n   Print( \"      for the groups in $\\\\Phi_{19}$, and a small number of \\n\");\n   Print( \"      typographical amendments. The linear ordering employed is \\n\");\n   Print( \"      very close to that of Easterfield. \\n \\n\");\n\n   Print( \"      Each group with order $p^6$ is described by a power- \\n\");\n   Print( \"      commutator presentation on 6 generators and 21 relations:\\n\");\n   Print( \"      15 are commutator relations and 6 are power relations. \\n\");\n   Print( \"      Each presentation has the prime $p$ as a parameter. \\n\");\n   Print( \"      The database contains about 500 parametrised \\n\");\n   Print( \"      presentations, most of these have $p$ as the only \\n\");\n   Print( \"      parameter. \\n\");\n\nend;\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 24 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 24 ] := function( size, smav, num )\n    local i, set, c;\n\n    Print( \"\\n\" );\n    Print( \"  The groups of squarefree order have a cylic socle and a \" );\n    Print( \"cylic socle factor.\\n\" );\n\n    Print( \"\\n\" );\n    i := 0;\n    for set in smav.sets do\n        c := Product( smav.primes{ set.kp } );\n        if c = 1 then\n            Print( \"    1 is abelian\\n\" );\n        elif set.number = 1 then\n            Print( \"    \", i + 1, \" has socle C_\" );\n            Print( size / c, \" and factor C_\", c, \"\\n\" );\n        else\n            Print( \"    \", i + 1, \" - \", i + set.number, \" have socle C_\" );\n            Print( size / c, \" and factor C_\", c, \"\\n\" );\n        fi;\n        i := i + set.number;\n    od;\nend;\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 25 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 25 ] := function( size, smav, num )\n    local i, set, c;\n    Print( \"\\n\" );\n    Print( \"  The groups of cubefree order are either solvable or a direct \",\n           \"product of \\n  the form PSL( 2, p ) x solvable group. \",\n           \"The cubefree solvable groups are \\n  determined by their Frattini\",\n           \" factor.\\n\\n\" );\n\n    i := 0;\n    for set in smav.sets do\n      if set.psl_p = 1 then\n        if set.size_phi = 1 then\n          if set.number = 1 then\n            Print( \"    \", i + 1, \" is solvable and Frattini free\\n\" );\n          else\n            Print( \"    \", i + 1, \" - \", i + set.number, \" are solvable \",\n                   \"and Frattini free\\n\" );\n          fi;\n        else\n          if set.number = 1 then\n            Print( \"    \", i + 1, \" is solvable with Frattini factor of \",\n                   \"size \", set.size_ff, \"\\n\" );\n          else\n            Print( \"    \", i + 1, \" - \", i + set.number, \" are solvable \",\n                   \"with Frattini factor of size \", set.size_ff, \"\\n\" );\n          fi;\n        fi;\n      elif\n        set.size_ff = 1 then\n          Print( \"    \", i + 1, \" is PSL( 2, \", set.psl_p, \" )\\n\" );\n      else\n        if set.size_phi = 1 then\n          if set.number = 1 then\n            Print( \"    \", i + 1, \" is PSL( 2, \", set.psl_p, \" ) x F, F \",\n                   \"solvable and Frattini free of order \", set.size_ff, \"\\n\");\n          else\n            Print( \"    \", i + 1, \" - \", i + set.number, \" are PSL( 2, \",\n                   set.psl_p, \" ) x F_i, F_i solvable \",\n                   \"Frattini free of order \", set.size_ff, \"\\n\" );\n          fi;\n        else\n          if set.number = 1 then\n            Print( \"    \", i + 1, \" is PSL( 2, \", set.psl_p, \" ) x G, G \",\n                   \"solvable of order \", set.size_ff * set.size_phi,\n                   \" with a Frattini factor\\n      of order \", set.size_ff,\n                   \"\\n\");\n          else\n            Print( \"    \", i + 1, \" - \", i + set.number, \" are PSL( 2, \",\n                   set.psl_p, \" ) x G_i, G_i \", \"solvable of order \",\n                   set.size_ff * set.size_phi, \" with a\",\n                   \"\\n      Frattini factor of order \", set.size_ff, \"\\n\");\n          fi;\n        fi;\n      fi;\n      i := i + set.number;\n    od;\nend;\n\n#############################################################################\n##\n#F SMALL_GROUPS_INFORMATION[ 26 ]( size, smav, num )\n##\nSMALL_GROUPS_INFORMATION[ 26 ] := function( size, smav, num )\n\n   Print( \" \\n\");\n   Print( \"      E.A. O'Brien and M.R. Vaughan-Lee determined presentations\\n\");\n   Print( \"      of the groups with order p^7. A preprint of their paper is\\n\");\n   Print( \"      available at\\n\" );\n   Print( \"      http://www.math.auckland.ac.nz/%7Eobrien/research/p7/paper-p7.pdf\\n\\n\" ); \n   Print( \"      For p in { 3, 5, 7, 11 } explicit lists of groups of order\\n\");\n   Print( \"      p^7 have been produced and stored into the database.\\n\\n\");\n   Print( \"      Giving the power commutator presentations of any of these\\n\");\n   Print( \"      groups using a standard notation they might be reduced to 35\\n\");\n   Print( \"      elements of the group or a 245 p-digit number.\\n\\n\");\n   Print( \"      Only 56 of these digits may be unlike 0 for any group and\\n\");\n   Print( \"      even these 56 digits are mostly like 0. Further on these\\n\");\n   Print( \"      digits are often quite likely for sequences of subsequent\\n\");\n   Print( \"      groups. Thus storage of groups was done by finding a so\\n\");\n   Print( \"      called head group and a so called tail. Along the tail\\n\");\n   Print( \"      only the different digits compared to the head are relevant.\\n\");\n   Print( \"      Even the tails occur more or less often and this is used\\n\");\n   Print( \"      to improve storage too. Since p^7 is too big the data is\\n\");\n   Print( \"      stored into some remaing holes of SMALL_GROUP_LIB at\\n\");\n   Print( \"      Primes[ p + 10 ].\\n\");\n\nend;\n\n", "meta": {"hexsha": "7ccc5ce9a8e8e1a422de36e15fea0ed8f5aa65c4", "size": 17407, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "gap/smlinfo.gi", "max_stars_repo_name": "hulpke/smallgrp", "max_stars_repo_head_hexsha": "b9664dbac0b9e8f8ad044b7c143cde17cff16a38", "max_stars_repo_licenses": ["Artistic-2.0"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2017-09-01T16:51:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-05T06:09:37.000Z", "max_issues_repo_path": "gap/smlinfo.gi", "max_issues_repo_name": "hulpke/smallgrp", "max_issues_repo_head_hexsha": "b9664dbac0b9e8f8ad044b7c143cde17cff16a38", "max_issues_repo_licenses": ["Artistic-2.0"], "max_issues_count": 50, "max_issues_repo_issues_event_min_datetime": "2016-08-01T12:41:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T00:10:22.000Z", "max_forks_repo_path": "gap/smlinfo.gi", "max_forks_repo_name": "gap-packages/smallgrp", "max_forks_repo_head_hexsha": "12d8f1f6075ebb1cfc2d148cc512e73852cee20b", "max_forks_repo_licenses": ["Artistic-2.0"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2017-09-04T08:13:00.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-26T14:10:43.000Z", "avg_line_length": 40.5757575758, "max_line_length": 91, "alphanum_fraction": 0.5043373356, "num_tokens": 5060, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6757646075489391, "lm_q1q2_score": 0.47913003668697224}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nnz := x->When(x=0,0,1);\nps := x -> PrintMat(MapMat(x,nz));\ncrdiag := rr -> List([1..DimensionsMat(rr)[1]/2], \n    i->rr[2*i-1][2*i-1] + E(4)*rr[2*i][2*i-1]);\n\nsubmat := (m, rbegin, colbegin, size) -> List(m{[rbegin..rbegin+size-1]}, x->x{[colbegin..colbegin+size-1]});\n\nN := 8;\nm := 4;\nn := N/m;\n\nBIGNT := PRDFT4; \nRIGHTNT := PRDFT4;\nLEFTNT := BIGNT;\n\n# DTT -> K^N_m (dirsum SkewDTT(m)) (DST3(n) tensor I(m)) B^N_m\nck := MatSPL(K(N,m));\ncm := ck^-1;\nrk := RCMatCyc(ck);\nrm := RCMatCyc(cm);\n\nbig := MatSPL(BIGNT(2*N));\nlhs := Tensor(I(n), LEFTNT(2*m));\nrhs := Tensor(RIGHTNT(n), I(2*m));\nquo := MatSPL(lhs)^-1 * rm * big;  #pquo := quo ^ MatSPL(L(2*N, n)); squo := MapMat(pquo, nz);\nrb := quo * MatSPL(rhs)^-1;\n\n# N=2, m=2, n=4\n#prb := (MatSPL(L(16,2)*Tensor(M(8,4),I(2)))*rb*MatSPL(L(16,8)));\n\n#TensorProductMat(IdentityMat(2*m), MatSPL(IPRDFT2(n,-1)*Diag(2,2,1,1)));\n#PRDFT3(n))^-1);\n#IPRDFT2(n,-1)*Diag(2,2,1,1)));\n\n#pquo := quo ^ MatSPL(L(2*N, 2*n));\n#blocks := List([1..m], x -> pquo{[1+2*n*(x-1) .. 2*n*x]}{[1+2*n*(x-1) .. 2*n*x]});\n\n#brfinv := MatSPL(PRDFT3(2*n))^-1;\n#rdiag := List(blocks, b -> b * brfinv);\n#cdiag := List(rdiag, crdiag);\n#diag := MatSPL(L(2*N, m)) * quo * MatSPL(L(2*N, 2*n)) * TensorProductMat(IdentityMat(m), brfinv); \n", "meta": {"hexsha": "554fa7bdae0027d8ba66d64ffc834c75ef7070dd", "size": 1329, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sym/unproj.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/unproj.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/unproj.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.2765957447, "max_line_length": 109, "alphanum_fraction": 0.5628291949, "num_tokens": 605, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375735, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.47868872823094766}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# !!!! what's missing: CRT of 2 primes perm pullout\n\nRewriteRules(RulesFuncSimp, rec(\n # ===================================================================\n # OddStride\n # ===================================================================\n OS_Id := Rule([OS, @N, 1], e->fId(@N.val)),\n\n OS_OS := ARule(fCompose, [[OS, @N, @r], [OS, @, @s]],\n     e -> [ OS(@N.val, @r.val * @s.val mod @N.val) ]),\n\n OS_RR_PhaseShift := ARule( fCompose, [[OS, @N, @r], [RR, @, @phi, @g]],\n     e -> [ RR(@N.val, @phi.val * @r.val, @g.val) ]),\n\n OS_RM_PhaseShift := ARule( fCompose, [[OS, @N, @r], [RM, @, @phi, @g]],\n     e -> [ RM(@N.val, @phi.val * @r.val, @g.val) ]),\n\n # ===================================================================\n # Cyclic shift (Z) propagation\n # Z o (fBase X f)  ->  (Z o f) X (Z o fBase)\n Z_Propagate := ARule(fCompose, [[Z, @, @z], [fTensor, @F, [fBase, @m, @j]]],\n     (e, cx) -> [ fTensor(\n       fCompose(Z(range(@F.val), memo(cx, \"g\", idiv(@j.val+@z.val, @m.val))), @F.val),\n       fCompose(Z(@m.val, @z.val), fBase(@m.val, @j.val))) ]),\n\n # ===================================================================\n # CRT / gammaTensor\n # ===================================================================\n#   NOTE: This rule triggers problems when fired too early, as gammatensor cannot be transposed -- what to do??\n# CRT_toGammaTensor := Rule(CRT, e->e.toGammaTensor()),\n\n GammaTensorAssoc := ARule(gammaTensor, [@(1,gammaTensor)], e->@(1).val.children()),\n\n # gammaTensor o fTensor -> gammaTensor( ... o ..., ... o ... , ...)\n GammaTensorMerge := ARule(fCompose,\n      [ @(1,gammaTensor), @(2,fTensor,e->compat_tensor_chains(\n                         @(1).val.children(), e.children(), domain, range)) ],\n e -> [ gammaTensor(merge_tensor_chains(\n       @(1).val.children(), @(2).val.children(), fCompose, x->x, x->x, domain, range))]),\n\n ### fTensor(..., Y, ...) o X -> fTensor(..., Y o X, ...)\n GammaTensorComposeMergeRight := ARule(fCompose,\n      [ @(1,gammaTensor), @(2).cond(e->compat_tensor_chains(\n                         @(1).val.children(), [e], domain, range)) ],\n e -> [ gammaTensor(merge_tensor_chains(\n       @(1).val.children(), [@(2).val], fCompose, x->x, x->x, domain, range)) ] ),\n\n ### X o fTensor(..., Y, ...) -> fTensor(..., X o Y, ...)\n GammaTensorComposeMergeLeft := ARule(fCompose,\n      [ @(1), @(2,gammaTensor,e->compat_tensor_chains(\n                         [@(1).val], e.children(), domain, range)) ],\n e -> [ gammaTensor(merge_tensor_chains(\n       [@(1).val], @(2).val.children(), fCompose, x->x, x->x, domain, range)) ] ),\n\n # ===================================================================\n # Rader permutations\n # ===================================================================\n # NB: RR = fStack(1,RM), RR plugged into gammaTensor, eg. F_15 -> F_3, F_5\n\n # RR o fAdd(N,1,0) -> (0)_N\n RR_1stPoint_fAdd := ARule(fCompose, [[RR, @N, @phi, @g], [fAdd, @, 1, 0]],\n     e -> [ H(@N.val, 1, 0, 1) ]),\n RR_1stPoint_H := ARule(fCompose, [[RR, @N, @phi, @g], [H, @, 1, 0, @]],\n     e -> [ H(@N.val, 1, 0, 1) ]),\n\n # RR o fAdd(N,N-1,1) -> RM\n RR_toRM_fAdd := ARule(fCompose,  [[RR, @N, @phi, @g], [fAdd, @, @(1).cond(e->e=@N.val-1), 1]],\n     e -> [ RM(@N.val, @N.val-1, @phi.val, @g.val) ]),\n RR_toRM_H := ARule(fCompose,  [[RR, @N, @phi, @g], [H, @, @(1).cond(e->e=@N.val-1), 1, 1]],\n     e -> [ RM(@N.val, @N.val-1, @phi.val, @g.val) ])\n));\n\nClass(RulesRaderTensor, RuleSet);\n\nRewriteRules(RulesRaderTensor, rec(\n # RM o fTensor -> RM\n RM_Tensor1 := ARule(fCompose, [ [RM,@N,@n,@phi,@g], [fTensor, @(1,fId), [fBase,@m,@j]] ],\n     (e, cx) -> [ RM(@N.val, domain(@1.val),\n           memo(cx, \"g\", powmod(@phi.val,@g.val,@j.val,@N.val)),\n           powmod(1,@g.val,@m.val,@N.val).eval()) ] ),\n\n RM_Tensor2 := ARule(fCompose, [ [RM,@N,@n,@phi,@g], [fTensor, [fBase,@m,@j], @(1,fId)] ],\n     (e, cx) -> [ RM(@N.val, domain(@1.val),\n           memo(cx, \"g\", powmod(@phi.val, powmod(1,@g.val,@m.val,@N.val).eval(), @j.val, @N.val)),\n           @g.val) ])\n));\n", "meta": {"hexsha": "41d46c22c98c371802e2573661ec15ff93ed692a", "size": 4091, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sigma/modp_rules.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/sigma/modp_rules.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/sigma/modp_rules.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 44.4673913043, "max_line_length": 111, "alphanum_fraction": 0.4688340259, "num_tokens": 1336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.478107698356493}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#D TPrm.getTags := self >> GetTags(self);\n#D TPrm.firstTag := self >> let(tags := GetTags(self), When(tags=[], ANoTag, tags[1]));\n#D TPrm.withTags := (self, tags) >> AddTag(self, tags);\n\n# Breakdowns for vectorized TPrm( IJ )\n#\nNewRulesFor(TPrm, rec(\n    # IP(N, any perm of size 1) -> I(N)\n    TPrm_IP_Base1 := rec(\n        applicable := (self,t) >> t.hasTags() and let(v := t.firstTag().v, p := t.params[1],\n            ObjId(p) = IP and Rows(p.params[2]) = 1),\n\n        apply := (self, t, C, Nonterms) >> I(Rows(t))\n    ),\n\n    TPrm_IJ_Vec := rec(\n        requiredFirstTag := AVecReg,\n        applicable := (self,t) >> t.hasTags() and let(v := t.firstTag().v, p := t.params[1],\n            ObjId(p) = IP and ObjId(p.params[2]) = J and\n            (Rows(p.params[2]) mod v) = 0\n        ),\n\n        children := (self, t) >> let(tags := t.getTags(), v := tags[1].v,\n            [[ TPrm(J(v)).withTags(tags) ]]),\n\n        apply := (self, t, C, Nonterms) >> let(\n            v := t.firstTag().v,\n            N := Rows(t),\n            m := Rows(t.params[1].params[2]),\n            k := N/m,\n            j := Ind(N/v),\n\n# NOTE: Pulling in breaks for vector code due to some missing comutative rule to pull it all over PushLR() -> VContainer() for now\n            VContainer(IDirSum(j,\n                COND(fCompose(diagTensor(II(k/2), II(2,0,1), II(m/v)), fBase(j)),\n                    VTensor(Prm(fId(1)), v), C[1])) *\n                    VTensor(Prm(condIJ(N/v, m/v)), v), t.firstTag().isa)\n        )\n    ),\n    TPrm_format := rec(\n        applicable := (self,t) >> t.hasTags() and t.hasTag(AVecReg),\n        apply := (self, t, C, Nonterms) >> FormatPrm(t.params[1])\n    )\n));\n\n\n# Breakdowns for vectorized TPrm( J )\n#\nNewRulesFor(TPrm, rec(\n    TPrm_J := rec(\n        requiredFirstTag := AVecReg,\n\n        applicable := (self,t) >> t.hasTags() and let(p := t.params[1], v := t.firstTag().v, s := Rows(p),\n            ObjId(p) = J and IsInt(s/v) and s<>v),\n\n        children := (self, t) >> let(tags := t.getTags(), v := t.firstTag().v,\n            [[ TPrm(J(v)).withTags(tags) ]]),\n\n        apply := (self, t, C, Nonterms) >> let(v:=t.firstTag().v, s:=t.params[1].params[1], s2:=s/v,\n                                    VTensor(J(s2), v) * Tensor(I(s2), C[1]))\n    ),\n\n    TPrm_Jv := rec(\n        requiredFirstTag := AVecReg,\n\n        applicable := (self,t) >> t.hasTags() and let(p := t.params[1], v := t.firstTag().v,\n            ObjId(p) = J and Rows(p) = v),\n\n        apply := (self, t, C, Nonterms) >> let(\n            v := t.firstTag().v, isa := t.firstTag().isa,\n            VPerm(J(v), isa.reverse, v, 0))\n    ),\n));\n", "meta": {"hexsha": "35f29d6cc8e0d57b90161210ba6e535ae66703a2", "size": 2708, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/vector/breakdown/sigmaspl.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/vector/breakdown/sigmaspl.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/vector/breakdown/sigmaspl.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 34.2784810127, "max_line_length": 130, "alphanum_fraction": 0.5022156573, "num_tokens": 855, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956580903722561, "lm_q2_score": 0.6001883592602049, "lm_q1q2_score": 0.4775447237926322}}
{"text": "\nlocal reps,tori,labels,I,II,ords,blocks;\n\nreps:=[[[1,1],[2,1],[3,1],[4,1],[5,1],[6,1]],        # E_6\n       [[3,1],[5,1],[1,1],[6,1],[9,1],[10,1],[2,1]], # E_6(a_1)\n       [[1,1],[3,1],[4,1],[2,1],[5,1]],              # D_5\n       [[13,1],[1,1],[15,1],[6,1],[14,1],[4,1]],     # E_6(a_3)\n       [[1,1],[3,1],[8,1],[10,1],[2,1],[5,1]],       # D_5(a_1)\n       [[1,1],[3,1],[4,1],[5,1],[6,1]],              # A_5\n       [[1,1],[3,1],[4,1],[2,1],[6,1]],              # A_4A_1\n       [[3,1],[4,1],[2,1],[5,1]],                    # D_4\n       [[1,1],[3,1],[4,1],[2,1]],                    # A_4\n       [[3,1],[8,1],[10,1],[2,1],[5,1]],             # D_4(a_1)\n       [[1,1],[3,1],[4,1],[6,1]],                    # A_3A_1\n       [[1,1],[3,1],[5,1],[6,1],[2,1]],              # A_2^2A_1\n       [[1,1],[3,1],[4,1]],                          # A_3\n       [[2,1],[4,1],[1,1],[6,1]],                    # A_2A_1^2\n       [[1,1],[3,1],[5,1],[6,1]],                    # A_2^2\n       [[1,1],[3,1],[2,1]],                          # A_2A_1\n       [[1,1],[3,1]],                                # A_2\n       [[1,1],[4,1],[6,1]],                          # A_1^3\n       [[1,1],[6,1]],                                # A_1^2\n       [[1,1]]                                       # A_1\n       ];\n\nI:=[[],[4],[],[2,3,5],[4],[],[],[],[],[4],\n    [],[],[],[],[],[],[],[],[],[]];\n\n#\n# The parabolic where the representative is distinguished\n#\nII:=[[1,2,3,4,5,6],\n     [1,2,3,4,5,6],\n     [1,2,3,4,5],\n     [1,2,3,4,5,6],\n     [1,2,3,4,5],\n     [1,3,4,5,6],\n     [1,2,3,4,6],\n     [2,3,4,5],\n     [1,2,3,4],\n     [2,3,4,5],\n     [1,3,4,6],\n     [1,2,3,5,6],\n     [1,3,4],\n     [1,2,4,6],\n     [1,3,5,6],\n     [1,2,3],\n     [1,3],\n     [1,4,6],\n     [1,6],\n     [1]];\n\nlabels:=[\"E_6\",\n         \"E_6(a_1)\",\n         \"D_5\",\n         \"E_6(a_3)\",\n         \"D_5(a_1)\",\n         \"A_5\",\n         \"A_4A_1\",\n         \"D_4\",\n         \"A_4\",\n         \"D_4(a_1)\",\n         \"A_3A_1\",\n         \"A_2^2A_1\",\n         \"A_3\",\n         \"A_2A_1^2\",\n         \"A_2^2\",\n         \"A_2A_1\",\n         \"A_2\",\n         \"A_1^3\",\n         \"A_1^2\",\n         \"A_1\"];\n\ntori:=[\n    [2,2,2,2,2,2],\n    [2,2,2,0,2,2],\n    [2,2,2,2,2,-10],\n    [2,0,0,2,0,2],\n    [2,2,2,0,2,-7],\n    [2,-9,2,2,2,2],\n    [2,2,2,2,-7,2],\n    [-6,2,2,2,2,-6],\n    [2,2,2,2,-6,0],\n    [-4,2,2,0,2,-4],\n    [2,-3,2,2,-4,2],\n    [2,2,2,-5,2,2],\n    [2,-3,2,2,-3,0],\n    [2,2,-3,2,-3,2],\n    [2,0,2,-4,2,2],\n    [2,2,2,-3,0,0],\n    [2,0,2,-2,0,0],\n    [2,-1,-2,2,-2,2],\n    [2,0,-1,0,-1,2],\n    [2,0,-1,0,0,0]\n    ];\n\n#blocks:=[];\nblocks:=[[[19, 1], [15, 2], [9, 3], [2, 1]], [[9, 8], [6, 1]], [[9, 7], [7, 2], [1, 1]], [[9, 4], [7, 1], [6, 4], [3, 3], [2, 1]], [[9, 3], [8, 2], [6, 4], [3, 2], [2, 2], [1, 1]], [[9, 3], [8, 2], [6, 4], [3, 2], [2, 1], [1, 3]], [[9, 1], [8, 2], [7, 1], [6, 2], [5, 3], [3, 6], [1, 1]], [[9, 2], [7, 7], [3, 1], [1, 8]], [[9, 1], [7, 5], [5, 3], [3, 5], [1, 4]], [[7, 1], [6, 2], [5, 6], [3, 9], [1, 2]], [[7, 1], [6, 2], [5, 3], [4, 6], [3, 4], [2, 2], [1, 4]], [[3, 24], [2, 3]], [[7, 1], [5, 5], [4, 8], [3, 1], [1, 11]], [[3, 23], [2, 4], [1, 1]], [[3, 23], [2, 1], [1, 7]], [[3, 22], [2, 2], [1, 8]], [[3, 21], [1, 15]], [[3, 13], [2, 14], [1, 11]], [[3, 8], [2, 16], [1, 22]], [[3, 1], [2, 20], [1, 35]]];\n\n#ords:=[];\nords:=[ 27, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 9, 3, 3, 3, 3, 3, 3, 3 ];\n\nreturn [reps,tori,labels,I,II,ords,blocks];\n", "meta": {"hexsha": "7297a9edb001f47a68a7ee08cb9d0c3cbfc269e4", "size": 3388, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/data/dataE6char3.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/dataE6char3.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/dataE6char3.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": 32.5769230769, "max_line_length": 713, "alphanum_fraction": 0.2703659976, "num_tokens": 1826, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321983146848, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.47747129578868713}}
{"text": "Flat([[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []]);\n", "meta": {"hexsha": "ec0f219e77bd77a0a8af74a9bf47d9557a970912", "size": 55, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Flatten-a-list/GAP/flatten-a-list.gap", "max_stars_repo_name": "mullikine/RosettaCodeData", "max_stars_repo_head_hexsha": "4f0027c6ce83daa36118ee8b67915a13cd23ab67", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Flatten-a-list/GAP/flatten-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/Flatten-a-list/GAP/flatten-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": 27.5, "max_line_length": 54, "alphanum_fraction": 0.2181818182, "num_tokens": 30, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.4774420005545171}}
{"text": "# Default function for dual points.\nBindGlobal(\"DefaultDualityFunction\", x -> x);\n\n# Default function for primal points.\nBindGlobal(\"DefaultPrimalityFunction\", x -> Intersection(x)[1]);\n\n# Duality function for bipartite doubles.\nBindGlobal(\"BipartiteDoubleDualityFunction\",\n    f -> x -> [x[1][1], f(List(x, y -> y[2]))]\n);\n\n# Duality function for Grassmann graphs.\nBindGlobal(\"GrassmannDualityFunction\", function(x)\n    local y;\n    y := Intersection(x);\n    if Dimension(y) = 0 then\n        return Sum(x);\n    else\n        return y;\n    fi;\nend);\n\n# Check whether function for dual and primal points exist,\n# and add them if they do not.\nBindGlobal(\"CheckDualityFunctions\", function(G)\n    if not \"duality\" in RecNames(G) then\n        G.duality := DefaultDualityFunction;\n    fi;\n    if not \"primality\" in RecNames(G) then\n        G.primality := DefaultPrimalityFunction;\n    fi;\nend);\n", "meta": {"hexsha": "68c2ac02021ec6fc7abdd4b832bb16df7ef02ad5", "size": 888, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/DualityFunctions.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/DualityFunctions.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/DualityFunctions.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": 26.9090909091, "max_line_length": 64, "alphanum_fraction": 0.6790540541, "num_tokens": 234, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4772031015592248}}
{"text": "run := function()\n  local a, b, f;\n  f := InputTextUser();\n  Print(\"a =\\n\");\n  a := Int(Chomp(ReadLine(f)));\n  Print(\"b =\\n\");\n  b := Int(Chomp(ReadLine(f)));\n  Display(Concatenation(String(a), \" + \", String(b), \" = \", String(a + b)));\n  Display(Concatenation(String(a), \" - \", String(b), \" = \", String(a - b)));\n  Display(Concatenation(String(a), \" * \", String(b), \" = \", String(a * b)));\n  Display(Concatenation(String(a), \" / \", String(b), \" = \", String(QuoInt(a, b)))); # toward 0\n  Display(Concatenation(String(a), \" mod \", String(b), \" = \", String(RemInt(a, b)))); # nonnegative\n  Display(Concatenation(String(a), \" ^ \", String(b), \" = \", String(a ^ b)));\n  CloseStream(f);\nend;\n", "meta": {"hexsha": "03b9f4a2d579f16a5e773d9063ed6bbfe8523381", "size": 685, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Arithmetic-Integer/GAP/arithmetic-integer.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Arithmetic-Integer/GAP/arithmetic-integer.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Arithmetic-Integer/GAP/arithmetic-integer.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 42.8125, "max_line_length": 99, "alphanum_fraction": 0.5591240876, "num_tokens": 222, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.47606505115406555}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n_setN := function(o) o.params[2].nested := true; return o; end;\n\n#F Filt(<n>, <taps>, <v>, <ds>) - FIR filter (linear convolution)\n#F\n#F Filt is a non-terminal for a linear convolution matrix optionallly\n#F downsampled by a factor of <ds>.\n#F\n#F For ds=1, it is a (n x n+l-1) matrix,  where l is the number of filter\n#F coefficients in <taps>.\n#F\n#F For ds<>1, it is a (n x ds*(n-1)+l) matrix.\n#F\n#F <n>    - number of outputs desired\n#F <taps> -  list of filter taps or a polynomial transfer function\n#F <v>    - valuation, optional, but used when <taps> is not a polynomial\n#F <ds>   - downsampling factor\n#F\n#F Examples: Filt(5, [1, 2, 3, 4, 5]) corresponds to the matrix\n#F             [ [1, 2, 3, 4, 5, 0, 0, 0, 0]\n#F               [0, 1, 2, 3, 4, 5, 0, 0, 0]\n#F               [0, 0, 1, 2, 3, 4, 5, 0, 0]\n#F               [0, 0, 0, 1, 2, 3, 4, 5, 0]\n#F               [0, 0, 0, 0, 1, 2, 3, 4, 5] ]\n#F\n#F           Filt(3, [1, 2, 3], -2, 2) corresponds to the matrix\n#F             [ [1, 2, 3, 0, 0, 0, 0]\n#F               [0, 0, 1, 2, 3, 0, 0]\n#F               [0, 0, 0, 0, 1, 2, 3] ]\n#F\n#F  Alternatively for downsampled filters valuation can be omitted:\n#F   Filt(n, taps, -Length(taps)+1, ds) is equivalent to\n#F   DSFilt(n, taps, ds)\n#F\nClass(Filt, TaggedNonTerminal, DataNonTerminalMixin, rec(\n    abbrevs := [\n       (n,L)   -> Checked(IsPosIntSym(n), Concat([n], toFiltFunc(L), [1])),\n       (n,L,v) -> Checked(IsPosIntSym(n), Concat([n], toFiltFuncV(L,v), [1])),\n       (n,L,v,ds) -> Checked(IsPosIntSym(n), IsPosIntSym(ds), Concat([n], toFiltFuncV(L,v), [ds])),\n    ],\n    isReal := self >> true,\n\n    filtlen := self >> self.params[2].domain(),\n\n    setData := meth(self, newData) self.params[2] := newData; return self; end,\n\n    dims := self >> let(n:=self.params[1], k:=self.params[2].domain(), ds:=self.params[4],\n                        [n, ds*(n-1) + k]),\n\n    terminate := self >> let(\n\tn    := self.params[1], \n\tcoef := self.params[2].lambda().tolist(),\n\tds   := self.params[4],\n\tk    := Length(coef),\n\tWhen(n=1, Mat([coef]),\n\t          RowTensor(n,k-ds,Mat([coef])))),\n\n    HashId := self >> let(h := [ self.params[1], self.params[2].domain(), self.params[4] ],\n    When(IsBound(self.tags), Concatenation(h, self.tags), h)),\n\n    print := (self,i,is) >> Print(self.name, \"(\", PrintCS(self.params), \")\",\n    When(self.hasTags(), Print(\".withTags(\", self.getTags(), \")\"), \"\")),\n    hashAs := meth(self)\n        local hfilt;\n        hfilt := Copy(self);\n        hfilt.params[2] := FUnk(self.params[2].domain()); \n        return hfilt;\n    end,\n    normalizedArithCost := self >> self.params[1] * (2*self.params[2].domain() - 1)\n));\n\n#F DSFilt(n, taps, ds) - creates a downsampled filter nonterminal\n#F\n#F This command is equivalent to Filt(n, taps, -Length(taps)+1, ds)\n#F\nDSFilt := (n, taps, ds) -> let(\n    func := toFiltFunc(taps),\n    Filt(n, func[1], func[2], ds)\n);\n\n\nConv := function(arg)\n    local filt, tr, v, deg;\n    filt := ApplyFunc(Filt, arg).transpose();\n    deg := filt.params[2].domain();\n    v   := filt.params[3];\n    filt.params[2] := fCompose(filt.params[2], J(deg));\n    filt.params[3] := -(v+deg)+1;\n    return filt;\nend;\n\n_vecList := (lst, t, vlen) -> let(l := Length(lst), Checked(l mod vlen = 0,\n    List([0..l/vlen-1], i -> Value(TVect(t, vlen), lst{[1+vlen*i .. vlen*(i+1)]}))\n));\n\n_pruneVecZeros := lst -> List(lst, x->When(ForAll(x.v, v->v=0), 0, x));\n\n#  a  b  c  d  0  0  0\n#  0  a  b  c  d  0  0\n#  0  0  a  b  c  d  0\n#  0  0  0  a  b  c  d\n\n#  a  b  c  d  0  0  0  0  0  0\n#  0  0  a  b  c  d  0  0  0  0\n#  0  0  0  0  a  b  c  d  0  0\n#  0  0  0  0  0  0  a  b  c  d\n\n_vecTapsHoriz := function(filt, vlen)\n    local zeros, taps, k, vtaps, t, ds;\n    t := filt.params[2].range(); # data type\n    ds := filt.params[4];\n# spiral> _roundup;\n# (n, v) -> v * QuoInt((n + v - 1), v)\n# _roundup(k + (v-1) ds,  v)\n# k + v ds -ds + v - 1\n# (k - ds - 1) + v (ds+1)\n# (k - ds - 1) / v + v * (ds+1)\n    k := filt.params[2].domain();\n    zeros := Replicate(vlen*(ds + 1 + QuoInt(k-ds-1, vlen)) - k, 0);\n    taps := Concatenation(List(filt.params[2].tolist(), EvalScalar), zeros);\n    vtaps := List([0 .. vlen-1], blk ->\n    List([0 .. k-1 + Length(zeros)], j -> taps[1 + ((j - blk*ds) mod (k + Length(zeros)))]));\n    vtaps := List(vtaps, x->_vecList(x,t,vlen));\n    return vtaps;\nend;\n\n_vecTaps := function(filt, vlen)\n    local zeros, taps, k, vtaps, t, ds;\n    t := filt.params[2].range(); # data type\n    ds := filt.params[4];\n    zeros := Replicate((vlen-1)*ds, 0);\n    taps := Concatenation(zeros, List(filt.params[2].tolist(), EvalScalar), zeros);\n    k := filt.params[2].domain();\n    vtaps := List((vlen-1)*ds + [1..k+(vlen-1)*ds], i -> Value(TVect(t, vlen),\n             List([0..vlen-1], j -> taps[i-ds*j])));\n    return vtaps;\nend;\n\n\n\n##\n## Rules\n##\nNewRulesFor(Filt, rec(\n    #F Filt_Base: (base case)\n    #F\n    #F Computes convolution by definition\n    #F\n    Filt_Base := rec(\n    requiredFirstTag := ANoTag,\n    info             := \"Filt -> Mat\",\n    forTransposition := true,\n    limit            := -1, # means no limit\n    applicable     := (self, t) >> When(self.limit < 0, true,\n        t.params[1] <= self.limit or t.params[2].domain() <= self.limit),\n    apply := (t, C, Nonterms) -> t.terminate()\n    ),\n\n    #F Filt_Nest: splits a wider filter into narrower filters, i.e. diagonal stripes\n    #F\n    Filt_Nest := rec(\n\trequiredFirstTag := ANoTag,\n\tforTransposition := false,\n\n        minLength := 2,\n        maxLength := 16,\n        minTaps := 4,\n\n        libApplicable := (self, t) >> let(n:=t.params[1], ntaps:=t.params[2].domain(),\n            leq(self.minLength, n, self.maxLength) * leq(self.minTaps, ntaps)),\n\n\tapplicable := (self, t) >> let(n:=t.params[1], ntaps:=t.params[2].domain(),\n            (IsSymbolic(n) or (n >= self.minLength and n <= self.maxLength)) and \n            (IsSymbolic(ntaps) or ntaps >= self.minTaps)),\n\n        freedoms := (self, t) >> let(ntaps := t.params[2].domain(),\n\t    # we split into filters with 2^k taps, to constrain the search space \n\t    [ List( Filtered([1..20], i -> 2^(i+1) <= ntaps), i -> [2^i, ntaps mod 2^i] ) ]),\n\n\tchild := (t, fr) -> let(\n\t    n  := t.params[1], \n\t    k  := t.params[2].domain(),\n\t    ds := t.params[4], \n            d := fr[1],\n\t    Cond(d[2]=0, [ _setN(DSFilt(n, d[1],ds)) ],\n                         [ _setN(DSFilt(n, d[1],ds)), _setN(DSFilt(n, d[2], ds)) ])),\n\n\tapply := function(t, C, Nonterms) \n\t    local n,k,kk,nfilts,j,core,tot_wid,bk_wid,rem_wid,taps,\n\t          bk_filtlen, rem_filtlen, ds;\n\t    taps := t.params[2];\n\t    n := t.params[1]; \n\t    k := t.filtlen();\n\t    ds := t.params[4];\n\t    tot_wid := ds*(n-1)+k; \n\t    bk_wid  := Cols(C[1]);\n\n\t    bk_filtlen := Nonterms[1].filtlen();\n\t    nfilts := idiv(k, bk_filtlen); \n\n      \t    j := Ind(nfilts);\n\t    Nonterms[1].setData(fCompose(taps, fAdd(k, bk_filtlen, bk_filtlen * j)));\n\n            core := ISumAcc(j, j.range, Scat(fId(n)) * C[1] *\n                                Gath(fAdd(tot_wid, bk_wid, bk_filtlen * j)));\n\n\t    if Length(C) = 1 then return core;\n\t    else \n\t\trem_wid     := Cols(Nonterms[2]);\n\t\trem_filtlen := Nonterms[2].filtlen();\n\t\tNonterms[2].setData(fCompose(taps, fAdd(k, rem_filtlen, bk_filtlen * nfilts)));\n\t\treturn SUMAcc(core, Scat(fId(n)) * C[2] *\n\t\t                    Gath(fAdd(tot_wid, rem_wid, bk_filtlen * nfilts)));\n\t    fi;\n\tend\n    ), \n\n    #F Filt_OverlapSave: Block convolution using Overlap-Save method.\n    #F\n    #F Filter_n -> Filter_n/b\n    #F\n    Filt_OverlapSave := rec(\n    info             := \"Filt(n,h) -> Filt(b,h)\",\n    forTransposition := true,\n    switch           := true,\n    applicable       := t -> t.params[1] > 2 and t.params[2].domain() > 1,\n    blockRatio       := 2,\n    children      := (self,t) >> let(\n        n  := t.params[1],\n        k  := t.params[2].domain(),\n        v  := t.params[3],\n        ds := t.params[4],\n        tags := t.getTags(),\n        newTags := Cond(tags=[], [],\n                    ObjId(tags[1])=AParSMP, Drop(tags, 1),\n                tags),\n        divs := List( Filtered([1..20], i -> 2^i <= self.blockRatio * k and 2^i < n),\n                  i-> [i, n mod 2^i]),\n        List(divs, d ->\n        When( d[2] = 0,\n            [Filt(2^d[1], k, v, ds).withTags(newTags)], # d|n\n            [Filt(2^d[1], k, v, ds).withTags(newTags), Filt(d[2], k, v, ds).withTags(newTags)]))), # not(d|n)\n\n    forceBB := 128, # set to 32 to force reasonable unrolling\n\n    apply := meth(self, t, C, Nonterms)\n        local n, k, s, ds, bb, tags, smp, dosmp;\n        Nonterms[1].setData(t.params[2]);\n        n := t.params[1];\n        k := t.params[2].domain();\n        s := Rows(C[1]);\n        ds := t.params[4];\n        tags := t.getTags();\n        smp := When(tags<>[] and ObjId(tags[1])=AParSMP, s -> SMP(tags[1].p, s), s->s);\n        dosmp := tags<>[] and ObjId(tags[1])=AParSMP;\n\n        # NOTE, this allows us not to use .area() for unrolling, since BB\n        # explicitly forces unrolling onto small guys\n        bb := When(not dosmp and self.forceBB > 0 and k*n <= self.forceBB, BB, x->x);\n        if Length(C)=1 then\n        return smp(bb(RowTensor(n/s, k-ds, C[1]))); # d|n\n        else\n        Nonterms[2].setData(t.params[2]);\n        return RowDirectSum(k-ds, smp(bb(RowTensor(QuoInt(n,s),k-ds,C[1]))), C[2]); # not(d|n)\n        fi;\n    end\n    ),\n\n  Filt_Vect := rec(\n    forTransposition := true,\n    switch           := true,\n    requiredFirstTag := AVecReg,\n    applicable       := t -> (t.params[1] mod t.getTags()[1].v)=0 and t.params[2].domain() >= 1,\n    freedoms := t -> [],\n\n    child := (t, freedoms) -> let(\n        n  := t.params[1], k := t.params[2].domain(), v := t.params[3], ds := t.params[4],\n        vlen := t.getTags()[1].v,\n        [ Filt(n/vlen, k+(vlen-1)*ds, v-(vlen-1)*ds, ds*vlen)\n         .withTags(Drop(t.getTags(), 1)) ]),\n\n    apply := meth(self, t, C, Nonterms)\n        local vlen;\n        vlen := t.getTags()[1].v;\n        Nonterms[1].setData(FData(_vecTaps(t, vlen)));\n        return VTensor(C[1], vlen) * VGath_dup(fId(Cols(t)), vlen);\n    end\n    ),\n\n  Filt_VectHoriz := rec(\n    forTransposition := true,\n    switch           := true,\n    requiredFirstTag := AVecReg,\n    applicable       := t -> let(vlen := t.getTags()[1].v,\n        t.params[1] = vlen and\n        t.params[2].domain() >= 1\n    ),\n    freedoms := t -> [],\n\n    child := (t, freedoms) -> let(vlen := t.getTags()[1].v,\n        vtaps := _vecTapsHoriz(t, vlen),\n        [ TTag(TL(vlen^2, vlen, 1, 1), AVecReg(vlen)),\n          Filt(1, vtaps[1]) ]),\n\n    apply := meth(self, t, C, Nonterms)\n        local vlen, vtaps, filts, vv;\n        vlen := t.getTags()[1].v;\n        vtaps := _vecTapsHoriz(t, vlen);\n        filts := [];\n        for vv in vtaps do\n            Nonterms[1].setData(vv);\n        Add(filts, Copy(C[1]));\n        od;\n\n        return VTensor(RowVec(fConst(vlen, 1)), vlen) *\n               C[1] *\n           VTensor(VStack(filts), vlen);\n    end\n    ),\n\n    # Vectorization by converting a filter into a v-way filterbank \n    #\n    Filt_VectBank := rec(\n \tforTransposition := true,\n \tswitch           := true,\n \trequiredFirstTag := AVecReg,\n        libApplicable    := t -> eq(imod(t.params[1], t.firstTag().v), 0),\n \tapplicable       := t -> let(n:=t.params[1], vlen:=t.firstTag().v,\n            IsSymbolic(n) or (n mod vlen)=0),\n\n \tfreedoms := t -> [],\n\n\tchild := (self,t,fr) >> let(\n \t    n := t.params[1], taps := t.params[2], v := t.params[3], ds := t.params[4], vlen := t.firstTag().v,\n \t    [ Filt(n/vlen, taps, v, ds*vlen).withTags(Drop(t.getTags(), 1)) ]), \n\n \tapply := (self, t, C, Nonterms) >> let(\n \t    n := t.params[1], taps := t.params[2], ds := t.params[4], vlen := t.firstTag().v,\n            #GT(C[1], HH(Cols(t), Cols(C[1]), 0, [1, ds]),\n            #         HH(Rows(t), Rows(C[1]), 0, [vlen, 1]), [vlen]).withTags(new_tags)\n            VTensor(C[1], vlen) * \n            VGath_u(H(Cols(t), Cols(C[1]), 0, 1), vlen)\n                     ),\n    ),\n\n));\n\nRulesFor(Filt, rec(\n    #F Filter_OverlapSaveFreq: Block convolution using Overlap-Save method suited\n    #F for Frequency-domain rules. It blocks so that we get powers of two for\n    #F the columns -> leading to Circulant rule.\n    #F\n    #F Filter_n -> Filter_n/b\n    #F\n    Filt_OverlapSaveFreq := rec(\n    info             := \"Filt(n,h) -> Filt(b,h)\",\n    forTransposition := true,\n    switch           := true,\n    isApplicable     := P -> let(n:=P[1], k:= P[2].domain(), x := Log2Int(n+k-2), ds := P[4],\n                                     (ds=1) and (n > 2) and (k > 1) and (k < 2^x)),\n    allChildren      := P -> let(\n        n  := P[1],\n        k  := P[2].domain(),\n         m := n + k - 1,\n        divs := List( Filtered([1..20], i -> 2^(i-3) <= k and 2^i >= k and 2^i < n+k-1),\n                  i-> [i, n mod (2^i-k+1)]),\n        List(divs, d->\n        When( d[2] = 0,\n            [Filt(2^d[1]-k+1, P[2], P[3])], # d|n\n            [Filt(2^d[1]-k+1, P[2], P[3]), Filt(d[2], P[2], P[3])]))), # not(d|n)\n\n    rule := (P, C) -> let(\n        n := P[1],\n        k := Length(P[2]),\n        s := C[1].dimensions[1],\n        When(Length(C)=1,\n        RowTensor(n/s, k-1, C[1]), # d|n\n        RowDirectSum(k-1, RowTensor(QuoInt(n,s),k-1,C[1]), C[2]))# not(d|n)\n    )\n    ),\n\n    #F Filt_OverlapAdd: block convolution using Overlap-Add method.\n    #F\n    #F Filt_n -> Conv_n/b, Toeplitz, Toeplitz\n    #F\n    Filt_OverlapAdd := rec(\n    info              := \"Filt(n,h) -> Conv(b,h)\",\n    forTransposition  := true,\n    isApplicable      := P -> P[1] > 2 and P[2].domain() <= P[1]+1 and P[4]=1,\n    switch := false,\n    allChildren := function(P)\n        local n,l,divs,d, coef,list1,list2;\n        coef := P[2].tolist();\n        l := Length(coef);\n        n := P[1]-l+1;\n        divs := List(Filtered([1..20], i-> 2^(i-1) < l and 2^i < P[1]),\n                 i-> [i, n mod 2^i]);\n        list1:= Reversed(Concat(Replicate(l-2,0),coef{[1..l-1]}));\n        list2:= Reversed(Concat(coef{[2..l]},Replicate(l-2,0)));\n        return List(divs, d->\n        When(d[2] = 0,\n             [ Conv(2^d[1], coef, P[3]), Toeplitz(list1), Toeplitz(list2) ], # d|n\n             [ Conv(2^d[1], coef, P[3]), Conv(d[2],coef, P[3]),            # not(d|n)\n                                     Toeplitz(list1), Toeplitz(list2) ]));\n    end,\n\n    rule := (P, C) -> let(\n        k := P[2].domain(),\n        n := P[1] - k + 1,\n        s := Cols(C[1]),\n        When(Length(C)=3,\n        ColDirectSum(k-1, C[2], ColTensor(n/s, k-1, C[1]), C[3]), # d|n\n        ColDirectSum(k-1, C[3], ColTensor(QuoInt(n,s), k-1, C[1]), C[2], C[4])) # not(d|n)\n    )\n    ),\n\n\n    #F Filt_OverlapAdd: block convolution using Overlap-Add method.\n    #F\n    #F Filt_n -> Ext * Conv_n/b\n    #F\n    Filt_OverlapAdd2 := rec(\n    info              := \"Filt(n,h) -> Conv(b,h)\",\n    switch            := false,\n    forTransposition  := true,\n    isApplicable      := P -> P[1] > 2 and P[2].domain() > 1 and P[4]=1,\n    allChildren := function(P)\n        local n,k,divs,d, coef;\n        k := P[2].domain();\n        n := P[1]+k-1;\n        coef := P[2];\n        divs := List( Filtered([1..20], i -> 2^(i-1) < k and 2^i < P[1]),\n                  i -> [i, n mod 2^i]);\n        return List(divs, d->\n        When( d[2] = 0,\n            [Conv(2^d[1], coef, P[3])], # d|n\n            [Conv(2^d[1], coef, P[3]), Conv(d[2], coef, P[3])])); # not(d|n)\n    end,\n    rule := (P, C) -> let(\n        k := P[2].domain(),\n        n := P[1] + k - 1,\n        s := Cols(C[1]),\n        ext := Ext(P[1],k-1,k-1).transpose(),\n        When(Length(C)=1,\n        ext * ColTensor(n/s, k-1, C[1]), # d|n\n        ext * ColDirectSum(k-1, ColTensor(QuoInt(n,s), k-1, C[1]), C[2]))# not(d|n)\n    )\n    ),\n\n    #F Filt_KaratsubaSimple:\n    #F\n    #F Filt_n(h) -> Filt_n(h0) dirsum Filt_n(h1) dirsum Filt_n(h0+h1)\n    #F\n    #F h0,h1 - even and odd downsampled h\n    #F This is radix-2 Karatsuba - \"transposed graph\" version.\n    #F Both the size and the length of the filter have to be divisible by 2\n    #F\n    Filt_KaratsubaSimple:= rec(\n    info              := \"Filt(n,h) -> Filt(b,h_e) dirsum Filt(b,h_o) dirsum Filt(b,h_e+h_o)\",\n    forTransposition  := false,\n    switch := false,\n\n    lowerLimit := 8,\n    upperLimit := 128,\n\n    isApplicable := (self, P) >> let(n := P[1], k := P[2].domain(), ds := P[4],\n        (ds=1) and\n        (n >= self.lowerLimit and n <= self.upperLimit) and (n mod 2 = 0) and\n        (k >= self.lowerLimit and k <= self.upperLimit) and (k mod 2 = 0) and\n        not IsBound(P[2].nested)),\n\n    allChildren := P -> let(n := P[1], k := P[2].domain(), v := Int(P[3]/2),\n        [[ Filt(n/2, k/2, v) ]]),\n\n    rule := function( P, C, Nonterms )\n        local n, m, l, m0, S, R, v0, v1, h0, h1, hsum, deg, coeffs, hds, f1,f2,f3;\n        [n, l, deg] := [P[1], P[2].domain(), P[3]];\n        coeffs := List(P[2].tolist(), x->x.ev());\n        hds := DownsampleTwo([coeffs,deg]);\n        [h0,v0] := hds[1];\n        [h1,v1] := hds[2];\n\n            if v0 <> v1 then Error(\"valuations of downsampled filters aren't the same\"); fi;\n\n        if (deg mod 2 = 1) then [h0,h1] := [h1,h0]; fi;\n        hsum := ListSum(h0, h1);\n\n        Nonterms[1].setData(FData(h0)); f1 := Copy(C[1]);\n        Nonterms[1].setData(FData(h1)); f2 := Copy(C[1]);\n        Nonterms[1].setData(FData(hsum)); f3 := Copy(C[1]);\n\n        m0 := n + l - 1;\n        m := (m0+1)/2 - 1;\n        S := Tensor(Mat([[1,0,1],[0,1,1]]), I(n/2));\n        # NOTE: use 3-band filter bank (instead of 3 separate filters) here to improve locality\n        return L(n,n/2) * S *\n               VStack(f1 * HStack(I(m), O(m,1), -I(m)),\n                  f2 * HStack(O(m,1), I(m), -I(m)),\n              f3 * Gath(fAdd(m0,m,m+1))) *\n           BB(OS(m0,2));\n        end\n    ),\n\n    #F Filt_Circulant\n    #F\n    #F Computes convolution by definition\n    #F\n    Filt_Circulant := rec(\n    info             := \"Filt -> Circulant\",\n    forTransposition := true,\n    isApplicable     := P -> let(n:= P[1], k:= P[2].domain(), m:= n+k-1, ds:=P[4],\n                               ds = 1 and m = 2^(Log2Int(m)) and n/k <= 8 and k/n <= 2),\n    allChildren      := P -> let(\n             n := P[1], l := P[3], coef := P[2], r := l+coef.domain()-1,\n         [[ Circulant(n+PosInt(-l)+ PosInt(r), FUnk(coef.domain()), l) ]]),\n\n    rule := (P,C,Nonterms) -> let(\n        n := P[1], l := P[3], r := l + P[2].domain() - 1,\n        nt := Nonterms[1].setData(P[2]),\n        Ext(n, PosInt(-l), PosInt(r)).transpose() * C[1] )\n    ),\n\n    #F Filt_Blocking\n    #F\n    #F Linear Convolution (Filter) -> Blocks (Toeplitzes)\n    #F\n    #F Filter is partitioned into square blocks of sizes given by all\n    #F proper divisors of the input size.\n    #F\n    Filt_Blocking := rec(\n    info             := \"Filt(n,h) -> Toeplitz(b,h')\",\n    forTransposition := false,\n    switch           := true,\n    isApplicable     := P -> let(n := P[1], k := P[2].domain(), ds := P[4],\n        ds = 1 and n > 2 and n < k and ObjId(P[2]) in [FData, FUnk, FList]),\n\n        # split into dense and half-sparse toeplitz, rest will be unrolled\n    allChildren := P -> let(n := P[1], k := P[2].domain(), b := n,\n        [[ Toeplitz(2*b-1),\n           Toeplitz(2*b-1, 0, b-1),\n           Toeplitz(2*b-1, b, 2*b-1) ]]),\n\n    #When((k-1) mod b <>0, [ Toeplitz(2*((k-1) mod b) - 1) ], [ ]),\n\n    rule := function(P, C, Nonterms)\n        local n, k, b, Ls, Lsdata, S, j, rem, ofs, jj;\n        n  := P[1];\n        k  := P[2].domain();\n        b := n;\n\n            # first block major part\n        Ls := List(P[2].tolist(), x->x.eval());\n        Ls := Concat(Replicate(b-1,0), Ls, Replicate(2*b - k mod b,0));\n        Lsdata := FData(Ls);\n\n        j := Ind(Int((k-1)/b)-1); # we unroll first and last iteration\n        jj := Ind(Int((k-1)/b)+1); # we unroll first and last iteration\n        Nonterms[1].setData(fCompose(Lsdata, fAdd(Lsdata.domain(), 2*b-1, (j+1)*b), J(2*b-1)));\n        Nonterms[2].setData(fCompose(Lsdata, fAdd(Lsdata.domain(), 2*b-1, jj*b), J(2*b-1)));\n        Nonterms[3].setData(fCompose(Lsdata, fAdd(Lsdata.domain(), 2*b-1, jj*b), J(2*b-1)));\n        Nonterms[3].setNonZero(b - (k mod b), 2*b - 1);\n\n        S := SUMAcc(\n        Data(jj, V(0),\n            Scat(fId(b)) * C[2] * Gath(fTensor(fBase(j.range+2,jj), fId(b)))),\n        ISumAcc(j, j.range,\n            Scat(fId(b)) * C[1] * Gath(fTensor(fBase(j.range+2,j+1), fId(b)))),\n        Data(jj, V(j.range+1),\n            Scat(fId(b)) * C[3] * Gath(fTensor(fBase(j.range+2,jj), fId(b))))\n        );\n\n            # we have to add a small remaining triangle to the right\n        if (k-1)mod b <> 0 then\n        ofs := b * Int(((k-1)/b)+1) + 1;\n        rem := Reversed( Concat( Ls{[ofs .. ofs + (k-1)mod b - 1]}, Replicate((k-1)mod b -1, 0)));\n        S := ColDirectSum((b+k-1) mod b, S, toeplitz(rem));\n        fi;\n\n        return S;\n    end\n    ),\n\n    Filt_KaratsubaFast := rec(\n    info              := \"Filt(n,h) -> Filt(b,h_e) dirsum Filt(b,h_o) dirsum Filt(b,h_e+h_o)\",\n    forTransposition  := false,\n    switch := false,\n\n    lowerLimit := 8,\n    upperLimit := 128,\n\n    isApplicable := (self, P) >> let(n := P[1], k := P[2].domain(), ds := P[4],\n        (ds=1) and\n        (n >= self.lowerLimit and n <= self.upperLimit) and (n mod 2 = 0) and\n        (k >= self.lowerLimit and k <= self.upperLimit) and (k mod 2 = 0)),\n\n    allChildren := P -> let(n := P[1], k := P[2].domain(), v := Int(P[3]/2),\n        [[ Filt(n/2, k/2, v) ]]),\n\n    rule := function( P, C, Nonterms )\n        local m, m0, S, R, l, h0, h1, hsum, deg, n, t, v, coeffs, newcoeffs, hds, j, dirsum, gfunc, one, minone;\n        n := P[1]; l := P[2].domain(); deg := P[3];\n        coeffs := List(P[2].tolist(), x->x.ev());\n        hds := DownsampleTwo([coeffs,deg]);\n            if hds[1][2] <> hds[2][2] then Error(\"valuations of downsampled filters aren't the same\"); fi;\n\n        v := hds[1][2]; h0 := hds[1][1]; h1 := hds[2][1];\n        if (deg mod 2 = 1) then t := h1; h1 := h0; h0 := t; fi;\n        hsum := ListSum(h0, h1);\n\n        newcoeffs := FData(Concat(h0, h1, hsum));\n        j := Ind(3);\n        gfunc := fCompose(newcoeffs, fTensor(fBase(j), fId(l/2)));\n        Nonterms[1].setData(gfunc);\n        dirsum := ISum(j, j.range,\n            Scat(fTensor(fBase(j), fId(n/2))) * C[1] * Gath(fTensor(fBase(j), fId(Cols(C[1])))));\n        m0 := n + l - 1;\n        m := (m0+1)/2 - 1;\n        S := Tensor(Mat([[1,0,1],[0,1,1]]), I(n/2));\n\n        one := Diag(fConst(m,1));\n        minone := Diag(fConst(m,-1));\n\n        R := VStack(\n            SUMAcc(one*Gath(fAdd(m0,m,0)), minone*Gath(fAdd(m0,m,m+1))),\n            SUMAcc(one*Gath(fAdd(m0,m,1)), minone*Gath(fAdd(m0,m,m+1))),\n        one*Gath(fAdd(m0,m,m+1))\n        );\n\n        return L(n,n/2) * S * dirsum * R * OS(m0,2);\n        end\n    )\n\n));\n", "meta": {"hexsha": "7169221619b15c40310b1449668ed0d5170ba16b", "size": 22839, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/filtering/filt.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/filtering/filt.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/filtering/filt.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 35.7978056426, "max_line_length": 112, "alphanum_fraction": 0.4987959193, "num_tokens": 8211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679957, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.47520837065695715}}
{"text": "# Copyright (c) 2018-2020, Carnegie Mellon University\n# See LICENSE for details\n\n# Radix N kernel for FFTE\n\nbuildScalarKernel_c := function(n, kk, conf, opts)\n    local name, suffix, filesuffix, j, k, l, l1, m, tmp1, tmp3, i1, i2, gf, sf, gath, scat, gc, sc, \n        dft, rts, opcnts, rt, dfts, dftc, cl, cc, c, clp, lp, mp;\n\n    name := DFTnameStr(n, kk);\n    suffix := \"c\";\n    filesuffix := \"c_\";\n#    suffix := \"_k\";\n    Print(\"\\n\\n// == Generating \\\"\", name, \"\\\" ==================================================\\n\\n\");    \n\n    # variables\n    j := V(0);\n    k := var.fresh_t(\"k\", TInt);\n    l := V(1);\n    l1 := var.fresh_t(\"l\", TInt);\n    m := var.fresh_t(\"m\", TInt);\n    lp := var.fresh_t(\"lp\", TPtr(TInt));\n    mp := var.fresh_t(\"mp\", TPtr(TInt));\n    \n    # temp arrays\n    tmp1 := var.fresh_t(\"R\", TArray(TReal, 2*n));\n    tmp3 := var.fresh_t(\"T\", TArray(TReal, 2*n));\n    \n    # gather and scatter\n    i1 := var.fresh_t(\"i\", n);\n    i2 := var.fresh_t(\"i\", n);\n    gf := fTensor(Lambda(i1, k + j*m + i1*l1*m), fId(2));\n    sf := fTensor(Lambda(i2, k+n*j*m + i2*m), fId(2));\n    gath := Gath(gf);\n    scat := Scat(sf);\n    \n    # generate gather and scatter code\n    gc := BlockUnroll(unroll_cmd(opts.codegen(gath, tmp1, X, opts)), opts);\n    sc := BlockUnroll(unroll_cmd(opts.codegen(scat, Y, tmp3, opts)), opts);\n\n    # generate DFT kernel\n    dft := RC(DFT(n, kk));\n    rts := AllRuleTrees(dft, opts);\n    opcnts := List(rts, r -> [ Length(Collect(CodeRuleTree(r, opts), @(1, [add, sub, mul], e->e.t=TReal))), r]);\n    rt := Minimum(opcnts)[2];\n    dfts := SumsRuleTree(rt, opts);\n    dftc := BlockUnroll(opts.codegen(dfts, tmp3, tmp1, opts), opts);\n\n    # stitch code fragments together\n    cl := func(TVoid, \"transform\", [Y, X, j, k, l1, m], \n            decl([tmp1, tmp3], chain(gc, dftc, sc)));\n    cc := Compile(cl, opts);\n    \n    # fixup to push decls inside (?)\n    c := func(TVoid, \"transform\", [Y, X, j, k, l1, m], \n            decl(cc.vars, cc.cmd.cmds[1].cmd));\n    \n    # print Radix N FFTE kernel as function\n    \n    # function with j and k loop in the function call\n    clp := func(TVoid, \"transform\", [Y, X, lp, mp], \n        decl(c.cmd.vars::c.free()::[l1,m],\n            chain(\n                assign(l1, deref(lp)),\n                assign(m, deref(mp)),\n                loopn(k, m, c.cmd.cmd)\n            )\n        )\n    );\n    \n    # print Radix N FFTE kernel as function\n    PrintCode(opts.FortranIze(name::suffix), clp, opts);\n    PrintTo(name::filesuffix::suffix::\".c\", PrintCode(opts.FortranIze(name::suffix), clp, opts));\nend;\n", "meta": {"hexsha": "f249c36de82d3124e9c0679901056badcfd169f8", "size": 2569, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "kernelgen/scalar_c.gi", "max_stars_repo_name": "spiral-software/spiral-package-ffte", "max_stars_repo_head_hexsha": "19f751776c117e28bdbcc3d2530c895ad554d855", "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": "kernelgen/scalar_c.gi", "max_issues_repo_name": "spiral-software/spiral-package-ffte", "max_issues_repo_head_hexsha": "19f751776c117e28bdbcc3d2530c895ad554d855", "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": "kernelgen/scalar_c.gi", "max_forks_repo_name": "spiral-software/spiral-package-ffte", "max_forks_repo_head_hexsha": "19f751776c117e28bdbcc3d2530c895ad554d855", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-15T12:41:51.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-15T12:41:51.000Z", "avg_line_length": 34.2533333333, "max_line_length": 112, "alphanum_fraction": 0.5340599455, "num_tokens": 850, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4745568639716012}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n\nNewRulesFor(InterpolateDFT, rec(\n    InterpolateDFT_tSPL_PrunedDFT := rec(\n       applicable := (self, nt) >> nt.hasTags() and ObjId(nt.params[2]) = fZeroPadMiddle,\n       children := nt -> let(n:=nt.params[2].domain(), N := nt.params[1].range(), us := N/n, blk := n/2,\n            [[ \n                TCompose([\n                    Downsample(nt.params[1]),\n                    PrunedDFT(N, 1, blk, [0, 2*us-1]),\n                    TDiag(fConst(n, 1/n)), \n                    DFT(n, -1)\n                ]).withTags(nt.getTags())\n            ]]),\n       apply := (nt, C, cnt) -> C[1] \n    )\n));\n\n_maxBkSize := function(exp)\n    local i, l, d;\n    \n    if IsExp(exp) and ObjId(exp)=mul and IsValue(exp.args[1]) then\n        return exp.args[1];\n    fi;\n\n    if IsInt(exp.eval()) or IsValue(exp.eval()) then return EvalScalar(exp); fi;\n    l := Lambda(Filtered(exp.free(), IsLoopIndex), exp);\n    d := List(spiral.sigma.GenerateData(l).tolist(), EvalScalar);\n    return Gcd(d);\nend;\n\n_divideFunc := function(exp, dval)\n    local l, d, i;\n\n    if IsValue(exp) or IsInt(exp) then return exp/dval; fi;\n\n    if IsExp(exp) and ObjId(exp)=mul and IsValue(exp.args[1]) then\n        return ApplyFunc(mul, Concat([idiv(exp.args[1], dval)], Drop(exp.args, 1)));\n    fi;\n\n    if IsInt(exp.eval()) or IsValue(exp.eval()) then return EvalScalar(exp/dval); fi;\n    i := Filtered(exp.free(), IsLoopIndex)[1];\n    l := Lambda(i, exp);\n    d := List(spiral.sigma.GenerateData(l).tolist(), EvalScalar)/dval;\n    return FData(List(d, j->i.t.value(j))).at(i);\nend;\n\nNewRulesFor(Downsample, rec(\n    Downsample_tag := rec(\n        applicable := (self, nt) >> nt.hasTags(),\n        apply := (nt, C, cnt) -> let(gcd := _maxBkSize(nt.params[1].domain()),\n            NeedInterleavedComplex(ScatGath(fTensor(fId(_divideFunc(nt.params[1].domain(), gcd)), fId(gcd)), nt.params[1])))\n    )\n));\n\n\nNewRulesFor(InterpolateSegmentDFT, rec(\n    InterpolateSegmentDFT_tSPL_PrunedDFT := rec(\n        applicable := (self, nt) >> nt.hasTags() and ObjId(nt.params[6]) = fZeroPadMiddle,\n        children := nt -> let(tags := nt.getTags(),\n                              numseg := nt.params[1], j := Ind(numseg), downsample := nt.params[5].at(j), upsample := nt.params[6], \n                              insize := nt.params[3], overlap := nt.params[4], n := upsample.domain(), N := downsample.range(), \n                              us := N/n, blk := n/2, \n                              inp := n + (numseg-1)*(n-overlap), over := inp - insize, l := n - over, g := Gcd(n, l), \n                              \n            [[ \n                Downsample(downsample).withTags(tags),\n                PrunedDFT(N, 1, blk, [0, 2*us-1]).withTags(tags), \n                DFT(n, -1).withTags(tags),\n                PrunedDFT(n, -1, g, [0..l/g-1]).withTags(tags),\n                InfoNt(j) \n            ]]),\n        apply := (nt, C, cnt) -> let(numseg := nt.params[1], _j := cnt[5].params[1], j := Ind(_j.range-1), downsample := nt.params[5].at(j), upsample := nt.params[6],\n                              outsize := nt.params[2], insize := nt.params[3], overlap := nt.params[4], n := upsample.domain(), N := downsample.range(), \n                              ids_rows := _sumSegDims(numseg-1, nt.params[5]),\n#                              ids_rows := RulesStrengthReduce(outsize - nt.params[5].at(numseg-1).domain()),\n                RowDirectSum(overlap,[\n                    IRowDirSum(j, numseg-1, overlap, \n                       SubstVars(Copy(C[1]), rec((_j.id) := j)) * C[2] * Diag(fConst(n, 1/n)) * C[3]).overrideDims([ids_rows, insize - C[4].dims()[2] + overlap]),\n                    SubstVars(Copy(C[1]), rec((_j.id) := V(numseg-1))) * C[2] * Diag(fConst(n, 1/n)) * C[4]\n                 ]).overrideDims([nt.params[2], nt.params[3]])\n       )\n    )\n));\n\n", "meta": {"hexsha": "0d3f8e20116c0bcefc22f0cad133db98e50fea91", "size": 3894, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/common/interpolate.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/common/interpolate.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/common/interpolate.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": 43.2666666667, "max_line_length": 166, "alphanum_fraction": 0.520287622, "num_tokens": 1130, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4745434064926262}}
{"text": "\n##  Copyright (c) 2018-2021, Carnegie Mellon University\n##  See LICENSE for details\n\nClass(MultiPtrSumsgenMixin, rec(\n    IterHStack := \n        (self, o, opts) >> let(\n        \tbkcols := Cols(o.child(1)),\n        \tbkrows := Rows(o.child(1)),\n        \tnblocks := o.domain,\n        \tcols := Cols(o), rows := Rows(o),\n        \tj := o.var,\n        \tch := self(o.child(1), opts),\n    \n    \t    ISum(j, j.range,\n        \t\tch *\n        \t\tGath(fTensor(fBase(nblocks, j), fId(bkcols)))\n        \t)\n        )    \n));\n\n", "meta": {"hexsha": "c65651e29f5795c10dd44d202324ad2d5c06baf2", "size": 509, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "sumsgen.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": "sumsgen.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": "sumsgen.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": 23.1363636364, "max_line_length": 55, "alphanum_fraction": 0.4833005894, "num_tokens": 150, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4742728512962738}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nbenchNEON := function()\n    return rec(\n        2x32f := rec(\n            wht := rec(\n                small := _defaultSizes(s->doSimdWht(s, NEON_HALF, rec(\n\t\t            verify := true, oddSizes := true, svct := true, stdTTensor := true, tsplPFA := false)), [4]),\n                medium := _defaultSizes(s->doSimdWht(s, NEON_HALF, rec(\n\t\t\t    oddSizes := false, svct := true, stdTTensor := true, tsplPFA := false)), List([2..10], i->2^i))\n                ),\n            1d := rec(\n                dft_sc := rec(\n                    small := _defaultSizes(s->doSimdDft(s, NEON_HALF, rec(\n\t\t\t\tverify:=true, tsplBluestein:=false, interleavedComplex := false, PRDFT:=true, URDFT:= true, \n\t\t\t\tcplxVect := true, stdTTensor := false, globalUnrolling:=10000)),\n                        [ 2..32 ]),\n                    medium := _defaultSizes(s->doSimdDft(s, NEON_HALF, rec(tsplRader:=false, tsplBluestein:=false, \n\t\t\t\ttsplPFA:=false, oddSizes:=false, interleavedComplex := false)),\n                        _svctSizes(1024, 16, 2)),\n\n                    ),\n                dft_ic := rec(\n                    small := _defaultSizes(s->doSimdDft(s, NEON_HALF, rec(\n\t\t\t\tverify:=true, tsplBluestein:=false, interleavedComplex := true, PRDFT:=true, URDFT:= true,\n\t\t\t\tcplxVect := true, stdTTensor := false, globalUnrolling:=10000)),\n                        [2..32]),\n                    medium := _defaultSizes(s->doSimdDft(s, NEON_HALF, rec(\n\t\t\t\ttsplRader:=false, tsplBluestein:=false, tsplPFA:=false, oddSizes:=false, interleavedComplex := true)),\n                        _svctSizes(1024, 16, 2)),\n                    medium_cx := _defaultSizes(s->doSimdDft(s, NEON_HALF, rec(\n\t\t\t\ttsplRader:=false, tsplBluestein:=false, tsplPFA:=false, oddSizes:=false, interleavedComplex := true, \n\t\t\t\tcplxVect := true, realVect := false)),\n                        _svctSizes(1024, 16, 2)),\n                    ),\n\n                trdft := _defaultSizes(s->doSimdSymDFT(TRDFT, s, NEON_HALF, rec( verify:=true, \n                            interleavedComplex := true, PRDFT:=true, URDFT:= true, tsplBluestein := false, cplxVect := true,\n                            realVect := true, propagateNth := true, useDeref := true, \n                            globalUnrolling:=10000)), 4*[1..32]),\n\n                dht := _defaultSizes(s->doSimdSymDFT(TDHT, s, NEON_HALF, rec(verify :=true)), 8*[1..12]),\n                dct2 := _defaultSizes(s->doSimdSymDFT(TDCT2, s, NEON_HALF, rec(verify :=true)), 8*[1..12]),\n                dct3 := _defaultSizes(s->doSimdSymDFT(TDCT3, s, NEON_HALF, rec(verify :=true)), 8*[1..12]),\n                dct4 := _defaultSizes(s->doSimdSymDFT(TDCT4, s, NEON_HALF, rec(verify :=true)), 8*[1..12]),\n                dst2 := _defaultSizes(s->doSimdSymDFT(TDST2, s, NEON_HALF, rec(verify :=true)), 8*[1..12]),\n                dst3 := _defaultSizes(s->doSimdSymDFT(TDST3, s, NEON_HALF, rec(verify :=true)), 8*[1..12]),\n                dst4 := _defaultSizes(s->doSimdSymDFT(TDST4, s, NEON_HALF, rec(verify :=true)), 8*[1..12]),\n                mdct := _defaultSizes(s->doSimdSymDFT(TMDCT, s, NEON_HALF, rec(verify :=true)), 8*[1..12]),\n                imdct := _defaultSizes(s->doSimdSymDFT(TIMDCT, s, NEON_HALF, rec(verify :=true)), 8*[1..12])\n                ),\n\n            2d := rec(\n                dft_ic := rec(\n                    medium := _defaultSizes(s -> doSimdMddft(s, NEON_HALF, rec(\n\t\t\t\tinterleavedComplex := true,\n                                oddSizes := false, svct := true, splitL := false, pushTag := true, \n\t\t\t\tflipIxA := false, stdTTensor := true, tsplPFA := false)),\n                        4 * List([1..16], i->[i,i])),\n\n                    small := _defaultSizes(s->doSimdMddft(s, NEON_HALF, rec(\n\t\t\t\tverify:=true, interleavedComplex := true, globalUnrolling:=10000,\n                                tsplPFA := false, pushTag:= false, oddSizes := true, svct := true, splitL := false)),\n                        List([2..16], i->[i,i]))\n                    ),\n                dft_sc := rec(\n                    medium := _defaultSizes(s -> doSimdMddft(s, NEON_HALF, rec(\n\t\t\t\tinterleavedComplex := false,\n                                oddSizes := false, svct := true, splitL := false, pushTag := true, flipIxA := false, \n\t\t\t\tstdTTensor := true, tsplPFA := false)),\n                        4*List([1..16], i->[i,i])),\n                    small := _defaultSizes(s->doSimdMddft(s, NEON_HALF, rec(verify:=true, interleavedComplex := false,\n\t\t\t\tglobalUnrolling:=10000, tsplPFA := false, pushTag:= false, oddSizes := true, \n\t\t\t\tsvct := true, splitL := false)),\n                        List([2..16], i->[i,i]))\n                    ),\n                dct2 := _defaultSizes(s->doSimdSymMDDFT(DCT2, s, NEON_HALF, rec(verify := true)), [4, 8, 12, 16]),\n                dct3 := _defaultSizes(s->doSimdSymMDDFT(DCT3, s, NEON_HALF, rec(verify := true)), [4, 8, 12, 16]),\n                dct4 := _defaultSizes(s->doSimdSymMDDFT(DCT4, s, NEON_HALF, rec(verify := true)), [4, 8, 12, 16]),\n                dst2 := _defaultSizes(s->doSimdSymMDDFT(DST2, s, NEON_HALF, rec(verify := true)), [4, 8, 12, 16]),\n                dst3 := _defaultSizes(s->doSimdSymMDDFT(DST3, s, NEON_HALF, rec(verify := true)), [4, 8, 12, 16]),\n                dst4 := _defaultSizes(s->doSimdSymMDDFT(DST4, s, NEON_HALF, rec(verify := true)), [4, 8, 12, 16])\n            )\n            ),\n\n        4x32f := rec(\n            wht := rec(\n                small := _defaultSizes(s -> doSimdWht(s, NEON, rec(\n\t\t\t    verify := true, oddSizes := true, svct := true, stdTTensor := true, tsplPFA := false)), \n\t\t    List([1..3], i->2^i)),\n                medium := _defaultSizes(s -> doSimdWht(s, NEON, rec(\n\t\t\t    oddSizes := false, svct := true, stdTTensor := true, tsplPFA := false\n\t\t\t    )), List([4..10], i->2^i))\n                ),\n            1d := rec(\n                dft_sc := rec(\n                    small := _defaultSizes(s->doSimdDft(s, NEON, rec(\n\t\t\t\tverify:=true, interleavedComplex := false, stdTTensor := false, globalUnrolling:=10000)),\n                        [ 2..64 ]),\n                    medium := _defaultSizes(s->doSimdDft(s, NEON, rec(\n\t\t\t\ttsplRader:=false, tsplBluestein:=false, tsplPFA:=false, oddSizes:=false, interleavedComplex := false)),\n                        _svctSizes(1024, 16, 4)),\n\n                    ),\n                dft_ic := rec(\n                    small := _defaultSizes(s->doSimdDft(s, NEON, rec(\n\t\t\t\tverify:=true, interleavedComplex := true, PRDFT:=true, URDFT:= true, \n\t\t\t\tcplxVect := true, stdTTensor := false, globalUnrolling:=10000)),\n                        [ 2..64 ]),\n                    medium := _defaultSizes(s->doSimdDft(s, NEON, rec(\n\t\t\t\ttsplRader:=false, tsplBluestein:=false, tsplPFA:=false, \n\t\t\t\toddSizes:=false, interleavedComplex := true)),\n                        _svctSizes(1024, 16, 4)),\n                    medium_cx := _defaultSizes(s->doSimdDft(s, NEON, rec(\n\t\t\t\ttsplRader:=false, tsplBluestein:=false, tsplPFA:=false, \n\t\t\t\toddSizes:=false, interleavedComplex := true,\n                                cplxVect := true, realVect := false, PRDFT := false, URDFT := true)),\n                        _svctSizes(1024, 16, 4))\n                    ),\n\n                rdft := _defaultSizes(s->doSimdSymDFT(TRDFT, s, NEON, rec(verify :=true)), 32*[1..12]),\n\n                trdft := _defaultSizes(s->doSimdSymDFT(TRDFT, s, NEON, rec( \n\t\t\t    verify := true, interleavedComplex := true, PRDFT:=true, URDFT:= true, \n\t\t\t    tsplBluestein := false, cplxVect := true,   stdTTensor := false, \n\t\t\t    realVect := true, propagateNth := true, useDeref := true, globalUnrolling:=10000)),\n\t\t    8*[1..32]),\n\n                dht := _defaultSizes(s->doSimdSymDFT(TDHT, s, NEON, rec(verify :=true)), 32*[1..12]),\n                dct2 := _defaultSizes(s->doSimdSymDFT(TDCT2, s, NEON, rec(verify :=true)), 32*[1..12]),\n                dct3 := _defaultSizes(s->doSimdSymDFT(TDCT3, s, NEON, rec(verify :=true)), 32*[1..12]),\n                dct4 := _defaultSizes(s->doSimdSymDFT(TDCT4, s, NEON, rec(verify :=true)), 32*[1..12]),\n                dst2 := _defaultSizes(s->doSimdSymDFT(TDST2, s, NEON, rec(verify :=true)), 32*[1..12]),\n                dst3 := _defaultSizes(s->doSimdSymDFT(TDST3, s, NEON, rec(verify :=true)), 32*[1..12]),\n                dst4 := _defaultSizes(s->doSimdSymDFT(TDST4, s, NEON, rec(verify :=true)), 32*[1..12]),\n                mdct := _defaultSizes(s->doSimdSymDFT(TMDCT, s, NEON, rec(verify :=true)), 32*[1..12]),\n                imdct := _defaultSizes(s->doSimdSymDFT(TIMDCT, s, NEON, rec(verify :=true)), 32*[1..12])\n                ),\n            2d := rec(\n                dft_ic := rec(\n                    medium := _defaultSizes(s -> doSimdMddft(s, NEON, rec(\n\t\t\t\tinterleavedComplex := true,\n                                oddSizes := false, svct := true, splitL := false, pushTag := true, \n\t\t\t\tflipIxA := false, stdTTensor := true, tsplPFA := false)),\n                        16*List([1..8], i->[i,i])),\n                    small := _defaultSizes(s->doSimdMddft(s, NEON, rec(\n\t\t\t\tverify:=true, interleavedComplex := true, globalUnrolling:=10000,\n                                tsplPFA := false, pushTag:= false, oddSizes := true, svct := true, splitL := false)),\n                        List([2..16], i->[i,i]))\n                    ),\n                dft_sc := rec(\n                    medium := _defaultSizes(s -> doSimdMddft(s, NEON, rec(\n\t\t\t\tinterleavedComplex := false,\n                                oddSizes := false, svct := true, splitL := false, pushTag := true, \n\t\t\t\tflipIxA := false, stdTTensor := true, tsplPFA := false)),\n                        16 * List([1..8], i->[i,i])),\n                    small := _defaultSizes(s->doSimdMddft(s, NEON, rec(verify:=true, interleavedComplex := false, \n\t\t\t\tglobalUnrolling:=10000, tsplPFA := false, pushTag:= false, oddSizes := true, \n\t\t\t\tsvct := true, splitL := false)),\n                        List([2..16], i->[i,i]))\n                    ),\n                dct2 := _defaultSizes(s -> doSimdSymMDDFT(DCT2, s, NEON, rec(verify := true)), [4, 8, 12, 16]),\n                dct3 := _defaultSizes(s -> doSimdSymMDDFT(DCT3, s, NEON, rec(verify := true)), [4, 8, 12, 16]),\n                dct4 := _defaultSizes(s -> doSimdSymMDDFT(DCT4, s, NEON, rec(verify := true)), [4, 8, 12, 16]),\n                dst2 := _defaultSizes(s -> doSimdSymMDDFT(DST2, s, NEON, rec(verify := true)), [4, 8, 12, 16]),\n                dst3 := _defaultSizes(s -> doSimdSymMDDFT(DST3, s, NEON, rec(verify := true)), [4, 8, 12, 16]),\n                dst4 := _defaultSizes(s -> doSimdSymMDDFT(DST4, s, NEON, rec(verify := true)), [4, 8, 12, 16]),\n                conv := _defaultSizes(s -> let(\n                        opts := SIMDGlobals.getOpts(NEON, rec(svct := true, oddSizes := false, \n\t\t\t\tsplitComplexTPrm := true, TRCDiag_VRCLR := true, globalUnrolling := 150,\n\t\t\t\tmeasureFinal := false)),\n                        t := Flat(List(s, n -> let(\n\t\t\t\t    tt := TRConv2D(ImageVar([n, n])).withTags(opts.tags), [tt, tt.forwardTransform()]))),\n                        spiral.libgen.DPBench.build(t, opts)), 16*[1..32])\n            )\n        )\n    );\nend;\n\n\n", "meta": {"hexsha": "2570940c053aa181efdf7998ddf5a45ed25aea1f", "size": 11207, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/platforms/neon/bench.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/platforms/neon/bench.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/platforms/neon/bench.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": 60.9076086957, "max_line_length": 124, "alphanum_fraction": 0.521281342, "num_tokens": 3416, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234877, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4736290742934203}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# NOTE: Support odd sizes ie with (I_4 dirsum J_3)\ncondIJ := (N, m) -> let(k := N/m, Checked(IsSymbolic(k) or IsEvenInt(k), \n    fCond(diagTensor(II(k/2), II(2,0,1), II(m)), fTensor(fId(k), fId(m)), \n                                                 fTensor(fId(k), J(m))) \n));\n\n# NOTE: Support odd sizes ie with (I_4 dirsum OS_3)\ncondIOS := (N, m) -> let(k := N/m, Checked(IsSymbolic(k) or IsEvenInt(k), \n    fCond(diagTensor(II(k/2), II(2,0,1), II(m)), fTensor(fId(k), fId(m)), \n                                                 fTensor(fId(k), OS(m, -1))) \n));\n\ncondM := (N, m) -> L(N, m) * Prm(condIJ(N, m));\ncondK := (N, m) -> Prm(condIJ(N, N/m)) * L(N, m);\n\ncondMp := (N, m) -> L(N, m) * Prm(condIOS(N, m));\ncondKp := (N, m) -> Prm(condIOS(N, N/m)) * L(N, m);\n\ncondB := (N, m) -> Checked(IsEvenInt(m), let(k := N/m, \n    condK(N, m) * Tensor(I(N/m), condM(m,m/2))));\n\ncondBp := (N, m) -> Checked(IsEvenInt(m), let(k := N/m, \n    condKp(N, m) * DirectSum(L(m,m/2), Tensor(I(k-1), condM(m,m/2)))));\n\ncondBpu := (N, m) -> Checked(IsEvenInt(m), let(k := N/m, \n    condKp(N, m) * DirectSum(I(m), Tensor(I(k-1), condM(m,m/2)))));\n\n# condBpu(k*m,m) == Scat(Refl0_u(k,m)) = Refl0_u(k,m).transpose()\n# u = stands for URDFT. i.e. this is for URDFT based algorithms\n# NOTE: not valid for odd <k> (but will need new ASPF rule anyway with an extra child)\n# GOOD:  valid for odd <m>.\nClass(Refl0_u, PermClass, rec(\n    def := (k, m) -> rec(), \n    domain := self >> self.params[1] * self.params[2], \n    range := self >> self.params[1] * self.params[2], \n    lambda := self >> let(k := self.params[1], m := self.params[2], i := Ind(k*m), \n        Lambda(i, cond(leq(i, m-1), k*i, \n                                    cond(leq(imod(i, m), idiv(m-1,2)), 2*k*imod(i,m) + idiv(i,m), \n                                                                      2*k*m - 2*k*imod(i,m) - idiv(i,m)))))\n));\n\n# Valid for odd <k>, even <m>\n# <omit> is how many initial points we want to omit from the permutation\n# the only sensible values for it are 0 and 1\nClass(Refl0_odd, PermClass, rec(\n    def := (k, m, omit) -> rec(), #size := k*m+idiv(m+1,2)-omit),\n    range := self >> self.domain(),\n    domain := self >> let(k:=self.params[1], m:=self.params[2], omit:=self.params[3],\n        k*m + idiv(m+1, 2) - omit),\n\n    lambda := self >> let(\n        k := self.params[1],   m := self.params[2], mc := idiv(m+1, 2),\n        N := self.domain(), omit := self.params[3], mf := idiv(m, 2),   \n        N2:= 2*k*m+m,         ii := Ind(N-omit),    i  := ii+omit,\n        \n        Lambda(ii, cond(leq(i, mc-1), (2*k+1)*i, \n                                     cond(leq(imod(i-mc, m), mc-1),       (2*k+1)*imod(i-mc,m) + idiv(i+mf,m), \n                                                                    N2  - (2*k+1)*imod(i-mc,m) - idiv(i+mf,m)))\n            -omit))\n));\n\n# condB(k*m,m) == Scat(Refl1(k,m)) = Refl1(k,m).transpose()\n# NOTE: not valid for odd <k> (but will need new ASPF rule anyway with an extra child)\n# GOOD:  valid for odd <m>.\nClass(Refl1, PermClass, rec(\n    def := (k, m) -> rec(), #size := k*m),\n    domain := self >> self.params[1]*self.params[2], \n    range := self >> self.params[1]*self.params[2], \n    lambda := self >> let(k := self.params[1], m := self.params[2], i := Ind(k*m), \n        Lambda(i, cond(leq(imod(i, m), idiv(m-1,2)), 2*k*imod(i,m) + idiv(i,m), \n                                       2*k*m - 1 - 2*k*imod(i,m) - idiv(i,m))))\n));\n\nDeclare(KK, MM, KKp, MMp);\n\nClass(KK, PermClass, rec(\n    def := (k, m) -> rec(), #size := k*m),\n    domain := self >> self.params[1]*self.params[2], \n    range := self >> self.params[1]*self.params[2], \n    transpose := self >> MM(self.params[2], self.params[1]),\n    lambda := self >> let(k := self.params[1], m := self.params[2],\n        fCompose(Tr(k,m), condIJ(k*m, k)).lambda()),\n));\n\nClass(MM, PermClass, rec(\n    def := (k, m) -> rec(), #size := k*m),\n    domain := self >> self.params[1]*self.params[2], \n    range := self >> self.params[1]*self.params[2], \n    transpose := self >> KK(self.params[2], self.params[1]),\n    lambda := self >> let(k := self.params[1], m := self.params[2],\n        fCompose(condIJ(k*m, m), Tr(k, m)).lambda()),\n));\n\nClass(KKp, PermClass, rec(\n    def := (k, m) -> rec(), #size := k*m),\n    domain := self >> self.params[1]*self.params[2], \n    range := self >> self.params[1]*self.params[2], \n    transpose := self >> MMp(self.params[2], self.params[1]),\n    lambda := self >> let(k := self.params[1], m := self.params[2],\n        fCompose(Tr(k,m), condIOS(k*m, k)).lambda()),\n));\n\nClass(MMp, PermClass, rec(\n    def := (k, m) -> rec(), #size := k*m),\n    domain := self >> self.params[1]*self.params[2], \n    range := self >> self.params[1]*self.params[2], \n    transpose := self >> KKp(self.params[2], self.params[1]),\n    lambda := self >> let(k := self.params[1], m := self.params[2],\n        fCompose(condIOS(k*m, m), Tr(k, m)).lambda()),\n));\n\nDeclare(IP);\n\nlibB := (k, m) -> Checked(IsSymbolic(m) or IsEvenInt(m), \n    KK(k, m) * Tensor(I(k), MM(2,m/2)));\n\nlibBp := (k, m) -> Checked(IsSymbolic(m) or IsEvenInt(m), \n    KKp(k, m) * DirectSum(Tr(2,m/2), Tensor(I(k-1), MM(2,m/2))));\n\nlibBpu := (k, m) -> Checked(IsSymbolic(m) or IsEvenInt(m), \n    KKp(k, m) * DirectSum(I(m), Tensor(I(k-1), MM(2,m/2))));\n\n#F IJ(<size>, <n>) - I_n dirsum J_n dirsum I_n dirsum ... (repeats N/n times, n|N)\n#F\n#\n# Subst(i -> BinXor(i, BinAnd(i,$n) - BinShr(BinAnd(i,$n), $(LogInt(n,2))))),\n# Class(IJ, PermClass, rec(\n#   def := (N, n) -> Checked(IsInt(N), IsInt(n), N mod n = 0,\n#       rec(\n#       size := N,\n#       direct  := Subst(x -> x + (QuoInt(x,$n) mod 2) * ($(n-1) - 2*(x mod $n))),\n#       inverse := Subst(x -> x + (QuoInt(x,$n) mod 2) * ($(n-1) - 2*(x mod $n)))\n#       )),\n#   transpose := self >> self\n#);\nIJ := (N, n) -> IP(N, J(n));\n\n#F IP(<N>, <splperm>) - I_n dirsum P_n dirsum I_n dirsum ... (repeats N/n times, n|N)\n#F\n#F    P_n given by <splperm>, which is a permutation function\n#F\nClass(IP, PermClass, rec(\n    def := (N, splperm) -> Checked(IsInt(N), IsSPL(splperm), N mod Rows(splperm) = 0, rec()), \n    range := self >> self.params[1],\n    domain := self >> self.params[1],\n\n    lambda := self >> let(\n\tN := self.params[1], \n\tP := self.params[2],\n\tPl := P.lambda(),\n\tn := P.domain(), \n\ti := Ind(N),\n\tLambda(i, n*idiv(i,n) + imod(1+idiv(i,n), 2)*imod(i, n) +\n                                imod(  idiv(i,n), 2)*Pl.at(imod(i,n)))\n    ),\n\n    transpose := self >> IP(self.params[1], self.params[2].transpose())\n));\n\n\n\n# -----------------------------------------------------------------------------#\n#F LIJ(<N>) - L(N, N/2) * (I(N/2) dirsum J(N/2))\n##   works also for odd sizes\nClass(LIJ, PermClass, rec(\n    def := N -> Checked(IsInt(N), rec()),\n    range := self >> self.params[1],\n    domain := self >> self.params[1],\n    lambda := self >> let(\n\tN := self.params[1],\n\tN1 := When(IsOddInt(N), N, N-1),\n\ti := Ind(N),\n\tWhen(not self.transposed,\n            Lambda(i, QuoInt(N,2) + idiv(N-i, 2)*cond(neq(imod(N1-i,2),0), -1, 1)),\n            Lambda(i, 2*i + idiv(i, QuoInt(N+1,2)) * (2*N - 1 - 4*i))\n        ))\n));\n\n\n# -- Originals\n# K ( <n>, <m> )\n#   returns the equivalent of the stride permutation for Cooley-Tukey FFT\n#   for the DCT3 and 4. <m> has to divide <n>\n#     (I_n/m dirsum J_n/m dirsum I_n/m ....) * L^n_m  (direct sum alternately)\n#   This permutation is to be used if it occurs on the left side in the rule.\n#   It is K(n, m)^-1 =  M(n, n/m).\nK := (mn, m) -> Checked(IsPosInt(mn), IsPosInt(m), mn mod m = 0, \n    IJ(mn, mn/m) * L(mn, m));\n\nM := (mn, m) -> Checked(IsPosInt(mn), IsPosInt(m), mn mod m = 0, \n    L(mn, m) * IJ(mn, m));\n# -------------\n\n\n########################\n# Generating functions\n########################\n\nL_or_OS := (n, str) -> When((n mod str) <> 0, OS(n, str), L(n, str));\n\nKp := (NN, m) -> let(n := NN / m,\n    Prm(IP(NN, OS(n, -1)))* L(NN, m));\n\nMp := (NN, m) -> Kp(NN, NN/m).transpose(); \n\n# Type 0 symmetries  (ce0, co0) aka whole-point\n# BH0(<Nreal>, <n>, <base>, <stride>), Nreal = number of output real pts = Rows(PRDFT(.))\n# BH0 := (Nreal,n,base,stride) -> BH(Int(Nreal/2)+1, Nreal, n, base, stride);\n\n# Type 1 symmetries  (ce1, co1) aka half-point\n# BH1(<Nreal>, <n>, <base>, <stride>), Nreal = number of output real pts = Rows(PRDFT3(.))\n# BH1 := (Nreal,n,base,stride) -> BH(Int((Nreal+1)/2), Nreal-1, n, base, stride);\n\n\n# BH(<N>, <reflect>, <n>, <b>, <s>) - Reflective stride function\n#   Defined as  i -> When(i < ceil(n/2)-1, si + b, reflect - si - b)\n# \nClass(BH, FuncClass, rec(\n    def := (N,reflect,n,base,stride) -> rec(), #N := N, n := n),\n    domain := self >> self.params[3],\n    range  := self >> self.params[1],\n    lambda := self >> let(\n\tN:=self.params[1], reflect:=self.params[2], n:=self.params[3], b:=self.params[4], \n\ts:=self.params[5], i:=Ind(n),\n\tLambda(i, cond(leq(i, idiv(n-1, 2)), s*i + b, reflect - s*i - b)))\n));\n\nDeclare(Refl);\n# Refl(<N>, <reflect>, <n>, <func>) - Reflective arbitrary function\n#   Defined as  i -> When(func(i) < N, func(i), reflect - func(i))\n#   with domain of <n> points (usually smaller than domain(func))\n# \nClass(Refl, FuncClass, rec(\n    def := (N,reflect,n,func) -> rec(), #N := N, n := n),\n    domain := self >> self.params[3],\n    range  := self >> self.params[1],\n    transpose := self >> Refl(self.params[1], self.params[2], self.params[3], self.params[4].transpose()),\n    lambda := self >> let(\n\tfunc:=self.params[4].lambda(), reflect:=self.params[2], N:=self.params[1], \n\ti := Ind(self.params[3]),\n\tLambda(i, cond(leq(func.at(i), N-1), func.at(i), reflect-func.at(i))))\n));\n", "meta": {"hexsha": "42e3d8451af7488c67316c8ac8af01163bd10a01", "size": 9663, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/ij.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/ij.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/ij.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": 38.9637096774, "max_line_length": 111, "alphanum_fraction": 0.5183690365, "num_tokens": 3352, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.47347409654375905}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nClass(InertTranspose, BaseContainer, SumsBase, rec(\n    dims := self >> Reversed(self.child(1).dims()),\n    toAMat := self >> AMatMat(TransposedMat(MatSPL(self.child(1))))\n));\n\nClass(InertConjTranspose, BaseContainer, SumsBase, rec(\n    dims := self >> Reversed(self.child(1).dims()),\n    toAMat := self >> AMatMat(Global.Conjugate(TransposedMat(MatSPL(self.child(1)))))\n));\n\nInertConjTranspose.conjTranspose := self >> self.child(1);\n", "meta": {"hexsha": "2d28e4deb8e739ade59252bfa92f3d09996d4d78", "size": 518, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/transpose.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/transpose.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/transpose.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.4705882353, "max_line_length": 85, "alphanum_fraction": 0.7027027027, "num_tokens": 147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.47342091420612}}
{"text": "# Copyright (c) 2018-2020, Carnegie Mellon University\n# See LICENSE for details\n\nDeclare(ScatH, VScat_L);\n\n\nClass(GathH, SumsBase, BaseMat, rec(\n    rChildren := self >> [self.N, self.n, self.base, self.stride],\n    rSetChild := rSetChildFields(\"N\", \"n\", \"base\", \"stride\"),\n    new := (self, N, n, base, stride) >> \n\tSPL(WithBases(self, rec(\n      \tN:= N, n := n, base := base, stride := stride, dimensions := [n, N]))),\n    dims := self >> self.dimensions,\n    sums := self >> self,\n    area := self >> self.n,\n    isReal := self >> true,\n    transpose := self >> ScatH(self.N, self.n, self.base, self.stride),\n    conjTranspose := self >> self.transpose(),\n    inverse := self >> self.transpose(),\n    toAMat := self >> let(\n\t   n := self.n,\n       N := self.N,\n       base := self.base,\n       stride := self.stride,\n       AMatMat(List([0..n-1], row -> let(\n         idx := base+row,\n\t\t BasisVec(N, idx))))\n    ),\n    isIdentity := self >> (self.n=self.N) and self.base=0 and self.stride = 1,\n));\n\nClass(ScatH, SumsBase, BaseMat, rec(\n    rChildren := self >> [self.N, self.n, self.base, self.stride],\n    rSetChild := rSetChildFields(\"N\", \"n\", \"base\", \"stride\"),\n    new := (self, N, n, base, stride) >> \nSPL(WithBases(self, rec(\n      \tN:= N, n := n, base := base, stride := stride, dimensions := [N, n]))),\n    dims := self >> self.dimensions,\n    sums := self >> self,\n    area := self >> self.n,\n    isReal := self >> true,\n    transpose := self >> GathH(self.N, self.n, self.base, self.stride),\n    conjTranspose := self >> self.transpose(),\n    inverse := self >> self.transpose(),\n    toAMat := self >> let(\n\t   n := self.n,\n       N := self.N,\n       base := self.base,\n       stride := self.stride,\n       TransposedAMat(AMatMat(List([0..n-1], row -> let(\n         idx := base+row*stride,\n\t\t BasisVec(N, idx))))\n    )),\n    isIdentity := self >> (self.n=self.N) and self.base=0 and self.stride = 1,\n));\n\n\n\nClass(VGath_L, SumsBase, BaseMat, rec(\n    rChildren := self >> [self.N, self.n, self.base],\n    rSetChild := rSetChildFields(\"N\", \"n\", \"base\"),\n    new := (self, N, n, base) >> \n\tSPL(WithBases(self, rec(\n      \tN:= N, n := n, base := base, dimensions := [2, N]))),\n    dims := self >> self.dimensions,\n    sums := self >> self,\n    area := self >> self.n,\n    isReal := self >> true,\n    transpose := self >> VScat_L(self.N, self.n, self.base),\n    conjTranspose := self >> self.transpose(),\n    inverse := self >> self.transpose(),\n    toAMat := self >> let(\n\t   n := self.n,\n       N := self.N,\n       base := self.base,\n       AMatSPL(L(2*n, 2) * Tensor(SPLAMat(AMatMat(List([0..n-1], row -> let(\n         idx := base+row,\n\t\t BasisVec(N, idx))))), I(2))) \n    ),\n    isIdentity := False\n));\n\nClass(VScat_L, SumsBase, BaseMat, rec(\n    rChildren := self >> [self.N, self.n, self.base],\n    rSetChild := rSetChildFields(\"N\", \"n\", \"base\"),\n    new := (self, N, n, base) >> \nSPL(WithBases(self, rec(\n      \tN:= N, n := n, base := base, dimensions := [N, 2]))),\n    dims := self >> self.dimensions,\n    sums := self >> self,\n    area := self >> self.n,\n    isReal := self >> true,\n    transpose := self >> VGath_L(self.N, self.n, self.base),\n    conjTranspose := self >> self.transpose(),\n    inverse := self >> self.transpose(),\n    toAMat := self >> TransposedAMat(self.transpose().toAMat()),\n    isIdentity := False\n));\n\n", "meta": {"hexsha": "d5a0beee800425953da76b51ba0543d9f4c54f08", "size": 3343, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "sigmaspl.gi", "max_stars_repo_name": "spiral-software/spiral-package-ffte", "max_stars_repo_head_hexsha": "19f751776c117e28bdbcc3d2530c895ad554d855", "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": "sigmaspl.gi", "max_issues_repo_name": "spiral-software/spiral-package-ffte", "max_issues_repo_head_hexsha": "19f751776c117e28bdbcc3d2530c895ad554d855", "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": "sigmaspl.gi", "max_forks_repo_name": "spiral-software/spiral-package-ffte", "max_forks_repo_head_hexsha": "19f751776c117e28bdbcc3d2530c895ad554d855", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-15T12:41:51.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-15T12:41:51.000Z", "avg_line_length": 33.43, "max_line_length": 78, "alphanum_fraction": 0.5530960215, "num_tokens": 1004, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4716721510225961}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# NOTE: The first section is Intel SSE/2/3 specific, and has to be ported\n# over to SPU\n\nunpacklo := (l1,l2,n,k) -> Flat(List([1..n/(2*k)], i-> [\n        List([1..k], j->l1[(i-1)*k+j]),\n        List([1..k], j->l2[(i-1)*k+j])\n]));\n\nunpackhi := (l1,l2,n,k) -> Flat(List([1..n/(2*k)], i -> [\n        List([1..k], j->l1[n/2+(i-1)*k+j]),\n        List([1..k], j->l2[n/2+(i-1)*k+j])\n]));\n\nsparams := (l,n) -> List([1..l], i->[1..n]);\n\nshuffle := (in1, in2, p, n, k) -> Flat([\n    List([1..n/(2*k)],     i->List([1..k], j->in1[(p[i]-1)*k+j])),\n    List([n/(2*k)+1..n/k], i->List([1..k], j->in2[(p[i]-1)*k+j]))\n]);\n\niperm4 := self >> Filtered(Cartesian(self.params()), i->i[1]<>i[2] and i[3] <> i[4]);\n", "meta": {"hexsha": "e2fcd2d58f679f1810a4b723bb08b3244e370c2a", "size": 776, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/platforms/altivec/misc.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/platforms/altivec/misc.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/platforms/altivec/misc.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.7407407407, "max_line_length": 85, "alphanum_fraction": 0.4806701031, "num_tokens": 325, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.4703032805965709}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# ==========================================================================\n# RowDirectSum\n# ==========================================================================\nClass(RowDirectSum, BaseOverlap, rec(\n    #-----------------------------------------------------------------------\n    abbrevs := [\n        function(arg)\n          arg:=Flat(arg);\n          return [arg[1], arg{[2..Length(arg)]}];\n        end ],\n    #-----------------------------------------------------------------------\n    new := meth(self, overlap, spls)\n       return self._new(0, overlap, spls);\n    end,\n    #-----------------------------------------------------------------------\n    _dims := meth(self)\n        local ovdim;\n    ovdim := self.ovDim(self.overlap,\n                        List(self._children, t -> t.dimensions[2]));\n    return [ Sum(self._children, t -> t.dimensions[1]),\n             ovdim[3] - ovdim[2] + 1 # max - min + 1\n    ];\n    end,\n    dims := self >> When(IsBound(self._setDims), self._setDims, let(d := Try(self._dims()), \n\t    When(d[1], d[2], [errExp(TInt), errExp(TInt)]))),\n    #-----------------------------------------------------------------------\n    toAMat := meth(self)\n        return\n      DirectSumAMat(List(self._children, AMatSPL)) *\n      AMatSPL(\n          Sparse(\n          self._rowoverlap(\n              List(self._children, t -> t.dimensions[2]),\n              self.overlap\n          )\n          )\n      );\n    end,\n    #-----------------------------------------------------------------------\n    arithmeticCost := meth(self, costMul, costAddMul)\n        return Sum(List(self.children(), x -> x.arithmeticCost(costMul, costAddMul)));\n    end\n));\n", "meta": {"hexsha": "60af6e51f3311e5cb26958a296b6617355dc5a46", "size": 1753, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/RowDirectSum.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/RowDirectSum.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/RowDirectSum.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 35.7755102041, "max_line_length": 92, "alphanum_fraction": 0.3776383343, "num_tokens": 361, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6297746074044135, "lm_q1q2_score": 0.46802834085944517}}
{"text": "for i in [10, 9 .. 0] do\n    Print(i, \"\\n\");\nod;\n", "meta": {"hexsha": "24fd418a002bd56e0a2389ab16424a2f1074dcb3", "size": 49, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Loops-Downward-for/GAP/loops-downward-for.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Loops-Downward-for/GAP/loops-downward-for.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Loops-Downward-for/GAP/loops-downward-for.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.25, "max_line_length": 24, "alphanum_fraction": 0.4285714286, "num_tokens": 23, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.46717526067544773}}
{"text": "#############################################################################\n##\n#W  loewy.gi             GAP 4 package SingerAlg                Thomas Breuer\n##\n##  This file contains implementations of GAP functions for studying\n##  the Loewy structure of Singer algebras A[q,z].\n##\n\n\n##  for those who worked with an earlier version of the package ...\nLoewyLayersData:= function( arg )\n    Print( \"use LoewyStructureInfo not LoewyLayersData\\n\" );\n    return CallFuncList( LoewyStructureInfoGAP, arg );\n    end;\n\n\nif IsPackageMarkedForLoading( \"JuliaInterface\", \"\" ) then\n\n#############################################################################\n##\n#M  LoewyStructureInfoJulia( <A> )\n##\n##  Call a Julia function, convert its result to a record,\n##  but keep the record components in Julia.\n##\nInstallMethod( LoewyStructureInfoJulia,\n    [ \"IsSingerAlgebra\" ],\n    A -> CallFuncList( LoewyStructureInfoJulia,\n                       ParametersOfSingerAlgebra( A ) ) );\n\nInstallMethod( LoewyStructureInfoJulia,\n    [ \"IsPosInt\", \"IsPosInt\" ],\n    { q, z } -> LoewyStructureInfoJulia( q, OrderMod( q, z ), z ) );\n\nInstallMethod( LoewyStructureInfoJulia,\n    [ \"IsPosInt\", \"IsPosInt\", \"IsPosInt\" ],\n    { q, n, z } -> CallFuncList( Julia.SingerAlg.LoewyStructureInfo,\n                       List( [ q, n, z ], GAPToJulia ) ) );\n\nfi;\n\n\nif IsPackageMarkedForLoading( \"JuliaInterface\", \"\" ) then\n\n#############################################################################\n##\n#M  LoewyStructureInfo( <A> )\n##\n##  We prefer 'LoewyStructureInfoJulia' to 'LoewyStructureInfoGAP'.\n##  For that, we convert the Julia dictionary into a GAP record.\n##\nInstallMethod( LoewyStructureInfo,\n    [ \"IsSingerAlgebra\" ],\n    A -> JuliaToGAP( IsRecord, LoewyStructureInfoJulia( A ), true ) );\n\nInstallMethod( LoewyStructureInfo,\n    [ \"IsPosInt\", \"IsPosInt\" ],\n    { q, z } -> LoewyStructureInfo( q, OrderMod( q, z ), z ) );\n\nInstallMethod( LoewyStructureInfo,\n    [ \"IsPosInt\", \"IsPosInt\", \"IsPosInt\" ],\n    { q, n, z } -> JuliaToGAP( IsRecord, LoewyStructureInfoJulia( q, n, z ),\n                               true ) );\n\nfi;\n\n\n#############################################################################\n##\n#F  LoewyStructureInfoGAP( <A> )\n#F  LoewyStructureInfoGAP( <q>[, <n>], <z> )\n##\nInstallMethod( LoewyStructureInfoGAP,\n    [ \"IsSingerAlgebra\" ],\n    A -> CallFuncList( LoewyStructureInfoGAP,\n                       ParametersOfSingerAlgebra( A ) ) );\n\nInstallMethod( LoewyStructureInfoGAP,\n    [ \"IsPosInt\", \"IsPosInt\" ],\n    { q, z } -> LoewyStructureInfoGAP( q, OrderMod( q, z ), z ) );\n\nInstallMethod( LoewyStructureInfoGAP,\n    [ \"IsPosInt\", \"IsPosInt\", \"IsPosInt\" ],\n    function( q, n, z )\n    local islessorequal, monomials, layers, degrees, predecessors, m, i,\n          mon, lambda, pred, j, mm;\n\n    if n mod OrderMod( q, z ) <> 0 then\n      Error( \"<z> must divide <q>^<n> - 1\" );\n    fi;\n\n    islessorequal:= function( mon1, mon2 )\n      local i;\n\n      for i in [ 1 .. n ] do\n        if mon2[i] < mon1[i] then\n          return false;\n        fi;\n      od;\n      return true;\n    end;\n\n    monomials:= [ 0 * [ 1 .. n ] ];\n    layers:= [ 0 ];\n    degrees:= [ 0 ];    # just for speedup: avoid comparisons\n\n    predecessors:= [ 0 ];\n\n    m:= n * (q-1);\n    for i in [ 1 .. z ] do\n      mon:= CoefficientsQadicReversed( i, z, q, n );\n      lambda:= 0;\n      pred:= 1;\n      mm:= Sum( mon );\n      for j in [ 2 .. i ] do\n        if lambda < layers[j] and degrees[j] < mm\n                              and islessorequal( monomials[j], mon ) then\n          lambda:= layers[j];\n          pred:= j;\n        fi;\n      od;\n      monomials[i+1]:= mon;\n      layers[i+1]:= lambda + 1;\n      degrees[i+1]:= mm;\n      predecessors[i+1]:= pred;\n\n      if lambda = 0 then\n        if mm < m then\n          m:= mm;\n        fi;\n      fi;\n    od;\n\n    # Extract information about one longest chain.\n    i:= Length( monomials );\n    pred:= [];\n    while i > 0 do\n      Add( pred, i );\n      i:= predecessors[i];\n    od;\n\n    return rec( monomials:= monomials,\n                layers:= layers,\n                chain:= pred,\n                m:= m,\n                LL:= lambda + 2,\n                parameters:= [ q, n, z ] );\n    end );\n\n\n#############################################################################\n##\n#F  DimensionsLoewyFactorsGAP( <A> )\n#F  DimensionsLoewyFactorsJulia( <A> )\n##\n##  Return the GAP object or the Julia object, respectively.\n##\nBindGlobal( \"DimensionsLoewyFactorsGAP\", function( A )\n    local data, v, i;\n\n    data:= LoewyStructureInfoGAP( A );\n    v:= ListWithIdenticalEntries( data.LL, 0 );\n    for i in data.layers do\n      v[ i+1 ]:= v[ i+1 ] + 1;\n    od;\n\n    return v;\n    end );\n\nif IsPackageMarkedForLoading( \"JuliaInterface\", \"\" ) then\n\nBindGlobal( \"DimensionsLoewyFactorsJulia\",\n    A -> Julia.SingerAlg.LoewyVector( LoewyStructureInfoJulia( A ) ) );\n\nfi;\n\n\n#############################################################################\n##\n#M  DimensionsLoewyFactors( <A> )\n##\n##  If Julia is available then use the Julia functionality,\n##  otherwise use the GAP code.\n##\nInstallMethod( DimensionsLoewyFactors,\n    [ \"IsSingerAlgebra\" ],\n    A -> DimensionsLoewyFactorsGAP( A ) );\n\n\nif IsPackageMarkedForLoading( \"JuliaInterface\", \"\" ) then\n\nInstallMethod( DimensionsLoewyFactors,\n    [ \"IsSingerAlgebra\" ],\n    A -> JuliaToGAP( IsList, DimensionsLoewyFactorsJulia( A ), true ) );\n\nfi;\n\n\n#############################################################################\n##\n#F  LoewyVectorAbbreviated( <v> )\n#F  LoewyVectorExpanded( <v> )\n##\nInstallGlobalFunction( LoewyVectorAbbreviated, function( v )\n    local result, x, m, i;\n\n    if not IsDenseList( v ) then\n      Error( \"<v> must be a dense list\" );\n    elif Length( v ) = 0 then\n      return [];\n    fi;\n    result:= [];\n    x:= v[1];\n    m:= 1;\n    for i in [ 2 .. Length( v ) ] do\n      if v[i] = x then\n        m:= m + 1;\n      elif m = 1 then\n        Add( result, x );\n        x:= v[i];\n      else\n        Add( result, [ x, m ] );\n        x:= v[i];\n        m:= 1;\n      fi;\n    od;\n\n    if m = 1 then\n      Add( result, x );\n    else\n      Add( result, [ x, m ] );\n    fi;\n\n    return result;\n    end );\n\nInstallGlobalFunction( LoewyVectorExpanded, function( v )\n    local result, x, i;\n\n    if not IsDenseList( v ) then\n      Error( \"<v> must be a dense list\" );\n    fi;\n    result:= [];\n    for x in v do\n      if IsList( x ) then\n        for i in [ 1 .. x[2] ] do\n          Add( result, x[1] );\n        od;\n      else\n        Add( result, x );\n      fi;\n    od;\n\n    return result;\n    end );\n\n\n#############################################################################\n##\n#F  SingerAlgebra( <q>[, <n>], <z>[, <R>] )\n#F  SingerAlgebra( <arec>[, <R>] )\n##\n##  The algebra returned by this function claims to be a structure constants\n##  algebra (via the filter 'IsSCAlgebraObjCollection'),\n##  but the structure constants table is not created until one asks for\n##  something that needs it.\n##  Currently a special method for 'CanonicalBasis' makes sure that the\n##  relevant data get stored.\n##\nInstallGlobalFunction( SingerAlgebra, function( arg )\n    local arec, paras, q, n, e, R, z, zero, filter, Fam, A;\n\n    if Length( arg ) = 1 and IsRecord( arg[1] ) then\n      # The record is assumed to belong to the database of Singer algebras.\n      arec:= arg[1];\n      q:= arec.q;\n      n:= arec.n;\n      if IsBound( arec.z ) then\n        z:= arec.z;\n      elif IsBound( arec.e ) then\n        z:= ( q^n - 1 ) / arec.e;\n      else\n        Error( \"<arec> must contain one of the components z or e\" );\n      fi;\n      R:= Rationals;\n    elif Length( arg ) = 2 and IsRecord( arg[1] ) and IsRing( arg[2] ) then\n      # The record is assumed to belong to the database of Singer algebras.\n      arec:= arg[1];\n      q:= arec.q;\n      n:= arec.n;\n      if IsBound( arec.z ) then\n        z:= arec.z;\n      elif IsBound( arec.e ) then\n        z:= ( q^n - 1 ) / arec.e;\n      else\n        Error( \"<arec> must contain one of the components z or e\" );\n      fi;\n      R:= arg[2];\n    elif Length( arg ) = 1 and IsList( arg[1] ) then\n      # The parameters must be q, n, e[, R].\n      paras:= arg[1];\n      if Length( paras ) = 3 then\n        q:= paras[1];\n        n:= paras[2];\n        e:= paras[3];\n        R:= Rationals;\n      elif Length( paras ) = 4 then\n        q:= paras[1];\n        n:= paras[2];\n        e:= paras[3];\n        R:= paras[4];\n      else\n        Error( \"usage: SingerAlgebra( <list> ) with list of length 3 or 4\" );\n      fi;\n      z:= ( q^n - 1 ) / e;\n    elif Length( arg ) = 2 then\n      # The parameters must be q, z.\n      q:= arg[1];\n      z:= arg[2];\n      n:= OrderMod( q, z );\n      R:= Rationals;\n    elif Length( arg ) = 3 and IsInt( arg[3] ) then\n      # The parameters must be q, n, z.\n      q:= arg[1];\n      n:= arg[2];\n      z:= arg[3];\n      R:= Rationals;\n    elif Length( arg ) = 3 and IsRing( arg[3] ) then\n      # The parameters must be q, z, R.\n      q:= arg[1];\n      z:= arg[2];\n      R:= arg[3];\n      n:= OrderMod( q, z );\n    elif Length( arg ) = 4 then\n      # The parameters must be q, n, z, R.\n      q:= arg[1];\n      n:= arg[2];\n      z:= arg[3];\n      R:= arg[4];\n    else\n      Error( \"usage: SingerAlgebra( <arec>[, <R>] ) or \",\n             \"SingerAlgebra( <q>[, <n>], <z>[, <R>] ) or \",\n             \"SingerAlgebra( <list> )\" );\n    fi;\n\n    if not ( IsPosInt( q ) and IsPosInt( n ) and IsPosInt( z ) ) then\n      Error( \"<q>, <n>, <z> must be positive integers\" );\n    elif z <> 1 and PowerMod( q, n, z ) <> 1 then\n      Error( \"<z> must divide <q>^<n> - 1\" );\n    elif q = 1 then\n      Error( \"<q> must be an integer > 1\" );\n    fi;\n\n    # Create the algebra as far as necessary.\n    # (Do not set a 'Name' value, in order to use the different methods\n    # installed for 'ViewObj' and 'PrintObj'.)\n    zero := Zero( R );\n    filter:= IsSCAlgebraObj;\n    if IsAdditivelyCommutativeElementFamily( FamilyObj( zero ) ) then\n      filter:= filter and IsAdditivelyCommutativeElement;\n    fi;\n    Fam:= NewFamily( \"SCAlgebraObjFamily\", filter );\n    if Zero( ElementsFamily( FamilyObj( R ) ) ) <> fail then\n      SetFilterObj( Fam, IsFamilyOverFullCoefficientsFamily );\n    else\n      Fam!.coefficientsDomain:= R;\n    fi;\n    Fam!.zerocoeff := zero;\n    SetCharacteristic( Fam, Characteristic( R ) );\n    SetCoefficientsFamily( Fam, ElementsFamily( FamilyObj( R ) ) );\n\n    A:= Objectify( NewType( CollectionsFamily( Fam ),\n                   IsSingerAlgebra and IsAttributeStoringRep ),\n                   rec() );\n    SetLeftActingDomain( A, R );\n    SetParametersOfSingerAlgebra( A, [ q, n, z ] );\n    SetGeneratingSubsetOfCanonicalBasisOfSingerAlgebra( A, [ 1 .. z+1 ] );\n    SetDimension( A, z+1 );\n    Fam!.fullSCAlgebra:= A;\n    SetIsFullSCAlgebra( A, true );\n\n    return A;\n    end );\n\n\n#############################################################################\n##\n#M  Display( <A> )\n#M  ViewObj( <A> )\n#M  PrintObj( <A> )\n#M  DisplayString( <A> )\n#M  ViewString( <A> )\n#M  PrintString( <A> )\n#M  String( <A> )\n##\n##  According to the Section \"View and Print\" in the GAP Reference Manual,\n##  we need methods (only) for\n##  'String' (which then covers 'PrintString' and 'PrintObj') and\n##  'ViewString' (which then covers 'ViewObj').\n##  (We do not need 'DisplayString', which would cover 'Display'.)\n##\n##  We want to *view* Singer algebras as 'A[q,n,z[,R]]',\n##  and to *print* them as calls to 'SingerAlgebra'.\n##\nInstallMethod( ViewString,\n    [ \"IsSingerAlgebra\" ],\n    function( A )\n    local paras;\n\n    paras:= ParametersOfSingerAlgebra( A );\n    if LeftActingDomain( A ) = Rationals then\n      return Concatenation( \"A[\",\n                 JoinStringsWithSeparator( List( paras, String ), \",\" ),\n                 \"]\" );\n    else\n      return Concatenation( \"A[\",\n                 JoinStringsWithSeparator( List( paras, String ), \",\" ),\n                 \",\", String( LeftActingDomain( A ) ), \"]\" );\n    fi;\n    end );\n\nInstallMethod( String,\n    [ \"IsSingerAlgebra\" ],\n    function( A )\n    local paras;\n\n    paras:= ParametersOfSingerAlgebra( A );\n    if LeftActingDomain( A ) = Rationals then\n      return Concatenation( \"SingerAlgebra( \",\n                 JoinStringsWithSeparator( List( paras, String ), \", \" ),\n                 \" )\" );\n    else\n      return Concatenation( \"SingerAlgebra( \",\n                 JoinStringsWithSeparator( List( paras, String ), \", \" ),\n                 \", \", String( LeftActingDomain( A ) ), \" )\" );\n    fi;\n    end );\n\n#T Currently the above installations are unfortunately *not* enough,\n#T since some 'ViewObj' and 'PrintObj' methods for algebras interfere,\n#T as well as a 'PrintString' method for magmas.\n\nInstallMethod( ViewObj,\n    [ \"IsSingerAlgebra\" ],\n    function( A ) Print( ViewString( A ) ); end );\n\nInstallMethod( PrintObj,\n    [ \"IsSingerAlgebra\" ],\n    function( A ) Print( PrintString( A ) ); end );\n\nInstallMethod( PrintString,\n    [ \"IsSingerAlgebra\" ],\n    String );\n\n\n#############################################################################\n##\n#M  CanonicalBasis( <A> )\n##\n##  This method provides the internal data for treating the Singer algebra\n##  <A> as a structure constants algebra in GAP.\n##\n##  Formally, we require those filters that are required also by the\n##  GAP library method for full s.c. algebras,\n##  in order to guarantee a higher rank for our method;\n##  these filters are set in algebras returned by 'SingerAlgebra'.\n##\nInstallMethod( CanonicalBasis,\n    [ Concatenation( \"IsSingerAlgebra and IsFreeLeftModule and \",\n                     \"IsSCAlgebraObjCollection and IsFullSCAlgebra\" ) ],\n    function( A )\n    local paras, q, n, z, dim, coeffs, T, R, zero, one, empty, nonempty,\n          i, j, Fam, gens;\n\n    # Create the structure constants table.\n    paras:= ParametersOfSingerAlgebra( A );\n    q:= paras[1];\n    n:= paras[2];\n    z:= paras[3];\n    dim:= Dimension( A );\n    coeffs:= List( [ 0 .. z ],\n                   k -> CoefficientsQadicReversed( k, z, q, n ) );\n    T:= [];\n    R:= LeftActingDomain( A );\n    zero:= Zero( R );\n    one:= One( R );\n    empty:= MakeImmutable( [ [], [] ] );\n    nonempty:= List( [ 1 .. dim ],\n                     i -> MakeImmutable( [ [ i ], [ one ] ] ) );\n    for i in [ 1 .. dim ] do\n      T[i]:= [];\n      for j in [ 1 .. i-1 ] do\n        T[i][j]:= T[j][i];\n      od;\n      for j in [ i .. dim-i+1 ] do\n        if q <= MaximumList( coeffs[i] + coeffs[j], 0 ) then\n          T[i][j]:= empty;\n        else\n          T[i][j]:= nonempty[ i+j-1 ];\n        fi;\n      od;\n      for j in [ dim-i+2 .. dim ] do\n        T[i][j]:= empty;\n      od;\n    od;\n    T[ dim+1 ]:= 1;  # commutativity flag\n    T[ dim+2 ]:= zero;\n\n    # Set the necessary entries in the family.\n    Fam:= ElementsFamily( FamilyObj( A ) );\n    Fam!.sctable:= T;\n    Fam!.names:= MakeImmutable( List( [ 0 .. dim-1 ],\n                     i -> Concatenation( \"b\", String( i ) ) ) );\n    Fam!.zerocoeff:= zero;\n    Fam!.defaultTypeDenseCoeffVectorRep :=\n        NewType( Fam, IsSCAlgebraObj and IsDenseCoeffVectorRep );\n    SetZero( Fam, ObjByExtRep( Fam, ListWithIdenticalEntries( dim, zero ) ) );\n\n    # Set the algebra generators.\n    gens:= MakeImmutable( List( IdentityMat( dim, R ),\n               x -> ObjByExtRep( Fam, x ) ) );\n    SetGeneratorsOfAlgebra( A, gens );\n    SetGeneratorsOfAlgebraWithOne( A, gens );\n    SetOne( A, gens[1] );\n    Fam!.basisVectors:= gens;\n\n    # Delegate to the library method for full s.c. algebras,\n    # which has a lower rank.\n    TryNextMethod();\n    end );\n\n\n#############################################################################\n##\n#M  Representative( <A> )\n#M  GeneratorsOfAlgebra( <A> )\n#M  GeneratorsOfAlgebraWithOne( <A> )\n##\n##  Note that we cannot use 'RedispatchOnCondition' here,\n##  because we have only the attribute tester 'HasCanonicalBasis'\n##  that may be missing,\n##  whereas 'RedispatchOnCondition' checks for missing property values\n##  plus their testers.\n##\nInstallMethod( Representative,\n    [ \"IsSingerAlgebra\" ],\n    function( A )\n    if HasCanonicalBasis( A ) then\n      TryNextMethod();\n    fi;\n\n    # Set the necessary data and redispatch.\n    CanonicalBasis( A );\n    return Representative( A );\n    end );\n\n\nInstallMethod( GeneratorsOfAlgebra,\n    [ \"IsSingerAlgebra\" ],\n    function( A )\n    if HasCanonicalBasis( A ) then\n      TryNextMethod();\n    fi;\n\n    # Set the necessary data and redispatch.\n    CanonicalBasis( A );\n    return GeneratorsOfAlgebra( A );\n    end );\n\n\nInstallMethod( GeneratorsOfAlgebraWithOne,\n    [ \"IsSingerAlgebra\" ],\n    function( A )\n    if HasCanonicalBasis( A ) then\n      TryNextMethod();\n    fi;\n\n    # Set the necessary data and redispatch.\n    CanonicalBasis( A );\n    return GeneratorsOfAlgebraWithOne( A );\n    end );\n\n\n#############################################################################\n##\n#M  GeneratingSubsetOfCanonicalBasisOfSingerAlgebra( <triv> )\n##\n##  Provide a method for the trivial subspace/subalgebra of a Singer algebra.\n##  (We cannot be sure that this attribute gets set on creation.)\n##\nInstallMethod( GeneratingSubsetOfCanonicalBasisOfSingerAlgebra,\n    [ \"IsVectorSpace and HasParent\" ],\n    function( V )\n    if IsSingerAlgebra( Parent( V ) ) and IsTrivial( V ) then\n      return [];\n    fi;\n    TryNextMethod();\n    end );\n\n\n#############################################################################\n##\n#M  LoewyLengthGAP( <A> )\n#M  LoewyLengthGAP( <q>, <z> )\n#M  LoewyLengthGAP( <q>, <n>, <z>, <m> )\n##\n##  Use stored 'LoewyStructureInfoGAP' values,\n##  use the cheap criteria when the upper bound is attained (using <m>),\n##  compute 'LoewyStructureInfoGAP' only if necessary.\n##\nInstallMethod( LoewyLengthGAP,\n    [ \"IsSingerAlgebra and HasLoewyStructureInfoGAP\" ],\n    A -> LoewyStructureInfoGAP( A ).LL );\n\nInstallMethod( LoewyLengthGAP,\n    [ \"IsSingerAlgebra\" ],\n    function( A )\n    local m, paras;\n\n    # We need m(q,e) anyhow in order to compute the upper bound\n    # to which the cheap criteria refer.\n    m:= MinimalDegreeOfSingerAlgebraGAP( A );\n    if HasLoewyStructureInfoGAP( A ) then\n      # Perhaps the computation of 'm' has triggered this.\n      return LoewyStructureInfoGAP( A ).LL;\n    else\n      paras:= ParametersOfSingerAlgebra( A );\n      return LoewyLengthGAP( paras[1], paras[2], paras[3], m );\n    fi;\n    end );\n\nInstallMethod( LoewyLengthGAP,\n    [ \"IsPosInt\", \"IsPosInt\" ],\n    function( q, z )\n    local n;\n\n    n:= OrderMod( q, z );\n    return LoewyLengthGAP( q, n, z,\n               MinimalDegreeOfSingerAlgebraGAP( q, SingerAlgE( q, n, z ) ) );\n    end );\n\nInstallMethod( LoewyLengthGAP,\n    [ \"IsPosInt\", \"IsPosInt\", \"IsPosInt\", \"IsPosInt\" ],\n    function( q, n, z, m )\n    local l;\n\n    l:= LoewyLengthCheapGAP( q, n, z, m );\n    if l = 0 then\n      l:= LoewyLengthHardGAP( q, n, z, m );\n    fi;\n    return l;\n    end );\n\n\n#############################################################################\n##\n#F  OrderModExt( <n>, <m>[, <bound>] )\n##\n##  The optional argument <bound> is not yet supported for 'OrderMod'\n##  in GAP 4.11.0, but it is useful in the context of this package.\n##\nInstallGlobalFunction( OrderModExt, function( n, m, bound... )\n    local  x, o, d;\n\n    # check the arguments and reduce $n$ into the range $0..m-1$\n    if m <= 0  then Error(\"<m> must be positive\");  fi;\n    if n < 0   then n := n mod m + m;  fi;\n    if m <= n  then n := n mod m;      fi;\n\n    # return 0 if $m$ is not coprime to $n$\n    if GcdInt(m,n) <> 1  then\n        o := 0;\n\n    # compute the order simply by iterated multiplying, $x= n^o$ mod $m$\n    elif m < 100  then\n        x := n;  o := 1;\n        while x > 1  do\n            x := x * n mod m;  o := o + 1;\n        od;\n\n    # otherwise try the divisors of $\\lambda(m)$ and their divisors, etc.\n    else\n        if Length( bound ) = 1 then\n            # We know a multiple of the desired order.\n            o := bound[1];\n        else\n            # The default a priori known multiple is 'Lambda( m )'.\n            o := Lambda( m );\n        fi;\n        for d in PrimeDivisors( o ) do\n            while o mod d = 0  and PowerModInt(n,o/d,m) = 1  do\n                o := o / d;\n            od;\n        od;\n\n    fi;\n\n    return o;\n    end );\n\n\n#############################################################################\n##\n#F  SufficientCriterionForLoewyBoundAttained( <q>, <n>, <z>, <m> )\n##\nInstallGlobalFunction( SufficientCriterionForLoewyBoundAttained,\n    function( q, n, z, m )\n    local qm, e, r, p, sum, d, phi6;\n\n    if n <= 3 then\n      return \"Cor. I.7.1 (n <= 3)\";\n    elif z < 70 then\n      # The bound is attained, by the classif. of small dim. Singer alg.\n      return \"z < 70\";\n    elif m = 2 then\n      return \"La. I.6.3\";\n    elif ( q - 1 ) mod m = 0 then\n      return \"Thm. I.7.1\";\n    elif n * (q-1) < 3 * m then\n      return \"La. I.7.1 (iii)\";\n    fi;\n\n    qm:= q mod m;\n    if 1 < qm and Int( n * ( qm-1 ) / m ) = 1 then\n      return \"Prop. II.3.15\";\n    fi;\n\n    e:= ( q^n - 1 ) / z;\n\n    if e <= 32 then\n      return \"Prop. II.6.1 (e <= 32)\";\n    elif e <= 3 * m then\n      return \"Prop. II.6.4\";\n    elif n <= 5 and ((q^n-1)/(q-1)) mod e = 0 then\n      return \"Prop. II.5.3, II.5.6 (e | (q^n-1)/(q-1), n <= 5)\";\n    elif n mod ( m / Gcd( m, q-1 ) * OrderModExt( q, e, n ) ) = 0 then\n      return \"La. II.5.2 (ii)\";\n    fi;\n\n    if ( (q^n-1)/(q-1) ) mod e = 0 then\n      # we know m <= n\n      if m >= n-1 then\n        return \"Prop. II.5.1 (ii)\";\n      elif  m = n-2 and ( q mod m ) in [ 1 .. Int( (m+1)/2 ) ] then\n        return \"Prop. II.5.1 (iii)\";\n      elif Int( (n-m) * (q-1) / m ) mod ( n-m ) = 0 then\n        return \"Prop. II.5.1 (i)\";\n      fi;\n    fi;\n\n    if ( n mod m = 0 ) then\n      if Sum( List( [ 0 .. m-1 ], i -> q^(i*n/m) ) ) mod e = 0 then\n        return \"La. II.4.1 for r = 1\";\n      fi;\n      for r in DivisorsInt( n ) do\n        if (n/r) mod m = 0 and\n           Sum( [ 0 .. m-1 ], i -> q^(n*i/(m*r)) ) mod e = 0 then\n          return \"La. II.4.1\";\n        fi;\n      od;\n    fi;\n\n    p:= SmallestRootInt( e );\n\n    if p = 2 then\n      return \"Thm. II.4.3 (iii)\";\n    elif IsPrimeInt( p ) then\n      # (Here we know that 'q mod p <> 1' holds.)\n      # Check whether 'p' is a Pierpont prime.\n      p:= p - 1;\n      while p mod 2 = 0 do\n        p:= p/2;\n      od;\n      while p mod 3 = 0 do\n        p:= p/3;\n      od;\n      if p = 1 then\n        return \"Thm. II.4.3 (ii)\";\n      fi;\n    fi;\n\n    # Concerning Remark II.5.4,\n    # we need not check \\Phi_2 (since m = e if e divides q-1,\n    # and we have checked whether m divides q-1),\n    # \\Phi_4, \\Phi_8 (because then m = 2).\n    phi6:= q^2 - q + 1;    # this is \\Phi_6(q)\n    if phi6 mod e = 0 or\n       ( q^3*(q^3+1) + 1 ) mod e = 0 or     # this is \\Phi_9(q)\n       ( q^3*(q-1) + phi6 ) mod e = 0 then  # this is \\Phi_{10}(q)\n      return \"Rem. II.5.4\";\n    fi;\n\n    # We give up.\n    return \"\";\n    end );\n\nInstallGlobalFunction( LoewyLengthCheapGAP, function( q, n, z, m )\n    if SufficientCriterionForLoewyBoundAttained( q, n, z, m ) <> \"\" then\n      return Int( n * ( q - 1 ) / m ) + 1;\n    else\n      return 0;\n    fi;\n    end );\n\nInstallGlobalFunction( LoewyLengthHardGAP,\n    { q, n, z, m } -> LoewyStructureInfoGAP( q, n, z ).LL );\n\n\n#############################################################################\n##\n#M  LoewyLengthJulia( <A> )\n#M  LoewyLengthJulia( <q>, <z> )\n#M  LoewyLengthJulia( <q>, <n>, <z>, <m> )\n##\n##  Use the same criteria as for the &GAP; variant.\n##  These methods are available only if &Julia; is available.\n##\nif IsPackageMarkedForLoading( \"JuliaInterface\", \"\" ) then\n\nInstallMethod( LoewyLengthJulia,\n    [ \"IsSingerAlgebra and HasLoewyStructureInfoJulia\" ],\n    A -> JuliaToGAP( IsInt,\n             Julia.Base.get( LoewyStructureInfoJulia( A ),\n                             JuliaSymbol( \"LL\" ), 0 )  ));\n\nInstallMethod( LoewyLengthJulia,\n    [ \"IsSingerAlgebra\" ],\n    function( A )\n    local paras;\n\n    paras:= ParametersOfSingerAlgebra( A );\n\n    # Leave the computation of m(q,e) and of the Loewy length to Julia,\n    # let Julia set also the 'MinimalDegreeOfSingerAlgebraJulia' value in A.\n    return JuliaToGAP( IsInt,\n               Julia.SingerAlg.LoewyLength( paras[1], paras[2], paras[3],\n                   A ) );\n    end );\n\nInstallMethod( LoewyLengthJulia,\n    [ \"IsPosInt\", \"IsPosInt\" ],\n    function( q, z )\n    return JuliaToGAP( IsInt, Julia.SingerAlg.LoewyLength( q, z ) );\n    end );\n\nInstallMethod( LoewyLengthJulia,\n    [ \"IsPosInt\", \"IsPosInt\", \"IsPosInt\", \"IsPosInt\" ],\n    function( q, n, z, m )\n    return JuliaToGAP( IsInt,\n               Julia.SingerAlg.LoewyLength( q, n, z, m ) );\n    end );\n\nfi;\n\n\n#############################################################################\n##\n#M  RadicalOfAlgebra( <A> )\n##\n##  The Jacobson radical of a Singer algebra of dimension <M>z+1</M>\n##  has the basis <M>[ b_1, b_2, \\ldots, b_z ]</M>.\n##\nInstallMethod( RadicalOfAlgebra,\n    [ \"IsSingerAlgebra\" ],\n    function( A )\n    local B, range, S;\n\n    B:= BasisVectors( CanonicalBasis( A ) );\n    range:= [ 2 .. Length( B ) ];\n    S:= SubalgebraNC( A, B{ range }, \"basis\" );\n    SetGeneratingSubsetOfCanonicalBasisOfSingerAlgebra( S, range );\n\n    return S;\n    end );\n\n\n#############################################################################\n##\n#M  RadicalSeriesOfAlgebra( <A> )\n##\nInstallMethod( RadicalSeriesOfAlgebra,\n    [ \"IsSingerAlgebra\" ],\n    function( A )\n    local result, data, B, i, S;\n\n    result:= [ A, RadicalOfAlgebra( A ) ];\n    data:= LoewyStructureInfoGAP( A );\n    data:= SingerAlg.BasesOfRadicalSeries( data );\n    B:= BasisVectors( CanonicalBasis( A ) );\n    for i in [ 2 .. Length( data ) ] do\n      S:= SubalgebraNC( A, B{ data[i] }, \"basis\" );\n      SetGeneratingSubsetOfCanonicalBasisOfSingerAlgebra( S, data[i] );\n      result[i+1]:= S;\n    od;\n    Add( result, TrivialSubalgebra( A ) );\n\n    return result;\n    end );\n\n\n#############################################################################\n##\n#M  SocleSeriesOfAlgebra( <A> )\n##\nInstallMethod( SocleSeriesOfAlgebra,\n    [ \"IsSingerAlgebra\" ],\n    function( A )\n    local result, data, B, i, S;\n\n    result:= [ TrivialSubalgebra( A ) ];\n    data:= LoewyStructureInfoGAP( A );\n    data:= SingerAlg.BasesOfSocleSeries( data );\n    B:= BasisVectors( CanonicalBasis( A ) );\n    for i in [ 1 .. Length( data ) ] do\n      S:= SubalgebraNC( A, B{ data[i] }, \"basis\" );\n      SetGeneratingSubsetOfCanonicalBasisOfSingerAlgebra( S, data[i] );\n      result[i+1]:= S;\n    od;\n    Add( result, A );\n\n    return result;\n    end );\n\n\n#############################################################################\n##\n#M  Intersection2( <A>, <B> )\n##\nInstallMethod( Intersection2,\n    IsIdenticalObj,\n    [ \"IsVectorSpace and HasGeneratingSubsetOfCanonicalBasisOfSingerAlgebra\",\n      \"IsVectorSpace and HasGeneratingSubsetOfCanonicalBasisOfSingerAlgebra\" ],\n    100,  # beat generic methods for two 'IsFLMLORWithOne'\n    function( A, B )\n    local P, basis, data, S;\n\n    P:= Parent( A );\n    if not IsIdenticalObj( P, Parent( B ) ) then\n      TryNextMethod();\n    fi;\n    basis:= BasisVectors( CanonicalBasis( P ) );\n    data:= Intersection2(\n               GeneratingSubsetOfCanonicalBasisOfSingerAlgebra( A ),\n               GeneratingSubsetOfCanonicalBasisOfSingerAlgebra( B ) );\n    S:= SubspaceNC( P, basis{ data }, \"basis\" );\n    SetGeneratingSubsetOfCanonicalBasisOfSingerAlgebra( S, data );\n\n    return S;\n    end );\n\n\n#############################################################################\n##\n#M  \\+( <A>, <B> )\n##\nInstallOtherMethod( \\+,\n    IsIdenticalObj,\n    [ \"IsVectorSpace and HasGeneratingSubsetOfCanonicalBasisOfSingerAlgebra\",\n      \"IsVectorSpace and HasGeneratingSubsetOfCanonicalBasisOfSingerAlgebra\" ],\n    100,  # beat generic methods for two rings, two left modules\n    function( A, B )\n    local P, basis, data, S;\n\n    P:= Parent( A );\n    if not IsIdenticalObj( P, Parent( B ) ) then\n      TryNextMethod();\n    fi;\n    basis:= BasisVectors( CanonicalBasis( P ) );\n    data:= Union(\n               GeneratingSubsetOfCanonicalBasisOfSingerAlgebra( A ),\n               GeneratingSubsetOfCanonicalBasisOfSingerAlgebra( B ) );\n    S:= SubspaceNC( P, basis{ data }, \"basis\" );\n    SetGeneratingSubsetOfCanonicalBasisOfSingerAlgebra( S, data );\n\n    return S;\n    end );\n\n\n#############################################################################\n##\n#M  ProductSpace( <A>, <B> )\n##\nInstallMethod( ProductSpace,\n    IsIdenticalObj,\n    [ \"IsVectorSpace and HasGeneratingSubsetOfCanonicalBasisOfSingerAlgebra\",\n      \"IsVectorSpace and HasGeneratingSubsetOfCanonicalBasisOfSingerAlgebra\" ],\n    100,  # beat generic methods for two algebras, two left modules\n    function( A, B )\n    local P, basis, data, S;\n\n    P:= Parent( A );\n    if not IsIdenticalObj( P, Parent( B ) ) then\n      TryNextMethod();\n    fi;\n    basis:= BasisVectors( CanonicalBasis( P ) );\n    data:= LoewyStructureInfoGAP( P );\n    data:= SingerAlg.BasisOfProductSpace( data,\n               GeneratingSubsetOfCanonicalBasisOfSingerAlgebra( A ),\n               GeneratingSubsetOfCanonicalBasisOfSingerAlgebra( B ) );\n    S:= SubspaceNC( P, basis{ data }, \"basis\" );\n    SetGeneratingSubsetOfCanonicalBasisOfSingerAlgebra( S, data );\n\n    return S;\n    end );\n\n\n#############################################################################\n##\n#F  CoefficientsQadicReversed( <k>, <z>, <q>, <n> )\n##\nInstallGlobalFunction( CoefficientsQadicReversed, function( k, z, q, n )\n    local v, i, r, rq, d;\n\n    v:= [];\n\n    if k = z then\n      for i in [ 1 .. n ] do\n        v[i]:= q-1;\n      od;\n    else\n      r:= k;\n      for i in [ 1 .. n ] do\n        rq:= r * q;\n        d:= QuoInt( rq, z );\n        r:= rq - d * z;\n        v[i]:= d;\n      od;\n    fi;\n\n    return v;\n    end );\n\n\n#############################################################################\n##\n#F  SingerAlg.MultTable( <data> )\n##\n##  <#GAPDoc Label=\"SingerAlg.MultTable\">\n##  <ManSection>\n##  <Func Name=\"SingerAlg.MultTable\" Arg='data'/>\n##\n##  <Description>\n##  Let <A>data</A> be the record returned by\n##  <Ref Oper=\"LoewyStructureInfoGAP\" Label=\"for parameters\"/>\n##  that describes a Singer algebra <M>A[q,z]</M>,\n##  and let <M>B = B(A)</M>.\n##  <Ref Func=\"SingerAlg.MultTable\"/> returns the\n##  <M>(z+1) \\times (z+1)</M> matrix that contains at the position\n##  <M>(i,j)</M> the value <M>i+j-1</M> if the product\n##  <M>B_i \\cdot B_j</M> is nonzero\n##  (hence equal to <M>B_{{i+j-1}}</M>, the <M>i+j-1</M>-th basis vector),\n##  and <M>0</M> otherwise.\n##  <P/>\n##  <Example><![CDATA[\n##  gap> data:= LoewyStructureInfoGAP( 2, 3, 7 );;\n##  gap> Display( SingerAlg.MultTable( data ) );\n##  [ [  1,  2,  3,  4,  5,  6,  7,  8 ],\n##    [  2,  0,  4,  0,  6,  0,  8,  0 ],\n##    [  3,  4,  0,  0,  7,  8,  0,  0 ],\n##    [  4,  0,  0,  0,  8,  0,  0,  0 ],\n##    [  5,  6,  7,  8,  0,  0,  0,  0 ],\n##    [  6,  0,  8,  0,  0,  0,  0,  0 ],\n##    [  7,  8,  0,  0,  0,  0,  0,  0 ],\n##    [  8,  0,  0,  0,  0,  0,  0,  0 ] ]\n##  ]]></Example>\n##  <P/>\n##  The multiplication table of a Singer algebra of dimension <M>N</M>\n##  has the value <M>N</M> on the antidiagonal (<M>i+j = N+1</M>),\n##  is zero below the antidiagonal,\n##  and contains only <M>N-i</M> and zero on the <M>i</M> parallel above the\n##  antidiagonal.\n##  </Description>\n##  </ManSection>\n##  <#/GAPDoc>\n##\nSingerAlg.MultTable:= function( data )\n    local monoms, n, nn, mat, q, qhalf, i, j;\n\n    if not IsBound( data.multtable ) then\n      monoms:= data.monomials;\n      n:= Length( monoms ); # z+1\n      nn:= QuoInt( n+1, 2 );\n      mat:= NullMat( n, n );\n      q:= data.parameters[1];\n      if q mod 2 = 1 then\n        qhalf:= QuoInt( q, 2 ) + 1;\n      else\n        qhalf:= QuoInt( q, 2 );\n      fi;\n      for i in [ 1 .. nn ] do \n        for j in [ 1 .. i-1 ] do \n          if ForAll( monoms[i] + monoms[j], x -> x < q ) then\n            mat[i,j]:= i+j-1;\n            mat[j,i]:= i+j-1;\n          fi;\n        od;\n        if ForAll( monoms[i], x -> x < qhalf ) then\n          mat[i,i]:= i+i-1;\n        fi;\n      od;\n      for i in [ nn+1 .. n ] do \n        # The [i,j] entry can be nonzero only if i+j <= z+2 holds.\n        for j in [ 1 .. n+1-i ] do \n          if ForAll( monoms[i] + monoms[j], x -> x < q ) then\n            mat[i,j]:= i+j-1;\n            mat[j,i]:= i+j-1;\n          fi;\n        od;\n      od;\n      data.multtable:= mat;\n    fi;\n\n    return data.multtable;\n    end;\n\n\n#############################################################################\n##\n#F  SingerAlg.BasisOfSum( <data>, <I>, <J> )\n#F  SingerAlg.BasisOfIntersection( <data>, <I>, <J> )\n##\n##  <#GAPDoc Label=\"SingerAlg.BasisOfSum\">\n##  <ManSection>\n##  <Heading>SingerAlg.BasisOfSum and SingerAlg.BasisOfIntersection</Heading>\n##  <Func Name=\"SingerAlg.BasisOfSum\" Arg='data, I, J'/>\n##  <Func Name=\"SingerAlg.BasisOfIntersection\" Arg='data, I, J'/>\n##\n##  <Description>\n##  For two subsets <A>I</A>, <A>J</A> of <M>\\{ 1, 2, \\ldots, z+1 \\}</M>,\n##  these functions just return the union and the intersection,\n##  respectively, of <A>I</A> and <A>J</A>.\n##  <P/>\n##  <A>I</A> and <A>J</A> describe subsets of a basis, which generate the\n##  spaces <M>U</M> and <M>V</M>, say, then the result describes the subset\n##  of this basis that generates the sum and the intersection, respectively,\n##  of <M>U</M> and <M>V</M>.\n##  <P/>\n##  <Example><![CDATA[\n##  gap> SingerAlg.BasisOfSum( data, [ 1, 2, 3 ], [ 2, 4, 6 ] );\n##  [ 1, 2, 3, 4, 6 ]\n##  gap> SingerAlg.BasisOfIntersection( data, [ 1, 2, 3 ], [ 2, 4, 6 ] );\n##  [ 2 ]\n##  ]]></Example>\n##  </Description>\n##  </ManSection>\n##  <#/GAPDoc>\n##\nSingerAlg.BasisOfSum:= { data, I, J } -> Union( I, J );\n\nSingerAlg.BasisOfIntersection:= { data, I, J } -> Intersection( I, J );\n\n\n#############################################################################\n##\n#F  SingerAlg.BasisOfProductSpace( <data>, <I>, <J> )\n##\n##  <#GAPDoc Label=\"SingerAlg.BasisOfProductSpace\">\n##  <ManSection>\n##  <Func Name=\"SingerAlg.BasisOfProductSpace\" Arg='data, I, J'/>\n##\n##  <Description>\n##  Let <A>data</A> be the record returned by\n##  <Ref Oper=\"LoewyStructureInfoGAP\" Label=\"for parameters\"/>\n##  that describes a Singer algebra <M>A = A[q,z]</M>,\n##  let <M>B = B(A)</M>,\n##  and let <A>I</A>, <A>J</A> be subsets of\n##  <M>\\{ 1, 2, \\ldots, z+1 \\}</M>,\n##  describing subspaces <M>U</M>, <M>V</M> of <M>A</M> with bases\n##  <M>( B_i; i \\in I )</M> and <M>( B_i; i \\in J )</M>, respectively.\n##  <Ref Func=\"SingerAlg.BasisOfProductSpace\"/> returns the subset <M>K</M>\n##  of <M>\\{ 1, 2, \\ldots, z+1 \\}</M> such that\n##  <M>( B_i; i \\in K )</M> is a basis of the product space <M>U \\cdot V</M>.\n##  <P/>\n##  <Example><![CDATA[\n##  gap> data:= LoewyStructureInfoGAP( 2, 7 );;\n##  gap> radser:= SingerAlg.BasesOfRadicalSeries( data );\n##  [ [ 2 .. 8 ], [ 4, 6, 7, 8 ], [ 8 ] ]\n##  gap> SingerAlg.BasisOfProductSpace( data, radser[1], radser[1] );\n##  [ 4, 6, 7, 8 ]\n##  gap> SingerAlg.BasisOfProductSpace( data, radser[1], radser[2] );\n##  [ 8 ]\n##  gap> SingerAlg.BasisOfProductSpace( data, radser[2], radser[2] );\n##  [  ]\n##  ]]></Example>\n##  </Description>\n##  </ManSection>\n##  <#/GAPDoc>\n##\nSingerAlg.BasisOfProductSpace:= function( data, I, J )\n    local mat, basis, i, j;\n\n    mat:= SingerAlg.MultTable( data );\n    basis:= [];\n\n    for i in I do\n      for j in J do\n        if mat[i,j] <> 0 then\n          AddSet( basis, i+j-1 );\n        fi;\n      od;\n    od;\n\n    return basis;\n    end;\n\n\n#############################################################################\n##\n#F  SingerAlg.BasisOfIdeal( <data>, <I> )\n##\n##  <#GAPDoc Label=\"SingerAlg.BasisOfIdeal\">\n##  <ManSection>\n##  <Func Name=\"SingerAlg.BasisOfIdeal\" Arg='data, I'/>\n##\n##  <Description>\n##  Let <A>data</A> be the record returned by\n##  <Ref Oper=\"LoewyStructureInfoGAP\" Label=\"for parameters\"/>\n##  that describes a Singer algebra <M>A = A[q,z]</M>,\n##  let <M>B = B(A)</M>,\n##  and let <A>I</A> be a subset of <M>\\{ 1, 2, \\ldots, z+1 \\}</M>,\n##  describing a subspace <M>U</M> of <M>A</M> with basis\n##  <M>( B_i; i \\in I )</M>.\n##  <Ref Func=\"SingerAlg.BasisOfIdeal\"/> returns the subset <M>J</M>\n##  of <M>\\{ 1, 2, \\ldots, z+1 \\}</M> such that\n##  <M>( B_i; i \\in J )</M> is a basis of the ideal <M>U \\cdot A</M>.\n##  <P/>\n##  <Example><![CDATA[\n##  gap> data:= LoewyStructureInfoGAP( 2, 7 );;\n##  gap> SingerAlg.BasisOfIdeal( data, [ 4 ] );\n##  [ 4, 8 ]\n##  ]]></Example>\n##  </Description>\n##  </ManSection>\n##  <#/GAPDoc>\n##\nSingerAlg.BasisOfIdeal:= { data, I } -> SingerAlg.BasisOfProductSpace( data,\n              I, [ 1 .. Length( data.monomials ) ] );\n\n\n#############################################################################\n##\n#F  SingerAlg.BasisOfAnnihilator( <data>, <I> )\n##\n##  <#GAPDoc Label=\"SingerAlg.BasisOfAnnihilator\">\n##  <ManSection>\n##  <Func Name=\"SingerAlg.BasisOfAnnihilator\" Arg='data, I'/>\n##\n##  <Description>\n##  Let <A>data</A> be the record returned by\n##  <Ref Oper=\"LoewyStructureInfoGAP\" Label=\"for parameters\"/>\n##  that describes a Singer algebra <M>A = A[q,z]</M>,\n##  let <M>B = B(A)</M>,\n##  and let <A>I</A> be a subset of <M>\\{ 1, 2, \\ldots, z+1 \\}</M>,\n##  describing a subspace <M>U</M> of <M>A</M> with basis\n##  <M>( B_i; i \\in I )</M>.\n##  <Ref Func=\"SingerAlg.BasisOfAnnihilator\"/> returns the subset <M>J</M>\n##  of <M>\\{ 1, 2, \\ldots, z+1 \\}</M> such that\n##  <M>( B_i; i \\in J )</M> is a basis of the annihilator\n##  <M>\\{ x \\in A; x \\cdot U = 0 \\}</M> of <M>U</M> in <M>A</M>.\n##  <P/>\n##  <Example><![CDATA[\n##  gap> data:= LoewyStructureInfoGAP( 2, 7 );;\n##  gap> radser:= SingerAlg.BasesOfRadicalSeries( data );\n##  [ [ 2 .. 8 ], [ 4, 6, 7, 8 ], [ 8 ] ]\n##  gap> List( radser, I -> SingerAlg.BasisOfAnnihilator( data, I ) );\n##  [ [ 8 ], [ 4, 6, 7, 8 ], [ 2, 3, 4, 5, 6, 7, 8 ] ]\n##  ]]></Example>\n##  </Description>\n##  </ManSection>\n##  <#/GAPDoc>\n##\nSingerAlg.BasisOfAnnihilator:= function( data, list )\n    local mat;\n\n    mat:= SingerAlg.MultTable( data );\n    return Filtered( [ 1 .. Length( mat ) ],\n                     i -> ForAll( list, j -> mat[i,j] = 0 ) );\n    end;\n\n\n#############################################################################\n##\n#F  SingerAlg.BasesOfRadicalSeries( <data> )\n##\n##  <#GAPDoc Label=\"SingerAlg.BasesOfRadicalSeries\">\n##  <ManSection>\n##  <Func Name=\"SingerAlg.BasesOfRadicalSeries\" Arg='data'/>\n##\n##  <Description>\n##  Let <A>data</A> be the record returned by\n##  <Ref Oper=\"LoewyStructureInfoGAP\" Label=\"for parameters\"/>\n##  that describes a Singer algebra <M>A = A[q,z]</M>,\n##  and let <M>B = B(A)</M>.\n##  <Ref Func=\"SingerAlg.BasesOfRadicalSeries\"/> returns the list\n##  <M>[ I_1, I_2, \\ldots, I_l ]</M> of subsets of\n##  <M>\\{ 1, 2, \\ldots, z+1 \\}</M> such that\n##  <M>( B_i; i \\in I_j )</M> is a basis of the <M>j</M>-th power of the\n##  Jacobson radical <M>J</M> of <M>A</M>,\n##  and such that <M>J^l</M> is nonzero and <M>J^{{l+1}}</M> is zero.\n##  <P/>\n##  <Example><![CDATA[\n##  gap> data:= LoewyStructureInfoGAP( 2, 7 );;\n##  gap> radser:= SingerAlg.BasesOfRadicalSeries( data );\n##  [ [ 2 .. 8 ], [ 4, 6, 7, 8 ], [ 8 ] ]\n##  ]]></Example>\n##  </Description>\n##  </ManSection>\n##  <#/GAPDoc>\n##\nSingerAlg.BasesOfRadicalSeries:= function( data )\n    local lay, ll, jbylayer, J, i;\n\n    lay:= data.layers;\n    ll:= data.LL;\n    jbylayer:= List( [ 1 .. ll-1 ], i -> Positions( lay, i ) );\n    J:= [ jbylayer[ ll-1 ] ];\n    for i in [ 2 .. ll-1 ] do\n      J[i]:= Union( J[ i-1 ], jbylayer[ ll - i ] );\n    od;\n\n    return Reversed( J );\n    end;\n\n\n#############################################################################\n##\n#F  SingerAlg.BasesOfSocleSeries( <data> )\n##\n##  <#GAPDoc Label=\"SingerAlg.BasesOfSocleSeries\">\n##  <ManSection>\n##  <Func Name=\"SingerAlg.BasesOfSocleSeries\" Arg='data'/>\n##\n##  <Description>\n##  Let <A>data</A> be the record returned by\n##  <Ref Oper=\"LoewyStructureInfoGAP\" Label=\"for parameters\"/>\n##  that describes a Singer algebra <M>A = A[q,z]</M>,\n##  and let <M>B = B(A)</M>.\n##  <Ref Func=\"SingerAlg.BasesOfSocleSeries\"/> returns the list \n##  <M>[ I_1, I_2, \\ldots, I_l ]</M> of subsets of \n##  <M>\\{ 1, 2, \\ldots, z+1 \\}</M> such that\n##  <M>( B_i; i \\in I_j )</M> is a basis of <M>S_j</M>,\n##  where <M>S_1</M> is the socle of <M>A</M>,\n##  <M>S_{{j+1}}/S_j</M> is the socle of <A>A</A><M>/S_j</M>,\n##  and <A>A</A><M>/S_l</M> is nonzero and its own socle.\n##  <P/>\n##  <Example><![CDATA[\n##  gap> socser:= SingerAlg.BasesOfSocleSeries( data );\n##  [ [ 8 ], [ 4, 6, 7, 8 ], [ 2 .. 8 ] ]\n##  ]]></Example>\n##  </Description>\n##  </ManSection>\n##  <#/GAPDoc>\n##\nSingerAlg.BasesOfSocleSeries:= function( data )\n    local lay, ll, sbylayer, S, i;\n\n    lay:= Reversed( data.layers );\n    ll:= data.LL;\n    sbylayer:= List( [ 0 .. ll-2 ], i -> Positions( lay, i ) );\n    S:= [ sbylayer[ 1 ] ];\n    for i in [ 2 .. ll-1 ] do\n      S[i]:= Union( S[ i-1 ], sbylayer[i] );\n    od;\n\n    return S;\n    end;\n\n\n#############################################################################\n##\n#F  SingerAlg.BasisOfPowers( <data>, <I>, <p>, <m> )\n##\n##  <#GAPDoc Label=\"SingerAlg.BasisOfPowers\">\n##  <ManSection>\n##  <Func Name=\"SingerAlg.BasisOfPowers\" Arg='data, I, p, m'/>\n##\n##  <Description>\n##  Let <A>p</A> be a prime integer,\n##  let <A>data</A> be the record returned by\n##  <Ref Oper=\"LoewyStructureInfoGAP\" Label=\"for parameters\"/>\n##  that describes a Singer algebra <M>A = A[q,z]</M>,\n##  let <M>B = B(A_p)</M>,\n##  let <A>I</A> be a subset of <M>\\{ 1, 2, \\ldots, z+1 \\}</M>,\n##  describing a subspace <M>U</M> of <M>A_p</M> with basis\n##  <M>( B_i; i \\in I )</M>,\n##  and let <A>m</A> be a positive integer.\n##  <Ref Func=\"SingerAlg.BasisOfPowers\"/> returns the subset <M>J</M>\n##  of <M>\\{ 1, 2, \\ldots, z+1 \\}</M> such that\n##  <M>( B_i; i \\in J )</M> is a basis of the subspace\n##  <M>\\{ x^{{p^m}}; x \\in U \\}</M> of <M>A_p</M>.\n##  <P/>\n##  <Example><![CDATA[\n##  gap> data:= LoewyStructureInfoGAP( 3, 8 );;\n##  gap> SingerAlg.BasisOfPowers( data, [ 1 .. 9 ], 2, 1 );\n##  [ 1, 3, 7, 9 ]\n##  gap> SingerAlg.BasisOfPowers( data, [ 1 .. 9 ], 2, 2 );\n##  [ 1 ]\n##  gap> SingerAlg.BasisOfPowers( data, [ 1 .. 9 ], 3, 1 );\n##  [ 1 ]\n##  ]]></Example>\n##  </Description>\n##  </ManSection>\n##  <#/GAPDoc>\n##\nSingerAlg.BasisOfPowers:= function( data, I, p, m )\n    local result, q, pm, quo, k;\n\n    result:= [];\n    q:= data.parameters[1];\n    pm:= p^m;\n    quo:= QuoInt( q-1, pm );\n    for k in I do\n      if Maximum( data.monomials[k] ) <= quo then\n        Add( result, pm * ( k-1 ) + 1 );\n      fi;\n    od;\n\n    return result;\n    end;\n\n\n#############################################################################\n##\n#F  SingerAlg.BasisOfPMRoots( <data>, <I>, <p>, <m> )\n##\n##  <#GAPDoc Label=\"SingerAlg.BasisOfPMRoots\">\n##  <ManSection>\n##  <Func Name=\"SingerAlg.BasisOfPMRoots\" Arg='data, I, p, m'/>\n##\n##  <Description>\n##  Let <A>p</A> be a prime integer,\n##  let <A>data</A> be the record returned by\n##  <Ref Oper=\"LoewyStructureInfoGAP\" Label=\"for parameters\"/>\n##  that describes a Singer algebra <M>A = A[q,z]</M>,\n##  let <M>B = B(A_p)</M>,\n##  let <A>I</A> be a subset of <M>\\{ 1, 2, \\ldots, z+1 \\}</M>,\n##  describing a subspace <M>U</M> of <M>A_p</M> with basis\n##  <M>( B_i; i \\in I )</M>,\n##  and let <A>m</A> be a positive integer.\n##  (See Section <Ref Sect=\"sect:Singer algebras\"/> for the definition of\n##  <M>A_p</M>.)\n##  <P/>\n##  <Ref Func=\"SingerAlg.BasisOfPMRoots\"/> returns the subset <M>J</M>\n##  of <M>\\{ 1, 2, \\ldots, z+1 \\}</M> such that\n##  <M>( B_i; i \\in J )</M> is a basis of the subspace\n##  <M>\\{ x \\in A_p; x^{{p^m}} \\in U \\}</M> of <M>A_p</M>.\n##  <P/>\n##  <Example><![CDATA[\n##  gap> data:= LoewyStructureInfoGAP( 3, 8 );;\n##  gap> SingerAlg.BasisOfPMRoots( data, [], 2, 1 );\n##  [ 3, 6, 7, 8, 9 ]\n##  gap> SingerAlg.BasisOfPMRoots( data, [], 2, 2 );\n##  [ 2, 3, 4, 5, 6, 7, 8, 9 ]\n##  gap> SingerAlg.BasisOfPMRoots( data, [ 3 ], 2, 1 );\n##  [ 2, 3, 6, 7, 8, 9 ]\n##  ]]></Example>\n##  </Description>\n##  </ManSection>\n##  <#/GAPDoc>\n##\nSingerAlg.BasisOfPMRoots:= function( data, I, p, m )\n    local q, pm, quo;\n\n    q:= data.parameters[1];\n    pm:= p^m;\n    quo:= QuoInt( q-1, pm );\n\n    # The first condition means that B_k^{p^m} is zero\n    # and hence inside the given subspace.\n    # For the second condition, we may assume that B_k^{p^m}\n    # is nonzero and hence equal to B_{p^m (k-1)+1}.\n    return Filtered( [ 1 .. Length( data.monomials ) ],\n                     k ->    Maximum( data.monomials[k] ) > quo\n                          or pm * (k-1) + 1 in I );\n    end;\n\n\n#############################################################################\n##\n#F  SingerAlg.BasisOfPC( <data>, <I>, <J> )\n##\n##  <#GAPDoc Label=\"SingerAlg.BasisOfPC\">\n##  <ManSection>\n##  <Func Name=\"SingerAlg.BasisOfPC\" Arg='data, I, J'/>\n##\n##  <Description>\n##  Let <A>data</A> be the record returned by\n##  <Ref Oper=\"LoewyStructureInfoGAP\" Label=\"for parameters\"/>\n##  that describes a Singer algebra <M>A = A[q,z]</M>,\n##  let <M>B = B(A)</M>,\n##  let <A>I</A> and <M>J</M> be subsets of <M>\\{ 1, 2, \\ldots, z+1 \\}</M>,\n##  describing subspaces <M>U</M> and <M>V</M> of <M>A</M> with bases\n##  <M>( B_i; i \\in I )</M> and <M>( B_i; i \\in J )</M>,\n##  respectively.\n##  <Ref Func=\"SingerAlg.BasisOfPC\"/> returns the subset <M>K</M>\n##  of <M>\\{ 2, 3, \\ldots, z+1 \\}</M> such that\n##  <M>( B_i; i \\in K )</M> is a basis of the subspace\n##  <M>\\{ x \\in J(A); x \\cdot U \\subseteq V \\}</M> of <M>J(A)</M>.\n##  <P/>\n##  (The perhaps strange name <Q>BasisOfPC</Q> was chosen because the\n##  result contains the indices of those basis vectors such that the\n##  <E>P</E>roduct with the space <M>U</M> is <E>C</E>ontained in the\n##  space <M>V</M>.)\n##  <P/>\n##  <Example><![CDATA[\n##  gap> data:= LoewyStructureInfoGAP( 23, 585 );;\n##  gap> soc:= SingerAlg.BasesOfSocleSeries( data );;\n##  gap> rad:= SingerAlg.BasesOfRadicalSeries( data );;\n##  gap> I1:= SingerAlg.BasisOfPC( data, soc[3], rad[3] );;\n##  gap> Length( I1 );\n##  581\n##  gap> data:= LoewyStructureInfoGAP( 212, 585 );;\n##  gap> soc:= SingerAlg.BasesOfSocleSeries( data );;\n##  gap> rad:= SingerAlg.BasesOfRadicalSeries( data );;\n##  gap> I2:= SingerAlg.BasisOfPC( data, soc[3], rad[3] );;\n##  gap> Length( I2 );\n##  545\n##  ]]></Example>\n##  </Description>\n##  </ManSection>\n##  <#/GAPDoc>\n##\nSingerAlg.BasisOfPC:= { data, I, J } -> Filtered(\n    # Note that we are interested in subspaces of the radical.\n    [ 2 .. Length( data.monomials ) ],\n    k -> IsSubset( J, SingerAlg.BasisOfProductSpace( data, [ k ], I ) ) );\n\n\n#############################################################################\n##\n#E\n\n", "meta": {"hexsha": "9dc187c884200abc6d81a92949730d1a963c0f5e", "size": 46588, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "gap/loewy.gi", "max_stars_repo_name": "oscar-system/SingerAlg", "max_stars_repo_head_hexsha": "7d303756163638d97fa3bc93dd3546b400a4122f", "max_stars_repo_licenses": ["Naumen", "Condor-1.1", "MS-PL"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-09-11T10:12:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-02T13:37:49.000Z", "max_issues_repo_path": "gap/loewy.gi", "max_issues_repo_name": "oscar-system/SingerAlg", "max_issues_repo_head_hexsha": "7d303756163638d97fa3bc93dd3546b400a4122f", "max_issues_repo_licenses": ["Naumen", "Condor-1.1", "MS-PL"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-05-04T21:41:17.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-04T21:41:17.000Z", "max_forks_repo_path": "gap/loewy.gi", "max_forks_repo_name": "oscar-system/SingerAlg", "max_forks_repo_head_hexsha": "7d303756163638d97fa3bc93dd3546b400a4122f", "max_forks_repo_licenses": ["Naumen", "Condor-1.1", "MS-PL"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.390084801, "max_line_length": 79, "alphanum_fraction": 0.5304799519, "num_tokens": 15246, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.46692354837676303}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nNewRulesFor(TConjEven, rec(\n    TConjEven_vec := rec(\n        switch := true,\n        applicable := (self, t) >> IsEvenInt(t.params[1]) and t.isTag(1, AVecReg) and\n\t    t.params[1] mod (2*t.getTag(1).v) = 0,\n\n        apply := (self, t, C, Nonterms) >> let(N := t.params[1], v := t.getTag(1).v, rot := t.params[2],\n            m := Mat([[1,0],[0,-1]]),\n#            d1 := Diag(diagDirsum(fConst(TReal, 2, 1.0), fConst(TReal, N-2, 1/2))),\n            d1 := VDiag(diagDirsum(fConst(TReal, 1, 1.0), fConst(TReal, v-1, 0.5), fConst(TReal, 1, 1.0), fConst(TReal, N-v-1, 0.5)), v),\n            #m1 := DirectSum(m, SUM(I(N-2), Tensor(J((N-2)/2), m))),\n            #dv1 := Diag(diagDirsum(fConst(TReal, v, 1.0), fConst(TReal, 1,-1.0), fConst(TReal, N-v-1, 1.0))),\n            dv1 := DirectSum(VTensor(I(1), v), \n\t\t             VBlk([[ [-1.0] :: Replicate(v-1, 1.0) ]], v), \n\t\t\t     VTensor(I(N/v-2), v)),\n            P1 := VPrm_x_I(L(N/v, N/(2*v)), v),\n            Q1 := VPrm_x_I(L(N/v, 2), v),\n            jv1 := P1*DirectSum(VO1dsJ(N/2, v), VScale(VO1dsJ(N/2, v), -1, v))*Q1,\n            mv1 := _VSUM([dv1,jv1], v),\n            #m2 := DirectSum(J(2), SUM(I(N-2), Tensor(J((N-2)/2), -m))),\n            e0 := [0.0] :: Replicate(v-1, 1.0), \n            e1 := [1.0] :: Replicate(v-1, 0.0), \n            blk := VBlk([[e0,e1],[e1,e0]], v).setSymmetric(),\n            dv2 := DirectSum(blk, VTensor(I(N/v-2), v)),\n            jv2 := P1 * DirectSum(VScale(VO1dsJ(N/2, v), -1, v), VO1dsJ(N/2, v))*Q1,\n            mv2 := _VSUM([dv2,jv2], v),\n            #\n            i := VTensor(I(N/v), v), \n            d2 := VRCLR(Diag(fPrecompute(diagDirsum(fConst(TReal, 1, 1.0), diagMul(fConst(TComplex, N/2-1, omegapi(-1/2)), fCompose(dOmega(N, rot), fAdd(N/2, N/2-1, 1)))))), v),\n            #\n            #d1 * \n\t    VBlkInt(d1 * _VHStack([mv1, mv2], v) * VStack(i, d2), v))\n    ),\n\n    TConjEven_vec_tr := rec(\n        switch := true,\n        applicable := (self, t) >> IsEvenInt(t.params[1]) and t.isTag(1, AVecReg) and t.params[1] mod (2*t.getTag(AVecReg).v)=0,\n\ttransposed := true,\n\n        apply := (self, t, C, Nonterms) >> let(N := t.params[1], v := t.getTag(1).v, rot := t.params[2],\n            m := Mat([[1,0],[0,-1]]),\n#            d1 := Diag(diagDirsum(fConst(TReal, 2, 1.0), fConst(TReal, N-2, 1/2))),\n            d1 := VDiag(diagDirsum(fConst(TReal, 1, 1.0), fConst(TReal, v-1, 0.5), fConst(TReal, 1, 1.0), fConst(TReal, N-v-1, 0.5)), v),\n            #m1 := DirectSum(m, SUM(I(N-2), Tensor(J((N-2)/2), m))),\n            #dv1 := Diag(diagDirsum(fConst(TReal, v, 1.0), fConst(TReal, 1,-1.0), fConst(TReal, N-v-1, 1.0))),\n            dv1 := DirectSum(VTensor(I(1), v), \n\t\t             VBlk([[ [-1.0] :: Replicate(v-1, 1.0) ]], v), \n\t\t\t     VTensor(I(N/v-2), v)),\n            P1 := VPrm_x_I(L(N/v, N/(2*v)), v),\n            Q1 := VPrm_x_I(L(N/v, 2), v),\n            jv1 := P1*DirectSum(VO1dsJ(N/2, v), VScale(VO1dsJ(N/2, v), -1, v))*Q1,\n            mv1 := _VSUM([dv1,jv1], v),\n            #m2 := DirectSum(J(2), SUM(I(N-2), Tensor(J((N-2)/2), -m))),\n            e0 := [0.0] :: Replicate(v-1, 1.0), \n            e1 := [1.0] :: Replicate(v-1, 0.0), \n            blk := VBlk([[e0,e1],[e1,e0]], v).setSymmetric(),\n            dv2 := DirectSum(blk, VTensor(I(N/v-2), v)),\n            jv2 := P1 * DirectSum(VScale(VO1dsJ(N/2, v), -1, v), VO1dsJ(N/2, v))*Q1,\n            mv2 := _VSUM([dv2,jv2], v),\n            #\n            i := VTensor(I(N/v), v), \n            d2 := VRCLR(Diag(fPrecompute(diagDirsum(fConst(TReal, 1, 1.0), diagMul(fConst(TComplex, N/2-1, omegapi(-1/2)), fCompose(dOmega(N, rot), fAdd(N/2, N/2-1, 1)))))), v),\n            #\n            #d1 * \n\t    VBlkInt(_VHStack([i, d2.transpose()], v) * VStack(mv1, mv2) * d1, v))\n    )\n));\n\n\nNewRulesFor(TXMatDHT, rec(\n    TXMatDHT_vec := rec(\n        switch := true,\n        applicable := (self, t) >> IsEvenInt(t.params[1]) and t.isTag(1, AVecReg),\n        apply := (self, t, C, Nonterms) >> let(N := t.params[1], v := t.getTag(1).v,\n\n            f0 := Replicate(v, 1.0), \n            f1 := [0.0] :: Replicate(v-1, 1.0), \n            f2 := [1.0] :: Replicate(v-1, -1.0), \n            fblk := VBlk([[f0,f1],[f1,f2]], v).setSymmetric(),\n            fdiag := VTensor(Tensor(I(N/(2*v)-1), F(2)), v),\n            ff := DirectSum(fblk, fdiag),\n\n            ###\n            m := Mat([[1,0],[0,-1]]),\n            d1 := Diag(diagDirsum(fConst(TReal, 2, 1.0), fConst(TReal, N-2, 1/2))),\n            #m1 := DirectSum(m, SUM(I(N-2), Tensor(J((N-2)/2), m))),\n            #dv1 := Diag(diagDirsum(fConst(TReal, v,1), fConst(TReal, 1,-1), fConst(TReal, N-v-1, 1))),\n            dv1 := DirectSum(VTensor(I(1), v), \n\t\t             VBlk([[ [-1.0] :: Replicate(v-1, 1.0) ]], v), \n\t\t\t     VTensor(I(N/v-2), v)),\n            P1 := VPrm_x_I(L(N/v, N/(2*v)), v),\n            Q1 := VPrm_x_I(L(N/v, 2), v),\n            jv1 := P1*DirectSum(VO1dsJ(N/2, v), VScale(VO1dsJ(N/2, v), -1, v))*Q1,\n            mv1 := _VSUM([dv1,jv1], v),\n            #m2 := DirectSum(J(2), SUM(I(N-2), Tensor(J((N-2)/2), -m))),\n            e0 := [0.0] :: Replicate(v-1, 1.0), \n            e1 := [1.0] :: Replicate(v-1, 0.0), \n            blk := VBlk([[e0,e1],[e1,e0]], v).setSymmetric(),\n            dv2 := DirectSum(blk, VTensor(I(N/v-2), v)),\n            jv2 := P1*DirectSum(VScale(VO1dsJ(N/2, v), -1, v), VO1dsJ(N/2, v))*Q1,\n            mv2 := _VSUM([dv2,jv2], v),\n            #\n            i := VTensor(I(N/v), v),\n            d2 := VRCLR(Diag(fPrecompute(diagDirsum(fConst(TReal, 1, 1.0), diagMul(fConst(TComplex, N/2-1, Complex(0,-1)), fCompose(dOmega(N, 1), fAdd(N/2, N/2-1, 1)))))), v),\n            #\n            d1 * VBlkInt(ff * _VHStack([mv1, mv2], v) * VStack(i, d2), v)\n    ))\n));\n", "meta": {"hexsha": "1432c26d6467768400d1ff86b0a3fdae8beca7c5", "size": 5763, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/vector/breakdown/tconjeven.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/vector/breakdown/tconjeven.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/vector/breakdown/tconjeven.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.5526315789, "max_line_length": 177, "alphanum_fraction": 0.4657296547, "num_tokens": 2305, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.793105951184112, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.46404720744327543}}
{"text": "\n# Copyright (c) 2018-2020, Carnegie Mellon University\n# See LICENSE for details\n\n\nClass(PrunedPRDFT, TaggedNonTerminal, rec(\n    abbrevs := [\n        (n,blk,pat) -> Checked(IsPosIntSym(n), IsPosIntSym(blk), IsList(pat),\n            AnySyms(n,blk) or (IsInt(_unwrap(n)/_unwrap(blk)) and ForAll(pat, i->IsInt(i) and i < n/blk)),\n            [_unwrap(n), 1, _unwrap(blk), pat]),\n        (n,k,blk,pat) -> Checked(IsPosIntSym(n), IsIntSym(k), IsPosIntSym(blk), IsList(pat),\n            AnySyms(n,k) or Gcd(_unwrap(n),_unwrap(k))=1,\n            AnySyms(n,blk) or (IsInt(_unwrap(n)/_unwrap(blk)) and ForAll(pat, i->IsInt(i) and i < n/blk)),\n            [_unwrap(n), When(AnySyms(n,k), k, k mod _unwrap(n)), _unwrap(blk), pat])\n        ],\n\n    dims := self >> let(\n        size := let(n:=self.params[1], 2*(Int(n/2)+1)),\n        d := [size, self.params[3]*Length(self.params[4])],\n        When(self.transposed, [d[2], d[1]], d)\n    ),\n\n    terminate := self >> let(\n        size := self.params[1], blk := self.params[3], pat := self.params[4],\n        res := Compose(PRDFT(size, self.params[2]),\n               Tensor(Mat(List(pat, i->BasisVec(size/blk, i))).transpose(), I(blk))).terminate(),\n        When(self.transposed, res.transpose(), res)\n    ),\n\n    isReal    := True,\n    normalizedArithCost := self >> let(n := self.params[1], IntDouble(2.5 * n * d_log(n) / d_log(2))),\n    TType := TReal\n));\n\n_pruned_PRF12_CT_Children := (N,k,PRFt,DFTt,PRFtp,PRF1) -> Map2(DivisorPairs(N),\n    (m,n) -> When(IsEvenInt(n),\n\t[ PRFt(m,k), DFTt(m,k), PRFtp(m,k) ] :: PRF1(m,n,k),\n\t[ PRFt(m,k), DFTt(m,k) ] :: PRF1(m,n,k))\n);\n\n_pruned_PRF12_CT_Stage1 := (N,k,C,Conj,Tw) ->\n    let(m:=Cols(C[1]),\n        n:=N/m,\n        Nf:=Int(N/2),\n        nf:=Int(n/2),\n        nc:=Int((n+1)/2),\n        mf:=Int(m/2),\n        mc:=Int((m+1)/2),\n        j:=Ind(nc-1),\n        SUM(\n            RC(Scat(H(Nf+1,mf+1,0,n))) * C[1] * Gath(H(2*(nf+1)*m, m, 0, 2*(nf+1))),\n            When(nc=1, [],\n                ISum(j,\n                    RC(Scat(BH(Nf+1,N,m,j+1,n))) *\n                    Conj * RC(C[2]) * Tw(j) *\n                    RC(Gath(H((nf+1)*m, m, j+1, nf+1)))\n                )\n            ),\n            When(IsOddInt(n), [],\n                RC(Scat(H(Nf+1,mc,nf,n))) * C[3] * Gath(H(2*(nf+1)*m, m, 2*nf, 2*(nf+1)))\n            )\n        )\n    );\n\n\n_pruned_IPRF12_CT_Stage2 := (N,k,C,Conj,Tw) ->\n    let(m:=Rows(C[1]),\n        n:=N/m,\n        Nf:=Int(N/2),\n        nf:=Int(n/2),\n        nc:=Int((n+1)/2),\n        mf:=Int(m/2),\n        mc:=Int((m+1)/2),\n        j:=Ind(nc-1),\n        SUM(\n            Scat(H(2*(nf+1)*m, m, 0, 2*(nf+1))) * C[1] * RC(Gath(H(Nf+1,mf+1,0,n))),\n        \tWhen(nc=1, [],\n                ISum(j,\n                    RC(Scat(H((nf+1)*m, m, j+1, nf+1))) *\n                    Tw(j) * RC(C[2]) * Conj *\n    \t            RC(Gath(BH(Nf+1,N,m,j+1,n)))\n                )\n            ),\n        \tWhen(IsOddInt(n), [],\n    \t       Scat(H(2*(nf+1)*m, m, 2*nf, 2*(nf+1))) * C[3] * RC(Gath(H(Nf+1,mc,nf,n))))\n        )\n    );\n\n\nNewRulesFor(PrunedPRDFT, rec(\n    PrunedPRDFT_base := rec(\n       forTransposition := false,\n       maxSize := 256,\n       applicable := (self, nt) >> not nt.hasTags() and nt.params[1] <= self.maxSize and nt.params[3] = 1,\n       children := nt -> [[PRDFT(nt.params[1], nt.params[2])]],\n       apply := (nt, C, cnt) -> let(size := nt.params[1], blk := nt.params[3], pat := nt.params[4],\n            C[1] * Tensor(Mat(List(pat, i->BasisVec(size/blk, i))).transpose(), I(blk)).terminate())\n    ),\n    PrunedPRDFT_DFT := rec(\n       forTransposition := false,\n       applicable := (self, nt) >> nt.params[1] = nt.params[3] and nt.params[4] = [0],\n       children := nt -> [[ PRDFT(nt.params[1], nt.params[2]).withTags(nt.getTags()) ]],\n       apply := (nt, C, cnt) -> C[1]\n    ),\n    PrunedPRDFT_CT_rec_block := rec(\n       forTransposition := true,\n       fPrecompute := f->fPrecompute(f),\n       applicable := (self, nt) >> nt.params[1] > 2\n            and not nt.hasTags()\n            and not IsPrime(nt.params[1])\n            and nt.params[3] = 1\n            and Last(nt.params[4])+1-nt.params[4][1] = Length(Set(nt.params[4]))\n            and ForAny(Map2(DivisorPairs(nt.params[1]), (m,n)->_ctpr_applicable(m, n, nt.params[4])), i->i),\n       children := (nt) -> Filtered(_pruned_PRF12_CT_Children(nt.params[1],nt.params[2],PRDFT1, DFT1, PRDFT3,\n                                        (m, n, k)->_pruned_children(m, n, nt.params[4], (r, sp) -> PrunedPRDFT(r, k mod n, nt.params[3], sp))),\n                              lst -> ForAll(Filtered(lst, i->ObjId(i) = PrunedPRDFT), j->j.params[4] <> [])),\n       apply := (self, nt, C, cnt) >> let(N:=nt.params[1], k:=nt.params[2], m:=Cols(C[1]), n := N/m,\n            _pruned_PRF12_CT_Stage1(N, k, C, Diag(BHD(m,1,-1)), j->RC(Diag(self.fPrecompute(Twid(N,m,k,0,0,j+1))))) *\n            _build_stack(m, n, nt.params[4], let(s1len := When(IsEvenInt(n), 3, 2), C{[s1len+1..Length(C)]}), nt.dims()[2], Gath, IterVStack, VStack, (a,b)->a*b))\n    )\n));\n\n\n\n\n\n\nClass(PrunedIPRDFT, TaggedNonTerminal, rec(\n    abbrevs := [\n        (n,blk,pat) -> Checked(IsPosIntSym(n), IsPosIntSym(blk), IsList(pat),\n            AnySyms(n,blk) or (IsInt(_unwrap(n)/_unwrap(blk)) and ForAll(pat, i->IsInt(i) and i < n/blk)),\n            [_unwrap(n), 1, _unwrap(blk), pat]),\n        (n,k,blk,pat) -> Checked(IsPosIntSym(n), IsIntSym(k), IsPosIntSym(blk), IsList(pat),\n            AnySyms(n,k) or Gcd(_unwrap(n),_unwrap(k))=1,\n            AnySyms(n,blk) or (IsInt(_unwrap(n)/_unwrap(blk)) and ForAll(pat, i->IsInt(i) and i < n/blk)),\n            [_unwrap(n), When(AnySyms(n,k), k, k mod _unwrap(n)), _unwrap(blk), pat])\n        ],\n\n    dims := self >> let(\n        size := let(n:=self.params[1], 2*(Int(n/2)+1)),\n        d := [self.params[3]*Length(self.params[4]), size],\n        When(self.transposed, [d[2], d[1]], d)\n    ),\n\n    terminate := self >> let(\n        size := self.params[1], blk := self.params[3], pat := self.params[4],\n        res := Compose(Tensor(Mat(List(pat, i->BasisVec(size/blk, i))), I(blk)),\n                       IPRDFT(size, self.params[2])).terminate(),\n        When(self.transposed, res.transpose(), res)\n    ),\n\n    isReal    := True,\n    normalizedArithCost := self >> let(n := self.params[1], IntDouble(2.5 * n * d_log(n) / d_log(2))),\n    TType := TReal\n));\n\n\nNewRulesFor(PrunedIPRDFT, rec(\n    PrunedIPRDFT_base := rec(\n       forTransposition := false,\n       maxSize := 256,\n       applicable := (self, nt) >> not nt.hasTags() and nt.params[1] <= self.maxSize and nt.params[3] = 1,\n       children := nt -> [[IPRDFT(nt.params[1], nt.params[2])]],\n       apply := (nt, C, cnt) -> let(size := nt.params[1], blk := nt.params[3], pat := nt.params[4],\n            Tensor(Mat(List(pat, i->BasisVec(size/blk, i))), I(blk)).terminate() * C[1] )\n    ),\n    PrunedIPRDFT_DFT := rec(\n       forTransposition := false,\n       applicable := (self, nt) >> nt.params[1] = nt.params[3] and nt.params[4] = [0],\n       children := nt -> [[ IPRDFT(nt.params[1], nt.params[2]).withTags(nt.getTags()) ]],\n       apply := (nt, C, cnt) -> C[1]\n    ),\n    PrunedIPRDFT_CT_rec_block := rec(\n       forTransposition := true,\n       applicable := (self, nt) >> nt.params[1] > 2\n            and not nt.hasTags()\n            and not IsPrime(nt.params[1])\n            and nt.params[3] = 1\n            and Last(nt.params[4])+1-nt.params[4][1] = Length(Set(nt.params[4]))\n            and ForAny(Map2(DivisorPairs(nt.params[1]), (m,n)->_ctpr_applicable(m, n, nt.params[4])), i->i),\n       children := (nt) -> Filtered(_pruned_PRF12_CT_Children(nt.params[1],nt.params[2], IPRDFT1, DFT1, IPRDFT2,\n                                        (m, n, k)->_pruned_children(m, n, nt.params[4], (r, sp) -> PrunedIPRDFT(r, k mod n, nt.params[3], sp))),\n                              lst -> ForAll(Filtered(lst, i->ObjId(i) = PrunedIPRDFT), j->j.params[4] <> [])),\n       apply := (nt, C, cnt) -> let(N:=nt.params[1], k:=nt.params[2], m:=Rows(C[1]), n := N/m,\n            _build_stack(m, n, nt.params[4], let(s1len := When(IsEvenInt(n), 3, 2), C{[s1len+1..Length(C)]}), nt.dims()[1], Scat, IterHStack1, HStack1, (a,b)->b*a) *\n            _pruned_IPRF12_CT_Stage2(N, k, C, Diag(BHD(m,1,-1)), j->RC(Diag(fPrecompute(Twid(N,m,k,0,0,j+1)))))\n       )\n    ),\n));\n\nClass(IOPrunedConv, TaggedNonTerminal, rec(\n    abbrevs := [\n        (n,h,oblk,opat,iblk,ipat) -> Checked(IsPosIntSym(n), IsPosIntSym(oblk), IsList(opat), IsPosIntSym(iblk), IsList(ipat),\n            AnySyms(n,iblk,oblk) or (IsInt(_unwrap(n)/_unwrap(iblk)) and IsInt(_unwrap(n)/_unwrap(oblk)) and\n                ForAll(ipat, i->IsInt(i) and i < n/iblk) and ForAll(opat, i->IsInt(i) and i < n/oblk)),\n            [_unwrap(n), h, _unwrap(oblk), opat, _unwrap(iblk), ipat, false]),\n        (n,h,oblk,opat,iblk,ipat,isFreqData) -> Checked(IsPosIntSym(n), IsPosIntSym(oblk), IsList(opat), IsPosIntSym(iblk), IsList(ipat),\n            AnySyms(n,iblk,oblk) or (IsInt(_unwrap(n)/_unwrap(iblk)) and IsInt(_unwrap(n)/_unwrap(oblk)) and\n                ForAll(ipat, i->IsInt(i) and i < n/iblk) and ForAll(opat, i->IsInt(i) and i < n/oblk)),\n            [_unwrap(n), h, _unwrap(oblk), opat, _unwrap(iblk), ipat, isFreqData])\n        ],\n    dims      := self >> [self.params[3]*Length(self.params[4]), self.params[5]*Length(self.params[6])],\n    terminate := self >> let(size := self.params[1],\n        taps := When(self.params[7], MatSPL(DFT(self.params[1], -1)) * \n               Cond(IsList(self.params[2]), self.params[2], IsLambda(self.params[2]), self.params[2].tolist(), IsBound(self.params[2].list), self.params[2].list), \n           self.params[2]),\n        oblk := self.params[3], opat := self.params[4], iblk := self.params[5], ipat := self.params[6],\n        Tensor(Mat(List(opat, i->BasisVec(size/oblk, i))), I(oblk)).terminate() *\n        spiral.transforms.filtering.Circulant(size, taps, -size).terminate() *\n        Tensor(Mat(List(ipat, i->BasisVec(size/iblk, i))).transpose(), I(iblk)).terminate()),\n    isReal    := self >> false,\n    normalizedArithCost := self >> let(n := self.params[1], IntDouble(5 * n * d_log(n) / d_log(2))),\n    TType := TComplex,\n    hashAs := self >> ApplyFunc(ObjId(self), [self.params[1], fUnk(self.params[2].range(), self.params[2].domain())]::Drop(self.params, 2))\n));\n\nNewRulesFor(IOPrunedConv, rec(\n    IOPrunedConv_PrunedDFT_IPrunedDFT := rec(\n       forTransposition := false,\n       applicable :=  (self, nt) >> not nt.hasTags(),\n       children := nt -> [[ PrunedIDFT(nt.params[1], 1, nt.params[3], nt.params[4]),\n                            PrunedDFT(nt.params[1], -1, nt.params[5], nt.params[6]) ]],\n       apply := (nt, C, cnt) -> Cond(ObjId(nt.params[2]) = var, # a variable is frequency domain data -> FData\n                                    Checked(nt.params[7], C[1] * Diag(FData(nt.params[2])) * C[2]), # if data is provided it needs to be frequency domain\n                                    ObjId(nt.params[2]) = Lambda,  # data is inside a larger array\n                                    Checked(nt.params[7], C[1] * Diag(nt.params[2]) * C[2]),\n                                    nt.params[7],   # if params[7] is true then data is frequency domain data\n                                    C[1] * Diag(When(IsList(nt.params[2]), FList(TComplex, nt.params[2]), nt.params[2])) * C[2],\n                                    let(cxfftdiag := 1/nt.params[1]*ComplexFFT(List(nt.params[2].tolist(), i->ComplexAny(_unwrap(i)))),\n                                        C[1] * Diag(FData(cxfftdiag)) * C[2]))\n    ),\n));\n\n\n#===========================================\n\nClass(IOPrunedRConv, TaggedNonTerminal, rec(\n    abbrevs := [\n        (n,h,oblk,opat,iblk,ipat) -> Checked(IsPosIntSym(n), IsPosIntSym(oblk), IsList(opat), IsPosIntSym(iblk), IsList(ipat),\n            AnySyms(n,iblk,oblk) or (IsInt(_unwrap(n)/_unwrap(iblk)) and IsInt(_unwrap(n)/_unwrap(oblk)) and\n                ForAll(ipat, i->IsInt(i) and i < n/iblk) and ForAll(opat, i->IsInt(i) and i < n/oblk)),\n            [_unwrap(n), h, _unwrap(oblk), opat, _unwrap(iblk), ipat, false]),\n        (n,h,oblk,opat,iblk,ipat,isFreqData) -> Checked(IsPosIntSym(n), IsPosIntSym(oblk), IsList(opat), IsPosIntSym(iblk), IsList(ipat),\n            AnySyms(n,iblk,oblk) or (IsInt(_unwrap(n)/_unwrap(iblk)) and IsInt(_unwrap(n)/_unwrap(oblk)) and\n                ForAll(ipat, i->IsInt(i) and i < n/iblk) and ForAll(opat, i->IsInt(i) and i < n/oblk)),\n            [_unwrap(n), h, _unwrap(oblk), opat, _unwrap(iblk), ipat, isFreqData])\n        ],\n    dims      := self >> [self.params[3]*Length(self.params[4]), self.params[5]*Length(self.params[6])],\n    terminate := self >> let(size := self.params[1],\n        taps := When(self.params[7], MatSPL(IPRDFT(self.params[1], -1)) * When(IsList(self.params[2]), self.params[2], self.params[2].list), self.params[2]),\n        oblk := self.params[3], opat := self.params[4], iblk := self.params[5], ipat := self.params[6],\n        Tensor(Mat(List(opat, i->BasisVec(size/oblk, i))), I(oblk)).terminate() *\n        spiral.transforms.filtering.Circulant(size, taps, -size).terminate() *\n        Tensor(Mat(List(ipat, i->BasisVec(size/iblk, i))).transpose(), I(iblk)).terminate()),\n    isReal    := self >> true,\n    normalizedArithCost := self >> let(n := self.params[1], IntDouble(5 * n * d_log(n) / d_log(2))),\n    TType := TReal\n));\n\nNewRulesFor(IOPrunedRConv, rec(\n    IOPrunedRConv_PrunedIPRDFT_PrunedPRDFT := rec(\n       forTransposition := false,\n       applicable :=  (self, nt) >> not nt.hasTags(),\n       children := nt -> [[ PrunedIPRDFT(nt.params[1], 1, nt.params[3], nt.params[4]),\n                            PrunedPRDFT(nt.params[1], -1, nt.params[5], nt.params[6]) ]],\n       apply := (nt, C, cnt) -> Cond(ObjId(nt.params[2]) = var, # a variable is frequency domain data -> FData\n                                Checked(nt.params[7], C[1] * RCDiag(FData(nt.params[2])) * C[2]), # if data is provided it needs to be frequency domain\n                                nt.params[7],   # if params[7] is true then data is frequency domain data\n                                C[1] *  RCDiag(When(IsList(nt.params[2]), FList(TReal, nt.params[2]), nt.params[2])) * C[2],\n                                let(cxfftdiag := 1/nt.params[1]*ComplexFFT(List(nt.params[2].tolist(), i->ComplexAny(_unwrap(i)))),\n                                    rcdiag := cxfftdiag{[1..Rows(PRDFT(nt.params[1], -1))/2]},\n                                    rlist := Flat(List(rcdiag, i->[ReComplex(_unwrap(i)), ImComplex(_unwrap(i))])),\n                                    C[1] * RCDiag(FList(TReal, rlist)) * C[2]))\n    ),\n));\n\n_complexify := l -> List([1..Length(l)/2], i->l[2*i-1] + E(4) * l[2*i]);\n\n#=========================================================================================================================================================\nDeclare(IOPrunedMDRConv);\nClass(IOPrunedMDRConv, TaggedNonTerminal, rec(\n    abbrevs := [\n        (n,h,oblk,opat,iblk,ipat) -> Checked(ForAll(n, IsPosIntSym), IsPosIntSym(oblk), ForAll(opat, IsList), IsPosIntSym(iblk), ForAll(ipat, IsList),\n            [_unwrap(n), h, _unwrap(oblk), opat, _unwrap(iblk), ipat, false]),\n        (n,h,oblk,opat,iblk,ipat,isFreqData) -> Checked(ForAll(n, IsPosIntSym), IsPosIntSym(oblk), ForAll(opat, IsList), IsPosIntSym(iblk), ForAll(ipat, IsList),\n            [_unwrap(n), h, _unwrap(oblk), opat, _unwrap(iblk), ipat, isFreqData])\n        ],\n    dims      := self >> [self.params[3]*Product(self.params[4], i->Length(i)), self.params[5]*Product(self.params[6], i->Length(i))],\n    isReal    := self >> true,\n    normalizedArithCost := self >> let(n := self.params[1], IntDouble(5 * n * d_log(n) / d_log(2))),\n    TType := TReal,\n    terminate := self >> When(self.params[7],\n                            let(nlist := self.params[1],\n                                n := nlist[1],\n                                nfreq := n/2+1,\n                                nrem := Drop(nlist, 1),\n                                idft := Tensor(IPRDFT(n, -1), I(Product(nrem))) *\n                                    Tensor(I(nfreq), L(2*Product(nrem), 2)) * Tensor(I(nfreq), RC(MDDFT(nrem, -1))),\n                                tlist := MatSPL(idft) * \n                                    Cond(IsList(self.params[2]), self.params[2], IsLambda(self.params[2]), self.params[2].tolist(), IsBound(self.params[2].list), self.params[2].list),\n                                IOPrunedMDRConv(self.params[1], FList(TReal, tlist), self.params[3], self.params[4],\n                                    self.params[5], self.params[6], false).terminate()\n                            ),\n                            let(nlist := self.params[1],\n                                oblk := self.params[3], opat_md := self.params[4],\n                                iblk := self.params[5], ipat_md := self.params[6],\n                                scat3d := Tensor(List(Zip2(ipat_md, nlist), j->let(ipat := j[1], size := j[2],\n                                    Tensor(Mat(List(ipat, i->BasisVec(size/iblk, i))).transpose(), I(iblk)).terminate()))::[Mat([[1], [0]])]),\n                                gath3d := Tensor(List(Zip2(opat_md, nlist), j->let(opat := j[1], size := j[2],\n                                    Tensor(Mat(List(opat, i->BasisVec(size/oblk, i))), I(oblk)).terminate()))::[Mat([[1, 0]])]),\n\n                                dft3dr := RC(MDDFT(nlist, -1)),\n                                idft3dr := RC(MDDFT(nlist, 1)),\n                                gfd := List(1/Product(nlist) * MatSPL(MDDFT(nlist, 1)) * self.params[2].list, i->ComplexAny(_unwrap(i))),\n                                gdiagr := RC(Diag(gfd)),\n                                t := gath3d * idft3dr * gdiagr * dft3dr * scat3d,\n                                t.terminate()\n                            )\n                        ),\n    hashAs := self >> ApplyFunc(ObjId(self), [self.params[1], fUnk(self.params[2].range(), self.params[2].domain())]::Drop(self.params, 2))\n));\n\nNewRulesFor(IOPrunedMDRConv, rec(\n    IOPrunedMDRConv_time2freq := rec(\n       forTransposition := false,\n       applicable :=  (self, nt) >> not nt.hasTags() and not nt.params[7],\n       children := nt -> let(htime := nt.params[2].list,\n                            nlist := nt.params[1],\n                            dft := 1/Product(nlist) * MatSPL(MDDFT(nlist, 1)),\n                            nfreq := nlist[1]/2+1,\n                            hfreq := dft*htime,\n                            hfreqc := List(hfreq, ComplexAny),\n                            hfreqce := hfreqc{[1..nfreq*Product(Drop(nlist,1))]},\n                            hfreqr := Flat(List(hfreqce, i->[ReComplex(i), ImComplex(i)])),\n                            [[IOPrunedMDRConv(nt.params[1], FList(TReal, hfreqr), nt.params[3], nt.params[4], nt.params[5], nt.params[6], true)]]\n                        ),\n       apply := (nt, C, cnt) -> C[1]\n    ),\n\n    ## GPU/TITAN V Hockney algotithm variant\n    ## 2-trip, 5-step, ZYX ====================================================\n    IOPrunedMDRConv_3D_2trip_zyx_freqdata := rec(\n       forTransposition := false,\n       applicable :=  (self, nt) >> not nt.hasTags() and Length(nt.params[1]) = 3 and nt.params[7],\n       children := nt -> let(nlist := nt.params[1],\n                            diag := nt.params[2],\n                            oblk := nt.params[3],\n                            opats := nt.params[4],\n                            iblk := nt.params[5],\n                            ipats := nt.params[6],\n                            nfreq := nlist[1]/2+1,\n                            i := Ind(nfreq*nlist[2]),\n                            hfunc := Cond(ObjId(diag) = Lambda,\n                                let(j := Ind(nlist[3]),\n                                    # Lambda(j, cxpack(diag.at(2*(j + i*nlist[3])), diag.at(2*(j + i*nlist[3])+1)))\n                                    pos := i +j*nfreq*nlist[2],\n                                    Lambda(j, cxpack(diag.at(2*pos), diag.at(2*pos+1)))\n                                ),\n                                ObjId(diag) = fUnk,\n                                fUnk(TComplex, nlist[3]),\n                                let(list := nt.params[2].list,  # here we assume FList(TReal, [...])\n                                    clist := List([1..Length(list)/2], i->Cplx(list[2*i-1], list[2*i])),\n                                    fc := FList(TComplex, clist),\n                                    gf := fTensor(fBase(i), fId(nlist[3])),\n                                    fCompose(fc, gf)\n                                )\n                            ),\n                            [[ PrunedPRDFT(nlist[1], -1, iblk, ipats[1]),  # stage 1: PRDFT z\n                                PrunedDFT(nlist[2], -1, iblk, ipats[2]),    # stage 2: DFT y\n                                IOPrunedConv(nlist[3], hfunc, oblk, opats[3], iblk, ipats[3], true), # stage 3+4+5: complex conv in x\n                                PrunedIDFT(nlist[2], 1, oblk, opats[2]), # stage 6: iDFT in y\n                                PrunedIPRDFT(nlist[1], 1, oblk, opats[1]),   # stage 7: iPRDFT in z\n                                InfoNt(i)\n                            ]]),\n\n       apply := (nt, C, cnt) -> let(prdft1d := C[1],\n                                    pdft1d := C[2],\n                                    iopconv := C[3],\n                                    ipdft1d := C[4],\n                                    iprdft1d := C[5],\n                                    i := cnt[6].params[1],\n                                    nlist := nt.params[1],\n                                    n1 := nlist[1],\n                                    nfreq := nlist[1]/2+1,\n                                    n2 := nlist[2],\n                                    n3 := nlist[3],\n                                    oblk := nt.params[3],\n                                    opats := nt.params[4],\n                                    iblk := nt.params[5],\n                                    ipats := nt.params[6],\n                                    ns1 := iblk * Length(ipats[1]),\n                                    ns2 := iblk * Length(ipats[2]),\n                                    ns3 := iblk * Length(ipats[3]),\n                                    nd1 := oblk * Length(opats[1]),\n                                    nd2 := oblk * Length(opats[2]),\n                                    nd3 := oblk * Length(opats[3]),\n                                    stage1 := L(2*nfreq*ns3*ns2, ns3) * Tensor(I(ns2), Tensor(L(2*nfreq, 2) * prdft1d, I(ns3))) * Tensor(L(ns2*ns1, ns2), I(ns3)),\n                                    stage2 := Tensor(I(ns3), Tensor(RC(pdft1d), I(nfreq))),\n                                    pp := Tensor(L(ns3*n2*nfreq, n2*nfreq), I(2)) * Tensor(I(ns3), L(2*nfreq*n2, nfreq)),\n                                    ppi := Tensor(I(nd3), L(2*nfreq*n2, 2*n2)) * Tensor(L(nd3*n2*nfreq, nd3), I(2)),\n                                    stage543 := ppi * IDirSum(i, RC(iopconv)) * pp,\n                                    stage76 := Tensor(L(nd2*nd1, nd1), I(nd3)) * Grp(Tensor((Tensor(I(nd2), iprdft1d * L(2*nfreq, nfreq)) *\n                                        Tensor(RC(ipdft1d), I(nfreq))), I(nd3)) * L(2*nfreq*nd3*n2, 2*nfreq*n2)),\n                                    conv3dr := stage76 * stage543 * stage2 * stage1,\n                                    conv3dr\n                            ),\n    ),\n\n    ## X dimension last (convolution)\n    ## 5-step, ZYX ====================================================\n    IOPrunedMDRConv_3D_5step_zyx_freqdata := rec(\n       forTransposition := false,\n       applicable :=  (self, nt) >> not nt.hasTags() and Length(nt.params[1]) = 3 and nt.params[7],\n       children := nt -> let(nlist := nt.params[1],\n                            diag := nt.params[2],\n                            oblk := nt.params[3],\n                            opats := nt.params[4],\n                            iblk := nt.params[5],\n                            ipats := nt.params[6],\n                            nfreq := nlist[1]/2+1,\n                            i := Ind(nfreq*nlist[2]),\n                            hfunc := Cond(ObjId(diag) = Lambda,\n                                let(j := Ind(nlist[3]),\n                                    Lambda(j, cxpack(diag.at(2*(j + i*nlist[3])), diag.at(2*(j + i*nlist[3])+1)))\n                                ),\n                                ObjId(diag) = fUnk,\n                                fUnk(TComplex, nlist[3]),\n                                let(list := nt.params[2].list,  # here we assume FList(TReal, [...])\n                                    clist := List([1..Length(list)/2], i->Cplx(list[2*i-1], list[2*i])),\n                                    fc := FList(TComplex, clist),\n                                    gf := fTensor(fBase(i), fId(nlist[3])),\n                                    fCompose(fc, gf)\n                                )\n                            ),\n                            [[ PrunedPRDFT(nlist[1], -1, iblk, ipats[1]),  # stage 1: PRDFT z\n                                PrunedDFT(nlist[2], -1, iblk, ipats[2]),    # stage 2: DFT y\n                                IOPrunedConv(nlist[3], hfunc, oblk, opats[3], iblk, ipats[3], true), # stage 3+4+5: complex conv in x\n                                PrunedIDFT(nlist[2], 1, oblk, opats[2]), # stage 6: iDFT in y\n                                PrunedIPRDFT(nlist[1], 1, oblk, opats[1]),   # stage 7: iPRDFT in z\n                                InfoNt(i)\n                            ]]),\n\n       apply := (nt, C, cnt) -> let(prdft1d := Grp(C[1]),\n                                    pdft1d := Grp(C[2]),\n                                    iopconv := Grp(C[3]),\n                                    ipdft1d := Grp(C[4]),\n                                    iprdft1d := Grp(C[5]),\n                                    i := cnt[6].params[1],\n                                    nlist := nt.params[1],\n                                    n1 := nlist[1],\n                                    nfreq := nlist[1]/2+1,\n                                    n2 := nlist[2],\n                                    n3 := nlist[3],\n                                    oblk := nt.params[3],\n                                    opats := nt.params[4],\n                                    iblk := nt.params[5],\n                                    ipats := nt.params[6],\n                                    ns1 := iblk * Length(ipats[1]),\n                                    ns2 := iblk * Length(ipats[2]),\n                                    ns3 := iblk * Length(ipats[3]),\n                                    nd1 := oblk * Length(opats[1]),\n                                    nd2 := oblk * Length(opats[2]),\n                                    nd3 := oblk * Length(opats[3]),\n                                    stage1 := Tensor(I(nfreq), L(2*ns2*ns3, ns2*ns3)) * Tensor(prdft1d, I(ns2*ns3)),\n                                    stage2 := RC(Tensor(I(nfreq), pdft1d, I(ns3))),\n                                    stage543c := IDirSum(i, iopconv),\n                                    stage543 := RC(stage543c),\n                                    stage6 := RC(Tensor(I(nfreq), ipdft1d, I(nd3))),\n                                    stage7 := Tensor(iprdft1d, I(nd2*nd3)) * Tensor(I(nfreq), L(2*nd2*nd3, 2)),\n                                    conv3dr := stage7 * stage6 * stage543 * stage2 * stage1,\n                                    conv3dr\n                            ),\n    ),\n    ## 5-step, YZX ====================================================\n    IOPrunedMDRConv_3D_5step_yzx_freqdata := rec(\n       forTransposition := false,\n       applicable :=  (self, nt) >> false, #not nt.hasTags() and Length(nt.params[1]) = 3 and nt.params[7], Breaks!\n       children := nt -> let(nlist := nt.params[1],\n                            diag := nt.params[2],\n                            oblk := nt.params[3],\n                            opats := nt.params[4],\n                            iblk := nt.params[5],\n                            ipats := nt.params[6],\n                            nfreq := nlist[1]/2+1,\n                            i := Ind(nfreq*nlist[2]),\n                            hfunc := Cond(ObjId(diag) = Lambda,\n                                let(j := Ind(nlist[3]),\n                                    Lambda(j, cxpack(diag.at(2*(j + i*nlist[3])), diag.at(2*(j + i*nlist[3])+1)))\n                                ),\n                                ObjId(diag) = fUnk,\n                                fUnk(TComplex, nlist[3]),\n                                let(list := nt.params[2].list,  # here we assume FList(TReal, [...])\n                                    clist := List([1..Length(list)/2], i->Cplx(list[2*i-1], list[2*i])),\n                                    fc := FList(TComplex, clist),\n                                    gf := fTensor(fBase(i), fId(nlist[3])),\n                                    fCompose(fc, gf)\n                                )\n                            ),\n                            [[ PrunedPRDFT(nlist[2], -1, iblk, ipats[2]),  # stage 1: PRDFT y\n                                PrunedDFT(nlist[1], -1, iblk, ipats[1]),    # stage 2: DFT z\n                                IOPrunedConv(nlist[3], hfunc, oblk, opats[3], iblk, ipats[3], true), # stage 3+4+5: complex conv in x\n                                PrunedIDFT(nlist[1], 1, oblk, opats[1]), # stage 6: iDFT in z\n                                PrunedIPRDFT(nlist[2], 1, oblk, opats[2]),   # stage 7: iPRDFT in y\n                                InfoNt(i)\n                            ]]),\n\n       apply := (nt, C, cnt) -> let(prdft1d := C[1],\n                                    pdft1d := C[2],\n                                    iopconv := C[3],\n                                    ipdft1d := C[4],\n                                    iprdft1d := C[5],\n                                    i := cnt[6].params[1],\n                                    nlist := nt.params[1],\n                                    n1 := nlist[1],\n                                    nfreq := nlist[2]/2+1,\n                                    n2 := nlist[2],\n                                    n3 := nlist[3],\n                                    oblk := nt.params[3],\n                                    opats := nt.params[4],\n                                    iblk := nt.params[5],\n                                    ipats := nt.params[6],\n                                    ns1 := iblk * Length(ipats[1]),\n                                    ns2 := iblk * Length(ipats[2]),\n                                    ns3 := iblk * Length(ipats[3]),\n                                    nd1 := oblk * Length(opats[1]),\n                                    nd2 := oblk * Length(opats[2]),\n                                    nd3 := oblk * Length(opats[3]),\n                                    stage1 := Tensor(I(nfreq*ns2), L(2*ns3, ns3)) * Tensor(I(ns2), prdft1d, I(ns3)),\n                                    stage2 := RC(Tensor(pdft1d, I(nfreq*ns3))),\n                                    stage543c := IDirSum(i, iopconv),\n                                    stage543 := RC(stage543c),\n                                    stage6 := RC(Tensor(ipdft1d, I(nfreq*nd3))),\n                                    stage7 := Tensor(I(nd2), iprdft1d, I(nd3)) * Tensor(I(nfreq*nd2), L(2*nd3, 2)),\n                                    conv3dr := stage7 * stage6 * stage543 * stage2 * stage1,\n                                    conv3dr\n                            ),\n    ),\n    ## 3-step, (ZY)X ====================================================\n    IOPrunedMDRConv_3D_3step_zyx_freqdata := rec(\n       forTransposition := false,\n       applicable :=  (self, nt) >> not nt.hasTags() and Length(nt.params[1]) = 3 and nt.params[7],\n       children := nt -> let(nlist := nt.params[1],\n                            diag := nt.params[2],\n                            oblk := nt.params[3],\n                            opats := nt.params[4],\n                            iblk := nt.params[5],\n                            ipats := nt.params[6],\n                            nfreq := nlist[1]/2+1,\n                            i := Ind(nfreq*nlist[2]),\n                            hfunc := Cond(ObjId(diag) = Lambda,\n                                let(j := Ind(nlist[3]),\n                                    Lambda(j, cxpack(diag.at(2*(j + i*nlist[3])), diag.at(2*(j + i*nlist[3])+1)))\n                                ),\n                                ObjId(diag) = fUnk,\n                                fUnk(TComplex, nlist[3]),\n                                let(list := nt.params[2].list,  # here we assume FList(TReal, [...])\n                                    clist := List([1..Length(list)/2], i->Cplx(list[2*i-1], list[2*i])),\n                                    fc := FList(TComplex, clist),\n                                    gf := fTensor(fBase(i), fId(nlist[3])),\n                                    fCompose(fc, gf)\n                                )\n                            ),\n                            [[ PrunedPRDFT(nlist[1], -1, iblk, ipats[1]),  # stage 1a: PRDFT z\n                                PrunedDFT(nlist[2], -1, iblk, ipats[2]),    # stage 1b: DFT y\n                                IOPrunedConv(nlist[3], hfunc, oblk, opats[3], iblk, ipats[3], true), # stage 3+4+5: complex conv in x\n                                PrunedIDFT(nlist[2], 1, oblk, opats[2]), # stage 6b: iDFT in y\n                                PrunedIPRDFT(nlist[1], 1, oblk, opats[1]),   # stage 6a: iPRDFT in z\n                                InfoNt(i)\n                            ]]),\n\n       apply := (nt, C, cnt) -> let(prdft1d := Grp(C[1]),\n                                    pdft1d := Grp(C[2]),\n                                    iopconv := Grp(C[3]),\n                                    ipdft1d := Grp(C[4]),\n                                    iprdft1d := Grp(C[5]),\n                                    i := cnt[6].params[1],\n                                    nlist := nt.params[1],\n                                    n1 := nlist[1],\n                                    nfreq := nlist[1]/2+1,\n                                    n2 := nlist[2],\n                                    n3 := nlist[3],\n                                    oblk := nt.params[3],\n                                    opats := nt.params[4],\n                                    iblk := nt.params[5],\n                                    ipats := nt.params[6],\n                                    ns1 := iblk * Length(ipats[1]),\n                                    ns2 := iblk * Length(ipats[2]),\n                                    ns3 := iblk * Length(ipats[3]),\n                                    nd1 := oblk * Length(opats[1]),\n                                    nd2 := oblk * Length(opats[2]),\n                                    nd3 := oblk * Length(opats[3]),\n                                    stage1 := Tensor(I(nfreq), L(2*ns2, ns2)) * Tensor(prdft1d, I(ns2)),\n                                    stage2 := RC(Tensor(I(nfreq), pdft1d)),\n                                    stage12 := Tensor(I(nfreq * n2), L(2*ns3, ns3)) * Tensor(stage2 * stage1, I(ns3)),\n                                    stage543c := IDirSum(i, iopconv),\n                                    stage543 := RC(stage543c),\n                                    stage6 := RC(Tensor(I(nfreq), ipdft1d)),\n                                    stage7 := Tensor(iprdft1d, I(nd2)) * Tensor(I(nfreq), L(2*nd2, 2)),\n                                    stage67 := Tensor(stage7 * stage6, I(nd3)) * Tensor(I(nfreq * n2), L(2*nd3, 2)),\n                                    conv3dr := stage67 * stage543 * stage12,\n                                    conv3dr\n                            ),\n    ),\n    ## 3-step, (YZ)X ====================================================\n    IOPrunedMDRConv_3D_3step_yzx_freqdata := rec(\n       forTransposition := false,\n       applicable :=  (self, nt) >> false, #not nt.hasTags() and Length(nt.params[1]) = 3 and nt.params[7], Breaks!\n       children := nt -> let(nlist := nt.params[1],\n                            diag := nt.params[2],\n                            oblk := nt.params[3],\n                            opats := nt.params[4],\n                            iblk := nt.params[5],\n                            ipats := nt.params[6],\n                            nfreq := nlist[1]/2+1,\n                            i := Ind(nfreq*nlist[2]),\n                            hfunc := Cond(ObjId(diag) = Lambda,\n                                let(j := Ind(nlist[3]),\n                                    Lambda(j, cxpack(diag.at(2*(j + i*nlist[3])), diag.at(2*(j + i*nlist[3])+1)))\n                                ),\n                                ObjId(diag) = fUnk,\n                                fUnk(TComplex, nlist[3]),\n                                let(list := nt.params[2].list,  # here we assume FList(TReal, [...])\n                                    clist := List([1..Length(list)/2], i->Cplx(list[2*i-1], list[2*i])),\n                                    fc := FList(TComplex, clist),\n                                    gf := fTensor(fBase(i), fId(nlist[3])),\n                                    fCompose(fc, gf)\n                                )\n                            ),\n                            [[ PrunedPRDFT(nlist[2], -1, iblk, ipats[2]),  # stage 1a: PRDFT y\n                                PrunedDFT(nlist[1], -1, iblk, ipats[1]),    # stage 1b: DFT z\n                                IOPrunedConv(nlist[3], hfunc, oblk, opats[3], iblk, ipats[3], true), # stage 3+4+5: complex conv in x\n                                PrunedIDFT(nlist[1], 1, oblk, opats[1]), # stage 6b: iDFT in z\n                                PrunedIPRDFT(nlist[2], 1, oblk, opats[2]),   # stage 6a: iPRDFT in y\n                                InfoNt(i)\n                            ]]),\n\n       apply := (nt, C, cnt) -> let(prdft1d := C[1],\n                                    pdft1d := C[2],\n                                    iopconv := C[3],\n                                    ipdft1d := C[4],\n                                    iprdft1d := C[5],\n                                    i := cnt[6].params[1],\n                                    nlist := nt.params[1],\n                                    n1 := nlist[1],\n                                    nfreq := nlist[2]/2+1,\n                                    n2 := nlist[2],\n                                    n3 := nlist[3],\n                                    oblk := nt.params[3],\n                                    opats := nt.params[4],\n                                    iblk := nt.params[5],\n                                    ipats := nt.params[6],\n                                    ns1 := iblk * Length(ipats[1]),\n                                    ns2 := iblk * Length(ipats[2]),\n                                    ns3 := iblk * Length(ipats[3]),\n                                    nd1 := oblk * Length(opats[1]),\n                                    nd2 := oblk * Length(opats[2]),\n                                    nd3 := oblk * Length(opats[3]),\n                                    stage1 := Tensor(I(ns1), prdft1d),\n                                    stage2 := RC(Tensor(pdft1d, I(nfreq))),\n                                    stage12 := Tensor(I(nfreq * n2), L(2*ns3, ns3)) * Tensor(stage2 * stage1, I(ns3)),\n                                    stage543c := IDirSum(i, iopconv),\n                                    stage543 := RC(stage543c),\n                                    stage6 := RC(Tensor(ipdft1d, I(nfreq))),\n                                    stage7 := Tensor(I(nd1), iprdft1d),\n                                    stage67 := Tensor(stage7 * stage6, I(nd3)) * Tensor(I(nfreq * n2), L(2*nd3, 2)),\n                                    conv3dr := stage67 * stage543 * stage12,\n                                    conv3dr\n                            ),\n    ),\n#======================\n\n    IOPrunedMDRConv_2D_2trip_xy_freqdata := rec(\n       forTransposition := true,\n       applicable :=  (self, nt) >> not nt.hasTags() and Length(nt.params[1]) = 2 and nt.params[7],\n       children := nt -> let(nlist := nt.params[1],\n                            diag := nt.params[2],\n                            oblk := nt.params[3],\n                            opats := nt.params[4],\n                            iblk := nt.params[5],\n                            ipats := nt.params[6],\n                            nfreq := nlist[2]/2+1,\n                            i := Ind(nfreq),\n                            hfunc := Cond(ObjId(diag) = Lambda,\n                                let(j := Ind(nlist[1]),\n                                    pos := i + j*nfreq,\n                                    Lambda(j, cxpack(diag.at(2*pos), diag.at(2*pos+1)))\n                                ),\n                                ObjId(diag) = fUnk,\n                                fUnk(TComplex, nlist[1]),\n                                let(list := nt.params[1].list,  # here we assume FList(TReal, [...])\n                                    clist := List([1..Length(list)/2], i->Cplx(list[2*i-1], list[2*i])),\n                                    fc := FList(TComplex, clist),\n                                    gf := fTensor(fBase(i), fId(nlist[1])),\n                                    fCompose(fc, gf)\n                                )\n                            ),\n                            [[ PrunedPRDFT(nlist[2], -1, iblk, ipats[2]),  # stage 1: PRDFT x\n                                IOPrunedConv(nlist[1], hfunc, oblk, opats[1], iblk, ipats[1], true), # stage 2+3+4: complex conv in y\n                                PrunedIPRDFT(nlist[2], 1, oblk, opats[1]),   # stage 5: iPRDFT in x\n                                InfoNt(i)\n                            ]]),\n\n       apply := (nt, C, cnt) -> let(prdft1d := C[1],\n                                    iopconv := C[2],\n                                    iprdft1d := C[3],\n                                    i := cnt[4].params[1],\n                                    nlist := nt.params[1],\n                                    n1 := nlist[1],\n                                    nfreq := nlist[1]/2+1,\n                                    n2 := nlist[2],\n                                    oblk := nt.params[3],\n                                    opats := nt.params[4],\n                                    iblk := nt.params[5],\n                                    ipats := nt.params[6],\n                                    ns1 := iblk * Length(ipats[1]),\n                                    ns2 := iblk * Length(ipats[2]),\n                                    nd1 := oblk * Length(opats[1]),\n                                    nd2 := oblk * Length(opats[2]),\n                                    \n#                                    stage1 := L(2*nfreq*ns3*ns2, ns3) * Tensor(I(ns2), Tensor(L(2*nfreq, 2) * prdft1d, I(ns3))) * Tensor(L(ns2*ns1, ns2), I(ns3)),\n#                                    stage2 := Tensor(I(ns3), Tensor(RC(pdft1d), I(nfreq))),\n#                                    pp := Tensor(L(ns3*n2*nfreq, n2*nfreq), I(2)) * Tensor(I(ns3), L(2*nfreq*n2, nfreq)),\n#                                    ppi := Tensor(I(nd3), L(2*nfreq*n2, 2*n2)) * Tensor(L(nd3*n2*nfreq, nd3), I(2)),\n#                                    stage543 := ppi * IDirSum(i, RC(iopconv)) * pp,\n#                                    stage76 := Tensor(L(nd2*nd1, nd1), I(nd3)) * Grp(Tensor((Tensor(I(nd2), iprdft1d * L(2*nfreq, nfreq)) *\n#                                        Tensor(RC(ipdft1d), I(nfreq))), I(nd3)) * L(2*nfreq*nd3*n2, 2*nfreq*n2)),\n\n                                    stage1 := Tensor(I(ns2), prdft1d),\n                                    pp := Tensor(L(ns2*nfreq, nfreq), I(2)),\n                                    ppi := Tensor(L(nd2*nfreq, nd2), I(2)),\n                                    stage432 := IDirSum(i, RC(iopconv)),\n                                    stage5 :=  Tensor(I(nd2), iprdft1d), \n                                    \n                                    conv2dr := Grp(stage5 * ppi) * stage432 * Grp(pp * stage1),\n                                    conv2dr\n                            ),\n    ),\n#     IOPrunedMDRConv_2D_2trip_yx_freqdata := rec(\n#       forTransposition := true,\n#       applicable :=  (self, nt) >> not nt.hasTags() and Length(nt.params[1]) = 2 and nt.params[7],\n#       children := nt -> let(nlist := nt.params[1],\n#                            diag := nt.params[2],\n#                            oblk := nt.params[3],\n#                            opats := nt.params[4],\n#                            iblk := nt.params[5],\n#                            ipats := nt.params[6],\n#                            nfreq := nlist[1]/2+1,\n#                            i := Ind(nfreq),\n#                            hfunc := Cond(ObjId(diag) = Lambda,\n#                                let(j := Ind(nlist[2]),\n#                                    pos := i + j*nfreq,\n#                                    Lambda(j, cxpack(diag.at(2*pos), diag.at(2*pos+1)))\n#                                ),\n#                                ObjId(diag) = fUnk,\n#                                fUnk(TComplex, nlist[2]),\n#                                let(list := nt.params[2].list,  # here we assume FList(TReal, [...])\n#                                    clist := List([1..Length(list)/2], i->Cplx(list[2*i-1], list[2*i])),\n#                                    fc := FList(TComplex, clist),\n#                                    gf := fTensor(fBase(i), fId(nlist[2])),\n#                                    fCompose(fc, gf)\n#                                )\n#                            ),\n#                            [[ PrunedPRDFT(nlist[1], -1, iblk, ipats[1]),  # stage 1: PRDFT y\n#                                IOPrunedConv(nlist[2], hfunc, oblk, opats[2], iblk, ipats[2], true), # stage 2+3+4: complex conv in x\n#                                PrunedIPRDFT(nlist[1], 1, oblk, opats[1]),   # stage 5: iPRDFT in y\n#                                InfoNt(i)\n#                            ]]),\n#\n#       apply := (nt, C, cnt) -> let(prdft1d := C[1],\n#                                    iopconv := C[2],\n#                                    iprdft1d := C[3],\n#                                    i := cnt[4].params[1],\n#                                    nlist := nt.params[1],\n#                                    n1 := nlist[1],\n#                                    nfreq := nlist[1]/2+1,\n#                                    n2 := nlist[2],\n#                                    oblk := nt.params[3],\n#                                    opats := nt.params[4],\n#                                    iblk := nt.params[5],\n#                                    ipats := nt.params[6],\n#                                    ns1 := iblk * Length(ipats[1]),\n#                                    ns2 := iblk * Length(ipats[2]),\n#                                    nd1 := oblk * Length(opats[1]),\n#                                    nd2 := oblk * Length(opats[2]),\n#                                    \n##                                    stage1 := L(2*nfreq*ns3*ns2, ns3) * Tensor(I(ns2), Tensor(L(2*nfreq, 2) * prdft1d, I(ns3))) * Tensor(L(ns2*ns1, ns2), I(ns3)),\n##                                    stage2 := Tensor(I(ns3), Tensor(RC(pdft1d), I(nfreq))),\n##                                    pp := Tensor(L(ns3*n2*nfreq, n2*nfreq), I(2)) * Tensor(I(ns3), L(2*nfreq*n2, nfreq)),\n##                                    ppi := Tensor(I(nd3), L(2*nfreq*n2, 2*n2)) * Tensor(L(nd3*n2*nfreq, nd3), I(2)),\n##                                    stage543 := ppi * IDirSum(i, RC(iopconv)) * pp,\n##                                    stage76 := Tensor(L(nd2*nd1, nd1), I(nd3)) * Grp(Tensor((Tensor(I(nd2), iprdft1d * L(2*nfreq, nfreq)) *\n##                                        Tensor(RC(ipdft1d), I(nfreq))), I(nd3)) * L(2*nfreq*nd3*n2, 2*nfreq*n2)),\n#\n#                                    stage1 := L(2*nfreq*ns3*ns2, ns3) * Tensor(I(ns2), Tensor(L(2*nfreq, 2) * prdft1d, I(ns3))) * Tensor(L(ns2*ns1, ns2), I(ns3)),\n#                                    pp := Tensor(L(ns3*n2*nfreq, n2*nfreq), I(2)) * Tensor(I(ns3), L(2*nfreq*n2, nfreq)),\n#                                    ppi := Tensor(I(nd3), L(2*nfreq*n2, 2*n2)) * Tensor(L(nd3*n2*nfreq, nd3), I(2)),\n#                                    stage432 := ppi * IDirSum(i, RC(iopconv)) * pp,\n#                                    stage5 := Tensor(L(nd2*nd1, nd1), I(nd3)) * Grp(Tensor((Tensor(I(nd2), iprdft1d * L(2*nfreq, nfreq)) *\n#                                        Tensor(RC(ipdft1d), I(nfreq))), I(nd3)) * L(2*nfreq*nd3*n2, 2*nfreq*n2)),\n#\n#                                    conv2dr := stage5 * stage432 * stage1,\n#                                    conv2dr\n#                            ),\n#    ),\n   \n    \n));\n", "meta": {"hexsha": "16d7a1a46b0ea0d5c78d89ce02aad2a715e343af", "size": 49075, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/realdft/rprune.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/transforms/realdft/rprune.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/transforms/realdft/rprune.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": 60.7363861386, "max_line_length": 183, "alphanum_fraction": 0.3970657157, "num_tokens": 13020, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624688140726, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4638579043036946}}
{"text": "############################################################################\n##\n##  recognize.gi                      IRREDSOL                         Burkhard H\u00f6fling\n##\n##  Copyright \u00a9 2003\u20132016 Burkhard H\u00f6fling\n##\n\n\n############################################################################\n##\n#F  IsAvailableIdIrreducibleSolubleMatrixGroup(<G>)\n##\n##  see the IRREDSOL manual\n##  \nInstallGlobalFunction(IsAvailableIdIrreducibleSolubleMatrixGroup,\n    function(G)\n        return IsMatrixGroup(G) and IsFinite(FieldOfMatrixGroup(G))\n            and IsSolvableGroup(G)  and IsIrreducibleMatrixGroup(G)\n            and IsAvailableIrreducibleSolubleGroupData(\n                DegreeOfMatrixGroup(G), Size(TraceField(G)));\n    end);\n\n\n############################################################################\n##\n#F  IsAvailableIdAbsolutelyIrreducibleSolubleMatrixGroup(<G>)\n##\n##  see the IRREDSOL manual\n##  \nInstallGlobalFunction(IsAvailableIdAbsolutelyIrreducibleSolubleMatrixGroup,\n    function(G)\n        return IsMatrixGroup(G) and IsFinite(FieldOfMatrixGroup(G))\n            and IsSolvableGroup(G) and IsAbsolutelyIrreducibleMatrixGroup(G)\n            and IsAvailableAbsolutelyIrreducibleSolubleGroupData(\n                DegreeOfMatrixGroup(G), Size(TraceField(G)));\n    end);\n\n\n############################################################################\n##\n#F  FingerprintDerivedSeries(<n>)\n##\nInstallMethod(FingerprintDerivedSeries, \"generic method for finite group\", true,\n    [IsGroup and IsFinite], 0,\n    function(G)\n        local EncodedPrimePower, EncodedAbInv, primes, max, der;\n\n\n        EncodedPrimePower := function(n, primes)\n\n            local res, i, p;\n            \n            res := -1; # count p^1 as zero\n\n            i := 1;\n            while n mod primes[i][1] <> 0 do\n                 res := res + primes[i][2];\n                 i := i + 1;\n            od;\n            p := primes[i][1];\n            repeat\n                    n := n / p;\n                    res := res + 1;\n            until n mod p <> 0;\n\n            if n <> 1 then \n                Error(\"cannot encode prime power n\");\n            fi;\n            return res;\n        end;\n\n        EncodedAbInv := function (inv, primes, max)\n\n            local i, res;\n            res := EncodedPrimePower(inv[1], primes);\n            for i in [2..Length(inv)] do\n                res := res * max + EncodedPrimePower(inv[i], primes);\n            od;\n            return res;\n        end;\n\n        primes := Collected(FactorsInt(Size(G)));\n        max := Sum(primes, p -> p[2]);\n        der := DerivedSeries(G);\n        return List(der{[1..Length(der)-1]}, N -> EncodedAbInv(AbelianInvariants(N), primes, max));\n    end);\n\nRedispatchOnCondition(FingerprintDerivedSeries, true,\n    [IsGroup], [IsFinite], 0);\n\n\n############################################################################\n##\n#M  FingerprintMatrixGroup(<G>)\n##  \nInstallMethod(FingerprintMatrixGroup, \"for irreducible FFE matrix group\", true,\n    [IsMatrixGroup and CategoryCollections(IsFFECollColl)], 0,\n    function(G)\n\n    local EncodedPrimeDecomposition, primes, max, ids, len, ccl, cl, id, pos, rep, i, g, q,\n        hsize, hstep, counts, fppoly;\n    \n    EncodedPrimeDecomposition := function(n, primes)\n\n        local res, i, p;\n        \n        res := 0;\n        \n        for i in [1..Length(primes)] do\n            res := res * (primes[i][2]+1);\n            p := primes[i][1];\n            while n mod p = 0 do\n                n := n / p;\n                res := res + 1;\n            od;\n        od;\n        if n <> 1 then \n            Error(\"cannot encode integer n\");\n        fi;\n        return res;\n    end;\n\n    primes := Collected(FactorsInt(Size(G)));\n    max := Product(primes, p -> p[2]+1);\n    q := Size(TraceField(G));\n    rep := RepresentationIsomorphism(G);\n    ccl := AttributeValueNotSet(ConjugacyClasses, Source(rep));\n    hsize := NextPrimeInt(2*Length(ccl));\n    hstep := NextPrimeInt(RootInt(hsize));\n    ids := EmptyPlist(hsize);\n    counts := EmptyPlist(hsize);\n    len := 0;\n    for cl in ccl do\n        g := Representative(cl);\n        id := EncodedPrimeDecomposition(Size(cl), primes)\n                + max * (EncodedPrimeDecomposition(Order(g), primes)\n                        + max * CodeCharacteristicPolynomial(ImageElm(rep, g), q));\n        pos := id mod hsize + 1;\n        while IsBound(ids[pos]) and ids[pos] <> id do\n            pos := pos + hstep;\n            if pos > hsize then\n                pos := pos - hsize;\n            fi;\n        od;\n        if IsBound(ids[pos]) then\n            counts[pos] := counts[pos] + 1;\n        else\n            ids[pos] := id;\n            counts[pos] := 1;\n        fi;\n    od;\n    fppoly := [];\n    for id in AsSet(ids) do\n        pos := id mod hsize + 1; \n        while IsBound(ids[pos]) and ids[pos] <> id do\n            pos := pos + hstep;\n            if pos > hsize then\n                pos := pos - hsize;\n            fi;\n        od;\n        Add(fppoly, [id, counts[pos]]);\n    od;\n    return fppoly;\nend);\n\n\n############################################################################\n##\n#F  ConjugatingMatIrreducibleRepOrFail(repG, repH, q, linonly, maxcost, limit_CMIROF)\n##\n##  computes a record x such that G^x.iso = H and (G^homG)^x.mat = H^homH.\n##  If no such matrix exists, the function returns fail.\n##\n##  maxcost and limit_CMIROF specify when the function will abort the search, returning\n##  the string \"too expensive\".\n##\n##  This works like the GAP function Morphium but only looks for linear\n##  isomorphisms.\n##\nInstallGlobalFunction(ConjugatingMatIrreducibleRepOrFail,\n    function(repG, repH, q, maxcost, limit_CMIROF)\n\n    local EncodedPrimeDecomposition, G, H, ccl, cl, hsize, hstep, ids, id, primes,\n        fac, gens, genspos, imglist, g, i, j, k, len,\n        cost, weight, mingens, mincost, mingenspos, totalcost, pos, d, ind, imgs, hom, count,\n        sizes, D, proj, homG, homH, group, cent, C, centsize, imgreps, matrep, orb, S, occ, cpH,\n        moduleG, moduleH, dirr, mat;\n    \n    EncodedPrimeDecomposition := function(n, primes)\n\n        local res, i, p;\n        \n        res := 0;\n        \n        for i in [1..Length(primes)] do\n            res := res * (primes[i][2]+1);\n            p := primes[i][1];\n            while n mod p = 0 do\n                n := n / p;\n                res := res + 1;\n            od;\n        od;\n        if n <> 1 then \n            Error(\"cannot encode integer n\");\n        fi;\n        return res;\n    end;\n\n    G := repG.group;\n    H := repH.group;\n    primes := Collected(FactorsInt(Size(G)));\n    fac := Sum(primes, p -> p[2]);\n    if not IsBound(repG.classes) then\n        repG.classes := AttributeValueNotSet(ConjugacyClasses, G);\n    fi;\n    ccl := repG.classes;\n    hsize := NextPrimeInt(2*Length(ccl));\n    hstep := NextPrimeInt(RootInt(hsize));\n    ids := EmptyPlist(hsize);\n    occ := EmptyPlist(hsize);\n    cost := EmptyPlist(hsize);\n    len := 0;\n    for i in [1..Length(ccl)] do\n        cl := ccl[i];\n        id := [Size(cl), Order(Representative(cl)), \n            CodeCharacteristicPolynomial(ImageElm(repG.rep, Representative(cl)), q)];\n        pos :=((id[3] * fac + EncodedPrimeDecomposition(id[1], primes)) * fac\n                + EncodedPrimeDecomposition(id[2], primes)) mod hsize + 1;\n        while IsBound(ids[pos]) and ids[pos]<>id do\n            pos := pos + hstep;\n            if pos > hsize then\n                pos := pos - hsize;\n            fi;\n        od;\n        if IsBound(ids[pos]) then\n            Add(occ[pos], i);\n        else\n            ids[pos] := id;\n            occ[pos] := [i];\n        fi;\n    od;\n    \n    for i in [1..Length(ids)] do\n        if IsBound(ids[i]) then\n            cost[i] := ids[i][1]*Length(occ[i]);\n        fi;\n    od;\n    \n    \n    gens := ShallowCopy(MinimalGeneratingSet(G));\n    Info(InfoMorph, 1, \"ConjugatingMat: MinimalGeneratingSet has \", Length(gens), \" generators\");\n    \n    mincost := 1;\n    mingenspos := [];\n    \n    for i in [1..Length(gens)] do\n        g := gens[i];\n        id := [Size(ConjugacyClass(G, g)), Order(g), \n            CodeCharacteristicPolynomial(ImageElm(repG.rep, g), q)];\n        pos :=((id[3] * fac + EncodedPrimeDecomposition(id[1], primes)) * fac\n                + EncodedPrimeDecomposition(id[2], primes)) mod hsize + 1;\n        while IsBound(ids[pos]) and ids[pos]<>id do\n            pos := pos + hstep;\n            if pos > hsize then\n                pos := pos - hsize;\n            fi;\n        od;\n        mincost := mincost + cost[pos];\n        Add(mingenspos, pos);\n    od;\n    mingens := gens;\n\n    Info(InfoMorph, 1, \"ConjugatingMat: cost of minimal generating system is \", mincost);\n    \n    # try to find better generators\n    \n    if mincost > maxcost or mincost > 100 then\n        weight := EmptyPlist(hsize);\n        weight[1] := 0;\n        for i in [2..Length(ids)] do\n            if IsBound(cost[i]) then\n                weight[i] := weight[i-1] + QuoInt(Size(G), cost[i]);\n            else\n                weight[i] := weight[i-1];\n            fi;\n        od;\n\n        for i in [1..LogInt(Size(G),2)*Length(MinimalGeneratingSet(G))] do\n            gens := [];\n            S := TrivialSubgroup(G);\n            totalcost := 1;\n            genspos := [];\n            repeat\n                if Random([1..10]) = 1 then\n                    g := Random(G);\n                    id := [Size(ConjugacyClass(G, g)), Order(g), \n                        CodeCharacteristicPolynomial(ImageElm(repG.rep, g), q)];\n                    pos :=((id[3] * fac + EncodedPrimeDecomposition(id[1], primes)) * fac\n                            + EncodedPrimeDecomposition(id[2], primes)) mod hsize + 1;\n                    while IsBound(ids[pos]) and ids[pos]<>id do\n                        pos := pos + hstep;\n                        if pos > hsize then\n                            pos := pos - hsize;\n                        fi;\n                    od;\n                else\n                    k := Random(1, weight[Length(weight)]);\n                    pos := PositionSorted(weight, k);\n                    g := Random(ccl[Random(occ[pos])]);\n                fi;\n                if not g in S then\n                    Add(gens, g);\n                    Add(genspos, pos);\n                    totalcost := totalcost + cost[pos];\n                    S := ClosureGroup(S, g);\n                    #remove for redundant generators - we need not check g\n                    j := 1;\n                    repeat\n                        while j < Length(gens) and Size(Subgroup(S, gens{Difference([1..Length(gens)], [j])})) < Size(S) do\n                            j := j + 1;\n                        od;\n                        if j < Length(gens) then\n                            totalcost := totalcost-cost[genspos[j]];\n                            Remove(gens, j);\n                            Remove(genspos, j);\n                        fi;\n                    until j >= Length(gens);\n                    if totalcost > mincost then\n                        break;\n                    fi;\n                fi;\n            until Size(S) = Size(G);\n            \n            if totalcost < mincost then\n                mingens := gens;\n                mincost := totalcost;\n                mingenspos := genspos;\n                Info(InfoMorph, 2, \"ConjugatingMat: found better generating system of cost \", mincost, \" after \", i, \" attempts\");\n            else\n                Info(InfoMorph, 3, \"ConjugatingMat: found generating system of cost \", totalcost);\n            fi;\n        od;\n    fi;\n    \n    if mincost > maxcost then\n        Info(InfoMorph, 1, \"ConjugatingMat: too expoensive\");\n        return \"too expensive\";\n    fi;\n    Info(InfoMorph, 1, \"ConjugatingMat: using generating system of cost \", mincost);\n    \n    if not IsBound(repH.classes) then\n        repH.classes := AttributeValueNotSet(ConjugacyClasses, H);\n    fi;\n    ccl := repH.classes;\n\n    # compute set of possible generator images\n    \n    imglist := [];\n    cpH := [];\n\n    # sort, most expensive first (one representative will be picked), then ascending cost\n    SortParallel(mingenspos, mingens, function(i, j) return cost[i] > cost[j]; end);\n\n    for i in [1..Length(mingens)] do\n        id := ids[mingenspos[i]];\n        imglist[i] := [];\n        count := Length(occ[mingenspos[i]]);\n        for j in [1..Length(ccl)] do\n            cl := ccl[j];\n            if Size(cl) = id[1] and Order(Representative(cl)) = id[2] then\n                if not IsBound(cpH[j]) then\n                    cpH[j] := CodeCharacteristicPolynomial(ImageElm(repH.rep, Representative(cl)), q);\n                fi;\n                if cpH[j] = id[3] then\n                    if i = 1 then\n                        Add(imglist[i], Representative(cl));\n                    else\n                        Append(imglist[i], AttributeValueNotSet(AsList, cl));\n                    fi;\n                    count := count - 1;\n                    \n                    # if H contains more such conjugacy classes, the groups cannot be\n                    # isomorphic so it doesn't matter if we miss some possible images\n                    if count = 0 then \n                        break; \n                    fi;\n                fi;\n            fi;\n        od;\n        if IsEmpty(imglist[i]) then\n            Info(InfoMorph, 1, \"ConjugatingMat: no suitable image ccl found, reps cannot be conjugate\");\n            return fail;\n        fi;\n    od;\n\n    gens := List(mingens, g -> ImageElm(repG.rep, g));\n\n    dirr := Length(mingens) + 1;\n\n    moduleG := List([1..Length(mingens)], d -> GModuleByMats(gens{[1..d]}, GF(q)));\n    repeat\n        dirr := dirr - 1;\n    until dirr = 0 or not MTX.IsIrreducible(moduleG[dirr]);\n    \n    dirr := dirr + 1;\n    \n    if dirr > Length(mingens) then\n        Error(\"repG must be irreducible\");\n    fi;\n\n    sizes := List([1..Length(mingens)], d -> Size(Group(mingens{[1..d]})));\n\n    D := DirectProduct(G, H);\n    homG := Embedding(D, 1);\n    homH := Embedding(D, 2);\n    proj := Projection(D, 2);\n    \n    gens := List(mingens, g -> ImageElm(homG, g));\n\n    C := G;\n    centsize := [Size(G)];\n    for g in mingens do\n        C := Centralizer(C, g);\n        Add (centsize, Size(C));\n    od;\n\n    # do a backtrack search through the possible images\n    d := 1;\n    ind := [0];\n    imgs := [];\n    group := [];\n    cent := [H];\n    matrep := [];\n    imgreps := [imglist[1]];\n    count := 0;\n    repeat\n        count := count + 1;\n        ind[d] := ind[d] + 1;\n        if count > limit_CMIROF then\n            Info(InfoMorph, 1, \"ConjugatingMat: exceeded limit  \", limit_CMIROF, \" attempts\");\n            return \"too expensive\";\n        elif count mod 1000 = 0 then\n            Info(InfoMorph, 2, \"count: \", count, \" trying indices: \", ind{[1..d]},\n                \", lengths: \", List([1..d], t -> Length(imgreps[t])));\n        else\n            Info(InfoMorph, 3, \"step: \", ind{[1..d]});\n        fi;\n            \n        imgs[d] := imgreps[d][ind[d]];\n        matrep[d] := fail;\n\n        if d = 1 then\n            group[d] := Group(gens[d]*ImageElm(homH, imgs[d]));\n        else\n            group[d] := ClosureGroup(group[d-1], gens[d]*ImageElm(homH, imgs[d]));\n        fi;\n        if d = 1 or Size(group[d]) = sizes[d] then\n        \n            # map from gens to imgs is an isomorphism\n            \n            if d >= dirr then\n                i := d;\n                while i > 0 and matrep[i] = fail do\n                    matrep[i] := ImageElm(repH.rep, imgs[i]);\n                    i := i - 1;\n                od;\n                moduleH := GModuleByMats(matrep{[1..d]}, GF(q));\n                mat :=  MTX.IsomorphismIrred(moduleG[d], moduleH);\n            else\n                mat := true;\n            fi;\n            if mat <> fail then\n                if d < Length(gens) then\n                    d := d + 1;\n                    ind[d] := 0;\n                    cent[d] := Centralizer(cent[d-1], imgs[d-1]);\n                    if Size(cent[d]) = centsize[d] then\n                        orb := OrbitsDomain(cent[d], imglist[d], OnPoints);\n                        Info(InfoMorph, 3, \"ConjugatingMat: \", Length(orb), \" orbits found\");\n                        orb := Filtered (orb, o -> Length(o)=centsize[d]/centsize[d+1]);\n                        imgreps[d] := List (orb, o -> o[1]);\n                        Info(InfoMorph, 3, \"ConjugatingMat: depth \", d, \": \",\n                            Length(orb), \" orbits of expected length found\");\n                    else\n                        Info(InfoMorph, 3, \"ConjugatingMat: centraliser sizes don't match\");\n                        imgreps[d] := [];\n                    fi;\n                else\n                    hom := GroupGeneralMappingByImagesNC(G, H,\n                        List(gens, g -> PreImagesRepresentative(homG, g)), imgs);\n                    if not IsGroupHomomorphism(hom) or not IsBijective(hom) then\n                        Error(\"hom is not an isomophism\");\n                    fi;\n                    Info(InfoMorph, 1, \"ConjugatingMat: found after \", count, \" attempts\");\n                    Info(InfoMorph, 2, \"ConjugatingMat: found indices \", ind);\n                    return rec(iso :=hom, mat := mat);\n                fi;\n            else\n                Info(InfoMorph, 3, \"step: \", ind{[1..d]}, \" linearity fails\");\n            fi;\n        fi;\n        while d > 0 and ind[d] = Length(imgreps[d]) do\n            d := d - 1;\n        od;\n    until d = 0;\n    Info(InfoMorph, 1, \"ConjugatingMat: reps cannot be conjugate,  \", count, \" attempts\");\n        \n    return fail;\nend);\n\n\n\n############################################################################\n##\n#F  ConjugatingMatIrreducibleOrFail(G, H, F)\n##\n##  G and H must be irreducible matrix groups over the finite field F\n##\n##  computes a record x such that G^x.mat = H and x.iso is an isomorphism\n##  from the source of RepresentationIsomorphism(G) to the source of\n##  RepresentationIsomorphism(H). If no such matrix exists, the\n##  function returns fail.\n##  this works like the GAP function Morphium but only looks for linear\n##  isomorphisms. \n##\nInstallGlobalFunction(ConjugatingMatIrreducibleOrFail, function(G, H, F)\n    \n    local q, repG, repH;\n    \n    q := Size(F);\n    repG := rec(rep := RepresentationIsomorphism(G));\n    repG.group := Source(repG.rep);\n    repG.classes := ConjugacyClasses(repG.group);\n\n    repH := rec(rep := RepresentationIsomorphism(H));\n    repH.group := Source(repH.rep);\n    repH.classes := ConjugacyClasses(repH.group);\n\n    return ConjugatingMatIrreducibleRepOrFail(repG, repH, q, infinity, infinity);\nend);\n\n\n############################################################################\n##\n#F  ConjugatingMatImprimitiveOrFail(G, H, d, F)\n##\n##  G and H must be irreducible matrix groups over the finite field F\n##  H must be block monomial with block dimension d\n##\n##  computes record x with a single component x.mat such that G^x.mat = H \n##  or returns fail if no such x.mat exists\n##\n##  The function works best if d is small. Irreducibility is only requried \n##  if ConjugatingMatIrreducibleOrFail is used\n##\nInstallGlobalFunction(ConjugatingMatImprimitiveOrFail, function(G, H, d, F)\n\n# H must have minimal block dimension d and must be a block monomial group for that block size\n\n    local n, systemsG, W, hom, r, basis, orb, posbasis, act, i, blocks, \n        permW, permH, sys, permG, gensG, C, Cinv, mat;\n    \n    n := DegreeOfMatrixGroup(H);\n    systemsG := ImprimitivitySystems(G);\n\n    if Minimum(List(systemsG, sys -> Length(sys.bases[1]))) <> d then\n        Info(InfoIrredsol, 1, \"different minimal block dimension - groups are not conjugate\");\n        return fail;\n    fi;\n    \n    if d = n then\n        if Size(G) < 100000 then\n            return ConjugatingMatIrreducibleOrFail(G, H, F);\n        fi;\n        hom := NiceMonomorphism(GL(n, Size(F)));\n        r := RepresentativeAction(ImagesSource(hom),\n                ImagesSet(hom, G), ImagesSet(hom, H));\n        if r <> fail then\n            Info(InfoIrredsol, 1, \" conjugating matrix found\");\n            return rec( mat := PreImagesRepresentative(hom, r));\n        else\n            Info(InfoIrredsol, 1, \"groups are not conjugate\");\n            return fail;\n        fi;\n    else\n        W := WreathProductOfMatrixGroup(GL(d, Size(F)), SymmetricGroup(n/d));\n        basis := IdentityMat(n, F);\n        orb := Orbit(W, basis[1], OnRight);\n        posbasis := List(basis, b -> Position(orb, b));\n        Assert(1, not fail in posbasis);\n        permW := Group(List(GeneratorsOfGroup(W), g -> Permutation(g, orb, OnRight)));\n            \n        blocks := [];\n        for i in [0,d..n-d] do\n            Add(blocks, basis{[i+1..i+d]});\n        od;\n        act := TransitiveIdentification(Action(H, blocks, OnSubspacesByCanonicalBasis));\n            \n        permH := Group(List(GeneratorsOfGroup(H), g -> Permutation(g, orb, OnRight)));\n        Assert(1, IsSubgroup(permW, permH));\n    \n        for sys in systemsG do\n            if Length(sys.bases[1]) = d \n                    and TransitiveIdentification(\n                        Action(G, sys.bases, OnSubspacesByCanonicalBasis)) = act then\n                C := Concatenation(sys.bases);\n                Cinv := C^-1;\n                gensG := List(GeneratorsOfGroup(G), B -> C*B*Cinv);\n                permG := Group(List(gensG, g->Permutation(g, orb, OnRight)));\n                Assert(1, IsSubgroup(permW, permG));\n                r := RepresentativeAction(permW, permG, permH);\n                if r <> fail then\n                    # compute the corresponding matrix\n                    mat := List(posbasis, k -> orb[k^r]);\n                    r := Cinv * mat;\n                    Info(InfoIrredsol, 1, \" conjugating matrix found\");\n                    return rec(mat := r);\n                fi;\n            fi;\n        od;\n        Info(InfoIrredsol, 1, \"groups are not conjugate\");\n        return fail;\n    fi;\nend);\n\n\n############################################################################\n##\n#F  RecognitionAISMatrixGroup(G, inds, wantmat, wantgroup, wantiso)\n##\n##  version of RecognitionIrreducibleSolubleMatrixGroupNC which \n##  only works for absolutely irreducible groups G. This version\n##  allows to prescribe a set of absolutely irreducible subgroups\n##  to which G is compared. This set is described as a subset <inds> of \n##  IndicesAbsolutelyIrreducibleSolubleMatrixGroups(n, q), where n is the\n##  degree of G and q is the order of the trace field of G. if inds is fail,\n##  all groups in the IRREDSOL library are considered.\n##\n##  WARNING: The result may be wrong if G is not among the groups\n##  described by <inds>.\n##\nInstallGlobalFunction(RecognitionAISMatrixGroup,\n    function(G, inds, wantmat, wantgroup, wantiso)\n    \n        local allinds, newinds, n, q, order, info, fppos, fpinfo, elminds, pos, t, tinv,\n            F, H, systems, rep, i, x;\n        \n        F := TraceField(G);\n        n := DegreeOfMatrixGroup(G);\n        q := Size(F);\n        order := Size(G);\n        \n        info := rec(); # set up the answer\n        \n        allinds := inds = fail;\n        \n        inds := SelectionIrreducibleSolubleMatrixGroups(\n            n, q, 1, inds, [order], fail, fail);\n\n        Info(InfoIrredsol, 1, Length(inds), \n                    \" groups of order \", order, \" to compare\");                \n            \n        if Length(inds) = 0 then\n            Error(\"panic: no group of order \", order, \" in the IRREDSOL library\");\n        elif Length(inds) > 1 then \n            # cut down candidate grops by looking at fingerprints\n            if not TryLoadAbsolutelyIrreducibleSolubleGroupFingerprintIndex(n, q) then\n                fppos := fail;\n            else\n                fppos := PositionSet(IRREDSOL_DATA.FP_INDEX[n][q][1], order);\n                \n                if fppos <> fail then # fingerprint info available\n                    LoadAbsolutelyIrreducibleSolubleGroupFingerprintData(\n                        n, q, IRREDSOL_DATA.FP_INDEX[n][q][2][fppos]);\n                    \n                    fpinfo := IRREDSOL_DATA.FP[n][q][fppos];        # fingerprint info\n\n                    if Length(fpinfo)=2 then # new format using FingerprintDerivedSubgroup\n                        if IsBound(fpinfo[1]) then\n                            pos := PositionSorted(fpinfo[1],\n                                FingerprintDerivedSeries(Source(RepresentationIsomorphism(G))));\n                            if pos = fail then\n                                Error(\"panic: FingerprintDerivedSeries not in database\");\n                            fi;\n                        else\n                            pos := 1;\n                        fi;\n                        fpinfo := fpinfo[2][pos];\n                        if IsInt(fpinfo) then\n                            fpinfo := [[], [[]], [fpinfo]];\n                        fi;\n                    fi;\n\n                    if Length(fpinfo) <> 3 then\n                        Error(\"panic: error in fingerprint database\");\n                    fi;\n\n                    Info(InfoIrredsol, 1, \"computing fingerprint of group\");\n                    \n                    # which distingushing elements are in G?\n                    \n                    if IsEmpty(fpinfo[1]) then\n                        Info(InfoIrredsol, 1, \"all groups have the same fingerprint\");\n                        # this is enough, same code handles this special case\n                        elminds := [];\n                    else\n                        Info(InfoIrredsol, 1, \"computing fingerprint of group\");\n                        elminds := Filtered([1..Length(fpinfo[1])], i ->\n                            fpinfo[1][i] in FingerprintMatrixGroup(G));\n                    fi;\n\n                    # find relevant info in database\n\n                    pos := PositionSet(fpinfo[2], elminds);\n                    \n                    if pos = fail then\n                        Error(\"panic: FingerprintMatrixGroup not found in database\");\n                    fi;\n\n                    newinds := fpinfo[3][pos];\n                    if IsInt(newinds) then\n                        newinds := [newinds];\n                    fi;\n                    if allinds then\n                        if not IsSubset(inds, newinds) then\n                            Error(\"panic: fingerprint indices do not match the IRREDSOL library indices\");\n                        fi;\n                        inds := newinds;\n                    else\n                        inds := Intersection(inds, newinds);\n                    fi;\n                    \n                    Info(InfoIrredsol, 1, Length(inds), \n                        \" groups in the library have the same fingerprint\");                \n                fi;\n            fi;\n        fi;\n\n        if Length(inds) > 1 or wantmat or wantiso then \n            # rewrite G over smaller field if necc.\n            \n            Info(InfoIrredsol, 1, \"rewriting group over its trace field\");\n            \n            t := ConjugatingMatTraceField(G);\n            if t <> One(G) then\n                tinv := t^-1;\n                H := GroupWithGenerators(List(GeneratorsOfGroup(G), g -> tinv * g * t));\n                Assert(1, FieldOfMatrixGroup(H) = F);\n                SetFieldOfMatrixGroup(H, F);\n                SetTraceField(H, F);\n                rep := RepresentationIsomorphism(G);\n                SetRepresentationIsomorphism(H,\n                        GroupHomomorphismByFunction(Source(rep), H,\n                            g -> tinv * ImageElm(rep, g)*t, h -> PreImagesRepresentative(rep, t*h*tinv)));\n                G := H;\n                \n                # we need the imprimitivity systems of G later anyway, so we can rule out groups\n                # with different minimal block dimensions as well\n                \n                if Length(inds) > 1 then\n                    Info(InfoIrredsol, 1, \"computing imprimitivity systems of group\");\n                    systems := ImprimitivitySystems(G);\n                    inds := SelectionIrreducibleSolubleMatrixGroups(\n                        DegreeOfMatrixGroup(G), Size(F), 1, inds, [Order(G)], \n                        [MinimalBlockDimensionOfMatrixGroup(G)], fail);\n                fi;\n                Info(InfoIrredsol, 1, Length(inds), \n                    \" groups also have the same minimal block dimension\");                \n            fi;\n            \n            # find possible groups in the library\n                        \n            for i in [1..Length(inds)-1] do \n                H := IrreducibleSolubleMatrixGroup(DegreeOfMatrixGroup(G), Size(F), 1, inds[i]);\n\n                if fppos = fail then # compare fingerprints now\n                    Info(InfoIrredsol, 1, \"comparing fingerprints\");                \n                    if FingerprintMatrixGroup(G) <> FingerprintMatrixGroup(H) then\n                        Info(InfoIrredsol, 1, \"fingerprint different from id \", \n                            IdIrreducibleSolubleMatrixGroup(H));\n                        continue;\n                    fi;\n                fi;\n\n                if wantiso then\n                     x := ConjugatingMatIrreducibleOrFail(G, H, F);\n                else\n                     x := ConjugatingMatImprimitiveOrFail(G, H,\n                          MinimalBlockDimensionOfMatrixGroup(G), F);\n                fi;\n                if x = fail then\n                    Info(InfoIrredsol, 1, \"group does not have id \", IdIrreducibleSolubleMatrixGroup(H));\n                else\n                    Assert(1, G^(x.mat) = H);\n                    info.id := [DegreeOfMatrixGroup(G), Size(F), 1, inds[i]];\n                    if wantgroup then\n                        info.group := H;\n                    fi;\n                    if wantmat then\n                        info.mat := t*x.mat;\n                    fi;\n                    if wantiso then\n                        info.iso := x.iso;\n                    fi;\n                  Info(InfoIrredsol, 1, \"group id is \", info.id);\n                    return info;\n                fi;\n            od;\n        fi;\n        \n        # we are down to the last group - this must be it\n        \n        i := inds[Length(inds)];\n        info.id := [DegreeOfMatrixGroup(G), Size(F), 1, i];\n        Info(InfoIrredsol, 1, \"group id is \", info.id);\n        if not wantgroup and not wantmat then\n            return info;\n        fi;\n        H := IrreducibleSolubleMatrixGroup(DegreeOfMatrixGroup(G), Size(F), 1, i);\n        if wantgroup then\n            info.group := H;\n        fi;\n        if wantmat or wantiso then\n            if wantiso then\n                x := ConjugatingMatIrreducibleOrFail(G, H, F);\n            else\n                x := ConjugatingMatImprimitiveOrFail(G, H,\n                          MinimalBlockDimensionOfMatrixGroup(G), F);\n            fi;\n            if x = fail then\n                Error(\"panic: group not found in database\");\n            fi;\n            if wantmat then\n                info.mat := t*x.mat;\n            fi;\n            if wantiso then\n                info.iso := x.iso;\n            fi;\n        fi;\n        return info;\n        \n    end);\n\n\n    \n############################################################################\n##\n#F  RecognitionIrreducibleSolubleMatrixGroup(G, wantmat, wantgroup)\n##\n##  Let G be an irreducible soluble matrix group over a finite field. \n##  This function identifies a conjugate H of G group in the library. \n##\n##  It returns a record which has the following entries:\n##  id:                     contains the id of H (and thus of G), \n##                            cf. IdIrreducibleSolubleMatrixGroup\n##  mat: (optional)     a matrix x such that G^x = H\n##  group: (optional)  the group H\n##\n##  The entries mat and group are only present if the booleans wantmat and/or\n##  wantgroup are true, respectively.\n##\n##  Currently, wantmat may only be true if G is absolutely irreducible.\n##\n##  Note that in most cases, the function will be much slower if wantmat\n##  is set to true.  \n##\nInstallGlobalFunction(RecognitionIrreducibleSolubleMatrixGroup, \n    function(arg)\n    \n        local G, wantmat, wantgroup, wantiso, info;\n        \n        if Length(arg) < 2 or Length(arg) > 4 then\n          Error(\"RecognitionIrreducibleSolubleMatrixGroup(G [, wantmat [, wantgroup [,wantiso]]])\");\n        fi;\n        \n        # test if G is soluble\n        \n        G := arg[1];\n        if not IsMatrixGroup(G) or not IsFinite (FieldOfMatrixGroup(G)) \n                or not IsSolvableGroup(G) then\n            Error(\"G must be a soluble matrix group over a finite field\");\n        fi;\n\n        wantmat := arg[2];\n        if Length(arg) = 2 then\n            wantgroup := false;\n        else\n            wantgroup := arg[3];\n            if Length(arg) = 3 then\n                wantiso := false;\n            else\n                wantiso := arg[4];\n            fi;\n        fi;\n        if not IsBool (wantmat) or not IsBool (wantgroup) or not IsBool (wantiso) then\n            Error(\"wantmat, wantgroup and wantiso must be booleans\");\n        fi;\n        info := RecognitionIrreducibleSolubleMatrixGroupNC(G, \n            wantmat, wantgroup, wantiso);\n        if info = fail then\n            Error(\"This group is not within the scope of the IRREDSOL library\");\n        fi;\n        return info;\n    end);\n\n    \n############################################################################\n##\n#F  RecognitionIrreducibleSolubleMatrixGroupNC(G, wantmat, wantgroup, wantiso)\n##\n##  version of RecognitionIrreducibleSolubleMatrixGroup which does not check\n##  its arguments and returns fail if G is not within the scope of the \n##  IRREDSOL library\n##\nInstallGlobalFunction(RecognitionIrreducibleSolubleMatrixGroupNC, \n    function(G, wantmat, wantgroup, wantiso)\n\n        local moduleG, module, info, newinfo, conjinfo, gens, perm_pow, basis, \n            gensG, repG, repH, H, d, e, q, gal;\n        \n        # reduce to the absolutely irreducible case\n        \n        repG := RepresentationIsomorphism (G);\n        gensG := List(GeneratorsOfGroup(Source(repG)), x -> ImageElm(repG, x));\n        moduleG := GModuleByMats (gensG, FieldOfMatrixGroup(G));\n        \n        if not MTX.IsIrreducible (moduleG) then\n            Error(\"G must be irreducible over FieldOfMatrixGroup(G)\");\n        elif MTX.IsAbsolutelyIrreducible (moduleG) then\n            Info(InfoIrredsol, 1, \"group is absolutely irreducible\");\n            info := RecognitionAISMatrixGroup(G, fail, wantmat, wantgroup, wantiso);\n            if info = fail then\n                return fail;\n            else\n                newinfo := rec(id := [DegreeOfMatrixGroup(G), Size(TraceField(G)), 1, info.id[4]]);\n                if wantgroup then\n                    newinfo.group := info.group;\n                fi;\n                if wantmat then\n                    newinfo.mat := info.mat;\n                fi;\n                if wantiso then\n                    newinfo.iso := info.iso;\n                fi;\n             fi;\n        else\n            Info(InfoIrredsol, 1, \"reducing to the absolutely irreducible case\");\n            module := GModuleByMats (gensG, GF(CharacteristicOfField (G)^MTX.DegreeSplittingField (moduleG)));\n            repeat\n                basis := MTX.ProperSubmoduleBasis (module);\n                module := MTX.InducedActionSubmodule (module, basis);\n            until MTX.IsIrreducible (module);\n            Assert(1, MTX.IsAbsolutelyIrreducible (module));\n            \n            # construct absolutely irreducible group\n            \n            H := Group(MTX.Generators (module));\n            SetIsAbsolutelyIrreducibleMatrixGroup(H, true);\n            SetIsIrreducibleMatrixGroup(H, true);\n            SetIsSolvableGroup(H, true);\n            SetSize(H, Size(G));\n            e := LogInt(Size(TraceField (H)), CharacteristicOfField (H));\n            d := DegreeOfMatrixGroup(G)/MTX.Dimension (module);\n            Assert(1, e mod d = 0);\n            \n            # construct representation isomorphism for H\n            \n            repH := GroupGeneralMappingByImagesNC (Source (repG), H,\n                    GeneratorsOfGroup(Source(repG)),\n                    MTX.Generators (module));\n            SetIsGroupHomomorphism (repH, true);\n            SetIsBijective (repH, true);\n            SetRepresentationIsomorphism (H, repH);\n            \n            # recognize absolutely irreducible component\n            \n            info := RecognitionAISMatrixGroup(H, fail, wantmat, false, wantiso);\n            if info = fail then \n                return fail;\n            fi;\n            \n            # translate results back\n            \n            q := CharacteristicOfField(H)^(e/d);\n            SetTraceField (G, GF(q));\n            Assert(1, q^d = info.id[2]);\n            perm_pow := PermCanonicalIndexIrreducibleSolubleMatrixGroup(\n                    DegreeOfMatrixGroup(G), q, d, info.id[4]);\n\n            newinfo := rec(\n                id := [DegreeOfMatrixGroup(G), q, d, info.id[4]^(perm_pow.perm^perm_pow.pow)]);\n            if wantgroup then\n                            \n                newinfo.group := CallFuncList(IrreducibleSolubleMatrixGroup, newinfo.id);\n            fi;\n\n            if wantmat then\n                Info(InfoIrredsol, 1, \"determining conjugating matrix\");\n                # raising to gal-th power is the field automorphism which maps H to a conjugate of\n                # the absolutely irreducible group which is used to construct the irreducible group\n                # we want to find\n                gal := q^perm_pow.pow; \n                if gal = 1 then\n                     gens := List(MTX.Generators(module), mat -> mat^info.mat);\n                     Info(InfoIrredsol, 1, \"already got right Galois conjugate\");\n                     if wantiso then\n                        if Source (RepresentationIsomorphism (newinfo.group)) <> Range (info.iso) then\n                            Error(\"sources of isomorphisms don't match\");\n                        fi;\n                        newinfo.iso := info.iso;\n                    fi;\n               else\n                    # construct Galois conjugate of module\n                    \n                    Info(InfoIrredsol, 1, \"computing and recognizing Galois conjugate\");\n                    \n                    module := GModuleByMats (\n                        List(MTX.Generators (module), mat -> List(mat, row -> List(row, x -> x^gal))),\n                        MTX.Dimension (module), MTX.Field(module));\n                        \n                    H := Group(MTX.Generators (module));\n                    SetIsAbsolutelyIrreducibleMatrixGroup(H, true);\n                    SetIsIrreducibleMatrixGroup(H, true);\n                    SetIsSolvableGroup(H, true);\n                    SetSize(H, Size(G));\n                    \n                    # construct representation isomorphism for H\n                    \n                    repH := GroupGeneralMappingByImagesNC (Source (repG), H,\n                            GeneratorsOfGroup(Source(repG)),\n                            MTX.Generators (module));\n                    SetIsGroupHomomorphism (repH, true);\n                    SetIsBijective (repH, true);\n                    SetRepresentationIsomorphism (H, repH);\n                    \n                    # recognize absolutely irreducible component\n                                    \n                    conjinfo := RecognitionAISMatrixGroup(H, [perm_pow.min], true, false, wantiso);\n                    if conjinfo = fail then \n                        Error(\"panic: internal error, Galois conjugate isn't in the library\");\n                    elif conjinfo.id <> [info.id[1], info.id[2], 1, perm_pow.min] then\n                        Error(\"panic: internal error, didn't find correct Galois conjugate\");\n                    fi;\n                    gens := List(MTX.Generators (module), mat -> mat^conjinfo.mat);\n                    if wantiso then\n                        if Source (RepresentationIsomorphism (newinfo.group)) <> Range (conjinfo.iso) then\n                            Error(\"sources of isomorphisms don't match\");\n                        fi;\n                        newinfo.iso := conjinfo.iso;\n                    fi;\n                fi;\n                 \n                basis := CanonicalBasis (AsVectorSpace (GF(q), GF(q^d)));\n                      # it is important to use CanonicalBasis here, in order to be sure\n                      # that the result is the same as during the construction of\n                      # the corresponding irreducible group\n                \n                # now construct a module over GF(q)\n                 module := GModuleByMats (\n                     List(gens, mat -> BlownUpMat (basis, mat)),\n                     MTX.Dimension (moduleG),\n                     MTX.Field (moduleG));\n                 \n                 newinfo.mat := MTX.Isomorphism (moduleG, module);\n                    if newinfo.mat = fail then\n                        Error(\"panic: no conjugating mat found\");\n                    fi;                                  \n            fi;\n\n        fi;\n        Info(InfoIrredsol, 1, \"irreducible group id is\", newinfo.id);\n        return newinfo;\n    end);\n\n\n############################################################################\n##\n#M  IdIrreducibleSolubleMatrixGroup(<G>)\n##\n##  see the IRREDSOL manual\n##  \nInstallMethod(IdIrreducibleSolubleMatrixGroup, \n    \"for irreducible soluble matrix group over finite field\", true,\n    [IsFFEMatrixGroup \n        and IsIrreducibleMatrixGroup and IsSolvableGroup], 0,\n\n    function(G)\n        \n        local info;\n        \n        info := RecognitionIrreducibleSolubleMatrixGroupNC(G, false, false, false);\n        if info = fail then\n            Error(\"group is beyond the scope of the IRREDSOL library\");\n        else\n            return info.id;\n        fi;\n    end);\n    \n    \nRedispatchOnCondition(IdIrreducibleSolubleMatrixGroup, true,\n    [IsFFEMatrixGroup],\n    [IsIrreducibleMatrixGroup and IsSolvableGroup], 0);\n\n\n############################################################################\n##\n#V  IRREDSOL_DATA.MS_GROUP_INDEX\n##\n##  translation table for Mark Short's irredsol library\n##\nIRREDSOL_DATA.MS_GROUP_INDEX :=\n[ , \n  [ , [ [ 2, 1 ], [ 1, 1 ] ], [ [ 2, 1 ], [ 1, 1 ], [ 1, 5 ], [ 2, 2 ], [ 1, \n                  4 ], [ 1, 3 ], [ 1, 2 ] ],, \n        [ [ 2, 1 ], [ 1, 11 ], [ 2, 2 ], [ 1, 5 ], [ 1, 4 ], [ 2, 3 ], \n             [ 1, 8 ], [ 1, 9 ], [ 2, 4 ], [ 1, 3 ], [ 1, 2 ], [ 1, 10 ], \n             [ 1, 7 ], [ 2, 5 ], [ 1, 14 ], [ 1, 1 ], [ 1, 6 ], [ 1, 13 ], \n             [ 1, 12 ] ],, \n        [ [ 2, 1 ], [ 1, 7 ], [ 1, 10 ], [ 1, 18 ], [ 2, 2 ], [ 1, 8 ], \n             [ 1, 6 ], [ 2, 3 ], [ 1, 14 ], [ 2, 4 ], [ 1, 16 ], [ 1, 4 ], \n             [ 1, 9 ], [ 1, 5 ], [ 2, 5 ], [ 1, 17 ], [ 1, 21 ], [ 1, 22 ], \n             [ 1, 13 ], [ 1, 3 ], [ 1, 2 ], [ 1, 15 ], [ 2, 6 ], [ 1, 12 ], \n             [ 1, 23 ], [ 1, 1 ], [ 1, 20 ], [ 1, 11 ], [ 1, 19 ] ],,,, \n        [ [ 2, 1 ], [ 2, 2 ], [ 2, 3 ], [ 1, 21 ], [ 1, 10 ], [ 2, 4 ], \n             [ 1, 26 ], [ 1, 6 ], [ 2, 5 ], [ 1, 20 ], [ 1, 17 ], [ 2, 6 ], \n             [ 1, 25 ], [ 1, 5 ], [ 1, 7 ], [ 2, 7 ], [ 1, 14 ], [ 2, 8 ], \n             [ 1, 16 ], [ 1, 29 ], [ 2, 9 ], [ 1, 22 ], [ 1, 9 ], [ 1, 8 ], \n             [ 1, 24 ], [ 2, 10 ], [ 1, 13 ], [ 1, 30 ], [ 1, 4 ], [ 1, 18 ], \n             [ 1, 19 ], [ 2, 11 ], [ 1, 23 ], [ 1, 2 ], [ 1, 3 ], [ 1, 12 ], \n             [ 2, 12 ], [ 1, 15 ], [ 1, 28 ], [ 1, 1 ], [ 1, 11 ], [ 1, 27 ] ],, \n        [ [ 1, 26 ], [ 2, 1 ], [ 1, 21 ], [ 1, 23 ], [ 2, 2 ], [ 1, 25 ], \n             [ 1, 27 ], [ 2, 3 ], [ 1, 43 ], [ 1, 18 ], [ 1, 29 ], [ 1, 11 ], \n             [ 2, 4 ], [ 1, 14 ], [ 1, 20 ], [ 1, 22 ], [ 1, 13 ], [ 1, 19 ], \n             [ 1, 30 ], [ 2, 5 ], [ 1, 51 ], [ 1, 50 ], [ 2, 6 ], [ 1, 40 ], \n             [ 1, 38 ], [ 1, 32 ], [ 1, 8 ], [ 1, 9 ], [ 2, 7 ], [ 1, 44 ], \n             [ 1, 17 ], [ 1, 28 ], [ 1, 15 ], [ 1, 12 ], [ 1, 49 ], [ 1, 48 ], \n             [ 2, 8 ], [ 1, 36 ], [ 1, 42 ], [ 1, 5 ], [ 1, 10 ], [ 1, 7 ], \n             [ 1, 6 ], [ 1, 47 ], [ 1, 39 ], [ 1, 35 ], [ 2, 9 ], [ 1, 31 ], \n             [ 1, 16 ], [ 1, 52 ], [ 1, 37 ], [ 1, 3 ], [ 1, 2 ], [ 1, 46 ], \n             [ 2, 10 ], [ 1, 34 ], [ 1, 41 ], [ 1, 1 ], [ 1, 45 ], [ 1, 33 ], \n             [ 1, 24 ], [ 1, 4 ] ] ], \n  [ , [ [ 3, 1 ], [ 1, 1 ] ], [ [ 1, 5 ], [ 3, 1 ], [ 1, 4 ], [ 1, 3 ], \n             [ 1, 2 ], [ 3, 2 ], [ 1, 7 ], [ 1, 1 ], [ 1, 6 ] ],, \n        [ [ 1, 12 ], [ 1, 15 ], [ 1, 16 ], [ 1, 6 ], [ 3, 1 ], [ 1, 3 ], \n             [ 1, 10 ], [ 1, 11 ], [ 1, 9 ], [ 3, 2 ], [ 1, 19 ], [ 1, 4 ], \n             [ 1, 5 ], [ 1, 14 ], [ 1, 13 ], [ 3, 3 ], [ 1, 18 ], [ 1, 8 ], \n             [ 1, 2 ], [ 1, 7 ], [ 1, 17 ], [ 1, 1 ] ] ], \n  [ , [ [ 4, 1 ], [ 2, 3 ], [ 4, 2 ], [ 2, 1 ], [ 1, 5 ], [ 2, 2 ], [ 1, 2 ], \n             [ 1, 3 ], [ 1, 4 ], [ 1, 1 ] ], \n        [ [ 4, 1 ], [ 2, 20 ], [ 4, 2 ], [ 2, 11 ], [ 2, 9 ], [ 2, 8 ], \n             [ 4, 3 ], [ 2, 12 ], [ 2, 16 ], [ 2, 17 ], [ 4, 4 ], [ 1, 73 ], \n             [ 1, 11 ], [ 1, 10 ], [ 2, 4 ], [ 1, 9 ], [ 1, 12 ], [ 1, 34 ], \n             [ 1, 32 ], [ 2, 7 ], [ 2, 6 ], [ 1, 33 ], [ 2, 5 ], [ 2, 10 ], \n             [ 4, 5 ], [ 1, 71 ], [ 2, 18 ], [ 2, 15 ], [ 1, 72 ], [ 2, 24 ], \n             [ 2, 23 ], [ 1, 13 ], [ 1, 14 ], [ 1, 7 ], [ 1, 6 ], [ 2, 3 ], \n             [ 1, 36 ], [ 1, 41 ], [ 2, 2 ], [ 1, 27 ], [ 1, 42 ], [ 1, 26 ], \n             [ 1, 35 ], [ 2, 19 ], [ 2, 14 ], [ 1, 69 ], [ 4, 6 ], [ 1, 70 ], \n             [ 1, 5 ], [ 1, 49 ], [ 1, 38 ], [ 1, 37 ], [ 2, 22 ], [ 2, 25 ], \n             [ 1, 57 ], [ 1, 65 ], [ 2, 26 ], [ 1, 8 ], [ 1, 28 ], [ 1, 39 ], \n             [ 1, 30 ], [ 1, 40 ], [ 1, 29 ], [ 1, 44 ], [ 1, 43 ], [ 1, 21 ], \n             [ 2, 1 ], [ 1, 67 ], [ 1, 68 ], [ 2, 13 ], [ 1, 76 ], [ 1, 3 ], \n             [ 1, 4 ], [ 1, 2 ], [ 1, 31 ], [ 1, 59 ], [ 1, 63 ], [ 1, 64 ], \n             [ 1, 62 ], [ 2, 21 ], [ 1, 61 ], [ 1, 19 ], [ 1, 45 ], [ 1, 24 ], \n             [ 1, 48 ], [ 1, 46 ], [ 1, 47 ], [ 1, 58 ], [ 1, 66 ], [ 1, 75 ], \n             [ 1, 1 ], [ 1, 22 ], [ 1, 23 ], [ 1, 60 ], [ 1, 25 ], [ 1, 54 ], \n             [ 1, 55 ], [ 1, 56 ], [ 1, 74 ], [ 1, 20 ], [ 1, 18 ], [ 1, 52 ], \n             [ 1, 51 ], [ 1, 53 ], [ 1, 17 ], [ 1, 16 ], [ 1, 50 ], [ 1, 15 ] ] ]\n     , \n  [ , [ [ 5, 1 ], [ 1, 1 ] ], [ [ 5, 1 ], [ 5, 2 ], [ 1, 11 ], [ 1, 4 ], [ 1, \n                  12 ], [ 5, 3 ], [ 1, 3 ], [ 1, 5 ], [ 1, 6 ], [ 5, 4 ], \n             [ 1, 7 ], [ 1, 2 ], [ 1, 8 ], [ 1, 10 ], [ 1, 1 ], [ 1, 9 ] ] ], \n  [ , [ [ 6, 1 ], [ 3, 2 ], [ 3, 4 ], [ 6, 2 ], [ 2, 4 ], [ 2, 3 ], \n             [ 1, 15 ], [ 3, 5 ], [ 2, 5 ], [ 1, 9 ], [ 1, 10 ], [ 6, 3 ], \n             [ 2, 7 ], [ 2, 8 ], [ 2, 2 ], [ 3, 1 ], [ 1, 11 ], [ 2, 11 ], \n             [ 1, 16 ], [ 3, 3 ], [ 2, 1 ], [ 1, 6 ], [ 1, 7 ], [ 2, 6 ], \n             [ 2, 12 ], [ 1, 21 ], [ 1, 20 ], [ 1, 14 ], [ 1, 13 ], [ 1, 8 ], \n             [ 1, 5 ], [ 1, 17 ], [ 1, 19 ], [ 1, 3 ], [ 1, 4 ], [ 1, 2 ], \n             [ 2, 10 ], [ 1, 12 ], [ 1, 1 ], [ 1, 18 ] ] ], \n  [ , [ [ 7, 1 ], [ 1, 1 ] ] ] ];\n\nMakeImmutable(IRREDSOL_DATA.MS_GROUP_INDEX);\n\n\n############################################################################\n##\n#F  IdIrreducibleSolubleMatrixGroupIndexMS(<n>, <p>, <k>)\n##\n##  see the IRREDSOL manual\n##  \nInstallGlobalFunction(IdIrreducibleSolubleMatrixGroupIndexMS,\n    function(n, p, k)\n        if IsInt(n) and n > 1 and IsPosInt(p) and IsPrimeInt(p) \n                and IsPosInt(k) then\n            if IsBound(IRREDSOL_DATA.MS_GROUP_INDEX[n]) then\n                if IsBound(IRREDSOL_DATA.MS_GROUP_INDEX[n][p]) then\n                    if IsBound(IRREDSOL_DATA.MS_GROUP_INDEX[n][p][k]) then\n                        return Concatenation([n, p], IRREDSOL_DATA.MS_GROUP_INDEX[n][p][k]);\n                    else\n                        Error(\"k is out of range\");\n                    fi;\n                else\n                    Error(\"p is out of range\");\n                fi;\n            else\n                Error(\"n is out of range\");\n            fi;    \n        else\n            Error(\"n, p, k must be integers, n > 1, and p must be a prime\");\n        fi;\n    end);\n\n\n############################################################################\n##\n#F  IndexMSIdIrreducibleSolubleMatrixGroup(<n>, <q>, <d>, <k>)\n##\n##  see the IRREDSOL manual\n##  \nInstallGlobalFunction(IndexMSIdIrreducibleSolubleMatrixGroup,\n    function(n, p, d, k)\n        local pos;\n        \n        if IsInt(n) and n > 1 and IsPosInt(p) and IsPrimeInt(p) \n                and IsPosInt(k) and IsPosInt(d) and n mod d = 0 then\n            if IsBound(IRREDSOL_DATA.MS_GROUP_INDEX[n]) then\n                if IsBound(IRREDSOL_DATA.MS_GROUP_INDEX[n][p]) then\n                    pos := Position (IRREDSOL_DATA.MS_GROUP_INDEX[n][p], [d, k]);                \n                    if pos <> fail then\n                        return [n, p, pos];\n                    else\n                        Error(\"inadmissible value for k\");\n                    fi;\n                else\n                    Error(\"p is out of range\");\n                fi;\n            else\n                Error(\"n is out of range\");\n            fi;    \n        else\n            Error(\"n, p, d, k must be integers, n > 1, p must be a prime, and d must divide n\");\n        fi;\n    end);\n\n\n############################################################################\n##\n#E\n##\n", "meta": {"hexsha": "c9bcec621b2b6bf9a1525c0f74b37016225ab790", "size": 49557, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/recognize.gi", "max_stars_repo_name": "fingolfin/irredsol", "max_stars_repo_head_hexsha": "c7ab06f5123650049142a5ae3a1c1e05a38d2151", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-09-01T16:53:11.000Z", "max_stars_repo_stars_event_max_datetime": "2017-09-01T16:53:11.000Z", "max_issues_repo_path": "lib/recognize.gi", "max_issues_repo_name": "fingolfin/irredsol", "max_issues_repo_head_hexsha": "c7ab06f5123650049142a5ae3a1c1e05a38d2151", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2017-08-02T16:19:58.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-01T08:57:23.000Z", "max_forks_repo_path": "lib/recognize.gi", "max_forks_repo_name": "fingolfin/irredsol", "max_forks_repo_head_hexsha": "c7ab06f5123650049142a5ae3a1c1e05a38d2151", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2016-02-17T18:26:09.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-02T10:40:35.000Z", "avg_line_length": 39.6773418735, "max_line_length": 130, "alphanum_fraction": 0.4664931291, "num_tokens": 13289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.46360739563757014}}
{"text": "\n##  Copyright (c) 2018-2021, Carnegie Mellon University\n##  See LICENSE for details\n\nNewRulesFor(Circulant, rec(\n    Circulant_PRDFT_FDataNT := rec(\n    \tforTransposition := false,\n    \tswitch           := true,\n    \n    \tapplicable       := nt -> ObjId(nt.params[2]) = FDataNT and ObjId(nt.params[2].nt) = IPRDFT and \n                                  nt.params[2].nt.params = [nt.params[1], 1] and nt.params[1] = -nt.params[3],\n    \n    \tchildren      := nt -> let(n := nt.params[1],\n    \t    [[ spiral.transforms.realdft.IPRDFT(n, 1), spiral.transforms.realdft.PRDFT(n, -1) ]]),\n    \n        apply := (nt, C, cnt) -> C[1] * RCDiag(FDataOfs(nt.params[2].var, Cols(nt.params[2].nt), 0)) * C[2]\n    )\n));\n\n#_isFractionP := (n, p) -> IntDouble(p*n)/p = n;\n#\n#NewRulesFor(TResample, rec(\n#    TResample_TGath := rec(\n#    \tforTransposition := false,\n#    \tswitch           := true,\n#    \n#    \tapplicable       := nt -> ForAny(Zip2(nt.params[1], nt.params[2]), l-> l[1]<l[2]),\n#    \n#    \tchildren      := nt -> [[TResample(nt.params[1], nt.params[1], nt.params[3]), TGath(_toBox(nt.params[2], nt.params[1]))]],\n#    \n#        apply := (nt, C, cnt) -> C[1] * C[2]\n#    ),\n#    \n#    TResample_TScath := rec(\n#    \tforTransposition := false,\n#    \tswitch           := true,\n#    \n#    \tapplicable       := nt -> ForAny(Zip2(nt.params[1], nt.params[2]), l-> l[1]>l[2]),\n#    \n#    \tchildren      := nt -> [[TScat(_toBox(nt.params[1], nt.params[2])), TResample(nt.params[2], nt.params[2], nt.params[3])]],\n#    \n#        apply := (nt, C, cnt) -> C[1] * C[2]\n#    ),\n#    \n#    TResample_RC := rec(\n#    \tforTransposition := false,\n#    \tswitch           := true,\n#    \n#    \tapplicable       := nt -> Length(nt.params[1]) > 1 and Length(nt.params[2]) > 1 and Length(nt.params[3]) > 1 \n#                                  and nt.params[1][1] = nt.params[2][1],\n#    \n#    \tchildren      := nt -> [ List(Zip2(Zip2(nt.params[1], nt.params[2]), nt.params[3]), e-> ApplyFunc(TResample, List(Flat(e), i->[i]))) ],\n#    \n#        apply := (nt, C, cnt) -> let(_C:= Reversed(C), n := Length(nt.params), Compose(\n#            List([1..n], i->let(lens := List(_C, j->j.dims()[1]), Tensor(I(Product(lens{[1..i-1]})), _C[i], I(Product(lens{[i+1..n]})))))))\n#    ),         \n#        \n#    TResample_I := rec(\n#    \tforTransposition := false,\n#    \tswitch           := true,\n#    \n#    \tapplicable       := nt -> Length(nt.params[1]) = 1 and Length(nt.params[2]) = 1 and Length(nt.params[3]) = 1 \n#                                  and nt.params[1][1] = nt.params[2][1]  and nt.params[3][1] = 0,\n#    \n#    \tchildren      := nt -> [[]],\n#    \n#        apply := (nt, C, cnt) -> I(nt.dims()[1])\n#    ),\n#\n#    TResample_PRDFT_frac := rec(\n#    \tforTransposition := false,\n#        denominator      := 2, \n#    \tswitch           := true,\n#    \n#    \tapplicable       := (self,nt) >> Length(nt.params[1]) = 1 and Length(nt.params[2]) = 1 and Length(nt.params[3]) = 1 \n#                                  and nt.params[1][1] = nt.params[2][1] and nt.params[3][1] <> 0 and _isFractionP(nt.params[3][1], self.denominator),\n#    \n#    \tchildren      := nt -> [[ IPRDFT1(nt.params[1][1], -1), PRDFT1(nt.params[1][1], 1) ]],\n#    \n#        apply := (self, nt, C, cnt) >> let(n := nt.params[1][1], nf := n/2+1, shft := IntDouble(nt.params[3][1] * self.denominator),\n#            df := diagMul(fConst(nf, 1/n), fCompose(dOmega(self.denominator*n, shft), dLin(nf, 1, 0, TInt))),\n#            dm :=RCDiag(RCData(df)),\n#            C[1] *dm * C[2])\n#    )\n#));\n#\n", "meta": {"hexsha": "426670d106901ad520098664c35e80764b38194f", "size": 3528, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "breakdown/breakdown.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/breakdown.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/breakdown.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": 40.5517241379, "max_line_length": 150, "alphanum_fraction": 0.4909297052, "num_tokens": 1170, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4633018247495842}}
{"text": "lpbp := (1,2,3);\nrpbp := (1,3,4);\n\ngpbp := Group([lpbp, rpbp]);\n\nlfbp := (1,2,3)(4,5,6);\nrfbp := (1,6,7)(4,3,8);\n\ngfbp := Group([lfbp,rfbp]);\n\nbs := Blocks(gfbp, [1..8]);\n\nhom := ActionHomomorphism(gfbp, bs, OnSets);\n\nim := Image(hom);\n\niso := IsomorphismGroups(im, gfbp);\n\nk := Kernel(im);\n", "meta": {"hexsha": "d9e4f26b45983b493f26b228f4895dfa292e47cf", "size": 291, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "skewb.gap", "max_stars_repo_name": "dvberkel/ultimate-skweb", "max_stars_repo_head_hexsha": "58810bbecb0cdf97ae6c87847a8b832965e01d38", "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": "skewb.gap", "max_issues_repo_name": "dvberkel/ultimate-skweb", "max_issues_repo_head_hexsha": "58810bbecb0cdf97ae6c87847a8b832965e01d38", "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": "skewb.gap", "max_forks_repo_name": "dvberkel/ultimate-skweb", "max_forks_repo_head_hexsha": "58810bbecb0cdf97ae6c87847a8b832965e01d38", "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": 14.55, "max_line_length": 44, "alphanum_fraction": 0.5498281787, "num_tokens": 130, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.798186787341014, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4609491702419888}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# ==========================================================================\n# Scale\n# ==========================================================================\nClass(Scale, BaseContainer, rec(\n    new := meth(self, s, spl)\n        Constraint(IsSPL(spl));\n\tif s = 1 then return spl; fi;\n        Constraint(IsScalarOrNum(s));\n        return SPL(WithBases( self, \n\t    rec( _children := [spl],\n\t\tscalar := s,\n\t\tdimensions := spl.dims() )));\n    end,\n\n    rChildren := self >> [self.scalar, self._children[1]],\n    rSetChild := meth(self, n, what)\n        if n=1 then self.scalar := what;\n        elif n=2 then self._children[1] := what;\n        else Error(\"<n> must be in [1..2]\");\n        fi;\n    end,\n    #from_rChildren  -- inherited\n    #-----------------------------------------------------------------------\n    isPermutation := False, \n    #-----------------------------------------------------------------------\n    isReal := self >> IsRealNumber(self.scalar) and IsRealSPL(self._children[1]),\n    #-----------------------------------------------------------------------\n    toAMat := self >> EvalScalar(self.scalar) * AMatSPL(self._children[1]),\n    #-----------------------------------------------------------------------\n    arithmeticCost := meth(self, costMul, costAddMul)\n        return costMul(self.scalar) * Minimum(self.dimensions) \n\t       + self._children[1].arithmeticCost(costMul, costAddMul);\n    end\n));\n", "meta": {"hexsha": "3a03cfa72595da826899f38a3ab47893c7a53b72", "size": 1509, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/Scale.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/Scale.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/Scale.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.725, "max_line_length": 81, "alphanum_fraction": 0.4294234592, "num_tokens": 320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.5926665999540697, "lm_q1q2_score": 0.46067967198221915}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n_ToDec := v -> let(d:=Length(v), Sum(List([1..d], e -> v[e]*2^(d-e))));\n_ToBin := (i,d) -> List([1..d], e -> BinAnd(QuoInt(i, 2^(d-e)), 1));\n\n_TB := (i, n) -> GF(2).one * _ToBin(i, n);\n_TD := (i) -> _ToDec(IntVecFFE(i));\n\nPrintHex := function(lst, del)\n    local i;\n    if Length(lst) = 0 then\n        return;\n    fi;\n    Print(HexInt(lst[1]));\n    for i in [2..Length(lst)] do\n        Print(del, HexInt(lst[i]));\n    od;\nend;\n\nDeclare(B);\nClass(B, PermClass, rec(\n    def := (n,l) -> Checked(\n        # make sure the 1s are inside the matrix.\n        ForAll(l, e ->\n            IsPosInt(e[1]) and IsPosInt(e[2])\n            and e[1] <= Log2Int(n) and e[2] <= Log2Int(n)),\n        # make sure 'l' is a list.\n        IsList(l),\n\t# done\n\trec()),\n\n    domain := self >> self.params[1],\n    range  := self >> self.params[1],\n\n    # return the bit matrix\n    bm := meth(self)\n        local n, m, i;\n\n        n := Log2Int(self.params[1]);\n\n        # generate matrix of zeros.\n        m := List([1..n], e -> List([1..n], ee -> 0));\n\n        # fill in identity\n        for i in [1..n] do\n            m[i][i] := 1;\n        od;\n\n        # xor in individual 1s from 'l'\n        for i in self.params[2] do\n            m[i[1]][i[2]] := BinXor(m[i[1]][i[2]], 1);\n        od;\n\n        return m * GF(2).root;\n    end,\n\n    # convert the sparse bit matrix info into a permutation matrix\n    toAMat := meth(self)\n        local m, n, i, M;\n\n        m := self.bm();\n        n := self.params[1];\n\n        # generate full permutation matrix\n        M := [];\n        for i in [0..(n-1)] do\n            Add(M, BasisVec(\n                n,\n                _TD(m * _TB(i, Log2Int(n)))\n            ));\n        od;\n\n        return AMatMat(M);\n    end,\n\n    transpose := (self) >> self(\n        self.params[1],\n        self._mklist(\n            MatAMat(\n                InverseAMat(\n                    AMatMat(self.bm())\n                )\n            )\n        )\n    ),\n\n    _mklist := function(b)\n        local l, i, j;\n\n        Constraint(Dimensions(b)[1] = Dimensions(b)[2]);\n\n        b := b - MatSPL(I(Dimensions(b)[1])) * GF(2).root;\n\n        l := [];\n        for i in [1..Length(b)] do\n            for j in [1..Length(b)] do\n                if b[i][j] = GF(2).root then\n                    Add(l, [i,j]);\n                fi;\n            od;\n        od;\n\n        return l;\n    end,\n\n    transpose := self >> B(self.params[1], List(self.params[2], e -> [e[2],e[1]])),\n\n    sums := (self) >> Chain(Error(\"Don't use legacy sumsgen!!\"), true),\n));\n\nDeclare(B2);\n\nClass(B2, PermClass, rec(\n    def := (N, E, S) -> Checked(\n            Is2Power(N),\n            Is2Power(E),\n            Is2Power(S),\n            E*(S^2) >= N,\n            rec( transposed := false)\n    ),\n\n    domain := self >> self.params[1],\n    range  := self >> self.params[1],\n\n    transpose := self >> CopyFields(\n        ApplyFunc(B2, self.params), rec(transposed := not self.transposed)),\n\n    getES := (self) >> Product(self.params{[2..3]}),\n\n    bm := meth(self)\n        local n, nes, b, i;\n\n        n := Log2Int(self.params[1]);\n        nes := n - Log2Int(self.params[2] * self.params[3]);\n\n        b := MatSPL(I(n)) * GF(2).root;\n\n        if self.transposed then\n            for i in [1..nes] do\n                b[i+nes][i] := GF(2).root;\n            od;\n        else\n            for i in [1..nes] do\n                b[i][i+nes] := GF(2).root;\n            od;\n        fi;\n\n        return b * GF(2).root;\n    end,\n\n    toAMat := meth(self)\n        local b, n, i, M;\n\n        b := self.bm();\n        n := self.params[1];\n\n        # generate full permutation matrix\n        M := [];\n        for i in [0..(n-1)] do\n            Add(M, BasisVec(\n                n,\n                _TD(_TB(i, Log2Int(n)) * b)\n            ));\n        od;\n\n        return AMatMat(M);\n    end,\n));\n\nDeclare(BP);\n\nBPI := (n) -> BP(MatSPL(I(Log2Int(n)))*GF(2).root);\nBPL := (n,str) -> BP(MatSPL(Z(Log2Int(n), Log2Int(str)))*GF(2).root);\n\nClass(BP, PermClass, rec(\n    # p must be a full rank 2-d square matrix of size no larger than 29x29.\n    def := function(arg)\n        local n, m;\n\n        n := Length(arg);\n\n        if n = 1 and IsMat(arg[1]) then\n            m := arg[1];\n            n := Dimensions(m)[1];\n        else if n > 0 and IsInt(arg[1]) then\n\n            Constraint(ForAny(arg, e -> e < 2^n));\n            m := List(arg, e -> _TB(e, n));\n        fi; fi;\n\n        # ints in SPIRAL are 29bits long, the upper bits are used for flags\n        Constraint(IsInvertibleMat(AMatMat(m)) and Dimensions(m)[1] < 30);\n\n        # NOTE: this is buggy, because fields below are not exposed through .rChildren\n        return rec(\n            size := 2^Dimensions(m)[1],\n            mat:= m,\n            fast := List(m, e -> _TD(e)),\n            operations := rec(\n                Print := (self) >> Print(self.name, \"(\", PrintCS(self.fast), \")\")\n            )\n        );\n    end,\n\n    # NOTE: this is buggy, because .size is not exposed through .rChildren\n    domain := self >> self.size,\n    range  := self >> self.size,\n\n#    this method converts 'i' to an array of bits, multiplies by the matrix, and converts back\n#\n#    lambda := self >> let(\n#       d := Dimensions(self.params[1])[1],\n#       i := Ind(self.size),\n#       Lambda(i, todec(self.params[1] * tobin(i,d)))),\n\n#   alternative method: ands a row of the matrix with the input and uses a parity\n#   check to see if the bit is set in the output. shifts the output to the proper place. repeat\n    lambda := self >> let(\n        f := Length(self.fast),\n        i := Ind(self.size),\n        Lambda(i, Sum(List([1..f], e -> bin_parity(bin_and(self.fast[e], i))*2^(f-e))))),\n\n    transpose := self >> self.__bases__[1](TransposedMat(self.mat))\n));\n\n## -----------------------------------------------------------------------------\n# CL(N, STR, [E,S,A,R]) - counters a stride L(N, STR) for cache given by [E,S,A,R]\n#\n# this returns a compound object, namely, P * B where\n#\n# P = I(N/(E*S)) x L(E*S, Ceil(E*S/STR))\n#\n# and B is a permutation specified by a function linear on the bits\n# which forces the P*B object to span the sets in the cache after L.\n#\n\nCL := function(N, STR, CS)\n    local E,S,A,Q,P,l,k,i,j, n;\n\n    E := CS[1];\n    S := CS[2];\n\n    # deal with degenerate cases and check params.\n\n    # if cache is larger/equal to transform size, no\n    # fancy footwork is necessary.\n    if E * S >= N then\n        return I(N);\n    fi;\n\n    # the cache must be large enough, otherwise this method\n    # will not build an adequate perm to counteract the stride.\n    if S^2 * E < N then\n        Error(\"CL failure: Cache inadequately sized.\");\n    fi;\n\n    # build the P portion as a bit matrix\n    P := MatSPL(DirectSum(\n        I(Log2Int(N/(E*S))),\n        Z(Log2Int(E*S), Log2Int(E*S) - Log2Int(Maximum(E*S/ Maximum(2*S/E, STR),1)))\n#        Z(Log2Int(E*S), Log2Int(E*S) - Log2Int(Maximum(E*S/STR,1)))\n    )) * GF(2).root;\n\n    # build the list of 1's in the B matrix.\n    l := [];\n    k := Log2Int(Minimum(STR, (N/(E*S))));\n    i := Log2Int(N/(E*S)) + 1;\n    n := Log2Int(N);\n\n    # paranoia check\n    if i-k < 1 then\n        Error(\"Problem!!\");\n    fi;\n\n    A := Copy(P);\n\n    for j in [0..i-2] do\n        A[j+1][j+i] := GF(2).root;\n    od;\n\n    Q := (TransposedMat(P) * A) - (MatSPL(I(n))*GF(2).root);\n\n    for j in [1..n] do\n        for i in [1..n] do\n            if Q[j][i] = GF(2).root then\n                Add(l, [j,i]);\n            fi;\n        od;\n    od;\n\n    # rebuild P as a normal perm matrix that corresponds to the\n    # bit matrix from earlier.\n    j := Maximum(E*S/ Maximum(2*S/E, STR),1);\n\n    P := When(E*S = j or j = 1,\n        I(N),\n        Tensor(\n            I(N/(E*S)),\n            L(E*S, j)\n        )\n    );\n\n    # combine the two and return\n    # temp -- remove the B matrix, to remove the xor/and/shifts\n    # this means we no longer guarantee spanning of the elements/sets\n    # but the expressions should reduce better.\n    return Compose(P,B(N, l));\nend;\n\n\n\n#F fB describes a permutation which can be expressed as a sparse linear\n#F     function on the bits.\n#F\n#F I_2^n -> I_2^N\n#F\n#F params: \n#F  n (input size)\n#F  N (output size)\n#F  l (list of location of 1s in the bit matrix)\n#F\n#F additional details:\n#F   l defines a list of pairs. each pair describes the position\n#F   of a 1 in bit matrix of size Nxn. The output mapping is described\n#F   by (I + BM)(index), where BM is the sparse bit matrix generated by the\n#F   pairs. the pairs themselves are in SPIRAL parlance, that is, [ROW, COL] \n#F   where the first row/col is index 1.\n#F\n#F NOTE:\n#F   in order for composition to work like matrix multiplication, the index\n#F   is now applied from the LEFT (eg: (index)(I + BM)) instead of from the\n#F   right (eg: (I + BM)(index)). \n#F\n#F example: fB(8,8, [[1,2],[2,3]])\n#F\n#F [ 1 1 0\n#F   0 1 1\n#F   0 0 1 ]\n#F\n#F\n#F\nClass(fB, FuncClass, rec(\n    # full input definition.\n    def := (n,N,l) -> rec(), \n    range := self >> self.params[2],\n    domain := self >> self.params[1],\n\n    # abbreviated input forms, from most complex to simplest.\n    abbrevs := [\n        (n, N, l) -> Checked(Is2Power(n), Is2Power(N), IsList(l),\n            [n,N,l]),\n        (n, l) -> Checked(Is2Power(n), IsList(l),\n            [n,n,l]),\n        (n) -> Checked(Is2Power(n),\n            [n,n,[]])\n    ],\n\n    transpose := (self) >> self(\n        self.params[2], \n        self.params[1], \n        self._mklist(\n            MatAMat(\n                InverseAMat(\n                    AMatMat(self.bm())\n                )\n            )\n        )\n    ),\n\n    # LAMBDA with index on the LEFT: (index)(I + BM)\n    lambdaLEFT := self >> let(\n        i := Ind(self.params[1]),\n        Lambda(i, \n            When(Length(self.params[3]) = 0,\n                i,\n                ApplyFunc(\n                    xor, \n                    Concat([i], List(self.params[3], e -> let(\n                        a := Log2Int(self.params[1]) - e[1],\n                        b := Log2Int(self.params[2]) - e[2],\n                        When(b = a,\n                            bin_and(i, V(2^a)),\n                            When(b > a,\n                                shl(bin_and(i, V(2^a)), b - a),\n                                shr(bin_and(i, V(2^a)), a - b)\n                            )\n                        )\n                    )))\n                )\n            )\n        )\n    ),\n    \n    # LAMBDA with index on the RIGHT: (I + BM)(index)\n    lambdaRIGHT := self >> let(\n        i := Ind(self.params[1]),\n        Lambda(i, \n            When(Length(self.params[3]) = 0,\n                i,\n                ApplyFunc(\n                    xor, \n                    Concat([i], List(self.params[3], e -> let(\n                        a := Log2Int(self.params[1]) - e[2],\n                        b := Log2Int(self.params[2]) - e[1],\n                        When(b = a,\n                            bin_and(i, V(2^a)),\n                            When(b > a,\n                                shl(bin_and(i, V(2^a)), b - a),\n                                shr(bin_and(i, V(2^a)), a - b)\n                            )\n                        )\n                    )))\n                )\n            )\n        )\n    ),\n\n    lambda := self >> self.lambdaLEFT(),\n\n    # a bit more complicated than the B case since matrix is not necessarily\n    # square.\n    bm := meth(self)\n        local n, N, m, minn, minN, j, i;\n    \n        n := Log2Int(self.params[1]);\n        N := Log2Int(self.params[2]);\n\n        # since we multiply the index from the right, i * BM,\n        # and n -> N, the bit matrix is nxN. (n rows, N cols)\n\n        # generate matrix of zeros.\n        m := List([1..n], e -> List([1..N], ee -> 0));\n\n        # fill in identity\n        minn := When(N > n, 1, n - N + 1);\n        minN := When(n > N, 1, N - n + 1);\n        for i in [minn..n] do\n            m[i][i-minn+minN] := 1;\n        od;\n\n        # xor in individual 1s from 'l'\n        for i in self.params[3] do\n            m[i[1]][i[2]] := BinXor(m[i[1]][i[2]], 1);\n        od;\n\n        return m * GF(2).root;\n    end,\n\n    # given a bit matrix, make a list.\n    _mklist := function(b)\n        local n,N, m, minn, minN, i, j, l;\n        \n        ## generate identity...\n        #\n\n        n := Dimensions(b)[1];\n        N := Dimensions(b)[2];\n\n        # generate matrix of zeros.\n        m := List([1..n], e -> List([1..N], ee -> GF(2).root*0));\n\n        # fill in identity\n        minn := When(N > n, 1, n - N + 1);\n        minN := When(n > N, 1, N - n + 1);\n        for i in [minn..n] do\n            m[i][i-minn+minN] := GF(2).root;\n        od;\n\n        ## subtract out identity.\n        b := b - m;\n\n        ## add a list entry for each nonzero elem in b.\n\n        l := [];\n        for j in [1..Length(b)] do #rows\n            for i in [1..Length(b[1])] do # cols\n                if b[j][i] = GF(2).root then\n                    Add(l, [j,i]);\n                fi;\n            od;\n        od;\n\n        return l;\n    end,\n));\n\n\nClass(fB2, fTensorBase, rec(\n    __call__ := meth(arg)\n        local self, children, lkup, res, h, es;\n        self := arg[1];\n        es := arg[2];\n        children := Flat(Drop(arg, 2));\n        if self.skipOneChild and Length(children)=1 then return children[1]; fi;\n\n        h := self.hash;\n        if h<>false then\n            lkup := h.objLookup(self, children);\n            if lkup[1]<>false then return lkup[1]; fi;\n        fi;\n        res := WithBases(self, rec(es := es, operations := RewritableObjectOps, _children := children));\n        if h<>false then return h.objAdd(res, lkup[2]);\n        else return res;\n        fi;\n    end,\n\n    rightBinary  := self >> FoldR1(self._children, (p,x) -> let(base:=self.__bases__[1], base(x, p))),\n    leftBinary := self >> FoldL1(self._children, (p,x) -> let(base:=self.__bases__[1], base(p, x))),\n\n    # this works just like the normal fTensor except that\n    # subject to some conditions, the variables responsible for the\n    # top-end of the range get XORed with variables responsible\n    # for the middle of the range.\n\n    lambda := meth(self)\n        local es;\n\n        es := self.es;\n\n        # flatten the fTensors first\n        # ensure we always work with 2 children\n        if self.numChildren() > 2 then\n            return self.leftBinary().lambda();\n        fi;\n\n        # the expression is now guaranteed to be a left sided\n        # binary tree. we need to tell each node/leaf how it is\n        # to be split according to the params available to the fB2.\n\n    end,\n\n    combine_op := (self, jv, split, f, g) >> let(a := Error(\"fB2.lambda()!\"), self),\n    transpose := self >> self.__bases__[1](List(self.children(), c->c.transpose()))\n));\n", "meta": {"hexsha": "be17834bf9dc649fac14d9d2357b95c8d20b3791", "size": 14758, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/ext_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/spl/ext_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/spl/ext_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": 27.4312267658, "max_line_length": 104, "alphanum_fraction": 0.4770294078, "num_tokens": 4261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.45992052435528735}}
{"text": "f := function(x,y)\n    local z, helper;\n    z := 1 - y;\n    helper := function(bla)\n        return x + y*z - bla;\n    end;\n    return helper;\nend;\n\nx -> x + 1;\n{x,y} -> x + y + 1;\n\nPrint(\"This is a string\\n\");\n\nfor n in [1..100] do\n  for i in [1..NrSmallGroups(n)] do\n    G := SmallGroup(n,i);\n    Print(\"SmallGroup(\", n, \",\", i, \") is abelian? \", IsAbelian(G), \"\\n\");\n    if IsPerfectGroup(G) = true then\n      break;\n    fi;\n  od;\nod;\n\nBindGlobal(\"foo\", 1);\nBIND_GLOBAL(\"bar\", 2);\n\nr := rec(\n    a := [1,2,3],\n    b := true,\n    c := fail,\n   );\n\nInstallImmediateMethod( IsFinitelyGeneratedGroup,\n    IsGroup and HasGeneratorsOfGroup,\n    function( G )\n    if IsFinite( GeneratorsOfGroup( G ) ) then\n      return true;\n    fi;\n    TryNextMethod();\n    end );\n", "meta": {"hexsha": "2819e0f4b9108babcd5d62c74fa39e73012cd87f", "size": 761, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "examples/mini.gi", "max_stars_repo_name": "fingolfin/tree-sitter-gap", "max_stars_repo_head_hexsha": "45df4655d7b0d3cd5a2fd2eba74a345d99da84b5", "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": "examples/mini.gi", "max_issues_repo_name": "fingolfin/tree-sitter-gap", "max_issues_repo_head_hexsha": "45df4655d7b0d3cd5a2fd2eba74a345d99da84b5", "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": "examples/mini.gi", "max_forks_repo_name": "fingolfin/tree-sitter-gap", "max_forks_repo_head_hexsha": "45df4655d7b0d3cd5a2fd2eba74a345d99da84b5", "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": 18.119047619, "max_line_length": 74, "alphanum_fraction": 0.5427069645, "num_tokens": 247, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.4597726530920882}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n########################################################################\n#   rules for A x I, I x A, (A x I)L, (I x A)L\nNewRulesFor(TTensorI, rec(\n#   loop splitting for A x I\n    AxI_LS_L := rec(\n        info := \"(A_rxs x I_n)(L|I) -> Sum(Sum(SAG))\",\n        forTransposition := false,\n        applicable := nt -> let(P := nt.params,\n            P[3] = AVec \n            and nt.isTag(1, AVecMemL)\n            and IsInt(P[2]/nt.firstTag().v) \n            and P[2]/nt.firstTag().v>1\n        ),\n        children := nt -> [[\n            When(nt.numTags() = 1, \n                nt.params[1], \n                nt.params[1].setTags(nt.params[1].withoutFirstTag())\n            )\n        ]],\n        apply := (nt, C, cnt) -> let(\n            v := nt.firstTag().v,\n            i := Ind(v), \n            m_by_v := nt.params[2]/v, \n            j := Ind(m_by_v), \n            d := C[1].dims(),\n            fr := When(nt.params[4] = AVec, \n                fTensor(fId(d[2]), fBase(m_by_v, j), fBase(v, i)), \n                fTensor(fBase(m_by_v, j), fBase(v, i), fId(d[2]))\n            ),\n\n            ISumLS(j, m_by_v, \n                Buf(Scat(fTensor(\n                    fId(d[1]), fBase(m_by_v, j), fId(v)\n                ))) \n                * ISum(i, v, Scat(fTensor(\n                    fId(d[1]), fBase(v, i))) * C[1] * Gath(fr)\n                )\n            )\n        )\n\n#D        isApplicable := P -> P[3].isVec and Length(P[5]) > 0 and P[5][1].isMemL and IsInt(P[2]/P[5][1].v) and P[2]/P[5][1].v>1,\n#D        allChildren := P -> let(pv:=P[5], v:=pv[1].v, d:=P[1].dims(), [[When(Length(pv)=1, P[1], P[1].setpv(Drop(pv, 1)))]]),\n#D        rule := (P, C) -> let(\n#D                v:=P[5][1].v, i:=Ind(v), m_by_v := P[2]/v, j:=Ind(m_by_v), d:=C[1].dims(),\n#D                fr:=When(P[4].isVec, fTensor(fId(d[2]), fBase(m_by_v, j), fBase(v, i)), fTensor(fBase(m_by_v, j), fBase(v, i), fId(d[2]))),\n#D                ISumLS(j, m_by_v, Buf(Scat(fTensor(fId(d[1]), fBase(m_by_v, j), fId(v)))) *\n#D                    ISum(i, v, Scat(fTensor(fId(d[1]), fBase(v, i))) * C[1] * Gath(fr)))\n#D            )\n    ),\n    AxI_LS_R := rec(\n        info := \"(I|L)(A_rxs x I_n) -> Sum(Sum(SAG))\",\n        forTransposition := false,\n        applicable := nt -> let(P := nt.params,\n            P[4] = AVec \n            and nt.isTag(1, AVecMemR)\n            and IsInt(P[2]/nt.firstTag().v) \n            and P[2]/nt.firstTag().v > 1\n        ),\n        children := nt -> [[\n            When(nt.numTags() = 1, \n                nt.params[1], \n                nt.params[1].setTags(nt.params[1].withoutFirstTag())\n            )\n        ]],\n        apply := (nt, C, cnt) -> let(\n            v := nt.firstTag().v, \n            i := Ind(v), \n            m_by_v := nt.params[2]/v, \n            j := Ind(m_by_v), \n            d := C[1].dims(),\n            fw := When(nt.params[3] = AVec, \n                fTensor(fId(d[1]), fBase(m_by_v, j), fBase(v, i)), \n                fTensor(fBase(m_by_v, j), fBase(v, i), fId(d[1]))\n            ),\n\n            ISumLS(j, m_by_v,\n                ISum(i, v, Scat(fw) * C[1] * Gath(fTensor(fId(d[2]), fBase(v, i)))) \n                * Buf(Gath(fTensor(\n                    fId(d[2]), fBase(m_by_v, j), fId(v)\n                )))\n            )\n        )\n\n#D        isApplicable := P -> P[4].isVec and Length(P[5]) > 0 and P[5][1].isMemR and IsInt(P[2]/P[5][1].v) and P[2]/P[5][1].v>1,\n#D        allChildren := P -> let(pv:=P[5], v:=pv[1].v, d:=P[1].dims(), [[When(Length(pv)=1, P[1], P[1].setpv(Drop(pv, 1)))]]),\n#D        rule := (P, C) -> let(\n#D                v:=P[5][1].v, i:=Ind(v), m_by_v := P[2]/v, j:=Ind(m_by_v), d:=C[1].dims(),\n#D                fw:=When(P[3].isVec, fTensor(fId(d[1]), fBase(m_by_v, j), fBase(v, i)), fTensor(fBase(m_by_v, j), fBase(v, i), fId(d[1]))),\n#D                ISumLS(j, m_by_v,\n#D                    ISum(i, v, Scat(fw) * C[1] * Gath(fTensor(fId(d[2]), fBase(v, i)))) *\n#D                            Buf(Gath(fTensor(fId(d[2]), fBase(m_by_v, j), fId(v)))))\n#D            )\n    ),\n    LS_drop := rec(\n        info := \"drop tag\",\n        forTransposition := false,\n        applicable := nt -> let(P := nt.params,\n            (nt.isTag(1, AVecMemL) or nt.isTag(1, AVecMemR))\n            and (\n                (not IsInt(P[2]/nt.firstTag().v))\n                or P[2]/nt.firstTag().v = 1\n            )\n        ),\n        children := nt -> let(P := nt.params,\n            [[ TTensorI(P[1], P[2], P[3], P[4]) ]]\n        ),\n        apply := (nt, C, cnt) -> C[1],\n\n#D        isApplicable := P -> Length(P[5]) > 0 and (P[5][1].isMemL or P[5][1].isMemR) and \n#D                            ((not IsInt(P[2]/P[5][1].v)) or P[2]/P[5][1].v=1),\n#D        allChildren := P -> [[TTensorI(P[1], P[2], P[3], P[4], [])]],\n#D        rule := (P, C) -> C[1],\n    )\n));\n\n########################################################################\n#   TCompose rules\nNewRulesFor(TCompose, rec(\n    TCompose_LS_L := rec(\n        info := \"TCompose loop splitting left\",\n        forTransposition := false,\n        applicable := nt -> nt.isTag(1, AVecMemL),\n        children := nt -> [ Concat(\n            [ nt.params[1][1].setTags(nt.getTags()) ], \n            Drop(nt.params[1], 1)\n        )],\n        apply := (nt, C, cnt) -> Compose(C)\n#D        isApplicable := P -> Length(P[2]) > 0 and P[2][1].isMemL,\n#D        allChildren := P -> [Concat([P[1][1].setpv(P[2])], Drop(P[1], 1))],\n#D        rule := (P, C) -> Compose(C)\n    ),\n    TCompose_LS_R := rec(\n        info := \"TCompose loop splitting right\",\n        forTransposition := false,\n        applicable := nt -> nt.isTag(1, AVecMemR),\n        children := nt -> [ Concat(\n            DropLast(nt.params[1], 1), \n            [\n                nt.params[1][Length(nt.params[1])].setTags(nt.getTags())\n            ]\n        )],\n        apply := (nt, C, cnt) -> Compose(C)\n\n#D        isApplicable := P -> Length(P[2]) > 0 and P[2][1].isMemR,\n#D        allChildren := P -> [Concat(DropLast(P[1], 1), [P[1][Length(P[1])].setpv(P[2])])],\n#D        rule := (P, C) -> Compose(C)\n    )\n));\n", "meta": {"hexsha": "fe47c557fb1a2177f123705ef7cbde8f0f9bb1e3", "size": 6130, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/loops/loopsplitting.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/loops/loopsplitting.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/loops/loopsplitting.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": 39.8051948052, "max_line_length": 141, "alphanum_fraction": 0.4203915171, "num_tokens": 2053, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4593397126223686}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nClass(DWT, NonTerminal, DataNonTerminalMixin, rec(\n    abbrevs := [ \n       (n,w) -> Checked(IsPosInt(n), IsEvenInt(n), n>=2, IsList(w), Length(w)=2, \n\t   [n, toFiltFunc(w[1]), toFiltFunc(w[2])]),\n       (n,g,h) -> Checked(IsPosInt(n), IsEvenInt(n), n>=2, \n\t   [n, toFiltFunc(g), toFiltFunc(h)]),\n    ], \n    isReal := self >> true,\n\n    setData := meth(self, gdata, hdata) \n       self.params[2][1] := gdata; self.params[3][1] := hdata; return self; \n    end,\n\n    dims := self >> let(n:=self.params[1], k:=self.params[2][1].domain(),\n                        [n, n + k - 2]), \n\n    terminate := self >> let(\n\tn := self.params[1], \n\tg := self.params[2],\n\th := self.params[3],\n\tVStack(Filt(n/2,g[1],g[2],2).terminate(), Filt(n/2,h[1],h[2],2).terminate())),\n\n    HashId := self >> [ self.params[1], self.params[2][1].domain() ]\n));\n\nKnownCoeffs := filtfunc -> ObjId(filtfunc[1])=FList or\n                           (ObjId(filtfunc[1])=FData and IsBound(filtfunc[1].var.value));\n\nRulesFor(DWT, rec(\n    #F DWT_Base: (base case)\n    #F\n    #F Computes DWT by definition\n    #F \n    DWT_Filt := rec(\n\tforTransposition := true,\n\tlimit            := -1, # means no limit\n\tisApplicable     := (self, P) >> When(self.limit < 0, true,\n\t    P[1] <= self.limit or P[2][1].domain() <= self.limit),\n\n\tallChildren := P -> let(n := P[1], g := P[2], h := P[3],\n\t    [[ Filt(n/2,g[1],g[2],2), Filt(n/2,h[1],h[2],2) ]]),\n\n\trule := (P, C) -> VStack(C[1], C[2])\n    ),\n\n    DWT_Base2 := rec(\n\tisApplicable := P -> true,\n\trule := (P, C) -> let(n := P[1], g := P[2][1].tolist(), h := P[3][1].tolist(),\n\t    diff := Length(h) - Length(g),\n\t    gg := Cond(diff <= 0, g, Concatenation(g, Replicate(diff,0))),\n\t    hh := Cond(diff >= 0, h, Concatenation(h, Replicate(-diff,0))),\n\t    k := Maximum(Length(g), Length(h)),\n\t    When(n=1, Mat([gg,hh]), L(n,2)*RowTensor(n/2,k-2,Mat([gg,hh]))))\n    ),\n\n    DWT_Base4 := rec(\n\tisApplicable := P -> P[1] mod 4 = 0,\n\trule := (P, C) -> let(n := P[1], g := P[2][1].tolist(), h := P[3][1].tolist(),\n\t    diff := Length(h) - Length(g),\n\t    gg := Cond(diff <= 0, g, Concatenation(g, Replicate(diff,0))),\n\t    hh := Cond(diff >= 0, h, Concatenation(h, Replicate(-diff,0))),\n\t    k := Maximum(Length(g), Length(h)),\n\t    When(n=1, Mat([gg,hh]), L(n,2)*RowTensor(n/4,k-2,BB(RowTensor(2,k-2,Mat([gg,hh]))))))\n    ),\n    DWT_Base8 := rec(\n\tisApplicable := P -> P[1] mod 8 = 0,\n\trule := (P, C) -> let(n := P[1], g := P[2][1].tolist(), h := P[3][1].tolist(),\n\t    diff := Length(h) - Length(g),\n\t    gg := Cond(diff <= 0, g, Concatenation(g, Replicate(diff,0))),\n\t    hh := Cond(diff >= 0, h, Concatenation(h, Replicate(-diff,0))),\n\t    k := Maximum(Length(g), Length(h)),\n\t    When(n=1, Mat([gg,hh]), L(n,2)*RowTensor(n/8,k-2,BB(RowTensor(4,k-2,Mat([gg,hh]))))))\n    ),\n\n    #F DWT_Lifting: lifting steps, does not work yet\n    #F \n    DWT_Lifting := rec(\n        info             := \"DWT(n,g,h) -> Lifting steps\",\n        forTransposition := false,\n        isApplicable     := P -> P[1]>2 and P[1] mod 2 =0 and KnownCoeffs(P[2]),\n\tswitch := false,\n        allChildren := function ( P )\n            local n,g,h,vg,vh, lift_schemes,children,scheme,step,filts,pol;\n            n       := P[1];\n\t    [g, h]  := [List(P[2][1].tolist(), EvalScalar), List(P[3][1].tolist(), EvalScalar)];\n\t    [vg,vh] := [P[2][2], P[3][2]];\n\n            lift_schemes := Copy(HashLookupWav(HashTableWavelets, [[g,h],[vg,vh]]));\n\t    children := [];\n\n            for scheme in lift_schemes do \n\t        filts := [];\n\t        for step in Drop(scheme,1) do\n\t\t    pol := FillZeros(ListPoly(step));\n\t\t    Add(filts, Filt(n/2, pol[1], pol[2]));\n\t\tod;\n                # attach the indicator of the type of the first liftings step\n\t\tfilts[1].lift := scheme[1];\n\t\tAdd(children, filts);\n            od;\n            return children;\n        end,\n\n        rule := function ( P, C, Nonterms )\n            local n, i, ind, b, l, M, ind0, ind1, lstep;\n            n := P[1];          \n            b := Nonterms[1].lift;\n            l:=Length(C);\n\n\t    ind0 := fTensor(fBase(2,0), fId(Rows(C[3])));\n\t    ind1 := fTensor(fBase(2,1), fId(Rows(C[3])));\n\t    lstep := (f,b) -> When(b=0, \n\t\tLStep(Scat(ind0) * f * Gath(ind1)),\n\t\tLStep(Scat(ind1) * f * Gath(ind0)));\n\n            M := When(b < 0, \n\t\tSUM(Scat(ind0)*C[2]*Gath(ind1), Scat(ind1)*C[1]*Gath(ind0)),\n\t\tSUM(Scat(ind0)*C[2]*Gath(ind0), Scat(ind1)*C[1]*Gath(ind1)));\n\n\t    b := (b+2) mod 2; # make b positive\n\t    for i in [1 .. l-2] do\n\t        M := M * lstep(C[i+2], b);\n\t\tb := (b+1) mod 2;\n            od; \n\n\t    return M.child(1) * Inplace(Compose(Drop(M.children(),1))) * L(n,2);\n       end\n    )\n));\n\n", "meta": {"hexsha": "d18b9d9cea519b2b962fbfc52217a63a8fd6be59", "size": 4707, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/filtering/dwt.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/filtering/dwt.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/filtering/dwt.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 34.6102941176, "max_line_length": 90, "alphanum_fraction": 0.513490546, "num_tokens": 1665, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799928900257127, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.45932933501233114}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# This rule seems to be unnecessary\n#\n\nRulesFor(WHT, rec(\n    #F WHT_Dirsum: switched off...\n    #F\n    #F see tensor products as direct sums so that they can be \n    #F split separately\n    #F\n    #F   WHT_(2^k) = \n    #F     prod_(i = 1)^r \n    #F       dirsum_(a = 1)^2^(k_1 + .. + k_(i-1))\n    #F         ( dirsum_(b = 1)^2^(k_(i+1) + .. + k_r) WHT_(2^(k_i))) ^ \n    #F           L^(2^(k_i + .. + k_r))_(2^(k_(i+1) + .. + k_r))\n    #F         )\n    #F\n    WHT_Dirsum := rec (\n\tinfo             := \"WHT_(2^k) -> prod dirsum (dirsum WHT_(2^ki))^L\",\n\tforTransposition := false,\n\tswitch           := false,\n\tisApplicable     := P -> P <> 1,\n\tisDerivable := meth ( self, S, C )\n\t    local C1, i, c, j;\n\t    if not (IsApplicableRule(self, S) and\n\t\t    ForAll(C, c -> ObjId(c) = WHT)) then return false; fi;\n\t    i  := 1;\n\t    C1 := [ ];\n\t    while i <= Length(C) do\n\t        c := C[i];\n\t\tfor j in [i..i + 2^(S.params - c.params) - 1] do\n\t\t    if c.params <> C[j].params then\n\t\t\treturn false;\n\t\t    fi;\n\t\tod;\n\t\tAdd(C1, c);\n\t\ti := i + 2^(S.params - c.params);\n\t    od;\n\t    return Sum(C1, c -> c.params) = S.params;\n\tend,\n\n\tallChildren := function ( P )\n\t    local C, C1, p, c, i, k;\n\t    C := OrderedPartitions(P);\n\t    Unbind(C[Length(C)]);\n\t    C1 := [ ];\n\t    for p in C do\n\t         c := [ ];\n\t\t for i in p do\n\t\t     for k in [1..2^(P - i)] do Add(c, WHT(i)); od;\n\t\t od;\n\t\t Add(C1, c);\n\t    od;\n\t    return C1;\n\tend,\n\n\trandomChildren := function ( P )\n\t    local C, sum, rand;\n\t    C   := [ ];\n\t    sum := 0;\n\t    while sum < P do\n\t        if sum = 0 then\trand := RandomList( [1..(P-1)] );\n\t\telse\t\trand := RandomList( [1..(P-sum)] );\n\t\tfi;\n\t\tAdd( C, rand );\n\t\tsum := sum + rand;\n\t    od;\n\t    return Concatenation(List(C, c -> List([1..2^(P - c)], i -> WHT(c))));\n\tend,\n\n\trule := function ( P, C )\n\t    local C1, c, left, right, factors, i;\n\t    i  := 1;\n\t    C1 := [ ];\n\t    while i <= Length(C) do\n\t        c := C[i];\n\t\tAdd(C1, c);\n\t        i := i + 2^P/c.dimensions[1];\n\t    od;\n\n\t    left    := 1;\n\t    right   := 2^P / C1[1].dimensions[1];\n\t    factors := [ ];\n   \n            # first factor\n\t    Add(factors,\n\t\tConjugate( \n\t\t    DirectSum(List([1..right], l -> C1[1])),\n\t\t    L(2^P, right))\n\t    );\n\n\t    left  := left * C1[1].dimensions[1];\n\t    right := right / C1[2].dimensions[1];\n\t    \n            # middle factors\n\t    for i in [2..Length(C1) - 1] do\n  \t        Add(factors, DirectSum(  \n\t\t    List([1..left],\n\t\t\tk -> Conjugate(\n\t\t\t    DirectSum(List([1..right], l -> C1[i])),\n\t\t\t    L(right * C1[i].dimensions[1], right))\n\t\t    )\n\t\t));\n\t\tleft  := left * C1[i].dimensions[1];\n\t\tright := right / C1[i+1].dimensions[1];\n\t    od;\n\n            # last factor\n\t    Add(factors, DirectSum(List([1..left], k -> C1[Length(C1)])));\n\t    return Compose(factors);\n\t end\n    )\n));\n", "meta": {"hexsha": "17035aae11ec0f4b15722f9bdbe4cb7b52db74c8", "size": 2864, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/wht/dirsum.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/wht/dirsum.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/wht/dirsum.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.2711864407, "max_line_length": 75, "alphanum_fraction": 0.4720670391, "num_tokens": 1001, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799252, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.4588509645484035}}
{"text": "\n#\n# Read(\"~/Workspace/groupsSB/epi/A2/handle.gi\");\n#\n\ntype:=\"A\";\nrank:=2;\nnr_pos_roots:=3;\n\nRead(\"~/Workspace/groupsSB/epi/group.gi\");\n\n\n\n#sList(rels,r->Value(r,[vars[22]],[vars[2]+vars[12]]);\n\n#\n# c_1, c_2 not 0 , so they can be choosen c_1=c_2=1 => c_3=c_1/2\n#\nhandleReg:=function()\n\t# a test that the coeffs are right\n\t#a:=root_group(1,xvars[1]);\n\t#b:=root_group(2,xvars[2]);\n\t#c:=root_group(3,xvars[3]);\n\t#test1:=evaluate_U(a*b*c,[[[xvars[1]],[One(APR)]],[[xvars[2]],[One(APR)]],[[xvars[3]],[One(APR)/2]]]);\n\t#test2:=evaluate_U(a*b*c,[[[xvars[1]],[One(APR)*2]],[[xvars[2]],[One(APR)*2]],[[xvars[3]],[One(APR)*2]]]);\n\t#test2-test1^2;\n\n\tlocal ua,ub,uab,u,e,nn,vals,rels,i,v;\n\t#ua:=root_group(1,2);\n\t#ub:=root_group(2,2);\n\t#uab:=root_group(3,2);\n\tua:=root_group(1,1);\n\tub:=root_group(2,1);\n\tuab:=root_group(3,1/2);\n\tu:=ua*ub*uab;\n\te:=u-id_mat;\n\n\tnn:=List([1..2*nr_pos_roots+rank],i->xvars[i]);\n\n\tvals:=[];\n\tAppend(vals,[[[xvars[6]],[Zero(APR)]]]);\n\tAppend(vals,[[[xvars[4]],[Zero(APR)]]]);\n\tAppend(vals,[[[xvars[5]],[Zero(APR)]]]);\n\tAppend(vals,[[[xvars[7]],[2*xvars[8]]]]);\n\tAppend(vals,[[[xvars[8]],[Zero(APR)]]]);\n\tAppend(vals,[[[xvars[2]],[xvars[1]]]]);\n\t##\n\t#Append(vals,[[[xvars[1]],[Zero(APR)]]]);\n\t#Append(vals,[[[xvars[3]],[Zero(APR)]]]);\n\t#Append(vals,[[[xvars[7]],[Zero(APR)]]]);\n\n\t#\n\t# atentie la ordinea transpunerilor\n\t#\n\trels:=nn*TransposedMat(u)-nn;\n\tfor i in [1..Length(rels)] do\n\t\tfor v in vals do\n\t\t\tPrint(rels[i],\"\\n\");\n\t\t\trels[i]:=One(APR)*Value(rels[i],v[1],v[2]);\n\t\t\tnn[i]:=One(APR)*Value(nn[i],v[1],v[2]);\n\t\tod;\n\tod;\n\treturn [u,nn,rels];\nend;\n\n#\n# c_2=0\n#\nhandle2:=function()\n\tlocal ua,ub,uab,u,e,nn,vals,rels,i,v;\n\tua:=root_group(1,1);\n\tuab:=root_group(3,1);\n\tu:=ua*uab;\n\te:=u-id_mat;\n\n\tnn:=List([1..2*nr_pos_roots+rank],i->xvars[i]);\n\n\tvals:=[];\n\tAppend(vals,[[[xvars[4]],[Zero(APR)]]]);\n\tAppend(vals,[[[xvars[6]],[Zero(APR)]]]);\n\tAppend(vals,[[[xvars[2]],[-xvars[7]-xvars[8]]]]);\n\tAppend(vals,[[[xvars[5]],[-2*xvars[7]+xvars[8]]]]);\n\t##\n\tAppend(vals,[[[xvars[1]],[Zero(APR)]]]);\n\tAppend(vals,[[[xvars[3]],[Zero(APR)]]]);\n\tAppend(vals,[[[xvars[7]],[Zero(APR)]]]);\n\n\t#\n\t# atentie la ordinea transpunerilor\n\t#\n\trels:=nn*TransposedMat(u)-nn;\n\tfor i in [1..Length(rels)] do\n\t\tfor v in vals do\n\t\t\tPrint(rels[i],\"\\n\");\n\t\t\trels[i]:=One(APR)*Value(rels[i],v[1],v[2]);\n\t\t\tnn[i]:=One(APR)*Value(nn[i],v[1],v[2]);\n\t\tod;\n\tod;\n\treturn [u,nn,rels];\nend;\n\n", "meta": {"hexsha": "8f73a2222b09299689a536a563b4389bfc17fd75", "size": 2369, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "epi/A2/handle.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/handle.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/handle.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.2254901961, "max_line_length": 107, "alphanum_fraction": 0.5774588434, "num_tokens": 1028, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6442251133170357, "lm_q1q2_score": 0.45883785959937545}}
{"text": "#############################################################################\n##\n#W  selfsimfam.gi            automgrp package                  Yevgen Muntyan\n#W                                                             Dmytro Savchuk\n##\n#Y  Copyright (C) 2003 - 2018 Yevgen Muntyan, Dmytro Savchuk\n##\n\n\n###############################################################################\n##\n#R  IsSelfSimFamilyRep\n##\n##  Any object from category SelfSimFamily which is created here, lies in a\n##  category IsSelfSimFamilyRep.\n##  Family of SelfSim object  < a >  contains all essential information about\n##  (mathematical) automaton which generates group containing  < a > :\n##  it contains automaton, properties of automaton and group generated by it,\n##  etc.\n##  Also family contains group generated by states of underlying automaton.\n##\nDeclareRepresentation(\"IsSelfSimFamilyRep\",\n                      IsComponentObjectRep and IsAttributeStoringRep,\n                      [ \"freegroup\",      # IsSelfSim objects store words from this group\n                        \"freegens\",       # list [f1, f2, ..., fn, f1^-1, ..., fn^-1, 1]\n                                          # where f1..fn are generators of freegroup,\n                                          # n is numstates; 1 is stored if and only if\n                                          # trivstate is not zero.\n                                          # Some fi^-1 may be missing if corresponding\n                                          # generator is not invertible (but the list still\n                                          # has the length of 2n + 1).\n                        \"recurgens\",      # Generators of the group, list of length n.\n                        \"numstates\",      # number of non - trivial generating states\n                        \"deg\",\n                        \"trivstate\",      # 0 or 2*numstates + 1\n                        \"isgroup\",        # whether all generators are invertible\n                        \"names\",          # list of non - trivial generating states\n                        \"recurlist\",      # the automaton table, states correspond to freegens\n                        \"oldstates\",      # mapping from states in the original table used to\n                                          # define the group to the states in recurlist:\n                                          # SelfSim(fam!.freegens[oldtstates[k]], fam) is the element\n                                          # which corresponds to k-th state in the original automaton\n                        \"rws\",            # rewriting system\n                        \"use_rws\",        # whether to use rewriting system in multiplication\n                        \"use_contraction\" # whether to use contraction in IsOne\n                      ]);\n\n\nBindGlobal(\"AG_FixRecurList\",\nfunction(list, oldstates, names)\n  local i, j, k, reduced, deg, isgroup, numstates, perm, trivstate, trivstates, new_trivstates;\n\n  deg := Length(list[1]) - 1;\n  isgroup := true;\n  trivstate := 0;\n  trivstates := [];\n  numstates := Length(list);\n\n  # convert list to a \"canonical\" form\n\n  for i in [1..numstates] do\n    for j in [1..deg] do\n      if not IsList(list[i][j]) then list[i][j] := [list[i][j]]; fi;\n    od;\n  od;\n\n  # find if there are any \"obviously\" trivial states\n\n  repeat\n    new_trivstates := [];\n    #  find new trivial states (new ones may appear in every iteration)\n    for i in [1..Length(list)] do\n      if (not i in trivstates) and AG_IsObviouslyTrivialStateInList(i, list) then\n        Add(new_trivstates, i);\n        numstates := numstates - 1;\n      fi;\n    od;\n\n    for trivstate in new_trivstates do\n      for i in [1..Length(list)] do\n        for j in [1..deg] do\n      #  remove trivstate from everywhere\n          list[i][j] := Filtered(list[i][j], x -> AbsInt(x) <> trivstate);\n      #  freely reduce words\n          repeat\n            reduced := true;\n            for k in [1..Length(list[i][j]) - 1] do\n              if list[i][j][k] = -list[i][j][k + 1] then\n                Remove(list[i][j], k);\n                Remove(list[i][j], k);\n                reduced := false;\n                break;\n              fi;\n            od;\n          until reduced;\n        od;\n      od;\n    od;\n    Append(trivstates, new_trivstates);\n  until new_trivstates = [];\n\n  # move trivial state to the end\n  Sort(trivstates);\n  trivstates := Reversed(trivstates);\n\n  for trivstate in trivstates do\n    for i in [1..Length(list)] do\n      for j in [1..deg] do\n    #  remove trivstate from everywhere\n        Apply(list[i][j], function(x)\n                            if x > trivstate then return x - 1;\n                            elif x < -trivstate then return x + 1;\n                            fi;\n                            return x;\n                          end);\n      od;\n    od;\n\n    for i in [1..Length(oldstates)] do\n      if oldstates[i] = trivstate then\n        oldstates[i] := 2*numstates + 1;\n      elif oldstates[i] > trivstate then\n        oldstates[i] := oldstates[i] - 1;\n      fi;\n    od;\n    Remove(list, trivstate);\n    Remove(names, trivstate);\n  od;\n\n  if trivstates <> [] then\n    trivstate := 2*numstates + 1;\n    list[trivstate] := List([1..deg], k -> []);\n    list[trivstate][deg + 1] := ();\n  fi;\n\n\n  # add inverses of states\n  for i in [1..numstates] do\n    if AG_IsInvertibleStateInList(i, list) then\n      list[i + numstates] := [];\n\n      list[i][deg + 1] := AG_PermFromTransformation(list[i][deg + 1]);\n\n      perm := list[i][deg + 1];\n      list[i + numstates][deg + 1] := perm^-1;\n      for j in [1..deg] do\n        list[i + numstates][j] := -Reversed(list[i][j^(perm^-1)]);\n      od;\n    else\n      isgroup := false;\n      if list[i][deg + 1]^-1<>fail then\n        list[i][deg + 1] := AG_PermFromTransformation(list[i][deg + 1]);\n      fi;\n    fi;\n  od;\n\n  return [list, numstates, trivstate, isgroup];\nend);\n\n\n###############################################################################\n##\n#M  SelfSimFamily( <list>, <names>, <bind_vars> )\n##\nInstallMethod(SelfSimFamily, \"for [IsList, IsList, IsBool]\",\n              [IsList, IsList, IsBool],\nfunction (list, names, bind_global)\n  local deg, tmp, trivstate, numstates, i,\n        freegroup, freegens, a, family, oldstates,\n        isgroup;\n\n  if not AG_IsCorrectRecurList(list, false) then\n    Error(\"in SelfSimFamily(IsList, IsList, IsString):\\n\",\n          \"  given list is not a correct list representing self-similar group\\n\");\n  fi;\n\n# 1. make a local copy of arguments, since they will be modified and put into the result\n\n  list := StructuralCopy(list);\n  names := StructuralCopy(names);\n  deg := Length(list[1]) - 1;\n\n# 2. Find trivial states, permute states\n\n  oldstates := [1..Length(list)];\n  tmp := AG_FixRecurList(list, oldstates, names);\n  list := tmp[1];\n  numstates := tmp[2];\n  trivstate := tmp[3];\n  isgroup := tmp[4];\n\n# 3. Create FreeGroup and FreeGens\n\n  freegroup := FreeGroup(names);\n  freegens := ShallowCopy(FreeGeneratorsOfFpGroup(freegroup));\n  for i in [1..numstates] do\n    if IsBound(list[i + numstates]) then\n      freegens[i + numstates] := freegens[i]^-1;\n    fi;\n  od;\n  if trivstate <> 0 then\n    freegens[trivstate] := One(freegroup);\n  fi;\n\n# 4. Create family\n\n  if isgroup then\n    family := NewFamily(\"SelfSimFamily\",\n                        IsInvertibleSelfSim,\n                        IsInvertibleSelfSim,\n                        IsSelfSimFamily and IsSelfSimFamilyRep);\n  else\n    family := NewFamily(\"SelfSimFamily\",\n                        IsSelfSim,\n                        IsSelfSim,\n                        IsSelfSimFamily and IsSelfSimFamilyRep);\n  fi;\n\n  family!.isgroup := isgroup;\n  family!.deg := deg;\n  family!.numstates := numstates;\n  family!.trivstate := trivstate;\n  family!.names := names;\n  family!.freegroup := freegroup;\n  family!.freegens := freegens;\n  family!.recurlist := list;\n  family!.oldstates := oldstates;\n  family!.use_rws := false;\n  family!.rws := fail;\n  family!.use_contraction := false;\n\n  SetIsActingOnBinaryTree(family, deg = 2);\n  SetDegreeOfTree(family, deg);\n  SetTopDegreeOfTree(family, deg);\n\n  family!.recurgens := [];\n  for i in [1..Length(list)] do\n    if IsBound(list[i]) then\n      family!.recurgens[i]  :=\n        __AG_CreateSelfSim(family, freegens[i],\n                        List([1..deg], j -> AssocWordByLetterRep(FamilyObj(freegens[1]), list[i][j])),\n                        list[i][deg + 1],\n                        i > numstates or IsBound(list[i + numstates]));\n    fi;\n  od;\n\n  # XXX It's evil to bind global names, consider AssignGeneratorVariables\n  # XXX Check whether names are actually valid names for variables\n  if bind_global then\n    for i in [1..family!.numstates] do\n      if IsBoundGlobal(family!.names[i]) then\n        UnbindGlobal(family!.names[i]);\n      fi;\n      BindGlobal(family!.names[i], family!.recurgens[i]);\n      MakeReadWriteGlobal(family!.names[i]);\n    od;\n    #BindGlobal(AG_Globals.identity_symbol, One(family));\n    #MakeReadWriteGlobal(AG_Globals.identity_symbol);\n  fi;\n\n  return family;\nend);\n\n\n###############################################################################\n##\n#M  SelfSimFamily( <list> )\n##\nInstallMethod(SelfSimFamily, \"for [IsList]\", [IsList],\nfunction(list)\n  return SelfSimFamily(list, false);\nend);\n\n\n###############################################################################\n##\n#M  SelfSimFamily( <list>, <bind_vars> )\n##\nInstallMethod(SelfSimFamily, \"for [IsList, IsBool]\", [IsList, IsBool],\nfunction(list, bind_vars)\n  if not AG_IsCorrectRecurList(list, false) then\n    Error(\"in SelfSimFamily(IsList):\\n\",\n          \"  given list is not a correct list representing self-similar group\\n\");\n  fi;\n\n  return SelfSimFamily(list,\n                     List([1..Length(list)],\n                          i -> Concatenation(AG_Globals.state_symbol, String(i))),\n                     bind_vars);\nend);\n\n\n###############################################################################\n##\n#M  SelfSimFamily( <list>, <names> )\n##\nInstallMethod(SelfSimFamily, \"for [IsList, IsList]\", [IsList, IsList],\nfunction(list, names)\n  if not AG_IsCorrectRecurList(list, false) then\n    Error(\"in SelfSimFamily(IsList, IsList):\\n\",\n          \"  given list is not a correct list representing automaton\\n\");\n  fi;\n\n  return SelfSimFamily(list, names, AG_Globals.bind_vars_autom_family);\nend);\n\n\n\n###############################################################################\n##\n#M  One( <fam> )\n##\nInstallMethod(One, \"for [IsSelfSimFamily]\", [IsSelfSimFamily],\nfunction(fam)\n  return __AG_CreateSelfSim(fam, One(fam!.freegroup),\n                         List([1..fam!.deg], i -> One(fam!.freegroup)),\n                         (), true);\nend);\n\n\n###############################################################################\n##\n#M  GroupOfSelfSimFamily( <fam> )\n##\nInstallMethod(GroupOfSelfSimFamily, \"for [IsSelfSimFamily]\",\n              [IsSelfSimFamily],\nfunction(fam)\n  local g;\n\n  if not fam!.isgroup then\n    return fail;\n  fi;\n\n  if fam!.numstates > 0 then\n    g := GroupWithGenerators(fam!.recurgens{[1..fam!.numstates]});\n  else\n    g := Group(One(fam));\n  fi;\n\n  SetUnderlyingSelfSimFamily(g, fam);\n  SetIsGroupOfSelfSimFamily(g, true);\n  # XXX\n  SetGeneratingRecurList(g, fam!.recurlist);\n  SetRecurList(g, fam!.recurlist);\n  SetDegreeOfTree(g, fam!.deg);\n  SetTopDegreeOfTree(g, fam!.deg);\n  SetIsActingOnBinaryTree(g, fam!.deg = 2);\n\n  return g;\nend);\n\n###############################################################################\n##\n#M  SemigroupOfSelfSimFamily( <fam> )\n##\nInstallMethod(SemigroupOfSelfSimFamily, \"for [IsSelfSimFamily]\",\n              [IsSelfSimFamily],\nfunction(fam)\n  local g;\n\n  if fam!.trivstate <> 0 then\n    if fam!.numstates = 0 then\n      g := SemigroupByGenerators([One(fam!.recurgens[fam!.trivstate])]);\n    else\n      g := MonoidByGenerators(fam!.recurgens{[1..fam!.numstates]});\n    fi;\n  else\n    g := SemigroupByGenerators(fam!.recurgens{[1..fam!.numstates]});\n  fi;\n\n  SetUnderlyingSelfSimFamily(g, fam);\n\n  # XXX\n  SetGeneratingRecurList(g, fam!.recurlist);\n  SetRecurList(g, fam!.recurlist);\n\n  SetDegreeOfTree(g, fam!.deg);\n  SetTopDegreeOfTree(g, fam!.deg);\n  SetIsActingOnBinaryTree(g, fam!.deg = 2);\n  SetIsSelfSimilarSemigroup(g, true);\n\n  return g;\nend);\n\n\n###############################################################################\n##\n#M  UnderlyingFreeMonoid( <G> )\n##\nInstallMethod(UnderlyingFreeMonoid, \"for [IsSelfSimFamily]\",\n              [IsSelfSimFamily],\nfunction(fam)\n  local monoid;\n\n  if fam!.numstates <> 0 then\n    monoid := MonoidByGenerators(GeneratorsOfGroup(fam!.freegroup));\n    SetSize(monoid, infinity);\n  else\n    monoid := MonoidByGenerators(fam!.freegens[1]);\n    SetSize(monoid, 1);\n  fi;\n\n  return monoid;\nend);\n\n###############################################################################\n##\n#M  UnderlyingFreeGroup( <G> )\n##\nInstallMethod(UnderlyingFreeGroup, \"for [IsSelfSimFamily]\",\n              [IsSelfSimFamily],\nfunction(fam)\n  return fam!.freegroup;\nend);\n\n\n###############################################################################\n##\n#M  IsObviouslyFiniteState( <G> )\n##\n##  returns `true' if there are no words longer than 1 in the wreath recursion\nInstallMethod(IsObviouslyFiniteState, \"for [IsSelfSimFamily]\",\n              [IsSelfSimFamily],\nfunction(fam)\n  local list, g, i;\n  list := fam!.recurlist;\n  for g in list do\n    for i in [1..fam!.deg] do\n      if Length(g[i]) > 1 then return false; fi;\n    od;\n  od;\n  IsFiniteState(GroupOfSelfSimFamily(fam));\n  return true;\nend);\n\n\n#############################################################################\n##\n#M  GeneratorsOfOrderTwo( <fam> )\n##\nInstallMethod(GeneratorsOfOrderTwo, \"for [IsSelfSimFamily]\", [IsSelfSimFamily],\nfunction(fam)\n  if not fam!.isgroup then\n    Error(\"not all generators of the family are invertible\");\n  fi;\n  return Filtered(GeneratorsOfGroup(GroupOfSelfSimFamily(fam)), g -> IsOne(g^2));\nend);\n\n\n###############################################################################\n##\n##  AG_AbelImagesGenerators(<fam>)\n##\nInstallMethod(AG_AbelImagesGenerators, \"for [IsAutomFamily]\",\n              [IsSelfSimFamily],\nfunction(fam)\n  if not fam!.isgroup then\n    Error(\"the underlying group is not generated by automorphisms\");\n  fi;\n  return AG_AbelImageAutomatonInList(fam!.recurlist);\nend);\n\n#E\n", "meta": {"hexsha": "ded321729253f1c1d1448bb9140c716a08613aa7", "size": 14367, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "gap/selfsimfam.gi", "max_stars_repo_name": "gap-packages/automgrp", "max_stars_repo_head_hexsha": "1beb0cbc96c9748cf912433c27c661e1f87ef5dc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-02T15:00:11.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-02T15:00:11.000Z", "max_issues_repo_path": "gap/selfsimfam.gi", "max_issues_repo_name": "gap-packages/automgrp", "max_issues_repo_head_hexsha": "1beb0cbc96c9748cf912433c27c661e1f87ef5dc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2019-09-21T22:10:40.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-26T23:51:41.000Z", "max_forks_repo_path": "gap/selfsimfam.gi", "max_forks_repo_name": "gap-packages/automgrp", "max_forks_repo_head_hexsha": "1beb0cbc96c9748cf912433c27c661e1f87ef5dc", "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.963362069, "max_line_length": 102, "alphanum_fraction": 0.544859748, "num_tokens": 3645, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4587049392124737}}
{"text": "# A Taggable operator (see tags.gi) is translated into an analogous SIMT operator that carries dim tag info\n \nClass(SIMTTensor, Tensor, rec(\n\n    abbrevs := [ (simt_dim, spl) -> When(IsASIMTDim(simt_dim) and ObjId(spl) = Tensor, [Flat([simt_dim, spl._children])], [[simt_dim, spl]] )  ]\n                :: Tensor.abbrevs,\n\n    new := meth(self, arg)\n        local simt_dim, L;\n        Constraint(IsList(arg) and Length(arg) >= 2);\n        simt_dim := arg[1];\n        L := arg{[2..Length(arg)]};\n#        L:=Filtered(L,x->x<>I(1));\n        if (Length(L)=0) then return I(1); fi;\n        if Length(L)=1 then return L[1]; fi;\n\n        return SPL(WithBases( self, \n                        rec( simt_dim := simt_dim,\n                             _children := L,\n                             dimensions := [ Product(L, t -> t.dims()[1]),\n                                             Product(L, t -> t.dims()[2]) ] )));\n    end,\n\n    from_rChildren := (self, rch) >> ApplyFunc(ObjId(self), [self.simt_dim]::rch).appendAobj(self)\n    \n    ));\n\nClass(SIMTISum, ISum, rec(\n\n    abbrevs := [ (simt_dim, spl) -> When(IsASIMTDim(simt_dim) and ObjId(spl) = ISum, [simt_dim, spl.var, spl.domain, spl._children[1]], [simt_dim, spl] )  ],\n\n    new := meth(self, simt_dim, var, domain, expr)\n        local res;\n        Constraint(IsSPL(expr));\n        # if domain is an integer (not symbolic) it must be positive\n        Constraint(not IsInt(domain) or domain >= 0);\n        var.isLoopIndex := true;\n        res := SPL(WithBases(self, rec(_children := [expr], simt_dim := simt_dim, var := var, domain := domain)));\n        res.dimensions := res.dims();\n        return res;\n    end,\n\n    print := (self, i, is) >> Print(\n        self.name, \"(\", self.simt_dim, \", \", self.var, \", \", self.domain, \",\\n\",\n        Blanks(i+is), self._children[1].print(i+is, is), \"\\n\",\n        Blanks(i), \")\", self.printA(),\n        When(IsBound(self._setDims), Print(\".overrideDims(\", self._setDims, \")\"), Print(\"\"))\n    )\n\n    ));\n\nClass(SIMTSUM, SUM, rec(\n\n    new := meth(self, arg)\n        local dims, simt_dim, L;\n        Constraint(IsList(arg) and Length(arg) >= 2);\n        simt_dim := arg[1];\n        L := arg{[2..Length(arg)]};\n        Constraint(Length(L) >= 1); Constraint(ForAll(L, IsSPL));\n#        if Length(L) = 1 then return L[1]; fi;\n        dims := L[1].dims();\n        if not (IsSymbolic(dims[1]) or IsSymbolic(dims[2])) and\n           not ForAll(Drop(L, 1), x -> let(d:=x.dims(),\n                   IsSymbolic(d[1]) or IsSymbolic(d[2]) or d = dims))\n            then Error(\"Dimensions of summands do not match\"); fi;\n        return SPL(WithBases(self, rec( simt_dim := simt_dim, _children := L, dimensions := dims)));\n    end,\n\n    from_rChildren := (self, rch) >> ApplyFunc(ObjId(self), [self.simt_dim]::rch).appendAobj(self),\n\n    print := meth(self, i, is) \n        local s, first, newline;\n\n        if self._short_print or ForAll(self._children, x->not IsRec(x) or IsSPLSym(x) or IsSPLMat(x)) then\n            newline := Ignore;\n        else \n            newline := self._newline;\n        fi;\n        first := true;\n        Print(self.name, \"( \", self.simt_dim, \",\");\n        for s in self._children do\n                if(first) then first:=false;\n                else Print(\", \"); fi;\n                newline(i + is);\n                When(IsSPL(s) or (IsRec(s) and IsBound(s.print) and NumGenArgs(s.print)=2),\n                    s.print(i + is, is), \n                    Print(s));\n        od;\n        newline(i);\n        Print(\")\");\n        self.printA();\n\n        if IsBound(self._setDims) then\n            Print(\".overrideDims(\", self._setDims, \")\");\n        fi;\n    end,\n    \n    ));\n\nClass(SIMTDirectSum, DirectSum, rec(\n\n    abbrevs := [ arg ->\n        [ Filtered(\n            Flat(List(Flat(arg),\n                s -> When(IsSPL(s) and ObjId(s)=DirectSum, s.children(), s))), x-> IsASIMTDim(x) or x.dimensions<>[0,0]) ]\n    ],\n\n    new := meth(self, arg)\n        local simt_dim, L;\n        Constraint(IsList(arg) and Length(arg) >= 2);\n        simt_dim := arg[1];\n        L := arg{[2..Length(arg)]};\n        if ForAll(L, IsIdentitySPL)\n            then return I(Sum(L, Rows));\n        else\n            return SPL(WithBases( self,\n            rec( simt_dim := simt_dim, _children := L,\n            dimensions := [ Sum(L, t -> t.dimensions[1]),\n                            Sum(L, t -> t.dimensions[2]) ] )));\n        fi;\n    end,\n\n    from_rChildren := (self, rch) >> ApplyFunc(ObjId(self), [self.simt_dim]::rch).appendAobj(self)\n    \n    ));\n\nClass(SIMTVStack, VStack, rec(\n\n    abbrevs := [ (simt_dim, spl) -> When(IsASIMTDim(simt_dim) and ObjId(spl) = VStack, [Flat([simt_dim, spl._children])], [[simt_dim, spl]] )  ]\n                :: VStack.abbrevs,\n\n    new := (self, arg) >> let(simt_dim := Checked(IsList(arg), arg[1]), spls := arg{[2..Length(arg)]}, \n                                Checked(\n                                    Length(spls) >= 1, \n                                    ForAll(spls, s -> IsSymbolic(Cols(s)) or IsSymbolic(Cols(spls[1])) or Cols(s) <= Cols(spls[1])),\n                                    SPL(WithBases(self, rec(simt_dim := simt_dim, _children := spls)).setDims())\n                                )\n                            ),\n\n    from_rChildren := (self, rch) >> ApplyFunc(ObjId(self), [self.simt_dim]::rch).appendAobj(self)\n\n    ));\n\nClass(SIMTHStack, HStack, rec(\n\n    abbrevs := [ (simt_dim, spl) -> When(IsASIMTDim(simt_dim) and ObjId(spl) = HStack, [Flat([simt_dim, spl._children])], [[simt_dim, spl]] )  ]\n                :: HStack.abbrevs,\n\n    new := (self, arg) >> let(simt_dim := Checked(IsList(arg), arg[1]), spls := arg{[2..Length(arg)]}, \n                                Checked(\n                                    IsList(spls), \n                                    Length(spls) >= 1, \n                                    ForAll(spls, s->Rows(s)<=Rows(spls[1])),\n                                    SPL(WithBases(self, rec(simt_dim := simt_dim, _children := spls)).setDims())\n                                )\n                            ),\n\n    from_rChildren := (self, rch) >> ApplyFunc(ObjId(self), [self.simt_dim]::rch).appendAobj(self)\n\n));\n\nClass(SIMTHStack1, SIMTHStack);\n\nClass(SIMTBaseIterative, BaseIterative, rec(\n\n    abbrevs := [ (simt_dim, spl) -> When(IsASIMTDim(simt_dim) and IsIterative(spl), [simt_dim, spl.var, spl.domain, spl._children[1]], [simt_dim, spl] )  ],\n\n    new := meth(self, simt_dim, var, domain, expr)\n        local res;\n        Constraint(IsSPL(expr));\n        # if domain is an integer (not symbolic) it must be positive\n        Constraint(not IsInt(domain) or domain >= 0);\n        var.isLoopIndex := true;\n        res := SPL(WithBases(self, rec(_children := [expr], simt_dim := simt_dim, var := var, domain := domain)));\n        res.dimensions := res.dims();\n        return res;\n    end,\n\n    print := (self, i, is) >> Print(\n        self.name, \"(\", self.simt_dim, \", \",  self.var, \", \", self.domain, \",\\n\",\n        Blanks(i+is), self._children[1].print(i+is, is), \"\\n\",\n        Blanks(i), \")\", self.printA(),\n        When(IsBound(self._setDims), Print(\".overrideDims(\", self._setDims, \")\"), Print(\"\"))\n    )\n));\n\nClass(SIMTIterVStack, SIMTBaseIterative, rec(\n    dims := self >> [ self.child(1).dimensions[1] * self.domain,\n                      self.child(1).dimensions[2] ],\n));\n\nClass(SIMTIterHStack, SIMTBaseIterative, rec(\n    dims := self >> [ self.child(1).dimensions[1],\n                      self.child(1).dimensions[2] * self.domain ],\n));\n\nClass(SIMTIterHStack1, SIMTIterHStack);\n\nClass(SIMTIDirSum, SIMTBaseIterative, rec(\n    dims := self >> let(d:=self._children[1].dimensions, [d[1]* self.domain, d[2]*self.domain])\n));\n\nClass(SIMTGrp, Grp);\n", "meta": {"hexsha": "9902fbdd4f2c4500d52a4d9c483c5980bdc05523", "size": 7745, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "spl.gi", "max_stars_repo_name": "broderickpt/spiral-package-simt", "max_stars_repo_head_hexsha": "a7b4947d0e870a0b877e8952a5a3f8c95d28cdde", "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": "spl.gi", "max_issues_repo_name": "broderickpt/spiral-package-simt", "max_issues_repo_head_hexsha": "a7b4947d0e870a0b877e8952a5a3f8c95d28cdde", "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": "spl.gi", "max_forks_repo_name": "broderickpt/spiral-package-simt", "max_forks_repo_head_hexsha": "a7b4947d0e870a0b877e8952a5a3f8c95d28cdde", "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": 37.9656862745, "max_line_length": 157, "alphanum_fraction": 0.5211103938, "num_tokens": 2174, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.640635861701035, "lm_q1q2_score": 0.4583262757944968}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nClass(ISumn, ISum, rec(\n    abbrevs := [ (dom, expr) -> Checked(IsPosIntSym(dom), IsSPL(expr), [dom, expr]) ],\n\n    new := meth(self, domain, expr)\n        local res;\n\t# ??? if domain = 1 then return SubstBottomUp(expr, var, e->V(0));\n\tres := SPL(WithBases(self, rec(_children := [expr], domain := domain)));\n\tres.dimensions := res.dims();\n\treturn res;\n    end,\n    #-----------------------------------------------------------------------\n    unrolledChildren := self >> Error(\"not implemented\"),\n    #    List(listRange(self.domain), u ->\n    #\t       SubstBottomUp(Copy(self._children[1]), self.var, e->V(u))),\n    #-----------------------------------------------------------------------\n    rChildren := self >> [self.domain, self._children[1]],\n    rSetChild := meth(self, n, what) \n        if n=1 then self.domain := what; \n\telif n=2 then self._children[1] := what; \n\telse Error(\"<n> must be in [1,2]\"); fi;\n    end,\n    #-----------------------------------------------------------------------\n    print := (self,i,is) >> Print(self.name, \"(\", self.domain, \",\\n\", \n\tBlanks(i+is), self._children[1].print(i+is, is), \"\\n\", Blanks(i), \")\"),\n    #-----------------------------------------------------------------------\n    sums := self >> let(base := self.__bases__[1],\n\tbase(self.var, self.domain, self._children[1].sums())),\n));\n\nTensor.sumsn := meth(self)\n    local ch, col_prods, row_prods, col_prods_rev, row_prods_rev, i, c, \n          cp1, cp2, rp1, rp2, cols, rows, prod, term, scat, gath;\n    if self.isPermutation() then return\n\tPrm(ApplyFunc(self.fTensor, List(self.children(), c->c.sums().func)));\n    elif ForAll(self.children(), x->ObjId(x)=Diag) then return\n\tDiag(ApplyFunc(diagTensor, List(self.children(), c->c.element)));\n    fi;\n\n    ch := self.children();\n    col_prods := ScanL(ch, (x,y)->x*Cols(y), 1);\n    col_prods_rev := Drop(ScanR(ch, (x,y)->x*Cols(y), 1), 1);\n    #row_prods := ScanL(ch, (x,y)->x*Rows(y), 1);\n    #row_prods_rev := DropLast(ScanR(ch, (x,y)->x*Rows(y), 1), 1);\n\n    prod := [];\n    for i in [1..Length(ch)] do\n        c := ch[i];\n        if not IsIdentitySPL(c) then\n\t    [cp1, cp2] := [col_prods[i], col_prods_rev[i]];\n\t    #[rp1, rp2] := [row_prods[i], row_prods_rev[i]];\n\t    [rows, cols] := Dimensions(c);\n\t    [scat, gath] := [[cp2], [cp2]];\n\t    if cp2 <> 1 then \n\t\tAdd(scat, 1);\n\t\tAdd(gath, 1); fi;\n\t    if cp1 <> 1 then \n\t\tAdd(scat, cp2*rows); \n\t\tAdd(gath, cp2*cols); fi;\n\n\t    term := Scat(HH(cp1*rows*cp2, rows, 0, scat)) * \n\t            c.sums() * \n\t\t    Gath(HH(cp1*cols*cp2, cols, 0, gath));\n\n\t    if cp2 <> 1 then term := ISumn(cp2, term); fi;\n\t    if cp1 <> 1 then term := ISumn(cp1, term); fi;\n\t    Add(prod, term);\n\tfi;\n    od;\n    return Compose(prod);\nend;\n\nIterDirectSum.sumsn := self >> let(A := self.child(1),\n    ISumn(self.domain,  \n\t  Scat(HH(Rows(self), Rows(A), 0, [1, Rows(A)])) *\n#\t  spiral.sigma.SumsSPL( # NOTE: subst to ind -- potentially unsafe! (other loops!)\n\t      SubstVars(Copy(A), rec((self.var.id) := ind(self.var.range, 1))).sums() *\n\t  Gath(HH(Cols(self), Cols(A), 0, [1, Cols(A)]))));\n\nRowTensor.sumsn := self >> let(A := self.child(1),\n    ISumn(self.isize,\n\t  Scat(HH(Rows(self), Rows(A), 0, [1, Rows(A)])) *\n#\t  spiral.sigma.SumsSPL(A) *\n\t  A.sums() * \n\t  Gath(HH(Cols(self), Cols(A), 0, [1, Cols(A) - self.overlap]))));\n\n", "meta": {"hexsha": "9dbc00f3a22f13afb98ddb11bb98c38e99a7a799", "size": 3395, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/gtsums.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/gtsums.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/gtsums.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.3076923077, "max_line_length": 86, "alphanum_fraction": 0.5237113402, "num_tokens": 1078, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4580054056955349}}
{"text": "# Dirty implementation\n# Only P3 format, an image is a list of 3 matrices (r, g, b)\n# Max color is always 255\nWriteImage := function(name, img)\n  local f, r, g, b, i, j, maxcolor, nrow, ncol, dim;\n  f := OutputTextFile(name, false);\n  r := img[1];\n  g := img[2];\n  b := img[3];\n  dim := DimensionsMat(r);\n  nrow := dim[1];\n  ncol := dim[2];\n  maxcolor := 255;\n  WriteLine(f, \"P3\");\n  WriteLine(f, Concatenation(String(ncol), \" \", String(nrow), \" \", String(maxcolor)));\n  for i in [1 .. nrow] do\n    for j in [1 .. ncol] do\n      WriteLine(f, Concatenation(String(r[i][j]), \" \", String(g[i][j]), \" \", String(b[i][j])));\n    od;\n  od;\n  CloseStream(f);\nend;\n\nPutPixel := function(img, i, j, color)\n  img[1][i][j] := color[1];\n  img[2][i][j] := color[2];\n  img[3][i][j] := color[3];\nend;\n\nGetPixel := function(img, i, j)\n  return [img[1][i][j], img[2][i][j], img[3][i][j]];\nend;\n\nNewImage := function(nrow, ncol, color)\n  local r, g, b;\n  r := color[1] + NullMat(nrow, ncol);\n  g := color[2] + NullMat(nrow, ncol);\n  b := color[3] + NullMat(nrow, ncol);\n  return [r, g, b];\nend;\n\n# Reproducing the example from Wikipedia\nblack := [ 0, 0, 0 ];\ng := NewImage(2, 3, black);\nPutPixel(g, 1, 1, [255, 0, 0]);\nPutPixel(g, 1, 2, [0, 255, 0]);\nPutPixel(g, 1, 3, [0, 0, 255]);\nPutPixel(g, 2, 1, [255, 255, 0]);\nPutPixel(g, 2, 2, [255, 255, 255]);\nPutPixel(g, 2, 3, [0, 0, 0]);\nWriteImage(\"example.ppm\", g);\n", "meta": {"hexsha": "0506cea8c6cb70f84c9cd29f0be2257d2a1c65e7", "size": 1394, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Bitmap-Write-a-PPM-file/GAP/bitmap-write-a-ppm-file.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/Bitmap-Write-a-PPM-file/GAP/bitmap-write-a-ppm-file.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/Bitmap-Write-a-PPM-file/GAP/bitmap-write-a-ppm-file.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 26.8076923077, "max_line_length": 95, "alphanum_fraction": 0.5645624103, "num_tokens": 554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872243177517, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4579784253728254}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nDropMat := function(fmat)\n    local mat;\n    mat := Copy(fmat);\n    if IsBound(mat.mat) then Unbind(mat.mat); fi;\n    return mat;\nend;\n\n#   All size x size digit swap permutations that could be implemented in register for v\nAllDigitSwaps := function(size, v)\n    local ll, l, Nl, N, nl, n, r, mats, L1, L2, spl;\n\n    mats := [];\n    ll := DropLast(DivisorsInt(v), 1);\n    for l in ll do\n        Nl := Filtered(DivisorsInt(size/l), i -> i >= 4);\n        for N in Nl do\n            r:= size/(N*l);\n            nl := DivisorsIntDrop(N);\n            for n in nl do\n                if l=1 then L1 := []; else L1 := [I(l)]; fi;\n                if r=1 then L2 := []; else L2 := [I(r)]; fi;\n                spl := Tensor(Concat(L1, [L(N,n)], L2));\n                Add(mats, rec(spl:=spl, mat:=MatSPL(spl), l:=l, N:=N, n:=n, r:=r));\n            od;\n        od;\n    od;\n\n    return mats;\nend;\n\n#   NOTE: Better algorithm: outer loop over AllDigitSwaps\n\n\nBuildCandidates := function(ops, v)\n    local mats, op, p, v;\n    mats := [];\n    for op in ops do\n        for p in op.permparams() do\n            Add(mats,\n                rec(instr := op,\n                    p := p,\n#   NOTE - how to get op.v correctly? maybe introduce op.getVLen() method\n                    mat := let(ov := When(IsInt(op.v), op.v, op.v()), When(op.isUnop(),\n                        TransposedMat(List([0..ov-1], i->op.semantic(BasisVec(ov, i), p))),\n                        TransposedMat(Concat(List([0..ov-1], i->op.semantic(BasisVec(ov, i), Replicate(v, 0), p)),\n                            List([0..ov-1], i->op.semantic(Replicate(v, 0), BasisVec(ov, i), p))))\n                        ))\n                ));\n        od;\n    od;\n    return mats;\nend;\n\n\n#   Build rules from binary operations\n#\nBuildBinRules := function(arch)\n    local archrules, binops, p, op1, op2, i1, i2, v, binmats, binperms, dsperms, opmat, fmat;\n\n    v := arch.v;\n    archrules := [];\n    binops := Filtered(arch.instr, i->i.isBinop());\n\n    #   find al candidate instructions to build permutations\n    binmats := BuildCandidates(binops, v);\n\n    # find all pairs of binops to build valid swap perms\n    dsperms := AllDigitSwaps(2*v, v);\n    for op1 in binmats do\n        for op2 in binmats do\n            opmat := Concat(op1.mat, op2.mat);\n            if IsPermMat(AMatMat(opmat)) then\n                fmat := Filtered(dsperms, i->i.mat=opmat);\n                if Length(fmat)=1 then\n                    i1 := op1.instr; i2 := op2.instr;\n                    Add(archrules, rec(perm := DropMat(fmat[1]), instr:=[DropMat(op1), DropMat(op2)], v:=v, # NOTE: use full list!\n                                vperm := VPerm(fmat[1].spl,\n                                Subst((y,x) -> chain(\n                                assign(vref(y, 0,$v), $i1(vref(x,0,$v), vref(x,$v,$v), $(op1.p))),\n                                assign(vref(y,$v,$v), $i2(vref(x,0,$v), vref(x,$v,$v), $(op2.p))))),\n                            v, op1.instr.vcost + op2.instr.vcost)\n                            ));\n                    dsperms := Filtered(dsperms, i->opmat<>i.mat);\n                fi;\n            fi;\n        od;\n    od;\n    return archrules;\nend;\n\n#   Build rules from binary operations - first shuffle Inputs by LxI\n#\nBuildBinRulesLxI := function(arch, binrules, left, right)\n    local archrules, binops, p, op1, op2, i1, i2, v, binmats, binperms, dsperms, opmat, fmat, lm, lmleft, lmright,\n        lmc, lmvleft, lmvright, opmatconcat, i2v, splleft, splright, lval, rval;\n\n    v := arch.v;\n    archrules := [];\n    binops := Filtered(arch.instr, i->i.isBinop());\n\n    lm := MatSPL(Tensor(L(4,2), I(v/2)));\n    lmleft := When(left, lm, MatSPL(I(2*v)));\n    splleft := When(left, Tensor(L(4,2), I(v/2)), I(2*v));\n    lmright := When(right, lm, MatSPL(I(2*v)));\n    splright := When(right, Tensor(L(4,2), I(v/2)), I(2*v));\n    i2v := MatSPL(I(2*v));\n\n    lmc := Filtered(binrules, i->(i.perm.l=1 and i.perm.r=v/2 and i.perm.N=4 and i.perm.n=2));\n\n    if Length(lmc) = 0 then return []; fi;\n\n    lmvleft := When(left, lmc[1].vperm, VTensor(I(2), v));\n    lmvright := When(right, lmc[1].vperm, VTensor(I(2), v));\n\n    lval := When(left, lmc[1].vperm._vcost + 0.2, 0);\n    rval := When(right, lmc[1].vperm._vcost + 0.2, 0);\n\n    #   find al candidate instructions to build permutations\n    binmats := BuildCandidates(binops, v);\n\n    # find all pairs of binops to build valid swap perms\n    dsperms := AllDigitSwaps(2*v, v);\n    for op1 in binmats do\n        for op2 in binmats do\n            opmatconcat := Concat(op1.mat, op2.mat);\n            if opmatconcat  <> i2v then\n                opmat := lmleft * opmatconcat * lmright;\n                if IsPermMat(AMatMat(opmat)) then\n                    fmat := Filtered(dsperms, i->i.mat=opmat);\n                    if Length(fmat)=1 then\n                        i1 := op1.instr; i2 := op2.instr;\n                        Add(archrules, rec(perm := DropMat(fmat[1]), instr:=[DropMat(op1), DropMat(op2)], v:=v, # NOTE: use full list!\n                                    vperm := lmvleft * VPerm(splleft * fmat[1].spl * splright,\n                                    Subst((y,x) -> chain(\n                                    assign(vref(y, 0,$v), $i1(vref(x,0,$v), vref(x,$v,$v), $(op1.p))),\n                                    assign(vref(y,$v,$v), $i2(vref(x,0,$v), vref(x,$v,$v), $(op2.p))))),\n                                v, 2 + lval + rval) * lmvright\n                                ));\n                        dsperms := Filtered(dsperms, i->opmat<>i.mat);\n                    fi;\n                fi;\n            fi;\n        od;\n    od;\n    return archrules;\nend;\n\n#   Build rules from unary operations\n#\nBuildUnRules := function(arch)\n    local archrules, unops, unmats, unperms, unperms2, unmats2, p, op, op1, op2, v, dsperms, opmat, fmat, i1, i2;\n\n    v := arch.v;\n    archrules := [];\n\n    #   unops -> perms\n    unops := Filtered(arch.instr, i->i.isUnop());\n    unmats := BuildCandidates(unops, v);\n\n    # find all unops to build valid swap perms\n    dsperms := AllDigitSwaps(v, v);\n    unmats2 := [];\n    for op in unmats do\n        opmat := op.mat;\n        if IsPermMat(AMatMat(opmat)) then\n            fmat := Filtered(dsperms, i->i.mat=opmat);\n\n            if Length(fmat)>=1 then\n        i1 := op.instr;\n        Add(archrules, rec(perm := DropMat(fmat[1]), instr:=DropMat(op), v:=v, # NOTE: use full list!\n                    vperm := VPerm(fmat[1].spl,\n                                   Subst((y,x) -> assign(vref(y, 0, $v), $i1(vref(x,0,$v), $(op.p)))),\n                   v, 0.9*op.instr.vcost) # NOTE: avoid unops as they may not exist\n        ));\n                dsperms := Filtered(dsperms, i->opmat<>i.mat);\n            else\n                Add(unmats2, op);\n            fi;\n        fi;\n    od;\n\n    #   product of unops -> perms\n    for op1 in unmats2 do\n        for op2 in unmats2 do\n            opmat := op2.mat * op1.mat;\n            if IsPermMat(AMatMat(opmat)) then\n                fmat := Filtered(dsperms, i->opmat=i.mat);\n\n                if Length(fmat)=1 then\n                    i1 := op1.instr;\n                    i2 := op2.instr;\n                    Add(archrules, rec(\n                        perm  := DropMat(fmat[1]),\n                        instr := [DropMat(op1), DropMat(op2)],\n                        v     := v, # NOTE: use full list!\n                        vperm := VPerm( fmat[1].spl, Subst((y,x) -> let(t := TempVec(TArray(x.t.t, $v)),\n                                        decl(t, chain(assign(vref(t,0,$v), $i1(vref(x,0,$v), $(op1.p))),\n                                                      assign(vref(y,0,$v), $i2(vref(t,0,$v), $(op2.p))))))),\n                                        v, 0.9*(op1.instr.vcost+op2.instr.vcost))\n                    ));\n                    dsperms := Filtered(dsperms, i->opmat<>i.mat);\n                fi;\n            fi;\n        od;\n    od;\n\n    return archrules;\nend;\n\n\nFind_x_I_vby2 := function(arch, i, j)\n    local gmat, v, binops, binmats, fmat, op;\n\n    v := arch.v;\n    binops := Filtered(arch.instr, i->i.isBinop());\n\n    #   find al candidate instructions to build permutations\n    binmats := BuildCandidates(binops, v);\n    gmat := MatSPL(Gath(fTensor(fDirsum(fBase(2,i), fBase(2,j)), fId(v/2))));\n\n    fmat := Filtered(binmats, i->i.mat=gmat);\n    return When(Length(fmat) > 0, DropMat(fmat[1]), []);\nend;\n\nBuild_x_I_vby2 := arch -> List([0,1], i-> List([0,1], j-> Find_x_I_vby2(arch,i,j)));\n", "meta": {"hexsha": "09e3ff58376b42093c1b74118b82ffb7f7966f1f", "size": 8545, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/vector/bases/build_bases.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/vector/bases/build_bases.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/vector/bases/build_bases.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.9913419913, "max_line_length": 134, "alphanum_fraction": 0.4917495611, "num_tokens": 2558, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.45793671978692585}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nDeclare(rDFTSkew, realDFTPerm, fRealAccPease, _rDFT_u_func);\n\n# A function to calculate \"next\" values of u for iteration j (used in rDFTSkew C-T rule)\n_rDFT_u_func := function(u, j, k)\n    if (u=0) then\n        return V(fdiv(j, (2*k)));\n    else \n        if (IsEvenInt(j)) then\n            return fdiv((u + idiv(j,2)), k);\n        else\n            return fdiv((1 - u + idiv(j,2)), k);\n        fi;\n    fi;        \nend;\n\n\n# Recusively determine the value for u given k, q, and l, where\n#    k = radix/2, \n#    q = log_k(m),\n#    l = access function (or iterator).\n_rDFT_u_rec := function(depth, u, k, q, l)   \n   if (depth = q) then\n       return V(u);\n   else\n       return _rDFT_u_func(_rDFT_u_rec(depth+1, u, k, q, l), idiv(imod(l, k^(depth+1)), V(k^(depth))), k);\n   fi;\nend;\n\n# An Exp wrapper for _rDFT_u_rec.  This is used so Spiral does not try to evaluate the expression\n# until Process_fPrecompute is called.\nClass(_rDFT_u_rec_exp, Exp, rec(\n    ev := self >> let(\n        depth := self.args[1].ev(),\n        u := self.args[2].ev(),\n        k := self.args[3].ev(),\n        q := self.args[4].ev(),\n        l := self.args[5].ev(),\n        _rDFT_u_rec(depth, u, k, q, l).ev()\n    ),\n    \n    computeType := self >> TReal\n));\n\n# A function wrapper for _rDFT_u_rec_exp.  The rewriting rule uses this function.  Then, it is evaluated to the\n# Exp above.  Then, that will evetually be evaluated into the final value.\nClass(_rDFT_u_rec_wrapper, FuncClass, rec(\n    def := (d, u, k, q, l) -> rec(N := 1, n := 1),\n    lambda := self >> let(i := Ind(1), Lambda(i, _rDFT_u_rec_exp(self.params[1], self.params[2], self.params[3], self.params[4], self.params[5]))),\n    t := TReal,\n    eval := self >> When(self.domain() = 1 and self.rank() = 0, self.at(0).eval(), self),\n    ev := self >> Checked(self.domain() = 1, self.at(0).ev()),\n));\n\n\n# An Exp wrapper for _rDFT_u_func.  This is used in the C-T rule, so the \"next\" values of u can be\n# calcualted (but not evaluated until they can be.)\nClass(_rDFT_u_r_exp, Exp, rec(\n   ev := self >> let(\n       u := self.args[1].ev(),\n       j := self.args[2].ev(),\n       k := self.args[3].ev(),\n       _rDFT_u_func(u, j, k).ev()\n   ),\n   \n   computeType := self >> TReal\n));\n\n\n\n# rDFTSkew(n,u).  This is the transform our streaming and Pease rules apply to.\nClass(rDFTSkew, TaggedNonTerminal, rec(\n    abbrevs := [(n,u) -> Checked(IsPosInt(n), [n, u])],\n    dims := self >> let(n := self.params[1], [n,n]),\n    isReal := self >> true,\n\n    terminate := self >> let(\n        n := self.params[1],\n        k := 2,\n        m := n/(2*k),\n        a := Cond(IsValue(self.params[2]), self.params[2], V(self.params[2])),\n        Cond(n=4,\n            \n            Cond(a=0,\n                Tensor(F(2), I(2)),\n                Diag(1,1,1,-1) * Tensor(F(2), I(2)) * \n                   DirectSum(I(2), Mat([[cospi(a.ev()), -1*sinpi(a.ev())], [sinpi(a.ev()), cospi(a.ev())]])) *\n                   L(4,2)\n            ),\n            \n            RC(Cond(a=0, Kp(k*m, m), K(k*m, m))) *\n            DirectSum(\n                rDFTSkew(2*m, _rDFT_u_func(a, 0, k)).terminate(), \n                rDFTSkew(2*m, _rDFT_u_func(a, 1, k)).terminate()\n            ) *\n            Tensor(rDFTSkew(2*k, a), I(m))\n        )\n    ),\n)); \n\n\n\nNewRulesFor(PkRDFT1, rec(\n\n    # PkRDFT1(n,0) --> DirectSum(F(2), I(n-2)) * rDFTSkew(n,0)\n    # We simplify by writing the direct sum already in TTensorInd form.\n\n    PkRDFT1_rDFTSkew := rec(\n        forTransposition := false,\n        applicable := (self, nt) >> nt.params[2] = 1,  #! temporary hack\n        children := (self, t) >> let(\n            n := t.params[1],\n            i := Ind(n/2),\n            tags := t.getTags(),\n            \n            [[ TCompose([TTensorInd(COND(eq(i,0), F(2), I(2)), i, APar, APar), rDFTSkew(n,V(0))]).withTags(tags) ]]\n        ),\n\n        apply := (nt, c, cnt) -> c[1]        \n    ),\n\n    PkRDFT1_DFT := rec(\n        forTransposition := false,\n        applicable := (self, nt) >> nt.params[2] = 1, #! temporary\n        children := (self, t) >> \n            [[TCompose([TConjEven(t.params[1]), TRC(DFT(t.params[1]/2))]).withTags(t.getTags())]],\n\n        apply := (nt, c, cnt) -> c[1]\n    )\n));\n\n\nNewRulesFor(rDFTSkew, rec(\n    # opts.breakdownRules := rec(rDFTSkew := [CopyFields(rDFT_Skew_CT, rec(radix:=4))])\n    #    \n\n\n    # rDFTSkew(2*k*m,0) --> Perm * (I_k x rDFTSkew(2*m, f(u,l))) * (rDFTSkew(2*k, u) x I_m)\n    rDFT_Skew_CT := rec(\n        forTransposition := false,\n        applicable := (self, nt) >> nt.params[1] > 4 and not nt.isTag(1, AStream),\n        children := (self, t) >> let(\n            n := t.params[1],\n            m := 2,\n            k := n/(2*m),\n\n            u := t.params[2],\n            j := Ind(k),\n\n            [[ rDFTSkew(2*m, _rDFT_u_r_exp(u, j, k)), rDFTSkew(2*k, u), InfoNt(j) ]]\n         ),\n\n        apply := (t,c,nt) -> let(\n            n := t.params[1],\n            m := 2,\n            k := n/(2*m),\n            u := t.params[2],\n            j := nt[3].params[1],\n            D := Dat1d(TReal, 1),\n\n            Data(D, fPrecompute(FList(TReal, [cospi(u)])),\n                COND(eq(nth(D,0),1), Tensor(Kp(k*m,m), I(2)), Tensor(K(k*m,m), I(2))) *\n                IDirSum(j, k, c[1]) * \n                Tensor(c[2], I(m))\n            )\n            \n        )\n        \n    ),\n\n\n    # rDFTSkew(4,u) base rule.\n    rDFT_Skew_Base4 := rec(\n        forTransposition := false,\n        applicable := (self, nt) >> nt.params[1] = 4,\n        apply := (t, c, nt) -> let(\n            u := t.params[2],\n            DC := Dat1d(TReal, 1),\n            DS := Dat1d(TReal, 1),\n\n            Data(DC, fPrecompute(FList(TReal, [cospi(u)])),\n                Data(DS, fPrecompute(FList(TReal, [sinpi(u)])),\n                    COND(eq(nth(DC,0),1), I(4), Diag(1,1,1,-1)) *\n                    Tensor(F(2), I(2)) *\n                    DirectSum(I(2), Mat([[nth(DC,0), -1*nth(DS,0)], [nth(DS,0), nth(DC,0)]])) *\n                    COND(eq(nth(DC,0),1), I(4), L(4,2))\n                )\n                \n            )\n        )\n    ),\n\n\n    # Streaming rDFTSkew(n,u) rule.\n    rDFT_Skew_Stream := rec(\n        forTransposition := false,\n        \n        radix := 4,\n\n        applicable := (self, nt) >> let(\n            k := self.radix/2,\n            m := nt.params[1]/(2*k),\n            logM := LogInt(m,k),\n            IsInt(nt.params[1]/(2*k)) and nt.isTag(1, AStream) and nt.getTags()[1].bs >= self.radix and\n            (k ^ logM = m)\n        ),\n\n        freedoms := t -> [[ ]],\n\n        children := (self, nt) >> let(\n            P    := nt.params,\n            k    := self.radix/2,\n            m    := P[1]/(k*2),\n            tags := nt.getTags(),\n            q    := LogInt(m,k),\n            u    := nt.params[2], \n            \n            itvars := List([0..q], i->Ind(m)),\n            \n            [[ TCompose(Concatenation(\n                 [ TPrm(realDFTPerm(2*k*m, k, u)) ],\n                 [ TTensorInd(rDFTSkew(2*k, _rDFT_u_rec_wrapper(0, u, k, q, itvars[1])), itvars[1], APar, APar) ],\n                 List([1..q], i-> TCompose([\n                     Cond(i=1, \n                         TTensorI(TPrm(L(2*k^(i+1), 2*k)), m/(k^i), APar, APar),\n                         TTensorI(TPrm(Compose(Tensor(I(k), L(2*(k^i), k^(i-1))), L(2*k^(i+1), 2*k))), m/(k^i), APar, APar)\n                     ),\n                     TTensorInd(rDFTSkew(2*k, _rDFT_u_rec_wrapper(0, u, k, q-i, bin_shr(itvars[i+1], Log2Int(k^i)))),\n                         itvars[i+1], APar, APar)\n\n                 ])),\n                 [ TPrm(L(2*k^(q+1), m)) ]\n             )).withTags(tags)]]\n        ),\n\n        apply := (nt, c, cnt) -> c[1]\n                      \n    ),\n\n    # Non-uniform radix streaming breakdown rule for rDFTSkew(n,u)\n    # This does not work correctly when u<>0 and k > 2.   I still need to debug this.\n    # NOTE\n    rDFT_Skew_Stream_Mult_Radices := rec(\n        forTransposition := false,\n        \n        applicable := (self, nt) >> let(\n            n  := nt.params[1],\n            rp := paradigms.stream.rDFT_Skew_Stream.radix,\n            kp := rp/2,\n            mp := kp ^ LogInt(n/(2*kp), kp),\n            m  := kp * mp,\n            k  := n/(2*m),\n            u := nt.params[2],   \n\n            IsInt(nt.params[1]/(2*k)) and nt.isTag(1, AStream) and\n                not paradigms.stream.rDFT_Skew_Stream.applicable(nt) and (u=0 or k<=2)\n        ),\n    \n        freedoms := t -> [[ ]],\n        \n        children := (self, nt) >> let(\n            n  := nt.params[1],\n            rp := paradigms.stream.rDFT_Skew_Stream.radix,\n            kp := rp/2,\n            mp := kp ^ LogInt(n/(2*kp), kp),\n            m  := kp * mp,\n            k  := n/(2*m),\n            logM := LogInt(m,k),\n\n            tags := nt.getTags(),\n            u := nt.params[2],\n            i := Ind(k), \n            \n            [[ TCompose([ TPrm(Tensor(COND(eq(u,0), Kp(k*m, m), K(k*m,m)), I(2))),\n                          TTensorInd(rDFTSkew(2*m, _rDFT_u_r_exp(u, i, k)), i, APar, APar),\n                          TPrm(L(2*k*m, 2*k)),\n                          TTensorI(rDFTSkew(2*k, u), m, APar, APar),\n                          TPrm(L(2*k*m, m)) ]).withTags(tags) ]]\n\n        ),\n\n        apply := (nt, c, cnt) -> c[1]\n\n    ),\n\n    # Pease rDFTSkew(n,0) rule\n    rDFT_Skew_Pease := rec(\n        forTransposition := false,\n\n        unroll_its := 1,\n        radix      := 4,\n        \n        # For some k between minRadix/2 and maxRadix/2, P[1]=2*k*m, where m=k^p where p is an integer\n        applicable := (self, nt) >> let(\n            k := self.radix/2,\n            m := nt.params[1]/(2*k),\n            logM := LogInt(m, k),\n\n            nt.params[2] = 0 and   # If we were to support u <> 0, we would need to change the\n                                   # the way we store constants.  The trick we currently use\n                                   # to go from O(n log n) to O(n) would not work without modification\n                                   # (it may in fact not work at all).\n            IsInt(nt.params[1]/(2*k)) and\n            (k ^ logM = m) and\n            IsInt((logM+1)/self.unroll_its) and\n            (logM+1)/self.unroll_its > 1 and\n            nt.isTag(1, AStream)\n        ),\n                  \n        freedoms := t -> [[ ]],\n\n\t    children := (self, nt) >> let(\n            P     := nt.params,\n            k     := self.radix/2,\n            m     := P[1]/(k*2),\n            tags  := nt.getTags(),\n            q     := LogInt(m,k),\n            it_i  := Ind((q+1) / self.unroll_its),\n            it_l  := Ind(m),\n            u     := 0,\n\n            it_ur := i >> self.unroll_its * it_i + i,\n            f_ur  := i >> fComputeOnline(fRealAccPease(k, m, it_ur(i), it_l)),\n            u_ur  := i >> _rDFT_u_rec_wrapper(0, u, k, q, f_ur(i)),\n\n            # This provides stage i of the datapath.\n            stage      := i >> TCompose([TTensorInd(rDFTSkew(2*k, u_ur(i)), it_l, APar, APar), TL(2*k*m, 2*m, 1, 1)]),\n\n            # This gives a full stage (multiple stage(i) when we unroll).\n            full_stage := List([1..self.unroll_its], t -> stage(t-1)),\n\n            [[ TCompose([\n                  realDFTPerm(2*k*m, k, u),\n                  TICompose(it_i, it_i.range, TCompose(full_stage)),\n                  TL(2*k*m, k*m, 1, 1)\n               ]).withTags(tags)]]\n        ),\n\n        apply := (nt, c, cnt) -> c[1]\n    ),\n));\n\n\n# Pease rDFTSkew access function for rDFTSkew(2*k*m, 0) where i is the stage and l is the position in stage.\n#     fRealAccPease(k, m, i, l)\nClass(fRealAccPease, FuncClass, rec(\n   def := (k, m, i, l) -> rec(N:=m, n:=1),\n\n   domain := self >> 1,\n   range  := self >> self.params[2],\n   \n   lambda := self >> let(k := self.params[1],\n                         m := self.params[2],\n                         i := self.params[3],\n\t\t\t             l := self.params[4],\n\t\t\t             j := Ind(1),\n                         logk := LogInt(k,2),\n\n       Lambda(j, bin_and(l, bin_shr(m-1, logk*i)))),\n\n   computeType := self >> TInt,\n   t := TInt,\n   eval := self >> When(self.domain() = 1 and self.rank() = 0, self.at(0).eval(), self),\n   ev := self >> Checked(self.domain() = 1, self.at(0).ev())\n    \n));\n\n\n\n\n# The output permutation in Pease or streaming rDFTSkew algorithms\n# realDFTPerm(n, k), where n = 2*k*m\nClass(realDFTPerm, TaggedNonTerminal, rec(\n\n    abbrevs := [(n, k, u)      -> [n, k, u]],\n\n    dims := self >> [ self.params[1], self.params[1] ],\n    domain := self >> self.params[1],\n    range := self >> self.params[1],\n\n    terminate := self >> let(\n\t    n := self.params[1],\n        k := self.params[2],\n        u := Cond(IsExp(self.params[3]), self.params[3].ev(), self.params[3]),\n        m := n/(2*k),\n        r := LogInt(m,k),\n\n        res := Cond(n < 8, I(n),\n            Cond(u=0,\n\t            Tensor(\n                    Compose(List([0..r-1], l->\n                        DirectSum(Kp(k*m/(k^l), k*m/(k^(l+1))),\n                            Tensor(I(k^l-1), K(k*m/(k^l), k*m/(k^(l+1))))\n                        )\n                    )),\n                    I(2)\n                ),\n\t            Tensor(\n                    Compose(List([0..r-1], l->\n                        Tensor(I(k^l), K(k*m/(k^l), k*m/(k^(l+1))))\n                    )),\n                    I(2)\n                )\n            )\n        ),\n\n        Cond(self.transposed, res.transpose(), res)\n    ),\n\n    isReal := self >> true,\n\n    print := meth(self, indent, indentStep)\n        local lparams, mparams;\n        if not IsBound(self.params) then Print(self.name); return; fi;\n        Print(self.name, \"(\");\n        if IsList(self.params) then\n            lparams := Filtered(self.params, i->not (IsList(i) and i=[]));\n            mparams := Filtered(lparams, i->not (IsBool(i) and not i));\n            DoForAllButLast(mparams, x -> Print(x, \", \"));\n            Print(Last(mparams));\n        else\n            Print(self.params);\n        fi;\n    Print(\")\", When(self.transposed, \".transpose()\", \"\"));\n    end,\n\n));\n\n\nNewRulesFor(realDFTPerm, rec(\n\n    # Rule to place realDFTPerm into a StreamPermGen wrapper.\n    # realDFTPerm --> StreamPermGen(realDFTPerm)\n\n   \n    realDFTPerm_Stream := rec(\n        isApplicable := (self, P) >> Checked(IsList(P[2]) and IsBound(P[2][1].bs),\n\t                                      IsInt((2^P[1])/P[2][1].bs)),\n\n      children := (self, nt) >> [[]],\n      apply := (nt, c, cnt) -> StreamPerm([realDFTPerm(nt.params[1], nt.params[2], nt.params[3])], 1, nt.getTags()[1].bs, 0),\n   )\n));\n\nClass(TConjEvenStreamBB, NonTerminal, rec(\n    abbrevs := [(n,j) -> Checked(IsPosInt(n), [n,j])],\n    dims    := self >> [4,4],\n    isReal  := self >> true,\n\n    terminate := self >> let(\n        j  := self.params[2].ev(),\n        n  := self.params[1],\n\n        c  := cospi(2*j/n)/2,\n        s  := sinpi(2*j/n)/2,\n        \n        Cond(j=0,\n            Mat([[1,1,0,0], [1, -1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),\n            \n            Diag(1,1,1,-1) *\n            Tensor(F(2), I(2)) *\n            DirectSum(Diag(1/2, 1/2), Mat([[c, -1*s], [s, c]])) *\n            L(4,2) * \n            Mat([[1,0,1,0],[0,1,0,1],[0,1,0,-1],[-1,0,1,0]])\n            \n\n        )\n    )\n));\n\n\nNewRulesFor(TConjEven, rec(\n    TConjEven_stream := rec(\n        switch := false,\n        applicable := (self, t) >> 2^Log2Int(t.params[1]) = t.params[1] and\n                                       t.isTag(1, AStream) and t.getTags()[1].bs >= 4,\n               \n        children := (self, nt) >> let(\n            n    := nt.params[1],\n            tags := nt.getTags(),\n            i    := Ind(n/4),\n\t    rot  := nt.params[2],\n\n            [[ TCompose([\n#                    TPrm(Tensor(DirectSum(I(n/4+1), J(n/4-1)) * L(n/2,2), I(2))),\n#                    TPrm(Tensor(Kp(n/2, 2), I(2))),\n                    TRC(TPrm(Kp(n/2, 2))),\n\t\t    # YSV: NOTE -- handle <rot> below\n                    TTensorInd(TConjEvenStreamBB(n, i), i, APar, APar),\n#                    TPrm(Tensor(L(n/2, n/4) * DirectSum(I(n/4+1), J(n/4-1)), I(2)))\n#                    TPrm(Tensor(Kp(n/2, 2).transpose(), I(2)))\n                    TRC(TPrm(Kp(n/2, 2).transpose()))\n               ]).withTags(tags)]]\n        ),\n\n        apply := (nt, c, cnt) -> c[1]\n                          \n    )\n));\n\nNewRulesFor(TConjEvenStreamBB, rec(\n    TConjEvenStreamBB_base := rec(\n        switch := false,\n        forTransposition := false,\n        applicable := (self, nt) >> IsPosInt(nt.params[1]),\n\n        # new: better alg.  store n/2 words, perform 4 multiplications\n        apply := (t, c, nt) -> let(\n            j := t.params[2],\n            n := t.params[1],\n            cs := Dat1d(TReal, 1),\n            sn := Dat1d(TReal, 1),\n            \n            Data(cs, fPrecompute(FList(TReal, [fdiv(cospi(fdiv(2*j,n)),2)])),\n                Data(sn, fPrecompute(FList(TReal, [fdiv(sinpi(fdiv(2*j,n)),2)])),\n                    COND(eq(j,0),\n                        Mat([[1, 1, 0, 0], [1, -1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),\n                        Diag(1,1,1,-1) *\n                        Tensor(F(2), I(2)) *\n                        Mat([[1/2, 0, 0, 0], [0, 1/2, 0, 0], [0, 0, nth(cs,0), -1*nth(sn,0)], [0, 0, nth(sn,0), nth(cs,0)]]) *\n                        L(4,2) *\n                        Mat([[1, 0, 1, 0], [0, 1, 0, 1], [0, 1, 0, -1], [-1, 0, 1, 0]])\n                    )                               \n                )\n            )\n        )\n\n        \n\n        # Store n/2 words\n#         apply := (t, c, nt) -> let(\n#             j := t.params[2],\n#             n := t.params[1],\n#             d0 := Dat1d(TReal, 1),\n#             d1 := Dat1d(TReal, 1),\n            \n#             Data(d0, fPrecompute(FList(TReal, [fdiv(sinpi(fdiv(2*j,n)),2)])),\n#                 Data(d1, fPrecompute(FList(TReal, [fdiv((cospi(fdiv(2*j,n))),2)])),\n#                     COND(eq(j,0), \n#                         Mat([[1, 1, 0, 0], [1, -1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),\n#                         let(\n#                             b0 := 0.5+nth(d0,0),\n#                             b2 := 0.5-nth(d0,0),\n#                             Mat([[b0, nth(d1,0), b2, nth(d1,0)],\n#                                  [-1*nth(d1, 0), b0, nth(d1,0), -1*b2],\n#                                  [b2, -1*nth(d1,0), b0, -1*nth(d1,0)],\n#                                  [-1*nth(d1, 0), -1*b2, nth(d1,0), b0]])\n#                         )\n#                     )\n#             ))\n#         )\n\n        # Store 3n/4 words\n#         apply := (t, c, nt) -> let(\n#             j := t.params[2],\n#             n := t.params[1],\n#             d0 := Dat1d(TReal, 1),\n#             d1 := Dat1d(TReal, 1),\n#             d2 := Dat1d(TReal, 1),\n\n#             Data(d0, fPrecompute(FList(TReal, [fdiv((1+sinpi(fdiv(2*j,n))),2)])),\n#                 Data(d1, fPrecompute(FList(TReal, [fdiv((cospi(fdiv(2*j,n))),2)])),\n#                     Data(d2, fPrecompute(FList(TReal, [fdiv((1-sinpi(fdiv(2*j,n))),2)])),\n#                         COND(eq(j,0), \n#                             Mat([[1, 1, 0, 0], [1, -1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),\n#                             Mat([[nth(d0, 0), nth(d1,0), nth(d2,0), nth(d1,0)],\n#                                  [-1*nth(d1, 0), nth(d0,0), nth(d1,0), -1*nth(d2,0)],\n#                                  [nth(d2, 0), -1*nth(d1,0), nth(d0,0), -1*nth(d1,0)],\n#                                  [-1*nth(d1, 0), -1*nth(d2,0), nth(d1,0), nth(d0,0)]])\n#                         )\n#             )))\n#         )\n\n\n     )\n));\n", "meta": {"hexsha": "a539dd6508596128e4a0b21f2968eb196987ea2c", "size": 19503, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/stream/real.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/real.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/real.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 33.5679862306, "max_line_length": 147, "alphanum_fraction": 0.4275239707, "num_tokens": 6226, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.45774343959312036}}
{"text": "#############################################################################\n##\n#W    matgrp.gi                                                  Bettina Eick\n##\n##    This file contains the header functions to handle the 3- and \n##    4-dimensional almost crystallographic integral matrix groups.\n##\n\n#############################################################################\n##\n#F AlmostCrystallographicDim3( type, param )\n##\nInstallGlobalFunction( AlmostCrystallographicDim3, \nfunction( type, param )\n    local g, G, info;\n  \n    # type is integer or string\n    if IsString( type ) then \n        g := Int( type );\n    elif IsInt( type ) then\n        g := type;\n    else \n        g := false;\n    fi;\n    if not g in [1..17] then \n        Error(\"type does not define a valid ac-group type\");\n    fi;\n\n    # check parameters\n    if IsBool( param ) then\n        param := List( [1..ACDim3Param[g]], x -> Random(Integers) );\n        if param[1] = 0 then param[1] := Random(Integers)^2 + 1; fi;\n    elif IsInt( param ) then \n        param := List( [1..ACDim3Param[g]], x -> param );\n    elif Length( param ) <> ACDim3Param[g] then\n        Error(\"parameter should be a list of length \", ACDim3Param[g] );\n    fi;\n\n    # get group\n    if Length( param ) = 4 then\n        G := ACDim3Funcs[g](param[1], param[2], param[3], param[4]);\n    elif Length(param) = 2 then\n        G := ACDim3Funcs[g](param[1], param[2] );\n    elif Length(param) = 1 then\n        G := ACDim3Funcs[g](param[1]);\n    fi;\n\n    # set some information\n    info := rec( dim := 3, type := g, param := param );\n    SetAlmostCrystallographicInfo( G, info );\n    SetIsAlmostCrystallographic( G, true );\n    SetDimensionOfMatrixGroup( G, 4 );\n    SetFieldOfMatrixGroup( G, Rationals );\n    SetSize( G, infinity );\n    return G;\nend );\n \n#############################################################################\n##\n#F AlmostCrystallographicDim4( type, param )\n##\nInstallGlobalFunction( AlmostCrystallographicDim4, \nfunction( type, param )\n    local g, G, info;\n\n    # type is integer or string\n    if IsString( type ) then\n        g := Position( ACDim4Types, type );\n    elif IsInt( type ) then\n        g := type;\n    else \n        g := false;\n    fi;\n    if not g in [1..95] then \n        Error(\"type does not define a valid ac-group type\");\n    fi;\n\n    # check parameters\n    if IsBool( param ) then\n        param := List( [1..ACDim4Param[g]], x -> Random(Integers) );\n        if param[1] = 0 then param[1] := Random(Integers)^2 + 1; fi;\n    elif IsInt( param ) then \n        param := List( [1..ACDim4Param[g]], x -> param );\n    elif Length( param ) <> ACDim4Param[g] then\n        Error(\"parameter should be a list of length \", ACDim4Param[g] );\n    fi;\n\n    # get group\n    if Length(param) = 7 then\n        G := ACDim4Funcs[g]( param[1], param[2], param[3], param[4], \n                             param[5], param[6], param[7]);\n    elif Length(param) = 6 then\n        G := ACDim4Funcs[g]( param[1], param[2], param[3], param[4], \n                             param[5], param[6]);\n    elif Length(param) = 5 then\n        G := ACDim4Funcs[g]( param[1], param[2], param[3], param[4], \n                             param[5]);\n    elif Length(param) = 4 then\n        G := ACDim4Funcs[g]( param[1], param[2], param[3], param[4]);\n    elif Length(param) = 3 then\n        G := ACDim4Funcs[g]( param[1], param[2], param[3]);\n    fi;\n\n    # set some information\n    info := rec( dim := 4, type := g, param := param );\n    SetAlmostCrystallographicInfo( G, info );\n    SetIsAlmostCrystallographic( G, true );\n    SetDimensionOfMatrixGroup( G, 5 );\n    SetFieldOfMatrixGroup( G, Rationals );\n    SetSize( G, infinity );\n    return G;\nend );\n\n#############################################################################\n##\n#F AlmostCrystallographicGroup( dim, type, param )\n##\nInstallGlobalFunction( AlmostCrystallographicGroup,\nfunction( dim, type, param )\n    if dim = 3 then \n        return AlmostCrystallographicDim3( type, param );\n    elif dim = 4 then \n        return AlmostCrystallographicDim4( type, param );\n    else\n        Error(\"dimension must be 3 or 4\");\n    fi;\nend );\n\n#############################################################################\n##\n#F IsAlmostCrystallographic( <G> )\n##\nInstallMethod( IsAlmostCrystallographic, \"for groups\", true, \n    [IsGroup ], 0,\nfunction( G )\n    if HasAlmostCrystallographicInfo( G ) then\n        return true;\n    else\n        Print(\"sorry - cannot check this property \\n\");\n        return fail;\n    fi;\nend );\n", "meta": {"hexsha": "03004365b8f07e30a51545f29e203f3083bfd833", "size": 4527, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "gap/matgrp.gi", "max_stars_repo_name": "alex-konovalov/aclib", "max_stars_repo_head_hexsha": "d1afb020805bfd60a8bbb0a9a4adac77fe9b44f1", "max_stars_repo_licenses": ["Artistic-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "gap/matgrp.gi", "max_issues_repo_name": "alex-konovalov/aclib", "max_issues_repo_head_hexsha": "d1afb020805bfd60a8bbb0a9a4adac77fe9b44f1", "max_issues_repo_licenses": ["Artistic-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2018-03-07T16:35:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-26T23:51:07.000Z", "max_forks_repo_path": "gap/matgrp.gi", "max_forks_repo_name": "alex-konovalov/aclib", "max_forks_repo_head_hexsha": "d1afb020805bfd60a8bbb0a9a4adac77fe9b44f1", "max_forks_repo_licenses": ["Artistic-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-03-10T19:58:42.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-10T19:58:42.000Z", "avg_line_length": 31.6573426573, "max_line_length": 77, "alphanum_fraction": 0.5292688315, "num_tokens": 1224, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.45711361670559664}}
{"text": "# Here . and , print and read an integer, not a character\nBrainfuck := function(prog)\n  local pointer, stack, leftcells, rightcells, instr, stackptr, len,\n    output, input, jump, i, j, set, get;\n  input := InputTextUser();\n  output := OutputTextUser();\n  instr := 1;\n  pointer := 0;\n  leftcells := [ ];\n  rightcells := [ ];\n  stack := [ ];\n  stackptr := 0;\n  len := Length(prog);\n  jump := [ ];\n\n  get := function()\n    local p;\n    if pointer >= 0 then\n      p := pointer + 1;\n      if IsBound(rightcells[p]) then\n        return rightcells[p];\n      else\n        return 0;\n      fi;\n    else\n      p := -pointer;\n      if IsBound(leftcells[p]) then\n        return leftcells[p];\n      else\n        return 0;\n      fi;\n    fi;\n  end;\n\n  set := function(value)\n    local p;\n    if pointer >= 0 then\n      p := pointer + 1;\n      if value = 0 then\n        Unbind(rightcells[p]);\n      else\n        rightcells[p] := value;\n      fi;\n    else\n      p := -pointer;\n      if value = 0 then\n        Unbind(leftcells[p]);\n      else\n        leftcells[p] := value;\n      fi;\n    fi;\n  end;\n\n  # find jumps for faster execution\n  for i in [1 .. len] do\n    if prog[i] = '[' then\n      stackptr := stackptr + 1;\n      stack[stackptr] := i;\n    elif prog[i] = ']' then\n      j := stack[stackptr];\n      stackptr := stackptr - 1;\n      jump[i] := j;\n      jump[j] := i;\n    fi;\n  od;\n\n  while instr <= len do\n    c := prog[instr];\n    if c = '<' then\n      pointer := pointer - 1;\n    elif c = '>' then\n      pointer := pointer + 1;\n    elif c = '+' then\n      set(get() + 1);\n    elif c = '-' then\n      set(get() - 1);\n    elif c = '.' then\n      WriteLine(output, String(get()));\n    elif c = ',' then\n      set(Int(Chomp(ReadLine(input))));\n    elif c = '[' then\n      if get() = 0 then\n        instr := jump[instr];\n      fi;\n    elif c = ']' then\n      if get() <> 0 then\n        instr := jump[instr];\n      fi;\n    fi;\n    instr := instr + 1;\n  od;\n  CloseStream(input);\n  CloseStream(output);\n  # for debugging purposes, return last state\n  return [leftcells, rightcells, pointer];\nend;\n\n# An addition\nBrainfuck(\"+++.<+++++.[->+<]>.\");\n# 3\n# 5\n# 8\n", "meta": {"hexsha": "4af35f287dcd33ae7465a4c1ae9b42d8870520d6", "size": 2143, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Execute-Brain----/GAP/execute-brain----.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/Execute-Brain----/GAP/execute-brain----.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/Execute-Brain----/GAP/execute-brain----.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 20.8058252427, "max_line_length": 68, "alphanum_fraction": 0.5058329445, "num_tokens": 640, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4548193603519451}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nClass(RulesHfunc, RuleSet, rec(__avoid__ := [])); #Diag]));\n\n# IsInt(range(e)) makes sure that we don't apply this to functions with range of TInt, \n# which are special. Otherwise \n# the following breaks eventually\n# RC(Diag(fPrecompute(fCompose(dOmega(6, 1), diagTensor(fCompose(dLin(V(2), 1, 0, TInt), \n#                       fBase(i601)), dLin(3, 1, 0, TInt)), H(3, 1, 0, 1))))), \n# because this rule matches\nbase := pat -> pat.cond(e->domain(e)=1 and IsInt(range(e))); \n\nunmemo := exp -> When(IsVar(exp) and IsBound(exp.mapping), exp.mapping, exp);\nSetRange := (exp,r) >> When(IsVar(exp), exp.setRange(r), exp);\n\nRewriteRules(RulesHfunc, rec(\n # fId -> H\n #Hid := Rule(fId, e -> H(e.params[1], e.params[1], 0, 1)),\n\n # fTensor -> H o f\n Tensor_toH1 := ARule(fTensor, [ @F, base(@(1)) ], \n     (e,cx) -> [ fCompose(H(range(@(1).val) * range(@F.val), \n\t\t            range(@F.val), \n\t\t            nomemo(cx, \"b\", @(1).val.lambda().at(0)), \n\t\t\t    range(@(1).val)),\n\t                  @F.val) ]),\n # fTensor -> H o f\n Tensor_toH2 := ARule(fTensor, [ base(@(1)), @F ],\n     (e,cx) -> [ fCompose(H(range(@(1).val)*range(@F.val), \n\t\t            range(@F.val), \n\t\t            nomemo(cx, \"b\", range(@F.val) * @(1).val.lambda().at(0)), \n\t\t\t    1),\n\t                  @F.val) ]),\n # gammaTensor -> HZ o f\n GammaTensor_toHZ1 := ARule(gammaTensor, [ @F, base(@(1)) ],\n     (e, cx) -> let(F := @F.val, b := @(1).val, j := b.lambda().at(0), \n\t [ fCompose(HZ(range(b)*range(F), range(F), memo(cx,\"g\",range(F)*j), range(b)), F) ])), \n\n # gammaTensor -> HZ o f, same RHS as in rule above\n GammaTensor_toHZ2 := ARule(gammaTensor, [ base(@(1)), @F ], #~.GammaTensor_toHZ1[3]),\n     (e, cx) -> let(F := @F.val, b := @(1).val, j := b.lambda().at(0), \n\t [ fCompose(HZ(range(b)*range(F), range(F), memo(cx,\"g\",range(F)*j), range(b)), F) ])), \n\n # H o H -> H\n H_H := ARule(fCompose, [ [H, @N, @n, @b, @s], [H, @n, @m, @bb, @ss] ],\n     (e, cx) -> [ H(@N.val, @m.val,\n\t            memo(cx, \"b\", @b.val + @s.val * @bb.val), # new base\n\t\t    @s.val * @ss.val) ]),                     # new stride\n ## HZ o (H | HZ) -> HZ \n HZ_H := ARule(fCompose, [ [HZ, @N, @n, @b, @s], [@(1,[H,HZ]), @n, @m, @bb, @ss] ],\n     (e, cx) -> [ HZ(@N.val, @m.val,\n\t             memo(cx, \"g\", @b.val + @s.val * @bb.val), # new base\n\t\t     @s.val * @ss.val) ]),                     # new stride\n # RM o (H | HZ) -> RM  (\"rho\" in the PLDI paper)\n RM_H := ARule(fCompose, [ [RM, @N, @n, @phi, @g], [@(1,[HZ,H]), @n, @m, @b, @s] ],\n     (e, cx) -> [ RM(@N.val, @m.val,\n\t             SetRange(memo(cx, \"f\", powmod(@phi.val,@g.val,unmemo(@b.val),@N.val)), @N.val),\n\t\t     powmod(1, @g.val, @s.val, @N.val).eval()) ]),\n\n# Following rule is for use in expressions like Gath(fBase(i))\n H_fBase := Rule(@(1,fBase),e ->H(@(1).val.params[1],1,@(1).val.params[2],1)),\n\n#Handle (H tensor I) o H\n# H_tensorI := ARule(fCompose,[[fTensor,[H,@(1),@(2),@(3),@(4)],[fId,@(5)]],[H,@.cond(e->e=@(2).val*@(5).val),1,@(6),@]],\n#e->[H(@(1).val*@(5).val,1,(@(3).val+@(4).val*idiv(@(6).val,@(5).val))*@(5).val+imod(@(6).val,@(5).val),1)]),\n\n));\n\n", "meta": {"hexsha": "c6bfb7d741674b2af908677e06d26962fec07975", "size": 3157, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sigma/hfunc_rules.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/sigma/hfunc_rules.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/sigma/hfunc_rules.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 43.8472222222, "max_line_length": 121, "alphanum_fraction": 0.5011086475, "num_tokens": 1183, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.45416433265573186}}
{"text": "\nlocal reps,tori,labels,I,II,ords,blocks;\n\n\n#......Ross \nreps:=[[[1,1],[2,1],[3,1]],    # C_3\n       [[3,1],[1,1],[7,1]]     # C_3(a_1)\n       ];\n\nI:=[[1,2,3],\n    [1,2,3]\n    ];\n\n#\n# The parabolic where the representative is distinguished\n#\nII:=[[],\n     [2]\n     ];\n\nlabels:=[\"C_3\",\n         \"C_3(a_1)\"\n         ];\n\ntori:=[\n       [],\n       []\n    ];\n\nblocks:=[];\n\nords:=[];\n\nreturn [reps,tori,labels,I,II,ords,blocks];\n", "meta": {"hexsha": "ff8a9e4960d25e084185316aa6aebd9644e12d5d", "size": 423, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/data/dataC3char2.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/dataC3char2.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/dataC3char2.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": 12.0857142857, "max_line_length": 57, "alphanum_fraction": 0.4302600473, "num_tokens": 160, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115011, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4541566416877781}}
{"text": "#############################################################################\n##\n#W    matgrp3.gi                                                Karel Dekimpe\n#W                                                               Bettina Eick\n##\n##    This file contains the 3-dimensional almost crystallographic groups\n##    as integral matrix groups. There are 17 types of groups.\n##\n\nACDim3Nr01 := function ( k1 )\nlocal a, b, c;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c] , IdentityMat(4) );\nend;\n \nACDim3Nr02 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k2, k3, k4/2], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa] , IdentityMat(4) );\nend;\n \nACDim3Nr03 := function ( k1, k2 )\nlocal a, b, c, alfa;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[-1, -k2, 0, 0], [0, 1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa] , IdentityMat(4) );\nend;\n \nACDim3Nr04 := function ( k1, k2 )\nlocal a, b, c, alfa;\na:=[[1, 0, -k1, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[-1, 2*k2, k1/2, 0], [0, 1, 0, 1/2], [0, 0, -1, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa] , IdentityMat(4) );\nend;\n \nACDim3Nr05 := function ( k1, k2 )\nlocal a, b, c, alfa;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[-1, -k2, -k2, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa ] , IdentityMat(4) );\nend;\n \nACDim3Nr06 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa, beta;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k2, k3, k4/2], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]];\nbeta:=[[-1, -k2, 0, 0], [0, 1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa, beta] , IdentityMat(4) );\nend;\n \nACDim3Nr07 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa, beta;\na:=[[1, 0, -k1, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k2, -2*(k3 + k4), k3/2], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]];\nbeta:=[[-1, k1/2 - k2, 0, 0], [0, 1, 0, 0], [0, 0, -1, 1/2], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa, beta] , IdentityMat(4) );\nend;\n \nACDim3Nr08 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa, beta;\na:=[[1, 0, -k1, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k1 + 2*k3, -k1 + 2*k2 - 2*k3, k4/2], [0, -1, 0, 0], [0, 0, -1, 0], \n [0, 0, 0, 1]];\nbeta:=[[-1, -k1/2 - 2*k3, k1/2, 0], [0, 1, 0, 1/2], [0, 0, -1, 1/2], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa, beta] , IdentityMat(4) );\nend;\n \nACDim3Nr09 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa, beta;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k2, -k2 + 2*k3, k4/2], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]];\nbeta:=[[-1, -k3, -k3, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa, beta] , IdentityMat(4) );\nend;\n \nACDim3Nr10 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k2, k3, k4/4], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa] , IdentityMat(4) );\nend;\n \nACDim3Nr11 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa, beta;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k2, k3, k4/4], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]];\nbeta:=[[-1, -k2 - k3, 0,  0], [0, 1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa, beta] , IdentityMat(4) );\nend;\n \nACDim3Nr12 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa, beta;\na:=[[1, 0, -k1, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k2, k1 - k2 - 2*k3, k4/4], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]];\nbeta:=[[-1, -k1/2 + 2*k3, k1/2, 0], [0, 1, 0, 1/2], [0, 0, -1, 1/2], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa, beta] , IdentityMat(4) );\nend;\n \nACDim3Nr13 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k2, -k1/2 + k3, k4/3], [0, 0, -1, 0], [0, 1, -1, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa] , IdentityMat(4) );\nend;\n \nACDim3Nr14 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa, beta;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k2, -k1/2 + k3, k4/3], [0, 0, -1, 0], [0, 1, -1, 0], [0, 0, 0, 1]];\nbeta:=[[-1, -k2 , k2 , 0], [0, 0, -1, 0], [0, -1, 0, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa, beta] , IdentityMat(4) );\nend;\n \nACDim3Nr15 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa, beta;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, k1 - 2*k3 + 3*k2, -k1/2 + k3, k4/3], [0, 0, -1, 0], [0, 1, -1, 0], \n [0, 0, 0, 1]];\nbeta:=[[-1, -k2, -k2,  0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa, beta] , IdentityMat(4) );\nend;\n \nACDim3Nr16 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, -k1/2 + k2, k3, k4/6], [0, 1, -1, 0], [0, 1, 0, 0], \n [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa] , IdentityMat(4) );\nend;\n \nACDim3Nr17 := function ( k1, k2, k3, k4)\nlocal a, b, c, alfa, beta;\na:=[[1, 0, -k1/2, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]];\nb:=[[1, k1/2, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1]];\nc:=[[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];\nalfa:=[[1, -k1/2 + k2, k3, k4/6], [0, 1, -1, 0], [0, 1, 0, 0], \n [0, 0, 0, 1]];\nbeta:=[[-1, -k3, -k3, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]];\nreturn Group( [a , b, c, alfa, beta] , IdentityMat(4) );\nend;\n \n#############################################################################\n##\n#V ACDim3Funcs\n#V ACDim3Param\n##\nACDim3Funcs := [ ACDim3Nr01, ACDim3Nr02, ACDim3Nr03, ACDim3Nr04, ACDim3Nr05, \nACDim3Nr06, ACDim3Nr07, ACDim3Nr08, ACDim3Nr09, ACDim3Nr10, ACDim3Nr11, \nACDim3Nr12, ACDim3Nr13, ACDim3Nr14, ACDim3Nr15, ACDim3Nr16, ACDim3Nr17 ];\nMakeReadOnlyGlobal( \"ACDim3Funcs\" );\n\nACDim3Param := [ 1,4,2,2,2,4,4,4,4,4,4,4,4,4,4,4,4 ]; \nMakeReadOnlyGlobal( \"ACDim3Param\" );\n\n\n\n", "meta": {"hexsha": "a63e6b8db2f885a5cb0a64dd24f71e30c04fa828", "size": 8081, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "gap/matgrp3.gi", "max_stars_repo_name": "alex-konovalov/aclib", "max_stars_repo_head_hexsha": "d1afb020805bfd60a8bbb0a9a4adac77fe9b44f1", "max_stars_repo_licenses": ["Artistic-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "gap/matgrp3.gi", "max_issues_repo_name": "alex-konovalov/aclib", "max_issues_repo_head_hexsha": "d1afb020805bfd60a8bbb0a9a4adac77fe9b44f1", "max_issues_repo_licenses": ["Artistic-2.0"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2018-03-07T16:35:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-26T23:51:07.000Z", "max_forks_repo_path": "gap/matgrp3.gi", "max_forks_repo_name": "alex-konovalov/aclib", "max_forks_repo_head_hexsha": "d1afb020805bfd60a8bbb0a9a4adac77fe9b44f1", "max_forks_repo_licenses": ["Artistic-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-03-10T19:58:42.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-10T19:58:42.000Z", "avg_line_length": 42.5315789474, "max_line_length": 83, "alphanum_fraction": 0.401559213, "num_tokens": 5220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392725805822, "lm_q2_score": 0.5117166047041654, "lm_q1q2_score": 0.4523775749900757}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nDeclare(_numBlocks);\n\n#F NumBlocks(<sums>, <blocksize>, <comp>)\n#F\n#F counts the number of blocks of <blocksize> in <sums>, and <comp> is\n#F a boolean that tells the function to only count blocks that actually do\n#F some computation. It checks for computation by testing the presence of the \n#F Blk() structure.\n\nNumBlocks := (S, blocksize, comp) -> \n    _numBlocks(S, blocksize, S.dims()[1], comp);\n\n_numBlocks := function(S, blocksize, size, comp)\n\n    if ObjId(S) = ISum then\n        size := size / S.var.range;\n\n        if size <= blocksize then\n            return When(comp = false or Collect(S, Blk) <> [], 1, 0);\n        fi;\n    fi;\n        \n    return Sum(S.rChildren(), e -> _numBlocks(e, blocksize, size, comp));\nend;\n\nDeclare(_numWBlocks);\n\nNumWeightedBlocks := (S, blocksize, comp) ->\n    _numWBlocks(S, blocksize, S.dims()[1], S.dims()[1], comp);\n\n_numWBlocks := function(S, blocksize, size, fullsize, comp)\n    if ObjId(S) = ISum then\n        size := size / S.var.range;\n\n        if size <= blocksize then\n            return When(comp = false or Collect(S, Blk) <> [],\n                fullsize / size,\n                0\n            );\n        fi;\n    fi;\n\n    return Sum(S.rChildren(), e -> _numWBlocks(e, blocksize, size, fullsize, comp));\nend;\n\nDeclare(_numW2Blocks);\n\n#F NumW2Blocks(<sums>, <blocksize>, <comp>)\n#F\n#F\n#F\nNumW2Blocks := (S, blocksize, comp) ->\n    _numW2Blocks(S, blocksize, S.dims()[1], S.dims()[1], comp);\n\n_numW2Blocks := function(S, blocksize, size, fullsize, comp)\n\n    if ObjId(S) = ISum then\n        size := size / S.var.range;\n\n        # <fullsize / size> gives the number of times a block of size\n        # <size> is executed.  <2 * size> is the number of out of\n        # block accesses a <size> sized block requires. <(2 * size) *\n        # (fullsize / size)> is the total number of out-of-block\n        # accesses required by this block.\n        #\n        # <size * fullsize> is an algebraic simplification.\n        #\n        # since fullsize is a constant factor, we drop it. \n        #\n        if size <= blocksize then\n            return When(comp = false or Collect(S, Blk) <> [],\n                size,\n                0\n            );\n        fi;\n    fi;\n\n    return Sum(S.rChildren(), e -> _numW2Blocks(e, blocksize, size, fullsize, comp));\nend;\n", "meta": {"hexsha": "a007fe019827a309b3273fb32930fa6c5d683666", "size": 2380, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/cache/spl.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/cache/spl.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/cache/spl.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.0, "max_line_length": 85, "alphanum_fraction": 0.5865546218, "num_tokens": 674, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482763, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.45202990489291195}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#######################################################################################\n#   tSPL DFT rules\nNewRulesFor(PrunedDFT, rec(\n    PrunedDFT_tSPL_CT := rec(\n\n    forTransposition := true,\n\n    maxSize       := false,\n\n    applicable    := (self, nt) >> nt.params[1] > 2\n        and (self.maxSize = false or nt.params[1] <= self.maxSize)\n        and not IsPrime(nt.params[1])\n        and nt.params[3] > 1\n        and nt.hasTags(),\n\n    children      := nt -> Map2(Filtered(DivisorPairs(nt.params[1]), (l) -> IsInt(nt.params[3]/l[1])), (m,n) -> [\n        TCompose([\n            TGrp(TCompose([\n                TTensorI(DFT(m, nt.params[2] mod m), n, AVec, AVec),\n                TDiag(fPrecompute(Tw1(m*n, n, nt.params[2])))\n            ])),\n            TGrp(TTensorI(PrunedDFT(n, nt.params[2] mod n, nt.params[3]/m, nt.params[4]), m, APar, AVec))\n        ]).withTags(nt.getTags())\n    ]),\n\n    apply := (nt, c, cnt) -> c[1],\n\n    switch := false\n    )\n));\n\n\nNewRulesFor(IOPrunedDFT, rec(\n    IOPrunedDFT_tSPL_CT := rec(\n\n    forTransposition := true,\n\n    maxSize       := false,\n\n    applicable    := (self, nt) >> nt.params[1] > 2\n        and (self.maxSize = false or nt.params[1] <= self.maxSize)\n        and not IsPrime(nt.params[1])\n        and nt.params[3] * nt.params[5] >= nt.params[1]\n        and nt.hasTags(),\n\n    children      := nt -> Map2(Filtered(DivisorPairs(nt.params[1]), (l) -> IsInt(nt.params[3]/l[2]) and IsInt(nt.params[5]/l[1])), (m,n) -> [\n        TCompose([\n            TGrp(TCompose([\n                TTensorI(PrunedDFT(m, nt.params[2] mod m, nt.params[3]/n, nt.params[4]).transpose(), n, AVec, AVec),\n                TDiag(fPrecompute(Tw1(m*n, n, nt.params[2])))\n            ])),\n            TGrp(TTensorI(PrunedDFT(n, nt.params[2] mod n, nt.params[5]/m, nt.params[6]), m, APar, AVec))\n        ]).withTags(nt.getTags())\n    ]),\n\n    apply := (nt, c, cnt) -> c[1],\n\n    switch := false\n    )\n));\n", "meta": {"hexsha": "361e1208767c7dbddbafe2e20ba76ecee10a1e12", "size": 2012, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/common/prune.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/common/prune.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/common/prune.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.4848484848, "max_line_length": 142, "alphanum_fraction": 0.5109343936, "num_tokens": 624, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.4515958347450584}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nImportAll(paradigms.vector); \n\nDeclare(ASPF);\n\nClass(flipBot, PermClass, rec(\n    def := k -> rec(size := 2*k),\n    lambda := self >> let(k := self.params[1],\n\ti := Ind(2*k),\n\tLambda(i, cond(leq(i, k-1), i, i + 1 - 2*imod(i,2))))\n));\n\nClass(ASPF, TaggedNonTerminal, rec(\n   _short_print := true,\n   abbrevs := [ (alg, tbasis, fbasis) -> Checked(\n           IsASPAlgebra(alg), IsASPTimeBasis(tbasis), IsASPFreqBasis(fbasis),\n           [alg, tbasis, fbasis]) ],\n\n   isReal := self >> self.params[3].dim() > 1, \n\n   dims := self >> let(n:=self.params[1].n, [n, n]),\n\n   print := (self, i, is) >> let(base_print := NonTerminal.print, \n       Print(base_print(self, i, is), \n           When(self.tags<>[], Print(\".withTags(\", self.tags, \")\")))),\n\n   hashAs := self >> let(p := self.params,\n       t := ObjId(self)(p[1].hashAs(), p[2], p[3].hashAs()).withTags(self.getTags()),\n       When(self.transposed, t.transpose(), t)),\n\n   HashId := self >> [ # NOTE: why is this function necessary?\n       [ObjId(self.params[1]), self.params[1].n], self.params[2], ObjId(self.params[3]), \n        self.getTags(), self.transposed ],\n\n\n   norm := self >> CopyFields(self, rec(params := \n                       [self.params[1], self.params[2].norm(), self.params[3].norm()])),\n\n   _scale12 := (self, s1, s2) >> let(n := self.params[1].n, Cond(\n       n<=2,         s1,\n       IsEvenInt(n), Diag(diagDirsum(fConst(TReal, 2, s1), fConst(TReal, n-2, s2))),\n       <# else #>    Diag(diagDirsum(fConst(TReal, 1, s1), fConst(TReal, n-1, s2))))),\n\n   _scale34 := (self, s1, s2) >> let(n := self.params[1].n, Cond(IsEvenInt(n),\n       s2,\n       Diag(diagDirsum(fConst(TReal, n-1, s2), fConst(TReal, 1, s1))))),\n\n   terminate := self >> let(  \n       A := self.params[1], T := self.params[2], F := self.params[3], s1 := F.scale1d, \n       n := EvalScalar(A.n),\n       res := CondPat(self, \n           [ASPF, XN_min_1,  Time_TX, Freq_1,  ...], s1 * DFT (n, A.rot), \n           [ASPF, XN_min_1,  Time_TX, Freq_1H, ...], s1 * DFT2(n, A.rot), \n           [ASPF, XN_plus_1, Time_TX, Freq_1,  ...], s1 * DFT3(n, A.rot), \n           [ASPF, XN_plus_1, Time_TX, Freq_1H, ...], s1 * DFT4(n, A.rot), \n\n           [ASPF, XN_skew,  @,  @(1, [Freq_1,Freq_1H]), ...], let(\n               aa := EvalScalar(A.a), \n               p := When(aa > 1/2, J(n), I(n)) * LIJ(n).transpose(),\n               p * s1 * Cond(ObjId(F)=Freq_1, BSkewDFT3(n, aa, A.rot), BSkewDFT4(n, aa, A.rot)) * T.toX(A)),\n\n           [ASPF, XN_min_1, ...],\n               DirectSum(List(A.rspectrum(), a -> F.from1X(a))) * BRDFT1(n, A.rot) * T.toX(A), \n           [ASPF, XN_min_1U, ...],\n               DirectSum(List(A.rspectrum(), a -> F.from1X(a))) * UBRDFT1(n, A.rot) * T.toX(A), \n           [ASPF, XN_plus_1, ...],\n               DirectSum(List(A.rspectrum(), a -> F.from1X(a))) * BRDFT3(n, 1/4, A.rot) * T.toX(A), \n           [ASPF, XN_skew, ...], let(aa := EvalScalar(A.a), \n               p := When(aa > 1/2, RC(J(n/2)), RC(I(n/2))) * RC(LIJ(n/2).transpose()),\n               DirectSum(List(A.rspectrum(), s -> F.from1X(s))) * p * BRDFT3(n, aa, A.rot) * T.toX(A)), \n\n           Error(\"not implemented\")),\n       Cond(self.transposed, TerminateSPL(res).transpose(), TerminateSPL(res))),\n\n   transpose := self >> Cond(\n       ObjId(self.params[1]) = XN_min_1 and self.params[2] = Time_TX and self.params[3]=Freq_1(1),\n           self, # DFT\n       CopyFields(self, rec(\n               transposed := not self.transposed,\n               dimensions := Reversed(self.dimensions) ))),\n\n   conjTranspose := self >> Cond(\n       self.isReal(),\n           self.transpose(),\n       CopyFields(self, rec(\n\t       params := [self.params[1].conj(), self.params[2], self.params[3]],\n               transposed := not self.transposed,\n               dimensions := Reversed(self.dimensions) ))),\n\n   normalizedArithCost := self >> let(n := self.params[1].n,\n       nlogn := n * log(n) / log(2),\n       When(self.params[3].dim() = 1, floor(5*nlogn), floor(2.5*nlogn)))\n));\n\n\nClass(ASP, rec(\n  rot := 1,\n  __call__ := (self, rot) >> WithBases(self, rec(rot := rot, operations := PrintOps)),\n  print := self >> Print(self.__name__, \"(\", self.rot, \")\"),\n\n  DFT    := (self, n) >> ASPF(XN_min_1(n,self.rot),  Time_TX, Freq_1(1)),\n  RDFT   := (self, n) >> ASPF(XN_min_1(n,self.rot),  Time_TX, Freq_E(1,1)),\n  URDFT  := (self, n) >> ASPF(XN_min_1U(n,self.rot), Time_TX, Freq_E(1,1)),\n  DHT    := (self, n) >> ASPF(XN_min_1(n,self.rot),  Time_TX, Freq_H(1,1)),\n  UDHT   := (self, n) >> ASPF(XN_min_1U(n,self.rot), Time_TX, Freq_H(1,1)),\n\n  BRDFT  := (self, n) >> ASPF(XN_min_1(n,self.rot),  Time_TX, Freq_T(1,1)),\n  MBRDFT := (self, n) >> ASPF(XN_min_1(n,self.rot),  Time_SX, Freq_S(1,1)), # Murakami BRDFT variant\n\n  IRDFT  := (self, n) >> ASPF(XN_min_1(n,self.rot),  Time_TX, Freq_E(1,2)).transpose(),\n  IURDFT := (self, n) >> ASPF(XN_min_1U(n,self.rot), Time_TX, Freq_E(1,2)).transpose(),\n\n  DFT2   := (self, n) >> ASPF(XN_min_1(n,self.rot), Time_TX,  Freq_1H(1)),\n  RDFT2  := (self, n) >> ASPF(XN_min_1(n,self.rot), Time_TX,  Freq_EH(1,1)),\n  DHT2   := (self, n) >> ASPF(XN_min_1(n,self.rot), Time_TX,  Freq_HH(1,1)),\n  BRDFT2 := (self, n) >> ASPF(XN_min_1(n,self.rot), Time_TX,  Freq_TH(1,1)),\n  SBRDFT2:= (self, n) >> ASPF(XN_min_1(n,self.rot), Time_TX,  Freq_THU(1,1)),\n\n  DFT3   := (self, n) >> ASPF(XN_plus_1(n,self.rot), Time_TX, Freq_1(1)),\n  RDFT3  := (self, n) >> ASPF(XN_plus_1(n,self.rot), Time_TX, Freq_E(1,1)),\n  DHT3   := (self, n) >> ASPF(XN_plus_1(n,self.rot), Time_TX, Freq_H(1,1)),\n  BRDFT3 := (self, n) >> ASPF(XN_plus_1(n,self.rot), Time_TX,  Freq_T(1,1)),\n  MBRDFT3:= (self, n) >> ASPF(XN_plus_1(n,self.rot), Time_SX, Freq_S(1,1)), # Murakami BRDFT variant\n\n  BDFT   := (self, n,a) >> ASPF(XN_skew(n, a,self.rot), Time_EX, Freq_1(1)),\n  rDFT   := (self, n,a) >> ASPF(XN_skew(n, a,self.rot), Time_EX, Freq_E(1,1)),\n  rDFTII := (self, n,a) >> ASPF(XN_skew(n, a,self.rot), Time_EX, Freq_EH(1,1)),\n  rDHT   := (self, n,a) >> ASPF(XN_skew(n, a,self.rot), Time_HX, Freq_H(1,1)),\n  rDHTII := (self, n,a) >> ASPF(XN_skew(n, a,self.rot), Time_HX, Freq_HH(1,1)),\n\n  brDFT   := (self, n,a) >> ASPF(XN_skew(n, a,self.rot), Time_SX, Freq_E(1,1)),\n  brDFTII := (self, n,a) >> ASPF(XN_skew(n, a,self.rot), Time_SX, Freq_EH(1,1)),\n  brDHT   := (self, n,a) >> ASPF(XN_skew(n, a,self.rot), Time_SX, Freq_H(1,1)),\n  brDHTII := (self, n,a) >> ASPF(XN_skew(n, a,self.rot), Time_SX, Freq_HH(1,1)),\n\n  bRDFT3 := (self, n,a) >> ASPF(XN_skew(n,a,self.rot),  Time_SX, Freq_S(1,1)), \n\n  skewSS := (self, n,a) >> ASPF(XN_skew(n,a,self.rot), Time_SX, Freq_S(1,1)), \n  skewTT := (self, n,a) >> ASPF(XN_skew(n,a,self.rot), Time_TX, Freq_T(1,1)), \n\n  DFT4   := (self, n) >> ASPF(XN_plus_1(n,self.rot), Time_TX, Freq_1H(1)),\n  RDFT4  := (self, n) >> ASPF(XN_plus_1(n,self.rot), Time_TX, Freq_EH(1,1)),\n  DHT4   := (self, n) >> ASPF(XN_plus_1(n,self.rot), Time_TX, Freq_HH(1,1)),\n\n  BRDFT4 := (self, n,a) >> ASPF(XN_skew(n,a, self.rot), Time_TX, Freq_TH(1,1)),\n  SBRDFT4:= (self, n,a) >> ASPF(XN_skew(n,a, self.rot), Time_TX, Freq_THU(1,1)),\n));\n\nClass(TCodelet, Tagged_tSPL_Container);\n\n_mid := F -> When(ObjId(F)=Freq_1, Freq_E, ObjId(F));\n\nFreq_H.fixbot := k -> Prm(flipBot(k));\nFreq_E.fixbot := k -> Diag(BHD(k, 1.0, -1.0));\nFreq_1.fixbot := k -> I(2*k); \nFreq_S.fixbot := k -> I(2*k);\nFreq_T.fixbot := k -> I(2*k);\n# NOTE: what is it for others?\n# NOTE: explain fixbot\n\nnsFiltered := (lst, func) -> Cond(\n    IsValue(lst), Filtered(lst.v, func),\n    IsSymbolic(lst), lst, \n    Filtered(lst, func)\n);\n\nASPF.isType1 := self >> ObjId(self.params[1]) in [XN_min_1, XN_min_1U];\nASPF.isType3 := self >> ObjId(self.params[1]) in [XN_plus_1];\nASPF.isSkew  := self >> ObjId(self.params[1]) in [XN_skew];\nASPF.size := self >> self.params[1].n;\n\n\nASPF_Breakdown_Rule := rec(\n    a := rec(\n        extraLeftTags := [],\n        extraRightTags := [],\n        inplaceTag := false,\n\tmaxRadix := -1,\n    ),\n\n    apply    := (t, C, N) -> C[1],\n    inplace := (self, x) >> When(self.getA(\"inplaceTag\"), Inplace(x), x),\n    leftTags := (self, t) >> Concatenation(t.tags, self.getA(\"extraLeftTags\", [])),\n    forTransposition := true,    \n);\n\nClass(even, AutoFoldExp, rec(\n    ev := self >> let(a := self.args[1].ev(), \n        Cond(not IsInt(a), Error(\"even(<n>) works only with integer <n>\"), \n             IsEvenInt(a), 1, \n             0)),\n    computeType := self >> TInt\n));\n\nClass(odd, AutoFoldExp, rec(\n    ev := self >> let(a := self.args[1].ev(), \n        Cond(not IsInt(a), Error(\"odd(<n>) works only with integer <n>\"), \n             IsOddInt(a), 1, \n             0)),\n    computeType := self >> TInt\n));\n\n\nClass(firstEltRft, FuncClass, rec(\n    def := (n,f) -> Checked(IsIntSym(n), IsFunction(f), let(d:=f.domain(), r:=f.range(), \n                   rec(n := n, N := 2*r-odd(n)))),\n    domain := self >> self.params[1],\n    range  := self >> 2*self.params[2].range() - odd(self.params[1]),\n\n    lambda := self >> let(\n        i := Ind(self.domain()), n := self.params[1], f := self.params[2], \n        fst := 1+even(n), o := odd(n),\n        Lambda(i, cond(lt(i,fst), i,  imod(i+o, 2) + 2*f.at(idiv(i+o,2)) - o))),\n\n    transpose := self >> self.__bases__[1](self.params[1], self.self.params[2].transpose())\n));\n\nClass(ASPF_CT1_DFT_Mat, TaggedNonTerminal, rec(\n    isAuxNonTerminal := true,\n    abbrevs := [ k -> Checked(IsPosIntSym(k), [k]) ],\n    dims := self >> [2*self.params[1], 2*self.params[1]],\n    isReal := self >> true,\n    terminate := self >> let(k := self.params[1],\n        mat := Mat([[1,1],[-E(4), E(4)]]),\n        res := L(2*k, 2) * RC(Tensor(I(k/2), mat) * MM(2,k/2)) * Diag(BHD(k,1.0,-1.0)),\n        Cond(self.transposed, res.transpose(), res)\n    )\n));\n\nNewRulesFor(ASPF_CT1_DFT_Mat, rec(\n    ASPF_CT1_DFT_Mat_terminate := rec(\n        applicable := t -> true,\n        freedoms := t -> [],\n        child := (t, fr) -> [],\n        apply := (self, t, C, Nonterms) >> t.terminate()\n    )\n));\n\nNewRulesFor(ASPF, rec(\n    # Type 1\n    #\n    ASPF_CT1_URFT := CopyFields(ASPF_Breakdown_Rule, rec(\n        applicable := t -> let(n := t.size(), \n            logic_and(t.isType1(), logic_and(eq(n mod 2, 0), logic_neg(isPrime(idiv(n,2)))))),\n\n        freedoms := (self, t) >> let(maxR := self.getA(\"maxRadix\", -1), \n            [ nsFiltered(divisorsIntNonTriv(t.size()/2), x -> (maxR < 0) or (x <= maxR/2)) ]),\n\n        child := (self, t, fr) >> let(\n            ltags := self.leftTags(t), rtags := self.getA(\"extraRightTags\", []), \n            A := t.params[1],  F    := t.params[3],  T    := t.params[2],\n            k := fr[1],        Fmid := _mid(F),      Tmid := Fmid.timeBasis(),  \n            m := A.n / (2*k),  j    := Ind(m-1),     aj   := fdiv(j+1, 2*m),   \n\n            C1 := ASPF(ObjId(A) (2*k,     A.rot),  Time_TX, F),\n            C2 := ASPF(XN_skew  (2*k, aj, A.rot),  Tmid,    F),\n            C3 := ASPF(XN_min_1U(2*m,     A.rot),  T,       Fmid(1,1)),\n            \n\t    [ GT(C1.withTags(ltags), fId(Cols(C1)), fId(Rows(C1)), []),\n\t      C2.withTags(ltags), \n\t      GT(C3.withTags(rtags), GTVec, GTVec, [k]).withTags(t.tags), \n\t      InfoNt(j) ]\n        ),\n\n\tapply := (self, t, C, Nonterms) >> let(\n            A := t.params[1],  F := t.params[3], j := Nonterms[4].params[1],\n\t    k := Cols(Nonterms[1])/2, m := Cols(Nonterms[3].params[1])/2,\n            When(F.dim()=1, Scat(Refl0_u(m, 2*k)),      # if transform is complex\n                            RC(Scat(Refl0_u(m, k)))) *  # if it is real\n            DirectSum(\n                C[1],\n\t\tIDirSum(j, F.fixbot(k) * C[2])) * \n            self.inplace(C[3])\n        )\n    )),\n\n    ASPF_CT1Prm_URFT := CopyFields(~.ASPF_CT1_URFT, rec(\n        child := (self, t, fr) >> let(\n            ltags := self.leftTags(t), rtags := self.getA(\"extraRightTags\", []), \n            A := t.params[1],    T := t.params[2],    F := t.params[3],\n            k := fr[1],          Fmid := _mid(F),     Tmid := Fmid.timeBasis(),  \n            m := div(A.n, 2*k),  j := Ind(m-1),       aj := fdiv(j+1, 2*m),   \n            \n            C1 := ASPF(ObjId(A) (2*k,     A.rot),  Time_TX, F),\n            C2 := ASPF(XN_skew  (2*k, aj, A.rot),  Tmid,    F),\n            C3 := ASPF(XN_min_1U(2*m,     A.rot),  T,       Fmid(1,1)),\n\n\t    [ GT(C1.withTags(ltags), fId(Cols(C1)), fId(Rows(C1)), []),\n\t      C2.withTags(ltags), \n\t      GT(C3.withTags(rtags), GTVec, GTPar, [k]).withTags(t.tags), \n\t      InfoNt(j) ]\n\t),\n        apply := (self, t, C, Nonterms) >> let(\n            A := t.params[1],  F := t.params[3], j := Nonterms[4].params[1],\n            N := t.params[1].n,          k := div(Cols(C[1]), 2),   tr := Tr(k, 2),\n            j := Nonterms[4].params[1],  m := div(N, 2*k),\n            fixbot := t.params[3].fixbot(k), \n\n            When(F.dim()=1, Scat(Refl0_u(m, 2*k)),      # if transform is complex\n                            RC(Scat(Refl0_u(m, k)))) *  # if it is real\n\t    DirectSum(\n\t\tC[1] * tr, \n\t\tIDirSum(j, F.fixbot(k) * C[2] * tr)) *\n\n            RC(Tr(k, m)) * C[3]\n        )\n    )),\n\n    ASPF_CT1_DFT := CopyFields(ASPF_Breakdown_Rule, rec(\n        applicable := t -> let(n := t.size(), \n            logic_and(t.isType1(), logic_and(eq(n mod 4, 0), logic_neg(isPrime(idiv(n,4)))))),\n\n        freedoms := (self, t) >> let(maxR := self.getA(\"maxRadix\", -1), \n            [ nsFiltered(divisorsIntNonTriv(t.size()/4), x -> (maxR < 0) or (x <= maxR/2)) ]),\n\n        child := (self, t, fr) >> [let(\n            ltags := self.leftTags(t), \n            A := t.params[1],  F    := t.params[3],  T    := t.params[2],\n            k := 2*fr[1],      Fmid := _mid(F),      Tmid := Fmid.timeBasis(),  \n            m := A.n / (2*k),  j    := Ind(m-1),     aj   := fdiv(j+1, 2*m),   \n\n            mat := Mat([[1,1],[-E(4), E(4)]]),\n            C1 := ASPF(ObjId(A) (2*k,     A.rot),  Time_TX, F),\n            C2 := ASPF(XN_skew  (2*k, aj, A.rot),  Tmid,    CopyFields(F, rec(scale2d:=1/2*F.scale2d))),\n            C3 := UDFT(2*m, A.rot), \n                          \n            P := When(F.dim()=1, Scat(Refl0_u(m, 2*k)),      # if transform is complex\n                                 RC(Scat(Refl0_u(m, k)))),   # if it is real\n            Pt := When(F.dim()=1, Prm(Refl0_u(m, 2*k)),      # if transform is complex\n                                 RC(Prm(Refl0_u(m, k)))),   # if it is real\n            self.inplace(\n                P * \n                DirectSum(\n                    C1.withTags(ltags) * RC(L(k, 2)), \n                    IDirSum(j, F.fixbot(k) * C2.withTags(ltags) * PushL(ASPF_CT1_DFT_Mat(k)))\n                ) *\n                Pt\n            ) * \n            RC(Tensor(I(k/2), C3) * \n               Tr(2*m,k/2))\n        )]\n    )),\n\n    ASPF_CT1Odd_RFT := CopyFields(~.ASPF_CT1_URFT, rec(\n        applicable := t -> let(n := t.size(), \n            logic_and(t.isType1(), logic_and(logic_neg(isPrime(n)), hasOddDivisors(n)))),\n\n        freedoms := (self, t) >> let(maxR := self.getA(\"maxRadix\", -1), \n            [ nsFiltered(oddDivisorsIntNonTriv(t.size()), x -> (maxR < 0) or (n/x <= maxR/2)) ]),\n\n        # m is odd here\n        child := (self, t, fr) >> [let(\n            ltags := self.leftTags(t), \n            A := t.params[1],  T    := t.params[2],  F    := t.params[3],       N  := A.n,\n            m := fr[1],        Fmid := _mid(F),      Tmid := Fmid.timeBasis(),  mf := (m-1)/2,\n            k := N / m,        j    := ind(mf,1),    aj   := fdiv(j+1, m),      Nc := idiv(N+1, 2),\n            kc:= idiv(k+1,2),\n            C1 := ASPF(ObjId(A) (  k,     A.rot), Time_TX, F).withTags(ltags),\n            C2 := ASPF(XN_skew  (2*k, aj, A.rot), Tmid,    F).withTags(ltags),\n            C3 := ASPF(XN_min_1 (  m,     A.rot), T,       Fmid(1,1)),\n            fst := 1 + even(k),\n            cpx := F.dim()=1,\n#           rp := fDirsum(fId(1+even(k)), fTensor(Refl0_odd(mf, k, 1), fId(2))), \n#           When(F.dim()=1, Scat(Refl0_odd(mf, 2*k, 0)), Scat(rp)) *\n            SUM(\n                Scat(Cond(cpx, HH(N,k,0,[m]), firstEltRft(k, HH(Nc,kc,0,[m])))) * C1 * Gath(HH(N, k, 0, [1])),\n\n                GT(F.fixbot(k) * C2,   # reflect = N-2  in BH compensates for fAdd shift\n                   HH(N, 2*k, k, [1, 2*k]),\n                   Cond(cpx, BHH(N, 2*k, 1, [m,1], 2*N),\n                             fCompose(HH(N, N-fst, fst, [1]), fTensor(BHH(Nc-1,k,0,[m,1], N-2), fId(2)))),\n                   [mf])) *\n            self.inplace(\n                GT(C3, GTVec, GTVec, [k]).withTags(t.tags))\n        )]\n    )),\n\n#     ASPF_CT1Inp_URFT := CopyFields(~.ASPF_CT1_URFT, rec(\n#         child := (self, t, fr) >> let(\n#             A := t.params[1],    T := t.params[2],    F := t.params[3],         r := A.rot,  \n#             k := fr[1],          Fmid := _mid(F),     Tmid := Fmid.timeBasis(),  \n#             m := div(A.n, 2*k),  j := Ind(m-1),       aj := fdiv(j+1, 2*m),   \n            \n#             [ ASPF(ObjId(A) (2*k, r),     Time_TX, F).withTags([ANoRecurse()]),\n#               ASPF(XN_skew  (2*k, aj, r), Tmid,    F).withTags([ANoRecurse()]),\n#               ASPF(XN_min_1U(2*m, r),     T,       Fmid(1,1)),\n#               InfoNt(j) ]),\n\n#         apply := (self, t, C, Nonterms) >> let(\n#             N := t.params[1].n,         k := div(Cols(C[1]), 2), \n#             j := Nonterms[4].params[1], m := div(N, 2*k),\n\n#             RC(Scat(Refl0_u(m, k))) * \n#             DirectSum(BB(C[1]*Tr(k,2)), \n#                       IDirSum(j, BB(Diag(BHD(k,1,-1))*C[2]*Tr(k,2)*RC(MM(2,k/2))))) *\n#             RC(Gath(Refl0_u(m, k))) * \n#             RC(condIOS(k*m, m))*\n#             Tensor(I(k), C[3]) * Tr(2*m, k)\n#         )\n#     )),\n\n    # Type 3\n    #\n    ASPF_CT3_RFT := CopyFields(ASPF_Breakdown_Rule, rec(\n        aj := (j, a, m) -> fdiv(j+1/2, 2*m), \n\n        libApplicable := t -> logic_and(eq(imod(t.params[1].n, 2),0), logic_neg(isPrime(div(t.params[1].n,2)))),\n        applicable := t -> let(A := ObjId(t.params[1]), n := t.params[1].n,\n            A = XN_plus_1 and (IsSymbolic(n) or (n > 4 and IsEvenInt(n)))),\n\n        freedoms := (self, t) >> let(n := t.params[1].n, maxR := self.getA(\"maxRadix\", -1), \n            [ When(IsSymbolic(n), divisorsIntNonTriv(div(n,2)), \n                                  Filtered(divisorsIntNonTriv(div(n,2)).ev(), x -> (maxR < 0) or (x <= maxR/2))) ]),\n\n        child := (self, t, fr) >> let(\n            A := t.params[1],     T := t.params[2],  F := t.params[3],         r := A.rot,  \n            k := fr[1],           Fmid := _mid(F),   Tmid := Fmid.timeBasis(), a := A.a, \n            m := div(A.n, 2*k),   j := Ind(m),       aj := self.aj(j, a, m), \n\n            C1 := ASPF(XN_skew(2*k, aj, r),                 Tmid, F),\n            C2 := ASPF(CopyFields(A, rec(n:=_unwrap(2*m))), T,    Fmid(1,1)),\n\n            [ C1.withTags(t.tags), GT(C2, GTVec, GTVec, [k]).withTags(t.tags), InfoNt(j) ]),\n\n        apply := (self, t, C, Nonterms) >> let( \n            N := t.params[1].n,         k := div(Cols(C[1]), 2), \n            j := Nonterms[3].params[1], m := div(N, 2*k),  \n            When(t.params[3].dim()=1, \n                 Scat(Refl1(m, 2*k)) *   IDirSum(j,                   C[1]) * C[2],\n                 RC(Scat(Refl1(m, k))) * IDirSum(j, Diag(BHD(k,1.0,-1.0))*C[1]) * C[2]))\n    )),\n\n    # Skew\n    #\n    ASPF_CTSkew_RFT := CopyFields(~.ASPF_CT3_RFT, rec(\n        aj := (j, a, m) -> fdiv(j+a, m), \n\n        applicable := t -> let(A := ObjId(t.params[1]), n := t.params[1].n,\n            A = XN_skew and (IsSymbolic(n) or (n > 4 and IsEvenInt(n)))),\n\n        apply := (self, t, C, Nonterms) >> let( \n            N := t.params[1].n,         k := div(Cols(C[1]),2), \n            j := Nonterms[3].params[1], m := div(N, 2*k),  \n            When(t.params[3].dim()=1, \n                 Tr(m, 2*k)   * IDirSum(j, C[1]) * C[2],\n                 RC(Tr(m, k)) * IDirSum(j, C[1]) * C[2]))\n    ))\n));\n\nNewRulesFor(ASPF, rec(\n    ASPF_CT1_URFT_LftInplace := CopyFields(ASPF_Breakdown_Rule, rec(\n        switch := false,\n\n        applicable := t -> let(A := ObjId(t.params[1]), n := t.params[1].n,\n            A in [XN_min_1, XN_min_1U] and\n            (IsSymbolic(n) or (n > 2 and IsEvenInt(n))) and\n            ObjId(t.params[3]) = Freq_1),\n\n        freedoms := (self, t) >> let(n := t.params[1].n, maxR := self.getA(\"maxRadix\", -1), \n            [ Filtered(DivisorsIntNonTrivSym(div(n,2)), x -> (maxR < 0) or (x <= maxR/2)) ]),\n\n        child := ASPF_CT1_URFT.child,\n\n        apply := (self, t, C, Nonterms) >> let(\n            N := t.params[1].n, k := Cols(C[1])/2, j := Nonterms[4].params[1], \n\t    m := div(N, 2*k), \n            cplx := ObjId(t.params[3])=Freq_1, \n\t    jj := Ind( Int(j.range/2) ),\n\t    pp := When(IsOddInt(m), DirectSum(I(1), condM(m-1, (m-1)/2)),\n\t\t                    condMp(m, m/2)),\n            # NOTE:  add a GT_IJ' transform (ie with IJ' on either side), and an inplace rule for it\n            #        also  GT_IJ transforms (ie with IJ on either side), and an inplace rule for it\n\t    When(not cplx, Error(\"not implemented\"), #  RC(condKp(div(n,2), k)) \n                Inplace(\n\t\t    DirectSum(\n\t\t        C[1], \n\t\t        When(IsOddInt(m), [], Data(j, V( (j.range-1)/2), C[2])),\n\t\t        When(jj.range = 0, [],\n\t\t\t    IDirSum(jj, \n\t\t\t        condM(4*k, 2)*L(4*k,2*k) * \n\t\t\t        DirectSum(Data(j, jj, C[2]), Data(j, j.range-1-jj, C[2])))))\n\t\t    ^ (L(N, m) * Tensor(I(2*k), pp))) *\n\t\tGrp(L(N, 2*k) * C[3])))\n    ))\n));\n\n#\n# Base cases\n#\nNewRulesFor(ASPF, rec(\n    ASPF_Base2 := rec(\n        requiredFirstTag := ANoTag,\n        forTransposition := true,\n        applicable := t -> t.params[1].n = 2, \n        apply := (t, C, Nonterms) -> t.terminate()\n    ),\n    \n    # This rules provides the base case for any complex transform (ie for any of the algebras)\n    # via the real transform.\n    #\n    # The trouble here, is that in different cases there are some 1d spectral components\n    # in the real transform already, and that makes permutations different.\n    #\n    ASPF_SmallCpx := rec(\n        requiredFirstTag := ANoTag,\n        forTransposition := true,\n        a := rec(maxSize := 512),\n        applicable := (self, t) >> ObjId(t.params[3]) = Freq_1 and t.params[1].n <= self.getA(\"maxRadix\", -1), \n        children := t -> let(F := t.params[3], s := F.scale1d, \n            [[ ASPF(t.params[1], t.params[2], Freq_E(s, s)) ]]),\n\n        apply := (t, C, Nonterms) -> let(\n            A := t.params[1], n := EvalScalar(A.n), \n            bcK := nn -> K(nn, 2) * Tensor(I(nn/2), Mat([[1, E(4)], [1, -E(4)]])), \n            bcL := nn -> L(nn, 2) * Tensor(I(nn/2), Mat([[1, E(4)], [1, -E(4)]])), \n                 # x^n-1\n            Cond(ObjId(A) = XN_min_1 and IsEvenInt(n),\n\t\t   When(n=2, I(2), DirectSum(I(1), Z(n/2, 1), I(n/2-1)) * DirectSum(I(2), bcK(n-2))) * C[1],\n                 ObjId(A) = XN_min_1 and IsOddInt(n),\n                   DirectSum(I(1), bcK(n-1)) * C[1],\n                 # x^n+1\n                 ObjId(A) = XN_plus_1 and IsEvenInt(n), \n                   bcK(n) * C[1],\n                 ObjId(A) = XN_plus_1 and IsOddInt(n),\n                   DirectSum(I((n-1)/2), Z((n+1)/2, -1)) * DirectSum(bcK(n-1), I(1)) * C[1],\n                 # skew \n                 ObjId(A) = XN_skew,  bcL(n) * C[1]\n            ))\n    ),\n\n    ASPF_NonSkew_Base_VecN := rec(\n       requiredFirstTag := [AVecReg, AVecRegCx],\n       forTransposition := false,\n       applicable := t -> let(v:=t.firstTag().v, alg := t.params[1],\n\t   ObjId(alg) in [XN_min_1, XN_min_1U, XN_plus_1] and \n\t   2 <= alg.n and alg.n <= 2*4*v\n       ),\n       apply := (t, C, Nonterms) -> VectorizedMatSPL(t.firstTag().isa, t)\n    ),\n    # need a separate rule because VectorizedMatSPL returns a non-transposeable result,\n    ASPF_NonSkew_Base_VecN_tr := rec(\n       requiredFirstTag := [AVecReg, AVecRegCx],\n       forTransposition := false,\n       transposed := true,\n       applicable := t -> let(v:=t.firstTag().v, alg := t.params[1],\n\t   ObjId(alg) in [XN_min_1, XN_min_1U, XN_plus_1] and \n\t   2 <= alg.n and alg.n <= 2*4*v\n       ),\n       apply := (t, C, Nonterms) -> VectorizedMatSPL(t.firstTag().isa, t)\n    ),\n\n    ASPF_BRDFT3_Base4 := rec(\n        requiredFirstTag := ANoTag,\n        forTransposition := true,\n        applicable := t -> t.hashAs() = ASP.bRDFT3(4,1/16),  # skew versionm but rule is probably invalid up to a permutation\n        apply := (t, C, Nonterms) -> let(\n\t   rot := t.params[1].rot, a := t.params[1].a, D := Dat1d(TReal, 2), \n           s := t.params[3].scale2d, dd := When(s=1, I(2), Diag(s, 1)), \n\t   Data(D, fPrecompute(FList(TReal, [2*s*cospi(rot*a), s*(4*cospi(rot*a)^2 - 1)])), \n           L(4,2) * VStack(\n\t       F(2) * dd * Mat([[1,   0,   -1,        0    ],\n\t\t                [0,   0,    0,    -nth(D,0)]]),\n\t       F(2)   *    Mat([[0,   s,    0,     nth(D,1)],\n\t\t                [0,   0,  nth(D,0),   0    ]]))))\n    ),\n\n    ASPF_URDFT_Base4 := rec(\n        requiredFirstTag := ANoTag,\n        forTransposition := true,\n        applicable := t -> t.hashAs() = ASP.URDFT(4),\n        apply := (t, C, Nonterms) -> let(rot := EvalScalar(t.params[1].rot) mod 4,\n            #NoPull\n            BB(\n                Cond(rot=1, I(4), Diag(1,1,1,-1)) * \n                Tensor(t.params[3].scale2d * F(2), I(2))))\n    ),\n\n    ASPF_URDFT_Base4_Vec2 := rec(\n        requiredFirstTag := [AVecReg, AVecRegCx],\n        forTransposition := true,\n        applicable := t -> t.hashAs() = ASP.URDFT(4).withTags(t.tags) and t.firstTag().v = 2,\n        apply := (t, C, Nonterms) -> \n            When(EvalScalar(t.params[1].rot)=1, \n                VTensor(t.params[3].scale2d * F(2), 2),\n                DirectSum(VBase(I(2), 2), VDiag(FList(TReal, [1,-1]), 2)) *\n                VTensor(t.params[3].scale2d * F(2), 2))\n    ),\n\n    ASPF_RDFT1_Base4 := rec(\n        requiredFirstTag := ANoTag, \n        forTransposition := true,\n        applicable := t -> t.hashAs() = ASP.RDFT(4),\n        apply := (t, C, Nonterms) -> let(rot := t.params[1].rot,\n            DirectSum(F(2), When(rot=1, I(2), Diag(1,-1))) * \n            Tensor(Diag(t.params[3].scale1d, t.params[3].scale2d) * F(2), I(2)))\n    ),\n\n    ASPF_RDFT_toPRDFT := rec(\n        requiredFirstTag := ANoTag, \n        forTransposition := true,\n        a := rec(maxSize := false), \n\n        applicable := (self, t) >> let(n:=t.params[1].n, \n            not Is2Power(n) and \n            (self.getA(\"maxSize\")=false or n <= self.getA(\"maxSize\")) and \n            When(IsEvenInt(n), t.hashAs() in [ASP.RDFT(n), ASP.URDFT(n)], \n                               t.hashAs() = ASP.RDFT(n))), \n\n        freedoms := (self, t) >> [],\n        child := (self, t, fr) >> [ PRDFT(EvalScalar(t.params[1].n), EvalScalar(t.params[1].rot)) ],\n\n        apply := (t, C, Nonterms) -> let(n := EvalScalar(t.params[1].n),\n            rdft := Perm_CCS(n) * C[1],\n            When(IsEvenInt(n) and t.hashAs() = ASP.URDFT(n), \n                 DirectSum((1/2)*F(2), I(n-2)) * rdft,\n                 rdft))\n    ),\n\n    ASPF_RDFT1_Base4_Vec2 := rec(\n        requiredFirstTag := [AVecReg, AVecRegCx],\n        forTransposition := true,\n        applicable := t -> t.hashAs() = ASP.RDFT(4).withTags(t.tags) and t.firstTag().v = 2,\n        apply := (t, C, Nonterms) -> let(rot := t.params[1].rot, vt := TVect(TReal, 2),\n            DirectSum(VBlk( [[ vt.value([1, -1]), vt.value([1,1]) ]], 2) * _VVStack([VTensor(I(1), 2), VIxJ2(2)], 2),\n                      When(rot=1, VBase(I(2), 2), VDiag(FList(TReal, [1,-1]), 2))) * \n            VTensor(Diag(t.params[3].scale1d, t.params[3].scale2d) * F(2), 2))\n    ),\n\n    ASPF_RDFT1_toTRDFT := rec(\n        requiredFirstTag := [AVecReg, AVecRegCx],\n        forTransposition := true,\n\ta := rec(maxSize := 512),\n        applicable := (self, t) >> let(n:=t.params[1].n, \n\t    t.hashAs() = ASP.RDFT(n).withTags(t.tags) and n <= self.getA(\"maxSize\", 512)),\n\tfreedoms := (self, t) >> [],\n\tchild := (self, t, fr) >> [ TRDFT(t.params[1].n, t.params[1].rot).withTags(t.tags) ],\n        apply := (t, C, Nonterms) -> let(\n\t    n := t.params[1].n,\n            s  := Double(t.params[3].scale1d),\n            s2 := Double(t.params[3].scale2d),\n\t    Cond(s=1 and s2=1, C[1],\n\t\t IsEvenInt(n), Diag(diagDirsum(fConst(TReal, 2, s), fConst(TReal, n-2, s2))) * C[1],\n\t\t IsOddInt(n),  Diag(diagDirsum(fConst(TReal, 1, s), fConst(TReal, n-1, s2))) * C[1]\n\t    )\n\t)\n    ),\n\n    ASPF_rDFT_Base4 := rec(\n       requiredFirstTag := ANoTag,\n       forTransposition := true,\n       applicable := t -> t.hashAs() = ASP.rDFT(4,1/16),\n       apply := (t, C, Nonterms) -> let(\n\t   a := t.params[1].a,\n           rot := t.params[1].rot,\n           s := t.params[3].scale2d,\n           NoPull(           #Diag(1,1,1,-1) * \n               Tensor(F(2), I(2)) *\n               DirectSum(s*I(2), RCDiag(fPrecompute(FList(TReal, [s*cospi(rot*a), s*sinpi(rot*a)])))) *\n               L(4,2)))\n    ),\n\n    ASPF_rDFT_toSkewDFT := rec(\n        requiredFirstTag := [ANoTag, ATwidOnline], \n        forTransposition := true,\n        a := rec(maxSize := 512),\n        applicable := (self, t) >> let(n:=t.params[1].n, \n            IsEvenInt(n) and n >= 4 and n <= self.getA(\"maxSize\", 512) and t.hashAs().setTags([]) = ASP.rDFT(n,1/16)),\n\n        freedoms := (self, t) >> [],\n        child := (self, t, fr) >> let(alg := t.params[1], \n            [ SkewDFT(alg.n/2, alg.a, alg.rot).withTags(t.getTags()) ]), \n\n        apply := (t, C, Nonterms) -> let(n:=t.params[1].n, s := t.params[3].scale2d,\n            RC(s * C[1]) * L(n, n/2))\n    ),\n\n    ASPF_rDFT_BaseN := rec(\n       requiredFirstTag := ANoTag,\n       forTransposition := true,\n       a := rec(maxSize := 512),\n       applicable := (self, t) >> let(n:=t.params[1].n, \n           IsEvenInt(n) and n >= 4 and n <= self.getA(\"maxSize\", 512) and t.hashAs() = ASP.rDFT(n,1/16)),\n\n       freedoms := (self, t) >> [],\n       child := (self, t, fr) >> [ DFT(EvalScalar(t.params[1].n/2), EvalScalar(t.params[1].rot)) ], \n       apply := (t, C, Nonterms) -> let(\n           n := t.params[1].n, \n\t   a := t.params[1].a,\n           rot := t.params[1].rot,\n           s := Double(t.params[3].scale2d), # NOTE: if Double() is not used, vector code uses _mm_set1_epi32(..) intead of _ps(..)\n           j := Ind(n-2), \n           exp := rot*a*(fdiv(4,n)), \n           twid := Lambda(j, cond(neq(imod(j, 2),0), s*sinpi(exp*idiv(j+2,2)), s*cospi(exp*idiv(j+2,2)))),\n           #NoPull\n\t   (\n               RC(C[1]) * \n               # XXX NOTE: Buf below delays sucking in, terrible hack, \n               # due to VJamData performance problems, fix it right now\n               # NOTE: fPrecompute inside diagDirsum causes twiddles to be vpacked on the fly in the code\n               Buf(RCDiag(diagDirsum(fConst(TReal, 1, s), fConst(TReal, 1, 0.0), #FList(TReal, [s,0]),\n                                      fPrecompute(twid)))) * \n               L(n,n/2)))\n    ),\n\n    ASPF_rDHT_BaseN := rec(\n #      requiredFirstTag := ANoTag,\n       forTransposition := true,\n       a := rec(maxSize := 512),\n       applicable := (self, t) >> let(n:=t.params[1].n, \n           IsEvenInt(n) and n >= 4 and n <= self.getA(\"maxSize\", 512) and t.setTags([]).hashAs() = ASP.rDHT(n,1/16)),\n\n       freedoms := (self, t) >> [],\n       child := (self, t, fr) >> [ DFT(EvalScalar(t.params[1].n/2), EvalScalar(t.params[1].rot)) ], \n       apply := (t, C, Nonterms) -> let(\n           n := t.params[1].n, \n\t   a := t.params[1].a,\n           rot := t.params[1].rot,\n           s := t.params[3].scale2d,\n           j := Ind(n-2), \n           exp := rot*a*(fdiv(4,n)),\n           twid := Lambda(j, cond(neq(imod(j, 2),0), s*sinpi(exp*idiv(j+2,2)), s*cospi(exp*idiv(j+2,2)))),\n\n           NoPull(\n               Tensor(I(n/2), Diag(1,-1)) *\n               RC(C[1]) * \n               DirectSum(s*I(2), RCDiag(fPrecompute(twid))) *\n               L(n,n/2) * Diag(diagDirsum(fConst(TReal, n/2, 1), fConst(TReal, n/2, -1)))))\n    ),\n\n    ASPF_DHT1_Base4 := rec(\n#        requiredFirstTag := ANoTag, \n        forTransposition := true,\n        applicable := t -> t.setTags([]).hashAs() = ASP.DHT(4),\n        apply := (t, C, Nonterms) -> let(rot := t.params[1].rot, \n            DirectSum(F(2), F(2)*When(rot=1, I(2), Diag(1,-1))) *\n            Tensor(Diag(t.params[3].scale1d, t.params[3].scale2d) * F(2), I(2)))\n    ),\n\n    ASPF_UDHT1_Base4 := rec(\n#        requiredFirstTag := ANoTag, \n        forTransposition := true,\n        applicable := t -> t.setTags([]).hashAs() = ASP.UDHT(4),\n        apply := (t, C, Nonterms) -> let(rot := t.params[1].rot, \n            NoPull(\n                DirectSum(I(2), F(2)*When(rot=1, I(2), Diag(1,-1))) * \n                Tensor(Diag(t.params[3].scale1d, t.params[3].scale2d) * F(2), I(2))))\n    ),\n\n    ASPF_rDHT_Base4 := rec(\n       requiredFirstTag := ANoTag,\n       forTransposition := true,\n       applicable := t -> t.hashAs() = ASP.rDHT(4,1/16),\n       apply := (t, C, Nonterms) -> let(\n\t   a := t.params[1].a,\n           rot := t.params[1].rot,\n           s := t.params[3].scale2d,\n           NoPull(Diag(1,-1,1,-1) * \n               Tensor(F(2), I(2)) *\n               DirectSum(s*I(2), RCDiag(fPrecompute(FList(TReal, [s*cospi(rot*a), s*sinpi(rot*a)])))) *\n               L(4,2)*Diag(1,1,-1,-1)))),\n\n    ASPF_rDFT_Base4_Vec2 := rec(\n       requiredFirstTag := [AVecReg, AVecRegCx],\n       forTransposition := true,\n       applicable := t -> t.hashAs() = ASP.rDFT(4,1/16).withTags(t.tags) and t.firstTag().v = 2, \n       freedoms := t -> [],\n       child := (t, fr) -> [TL(4,2,1,1).withTags(t.getTags())],\n       apply := (t, C, Nonterms) -> let(\n\t   a := t.params[1].a, \n           rot := t.params[1].rot,\n           s := t.params[3].scale2d,\n           #VDiag(FList(TReal, [1,1,1,-1]), 2) * \n           VTensor(F(2), 2) * \n           C[1] * \n           VRCDiag(fPrecompute(VData(FList(TReal, [s, s*cospi(rot*a), 0, s*sinpi(rot*a)]), 2)), 2))\n    ),\n\n    ASPF_rDFT_Base_VecN_Drop := rec(\n\trequiredFirstTag := [AVecReg, AVecRegCx],\n\tforTransposition := true,\n\tapplicable := t -> IsEvenInt(t.params[1].n) and t.hashAs() = ASP.rDFT(t.params[1].n, 1/16).withTags(t.tags), \n\n\tfreedoms := t -> [],\n\tchild := (t, fr) -> [ t.withoutFirstTag() ],\n\tapply := (t, C, Nonterms) -> C[1]\n    ),\n\n    ASPF_rDFT_Base_VecN := rec(\n\trequiredFirstTag := [AVecReg, AVecRegCx],\n\tforTransposition := false,\n\tapplicable := t -> IsEvenInt(t.params[1].n) and t.hashAs() = ASP.rDFT(t.params[1].n, 1/16).withTags(t.tags), \n\tfreedoms := t -> [],\n\tchild := (t, fr) -> let(\n            n := t.params[1].n, \n\t    a := t.params[1].a,\n            rot := t.params[1].rot,\n            s := Double(t.params[3].scale2d), # NOTE: if Double() is not used, vector code uses _mm_set1_epi32(..) intead of _ps(..)\n            j := Ind(n/2-1), \n            exp := rot*a*(fdiv(4,n)), \n            twid := Lambda(j, s*omegapi(exp*(j+1))), \n\t    [ TConj(\n                  TRC(DFT(n/2, rot) * \n\t\t      TDiag(fPrecompute(diagDirsum(fConst(TReal, 1, s), twid)))),  # NOTE: fPrecompute inside diagDirsum causes twiddles to be vpacked on the fly in the code\n\t          fId(n), L(n, n/2)\n\t      ).withTags(t.tags) ]\n        ),\n\tapply := (t, C, Nonterms) -> C[1]\n    ),\n\n    ASPF_rDFT_Base_VecN_tr := rec(\n\trequiredFirstTag := [AVecReg, AVecRegCx],\n\tforTransposition := false,\n\ttransposed := true,\n\tapplicable := t -> IsEvenInt(t.params[1].n) and t.hashAs() = ASP.rDFT(t.params[1].n, 1/16).withTags(t.tags).transpose(), \n\tfreedoms := t -> [],\n\tchild := (t, fr) -> let(\n            n := t.params[1].n, \n\t    a := t.params[1].a,\n            rot := t.params[1].rot,\n            s := Double(t.params[3].scale2d), # NOTE: if Double() is not used, vector code uses _mm_set1_epi32(..) intead of _ps(..)\n            j := Ind(n/2-1), \n            exp := rot*a*(fdiv(4,n)), \n            twid := Lambda(j, s*omegapi(exp*(j+1))), \n\t    [ TConj(\n                  TRC( TDiag(fPrecompute(diagDirsum(fConst(TReal, 1, s), twid))).conjTranspose() *\n                       DFT(n/2, rot).conjTranspose()\n                       ),  # NOTE: fPrecompute inside diagDirsum causes twiddles to be vpacked on the fly in the code\n\t          L(n, 2), fId(n)\n\t      ).withTags(t.tags) ]\n        ),\n\tapply := (t, C, Nonterms) -> C[1]\n    ),\n\n    ASPF_Cpx_rDFT_Base_VecN := rec(\n\trequiredFirstTag := [AVecReg, AVecRegCx],\n\tforTransposition := true,\n\tapplicable := t -> IsEvenInt(t.params[1].n) and \n\t    ObjId(t.params[1])=XN_skew and t.params[2]=Time_EX and \n\t    ObjId(t.params[3])=Freq_1,\n\n\tfreedoms := t -> [],\n\tchild := (t, fr) -> let(\n            n := t.params[1].n, \n\t    a := t.params[1].a,\n            rot := t.params[1].rot,\n            s := Double(t.params[3].scale1d), # NOTE: if Double() is not used, vector code uses _mm_set1_epi32(..) intead of _ps(..)\n            j := Ind(n/2-1), \n            exp := rot*a*(fdiv(4,n)), \n            twid := Lambda(j, s*omegapi(exp*(j+1))), \n\t    mat := Mat([[1, E(4)], [1, -E(4)]]),\n\t    [ GT(mat, GTVec, GTVec, [n/2]).withTags(t.tags) *\n\t      TConj(\n                  TRC(DFT(n/2, rot) * \n\t\t      TDiag(fPrecompute(diagDirsum(fConst(TReal, 1, s), twid)))),  # NOTE: fPrecompute inside diagDirsum causes twiddles to be vpacked on the fly in the code\n\t          L(n, 2), L(n, n/2)\n\t      ).withTags(t.tags) ]\n        ),\n\tapply := (t, C, Nonterms) -> C[1]\n    ),\n  \n#     ASPF_rDFT_Base4_Vec2b := rec(\n#        requiredFirstTag := [AVecReg, AVecRegCx],\n#        forTransposition := true,\n#        applicable := t -> t.hashAs() = ASP.rDFT(4,1/16).withTags(t.tags) and t.firstTag().v = 2, \n#        apply := (t, C, Nonterms) -> let(\n# \t   a := t.params[1].a, \n#            rot := t.params[1].rot,\n#            s := t.params[3].scale2d,\n#            VTensor(F(2), 2) *\n#            DirectSum(VBase(I(2), 2), VBase(J(2), 2)*VDiag(FList(TReal, [1,-1]), 2)) * \n# \t   VTensor(Mat([[1,0],[0,1]]),2) * \n#            VRCDiag(fPrecompute(VData(FList(TReal, [s, s*sinpi(rot*a), 0, -s*cospi(rot*a)]), 2)), 2))\n#     ),\n    \n    ASPF_RDFT3_Base4 := rec(\n       requiredFirstTag := ANoTag,\n       forTransposition := true,\n       applicable := t -> t.hashAs() = ASP.RDFT3(4), \n       apply := (t, C, Nonterms) -> let(\n\t   D := Dat1d(TReal, 2), d := Diag(1,-1), s := t.params[3].scale2d,\n           rot := t.params[1].rot, pm := s*sinpi(rot*1/2), # pm = +/- s \n           NoPull(\n\t   Data(D, fPrecompute(FList(TReal, [s*cospi(rot*1/4), s*sinpi(rot*1/4) ])), \n               L(4,2) * \n               DirectSum(F(2)*Diag(1,nth(D,0)), d*F(2)*Diag(1, nth(D,1))) * \n               Mat([[s,  0,  0,   0 ],\n                    [0,  1,  0,  -1 ],\n                    [0,  0,  pm,  0 ],\n                    [0,  1,  0,   1 ]]))))\n    )\n));\n", "meta": {"hexsha": "dd168d71154607fd77959ad220303f9588759f2a", "size": 38509, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sym/asp_fourier.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/asp_fourier.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/asp_fourier.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.9787946429, "max_line_length": 159, "alphanum_fraction": 0.4938585785, "num_tokens": 13596, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.45120226731713}}
{"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n_RDFT_CONST := 2.5;\n\n#F TRDFT(<n>, <k>) - RDFT Nonterminal\nClass(TRDFT, TaggedNonTerminal, rec(\n    abbrevs := [ (n) -> Checked(IsPosIntSym(n),  [n, 1]),\n                 (n,k) -> Checked(IsPosIntSym(n), IsIntSym(k), \n                             Cond( IsSymbolic(n) or IsSymbolic(k), [n, k],\n                                    Checked(Gcd(n,k)=1, [n, k mod n]))) ],\n    dims := self >> [self.params[1], self.params[1]],\n    isReal := True,\n    terminate := self >> let(\n\tmat := PkRDFT1(self.params[1], self.params[2]).terminate(),\n\tWhen(self.transposed, mat.transpose(), mat)),\n\n    SmallRandom := () -> Random([2,4,6,8,10,12,16,18,24,30,32]),\n    normalizedArithCost := (self) >> let(n := self.params[1], floor(_RDFT_CONST * n * log(n) / log(2.0)))\n));\n\n\n_conjEven := (N, rot) -> let(\n    m := Mat([[1,0],[0,-1]]),\n    d1 := Diag(diagDirsum(fConst(TReal, 2, 1.0), fConst(TReal, N-2, 1/2))),\n    m1 := DirectSum(   m, _SUM(I(N-2), Tensor(J((N-2)/2), m))),\n    m2 := DirectSum(J(2), _SUM(I(N-2), Tensor(J((N-2)/2), -m))),\n    i := I(N),\n    d2 := RC(Diag(fPrecompute(diagDirsum(\n\t\t    fConst(TReal, 1, 1.0), \n\t\t    diagMul(fConst(TComplex, N/2-1, omegapi(-1/2)), \n\t\t\t    fCompose(dOmega(N, rot), fAdd(N/2, N/2-1, 1))))))),\n    d1 * _HStack(m1, m2) * VStack(i, d2)\n);\n\n\n#F TConjEven(<n>) - extract conjugate even from RC(DFT) of half the size\nClass(TConjEven, TaggedNonTerminal, rec(\n    abbrevs := [ (n)      -> Checked(IsPosIntSym(n), [n, 1]),\n                 (n, rot) -> Checked(IsPosIntSym(n), IsIntSym(rot), [n, rot]) ],\n\n    dims := self >> [self.params[1], self.params[1]],\n    isReal := True,\n\n    terminate := self >> let(mat := _conjEven(self.params[1], self.params[2]),\n\tCond(self.transposed, mat.transpose(), mat)),\n\n    conjTranspose := self >> self.transpose(),\n    SmallRandom := () -> [Random([2,4,6,8,10,12,16,18,24,30,32]), 1],\n    doNotMeasure := true\n));\n\n\n#F  \"FFT of Single Real Function\"\n#F  Numerical Recipes in C, Chapter 12, pp 512--514\nNewRulesFor(TRDFT, rec(\n    TRDFT_DFT_NR_tSPL_New := rec(\n        switch := true,\n\tforTransposition := true,\n        applicable := (self, t) >> IsEvenInt(t.params[1]), # and t.hasTags(),\n        children := (self, t) >> let(N := t.params[1], rot := t.params[2], \n            [[\n                TConjEven(N, rot).withTags(t.getTags()),\n                TRC(DFT(N/2, t.params[2])).withTags(t.getTags())\n            ]]),\n        apply := (self, t, C, Nonterms) >> C[1] * C[2]\n    ),\n\n    TRDFT_DFT_NR_tSPL := rec(\n        switch := true,\n\tforTransposition := true,\n        useComplexCh := false,\n        applicable := (self, t) >> IsEvenInt(t.params[1]), # and t.hasTags(),\n        children := (self, t) >> let(N := t.params[1], rot := t.params[2], \n            cmpxtags := t.getTags(),\n            realtags := List(cmpxtags, e -> Cond(e.kind()=spiral.paradigms.vector.AVecRegCx, spiral.paradigms.vector.AVecReg(e.params[1]), e)),\n            [[\n                TConjEven(N, rot).withTags(realtags),\n                TRC(DFT(N/2, t.params[2])).withTags(Cond(self.useComplexCh, cmpxtags, realtags))\n            ]]),\n        apply := (self, t, C, Nonterms) >> C[1] * C[2]\n    ),\n\n    TRDFT_DFT_NR_tSPL_Cplx := CopyFields(~.TRDFT_DFT_NR_tSPL, rec(\n        useComplexCh := true,\n        applicable   := (self, t) >> IsEvenInt(t.params[1]) and t.hasTag(spiral.paradigms.vector.AVecRegCx),\n    )),\n\n   TRDFT_CT_tSPL_New := rec(\n        applicable := t -> let(n:=t.params[1],  t.hasTags() and \n            not IsPrime(n) and not (IsEvenInt(n) and IsPrime(n/2))),\n\n        freedoms := t -> let(N := t.params[1], v2 := t.firstTag().params[1].v, \n            # TRC(TDiag(f)) needs 2*v | f.domain(), not to mention TConj\n            [ Filtered(DivisorsIntNonTriv(N), x->x>2 and N/x mod v2=0) ]),\n\n        child := (self, t, fr) >> let(\n            N := t.params[1],  k := t.params[2],\n            n := fr[1],        m := N/n,         j := Ind(Int((n+1)/2)-1),\n\t    tags := t.getTags(),\n\n            [ When(IsEvenInt(n), TRDFT(2*m, k).withTags(tags), \n                                 TRDFT(m,   k).withTags(tags)),\n              When(IsEvenInt(n), TTensorI(URDFT(n, k), m, AVec, AVec).withTags(tags),\n                                 TTensorI(PkRDFT1(n, k), m, AVec, AVec).withTags(tags)),\n              InfoNt(j),\n              TConj(TRC(DFT(m, k) * TDiag(fPrecompute(Twid(N,m,k,0,0,j+1)))), \n\t\t    fId(2*m), L(2*m, m)).withTags(tags)\n\t    ]\n        ),\n\n\tapply := (self, t, C, Nonterms) >> let(\n            N  := t.params[1],           m  := Nonterms[2].params[2],  n  := N/m,\n            Nf := Int(N/2),              mf := Int(m/2),               nf := Int(n/2), \n            Nc := Int((N+1)/2),          mc := Int((m+1)/2),           nc := Int((n+1)/2), \n            j  := Nonterms[3].params[1], k  := t.params[2],            tags := t.getTags(),\n\n            RC(Tensor(I(m/2), DirectSum(I(n/2+1), J(n/2-1)))) *\n            RC(L(N/2, m)) * \n            DirectSum(\n                C[1],\n                IDirSum(j, RC(LIJ(m)) * Diag(BHD(m,1,-1)) * C[4])\n            ) * \n            C[2]\n        )\n    ),\n\n    TRDFT_CT_tSPL := rec(\n#        requiredFirstTag := [AVecReg, AVecRegCx],\n\n        # rule TRDFT_CT_tSPL_Cplx sets useComplexCh to <true> and overrides some methods\n        useComplexCh := false,\n        \n        applicable := t -> let(n:=t.params[1],  t.hasTags() and \n            not IsPrime(n) and not (IsEvenInt(n) and IsPrime(n/2))),\n\n        freedoms := t -> let( N := t.params[1], v2 := 2*t.firstTag().params[1].v, \n            # TRC(TDiag(f)) needs 2*v | f.domain(), not to mention TConj\n            [ Filtered(DivisorsIntNonTriv(N), x->x>2 and N/x mod v2=0) ]),\n\n        child := (self, t, fr) >> let(\n            N := t.params[1],  k := t.params[2],\n            n := fr[1],        m := N/n,         j := Ind(Int((n+1)/2)-1),\n\n            cmpxtags := t.getTags(),\n            realtags := List(cmpxtags, e -> Cond(e.kind()=spiral.paradigms.vector.AVecRegCx, spiral.paradigms.vector.AVecReg(e.params[1]), e)),\n\n            [ When(IsEvenInt(n), TRDFT(2*m, k).withTags(cmpxtags), \n                                 TRDFT(m,   k).withTags(cmpxtags)),\n              When(IsEvenInt(n), TTensorI(URDFT(n, k), m, AVec, AVec).withTags(realtags),\n                                 TTensorI(PkRDFT1(n, k), m, AVec, AVec).withTags(realtags)),\n              InfoNt(j)\n            ] :: \n            Cond( self.useComplexCh,\n              [ TRC(DFT(m, k)).withTags(cmpxtags),\n                TRC(TDiag(fPrecompute(Twid(N,m,k,0,0,j+1)))).withTags(cmpxtags),\n                TL(2*m, m, 1, 1).withTags(realtags) ],\n              [ TConj(TRC(DFT(m, k)), fId(2*m), L(2*m, m)).withTags(realtags),\n                TConj(TRC(TDiag(fPrecompute(Twid(N,m,k,0,0,j+1)))), L(2*m, 2), L(2*m, m)).withTags(realtags)] )\n        ),\n\n\tapply := (self, t, C, Nonterms) >> let(\n            N  := t.params[1],           m  := Nonterms[2].params[2],  n  := N/m,\n            Nf := Int(N/2),              mf := Int(m/2),               nf := Int(n/2), \n            Nc := Int((N+1)/2),          mc := Int((m+1)/2),           nc := Int((n+1)/2), \n            j  := Nonterms[3].params[1], k  := t.params[2],            tags := t.getTags(),\n\n            dft:= Cond(self.useComplexCh, C[4]*C[5]*C[6], C[4]*C[5]),\n\n            RC(Tensor(I(m/2), DirectSum(I(n/2+1), J(n/2-1)))) *\n            RC(L(N/2, m)) * \n            DirectSum(\n                C[1],\n                IDirSum(j, RC(LIJ(m)) * Diag(BHD(m,1,-1)) * dft )\n            ) * \n            C[2]\n        )\n    ),\n\n    TRDFT_CT_tSPL_Cplx := CopyFields(~.TRDFT_CT_tSPL, rec(\n        useComplexCh := true,\n        applicable := t -> let(n:=t.params[1],  t.hasTag(spiral.paradigms.vector.AVecRegCx) and \n            not IsPrime(n) and not (IsEvenInt(n) and IsPrime(n/2))),\n        \n        freedoms := t -> let( N := t.params[1], v := t.firstTag().v, \n            # TRC(TDiag(f)) needs v/2 | f.domain()\n            [ Filtered(DivisorsIntNonTriv(N), x->x>2 and N/x mod v=0) ]),\n    )),\n\n    TRDFT_By_Def := rec(\n         forTransposition := false,\n         applicable := (self, t) >> (t.firstTagIs(spiral.paradigms.vector.AVecReg) or \n                                     t.firstTagIs(spiral.paradigms.vector.AVecRegCx)) and \n                                     t.params[1]<=t.firstTag().isa.v,\n         apply := (self, t, C, Nonterms) >> spiral.paradigms.vector.breakdown.VectorizedMatSPL(t.firstTag().isa, t),\n    ),\n\n    TRDFT_By_Def_tr := rec(\n         forTransposition := false,\n\t transposed := true,\n         applicable := (self, t) >> (t.firstTagIs(spiral.paradigms.vector.AVecReg) or \n                                     t.firstTagIs(spiral.paradigms.vector.AVecRegCx)) and \n                                     t.params[1]<=t.firstTag().isa.v,\n         apply := (self, t, C, Nonterms) >> spiral.paradigms.vector.breakdown.VectorizedMatSPL(t.firstTag().isa, t),\n    ),\n\n));\n\nNewRulesFor(TConjEven, rec(\n    TConjEven_base := rec(\n        switch := true,\n        applicable := (self, t) >> IsEvenInt(t.params[1]),\n        apply := (self, t, C, Nonterms) >> _conjEven(t.params[1], t.params[2])\n    )\n));\n", "meta": {"hexsha": "2b83a28305014d95710b0667304f946824a4a6ae", "size": 9162, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/common/rdft.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/common/rdft.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/common/rdft.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.0275229358, "max_line_length": 143, "alphanum_fraction": 0.497707924, "num_tokens": 2981, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833737577158, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4502677091270595}}
