// Numbas version: finer_feedback_settings {"name": "Find a parity check matrix for a linear code", "extensions": ["codewords", "permutations"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Find a parity check matrix for a linear code", "tags": [], "metadata": {"description": "
Given a generating matrix for a linear code, give a parity check matrix
", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "Find a parity check matrix $\\mathrm{H}$ for the {nary} code $C$ with generator matrix
\n\\[ \\mathrm{G} =\\var{G} \\]
", "advice": "First, row-reduce $\\mathrm{G}$ to obtain a standard generator matrix $\\mathrm{M}$ for the code
\n\\[ \\mathrm{G}' = \\var{codeword_matrix(M)} \\]
\nThis is in the form $(\\mathrm{I}_{\\var{dimension}}|\\mathrm{A})$. A parity check matrix is then $(-\\mathrm{A^T}|\\mathrm{I}_{\\var{word_length}-\\var{dimension}})$, i.e.
\n\\[ \\mathrm{H} = \\var{G_dual} \\]
\nNote that this is just one possible parity-check matrix. In general any basis for the dual code $C^{\\bot}$ would do for the rows of the parity-check matrix.
", "rulesets": {}, "extensions": ["codewords", "permutations"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"M": {"name": "M", "group": "Ungrouped variables", "definition": "identity_left(A)", "description": "Standard generating matrix for the code.
", "templateType": "anything", "can_override": false}, "word_length": {"name": "word_length", "group": "Ungrouped variables", "definition": "dimension+random(3..5)", "description": "Length of each word in the code
", "templateType": "anything", "can_override": false}, "dimension": {"name": "dimension", "group": "Ungrouped variables", "definition": "3", "description": "Dimension of the code - number of rows in the generating matrix.
", "templateType": "anything", "can_override": false}, "dual_dimension": {"name": "dual_dimension", "group": "Ungrouped variables", "definition": "word_length-dimension", "description": "Dimension of the dual code
", "templateType": "anything", "can_override": false}, "field_size": {"name": "field_size", "group": "Ungrouped variables", "definition": "random(2,3,5)", "description": "", "templateType": "anything", "can_override": false}, "g_words": {"name": "g_words", "group": "Ungrouped variables", "definition": "shuffle(set_generated_by(M))[0..dimension]", "description": "The generating matrix presented to the student, as a list of codewords.
\nThe variable testing condition ensures these words are linearly independent.
", "templateType": "anything", "can_override": false}, "G_dual": {"name": "G_dual", "group": "Ungrouped variables", "definition": "codeword_matrix(parity_check_matrix(M))", "description": "Parity check matrix for $M$ (a generator matrix for the dual code of $M$)
", "templateType": "anything", "can_override": false}, "g": {"name": "g", "group": "Ungrouped variables", "definition": "codeword_matrix(G_words)", "description": "A random generating matrix for the code, not in standard form.
", "templateType": "anything", "can_override": false}, "nary": {"name": "nary", "group": "Ungrouped variables", "definition": "[\"\",\"unary\",\"binary\",\"ternary\",\"$4$-ary\",\"$5$-ary\"][field_size]", "description": "", "templateType": "anything", "can_override": false}, "A": {"name": "A", "group": "Ungrouped variables", "definition": "repeat(codeword(repeat(random(0..field_size-1),word_length-dimension),field_size),dimension)", "description": "The generating matrix is $I_{dim}|A$, where $A$ is random.
", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "linearly_independent(G_words)", "maxRuns": 100}, "ungrouped_variables": ["field_size", "nary", "dimension", "word_length", "dual_dimension", "A", "M", "g_words", "g", "G_dual"], "variable_groups": [], "functions": {"identity_right": {"parameters": [["words", "list"]], "type": "list", "language": "javascript", "definition": "var k = words.length;\nvar field_size = words[0].field_size;\nvar out = [];\nfor(var i=0;i