Ejemplo n.º 1
0
 def BlockMatrix(expr, assumptions):
     from sympy.matrices.expressions.blockmatrix import reblock_2x2
     if not expr.is_square:
         return False
     if expr.blockshape == (1, 1):
         return ask(Q.invertible(expr.blocks[0, 0]), assumptions)
     expr = reblock_2x2(expr)
     if expr.blockshape == (2, 2):
         [[A, B], [C, D]] = expr.blocks.tolist()
         if ask(Q.invertible(A), assumptions) == True:
             invertible = ask(Q.invertible(D - C * A.I * B), assumptions)
             if invertible is not None:
                 return invertible
         if ask(Q.invertible(B), assumptions) == True:
             invertible = ask(Q.invertible(C - D * B.I * A), assumptions)
             if invertible is not None:
                 return invertible
         if ask(Q.invertible(C), assumptions) == True:
             invertible = ask(Q.invertible(B - A * C.I * D), assumptions)
             if invertible is not None:
                 return invertible
         if ask(Q.invertible(D), assumptions) == True:
             invertible = ask(Q.invertible(A - B * D.I * C), assumptions)
             if invertible is not None:
                 return invertible
     return None
Ejemplo n.º 2
0
def test_reblock_2x2():
    B = BlockMatrix([[MatrixSymbol("A_%d%d" % (i, j), 2, 2) for j in range(3)] for i in range(3)])
    assert B.blocks.shape == (3, 3)

    BB = reblock_2x2(B)
    assert BB.blocks.shape == (2, 2)

    assert B.shape == BB.shape
    assert B.as_explicit() == BB.as_explicit()
Ejemplo n.º 3
0
def test_reblock_2x2():
    B = BlockMatrix([[MatrixSymbol('A_%d%d' % (i, j), 2, 2) for j in range(3)]
                     for i in range(3)])
    assert B.blocks.shape == (3, 3)

    BB = reblock_2x2(B)
    assert BB.blocks.shape == (2, 2)

    assert B.shape == BB.shape
    assert B.as_explicit() == BB.as_explicit()
Ejemplo n.º 4
0
def test_deblock():
    B = BlockMatrix([[MatrixSymbol('A_%d%d' % (i, j), n, n) for j in range(4)]
                     for i in range(4)])

    assert deblock(reblock_2x2(B)) == B
Ejemplo n.º 5
0
def test_deblock():
    B = BlockMatrix([[MatrixSymbol("A_%d%d" % (i, j), n, n) for j in range(4)] for i in range(4)])

    assert deblock(reblock_2x2(B)) == B