code: def ckchol(M):
      
      from numpy import linalg, matrix, eye, size
  
      try: # First, try the Cholesky decomposition
          output=linalg.cholesky(M)
      except: # If not, just return garbage
          print('WARNING: Cholesky failed, so returning (invalid) identity matrix!')    
          output=matrix(eye(size(M,0)))
      
      return output
docs: CKCHOL
      
      This function computes the Cholesky decomposition of the matrix if it's
      positive-definite; else it returns the identity matrix. It was written
      to handle the "matrix must be positive definite" error in linalg.cholesky.
      
      Version: 2011may03