(matrix_a, b)
return x
Computes the solution to a system of linear equations with partial pivoting.

    This function solves :math:`Ax = b` using LUP decomposition. :math:`A` is a
    :math:`N \\times N` matrix, :math:`b` is :math:`N \\times M` matrix of
    :math:`M` column vectors. Each column of :math:`x` is a solution for
    corresponding column of :math:`b`.

    :param matrix_a: matrix A
    :type m_l: list
    :param b: matrix of M column vectors
    :type b: list
    :return: x, the solution matrix
    :rtype: list
Computes the solution to a system of linear equations with partial pivoting.
Computes the solution to a system of linear equations with partial pivoting .
def lu_factor(matrix_a, b):
    """ Computes the solution to a system of linear equations with partial pivoting.

    This function solves :math:`Ax = b` using LUP decomposition. :math:`A` is a
    :math:`N \\times N` matrix, :math:`b` is :math:`N \\times M` matrix of
    :math:`M` column vectors. Each column of :math:`x` is a solution for
    corresponding column of :math:`b`.

    :param matrix_a: matrix A
    :type m_l: list
    :param b: matrix of M column vectors
    :type b: list
    :return: x, the solution matrix
    :rtype: list
    """
    # Variable initialization
    dim = len(b[0])
    num_x = len(b)
    x = [[0.0 for _ in range(dim)] for _ in range(num_x)]

    # LUP decomposition
    mp, p = matrix_pivot(matrix_a)
    m_l, m_u = lu_decomposition(mp)

    # Solve the system of linear equations
    for i in range(dim):
        bt = [b1[i] for b1 in b]
        y = forward_substitution(m_l, bt)
        xt = backward_substitution(m_u, y)
        for j in range(num_x):
            x[j][i] = xt[j]

    # Return the solution
    return x
def lu_factor ( matrix_a , b ) : # Variable initialization dim = len ( b [ 0 ] ) num_x = len ( b ) x = [ [ 0.0 for _ in range ( dim ) ] for _ in range ( num_x ) ] # LUP decomposition mp , p = matrix_pivot ( matrix_a ) m_l , m_u = lu_decomposition ( mp ) # Solve the system of linear equations for i in range ( dim ) : bt = [ b1 [ i ] for b1 in b ] y = forward_substitution ( m_l , bt ) xt = backward_substitution ( m_u , y ) for j in range ( num_x ) : x [ j ] [ i ] = xt [ j ] # Return the solution return x