def test_galue_field_vondermond_rank3(self): gfp = GFP(7) operations = MOperations(gfp) vectorC = [[-3], [-7], [2]] vectorA = [[-16], [-108], [9]] expectedResult = [[11], [3], [-2]] gVectorC = gfp.toGFP(vectorC) gVectorA = gfp.toGFP(vectorA) gExpResult = gfp.toGFP(expectedResult) self.assertEqual(operations.solveVondermond(gVectorA, gVectorC), gExpResult)
def test_galue_field_vondermond_rank4(self): gfp = GFP(7) operations = MOperations(gfp) vectorC = [[2], [-1], [-3], [-2]] vectorA = [[35], [2], [-50], [-13]] expectedResult = [[7], [4], [1], [2]] gVectorC = gfp.toGFP(vectorC) gVectorA = gfp.toGFP(vectorA) gExpResult = gfp.toGFP(expectedResult) self.assertEqual(operations.solveVondermond(gVectorA, gVectorC), gExpResult)
def test_galue_field_matrix_mult(self): gfp = GFP(7) operations = MOperations(gfp) matrixA = [[3, 2, 1], [1, -7, 8], [9, 1, 1]] matrixB = [[2, 1, 1], [3, 2, -2], [-1, -2, -3]] expectedMatrix = [[11, 5, -4], [-27, -29, -9], [20, 9, 4]] galueMatrixA = gfp.toGFP(matrixA) galueMatrixB = gfp.toGFP(matrixB) galueExpectedMatrix = gfp.toGFP(expectedMatrix) calcMatrix = operations.matrixMult(galueMatrixA, galueMatrixB) self.assertEqual(galueExpectedMatrix, calcMatrix)
def test_galue_field_matrix_add(self): gfp = GFP(5) operations = MOperations(gfp) matrixA = [[6, 0, 5], [12, -7, 8], [3, 1, 1]] matrixB = [[2, 1, 1], [3, 2, -2], [-1, 0, 17]] galueExpectedMatrix = [[3, 1, 1], [0, 0, 1], [2, 1, 3]] galueMatrixA = gfp.toGFP(matrixA) galueMatrixB = gfp.toGFP(matrixB) calcMatrix = operations.matrixAddition(galueMatrixA, galueMatrixB) self.assertEqual(galueExpectedMatrix, calcMatrix)