def step_impl(context):
    expected = Matrix(4, 4)
    for row in range(4):
        for column in range(4):
            expected.matrix[row][column] = float(context.table[row][column])
    result = context.A.transpose()
    assert expected == result, 'The transpose of Matrix A does not match the expected result.'
def step_impl(context, row, column, rows, columns):
    expected = Matrix(rows, columns)
    for e_row in range(rows):
        for e_col in range(columns):
            expected.matrix[e_row][e_col] = float(context.table[e_row][e_col])
    result = context.M.submatrix(row, column)
    assert expected == result, 'The expected submatrix was not found with the calculated result.'
def step_impl(context):
    expected = Matrix(4, 4)
    for row in range(4):
        for column in range(4):
            expected.matrix[row][column] = float(context.table[row][column])
    result = context.A * context.B
    assert expected == result, 'The multiplication of A * B does not match the expected result.'
def step_impl(context):
    expected = Matrix(4, 4)
    for e_row in range(4):
        for e_col in range(4):
            expected.matrix[e_row][e_col] = float(context.table[e_row][e_col])
    result = context.M.inverse()
    assert expected == result, 'The expected matrix is does not match the given inverse.'
def step_impl(context):
    expected = Matrix(4, 4)
    for e_row in range(4):
        for e_col in range(4):
            expected.matrix[e_row][e_col] = float(context.table[e_row][e_col])
    result = context.B
    assert expected == result, 'The expected matrix does not match what was given.'
예제 #6
0
def step_impl(context, col, row):
    expected = Matrix(col, row)
    i = j = 0
    for row in context.table:
        for col in row:
            expected._matrix[i][j] = float(col)
            j += 1
        i += 1
        j = 0
    assert expected == context.t, f't != {expected._matrix}'
예제 #7
0
def question_two():
    print('2. What do you get when you multiply a matrix by its inverse?')
    m = Matrix(3, 3)
    m._matrix = [[1, 2, 3],
                [20, 5, 6],
                [7, 8, 11]]
    print('We have the following matrix:')
    for row in m.matrix:
        print(row)

    print('\nThe inverse matrix is the following:')
    i = m.inverse()
    for row in i.matrix:
        print(row)

    print('\nThe product of the matrix with it\'s inverse is the following:')
    p = i * m
    for row in p.matrix:
        print(row)
def step_impl(context, rows, columns):
    context.M = Matrix(rows, columns)
    for row_index, row in enumerate(context.table):
        for column_index, column in enumerate(row):
            context.M.matrix[row_index][column_index] = float(column)
def step_impl(context):
    context.B = Matrix(4, 4)
    for row in range(4):
        for column in range(4):
            context.B.matrix[row][column] = float(context.table[row][column])