def load_processors(self, A, B): p_A = matrix_split(matrix_horizontal_shift(A, (A.ncols / self.order)), (A.ncols / self.order)) p_B = matrix_split(matrix_vertical_shift(B, (A.ncols / self.order)), (A.ncols / self.order)) for i in range(len(p_A)): self.procesadores[i].begin_injectFirst(p_A[i], 0) self.procesadores[i].begin_injectSecond(p_B[i], 0)
def test_horizontal_shift_4x4_by_blocks_2x2(self): # given original = M4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) # when actual = matrix_horizontal_shift(original, block_order=2) # then expected = M4(1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 9, 10, 15, 16, 13, 14) assert_that(actual, is_(expected))
def test_horizontal_shift_3x3_by_blocks_1x1(self): # given original = M3(1, 2, 3, 4, 5, 6, 7, 8, 9) # when actual = matrix_horizontal_shift(original, block_order=1) # then expected = M3(1, 2, 3, 5, 6, 4, 9, 7, 8) assert_that(actual, is_(expected))
def test_horizontal_shift_2x2_by_blocks_1x1(self): # given M = Cannon.Matrix(2, [1, 2, 3, 4]) # when actual = matrix_horizontal_shift(M, block_order=1) # then expected = Cannon.Matrix(2, [1, 2, 4, 3]) assert_that(actual, is_(expected))
def test_horizontal_shift_6x6_blocks_3x3(self): # given original = M6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36) # when actual = matrix_horizontal_shift(original, block_order=3) # then expected = M6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 19, 20, 21, 28, 29, 30, 25, 26, 27, 34, 35, 36, 31, 32, 33) assert_that(actual, is_(expected))
def test_horizontal_shift_6x6_by_blocks_1x1(self): # given original = M6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36) # when actual = matrix_horizontal_shift(original, block_order=1) # then expected = M6(1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 7, 15, 16, 17, 18, 13, 14, 22, 23, 24, 19, 20, 21, 29, 30, 25, 26, 27, 28, 36, 31, 32, 33, 34, 35) assert_that(actual, is_(expected))
def load_processors(self, A, B): p_A = matrix_split(matrix_horizontal_shift(A, (A.ncols / self.order)), (A.ncols / self.order)) p_B = matrix_split(matrix_vertical_shift(B, (A.ncols / self.order)), (A.ncols / self.order)) for i in range(len(p_A)): self.procesadores[i].begin_injectFirst(p_A[i], 0); self.procesadores[i].begin_injectSecond(p_B[i], 0)