docstr: 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]])
docstr_tok: ["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","]","]",")"]
code: 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[n - 1, n - 3] = -1
      m[0, 1] = -1
      return m
  
file_path: sympy/sympy/liealgebras/type_d.py
imports: from .cartan_type import Standard_Cartan
  from sympy.core.backend import eye
label_desc: Use image node_id 7 for calling the TypeD obj's underlying member method code with example usage: obj.cartan_matrix() and returns: m