// Numbas version: finer_feedback_settings {"name": "Fixed size matrix gives a hint", "extensions": ["codewords"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {"identity_right": {"definition": "var k = words.length;\nvar field_size = words[0].field_size;\nvar out = [];\nfor(var i=0;iFirst, row-reduce $\\mathrm{G}$ to obtain a standard generator matrix $\\mathrm{M}$ for the code

\n

\\[ \\mathrm{G}' = \\var{codeword_matrix(M)} \\]

\n

This 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} \\]

\n

Note 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": {}, "parts": [{"prompt": "

$\\mathrm{H} = $ [[0]]

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"numRows": "dual_dimension", "numColumns": "word_length", "allowResize": false, "allowFractions": false, "variableReplacements": [], "markPerCell": false, "variableReplacementStrategy": "originalfirst", "tolerance": 0, "correctAnswerFractions": false, "showCorrectAnswer": true, "correctAnswer": "G_dual", "scripts": {"mark": {"order": "instead", "script": "with(Numbas.extensions.codewords) {\n\n // convert student's answer to a list of codewords\n var words = this.studentAnswer.map(function(row) {\n var digits = row.map(util.parseNumber);\n return new Numbas.extensions.codewords.Codeword(digits,variables.field_size);\n })\n\n this.answered = true;\n\n // check student's answer is the right size\n if(this.studentAnswerRows != variables.dual_dimension || this.studentAnswerColumns != variables.word_length) {\n this.setCredit(0,\"Your answer is incorrect.\");\n return;\n }\n \n // rows must be linearly independent\n if(!linearly_independent(words)) {\n this.setCredit(0,\"Your answer is incorrect.\");\n return;\n }\n \n // each row in the parity check matrix must be orthogonal to all of the words in the code\n var wrong = 0;\n words.map(function(w) {\n variables.g_words.map(function(g) {\n var t = 0;\n for(var i=0;iFind a parity check matrix $\\mathrm{H}$ for the {nary} code $C$ with generator matrix

\n

\\[ \\mathrm{G} =\\var{G} \\]

", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": "linearly_independent(G_words)"}, "variables": {"A": {"definition": "repeat(codeword(repeat(random(0..field_size-1),word_length-dimension),field_size),dimension)", "templateType": "anything", "group": "Ungrouped variables", "name": "A", "description": "

The generating matrix is $I_{dim}|A$, where $A$ is random.

"}, "dual_dimension": {"definition": "word_length-dimension", "templateType": "anything", "group": "Ungrouped variables", "name": "dual_dimension", "description": "

Dimension of the dual code

"}, "field_size": {"definition": "random(2,3,5)", "templateType": "anything", "group": "Ungrouped variables", "name": "field_size", "description": ""}, "nary": {"definition": "[\"\",\"unary\",\"binary\",\"ternary\",\"$4$-ary\",\"$5$-ary\"][field_size]", "templateType": "anything", "group": "Ungrouped variables", "name": "nary", "description": ""}, "g": {"definition": "codeword_matrix(G_words)", "templateType": "anything", "group": "Ungrouped variables", "name": "g", "description": "

A random generating matrix for the code, not in standard form.

"}, "M": {"definition": "identity_left(A)", "templateType": "anything", "group": "Ungrouped variables", "name": "M", "description": "

Standard generating matrix for the code.

"}, "word_length": {"definition": "dimension+random(3..5)", "templateType": "anything", "group": "Ungrouped variables", "name": "word_length", "description": "

Length of each word in the code

"}, "G_dual": {"definition": "codeword_matrix(parity_check_matrix(M))", "templateType": "anything", "group": "Ungrouped variables", "name": "G_dual", "description": "

Parity check matrix for $M$ (a generator matrix for the dual code of $M$)

"}, "dimension": {"definition": "3", "templateType": "anything", "group": "Ungrouped variables", "name": "dimension", "description": "

Dimension of the code - number of rows in the generating matrix.

"}, "g_words": {"definition": "shuffle(set_generated_by(M))[0..dimension]", "templateType": "anything", "group": "Ungrouped variables", "name": "g_words", "description": "

The generating matrix presented to the student, as a list of codewords.

\n

The variable testing condition ensures these words are linearly independent.

"}}, "metadata": {"description": "", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}