| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nClass(SSE_LDST, rec(\n list := [],\n __call__ := meth(arg)\n local self;\n\tself := arg[1];\n\tAppend(self.list, Drop(arg, 1));\n end\n));\n\n\n#######################################################################################\n# SSE2 2-way 64-bit floating-point instructions\n#######################################################################################\n\nvzero_2x64f_const := TVect(TReal, 2).zero();\nvzero_2x64f := () -> vzero_2x64f_const;\n\n# Load\n#\nSSE_LDST(\n Class(vload1sd_2x64f, VecExp_2.unary()),\n Class(vload_1l_2x64f, VecExp_2.binary()),\n Class(vload_1h_2x64f, VecExp_2.binary()),\n Class(vloadu_2x64f, VecExp_2.unary())\n);\n\n# Store\n#\nSSE_LDST(\n Class(vstore_1l_2x64f, VecStoreCommand.binary()),\n Class(vstore_1h_2x64f, VecStoreCommand.binary()),\n Class(vstoreu_2x64f, VecStoreCommand.binary())\n);\n\n# Binary shuffle\n#\nClass(vunpacklo_2x64f, VecExp_2.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 2, 1)));\n\nClass(vunpackhi_2x64f, VecExp_2.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 2, 1)));\n\nClass(vshuffle_2x64f, VecExp_2.binary(), rec(\n semantic := (in1, in2, p) -> shuffle(in1, in2, p, 2, 1),\n params := self >> sparams(2,2),\n ev := self >> self.t.value(self.semantic(self._vval(1),self. _vval(2), self.args[3].p)),\n));\n\n# Unary shuffle, sign change\n#\nClass(vushuffle_2x64f, VecExp_2.unaryFromBinop(vshuffle_2x64f));\n\nClass(chslo_2x64f, VecExp_2.unary(), rec(\n ev := self >> let(v := self.args[1], v * self.t.value([-1.0, 1.0])),\n));\n\nClass(chshi_2x64f, VecExp_2.unary(), rec(\n ev := self >> let(v := self.args[1], v * self.t.value([1.0, -1.0])),\n));\n\n# SSE3 new addsub and hadd instructions\n#\nClass(addsub_2x64f, VecExp_2.binary(), rec(\n ev := self >> add(self.args[1], chslo_2x64f(self.args[2]))\n));\nClass(hadd_2x64f, VecExp_2.binary());\n\n\n#######################################################################################\n# SSE2 2-way 64-bit integer instructions\n# NOTE: use TFixedPt instead of TReal in as the type in below instructions\n#######################################################################################\n\nvzero_2x64i_const := TVect(TReal, 2).zero();\nvzero_2x64i := () -> vzero_2x64i_const;\n\n# Binary shuffle\n#\nClass(vunpacklo_2x64i, VecExp_2.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 2, 1)\n));\n\nClass(vunpackhi_2x64i, VecExp_2.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 2, 1)\n));\n\nClass(vshuffle_2x64i, VecExp_2.binary(), rec(\n semantic := (in1, in2, p) -> shuffle(in1, in2, p, 2, 1),\n params := self >> sparams(2,2)\n));\n\n# Unary shuffle, sign change\n#\nClass(vushuffle_2x64i, VecExp_2.unaryFromBinop(vshuffle_2x64i));\nClass(chslo_2x64i, VecExp_2.unary());\nClass(chshi_2x64i, VecExp_2.unary());\n\n# cmpge_2x64f\nClass(cmpge_2x64f, VecExp_2.binary());\nClass(cmple_2x64f, VecExp_2.binary());\nClass(cmpeq_2x64f, VecExp_2.binary());\n\n\n#######################################################################################\n# SSE2 2-way 32-bit floating-point instructions\n# this architecture simulates 2-way inside 4-way\n#######################################################################################\n\nvzero_2x32f_const := TVect(TReal, 2).zero();\nvzero_2x32f := () -> vzero_2x32f_const;\n\n# Load\n#\nSSE_LDST(\n Class(vload1sd_2x32f, VecExp_2.unary()),\n Class(vload_1l_2x32f, VecExp_2.binary()),\n Class(vload_1h_2x32f, VecExp_2.binary()),\n Class(vload_2x32f, VecExp_2.binary()),\n Class(vloadu_2x32f, VecExp_2.unary())\n);\n\n# Store\n#\nSSE_LDST(\n Class(vstore_1l_2x32f, VecExpCommand),\n Class(vstore_1h_2x32f, VecExpCommand),\n Class(vstore_2x32f, VecExpCommand),\n Class(vstoreu_2x32f, VecExpCommand)\n);\n\n# Binary shuffle\n#\nClass(vunpacklo_2x32f, VecExp_2.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 2, 1)\n));\n\nClass(vunpackhi_2x32f, VecExp_2.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 2, 1)\n));\n\nClass(vshuffle_2x32f, VecExp_2.binary(), rec(\n semantic := (in1, in2, p) -> shuffle(in1, in2, p, 2, 1),\n params := self >> sparams(2,2)\n));\n\n# Unary shuffle, sign change\n#\nClass(vushuffle_2x32f, VecExp_2.unaryFromBinop(vshuffle_2x32f));\nClass(chslo_2x32f, VecExp_2.unary());\nClass(chshi_2x32f, VecExp_2.unary());\n\n# SSE3 new addsub and hadd instructions\n#\nClass(addsub_2x32f, VecExp_2.binary());\nClass(hadd_2x32f, VecExp_2.binary());\n\n\n#######################################################################################\n# SSE 4-way 32-bit float instructions\n#######################################################################################\n\nvzero_4x32f_const := TVect(T_Real(32), 4).zero();\nvzero_4x32f := () -> vzero_4x32f_const;\n\n# Load\n#\nSSE_LDST(\n Class(vload1_4x32f, VecExp_4.unary()),\n Class(vload_2l_4x32f, VecExp_4.binary()),\n Class(vload_2h_4x32f, VecExp_4.binary()),\n Class(vloadu_4x32f, VecExp_4.unary()),\n Class(vloadu2_4x32f, VecExp_4.unary()),\n Class(vinsert_4x32f, VecExp_4.binary())\n);\n\n# Store\n#\nSSE_LDST(\n Class(vstore1_4x32f, VecStoreCommand.binary()),\n Class(vstore_2l_4x32f, VecStoreCommand.binary()),\n Class(vstore_2h_4x32f, VecStoreCommand.binary()),\n Class(vstoreu_4x32f, VecStoreCommand.binary()),\n Class(vstoreu2_4x32f, VecStoreCommand.binary()), # cprint: self.loc.svcprint(16)\n Class(vstoremsk_4x32f, VecStoreCommand.binary()), # cprint: self.loc.svcprint(8)\n Class(vextract_4x32f, VecStoreCommand.binary())\n);\n\n# Binary shuffle\n#\nClass(vunpacklo_4x32f, VecExp_4.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 4, 1),\n));\n\nClass(vunpackhi_4x32f, VecExp_4.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 4, 1),\n));\n\nClass(vshuffle_4x32f, VecExp_4.binary(), rec(\n semantic := (in1, in2, p) -> shuffle(in1, in2, p, 4, 1),\n params := self >> sparams(4,4),\n permparams := iperm4,\n ev := self >> self.t.value(self.semantic(self._vval(1),self._vval(2), self.args[3].p)),\n));\n\n# Unary shuffle\n#\nClass(vushuffle_4x32f, VecExp_4.unaryFromBinop(vshuffle_4x32f), rec(\n ev := self >> self.t.value(self.semantic(self._vval(1), self.args[2].p)),\n));\n\nClass(chshi_4x32f, VecExp_4.unary(), rec(\n ev := self >> let( v := self.args[1], v * self.t.value([1.0, -1.0, 1.0, -1.0]) )\n));\n\nClass(chslo_4x32f, VecExp_4.unary(), rec(\n ev := self >> let( v := self.args[1], v * self.t.value([-1.0, 1.0, -1.0, 1.0]) )\n));\n\nClass(vldup_4x32f, VecExp_4.unary(), rec(\n ev := self >> let( v := self._vval(1), self.t.value([v[1], v[1], v[3], v[3]]) )\n));\nClass(vhdup_4x32f, VecExp_4.unary(), rec(\n ev := self >> let( v := self._vval(1), self.t.value([v[2], v[2], v[4], v[4]]) )\n));\n\n# horizontal add\nClass(alignr_4x32f, VecExp_4.binary());\n\n\n#######################################################################################\n# SSE 4-way 32-bit integer instructions\n#######################################################################################\n\nvzero_4x32i_const := TVect(TReal, 4).zero();\nvzero_4x32i := () -> vzero_4x32i_const;\n\nClass(vloadu_4x32i, VecExp_4.unary());\nClass(vstoreu_4x32i, VecExpCommand);\n\n# Binary shuffle\n#\nClass(vunpacklo_4x32i, VecExp_4.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 4, 1)));\n\nClass(vunpackhi_4x32i, VecExp_4.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 4, 1)));\n\nClass(vpacks_4x32i, VecExp_4.binary(), rec(\n semantic := (in1, in2, p) -> pack_semantic(in1, in2, 4),\n computeType := self >> TVect(T_Int(16), 8)));\n\nClass(vshuffle_4x32i, VecExp_4.binary(), rec(\n semantic := (in1, in2, p) -> shuffle(in1, in2, p, 4, 1),\n params := self >> sparams(4,4),\n permparams := iperm4\n));\n\n# Unary shuffle\n#\nClass(vushuffle_4x32i, VecExp_4.unaryFromBinop(vshuffle_4x32i));\n\n# for Viterbi\nClass(interleavedmask_4x32i, VecExp_4.binary(), rec(\n computeType := self >> TUChar\n));\n\n#_mm_testz_si128\nClass(testz_4x32i, VecExp_4.binary(), rec(\n computeType := self >> TInt\n));\n\n#_mm_testc_si128\nClass(testc_4x32i, VecExp_4.binary(), rec(\n computeType := self >> TInt\n));\n\n#_mm_testnzc_si128\nClass(testnzc_4x32i, VecExp_4.binary(), rec(\n computeType := self >> TInt\n));\n\n\n\n# SSE3 new addsub and hadd instructions\n#\nClass(addsub_4x32f, VecExp_4.binary(), rec(\n ev := self >> add(self.args[1], chslo_4x32f(self.args[2]))\n));\n\nClass(hadd_4x32f, VecExp_4.binary());\n\n# type conversion of lower two elements from 4x32f to 2x64f\nClass(vcvt_64f32f, VecExp_4.unary(), rec(\n computeType := (self) >> TVect(T_Real(64), 2)\n));\n\n# type conversion of 2x64f to lower two of 4x32f\nClass(vcvt_32f64f, VecExp_2.unary(), rec(\n computeType := (self) >> TVect(T_Real(32), 4)\n));\n\n# type conversion 4x32i to 4x32f\nClass(vcvt_4x32_i2f, VecExp_4.unary(), rec(\n computeType := (self) >> TVect(T_Real(32), 4)\n));\n\n# type conversion 4x32f to 4x32i, rounding acording MXCSR register rules\nClass(vcvt_4x32_f2i, VecExp_4.unary(), rec(\n computeType := (self) >> TVect(T_Int(32), 4)\n));\n\n# type conversion 4x32f to 4x32i, truncation toward zero\nClass(vcvtt_4x32_f2i, VecExp_4.unary(), rec(\n computeType := (self) >> TVect(T_Int(32), 4)\n));\n\n#######################################################################################\n# SSE2 8-way 16-bit integer instructions\n#######################################################################################\n\nvzero_8x16i_const := TVect(TReal, 8).zero();\nvzero_8x16i := () -> vzero_8x16i_const;\n\n# SSSE3 sign change instructions\nClass(chs_8x16i, VecExp_8.binary());\n\n# Load\n#\nSSE_LDST(\n Class(vload1_8x16i, VecExp_8.ternary()),\n Class(vload2_8x16i, VecExp_8.unary()),\n Class(vload4_8x16i, VecExp_8.unary()),\n Class(vloadu_8x16i, VecExp_8.unary())\n);\n\n# Store\n#\nSSE_LDST(\n Class(vextract1_8x16i, VecExpCommand, rec(numargs := 2)),\n Class(vextract2_8x16i, VecExpCommand, rec(numargs := 1)),\n Class(vstoreu_8x16i, VecExpCommand),\n Class(vstore4_8x16i, VecExpCommand),\n Class(vstoremsk_8x16i, VecExpCommand)\n);\n\n# Binary shuffle\n#\nClass(vunpacklo_8x16i, VecExp_8.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 8, 1)));\n\nClass(vunpackhi_8x16i, VecExp_8.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 8, 1)));\n\nClass(vunpacklo2_8x16i, VecExp_8.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 8, 2)));\n\nClass(vunpackhi2_8x16i, VecExp_8.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 8, 2)));\n\nClass(vunpacklo4_8x16i, VecExp_8.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 8, 4)));\n\nClass(vunpackhi4_8x16i, VecExp_8.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 8, 4)));\n\nClass(vpacks_8x16i, VecExp_8.binary(), rec(\n semantic := (in1, in2, p) -> pack_semantic(in1, in2, 16),\n computeType := self >> TVect(T_Int(8), 16)));\n\nClass(vpackus_8x16i, VecExp_8.binary(), rec(\n semantic := (in1, in2, p) -> pack_semantic(in1, in2, 16),\n computeType := self >> TVect(T_UInt(8), 16)));\n\nClass(vshuffle2_8x16i, VecExp_8.binary(), rec(\n semantic := (in1, in2, p) -> shuffle(in1, in2, p, 8, 2),\n params := self >> sparams(4,4),\n permparams := iperm4\n));\n\nClass(vshuffle4_8x16i, VecExp_8.binary(), rec(\n semantic := (in1, in2, p) -> shuffle(in1, in2, p, 8, 4),\n params := self >> sparams(2,2),\n));\n\n# Unary shuffle\n#\nClass(vushuffle2_8x16i, VecExp_8.unaryFromBinop(vshuffle2_8x16i), rec(\n params := self >> sparams(4,4),\n permparams := iperm4,\n));\n\nClass(vushufflelo_8x16i, VecExp_8.unary(), rec(\n params := self >> sparams(4,4),\n permparams := iperm4,\n semantic := (in1, p) -> shufflelo(in1, p, 8, 1))); #Complicated, buggy?\n\nClass(vushufflehi_8x16i, VecExp_8.unary(), rec(\n params := self >> sparams(4,4),\n permparams := iperm4,\n semantic := (in1, p) -> shufflehi(in1, p, 8, 1))); #Complicated, buggy?\n\n# SSSE3 unary shuffle\nClass(vushuffle_8x16i, VecExp_8.binary());\n\n# for Viterbi\nClass(interleavedmask_8x16i, VecExp_8.binary(), rec(\n computeType := self >> TSym(\"short int\")\n));\n\nClass(alignr_8x16i, VecExp_8.binary());\n\n# cmplt_8x16i\nClass(cmplt_8x16i, VecExp_8.binary());\n\n\n#_mm_testz_si128\nClass(testz_8x16i, VecExp_8.binary(), rec(\n computeType := self >> TInt\n));\n#_mm_testc_si128\nClass(testc_8x16i, VecExp_8.binary(), rec(\n computeType := self >> TInt\n));\n\n#_mm_testnzc_si128\nClass(testnzc_8x16i, VecExp_8.binary(), rec(\n computeType := self >> TInt\n));\n\n\n#######################################################################################\n# SSE2 16-way 8-bit integer instructions\n#######################################################################################\n\nClass(vushuffle_16x8i, VecExp_16.unary(), rec(\n params := self >> sparams(4,4),\n));\n\n# Load/Store\n#\nSSE_LDST(\n Class(vloadu_16x8i, VecExp_16.unary()),\n Class(vstoreu_16x8i, VecExpCommand),\n Class(vstoremsk_16x8i, VecExpCommand)\n);\n\n# Binary shuffle\n#\nClass(vunpacklo_16x8i, VecExp_16.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 16, 1)));\n\nClass(vunpackhi_16x8i, VecExp_16.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 16, 1)));\n\nClass(vunpacklo2_16x8i, VecExp_16.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 16, 2)));\n\nClass(vunpackhi2_16x8i, VecExp_16.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 16, 2)));\n\nClass(vunpacklo4_16x8i, VecExp_16.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 16, 4)));\n\nClass(vunpackhi4_16x8i, VecExp_16.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 16, 4)));\n\nClass(vunpacklo8_16x8i, VecExp_16.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpacklo(in1, in2, 16, 8)));\n\nClass(vunpackhi8_16x8i, VecExp_16.binary(), _ev_binop_semantic_mixin, rec(\n semantic := (in1, in2, p) -> unpackhi(in1, in2, 16, 8)));\n\nClass(vshuffle4_16x8i, VecExp_16.binary(), rec(\n semantic := (in1, in2, p) -> shuffle(in1, in2, p, 16, 4),\n params := self >> sparams(4,4),\n permparams := iperm4\n));\n\nClass(vshuffle8_16x8i, VecExp_16.binary(), rec(\n semantic := (in1, in2, p) -> shuffle(in1, in2, p, 16, 8),\n params := self >> sparams(2,2),\n));\n\n# Unary shuffles\n#\nClass(vushuffle4_16x8i, vushuffle_16x8i, rec(\n semantic := (in1, p) -> shuffle(in1, in1, p, 16, 4)));\n\nClass(vushufflelo2_16x8i, vushuffle_16x8i, rec(\n semantic := (in1, p) -> shufflelo(in1, p, 16, 2)));\n\nClass(vushufflehi2_16x8i, vushuffle_16x8i, rec(\n semantic := (in1, p) -> shufflehi(in1, p, 16, 2)));\n\n# Viterbi\n#\nClass(interleavedmaskhi_16x8i, VecExp_8.binary(), rec(\n computeType := self >> TSym(\"short int\")));\n\nClass(interleavedmasklo_16x8i, VecExp_8.binary(), rec(\n computeType := self >> TSym(\"short int\")));\n\nClass(average_16x8i, VecExp_16.binary());\n\nClass(vmovemask_16x8i, VecExp_16.unary(), rec(\n computeType := self >> T_UInt(16)));\n\nClass(vcastizxlo, castizx, rec(\n ev := self >> vtakelo(self.args[1].t.toUnsigned().value(self.args[1].ev()))\n));\n\nClass(vcastizxhi, castizx, rec(\n ev := self >> vtakehi(self.args[1].t.toUnsigned().value(self.args[1].ev()))\n));\n\nClass(vcastuzxlo, castuzx, rec(\n ev := self >> vtakelo(self.args[1].t.toUnsigned().value(self.args[1].ev()))\n));\n\nClass(vcastuzxhi, castuzx, rec(\n ev := self >> vtakehi(self.args[1].t.toUnsigned().value(self.args[1].ev()))\n));\n", "meta": {"hexsha": "a9789fe0044c7a0772f93dbdf90527add712f755", "size": 16009, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/platforms/sse/code.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/sse/code.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/sse/code.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.3200757576, "max_line_length": 92, "alphanum_fraction": 0.6195265163, "num_tokens": 5648, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.39735374981948346}} | |
| {"text": "a := [1 .. 4];\nb := ShallowCopy(a);\n\n# Apply and replace values\nApply(a, n -> n*n);\na;\n# [ 1, 4, 9, 16 ]\n\n# Apply and don't change values\nList(b, n -> n*n);\n# [ 1, 4, 9, 16 ]\n\n# Apply and don't return anything (only side effects)\nPerform(b, Display);\n1\n2\n3\n4\n\nb;\n# [ 1 .. 4 ]\n", "meta": {"hexsha": "aa162eec9e24f445725c0398ae30f89435a051b8", "size": 276, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Apply-a-callback-to-an-array/GAP/apply-a-callback-to-an-array.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Apply-a-callback-to-an-array/GAP/apply-a-callback-to-an-array.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Apply-a-callback-to-an-array/GAP/apply-a-callback-to-an-array.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 12.5454545455, "max_line_length": 53, "alphanum_fraction": 0.5507246377, "num_tokens": 110, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5888891451980403, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.3938963286567488}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nRandInput := () -> Complex(\n RandomList([1..2^27])/(1.0*2^27),\n RandomList([1..2^27])/(1.0*2^27));\n\nRandValExp := function(exp)\n local e, rargs;\n if IsBound(exp.randVal) then \n\treturn exp.randVal;\n\n elif IsValue(exp) then\n\texp.randVal := exp.v;\n\treturn exp.randVal;\n\n elif IsLoc(exp) then\n\texp.randVal := RandInput();\n\t#Print(\"RandInput : \", exp, \" = \", exp.randVal, \"\\n\");\n\treturn exp.randVal;\n else \n\trargs := List(exp.args, RandValExp);\n\te := ApplyFunc(ObjId(exp), rargs);\n\te := e.ev();\n\tConstraint(not IsExp(e) and not IsLoc(e));\n\texp.randVal := e;\n\treturn exp.randVal;\n fi;\nend;\n\nRandValAssign := function(cmd) \n local r;\n if IsBound(cmd.loc.randVal) then return cmd.loc.randVal;\n elif IsBound(cmd.exp.randVal) then\n\tcmd.loc.randVal := cmd.exp.randVal;\n\treturn cmd.loc.randVal;\n else\n\tr := RandValExp(cmd.exp);\n\tcmd.exp.randVal := r;\n\tcmd.loc.randVal := r;\n\treturn r;\n fi; \nend;\n \nClass(RCSE, rec(\n cseLookup := (self, randVal) >> HashLookup(self.csetab, V(randVal)),\n\n cseAdd := meth(self, cmd)\n local op, ent, v;\n\tif not IsBound(cmd.exp.isExpComposite) then return; fi;\n\tHashAdd(self.csetab, V(cmd.loc.randVal), cmd.loc);\n\tHashAdd(self.csetab, V(-cmd.loc.randVal), neg(cmd.loc));\n end,\n\n cseCmd := meth(self, cmd)\n local lkup;\n\tRandValAssign(cmd);\n\tlkup := self.cseLookup(cmd.loc.randVal); \n\tif lkup <> false then\n\t cmd.exp := lkup;\n\telse\n\t self.cseAdd(cmd);\n\tfi;\n end,\n\n remove_node := (self, exp) >> Chain(\n\tHashDelete(self.csetab, V(exp.randVal)), \n\tHashDelete(self.csetab, V(-exp.randVal))),\n\n node := meth(self, t, exp)\n local lkup, v;\n\tif IsValue(exp) or IsLoc(exp) then\n\t RandValExp(exp); \n\t return exp; \n\tfi;\n\n\texp := ApplyFunc(ObjId(exp), List(exp.args, a->self.node(t, a)));\n\tRandValExp(exp);\n\n\tlkup := self.cseLookup(exp.randVal); \n\tif lkup <> false then\n\t return lkup;\n\telse\n\t v := var.fresh_t(\"t\", t);\n\t v.randVal := exp.randVal;\n\t v.def := assign(v, exp);\n\t self.cseAdd(v.def);\n\t return v;\n\tfi;\n end,\n\n flush := meth(self)\n self.csetab := HashTable( (val,size) -> val.t.hash(val.v, size) );\n end,\n\n __call__ := meth(self, code)\n self.csetab := HashTable( (val,size) -> val.t.hash(val.v, size) );\n\tDoForAll(Collect(code, assign), cmd -> self.cseCmd(cmd));\n\treturn code;\n end\n));\n", "meta": {"hexsha": "fce1f299dab333b1f627faace441e4748c480bdd", "size": 2428, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/compiler/cse_rand.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/compiler/cse_rand.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/compiler/cse_rand.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 23.3461538462, "max_line_length": 74, "alphanum_fraction": 0.6140856672, "num_tokens": 748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.39180788657816473}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nClass(LinearModel, rec(\n __call__ := (self, k, d) >> CopyFields(self, rec(k := k, d := d)),\n d := 0,\n k := 1,\n eval := (self, x) >> self.d + self.k * x\n));\n\nClass(ExpModel, rec(\n __call__ := (self, alpha, tau) >> CopyFields(self, rec(alpha := alpha, tau := tau)),\n alpha := 0.1,\n tau := 5,\n eval := (self, x) >> (self.alpha + (1 - d_exp(-self.tau * x))) / (1+self.alpha)\n));\n\n\nClass(ScratchModel, rec(\n config := rec(\n loadModel := (numPkts, pktSize) -> numPkts * pktSize / (0.2 * ExpModel(0.1, 0.2).eval(pktSize)),\n storeModel := (numPkts, pktSize) -> 1.1 * numPkts * pktSize / (0.2 * ExpModel(0.1, 0.2).eval(pktSize)),\n computeModel := x->LinearModel(1.1, 5).eval(x)\n ),\n getKernels := (self, spl) >> List(Collect(self.updateInfo(spl), LSKernel), i->i.info),\n updateInfo := (self, spl) >> SubstTopDown(spl, [@(1, Compose), @(2, DMAScat), @(3, LSKernel), @(4, DMAGath)],\n (e,cx) -> @(2).val *\n LSKernel(@(3).val.child(1), rec(\n opcount := @(3).val.info.opcount,\n loadFunc := @(4).val.func,\n storeFunc := @(2).val.func,\n free := When(IsBound(cx.ISum), Set(Concat(List(cx.ISum, i->i.var))), Set([])))) *\n @(4).val),\n\n getPacketData := meth(self, func)\n local domain, pktSize, numPkts;\n\n domain := func.domain();\n pktSize := 1;\n if ObjId(func) = fTensor and ObjId(Last(func.children())) = fId then\n pktSize := Last(func.children()).domain();\n fi;\n numPkts := domain / pktSize;\n\n return [pktSize, numPkts];\n end,\n\n modelStat := meth(self, spl)\n local kernels, stat, numPkts, pktSize, kernel, iter, func, n,\n flops, bw, loadcycles, storecycles, cpucycles, cycles;\n\n kernels := self.getKernels(spl);\n stat := [];\n\n for kernel in kernels do\n flops := kernel.opcount;\n cpucycles := self.config.computeModel(flops);\n\n n := kernel.loadFunc.domain();\n [pktSize, numPkts] := self.getPacketData(kernel.loadFunc);\n loadcycles := self.config.loadModel(numPkts, pktSize);\n [pktSize, numPkts] := self.getPacketData(kernel.storeFunc);\n storecycles := self.config.storeModel(numPkts, pktSize);\n iter := Product(List(kernel.free, i->i.range));\n Add(stat, rec(\n iter := iter,\n kernelcycles := Maximum(loadcycles, storecycles, cpucycles),\n loadcycles := loadcycles,\n storecycles := storecycles,\n cpucycles := cpucycles,\n balance := cpucycles / Maximum(loadcycles, storecycles)\n ));\n\n od;\n return stat;\n end,\n\n modelRuntime := meth(self, spl)\n local stat, s, runtime, cycles;\n\n runtime := 0;\n stat := self.modelStat(spl);\n\n for s in stat do\n cycles := s.loadcycles + s.storecycles + s.iter * s.kernelcycles;\n runtime := runtime + cycles;\n od;\n return When(IsInt(runtime), runtime, IntDouble(runtime));\n end,\n\n measureFunction := (rt, opts) -> let(s := SumsRuleTree(rt, opts), paradigms.scratchpad.ScratchModel.modelRuntime(s))\n));\n", "meta": {"hexsha": "d19aca5be2d4a2b086b302a0292612b6d76d77a3", "size": 3339, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/scratchpad/model.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/scratchpad/model.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/scratchpad/model.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.1473684211, "max_line_length": 121, "alphanum_fraction": 0.5462713387, "num_tokens": 917, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.7826624789529376, "lm_q2_score": 0.5, "lm_q1q2_score": 0.3913312394764688}} | |
| {"text": "#!/usr/bin/gap\n\n# time gap -o 8g hierarchy.gap\n\n# Build clifford groups, up to 3 qubits, and\n# search for T operators defined by field extensions......\n\n\nPrint(\"running hierarchy.gap\\n\");;\n\n# See:\n# https://www.mathstat.dal.ca/~selinger/papers/clifford.pdf\n\nr2 := Sqrt(2);;\nir2 := 1/r2;;\n\ni := [[1, 0], [0, 1]];;\nw := [[E(4), 0], [0, E(4)]];;\nx := [[0, 1], [1, 0]];;\nz := [[1, 0], [0, -1]];;\ns := [[1, 0], [0, E(4)]];;\nh := [[ir2, ir2], [ir2, -ir2]];;\n\nCliff1 := Group(w, s, h);; # Order 192\nPauli1 := Group(w, x, z);; # Order 32\n\nfor U in Cliff1 do\n found := false;;\n #Udag := Inverse(U);\n #Print(\"found? \");\n for g in Pauli1 do\n if (U*g*Inverse(U)*Inverse(g) in Pauli1) then found:=true; break; fi;\n od;\n if not found then Print(\"Not found\\n\"); fi;\nod;\n\nxi := KroneckerProduct(x, i);;\nix := KroneckerProduct(i, x);;\nzi := KroneckerProduct(z, i);;\niz := KroneckerProduct(i, z);;\nsi := KroneckerProduct(s, i);;\nis := KroneckerProduct(i, s);;\nhi := KroneckerProduct(h, i);;\nih := KroneckerProduct(i, h);;\nwi := KroneckerProduct(w, i);;\n\n\ncz := [\n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, -1]];;\n\nCliff2 := Group(si, is, hi, ih, wi, cz);; # Order 92160\nOrder(Cliff2);\n#for g in Cliff2 do Print(g, \"\\n\"); od;\nPhase2 := Group(wi);;\nPauli2 := Group(wi, xi, ix, zi, iz);;\n\n# Works:\nfor U in Cliff2 do\n found := false;;\n #Udag := Inverse(U);\n #Print(\"found? \");\n for g in Pauli2 do\n if (U*g*Inverse(U)*Inverse(g) in Pauli2) then found:=true; break; fi;\n od;\n if not found then Print(\"Not found\\n\"); fi;\nod;\n\nHadamard4 := (1/2)*[\n [0, 1, 0, 1],\n [2, 0, 2, 0],\n [0, 1, 0, -1],\n [2, 0, -2, 0]];\n#Print(Hadamard4*Hadamard4, \"\\n\");\n#Print(Hadamard4, \" in Cliff2 \", Hadamard4 in Cliff2, \"\\n\");\n\na := [\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1],\n [-1, 0, 0, 0]];;\n\n# Print(a in Cliff2, \"\\n\"); # true\n\n#hom:=EpimorphismFromFreeGroup(Cliff2:names:=[\"si\", \"is\", \"hi\", \"ih\", \"wi\", \"cz\"]);\n#Print(PreImagesRepresentative(hom, a), \"\\n\"); # si^3*is^3*hi*si^2*ih*is^2*ih*cz*hi*si\n#Print(PreImagesRepresentative(hom, a*a), \"\\n\"); # (si^2*hi)^2\n#Print(PreImagesRepresentative(hom, a*a*a), \"\\n\"); # si^2*is^3*hi*(si^2*hi*si)^2*si*ih*is^2*ih*cz*hi*si\n\ncls := ConjugacyClass(Cliff2, a);;\n#Print(a, a in cls, \"\\n\"); # true\n#Print(a*a, a*a in cls, \"\\n\"); # false\n#Print(a*a*a, a*a*a in cls, \"\\n\"); # true\n#Print(a*a*a*a, a*a*a*a in cls, \"\\n\"); # false\n#Print(a*a*a*a*a, a*a*a*a*a in cls, \"\\n\"); # true\n#Print(a*a*a*a*a*a, a*a*a*a*a*a in cls, \"\\n\"); # false\n#Print(a*a*a*a*a*a*a, a*a*a*a*a*a*a in cls, \"\\n\"); # true\n#Print(a*a*a*a*a*a*a*a, a*a*a*a*a*a*a*a in cls, \"\\n\"); # false\n#Print(cz, cz in cls, \"\\n\"); # false\n\n\n#b := [\n# [1, 0, 0, 0],\n# [0, 1, 0, 0],\n# [0, 0, 0, 1],\n# [0, 0, -1, 0]];;\n#Print(cz, cz in ConjugacyClass(Cliff2, b), \"\\n\"); # false\n#for b in ConjugacyClass(Cliff2, cz) do Print(b, \"\\n\"); od;\n\n#a1 := [\n# [0, 0, 1, 0],\n# [0, 0, 0, 1],\n# [0, 1, 0, 0],\n# [-1, 0, 0, 0]];;\n#Print(a1 in Pauli2, \"\\n\"); # false\n#Print(a1 in Cliff2, \"\\n\"); # true\n#Print(a1 in cls, \"\\n\"); # true\n\n#Print(Eigenvalues(Cyclotomics, b), \"\\n\"); # fail\n\n\n#Print(a*a, \"\\n\");\n#Print(a*a*a, \"\\n\");\n#Print(a*a*a*a, \"\\n\");\n\n# Print(Order(G2));\n\nHadamard8 := (1/2)*[\n [ 0, 1, 0,-1, 0, 1, 0,-1],\n [ 1, 0, 1, 0, 1, 0, 1, 0],\n [ 0, 1, 0, 1, 0, 1, 0, 1],\n [-1, 0, 1, 0,-1, 0, 1, 0],\n [ 0, 1, 0,-1, 0,-1, 0, 1],\n [ 1, 0, 1, 0,-1, 0,-1, 0],\n [ 0, 1, 0, 1, 0,-1, 0,-1],\n [-1, 0, 1, 0, 1, 0,-1, 0]];\n\n#Print(Hadamard8, \"\\n\");\n#Print(Hadamard8*Hadamard8, \"\\n\"); # = identity\n\n\nU2 := [ \n [1, 0, 0, 0],\n [0, 1, 0, 0],\n [0, 0, 1, 0],\n [0, 0, 0, 1]];\n\n\n\nin_third_level_2 := function(U2)\n # Is U2 in the third level of the clifford hierarchy ?\n local A;\n for g in Pauli2 do\n A := U2*g*Inverse(U2)*Inverse(g);\n if A in Cliff2 then continue; fi;\n return false; # no\n od;\n return true; # yes\nend;;\n\nin_fourth_level_2 := function(U2)\n # Is U2 in the fourth level of the clifford hierarchy ?\n local A;\n for g in Pauli2 do\n A := U2*g*Inverse(U2)*Inverse(g);\n if in_third_level_2(U2) then continue; fi;\n return false; # no\n od;\n return true; # yes\nend;;\n\nin_fifth_level_2 := function(U2)\n # Is U2 in the fifth level of the clifford hierarchy ?\n local A;\n for g in Pauli2 do\n A := U2*g*Inverse(U2)*Inverse(g);\n if in_fourth_level_2(U2) then continue; fi;\n return false; # no\n od;\n return true; # yes\nend;;\n\nget_level_2 := function(U2)\n if U2 in Phase2 then return \"0\\c\"; fi;\n if U2 in Pauli2 then return \"1\\c\"; fi;\n if U2 in Cliff2 then return \"2\\c\"; fi;\n if in_third_level_2(U2) then return \"3\\c\"; fi;\n if in_fourth_level_2(U2) then return \"4\\c\"; fi;\n if in_fifth_level_2(U2) then return \"5\\c\"; fi;\n return \".\\c\";\nend;;\n\n\nif true then\n Print(\"# Where do control 1-qubit Pauli gates live ?\\n\");\n for g in Pauli1 do \n #Print(g, \"\\n\");\n U2{[3,4]}{[3,4]} := g;\n Print(get_level_2(U2));\n od;\n Print(\"\\n\");\n \n Print(\"# Where do control 1-qubit clifford gates live ?\\n\");\n for g in Cliff1 do \n #Print(g, \"\\n\");\n U2{[3,4]}{[3,4]} := g;\n Print(get_level_2(U2));\n od;\n Print(\"\\n\");\nfi;\n\n\n\n# ---------------------------------------------------\n#\n# 3 qubit gates\n#\n\n\nxii := KroneckerProduct(xi, i);;\nixi := KroneckerProduct(i, xi);;\niix := KroneckerProduct(i, ix);;\n\nzii := KroneckerProduct(zi, i);;\nizi := KroneckerProduct(i, zi);;\niiz := KroneckerProduct(i, iz);;\n\nsii := KroneckerProduct(si, i);;\nisi := KroneckerProduct(i, si);;\niis := KroneckerProduct(i, is);;\n\nhii := KroneckerProduct(hi, i);;\nihi := KroneckerProduct(i, hi);;\niih := KroneckerProduct(i, ih);;\n\nwii := KroneckerProduct(wi, i);;\n\nicz := KroneckerProduct(i, cz);;\nczi := KroneckerProduct(cz, i);;\n\nca := [\n [1, 0, 0, 0, 0, 0, 0, 0],\n [0, 1, 0, 0, 0, 0, 0, 0],\n [0, 0, 1, 0, 0, 0, 0, 0],\n [0, 0, 0, 1, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 1, 0,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, 0, 1, 0, 0, 0, 0, 0],\n [0, 0, 0, 1, 0, 0, 0, 0],\n [0, 0, 0, 0, 1, 0, 0, 0],\n [0, 0, 0, 0, 0, 1, 0, 0],\n [0, 0, 0, 0, 0, 0, 0, 1],\n [0, 0, 0, 0, 0, 0, 1, 0]];;\n\n\nCliff3 := Group(sii, isi, iis, hii, ihi, iih, wii, icz, czi);; # Order 743178240\nPauli3 := Group(wii, xii, ixi, iix, zii, izi, iiz);; # Order 256\n\n# Print(Order(Pauli3), \"\\n\");;\n\n# ca in Cliff3 = false\n# ca in third level of clifford hierarchy = true\n\n\nCliff3_12 := Group(sii, isi, hii, ihi, wii, czi);;\nCliff3_13 := Group(sii, iis, hii, iih, wii);; # cz on 1&3 ??\nCliff3_23 := Group(isi, iis, ihi, iih, wii, icz);;\n\n#SmCliff3 := Group(sii, isi, iis, hii, ihi, iih, icz, czi);; # Order 743178240\n\nPrint(\"warming up...\\n\");\nOrder(Cliff3);; # need this line otherwise membership test eats all memory...!\nPrint(\"Ok\\n\");\n\n#Print(\"Hadamard8 in Cliff3 \", Hadamard8 in Cliff3, \"\\n\"); # true\n\nin_first_level := function(U3)\n return U3 in Pauli3;\nend;;\n\nin_second_level := function(U3)\n if U3 in Cliff3_12 then return true; fi;\n if U3 in Cliff3_13 then return true; fi;\n if U3 in Cliff3_23 then return true; fi;\n if U3 in Cliff3 then return true; fi;\n return false;\nend;;\n \n#in_second_level := function(U3)\n# # Is U3 in the second level of the clifford hierarchy ?\n# local A;\n# for g in Pauli3 do\n# A := U3*g*Inverse(U3)*Inverse(g);\n# if in_first_level(A) then continue; fi;\n# return false; # no\n# od;\n# return true; # yes\n#end;;\n\n\nin_third_level := function(U3)\n # Is U3 in the third level of the clifford hierarchy ?\n local A;\n for g in Pauli3 do\n A := U3*g*Inverse(U3)*Inverse(g);\n if in_second_level(A) then continue; fi;\n return false; # no\n od;\n return true; # yes\nend;;\n\n#Print(in_third_level(ca1), \"\\n\"); # true\n#quit;\n\nin_fourth_level := function(U3)\n # Is U3 in the fourth level of the clifford hierarchy ?\n local A;\n for g in Pauli3 do\n A := U3*g*Inverse(U3)*Inverse(g);\n if in_third_level(A) then continue; fi;\n return false; # no\n od;\n return true; # yes\nend;;\n\n\nin_fifth_level := function(U3)\n # Is U3 in the fifth level of the clifford hierarchy ?\n local A;\n for g in Pauli3 do\n A := U3*g*Inverse(U3)*Inverse(g);\n if in_fourth_level(A) then continue; fi;\n return false; # no\n od;\n return true; # yes\nend;;\n\n\nget_level := function(U3)\n if U3 in Pauli3 then return \"1\\c\"; fi;\n if in_second_level(U3) then return \"2\\c\"; fi;\n if in_third_level(U3) then return \"3\\c\"; fi;\n if in_fourth_level(U3) then return \"4\\c\"; fi;\n if in_first_level(U3) then return \"5\\c\"; fi;\n return \".\\c\";\nend;;\n \n\n#Print(\"in_third_level(d):\", in_third_level(cc), \"\\n\"); # true\n#Print(\"in_third_level(ca):\", in_third_level(ca), \"\\n\"); # true\n#Print(\"in_third_level(cb):\", in_third_level(cb), \"\\n\"); # true\n#Print(\"in_third_level(cc):\", in_third_level(cc), \"\\n\"); # true\n#Print(\"in_third_level(Tofolli):\", in_third_level(Tofolli), \"\\n\"); # true\n#Print(\"in_third_level(Tofolli*ca):\", in_third_level(Tofolli*ca), \"\\n\"); # false\n\nU3 := [ \n [1, 0, 0, 0, 0, 0, 0, 0],\n [0, 1, 0, 0, 0, 0, 0, 0],\n [0, 0, 1, 0, 0, 0, 0, 0],\n [0, 0, 0, 1, 0, 0, 0, 0],\n [0, 0, 0, 0, 1, 0, 0, 0],\n [0, 0, 0, 0, 0, 1, 0, 0],\n [0, 0, 0, 0, 0, 0, 1, 0],\n [0, 0, 0, 0, 0, 0, 0, 1]];\n\nPrint(\"# Where do control control 1-qubit Pauli gates live ?\\n\");\nfor g in Pauli1 do \n #Print(g, \"\\n\");\n U3{[7,8]}{[7,8]} := g;\n Print(get_level(U3));\nod;\nPrint(\"\\n\");\n\nPrint(\"# Where do control control 1-qubit clifford gates live ?\\n\");\nfor g in Cliff1 do \n #Print(g, \"\\n\");\n U3{[7,8]}{[7,8]} := g;\n Print(get_level(U3));\nod;\nPrint(\"\\n\");\n\nPrint(\"# Where do control 2-qubit Pauli gates live ?\\n\");\nfor g in Pauli2 do \n #Print(g, \"\\n\");\n U3{[5,6,7,8]}{[5,6,7,8]} := g;\n Print(get_level(U3));\nod;\nPrint(\"\\n\");\n\nPrint(\"# Where do control 2-qubit clifford gates live ?\\n\");\nfor g in Cliff2 do \n #Print(g, \"\\n\");\n U3{[5,6,7,8]}{[5,6,7,8]} := g;\n Print(get_level(U3));\nod;\n\nPrint(\"\\n\");\n\nPrint(\"Done.\\n\");\n\n\n", "meta": {"hexsha": "e0bcefcdad70b2bb885de684db53775c90151971", "size": 11364, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "bruhat/dev/hierarchy.gap", "max_stars_repo_name": "punkdit/bruhat", "max_stars_repo_head_hexsha": "3231eacc49fd3464542f7eb72684751371d9876c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T13:21:30.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-15T02:07:20.000Z", "max_issues_repo_path": "bruhat/dev/hierarchy.gap", "max_issues_repo_name": "punkdit/bruhat", "max_issues_repo_head_hexsha": "3231eacc49fd3464542f7eb72684751371d9876c", "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": "bruhat/dev/hierarchy.gap", "max_forks_repo_name": "punkdit/bruhat", "max_forks_repo_head_hexsha": "3231eacc49fd3464542f7eb72684751371d9876c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1973392461, "max_line_length": 103, "alphanum_fraction": 0.508623724, "num_tokens": 5087, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.5156199157230157, "lm_q1q2_score": 0.38924920190672796}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#\n# Functions\n#\nIsASPFreqBasis := x -> IsRec(x) and IsBound(x.isASPFreqBasis) and x.isASPFreqBasis;\nIsASPTimeBasis := x -> IsRec(x) and IsBound(x.isASPTimeBasis) and x.isASPTimeBasis;\n\nClass(BasisOps, PrintOps, rec(\n \\= := (b1, b2) -> Cond(\n not IsASPFreqBasis(b1) or not IsASPFreqBasis(b2), false,\n ObjId(b1)=ObjId(b2) and b1.rChildren() = b2.rChildren())\n));\n\n#\n# Base classes\n#\nClass(ASPTimeBasis, rec(\n isAtomic := true, # NOTE: these probably should not be atomic, maybe use TimeComp(Freq_E) for composed bases\n isASPTimeBasis := true,\n doNormalize := false,\n operations := PrintOps,\n print := self >> Print(self.__name__, When(self.doNormalize, \".norm()\")),\n norm := self >> CopyFields(self, rec(doNormalize:=true)),\n rChildren := self >> [],\n from_rChildren := (self, rch) >> self,\n unparse := \"ConstClass\",\n)); \n\nClass(ASPComposedTimeBasis, ASPTimeBasis, rec(\n composedFrom := self >> Error(\"must be defined in the subclass\"),\n toX := (self, alg) >> Checked(ObjId(alg) = XN_skew, IsEvenInt(alg.n), \n let(C := When(self.doNormalize, self.composedFrom().norm(), \n self.composedFrom()),\n Tensor(C.to1X(XN_skew(2, alg.a, alg.rot)), I(alg.n/2))))\n));\n\nClass(ASPFreqBasis, rec(\n doNormalize := false,\n isASPFreqBasis := true,\n dim := self >> Error(\"must be defined in the subclass\"),\n from_rChildren := (self, rch) >> ApplyFunc(ObjId(self), rch),\n unparse := \"RewritableObjectExp\",\n));\n\nClass(ASPFreqBasis1d, ASPFreqBasis, rec(\n __call__ := (self, scale1d) >> WithBases(self, rec(\n scale1d := scale1d, operations := BasisOps\n )),\n rChildren := self >> [self.scale1d],\n rSetChild := rSetChildFields(\"scale1d\"),\n print := self >> Print(self.name, \"(\", self.scale1d, \")\", When(self.doNormalize, \".norm()\")),\n dim := self >> 1,\n hashAs := self >> ObjId(self)(1)\n)); \n\nClass(ASPFreqBasis1d2d, ASPFreqBasis, rec(\n __call__ := (self, scale1d, scale2d) >> WithBases(self, rec(\n scale1d := scale1d, scale2d := scale2d, operations := BasisOps\n )),\n rChildren := self >> [self.scale1d, self.scale2d],\n rSetChild := rSetChildFields(\"scale1d\", \"scale2d\"),\n print := self >> Print(self.name, \"(\", self.scale1d, \", \", self.scale2d, \")\",\n When(self.doNormalize, \".norm()\")),\n\n norm := self >> CopyFields(self, rec(doNormalize:=true)),\n\n dim := self >> 2,\n hashAs := self >> ObjId(self)(1, 1),\n\n to1X_2d0 := (self, rot) >> I(2),\n to1X_2d := (self, a, rot) >> Error(\"Must be implemented in a subclass\"),\n to1X := (self, alg) >> let(t := ObjId(alg), s1 := self.scale1d, s2 := self.scale2d, Cond(\n alg.n=1, 1/s1 * I(1),\n\n alg.n=2 and (t in [XN_min_1, XN_min_1U]),\n 1/s2 * self.to1X_2d0(alg.rot),\n\n alg.n=2 and (t in [XN_skew, XN_plus_1]), let(\n a := alg.a, #EvalScalar(alg.a),\n aa := Cond(self.doNormalize, cond(gt(a, 0.5), 1-a, a), a), #Cond(self.doNormalize and a > 1/2, 1-a, a), \n 1/s2 * self.to1X_2d(aa, alg.rot)),\n\n Error(\"Algebra <alg> must have dimension of 1 or 2\"))),\n\n\n from1X_2d0 := (self, rot) >> I(2),\n from1X_2d := (self, a, rot) >> Mat(MatSPL(self.to1X_2d(a, rot))^-1), \n from1X := (self, alg) >> let(t := ObjId(alg), s1 := self.scale1d, s2 := self.scale2d, Cond(\n alg.n=1, s1 * I(1),\n\n alg.n=2 and (t in [XN_min_1, XN_min_1U]),\n s2 * self.from1X_2d0(alg.rot),\n\n alg.n=2 and (t in [XN_skew, XN_plus_1]), let(\n a := alg.a, #EvalScalar(alg.a),\n aa := Cond(self.doNormalize, cond(gt(a, 0.5), 1-a, a), a), \n s2 * self.from1X_2d(aa, alg.rot)),\n\n Error(\"Algebra <alg> must have dimension of 1 or 2\"))),\n)); \n\n#\n# TIME BASIS Classes\n#\nDeclare(Freq_1, Freq_1H, Freq_T, Freq_S, Freq_TH, Freq_THU, Freq_E, Freq_EH, Freq_H, Freq_HH);\n\nDeclare(Time_TX, Time_SX, Time_THX, Time_THUX, Time_EX, Time_EHX, Time_HX, Time_HHX);\n\n# ASP time basis: standard \"time\" basis (1, x, ..., x^{n-1}) \nClass(Time_TX, ASPTimeBasis, rec(\n toX := (self, alg) >> I(alg.n)\n));\n\n# ASP time basis: symmetric \"time\" basis (-x^{n/2}, ..., 1, x, ..., x^{n/2-1}) \nClass(Time_SX, ASPTimeBasis, rec(\n toX := (self, alg) >> let(t := ObjId(alg), hf := Int(alg.n/2), \n Cond(t in [XN_min_1, XN_min_1U], \n Z(alg.n, hf),\n t = XN_plus_1 or (t = XN_skew and alg.a = 1/4),\n DirectSum(I(Int((alg.n+1)/2)), -I(hf)) * Z(alg.n, hf),\n t = XN_skew, \n Tensor(Freq_S(1,1).to1X(XN_skew(2, alg.a, alg.rot)), I(alg.n/2)), \n Error(\"Unrecognized algebra <alg>\")))\n)); \n\nClass(Time_THX, ASPComposedTimeBasis, rec(composedFrom := self >> Freq_TH(1,1)));\nClass(Time_THUX, ASPComposedTimeBasis, rec(composedFrom := self >> Freq_THU(1,1)));\nClass(Time_EX, ASPComposedTimeBasis, rec(composedFrom := self >> Freq_E(1,1))); # e_a(x^n) (*) t_n\nClass(Time_EHX, ASPComposedTimeBasis, rec(composedFrom := self >> Freq_EH(1,1)));\nClass(Time_HX, ASPComposedTimeBasis, rec(composedFrom := self >> Freq_H(1,1))); # h_a(x^n) (*) t_n\nClass(Time_HHX, ASPComposedTimeBasis, rec(composedFrom := self >> Freq_HH(1,1)));\n\n\n#\n# FREQUENCY BASIS Classes\n#\n\n# ASP frequency basis: (1)\nClass(Freq_1, ASPFreqBasis1d, rec(\n timeBasis := self >> Time_TX\n));\n\nClass(Freq_1H, ASPFreqBasis1d, rec(\n timeBasis := self >> Error(\"not implemented\"),\n to1X := (self, alg) >> Error(\"not implemented\"),\n));\n\n# ASP frequency basis: (1, x), also implies 2d spectral components, ie real DFT\nClass(Freq_T, ASPFreqBasis1d2d, rec(\n timeBasis := self >> Time_TX,\n to1X := (self, alg) >> let(t := ObjId(alg), s1 := self.scale1d, s2 := self.scale2d, Cond(\n alg.n = 2, 1/s2 * I(2),\n alg.n = 1, 1/s1 * I(1),\n Error(\"Algebra <alg> must have dimension of 1 or 2\"))),\n from1X := (self, alg) >> let(t := ObjId(alg), s1 := self.scale1d, s2 := self.scale2d, Cond(\n alg.n = 2, s2 * I(2),\n alg.n = 1, s1 * I(1),\n Error(\"Algebra <alg> must have dimension of 1 or 2\"))),\n));\n\n# ASP frequency basis: (x^-1, 1), also implies 2d spectral components, ie real DFT\nClass(Freq_S, ASPFreqBasis1d2d, rec(\n timeBasis := self >> Time_SX,\n to1X_2d0 := (self, rot) >> J(2), \n to1X_2d := (self, a, rot) >> Mat(_stripval([[ 2*cospi(2*a*rot), 1], \n [ -1 , 0]])),\n));\n\n# ASP frequency basis: (x^1/2, x^3/2) for type 2--4 transforms, also implies 2d spectral components, ie real DFT\nClass(Freq_TH, ASPFreqBasis1d2d, rec(\n timeBasis := self >> Time_THX,\n to1X_2d := (self, a, rot) >> let(c := cospi(2*a*rot), q := 1/(2*cospi(a*rot)), \n Mat(_stripval(q * [[1+2*c, 1],\n [-1, 1]])))\n));\n\nClass(Freq_THU, ASPFreqBasis1d2d, rec(\n timeBasis := self >> Time_THUX,\n to1X_2d := (self, a, rot) >> let(c := cospi(2*a*rot), q := 1/(2*cospi(a * rot)), \n Mat(_stripval(q^2 * [[1+2*c, 1],\n [-1, 1]])))\n));\n\n# ASP frequency basis: (1, (x-cos(a)) / sin(a)), also implies 2d spectral components, ie real DFT\nClass(Freq_E, ASPFreqBasis1d2d, rec(\n timeBasis := self >> Time_EX,\n to1X_2d := (self, a, rot) >> let(c := cospi(2*rot*a), s := sinpi(2*rot*a), \n Mat(_stripval([[1, -c/s], \n [0, 1/s]]))),\n from1X_2d := (self, a, rot) >> let(c := cospi(2*rot*a), s := sinpi(2*rot*a), \n Mat(_stripval([[1, c], \n [0, s]])))\n));\n\nClass(Freq_EH, ASPFreqBasis1d2d, rec(\n timeBasis := self >> Time_EX,\n to1X_2d := (self, a, rot) >> let(c := r->cospi(r*2*rot*a), s := r->sinpi(r*2*rot*a), \n Mat(_stripval(1/s(1) * [[ s(3/2), -c(3/2)], \n [-s(1/2), c(1/2)]])))\n));\n\n# ASP frequency basis: (1 + (x-cos(a)) / sin(a), 1 - (x-cos(a))/sin(a)), ie Hartley transform\nClass(Freq_H, ASPFreqBasis1d2d, rec(\n timeBasis := self >> Time_HX,\n to1X_2d := (self, a, rot) >> let(c := cospi(2*rot*a), s := sinpi(2*rot*a), \n Mat(_stripval(1/2 * [[1-c/s, 1+c/s], \n [ 1/s, -1/s]])))\n));\n\nClass(Freq_HH, ASPFreqBasis1d2d, rec(\n timeBasis := self >> Time_EX,\n to1X_2d := (self, a, rot) >> let(s := sinpi(2*rot*a), \n cas := r -> cospi(r*2*rot*a)+sinpi(r*2*rot*a), cms := r -> cospi(r*2*rot*a)-sinpi(r*2*rot*a),\n Mat(_stripval(1/(2*s) * [[-cms(3/2), -cas(3/2)], \n [ cms(1/2), cas(1/2)]])))\n));\n\n", "meta": {"hexsha": "892da53499a8b10f99c98d424c8f374f6933bc62", "size": 8587, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sym/asp_basis.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_basis.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_basis.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.6801801802, "max_line_length": 116, "alphanum_fraction": 0.5596832421, "num_tokens": 3061, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.3882601057423013}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F ==========================================================================\n#F Diag(<diag-func>)\n#F ==========================================================================\nClass(Diag, BaseMat, rec(\n _short_print := true,\n abbrevs := [ arg -> When(Length(arg)=1,\n When(IsFunction(arg[1]) or IsFuncExp(arg[1]) or (IsRec(arg[1]) and not IsScalar(arg[1])) or IsList(arg[1]), [arg[1]], [[arg[1]]]),\n [Flat(arg)]) ],\n\n new := meth(self, L)\n if IsList(L) then \n L := List(L, toExpArg); \n L := FList(UnifyTypes(List(L, x->x.t)), L);\n elif not IsRec(L) or not IsBound(L.lambda) then\n Error(\"List of numbers or LambdaList expected\");\n fi;\n return SPL(WithBases(self, rec(element := L, TType := L.range()))).setDims();\n end,\n #-----------------------------------------------------------------------\n dims := self >> Replicate(2, self.element.domain()),\n #-----------------------------------------------------------------------\n isPermutation := self >> false,\n #-----------------------------------------------------------------------\n isReal := self >> let(\n\tt := self.element.range(), \n tt := Cond(IsVecT(t), t.t, t),\n\ttt <> TComplex and ObjId(tt)<>T_Complex),\n #-----------------------------------------------------------------------\n toAMat := self >> DiagonalAMat(List(EvalScalar(self.element.tolist()), EvalScalar)),\n #-----------------------------------------------------------------------\n transpose := self >> self,\n conjTranspose := self >> Diag(FConj(self.element)),\n inverse := self >> Diag(FInv(self.element)),\n #-----------------------------------------------------------------------\n normalizedArithCost := self >> 0,\n #-----------------------------------------------------------------------\n arithmeticCost := (self, costMul, costAddMul) >> Sum(self.element.tolist(), costMul),\n #-----------------------------------------------------------------------\n toloop := (self, bksize) >> let(\n\tj := Ind(self.element.domain()),\n\tISum(j, \n\t Scat(fTensor(fBase(j), fId(1))) *\n\t Diag(fCompose(self.element, fTensor(fBase(j), fId(1)))) *\n\t Gath(fTensor(fBase(j), fId(1)))\n\t).split(bksize)\n )\n\n));\n\n\n#F ==========================================================================\n#F DiagCpxSplit(<diag-func>) - complex diagonal specified in split format \n#F NOTE: maybe this should be somehow replaced by VRCDiag (?)\n#F this object is helpful for complex code, because it improves performance\n# when using SSE\n#F ==========================================================================\nClass(DiagCpxSplit, Diag, rec(\n #-----------------------------------------------------------------------\n dims := self >> Replicate(2, div(self.element.domain(), 2)),\n #-----------------------------------------------------------------------\n isReal := self >> false, \n #-----------------------------------------------------------------------\n toAMat := meth(self)\n local lst, i, cpxlst;\n lst := List(EvalScalar(self.element.tolist()), EvalScalar);\n cpxlst := [];\n for i in [0..Length(lst)/2-1] do\n Add(cpxlst, lst[2*i+1]+E(4)*lst[2*i+2]);\n od;\n return DiagonalAMat(cpxlst);\n end,\n #-----------------------------------------------------------------------\n transpose := self >> self,\n conjTranspose := self >> ObjId(self)(FRConj(self.element)),\n #-----------------------------------------------------------------------\n normalizedArithCost := self >> 0,\n #-----------------------------------------------------------------------\n #arithmeticCost := (self, costMul, costAddMul) >> Sum(self.element.tolist(), costMul)\n));\n\nDeclare(RowVec, ColVec);\n\nClass(RowVec, Diag, rec(\n dims := self >> [1, self.element.domain()],\n toAMat := self >> AMatMat([List(self.element.tolist(), EvalScalar)]),\n transpose := self >> ColVec(self.element),\n conjTranspose := self >> ColVec(FConj(self.element)),\n arithmeticCost := (self, costMul, costAddMul) >> Sum(self.element.tolist(), costAddMul),\n\n toBlk := self >> Checked(not IsSymbolic(self.element.domain()), Blk([self.element.tolist()])),\n toDiagBlk := self >> Checked(not IsSymbolic(self.element.domain()), \n\tBlk([Replicate(EvalScalar(self.element.domain()), 1)]) * Diag(self.element)),\n));\n\nClass(ColVec, Diag, rec(\n dims := self >> [self.element.domain(), 1],\n toAMat := self >> AMatMat(TransposedMat([List(self.element.tolist(), EvalScalar)])),\n transpose := self >> RowVec(self.element),\n conjTranspose := self >> RowVec(FConj(self.element)),\n\n toBlk := self >> self.transpose().toBlk().transpose(),\n toDiagBlk := self >> self.transpose().toDiagBlk().transpose(),\n));\n\nDeclare(RCDiag);\n\n#F RCDiagonalAMat(<elts>, <post>)\n#F\n#F Works similarly to RCDiag, but creates an AMat object instead of SPL.\n#F See Doc(RCDiag).\n#F\n#F <elts> must be a list of size 2*n, which consists of interleaved real/imaginary data. \n#F (not a symbolic function as in RCDiag)\n#F\n#F <post> must be an <amat>, and not spl\n#F\nRCDiagonalAMat := (elts, post) -> \n DirectSumAMat(List([1..Length(elts)/2], x -> \n let(r := EvalScalar(elts[2*x-1]), i := EvalScalar(elts[2*x]),\n post * AMatMat([[r,-i],[i,r]]))));\n\n#F RCDiag(<diagfunc>)\n#F RCDiag(<diagfunc>, <2x2 spl>)\n#F\n#F Complex diagonal operating on real data in (r,i) format.\n#F Represents a block diagonal with 2x2 blocks (complex rotations),\n#F with post-processing matrix <post-spl> applied to each block.\n#F\n#F For n complex numbers, <diagfunc> must be a diagonal function of size 2*n,\n#F which consists of interleaved real/imaginary data. \n#F\n#F Example: RCDiag(RCData(Tw1(8,4,1)) normal twiddle diagonal\n#F RCDiag(RCData(Tw1(8,4,1)), 1/2*F(2)) twiddles for Hartley transform\n#F\nClass(RCDiag, BaseMat, rec(\n dims := self >> Replicate(2, self.element.domain()),\n area := self >> 2*self.element.domain(),\n transpose := self >> RCDiag(FRConj(self.element), self.post),\n\n conjTranspose := self >> Cond(self.element.range()=TComplex,\n RCDiag(FRConj(FConj(self.element)), self.post),\n RCDiag(FRConj(self.element), self.post)),\n\n toAMat := self >> let(elts := self.element.tolist(), # r,i,r,i,...\n Checked(Length(elts) mod 2 = 0,\n DirectSumAMat(List([1..Length(elts)/2], x -> \n let(r := EvalScalar(elts[2*x-1]), i := EvalScalar(elts[2*x]),\n self.post.toAMat() * AMatMat([[r,-i],[i,r]])))))),\n\n toloop := self >> let(\n func := self.element, # r,i,r,i,...\n j := Ind(idiv(func.domain(),2)),\n re := func.at(2*j),\n im := func.at(2*j+1),\n IDirSum(j, j.range,\n self.post * Mat([[re, -im],\n [im, re]]))),\n\n abbrevs := [\n () -> Error(\"Usage: \\n RCDiag(<diagfunc>, <2x2 spl>)\\n\",\n \" RCDiag(<diagfunc>)\\n\",\n \" RCDiag(<e0>, <e1>, ...)\\n\"),\n (L) -> Checked(IsList(L) or IsFunction(L), [L, I(2)]),\n (L, P) -> Checked(IsList(L) or IsFunction(L), IsSPL(P), [L, P])\n ],\n\n new := meth(self, L, P)\n local inline, res;\n if IsList(L) then L := FList(L);\n elif not IsRec(L) or not IsBound(L.lambda) then\n Error(\"List of numbers or LambdaList expected\");\n fi;\n res := SPL(WithBases(self, rec(element := L, post := P, TType := L.range())));\n res.dimensions := res.dims();\n return res;\n end,\n\n isReal := self >> self.element.range() <> TComplex and self.post.isReal(),\n rChildren := self >> [self.element, self.post],\n rSetChild := rSetChildFields(\"element\", \"post\"),\n\n normalizedArithCost := self >> 0,\n));\n\n# Won't work for now because divisions by zero need to be handled.\n# Declare(RCDiagLiftingSteps);\n#\n# #F RCDiagLiftingSteps(<diagfunc>)\n# #F RCDiagLiftingSteps(<diagfunc>, <2x2 spl>)\n# #F\n# #F Complex diagonal operating on real data in (r,i) format.\n# #F Represents a block diagonal with 2x2 blocks (complex rotations),\n# #F with post-processing matrix <post-spl> applied to each block.\n# #F\n# #F Example: RCDiagLiftingSteps(T(8,4)) normal twiddle diagonal\n# #F RCDiagLiftingSteps(T(8,4), 1/2*F(2)) twiddles for Hartley transform\n# #F\n#\n# Class(RCDiagLiftingSteps, BaseMat, rec(\n# dims := self >> Replicate(2, self.element.domain()),\n#\n# transpose := self >> RCDiagLiftingSteps(FRConj(self.element), self.post),\n# conjTranspose := self >> self.transpose(),\n#\n# toAMat := self >> let(elts := self.element.tolist(), # r,i,r,i,...\n# Checked(Length(elts) mod 2 = 0,\n# DirectSumAMat(List([1..Length(elts)/2],\n# x -> let(r := EvalScalar(elts[2*x-1]), i := EvalScalar(elts[2*x]),\n# self.post.toAMat() * AMatMat([[r,-i],[i,r]])))))),\n#\n# abbrevs := [\n# () -> Error(\"Usage: \\n RCDiagLiftingSteps(<diagfunc>, <2x2 spl>)\\n\",\n# \" RCDiagLiftingSteps(<diagfunc>)\\n\",\n# \" RCDiagLiftingSteps(<e0>, <e1>, ...)\\n\"),\n# (L) -> Checked(IsList(L) or IsFunction(L), [L, I(2)]),\n# (L, P) -> Checked(IsList(L) or IsFunction(L), IsSPL(P), [L, P])\n# ],\n#\n# new := meth(self, L, P)\n# local inline, res;\n# if IsList(L) then L := FList(L);\n# elif not IsRec(L) or not IsBound(L.lambda) then\n# Error(\"List of numbers or LambdaList expected\");\n# fi;\n# inline := IsBound(L.inline) and L.inline;\n# res := SPL(WithBases(self, rec(element := L, post := P, inline := inline)));\n# res.dimensions := res.dims();\n# return res;\n# end,\n#\n# isReal := True,\n# rChildren := self >> [self.element, self.post],\n# rSetChild := rSetChildFields(\"element\", \"post\"),\n# print := (self, i, is) >> Print(self.name, \"(\", self.element,\n# When(ObjId(self.post)<>I, Print(\", \", self.post)), \")\")\n# ));\n", "meta": {"hexsha": "3778a0fef59077b9b1dac28cbed7df15d7f7c3a3", "size": 10031, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/Diag.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/Diag.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/Diag.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.4504132231, "max_line_length": 155, "alphanum_fraction": 0.5073272854, "num_tokens": 2691, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.3862752578521707}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n#F HashIndex and HashEqual Functions\n#F ---------------------------------\n#F\n\n#F HashLookup( hashTable, key )\n#F returns the data associated with key in hashTable.\n#F returns false if key is not found in hashTable.\n#F\nHashLookup := function( hashTable, key )\n local index, entry, pos, chash, temp;\n\n if not IsHashTable( hashTable ) then\n Error( \"<hashTable> is not a valid HashTable\" );\n fi;\n\n index := hashTable.indexFun( key, hashTable.size );\n\n if not ( index > 0 and index <= hashTable.size ) then\n Error( \"Did not obtain a valid hash index for key\" );\n fi;\n\n if IsBound( hashTable.entries[index] ) then\n entry := hashTable.entries[index];\n pos := PositionProperty( entry, a -> hashTable.equalFun(a.key, key) );\n\n if pos = false then\n\t return false;\n else\n # # catch the case of hash-identical but not identical spls\n# elif IsSPL(key) and not IsIdenticalSPL(entry[pos].key, key) then\n# chash := Copy(entry[pos].data); \n# if(IsList(chash)) then\n# for index in [1..Length(chash)] do\n# chash[index].ruletree := \n# \t\t # NOTE:\n# spiral.formgen.ApplyRuleTreeSPL(entry[pos].data[index].ruletree, key);\n# od;\n# else\n# \t\t# NOTE:\n# chash.ruletree := \n# spiral.formgen.ApplyRuleTreeSPL(entry[pos].data.ruletree, key);\n# fi; \n# return chash;\n# else\n return entry[pos].data;\n fi;\n else\n return false;\n fi;\nend;\n\nMultiHashLookup := function(hashes, key)\n local h, lkup;\n for h in hashes do\n lkup := HashLookup(h, key);\n\tif lkup<>false then return lkup; fi;\n od;\n return false;\nend;\n\nDeclare(HashIndexSPLRec);\n\nHashIndexParams := function(param, index)\n local p;\n # hash symbolic Value(type, val) simply as <val>\n if IsValue(param) then param := param.v; fi;\n\n if IsFFE(param) then\n index := index + 1 + When(param <> GF(2).zero, 0, 1);\n elif IsInt(param) then\n\t index := index * (param+1);\n elif IsString(param) then\n\t index := index * (Length(param)+1);\n \n elif IsFloat(param) then\n\t index := index + 1; \n elif IsRat(param) then\n\t index := index + 1; \n elif IsFloat(param) then\n\t index := index + 1; \n ## NOTE: How to handle bools???\n elif IsBool(param) then\n\t index := index * When(param, 2,3); \n\n elif IsCyc(param) then\n\t index := index + 1;\n elif IsList(param) then\n\t for p in param do \n\t index := HashIndexParams(p, index);\n\t od;\n elif IsMat(param) then\n\t index := index * Product(DimensionsMat(param));\n elif IsPolynomial(param) then\n\t index := index * LaurentDegree(param);\n\n # MP: now we have transforms as parameter and thus need to handle this case\n # by calling the function recursively \n elif IsSPL(param) then\n\t index := index + HashIndexSPLRec(param);\n\n elif IsClass(ObjId(param)) then\n index := index + BagAddr(ObjId(param));\n fi;\n return index;\nend;\n\n#F HashIndexSPLRec( <spl> )\n#F Does the actual dirty work for HashIndexSPL recursively\n#F Do not call directly\n#F\n\nHashIndexSPLRec := function( spl )\n local type, index, param, params;\n\n if not IsSPL(spl) then\n Error( \"<spl> must be a valid SPL\" );\n fi;\n\n if IsNonTerminal(spl) and IsBound(spl.params) then\n index := BagAddr(ObjId(spl));\n params := When(IsBound(spl.HashId), spl.HashId(), spl.params);\n if IsInt( params ) then\n\t index := index * (params+1);\n else \n\t params := When(not IsList(params), [params], params);\n\t for param in params do\n\t index := HashIndexParams(param, index);\n\t od;\n fi;\n elif IsBound(spl.children) then\n index := Product( spl.children(), a->HashIndexSPLRec(a) );\n elif IsBound(spl.element) and IsList(spl.element) then\n index := Length(spl.element);\n else\n index := BagAddr(ObjId(spl));\n fi;\n\n return index;\nend;\n\n\n#F HashIndexSPL( <spl>, <hashSize> )\n#F one possible method of returning a hash index (probably not that good).\n#F takes a SPL and returns a hash index.\n#F\nHashIndexSPL := function( spl, hashSize )\n if not IsSPL(spl) then\n Error( \"<spl> must be a valid SPL\" );\n fi;\n\n if IsBound(spl.hashIndex) then\n return ( (spl.hashIndex mod hashSize) + 1 );\n fi;\n\n spl.hashIndex := HashIndexSPLRec(spl);\n return ( (spl.hashIndex mod hashSize) + 1 );\nend;\n\n\n#F HashIndexRuleTree( <ruletree>, <hashSize> )\n#F one possible method of returning a hash index (probably not that good).\n#F takes a RuleTree and returns a hash index.\n#F\n\nHashIndexRuleTree := function( tree, hashSize )\n local index,\n child;\n\n index := BagAddr(tree.rule);\n if tree.transposed then\n index := index*3;\n else\n index := index*7;\n fi;\n if IsBound(tree.splOptions) and tree.splOptions=\"unrolled\" then\n index := index*11;\n else\n index := index*13;\n fi;\n index := ((index+1) * (HashIndexSPL(tree.node, hashSize)+1))\n mod hashSize;\n for child in tree.children do\n index := ((index+1) * (HashIndexRuleTree(child, hashSize)+1))\n mod hashSize;\n od;\n return index+1;\nend;\n\n\n#F HashTableSPL() - create hashtable with SPLs as keys\nHashTableSPL := function()\n return HashTable( HashIndexSPL, IsHashIdenticalSPL, \"HashTableSPL()\" );\nend;\n", "meta": {"hexsha": "1f45d16f3817eac292f05a893da92a6f5aa2b7cb", "size": 5461, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/hashspl.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/hashspl.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/hashspl.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.4422110553, "max_line_length": 90, "alphanum_fraction": 0.6130745285, "num_tokens": 1520, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710234, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.3856603797970666}} | |
| {"text": "#############################################################################\n##\n#W utilsfrgrp.gi automgrp package Yevgen Muntyan\n## Dmytro Savchuk\n##\n#Y Copyright (C) 2003 - 2018 Yevgen Muntyan, Dmytro Savchuk\n##\n\n\n#############################################################################\n##\n## AG_InverseLessThanForLetters(<w1>, <w2>)\n##\n## Compares w1 and w2 according to lexicografic ordering given by\n## x1 < x1^-1 < x2 < x2^-1 < ...\n##\nBindGlobal(\"AG_InverseLessThanForLetters\",\nfunction(w1, w2)\n local i, er1, er2;\n\n if Length(w1) <> Length(w2) then\n return Length(w1) < Length(w2);\n fi;\n\n er1 := LetterRepAssocWord(w1);\n er2 := LetterRepAssocWord(w2);\n for i in [1..Length(er1)] do\n if AbsInt(er1[i]) <> AbsInt(er2[i]) then\n return AbsInt(er1[i]) < AbsInt(er2[i]);\n fi;\n if er1[i] <> er2[i] then\n return er1[i] > er2[i];\n fi;\n od;\n\n return false;\nend);\n\n\n#############################################################################\n##\n## AG_ReducedListOfWordsByNielsen(<words_list>)\n## AG_ReducedListOfWordsByNielsenBack(<words_list>)\n## AG_ReducedListOfWordsByNielsen(<words_list>, <string>)\n## AG_ReducedListOfWordsByNielsenBack(<words_list>, <string>)\n##\nInstallMethod(AG_ReducedListOfWordsByNielsen, [IsAssocWordCollection],\nfunction(words)\n return AG_ReducedListOfWordsByNielsen(words, \\<);\nend);\n\nInstallMethod(AG_ReducedListOfWordsByNielsenBack, [IsAssocWordCollection],\nfunction(words)\n return AG_ReducedListOfWordsByNielsen(words, \\<);\nend);\n\nInstallMethod(AG_ReducedListOfWordsByNielsen, [IsAssocWordCollection, IsString],\nfunction(words, string)\n return AG_ReducedListOfWordsByNielsen(words, AG_InverseLessThanForLetters);\nend);\n\nInstallMethod(AG_ReducedListOfWordsByNielsenBack, [IsAssocWordCollection, IsString],\nfunction(words, string)\n return AG_ReducedListOfWordsByNielsen(words, AG_InverseLessThanForLetters);\nend);\n\n\n#############################################################################\n##\n#M AG_ReducedListOfWordsByNielsen(<words_list>, <lt>)\n##\nInstallMethod( AG_ReducedListOfWordsByNielsen,\n [IsAssocWordCollection, IsFunction],\nfunction(words_list, lt)\n local result, transform, did_something, n, i, j, try_again, tmp;\n\n n := Length(words_list);\n result := ShallowCopy(words_list);\n transform := ShallowCopy(FreeGeneratorsOfFpGroup(FreeGroup(n)));\n did_something := false;\n try_again := true;\n\n for i in [1..n] do\n if not IsAssocWord(result[i]) then\n Print(\"error in AG_ReducedListOfWordsByNielsen(IsAssocWordCollection, IsFunction):\\n\");\n Print(\" \", i, \"-th element of list is not an associative word\\n\");\n return fail;\n fi;\n od;\n\n while try_again do\n try_again := false;\n\n for i in [1..n] do\n for j in [1..n] do\n\n if i = j then\n if lt(result[i]^-1, result[i]) then\n result[i] := result[i]^-1;\n transform[i] := transform[i]^-1;\n did_something := true;\n try_again := true;\n fi;\n continue;\n fi;\n\n if i > j and lt(result[i], result[j]) then\n tmp := result[i];\n result[i] := result[j];\n result[j] := tmp;\n tmp := transform[i];\n transform[i] := transform[j];\n transform[j] := tmp;\n did_something := true;\n try_again := true;\n fi;\n\n if lt(result[i]*result[j], result[i]) then\n result[i] := result[i]*result[j];\n transform[i] := transform[i]*transform[j];\n did_something := true;\n try_again := true;\n fi;\n if lt(result[i]*result[j], result[j]) then\n result[j] := result[i]*result[j];\n transform[j] := transform[i]*transform[j];\n did_something := true;\n try_again := true;\n fi;\n\n if lt(result[i]^-1*result[j], result[i]) then\n result[i] := result[i]^-1*result[j];\n transform[i] := transform[i]^-1*transform[j];\n did_something := true;\n try_again := true;\n fi;\n if lt(result[i]^-1*result[j], result[j]) then\n result[j] := result[i]^-1*result[j];\n transform[j] := transform[i]^-1*transform[j];\n did_something := true;\n try_again := true;\n fi;\n\n if lt(result[i]*result[j]^-1, result[i]) then\n result[i] := result[i]*result[j]^-1;\n transform[i] := transform[i]*transform[j]^-1;\n did_something := true;\n try_again := true;\n fi;\n if lt(result[i]*result[j]^-1, result[j]) then\n result[j] := result[i]*result[j]^-1;\n transform[j] := transform[i]*transform[j]^-1;\n did_something := true;\n try_again := true;\n fi;\n\n if lt(result[i]^-1*result[j]^-1, result[i]) then\n result[i] := result[i]^-1*result[j]^-1;\n transform[i] := transform[i]^-1*transform[j]^-1;\n did_something := true;\n try_again := true;\n fi;\n if lt(result[i]^-1*result[j]^-1, result[j]) then\n result[j] := result[i]^-1*result[j]^-1;\n transform[j] := transform[i]^-1*transform[j]^-1;\n did_something := true;\n try_again := true;\n fi;\n od;\n od;\n od;\n\n return [result, transform, did_something];\nend);\n\n\n#############################################################################\n##\n#M AG_ReducedListOfWordsByNielsenBack(<words_list>, <lt>)\n##\nInstallMethod(AG_ReducedListOfWordsByNielsenBack,\n [IsAssocWordCollection, IsFunction],\nfunction(words_list, lt)\n local result, transform, did_something, n, i, j, try_again, tmp;\n\n n := Length(words_list);\n result := ShallowCopy(words_list);\n transform := ShallowCopy(FreeGeneratorsOfFpGroup(FreeGroup(n)));\n did_something := false;\n try_again := true;\n\n for i in [1..n] do\n if not IsAssocWord(result[i]) then\n Print(\"error in AG_ReducedListOfWordsByNielsenBack(IsAssocWordCollection, IsFunction):\\n\");\n Print(\" \", i, \"-th element of list is not an associative word\\n\");\n return fail;\n fi;\n od;\n\n while try_again do\n try_again := false;\n\n for i in [1..n] do\n for j in [1..n] do\n\n if i = j then\n if lt(result[i]^-1, result[i]) then\n result[i] := result[i]^-1;\n transform[i] := transform[i]^-1;\n did_something := true;\n try_again := true;\n fi;\n continue;\n fi;\n\n if i > j and lt(result[i], result[j]) then\n tmp := result[i];\n result[i] := result[j];\n result[j] := tmp;\n tmp := transform[i];\n transform[i] := transform[j];\n transform[j] := tmp;\n did_something := true;\n try_again := true;\n fi;\n\n if lt(result[i]^-1*result[j]^-1, result[j]) then\n result[j] := result[i]^-1*result[j]^-1;\n transform[j] := transform[i]^-1*transform[j]^-1;\n did_something := true;\n try_again := true;\n fi;\n if lt(result[i]^-1*result[j]^-1, result[i]) then\n result[i] := result[i]^-1*result[j]^-1;\n transform[i] := transform[i]^-1*transform[j]^-1;\n did_something := true;\n try_again := true;\n fi;\n\n if lt(result[i]*result[j]^-1, result[j]) then\n result[j] := result[i]*result[j]^-1;\n transform[j] := transform[i]*transform[j]^-1;\n did_something := true;\n try_again := true;\n fi;\n if lt(result[i]*result[j]^-1, result[i]) then\n result[i] := result[i]*result[j]^-1;\n transform[i] := transform[i]*transform[j]^-1;\n did_something := true;\n try_again := true;\n fi;\n\n if lt(result[i]^-1*result[j], result[i]) then\n result[i] := result[i]^-1*result[j];\n transform[i] := transform[i]^-1*transform[j];\n did_something := true;\n try_again := true;\n fi;\n if lt(result[i]^-1*result[j], result[j]) then\n result[j] := result[i]^-1*result[j];\n transform[j] := transform[i]^-1*transform[j];\n did_something := true;\n try_again := true;\n fi;\n\n if lt(result[i]*result[j], result[j]) then\n result[j] := result[i]*result[j];\n transform[j] := transform[i]*transform[j];\n did_something := true;\n try_again := true;\n fi;\n if lt(result[i]*result[j], result[i]) then\n result[i] := result[i]*result[j];\n transform[i] := transform[i]*transform[j];\n did_something := true;\n try_again := true;\n fi;\n\n od;\n od;\n\n od;\n\n return [result, transform, did_something];\nend);\n\n\n#############################################################################\n##\n## AG_ComputeMihailovaSystemPairs(<pairs_list>)\n##\nInstallGlobalFunction(AG_ComputeMihailovaSystemPairs,\nfunction(pairs)\n local result, i, nie, m, n, w, tmp,\n did_smth, npairs, transform,\n generate_full_group, nielsen_mihaylov, nielsen_low, rank,\n number_of_letters;\n\n if not IsDenseList(pairs) then\n Print(\"error in AG_ComputeMihailovaSystemPairs: \\n\");\n Print(\" argument is not an IsDenseList\\n\");\n return fail;\n fi;\n if not IsList(pairs[1]) then\n Print(\"error in AG_ComputeMihailovaSystemPairs: \\n\");\n Print(\" first element of list is not an IsList\\n\");\n return fail;\n fi;\n if Length(pairs[1]) <> 2 then\n Print(\"error in AG_ComputeMihailovaSystemPairs: \\n\");\n Print(\" can work only with pairs\\n\");\n return fail;\n fi;\n if not IsAssocWord(pairs[1][1]) then\n Print(\"error in AG_ComputeMihailovaSystemPairs: \\n\");\n Print(\" <arg>[1][1] is not IsAssocWord\\n\");\n return fail;\n fi;\n\n\n #############################################################################\n ##\n ## generate_full_group\n ##\n generate_full_group := function(list, rank)\n local nie, i;\n nie := AG_ReducedListOfWordsByNielsen(list)[1];\n if Length(Difference(nie, [One(nie[1])])) <> rank then\n return false;\n fi;\n for i in [1..Length(nie)] do\n if Length(nie[i]) > 1 then return false; fi;\n od;\n return true;\n end;\n\n\n #############################################################################\n ##\n ## rank\n ##\n rank := function(words)\n return Length(Difference(AG_ReducedListOfWordsByNielsen(words)[1],\n [One(words[1])]));\n end;\n\n\n #############################################################################\n ##\n ## number_of_letters\n ##\n number_of_letters := function(list)\n local letters, i, j;\n letters := [];\n for i in [1..Length(list)] do\n for j in [1..NumberSyllables(list[i])] do\n AddSet(letters, GeneratorSyllable(list[i], j));\n od;\n od;\n return Length(letters);\n end;\n\n\n #############################################################################\n ##\n ## nielsen_mihaylov\n ##\n nielsen_mihaylov := function(words_list, m, n)\n local result, transform, did_something, try_again, nie, i, j, tf, pair,\n good_tf, good_pair, tmp;\n\n result := StructuralCopy(words_list);\n transform := ShallowCopy(FreeGeneratorsOfFpGroup(FreeGroup(m+n)));\n did_something := false;\n try_again := true;\n\n while try_again do\n try_again := false;\n\n nie := nielsen_low(result, m, n, \\<);\n if nie[3] then\n did_something := true;\n try_again := true;\n result := nie[1];\n transform := AG_CalculateWords(nie[2], transform);\n fi;\n\n nie := AG_ReducedListOfWordsByNielsen(result{[m+1..m+n]});\n if nie[3] then\n did_something := true;\n try_again := true;\n result := Concatenation(result{[1..m]}, nie[1]);\n transform := Concatenation( transform{[1..m]},\n AG_CalculateWords(nie[2],\n transform{[m+1..m+n]}));\n fi;\n\n if rank(result{[m+1..m+n]}) = n then\n if List(result{[m+1..m+n]}, w -> Length(w)) = List([1..n], i -> 1) then\n ## ok\n try_again := false;\n else\n ## try to minimize sum of lengths\n good_pair := false;\n for pair in ListX([m+1..m+n], [1..m], function(i,j) return [i,j]; end) do\n good_tf := false;\n for tf in [ [1,1,2,1],[2,1,1,1],[1,-1,2,1],[2,-1,1,1],\n [1,1,2,-1],[2,1,1,-1],[1,-1,2,-1],[2,-1,1,-1] ] do\n tmp := StructuralCopy(result);\n tmp[pair[1]] := tmp[pair[tf[1]]]^tf[2] * tmp[pair[tf[3]]]^tf[4];\n if rank(tmp{[m+1..m+n]}) = n and\n number_of_letters(tmp{[m+1..m+n]}) =\n number_of_letters(result{[m+1..m+n]}) and\n Sum(List(tmp{[m+1..m+n]}, w -> Length(w))) <\n Sum(List(result{[m+1..m+n]}, w -> Length(w)))\n then\n good_tf := true;\n break;\n fi;\n od;\n if good_tf then\n good_pair := true;\n break;\n fi;\n od;\n if not good_pair then\n ## give up\n return [result, transform, did_something];\n else\n result[pair[1]] := result[pair[tf[1]]]^tf[2] *\n result[pair[tf[3]]]^tf[4];\n transform[pair[1]] := transform[pair[tf[1]]]^tf[2] *\n transform[pair[tf[3]]]^tf[4];\n try_again := true;\n did_something := true;\n fi;\n fi;\n else\n ## try to make rank bigger\n for i in [1..m] do\n good_tf := false;\n pair := [m+1, i];\n for tf in [ [1,1,2,1],[2,1,1,1],[1,-1,2,1],[2,-1,1,1],\n [1,1,2,-1],[2,1,1,-1],[1,-1,2,-1],[2,-1,1,-1] ] do\n tmp := StructuralCopy(result);\n tmp[pair[1]] := tmp[pair[tf[1]]]^tf[2] * tmp[pair[tf[3]]]^tf[4];\n if rank(tmp{[m+1..m+n]}) > rank(result{[m+1..m+n]}) and\n number_of_letters(tmp{[m+1..m+n]}) >=\n number_of_letters(result{[m+1..m+n]})\n then\n good_tf := true;\n break;\n fi;\n od;\n if good_tf then\n good_pair := true;\n break;\n fi;\n od;\n if not good_pair then\n ## give up\n return [result, transform, did_something];\n else\n result[pair[1]] := result[pair[tf[1]]]^tf[2] *\n result[pair[tf[3]]]^tf[4];\n transform[pair[1]] := transform[pair[tf[1]]]^tf[2] *\n transform[pair[tf[3]]]^tf[4];\n try_again := true;\n did_something := true;\n fi;\n fi;\n\n od;\n\n return [result, transform, did_something];\n end;\n\n\n #############################################################################\n ##\n ## nielsen_low\n ##\n nielsen_low := function(words_list, m, n, lt)\n local result, transform, did_something, i, j, try_again, tmp, nie;\n\n result := ShallowCopy(words_list);\n transform := ShallowCopy(FreeGeneratorsOfFpGroup(FreeGroup(m+n)));\n did_something := false;\n try_again := true;\n\n while try_again do\n try_again := false;\n\n nie := AG_ReducedListOfWordsByNielsen(result{[1..m]});\n if nie[3] then\n result := Concatenation(AG_CalculateWords(nie[2], result{[1..m]}),\n result{[m+1..m+n]});\n transform := Concatenation( AG_CalculateWords(nie[2], transform{[1..m]}),\n transform{[m+1..m+n]} );\n did_something := true;\n try_again := true;\n fi;\n\n for i in [1..m] do\n for j in [m+1..m+n] do\n if lt(result[i]^result[j], result[i]) then\n result[i] := result[i]^result[j];\n transform[i] := transform[i]^transform[j];\n did_something := true;\n try_again := true;\n fi;\n if lt(result[i]^(result[j]^-1), result[i]) then\n result[i] := result[i]^(result[j]^-1);\n transform[i] := transform[i]^(transform[j]^-1);\n did_something := true;\n try_again := true;\n fi;\n if lt((result[i]^-1)^result[j], result[i]) then\n result[i] := (result[i]^-1)^result[j];\n transform[i] := (transform[i]^-1)^transform[j];\n did_something := true;\n try_again := true;\n fi;\n if lt((result[i]^-1)^(result[j]^-1), result[i]) then\n result[i] := (result[i]^-1)^(result[j]^-1);\n transform[i] := (transform[i]^-1)^(transform[j]^-1);\n did_something := true;\n try_again := true;\n fi;\n od;\n od;\n od;\n\n return [result, transform, did_something];\n end;\n\n #############################################################################\n ##\n ## MihailovaSystem body\n ##\n n := Length(FreeGeneratorsOfWholeGroup(Group(pairs[1][1])));\n m := Length(pairs) - n;\n npairs := StructuralCopy(pairs);\n transform := StructuralCopy(FreeGeneratorsOfFpGroup(FreeGroup(n+m)));\n did_smth := false;\n if not generate_full_group(List(pairs, p -> p[1]), n)\n or not generate_full_group(List(pairs, p -> p[2]), n)\n then\n Print(\"error in AG_ComputeMihailovaSystemPairs: \\n\");\n Print(\" projections do not generate full free group\\n\");\n return fail;\n fi;\n\n ## if rank equals number of pairs then just make one coordinate nicer\n if m = 0 then\n nie := AG_ReducedListOfWordsByNielsen(List(npairs, p -> p[1]), \"r\");\n if nie[3] then\n tmp := List(npairs, p -> []);\n for i in [1..m+n] do\n tmp[i][1] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[1]));\n tmp[i][2] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[2]));\n od;\n npairs := StructuralCopy(tmp);\n transform := StructuralCopy(nie[2]);\n did_smth := true;\n fi;\n return [npairs, transform, did_smth];\n fi;\n\n ## else try to do as much as possible\n\n ## 1. Apply Nielsen to first coordinate\n nie := AG_ReducedListOfWordsByNielsen(List(npairs, p -> p[1]), \"r\");\n if nie[3] then\n tmp := StructuralCopy(npairs);\n for i in [1..m+n] do\n tmp[i][1] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[1]));\n tmp[i][2] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[2]));\n od;\n npairs := StructuralCopy(tmp);\n transform := StructuralCopy(nie[2]);\n did_smth := true;\n fi;\n\n ## 2. Now apply nielsen_mihaylov to the second coordinate\n nie := nielsen_mihaylov(List(npairs, p -> p[2]), m, n);\n if nie[3] then\n tmp := StructuralCopy(npairs);\n for i in [1..m+n] do\n tmp[i][1] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[1]));\n tmp[i][2] := AG_CalculateWord(nie[2][i], List(npairs, p -> p[2]));\n od;\n npairs := StructuralCopy(tmp);\n tmp := StructuralCopy(transform);\n for i in [1..m+n] do\n tmp[i] := AG_CalculateWord(nie[2][i], transform);\n od;\n transform := StructuralCopy(tmp);\n did_smth := true;\n fi;\n\n ## 3. Try to get nice generators on first coordinate\n nie := AG_ReducedListOfWordsByNielsenBack(List(npairs{[m+1..m+n]}, p -> p[1]), \"r\");\n if nie[3] then\n tmp := StructuralCopy(npairs);\n for i in [1..n] do\n tmp[m+i][1] := AG_CalculateWord(nie[2][i], List(npairs{[m+1..m+n]}, p -> p[1]));\n tmp[m+i][2] := AG_CalculateWord(nie[2][i], List(npairs{[m+1..m+n]}, p -> p[2]));\n od;\n npairs := StructuralCopy(tmp);\n tmp := StructuralCopy(transform);\n for i in [1..n] do\n tmp[m+i] := AG_CalculateWord(nie[2][i], transform{[m+1..m+n]});\n od;\n transform := StructuralCopy(tmp);\n did_smth := true;\n fi;\n\n return [npairs, transform, did_smth];\nend);\n\n\n#############################################################################\n##\n#M AG_ReducedByNielsen(<words_list>)\n##\nInstallMethod(AG_ReducedByNielsen,\n \"for [IsList and IsAssocWordCollection]\",\n [IsList and IsAssocWordCollection],\nfunction(words)\n if AG_Globals.use_inv_order_in_apply_nielsen then\n return AG_ReducedListOfWordsByNielsen(words, \"back\")[1];\n else\n return AG_ReducedListOfWordsByNielsen(words)[1];\n fi;\nend);\n\n\n#############################################################################\n##\n#M AG_ReducedByNielsen(<autom_list>)\n##\nInstallMethod(AG_ReducedByNielsen,\n \"for [IsList and IsAutomCollection]\",\n [IsList and IsAutomCollection],\nfunction(automs)\n local words;\n if IsEmpty(automs) then\n return [];\n fi;\n words := AG_ReducedByNielsen(List(automs, a -> a!.word));\n return List(words, w -> Autom(w, automs[1]));\nend);\n\n\n#E\n", "meta": {"hexsha": "9cc497e14da48b95d332f0cfa76c3dad75c803fd", "size": 20445, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "gap/utilsfrgrp.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/utilsfrgrp.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/utilsfrgrp.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": 31.1187214612, "max_line_length": 97, "alphanum_fraction": 0.5264367816, "num_tokens": 5653, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.3828892251842272}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nImport(paradigms.common, paradigms.vector, paradigms.vector.sigmaspl);\n\n_bDivisorPairs := N -> Concatenation(DivisorPairs(N), [[N, 1]]);\n\nVBfly1 := VBase(F(2), 2);\nVBfly3 := VBase(Mat([[1,E(4)],[1,-E(4)]]), 2);\n\nClass(v_lo2, Exp);\nClass(v_hi2, Exp);\nClass(v_rev2, Exp);\nClass(v_revhi2, Exp);\nClass(v_neg01, Exp);\nClass(v_neg03, Exp);\nClass(v_neg23, Exp);\nClass(v_neg2, Exp);\nClass(v_mul1j, Exp);\n\nVBaseHash := HashTableSPL();\n\nVectorCodegen.VBase := (self, o, y, x, opts) >> let(\n lkup := HashLookup(VBaseHash, o),\n Cond(lkup <> false,\n lkup.code(o, y, x, opts),\n Error(\"VBase implementation of <o> not found in VBaseHash\")));\n\n# NOTE: increase vlen to 4 and RC the matrices\nHashAdd(VBaseHash, VBase(L(4,2), 2),\n rec(\n spl := VBase(L(4,2), 2),\n code := (o, y, x, opts) -> chain(\n assign(vvref(y,0,2), v_lo2(vvref(x,0,2), vvref(x,1,2))),\n assign(vvref(y,1,2), v_hi2(vvref(x,0,2), vvref(x,1,2))))\n ));\n\nHashAdd(VBaseHash, VBfly1,\n rec(\n spl := VBfly1,\n code := (o, y, x, opts) -> let(\n hi := TempVar(TVect(x.t.t, 2)),\n lo := TempVar(TVect(x.t.t, 2)),\n chain(\n assign(lo, v_lo2(vvref(x,0,2), vvref(x,0,2))),\n assign(hi, v_hi2(vvref(x,0,2), vvref(x,0,2))),\n assign(hi, v_neg03(hi)),\n assign(vvref(y, 0, 2), hi+lo)))\n ));\n\nHashAdd(VBaseHash, VBfly3,\n rec(\n spl := VBfly3,\n code := (o, y, x, opts) -> let(\n hi := TempVar(TVect(x.t.t, 2)),\n lo := TempVar(TVect(x.t.t, 2)),\n chain(\n assign(lo, v_lo2(vvref(x,0,2), vvref(x,0,2))),\n assign(hi, v_revhi2(vvref(x,0,2), vvref(x,0,2))),\n assign(hi, v_neg03(hi)),\n assign(vvref(y, 0, 2), hi+lo)))\n ));\n\nHashAdd(VBaseHash, VBase(J(2), 2),\n rec(\n spl := VBase(J(2), 2),\n code := (o, y, x, opts) ->\n assign(vvref(y, 0, 2), v_rev2(vvref(x,0,2)))\n ));\n\nHashAdd(VBaseHash, VBase(I(2), 2),\n rec(\n spl := VBase(J(2), 2),\n code := (o, y, x, opts) ->\n assign(vvref(y, 0, 2), vvref(x,0,2))\n ));\n\n\n# NOTE: Pull out twiddles, for 2-way nothing else needs to be done! (1-way cplx)\nRulesFor(PSkewDFT3, rec(\n PSkewDFT3_toSkewDFT := rec(\n isApplicable := P -> IsEvenInt(P[1]),\n allChildren := P -> [[ SkewDFT(P[1]/2, P[2]) ]],\n rule := (P, C) -> let(n := P[1],\n M(n, n/2) *\n L(n,2) *\n Tensor(I(n/2), Mat([[1, E(4)], [1, -E(4)]])) *\n RC(C[1]) *\n L(n,n/2))\n )\n));\n\nRulesFor(BSkewDFT3, rec(\n BSkewDFT3_Base2 := rec(\n isApplicable := P -> P[1]=2,\n rule := (P, C) -> let(\n D := Dat1d(TReal, 2),\n re := nth(D, 0), im := nth(D, 1),\n Data(D, fPrecompute(FList(TReal, [cospi(2*P[2]), sinpi(2*P[2])])),\n F(2)*Mat([[1,re],\n [0,E(4)*im]])))\n ),\n\n BSkewDFT3_Base4 := rec(\n isApplicable := P -> P[1]=4,\n allChildren := P -> let(n:=P[1], a:=P[2], aa:=[a/2, (1-a)/2],\n [[ BSkewDFT3(n/2, aa[1]), BSkewDFT3(n/2, aa[2]), BRDFT3(4,a) ]]),\n rule := (P, C) ->\n K(P[1],P[1]/2) * DirectSum(C[1], C[2]) * C[3]\n ),\n\n BSkewDFT3_Fact := rec(\n switch := false,\n isApplicable := P -> P[1] = 4,\n allChildren := P -> let(n:=P[1], a:=P[2], aa:=[a/2, (1-a)/2],\n [[ BSkewDFT3(n/2, aa[1]), BSkewDFT3(n/2, aa[2]) ]]),\n rule := (P, C) -> K(P[1],P[1]/2) * DirectSum(C) * bruun2(P[1],P[2])\n ),\n\n BSkewDFT3_Decomp := rec(\n isApplicable := P -> P[1] > 4,\n allChildren := P -> let(N:=P[1], a:=P[2],\n Map2(DivisorPairs(N/2), (m,n) -> let(i := Ind(n),\n [BSkewDFT3(2*m, fr(2*n,i,2*a)), BRDFT3(2*n,a), InfoNt(i)]))),\n\n rule := (P, C, Nonterms) -> let(N := P[1], m := Cols(C[1])/2,\n K(N,2*m) * IterDirectSum(Nonterms[3].params[1], C[1]) * Tensor(C[2], I(m)))\n )\n));\n\nRulesFor(BSkewDFT4, rec(\n BSkewDFT4_Base2 := rec(\n isApplicable := P -> P[1]=2,\n rule := (P, C) -> let(w:=E(2*Denominator(P[2]))^Numerator(P[2]), cc:=Global.Conjugate,\n Mat([[w, w^3],\n [-cc(w), -cc(w)^3]]))\n ),\n\n BSkewDFT4_Base4 := rec(\n isApplicable := P -> P[1]=4,\n allChildren := P -> let(n:=P[1], a:=P[2], aa:=[a/2, (1-a)/2],\n [[ BSkewDFT4(n/2, aa[1]), BSkewDFT4(n/2, aa[2]), BRDFT3(4,a) ]]),\n rule := (P, C) ->\n K(P[1],P[1]/2) * DirectSum(C[1], C[2]) * C[3]\n ),\n\n BSkewDFT4_Decomp := rec(\n isApplicable := P -> P[1] > 4,\n allChildren := P -> let(N:=P[1], a:=P[2],\n Map2(DivisorPairs(N/2), (m,n) -> Concatenation(\n List([0..n-1], i->BSkewDFT4(2*m, fr(2*n,i,2*a).ev())),\n [BRDFT3(2*n,a)]))),\n rule := (P, C) -> let(N := P[1], m := Cols(C[1])/2,\n K(N,2*m) * DirectSum(DropLast(C,1)) * Tensor(Last(C), I(m)))\n )\n));\n\nRulesFor(BRDFT1, rec(\n BRDFT1_Base2 := rec(\n isApplicable := P -> P[1]=2,\n rule := (P, C) -> F(2)),\n\n BRDFT1_Base3 := rec(\n isApplicable := P -> P[1]=3,\n rule := (P, C) -> BRDFT1(P[1], P[2]).terminate()),\n\n BRDFT1_Decomp := rec(\n # NOTE: add support for odd sizes\n isApplicable := P -> P[1] > 2 and IsEvenInt(P[1]),\n allChildren := P -> let(N:=P[1],\n Map2(_bDivisorPairs(N/2), (m,n) -> let(i := Ind(n-1),\n When(n=1,\n [BRDFT1(m), BRDFT3(m), BRDFT1(2*n)],\n [BRDFT1(m), BRDFT3(m), BRDFT1(2*n), InfoNt(i), BRDFT3(2*m, (1+i)/(2*n))])))),\n\n rule := (P, C, Nonterms) -> let(N := P[1], m := Cols(C[1]), n := N/m/2,\n RC(Scat(IP(N/2, OS(n, -1)))) * RC(L(N/2, m)) * # RC(K'(N/2,m)) *\n DirectSum(RC(L(m, m/2)) * DirectSum(C[1], C[2]),\n When(n=1, [], IterDirectSum(Nonterms[4].params[1], C[5]))) *\n Tensor(C[3], I(m)))\n )\n));\n\n# URDFT_Decomp:\n# MatSPL(Kp(16,4))^-1 * MatSPL(DFT(16))*MatSPL(Tensor(URDFT(8), I(2)))^-\n#\nNewRulesFor(DFT, rec(\n DFT_Bruun_Decomp := rec(\n switch := false,\n # NOTE: add support for odd sizes\n # only apply if there are no tSPL tags.\n applicable := nt -> nt.params[1] > 2 and IsEvenInt(nt.params[1]) and not nt.hasTags(),\n\n children := nt -> let(\n N := nt.params[1],\n Map2(_bDivisorPairs(N/2), (m,n) -> let(\n i := Ind(n-1),\n When(n=1,\n [DFT(m), BSkewDFT3(m), BRDFT1(2*n)],\n [DFT(m), BSkewDFT3(m), BRDFT1(2*n), InfoNt(i), BSkewDFT3(2*m, (1+i)/(2*n))]\n )\n ))\n ),\n\n apply := (nt, C, nonterms) -> let(\n N := nt.params[1], \n m := Cols(C[1]), \n n := N/m/2,\n\n Scat(IP(N, OS(n, -1))) \n * L(N, 2*m) \n# * RC(K'(N/2,m)) \n * DirectSum(\n L(2*m, m) \n * DirectSum(C[1], C[2]),\n When(n=1, \n [], \n IterDirectSum(Nonterms[4].params[1], C[5])\n )\n ) \n * Tensor(C[3], I(m))\n )\n\n#D isApplicable := (self, P) >> P[1] > 2 and IsEvenInt(P[1]) and PHasNoTags(self.nonTerminal, P),\n#D allChildren := P -> let(N:=P[1],\n#D Map2(_bDivisorPairs(N/2), (m,n) -> let(i := Ind(n-1),\n#D When(n=1,\n#D [DFT(m), BSkewDFT3(m), BRDFT1(2*n)],\n#D [DFT(m), BSkewDFT3(m), BRDFT1(2*n), InfoNt(i), BSkewDFT3(2*m, (1+i)/(2*n))])))),\n#D\n#D rule := (P, C, Nonterms) -> let(N := P[1], m := Cols(C[1]), n := N/m/2,\n#D Scat(IP(N, OS(n, -1))) * L(N, 2*m) * # RC(K'(N/2,m)) *\n#D DirectSum(L(2*m, m) * DirectSum(C[1], C[2]),\n#D When(n=1, [], IterDirectSum(Nonterms[4].params[1], C[5]))) *\n#D Tensor(C[3], I(m)))\n )\n));\n\nClass(VWrapRC, VWrapBase, rec(\n __call__ := self >> self,\n wrap := (self, r, t, opts) >> @_Base(RC(t), r),\n twrap := (self, t, opts) >> RC(t)\n));\n\nNewRulesFor(DFT, rec(\n DFT_URDFT_Decomp := rec(\n switch := false,\n\n # NOTE: add support for odd sizes\n applicable := (self, t) >> let(n:=t.params[1],\n n > 4 and IsEvenInt(n) and not IsPrime(n/2)) and t.getTags() = [],\n\n maxRadix := 128,\n\n children := (self, t) >> let(N:=t.params[1], maxrad := self.maxRadix, rot := t.params[2],\n Map2(Filtered(DivisorPairs(N/2), x -> x[1] <= maxrad/2),\n (m,n) -> [ DFT(2*m, rot), DFT(m, rot).addWrap(VWrapRC()),\n GT(URDFT1(2*n, rot), GTVec, GTVec, [m]).withTags(t.getTags()) ])),\n\n apply := (t, C, Nonterms) -> let(\n N := t.params[1], m := Cols(C[2]), n := N/m/2, rot := t.params[2],\n j := Ind(n-1),\n\n Scat(Refl0_u(n, 2*m)) *\n DirectSum(\n BB(C[1]),\n IterDirectSum(j, BB(\n #condM(2*m, m) * \n L(2*m, 2) *\n Tensor(I(m), Mat([[1, E(4)], [1, -E(4)]])) *\n RC(C[2]) *\n RC(DirectSum(I(1), Diag(fPrecompute(\n fCompose(Twid(N, m, rot, 0, 0, j+1), fAdd(m, m-1, 1)))))) *\n L(2*m, m))\n # can replace by jj * b * (rdft(a) x I2)\n # b = b' * (I x L^4_2)\n )\n ) *\n C[3] #Tensor(C[3], I(m))\n )\n ),\n\n DFT_Base4_VecCx := rec(\n switch := false,\n requiredFirstTag := AVecRegCx,\n applicable := (self, t) >> t.params[1]=4 and t.firstTag().v = 2,\n apply := (t, C, Nonterms) ->\n VTensor(F(2), 2) *\n VDiag(Tw1(4,2,t.params[2]), 2) *\n VBase(L(4,2), 2) *\n VTensor(F(2), 2)\n ),\n\n DFT_URDFT_Decomp_VecCx := rec(\n switch := false,\n requiredFirstTag := AVecRegCx,\n\n # NOTE: add support for odd sizes\n applicable := (self, t) >> let(n:=t.params[1], k:=t.params[2],\n k = 1 and n > 4 and IsEvenInt(n)), # and t.getTags() = []),\n\n maxRadix := 32,\n\n children := (self, t) >> let(N:=t.params[1], maxrad := self.maxRadix, tags := t.getTags(),\n Map2(Filtered(DivisorPairs(N/2), x -> x[1] <= maxrad/2),\n (m,n) -> let(j := Ind(n-1),\n [ DFT(2*m).withTags(tags),\n rDFT(2*m, (j+1)/(2*n), 1).withTags(tags),\n GT(URDFT1(2*n), GTVec, GTVec, [m]).withTags(tags),\n InfoNt(j) ]))),\n\n apply := (t, C, Nonterms) -> let(\n N := t.params[1], m := Cols(C[2])/2,\n j := Nonterms[4].params[1],\n v := t.getTags()[1].v,\n\n condKp(N, 2*m) *\n DirectSum(C[1],\n IDirSum(j, K(2*m, 2) * Tensor(I(m), VBfly3) * C[2])) *\n C[3]\n )\n )\n));\n\nRulesFor(PkRDFT1, rec(\n PkRDFT1_Base2 := rec(\n isApplicable := P -> P[1]=2,\n rule := (P, C) -> F(2)\n ),\n\n PkRDFT1_Bruun_Decomp := CopyFields(BRDFT1_Decomp, rec(\n allChildren := P -> let(N:=P[1],\n Map2(_bDivisorPairs(N/2), (m,n) -> let(i := Ind(n-1),\n When(n=1,\n [PkRDFT1(m), BSkewPRDFT(m), BRDFT1(2*n), InfoNt(i)],\n [PkRDFT1(m), BSkewPRDFT(m), BRDFT1(2*n), InfoNt(i), BSkewPRDFT(2*m, (1+i)/(2*n))])))),\n )),\n));\n\n\nRulesFor(BRDFT3, rec(\n BRDFT3_Base2 := rec(\n isApplicable := P -> P[1]=2,\n rule := (P, C) -> I(2)),\n\n BRDFT3_Base3 := rec(\n isApplicable := P -> P[1]=3,\n rule := (P, C) -> ApplyFunc(BRDFT3, P).terminate()),\n\n BRDFT3_Base4 := rec(\n isApplicable := P -> P[1]=4,\n rule := (P, C) -> let(\n a := P[2], D := Dat1d(TReal, 2), q := nth(D, 0), q2 := nth(D, 1),\n Data(D, fPrecompute(FList(TReal, [2*cospi(a), 4*cospi(a)^2 - 1])),\n L(4,2) * VStack(\n F(2)*Mat([[1, 0,-1, 0],\n [0, 0, 0,-q]]),\n F(2)*Mat([[0, 1, 0,q2],\n [0, 0, q, 0]]))))\n ),\n\n BRDFT3_Fact := rec(\n switch := false,\n isApplicable := P -> P[1] > 2,\n allChildren := P -> let(n:=P[1], a:=P[2], [[ BRDFT3(n/2, a/2), BRDFT3(n/2, (1-a)/2) ]]),\n rule := (P, C) -> K(P[1],P[1]/2) * DirectSum(C) * bruun2(P[1],P[2])\n ),\n\n BRDFT3_Trig := rec(\n switch := false,\n isApplicable := P -> P[1] > 2 and (P[1] mod 2) = 0,\n allChildren := P -> let(n:=P[1], a:=P[2], [[ PolyDTT(SkewDTT(DST3(n/2), 2*a)) ]]),\n rule := (P, C) -> let(n := P[1], nn := n/2-1,\n b := Diag(BHD(n/2, 1, -1)) *\n VStack(\n HStack(DirectSum(I(1), -I(nn-1)), O(nn,1), -J(nn), O(nn,1)),\n RowVec(Replicate(nn,0), -1, Replicate(nn+1, 0)),\n HStack(O(nn,1), I(nn), O(nn,1), J(nn)),\n RowVec(Replicate(nn+1,0), 1, Replicate(nn, 0))),\n M(P[1],P[1]/2) * Tensor(C[1], I(2)) * b)\n ),\n\n BRDFT3_Decomp := rec(\n isApplicable := P -> P[1] > 4,\n allChildren := P -> let(N:=P[1], a:=P[2], rot := P[3],\n Map2(DivisorPairs(N/2), (m,n) -> let(i := Ind(n),\n [BRDFT3(2*m, fr(2*n,i,2*a), rot), BRDFT3(2*n,a,rot), InfoNt(i)]))),\n\n rule := (P, C, Nonterms) -> let(N := P[1], m := Cols(C[1])/2,\n RC(K(N/2,m)) * IterDirectSum(Nonterms[3].params[1], C[1]) * Tensor(C[2], I(m)))\n )\n));\n\nNewRulesFor(rDFT, rec(\n rDFT_Base4 := rec(\n requiredFirstTag := ANoTag,\n applicable := t -> t.params[1]=4,\n apply := (t, C, Nonterms) -> let(\n a := t.params[2],\n Diag(1,1,1,-1) *\n Tensor(F(2), I(2)) *\n DirectSum(I(2), RCDiag(fPrecompute(FList(TReal, [cospi(a), sinpi(a)])))) *\n L(4,2))\n ),\n\n rDFT_Base4_Vec := rec(\n requiredFirstTag := AVecRegCx,\n applicable := t -> t.params[1]=4 and t.firstTag().v = 2,\n apply := (t, C, Nonterms) -> let(\n a :=t.params[2], D := Dat1d(TReal, 2),\n VTensor(F(2), 2) *\n DirectSum(VBase(I(2), 2), VBase(J(2), 2)*VDiag(FList(TReal, [1,-1]), 2)) *\n VRCDiag(fPrecompute(VData(FList(TReal, [1, cospi(a), 0, -sinpi(a)]), 2)), 2)\n ) # for some reason its not 1 c 0 s ...\n ),\n\n rDFT_Decomp := rec(\n applicable := t -> t.params[1] > 4,\n children := t -> let(N := t.params[1], a := t.params[2], tags := t.getTags(),\n Map2(DivisorPairs(N/2), (m,n) -> let(i := Ind(n),\n [ rDFT(2*m, fr(2*n,i,2*a)).withTags(tags),\n GT(rDFT(2*n, a), GTVec, GTVec, [m]).withTags(tags),\n InfoNt(i)]))),\n\n apply := (t, C, Nonterms) -> let(N := t.params[1], m := Cols(C[1])/2,\n RC(K(N/2,m)) * IterDirectSum(Nonterms[3].params[1], C[1]) * C[2]),\n )\n));\n#s:=SPLRuleTree(ExpandSPL(rDFT(4).withTags([AVecRegCx(SSE_4x32f)]), SpiralDefaults)[2]);\n\n\n# packed fmt\nRulesFor(BSkewPRDFT, rec(\n BSkewPRDFT_Decomp := CopyFields(BRDFT3_Decomp, rec(\n allChildren := P -> let(N:=P[1], a:=P[2],\n Map2(DivisorPairs(N/2), (m,n) -> let(i := Ind(n),\n [BSkewPRDFT(2*m, fr(2*n,i,2*a)), BRDFT3(2*n,a), InfoNt(i) ]))),\n )),\n\n BSkewPRDFT_Base2 := rec(\n isApplicable := P -> P[1]=2,\n rule := (P, C) -> I(2)\n ),\n\n BSkewPRDFT_Base4 := rec(\n isApplicable := P -> P[1]=4,\n rule := (P, C) -> let(\n a := P[2], D := Dat1d(TReal, 6), d := Diag(1,-1),\n Data(D, fPrecompute(FList(TReal, [cospi(a), cospi(2*a), cospi(3*a),\n sinpi(a), sinpi(2*a), sinpi(3*a) ])),\n L(4,2) * VStack(\n F(2)*Mat([[1, 0, nth(D,1), 0 ],\n [0, nth(D,0), 0, nth(D, 2) ]]),\n d*F(2)*Mat([[0, 0, nth(D,4), 0 ],\n [0, nth(D,3), 0, nth(D, 5) ]]))))\n )\n));\n\n# algebraic fmt\nRulesFor(BSkewRDFT, rec(\n BSkewRDFT_Decomp := rec(\n isApplicable := P -> P[1] > 4,\n allChildren := P -> let(N:=P[1], a:=P[2],\n Map2(DivisorPairs(N/2), (m,n) -> Concatenation(\n List([0..n-1], i->BSkewRDFT(2*m, fr(2*n,i,2*a).ev())),\n [BRDFT3(2*n,a)]))),\n rule := (P, C) -> let(N := P[1], m := Cols(C[1])/2,\n K(N,2*m) * DirectSum(DropLast(C,1)) * Tensor(Last(C), I(m)))\n )\n));\n\nRulesFor(DCT4, rec(\n DCT4_BSkew_Decomp := rec(\n switch := false,\n isApplicable := P -> P > 2,\n allChildren := P -> let(N:=P, a:=1/2,\n Map2(DivisorPairs(N), (m,n) -> Concatenation(\n List([0..n-1], i->SkewDTT(DCT4(m), fr(n,i,a).ev())),\n [BRDFT3(2*n,a/2)]))),\n\n rule := (P, C) -> let(N := P, m := Cols(C[1])/2, n:=Cols(Last(C))/2,\n i := Ind(m),\n K(N,2*m) *\n DirectSum(DropLast(C,1)) *\n K(N, 2*n) *\n ISum(i,\n Scat(H(N,2*n,(2*n)*i,1)) * Last(C) *\n DirectSum(I(n+1), -I(n-1)) * OS(2*n,-1) * Gath(BH(N,2*N-1,2*n,i,2*m))))\n )\n));\n\n# right := (m,n) -> let(N:=2*m*n, i:=Ind(m),\n# ISum(i,\n# Scat(H(N,2*n,(2*n)*i,1)) * BRDFT3(2*n,1/4) *\n# DirectSum(I(n), -I(n)) * Gath(BH1(2*N,2*n,i,2*m))));\n\n# RC.toAMat := self >> AMatMat(RCMatCyc(MatSPL(self.child(1))));\n\n# bb:=(n,a)->MatSPL(BRDFT3(n,a));;\n# ts:=TensorProductMat;;\n# ii:=IdentityMat;;\n# ms:=MatSPL;\n# rms := x->RCMatCyc(MatSPL(x));\n\n# BRDFT3(4,a) -> 6a+3m\n# BRDFT3(4,1/4) -> 6a+2m\n\n# costs:\n# 4, 6+2 = 8\n# PRDFT3, 8, 22+10 = 32\n# 16, 66+30 = 96\n#\n# 4, 8(1/4) or 9(other)\n# BRDFT3, 8, 34\n# 16, 104\n", "meta": {"hexsha": "b7eb7aa2db11d5076c6311bcfb14c6778879e87c", "size": 17258, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sym/bruun.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/bruun.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/bruun.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.3166023166, "max_line_length": 103, "alphanum_fraction": 0.4511530884, "num_tokens": 6598, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863695, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.3793771629775722}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# ================================================================\n# Sum of Monomials\n# NOTE: fix sum_mons, mon_diags, mon_perms\n# ================================================================\nsum_mons := pat -> pat.target(SUMAcc).cond(e->ForAll(e.children(), IS(Mon)));\nmon_vdiags := pat -> List(pat.val.children(), c -> c.vdiag);\nmon_sdiags := pat -> List(pat.val.children(), c -> c.sdiag);\nmon_perms := pat -> List(pat.val.children(), c -> c.perm);\n\ncompat_tensor_mons := (p,v,s) -> let(\n pp := Filtered(p, c->domain(c) > 1),\n vv := Filtered(v, c->domain(c) > 1),\n ss := Filtered(s, c->domain(c) > 1),\n fully_compat_tensor_chains(pp, vv, domain, domain) and\n fully_compat_tensor_chains(vv, ss, domain, domain));\n\nmerge_tensor_mons := function(pp, vv, ss, combine) #, fid, gid, hid)\n local i, j, k, np, nv, ns, p, v, s, res;\n np := Length(pp); \n nv := Length(vv);\n ns := Length(ss);\n res := []; i:=1; j:=1; k := 1;\n\n while i <= np or j <= nv or k <= ns do\n if (i <= np and j <= nv and k <= ns) and \n domain(pp[i]) = domain(vv[j]) and\n domain(vv[j]) = domain(ss[k]) \n then\n Add(res, combine(pp[i], vv[j], ss[k]));\n i := i+1;\n j := j+1;\n k := k+1;\n else\n p := fId(1);\n v := II(1);\n s := II(1);\n\n if i<=np and domain(pp[i]) = 1 then\n p := pp[i]; i:=i+1; fi;\n if j<=nv and domain(vv[j]) = 1 then\n v := vv[j]; j:=j+1; fi;\n if k<=ns and domain(ss[k]) = 1 then\n s := ss[k]; k:=k+1; fi;\n \n Add(res, combine(p,v,s));\n fi;\n od;\n return res;\nend;\n\n#UseRuleSet(RulesSums);\n\n# pulling in sum of monomials into ISum\nARule( Compose, \n [ @(1, ISum), sum_mons(@(2)) ],\t\n e -> [ ISum(@(1).val.var, @(1).val.domain, @(1).val.child(1) * @(2).val).attrs(@(1).val) ]);\n\n# Gath * SUMAcc(Mon, Mon,...) -> SUMAcc(GMon, GMon, ...)\nARule( Compose, \n [ [Gath, @(1)], sum_mons(@(2)) ],\t\n e -> [ SUMAcc( \n\t let(vdiags := mon_vdiags(@(2)),\n\t sdiags := mon_sdiags(@(2)),\n\t perms := mon_perms(@(2)),\n\t numdiags := Length(vdiags),\n\n\t List([1..numdiags], \n\t\t i -> GMon(fCompose(perms[i], @(1).val), \n\t\t fCompose(vdiags[i], perms[i], @(1).val),\n\t\t fCompose(sdiags[i], perms[i], @(1).val))))) ]\n);\n\n# low-priority suck in of Gath into SUMAcc\nARule( Compose, \n [ @(1, SUMAcc), @(2, Gath) ],\n e -> [ ApplyFunc(ObjId(@(1).val), \n\t List(@(1).val.children(), c -> c * @(2).val)) ]);\n\n\n# Combining GMon and Gath, SMon and Scat, Mon and Prm\nARule( Compose,\n [ @(1, GMon), @(2, Gath) ], # o 1-> 2->\n e -> [ GMon(fCompose(@(2).val.func, @(1).val.perm), \n\t @(1).val.vdiag, @(1).val.sdiag) ] );\n\nARule( Compose,\n [ @(1, Scat), @(2, SMon) ], # o 1-> 2->\n e -> [ GMon(fCompose(@(1).val.func, @(2).val.perm), \n\t @(2).val.vdiag, @(2).val.sdiag) ] );\n\t \nARule( Compose,\n [ @(1, Mon), @(2, Prm) ], # o 1-> 2->\n e -> [ GMon(fCompose(@(2).val.func, @(1).val.perm), \n\t fCompose(@(1).val.vdiag, @(2).val.func.transpose()),\n\t fCompose(@(1).val.sdiag, @(2).val.func.transpose())) ]);\n\n#UseRuleSet(RulesFuncSimp);\n\n# ================================================================\n# Simplification of Intervals\n# ================================================================\n\nfull_interval := (int, size) -> \n [int.target(II), size, zero, @.cond(e->e=size.val)];\n\nleft_interval := (int, size, endd) -> \n [int.target(II), size, zero, endd];\n\nright_interval := (int, size,start) -> \n [int.target(II), size, start, @.cond(e->e=size.val)];\n\n# full interval o index mapping func @(3) = interval with domain of @(3)\n# II(n, 0, n) o f = II(domain(f), 0, domain(f))\nARule( fCompose,\n [ full_interval(@, @(1)), @(2) ],\n e -> [ II(pdomain(@(2))) ]\n);\n\n# partial interval o dirsum of perms\n# II(n, 0, k) o fDirsum(perm_k, perm_?) -> II(n,0,k)\nARule( fCompose, \n [ left_interval(@(0), @(1), @(2)), \n\t[fDirsum, @(3).cond(e -> is_perm(e) and range(e)=@(2).val), ...] ],\n e -> [ @(0).val ]\n);\n\n# partial interval o dirsum of perms\n# II(n, n-k, n) o fDirsum(perm_?, perm_k) -> II(n,n-k,n)\nARule( fCompose, \n [ right_interval(@(0), @(1), @(2)),\n\t[fDirsum, ..., @(4).cond(e -> is_perm(e) and range(e) = @(1).val-@(2).val)] ],\n e -> [ @(0).val ]\n);\n\n\n# fTensor(IIn, IIk) -> II(n*k)\nARule( fTensor, [full_interval(@(0), @(1)), full_interval(@(0), @(2))],\n e -> [ II(@(1).val * @(2).val) ]\n);\n\n\n# fDirsum(IIn, IIk) -> II(n+k)\nARule( fDirsum, [full_interval(@(0), @(1)), full_interval(@(0), @(2))],\n e -> [ II(@(1).val + @(2).val) ]\n);\n\n# Interval Shifting, we support shift left (shift <= start), and right (shift >= end)\n# II o Z = shifted II# \nARule( fCompose, \n [ [II, @(1), @(2), @(3)], \n\t[Z, @(4), @(5).cond(e -> (e<=@(2).val) or (e >= @(3).val)) ] \n ],\n e -> [\tII(@(1).val, (@(2).val-@(5).val) mod @(1).val, \n # this makes 0->size, because size mod size = 0\n\t let(last:=(@(3).val-@(5).val) mod @(1).val, \n\t When(last=0, @(1).val, last))) ]\n);\n \n# full_interval_diag * mat = mat\nARule( Compose, \n [ [Diag, [II, @(1), zero, @(2).cond(e->e=@(1).val)]], @(3) ],\n e -> [ @(3).val ]\n);\n\n# mat * full_interval_diag = mat\nARule( Compose, \n [ @(3), [Diag, [II, @(1), zero, @(2).cond(e->e=@(1).val)]] ],\n e -> [ @(3).val ]\n);\n\n\n# ================================================================\n# Sum of Monomials\n# ================================================================\n# *******************************************************************\nClass( RulesGMonTensorPullOut, RuleSet );\n# *******************************************************************\n\n# GMon splitting\n# GMon(fTensor, fTensor, fTensor) -> Tensor(GMon, GMon, ...)\n#\ntensor_ch := o -> When(IS_A(o, fTensor), o.children(), [o]);\n\nRule([GMon, \n @(1),\n @(2), \n @(3).cond(e -> \n\t let(p := @(1).val, v := @(2).val, s := e, \n\t ForAny([p,v,s], IS(fTensor)) and\n\t compat_tensor_mons(tensor_ch(p), tensor_ch(v), tensor_ch(s))))],\n e -> let(\n cp := tensor_ch(@(1).val),\n cv := tensor_ch(@(2).val),\n cs := tensor_ch(@(3).val),\n Tensor( merge_tensor_mons(cp, cv, cs, GMon) ))\n);\n\n# ================================================================\n# GMon -> SGMon\n# (delta * gath)\n# ================================================================\n# *******************************************************************\nClass( RulesGMonToSGMon, RuleSet );\n# *******************************************************************\n\nRule( [ GMon, @(1), @(2), full_interval(@(3),@(4)) ],\n e -> SGMon(fId(domain(@(1).val)), # scatter\n\t @(1).val, # gather\n\t @(2).val, # vdiag,\n\t @(3).val));\n\n## Diag(II) * Diag(..) * Gath(fId)\nRule( [ GMon, @(1,fId), @(2), @(3,II) ],\n e -> let(left := @(3).val.params[2], \n right:= @(3).val.params[3],\n size := @(3).val.params[1],\n\t fadd := fAdd(size, right-left, left),\n SGMon(fadd, fadd, \n fCompose(@(2).val, fadd), II(right-left)))\n);\n\n## Diag(II) * Diag(..) * Gath(Z)\nRule( [ GMon, \n\t[Z, @n, @z],\n\t@(1), \n\t[II, @, @l, @(3).cond(r -> (@z.val <= @n.val-r) or \n\t\t (@z.val >= @n.val-@l.val)) ] ],\ne -> let(size := @n.val, \n\t left := @l.val, \n right := @(3).val, \n\t shift := @z.val,\n\t scat := fAdd(size, right-left, left),\n\t gath := fAdd(size, right-left, (left + shift) mod size),\n SGMon(scat, gath, \n\t fCompose(@(1).val, scat), II(domain(gath))))\n);\n\n\n## Diag(II o fBase) * Gath(fBase)\nRule([GMon, \n\t@(1,fBase), \n\t@(2), \n\t[fCompose, @(3,II), same_params(@(4),fBase,@(1)) ] ],\n\n e -> let(left := @(3).val.params[2], right := @(3).val.params[3], \n j := @(1).val.params[2], \n\t gath := @(1).val,\n\t COND(leq(left, j, right-1), \n\t SGMon(fId(1), gath, @(2).val, II(1)),\n\t O(1, range(gath))))\n);\n\n## Diag(II o fBase) * Gath(fId(1))\nRule([skip, \n\t@(1,fId,e->range(e)=1),\n\t@(2), \n\t[fCompose, @(3,II), @(4,fBase) ] ],\n\n e -> let(left := @(3).val.params[2], right := @(3).val.params[3], \n j := @(4).val.params[2], \n\t COND(leq(left, j, right-1), \n\t SGMon(fId(1), fId(1), @(2).val, II(1)),\n\t O(1, 1)))\n);\n\n# NOTE:Make direct sum rules more general (... + p + ...) o fBase\n#\n## Diag(leftII o fBase) * Gath((p + ...) o fBase) \nRule([GMon, \n [fCompose, \n\t [fDirsum, @(1).cond(e -> is_perm(e)), ...],\n\t @(2,fBase) ],\n\t@(3),\n\t[fCompose, left_interval(@(10), @(20), @(4).cond(e->range(@(1).val)=e)), \n\t same_params(@(5), fBase, @(2))] ],\n\n e -> let(right := @(4).val,\n size := @(2).val.params[1],\n j := @(2).val.params[2], \n\t COND(leq(0, j, right-1), \n\t SGMon(\n\t\t fId(1),\n\t\t fCompose(fAdd(size, right, 0), @(1).val, fBase(right, j)),\n\t\t @(3).val,\n\t\t II(1)),\n\t O(1, size)))\n);\n\n## Diag(rightII o fBase) * Gath((... + p) o fBase)\nRule([GMon, \n [fCompose, \n\t [fDirsum, ..., @(1).cond(e -> is_perm(e))],\n\t @(2,fBase) ],\n\t@(3),\n\t[fCompose, right_interval(@(0), @(4), @(5).cond(e->range(@(1).val) = @(4).val - e)), \n\t same_params(@(6), fBase, @(2)) ] ],\n\n e -> let(left := @(4).val,\n size := @(2).val.params[1],\n j := @(2).val.params[2], \n\t COND(leq(left, j, size-1), \n\t SGMon(\n\t\t fId(1),\n\t\t fCompose(fAdd(size, size-left, left), @(1).val, fBase(size-left, j-left)),\n\t\t @(3).val,\n\t\t II(1)),\n\t O(1, size)))\n);\n \n# ================================================================\n# Going back from Tensor(SGMon, ...) into SGMon(fTensor,...)\n# ================================================================\n\nRule([@(0,Tensor), ..., @(1,COND), ...],\n e -> let( ch := e.children(), \n\t left := Left(...), \n\t right := Right(...),\n\t leftch := ch{[1..left]},\n\t rightch := ch{[right..Length(ch)]},\n\t OP := ObjId(@(0).val),\n\t COND(@(1).val.cond,\n\t\t List(@(1).val.children(), \n\t\t c -> OP(Concatenation(Copy(leftch), [c], Copy(rightch)))))));\n\n# *******************************************************************\nClass( RulesSGMonTensorPullIn, RuleSet );\n# *******************************************************************\n\nRule( @(1,Tensor,CHILDREN_ARE(SGMon)),\n e -> let( ch:=e.children(),\n SGMon(\n\t fTensor(List(ch, c->c.scat)),\n\t fTensor(List(ch, c->c.gath)),\n\t fTensor(List(ch, c->c.vdiag)),\n\t fTensor(List(ch, c->c.sdiag)))));\n\t \n# ================================================================\n# Finalization\n# ================================================================\nClass( RulesFinalize, RuleSet );\n\n#z:=SUMAcc(Gath(fId(4)), Scat(fAdd(4,3,0)) * Gath(fAdd(4,3,0)));\n\nElim := (elim_func, s) -> When(elim_func(s), [], s);\n\nARule(SUMAcc, \n [ [Gath, @R],\n [Compose, \n\t [@(1,Scat), [@(2,fAdd), @, @, @k]], \n\t [@(3,Gath), @S]] ],\n\n e -> let(n := domain(@R.val), N := range(@R.val), \n\t nmk := domain(@S.val), nm := nmk + @k.val, \n\t m := n - nm, \n [ SUM( Elim(e->@k.val=0, Scat(fAdd(n, @k.val, 0)) * Gath(fCompose(@R.val, fAdd(n, @k.val, 0)))),\n\t Scat(Copy(@(2).val)) * \n\t SUMAcc(\n\t Gath(fCompose(@R.val, fAdd(n, nmk, @k.val))),\n\t Gath(@S.val)),\n\t Elim(e->m=0, Scat(fAdd(n, m, nm)) * Gath(fCompose(@R.val, fAdd(n, m, nm))))\n ) ])\n);\n\nARule(Compose,\n [ [Scat, @W], \n @(1, SUMAcc, e->ForAll(e.children(), c->ObjId(c)=Gath and domain(c.func)>1)) ],\n\n e -> [ let(n := domain(@W.val), \n\t i := Ind(n),\n\t fbase := fBase(n, i),\n\t ISum(i, n, \n\t Scat(fCompose(@W.val, fbase)) *\n\t SUMAcc(List(@(1).val.children(), c -> Gath(fCompose(c.func, fbase)))))) ]\n);\n\n \nARule(Compose,\n [ [Scat, @W], [Diag, @D], [Gath, @R] ],\n\n e -> [ let(n := domain(@R.val), \n\t i := Ind(n),\n\t fbase := fBase(n, i),\n\t ISum(i, n, \n\t Scat(fCompose(@W.val, fbase)) *\n\t Blk1(@D.val.lambda().at(i)) *\n\t Gath(fCompose(@R.val, fbase)))) ]\n);\n\nARule(Compose, [@(1, O), @(2)], e->[ @(1).val ]);\n\nRule([Compose, [Scat, @(1)], @(2, O)], e->\n let(n := @(1).val.domain(),\n\ti := Ind(n),\n\tfbase := fBase(n,i),\n\tISum(i, n,\n\t Scat(fCompose(@(1).val, fbase)) * \n\t Blk1(0) * \n\t Gath(fCompose(fId(Cols(@(2).val)), fbase))))\n);\n", "meta": {"hexsha": "ed849440316f1a0304a0454041ea81b7f4a85065", "size": 12272, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sigma/mon_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/mon_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/mon_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": 30.3012345679, "max_line_length": 100, "alphanum_fraction": 0.4381518905, "num_tokens": 4030, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.3786937978460437}} | |
| {"text": "#############################################################################\n##\n#W In this file we prepare functions to loop over the 2,3 or 4 dimensional\n#W crystallographic groups as matrix groups or pcp groups.\n##\n\ncryst4params:=\n[ [ 1, 1, 1, 1 ], [ 1, 2, 1, 1 ], [ 2, 1, 1, 1 ], [ 2, 1, 1, 2 ], \n [ 2, 1, 2, 1 ], [ 2, 1, 2, 2 ], [ 2, 2, 1, 1 ], [ 2, 2, 1, 2 ], \n [ 2, 2, 2, 1 ], [ 2, 3, 1, 1 ], [ 2, 3, 1, 2 ], [ 2, 3, 1, 3 ], \n [ 2, 3, 1, 4 ], [ 2, 3, 2, 1 ], [ 2, 3, 2, 2 ], [ 3, 1, 1, 1 ], \n [ 3, 1, 1, 2 ], [ 3, 1, 2, 1 ], [ 3, 1, 2, 2 ], [ 3, 1, 3, 1 ], \n [ 3, 2, 1, 1 ], [ 3, 2, 1, 2 ], [ 3, 2, 1, 3 ], [ 3, 2, 2, 1 ], \n [ 3, 2, 2, 2 ], [ 3, 2, 2, 3 ], [ 3, 2, 3, 1 ], [ 4, 1, 1, 1 ], \n [ 4, 1, 1, 2 ], [ 4, 1, 1, 3 ], [ 4, 1, 1, 4 ], [ 4, 1, 1, 5 ], \n [ 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 6, 3, 1, 86 ], [ 6, 3, 1, 87 ], [ 6, 3, 1, 88 ], \n [ 6, 3, 1, 89 ], [ 6, 3, 1, 90 ], [ 6, 3, 1, 91 ], [ 6, 3, 1, 92 ], \n [ 6, 3, 1, 93 ], [ 6, 3, 1, 94 ], [ 6, 3, 1, 95 ], [ 6, 3, 1, 96 ], \n [ 6, 3, 1, 97 ], [ 6, 3, 1, 98 ], [ 6, 3, 1, 99 ], [ 6, 3, 1, 100 ], \n [ 6, 3, 1, 101 ], [ 6, 3, 1, 102 ], [ 6, 3, 1, 103 ], [ 6, 3, 1, 104 ], \n [ 6, 3, 1, 105 ], [ 6, 3, 1, 106 ], [ 6, 3, 1, 107 ], [ 6, 3, 1, 108 ], \n [ 6, 3, 1, 109 ], [ 6, 3, 1, 110 ], [ 6, 3, 1, 111 ], [ 6, 3, 1, 112 ], \n [ 6, 3, 1, 113 ], [ 6, 3, 1, 114 ], [ 6, 3, 1, 115 ], [ 6, 3, 1, 116 ], \n [ 6, 3, 1, 117 ], [ 6, 3, 1, 118 ], [ 6, 3, 1, 119 ], [ 6, 3, 1, 120 ], \n [ 6, 3, 1, 121 ], [ 6, 3, 1, 122 ], [ 6, 3, 1, 123 ], [ 6, 3, 1, 124 ], \n [ 6, 3, 1, 125 ], [ 6, 3, 1, 126 ], [ 6, 3, 1, 127 ], [ 6, 3, 1, 128 ], \n [ 6, 3, 1, 129 ], [ 6, 3, 1, 130 ], [ 6, 3, 1, 131 ], [ 6, 3, 1, 132 ], \n [ 6, 3, 1, 133 ], [ 6, 3, 1, 134 ], [ 6, 3, 1, 135 ], [ 6, 3, 1, 136 ], \n [ 6, 3, 1, 137 ], [ 6, 3, 1, 138 ], [ 6, 3, 1, 139 ], [ 6, 3, 1, 140 ], \n [ 6, 3, 1, 141 ], [ 6, 3, 1, 142 ], [ 6, 3, 1, 143 ], [ 6, 3, 1, 144 ], \n [ 6, 3, 1, 145 ], [ 6, 3, 1, 146 ], [ 6, 3, 1, 147 ], [ 6, 3, 1, 148 ], \n [ 6, 3, 1, 149 ], [ 6, 3, 1, 150 ], [ 6, 3, 1, 151 ], [ 6, 3, 1, 152 ], \n [ 6, 3, 1, 153 ], [ 6, 3, 1, 154 ], [ 6, 3, 1, 155 ], [ 6, 3, 1, 156 ], \n [ 6, 3, 1, 157 ], [ 6, 3, 1, 158 ], [ 6, 3, 1, 159 ], [ 6, 3, 1, 160 ], \n [ 6, 3, 1, 161 ], [ 6, 3, 1, 162 ], [ 6, 3, 1, 163 ], [ 6, 3, 1, 164 ], \n [ 6, 3, 1, 165 ], [ 6, 3, 1, 166 ], [ 6, 3, 1, 167 ], [ 6, 3, 1, 168 ], \n [ 6, 3, 1, 169 ], [ 6, 3, 1, 170 ], [ 6, 3, 1, 171 ], [ 6, 3, 1, 172 ], \n [ 6, 3, 1, 173 ], [ 6, 3, 1, 174 ], [ 6, 3, 1, 175 ], [ 6, 3, 1, 176 ], \n [ 6, 3, 1, 177 ], [ 6, 3, 1, 178 ], [ 6, 3, 1, 179 ], [ 6, 3, 1, 180 ], \n [ 6, 3, 1, 181 ], [ 6, 3, 1, 182 ], [ 6, 3, 1, 183 ], [ 6, 3, 1, 184 ], \n [ 6, 3, 1, 185 ], [ 6, 3, 1, 186 ], [ 6, 3, 1, 187 ], [ 6, 3, 1, 188 ], \n [ 6, 3, 1, 189 ], [ 6, 3, 1, 190 ], [ 6, 3, 1, 191 ], [ 6, 3, 1, 192 ], \n [ 6, 3, 1, 193 ], [ 6, 3, 1, 194 ], [ 6, 3, 1, 195 ], [ 6, 3, 1, 196 ], \n [ 6, 3, 1, 197 ], [ 6, 3, 1, 198 ], [ 6, 3, 1, 199 ], [ 6, 3, 1, 200 ], \n [ 6, 3, 1, 201 ], [ 6, 3, 1, 202 ], [ 6, 3, 1, 203 ], [ 6, 3, 1, 204 ], \n [ 6, 3, 1, 205 ], [ 6, 3, 1, 206 ], [ 6, 3, 1, 207 ], [ 6, 3, 1, 208 ], \n [ 6, 3, 1, 209 ], [ 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 ], \n [ 12, 5, 2, 8 ], [ 12, 5, 2, 9 ], [ 12, 5, 2, 10 ], [ 12, 5, 2, 11 ], \n [ 12, 5, 2, 12 ], [ 12, 5, 2, 13 ], [ 12, 5, 2, 14 ], [ 12, 5, 2, 15 ], \n [ 12, 5, 2, 16 ], [ 12, 5, 2, 17 ], [ 12, 5, 2, 18 ], [ 12, 5, 2, 19 ], \n [ 12, 5, 2, 20 ], [ 12, 5, 2, 21 ], [ 12, 5, 2, 22 ], [ 12, 5, 2, 23 ], \n [ 12, 5, 2, 24 ], [ 12, 5, 2, 25 ], [ 12, 5, 2, 26 ], [ 12, 5, 2, 27 ], \n [ 12, 5, 2, 28 ], [ 12, 5, 2, 29 ], [ 12, 5, 2, 30 ], [ 12, 5, 2, 31 ], \n [ 12, 5, 2, 32 ], [ 12, 5, 2, 33 ], [ 12, 5, 2, 34 ], [ 12, 5, 2, 35 ], \n [ 12, 5, 2, 36 ], [ 12, 5, 3, 1 ], [ 12, 5, 3, 2 ], [ 12, 5, 3, 3 ], \n [ 12, 5, 3, 4 ], [ 12, 5, 3, 5 ], [ 12, 5, 3, 6 ], [ 12, 5, 3, 7 ], \n [ 12, 5, 3, 8 ], [ 12, 5, 3, 9 ], [ 12, 5, 3, 10 ], [ 12, 5, 3, 11 ], \n [ 12, 5, 3, 12 ], [ 12, 5, 3, 13 ], [ 12, 5, 3, 14 ], [ 12, 5, 3, 15 ], \n [ 12, 5, 3, 16 ], [ 12, 5, 3, 17 ], [ 12, 5, 3, 18 ], [ 12, 5, 3, 19 ], \n [ 12, 5, 3, 20 ], [ 12, 5, 3, 21 ], [ 12, 5, 3, 22 ], [ 12, 5, 3, 23 ], \n [ 12, 5, 3, 24 ], [ 12, 5, 3, 25 ], [ 12, 5, 3, 26 ], [ 12, 5, 3, 27 ], \n [ 12, 5, 3, 28 ], [ 12, 5, 3, 29 ], [ 12, 5, 3, 30 ], [ 12, 5, 3, 31 ], \n [ 12, 5, 3, 32 ], [ 12, 5, 3, 33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], \n [ 12, 5, 8, 3 ], [ 12, 5, 8, 4 ], [ 12, 5, 8, 5 ], [ 12, 5, 8, 6 ], \n [ 12, 5, 8, 7 ], [ 12, 5, 8, 8 ], [ 12, 5, 8, 9 ], [ 12, 5, 9, 1 ], \n [ 12, 5, 9, 2 ], [ 12, 5, 9, 3 ], [ 12, 5, 9, 4 ], [ 12, 5, 9, 5 ], \n [ 12, 5, 9, 6 ], [ 12, 5, 10, 1 ], [ 12, 5, 10, 2 ], [ 12, 5, 10, 3 ], \n [ 12, 5, 11, 1 ], [ 12, 5, 11, 2 ], [ 12, 5, 11, 3 ], [ 12, 5, 11, 4 ], \n [ 12, 5, 11, 5 ], [ 12, 5, 11, 6 ], [ 12, 5, 11, 7 ], [ 12, 5, 11, 8 ], \n [ 12, 5, 11, 9 ], [ 13, 1, 1, 1 ], [ 13, 1, 1, 2 ], [ 13, 1, 1, 3 ], \n [ 13, 1, 1, 4 ], [ 13, 1, 1, 5 ], [ 13, 1, 1, 6 ], [ 13, 1, 1, 7 ], \n [ 13, 1, 1, 8 ], [ 13, 1, 1, 9 ], [ 13, 1, 1, 10 ], [ 13, 1, 1, 11 ], \n [ 13, 1, 1, 12 ], [ 13, 1, 1, 13 ], [ 13, 1, 1, 14 ], [ 13, 1, 1, 15 ], \n [ 13, 1, 1, 16 ], [ 13, 1, 1, 17 ], [ 13, 1, 1, 18 ], [ 13, 1, 1, 19 ], \n [ 13, 1, 1, 20 ], [ 13, 1, 1, 21 ], [ 13, 1, 1, 22 ], [ 13, 1, 1, 23 ], \n [ 13, 1, 1, 24 ], [ 13, 1, 2, 1 ], [ 13, 1, 2, 2 ], [ 13, 1, 2, 3 ], \n [ 13, 1, 2, 4 ], [ 13, 1, 2, 5 ], [ 13, 1, 2, 6 ], [ 13, 1, 3, 1 ], \n [ 13, 1, 3, 2 ], [ 13, 1, 3, 3 ], [ 13, 1, 3, 4 ], [ 13, 1, 3, 5 ], \n [ 13, 1, 3, 6 ], [ 13, 1, 3, 7 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 13, 4, 6, 2 ], [ 13, 4, 6, 3 ], \n [ 13, 4, 6, 4 ], [ 13, 5, 1, 1 ], [ 13, 5, 1, 2 ], [ 13, 5, 1, 3 ], \n [ 13, 5, 1, 4 ], [ 13, 5, 1, 5 ], [ 13, 5, 1, 6 ], [ 13, 5, 1, 7 ], \n [ 13, 5, 1, 8 ], [ 13, 5, 1, 9 ], [ 13, 5, 1, 10 ], [ 13, 5, 1, 11 ], \n [ 13, 5, 1, 12 ], [ 13, 5, 1, 13 ], [ 13, 5, 1, 14 ], [ 13, 5, 1, 15 ], \n [ 13, 5, 1, 16 ], [ 13, 5, 1, 17 ], [ 13, 5, 1, 18 ], [ 13, 5, 1, 19 ], \n [ 13, 5, 1, 20 ], [ 13, 5, 1, 21 ], [ 13, 5, 1, 22 ], [ 13, 5, 1, 23 ], \n [ 13, 5, 1, 24 ], [ 13, 5, 1, 25 ], [ 13, 5, 1, 26 ], [ 13, 5, 1, 27 ], \n [ 13, 5, 1, 28 ], [ 13, 5, 1, 29 ], [ 13, 5, 1, 30 ], [ 13, 5, 1, 31 ], \n [ 13, 5, 1, 32 ], [ 13, 5, 1, 33 ], [ 13, 5, 1, 34 ], [ 13, 5, 1, 35 ], \n [ 13, 5, 1, 36 ], [ 13, 5, 2, 1 ], [ 13, 5, 2, 2 ], [ 13, 5, 2, 3 ], \n [ 13, 5, 2, 4 ], [ 13, 5, 2, 5 ], [ 13, 5, 2, 6 ], [ 13, 5, 3, 1 ], \n [ 13, 5, 3, 2 ], [ 13, 5, 3, 3 ], [ 13, 5, 3, 4 ], [ 13, 5, 3, 5 ], \n [ 13, 5, 3, 6 ], [ 13, 5, 3, 7 ], [ 13, 5, 3, 8 ], [ 13, 5, 3, 9 ], \n [ 13, 5, 3, 10 ], [ 13, 5, 3, 11 ], [ 13, 5, 3, 12 ], [ 13, 5, 3, 13 ], \n [ 13, 5, 3, 14 ], [ 13, 5, 3, 15 ], [ 13, 5, 3, 16 ], [ 13, 5, 4, 1 ], \n [ 13, 5, 4, 2 ], [ 13, 5, 4, 3 ], [ 13, 5, 4, 4 ], [ 13, 5, 4, 5 ], \n [ 13, 5, 4, 6 ], [ 13, 5, 5, 1 ], [ 13, 5, 5, 2 ], [ 13, 5, 5, 3 ], \n [ 13, 6, 1, 1 ], [ 13, 6, 1, 2 ], [ 13, 6, 1, 3 ], [ 13, 6, 1, 4 ], \n [ 13, 6, 1, 5 ], [ 13, 6, 1, 6 ], [ 13, 6, 1, 7 ], [ 13, 6, 1, 8 ], \n [ 13, 6, 1, 9 ], [ 13, 6, 1, 10 ], [ 13, 6, 1, 11 ], [ 13, 6, 1, 12 ], \n [ 13, 6, 1, 13 ], [ 13, 6, 1, 14 ], [ 13, 6, 1, 15 ], [ 13, 6, 1, 16 ], \n [ 13, 6, 1, 17 ], [ 13, 6, 1, 18 ], [ 13, 6, 1, 19 ], [ 13, 6, 1, 20 ], \n [ 13, 6, 1, 21 ], [ 13, 6, 1, 22 ], [ 13, 6, 1, 23 ], [ 13, 6, 1, 24 ], \n [ 13, 6, 1, 25 ], [ 13, 6, 1, 26 ], [ 13, 6, 1, 27 ], [ 13, 6, 1, 28 ], \n [ 13, 6, 1, 29 ], [ 13, 6, 1, 30 ], [ 13, 6, 1, 31 ], [ 13, 6, 1, 32 ], \n [ 13, 6, 1, 33 ], [ 13, 6, 1, 34 ], [ 13, 6, 1, 35 ], [ 13, 6, 1, 36 ], \n [ 13, 6, 1, 37 ], [ 13, 6, 1, 38 ], [ 13, 6, 1, 39 ], [ 13, 6, 1, 40 ], \n [ 13, 6, 1, 41 ], [ 13, 6, 1, 42 ], [ 13, 6, 1, 43 ], [ 13, 6, 1, 44 ], \n [ 13, 6, 1, 45 ], [ 13, 6, 1, 46 ], [ 13, 6, 1, 47 ], [ 13, 6, 1, 48 ], \n [ 13, 6, 1, 49 ], [ 13, 6, 1, 50 ], [ 13, 6, 1, 51 ], [ 13, 6, 1, 52 ], \n [ 13, 6, 1, 53 ], [ 13, 6, 1, 54 ], [ 13, 6, 1, 55 ], [ 13, 6, 1, 56 ], \n [ 13, 6, 1, 57 ], [ 13, 6, 1, 58 ], [ 13, 6, 1, 59 ], [ 13, 6, 1, 60 ], \n [ 13, 6, 1, 61 ], [ 13, 6, 1, 62 ], [ 13, 6, 1, 63 ], [ 13, 6, 1, 64 ], \n [ 13, 6, 1, 65 ], [ 13, 6, 1, 66 ], [ 13, 6, 1, 67 ], [ 13, 6, 1, 68 ], \n [ 13, 6, 1, 69 ], [ 13, 6, 1, 70 ], [ 13, 6, 1, 71 ], [ 13, 6, 1, 72 ], \n [ 13, 6, 1, 73 ], [ 13, 6, 1, 74 ], [ 13, 6, 1, 75 ], [ 13, 6, 1, 76 ], \n [ 13, 6, 1, 77 ], [ 13, 6, 1, 78 ], [ 13, 6, 1, 79 ], [ 13, 6, 1, 80 ], \n [ 13, 6, 1, 81 ], [ 13, 6, 1, 82 ], [ 13, 6, 1, 83 ], [ 13, 6, 1, 84 ], \n [ 13, 6, 1, 85 ], [ 13, 6, 1, 86 ], [ 13, 6, 1, 87 ], [ 13, 6, 1, 88 ], \n [ 13, 6, 1, 89 ], [ 13, 6, 1, 90 ], [ 13, 6, 1, 91 ], [ 13, 6, 1, 92 ], \n [ 13, 6, 1, 93 ], [ 13, 6, 1, 94 ], [ 13, 6, 1, 95 ], [ 13, 6, 1, 96 ], \n [ 13, 6, 1, 97 ], [ 13, 6, 1, 98 ], [ 13, 6, 1, 99 ], [ 13, 6, 1, 100 ], \n [ 13, 6, 1, 101 ], [ 13, 6, 1, 102 ], [ 13, 6, 1, 103 ], [ 13, 6, 1, 104 ], \n [ 13, 6, 1, 105 ], [ 13, 6, 1, 106 ], [ 13, 6, 1, 107 ], [ 13, 6, 1, 108 ], \n [ 13, 6, 1, 109 ], [ 13, 6, 1, 110 ], [ 13, 6, 1, 111 ], [ 13, 6, 1, 112 ], \n [ 13, 6, 1, 113 ], [ 13, 6, 1, 114 ], [ 13, 6, 1, 115 ], [ 13, 6, 1, 116 ], \n [ 13, 6, 1, 117 ], [ 13, 6, 1, 118 ], [ 13, 6, 1, 119 ], [ 13, 6, 1, 120 ], \n [ 13, 6, 1, 121 ], [ 13, 6, 1, 122 ], [ 13, 6, 1, 123 ], [ 13, 6, 1, 124 ], \n [ 13, 6, 1, 125 ], [ 13, 6, 1, 126 ], [ 13, 6, 1, 127 ], [ 13, 6, 1, 128 ], \n [ 13, 6, 2, 1 ], [ 13, 6, 2, 2 ], [ 13, 6, 2, 3 ], [ 13, 6, 2, 4 ], \n [ 13, 6, 2, 5 ], [ 13, 6, 2, 6 ], [ 13, 6, 2, 7 ], [ 13, 6, 2, 8 ], \n [ 13, 6, 2, 9 ], [ 13, 6, 2, 10 ], [ 13, 6, 2, 11 ], [ 13, 6, 2, 12 ], \n [ 13, 6, 2, 13 ], [ 13, 6, 2, 14 ], [ 13, 6, 2, 15 ], [ 13, 6, 2, 16 ], \n [ 13, 6, 3, 1 ], [ 13, 6, 3, 2 ], [ 13, 6, 3, 3 ], [ 13, 6, 3, 4 ], \n [ 13, 6, 3, 5 ], [ 13, 6, 3, 6 ], [ 13, 6, 3, 7 ], [ 13, 6, 3, 8 ], \n [ 13, 6, 3, 9 ], [ 13, 6, 3, 10 ], [ 13, 6, 3, 11 ], [ 13, 6, 3, 12 ], \n [ 13, 6, 3, 13 ], [ 13, 6, 3, 14 ], [ 13, 6, 3, 15 ], [ 13, 6, 3, 16 ], \n [ 13, 6, 3, 17 ], [ 13, 6, 3, 18 ], [ 13, 6, 3, 19 ], [ 13, 6, 3, 20 ], \n [ 13, 6, 3, 21 ], [ 13, 6, 3, 22 ], [ 13, 6, 3, 23 ], [ 13, 6, 3, 24 ], \n [ 13, 6, 3, 25 ], [ 13, 6, 3, 26 ], [ 13, 6, 3, 27 ], [ 13, 6, 3, 28 ], \n [ 13, 6, 3, 29 ], [ 13, 6, 3, 30 ], [ 13, 6, 3, 31 ], [ 13, 6, 3, 32 ], \n [ 13, 6, 4, 1 ], [ 13, 6, 4, 2 ], [ 13, 6, 4, 3 ], [ 13, 6, 4, 4 ], \n [ 13, 6, 4, 5 ], [ 13, 6, 4, 6 ], [ 13, 6, 4, 7 ], [ 13, 6, 4, 8 ], \n [ 13, 6, 4, 9 ], [ 13, 6, 4, 10 ], [ 13, 6, 4, 11 ], [ 13, 6, 4, 12 ], \n [ 13, 6, 4, 13 ], [ 13, 6, 4, 14 ], [ 13, 6, 4, 15 ], [ 13, 6, 4, 16 ], \n [ 13, 6, 4, 17 ], [ 13, 6, 4, 18 ], [ 13, 6, 4, 19 ], [ 13, 6, 4, 20 ], \n [ 13, 6, 4, 21 ], [ 13, 6, 4, 22 ], [ 13, 6, 4, 23 ], [ 13, 6, 4, 24 ], \n [ 13, 6, 4, 25 ], [ 13, 6, 4, 26 ], [ 13, 6, 4, 27 ], [ 13, 6, 4, 28 ], \n [ 13, 6, 4, 29 ], [ 13, 6, 4, 30 ], [ 13, 6, 4, 31 ], [ 13, 6, 4, 32 ], \n [ 13, 6, 5, 1 ], [ 13, 6, 5, 2 ], [ 13, 6, 5, 3 ], [ 13, 6, 5, 4 ], \n [ 13, 6, 5, 5 ], [ 13, 6, 5, 6 ], [ 13, 6, 5, 7 ], [ 13, 6, 5, 8 ], \n [ 13, 6, 5, 9 ], [ 13, 6, 5, 10 ], [ 13, 6, 5, 11 ], [ 13, 6, 5, 12 ], \n [ 13, 6, 5, 13 ], [ 13, 6, 5, 14 ], [ 13, 6, 5, 15 ], [ 13, 6, 5, 16 ], \n [ 13, 6, 6, 1 ], [ 13, 6, 6, 2 ], [ 13, 6, 6, 3 ], [ 13, 6, 6, 4 ], \n [ 13, 6, 6, 5 ], [ 13, 6, 6, 6 ], [ 13, 6, 6, 7 ], [ 13, 6, 6, 8 ], \n [ 13, 7, 1, 1 ], [ 13, 7, 1, 2 ], [ 13, 7, 1, 3 ], [ 13, 7, 1, 4 ], \n [ 13, 7, 1, 5 ], [ 13, 7, 1, 6 ], [ 13, 7, 1, 7 ], [ 13, 7, 1, 8 ], \n [ 13, 7, 1, 9 ], [ 13, 7, 1, 10 ], [ 13, 7, 1, 11 ], [ 13, 7, 1, 12 ], \n [ 13, 7, 1, 13 ], [ 13, 7, 1, 14 ], [ 13, 7, 1, 15 ], [ 13, 7, 1, 16 ], \n [ 13, 7, 1, 17 ], [ 13, 7, 1, 18 ], [ 13, 7, 1, 19 ], [ 13, 7, 1, 20 ], \n [ 13, 7, 1, 21 ], [ 13, 7, 1, 22 ], [ 13, 7, 1, 23 ], [ 13, 7, 1, 24 ], \n [ 13, 7, 1, 25 ], [ 13, 7, 1, 26 ], [ 13, 7, 1, 27 ], [ 13, 7, 1, 28 ], \n [ 13, 7, 1, 29 ], [ 13, 7, 1, 30 ], [ 13, 7, 1, 31 ], [ 13, 7, 1, 32 ], \n [ 13, 7, 1, 33 ], [ 13, 7, 1, 34 ], [ 13, 7, 1, 35 ], [ 13, 7, 1, 36 ], \n [ 13, 7, 1, 37 ], [ 13, 7, 1, 38 ], [ 13, 7, 1, 39 ], [ 13, 7, 1, 40 ], \n [ 13, 7, 1, 41 ], [ 13, 7, 1, 42 ], [ 13, 7, 1, 43 ], [ 13, 7, 1, 44 ], \n [ 13, 7, 1, 45 ], [ 13, 7, 1, 46 ], [ 13, 7, 1, 47 ], [ 13, 7, 1, 48 ], \n [ 13, 7, 1, 49 ], [ 13, 7, 1, 50 ], [ 13, 7, 1, 51 ], [ 13, 7, 1, 52 ], \n [ 13, 7, 1, 53 ], [ 13, 7, 1, 54 ], [ 13, 7, 1, 55 ], [ 13, 7, 1, 56 ], \n [ 13, 7, 1, 57 ], [ 13, 7, 1, 58 ], [ 13, 7, 1, 59 ], [ 13, 7, 1, 60 ], \n [ 13, 7, 1, 61 ], [ 13, 7, 1, 62 ], [ 13, 7, 1, 63 ], [ 13, 7, 1, 64 ], \n [ 13, 7, 2, 1 ], [ 13, 7, 2, 2 ], [ 13, 7, 2, 3 ], [ 13, 7, 2, 4 ], \n [ 13, 7, 2, 5 ], [ 13, 7, 2, 6 ], [ 13, 7, 2, 7 ], [ 13, 7, 2, 8 ], \n [ 13, 7, 2, 9 ], [ 13, 7, 2, 10 ], [ 13, 7, 2, 11 ], [ 13, 7, 2, 12 ], \n [ 13, 7, 2, 13 ], [ 13, 7, 2, 14 ], [ 13, 7, 2, 15 ], [ 13, 7, 2, 16 ], \n [ 13, 7, 2, 17 ], [ 13, 7, 2, 18 ], [ 13, 7, 2, 19 ], [ 13, 7, 2, 20 ], \n [ 13, 7, 2, 21 ], [ 13, 7, 2, 22 ], [ 13, 7, 2, 23 ], [ 13, 7, 2, 24 ], \n [ 13, 7, 2, 25 ], [ 13, 7, 2, 26 ], [ 13, 7, 2, 27 ], [ 13, 7, 2, 28 ], \n [ 13, 7, 2, 29 ], [ 13, 7, 2, 30 ], [ 13, 7, 2, 31 ], [ 13, 7, 2, 32 ], \n [ 13, 7, 2, 33 ], [ 13, 7, 2, 34 ], [ 13, 7, 2, 35 ], [ 13, 7, 2, 36 ], \n [ 13, 7, 2, 37 ], [ 13, 7, 2, 38 ], [ 13, 7, 2, 39 ], [ 13, 7, 2, 40 ], \n [ 13, 7, 2, 41 ], [ 13, 7, 2, 42 ], [ 13, 7, 2, 43 ], [ 13, 7, 2, 44 ], \n [ 13, 7, 2, 45 ], [ 13, 7, 2, 46 ], [ 13, 7, 2, 47 ], [ 13, 7, 2, 48 ], \n [ 13, 7, 2, 49 ], [ 13, 7, 2, 50 ], [ 13, 7, 2, 51 ], [ 13, 7, 2, 52 ], \n [ 13, 7, 2, 53 ], [ 13, 7, 2, 54 ], [ 13, 7, 2, 55 ], [ 13, 7, 2, 56 ], \n [ 13, 7, 2, 57 ], [ 13, 7, 2, 58 ], [ 13, 7, 2, 59 ], [ 13, 7, 2, 60 ], \n [ 13, 7, 2, 61 ], [ 13, 7, 2, 62 ], [ 13, 7, 2, 63 ], [ 13, 7, 2, 64 ], \n [ 13, 7, 3, 1 ], [ 13, 7, 3, 2 ], [ 13, 7, 3, 3 ], [ 13, 7, 3, 4 ], \n [ 13, 7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8, 3 ], [ 13, 7, 8, 4 ], \n [ 13, 7, 8, 5 ], [ 13, 7, 8, 6 ], [ 13, 7, 8, 7 ], [ 13, 7, 8, 8 ], \n [ 13, 7, 8, 9 ], [ 13, 7, 8, 10 ], [ 13, 7, 8, 11 ], [ 13, 7, 8, 12 ], \n [ 13, 7, 8, 13 ], [ 13, 7, 8, 14 ], [ 13, 7, 8, 15 ], [ 13, 7, 8, 16 ], \n [ 13, 7, 9, 1 ], [ 13, 7, 9, 2 ], [ 13, 7, 9, 3 ], [ 13, 7, 9, 4 ], \n [ 13, 7, 9, 5 ], [ 13, 7, 9, 6 ], [ 13, 7, 9, 7 ], [ 13, 7, 9, 8 ], \n [ 13, 7, 10, 1 ], [ 13, 7, 10, 2 ], [ 13, 7, 10, 3 ], [ 13, 7, 10, 4 ], \n [ 13, 7, 10, 5 ], [ 13, 7, 10, 6 ], [ 13, 7, 10, 7 ], [ 13, 7, 10, 8 ], \n [ 13, 7, 11, 1 ], [ 13, 7, 11, 2 ], [ 13, 7, 11, 3 ], [ 13, 7, 11, 4 ], \n [ 13, 7, 12, 1 ], [ 13, 7, 12, 2 ], [ 13, 7, 12, 3 ], [ 13, 7, 12, 4 ], \n [ 13, 8, 1, 1 ], [ 13, 8, 1, 2 ], [ 13, 8, 1, 3 ], [ 13, 8, 1, 4 ], \n [ 13, 8, 1, 5 ], [ 13, 8, 1, 6 ], [ 13, 8, 1, 7 ], [ 13, 8, 1, 8 ], \n [ 13, 8, 1, 9 ], [ 13, 8, 1, 10 ], [ 13, 8, 1, 11 ], [ 13, 8, 1, 12 ], \n [ 13, 8, 1, 13 ], [ 13, 8, 1, 14 ], [ 13, 8, 1, 15 ], [ 13, 8, 1, 16 ], \n [ 13, 8, 1, 17 ], [ 13, 8, 1, 18 ], [ 13, 8, 1, 19 ], [ 13, 8, 1, 20 ], \n [ 13, 8, 1, 21 ], [ 13, 8, 1, 22 ], [ 13, 8, 1, 23 ], [ 13, 8, 1, 24 ], \n [ 13, 8, 1, 25 ], [ 13, 8, 1, 26 ], [ 13, 8, 1, 27 ], [ 13, 8, 1, 28 ], \n [ 13, 8, 1, 29 ], [ 13, 8, 1, 30 ], [ 13, 8, 1, 31 ], [ 13, 8, 1, 32 ], \n [ 13, 8, 1, 33 ], [ 13, 8, 1, 34 ], [ 13, 8, 1, 35 ], [ 13, 8, 1, 36 ], \n [ 13, 8, 1, 37 ], [ 13, 8, 1, 38 ], [ 13, 8, 1, 39 ], [ 13, 8, 1, 40 ], \n [ 13, 8, 1, 41 ], [ 13, 8, 1, 42 ], [ 13, 8, 1, 43 ], [ 13, 8, 1, 44 ], \n [ 13, 8, 1, 45 ], [ 13, 8, 1, 46 ], [ 13, 8, 1, 47 ], [ 13, 8, 1, 48 ], \n [ 13, 8, 1, 49 ], [ 13, 8, 1, 50 ], [ 13, 8, 1, 51 ], [ 13, 8, 1, 52 ], \n [ 13, 8, 1, 53 ], [ 13, 8, 1, 54 ], [ 13, 8, 1, 55 ], [ 13, 8, 1, 56 ], \n [ 13, 8, 1, 57 ], [ 13, 8, 1, 58 ], [ 13, 8, 1, 59 ], [ 13, 8, 1, 60 ], \n [ 13, 8, 1, 61 ], [ 13, 8, 1, 62 ], [ 13, 8, 1, 63 ], [ 13, 8, 1, 64 ], \n [ 13, 8, 1, 65 ], [ 13, 8, 1, 66 ], [ 13, 8, 1, 67 ], [ 13, 8, 1, 68 ], \n [ 13, 8, 1, 69 ], [ 13, 8, 1, 70 ], [ 13, 8, 1, 71 ], [ 13, 8, 1, 72 ], \n [ 13, 8, 1, 73 ], [ 13, 8, 1, 74 ], [ 13, 8, 1, 75 ], [ 13, 8, 1, 76 ], \n [ 13, 8, 1, 77 ], [ 13, 8, 1, 78 ], [ 13, 8, 1, 79 ], [ 13, 8, 1, 80 ], \n [ 13, 8, 1, 81 ], [ 13, 8, 1, 82 ], [ 13, 8, 1, 83 ], [ 13, 8, 1, 84 ], \n [ 13, 8, 1, 85 ], [ 13, 8, 1, 86 ], [ 13, 8, 1, 87 ], [ 13, 8, 1, 88 ], \n [ 13, 8, 1, 89 ], [ 13, 8, 1, 90 ], [ 13, 8, 1, 91 ], [ 13, 8, 1, 92 ], \n [ 13, 8, 1, 93 ], [ 13, 8, 1, 94 ], [ 13, 8, 1, 95 ], [ 13, 8, 1, 96 ], \n [ 13, 8, 2, 1 ], [ 13, 8, 2, 2 ], [ 13, 8, 2, 3 ], [ 13, 8, 2, 4 ], \n [ 13, 8, 2, 5 ], [ 13, 8, 2, 6 ], [ 13, 8, 2, 7 ], [ 13, 8, 2, 8 ], \n [ 13, 8, 2, 9 ], [ 13, 8, 2, 10 ], [ 13, 8, 2, 11 ], [ 13, 8, 2, 12 ], \n [ 13, 8, 3, 1 ], [ 13, 8, 3, 2 ], [ 13, 8, 3, 3 ], [ 13, 8, 3, 4 ], \n [ 13, 8, 3, 5 ], [ 13, 8, 3, 6 ], [ 13, 8, 3, 7 ], [ 13, 8, 3, 8 ], \n [ 13, 8, 3, 9 ], [ 13, 8, 3, 10 ], [ 13, 8, 3, 11 ], [ 13, 8, 3, 12 ], \n [ 13, 8, 3, 13 ], [ 13, 8, 3, 14 ], [ 13, 8, 3, 15 ], [ 13, 8, 3, 16 ], \n [ 13, 8, 3, 17 ], [ 13, 8, 3, 18 ], [ 13, 8, 3, 19 ], [ 13, 8, 3, 20 ], \n [ 13, 8, 3, 21 ], [ 13, 8, 3, 22 ], [ 13, 8, 3, 23 ], [ 13, 8, 3, 24 ], \n [ 13, 8, 4, 1 ], [ 13, 8, 4, 2 ], [ 13, 8, 4, 3 ], [ 13, 8, 4, 4 ], \n [ 13, 8, 4, 5 ], [ 13, 8, 4, 6 ], [ 13, 8, 4, 7 ], [ 13, 8, 4, 8 ], \n [ 13, 8, 4, 9 ], [ 13, 8, 4, 10 ], [ 13, 8, 4, 11 ], [ 13, 8, 4, 12 ], \n [ 13, 8, 4, 13 ], [ 13, 8, 4, 14 ], [ 13, 8, 4, 15 ], [ 13, 8, 4, 16 ], \n [ 13, 8, 5, 1 ], [ 13, 8, 5, 2 ], [ 13, 8, 5, 3 ], [ 13, 8, 5, 4 ], \n [ 13, 8, 5, 5 ], [ 13, 8, 5, 6 ], [ 13, 8, 5, 7 ], [ 13, 8, 5, 8 ], \n [ 13, 8, 5, 9 ], [ 13, 8, 5, 10 ], [ 13, 8, 5, 11 ], [ 13, 8, 5, 12 ], \n [ 13, 8, 6, 1 ], [ 13, 8, 6, 2 ], [ 13, 8, 6, 3 ], [ 13, 8, 6, 4 ], \n [ 13, 9, 1, 1 ], [ 13, 9, 1, 2 ], [ 13, 9, 1, 3 ], [ 13, 9, 1, 4 ], \n [ 13, 9, 1, 5 ], [ 13, 9, 1, 6 ], [ 13, 9, 1, 7 ], [ 13, 9, 1, 8 ], \n [ 13, 9, 1, 9 ], [ 13, 9, 1, 10 ], [ 13, 9, 1, 11 ], [ 13, 9, 1, 12 ], \n [ 13, 9, 1, 13 ], [ 13, 9, 1, 14 ], [ 13, 9, 1, 15 ], [ 13, 9, 1, 16 ], \n [ 13, 9, 1, 17 ], [ 13, 9, 1, 18 ], [ 13, 9, 1, 19 ], [ 13, 9, 1, 20 ], \n [ 13, 9, 1, 21 ], [ 13, 9, 1, 22 ], [ 13, 9, 1, 23 ], [ 13, 9, 1, 24 ], \n [ 13, 9, 1, 25 ], [ 13, 9, 1, 26 ], [ 13, 9, 1, 27 ], [ 13, 9, 1, 28 ], \n [ 13, 9, 1, 29 ], [ 13, 9, 1, 30 ], [ 13, 9, 1, 31 ], [ 13, 9, 1, 32 ], \n [ 13, 9, 1, 33 ], [ 13, 9, 1, 34 ], [ 13, 9, 1, 35 ], [ 13, 9, 1, 36 ], \n [ 13, 9, 2, 1 ], [ 13, 9, 2, 2 ], [ 13, 9, 2, 3 ], [ 13, 9, 2, 4 ], \n [ 13, 9, 2, 5 ], [ 13, 9, 2, 6 ], [ 13, 9, 3, 1 ], [ 13, 9, 3, 2 ], \n [ 13, 9, 3, 3 ], [ 13, 9, 3, 4 ], [ 13, 9, 3, 5 ], [ 13, 9, 3, 6 ], \n [ 13, 9, 3, 7 ], [ 13, 9, 3, 8 ], [ 13, 9, 3, 9 ], [ 13, 9, 3, 10 ], \n [ 13, 9, 3, 11 ], [ 13, 9, 3, 12 ], [ 13, 9, 3, 13 ], [ 13, 9, 3, 14 ], \n [ 13, 9, 3, 15 ], [ 13, 9, 3, 16 ], [ 13, 9, 4, 1 ], [ 13, 9, 4, 2 ], \n [ 13, 9, 4, 3 ], [ 13, 9, 4, 4 ], [ 13, 9, 4, 5 ], [ 13, 9, 4, 6 ], \n [ 13, 9, 5, 1 ], [ 13, 9, 5, 2 ], [ 13, 9, 5, 3 ], [ 13, 10, 1, 1 ], \n [ 13, 10, 1, 2 ], [ 13, 10, 1, 3 ], [ 13, 10, 1, 4 ], [ 13, 10, 1, 5 ], \n [ 13, 10, 1, 6 ], [ 13, 10, 1, 7 ], [ 13, 10, 1, 8 ], [ 13, 10, 1, 9 ], \n [ 13, 10, 1, 10 ], [ 13, 10, 1, 11 ], [ 13, 10, 1, 12 ], [ 13, 10, 1, 13 ], \n [ 13, 10, 1, 14 ], [ 13, 10, 1, 15 ], [ 13, 10, 1, 16 ], [ 13, 10, 1, 17 ], \n [ 13, 10, 1, 18 ], [ 13, 10, 1, 19 ], [ 13, 10, 1, 20 ], [ 13, 10, 1, 21 ], \n [ 13, 10, 1, 22 ], [ 13, 10, 1, 23 ], [ 13, 10, 1, 24 ], [ 13, 10, 1, 25 ], \n [ 13, 10, 1, 26 ], [ 13, 10, 1, 27 ], [ 13, 10, 1, 28 ], [ 13, 10, 1, 29 ], \n [ 13, 10, 1, 30 ], [ 13, 10, 1, 31 ], [ 13, 10, 1, 32 ], [ 13, 10, 1, 33 ], \n [ 13, 10, 1, 34 ], [ 13, 10, 1, 35 ], [ 13, 10, 1, 36 ], [ 13, 10, 1, 37 ], \n [ 13, 10, 1, 38 ], [ 13, 10, 1, 39 ], [ 13, 10, 1, 40 ], [ 13, 10, 1, 41 ], \n [ 13, 10, 1, 42 ], [ 13, 10, 1, 43 ], [ 13, 10, 1, 44 ], [ 13, 10, 1, 45 ], \n [ 13, 10, 1, 46 ], [ 13, 10, 1, 47 ], [ 13, 10, 1, 48 ], [ 13, 10, 1, 49 ], \n [ 13, 10, 1, 50 ], [ 13, 10, 1, 51 ], [ 13, 10, 1, 52 ], [ 13, 10, 1, 53 ], \n [ 13, 10, 1, 54 ], [ 13, 10, 1, 55 ], [ 13, 10, 1, 56 ], [ 13, 10, 1, 57 ], \n [ 13, 10, 1, 58 ], [ 13, 10, 1, 59 ], [ 13, 10, 1, 60 ], [ 13, 10, 1, 61 ], \n [ 13, 10, 1, 62 ], [ 13, 10, 1, 63 ], [ 13, 10, 1, 64 ], [ 13, 10, 1, 65 ], \n [ 13, 10, 1, 66 ], [ 13, 10, 1, 67 ], [ 13, 10, 1, 68 ], [ 13, 10, 1, 69 ], \n [ 13, 10, 1, 70 ], [ 13, 10, 1, 71 ], [ 13, 10, 1, 72 ], [ 13, 10, 1, 73 ], \n [ 13, 10, 1, 74 ], [ 13, 10, 1, 75 ], [ 13, 10, 1, 76 ], [ 13, 10, 1, 77 ], \n [ 13, 10, 1, 78 ], [ 13, 10, 1, 79 ], [ 13, 10, 1, 80 ], [ 13, 10, 1, 81 ], \n [ 13, 10, 1, 82 ], [ 13, 10, 1, 83 ], [ 13, 10, 1, 84 ], [ 13, 10, 1, 85 ], \n [ 13, 10, 1, 86 ], [ 13, 10, 1, 87 ], [ 13, 10, 1, 88 ], [ 13, 10, 1, 89 ], \n [ 13, 10, 1, 90 ], [ 13, 10, 1, 91 ], [ 13, 10, 1, 92 ], [ 13, 10, 1, 93 ], \n [ 13, 10, 1, 94 ], [ 13, 10, 1, 95 ], [ 13, 10, 1, 96 ], [ 13, 10, 1, 97 ], \n [ 13, 10, 1, 98 ], [ 13, 10, 1, 99 ], [ 13, 10, 1, 100 ], \n [ 13, 10, 1, 101 ], [ 13, 10, 1, 102 ], [ 13, 10, 1, 103 ], \n [ 13, 10, 1, 104 ], [ 13, 10, 1, 105 ], [ 13, 10, 1, 106 ], \n [ 13, 10, 1, 107 ], [ 13, 10, 1, 108 ], [ 13, 10, 1, 109 ], \n [ 13, 10, 1, 110 ], [ 13, 10, 1, 111 ], [ 13, 10, 1, 112 ], \n [ 13, 10, 1, 113 ], [ 13, 10, 1, 114 ], [ 13, 10, 1, 115 ], \n [ 13, 10, 1, 116 ], [ 13, 10, 1, 117 ], [ 13, 10, 1, 118 ], \n [ 13, 10, 1, 119 ], [ 13, 10, 1, 120 ], [ 13, 10, 1, 121 ], \n [ 13, 10, 1, 122 ], [ 13, 10, 1, 123 ], [ 13, 10, 1, 124 ], \n [ 13, 10, 1, 125 ], [ 13, 10, 1, 126 ], [ 13, 10, 1, 127 ], \n [ 13, 10, 1, 128 ], [ 13, 10, 1, 129 ], [ 13, 10, 1, 130 ], \n [ 13, 10, 1, 131 ], [ 13, 10, 1, 132 ], [ 13, 10, 1, 133 ], \n [ 13, 10, 1, 134 ], [ 13, 10, 1, 135 ], [ 13, 10, 1, 136 ], \n [ 13, 10, 1, 137 ], [ 13, 10, 1, 138 ], [ 13, 10, 1, 139 ], \n [ 13, 10, 1, 140 ], [ 13, 10, 1, 141 ], [ 13, 10, 1, 142 ], \n [ 13, 10, 1, 143 ], [ 13, 10, 1, 144 ], [ 13, 10, 1, 145 ], \n [ 13, 10, 1, 146 ], [ 13, 10, 1, 147 ], [ 13, 10, 1, 148 ], \n [ 13, 10, 1, 149 ], [ 13, 10, 1, 150 ], [ 13, 10, 1, 151 ], \n [ 13, 10, 1, 152 ], [ 13, 10, 1, 153 ], [ 13, 10, 1, 154 ], \n [ 13, 10, 1, 155 ], [ 13, 10, 1, 156 ], [ 13, 10, 1, 157 ], \n [ 13, 10, 1, 158 ], [ 13, 10, 1, 159 ], [ 13, 10, 1, 160 ], \n [ 13, 10, 1, 161 ], [ 13, 10, 1, 162 ], [ 13, 10, 1, 163 ], \n [ 13, 10, 1, 164 ], [ 13, 10, 1, 165 ], [ 13, 10, 1, 166 ], \n [ 13, 10, 1, 167 ], [ 13, 10, 1, 168 ], [ 13, 10, 1, 169 ], \n [ 13, 10, 1, 170 ], [ 13, 10, 1, 171 ], [ 13, 10, 1, 172 ], \n [ 13, 10, 1, 173 ], [ 13, 10, 1, 174 ], [ 13, 10, 1, 175 ], \n [ 13, 10, 1, 176 ], [ 13, 10, 1, 177 ], [ 13, 10, 1, 178 ], \n [ 13, 10, 1, 179 ], [ 13, 10, 1, 180 ], [ 13, 10, 1, 181 ], \n [ 13, 10, 1, 182 ], [ 13, 10, 1, 183 ], [ 13, 10, 1, 184 ], \n [ 13, 10, 1, 185 ], [ 13, 10, 1, 186 ], [ 13, 10, 1, 187 ], \n [ 13, 10, 1, 188 ], [ 13, 10, 1, 189 ], [ 13, 10, 1, 190 ], \n [ 13, 10, 1, 191 ], [ 13, 10, 1, 192 ], [ 13, 10, 1, 193 ], \n [ 13, 10, 1, 194 ], [ 13, 10, 1, 195 ], [ 13, 10, 1, 196 ], \n [ 13, 10, 1, 197 ], [ 13, 10, 1, 198 ], [ 13, 10, 1, 199 ], \n [ 13, 10, 1, 200 ], [ 13, 10, 1, 201 ], [ 13, 10, 1, 202 ], \n [ 13, 10, 1, 203 ], [ 13, 10, 1, 204 ], [ 13, 10, 1, 205 ], \n [ 13, 10, 1, 206 ], [ 13, 10, 1, 207 ], [ 13, 10, 1, 208 ], \n [ 13, 10, 1, 209 ], [ 13, 10, 1, 210 ], [ 13, 10, 1, 211 ], \n [ 13, 10, 1, 212 ], [ 13, 10, 1, 213 ], [ 13, 10, 1, 214 ], \n [ 13, 10, 1, 215 ], [ 13, 10, 1, 216 ], [ 13, 10, 1, 217 ], \n [ 13, 10, 1, 218 ], [ 13, 10, 1, 219 ], [ 13, 10, 1, 220 ], \n [ 13, 10, 1, 221 ], [ 13, 10, 1, 222 ], [ 13, 10, 1, 223 ], \n [ 13, 10, 1, 224 ], [ 13, 10, 1, 225 ], [ 13, 10, 1, 226 ], \n [ 13, 10, 1, 227 ], [ 13, 10, 1, 228 ], [ 13, 10, 1, 229 ], \n [ 13, 10, 1, 230 ], [ 13, 10, 1, 231 ], [ 13, 10, 1, 232 ], \n [ 13, 10, 1, 233 ], [ 13, 10, 1, 234 ], [ 13, 10, 1, 235 ], \n [ 13, 10, 1, 236 ], [ 13, 10, 1, 237 ], [ 13, 10, 1, 238 ], \n [ 13, 10, 1, 239 ], [ 13, 10, 1, 240 ], [ 13, 10, 1, 241 ], \n [ 13, 10, 1, 242 ], [ 13, 10, 1, 243 ], [ 13, 10, 1, 244 ], \n [ 13, 10, 1, 245 ], [ 13, 10, 1, 246 ], [ 13, 10, 1, 247 ], \n [ 13, 10, 1, 248 ], [ 13, 10, 1, 249 ], [ 13, 10, 1, 250 ], \n [ 13, 10, 1, 251 ], [ 13, 10, 1, 252 ], [ 13, 10, 1, 253 ], \n [ 13, 10, 1, 254 ], [ 13, 10, 1, 255 ], [ 13, 10, 1, 256 ], \n [ 13, 10, 1, 257 ], [ 13, 10, 1, 258 ], [ 13, 10, 1, 259 ], \n [ 13, 10, 1, 260 ], [ 13, 10, 1, 261 ], [ 13, 10, 1, 262 ], \n [ 13, 10, 1, 263 ], [ 13, 10, 1, 264 ], [ 13, 10, 1, 265 ], \n [ 13, 10, 1, 266 ], [ 13, 10, 1, 267 ], [ 13, 10, 1, 268 ], \n [ 13, 10, 1, 269 ], [ 13, 10, 1, 270 ], [ 13, 10, 1, 271 ], \n [ 13, 10, 1, 272 ], [ 13, 10, 2, 1 ], [ 13, 10, 2, 2 ], [ 13, 10, 2, 3 ], \n [ 13, 10, 2, 4 ], [ 13, 10, 2, 5 ], [ 13, 10, 2, 6 ], [ 13, 10, 2, 7 ], \n [ 13, 10, 2, 8 ], [ 13, 10, 2, 9 ], [ 13, 10, 2, 10 ], [ 13, 10, 2, 11 ], \n [ 13, 10, 2, 12 ], [ 13, 10, 2, 13 ], [ 13, 10, 2, 14 ], [ 13, 10, 2, 15 ], \n [ 13, 10, 2, 16 ], [ 13, 10, 2, 17 ], [ 13, 10, 2, 18 ], [ 13, 10, 2, 19 ], \n [ 13, 10, 2, 20 ], [ 13, 10, 2, 21 ], [ 13, 10, 2, 22 ], [ 13, 10, 2, 23 ], \n [ 13, 10, 2, 24 ], [ 13, 10, 3, 1 ], [ 13, 10, 3, 2 ], [ 13, 10, 3, 3 ], \n [ 13, 10, 3, 4 ], [ 13, 10, 3, 5 ], [ 13, 10, 3, 6 ], [ 13, 10, 3, 7 ], \n [ 13, 10, 3, 8 ], [ 13, 10, 3, 9 ], [ 13, 10, 3, 10 ], [ 13, 10, 3, 11 ], \n [ 13, 10, 3, 12 ], [ 13, 10, 3, 13 ], [ 13, 10, 3, 14 ], [ 13, 10, 3, 15 ], \n [ 13, 10, 3, 16 ], [ 13, 10, 3, 17 ], [ 13, 10, 3, 18 ], [ 13, 10, 3, 19 ], \n [ 13, 10, 3, 20 ], [ 13, 10, 3, 21 ], [ 13, 10, 3, 22 ], [ 13, 10, 3, 23 ], \n [ 13, 10, 3, 24 ], [ 13, 10, 3, 25 ], [ 13, 10, 3, 26 ], [ 13, 10, 3, 27 ], \n [ 13, 10, 3, 28 ], [ 13, 10, 3, 29 ], [ 13, 10, 3, 30 ], [ 13, 10, 3, 31 ], \n [ 13, 10, 3, 32 ], [ 13, 10, 3, 33 ], [ 13, 10, 3, 34 ], [ 13, 10, 3, 35 ], \n [ 13, 10, 3, 36 ], [ 13, 10, 3, 37 ], [ 13, 10, 3, 38 ], [ 13, 10, 3, 39 ], \n [ 13, 10, 3, 40 ], [ 13, 10, 3, 41 ], [ 13, 10, 3, 42 ], [ 13, 10, 3, 43 ], \n [ 13, 10, 3, 44 ], [ 13, 10, 3, 45 ], [ 13, 10, 3, 46 ], [ 13, 10, 3, 47 ], \n [ 13, 10, 3, 48 ], [ 13, 10, 3, 49 ], [ 13, 10, 3, 50 ], [ 13, 10, 3, 51 ], \n [ 13, 10, 3, 52 ], [ 13, 10, 3, 53 ], [ 13, 10, 3, 54 ], [ 13, 10, 3, 55 ], \n [ 13, 10, 3, 56 ], [ 13, 10, 3, 57 ], [ 13, 10, 3, 58 ], [ 13, 10, 3, 59 ], \n [ 13, 10, 3, 60 ], [ 13, 10, 3, 61 ], [ 13, 10, 3, 62 ], [ 13, 10, 3, 63 ], \n [ 13, 10, 3, 64 ], [ 13, 10, 4, 1 ], [ 13, 10, 4, 2 ], [ 13, 10, 4, 3 ], \n [ 13, 10, 4, 4 ], [ 13, 10, 4, 5 ], [ 13, 10, 4, 6 ], [ 13, 10, 4, 7 ], \n [ 13, 10, 4, 8 ], [ 13, 10, 4, 9 ], [ 13, 10, 4, 10 ], [ 13, 10, 4, 11 ], \n [ 13, 10, 4, 12 ], [ 13, 10, 4, 13 ], [ 13, 10, 4, 14 ], [ 13, 10, 4, 15 ], \n [ 13, 10, 4, 16 ], [ 13, 10, 4, 17 ], [ 13, 10, 4, 18 ], [ 13, 10, 4, 19 ], \n [ 13, 10, 4, 20 ], [ 13, 10, 5, 1 ], [ 13, 10, 5, 2 ], [ 13, 10, 5, 3 ], \n [ 13, 10, 5, 4 ], [ 13, 10, 5, 5 ], [ 13, 10, 5, 6 ], [ 14, 1, 1, 1 ], \n [ 14, 1, 1, 2 ], [ 14, 1, 1, 3 ], [ 14, 1, 1, 4 ], [ 14, 1, 2, 1 ], \n [ 14, 1, 2, 2 ], [ 14, 1, 3, 1 ], [ 14, 1, 3, 2 ], [ 14, 1, 3, 3 ], \n [ 14, 1, 3, 4 ], [ 14, 1, 4, 1 ], [ 14, 1, 4, 2 ], [ 14, 2, 1, 1 ], \n [ 14, 2, 1, 2 ], [ 14, 2, 2, 1 ], [ 14, 2, 3, 1 ], [ 14, 2, 3, 2 ], \n [ 14, 2, 3, 3 ], [ 14, 2, 3, 4 ], [ 14, 2, 4, 1 ], [ 14, 2, 4, 2 ], \n [ 14, 3, 1, 1 ], [ 14, 3, 1, 2 ], [ 14, 3, 1, 3 ], [ 14, 3, 1, 4 ], \n [ 14, 3, 2, 1 ], [ 14, 3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6, 1 ], [ 14, 8, 6, 2 ], [ 14, 9, 1, 1 ], \n [ 14, 9, 1, 2 ], [ 14, 9, 1, 3 ], [ 14, 9, 1, 4 ], [ 14, 9, 2, 1 ], \n [ 14, 9, 3, 1 ], [ 14, 9, 3, 2 ], [ 14, 9, 3, 3 ], [ 14, 9, 3, 4 ], \n [ 14, 9, 3, 5 ], [ 14, 9, 3, 6 ], [ 14, 9, 3, 7 ], [ 14, 9, 3, 8 ], \n [ 14, 9, 4, 1 ], [ 14, 9, 4, 2 ], [ 14, 9, 4, 3 ], [ 14, 9, 4, 4 ], \n [ 14, 9, 4, 5 ], [ 14, 9, 4, 6 ], [ 14, 9, 4, 7 ], [ 14, 9, 4, 8 ], \n [ 14, 9, 5, 1 ], [ 14, 9, 5, 2 ], [ 14, 9, 6, 1 ], [ 14, 9, 6, 2 ], \n [ 14, 10, 1, 1 ], [ 14, 10, 1, 2 ], [ 14, 10, 1, 3 ], [ 14, 10, 1, 4 ], \n [ 14, 10, 1, 5 ], [ 14, 10, 1, 6 ], [ 14, 10, 1, 7 ], [ 14, 10, 1, 8 ], \n [ 14, 10, 1, 9 ], [ 14, 10, 1, 10 ], [ 14, 10, 1, 11 ], [ 14, 10, 1, 12 ], \n [ 14, 10, 1, 13 ], [ 14, 10, 1, 14 ], [ 14, 10, 1, 15 ], [ 14, 10, 1, 16 ], \n [ 14, 10, 2, 1 ], [ 14, 10, 2, 2 ], [ 14, 10, 3, 1 ], [ 14, 10, 3, 2 ], \n [ 14, 10, 3, 3 ], [ 14, 10, 3, 4 ], [ 14, 10, 3, 5 ], [ 14, 10, 3, 6 ], \n [ 14, 10, 3, 7 ], [ 14, 10, 3, 8 ], [ 14, 10, 3, 9 ], [ 14, 10, 3, 10 ], \n [ 14, 10, 3, 11 ], [ 14, 10, 3, 12 ], [ 14, 10, 3, 13 ], [ 14, 10, 3, 14 ], \n [ 14, 10, 3, 15 ], [ 14, 10, 3, 16 ], [ 14, 10, 4, 1 ], [ 14, 10, 4, 2 ], \n [ 14, 10, 4, 3 ], [ 14, 10, 4, 4 ], [ 14, 10, 4, 5 ], [ 14, 10, 4, 6 ], \n [ 14, 10, 4, 7 ], [ 14, 10, 4, 8 ], [ 14, 10, 4, 9 ], [ 14, 10, 4, 10 ], \n [ 14, 10, 4, 11 ], [ 14, 10, 4, 12 ], [ 14, 10, 4, 13 ], [ 14, 10, 4, 14 ], \n [ 14, 10, 4, 15 ], [ 14, 10, 4, 16 ], [ 14, 10, 5, 1 ], [ 14, 10, 5, 2 ], \n [ 14, 10, 6, 1 ], [ 14, 10, 6, 2 ], [ 15, 1, 1, 1 ], [ 15, 1, 1, 2 ], \n [ 15, 1, 1, 3 ], [ 15, 1, 1, 4 ], [ 15, 1, 1, 5 ], [ 15, 1, 1, 6 ], \n [ 15, 1, 1, 7 ], [ 15, 1, 1, 8 ], [ 15, 1, 1, 9 ], [ 15, 1, 1, 10 ], \n [ 15, 1, 1, 11 ], [ 15, 1, 1, 12 ], [ 15, 1, 1, 13 ], [ 15, 1, 1, 14 ], \n [ 15, 1, 1, 15 ], [ 15, 1, 1, 16 ], [ 15, 1, 2, 1 ], [ 15, 1, 2, 2 ], \n [ 15, 1, 2, 3 ], [ 15, 1, 2, 4 ], [ 15, 2, 1, 1 ], [ 15, 2, 1, 2 ], \n [ 15, 2, 1, 3 ], [ 15, 2, 2, 1 ], [ 15, 3, 1, 1 ], [ 15, 3, 1, 2 ], \n [ 15, 3, 1, 3 ], [ 15, 3, 2, 1 ], [ 15, 4, 1, 1 ], [ 15, 4, 1, 2 ], \n [ 15, 4, 1, 3 ], [ 15, 4, 1, 4 ], [ 15, 4, 1, 5 ], [ 15, 4, 1, 6 ], \n [ 15, 4, 1, 7 ], [ 15, 4, 1, 8 ], [ 15, 4, 1, 9 ], [ 15, 4, 1, 10 ], \n [ 15, 4, 1, 11 ], [ 15, 4, 1, 12 ], [ 15, 4, 1, 13 ], [ 15, 4, 1, 14 ], \n [ 15, 4, 1, 15 ], [ 15, 4, 1,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 ], \n [ 15, 7, 2, 5 ], [ 15, 7, 2, 6 ], [ 15, 7, 2, 7 ], [ 15, 7, 2, 8 ], \n [ 15, 7, 2, 9 ], [ 15, 7, 2, 10 ], [ 15, 7, 3, 1 ], [ 15, 7, 3, 2 ], \n [ 15, 7, 4, 1 ], [ 15, 7, 4, 2 ], [ 15, 8, 1, 1 ], [ 15, 8, 1, 2 ], \n [ 15, 8, 1, 3 ], [ 15, 8, 1, 4 ], [ 15, 8, 1, 5 ], [ 15, 8, 1, 6 ], \n [ 15, 8, 1, 7 ], [ 15, 8, 1, 8 ], [ 15, 8, 1, 9 ], [ 15, 8, 1, 10 ], \n [ 15, 8, 2, 1 ], [ 15, 8, 2, 2 ], [ 15, 9, 1, 1 ], [ 15, 9, 1, 2 ], \n [ 15, 9, 1, 3 ], [ 15, 9, 1, 4 ], [ 15, 9, 1, 5 ], [ 15, 9, 1, 6 ], \n [ 15, 9, 1, 7 ], [ 15, 9, 1, 8 ], [ 15, 9, 1, 9 ], [ 15, 9, 1, 10 ], \n [ 15, 9, 1, 11 ], [ 15, 9, 1, 12 ], [ 15, 9, 1, 13 ], [ 15, 9, 1, 14 ], \n [ 15, 9, 1, 15 ], [ 15, 9, 1, 16 ], [ 15, 9, 1, 17 ], [ 15, 9, 1, 18 ], \n [ 15, 9, 1, 19 ], [ 15, 9, 1, 20 ], [ 15, 9, 1, 21 ], [ 15, 9, 1, 22 ], \n [ 15, 9, 1, 23 ], [ 15, 9, 1, 24 ], [ 15, 9, 1, 25 ], [ 15, 9, 1, 26 ], \n [ 15, 9, 1, 27 ], [ 15, 9, 1, 28 ], [ 15, 9, 1, 29 ], [ 15, 9, 1, 30 ], \n [ 15, 9, 1, 31 ], [ 15, 9, 1, 32 ], [ 15, 9, 2, 1 ], [ 15, 9, 2, 2 ], \n [ 15, 9, 2, 3 ], [ 15, 9, 2, 4 ], [ 15, 10, 1, 1 ], [ 15, 10, 1, 2 ], \n [ 15, 10, 1, 3 ], [ 15, 10, 1, 4 ], [ 15, 10, 1, 5 ], [ 15, 10, 1, 6 ], \n [ 15, 10, 1, 7 ], [ 15, 10, 1, 8 ], [ 15, 10, 1, 9 ], [ 15, 10, 1, 10 ], \n [ 15, 10, 2, 1 ], [ 15, 10, 2, 2 ], [ 15, 10, 2, 3 ], [ 15, 10, 2, 4 ], \n [ 15, 10, 2, 5 ], [ 15, 10, 2, 6 ], [ 15, 10, 2, 7 ], [ 15, 10, 2, 8 ], \n [ 15, 10, 2, 9 ], [ 15, 10, 2, 10 ], [ 15, 10, 3, 1 ], [ 15, 10, 3, 2 ], \n [ 15, 10, 4, 1 ], [ 15, 10, 4, 2 ], [ 15, 11, 1, 1 ], [ 15, 11, 1, 2 ], \n [ 15, 11, 1, 3 ], [ 15, 11, 1, 4 ], [ 15, 11, 1, 5 ], [ 15, 11, 1, 6 ], \n [ 15, 11, 1, 7 ], [ 15, 11, 1, 8 ], [ 15, 11, 1, 9 ], [ 15, 11, 1, 10 ], \n [ 15, 11, 2, 1 ], [ 15, 11, 2, 2 ], [ 15, 12, 1, 1 ], [ 15, 12, 1, 2 ], \n [ 15, 12, 1, 3 ], [ 15, 12, 1, 4 ], [ 15, 12, 1, 5 ], [ 15, 12, 1, 6 ], \n [ 15, 12, 1, 7 ], [ 15, 12, 1, 8 ], [ 15, 12, 1, 9 ], [ 15, 12, 1, 10 ], \n [ 15, 12, 1, 11 ], [ 15, 12, 1, 12 ], [ 15, 12, 1, 13 ], [ 15, 12, 1, 14 ], \n [ 15, 12, 1, 15 ], [ 15, 12, 1, 16 ], [ 15, 12, 1, 17 ], [ 15, 12, 1, 18 ], \n [ 15, 12, 1, 19 ], [ 15, 12, 1, 20 ], [ 15, 12, 1, 21 ], [ 15, 12, 1, 22 ], \n [ 15, 12, 1, 23 ], [ 15, 12, 1, 24 ], [ 15, 12, 1, 25 ], [ 15, 12, 1, 26 ], \n [ 15, 12, 1, 27 ], [ 15, 12, 1, 28 ], [ 15, 12, 1, 29 ], [ 15, 12, 1, 30 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n [ 18, 5, 3, 1 ], [ 18, 5, 3, 2 ], [ 18, 5, 3, 3 ], [ 18, 5, 3, 4 ], \n [ 18, 5, 3, 5 ], [ 18, 5, 3, 6 ], [ 18, 5, 3, 7 ], [ 18, 5, 3, 8 ], \n [ 18, 5, 3, 9 ], [ 18, 5, 3, 10 ], [ 18, 5, 3, 11 ], [ 18, 5, 3, 12 ], \n [ 18, 5, 3, 13 ], [ 18, 5, 3, 14 ], [ 18, 5, 3, 15 ], [ 18, 5, 3, 16 ], \n [ 18, 5, 3, 17 ], [ 18, 5, 3, 18 ], [ 18, 5, 3, 19 ], [ 18, 5, 3, 20 ], \n [ 18, 5, 3, 21 ], [ 18, 5, 3, 22 ], [ 18, 5, 3, 23 ], [ 18, 5, 3, 24 ], \n [ 18, 5, 4, 1 ], [ 18, 5, 4, 2 ], [ 18, 5, 4, 3 ], [ 18, 5, 4, 4 ], \n [ 18, 5, 4, 5 ], [ 18, 5, 4, 6 ], [ 18, 5, 4, 7 ], [ 18, 5, 4, 8 ], \n [ 18, 5, 4, 9 ], [ 18, 5, 4, 10 ], [ 18, 5, 4, 11 ], [ 18, 5, 4, 12 ], \n [ 18, 5, 4, 13 ], [ 18, 5, 4, 14 ], [ 18, 5, 4, 15 ], [ 18, 5, 4, 16 ], \n [ 18, 5, 4, 17 ], [ 18, 5, 4, 18 ], [ 18, 5, 4, 19 ], [ 18, 5, 4, 20 ], \n [ 18, 5, 4, 21 ], [ 18, 5, 4, 22 ], [ 18, 5, 4, 23 ], [ 18, 5, 4, 24 ], \n [ 18, 5, 5, 1 ], [ 18, 5, 5, 2 ], [ 18, 5, 5, 3 ], [ 18, 5, 5, 4 ], \n [ 18, 5, 5, 5 ], [ 18, 5, 5, 6 ], [ 18, 5, 6, 1 ], [ 18, 5, 6, 2 ], \n [ 18, 5, 6, 3 ], [ 18, 5, 6, 4 ], [ 18, 5, 7, 1 ], [ 18, 5, 7, 2 ], \n [ 18, 5, 7, 3 ], [ 18, 5, 7, 4 ], [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 19, 4, 2, 6 ], [ 19, 4, 2, 7 ], [ 19, 4, 2, 8 ], [ 19, 4, 2, 9 ], \n [ 19, 4, 2, 10 ], [ 19, 4, 2, 11 ], [ 19, 4, 2, 12 ], [ 19, 4, 2, 13 ], \n [ 19, 4, 2, 14 ], [ 19, 4, 2, 15 ], [ 19, 4, 2, 16 ], [ 19, 4, 3, 1 ], \n [ 19, 4, 3, 2 ], [ 19, 4, 3, 3 ], [ 19, 4, 3, 4 ], [ 19, 4, 4, 1 ], \n [ 19, 4, 4, 2 ], [ 19, 4, 4, 3 ], [ 19, 4, 4, 4 ], [ 19, 5, 1, 1 ], \n [ 19, 5, 1, 2 ], [ 19, 5, 1, 3 ], [ 19, 5, 1, 4 ], [ 19, 5, 1, 5 ], \n [ 19, 5, 1, 6 ], [ 19, 5, 1, 7 ], [ 19, 5, 1, 8 ], [ 19, 5, 1, 9 ], \n [ 19, 5, 1, 10 ], [ 19, 5, 2, 1 ], [ 19, 5, 2, 2 ], [ 19, 5, 2, 3 ], \n [ 19, 5, 2, 4 ], [ 19, 6, 1, 1 ], [ 19, 6, 1, 2 ], [ 19, 6, 1, 3 ], \n [ 19, 6, 1, 4 ], [ 19, 6, 1, 5 ], [ 19, 6, 1, 6 ], [ 19, 6, 1, 7 ], \n [ 19, 6, 1, 8 ], [ 19, 6, 1, 9 ], [ 19, 6, 1, 10 ], [ 19, 6, 1, 11 ], \n [ 19, 6, 1, 12 ], [ 19, 6, 1, 13 ], [ 19, 6, 1, 14 ], [ 19, 6, 1, 15 ], \n [ 19, 6, 1, 16 ], [ 19, 6, 1, 17 ], [ 19, 6, 1, 18 ], [ 19, 6, 1, 19 ], \n [ 19, 6, 1, 20 ], [ 19, 6, 1, 21 ], [ 19, 6, 1, 22 ], [ 19, 6, 1, 23 ], \n [ 19, 6, 1, 24 ], [ 19, 6, 1, 25 ], [ 19, 6, 1, 26 ], [ 19, 6, 1, 27 ], \n [ 19, 6, 1, 28 ], [ 19, 6, 1, 29 ], [ 19, 6, 1, 30 ], [ 19, 6, 1, 31 ], \n [ 19, 6, 1, 32 ], [ 19, 6, 1, 33 ], [ 19, 6, 1, 34 ], [ 19, 6, 1, 35 ], \n [ 19, 6, 1, 36 ], [ 19, 6, 2, 1 ], [ 19, 6, 2, 2 ], [ 19, 6, 2, 3 ], \n [ 19, 6, 2, 4 ], [ 19, 6, 2, 5 ], [ 19, 6, 2, 6 ], [ 20, 1, 1, 1 ], \n [ 20, 2, 1, 1 ], [ 20, 3, 1, 1 ], [ 20, 3, 2, 1 ], [ 20, 4, 1, 1 ], \n [ 20, 4, 1, 2 ], [ 20, 4, 2, 1 ], [ 20, 4, 2, 2 ], [ 20, 5, 1, 1 ], \n [ 20, 5, 1, 2 ], [ 20, 6, 1, 1 ], [ 20, 6, 1, 2 ], [ 20, 7, 1, 1 ], \n [ 20, 7, 1, 2 ], [ 20, 7, 2, 1 ], [ 20, 7, 2, 2 ], [ 20, 8, 1, 1 ], \n [ 20, 8, 1, 2 ], [ 20, 9, 1, 1 ], [ 20, 9, 1, 2 ], [ 20, 9, 2, 1 ], \n [ 20, 9, 2, 2 ], [ 20, 10, 1, 1 ], [ 20, 10, 1, 2 ], [ 20, 10, 2, 1 ], \n [ 20, 10, 2, 2 ], [ 20, 11, 1, 1 ], [ 20, 11, 1, 2 ], [ 20, 11, 2, 1 ], \n [ 20, 11, 2, 2 ], [ 20, 12, 1, 1 ], [ 20, 12, 1, 2 ], [ 20, 12, 2, 1 ], \n [ 20, 12, 2, 2 ], [ 20, 12, 3, 1 ], [ 20, 12, 3, 2 ], [ 20, 12, 4, 1 ], \n [ 20, 12, 4, 2 ], [ 20, 13, 1, 1 ], [ 20, 13, 1, 2 ], [ 20, 13, 2, 1 ], \n [ 20, 13, 2, 2 ], [ 20, 13, 3, 1 ], [ 20, 13, 3, 2 ], [ 20, 13, 4, 1 ], \n [ 20, 13, 4, 2 ], [ 20, 14, 1, 1 ], [ 20, 14, 1, 2 ], [ 20, 15, 1, 1 ], \n [ 20, 15, 1, 2 ], [ 20, 15, 1, 3 ], [ 20, 15, 1, 4 ], [ 20, 16, 1, 1 ], \n [ 20, 16, 1, 2 ], [ 20, 16, 1, 3 ], [ 20, 16, 1, 4 ], [ 20, 16, 2, 1 ], \n [ 20, 16, 2, 2 ], [ 20, 16, 2, 3 ], [ 20, 16, 2, 4 ], [ 20, 17, 1, 1 ], \n [ 20, 17, 1, 2 ], [ 20, 17, 1, 3 ], [ 20, 17, 1, 4 ], [ 20, 17, 2, 1 ], \n [ 20, 17, 2, 2 ], [ 20, 17, 2, 3 ], [ 20, 17, 2, 4 ], [ 20, 18, 1, 1 ], \n [ 20, 18, 1, 2 ], [ 20, 18, 1, 3 ], [ 20, 18, 1, 4 ], [ 20, 19, 1, 1 ], \n [ 20, 19, 1, 2 ], [ 20, 19, 1, 3 ], [ 20, 19, 1, 4 ], [ 20, 20, 1, 1 ], \n [ 20, 20, 1, 2 ], [ 20, 20, 1, 3 ], [ 20, 20, 1, 4 ], [ 20, 20, 2, 1 ], \n [ 20, 20, 2, 2 ], [ 20, 20, 2, 3 ], [ 20, 20, 2, 4 ], [ 20, 20, 3, 1 ], \n [ 20, 20, 3, 2 ], [ 20, 20, 3, 3 ], [ 20, 20, 3, 4 ], [ 20, 20, 4, 1 ], \n [ 20, 20, 4, 2 ], [ 20, 20, 4, 3 ], [ 20, 20, 4, 4 ], [ 20, 21, 1, 1 ], \n [ 20, 21, 1, 2 ], [ 20, 21, 1, 3 ], [ 20, 21, 1, 4 ], [ 20, 21, 2, 1 ], \n [ 20, 21, 2, 2 ], [ 20, 21, 2, 3 ], [ 20, 21, 2, 4 ], [ 20, 22, 1, 1 ], \n [ 20, 22, 1, 2 ], [ 20, 22, 1, 3 ], [ 20, 22, 1, 4 ], [ 20, 22, 1, 5 ], \n [ 20, 22, 1, 6 ], [ 20, 22, 1, 7 ], [ 20, 22, 1, 8 ], [ 21, 1, 1, 1 ], \n [ 21, 1, 2, 1 ], [ 21, 2, 1, 1 ], [ 21,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 1 ], [ 25, 9, 3, 2 ], [ 25, 9, 4, 1 ], [ 25, 9, 4, 2 ], \n [ 25, 9, 4, 3 ], [ 25, 9, 4, 4 ], [ 25, 9, 4, 5 ], [ 25, 9, 4, 6 ], \n [ 25, 9, 4, 7 ], [ 25, 9, 4, 8 ], [ 25, 9, 5, 1 ], [ 25, 9, 5, 2 ], \n [ 25, 10, 1, 1 ], [ 25, 10, 1, 2 ], [ 25, 10, 1, 3 ], [ 25, 10, 1, 4 ], \n [ 25, 10, 1, 5 ], [ 25, 10, 1, 6 ], [ 25, 10, 1, 7 ], [ 25, 10, 1, 8 ], \n [ 25, 10, 1, 9 ], [ 25, 10, 1, 10 ], [ 25, 10, 1, 11 ], [ 25, 10, 1, 12 ], \n [ 25, 10, 2, 1 ], [ 25, 10, 2, 2 ], [ 25, 10, 2, 3 ], [ 25, 10, 2, 4 ], \n [ 25, 10, 3, 1 ], [ 25, 10, 3, 2 ], [ 25, 10, 3, 3 ], [ 25, 10, 4, 1 ], \n [ 25, 10, 4, 2 ], [ 25, 10, 4, 3 ], [ 25, 10, 4, 4 ], [ 25, 10, 4, 5 ], \n [ 25, 10, 4, 6 ], [ 25, 10, 4, 7 ], [ 25, 10, 4, 8 ], [ 25, 10, 5, 1 ], \n [ 25, 10, 5, 2 ], [ 25, 11, 1, 1 ], [ 25, 11, 1, 2 ], [ 25, 11, 1, 3 ], \n [ 25, 11, 1, 4 ], [ 25, 11, 1, 5 ], [ 25, 11, 1, 6 ], [ 25, 11, 1, 7 ], \n [ 25, 11, 1, 8 ], [ 25, 11, 1, 9 ], [ 25, 11, 1, 10 ], [ 25, 11, 1, 11 ], \n [ 25, 11, 1, 12 ], [ 25, 11, 1, 13 ], [ 25, 11, 1, 14 ], [ 25, 11, 1, 15 ], \n [ 25, 11, 1, 16 ], [ 25, 11, 1, 17 ], [ 25, 11, 1, 18 ], [ 25, 11, 1, 19 ], \n [ 25, 11, 1, 20 ], [ 25, 11, 1, 21 ], [ 25, 11, 1, 22 ], [ 25, 11, 1, 23 ], \n [ 25, 11, 1, 24 ], [ 25, 11, 1, 25 ], [ 25, 11, 1, 26 ], [ 25, 11, 1, 27 ], \n [ 25, 11, 1, 28 ], [ 25, 11, 1, 29 ], [ 25, 11, 1, 30 ], [ 25, 11, 1, 31 ], \n [ 25, 11, 1, 32 ], [ 25, 11, 2, 1 ], [ 25, 11, 2, 2 ], [ 25, 11, 2, 3 ], \n [ 25, 11, 2, 4 ], [ 25, 11, 2, 5 ], [ 25, 11, 2, 6 ], [ 25, 11, 2, 7 ], \n [ 25, 11, 2, 8 ], [ 25, 11, 3, 1 ], [ 25, 11, 3, 2 ], [ 25, 11, 3, 3 ], \n [ 25, 11, 3, 4 ], [ 25, 11, 4, 1 ], [ 25, 11, 4, 2 ], [ 25, 11, 4, 3 ], \n [ 25, 11, 4, 4 ], [ 25, 11, 4, 5 ], [ 25, 11, 4, 6 ], [ 25, 11, 4, 7 ], \n [ 25, 11, 4, 8 ], [ 25, 11, 4, 9 ], [ 25, 11, 4, 10 ], [ 25, 11, 4, 11 ], \n [ 25, 11, 4, 12 ], [ 25, 11, 4, 13 ], [ 25, 11, 4, 14 ], [ 25, 11, 4, 15 ], \n [ 25, 11, 4, 16 ], [ 25, 11, 4, 17 ], [ 25, 11, 4, 18 ], [ 25, 11, 4, 19 ], \n [ 25, 11, 4, 20 ], [ 25, 11, 4, 21 ], [ 25, 11, 4, 22 ], [ 25, 11, 4, 23 ], \n [ 25, 11, 4, 24 ], [ 25, 11, 4, 25 ], [ 25, 11, 4, 26 ], [ 25, 11, 4, 27 ], \n [ 25, 11, 4, 28 ], [ 25, 11, 4, 29 ], [ 25, 11, 4, 30 ], [ 25, 11, 4, 31 ], \n [ 25, 11, 4, 32 ], [ 25, 11, 5, 1 ], [ 25, 11, 5, 2 ], [ 25, 11, 5, 3 ], \n [ 25, 11, 5, 4 ], [ 26, 1, 1, 1 ], [ 26, 2, 1, 1 ], [ 26, 2, 1, 2 ], \n [ 27, 1, 1, 1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], [ 32, 9, 2, 2 ], [ 32, 9, 2, 3 ], [ 32, 9, 3, 1 ], \n [ 32, 9, 3, 2 ], [ 32, 9, 3, 3 ], [ 32, 9, 4, 1 ], [ 32, 9, 4, 2 ], \n [ 32, 9, 4, 3 ], [ 32, 9, 4, 4 ], [ 32, 9, 4, 5 ], [ 32, 9, 4, 6 ], \n [ 32, 9, 5, 1 ], [ 32, 9, 5, 2 ], [ 32, 9, 5, 3 ], [ 32, 9, 5, 4 ], \n [ 32, 9, 5, 5 ], [ 32, 9, 5, 6 ], [ 32, 10, 1, 1 ], [ 32, 10, 1, 2 ], \n [ 32, 10, 2, 1 ], [ 32, 10, 2, 2 ], [ 32, 10, 2, 3 ], [ 32, 10, 2, 4 ], \n [ 32, 10, 2, 5 ], [ 32, 10, 2, 6 ], [ 32, 10, 2, 7 ], [ 32, 11, 1, 1 ], \n [ 32, 11, 1, 2 ], [ 32, 11, 2, 1 ], [ 32, 11, 3, 1 ], [ 32, 12, 1, 1 ], \n [ 32, 12, 1, 2 ], [ 32, 12, 1, 3 ], [ 32, 12, 1, 4 ], [ 32, 12, 2, 1 ], \n [ 32, 12, 2, 2 ], [ 32, 12, 2, 3 ], [ 32, 12, 2, 4 ], [ 32, 12, 2, 5 ], \n [ 32, 12, 2, 6 ], [ 32, 13, 1, 1 ], [ 32, 13, 1, 2 ], [ 32, 13, 1, 3 ], \n [ 32, 13, 1, 4 ], [ 32, 13, 2, 1 ], [ 32, 13, 2, 2 ], [ 32, 13, 2, 3 ], \n [ 32, 13, 2, 4 ], [ 32, 13, 2, 5 ], [ 32, 13, 2, 6 ], [ 32, 13, 3, 1 ], \n [ 32, 13, 3, 2 ], [ 32, 13, 3, 3 ], [ 32, 13, 3, 4 ], [ 32, 13, 3, 5 ], \n [ 32, 13, 3, 6 ], [ 32, 13, 4, 1 ], [ 32, 13, 4, 2 ], [ 32, 13, 4, 3 ], \n [ 32, 13, 4, 4 ], [ 32, 14, 1, 1 ], [ 32, 14, 1, 2 ], [ 32, 14, 1, 3 ], \n [ 32, 14, 1, 4 ], [ 32, 14, 2, 1 ], [ 32, 14, 2, 2 ], [ 32, 14, 2, 3 ], \n [ 32, 14, 2, 4 ], [ 32, 14, 3, 1 ], [ 32, 14, 3, 2 ], [ 32, 14, 3, 3 ], \n [ 32, 14, 3, 4 ], [ 32, 14, 3, 5 ], [ 32, 14, 4, 1 ], [ 32, 14, 4, 2 ], \n [ 32, 14, 4, 3 ], [ 32, 14, 4, 4 ], [ 32, 14, 4, 5 ], [ 32, 14, 4, 6 ], \n [ 32, 14, 4, 7 ], [ 32, 14, 4, 8 ], [ 32, 14, 4, 9 ], [ 32, 14, 4, 10 ], \n [ 32, 15, 1, 1 ], [ 32, 15, 1, 2 ], [ 32, 15, 1, 3 ], [ 32, 15, 1, 4 ], \n [ 32, 15, 2, 1 ], [ 32, 15, 2, 2 ], [ 32, 15, 2, 3 ], [ 32, 15, 2, 4 ], \n [ 32, 16, 1, 1 ], [ 32, 16, 2, 1 ], [ 32, 16, 2, 2 ], [ 32, 16, 3, 1 ], \n [ 32, 17, 1, 1 ], [ 32, 17, 1, 2 ], [ 32, 17, 1, 3 ], [ 32, 17, 1, 4 ], \n [ 32, 17, 1, 5 ], [ 32, 17, 1, 6 ], [ 32, 17, 1, 7 ], [ 32, 17, 1, 8 ], \n [ 32, 17, 2, 1 ], [ 32, 17, 2, 2 ], [ 32, 17, 2, 3 ], [ 32, 17, 2, 4 ], \n [ 32, 17, 2, 5 ], [ 32, 17, 2, 6 ], [ 32, 17, 2, 7 ], [ 32, 17, 2, 8 ], \n [ 32, 18, 1, 1 ], [ 32, 18, 1, 2 ], [ 32, 18, 2, 1 ], [ 32, 18, 3, 1 ], \n [ 32, 18, 3, 2 ], [ 32, 19, 1, 1 ], [ 32, 19, 1, 2 ], [ 32, 19, 2, 1 ], \n [ 32, 19, 2, 2 ], [ 32, 19, 3, 1 ], [ 32, 19, 3, 2 ], [ 32, 20, 1, 1 ], \n [ 32, 20, 1, 2 ], [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, 1, 3 ], \n [ 7, 5, 1, 4 ], [ 7, 5, 2, 1 ], [ 7, 5, 2, 2 ], [ 7, 5, 2, 3 ], \n [ 7, 5, 2, 4 ], [ 7, 5, 3, 1 ], [ 7, 5, 3, 2 ] ];\n\ncryst2params := \n[ [ 1, 1, 1, 1 ], [ 1, 2, 1, 1 ], [ 2, 1, 1, 1 ], [ 2, 1, 1, 2 ], \n [ 2, 1, 2, 1 ], [ 2, 2, 1, 1 ], [ 2, 2, 1, 2 ], [ 2, 2, 1, 3 ], \n [ 2, 2, 2, 1 ], [ 3, 1, 1, 1 ], [ 3, 2, 1, 1 ], [ 3, 2, 1, 2 ], \n [ 4, 1, 1, 1 ], [ 4, 2, 1, 1 ], [ 4, 2, 2, 1 ], [ 4, 3, 1, 1 ], \n [ 4, 4, 1, 1 ] ];\n\nNumberSpaceGroups := function( dim )\n if dim = 4 then return 4783; fi;\n if dim = 3 then return 219; fi;\n if dim = 2 then return 17; fi;\nend;\n\nSpaceGroup := function( dim, nr )\n local type;\n if dim = 4 then\n type := cryst4params[nr];\n return SpaceGroupBBNWZ( 4, type[1], type[2], type[3], type[4] );\n elif dim = 3 then \n type := cryst3params[nr];\n return SpaceGroupBBNWZ( 3, type[1], type[2], type[3], type[4] );\n elif dim = 2 then \n type := cryst2params[nr];\n return SpaceGroupBBNWZ( 2, type[1], type[2], type[3], type[4] );\n else\n return fail;\n fi;\nend; \n\nPointGroupByNumber := function( dim, nr )\n local type;\n if dim = 4 then \n type := cryst4params[nr];\n return MatGroupZClass( 4, type[1], type[2], type[3] );\n elif dim = 3 then \n type := cryst3params[nr];\n return MatGroupZClass( 3, type[1], type[2], type[3] );\n elif dim = 2 then \n type := cryst2params[nr];\n return MatGroupZClass( 2, type[1], type[2], type[3] );\n fi;\nend;\n\nSpaceGroupPcpGroup := function( dim, nr )\n local G, iso, H, F, n;\n G := SpaceGroup( dim, nr );\n iso := IsomorphismPcpGroup( G );\n if IsBool( iso ) then return fail; fi;\n H := Image( iso );\n n := Length( Igs(H) );\n F := Subgroup( H, Igs(H){[n-dim+1..n]} );\n SetFittingSubgroup( H, F );\n return H;\nend;\n\n", "meta": {"hexsha": "b3d291199970a9b90616d956629820e784eb5d1e", "size": 92503, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "gap/crystgrp.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/crystgrp.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/crystgrp.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": 69.4466966967, "max_line_length": 78, "alphanum_fraction": 0.2996335254, "num_tokens": 68312, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.5273165233795671, "lm_q1q2_score": 0.37725490059787614}} | |
| {"text": "#############################################################################\n##\n## ExternalPolymakeCone.gi JConvex package\n## Martin Bies\n##\n## Copyright 2021 University of Pennsylvania\n##\n## A Gap package to do convex geometry by Polymake\n##\n## Chapter Cones in Polymake\n##\n#############################################################################\n\n\n##############################################################################################\n##\n## Section GAP category of PolymakeCones\n##\n##############################################################################################\n\nDeclareRepresentation( \"IsPolymakeConeRep\", IsPolymakeCone and IsAttributeStoringRep, [ ] );\n\nBindGlobal( \"TheFamilyOfPolymakeCones\", NewFamily( \"TheFamilyOfPolymakeCones\" ) );\n\nBindGlobal( \"TheTypeOfPolymakeCone\", NewType( TheFamilyOfPolymakeCones, IsPolymakeConeRep ) );\n\nBindGlobal( \"JuliaMatrixInt\", JuliaEvalString(\"Matrix{BigInt}\") );\n\nBindGlobal( \"PolymakeMatrixToGAP\", function( mat )\n mat := _Polymake_jl.common.primitive( mat ); # ensure integer coeffs\n return JuliaToGAP( IsList, JuliaMatrixInt( mat ), true );\nend );\n\nBindGlobal( \"MakePolymakeConeVRep\", function( rays, lineality )\n local cone, kwargs;\n cone := Objectify( TheTypeOfPolymakeCone,\n rec( rays := Immutable( rays ),\n lineality := Immutable( lineality ),\n number_type := \"rational\",\n rep_type := \"V-rep\" ) );\n\n kwargs := rec();\n\n # TODO: verify that kwargs is set correctly, also if one or both lists are empty\n\n # check for degenerate case\n if Length( rays ) > 0 then\n kwargs.INPUT_RAYS := JuliaMatrixInt( rays );\n\n # if we also have lineality, add them\n if Length( lineality ) > 0 then\n kwargs.INPUT_LINEALITY := JuliaMatrixInt( lineality );\n fi;\n elif Length( lineality ) > 0 then\n kwargs.INPUT_RAYS := JuliaMatrixInt( lineality );\n kwargs.INPUT_LINEALITY := kwargs.INPUT_RAYS;\n fi;\n\n cone!.pmobj := CallJuliaFunctionWithKeywordArguments( _Polymake_jl.polytope.Cone, [], kwargs );\n return cone;\nend);\n\nBindGlobal( \"MakePolymakeConeHRep\", function( inequalities, equalities )\n local cone, kwargs;\n cone := Objectify( TheTypeOfPolymakeCone,\n rec( inequalities := Immutable( inequalities ),\n equalities := Immutable( equalities ),\n number_type := \"rational\",\n rep_type := \"H-rep\" ) );\n\n kwargs := rec();\n\n # TODO: verify that kwargs is set correctly, also if one or both lists are empty\n\n # check for degenerate case\n if Length( inequalities ) > 0 then\n kwargs.INEQUALITIES := JuliaMatrixInt( inequalities );\n\n # if we have non-zero equalities, add them\n if Length( equalities ) > 0 then\n kwargs.EQUATIONS := JuliaMatrixInt( equalities );\n fi;\n elif Length( equalities ) > 0 then\n kwargs.INEQUALITIES := JuliaMatrixInt( equalities );\n kwargs.EQUATIONS := kwargs.INEQUALITIES;\n fi;\n\n cone!.pmobj := CallJuliaFunctionWithKeywordArguments( _Polymake_jl.polytope.Cone, [], kwargs );\n return cone;\nend);\n\n\n##############################################################################################\n##\n## Constructors for PolymakeCones\n##\n##############################################################################################\n\nInstallGlobalFunction( Polymake_ConeByGenerators,\n function( arg )\n local given_rays, i, given_lineality, cone;\n \n if Length( arg ) = 0 then\n \n Error( \"Wrong input: Please provide some input!\" );\n \n elif Length( arg ) = 1 and IsList( arg[1] ) then\n \n given_rays := Filtered( arg[ 1 ], row -> not IsZero( row ) );\n if Length( given_rays ) > 0 then\n \n # non-trivial cone\n return Polymake_ConeByGenerators( arg[ 1 ], [ ] );\n \n else\n \n # received the trivial cone\n cone := MakePolymakeConeVRep( [ ], [ ] );\n return cone;\n \n fi;\n \n elif Length( arg ) = 2 and IsList( arg[ 1 ] ) and IsList( arg[ 2 ] ) then\n \n if ( not IsEmpty( arg[ 1 ] ) ) and not ( IsMatrix( arg[ 1 ] ) ) then\n Error( \"Wrong input: The first argument should be a Gap matrix!\" );\n fi;\n \n if ( not IsEmpty( arg[ 2 ] ) ) and not ( IsMatrix( arg[ 2 ] ) ) then\n Error( \"Wrong input: The second argument should be a Gap matrix!\" );\n fi;\n \n given_rays := Filtered( arg[ 1 ], row -> not IsZero( row ) );\n given_lineality := Filtered( arg[ 2 ], row -> not IsZero( row ) );\n cone := MakePolymakeConeVRep( given_rays, given_lineality );\n return Polymake_CanonicalConeByGenerators( cone );\n \n fi;\n \nend );\n\nInstallGlobalFunction( Polymake_ConeFromInequalities,\n function( arg )\n local given_ineqs, given_eqs, cone;\n \n if Length( arg ) = 0 or ForAll( arg, IsEmpty ) then\n \n Error( \"Wrong input: Please provide some input!\" );\n \n elif Length( arg ) = 1 and IsList( arg[ 1 ] ) then\n \n return Polymake_ConeFromInequalities( arg[ 1 ], [ ] );\n \n elif Length( arg ) = 2 and IsList( arg[ 1 ] ) and IsList( arg[ 2 ] ) then\n \n if ( not IsEmpty( arg[ 1 ] ) ) and not ( IsMatrix( arg[ 1 ] ) ) then\n Error( \"Wrong input: The first argument should be a Gap matrix!\" );\n fi;\n \n if ( not IsEmpty( arg[ 2 ] ) ) and not ( IsMatrix( arg[ 2 ] ) ) then\n Error( \"Wrong input: The second argument should be a Gap matrix!\" );\n fi;\n \n given_ineqs := Filtered( arg[ 1 ], row -> not IsZero( row ) );\n given_eqs := Filtered( arg[ 2 ], row -> not IsZero( row ) );\n cone := MakePolymakeConeHRep( given_ineqs, given_eqs );\n return Polymake_CanonicalConeFromInequalities( cone );\n \n fi;\n \nend );\n\n\n##############################################################################################\n##\n## Canonicalize cones\n##\n##############################################################################################\n\nInstallMethod( Polymake_CanonicalConeByGenerators,\n [ IsPolymakeCone ],\n function( cone )\n local rays, lineality;\n \n if cone!.rep_type = \"H-rep\" then\n \n return fail;\n \n else\n \n # compute rays\n rays := PolymakeMatrixToGAP( cone!.pmobj.RAYS );\n \n # extract lineality\n lineality := PolymakeMatrixToGAP( cone!.pmobj.LINEALITY_SPACE );\n \n # construct the new cone\n return MakePolymakeConeVRep( rays, lineality );\n \n fi;\n \nend );\n\nInstallMethod( Polymake_CanonicalConeFromInequalities,\n [ IsPolymakeCone ],\n function( cone )\n local ineqs, eqs;\n \n if cone!.rep_type = \"V-rep\" then\n \n return fail;\n \n else\n \n # compute facets\n ineqs := PolymakeMatrixToGAP( cone!.pmobj.FACETS );\n \n # compute linear span\n eqs := PolymakeMatrixToGAP( cone!.pmobj.LINEAR_SPAN );\n \n # construct the new cone\n return MakePolymakeConeHRep( ineqs, eqs );\n \n fi;\n \nend );\n\n\n##############################################################################################\n##\n## Conversion of cones\n##\n##############################################################################################\n\nInstallMethod( Polymake_V_Rep,\n [ IsPolymakeCone ],\n function( cone )\n local rays, lineality;\n \n if cone!.rep_type = \"V-rep\" then\n return cone;\n else\n \n # compute rays\n rays := PolymakeMatrixToGAP( cone!.pmobj.RAYS );\n \n # extract lineality\n lineality := PolymakeMatrixToGAP( cone!.pmobj.LINEALITY_SPACE );\n \n # construct the new cone\n return MakePolymakeConeVRep( rays, lineality );\n \n fi;\n \nend );\n\nInstallMethod( Polymake_H_Rep,\n [ IsPolymakeCone ],\n function( cone )\n local ineqs, eqs;\n \n if cone!.rep_type = \"H-rep\" then\n \n return cone;\n \n else\n \n if cone!.rep_type = \"V-rep\" and cone!.rays = [] then\n return Polymake_ConeFromInequalities( [ [ 0, 1 ], [ -1, -1 ] ] );\n fi;\n \n # compute facets\n ineqs := PolymakeMatrixToGAP( cone!.pmobj.FACETS );\n \n # compute linear span\n eqs := PolymakeMatrixToGAP( cone!.pmobj.LINEAR_SPAN );\n \n # construct the new cone\n return MakePolymakeConeHRep( ineqs, eqs );\n \n fi;\n \nend );\n\n\n##############################################################################################\n##\n## Attributes of cones\n##\n##############################################################################################\n\nInstallMethod( Polymake_AmbientSpaceDimension,\n \"finding the dimension of the ambient space of the cone\",\n [ IsPolymakeCone ],\n function( cone )\n \n return Length( Polymake_V_Rep( cone )!.rays[1] );\n \nend );\n\n\nInstallMethod( Polymake_Dimension,\n \" returns the dimension of the cone\",\n [ IsPolymakeCone ],\n function( cone )\n \n if Polymake_IsEmpty( cone ) then \n return -1;\n fi;\n \n return cone!.pmobj.CONE_DIM;\n \nend );\n\n\nInstallMethod( Polymake_Rays,\n \" return the list of generating vertices\",\n [ IsPolymakeCone ],\n function( cone )\n \n return Set( Polymake_V_Rep( cone )!.rays );\n \nend );\n\n\nInstallMethod( Polymake_Lineality,\n \" return the list of generating vertices\",\n [ IsPolymakeCone ],\n function( cone )\n \n return Set( Polymake_V_Rep( cone )!.lineality );\n \nend );\n\n\nInstallMethod( Polymake_Equalities,\n \" return the list of equalities of a cone\",\n [ IsPolymakeCone ],\n function( cone )\n \n return Set( ( Polymake_H_Rep( cone ) )!.equalities );\n \nend );\n\n\nInstallMethod( Polymake_Inequalities,\n \" return the list of inequalities of a cone\",\n [ IsPolymakeCone ],\n function( cone )\n \n return Set( ( Polymake_H_Rep( cone ) )!.inequalities );\n \nend );\n\n\nInstallMethod( Polymake_RaysInFacets,\n \" returns the incident matrix of the rays in the facets\",\n [ IsPolymakeCone ],\n function( cone )\n local help_cone, s, res_string, number_rays, ray_list, i, dummy, j, helper;\n \n help_cone := Polymake_V_Rep( cone );\n number_rays := Length( help_cone!.rays );\n s := JuliaToGAP( IsString, Julia.string( help_cone!.pmobj.RAYS_IN_FACETS ) );\n \n # process the string\n res_string := SplitString( s, '\\n' );\n res_string := List( [ 2 .. Length( res_string ) ], i -> EvalString( res_string[ i ] ) );\n \n # now construct list of rays -- each facets is a list number_rays entries: 0 indicates that the ray generator is not in the facet and a 1 that it is part of the facet\n ray_list := [];\n for i in [ 1 .. Length( res_string ) ] do\n dummy := List( [ 1 .. number_rays ], i -> 0 );\n for j in [ 1 .. Length( res_string[ i ] ) ] do\n dummy[ res_string[ i ][ j ] ] := 1;\n od;\n Append( ray_list, [ dummy ] );\n od;\n \n # return the result\n return ray_list;\n \nend );\n\nInstallMethod( Polymake_RaysInFaces,\n \" returns the incident matrix of the rays in the faces\",\n [ IsPolymakeCone ],\n function( cone )\n local dim, help_cone, rays, rays_in_faces, i, generators, additional_rays, j, converted_additional_rays, pos, pos2, k, help_list;\n \n # check degenerate case\n dim := Polymake_Dimension( cone );\n if ( dim = 2 ) then\n \n rays_in_faces := Polymake_RaysInFacets( cone );\n \n else\n \n # compute a V-representation of the cone\n help_cone := Polymake_V_Rep( cone );\n \n # read-off the rays and the list of rays in the facets\n rays := help_cone!.rays;\n rays_in_faces := Polymake_RaysInFacets( help_cone );\n \n # construct the facets as cones, compute their facets and add them\n # this is thus a recursive function, with (presumably) low performance\n for i in [ 1 .. Length( rays_in_faces ) ] do\n \n # construct the i-th facet and compute the rays in its facets\n generators := List( Filtered( [ 1 .. Length( rays ) ], j -> not IsZero( rays_in_faces[ i ][ j ] ) ), k -> rays[ k ] );\n additional_rays := RaysInFaces( Cone( generators ) );\n \n # convert these lists into a list with the rays above\n converted_additional_rays := [];\n for j in [ 1 .. Length( additional_rays ) ] do\n pos := Positions( additional_rays[ j ], 1 );\n pos2 := List( [ 1 .. Length( pos ) ], k -> Position( rays, generators[ pos[ k ] ] ) );\n help_list := List( [ 1 .. Length( rays ) ], k -> 0 );\n for k in pos2 do\n help_list[ k ] := 1;\n od;\n converted_additional_rays := Concatenation( converted_additional_rays, [ help_list ] );\n od;\n \n # add this list of rays in the faces of the i-th facet to the above-computed list of rays_in_facets\n rays_in_faces := Concatenation( rays_in_faces, converted_additional_rays );\n \n od;\n \n fi;\n \n # all all rays, since the overall cone is also a face\n rays_in_faces := Concatenation( rays_in_faces, [ ListWithIdenticalEntries( Length( Polymake_Rays( cone ) ), 1 ) ] );\n \n # return the result\n return DuplicateFreeList( rays_in_faces );\n \nend );\n\n\n##############################################################################################\n##\n## Properties of PolymakeCones\n##\n##############################################################################################\n\nInstallMethod( Polymake_IsEmpty,\n \"finding if the cone empty is or not\",\n [ IsPolymakeCone ],\n function( cone )\n \n return Length( Polymake_V_Rep( cone )!.rays ) = 0;\n \nend );\n\n\nInstallMethod( Polymake_IsPointed,\n \"finding if the cone is pointed or not\",\n [ IsPolymakeCone ],\n function( cone )\n local help_cone;\n \n help_cone := Polymake_V_Rep( cone );\n \n return help_cone!.pmobj.POINTED;\n \nend );\n\n\n##############################################################################################\n##\n## Operations with cones\n##\n##############################################################################################\n\nInstallMethod( Polymake_Intersection,\n \"construct intersection of two cones\",\n [ IsPolymakeCone, IsPolymakeCone ],\n function( cone1, cone2 )\n local cone1_h, cone2_h, new_ineqs, new_equ;\n \n cone1_h := Polymake_H_Rep( cone1 );\n cone2_h := Polymake_H_Rep( cone2 );\n \n new_ineqs := Concatenation( cone1_h!.inequalities, cone2_h!.inequalities );\n new_equ := Concatenation( cone1_h!.equalities, cone2_h!.equalities );\n \n return Polymake_ConeFromInequalities( new_ineqs, new_equ );\n \nend );\n", "meta": {"hexsha": "c4da053e6523a5ef7e03700919068f4f1311e5ac", "size": 15327, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "pkg/JConvex/gap/ExternalPolymakeCone.gi", "max_stars_repo_name": "HereAround/JToric.jl", "max_stars_repo_head_hexsha": "e8907f1ccd10a637254808916f859e354e479296", "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": "pkg/JConvex/gap/ExternalPolymakeCone.gi", "max_issues_repo_name": "HereAround/JToric.jl", "max_issues_repo_head_hexsha": "e8907f1ccd10a637254808916f859e354e479296", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 44, "max_issues_repo_issues_event_min_datetime": "2021-09-17T01:15:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-25T00:15:13.000Z", "max_forks_repo_path": "pkg/JConvex/gap/ExternalPolymakeCone.gi", "max_forks_repo_name": "HereAround/JToric.jl", "max_forks_repo_head_hexsha": "e8907f1ccd10a637254808916f859e354e479296", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-19T11:22:58.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-19T11:22:58.000Z", "avg_line_length": 31.1524390244, "max_line_length": 170, "alphanum_fraction": 0.5256736478, "num_tokens": 3734, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.37719850583480313}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# First, for Pease, need parameters:\n# 1. n\n# 2. direction (forward or inverse)\n# 3. data width\n# 4. twiddle width\n# 5. bit reverse in/out\n# 6. scaling?\n# 7. parallelism (streaming width)\n# 8. BRAM budget\n\n# bitrev = 0 --> n/n\n# bitrev = 1 --> n/r\n# bitrev = 2 --> r/n\n\n# direction = 0 --> DFT(n, -1) (forward)\n# direction = 1 --> DFT(n, 1) (inverse)\n\n# test:\n# webGen(0, 16, 2, 0, 0, 16, 16, 0, 0, 4, -1, 0, \"test\");\n# output in /tmp/spiral/[PID]/test.v\n\n_splhdl_path := \"\"; #set in .gaprc\n\n\n\nwebGen := function(arch, size, radix, direction, d_type, d_width, t_width, bitrev, scaling, width, brams, ip, name)\n local opts, t, fwd, scale_str, bram_str;\n\n # With radix limited to 16, this will avoid more expensive 2/8 and 8/2 CT splits.\n# DFT_CT.children := (nt) -> Map2(Filtered(DivisorPairs(nt.params[1]), divpair -> (divpair[1] <= 4 and divpair[2] <= 4)), (m,n) -> [ DFT(m, nt.params[2] mod m), DFT(n, nt.params[2] mod n) ]);\n\n if (ip = 0) then\n paradigms.stream.avoidPermPatent := 1;\n fi;\n\n\n if (arch = 0) then\n opts := InitStreamHw();\n else\n opts := InitStreamUnrollHw();\n fi;\n\n fwd := Cond(direction = 0, -1, 1);\n scale_str := Cond(scaling = 0, \" \", \" -s \");\n bram_str := Cond(brams = -1, \" \", ConcatenationString(\" -br \", String(brams)));\n \n if (_splhdl_path = \"\") then\n\tError(\"Error: path to SPLHDL compiler not set: paradigms.stream._splhdl_path is not bound.\");\n fi;\n\n\n opts.profile.makeopts.SPLHDL := _splhdl_path; #\"/home/pam/web_backends/splhdl/src/splhdl\";\n opts.profile.makeopts.OUTNAME := ConcatenationString(String(name), \".v\");\n opts.profile.makeopts.GAP := \"gap.spl\"; \n opts.profile.makeopts.WRAP := ConcatenationString(scale_str, bram_str, \" -lic -web\");\n\n if (d_type = 0) then\n opts.profile.makeopts.DATATYPE := ConcatenationString(\"fix \", StringInt(d_width));\n else\n opts.profile.makeopts.DATATYPE := ConcatenationString(\"flt \", StringInt(d_width));\n fi;\n\n# opts.profile.makeopts.TWIDTYPE := ConcatenationString(\"-fixtw\", \" \", StringInt(t_width));\n# Print(\"name: \", name, \"\\n\");\n \n DFTDR_tSPL_Pease.unroll_its := 1;\n DRDFT_tSPL_Pease.unroll_its := 1;\n \n if ((size = 4) and (width=4) and (radix=2)) then \n radix := 4; \n fi; \n \n if (bitrev = 0) then\n t := streamDFT(TRC(DFT(size, fwd)).withTags([AStream(2*width)]), radix, opts);\n else\n if (bitrev = 1) then\n t := streamDFT(TRC(DRDFT(size, fwd, radix)).withTags([AStream(2*width)]), radix, opts);\n else\n t := streamDFT(TRC(DFTDR(size, fwd, radix)).withTags([AStream(2*width)]), radix, opts);\n fi;\n fi;\n\n# Print(\"t = \", t, \"\\n\\n\\n\");\n \n return CMeasure(t, opts);\n\nend;\n\n\nwebGenDCT := function(size, d_type, d_width, brams, width, ip, name)\n local opts, bram_str, t, width;\n\n if (ip = 0) then\n paradigms.stream.avoidPermPatent := 1;\n fi;\n\n\n opts := InitStreamUnrollHw();\n bram_str := Cond(brams = -1, \" \", ConcatenationString(\" -br \", String(brams)));\n\n if (_splhdl_path = \"\") then\n\tError(\"Error: path to SPLHDL compiler not set: paradigms.stream._splhdl_path is not bound.\");\n fi;\n\n opts.profile.makeopts.SPLHDL := _splhdl_path; \n opts.profile.makeopts.OUTNAME := ConcatenationString(String(name), \".v\");\n opts.profile.makeopts.GAP := \"gap.spl\"; \n opts.profile.makeopts.WRAP := ConcatenationString(bram_str, \" -lic -webdct\");\n\n if (d_type = 0) then\n opts.profile.makeopts.DATATYPE := ConcatenationString(\"fix \", StringInt(d_width));\n else\n opts.profile.makeopts.DATATYPE := ConcatenationString(\"flt \", StringInt(d_width));\n fi;\n \n t := streamDCTUnroll(size, width);\n return CMeasure(t, opts);\nend;\n", "meta": {"hexsha": "cfc227fb5e88f83ae6723abcffe175bbd04be2b9", "size": 3763, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/stream/webscr.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/webscr.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/webscr.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.3467741935, "max_line_length": 193, "alphanum_fraction": 0.6266276907, "num_tokens": 1236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.5234203489363239, "lm_q1q2_score": 0.37612692770312334}} | |
| {"text": "\nlocal reps,tori,labels,I,II,ords,mizuno,blocks;\n\nmizuno:=[[ 1, 2, 3, 4, 5, 6, 7,\n 8, 9, 10, 11,\n 12, 13, 14, 15,\n 17, 16, 18, 19,\n 20, 21, 22, 24,\n 23, 25, 26, 27,\n 28, 29, 31, 30,\n 32, 33, 34, 35,\n 36, 37, 38, 39,\n 40, 41, 42, 43,\n 44, 45, 46, 47,\n 48, 49, 50, 51,\n 52, 53, 54, 55,\n 56, 57, 58, 59,\n 60, 61, 62, 63 ],\n []];\n\nreps:=[[[1,1],[2,1],[3,1],[4,1],[5,1],[6,1],[7,1]], # E_7\n [[1,1],[3,1],[10,1],[9,1],[5,1],[6,1],[7,1]], # E_7(a_1)\n [[1,1],[2,1],[3,1],[9,1],[11,1],[12,1],[13,1]], # E_7(a_2) ? 3/8\n [[1,1],[9,1],[10,1],[17,1],[22,1],[12,1],[7,1]], # D_6+A_1\n [[1,1],[3,1],[9,1],[11,1],[12,1],[13,1]], # E_6 ? 3/8\n [[8,1],[9,1],[11,1],[16,1],[12,1],[13,1]], # E_6(a_1)\n [[1,1],[15,1],[16,1],[17,1],[6,1],[7,1]], # D_6\n [[1,1],[15,1],[16,1],[17,1],[18,1],[23,1],[13,1]], # D_6(a_1)+A_1\n [[14,1],[15,1],[16,1],[17,1],[12,1],[13,1]], # A_6\n [[1,1],[15,1],[17,1],[23,1],[24,1],[7,1]], # D_6(a_1)\n [[1,1],[15,1],[16,1],[17,1],[18,1],[19,1]], # D_5+A_1\n [[14,1],[15,1],[27,1],[17,1],[18,1],[19,1],[23,1]], # D_6(a_2)+A_1\n [[1,1],[15,1],[16,1],[18,1],[19,1]], # D_5\n [[8,1],[15,1],[16,1],[20,1],[24,1],[25,1]], # (A_5+A_1)'\n [[15,1],[20,1],[21,1],[23,1],[13,1],[17,1]], # D_6(a_2)\n [[20,1],[21,1],[23,1],[24,1],[28,1],[7,1]], # (A_5+A_1)''\n [[28,1],[12,1],[13,1],[20,1],[21,1]], # A_5'\n [[14,1],[22,1],[23,1],[24,1],[25,1],[19,1]], # D_5(a_1)+A_1\n [[20,1],[21,1],[23,1],[24,1],[7,1]], # A_5''\n [[20,1],[21,1],[22,1],[23,1],[24,1],[25,1]], # A_4+A_2\n [[8,1],[28,1],[24,1],[25,1],[30,1]], # D_5(a_1)\n [[20,1],[21,1],[24,1],[30,1]], # A_4\n [[20,1],[21,1],[24,1],[28,1],[30,1]], # A_4+A_1\n [[1,1],[28,1],[29,1],[30,1],[31,1]], # D_4+A_1\n [[26,1],[27,1],[28,1],[29,1],[30,1],[31,1]], # A_3+A_2+A_1\n [[1,1],[28,1],[29,1],[30,1]], # D_4\n [[27,1],[29,1],[30,1],[31,1],[32,1],[37,1]], # A_3+A_2\n# [[27,1],[29,1],[30,1],[31,1],[32,1]], # (A_3+A_2)_2\n [[28,1],[30,1],[31,1],[33,1],[34,1]], # D_4(a_1)+A_1\n [[28,1],[30,1],[33,1],[34,1]], # D_4(a_1)\n [[30,1],[31,1],[32,1],[33,1],[40,1]], # A_3+2A_1\n [[26,1],[27,1],[40,1],[41,1]], # (A_3+A_1)'\n [[30,1],[31,1],[32,1],[33,1]], # (A_3+A_1)''\n [[20,1],[21,1],[49,1]], # A_3\n [[34,1],[36,1],[37,1],[38,1],[40,1]], # 2A_2+A_1\n [[34,1],[36,1],[38,1],[40,1]], # 2A_2\n [[37,1],[38,1],[39,1],[40,1],[41,1]], # A_2+3A_1\n [[42,1],[43,1],[44,1],[45,1]], # A_2+2A_1\n [[44,1],[46,1],[49,1]], # A_2+A_1\n [[44,1],[46,1]], # A_2\n [[47,1],[48,1],[49,1],[53,1]], # 4A_1\n [[53,1],[54,1],[55,1]], # (3A_1)'\n [[47,1],[48,1],[49,1]], # (3A_1)''\n [[58,1],[59,1]], # 2A_1\n [[63,1]] # A_1\n ];\n\nlabels:=[\"E_7\",\n \"E_7(a_1)\",\n \"E_7(a_2)\",\n \"D_6+A_1\",\n \"E_6\",\n \"E_6(a_1)\",\n \"D_6\",\n \"D_6(a_1)+A_1\",\n \"A_6\",\n \"D_6(a_1)\",\n \"D_5+A_1\",\n \"D_6(a_2)+A_1\",\n \"D_5\",\n \"(A_5+A_1)'\",\n \"D_6(a_2)\",\n \"(A_5+A_1)''\",\n \"A_5'\",\n \"D_5(a_1)+A_1\",\n \"A_5''\",\n \"A_4+A_2\",\n \"D_5(a_1)\",\n \"A_4\",\n \"A_4+A_1\",\n \"D_4+A_1\",\n \"A_3+A_2+A_1\",\n \"D_4\",\n \"A_3+A_2\",\n# \"(A_3+A_2)_2\"\n \"D_4(a_1)+A_1\",\n \"D_4(a_1)\",\n \"A_3+2A_1\",\n \"(A_3+A_1)'\",\n \"(A_3+A_1)''\",\n \"A_3\",\n \"2A_2+A_1\",\n \"2A_2\",\n \"A_2+3A_1\",\n \"A_2+2A_1\",\n \"A_2+A_1\",\n \"A_2\",\n \"4A_1\",\n \"(3A_1)'\",\n \"(3A_1)''\",\n \"2A_1\",\n \"A_1\",\n ];\n\nI:=[ [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ] ];#, [ ] ];\n\nII:=[ [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ] ];#, [ ] ];\n\ntori:=[ [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ] ];#, [ ] ];\n\n#blocks:=[];\nblocks:=[[[27, 3], [19, 1], [15, 1], [9, 2]], [[27, 1], [19, 1], [18, 2], [15, 1], [9, 4]], [[19, 1], [18, 2], [15, 1], [9, 7]], [[19, 1], [17, 1], [15, 2], [11, 2], [9, 3], [6, 2], [3, 2]], [[19, 1], [15, 4], [9, 5], [3, 3]], [[9, 14], [7, 1]], [[19, 1], [16, 2], [15, 1], [11, 1], [10, 2], [9, 2], [6, 2], [3, 1], [1, 3]], [[9, 12], [7, 1], [6, 2], [3, 2]], [[9, 11], [7, 4], [3, 1], [1, 3]], [[9, 11], [8, 2], [6, 2], [3, 1], [1, 3]], [[9, 11], [8, 2], [6, 2], [3, 1], [1, 3]], [[9, 9], [7, 1], [6, 2], [5, 3], [3, 6]], [[9, 11], [7, 4], [1, 6]], [[9, 6], [7, 1], [6, 8], [3, 8]], [[9, 9], [7, 1], [6, 2], [5, 1], [4, 4], [3, 3], [1, 3]], [[9, 9], [3, 16], [2, 2]], [[9, 5], [8, 2], [6, 8], [3, 7], [1, 3]], [[9, 5], [7, 4], [6, 6], [3, 7], [1, 3]], [[9, 9], [3, 15], [1, 7]], [[9, 3], [7, 1], [6, 8], [5, 3], [3, 12]], [[9, 3], [8, 4], [7, 2], [6, 6], [3, 4], [2, 4], [1, 4]], [[9, 1], [7, 7], [5, 9], [3, 7], [1, 9]], [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 2], [3, 8], [2, 2], [1, 2]], [[9, 2], [8, 4], [7, 5], [6, 4], [3, 2], [2, 4], [1, 10]], [[7, 1], [6, 8], [5, 3], [3, 21]], [[9, 2], [7, 13], [3, 1], [1, 21]], [[7, 1], [6, 8], [5, 1], [4, 4], [3, 18], [1, 3]], [[7, 1], [6, 6], [5, 4], [4, 4], [3, 16], [1, 6]], [[7, 1], [6, 2], [5, 12], [3, 15], [1, 9]], [[7, 1], [6, 4], [5, 7], [4, 4], [3, 11], [2, 6], [1, 6]], [[7, 1], [6, 2], [5, 7], [4, 10], [3, 6], [2, 6], [1, 9]], [[7, 1], [5, 15], [3, 10], [1, 21]], [[7, 1], [5, 7], [4, 16], [3, 1], [1, 24]], [[3, 43], [2, 2]], [[3, 42], [1, 7]], [[3, 42], [1, 7]], [[3, 37], [2, 8], [1, 6]], [[3, 34], [2, 8], [1, 15]], [[3, 33], [1, 34]], [[3, 28], [2, 14], [1, 21]], [[3, 19], [2, 26], [1, 24]], [[3, 27], [1, 52]], [[3, 10], [2, 32], [1, 39]], [[3, 1], [2, 32], [1, 66]]];\n\n#ords:=[];\nords:=[ 27, 27, 27, 27, 27, 9, 27, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ];\n\nreturn [reps,tori,labels,I,II,ords,blocks,mizuno];\n", "meta": {"hexsha": "79b36d5781f38e1cd781ccdac75f287b7d095a52", "size": 7528, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "lib/data/dataE7char3Mizuno.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/dataE7char3Mizuno.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/dataE7char3Mizuno.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": 58.8125, "max_line_length": 1739, "alphanum_fraction": 0.2489373007, "num_tokens": 3810, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8128673087708698, "lm_q2_score": 0.4610167793123159, "lm_q1q2_score": 0.3747454686978162}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\nNewRulesFor(TRCDiag, rec(\n TRCDiag_VRCLR := rec(\n applicable := (self, t) >> t.hasTags() and ObjId(t.firstTag()) = AVecReg,\n apply := (self, t, C, Nonterms) >> let(isa := t.firstTag().isa, v := isa.v, n := Rows(t), \n FormatPrm(fTensor(fId(n/v), L(2*v, v))) * \n VRCLR(Diag(t.params[1]), v) * \n FormatPrm(fTensor(fId(n/v), L(2*v, 2)))\n )\n )\n));\n", "meta": {"hexsha": "cc471b799c9ec9e37711d66db406cc0df96f8e38", "size": 485, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/vector/breakdown/trcdiag.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/trcdiag.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/trcdiag.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.3333333333, "max_line_length": 98, "alphanum_fraction": 0.5402061856, "num_tokens": 163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.36971524648927734}} | |
| {"text": "# Action of a group on a signed point.\nBindGlobal(\"OnSignedPoints\", function(dp, signs)\n local p1, p2;\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n return function(e, g)\n return [OnPoints(e[1], Image(p1, g)),\n Permuted(signs, Image(p2, g))[Position(signs, e[2])]];\n end;\nend);\n\n# Action of a product group on vertices of a product graph.\nBindGlobal(\"OnProduct\", function(n, dp)\n local pr;\n pr := List([1..n], i -> Projection(dp, i));\n return function(e, g)\n return List([1..n],\n i -> OnPoints(e[i], Image(pr[i], g)));\n end;\nend);\n\n# Action of a product group on vertices of a sum graph.\nBindGlobal(\"OnSum\", dp -> function(e, g)\n return [e[1], OnPoints(e[2], Image(Projection(dp, e[1]), g))];\n end\n);\n\n# Action of a product group on the multiplication table of its factors.\nBindGlobal(\"OnLatinSquare\", function(dp)\n local p1, p2;\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n return function(e, g)\n return [Image(p1, g) * e[1], e[2] * Image(p2, g)];\n end;\nend);\n\n# Action of a wreath product on vectors over a ring.\nBindGlobal(\"OnZmodnZVectors\", function(d, e)\n local ij;\n ij := Cartesian([1..d], [0..e-1]);\n return function(vec, g)\n local ji, v, w, vw;\n ji := ij{OnTuples([1..d*e], g)};\n vw := List([1..d], i -> ji[Int(vec[i])+(i-1)*e+1]);\n v := List(vw, x -> ZmodnZObj(x[2], e));\n w := List(vw, x -> x[1]);\n return v{List([1..d], i -> Position(w, i))};\n end;\nend);\n\n# Action of a wreath product on pairs of vectors with 3 elements.\nBindGlobal(\"OnVectorPairs\", function(q)\n local ij;\n ij := Cartesian([1..2], [1..3], [0..q-1]);\n return function(M, g)\n local ji, v, w, vw;\n ji := ij{OnTuples([1..6*q], g)};\n vw := List([1..2],\n i -> List([1..3],\n j -> ji[FFEToInt(M[i][j], q)+(j-1)*q+(i-1)*q*3+1]));\n v := List(vw, r -> List(r, x -> IntToFFE(x[3], q)));\n w := List(vw, r -> List(r, x -> x[2]));\n v := List([1..2], i -> v[i]{List([1..3], j -> Position(w[i], j))});\n w := List([1..2], i -> M[i]{List([1..3], j -> Position(w[i], j))});\n return [v[1] + VectorProduct(w[2], v[2]), v[2]];\n end;\nend);\n\n# Action of a wreath product on matrices over a field.\nBindGlobal(\"OnMatrices\", function(q, d, e, dp)\n local F, N, p1, p2, pm;\n F := Elements(GF(q));\n N := Position(F, 0*Z(q));\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n pm := List([0..d-1], i -> List([1..e], j -> Projection(dp, e*i+j+2)));\n return function(M, g)\n return Image(p1, g)*M*Image(p2, g) +\n List(pm, r -> List(r, p -> F[N^Image(p, g)]));\n end;\nend);\n\n# Action of a wreath product on Hermitean matrices over a field.\nBindGlobal(\"OnHermiteanMatrices\", function(r, d, dp)\n local C, F, K, N, p1, pm;\n F := Elements(GF(r));\n N := Position(F, 0*Z(r));\n K := Elements(GF(r^2));\n C := List(K, x -> Conjugates(GF(r^2), GF(r), x)[2]);\n p1 := Projection(dp, 1);\n pm := List([0..d-1], i -> List([1..d], j -> Projection(dp, d*i+j+1)));\n return function(M, g)\n local H;\n H := Image(p1, g);\n return List(H, r -> List(r, x -> C[Position(K, x)]))*M*TransposedMat(H)\n + ToHermitean(List(pm, r -> List(r, p -> F[N^Image(p, g)])), r);\n end;\nend);\n\n# Action of a matrix group on subspaces of a vector space over a finite field.\nBindGlobal(\"OnSubspaces\",\n V -> function(S, g)\n return Subspace(V, OnSubspacesByCanonicalBasis(Basis(S), g));\n end);\n\n# Action of a matrix group on a set of subspaces of a vector space over a\n# finite field.\nBindGlobal(\"OnSetsSubspaces\", function(V)\n local A;\n A := OnSubspaces(V);\n return function(L, g)\n return Set(List(L, S -> A(S, g)));\n end;\nend);\n\n# Action on the vertices of doubled Odd graphs.\nBindGlobal(\"OnDoubledOdd\", function(n, dp)\n local F, p1, p2;\n F := [x -> x, x -> Difference([1..n], x)];\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n return function(s, g)\n return F[1^Image(p2, g)](OnSets(s, Image(p1, g)));\n end;\nend);\n\n# Action on the vertices of doubled Grassmann graphs.\nBindGlobal(\"OnDoubledGrassmann\", function(V, dp)\n local A, F, p1, p2;\n F := [x -> x, OrthogonalSpaceInFullRowSpace];\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n A := OnSubspaces(V);\n return function(S, g)\n return F[1^Image(p2, g)](A(S, Image(p1, g)));\n end;\nend);\n\n# Action on the vertices of Paley graphs.\nBindGlobal(\"OnPaley\", function(q, dp)\n local F, N, p1, p2;\n F := Elements(GF(q));\n N := Position(F, 0*Z(q));\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n return function(x, g)\n return (x + F[N^Image(p1, g)]) * Z(q)^((q-1)^Image(p2, g));\n end;\nend);\n\n# Action on the vertices of Preparata graphs.\nBindGlobal(\"OnPreparata\", function(q, s, dp)\n local F, N, p1, p2, p3, p4;\n F := Elements(GF(q));\n N := Position(F, 0*Z(q));\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n p3 := Projection(dp, 3);\n p4 := Projection(dp, 4);\n return function(t, g)\n local w, z;\n z := Z(q)^((q-1)^Image(p1, g));\n w := [z*t[1], t[2] + 2^Image(p2, g),\n t[3]*z^(s+1) + F[N^Image(p3, g)]];\n return List(w, x -> F[Position(F, x)^Image(p4, g)]);\n end;\nend);\n\n# Action on the vertices of Kasami graphs.\nBindGlobal(\"OnKasami\", function(q, s, dp)\n local Fq, Fs, Nq, Ns, p1, p2, p3;\n Fq := Elements(GF(q));\n Nq := Position(Fq, 0*Z(q));\n Fs := Elements(GF(s));\n Ns := Position(Fs, 0*Z(s));\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n p3 := Projection(dp, 3);\n return function(v, g)\n local w;\n w := [v[1] + Fq[Nq^Image(p1, g)],\n v[2] + Fs[Ns^Image(p2, g)]];\n return List(w, x -> Fs[Position(Fs, x)^Image(p3, g)]);\n end;\nend);\n\n# Action on vertices of additive symplectic covers of complete graphs.\nBindGlobal(\"OnAdditiveSymplecticCover\", function(q, m, B, dp)\n local F, N, p1, p2, pr;\n F := Elements(GF(q));\n N := Position(F, 0*Z(q));\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n pr := List([1..m], i -> Projection(dp, i+2));\n return function(p, g)\n local z;\n z := List([1..m], i -> F[N^Image(pr[i], g)]);\n return [p[1] + F[N^Image(p2, g)] + p[2]*B*z,\n p[2]*Image(p1, g) + z];\n end;\nend);\n\n# Action on vertices of multiplicative symplectic covers of complete graphs.\nBindGlobal(\"OnMultiplicativeSymplecticCover\", function(q, dp)\n local F, p1, p2, p3;\n F := Elements(GF(q));\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n p3 := Projection(dp, 3);\n return function(s, g)\n local g2, g3;\n g2 := Image(p2, g);\n g3 := Image(p3, g);\n return OnSets(Set(List(s, p -> List(Permuted([1,2], g2),\n i -> F[Position(F, p[i])^g3]))),\n Image(p1, g));\n end;\nend);\n\n# Action on the vertices of affine polar graphs.\nBindGlobal(\"OnAffine\", function(q, d, dp)\n local F, N, p1, pr;\n F := Elements(GF(q));\n N := Position(F, 0*Z(q));\n p1 := Projection(dp, 1);\n pr := List([1..d], i -> Projection(dp, i+1));\n return function(v, g)\n return v^Image(p1, g) + List([1..d], i -> F[N^Image(pr[i], g)]);;\n end;\nend);\n\n# Action on the roots of E_8\nBindGlobal(\"OnRoots\", function(v, g)\n return (-1)^(10^g) * v{OnTuples([1..Length(v)], g)};\nend);\n\n# Action of a matrix group on normalized vectors over a semifield.\nBindGlobal(\"OnSemifieldVectors\", function(div)\n local norm;\n norm := NormalizeSemifieldVector(div);\n return function(s, g)\n return norm(s*g);\n end;\nend);\n\n# Action of a matrix group on sets of normalized vectors over a semifield.\nBindGlobal(\"OnSetsSemifieldVectors\", function(div)\n local norm;\n norm := NormalizeSemifieldVector(div);\n return function(S, g)\n return Set(List(S*g, norm));\n end;\nend);\n\n# Action on points and lines of Desarguesian projective planes.\nBindGlobal(\"OnProjectivePlane\", function(V, dp)\n local F, P, p1, p2;\n F := OnSubspaces(V);\n P := [x -> x, OrthogonalSpaceInFullRowSpace];\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n return function(S, g)\n return P[2^Image(p2, g)](F(S, Image(p1, g)));\n end;\nend);\n\n# Action on points or lines of a point-line geometry.\nBindGlobal(\"OnPointsOrLines\", function(act, line)\n return function(x, g)\n if line(x) then\n return Set(List(x, p -> act(p, g)));\n else\n return act(x, g);\n fi;\n end;\nend);\n\n# Action on points and lines of Hall planes.\nBindGlobal(\"OnHallPlane\", function(q, dp)\n local p5, p6, p7, p8, pr, A, F, N;\n pr := List([0,1], i -> List([1,2], j -> Projection(dp, 2*i+j)));\n p5 := Projection(dp, 5);\n p6 := Projection(dp, 6);\n p7 := Projection(dp, 7);\n F := Elements(GF(q));\n N := Position(F, 0*Z(q));\n A := function(p, g)\n local s, M;\n M := Image(p7, g);\n p := List(p, z -> [z[1] + F[N^Image(p5, g)]*z[2],\n z[2]*(Z(q)^((q-1)^Image(p6, g)))]);\n if p = [] then\n if IsZero(M[2][1]) then\n return [];\n else\n return [[M[2][2]/M[1][2], 0*Z(q)]];\n fi;\n elif Length(p) = 1 then\n if not IsZero(p[1][2]) then\n return p;\n fi;\n s := M[1][1] + p[1][1]*M[1][2];\n if IsZero(s) then\n return [];\n else\n return [[(M[2][1] + p[1][1]*M[2][2])/s, 0*Z(q)]];\n fi;\n else\n return M*p + List(pr, r -> List(r, e -> F[N^Image(e, g)]));\n fi;\n end;\n return OnPointsOrLines(A, x -> Length(x) > 2);\nend);\n\n# Action on points and lines of Hughes planes.\nBindGlobal(\"OnHughesPlane\", function(q, div, dp)\n local p1, p2, act, F;\n p1 := Projection(dp, 1);\n p2 := Projection(dp, 2);\n act := OnSemifieldVectors(div);\n F := [Inverse, TransposedMat];\n return function(p, g)\n return [p[1]^Image(p2, g), act(p[2], F[p[1]](Image(p1, g)))];\n end;\nend);\n", "meta": {"hexsha": "4e9246178e6d9643b44fbe6af98b95a89c768c09", "size": 10201, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "lib/GroupActions.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/GroupActions.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/GroupActions.gap", "max_forks_repo_name": "jaanos/gap-graphs", "max_forks_repo_head_hexsha": "18dd56c9b90a12a717a0cc893fdd72c6343ee79b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.1957186544, "max_line_length": 79, "alphanum_fraction": 0.5323007548, "num_tokens": 3334, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.5078118642792044, "lm_q1q2_score": 0.36967456386455866}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\nNewRulesFor(DFT, rec(\n #F DFT_Base: DFT_2 = F_2\n #F\n DFT_tSPL_VBase := rec(\n switch := false,\n applicable := (t) -> Rows(t) = 2 and t.isTag(1,AVecReg),\n children := t -> [[ TTensorI(DFT(2), 1, AVec, AVec).withTags(t.getTags()) ]],\n apply := (t, C, Nonterms) -> C[1]\n ),\n #F DFT_Base: DFT_2 = F_2 for complex v/2-way vectorization\n #F\n DFT_tSPL_CxVBase := rec(\n switch := false,\n applicable := (t) -> Rows(t) = 2 and t.isTag(1,AVecRegCx),\n apply := (t, C, Nonterms) -> let(\n\t v := t.getTags()[1].v, \n\t Cond(v = 1, VTensor(F(2), 1), \n\t\t # else\n\t\t let(zeros := Replicate(v-2, 0.0), \n\t\t one_one := TVect(TReal, v).value( [1.0, 1.0] :: zeros ), \n\t\t one_mone := TVect(TReal, v).value( [1.0, -1.0] :: zeros ), \n\t\t blk := VBlk([[ one_mone, one_one ]], v),\n\t\t scat := _VVStack([VTensor(I(1), v), VIxJ2(v)], v),\n\t\t IxVScat_pc(1,2,2,0,v) * blk * scat * IxVGath_pc(1,2,2,0,v)))\n )\n ),\n\n #F DFT_Base: DFT_4 for complex v/2-way vectorization\n #F Tensor(F(2),I(4)) * RC(Diag(Tw1(4,2,-1))) * Tensor(I(2), F(2), I(2)) * Tensor(L(4,2),I(2))\n DFT_tSPL_CxVBase2 := rec(\n switch := false,\n applicable := (t) -> t.params[1] = 4 and t.firstTagIs(AVecRegCx) and t.firstTag().v>=4,\n children := nt -> [[TL(4, 2, 1, 1).withTags(nt.getTags()).setWrap(VWrapId)]],\n\n apply := (t, C, Nonterms) -> let(\n\t v := t.firstTag().v,\n vt := TVect(TReal, v),\n\n IxVScat_pc(1,4,4,0,v) * \n VBlk( [[ vt.value([1, 1, -1,-1]), vt.one() ]], v) * \n _VVStack([VTensor(I(1), v), VJxI(2, v)], v) *\n VDiag(Tw1(4,2,t.params[2]), v) * \n VBlk( [[ vt.value([1, -1, 1,-1]), vt.one() ]], v) *\n _VVStack([VTensor(I(1), v), VIxJ2(v)], v) *\n C[1] *\n IxVGath_pc(1,4,4,0,v)\n )\n ),\n #F DFT_tSPL_CT_oddvloop\n #F DFT(mn, k)->Tensor(t2 * RI(m, mu), RI(n,nu)) * (Tensor(RI(mu,m), RI(nu,n)) * Diag(twf) * Tensor(RI(m,mu), RI(n,nu))) * L(mu*nu, mu) * Tensor(RI(nu,n) * t1, RI(mu, m))\n DFT_tSPL_CT_oddvloop := rec(\n switch := false,\n maxSize := false,\n filter := e->true,\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.firstTagIs(AVecReg) or nt.firstTagIs(AVecRegCx)),\n \n children := (self, nt) >> let(\n pv := nt.getTags(),\n v := pv[1].v,\n isa := pv[1].isa,\n _wrp := _nt -> When(Length(pv)=1, _nt.setWrap(VWrap(isa)), _nt.withTags(Drop(pv, 1)).setWrap(VWrap(isa))),\n Map2(Filtered(Filtered(DivisorPairs(nt.params[1]), a->IsOddInt(a[1])), self.filter), \n (m,n) -> [ _wrp(DFT(m, nt.params[2] mod m)), \n _wrp(DFT(n, nt.params[2] mod n)),\n TL(_roundup(n,v).v*v,v).withTags(pv).setWrap(VWrapId)\n ])),\n \n apply := (t, C, Nonterms) -> let(\n \t v := t.firstTag().v,\n lprm := C[3],\n m := Rows(C[1]),\n n := Rows(C[2]),\n N := m * n,\n k := t.params[2],\n dftm := C[1],\n dftn := C[2],\n mu := _roundup(m,v).v,\n md := _rounddown(m,v).v,\n nu := _roundup(n,v).v,\n nd := _rounddown(n,v).v,\n f1 := fCompose(Tw1(N, n, k), fTensor(fId(m), fAdd(n,nd,0))),\n f2 := When(mu = m, \n fCompose(Tw1(N, n, k), fTensor(fId(m), fAdd(n,n-nd,nd))), \n fStretch(fCompose(Tw1(N, n, k), fTensor(fId(m), fAdd(n,n-nd,nd))), v, mu-m)),\n i1 := Ind(md/v),\n i2 := Ind(nd/v),\n #--------------------- \n stage1 := ApplyFunc(SUM, Concat([\n ISum(i1, \n VScat(fTensor(fAdd(mu/v,1,i1), fId(nu)),v) * \n lprm * VScat_zero(nu, n, v) * VTensor(dftn,v) * \n IxVGath_pc(n, m, v, v*i1, v)\n )],\n Cond(IsOddInt(m), \n [VScat(fTensor(fAdd(mu/v,1,md/v), fId(nu)),v) * \n lprm * VScat_zero(nu, n, v) * VTensor(dftn,v) * \n IxVGath_pc(n, m, m-md, md, v)],\n [])\n )\n ),\n #--------------------- \n stage2 := ApplyFunc(SUM, Concat([\n ISum(i2, \n IxVScat_pc(m, n, v, v*i2, v) * \n VTensor(dftm, v) * VDiag(fPrecompute(fCompose(f1, fTensor(fId(m), fBase(i2), fId(v)))), v) * VGath(fAdd(mu, m, 0), v) * \n VGath(fTensor(fId(mu), fAdd(nu/v, 1,i2)),v)\n )],\n Cond(IsOddInt(n),\n [IxVScat_pc(m, n, n-nd, nd, v) * \n VTensor(dftm, v) * VDiag(f2, v) * VGath(fAdd(mu, m, 0), v) * \n VGath(fTensor(fId(mu), fAdd(nu/v, 1,nd/v)),v)],\n [])\n )\n ),\n# #--------------------- \n# stage1 := SUM(\n# ISum(i1, \n# VScat(fTensor(fAdd(mu/v,1,i1), fId(nu)),v) * \n# lprm * VScat_zero(nu, n, v) * VTensor(dftn,v) * \n# IxVGath_pc(n, m, v, v*i1, v)\n# ),\n# VScat(fTensor(fAdd(mu/v,1,md/v), fId(nu)),v) * \n# lprm * VScat_zero(nu, n, v) * VTensor(dftn,v) * \n# IxVGath_pc(n, m, m-md, md, v)\n# ),\n# #--------------------- \n# stage2 := SUM(\n# ISum(i2, \n# IxVScat_pc(m, n, v, v*i2, v) * \n# VTensor(dftm, v) * VDiag(fPrecompute(fCompose(f1, fTensor(fId(m), fBase(i2), fId(v)))), v) * VGath(fAdd(mu, m, 0), v) * \n# VGath(fTensor(fId(mu), fAdd(nu/v, 1,i2)),v)\n# ),\n# IxVScat_pc(m, n, n-nd, nd, v) * \n# VTensor(dftm, v) * VDiag(f2, v) * VGath(fAdd(mu, m, 0), v) * \n# VGath(fTensor(fId(mu), fAdd(nu/v, 1,nd/v)),v)\n# ),\n #--------------------- \n stage2 * stage1\n )\n ),\n\n# #F DFT_tSPL_CT_evenoddvloop\n# #F DFT(mn, k)->Tensor(t2 * RI(m, mu), RI(n,nu)) * (Tensor(RI(mu,m), RI(nu,n)) * Diag(twf) * Tensor(RI(m,mu), RI(n,nu))) * L(mu*nu, mu) * Tensor(RI(nu,n) * t1, RI(mu, m))\n# DFT_tSPL_CT_evenoddvloop := rec(\n# switch := false,\n# maxSize := false,\n# filter := e->true,\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 IsOddInt(nt.params[1]/2)\n# and IsEvenInt(nt.params[1])\n# and (nt.firstTagIs(AVecReg) or nt.firstTagIs(AVecRegCx)),\n# \n# children := (self, nt) >> let(\n# pv := nt.getTags(),\n# v := pv[1].v,\n# isa := pv[1].isa,\n# _wrp := _nt -> When(Length(pv)=1, _nt.setWrap(VWrap(isa)), _nt.withTags(Drop(pv, 1)).setWrap(VWrap(isa))),\n# Map2(Filtered(DivisorPairs(nt.params[1]), self.filter), \n# (m,n) -> [ _wrp(DFT(m, nt.params[2] mod m)), \n# _wrp(DFT(n, nt.params[2] mod n)),\n# TL(_roundup(n,v).v*v,v).withTags(pv).setWrap(VWrapId)\n# ])),\n# \n# apply := (t, C, Nonterms) -> let(\n# \t v := t.firstTag().v,\n# lprm := C[3],\n# m := Rows(C[1]),\n# n := Rows(C[2]),\n# N := m * n,\n# k := t.params[2],\n# dftm := C[1],\n# dftn := C[2],\n# mu := _roundup(m,2).v,\n# md := _rounddown(m,2).v,\n# nu := _roundup(n,2).v,\n# nd := _rounddown(n,2).v,\n# f1 := fCompose(Tw1(N, n, k), fTensor(fId(m), fAdd(n,nd,0))),\n# f2 := fStretch(fCompose(Tw1(N, n, k), fTensor(fId(m), fAdd(n,n-nd,nd))), v, mu-m),\n# i1 := Ind(md/v),\n# i2 := Ind(nd/v),\n# #--------------------- \n# stage1 := ApplyFunc(SUM, Concat([\n# ISum(i1, \n# VScat(fTensor(fAdd(mu/v,1,i1), fId(nu)),v) * \n# lprm * VScat_zero(nu, n, v) * VTensor(dftn,v) * \n# IxVGath_pc(n, m, v, v*i1, v)\n# )],\n# Cond(IsOddInt(m), \n# [VScat(fTensor(fAdd(mu/v,1,md/v), fId(nu)),v) * \n# lprm * VScat_zero(nu, n, v) * VTensor(dftn,v) * \n# IxVGath_pc(n, m, m-md, md, v)],\n# [])\n# )\n# ),\n# #--------------------- \n# stage2 := ApplyFunc(SUM, Concat([\n# ISum(i2, \n# IxVScat_pc(m, n, v, v*i2, v) * \n# VTensor(dftm, v) * VDiag(fPrecompute(fCompose(f1, fTensor(fId(m), fBase(i2), fId(v)))), v) * VGath(fAdd(mu, m, 0), v) * \n# VGath(fTensor(fId(mu), fAdd(nu/v, 1,i2)),v)\n# )],\n# Cond(IsOddInt(n),\n# [IxVScat_pc(m, n, n-nd, nd, v) * \n# VTensor(dftm, v) * VDiag(f2, v) * VGath(fAdd(mu, m, 0), v) * \n# VGath(fTensor(fId(mu), fAdd(nu/v, 1,nd/v)),v)],\n# [])\n# )\n# ),\n# #--------------------- \n# stage2 * stage1\n# )\n# )\n));\n", "meta": {"hexsha": "0cb6bf76207028c8d36617873557ac38d2a81117", "size": 9646, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/vector/breakdown/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/paradigms/vector/breakdown/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/paradigms/vector/breakdown/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": 43.2556053812, "max_line_length": 174, "alphanum_fraction": 0.4043126685, "num_tokens": 3242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.46101677931231594, "lm_q1q2_score": 0.369132448027407}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nRulesFor(DFT, rec(\n DFT_SR_Reg := rec(\n\tisApplicable := P -> P[1] mod 2 = 0 and P[1] > 4,\n\n\tallChildren := P -> let(k:=P[2], \n\t Map2(Filtered(DivisorPairs(P[1]), dd->dd[2]>2 and (dd[2] mod 2 = 0)),\n\t (m,n) -> [DFT(m,k), DFT(2*m,k), UDFT(n,k)])), \n\n\trule := (P,C) -> let( # we know that n >= 4\n\t N := P[1], m:=Cols(C[1]), n:=Cols(C[3]), k:=P[2], hf:=(n-2)/2,\n\t i := Ind(hf), j := Ind(hf), \n\n\t SUM( _hhi(N, 2*m, 0, n/2, C[2] * L(2*m,2)),\n\t\tISum(i, _hhi(N, m, i+1, n, C[1] * Diag(Twid(N,m,k,0,0,i+1)))),\n\t\tISum(j, _hhi(N, m, j+2+hf, n, C[1] * Diag(Twid(N,m,k,0,0,j+2+hf))))\n\t ), \n\t Tensor(I(m), C[3]) * \n\t L(N,m)\n\t)\n ),\n\n DFT_SR_Reg2 := rec(\n\tisApplicable := P -> P[1] mod 4 = 0 and P[1] > 4,\n\n\tallChildren := P -> let(k:=P[2], \n\t Map2(Filtered(DivisorPairs(P[1]), dd->dd[1]>2 and dd[2]>2 and (dd[1] mod 2 = 0) and (dd[2] mod 2 = 0)),\n\t (m,n) -> [UDFT(m,k).transpose(), UUDFT(2*m,k).transpose(), \n\t\t UDFT(n,k), UUDFT(2*n, k)])), \n\n\trule := (P,C) -> let( # we know that n >= 4\n\t N := P[1], m:=Cols(C[1]), n:=Cols(C[3]), k:=P[2], nhf:=(n-2)/2, mhf:=(m-2)/2,\n\t i := Ind(nhf), j := Ind(nhf), ii := Ind(mhf), jj := Ind(mhf), \n\t q := Ind(2*n),\n\t dd := Diag(Lambda(q, cond(eq(q,3*n/2), (-E(4))^k, 1))), \n\n\t SUM( _hhi(N, 2*m, 0, n/2, C[2] * L(2*m,2)),\n\t\tISum(i, _hhi(N, m, i+1, n, C[1] * Diag(UTwid(N,m,k,0,0,i+1)))),\n\t\tISum(j, _hhi(N, m, j+2+nhf, n, C[1] * Diag(UTwid(N,m,k,0,0,j+2+nhf))))\n\t ) * \n\t SUM(Scat(fStack(H(N,n,0,1), H(N,n,N/2,1))) * dd * C[4] * Gath(H(N, 2*n, 0, m/2)), \n\t\tISum(ii, _hho(N, n, n+ii*n, 1, ii+1, m, C[3])),\n\t\tISum(jj, _hho(N, n, 2*n+mhf*n+jj*n, 1, jj+mhf+2, m, C[3]))\n\t )\n\t)\n ),\n\n DFT_SR123_Corr := rec(\n\tisApplicable := P -> P[1] mod 4 = 0,\n\tallChildren := P -> let(k:=P[2], \n\t Map2(Filtered(DivisorPairs(P[1]), dd -> (dd[1] mod 2=0) and (dd[2] mod 2 = 0)),\n\t (m,n) -> [DFT(m,k), DFT3(m,k), DFT(n,k), DFT2(n, k)])), \n\n\trule := function(P,C)\n\t local N,m,n,k,nhf,mhf, i,j,ii,jj,q,dd,isum, tw1a, tw1b, tw2a, tw2b;\n\n\t N := P[1]; m:=Cols(C[1]); n:=Cols(C[3]); k:=P[2]; nhf:=(n-2)/2; mhf:=(m-2)/2;\n\t i := Ind(nhf); j := Ind(nhf); ii := Ind(mhf); jj := Ind(mhf); \n\t q := Ind(n);\n\t dd := Diag(Lambda(q, cond(eq(q,n/2), (-E(4))^k, 1)));\n\t isum := (var, expr) -> When(var.range=0, [], ISum(var, expr));\n\t\n\t return\n\t SUM( _hhi(N, m, 0, n, C[1]),\n\t\tisum(i, _hhi(N, m, i+1, n, C[1] * Diag(fPrecompute(UTwid(N,m,k,0,0,i+1))))),\n\t\t _hhi(N, m, nhf+1, n, C[2]),\n\t\tisum(j, _hhi(N, m, j+nhf+2, n, C[1] * Diag(fPrecompute(UTwid(N,m,k,0,0,j+2+nhf)))))\n\t ) * \n\t SUM( _hho(N, n, 0, 1, 0, m, C[3]),\n\t\tisum(ii, _hho(N, n, n+ii*n, 1, ii+1, m, C[3])),\n\t\t _hho(N, n, n+mhf*n, 1, mhf+1, m, dd*C[4]), \n\t\tisum(jj, _hho(N, n, 2*n+mhf*n+jj*n, 1, jj+mhf+2, m, C[3]))\n\t );\n\tend\n ),\n\n DFT_SR123 := rec(\n\tisApplicable := P -> P[1] mod 4 = 0,\n\tmaxRadix := 4,\n\tallChildren := (self, P) >> let(k:=P[2], \n\t Map2(Filtered(DivisorPairs(P[1]), dd -> (dd[1] mod 2=0 and dd[1]<=self.maxRadix) and (dd[2] mod 2 = 0)),\n\t (m,n) -> [DFT(m,k), DFT3(m,k), DFT(n,k), DFT2(n, k)])), \n\n\tinplace := Inplace, \n\trule := meth(self,P,C)\n\t local N,m,n,k,nhf,mhf, i,j,ii,jj,q,dd,isum, tw1a, tw1b, tw2a, tw2b, d1;\n\n\t N := P[1]; m:=Cols(C[1]); n:=Cols(C[3]); k:=P[2]; nhf:=(n-2)/2; mhf:=(m-2)/2;\n\t i := Ind(nhf); j := Ind(nhf); ii := Ind(mhf); jj := Ind(mhf); \n\t q := Ind(n);\n\t dd := Diag(Lambda(q, cond(eq(q,n/2), (-E(4))^k, 1))); \n\t isum := (var, expr) -> When(var.range=0, [], ISum(var, expr));\n\t\n\t tw1a := fPrecompute(fCompose(dOmega(N,k), dLin(mhf, i+1, i+1, TInt)));\n\t tw1b := fPrecompute(fCompose(dOmega(N,k), dLin(mhf, i+1, (i+1)*(mhf+2), TInt)));\n\n\t tw2a := fPrecompute(fCompose(dOmega(N,k), dLin(mhf, j+2+nhf, j+2+nhf, TInt)));\n\t tw2b := fPrecompute(fCompose(dOmega(N,k), dLin(mhf, j+2+nhf, (j+2+nhf)*(mhf+2), TInt)));\n\t \n\t d1 := fConst(1, 1.0);\n\n\t return\n\t self.inplace(\n\t SUM( _hhi(N, m, 0, n, C[1]),\n\t\tisum(i, _hhi(N, m, i+1, n, C[1] * When(tw1a.domain()=0, I(2), Diag(diagDirsum(d1, tw1a, d1, tw1b))))),\n\t\t _hhi(N, m, nhf+1, n, C[2]),\n\t\tisum(j, _hhi(N, m, j+nhf+2, n, C[1] * When(tw2a.domain()=0, I(2), Diag(diagDirsum(d1, tw2a, d1, tw2b)))))\n\t )) * \n\t SUM( _hho(N, n, 0, 1, 0, m, C[3]),\n\t\tisum(ii, _hho(N, n, n+ii*n, 1, ii+1, m, C[3])),\n\t\t _hho(N, n, n+mhf*n, 1, mhf+1, m, C[4]), #dd * C[4]),\n\t\tisum(jj, _hho(N, n, 2*n+mhf*n+jj*n, 1, jj+mhf+2, m, C[3]))\n\t );\n\tend\n )\n));\n\n RulesFor(DFT3, rec(\n DFT3_CT_Twids := Inherit(DFT_CT, rec(\n \tswitch := false,\n\tmaxRadix := 4,\n \tallChildren := (self, P) >> Map2(Filtered(DivisorPairs(P[1]), dd->dd[1] <= self.maxRadix), \n \t (m,n) -> [ DFT(m, P[2]), DFT3(n, P[2]) ]),\n \n\tinplace := Inplace,\n \trule := meth(self, P,C) \n\t local N, m, n, k, i, tw;\n\t N := P[1]; \n\t m := Cols(C[1]); n := Cols(C[2]); k := P[2]; \n\t i := Ind(n);\n\t tw := fPrecompute(fCompose(dOmega(2*N,k), dLin(m-1, 2*i+1, 2*i+1, TInt)));\n\n\t return self.inplace(ISum(i, _hhi(N, m, i, n, C[1] * Diag(diagDirsum(fConst(1,1.0), tw))))) *\n \t Tensor(I(m), C[2]) * \n\t\t L(N, m);\n \tend\n )),\n\n DFT3_SR34_Corr := rec(\n\tisApplicable := P -> P[1] mod 4 = 0,\n\tallChildren := P -> let(k:=P[2], \n\t Map2(Filtered(DivisorPairs(P[1]), dd -> (dd[1] mod 2=0) and (dd[2] mod 2 = 0)),\n\t (m,n) -> [DFT(m,k), DFT3(n,k), DFT4(n, k)])), \n\n\trule := function(P,C)\n\t local N,m,n,k,nhf,mhf, i,j,ii,jj,q,dd,isum, tw1a, tw1b, tw2a, tw2b;\n\n\t N := P[1]; m:=Cols(C[1]); n:=Cols(C[3]); k:=P[2]; nhf:=(n-2)/2; mhf:=(m-2)/2;\n\t i := Ind(n); ii := Ind(mhf); jj := Ind(mhf); \n\t isum := (var, expr) -> When(var.range=0, [], ISum(var, expr));\n\t\n\t return\n isum(i, _hhi(N, m, i, n, C[1] * Diag(fPrecompute(UTwid1(N,m,k,1/2,0,i))))) * \n\t SUM( _hho(N, n, 0, 1, 0, m, C[2]),\n\t\tisum(ii, _hho(N, n, n+ii*n, 1, ii+1, m, C[2])),\n\t\t _hho(N, n, n+mhf*n, 1, mhf+1, m, C[3]), \n\t\tisum(jj, _hho(N, n, 2*n+mhf*n+jj*n, 1, jj+mhf+2, m, C[2]))\n\t );\n\tend\n ),\n\n ));\n\nRulesFor(UUDFT, rec(\n UUDFT1_Base4 := BaseRule(UUDFT1, [4, @])\n));\n\nRulesFor(UDFT1, rec(\n UDFT1_Base2 := rec(\n isApplicable := P -> P[1] = 2,\n rule := (P, C) -> I(2)\n ),\n\n UDFT1_Base4 := rec(\n isApplicable := P -> P[1] = 4,\n rule := (P, C) -> \n DirectSum(I(2), F(2))^L(4,2) *\n\t Diag(Tw1(4, 2, 1)) * \n\t Tensor(I(2), F(2)) * \n\t L(4, 2)\n ),\n\n UDFT1_toDFT := rec(\n isApplicable := P -> P[1] > 4,\n allChildren := P -> [[ DFT(P[1], P[2]) ]],\n rule := (P, C) -> \n DirectSum((1/2)*F(2), I(P[1]-2))^L(P[1],P[1]/2) * C[1]\n ),\n\n UDFT1_SR_Reg := rec(\n\tisApplicable := P -> Is2Power(P[1]) and P[1] > 4,\n\n\tallChildren := P -> let(k:=P[2], Map2(Filtered(DivisorPairs(P[1]), dd->dd[2]>2),\n\t (m,n) -> [DFT(m,k), UDFT(2*m,k), UDFT(n,k)])),\n\n\tforTransposition := false,\n\n\trule := (P,C) -> let( # we know that n >= 4\n\t N := P[1], m:=Cols(C[1]), n:=Cols(C[3]), k:=P[2], j := Ind((n-2)/2), jj := Ind((n-2)/2), \n\t SUM(\n\t\tScat(H(N,2*m,0,n/2)) * C[2] * L(2*m,2) * Gath(H(N,2*m,0,n/2)),\n\t\tISum(j, \n\t\t Scat(H(N,m,j+1,n)) *\n\t\t C[1] * Diag(Twid(N,m,k,0,0,j+1)) *\n\t\t Gath(H(N, m,j+1,n))),\n\t\tISum(jj, \n\t\t Scat(H(N,m,jj+2+(n-2)/2,n)) *\n\t\t C[1] * Diag(Twid(N,m,k,0,0,jj+2+(n-2)/2)) *\n\t\t Gath(H(N, m,jj+2+(n-2)/2,n)))\n\n\t ) * \n\t Tensor(I(m), C[3]) * L(N,m))\n )\n));\n\n#Unbind(UDFT.transpose);\n#SwitchRules(DFT, [1,3,18]);\n#DFT_CT.isApplicable := P -> P[1]=4;\n", "meta": {"hexsha": "1a0d3a866b15d7441d30868956c2a70ba57ed4a3", "size": 7912, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/transforms/dft/dft_srreg.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/transforms/dft/dft_srreg.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/transforms/dft/dft_srreg.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.4798206278, "max_line_length": 113, "alphanum_fraction": 0.4480535895, "num_tokens": 3639, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.4960938294709195, "lm_q1q2_score": 0.36868106333284306}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n_symGreater1 := o -> IsSymbolic(o) or o > 1;\n\nClass(RulesRankedIndf, RuleSet);\nRewriteRules(RulesRankedIndf, rec(\n fCompose_flatten := ARule(fCompose, [@(1,fCompose)], e->@(1).val.children()),\n\n # Degenerate HH rules (HH -> fAdd)\n #HH_to_fAdd := Rule([HH, @, @, @(1).cond(e->e[1]=1 and Sum(e)=1)], e -> fAdd(e.N, e.n, 0)),\n \n fAddElim := ARule(fCompose, \n [@(1), @(2, fAdd, e -> e.params[3] = 0 and range(e) = range(@(1).val) and domain(e)=domain(@(1).val))], \n e -> [ @(1).val ]),\n\n HHZ_fAdd := ARule(fCompose, [@(1, HHZ), @(2, [fAdd])], e -> When(@(2).val.params[3]=0, [ @(1).val ],\n\t[ HHZ(@(1).val.params[1], @(2).val.params[2], @(1).val.params[3] + @(2).val.params[3] * @(1).val.params[4][1], @(1).val.params[4])])),\n\n HH_fAdd := ARule(fCompose, [@(1, HH), @(2, fAdd)], e -> \n\t[ HH(@(1).val.params[1], @(2).val.params[2], @(1).val.params[3] + @(2).val.params[3] * @(1).val.params[4][1],\n\t @(1).val.params[4]) ]),\n\n fAdd_HH := ARule(fCompose, [@(2, fAdd), @(1, HH)], e -> \n\t[ HH(range(@(2).val), domain(@(1).val), @(1).val.params[3] + @(2).val.params[3], @(1).val.params[4]) ]),\n\n # Maude: \n # var b1 b2 m n MM NN : NatExp . var d : Diagf . var i : Indf . \n # var w ww : NatExpList . var v vv : NeNatExpList . vars gg gf : Genf .\n # eq H ( b1, n w) o H ( b2, m ww) = H ( b1 + n * b2, (n * m) (w + lmul(n, ww))) .\n # eq HZ(NN, b1, n w) o H ( b2, m ww) = HZ(NN, b1 + n * b2, (n * m) (w + lmul(n, ww))) .\n # eq HZ(NN, b1, n w) o HZ(MM, b2, m ww) = HZ(NN, b1 + n * b2, (n * m) (w + lmul(n, ww))) .\n #\n HHoHH := ARule(fCompose, [@(1, HH), @(2, HH)], e -> [ let(\n s1 := @(1).val.params[4], s2 := @(2).val.params[4],\n b1 := @(1).val.params[3], b2 := @(2).val.params[3], \n n := s1[1], m := s2[1], w := Drop(s1, 1), ww := List(Drop(s2, 1), x -> n*x), \n HH(@(1).val.params[1], @(2).val.params[2], b1 + n*b2, Concatenation([n*m], ListAddZP(w, ww)))) ]),\n\n # This rule is invalid when HH stride is odd, so in general it should not be used\n # NOTE: this rule is needed for DCTs, it seems that in that case stride is always even, so its ok to use it\n # how to guard this for libraries??\n BHHoHH := ARule(fCompose, [@(1, BHH), @(2, HH, e->_symGreater1(e.params[4][1]))], e -> [ let(\n s1 := @(1).val.params[4], s2 := @(2).val.params[4],\n b1 := @(1).val.params[3], b2 := @(2).val.params[3], \n n := s1[1], m := s2[1], w := Drop(s1, 1), ww := List(Drop(s2, 1), x -> n*x), \n BHH(@(1).val.params[1], @(2).val.params[2], b1 + n*b2, Concatenation([n*m], ListAddZP(w, ww)),\n @(1).val.params[5])) ]),\n\n #BHH_pull_out_base := Rule([BHH, @, @, @.cond(e->e<>0), @, @], e -> \n # fCompose(HH(e.params[1], e.params[1], e.params[3], [1]), BHH(e.params[1], e.params[2], 0, e.params[4], e.params[5]-2*e.params[3]))),\n \n HH_1_ftensor_pull_out := Rule([fTensor, [@(1,fCompose), [@(2,HH), @, @, @, [ListClass, _1]], ...], @(3, fId)], e->\n let(h := @(2).val, id := @(3).val.params[1], \n fCompose(HH(id*h.params[1], id*h.params[2], id*h.params[3], [1]), \n fTensor(fCompose(Drop(@(1).val.rChildren(), 1)), @(3).val)))),\n \n # HHxI2_base_pull_out is for closure reduction in autolib RDFT.\n # Commented out to get smaller closure in DFT and it conflicts with HHxfId_base_pull_in rule below\n #HHxI2_base_pull_out := Rule([fTensor, [@(2,HH), @, @, @.cond(e->e<>0), @], @(3, fId)], e->\n # let(hp := @(2).val.params, id := @(3).val.params[1], \n # fCompose(HH(id*hp[1], id*hp[1], id*hp[3], [1]), \n # fTensor(HH(hp[1], hp[2], 0, hp[4]), @(3).val)))),\n\n # Pull in HH into fTensor. \n #\n HHxfId_base_pull_in := ARule(fCompose, [[HH, @(1), @(2), @(3), [ListClass, _1]], \n [fTensor, [@(4,HH), @, @, @, @], @(5, fId, x -> ForAll([@(1).val, @(2).val, @(3).val], e -> _divides(x.params[1], e)))]], \n e -> let( t := @(5).val.params[1], hh := @(4).val.params,\n [fTensor( HH( div(@(1).val, t), hh[2], hh[3] + div(@(3).val, t), hh[4] ), @(5).val )])), \n\n HHoBHH := ARule(fCompose, [@(1, HH, e->e.params[3]=0 and _symGreater1(e.params[4][1])), @(2, BHH)], e -> [ let(\n s1 := @(1).val.params[4], s2 := @(2).val.params[4],\n b1 := @(1).val.params[3], b2 := @(2).val.params[3], \n n := s1[1], m := s2[1], w := Drop(s1, 1), ww := List(Drop(s2, 1), x -> n*x), \n BHH(@(1).val.params[1], @(2).val.params[2], b1 + n*b2, Concatenation([n*m], ListAddZP(w, ww)),\n n*@(2).val.params[5])) ]),\n\n HHZoHH := ARule(fCompose, [@(1, HHZ), @(2, HH)], e -> [ let(\n\t s1 := @(1).val.params[4],\n\t s2 := @(2).val.params[4],\n\t b := @(1).val.params[3], bb := @(2).val.params[3], \n\t n := s1[1], m := s2[1], w := Drop(s1, 1), ww := List(Drop(s2, 1), x->n*x), \n\t HHZ(@(1).val.params[1], @(2).val.params[2], b + n*bb, Concatenation([n*m], ListAddZP(w, ww)))) ]),\n\n HHZoHHZ := ARule(fCompose, [@(1, HHZ), @(2, HHZ)], e -> [ let(\n\t s1 := @(1).val.params[4],\n\t s2 := @(2).val.params[4],\n\t b := @(1).val.params[3], bb := @(2).val.params[3], \n\t n := s1[1], m := s2[1], w := Drop(s1, 1), ww := List(Drop(s2, 1), x->n*x), \n\t HHZ(@(1).val.params[1], @(2).val.params[2], b + n*bb, Concatenation([n*m], ListAddZP(w, ww)))) ]),\n\n KHoKH := ARule(fCompose, [@(1, KH), \n [@(2, KH), @, @, _0, [ListClass, @, _1], [ListClass, _0, _0]]], \n e -> [ let(\n\t s1 := @(1).val.params[4],\n\t s2 := @(2).val.params[4],\n corr := @(1).val.params[5],\n\t b := @(1).val.params[3], bb := @(2).val.params[3], \n\t n := s1[1], m := s2[1], w := Drop(s1, 1), ww := List(Drop(s2, 1), x->n*x), \n\t KH(@(1).val.params[1], @(2).val.params[2], b, \n Concatenation([n*m], ListAddZP(w, ww)), corr)) ]),\n\n # HHxIoHH assumes @(3) cannot be pulled into fTensor\n HHxIoHH := ARule(fCompose, [[fTensor, [@(1, HH), @, @, @, [ListClass, _1]], @(2, fId)], @(3, HH)],\n e -> let( p := @(1).val.params, n := @(2).val.params[1],\n [ HH(n*p[1], n*p[2], n*p[3], [1]), @(3).val ] )),\n \n # eq tr(n, m) o H(0, 1 n) = H(0, m 1) .\n # H.domain must be less or equal to n\n TroHH := ARule(fCompose, \n [@(1, Tr), @(2, HH, e -> let(n := @(1).val.params[1], Cond(AnySyms(n, e.params[2]), n=e.params[2], n>=e.params[2]) and e.params[4][1]=1 and ForAll([e.params[3]]::Drop(e.params[4],1), x -> _divides(n, x))))], \n e -> [ let(\n\t n := @(1).val.params[1], m := @(1).val.params[2], b := @(2).val.params[3], str := Drop(@(2).val.params[4], 1),\n\t HH(@(2).val.params[1], @(2).val.params[2], b/n, [m] :: List(str, x -> x/n))) ]),\n\n Refl0_u_HH0 := ARule(fCompose, [@(1, Refl0_u), @(2, HH, e -> e.params[3]=0 and e.params[4]=[1])], e -> [ let(\n\t k := @(1).val.params[1],\n\t HH(@(1).val.range(), @(2).val.domain(), 0, [k])) ]),\n\n Refl0_u_HHrest := ARule(fCompose, [@(1, Refl0_u), @(2, HH, e -> e.params[3]=e.params[2] and e.params[4]=[1, @(1).val.params[2]])], e -> [ let(\n\t k := @(1).val.params[1],\n\t BHH(@(1).val.range(), @(2).val.domain(), 1, [2*k,1], 2*@(1).val.range())) ]),\n\n Refl0_odd_HH0 := ARule(fCompose, [@(1, Refl0_odd), @(2, HH, e -> e.params[3]=0 and e.params[4]=[1])], e -> [ let(\n\t k := @(1).val.params[1],\n\t HH(@(1).val.range(), @(2).val.domain(), 0, [2*k+1])) ]),\n\n Refl0_odd_HHrest := ARule(fCompose, [@(1, Refl0_odd), @(2, HH, e -> e.params[4]=[1, @(1).val.params[2]])], e -> [ let(\n\t k := @(1).val.params[1],\n\t BHH(@(1).val.range(), @(2).val.domain(), 1, [2*k+1,1], 2*@(1).val.range())) ]),\n\n\n Refl1_HH := ARule(fCompose, [@(1, Refl1), @(2, HH, e -> e.params[3]=0 and e.params[4]=[1, @(1).val.params[2]])], e -> [ let(\n\t k := @(1).val.params[1],\n\t BHH(@(1).val.range(), @(2).val.domain(), 0, [2*k,1], 2*@(1).val.range() - 1)) ]),\n\n MMoHH := ARule(fCompose, [@(1, MM), @(2, HH, e -> e.params[3]=0 and e.params[4]=[1, @(1).val.params[1]])], e -> [ let(\n\t m := @(1).val.params[2],\n\t KH(@(2).val.params[1], @(2).val.params[2], 0, [m, 1], [0,0])) ]),\n\n fTensor_AxI_HH_stride_1 := ARule(fCompose, [[@(1, fTensor), ..., [fId, @(2)]], # NOTE: assumes d | base\n [@(3,HH), @, \n @.cond(e->_dividesUnsafe(@(2).val,e)), \n @.cond(e->_dividesUnsafe(@(2).val,e)), \n [ListClass, _1, ...]]], e ->\n let(p := @(3).val.params, d := @(2).val, vs := Drop(p[4],1), base := p[3],\n [ fTensor( fCompose( fTensor(DropLast(@(1).val.children(), 1)), HH(div(p[1],d), div(p[2],d), div(base,d), \n Concatenation([1], List(vs, v -> div(v,d))))), fId(d))])),\n\n fTensor_AxI_HH_stride_n := ARule(fCompose, # NOTE: check assumptions\n [[@(1,fTensor), ..., [fId, @(2)]], \n [@(3,HH), @, @, _0, [ListClass, @.cond(e->e=@(2).val), _0, _1]]], \n\n e -> let(\n\t d := @(2).val,\n\t p := @(3).val.params,\n\t ch := @(1).val.children(),\n\t A := fTensor(DropLast(ch, 1)),\n [ fCompose(HH(range(A)*d, range(A), 0, [d, 0, 1]), A) ])\n ), \n\n\n fTensor_HH_domain1_fId := ARule(fTensor, [ [@(1, HH), @, _1, @, @], @(2, fId) ], \n e -> let(\n\t p := @(1).val.params,\n\t n := @(2).val.params[1],\n\t [ HH(n*p[1], n, n*p[3], [1] :: List(Drop(p[4], 1), x->n*x)) ])\n ),\n\n HH_domain1_s1_to_fId1 := Rule( [HH, _1, _1, _0, [ListClass, _1]], e -> fId(1) ),\n\n fTensor_fId_X_HH := ARule(fCompose, [[@(4,fTensor), @(1, fId), @(2)], \n [@(3,HH), @, @.cond(e->e=@(2).val.domain()), _0, [ListClass, _1, @.cond(e->e=@(2).val.domain())]]], \n e ->let(p := @(3).val.params, vs := p[4][2],\n [ HH(@(4).val.range(), @(2).val.domain(), 0, [1, vs]), @(2).val ])),\n\n # This rule is a hack because it changing advdims of SPL. Range of the outer loop is also\n # assumed to be less than @(5).val (though if it's not then there is overlap in the\n # inner loop. \n f2DTensor_HH_HH_HH :=ARule( fCompose, [\n [f2DTensor, [HH, @(1), @(2), @(3), [ListClass, _1]],\n [HH, @(4), @(5), @(6), [ListClass, _1]]],\n [HH, @(7).cond(x->x=@(2).val*@(5).val or x=@(5).val*@(2).val), \n @(8).cond(x->x=@(2).val), \n _0, \n [ListClass, @(9).cond(x->x=@(5).val), _1]]],\n e -> [HH( @(1).val*@(4).val, @(2).val, @(6).val+@(4).val*@(3).val, [@(4).val, 1] )]),\n \n # simplified merge_tensors rule\n fTensor_fTensor := ARule(fCompose, \n [[fTensor, @(1), @(2)], [fTensor, @(3), @(4).cond(\n e->e.range()=@(2).val.domain() or @(3).val.range() = @(1).val.domain())]],\n e -> [ fTensor(fCompose(@(1).val, @(3).val), fCompose(@(2).val, @(4).val)) ]),\n\n # eq crt(n, m) o H(0, 1 m) = HZ(m * n, 0, m n) .\n # eq crt(n, m) o H(0, m 1) = HZ(m * n, 0, n m) .\n CRToHH := ARule(fCompose, [ [CRT, @(1), @(2), 1, 1], \n\t @(3,HH,e -> e.params[3]=0 and e.params[4] in [[1,@(2).val], [@(2).val, 1]]) ], e -> [ let(\n\t\tn := @(1).val,\n m := @(2).val,\n\t\ts1 := @(3).val.params[4][1],\n\t\tHHZ(@(3).val.params[1], @(3).val.params[2], 0, When(s1=1, [m, n], [n,m]))) ]),\n\n ## Scat * ISumn, ISumn * Gath\n Scat_ISumn := ARule(Compose, [ @(1, Scat), @(2, ISumn) ],\n e -> [ ISumn(@(2).val.domain, \n\t Scat(@(1).val.func.upRank()) * @(2).val.child(1)) ]),\n\n ISumn_Gath := ARule(Compose, [ @(1, ISumn), @(2, Gath) ],\n e -> [ ISumn(@(1).val.domain, \n\t @(1).val.child(1) * Gath(@(2).val.func.upRank())) ]),\n\n ## Prm * ISumn, ISumn * Prm\n Prm_ISumn := ARule(Compose, [ @(1, Prm), @(2, ISumn) ],\n e -> [ ISumn(@(2).val.domain, \n\t Prm(@(1).val.func.upRank()) * @(2).val.child(1)) ]),\n\n ISumn_Prm := ARule(Compose, [ @(1, ISumn), @(2, Prm) ],\n e -> [ ISumn(@(1).val.domain, \n\t @(1).val.child(1) * Prm(@(2).val.func.upRank())) ]),\n\n ## Diag * ISumn, ISumn * Diag\n Diag_ISumn := ARule(Compose, [ @(1, Diag), @(2, ISumn) ],\n e -> [ ISumn(@(2).val.domain, \n\t Diag(@(1).val.element.upRank()) * @(2).val.child(1)) ]),\n\n ISumn_Diag := ARule(Compose, [ @(1, ISumn), @(2, Diag) ],\n e -> [ ISumn(@(1).val.domain, \n\t @(1).val.child(1) * Diag(@(2).val.element.upRank())) ]),\n\n ##UU \n #Implementing non-zero base would probably require to have a 2D base\n #Implicit requirements 2 has base=0 and both leading dims are the same.\n UU_UU := ARule(fCompose, [@(1, UU), @(2, UU)],\n e-> let(b1X := @(1).val.params[3], b2X := @(2).val.params[3], b1Y := @(1).val.params[4], b2Y := @(2).val.params[4], s1 := @(1).val.params[5], s2 := @(2).val.params[5],\n c2 := @(2).val.params[6], ld := @(1).val.params[7], ss1 := @(1).val.params[8], \n ss2 := @(2).val.params[8], ss:=ListAddLP(When(Length(ss2)>0,Transposed([List(Transposed(ss2)[1],x->x*s1)\n ,Transposed(ss2)[2]]),[]), ss1),\n [UU(@(1).val.params[1], @(2).val.params[2], b1X + s1*b2X, b1Y+b2Y, s1*s2, c2, ld, ss)])),\n\n# UU_H := ARule(fCompose, [@(1, UU), @(2, H)],\n# e-> let(b1X := @(1).val.params[3], b2X := @(2).val.params[3], b1Y := @(1).val.params[4], s1 := @(1).val.params[5], s2 := @(2).val.params[4],\n# ld := @(1).val.params[7], ss1 := @(1).val.params[8], c1 := @(1).val.params[6], \n# [UU(@(1).val.params[1], @(2).val.params[2], b1X + s1*b2X, b1Y, s1*s2, c1, ld, ss1)])),\n\n\n\n));\n", "meta": {"hexsha": "873edcf4ff637b7d608e3234fd05f3665dba7864", "size": 13619, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/spl/gtrules.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/gtrules.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/gtrules.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": 54.0436507937, "max_line_length": 215, "alphanum_fraction": 0.466480652, "num_tokens": 5312, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984445, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.3654508037693126}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\nNewRulesFor(DFT, rec(\n\tDFT_tSPL_CT_Mem := rec(\n\t\tswitch := true,\n\n\t\tapplicable := (self, nt) >> nt.params[1] > 2\n\t\t\tand not IsPrime(nt.params[1])\n\t\t\tand nt.hasTag(AMem),\n\n\t\tchildren := nt -> let(\n\t\t\tmemtag := nt.getTag(AMem),\n\t\t\tMap2(\n\t\t\t\tFiltered(DivisorPairs(nt.params[1]), (m,n) -> n mod memtag.block = 0),\n\t\t\t\t(m,n) -> [\n\t\t\t\t\tTCompose([\n\t\t\t\t\t\tTGrp(TCompose([\n\t\t\t\t\t\t\tTTensorI(DFT(m, nt.params[2] mod n), n, AVec, AVec),\n\t\t\t\t\t\t\tTDiag(fPrecompute(Tw1(m*n, n, nt.params[2])))\n\t\t\t\t\t\t])),\n\t\t\t\t\t\tTGrp(TTensorI(DFT(n, nt.params[2] mod n), m, APar, AVec))\n\t\t\t\t\t]).withTags(nt.getTags())\n\t\t\t\t]\n\t\t\t)\n\t\t),\n\n\t\tapply := (nt, c, cnt) -> c[1]\n\t)\n));\n", "meta": {"hexsha": "f73e9334384b1a9a7ac42792885987c9d6a380dd", "size": 720, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/cache/breakdown/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/paradigms/cache/breakdown/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/paradigms/cache/breakdown/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": 22.5, "max_line_length": 74, "alphanum_fraction": 0.5652777778, "num_tokens": 261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.4882833952958347, "lm_q1q2_score": 0.3643272753669266}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# ================================================================\n# Integer Strength Reduction Rules\n# ================================================================\n\nClass(RulesStrengthReduce, RuleSet);\n\n#F SReduceSimple(<c>) -- applies strength reduction rules to any object <c>\n#F disables <opts> sensitive rules\nSReduceSimple := c -> ApplyStrategy(c, [RulesStrengthReduce], BUA, rec());\n\n#F SReduce(<c>, <opts>) - applies strength reduction rules to any object <c>\n#F\nSReduce := (c,opts) -> ApplyStrategy(c, [RulesStrengthReduce], BUA, opts);\n\n#@1:=@(1);\n#@2:=@(2);\n\n@1int := @(1).cond(e -> IsValue(e) and IsInt(e.v));\n@2int := @(2).cond(e -> IsValue(e) and IsInt(e.v));\n@2ge_var := than@ -> @(2).cond(\n e -> IsValue(e) and IsBound(than@.val.range) and than@.val.range <= e.v);\n\nisNegV := o -> o.v<0;\nisNonZero := o -> o <> 0;\n\n@negVal := @.target(Value).cond(isNegV);\n\n@2Teq1 := @(2).cond( x -> x.t = @(1).val.t );\n\n_0noneOrZero := (t) -> When(ObjId(@(0).val)=noneExp, noneExp(t), t.zero());\n_sameTasOp := (opname, func) -> @@(0, [Value, noneExp]).cond((e, cx) -> \n let( op := Last(cx.(opname)), \n func(e) and ForAny(op.args, (a) -> not Same(a, e) and a.t=op.t)\n )\n);\n\nv0:=V(0);\nv1:=V(1);\n\n@vpos := (n) -> @(n, Value, e -> IsPosInt(e.v));\n@vpos0 := (n) -> @(n, Value, e -> IsPosInt0(e.v));\n\nRewriteRules(RulesStrengthReduce, rec(\n\n # FF: SAR-specific rule. Not sure if they should be turned on by default.\n # YSV: below rule is invalid, because idiv(a+b, c) <> idiv(a) + idiv(b)\n # example: idiv(2+3, 4) == 1 \n # idiv(2,4) + idiv(3,4) == 0\n # div_sar := Rule([@(1,idiv), @(2, add), @(3,Value) ], e -> ApplyFunc(add, List(@(2).val.args, i->idiv(i, @(3).val)))),\n\n ################\n # leq \n # ===========\n leq_single := Rule([leq, @(1)], e-> V_true),\n leq_eq := Rule([leq, @(1), @(2), @(3).cond(e->e=@(1).val)], e -> eq(@(1).val, @(2).val)),\n\n leq_val_mulindex := Rule( [leq, @vpos0(1), [mul, @vpos0(2), @(3, [var, param], IsLoopIndex)]],\n e -> leq(idiv(@(1).val + @(2).val - 1, @(2).val), @(3).val)),\n \n leq_val_mulindex_val := Rule( [leq, @vpos0(1), [mul, @vpos(2), @(3, [var, param], IsLoopIndex)], @vpos0(4)],\n e -> leq(idiv(@(1).val + @(2).val - 1, @(2).val), @(3).val, idiv(@(4).val, @(2).val))),\n \n leq_mulindex_val := Rule( [leq, [mul, @vpos0(2), @(3, [var, param], IsLoopIndex)], @vpos0(4)],\n e -> leq(@(3).val, idiv(@(4).val, @(2).val))),\n\n leq_index_neg := Rule([leq, @(2,var,IsLoopIndex), @(3, Value, x->x.v<0), ...], e -> V_false), \n leq_index_big := ARule(leq, [@(2,var,x->IsLoopIndex(x) and IsInt(x.range)), @(3, Value, x->x.v >= @(2).val.range-1)],\n e -> [@(2).val]),\n\n leq_neg_mul_index := Rule([leq, [mul, @(2, Value, x->x.v>0), @(3,var,IsLoopIndex)], @(4, Value, x->x.v<0), ...], \n e -> V_false), \n\n leq_index_0 := Rule([leq, @(2,var,IsLoopIndex), @(3, Value, x->x.v=0)], e -> eq(@(2).val, @(3).val)), \n leq_mul_index_0 := Rule([leq, [mul, @(2, Value, x->x.v<>0), @(3,var,IsLoopIndex)], @(4, Value, x->x.v=0)], \n e -> eq(@(3).val, @(4).val)), \n\n leq_neg_index_A := ARule(leq, [@(1, Value, x->x.v<=0), @(2,var,IsLoopIndex)], e -> [@(2).val]),\n leq_neg_mul_index_A := ARule(leq, [@(1, Value, x->x.v<=0), [@(0,mul), @(2, Value, x->x.v>0), @(3,var,IsLoopIndex)]], \n e -> [@(0).val]),\n\n leq_val_val_l := Rule([leq, @(1, Value), @(2, Value, x->@(1).val<=x), @, ...],\n e -> ApplyFunc(leq, Drop(e.args, 1))),\n leq_val_val_r := Rule([leq, ..., @, @(1, Value), @(2, Value, x->@(1).val<=x)],\n e -> ApplyFunc(leq, DropLast(e.args, 1))),\n \n ################\n # add/sub/mul 0\n # =============\n subzr := Rule([sub, @1, _sameTasOp(\"sub\", _is0none)], e -> @1.val),\n subzl := Rule([sub, _sameTasOp(\"sub\", _is0none), @1], e -> neg(@1.val)),\n\n div0 := Rule([@(1, [div, idiv, fdiv]), _0none, @], e->_0noneOrZero(e.t)),\n div1 := Rule([@(1, [div, idiv, fdiv]), @, @@(0).cond((e, cx) -> let( op := Last(cx.(ObjId(@(1).val).__name__)),\n Cond(IsValue(e), isValueOne(e), e=1) and ForAny(op.args, (a) -> not Same(a, e) and a.t=op.t)))], \n e -> @.val),\n\n add_assoc := ARule(add, [ @(1,add) ], e -> @1.val.args),\n add_zero := ARule(add, [_sameTasOp(\"add\", _is0none)], e -> [ ]),\n add_single := Rule([add, @1], e -> @1.val),\n\n add_cfold := Rule(@(1,add,e->Length(e.args)>2 and Length(Filtered(e.args, IsValue)) >= 2),\n e -> let(s := SplitBy(e.args, IsValue), values := s[1], exps := s[2],\n ApplyFunc(add, Concatenation([ApplyFunc(add,values)], exps)))),\n\n sub_sub := Rule( [@(1, sub), @(2), [sub, @(3), @(4)]], e -> sub(add(@(2).val, @(4).val), @(3).val)),\n\n ################\n # logic and/or\n # ============\n logic_single := Rule([@(1, [logic_and, logic_or]), @1], e->@1.val),\n logic_empty := Rule([@(1, [logic_and, logic_or])], e->V_true),\n\n logic_and_assoc := ARule(logic_and, [ @(1,logic_and) ], e -> @1.val.args),\n logic_and_false := Rule([logic_and, ..., _vfalse, ...], e -> V_false),\n logic_and_true := ARule(logic_and, [_vtrue], e -> [ ]),\n\n logic_or_assoc := ARule(logic_or, [ @(1,logic_or) ], e -> @1.val.args),\n logic_or_true := Rule([logic_or, ..., _vtrue, ...], e -> V_true),\n logic_or_false := ARule(logic_or, [_vfalse], e -> [ ]),\n \n logic_neg_neg := Rule([logic_neg, [logic_neg, @(1)]], e -> @(1).val),\n logic_neg_eq := Rule([logic_neg, [eq, @(1), @(2)]], e -> neq(@(1).val, @(2).val)),\n\n # 'maybe' is a \"magic\" boolean function that behaves as 'true' inside 'and'/'or' operators,\n # but also satisfies the uncertainty rule logic_not(maybe()) = maybe()\n # \n logic_neg_maybe := Rule([logic_neg, @(1, maybe)], e -> @(1).val),\n logic_and_maybe := ARule(logic_and, [maybe], e -> [ ]),\n logic_or_maybe := ARule(logic_or, [maybe], e -> [ ]),\n\n eq_logic_true := Rule( [eq, @(1), _vtrue], e -> @(1).val ),\n \n ################\n # mul\n # ===\n\n # mul_assoc is slow, and we enable it in RulesExpensiveStrength reduce\n # mul_assoc := ARule(mul, [ @(1,mul) ], e -> @1.val.args),\n mul_one := ARule(mul, [ _sameTasOp(\"mul\", _is1) ], e -> [ ]),\n\n mul_single := Rule([mul, @1], e->@1.val),\n mul_zero := Rule([mul, ..., _v0none, ...], e -> _0noneOrZero(e.t)), # must be @(0).val so that none*x -> none\n mul_mul := Rule([mul, @(1,Value), [mul, @(2,Value), @(3)]], e -> let(\n t := UnifyPair(@(1).val.t, @(2).val.t),\n val := t.value(t.product(@(1).val.v, @(2).val.v)),\n mul(val, @(3).val))),\n\n # apply distributivity a * (b+c) -> a*b + a*c, only if inside nth()\n mul_add_nth := Rule([@@(0,mul,(e,cx)->IsBound(cx.nth) and cx.nth<>[]), @(1), @(2,add)],\n e -> ApplyFunc(add, List(@(2).val.args, a->@(1).val * a))),\n\n # FF: NOTE: Need to guard this rule in the SAR case. Not sure how to properly do this.\n # Guard against nth indexing integer tables. This is at the moment only used in SAR.\n # NB: Without guard, there is an infinite loop with sar_sub rule\n mul_sub_nth := Rule([@@(0, mul, (e,cx) -> cx.isInside(nth) and cx.nth[1].loc.t.t <> TInt), @(1), @(2,sub)],\n e -> ApplyFunc(sub, List(@(2).val.args, a->@(1).val * a))), # Above guard to prevent inf loop with sar_sub\n\n # NB: Below rule became obsolete due to change in segment length computation\n # sar_sub := Rule([sub, @(1,Value,e->e.t=TInt), [mul, @(2, Value, e->e.t=TInt and IsInt(@(1).val.v/e.v)), @(3)]],\n # e->mul(@(2).val, sub(@(1).val/@(2).val, @(3).val))),\n\n # Value * (Value * a +/- Value * b) -> Value * a +/- Value * b\n mul_add_mul := Rule([mul, @(1, Value), [@(0,[add,sub]), [mul, @(2, Value), @(3)], [mul, @(4, Value), @(5)]]],\n e -> let(t1 := UnifyPair(@(1).val.t, @(2).val.t),\n t2 := UnifyPair(@(1).val.t, @(4).val.t),\n op := ObjId(@(0).val),\n op(t1.value(t1.product(@(1).val.v, @(2).val.v)) * @(3).val,\n t2.value(t2.product(@(1).val.v, @(4).val.v)) * @(5).val))),\n\n # mul_cfold := Rule(@(1,mul,e->Length(e.args)>2 and Length(Filtered(e.args, IsValue)) >= 2),\n # e -> let(s := SplitBy(e.args, IsValue), values := s[1], vars := s[2],\n # ApplyFunc(mul, Concatenation( [Product(values,v->v.v)], vars)))),\n\n fpmul_2power := Rule([fpmul, @(1, Value), @(2, Value, e->Is2Power(e.v)), @(3)], e ->\n let(sh := Log2Int(@(2).val.v),\n Cond(sh = @(1).val.v, @(3).val,\n sh > @(1).val.v, arith_shl(@(3).val, sh - @(1).val.v),\n sh < @(1).val.v, arith_shr(@(3).val, @(1).val.v - sh)))),\n\n # mul_add_expand := Rule([mul, @(1,Value,e->e.t=TInt), @(2,add)],\n # e -> ApplyFunc(add, List(@2.val.args, a->mul(@1.val, a).eval()))),\n #\n # mul_sub_expand := Rule([mul, @(1,Value,e->e.t=TInt), @(2,sub)],\n # e -> ApplyFunc(sub, List(@2.val.args, a->mul(@1.val, a).eval()))),\n\n\n ##############\n # neg\n # =====\n mul_negone := Rule([mul, _neg1, @2], e -> neg(@2.val)),\n neg_neg := Rule([neg, [neg, @1]], e -> @1.val), # -(-1) -> 1\n neg_sub := Rule([neg, [sub, @1, @2]], e -> sub(@2.val, @1.val)), # -(1-2) -> 2-1\n neg_zero := Rule([neg, _v0none], e -> e.args[1]),\n\n sub_neg1 := Rule([sub, @1, [neg, @2]], e -> add(@1.val, @2.val)), # 1-(-2) -> 1+2\n sub_neg2 := Rule([sub, [neg, @1], @2], e -> neg(add(@1.val, @2.val))), # (-1)-2 -> -(1+2)\n add_neg1 := Rule([add, @1, [neg, @2]], e -> sub(@1.val, @2.val)), # 1+(-2) -> 1-2\n add_neg2 := Rule([add, [neg, @1], @2], e -> sub(@2.val, @1.val)), # (-1)+2 -> 2-1\n\n mul_neg1 := Rule([mul, @1, [neg, @2]], e -> neg(mul(@1.val, @2.val))), # 1*(-2) -> -(1*2)\n mul_neg2 := Rule([mul, [neg, @1], @2], e -> neg(mul(@1.val, @2.val))), # (-1)*2 -> -(1*2)\n mul_negc1 := Rule([mul, @1, @(2,Value,isNegV)], e -> neg(mul(Value.new(@2.val.t, -@2.val.v), @1.val))),\n mul_negc2 := Rule([mul, @(1,Value,isNegV), @2], e -> neg(mul(Value.new(@1.val.t, -@1.val.v), @2.val))),\n\n\n #################################\n # general constant folding\n # ==========================\n\n # The rules below can be used instead of generic cfold to speed up this ruleset\n # cfold_add := Rule([add, Value,Value], e->Value.new(e.args[1].t, e.args[1].v + e.args[2].v)),\n # cfold_mul := Rule([mul, Value,Value], e->Value.new(e.args[1].t, e.args[1].v * e.args[2].v)),\n # cfold_sub := Rule([sub, Value,Value], e->Value.new(e.args[1].t, e.args[1].v - e.args[2].v)),\n # cfold_imod := Rule([imod, Value,Value], e->Value.new(e.args[1].t, e.args[1].v mod e.args[2].v)),\n # cfold_idiv := Rule([idiv, Value,Value], e->Value.new(e.args[1].t, QuoInt(e.args[1].v, e.args[2].v))),\n # cfold_nth := Rule([nth, @(1,var,e->IsBound(e.value)), Value], e->e.loc.value.v[e.idx.v+1]),\n # cfold_nthv := Rule([nth, Value,Value], e->e.loc.v[e.idx.v+1]),\n # cfold_re := Rule([re, Value], e->Value.new(TDouble, ReComplex(Complex(e.args[1].v)))),\n # cfold_im := Rule([im, Value], e->Value.new(TDouble, ImComplex(Complex(e.args[1].v)))),\n # cfold_neg := Rule([neg, Value], e->Value.new(e.args[1].t, -e.args[1].v)),\n\n # cfold_arith := Rule([@(1,[add,mul,sub]), Value,Value], e->e.eval()),\n # cfold_divmod := Rule([@(1,[imod,idiv]), Value,Value], e->e.eval()),\n # cfold_unary := Rule([@(1,[re,im,neg]), Value], e->e.eval()),\n # cfold_nth := Rule([nth, @(1,var,e->IsBound(e.value)), Value], e->e.eval()),\n # cfold_nthv := Rule([nth, Value, Value], e->e.eval()),\n\n cfold := Rule(@(1).cond(e -> IsExp(e) and e.can_fold()), e -> e.eval()),\n\n # In below rules @(1) is a type, and if t is a type, \n # t.value creates a value of this type, and thus performs the typecast \n tcast_varvalue := Rule([tcast, @(1), @(2,var,e->IsBound(e.value))], \n e -> Cond(IsPtrT(@(1).val), @(2).val, @(1).val.value(@(2).val.v))), # NOTE: IsPtrT branch is unsafe, and relies on correct\n # scalarization/non-scalarization\n# tcast_value := Rule([tcast, @(1), @(2,Value)], e -> Cond(\n# # if an array value is typecast to a pointer of same type, just drop the typecast\n# IsPtrT(@(1).val) and IsArrayT(@(2).val.t) and @(1).val.t = @(2).val.t.t, @(2).val, \n# @(1).val.value(@(2).val.v))),\n \n # only applies to pointers, otherwise is not valid -- for example (double)((int)3.2) is not (double)3.2\n tcast_tcast := Rule([tcast, @(1).cond(t->IsPtrT(t)), [tcast, @(2).cond(t->IsPtrT(t)), @(3)]], \n e -> tcast(@(1).val, @(3).val)), \n\n # allow adding zero to ptrs.\n tptr_addzero := ARule(add, [@@(0, Value).cond( (e, cx) -> \n let( op := Last(cx.(\"add\")),\n _is0none(e) and ObjId(op.t) = TPtr\n ))],\n ee -> []\n ), \n\n # cfold_vref := Rule(@(1).cond(e -> IsRec(e) and IsBound(e.isVref) and e.isVref and e.canScalarize() and not IsBound(e.didEval)),\n # e -> e.eval()),\n\n # cfold_vref := Rule(@(1).cond(e -> IsRec(e) and IsBound(e.isVref) and e.isVref and e.canScalarize() and not IsBound(e.didEval)),\n # e -> e.eval()),\n\n ##################\n # cond rules\n # ============\n cond_rid := Rule([cond, @(1), @(2), @(3).cond(e->e=@(2).val)], e -> @(2).val),\n\n cond_fold := Rule([cond, @(1,Value), @2, ...], e -> Cond(\n @1.val.v = false or @1.val.v = 0,\n When(Length(e.args) = 3, e.args[3], ApplyFunc(cond, Drop(e.args, 2))),\n @1.val.v = true or IsInt(@1.val.v),\n (@2.val),\n Error(\"non boolean condition\"))),\n\n IF_fold := Rule([IF, @(1,Value), @(2), @(3)], e -> Cond(\n @(1).val.v = false or @1.val.v = 0,\n @(3).val,\n @(1).val.v = true or IsInt(@1.val.v),\n @(2).val,\n Error(\"non boolean condition\"))),\n\n IF_skip := Rule([IF, @(1), skip, skip], e -> skip()),\n\n multi_if2 := Rule([multi_if, @(1), @(2)], e -> IF(@(1).val, @(2).val, skip())),\n multi_if3 := Rule([multi_if, @(1), @(2), @(3)], e -> IF(@(1).val, @(2).val, @(3).val)),\n multi_if_skip := Rule([multi_if, skip], e->skip()),\n multi_if_skip_skip := Rule([@(1, multi_if), @(2, e->ObjId(Last(@(1).val.rChildren()))=skip), skip, ...],\n e -> ApplyFunc(multi_if, Drop(@(1).val.rChildren(), 2))),\n #NOTE: code in autolib's _genPlan messing with 'args' directly, have to drop empty multi_if even though it could fold automatically\n multi_if_drop := ARule( chain, [[multi_if]], e -> [] ),\n\n\n ###################\n # chain rules\n # =============\n chain_empty := Rule([chain], e-> skip()),\n\n chain_skip := Rule([chain, skip], e-> skip()),\n\n\n ##########################\n # rules for functions\n # =====================\n frotate_rank1 := Rule([frotate, @(1).cond(e->e.rank()<=1)], e -> @(1).val),\n fcall_fexp := Rule(\n [@(0,fcall), \n\t @(1,[fcurry,flift,fsplit,frotate,Lambda], e -> e.rank()+2=Length(@(0).val.args)), \n\t ...], \n e -> e.eval()),\n\n fexp_Lambda := Rule(\n [@(1,[fcurry,flift,fsplit,frotate]), \n\t Lambda, \n\t ...], \n e -> e.eval()),\n\n fcurry_void := Rule(\n [fcurry,\n\t @(1), \n\t @(2).cond(x -> IsValue(x) and ObjId(@(1).val.t)=TFunc and @(1).val.t.params[x.v] in [TVoid, TDummy]), \n @(3).cond(x -> x<>0)], \n x -> fcurry(@(1).val, @(2).val, 0)),\n\n fcall_void := Rule(\n [@(0,fcall), \n\t @(1).cond(x -> ObjId(x.t)=TFunc and\n\t let(pos := Position(x.t.params, TDummy), \n\t\t\t pos <> false and\n\t\t\t Length(@(0).val.args) >= 1+pos and\n\t\t\t not IsValue(@(0).val.args[1+pos]))),\n\t ...],\n e -> let(types := e.args[1].t.params,\n\t len := Length(e.args),\n\t ApplyFunc(fcall, [e.args[1]] :: List([2..len], i -> Cond(types[i-1]=TDummy, 0, e.args[i]))))),\n\n # if lambdaWrap(Lambda(..)) has Lambda of the form x -> exp, where exp does not depend on x, then eliminate the Lambda\n #lambdaWrap_dummyLambda := Rule([lambdaWrap, @(1, Lambda, x->x.t.params[1]=TDummy and Length(x.t.params)=2)], e -> @(1).val.at(0)),\n\n #lambdaWrap_rank0 := Rule([lambdaWrap, @(1).cond(x->x.rank()=0)], e -> fcall(@(1).val, 0)), \n\n\n ###############\n # omega\n # =======\n re_omega := Rule([re, [omega, @(1), @(2)]], e -> cospi(fdiv(2*@(2).val, @(1).val))),\n im_omega := Rule([im, [omega, @(1), @(2)]], e -> sinpi(fdiv(2*@(2).val, @(1).val))),\n\n re_omegapi := Rule([re, [omegapi, @(1)]], e -> cospi(@(1).val)),\n im_omegapi := Rule([im, [omegapi, @(1)]], e -> sinpi(@(1).val)),\n\n re_conj_omega := Rule([re, [conj, [omega, @(1), @(2)]]], e -> cospi(fdiv(2*@(2).val, @(1).val))),\n im_conj_omega := Rule([im, [conj, [omega, @(1), @(2)]]], e -> -sinpi(fdiv(2*@(2).val, @(1).val))),\n\n\n ######################\n # complex arith\n # ===============\n conj_conj := Rule([conj, [conj, @(1)]], e->@(1).val),\n re_conj := Rule([re, [conj, @(1)]], x->re(@(1).val)),\n im_conj := Rule([im, [conj, @(1)]], x->-im(@(1).val)),\n\n # the re_cond/im_cond rules prevent cond from having different types in different branches (ie TReal vs TComplex)\n # \n re_cond := Rule([re, @(1,cond)], x -> ApplyFunc(cond, \n\t List(@(1).val.args, x->Cond(x.t=TBool, x, re(x))))),\n im_cond := Rule([im, @(1,cond)], x -> ApplyFunc(cond, \n\t List(@(1).val.args, x->Cond(x.t=TBool, x, im(x))))),\n\n re_real := Rule([re, @.cond(e->e.t=TReal or ObjId(e.t)=T_Real)], e -> e.args[1]), \n im_real := Rule([im, @.cond(e->e.t=TReal or ObjId(e.t)=T_Real)], e -> e.t.zero()), \n\n re_mul := Rule([re, [@(1, mul), @(2).cond(e->e.t=TReal), ...]], e -> @(2).val * re(ApplyFunc(mul, Drop(@(1).val.args, 1)))),\n im_mul := Rule([im, [@(1, mul), @(2).cond(e->e.t=TReal), ...]], e -> @(2).val * im(ApplyFunc(mul, Drop(@(1).val.args, 1)))),\n\n re_cxpack := Rule([re, [cxpack, @(1), @]], e -> @(1).val),\n im_cxpack := Rule([im, [cxpack, @, @(1)]], e -> @(1).val),\n\n re_vdup := Rule([re, [vdup, @(1), @(2)]], e -> vdup(re(@(1).val), @(2).val)),\n im_vdup := Rule([im, [vdup, @(1), @(2)]], e -> vdup(im(@(1).val), @(2).val)),\n\n mul_cxpack := ARule( mul, [[cxpack, @(1), @(2)], [cxpack, @(3), @(4)]],\n e -> [cxpack( @(1).val*@(3).val - @(2).val*@(4).val,\n @(1).val*@(4).val + @(2).val*@(3).val )]),\n\n add_cxpack := ARule( add, [[cxpack, @(1), @(2)], [cxpack, @(3), @(4)]],\n e -> [cxpack( add(@(1).val, @(3).val), add(@(2).val, @(4).val) )]),\n\n sub_cxpack := Rule( [sub, [cxpack, @(1), @(2)], [cxpack, @(3), @(4)]],\n e -> [cxpack( sub(@(1).val, @(3).val), sub(@(2).val, @(4).val) )]),\n\n # re( (a + i*b) * (a - i*b) ) -> a*a + b*b\n re_cxmulconj := Rule( [re, [mul, [cxpack, @(1), @(2)], [conj, [cxpack, @(3).cond(x->x=@(1).val), @(4).cond(x->x=@(2).val)]]]],\n e -> add(mul(@(1).val, @(1).val), mul(@(2).val, @(2).val))),\n # im( (a + i*b) * (a - i*b) ) -> 0\n im_cxmulconj := Rule( [im, [mul, [cxpack, @(1), @(2)], [conj, [cxpack, @(3).cond(x->x=@(1).val), @(4).cond(x->x=@(2).val)]]]],\n e -> e.t.zero() ),\n\n #############\n # imod\n # ======\n imod_by_one := Rule([imod, @1, _1], e -> v0),\n imod_zero := Rule([imod, _0none, @], e -> @(0).val),\n imod_one := Rule([imod, _1, @], e -> v1),\n\n imod_imod := Rule([imod, [imod, @(1,Value), @(2)], @(3,Value, e->@(2).val.v <= e.v )],\n e -> imod(@(1).val, @(2).val)),\n\n imod_small := Rule([imod, @(1,var,e->IsBound(e.range) and not IsSymbolic(e.range)), @(2,Value,e->e.v >= @(1).val.range)],\n e -> @(1).val),\n\n # this is a less general version of imod_mul_reduce_const, commented out below\n # v1*exp mod v3 -> ((v1 mod v3)*exp) mod v3\n imod_mul := Rule([imod, [@(2, mul), @(1,Value), ...], @(3,Value, e->@(1).val.v >= e.v)],\n e -> imod(ApplyFunc(mul, [@(1).val.v mod @(3).val.v] :: Drop(@(2).val.args, 1)), @(3).val)),\n\n # (v1*exp + exp4) mod v3 -> ((v1 mod v3)*exp + exp4) mod v3\n imod_addmul_l := Rule([imod, [add, [@(2,mul), @(1,Value), ...], @(4)], @(3,Value, e->@(1).val.v >= e.v)],\n e -> imod(ApplyFunc(mul, [@(1).val.v mod @(3).val.v] :: Drop(@(2).val.args, 1)) + @(4).val, @(3).val)),\n imod_addmul_r := Rule([imod, [add, @(4), [@(2,mul), @(1,Value), ...]], @(3,Value, e->@(1).val.v >= e.v)],\n e -> imod(ApplyFunc(mul, [@(1).val.v mod @(3).val.v] :: Drop(@(2).val.args, 1)) + @(4).val, @(3).val)),\n\n no_mod_imod := Rule([no_mod, [imod, @1, @2]], e -> @1.val),\n no_mod_small_mod := Rule([no_mod, [small_mod, @1, @2]], e -> @1.val),\n\n # imod_mul_reduce_const := Rule( [imod, @(1,mul),\n # @(2,Value, e -> Filtered(@1.val.args, a->IsValue(a) and a.v >= e.v) <>[]) ],\n # e -> imod(\n # ApplyFunc(mul, List(@1.val.args, a->Cond(IsValue(a), V(a.v mod @2.val.v), a))),\n # @2.val)),\n\n # NOTE: These rules are very general but lead to an infinite loop.\n #\n # imod_mul := Rule([imod, @(1, mul, NOT_ALL_ARGS_ARE(imod)), @(2)],\n # e -> imod(ApplyFunc(mul, List(@(1).val.args, a -> imod(a, @(2).val))), @(2).val)),\n #\n # imod_add := Rule([imod, @(1, [add,sub], NOT_ALL_ARGS_ARE(imod)), @(2)],\n # e -> imod(ApplyFunc(ObjId(@(1).val), List(@(1).val.args, a -> imod(a, @(2).val))), @(2).val)),\n\n\n #############\n # idiv\n # ======\n idiv_small := Rule([idiv, @(1, var, e -> IsBound(e.range) and not IsSymbolic(e.range)), @(2, Value, e-> e.v >= @(1).val.range)],\n e -> V(0)),\n\n # exp / value -> (1/value) * exp, for floating-point types. NOTE: use .t.isFloat()\n div_byV_tomul := Rule([@(0, [div, fdiv]), @(1), @(2, Value, x->x.t in [TReal, TComplex])],\n e -> div(@(2).val.t.one(), @(2).val) * @(1).val),\n\n # (v1*exp2 + exp3)/v4 -> v1/v4*exp2 + exp3/v4; v4 | v1;\n # NOTE: these rules are invalid if sign(exp2)<>sign(exp4) !!!\n \n #idiv_addmul_l := Rule([idiv, [add, [mul, @(1, Value), @(2)], @(3)], @(4, Value, x -> _divides(x, @(1).val))],\n # e -> add(mul(div(@(1).val, @(4).val), @(2).val), idiv(@(3).val, @(4).val))),\n \n #idiv_addmul_r := Rule([idiv, [add, @(3), [mul, @(1, Value), @(2)]], @(4, Value, x -> _divides(x, @(1).val))],\n # e -> add(mul(div(@(1).val, @(4).val), @(2).val), idiv(@(3).val, @(4).val))),\n\n # (v1*loop_idx + v2)/v3 -> v1/v3*loop_idx + v2/v3; when (v3 | v1) & (v2 >= 0) & (v1 >= 0);\n # assumption: loop index cannot be negative \n idiv_addmul_pos_l := Rule([idiv, [add, [mul, @vpos0(1), @(2).cond(IsLoopIndex)], @vpos0(3)], @(4, Value, x -> _divides(x, @(1).val))],\n e -> add(mul(idiv(@(1).val, @(4).val), @(2).val), idiv(@(3).val, @(4).val))),\n \n idiv_addmul_pos_r := Rule([idiv, [add, @vpos0(3), [mul, @vpos0(1), @(2).cond(IsLoopIndex)]], @(4, Value, x -> _divides(x, @(1).val))],\n e -> add(mul(idiv(@(1).val, @(4).val), @(2).val), idiv(@(3).val, @(4).val))),\n\n ############\n # pow, sqrt, rsqrt\n # =====\n pow_zero := Rule([pow, @1, _0none], e->v1),\n\n powmod_mul_const := Rule([powmod, @, Value, @(1,mul,e->ForAny(e.args,IsValue)), @],\n e -> let(split := SplitBy(@1.val.args, IsValue),\n value := Product(split[1], x->x.v),\n vars := split[2],\n powmod( e.args[1],\n (e.args[2].v ^ value) mod e.args[4].v,\n ApplyFunc(mul, vars),\n e.args[4]))),\n\n powmod_cfold := Rule([powmod, @1, Value, Value, Value],\n e -> imod(((e.args[2].v ^ e.args[3].v) mod e.args[4].v)*e.args[1], e.args[4].v)),\n\n sqrt_pow2 := Rule( [sqrt, [pow, @(1), _2]], e -> abs(@(1).val) ),\n pow2_sqrt := Rule( [pow, [sqrt, @(1)], _2], e -> @(1).val ),\n\n rsqrt_pow2 := Rule( [rsqrt, [pow, @(1), _2]], e -> fdiv(e.t.one(), abs(@(1).val)) ),\n pow2_rsqrt := Rule( [pow, [rsqrt, @(1)], _2], e -> fdiv(e.t.one(), @(1).val) ),\n \n #############\n # bin\n # ====\n\n bin_xor_zero := Rule([bin_xor, ..., _0none, ...], e -> When(@(0).val = e.args[2], e.args[1], e.args[2])),\n bin_and_zero := Rule([bin_and, ..., _0none, ...], e -> @(0).val),\n\n bin_shr_zero := Rule([bin_shr, _0none, @], e -> e.args[1]),\n bin_shr_zeroshift := Rule([bin_shr, @, _0none], e -> e.args[1]),\n bin_shl_zero := Rule([bin_shl, _0none, @], e -> e.args[1]),\n bin_shl_zeroshift := Rule([bin_shl, @, _0none], e -> e.args[1]),\n\n absdiff2_to_abssub := Rule([@(0, absdiff2, x -> not IsOrdT(x.t.base_t())), @(1), @(2)],\n e -> Cond( IsValue(@(1).val) and isValueZero(@(1).val),\n @(2).val,\n IsValue(@(1).val) and Length(Set(Flat([@(1).val.v])))=1,\n sub(@(1).val, @(2).val),\n # else\n abs(sub(@(1).val, @(2).val)))),\n\n # Memory allocation\n allocate_0 := Rule([allocate, @(1), [TArray, @(2), _0]], e -> assign(@(1).val, null())),\n deallocate_0 := Rule([deallocate, @(1), [TArray, @(2), _0]], e -> skip()),\n\n # funcExp rule\n\n expr_funcExp := Rule( [@(0, [mul, add, sub, div, idiv, imod]), ..., @(1, funcExp), ...], \n e -> @(1).val ),\n\n expr_cond_funcExp := Rule( [@(1, [mul, add]), ..., [@(2, cond), ..., funcExp, ...], ...], \n e -> let( args := RemoveList(e.args, @(2).val), \n _map_cond(@(2).val, p -> p, exp -> ApplyFunc(ObjId(e), args :: [exp])))),\n\n divmod_cond_funcExp := Rule( [@(1, [div, idiv, imod]), [@(2, cond), ..., funcExp, ...], @(3)], \n e -> _map_cond(@(2).val, p -> p, exp -> ObjId(e)(exp, @(3).val))),\n\n # always pull cond() from nth() for nth(funcExp) annihilation.\n nth_cond := Rule( [nth, @(1), @(2, cond)], \n e -> _map_cond(@(2).val, p->p, exp->nth(@(1).val, exp))),\n\n\n #############\n vdup_noneExp := Rule([vdup, [noneExp, @(1)], @(2)], e -> vdup(@(1).val.zero(), @(2).val) ),\n\n vdup_vdup := Rule([vdup, [vdup, @(1), @(2)], @(3)], e -> vdup(@(1).val, @(2).val * @(3).val)),\n\n vdup_vpack := Rule([vdup, @(1, vpack), @(3)], e -> ApplyFunc(vpack, ConcatList(@(1).val.args, x -> [x,x])))\n));\n\nClass(stickyNeg, neg, rec(doPeel := false, unparse := \"neg\"));\n\nClass(RulesExpensiveStrengthReduce, RuleSet);\n\n__groupSummands := function(lst, is_full)\n local e, grp, non, grpid, id, mult, i, one, ptrs;\n [grp, grpid, non] := [rec(), Set([]), []];\n [ptrs, lst] := SplitBy(lst, e -> IsPtrT(e.t) or IsArrayT(e.t));\n for e in lst do\n one := e.t.one();\n if ObjId(e) in [var, param] then\n\t if not IsBound(grp.(e.id)) then grp.(e.id) := [one, e];\n\t else \t\t grp.(e.id)[1] := grp.(e.id)[1] + one;\n\t fi;\n\t AddSet(grpid, e.id);\n elif ObjId(e) in [neg, stickyNeg] and ObjId(e.args[1]) in [var, param] then\n\t id := e.args[1].id;\n\t if not IsBound(grp.(id)) then grp.(id) := [-one, e.args[1]];\n\t else \t\t grp.(id)[1] := grp.(id)[1] - one;\n\t fi;\n\t AddSet(grpid, id);\n elif ObjId(e)=mul and Length(e.args)=2 and ObjId(e.args[1])=Value and ObjId(e.args[2]) in [var, param] then\n\t id := e.args[2].id;\n\t if not IsBound(grp.(id)) then grp.(id) := [e.args[1], e.args[2]];\n\t else \t\t grp.(id)[1] := grp.(id)[1] + e.args[1];\n\t fi;\n\t AddSet(grpid, id);\n\telif ObjId(e) in [ neg, stickyNeg ] and ObjId(e.args[1]) = mul and Length(e.args[1].args) = 2\n and ObjId(e.args[1].args[1]) = Value and ObjId(e.args[1].args[2]) in [ var, param ] then\n id := e.args[1].args[2].id;\n if not IsBound(grp.(id)) then grp.(id) := [ -e.args[1].args[1], e.args[1].args[2] ];\n else grp.(id)[1] := grp.(id)[1] - e.args[1].args[1];\n fi;\n AddSet(grpid, id);\n elif not is_full then \n\t Add(non, [one, e]);\n\telse\n\t mult := one;\n\t if ObjId(e) in [neg, stickyNeg] then mult := -mult; e := e.args[1]; fi;\n\t if ObjId(e) = mul and IsValue(e.args[1]) then mult := mult*e.args[1]; e := ApplyFunc(mul, Drop(e.args, 1)); fi;\n\t if ObjId(e) in [neg, stickyNeg] then mult := -mult; e := e.args[1]; fi;\n\n\t i := PositionProperty(non, x->x[2]=e);\n\t if i=false then Add(non, [mult, e]);\n\t else \n\t\tnon[i][1] := non[i][1] + mult;\n\t fi;\n\tfi;\n od;\n return ApplyFunc(add, ptrs :: List(grpid, id -> grp.(id)[1] * grp.(id)[2]) :: List(non, x->x[1]*x[2])); \nend;\n\n#F __groupSummandsVar(<lst>) is similar to __groupSummands but pulls out\n#F variables. This helps to implement rolling pointers in Autolib \n#F because grouping this way helps to get stride expression for a loop index variable.\n#F\n\n__groupSummandsVar := function(lst)\n local e, grp, non, grpid, id, mult, i, one, ptrs;\n [grp, grpid, non] := [rec(), Set([]), []];\n [ptrs, lst] := SplitBy(lst, e -> IsPtrT(e.t) or IsArrayT(e.t));\n for e in lst do\n one := e.t.one();\n if ObjId(e) in [var, param] then\n\t if not IsBound(grp.(e.id)) then grp.(e.id) := [one, e];\n\t else \t\t grp.(e.id)[1] := grp.(e.id)[1] + one;\n\t fi;\n\t AddSet(grpid, e.id);\n elif ObjId(e) in [neg, stickyNeg] and ObjId(e.args[1]) in [var, param] then\n\t id := e.args[1].id;\n\t if not IsBound(grp.(id)) then grp.(id) := [-one, e.args[1]];\n\t else \t\t grp.(id)[1] := grp.(id)[1] - one;\n\t fi;\n\t AddSet(grpid, id);\n elif ObjId(e)=mul and ObjId(Last(e.args))=var then\n\t id := Last(e.args).id;\n\t if not IsBound(grp.(id)) then grp.(id) := [ApplyFunc(mul, DropLast(e.args, 1)), Last(e.args)];\n\t else \t\t grp.(id)[1] := grp.(id)[1] + ApplyFunc(mul, DropLast(e.args, 1));\n\t fi;\n\t AddSet(grpid, id);\n\telif ObjId(e) in [ neg, stickyNeg ] and ObjId(e.args[1]) = mul\n and ObjId(Last(e.args[1].args)) = var then\n id := Last(e.args[1].args).id;\n if not IsBound(grp.(id)) then grp.(id) := [ -ApplyFunc(mul, DropLast(e.args[1].args, 1)), Last(e.args[1].args) ];\n else grp.(id)[1] := grp.(id)[1] - ApplyFunc(mul, DropLast(e.args[1].args, 1));\n fi;\n AddSet(grpid, id);\n else \n\t Add(non, [one, e]);\n\tfi;\n od;\n return ApplyFunc(add, ptrs :: List(grpid, id -> grp.(id)[1] * grp.(id)[2]) :: List(non, x->x[1]*x[2])); \nend;\n\n_groupSummands := lst -> __groupSummands(lst, true);\n_groupSummandsSimple := lst -> __groupSummands(lst, false);\n\n\nRewriteRules(RulesExpensiveStrengthReduce, rec(\n mul_add := Rule([mul, @(1,Value), [add, @(2, Value), @(3)]], e -> @(1).val*@(2).val + @(1).val*@(3).val),\n\n mul_assoc := ARule(mul, [ @(1,mul) ], e -> @1.val.args),\n\n mul_cfold := Rule(@(1,mul,e->Length(e.args)>2 and Length(Filtered(e.args, IsValue)) >= 2),\n e -> let(s := SplitBy(e.args, IsValue), values := s[1], exps := s[2],\n ApplyFunc(mul, Concatenation( [Product(values,v->v.v)], exps)))),\n\n add_assoc := Rule([add, ..., @(1,add), ... ], e -> let(\n\t args := ConcatList(e.args, x->Cond(ObjId(x)=add, x.args, [x])),\n\t #args)),\n\t _groupSummands(args))), \n\n add_cfold := Rule(@(1,add,e->Length(e.args)>2 and Length(Filtered(e.args, IsValue)) >= 2),\n e -> let(s := SplitBy(e.args, IsValue), values := s[1], exps := _groupSummands(s[2]), \n ApplyFunc(add, Concatenation([Sum(values,v->v.v)], [exps])))),\n\n add_sub_val := Rule( [add, ..., [@(1, sub), @(2), @(3, Value)], ...], \n e -> ApplyFunc(add, [@(2).val, neg(@(3).val)] :: Filtered(e.args, x -> not Same(x, @(1).val)))),\n sub_add_val := Rule( [@(1, sub), @(2, add), @(3, Value)], \n e -> ApplyFunc(add, [neg(@(3).val)] :: @(2).val.args)),\n\n # super ugly: ((a+b+c)-b) -> a+c\n # group summands could do this\n sub_add_same_exp := Rule( [sub, @(1, add), @(2).cond(x -> x in @(1).val.args)],\n e -> let( a := SplitBy(@(1).val.args, x -> x=@(2).val),\n ApplyFunc(add, a[2] :: Drop(a[1], 1) :: [a[1][1].t.zero()]))),\n add_sub_same_exp := Rule( [@(1, add), ..., [@(2, sub), @(3), @(4).cond(x -> x in @(1).val.args)], ...],\n e -> let( a := SplitBy(@(1).val.args, x -> x=@(4).val),\n b := SplitBy(a[2], x -> x=@(2).val),\n ApplyFunc(add, b[2] :: Drop(a[1], 1) :: Drop(b[1], 1) :: [@(3).val, a[1][1].t.zero()]))),\n\n# fold the constants in an xor expression with >2 arguments of which >=2 arguments are constants\n xor_cfold := Rule(@(1,xor,e -> Length(e.args)>2 and Length(Filtered(e.args, IsValue))>=2),\n e -> let(\n s := SplitBy(e.args, IsValue),\n values := s[1],\n vars := s[2],\n\n ApplyFunc(xor, Concatenation( [Xor(values, v -> v.v)], vars ) )\n )\n ),\n\n xor_zero := ARule(xor, [_0none], e -> []),\n\n xor_one := Rule(@(1,xor, e -> Length(e.args) = 1),\n e -> e.args[1]\n ),\n\n# NOTE: removed <idiv> since the rule is invalid for non-divisible numbers\n# can one create a new rule for idiv?\n\n mul_div := Rule([mul, ..., @(1, div), ...], e ->\n let(facs := e.args, divkind := ObjId(@(1).val), dd := Filtered(facs, f->ObjId(f)=divkind),\n divkind(Product(List(facs, f->When(ObjId(f)=divkind, f.args[1], f))),\n Product(List(dd, d->d.args[2]))))),\n\n imod_imod := Rule([imod, [imod, @(1), @(2, Value)], @(3, Value, e->@(2).val.v mod e.v = 0)],\n e -> imod(@(1).val, @(3).val)),\n\n imod_addmul := Rule([imod,[@(1,add),...,[@(2,mul),...,@(3,Value),...],...],@(4,Value,e->Mod(@(3).val.v,e.v)=0)],\n e->let(p1:=FirstPosition(@1.val.rChildren(),e->e=@(2).val),a:=ApplyFunc(add,ListWithout(@(1).val.rChildren(),p1)),imod(a,@(4).val))),\n\n imod_sub := Rule([imod, [@(0,sub), @(1), @(2)], @(3).cond(x -> _divides(x, @(1).val) or _divides(x, @(2).val))], \n e -> When(_divides(@(3).val, @(2).val), imod(@(1).val, @(3).val), imod(-@(2).val, @(3).val))),\n\n imod_add := Rule([@(1, imod), [ add, ..., @(2).cond(x -> _divides(@(1).val.args[2], x)), ... ], @], \n e -> imod(ApplyFunc(add, Filtered(e.args[1].args, x -> not _divides(e.args[2], x))), e.args[2])),\n\n imod_divides := Rule( [imod, @(1), @(2).cond( x -> _divides(x, @(1).val) )],\n e -> e.t.zero() ),\n\n # NOTE: idiv rule disabled, because its invalid if summands have different signs (a+2)/2 != a/2 + 1, if a<0\n # can this be overcome?\n #idiv_addmul := Rule([idiv,[@(1,add),...,[@(2,mul),...,@(3,Value),...],...],@(4,Value,e->Mod(@(3).val.v,e.v)=0)],\n # e->let(p1:=FirstPosition(@1.val.rChildren(),e->e=@(2).val),a:=ApplyFunc(add,ListWithout(@(1).val.rChildren(),p1)),add(idiv(a,@(4).val),idiv(@(2).val,@(4).val)))),\n\n # NOTE: idiv rule disabled, because its invalid if summands have different signs (a+2)/2 != a/2 + 1, if a<0\n # can this be overcome?\n divs_addmul2 := Rule([@(1, [div, fdiv]), [ add, ..., [ @(2, mul), ..., @(3).cond(x -> x = @(1).val.args[2]), ...], ... ], @], \n e -> add( ApplyFunc(mul, DropCond(@(2).val.args, x -> x=e.args[2], 1)),\n ObjId(e)(ApplyFunc(add, DropCond(e.args[1].args, x -> x = @(2).val, 1)), e.args[2]))),\n\n # NOTE: idiv rule disabled, because its invalid if summands have different signs (a+2)/2 != a/2 + 1, if a<0\n # can this be overcome?\n divs_addmul3 := Rule([@(1, [div, fdiv]), [ add, ..., @(2).cond(x -> x = @(1).val.args[2]), ...], @], \n e -> add( e.t.one(), ObjId(e)(ApplyFunc(add, DropCond(e.args[1].args, x -> x = @(2).val, 1)), e.args[2]))), \n\n div_div1 := Rule([div, @(1), [div, @(2), @(3)]], e -> div(@(1).val*@(3).val, @(2).val)),\n div_div2 := Rule([div, [div, @(1), @(2)], @(3)], e -> div(@(1).val, @(2).val*@(3).val)),\n\n# NOTE: removed <idiv> since the rule is invalid for non-divisible numbers\n# can one create a new rule for idiv?\n# idiv_idiv1 := Rule([idiv, @(1), [idiv, @(2), @(3)]], e -> idiv(@(1).val*@(3).val, @(2).val)),\n# idiv_idiv2 := Rule([idiv, [idiv, @(1), @(2)], @(3)], e -> idiv(@(1).val, @(2).val*@(3).val)),\n\n fdiv_fdiv1 := Rule([fdiv, @(1), [fdiv, @(2), @(3)]], e -> fdiv(@(1).val*@(3).val, @(2).val)),\n fdiv_fdiv2 := Rule([fdiv, [fdiv, @(1), @(2)], @(3)], e -> fdiv(@(1).val, @(2).val*@(3).val)),\n\n mul_middleValue := Rule(@(1,mul,e -> PositionProperty(e.args, IsValue) > 1 and\n Length(Filtered(e.args, IsValue))=1),\n e -> let(i := PositionProperty(e.args, IsValue),\n Product(Permuted(e.args, (1,i))))),\n\n add_Value_1st := Rule(@(1,add,e->ForAny(e.args, IsValue) and not IsValue(e.args[1])),\n e -> let(s := SplitBy(e.args, IsValue), values := s[1], vars := s[2],\n ApplyFunc(add, [ApplyFunc(add, values)] :: vars))),\n\n\n# NOTE: removed <idiv> since the rule is invalid for non-divisible numbers\n# can one create a new rule for idiv?\n\n div_add_Values := Rule([@(0,[div,fdiv]), [@(1,add), @(2, Value), ...],\n @(3, Value, e->IsInt(@(2).val.v) and (@(2).val.v mod e.v = 0))],\n e -> add(@(2).val.v / @(3).val.v,\n ObjId(@(0).val)(ApplyFunc(add, Drop(@(1).val.args, 1)), @(3).val))),\n\n # NOTE: this rule ignores the 3rd parameter of bin_shl (!!), which is 'bits'\n div_add_shl := Rule([@(0,[div,fdiv]), [@(1,add), ..., @(2, arith_shl)],\n @(3, Value, e->IsInt(@(2).val.args[2].v)\n and Is2Power(e.v)\n and Log2Int(e.v)<=@(2).val.args[2].v)],\n e -> add(\n arith_shl(@(2).val.args[1],@(2).val.args[2].v - Log2Int(@(3).val.v)),\n ObjId(@(0).val)(ApplyFunc(add, DropLast(@(1).val.args, 1)), @(3).val))),\n\n\n div_mul_mul_cfold1 := Rule([@(0,[idiv,div,fdiv]),\n [@(1,mul), @(2,Value), ...],\n [@(3,mul), @(4,Value,\n e -> (@(2).val.t = TInt and e.t=TInt and (@(2).val.v mod e.v)=0)), ...]],\n e -> ObjId(@(0).val)(ApplyFunc(mul, Concatenation([@(2).val.v/@(4).val.v], Drop(@(1).val.args, 1))),\n ApplyFunc(mul, Drop(@(3).val.args, 1)))),\n\n div_mul_mul_cfold2 := Rule([@(0,[idiv,div,fdiv]),\n [@(1,mul), @(2,Value), ...],\n [@(3,mul), @(4,Value,\n e -> (@(2).val.t = TInt and e.t=TInt and (e.v mod @(2).val.v)=0)), ...]],\n e -> ObjId(@(0).val)(ApplyFunc(mul, Drop(@(1).val.args, 1)),\n ApplyFunc(mul, Concatenation([@(4).val.v/@(2).val.v], Drop(@(3).val.args, 1))))),\n\n div_mul_Value_cfold1 := Rule([@(0,[div, idiv, fdiv]),\n [@(1,mul), @(2,Value), ...],\n @(4,Value, e->(@(2).val.t = TInt and e.t=TInt and (@(2).val.v mod e.v)=0))],\n e -> ApplyFunc(mul, Concatenation([@(2).val.v/@(4).val.v], Drop(@(1).val.args, 1)))),\n\n div_mul_Value_cfold2 := Rule([@(0,[div,idiv, fdiv]),\n [@(1,mul), @(2,Value), ...],\n @(4,Value, e->(@(2).val.t = TInt and e.t=TInt and (e.v mod @(2).val.v)=0))],\n e -> ObjId(@(0).val)(Product(Drop(@(1).val.args, 1)),\n @(4).val.v/@(2).val.v)),\n\n div_mulmul_cfold_vars1 := Rule([@(0,[div,idiv,fdiv]),\n @(1, mul, e->Length(Filtered(e.args, IsLoc)) >= 1),\n @(2, mul, e->let(vv:=Filtered(e.args, IsLoc), Length(vv) >= 1 and Intersection(vv, @(1).val.args)<>[]))],\n e -> let(s1 := SplitBy(@(1).val.args, IsLoc), vars1 := s1[1], nonvars1 := s1[2],\n s2 := SplitBy(@(2).val.args, IsLoc), vars2 := s2[1], nonvars2 := s2[2],\n ObjId(@(0).val)(\n Product(nonvars1) * Product(ListDifference(vars1, vars2)),\n Product(nonvars2) * Product(ListDifference(vars2, vars1))))),\n\n div_mulmul_cfold_vars2 := Rule([@(0,[div,idiv,fdiv]),\n @(1, mul, e->Length(Filtered(e.args, IsLoc)) >= 1),\n @(2).cond(e->IsLoc(e) and e in @(1).val.args) ],\n e -> let(a := @(1).val.args, ApplyFunc(mul, ListWithout(a, Position(a, @(2).val))))),\n\n div_mulmul_cfold_vars3 := Rule([@(0,[div,idiv,fdiv]),\n @(1).cond(IsLoc),\n @(2, mul, e->@(1).val in e.args) ],\n e -> let(a := @(2).val.args, ObjId(@(0).val)(1, ApplyFunc(mul, ListWithout(a, Position(a, @(1).val)))))),\n\n div_cfold_vars4 := Rule([@(0,[div, idiv, fdiv]), \n @(1).cond(IsLoc),\n @(2).cond(x->IsLoc(x) and x=@(1).val)],\n e -> e.t.one()),\n\n pdiv_param := Rule([pdiv, @(0, param), @(1, Value)], e -> div(@(0).val, @(1).val)),\n\n pdiv_add := Rule([pdiv, @(0, add), @(1, Value)], e -> ApplyFunc(add, List(@(0).val.rChildren(), x->pdiv(x, @(1).val)))),\n\n #idiv is a trick to avoid inversion of this rule by mul_div\n pdiv_mul := Rule([pdiv, [mul, @(1, param), @(2)], @(3, Value)], e -> mul(idiv(@(1).val, @(3).val), @(2).val)),\n\n pdiv_const := Rule([pdiv, [mul, @(1, Value), @(2)], @(3, Value, e->Mod(@(1).val.v, e.v)=0)],\n e -> mul(div(@(1).val, @(3).val), @(2).val)),\n\n merge_logic_and := Rule([ logic_and, ..., logic_and, ... ], \n x -> ApplyFunc(logic_and, ConcatList(x.args, e->When(ObjId(e)=logic_and, e.args, [e]) )))\n));\n\nRulesMergedStrengthReduce := MergedRuleSet(RulesStrengthReduce, RulesExpensiveStrengthReduce);\n\nESReduce := (c, opts) -> ApplyStrategy(c, [RulesMergedStrengthReduce], BUA, opts);\n\n\nClass(NormalizeLinearExp, RuleSet);\nRewriteRules(NormalizeLinearExp, rec(\n # Normalization\n mul_zero := Rule([mul, _0none, @], e -> @(0).val),\n mul_one := Rule([mul, _1, @], e -> @.val),\n mul_assoc := ARule(mul, [ @(1,mul) ], e -> @1.val.args),\n\n mul_Value_Value := Rule([mul, @(1,Value), @(2,Value)], # UnifyTypes([@(1).val.t, @(2).val.t]).value\n e -> V(@(1).val.v * @(2).val.v)),\n\n mul_add_rt := Rule([mul, ..., @(2,add)], \n e -> ApplyFunc(add, List(@(2).val.args, \n a -> ApplyFunc(mul, Concatenation(Copy(DropLast(e.args, 1)),[a]))))), #Copy prevents aliasing\n mul_add_lft := Rule([mul, @(2,add), ...], \n e -> ApplyFunc(add, List(@(2).val.args, \n a -> ApplyFunc(mul, Concatenation([a], Copy(Drop(e.args, 1))))))), #Copy prevents aliasing\n\n mul_mul := Rule([mul, @(1,Value), [mul, @(2,Value), @(3)]], e -> mul(@(1).val.v * @(2).val.v, @(3).val)),\n\n sub_to_add := Rule([sub, @(1), @(2)], e -> add(@(1).val, stickyNeg(@(2).val))),\n\n add_assoc := Rule([add, ..., @(1,add), ... ], e -> let(\n\t args := ConcatList(e.args, x->Cond(ObjId(x)=add, x.args, [x])),\n\t #args)),\n _groupSummandsSimple(args))), \n\n add_zero := ARule(add, [_0none], e -> [ ]),\n add_single := Rule([add, @(1)], e -> @(1).val),\n add_none := Rule([add], e -> V(0)),\n\n # Constant folding\n cfold := RulesStrengthReduce.rules.cfold,\n\n mul_cfold := RulesExpensiveStrengthReduce.rules.mul_cfold,\n add_cfold := RulesExpensiveStrengthReduce.rules.add_cfold,\n # put constants first\n mul_middleValue := RulesExpensiveStrengthReduce.rules.mul_middleValue,\n\n # negation\n neg := Rule(neg, e -> stickyNeg(e.args[1])),\n mul_negone := Rule([mul, _neg1, @2], e -> stickyNeg(@2.val)),\n neg_neg := Rule([stickyNeg, [stickyNeg, @1]], e -> @1.val), # -(-1) -> 1\n\n mul_neg := Rule([mul, ..., @(1, [stickyNeg, Value], e->When(ObjId(e)=Value, isNegV(e), true)), ...],\n e -> let(cnt := Counter(0),\n count := List(e.args, x -> When(ObjId(x)=stickyNeg or (ObjId(x)=Value and isNegV(x)), cnt.next(), 0)),\n newargs := List(e.args, x -> Cond(\n ObjId(x)=stickyNeg, x.args[1],\n ObjId(x)=Value and isNegV(x), Value.new(x.t, -x.v),\n x)),\n res := ApplyFunc(mul, newargs),\n When(IsOddInt(cnt.n), stickyNeg(res), res))),\n sink_stickyNeg_add := Rule([stickyNeg, @(1, add)], e -> ApplyFunc(add, List(@(1).val.args, stickyNeg))),\n\n # This rule is in conflict with mul_div rule from ESReduce but it simplifies index computations.\n # div implies divisibility but loop index takes different values from .range field -> other\n # arguments must be divisible by @(3)\n div_pull_out_idx := Rule([div, [@(1, mul), ..., @.cond(IsLoopIndex), ...], @(3, Value)],\n e -> let( m := SplitBy(@(1).val.args, IsLoopIndex),\n ApplyFunc(mul, [div(ApplyFunc(mul, m[2]), @(3).val)] :: m[1]) )),\n));\n\nGroupSummandsExp := s -> NormalizeLinearExp(SubstBottomUp(NormalizeLinearExp(s), add, e->_groupSummands(e.args)));\n", "meta": {"hexsha": "fafb92ddb47f9e8e1497b13866c2fef9c2b9b1ec", "size": 42739, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/code/sreduce.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/code/sreduce.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/code/sreduce.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": 47.6997767857, "max_line_length": 170, "alphanum_fraction": 0.5140036033, "num_tokens": 15175, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584174871563662, "lm_q2_score": 0.546738151984614, "lm_q1q2_score": 0.35998196016222495}} | |
| {"text": "\n## Copyright (c) 2018-2021, Carnegie Mellon University\n## See LICENSE for details\n\nImport(simt);\n\n_isSIMTTag := tag -> IsBound(tag.isSIMTTag) and tag.isSIMTTag;\n_toSIMTDim := (tags, n) -> Cond( \n ObjId(tags[1]) = ASIMTLoopDim, tags[1],\n IsBound(tags[1].params[1]) and not IsInt(tags[1].params[1]), ApplyFunc(ObjId(tags[1]), [tags[1].params[1](n)]), \n tags[1](n));\n\nNewRulesFor(TIterHStack, rec(\n TIterHStack_SIMT := rec(\n applicable := nt->nt.hasTags() and _isSIMTTag(nt.firstTag()), \n forTransposition := false,\n children := nt -> [[ nt.params[1].withTags(Drop(nt.getTags(), 1)), InfoNt(nt.params[2]) ]],\n apply := (nt, c, cnt) -> SIMTIterHStack1(_toSIMTDim(nt.getTags(), cnt[2].params[1].range), cnt[2].params[1], cnt[2].params[1].range, c[1])\n )\n));\n\nNewRulesFor(TIterVStack, rec(\n TIterVStack_SIMT := rec(\n applicable := nt->nt.hasTags() and _isSIMTTag(nt.firstTag()), \n forTransposition := false,\n children := nt -> [[ nt.params[1].withTags(Drop(nt.getTags(), 1)), InfoNt(nt.params[2]) ]],\n apply := (nt, c, cnt) -> SIMTIterVStack(_toSIMTDim(nt.getTags(), cnt[2].params[1].range), cnt[2].params[1], cnt[2].params[1].range, c[1])\n )\n));\n\n\nNewRulesFor(MDDFT, rec(\n MDDFT_RowCol_3D_SIMT := rec(\n info :=\"MDDFT(n_1,n_2,...,n_t) = (RC(MDDFT(n_1,n_2,...,n_{t-1}) x I(.))) (I(n_1*n_2*...*n_{t-1}) x PRDFT1(n_t))\",\n applicable := nt->nt.hasTags() and Length(nt.getTags()) = 2 and ForAll(nt.getTags(), _isSIMTTag) and Length(nt.params[1]) = 3,\n children := nt -> let(a_lengths := nt.params[1],\n a_exp := nt.params[2],\n tags := nt.getTags(),\n taglen := Length(tags),\n rtags1 := tags{[2]},\n [[ MDDFT(DropLast(a_lengths, 1), a_exp).withTags(rtags1),\n DFT(Last(a_lengths), a_exp) ]]),\n\n apply := (nt, C, cnt) -> let(\n a := nt.params[1],\n n1 := a[1],\n n2 := a[2],\n n3 := a[3],\n SIMTTensor(_toSIMTDim(nt.getTags(){[1]}, n3), C[1], I(n3)) *\n SIMTTensor(_toSIMTDim(nt.getTags(){[1]}, n1), I(n1), \n SIMTTensor(_toSIMTDim(nt.getTags(){[2]}, n2), I(n2),\n C[2])))\n ),\n MDDFT_tSPL_RowCol_SIMT := rec(\n info :=\"MDDFT(n_1,n_2,...,n_t) = (RC(MDDFT(n_1,n_2,...,n_{t-1}) x I(.))) (I(n_1*n_2*...*n_{t-1}) x PRDFT1(n_t))\",\n applicable := nt->nt.hasTags() and ForAll(nt.getTags(), _isSIMTTag) and Length(nt.params[1]) > 1,\n children := nt -> let(a_lengths := nt.params[1],\n a_exp := nt.params[2],\n tags := nt.getTags(),\n [[ TTensorI(MDDFT(DropLast(a_lengths, 1), a_exp), Last(a_lengths), AVec, AVec).withTags(tags),\n FoldR(DropLast(a_lengths, 1), (a,b)->TTensorI(a, b, APar, APar), DFT(Last(a_lengths), a_exp)).withTags(tags) ]]),\n apply := (nt, C, cnt) -> C[1] * C[2]\n ),\n MDDFT_tSPL_Pease_SIMT := rec(\n applicable := nt->nt.hasTags() and ForAll(nt.getTags(), _isSIMTTag) and Length(nt.params[1]) > 1,\n children := nt -> let(a_lengths := nt.params[1],\n a_exp := nt.params[2],\n tags := nt.getTags(),\n [ [TCompose(List(nt.params[1], i->TTensorI(DFT(i, a_exp), Product(nt.params[1])/i, AVec, APar))).withTags(tags) ]]),\n apply := (nt, C, cnt) -> C[1]\n )\n));\n\n\n\nNewRulesFor(MDPRDFT, rec(\n MDPRDFT_3D_SIMT := rec(\n info :=\"MDDFT(n_1,n_2,...,n_t) = (RC(MDDFT(n_1,n_2,...,n_{t-1}) x I(.))) (I(n_1*n_2*...*n_{t-1}) x PRDFT1(n_t))\",\n applicable := nt->nt.hasTags() and Length(nt.getTags()) = 2 and ForAll(nt.getTags(), _isSIMTTag) and Length(nt.a_lengths()) = 3,\n # Generally, children is list of ordered lists of all possible children.\n # 2 children, both with same parameter a_exp():\n # [1] MDDFT on all but last dimension;\n # [2] PRDFT1 on last dimension, the fastest varying dimension.\n children := nt -> let(a_lengths := nt.a_lengths(),\n a_exp := nt.a_exp(),\n tags := nt.getTags(),\n taglen := Length(tags),\n rtags1 := tags{[2]},\n [[ MDDFT(DropLast(a_lengths, 1), a_exp).withTags(rtags1),\n PRDFT1(Last(a_lengths), a_exp) ]]),\n\n # nonterminal, children, children non-terminals\n # NOT YET CORRECT\n apply := (nt, C, cnt) -> let(a_lengths := nt.a_lengths(),\n Clast := C[2],\n Crest := C[1],\n Nlastcomplex := Clast.dims()[1]/2,\n Nrest := DropLast(a_lengths, 1),\n Nallbutlast := Product(Nrest),\n # Apply Clast on last dimension,\n # then Crest on all dimensions but last.\n RC(SIMTTensor(_toSIMTDim(nt.getTags(){[1]}, Nlastcomplex), Crest, I(Nlastcomplex))) *\n SIMTTensor(_toSIMTDim(nt.getTags(){[1]}, Nrest[1]), I(Nrest[1]), \n SIMTTensor(_toSIMTDim(nt.getTags(){[2]}, Nrest[2]), I(Nrest[2]),\n Clast)))\n ),\n MDPRDFT_tSPL_RowCol_SIMT := rec(\n info :=\"MDDFT(n_1,n_2,...,n_t) = (RC(MDDFT(n_1,n_2,...,n_{t-1}) x I(.))) (I(n_1*n_2*...*n_{t-1}) x PRDFT1(n_t))\",\n applicable := nt->nt.hasTags() and ForAll(nt.getTags(), _isSIMTTag) and Length(nt.params[1]) > 1,\n children := nt -> let(a_lengths := nt.params[1],\n a_exp := nt.params[2],\n tags := nt.getTags(),\n mddft := MDDFT(DropLast(a_lengths, 1), a_exp),\n prdft := PRDFT1(Last(a_lengths), a_exp),\n [[ TTensorI(mddft, prdft.dims()[1]/2, AVec, AVec).withTags(tags),\n FoldR(DropLast(a_lengths, 1), (a,b)->TTensorI(a, b, APar, APar), prdft).withTags(tags) ]]),\n apply := (nt, C, cnt) -> RC(C[1]) * C[2]\n ),\n MDPRDFT_tSPL_Pease_SIMT := rec(\n applicable := nt->nt.hasTags() and ForAll(nt.getTags(), _isSIMTTag) and Length(nt.params[1]) > 1,\n children := nt -> let(a_lengths := nt.params[1],\n a_exp := nt.params[2],\n tags := nt.getTags(),\n prdft := PRDFT1(Last(a_lengths), a_exp),\n rcdim := Rows(prdft),\n [ [ TCompose(List(DropLast(nt.params[1], 1), i->TRC(TTensorI(DFT(i, a_exp), rcdim * Product(DropLast(nt.params[1], 1))/(2*i), AVec, APar)))::\n [ TGrp(TCompose([TL(rcdim * Product(DropLast(nt.params[1], 1)) / 2, rcdim / 2, 1, 2), \n TTensorI(PRDFT1(Last(a_lengths), a_exp), Product(DropLast(nt.params[1], 1)), APar, APar)])) ]).withTags(tags) ]] ),\n apply := (nt, C, cnt) -> C[1]\n )\n \n));\n\n\nNewRulesFor(IMDPRDFT, rec(\n IMDPRDFT_3D_SIMT := rec(\n info :=\"IMDDFT(n_1,n_2,...,n_t) = (RC(IMDDFT(n_1,n_2,...,n_{t-1}) x I(.))) (I(n_1*n_2*...*n_{t-1}) x PRDFT1(-n_t))\",\n applicable := nt->nt.hasTags() and Length(nt.getTags()) = 2 and ForAll(nt.getTags(), _isSIMTTag) and Length(nt.a_lengths()) = 3,\n # Generally, children is list of ordered lists of all possible children.\n # 2 children, both with same parameter a_exp():\n # [1] IMDDFT on all but last dimension;\n # [2] IPRDFT1 on last dimension, the fastest varying dimension.\n children := nt -> let(a_lengths := nt.a_lengths(),\n a_exp := nt.a_exp(),\n tags := nt.getTags(),\n taglen := Length(tags),\n rtags1 := tags{[2]},\n [[ MDDFT(DropLast(a_lengths, 1), a_exp).withTags(rtags1),\n IPRDFT1(Last(a_lengths), a_exp) ]]),\n\n # nonterminal, children, children non-terminals\n # NOT YET CORRECT\n apply := (nt, C, cnt) -> let(a_lengths := nt.a_lengths(),\n Clast := C[2],\n Crest := C[1],\n Nlastcomplex := Clast.dims()[2]/2,\n Nrest := DropLast(a_lengths, 1),\n Nallbutlast := Product(Nrest),\n # Apply Crest on all dimensions but last,\n # then Clast on last dimension.\n SIMTTensor(_toSIMTDim(nt.getTags(){[1]}, Nrest[1]), I(Nrest[1]), \n SIMTTensor(_toSIMTDim(nt.getTags(){[2]}, Nrest[2]), I(Nrest[2]), \n Clast)) *\n RC(SIMTTensor(_toSIMTDim(nt.getTags(){[1]}, Nlastcomplex), Crest, I(Nlastcomplex))))\n ),\n IMDPRDFT_tSPL_RowCol_SIMT := rec(\n info :=\"IMDDFT(n_1,n_2,...,n_t) = (RC(IMDDFT(n_1,n_2,...,n_{t-1}) x I(.))) (I(n_1*n_2*...*n_{t-1}) x PRDFT1(-n_t))\",\n applicable := nt->nt.hasTags() and ForAll(nt.getTags(), _isSIMTTag) and Length(nt.params[1]) > 1,\n children := nt -> let(a_lengths := nt.params[1],\n a_exp := nt.params[2],\n tags := nt.getTags(),\n mddft := MDDFT(DropLast(a_lengths, 1), a_exp),\n iprdft := IPRDFT1(Last(a_lengths), a_exp),\n [[ FoldR(DropLast(a_lengths, 1), (a,b)->TTensorI(a, b, APar, APar), iprdft).withTags(tags),\n TTensorI(mddft, iprdft.dims()[2]/2, AVec, AVec).withTags(tags) ]]),\n apply := (nt, C, cnt) -> C[1] * RC(C[2])\n ),\n IMDPRDFT_tSPL_Pease_SIMT := rec(\n applicable := nt->nt.hasTags() and ForAll(nt.getTags(), _isSIMTTag) and Length(nt.params[1]) > 1,\n children := nt -> let(a_lengths := nt.params[1],\n a_exp := nt.params[2],\n tags := nt.getTags(),\n iprdft := IPRDFT1(Last(a_lengths), a_exp),\n rdim := Rows(iprdft),\n cdim := Cols(iprdft),\n [ [ TCompose([ TGrp(TCompose([\n TTensorI(IPRDFT1(Last(a_lengths), a_exp), Product(DropLast(a_lengths, 1)), APar, APar),\n TL(cdim * Product(DropLast(a_lengths, 1)) / 2, Product(DropLast(a_lengths, 1)), 1, 2), \n ])) ] ::\n Reversed(List(DropLast(a_lengths, 1), i->TRC(TTensorI(DFT(i, a_exp), cdim * Product(DropLast(a_lengths, 1))/(2*i), APar, AVec))))\n ).withTags(tags) ]] ),\n apply := (nt, C, cnt) -> C[1]\n )\n \n));\n\n\nNewRulesFor(TRC, rec(\n TRC_SIMT := rec(\n forTransposition := false,\n applicable := nt->nt.hasTags() and _isSIMTTag(nt.firstTag()), \n children := nt -> [[ nt.params[1].withTags(nt.getTags()) ]],\n apply := (nt, c, cnt) -> RC(c[1])\n )\n));\n\n\nNewRulesFor(TL, rec(\n# TL(N,n,l,r,[]) -> I_l x L(N,n) x I_r\n L_SIMT := rec(\n forTransposition := false,\n applicable := nt->nt.hasTags() and _isSIMTTag(nt.firstTag()), \n apply := (nt, c, cnt) -> let(\n c1 := When(nt.params[3]=1, [], [I(nt.params[3])]),\n c2 := When(nt.params[4]=1, [], [I(nt.params[4])]),\n Tensor(Concat(c1, [ L(nt.params[1], nt.params[2]) ], c2))\n )\n )\n));\n\n\nNewRulesFor(TTensorInd, rec(\n# base cases\n# I x A\n TTensorInd_SIMT := rec(\n info := \"IxA base\",\n forTransposition := false,\n applicable := nt -> nt.hasTags() and _isSIMTTag(nt.firstTag()) and IsParPar(nt.params),\n children := nt -> [[ nt.params[1].withTags(Drop(nt.getTags(), 1)), InfoNt(nt.params[2]) ]],\n apply := (nt, c, cnt) -> SIMTIDirSum(_toSIMTDim(nt.getTags(), cnt[2].params[1].range), cnt[2].params[1], cnt[2].params[1].range, c[1])\n )\n));\n\n\nNewRulesFor(TTensorI, rec(\n# base cases\n# I x A\n IxA_SIMT := rec(\n info := \"IxA base\",\n forTransposition := false,\n applicable := nt -> nt.hasTags() and _isSIMTTag(nt.firstTag()) and IsParPar(nt.params) and nt.params[2] > 1,\n children := nt -> [[ nt.params[1].withTags(Drop(nt.getTags(), 1)) ]],\n apply := (nt, c, cnt) -> #When(nt.params[2] > 1,\n SIMTTensor(_toSIMTDim(nt.getTags(), nt.params[2]), I(nt.params[2]), c[1])#,\n #c[1])\n ),\n# A x I\n AxI_SIMT := rec(\n info := \"AxI base\",\n forTransposition := false,\n applicable := nt -> nt.hasTags() and _isSIMTTag(nt.firstTag()) and IsVecVec(nt.params) and nt.params[2] > 1,\n children := nt -> [[ nt.params[1].withTags(Drop(nt.getTags(), 1)) ]],\n apply := (nt, c, cnt) -> #When(nt.params[2] > 1,\n SIMTTensor(_toSIMTDim(nt.getTags(), nt.params[2]), c[1], I(nt.params[2]))#,\n #c[1])\n ),\n# A x I\n trivialLoop := rec(\n info := \"AxI base\",\n forTransposition := false,\n applicable := nt -> nt.hasTags() and _isSIMTTag(nt.firstTag()) and nt.params[2] = 1,\n children := nt -> [[ nt.params[1].withTags(DropLast(nt.getTags(), 1)) ]],\n apply := (nt, c, cnt) -> c[1]\n ),\n# L (I x A)\n L_IxA_SIMT := rec(\n forTransposition := false,\n \n # these config parameters need to be moved into the opts...\n mem := 1024*96,\n mem_per_pt := 2*8*2,\n max_threads := 2048,\n max_kernel := 18 * 18,\n _peelof := (self,n,m) >> Maximum(Filtered(self.mem_per_pt * Filtered(n*DivisorsInt(m), e-> e<self.max_threads), \n f -> f < When(n >= self.max_kernel, self.mem/2, self.mem)))/(self.mem_per_pt*n),\n \n applicable := nt -> nt.hasTags() and _isSIMTTag(nt.firstTag()) and IsVecPar(nt.params) and nt.params[2] > 1,\n children := (self, nt) >> let(n := Rows(nt.params[1]), m:= nt.params[2], peelof := self._peelof(n,m), remainder := m/peelof,\n [[ TCompose([TL(Rows(nt)/peelof, n, 1, peelof), \n TTensorI(\n TCompose([TL(Rows(nt.params[1]) * peelof, Rows(nt.params[1])), TTensorI(nt.params[1], peelof, APar, APar)]),\n remainder, APar, APar)]).withTags(nt.getTags()) ]]),\n apply := (nt, c, cnt) -> c[1]\n ),\n# (I x A) L\n IxA_L_SIMT := rec(\n forTransposition := false,\n \n # these config parameters need to be moved into the opts...\n mem := 1024*96,\n mem_per_pt := 2*8*2,\n max_threads := 2048,\n max_kernel := 18 * 18,\n _peelof := (self,n,m) >> Maximum(Filtered(self.mem_per_pt * Filtered(n*DivisorsInt(m), e-> e<self.max_threads), \n f -> f < When(n >= self.max_kernel, self.mem/2, self.mem)))/(self.mem_per_pt*n),\n \n applicable := nt -> nt.hasTags() and _isSIMTTag(nt.firstTag()) and IsParVec(nt.params) and nt.params[2] > 1,\n children := (self, nt) >> let(n := Rows(nt.params[1]), m:= nt.params[2], peelof := self._peelof(n,m), remainder := m/peelof,\n [[ TCompose([\n TTensorI(\n TCompose([TTensorI(nt.params[1], peelof, APar, APar), TL(Rows(nt.params[1]) * peelof, peelof)]), remainder, APar, APar),\n TL(Rows(nt)/peelof, (Rows(nt)/peelof)/n, 1, peelof), \n ]).withTags(nt.getTags()) ]]),\n apply := (nt, c, cnt) -> c[1]\n )\n \n));\n\n\n\n", "meta": {"hexsha": "67b3096db6437ea96ce3ef1b4f97e8716cf0ed96", "size": 16220, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "platforms/cuda/breakdown.gi", "max_stars_repo_name": "mikefranusich/spiral-package-fftx", "max_stars_repo_head_hexsha": "a1a355f3764aade9665145aa63c2318201421543", "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": "platforms/cuda/breakdown.gi", "max_issues_repo_name": "mikefranusich/spiral-package-fftx", "max_issues_repo_head_hexsha": "a1a355f3764aade9665145aa63c2318201421543", "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": "platforms/cuda/breakdown.gi", "max_forks_repo_name": "mikefranusich/spiral-package-fftx", "max_forks_repo_head_hexsha": "a1a355f3764aade9665145aa63c2318201421543", "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": 52.154340836, "max_line_length": 172, "alphanum_fraction": 0.4799013564, "num_tokens": 4664, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228625116081, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.3593336183499944}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nClass(Drawer, rec(\n __call__ := meth(self,n)\n return WithBases(self,rec(n:=n,instances:=[]));\n end,\n \n add := meth(self,instance)\n if (not IsList(instance)) or (Length(instance)<>self.n) then\n Error(\"Trying to add a non regular instance\");\n fi;\n Add(self.instances,instance);\n end,\n\n getNormalTransfo := meth(self)\n local result,l,m,s;\n result:=[];\n for l in Transposed(self.instances) do\n m:=Mean(l);\n s:=Try(StdDev(l));\n if not s[1] then s:=0; else s:=s[2]; fi;\n Add(result,[m,s]);\n od;\n return result;\n end,\n\n normalize := meth(self,transfo)\n local t,n,l;\n t:=[];\n n:=1;\n for l in Transposed(self.instances) do\n if (transfo[n][2]<>0) then\n Add(t,List(l,x->(x-transfo[n][1])/transfo[n][2]));\n else\n Add(t,List(l,x->(x-transfo[n][1])));\n fi;\n n:=n+1;\n od;\n self.instances:=Transposed(t);\n end,\n\n checkCredibility := meth(self,testing, transfo) \n local j;\n for j in [1..Length(self.instances)] do\n for i in [1..Length(testing.instances[1])] do\n if transfo[i][2]=0 and transfo[i][1]<>testing.instances[j][i] then\n self.instances[j]:=[2^16,1,2^32];\n fi;\n od;\n od;\n end,\n\n denormalize := meth(self,transfo)\n local t,n,l;\n t:=[];\n n:=1;\n for l in Transposed(self.instances) do\n if (transfo[n][2]<>0) then\n Add(t,List(l,x->x*transfo[n][2] + transfo[n][1]));\n else\n Add(t,List(l,x->x + transfo[n][1]));\n fi;\n n:=n+1;\n od;\n self.instances:=Transposed(t);\n end,\n\n print := meth(self,filename)\n local l,a;\n PrintTo(filename,\"\");\n for l in self.instances do\n for a in l do\n AppendTo(filename,a,\" \");\n od;\n AppendTo(filename,\"\\n\");\n od;\n end,\n\n));\n\nClass(GaussianPredictor, rec(\n\n __call__ := meth(self)\n return WithBases(self);\n end,\n\n predict := meth(self, hash, objid, testCases, tags)\n local n,a,i,transfo,training,testing,predict,index,sol,t;\n n:=DimensionsMat(testCases)[2];\n training:=Drawer(n+1);\n for a in Flat(hash.entries) do\n if ObjId(a.key)=objid and a.key.params[n+1]=tags and Length(a.data)>0 and IsBound(a.data[1].mflopslibgen) then\n training.add(Concat(a.key.params{[1..n]},\n [a.data[1].mflopslibgen]));\n fi;\n od;\n\n transfo:=training.getNormalTransfo();\n a:=Copy(training);\n a.normalize(transfo);\n a.print(\"trainingset\");\n\n testing:=Drawer(n);\n testing.instances:=testCases;\n a:=Copy(testing);\n a.normalize(DropLast(transfo,1));\n a.print(\"testingset\");\n\n IntExec(\"rm -f rlog.gp\");\n IntExec(Concat(\"gp-spec rlog.gp \",String(n),\n \" 1 10 / 0.05:0.4 0.05:0.4\"));\n IntExec(\"model-spec rlog.gp real 0.05:0.4\");\n IntExec(Concat(\"data-spec rlog.gp \",String(n),\" 1 / trainingset .\"));\n IntExec(\"gp-gen rlog.gp fix 0.5 0.1\");\n IntExec(\"mc-spec rlog.gp heatbath hybrid 18:3 0.5\");\n IntExec(\"gp-mc rlog.gp 100\");\n IntExec(\"gp-pred nqb rlog.gp 51: / testingset >myoutput\");\n IntExec(\"awk 'BEGIN {print \\\"[\\\"} {print \\\"[\\\",$1,\\\", \\\",$2,\\\", \\\",$3,\\\"], \\\"} END{print\\\"];\\\"}' myoutput >myrealoutput\");\n\n a:=ReadVal(\"myrealoutput\");\n\n predict:=Drawer(3);\n predict.instances:=a;\n predict.denormalize(Replicate(3,Last(transfo)));\n\n for a in [1..Length(testing.instances)] do\n t:=ApplyFunc(objid,Concat(testing.instances[a],[tags]));\n i:=HashLookup(hash,t);\n if (i<>false) and IsBound(i[1].mflopslibgen) then\n predict.instances[a]:=Replicate(3,i[1].mflopslibgen);\n fi;\n od;\n\n return predict.instances;\n end,\n\n predict2 := meth(self, hash, objid, testCases, tags)\n local n,a,i,transfo,training,testing,predict,index,sol,t,tmp;\n n:=DimensionsMat(testCases)[2];\n training:=Drawer(n+1);\n for a in Flat(hash.entries) do\n if ObjId(a.key)=objid and a.key.params[n+1]=tags and Length(a.data)>0 and \n IsBound(a.data[1].measured) then\n training.add(Concat(a.key.params{[1..n]},\n [_compute_mflops(When(IsBound(a.key.normalizedArithCost), \n a.key.normalizedArithCost(), 0), a.data[1].measured)]));\n fi;\n od;\n Print(\"Estimating \",Length(testCases),\" points (with \",Length(training.instances),\"): \", \n objid,\" (\",tags,\")\\n\");\n\n if Length(training.instances)=0 then\n return Replicate(Length(testCases),[2^16,0,2^32]);\n fi;\n transfo:=training.getNormalTransfo();\n a:=Copy(training);\n a.normalize(transfo);\n a.print(\"trainingset\");\n\n testing:=Drawer(n);\n testing.instances:=testCases;\n a:=Copy(testing);\n a.normalize(DropLast(transfo,1));\n a.print(\"testingset\");\n\n IntExec(\"rm -f rlog.gp\");\n IntExec(Concat(\"gp-spec rlog.gp \",String(n),\n \" 1 10 / 0.05:0.4 0.05:0.4\"));\n IntExec(\"model-spec rlog.gp real 0.05:0.4\");\n IntExec(Concat(\"data-spec rlog.gp \",String(n),\" 1 / trainingset . 2>/dev/null\"));\n IntExec(\"gp-gen rlog.gp fix 0.5 0.1\");\n IntExec(\"mc-spec rlog.gp heatbath hybrid 18:3 0.5\");\n IntExec(\"gp-mc rlog.gp 100\");\n IntExec(\"gp-pred nqb rlog.gp 51: / testingset >myoutput\");\n IntExec(\"awk 'BEGIN {print \\\"[\\\"} {print \\\"[\\\",$1,\\\", \\\",$2,\\\", \\\",$3,\\\"], \\\"} END{print\\\"];\\\"}' myoutput >myrealoutput\");\n\n a:=ReadVal(\"myrealoutput\");\n\n predict:=Drawer(3);\n predict.instances:=a;\n predict.denormalize(Replicate(3,Last(transfo)));\n\n predict.checkCredibility(testing, transfo);\n\n for a in [1..Length(testing.instances)] do\n t:=ApplyFunc(objid,Concat(testing.instances[a],[tags]));\n i:=HashLookup(hash,t);\n if (i<>false) and IsBound(i[1].measured) then\n predict.instances[a]:=Replicate(3,i[1].measured);\n else\n predict.instances[a]:=List(predict.instances[a],x->\n _compute_cycles_from_mflops(When(IsBound(t.normalizedArithCost),\n t.normalizedArithCost(), 0),x));\n #invert max and min because min flops is max runtime\n tmp:=predict.instances[a][2];\n predict.instances[a][2]:=predict.instances[a][3];\n predict.instances[a][3]:=When(tmp<0,2^64,tmp);\n fi;\n od;\n\n return predict.instances;\n end,\n\n \n countTraining:=meth(self, dpbench, objid, n, tags)\n local r,hash,a;\n hash:=dpbench.exp.bases.hashTable;\n r:=0;\n for a in Flat(hash.entries) do\n if ObjId(a.key)=objid and a.key.params[n+1]=tags and Length(a.data)>0 then\n r:=r+1;\n fi;\n od; \n return r;\n end,\n\n findMax:=meth(self, base_bench, libgen_bench, base_objid, libgen_objid, testing, tags,flopsfactor)\n local over,sol,secured,estimate,a,s, unscaledsol;\n base_bench.verbosity:=0;\n if (g.countTraining(base_bench,base_objid,DimensionsMat(testing)[2],tags)<2) then\n base_bench.exp.bases.benchTransforms:=[ApplyFunc(base_objid,Concat(First(testing,x->true),[tags])),[ApplyFunc(base_objid,Concat(Last(testing),[tags]))]];\n base_bench.resumeAll();\n fi;\n\n over:=false;\n while(not over) do\n unscaledsol:=self.predict(base_bench.exp.bases.hashTable,base_objid,testing,tags);\n sol:=List([1..Length(testing)],x->List(unscaledsol[x],y->flopsfactor(testing[x],y)));\n secured:=[testing[1],sol[1]];\n estimate:=[testing[1],sol[1]];\n for a in [1..Length(testing)] do\n s:=[testing[a],sol[a]];\n if (s[2][1]=s[2][2] and s[2][1]=s[2][3] and s[2][1]>secured[2][1]) then\n secured:=s;\n fi;\n if (s[2][3]>estimate[2][3]) then\n estimate:=s;\n fi;\n od;\n\n Print(\"Current Maximum is \",Red(StringDouble(\"%.3f\",secured[2][1]/1000)),\" [Gf/s] achieved by \",ApplyFunc(base_objid,Concat(secured[1],[tags])),\"\\n\" );\n if (estimate[2][3]<=secured[2][1]) then\n over:=true;\n else\n Print(\"Best Hope is \",ApplyFunc(base_objid, Concat(estimate[1],[tags])),\" with \",StringDouble(\"%.3f\",estimate[2][1]/1000),\" [Gf/s] (\",StringDouble(\"%.3f\",estimate[2][2]/1000),\" < x < \",StringDouble(\"%.3f\",estimate[2][3]/1000),\")\\n\" );\n base_bench.exp.bases.benchTransforms:=[ApplyFunc(base_objid,Concat(estimate[1],[tags]))];\n base_bench.resumeAll();\n libgen_bench.runExhaust([ApplyFunc(libgen_objid,Concat(estimate[1]*2,[ApplyFunc(base_objid,Concat(estimate[1],[tags]))]))]);\n base_bench.exp.bases.benchTransforms:=[];\n base_bench.resumeAll(); #Fire Callbacks\n fi;\n od;\n return ApplyFunc(base_objid,Concat(secured[1],[tags]));\n end,\n));\n", "meta": {"hexsha": "c1ea1b6b39a4117452f041d7085abe05a1f50178", "size": 9276, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/nontransforms/ol/ML.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/nontransforms/ol/ML.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/nontransforms/ol/ML.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.8146718147, "max_line_length": 249, "alphanum_fraction": 0.5515308323, "num_tokens": 2634, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.5039061705290805, "lm_q1q2_score": 0.3588981924874103}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nImport(approx);\n\nSubMat := (mat, ri, ci, rsize, csize) -> let(\n d := DimensionsMat(mat),\n nrows := d[1],\n ncols := d[2], \n List(mat{[ri .. Min2(ri+rsize-1, nrows)]}, \n\trow -> row{[ci .. Min2(ci+csize-1, ncols)]})\n);\n\nGetBlocksMat := (mat, rblk, cblk) -> Checked(IsPosInt(rblk), IsPosInt(cblk), let(\n d := DimensionsMat(mat),\n nrows := d[1],\n ncols := d[2], \n List([0 .. CeilingRat(nrows/rblk)-1], rb -> \n\tList([0 .. CeilingRat(ncols/cblk)-1], cb -> \n\t SubMat(mat, 1+rb*rblk, 1+cb*cblk, rblk, cblk)))\n));\n\n# Cyclic diagonal vectorization:\nVectorizedZMatSPL := ( isa, spl ) -> Checked( Rows(spl)=Cols(spl) and isa.v = Rows(spl), let(\n mat := Cond(IsMat(spl), spl, MatSPL(spl)),\n VBlk( [List( [0 .. isa.v-1], j -> isa.t.value(\n List( [0 .. isa.v-1], i -> mat[1 + i][1 + (i-j) mod isa.v])\n ))], \n isa.v)\n));\n\n# Straight diagonal vectorization:\nVectorizedDMatSPL := ( isa, spl ) -> Checked(Rows(spl) <= isa.v, let(\n mat := Cond(IsMat(spl), spl, MatSPL(spl)),\n r := Rows(mat),\n c := Cols(mat),\n padd := (offs, l) -> Replicate(offs, 0) :: l :: Replicate(isa.v - offs - Length(l), 0),\n VBlk( [ List( [0 .. r-2], i -> isa.t.value(padd(r-i-1, List( [0 .. _unwrap(min(i,c-1))], j -> mat[r-i+j][j+1] )))) ::\n List( [0 .. c-1], i -> isa.t.value(padd( 0, List( [0 .. When(i+r<=c, r-1, c-i-1)], j -> mat[j+1][i+j+1] )))) ], \n isa.v)\n));\n\n# Zero pad both dimensions:\nZeroPadMat := (mat, v) -> let(\n r := Rows(mat),\n c := Cols(mat),\n dr := CeilingRat(r/v)*v - r,\n dc := CeilingRat(c/v)*v - c,\n List( mat, row -> row :: Replicate(dc, 0) ) :: Replicate(dr, Replicate(c+dc, 0))\n);\n\n# Zero pad matrix by adding zero rows:\nZeroPadMatV := (mat, v) -> let(\n r := Rows(mat),\n c := Cols(mat),\n dr := CeilingRat(r/v)*v - r,\n mat :: Replicate(dr, Replicate(c, 0))\n);\n\nNewRulesFor(TMat, rec(\n TMat_Base := rec(\n\tapplicable := (self, t) >> not t.hasTags(), \n apply := (self, t, C, Nonterms) >> Mat(t.params[1])\n ),\n\n TMat_Vec := rec(\n\tforTransposition := false,\n\tmaxSize := 128,\n\tapplicable := (self, t) >> t.hasTags() and t.isTag(1, AVecReg) and \n\t (self.maxSize<0 or (Rows(t) <= self.maxSize and Cols(t) <= self.maxSize)),\n\n apply := (self, t, C, Nonterms) >> let(\n\t isa := t.getTag(AVecReg, 1).isa,\n\t VectorizedMatSPL(isa, t)\n )\n ),\n\n # vectorization of square matrix with dimensions equal to vector width using cyclic shifts\n TMat_VecZ := rec(\n forTransposition := false,\n\tapplicable := (self, t) >> t.hasTags() and t.isTag(1, AVecReg) and \n\t Rows(t) = Cols(t) and Rows(t)=t.getTag(AVecReg).v,\n\n apply := (self, t, C, Nonterms) >> let( isa := t.getTag(AVecReg).isa, i := Ind(isa.v),\n\t VectorizedZMatSPL(isa, t)\n\t * ISum(i, VScat(fBase(isa.v, i), isa.v) * VPerm(Z(isa.v,-i), isa.rotate_left(i), isa.v, 1))\n\t * VGath(fId(1), isa.v)\n )\n ),\n\n # Vectorization of non square matrix by diagonals\n TMat_VecD := rec(\n forTransposition := false,\n maxSize := 256,\n\tapplicable := (self, t) >> t.hasTags() and t.isTag(1, AVecReg) and \n\t Rows(t) <= t.getTag(AVecReg).v and (self.maxSize<0 or Cols(t) <= self.maxSize),\n\n apply := (self, t, C, Nonterms) >> let( \n isa := t.getTag(AVecReg).isa,\n v := isa.v,\n r := Rows(t),\n c := Cols(t),\n ru := _roundup(c + v-1, v),\n i := Ind(r-1),\n j := Ind(c),\n VScat_pc( r, r, 0, v) *\n VectorizedDMatSPL(isa, t) *\n SUM(\n When(r>1, \n [ ISum(i, \n VScat(fBase(r+c-1, i), v) * VPerm(Z(v,v-r+i+1), isa.rotate_left(r-i-1), v, 1) \n * VGath_pc(c, min(c, v), 0, v))], []) ::\n [ISum(j, \n VScat(fBase(r+c-1, j+r-1), v) \n * VGath_pc(c, min(v, c-j), j, v)).unrolledChildren()]\n )\n )\n ),\n\n TMat_UnrolledBlkH := rec(\n forTransposition := false,\n\tapplicable := (self, t) >> t.hasTags() and t.isTag(1, AVecReg) and \n\t Rows(t) > t.getTag(AVecReg).v,\n\n freedoms := (self, t) >> [[t.getTag(AVecReg).v]],\n\n\tchild := (self, t, fr) >> Flat(MapMat(GetBlocksMat(ZeroPadMatV(t.params[1], t.getTag(AVecReg).v), fr[1], Cols(t)), e -> TMat(e).withTags(t.getTags()))),\n\n apply := (self, t, C, Nonterms) >> let( \n isa := t.getTag(AVecReg).isa,\n v := isa.v,\n c := Cols(t),\n r := Rows(t),\n VScat_pc(r, r, 0, v) * SUM( \n List( [1..Length(C)], i -> VScat(fAdd(Length(C), 1, i-1), v) * C[i] ))\n )\n ),\n\n TMat_UnrolledBlkV := rec(\n forTransposition := false,\n\tapplicable := (self, t) >> t.hasTags() and t.isTag(1, AVecReg) and \n\t Cols(t) > t.getTag(AVecReg).v,\n\n freedoms := (self, t) >> [[1]],\n\n\tchild := (self, t, fr) >> let(\n\t v := t.getTag(AVecReg).v,\n\t m := ZeroPadMat(t.params[1], v),\n\t Flat(MapMat(GetBlocksMat(m, Rows(m), v), e -> TMat(e).withTags(t.getTags())))\n\t),\n\n apply := (self, t, C, Nonterms) >> let( \n isa := t.getTag(AVecReg).isa,\n v := isa.v,\n c := Cols(t),\n r := Rows(t),\n h := CeilingRat(r/v),\n VScat_pc(r, r, 0, v) * \n VBlk( MapMat(TensorProductMat( [Replicate( CeilingRat(c/v), 1)], IdentityMat(h) ), e -> When(e=0, isa.t.zero(), isa.t.one())), v)*\n SUM( \n List( [1..Length(C)], i -> VScat(fAdd(Length(C)*h, h, (i-1)*h), v) * C[i] * VGath(fAdd(Length(C), 1, i-1), v) ))*\n #HStack(C) *\n VGath_pc(c, c, 0, v)\n )\n ),\n\n TMat_Blk := rec(\n \tforTransposition := false,\n\n \tapplicable := (self, t) >> t.hasTags() and t.isTag(1, AVecReg) \n\t and (Rows(t) > self.rblk or Cols(t) > self.cblk),\n\n\t# Matrix partition \n\t# N - normal block (rblk x cblk), T - tall blocks, S - short blocks, C - corner bock\n\t#\n\t# N ... N T\n\t# . \\ . T\n\t# . \\ . T\n\t# N ... N T\n # S S S S S\n\t#\n\t_NTSC_Split := meth(self, mat, rblk, cblk) \n\t local r, c, nr, nc, N, T, S, C;\n\t [ r, c] := Dimensions(mat);\n\t [nr, nc] := [r - r mod rblk, c - c mod cblk];\n\t N := mat{[1..nr]}{[1..nc]};\n\t T := mat{[1..nr]}{[nc+1..c]};\n\t S := mat{[nr+1..r]}{[1..nc]};\n\t C := mat{[nr+1..r]}{[nc+1..c]};\n\t return [N, T, S, C];\n\tend,\n\t \n apply := meth(self, t, C, Nonterms) \n\t local isa, N, T, S, C, blks, dat, dvar, i, j;\n\n \t isa := t.getTag(AVecReg, 1).isa;\n\n\t [N, T, S, C] := self._NTSC_Split(t.params[1], self.rblk, self.cblk);\n\t blks := rec(\n\t\tN := MapMat(GetBlocksMat(N, self.rblk, self.cblk), x -> VectorizedMatSPL(isa, x)),\n\t\tT := MapMat(GetBlocksMat(T, self.rblk, self.cblk), x -> VectorizedMatSPL(isa, x)),\n\t\tS := MapMat(GetBlocksMat(S, self.rblk, self.cblk), x -> VectorizedMatSPL(isa, x))\n\t );\n\t dat := rec(\n\t\tN := V(List(Collect(blks.N, VBlk), x->x.element)),\n\t\tT := V(List(Collect(blks.T, VBlk), x->x.element)),\n\t\tS := V(List(Collect(blks.S, VBlk), x->x.element))\n\t );\n\t dvar := rec(\n\t\tN := var.fresh_t(\"DN\", dat.N.t),\n\t\tT := var.fresh_t(\"DT\", dat.T.t),\n\t\tS := var.fresh_t(\"DS\", dat.S.t)\n\t );\n\n\t [i, j] := [Ind(Rows(blks.N)), Ind(Cols(blks.N))];\n\n\t return\n\t Data(dvar.N, dat.N, \n\t Data(dvar.T, dat.T, \n\t Data(dvar.S, dat.S, \n\t\tVStack(\n\t\t IterVStack(i, \n\t\t\tHStack(\n\t\t\t IterHStack(j, \n\t\t\t\tBB(SubstTopDownNR(blks.N[1][1], VBlk, x->VBlk(nth(dvar.N, i*Cols(blks.N)+j), isa.v)))\n\t\t\t ),\n\t\t\t BB(SubstTopDownNR(blks.T[1][1], VBlk, x->VBlk(nth(dvar.T, i), isa.v)))\n\t\t\t)\n\t\t ),\n\t\t HStack(\n\t\t\tIterHStack(j, \n\t\t\t BB(SubstTopDownNR(blks.S[1][1], VBlk, x->VBlk(nth(dvar.S, j), isa.v)))\n\t\t\t),\n\t\t\tVectorizedMatSPL(isa, C)\n\t\t )\n\t\t)\n\t )));\n\tend\n )\n));\n\n", "meta": {"hexsha": "d4497f8e95d4994cec252abb05d9ca58a1c9c302", "size": 7912, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/vector/breakdown/tmat.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/tmat.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/tmat.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.4262295082, "max_line_length": 153, "alphanum_fraction": 0.497851365, "num_tokens": 2802, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.49218813572079556, "lm_q1q2_score": 0.358300873238078}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# Symbolic Scalars\n# ================\n\n#F Scalars\n#F =======\n#F\n\n#F The class \"Scalar\" represents a symbolic scalar, that is not\n#F evaluated. The main motivation is to\n#F deal with trigonometric expressions (e.g., cosines) efficiently.\n#F The usual numbers provided by gap will be called numbers.\n#F\n#F A Scalar is a GAP record with the following fields mandatory\n#F for all types\n#F\n#F isScalar (=true)\n#F operations (=ScalarOps)\n#F domain (=Scalars)\n#F val\n#F\n#F where val is the actual symbolic expression represented as the delayed\n#F evaluation object constructed with Delay() function.\n#F\n\n#F CanBeScalar( <obj> )\n#F This functions returns true if an object can become a Scalar record.\n#F Integers and rationals can't become a Scalar record, although they\n#F are considered to be part of Scalars field. This implies that this\n#F function is *misleading*. (NOTE: function def + description)\nCanBeScalar := obj ->\n IsFloat(obj) or IsComplex(obj) or obj in FieldElements;\n\nDeclare(ScalarsOps, IsScalar);\n\n_abs := x->Cond(IsComplex(x), AbsComplex(x),\n IsCyc(x), AbsComplex(Complex(x)),\n AbsFloat(x));\n\ninf_norm := mat ->\n Maximum(List(mat, r -> Sum(r, x -> Cond(IsExp(x), _abs(x.ev()),\n IsValue(x), _abs(x.v), _abs(x)))));\nevmat := mat ->\n List(mat, r -> List(r, x -> Cond(IsExp(x), x.ev(), IsValue(x), x.v, x)));\nabsmat := mat ->\n List(mat, r -> List(r, x -> Cond(IsExp(x), _abs(x.ev()), IsValue(x), _abs(x.v), _abs(x))));\nremat := mat -> MapMat(mat, x->ReComplex(Complex(x)));\n\ncol := (mat, c) -> List(mat, row->[row[c]]);\n\nInfinityNormMat := inf_norm;\n\nRealMatComplexMat := function(mat)\n local res, row, row1, row2, r, i, e, ee;\n res := []; # list of rows\n for row in mat do\n row1 := []; row2 := [];\n for e in row do\n ee := When(IsExp(e), e.eval(), e); r := re(ee).eval(); i := im(ee).eval();\n Append(row1, [r, -i]);\n Append(row2, [Copy(i), Copy(r)]);\n od;\n Add(res, row1); Add(res, row2);\n od;\n return res;\nend;\n\nRealVMatComplexVMat := function(vmat)\n local res, row, row1, row2, r, i, e, ee, el;\n res := []; # list of rows\n for row in vmat do\n row1 := []; row2 := [];\n for el in row do\n if IsRec(el) and IsBound(el.t) and IsArrayT(el.t) then el := el.v; fi;\n if IsList(el) then\n r := [];\n i := [];\n for e in el do\n ee := When(IsExp(e), e.eval(), e);\n Append(r, [re(ee).eval()]);\n Append(i, [im(ee).eval()]);\n od;\n else\n Constraint((IsExp(el) or IsValue(el)) and IsVecT(el.t) and el.t.t<>TComplex);\n r := el;\n i := el.t.value(0);\n fi;\n Append(row1, [r, -i]);\n Append(row2, [Copy(i), Copy(r)]);\n od;\n Add(res, row1); Add(res, row2);\n od;\n return res;\nend;\n\nRCMat := RealMatComplexMat;\n\nRCMatCyc := function ( mat )\n local res, row, row1, row2, r, i, e, ee;\n res := [];\n for row in mat do\n row1 := []; row2 := [];\n for e in row do\n ee := When(IsExp(e), e.ev(), e);\n r := Re(ee); i := Im(ee);\n Append(row1, [ r, -i ]);\n Append(row2, [ i, r ]);\n od;\n Add(res, row1); Add(res, row2);\n od;\n return res;\nend;\n\ngetReIm := function(c)\n local r, i;\n if IsCyc(c) then c:=ComplexCyc(c); fi;\n if IsInt(c) or IsFloat (c) then r:=c; i:=0;\n else if IsComplex(c) then r:=ReComplex(c); i:=ImComplex(c);\n else Error(\"bad matrix entry type\");\n fi; fi;\n return [r,i];\nend;\n\n#############################################################################\n#V Scalars . . . . . . . . . . . . . . . . . . . . . . field of all scalars\n#V ScalarsOps . . . . . . . . . . . . . . operations record for the domain\n##\nClass(Scalars, rec(\n isDomain := true,\n isField := true,\n #generators := [ ]\n zero := V(0),\n one := V(1),\n size := \"infinity\",\n char := 0,\n field := 0,\n isFinite := false,\n));\n\nScalars.operations := Class(ScalarsOps, OpsOps, rec(\n \\in := ( x, Scalars ) -> IsScalar(x) or IsRat(x) or IsCyc(x) or CanBeScalar(x),\n Field := elms -> Scalars,\n DefaultField := elms ->Scalars\n));\n\n#F IsScalar( <obj> )\n#F tests whether <obj> is a scalar and returns true in the affirmative\n#F case. Else, false is returned.\n#F\nIsScalar := s -> IsRec(s) and (IsExp(s) or IsValue(s) or IsLoc(s));\n\n#F IsScalarOrNum( <obj> )\n#F\nIsScalarOrNum := x -> IsScalar(x) or CanBeScalar(x);\n\n#F Scalar( <d> )\n#F adds fields common to all scalars to a record to form a scalar\n#F from the delayed evaluation object <d>\n#F\nScalar := d -> When(not IsDelay(d) and IsList(d),\n List(d, Scalar),\n toExpArg(d));\n\n# Construction macro (allows to skip D())\nSS := UnevalArgs( x -> Scalar(x) );\n\n# we use lower case function names for optical convenience in SPLs\nnormPi := function(r)\n # move r into the interval [0,2)\n r := 2 * (r/2 - Int(r/2));\n if r < 0 then\n r := r + 2;\n fi;\n return r;\nend;\n\nExportBagSPL := x->x;\n\nTranslateGapFuncToSPL := rec(\n CosPi := cc -> Print(\"cos(\", ExportBagSPL(cc[2]), \"*pi)\"),\n SinPi := cc -> Print(\"sin(\", ExportBagSPL(cc[2]), \"*pi)\"),\n Sqrt := cc -> Print(\"sqrt(\", ExportBagSPL(cc[2]), \")\")\n);\n\nExportBagSPL := function(o)\n local t, cc;\n t := BagType(o);\n cc := Children(o);\n cc := cc{[2..Length(cc)]};\n\n Cond(t = T_PROD, Print(\"(\", ExportBagSPL(cc[1]), \" * \", ExportBagSPL(cc[2]), \")\"),\n t = T_QUO, Print(\"(\", ExportBagSPL(cc[1]), \" / \", ExportBagSPL(cc[2]), \")\"),\n t = T_SUM, Print(\"(\", ExportBagSPL(cc[1]), \" + \", ExportBagSPL(cc[2]), \")\"),\n t = T_DIFF, Print(\"(\", ExportBagSPL(cc[1]), \" - \", ExportBagSPL(cc[2]), \")\"),\n t = T_FUNCCALL, When(BagType(cc[1]) = T_VAR,\n let(f := NameOf(cc[1]),\n\t\t\t tr := TranslateGapFuncToSPL,\n When(IsBound(tr.(f)), tr.(f)(cc),\n Error(\"Don't know how to translate '\", f, \"' to SPL\")) ),\n Error(\"Can't translate unnamed function to SPL\")),\n\n t = T_CYC, let(c := ComplexCyc(o),\n Print(\"(\", String(ReComplex(c)), \",\", String(ImComplex(c)), \")\")),\n Print(o));\n return \"\";\nend;\n\n# PrintScalarToSPLNC ( <scalar> )\n# prints <scalar> in spl syntax. Used for exporting (spl.g).\n#\nPrintScalarToSPLNC := s -> s.printSPL();\n\nValue.printSPL := self >> spiral.spl.PrintNumberToSPLNC(self.v);\nExp.printSPL := self >> Print(self.name, \"(\",\n DoForAllButLast(self.args, a->Chain(a.printSPL(), Print(\", \"))),\n Last(self.args).printSPL(), \")\");\n\nLoc.printSPL := self >> self.print();\n\nfdiv.printSPL := self >> Print(\"(\", self.args[1].printSPL(), \"/\", self.args[2].printSPL(), \")\");\nmul.printSPL := self >> Print(\"(\", self.args[1].printSPL(), \"*\", self.args[2].printSPL(), \")\");\nadd.printSPL := self >> Print(\"(\", self.args[1].printSPL(), \"+\", self.args[2].printSPL(), \")\");\nsub.printSPL := self >> Print(\"(\", self.args[1].printSPL(), \"-\", self.args[2].printSPL(), \")\");\nneg.printSPL := self >> Print(\"(-\", self.args[1].printSPL(), \")\");\n\ncospi.printSPL := self >> Print(\"cos(\", self.args[1].printSPL(), \"*pi)\");\nsinpi.printSPL := self >> Print(\"sin(\", self.args[1].printSPL(), \"*pi)\");\nScalarIsCos := x -> ObjId(x) = cospi;\nScalarIsSin := x -> ObjId(x) = sinpi;\nScalarCosArg := x -> x.args[1];\n\n\n#F Functions for Scalars\n#F ---------------------\n#F\n\n#F EvalScalar ( <scalar>/<number> )\n#F returns the number represented by <scalar>. If a <number>\n#F is given, then <number> is returned.\n#F\nEvalScalar := s -> _unwrap(\n Cond(s _is funcExp, \n\t s.eval(),\n\t IsScalar(s) and IsBound(s.ev), \n\t s.ev(), \n\t Eval(s)));\n\n#F <s1> = <s2>\n#F returns true if both <s1> and <s2> are scalars, not of\n#F type \"float\" or \"complex\", and represent the same number.\n#F\n#Ops.\\= := function ( s1, s2 )\n# return IsScalar(s1) and IsScalar(s2) and\n# s1.ev() = s2.ev();\n#end;\n\n\n#Exp.domain := Scalars;\n#Value.domain := Scalars;\n#Loc.domain := Scalars;\n", "meta": {"hexsha": "a68cdf6ab37eaa481d787e400284710d2e647aeb", "size": 8242, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/code/scalar.gi", "max_stars_repo_name": "sr7cb/spiral-software", "max_stars_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_stars_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2019-09-01T19:29:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T12:26:12.000Z", "max_issues_repo_path": "namespaces/spiral/code/scalar.gi", "max_issues_repo_name": "sr7cb/spiral-software", "max_issues_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_issues_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2020-11-20T16:15:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T21:17:28.000Z", "max_forks_repo_path": "namespaces/spiral/code/scalar.gi", "max_forks_repo_name": "sr7cb/spiral-software", "max_forks_repo_head_hexsha": "349d9e0abe75bf4b9a4690f2dbee631700f8361a", "max_forks_repo_licenses": ["BSD-2-Clause-FreeBSD"], "max_forks_count": 21, "max_forks_repo_forks_event_min_datetime": "2019-08-20T19:27:52.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:11:18.000Z", "avg_line_length": 31.1018867925, "max_line_length": 96, "alphanum_fraction": 0.5425867508, "num_tokens": 2493, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318479832804, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.35564890100188445}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n_md := function(lst)\n local i, str;\n str:=\"\";\n if Length(lst) = 0 then\n return str;\n fi;\n str := Concat(str, StringInt(lst[1]));\n for i in [ 2 .. Length(lst) ] do\n str := Concat(str, \"x\", StringInt(lst[i]));\n od;\n return str;\nend;\n\n# doSimdDft argument parser\n#\n# spiral> doSimdDft();\n# [ [ 4 ], SSE_2x64f, rec(\n# svct := true,\n# oddSizes := false ) ]\n# spiral> doSimdDft(1);\n# [ [ 4, 8 ], SSE_2x64f, rec(\n# svct := true,\n# oddSizes := false ) ]\n# spiral> doSimdDft([4,6]);\n# [ [ 4, 6 ], SSE_2x64f, rec(\n# svct := true,\n# oddSizes := true ) ]\n# spiral> doSimdDft(SSE_4x32f);\n# [ [ 16 ], SSE_4x32f, rec(\n# svct := true,\n# oddSizes := false ) ]\n# spiral> doSimdDft(1, SSE_4x32f);\n# [ [ 16, 32 ], SSE_4x32f, rec(\n# svct := true,\n# oddSizes := false ) ]\n# spiral> doSimdDft([4,6], SSE_4x32f);\n# [ [ 4, 6 ], SSE_4x32f, rec(\n# svct := true,\n# oddSizes := true ) ]\n# spiral> doSimdDft([4,6], SSE_4x32f, rec(svct:=false, oddSizes:=true));\n# [ [ 4, 6 ], SSE_4x32f, rec(\n# svct := false,\n# oddSizes := true ) ]\n\n_parse := function(arglist, multiplier)\n local isa, n, sizes, optrec;\n\n isa := SIMD_ISA_DB.active()[1];\n optrec := rec(svct := true, oddSizes :=false);\n\n if Length(arglist) = 0 then\n n := 0;\n elif Length(arglist) = 1 then\n if IsInt(arglist[1]) then\n n := arglist[1];\n elif IsList(arglist[1]) then\n n := arglist[1];\n optrec := rec(svct := true, oddSizes :=true);\n else\n n := 0;\n isa := arglist[1];\n fi;\n elif Length(arglist) = 2 then\n n := arglist[1];\n isa := arglist[2];\n if IsList(arglist[1]) then\n optrec := rec(svct := true, oddSizes :=true);\n fi;\n else\n n := arglist[1];\n isa := arglist[2];\n optrec := arglist[3];\n fi;\n\n sizes := When(IsList(n), n, List([0..n], i->multiplier*isa.v^2*2^i));\n\n return [sizes, isa, optrec];\nend;\n\ncodeSimdDft := function(arg)\n local sizes, opts, isa, res, t,rt, s, c, optrec;\n [sizes, isa, optrec] := _parse(arg, 1);\n opts := SIMDGlobals.getOpts(isa, optrec);\n\n t := ComplexT(DFT(sizes[1]), opts).withTags(opts.tags);\n rt := RandomRuleTree(t, opts);\n s := SumsRuleTreeOpts(rt, opts);\n c := CodeSumsOpts(s, opts);\n return rec(opts:=opts,t:=t,rt:=rt,s:=s,c:=c);\nend;\n\n\n_doSimd := function(sizes, isa, opts, dpr, name, trafo, mflops, stringint)\n local results, res, i;\n\n results := [];\n if not IsBound(dpr.hashTable) then dpr.hashTable := HashTableDP(); fi;\n\n Print(name, \": running \", isa, \": \", sizes, \"...\\n\");\n for i in sizes do\n res := TimedAction(DP(trafo(i), dpr, opts));\n if Length(res[1]) > 0 then\n Add(results, res[1]);\n ExportCodeRuleTree(res[1][1].ruletree,\n Concat(name, \"_\", isa.name, \"_\", stringint(i)),\n CopyFields(opts, rec(verbosity := 0, fileinfo := rec(\n cycles := res[1][1].measured,\n flops := mflops(i),\n file := Concat(name, \"_\", isa.name, \"_\", stringint(i)),\n algorithm := res[1][1].ruletree\n ))));\n\n if opts.verify then\n _seqPerfStatsMflopsAcc(Concat(name, \"_\", isa.name, \".txt\"),\n i, mflops(i), res[1][1].measured, res[2], IntDouble(d_log(1e-16+CVerifyRT(res[1][1].ruletree, opts))/d_log(10)));\n else\n _seqPerfStatsMflops(Concat(name, \"_\", isa.name, \".txt\"),\n i, mflops(i), res[1][1].measured, res[2]);\n fi;\n HashSave(dpr.hashTable, Concat(name, \"_\", isa.name, \".hash\"));\n fi;\n od;\n\n return results;\nend;\n\n\n#F doSimdDft(sizes, isa, optrec)\ndoSimdDft := function(arg)\n local sizes, opts, dpr, isa, optrec, trafos, dpbench, direction;\n\n [sizes, isa, optrec] := _parse(arg, 1);\n\t\n\tdirection := When(IsBound(optrec.transInverse) and optrec.transInverse, 1, -1);\n\n opts := SIMDGlobals.getOpts(isa, optrec);\n opts.benchTransforms := List(sizes, k -> ComplexT(DFT(k, direction), opts).withTags(opts.tags));\n\n if not IsBound(optrec.globalUnrolling) and ForAny(sizes, i -> not IsInt(i/isa.v^2)) then\n optrec.globalUnrolling := 16384;\n fi;\n dpr := rec(verbosity := 0, timeBaseCases:=true);\n dpbench := spiral.libgen.DPBench(rec((Concat(isa.name, When(opts.vector.conf.interleavedComplex, \"_ic\", \"_sc\"))) := opts), dpr);\n if IsBound(optrec.verify) then dpbench.matrixVerify := optrec.verify; fi;\n\t\n\tdpbench.sizes := sizes;\n\n return dpbench;\nend;\n\n\n#F doSimdWht(sizes, isa, optrec)\ndoSimdWht := function(arg)\n local sizes, isa, opts, optrec, defrec, dpr, dpbench;\n\n [sizes, isa, optrec] := _parse(arg, 1);\n\n defrec := rec(\n oddSizes := false,\n svct := true,\n stdTTensor := true,\n tsplPFA := false,\n splitL:=false,\n realVect := true,\n cplxVect := false,\n useConj := false,\n );\n opts := SIMDGlobals.getOpts(isa, CopyFields(optrec, defrec));\n opts.benchTransforms := List(sizes, k -> WHT(Log2Int(k)).withTags(opts.tags));\n #opts.benchTransforms := List(sizes, k -> GT(WHT(Log2Int(k)), GTPar, GTPar, [4]).withTags(opts.tags));\n #opts.benchTransforms := List(sizes, k -> GT(WHT(Log2Int(k)), GTPar, GTPar, [8]).withTags(opts.tags));\n dpr := rec(verbosity := 0, timeBaseCases:=true);\n\n dpbench := spiral.libgen.DPBench(rec((isa.name) := opts), dpr);\n if IsBound(optrec.verify) then dpbench.matrixVerify := optrec.verify; fi;\n\t\n\tdpbench.sizes := sizes;\n\n return dpbench;\nend;\n\n\n\ndoSimdMddft := function(arg)\n local sizes, opts, tags, dpr, isa, defrec, optrec, dpbench, direction;\n\n [sizes, isa, optrec] := _parse(arg, 1);\n\t\n\tdirection := When(IsBound(optrec.transInverse) and optrec.transInverse, 1, -1);\n\n # for cannot do larger sizes at this point\n defrec := rec(\n realVect := true,\n cplxVect := false,\n useConj := false,\n );\n opts := SIMDGlobals.getOpts(isa, CopyFields(optrec, defrec));\n\n opts.benchTransforms := List(sizes, k -> ComplexT(MDDFT(k, direction), opts).withTags(opts.tags));\n dpr := rec(verbosity := 0, timeBaseCases:=true);\n\n dpbench := spiral.libgen.DPBench(rec((Concat(isa.name, When(opts.vector.conf.interleavedComplex, \"_ic\", \"_sc\"))) := opts), dpr);\n if IsBound(optrec.verify) then dpbench.matrixVerify := optrec.verify; fi;\n\t\n\tdpbench.sizes := sizes;\n\n return dpbench;\nend;\n\n\ncodeSimdSymDFT := function(arg)\n local sizes, opts, dpr, isa, defrec, optrec, t, r, s, c, ttype;\n\n ttype := arg[1];\n [sizes, isa, optrec] := _parse(Drop(arg, 1), 2);\n defrec := rec(oddSizes := false, svct := true, splitL:=false, realVect := true,\n cplxVect := false, useConj := false, globalUnrolling := 1024);\n opts := SIMDGlobals.getOpts(isa, CopyFields(optrec, defrec));\n t := ttype(sizes[1]).withTags(opts.tags);\n r := RandomRuleTree(t, opts);\n s := SumsRuleTree(r, opts);\n c := CodeSums(s, opts);\n return rec(opts:=opts, t:=t, rt:=r, s:=s, c:=c);\nend;\n\n\ndoSimdSymDFT := function(arg)\n local sizes, opts, dpr, isa, optrec, results, defrec, ur, ttype, dpbench;\n\n ttype := arg[1];\n [sizes, isa, optrec] := _parse(Drop(arg, 1), 2);\n\n defrec := rec(\n oddSizes := false,\n svct := true,\n splitL:=false,\n realVect := true,\n cplxVect := false,\n useConj := false,\n globalUnrolling := 1024\n );\n ur := rec(\n globalUnrollingMin := 1024,\n globalUnrollingMax := 1024\n );\n opts := SIMDGlobals.getOpts(isa, CopyFields(defrec, optrec));\n opts.benchTransforms := List(sizes, k -> ttype(k).withTags(Cond(IsBound(optrec.cplxVect) and optrec.cplxVect, opts.cxtags, opts.tags)));\n if not IsBound(optrec.globalUnrolling) and ForAny(sizes, i -> not IsInt(i/isa.v^2)) then\n optrec.globalUnrolling := 16384;\n fi;\n dpr := rec(verbosity := 0, timeBaseCases:=true);\n\n dpbench := spiral.libgen.DPBench(rec((isa.name) := opts), dpr);\n if IsBound(optrec.verify) then dpbench.matrixVerify := optrec.verify; fi;\n\t\n\tdpbench.sizes := sizes;\n\n return dpbench;\n\n# results := _doSimd(sizes, isa, opts, dpr, arg[1], k -> ttype(k).withTags(opts.tags), i->2*i*d_log(i)/d_log(2) + i, StringInt);\n# return rec(opts:=opts, results:=results);\nend;\n\n\n\ndoSimdSymMDDFT := function(arg)\n local sizes, isa, opts, optrec, defrec, dpr, dpbench, ttype;\n\n ttype := arg[1];\n [sizes, isa, optrec] := _parse(Drop(arg, 1), 2);\n\n defrec := rec(svct := true, splitL := false, stdTTensor := true, tsplRader:=false, tsplBluestein:=false,\n tsplPFA:=false, oddSizes:=false, interleavedComplex := false, pushTag := false, flipIxA := true);\n opts := SIMDGlobals.getOpts(isa, CopyFields(optrec, defrec));\n\n opts.benchTransforms := List(sizes, k -> TTensor(ttype(k), ttype(k)).withTags(opts.tags));\n dpr := rec(verbosity := 0, timeBaseCases:=true);\n\n dpbench := spiral.libgen.DPBench(rec((isa.name) := opts), dpr);\n if IsBound(optrec.verify) then dpbench.matrixVerify := optrec.verify; fi;\n\t\n\tdpbench.sizes := sizes;\n\n return dpbench;\nend;\n\n\ndoSimdMdConv := function(arg)\n local sizes, isa, opts, optrec, defrec, dpbench, transforms;\n\n [sizes, isa, optrec] := _parse(arg, 1);\n\t\n defrec := rec();\n\t\n opts := SIMDGlobals.getOpts(isa, CopyFields(optrec, defrec));\n\t\n\ttransforms := Flat(List(sizes, n -> let(tt := TRConv2D(ImageVar([n, n])).withTags(opts.tags), [tt, tt.forwardTransform()])));\n\t\n\tdpbench := spiral.libgen.DPBench.build(transforms, opts);\n\t\n\tdpbench.sizes := sizes;\n\n return dpbench;\nend;\n\n\n\n", "meta": {"hexsha": "b0d6ab53ef378c304afb5978f6eea5f9f44d557d", "size": 9733, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/vector/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/paradigms/vector/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/paradigms/vector/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": 31.0958466454, "max_line_length": 140, "alphanum_fraction": 0.5922120621, "num_tokens": 3074, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.35539823064010906}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\nisXchain := (o,dot) -> \n Same(ObjId(o), fTensor) and Same(ObjId(o.child(1)), fId) and\n ForAll(Drop(o.children(),1), c->Same(ObjId(c), fXbase) and Same(dot, c.params[4]));\n\nmergeXchains := function(v, c1, c2)\n local terms, i, t, other;\n terms := [ Copy(c2.child(1)) ];\n for t in Drop(c2.children(),1) do\n Add(terms, \n\t fXbase(t.params[1], t.params[2], t.params[3], v));\n od;\n\n other := c2.child(c2.numChildren());\n for i in [2 .. c1.numChildren()] do\n t := c1.child(i);\n Add(terms, \n\t fXbase(t.params[1], t.params[2], t.params[3] + other.params[2] + other.params[3], v));\n od;\n return fTensor(terms);\nend;\n\n# ===================================================================\n# fXbase and fDot \n# ===================================================================\nRewriteRules(RulesFuncSimp, rec(\n # fCompose [[IP, @(1), J], [fTensor, fId, fBase]],\n IP_toXbase := ARule(fCompose,\n [ [ IP, @(1), @(2,J) ], [ fTensor, @(3,fId, e -> e.params[1] = @(1).val / @(2).val.params[1]), \n\t @(4,fBase, e -> e.params[1] = @(2).val.params[1]) ] ],\n e -> let(v:=Ind(), \n\t [ fDot(v, fTensor(@(3).val, fXbase(@(2).val.params[1], @(4).val.params[2], 0, v))) ])\n ),\n\n IP_toYbase := ARule(fCompose,\n [ [ IP, @(1), [@(2,OS), @, -1] ], [ fTensor, @(3,fId, e -> e.params[1] = @(1).val / @(2).val.params[1]), \n\t @(4,fBase, e -> e.params[1] = @(2).val.params[1]) ] ],\n e -> let(v:=Ind(), \n\t [ fDot(v, fTensor(@(3).val, fYbase(@(2).val.params[1], @(4).val.params[2], 0, v))) ])\n ),\n\n # fCompose, [ fDot, [fTensor, fId, fXbase] ]\n #\t [ fDot, [fTensor, @, fXbase] ]\n MergeXchains1 := ARule(fCompose,\n [ [ fDot, @(1), \n\t [ fTensor, fId, [@(10,fXbase), @, @, zero, @.cond(e->Same(e, @(1).val)) ]]], \n\t [ @(30,fDot), @(3), \n\t [ fTensor, ..., [@(20,fXbase), @, @, @, @.cond(e->Same(e, @(3).val)) ]]] ],\n\n e -> let(v:=IndNR(), f:=@(10).val, g:=@(20).val,\n\t dots:=DropLast(@(30).val.params[2].children(), 1),\n [ fDot(v, fTensor(dots, \n\t fXbase(g.params[1], g.params[2], g.params[3], v), \n\t\t fXbase(f.params[1], f.params[2], g.params[2] + g.params[3], v))) ])\n ),\n\n # fDot X fDot -> fDot\n MergeXchains2 := ARule(fCompose, \n [ [ fDot, @(1), @(2).cond(e->isXchain(e,@(1).val)) ],\n [ fDot, @(3), @(4).cond(e->isXchain(e,@(3).val)) ] ],\n e -> let(v:=Ind(), \n\t [ fDot(v, fTensor( mergeXchains(v, @(2).val, @(4).val))) ])\n )\n));\n\nClass(RulesDot, RuleSet);\nRewriteRules(RulesDot, rec(\n IP_toYbase := ARule(fCompose,\n [ [ IP, @(1), [@(2,OS), @, -1] ], [ fTensor, @(3,fId, e -> e.params[1] = @(1).val / @(2).val.params[1]), \n\t @(4,fBase, e -> e.params[1] = @(2).val.params[1]) ] ],\n e -> let(v:=Ind(), \n\t [ fDot(v, fTensor(@(3).val, fYbase(@(2).val.params[1], @(4).val.params[2], 0, v))) ])\n )\n));\n", "meta": {"hexsha": "c3fe06601f9fa073332bb9fee8c21abdffd91a57", "size": 2993, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/sigma/dot_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/dot_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/dot_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": 37.8860759494, "max_line_length": 110, "alphanum_fraction": 0.4667557634, "num_tokens": 1072, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.3532147608096484}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\nNewRulesFor(TTensorInd, rec(\n# base cases\n# I x A\n dsA_base_vec_push := rec(\n info := \"IxA base\",\n forTransposition := false,\n applicable := nt -> IsParPar(nt.params) and nt.isTag(1, AVecReg),\n children := nt -> let(_krnl := nt.params[1].withTags(nt.getTags()), krnl := When(_krnl.isReal(), _krnl.setWrap(VWrapId), _krnl.setWrap(VWrapTRC(nt.firstTag().isa))),\n [[ krnl, InfoNt(nt.params[2]) ]]),\n apply := (nt, c, cnt) -> IDirSum(cnt[2].params[1], c[1])\n ),\n# A x Iv\n L_dsA_L_base_vec := rec(\n info := \"AxI base\",\n forTransposition := false,\n applicable := nt -> IsVecVec(nt.params) and nt.isTag(1, AVecReg) and nt.params[2].range = nt.getTags()[1].v,\n children := nt -> let(jv := Ind(nt.getTags()[1].v), \n [[ SubstVars(Copy(nt.params[1]), rec((nt.params[2].id) := jv)).setWrap(VWrap(nt.firstTag().isa)).withTags(Drop(nt.getTags(), 1)), \n InfoNt(jv) ]]),\n apply := (nt, c, cnt) -> let(v := nt.getTags()[1].v, jv := cnt[2].params[1], \n VTensorInd(c[1], jv))\n ),\n# A x In\n L_dsA_L_vec := rec(\n info := \"AxI base\",\n forTransposition := false,\n applicable := nt -> IsVecVec(nt.params) and nt.isTag(1, AVecReg) and nt.params[2].range > nt.getTags()[1].v,\n children := nt -> let(v := nt.getTags()[1].v, jv := Ind(nt.getTags()[1].v), j := Ind(nt.params[2].range/nt.getTags()[1].v), \n [[ TTensorInd(\n SubstVars(Copy(nt.params[1]), rec((nt.params[2].id) := j*V(v)+jv)), \n j, AVec, AVec).setWrap(VWrap(nt.firstTag().isa)).withTags(Drop(nt.getTags(), 1)), InfoNt(jv) ]]),\n apply := (nt, c, cnt) -> let(jv := cnt[2].params[1],\n VTensorInd(c[1], jv))\n )\n));\n", "meta": {"hexsha": "d372251dd158386fef612b9c7eb6db1dbb073609", "size": 1854, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/vector/breakdown/ttensorind.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/ttensorind.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/ttensorind.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": 46.35, "max_line_length": 173, "alphanum_fraction": 0.5474649407, "num_tokens": 604, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.5273165233795671, "lm_q1q2_score": 0.352711620417273}} | |
| {"text": "\n# Copyright (c) 2018-2021, Carnegie Mellon University\n# See LICENSE for details\n\n\n# -------------------------------------------------------------------------------\n# NOTE: Make at()/lambda() methods consistent\n#\n# Either implement at via lambda consistently or the other way around\n# Currently some classes implement at() via lambda(), and some lambda() via at()\n# This is error prone!\n# -------------------------------------------------------------------------------\n\n#################################################################################\n#F VData( <diagfunc>, <vlen> ) - new diagonal gen. function returning vectors\n#F\n#F Given a diagonal generating function F with domain N, and range (=element\n#F type) T, VData(F, v) is a new \"vector\" diagonal function with domain N/v,\n#F and range (=element type) T.vectorType(v).\n#F\n#F It uses vpack(_, _, ...) pseudo-instruction to pack scalars into vectors.\n#F This instrucion has to be converted into architecture specific sequence\n#F by the backend.\n#F\nClass(VData, Function, rec(\n __call__ := (self, func, v) >> WithBases(self, rec(\n func := Checked(IsFunction(func) or IsFuncExp(func), func),\n v := v,\n operations := PrintOps)),\n\n print := self >> Print(self.name, \"(\", self.func, \", \", self.v, \")\"),\n rChildren := self >> [ self.func, self.v ],\n rSetChild := rSetChildFields(\"func\", \"v\"),\n\n at := (self, i) >> let(\n n := self.func.domain(), v := self.v, f := self.func.lambda(),\n ApplyFunc(vpack, List([0..v-1], j->f.at(v*i + j)))),\n\n lambda := self >> let(\n n := self.func.domain(), v := self.v, f := self.func.lambda(),\n i := Ind(n/v),\n Lambda(i, ApplyFunc(vpack, List([0..v-1], j->f.at(v*i + j))))),\n\n domain := self >> div(self.func.domain(), self.v),\n range := self >> TVect(self.func.range(), self.v),\n free := self >> self.func.free()\n));\n\n#################################################################################\n#F VDup( <diagfunc>, <vlen> ) - new diagonal gen. function returning vectors\n#F\n#F\n#F Given a diagonal generating function F with domain N, and range (=element\n#F type) T, VData(F, v) is a new \"vector\" diagonal function with domain N,\n#F and range (=element type) T.vectorType(v). Every vector element is the\n#F replicated original scalar.\n#F\n#F It uses vdup(<elt>, <vlen>) pseudo-instruction to duplicate scalars\n#F to form vectors. This instrucion has to be converted into\n#F architecture specific sequence by the backend.\n#F\nClass(VDup, Function, rec(\n __call__ := (self, func, v) >> WithBases(self, rec(\n func := Checked(IsFunction(func) or IsFuncExp(func), func),\n v := v,\n operations := PrintOps)),\n\n print := self >> Print(self.name, \"(\", self.func, \", \", self.v, \")\"),\n rChildren := self >> [ self.func, self.v ],\n rSetChild := rSetChildFields(\"func\", \"v\"),\n\n at := (self, i) >> vdup(self.func.at(i), self.v),\n\n lambda := self >> let(\n i := Ind(self.func.domain()),\n Lambda(i, vdup(self.func.at(i), self.v))),\n\n domain := self >> self.func.domain(),\n range := self >> TVect(self.func.range(), self.v),\n free := self >> self.func.free()\n));\n\n\n#################################################################################\n#F VDupOnline( <diagfunc>, <vlen> ) - is an online version of VDup.\n#F\n#F VDupOnline semantically the same as VDup(), but unlike VDup() it is pulled out\n#F of fPrecompute and executed at compute time. \n#F \n\nClass(VDupOnline, VDup, rec(\n range := (self) >> let( t := self.func.range(), \n Cond( IsVecT(t), TVect(t.t, t.size*self.v), TVect(t, self.v)))\n));\n\n#################################################################################\n#F RCVData( <cplx_vdiagfunc> ) - func returning real vecs given complex vec func\n#F\n#F Given a diagonal generating function F with domain N, and range of\n#F of complex vectors TVect(CT, v), RCVData(F) is a new real vector diagonal\n#F function with domain N and range TVect(CT.realType(), 2*v) \n#F\nClass(RCVData, Function, rec(\n __call__ := (self, func) >> WithBases(self, rec(\n func := Checked((IsFunction(func) or IsFuncExp(func)) and IsVecT(func.range()), func),\n operations := PrintOps)),\n\n print := self >> Print(self.name, \"(\", self.func, \")\"),\n rChildren := self >> [ self.func ],\n rSetChild := rSetChildFields(\"func\"),\n\n at := (self, i) >> let(\n t := self.func.range(), \n f := self.func.lambda(),\n Cond(IsVecT(t), \n\t ApplyFunc(vpack, ConcatList([0..t.size-1], j -> [ re(velem(f.at(i), j)), im(velem(f.at(i), j)) ])),\n\t ApplyFunc(vpack, [ re(f.at(i)), im(f.at(i)) ]))\n ),\n\n lambda := self >> let(j := Ind(self.domain()), Lambda(j, self.at(j))), \n domain := self >> self.func.domain(), \n range := self >> let(t := self.func.range(), \n Cond(IsVecT(t), TVect(t.t.realType(), 2*t.size), TVect(t.realType(), 2))),\n free := self >> self.func.free()\n));\n\n#################################################################################\n#F RCVDataSplit(<cplx_func>, <v>)\n#F\n#F Given a complex function f RCVDataSplit(f, v)\n#F is a new function that returns v-way vectors of the form\n#F [ re0, re0, re1, re1, ... ], [-im0, im0, -im1, im1, ...]\n#F\nClass(RCVDataSplit, Function, rec(\n __call__ := (self, cplx_func, v) >> WithBases(self, rec(\n func := Checked(IsFunction(cplx_func) or IsFuncExp(cplx_func), cplx_func),\n v := v,\n operations := PrintOps)),\n\n print := self >> Print(self.name, \"(\", self.func, \", \", self.v, \")\"),\n rChildren := self >> [ self.func, self.v ],\n rSetChild := rSetChildFields(\"func\", \"v\"),\n\n lambda := self >> let(\n i := Ind(self.domain()),\n n := self.func.domain(), \n v := self.v, \n f := self.func.lambda(),\n vars := DropLast(f.mkVars(), 1),\n ip := idiv(i, 2),\n Lambda(vars :: [i], \n cond(imod(i, 2), \n ApplyFunc(vpack, ConcatList([0..v/2-1], j ->\n\t [ -im(f.at(vars :: [(v/2)*ip+j])), im(f.at(vars :: [(v/2)*ip+j])) ])),\n ApplyFunc(vpack, ConcatList([0..v/2-1], j -> \n\t\t[ re(f.at(vars :: [(v/2)*ip+j])), re(f.at(vars :: [(v/2)*ip+j])) ]))))\n ),\n\n at := (self, i) >> self.lambda().at(i), \n\n # each cpx element -> 2 duplicated reals (r r -i i) = 4 reals -> packed into vectors of length <v>\n domain := self >> let(d := self.func.domain(), \n Cond(IsType(d), d, 4 * self.func.domain() / self.v)), \n\n range := self >> let(t := self.func.range(), TVect(t.realType(), self.v)),\n free := self >> self.func.free()\n));\n\n#################################################################################\n#F RCVDataSplitVec( <cplx_vdiagfunc> ) \n#F\n#F Given a v/2-way complex vector function f RCVDataSplitVec(f, v)\n#F is a new function that returns v-way real vectors of the form\n#F [ re0, re0, re1, re1, ... ], [-im0, im0, -im1, im1, ...]\n#F\nClass(RCVDataSplitVec, RCVData, rec(\n # lambda := <inherited from RCVData, implemented via at>\n #\n at := (self, i) >> let(\n v := self.func.range().size, \n f := self.func.lambda(),\n ip := idiv(i, 2),\n cond(imod(i, 2), \n ApplyFunc(vpack, ConcatList([0..v-1], j -> \n\t\t [ -im(velem(f.at(ip), j)), im(velem(f.at(ip), j)) ])),\n ApplyFunc(vpack, ConcatList([0..v-1], j ->\n\t\t [ re(velem(f.at(ip), j)), re(velem(f.at(ip), j)) ])))\n ),\n\n # each cpx element -> 2 duplicated reals (r r -i i) = 4 reals\n # -> packed into vectors of length <v>\n domain := self >> let(d:=self.func.domain(), \n Cond(IsType(d), d, 2 * self.func.domain())), \n));\n\n\n#################################################################################\n#F VDataRDup(<real-vector-func>)\n#F\n#F Returns new function of twice the vector length, with every element\n#F duplicated.\n#F\n#F\nClass(VDataRDup, RCVData, rec(\n # lambda := <inherited from RCVData, implemented via at>\n #\n at := (self, i) >> let(\n v := self.func.range().size, \n f := self.func.lambda(),\n ApplyFunc(vpack, ConcatList([0..v-1],\n\t j -> [ velem(f.at(i), j), velem(f.at(i), j) ]))\n ),\n\n # domain doesn't change, but output vectors get longer (ie range is different)\n domain := self >> self.func.domain(),\n));\n\n#################################################################################\n#F fStretch( <diagfunc>, num, den ) - new diagonal gen. function stretching the old one\n#F\nClass(fStretch, Function, rec(\n __call__ := (self, func, num, den) >> WithBases(self, rec(\n func := Checked(IsFunction(func) or IsFuncExp(func), func),\n den := den,\n num := num,\n operations := PrintOps)),\n\n print := self >> Print(self.__name__, \"(\", self.func, \", \", self.num, \", \", self.den, \")\"),\n rChildren := self >> [ self.func, self.num, self.den ],\n rSetChild := rSetChildFields(\"func\", \"num\", \"den\"),\n\n at := (self, i) >> self.lambda().at(i).eval(),\n\n lambda := self >> let(\n n := self.func.domain(), \n f := self.func.lambda(),\n i := Ind(n * self.num / self.den),\n i_old := self.den * idiv(i, self.num) + imod(i, self.num),\n Lambda(i, cond(leq(imod(i, self.num), self.den - 1), f.at(i_old), 0))\n ),\n\n domain := self >> self.func.domain() * self.num/self.den,\n range := self >> self.func.range(),\n free := self >> self.func.free()\n));\n\n#F ==========================================================================\n#F VDiag(<func>, <v>)\n#F\n#F Vectorized diagonal. <func> must be a plain scalar function.\n#F\n#F Diag(f) == VDiag(f, v)\n#F\nClass(VDiag, Diag, rec(\n abbrevs := [ \n\t(f, v) -> Checked(IsInt(v), \n\t Cond(IsList(f), let(ff := List(f, toExpArg),\n\t\t [ FList(UnifyTypes(List(f, x -> x.t)), f), v]),\n\t\t IsFunction(f), \n\t\t [ f, v ]))\n ],\n\n new := (self, f, v) >> SPL(WithBases(self, rec(element := f, v := v))).setDims(), \n\n print := (self, indent, indentStep) >> Print(self.name, \"(\", self.element, \", \", self.v, \")\"),\n needInterleavedLeft := False,\n needInterleavedRight := False,\n transpose := self >> self,\n conjTranspose := self >> ObjId(self)(FConj(self.element), self.v),\n # self.v is not exposed in rChildren\n from_rChildren := (self, rch) >> ObjId(self)(rch[1], self.v),\n));\n\n#################################################################################\n#F VDiag_x_I(<func>, <v>)\n#F\n#F VTensor(Diag(f), v) == VDiag_x_I(f, v)\n#F\nClass(VDiag_x_I, VDiag, rec(\n toAMat := self >> Tensor(Diag(self.element), I(self.v)).toAMat(),\n dims := self >> self.v * Diag(self.element).dims(),\n needInterleavedLeft := False,\n needInterleavedRight := False,\n transpose := self >> self\n));\n\n#################################################################################\n#F VRCDiag(<func>, <v>)\n#F\n#F Semantically equivalent to (I tensor L) * RCDiag * (I tensor L), and vectorized.\n#F\n#F Expects <func> and Input/output data to be in vector-interleaved complex format.\n#F I.e. that packing is r0,r1,r2,...,r_(v-1); i0,i1,..,i_(v-1); ... into vectors.\n#F\n#F Example, given a complex function <f> (range = TComplex), and vector length <v>:\n#F (different SIMD slots perform subsequent complex mults)\n#F\n#F VRCDiag(VData(fCompose(RCData(f.domain()), fTensor(fId(d.domain()/v), L(2*v, 2))), v), v)\n#F\n#F Example, given a complex function <f> (range = TComplex), and vector length <v>:\n#F (different SIMD slots perform SAME complex mults)\n#F\n#F VRCDiag(VDup(RCData(f), v), v)\n#F\nDeclare(VRCDiag);\nClass(VRCDiag, VDiag, rec(\n print := (self, indent, indentStep) >> Print(self.name, \"(\", self.element, \", \", self.v, \")\"),\n\n toAMat := meth(self)\n local elts, k, res, r, i;\n elts := self.element.tolist();\n Constraint(Length(elts) mod 2 = 0);\n res := [];\n for k in [ 1 .. Length(elts)/2 ] do\n r := EvalScalar(elts[2 * k - 1]);\n i := EvalScalar(elts[2 * k]);\n Add(res, BlockMat([[Diag(r), Diag(-i)], [Diag(i), Diag(r)]]).toAMat());\n od;\n return DirectSumAMat(res);\n end,\n\n toloop := self >> let(\n func := self.element, # r,i,r,i,...\n j := Ind(idiv(func.domain(),2)),\n re := func.at(2*j),\n im := func.at(2*j+1),\n ISum(j, j.range, \n VScat(H(2*j.range, 2, 2*j, 1), self.v) *\n VBlk([[re, -im],\n [im, re]], self.v) *\n VGath(H(2*j.range, 2, 2*j, 1), self.v))),\n\n dims := self >> let(n:=self.element.domain() * self.v, [n,n]), # data stores r,i pairs\n needInterleavedLeft := False,\n needInterleavedRight := False,\n transpose := self >> VRCDiag(FRConj(self.element), self.v)\n));\n\n#################################################################################\n#F RCVDiag(<func>, <v>)\n#F\n#F Semantically equivalent to RCDiag, but vectorized.\n#F Expects <func> to pack r0,i0,r1,i1,.. into vectors. Input/Output data format is same.\n#F\n#F Example, given a complex function <f> (range = TComplex), and vector length <v>:\n#F (different SIMD slots perform subsequent complex mults)\n#F\n#F RCDiag(RCData(f)) == RCVDiag(VData(RCData(f), v), v)\n#F\n#F Example, given a complex function <f> (range = TComplex), and vector length <v>:\n#F (different SIMD slots perform SAME complex mults)\n#F\n#F RCDiag(RCData(f)) == RCVDiag(RCVData(VDup(f, v/2)), v)\n#F\n#F Example, given a complex vector function <f> (range = TVect(TComplex, v/2))\n#F\n#F RCVDiag(RCVData(f), v),\n#F\nClass(RCVDiag, VDiag, rec(\n print := (self, indent, indentStep) >> Print(self.name, \"(\", self.element, \", \", self.v, \")\"),\n\n toAMat := self >> RCDiagonalAMat(\n\tConcatList(self.element.tolist(), x -> Cond(IsValue(x), x.v, List([1..self.v], i->velem(x,i)))), \n\tIdentityPermAMat(2)),\n\n dims := self >> let(n:=self.element.domain() * self.v, [n,n]), # data stores r,i pairs\n needInterleavedLeft := True,\n needInterleavedRight := True,\n\n transpose := self >> self # this is invalid! need to conjugate complex function\n));\n\n#################################################################################\n#F RCVDiagSplit(<func>, <v>)\n#F\n#F Semantically equivalent to RCDiag, but vectorized, and expects different <func>\n#F data format than RCVDiag. \n#F\n#F Expects <func> to pack r0,r0,r1,r1,...; -i0,i0,-i1,i1,...; ... into vectors.\n#F Expects Input/Output data to pack r0,i0,r1,i1,.. into vectors.\n#F\n#F Example, given a complex function <f> (range = TComplex), and vector length <v/2>:\n#F (different SIMD slots perform SAME complex mults)\n#F\n#F RCVDiagSplit(RCVDataSplitVec(VDup(f, v/2)), v); \n#F\n#F Example, given a complex function <f> (range = TComplex), and vector length <v/2>:\n#F (different SIMD slots perform different complex mults)\n#F\n#F RCVDiagSplit(RCVDataSplit(f, v), v);\n#F\nClass(RCVDiagSplit, VDiag, rec(\n print := (self, indent, indentStep) >> Print(self.name, \"(\", self.element, \", \", self.v, \")\"),\n\n toAMat := meth(self)\n local elts, k, res, r, i, p;\n elts := self.element.tolist();\n Constraint(Length(elts) mod 2 = 0);\n res := [];\n p := Tensor(I(self.v/2), J(2));\n for k in [ 1 .. Length(elts)/2 ] do\n r := EvalScalar(elts[2 * k - 1]);\n i := EvalScalar(elts[2 * k]);\n Add(res, SUM(Diag(r), Diag(i)*p).toAMat());\n od;\n return DirectSumAMat(res);\n end,\n\n dims := self >> let(n:=self.element.domain() * (self.v/2), [n,n]), # data stores r,i pairs\n needInterleavedLeft := True,\n needInterleavedRight := True,\n transpose := self >> self # this is invalid! need to conjugate complex function\n));\n\n#################################################################################\n#F VScale(<spl>, <constant>, <v>)\n#F\n#F Vecorized version of Scale\n#F \nDeclare(VScale);\nClass(VScale, BaseMat, SumsBase, rec(\n new := (self, spl, s, v) >> SPL(WithBases(self,\n rec(dimensions := spl.dims(), _children:=[spl], s:=s, v := v))),\n #-----------------------------------------------------------------------\n dims := self >> self.dimensions,\n child := (self, i) >> self._children[i],\n rChildren := self >> [self._children[1], self.s, self.v],\n rSetChild := meth(self, n, what)\n if n=1 then self._children[1] := what;\n elif n=2 then self.s := what;\n elif n=3 then self.v := what;\n else Error(\"<n> must be in [1..3]\");\n fi;\n end,\n #-----------------------------------------------------------------------\n print := (self, i, is) >> Print(self.name, \"(\", self.child(1).print(i+is,is), \", \", self.s, \", \", self.v, \")\"),\n unroll := self >> self,\n transpose := self >> VScale(self.child(1).transpose(), self.s, self.v),\n isReal := self >> self.child(1).isReal(),\n #-----------------------------------------------------------------------\n toAMat := self >> AMatMat(MatSPL(Scale(self.s, self.child(1))))\n));\n\n\n#################################################################################\n# Below are the version of above objects hacked up for online twiddle computation\n# The difference is in the codegen, as it uses a different style of underlying\n# function, that is recursive.\n#\n# NOTE: Find a cleaner and more general solution\n# NOTE: document this\n# NOTE: .toAMat() does not work for the below object, because self.func is different\n#\nClass(RCVOnlineDiag, RCVDiag);\nClass(VOnlineDiag, VDiag);\nClass(VOnlineDiag_x_I, VDiag_x_I);\n", "meta": {"hexsha": "6aaadba5fb04d44d61d93dc8fe26652c8c0fa2cb", "size": 17290, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "namespaces/spiral/paradigms/vector/sigmaspl/diag.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/sigmaspl/diag.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/sigmaspl/diag.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.8336980306, "max_line_length": 115, "alphanum_fraction": 0.5378253326, "num_tokens": 4925, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5851011686727231, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.3511709104269101}} | |