Exemple #1
0
    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))
Exemple #2
0
    def test_join_4_3x3_blocks_in_6x6_matrix(self):
        # given
        A0 = M3(1, 2, 3, 7, 8, 9, 13, 14, 15)

        A1 = M3(4, 5, 6, 10, 11, 12, 16, 17, 18)

        A2 = M3(19, 20, 21, 25, 26, 27, 31, 32, 33)

        A3 = M3(22, 23, 24, 28, 29, 30, 34, 35, 36)

        # when
        actual = matrix_join(A0, A1, A2, A3)

        # then
        expected = 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)

        assert_that(actual, is_(expected))
Exemple #3
0
    def test_split_6x6_in_4_blocks(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
        blocks = matrix_split(original, block_order=3)

        # then
        E00 = M3(1, 2, 3, 7, 8, 9, 13, 14, 15)

        E01 = M3(4, 5, 6, 10, 11, 12, 16, 17, 18)

        E10 = M3(19, 20, 21, 25, 26, 27, 31, 32, 33)

        E11 = M3(22, 23, 24, 28, 29, 30, 34, 35, 36)

        assert_that(blocks, is_([E00, E01, E10, E11]))
Exemple #4
0
    def test_3x3_processors_3x3_operands(self):
        nprocs = 9

        # given
        P = [
            self.broker.add_servant(ProcessorI(), Cannon.ProcessorPrx)
            for i in range(nprocs)
        ]
        frontend = self.broker.add_servant(FrontendI(P), Cannon.FrontendPrx)

        A = M3(1, 2, 3, 4, 5, 6, 7, 8, 9)
        B = M3(10, 11, 12, 13, 14, 15, 16, 17, 18)

        # when
        C = frontend.multiply(A, B)

        # then
        expected = M3(84, 90, 96, 201, 216, 231, 318, 342, 366)

        assert_that(C, is_(expected))