def decode(self, vector): syndrome = self.calc_syndrome(vector) representative = self.decoding_table[np.array_str(syndrome)] return f"{syndrome}-{representative}", Decoder.fix_row( [np.add(vector, representative)])[0]
def calc_syndrome(self, vector: np.ndarray): pc_transpose = np.transpose(self.parity_control_matrix) return Decoder.fix_row([np.matmul(vector, pc_transpose)])[0]