'Gets the precedence matrix. This is used for computing the
distance between two permutations.
Examples
>>> from sympy.combinatorics.permutations import Permutation
>>> p = Permutation.josephus(3, 6, 1)
>>> p
Permutation([2, 5, 3, 1, 4, 0])
>>> p.get_precedence_matrix()
Matrix([
[0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 1, 0],
[1, 1, 0, 1, 1, 1],
[1, 1, 0, 0, 1, 0],
[1, 0, 0, 0, 0, 0],
[1, 1, 0, 1, 1, 0]])
See Also
get_precedence_distance, get_adjacency_matrix, get_adjacency_distance'

def get_precedence_matrix(self):

    m = zeros(self.size)
    perm = self.array_form
    for i in range(m.rows):
        for j in range((i + 1), m.cols):
            m[(perm[i], perm[j])] = 1
    return m
