Ejemplo n.º 1
0
def test_solve_2x2():
    # 2x2 blocks
    A = BlockSymmetricToeplitzMatrix([[np.random.rand(3, 3)
                                       for _ in range(2)]])
    b = np.random.rand(A.shape[0])

    x_toe = solve_directly(A, b)
    x_dumb = np.linalg.solve(A.full_matrix(), b)

    assert np.allclose(x_toe, x_dumb, rtol=1e-6)
Ejemplo n.º 2
0
def test_solve_nested_block_circulant():
    A = BlockCirculantMatrix(
        [[random_block_matrix([1, 1], [1, 1]) for _ in range(6)]])
    b = np.random.rand(A.shape[0])

    x_circ = solve_directly(A, b)
    x_dumb = np.linalg.solve(A.full_matrix(), b)

    assert np.allclose(x_circ, x_dumb, rtol=1e-6)

    x_gmres = solve_gmres(A, b)
    x_dumb_gmres = solve_gmres(A.full_matrix(), b)

    assert np.allclose(x_gmres, x_dumb_gmres, rtol=1e-6)