def IJ(mu, N):
    """Return i, j, s for any given mu."""
    if mu == 0: return 1, 1, 1

    if mu not in range(0, N**2):
        raise ValueError('mu has an invalid value mu='+str(mu)+'.')

    if 1 <= mu <= N-1:
        return mu+1, mu+1, 1
    else:
        m = N-1
        M = N*(N-1)/2
        for jj in range(1, N):
            for ii in range(jj+1, N+1):
                m += 1
                if m == mu or m+M == mu:
                    if mu > N*(N+1)/2 - 1:
                        return ii, jj, -1
                    else:
                        return ii, jj, 1
def IJ ( mu , N ) : if mu == 0 : return 1 , 1 , 1 if mu not in range ( 0 , N ** 2 ) : raise ValueError ( 'mu has an invalid value mu=' + str ( mu ) + '.' ) if 1 <= mu <= N - 1 : return mu + 1 , mu + 1 , 1 else : m = N - 1 M = N * ( N - 1 ) / 2 for jj in range ( 1 , N ) : for ii in range ( jj + 1 , N + 1 ) : m += 1 if m == mu or m + M == mu : if mu > N * ( N + 1 ) / 2 - 1 : return ii , jj , - 1 else : return ii , jj , 1
Return i, j, s for any given mu.