def get_diag_blocks(M):
  b = []
  n = M.shape[0]
  c = 0
  while c < n-1:
      for l in range(n-1,c,-1):
          if M[l,c] != 0 or M[c,l] != 0:
              break
          elif l == c+1:
              b.append(l)
      c = l
  return b + [n]
dataset/ETHPy150Open cdsousa/SymPyBotics/sympybotics/dynident/regression.py/get_diag_blocks/original