(m, sign=False)
return mp, p
Computes the pivot matrix for M, a square matrix.

    This function computes

    * the permutation matrix, :math:`P`
    * the product of M and P, :math:`M \\times P`
    * determinant of P, :math:`det(P)` if ``sign = True``

    :param m: input matrix
    :type m: list, tuple
    :param sign: flag to return the determinant of the permutation matrix, P
    :type sign: bool
    :return: a tuple containing the matrix product of M x P, P and det(P)
    :rtype: tuple
Computes the pivot matrix for M, a square matrix.
Computes the pivot matrix for M a square matrix .
def matrix_pivot(m, sign=False):
    """ Computes the pivot matrix for M, a square matrix.

    This function computes

    * the permutation matrix, :math:`P`
    * the product of M and P, :math:`M \\times P`
    * determinant of P, :math:`det(P)` if ``sign = True``

    :param m: input matrix
    :type m: list, tuple
    :param sign: flag to return the determinant of the permutation matrix, P
    :type sign: bool
    :return: a tuple containing the matrix product of M x P, P and det(P)
    :rtype: tuple
    """
    mp = deepcopy(m)
    n = len(mp)
    p = matrix_identity(n)  # permutation matrix
    num_rowswap = 0
    for j in range(0, n):
        row = j
        a_max = 0.0
        for i in range(j, n):
            a_abs = abs(mp[i][j])
            if a_abs > a_max:
                a_max = a_abs
                row = i
        if j != row:
            num_rowswap += 1
            for q in range(0, n):
                # Swap rows
                p[j][q], p[row][q] = p[row][q], p[j][q]
                mp[j][q], mp[row][q] = mp[row][q], mp[j][q]
    if sign:
        return mp, p, math.pow(-1, num_rowswap)
    return mp, p
def matrix_pivot ( m , sign = False ) : mp = deepcopy ( m ) n = len ( mp ) p = matrix_identity ( n ) # permutation matrix num_rowswap = 0 for j in range ( 0 , n ) : row = j a_max = 0.0 for i in range ( j , n ) : a_abs = abs ( mp [ i ] [ j ] ) if a_abs > a_max : a_max = a_abs row = i if j != row : num_rowswap += 1 for q in range ( 0 , n ) : # Swap rows p [ j ] [ q ] , p [ row ] [ q ] = p [ row ] [ q ] , p [ j ] [ q ] mp [ j ] [ q ] , mp [ row ] [ q ] = mp [ row ] [ q ] , mp [ j ] [ q ] if sign : return mp , p , math . pow ( - 1 , num_rowswap ) return mp , p