def solve ( A , x ) : # https://stackoverflow.com/a/48387507/353337 x = numpy . asarray ( x ) return numpy . linalg . solve ( A , x . reshape ( x . shape [ 0 ] , - 1 ) ) . reshape ( x . shape )
how to solve a m x n matrix in python
Solves a linear equation system with a matrix of shape ( n n ) and an array of shape ( n ... ) . The output has the same shape as the second argument .
def solve(A, x):
    """Solves a linear equation system with a matrix of shape (n, n) and an
    array of shape (n, ...). The output has the same shape as the second
    argument.
    """
    # https://stackoverflow.com/a/48387507/353337
    x = numpy.asarray(x)
    return numpy.linalg.solve(A, x.reshape(x.shape[0], -1)).reshape(x.shape)