code: def gill_king(mat, eps=1e-16):
      
      if not scipy.sparse.issparse(mat):
          mat = numpy.asfarray(mat)
      assert numpy.allclose(mat, mat.T)
  
      size = mat.shape[0]
      mat_diag = mat.diagonal()
      gamma = abs(mat_diag).max()
      off_diag = abs(mat - numpy.diag(mat_diag)).max()
  
      delta = eps*max(gamma + off_diag, 1)
      beta = numpy.sqrt(max(gamma, off_diag/size, eps))
  
      lowtri = _gill_king(mat, beta, delta)
  
      return lowtri
docs: Gill-King algorithm for modified cholesky decomposition.
  
      Args:
          mat (numpy.ndarray):
              Must be a non-singular and symmetric matrix.  If sparse, the result
              will also be sparse.
          eps (float):
              Error tolerance used in algorithm.
  
  
      Returns:
          (numpy.ndarray):
              Lower triangular Cholesky factor.
  
      Examples:
          >>> mat = [[4, 2, 1], [2, 6, 3], [1, 3, -.004]]
          >>> lowtri = gill_king(mat)
          >>> print(numpy.around(lowtri, 4))
          [[2.     0.     0.    ]
           [1.     2.2361 0.    ]
           [0.5    1.118  1.2264]]
          >>> print(numpy.around(numpy.dot(lowtri, lowtri.T), 4))
          [[4.    2.    1.   ]
           [2.    6.    3.   ]
           [1.    3.    3.004]]