def cartan_matrix(self):
        """
        Returns the Cartan matrix for D_n.
        The Cartan matrix matrix for a Lie algebra is
        generated by assigning an ordering to the simple
        roots, (alpha[1], ...., alpha[l]).  Then the ijth
        entry of the Cartan matrix is (<alpha[i],alpha[j]>).

        Examples
        ========

        >>> from sympy.liealgebras.cartan_type import CartanType
        >>> c = CartanType('D4')
        >>> c.cartan_matrix()
            Matrix([
            [ 2, -1,  0,  0],
            [-1,  2, -1, -1],
            [ 0, -1,  2,  0],
            [ 0, -1,  0,  2]])

        """

        n = self.n
        m = 2*eye(n)
        i = 1
        while i < n-2:
           m[i,i+1] = -1
           m[i,i-1] = -1
           i += 1
        m[n-2, n-3] = -1
        m[n-3, n-1] = -1
        m[1-n, n-3] = -1
        m[0, 1] = -1
        return m
dataset/ETHPy150Open sympy/sympy/sympy/liealgebras/type_d.py/TypeD.cartan_matrix/swapped operands of `-`