code: def calc_part_factor(self):
          
          mu, N = numpy.linalg.eig(self.As)
          # TODO: use scipy.sparse.linalg.eigs(self.As)
  
          N = matrix(N)
          n = len(mu)
          idx = range(n)
  
          W = matrix(spmatrix(1.0, idx, idx, (n, n), N.typecode))
          gesv(N, W)
  
          partfact = mul(abs(W.T), abs(N))
  
          b = matrix(1.0, (1, n))
          WN = b * partfact
          partfact = partfact.T
  
          for item in idx:
              mu_real = mu[item].real
              mu_imag = mu[item].imag
              mu[item] = complex(round(mu_real, 4), round(mu_imag, 4))
              partfact[item, :] /= WN[item]
  
          # participation factor
          self.mu = matrix(mu)
          self.part_fact = matrix(partfact)
  
          return self.mu, self.part_fact
docs: Compute participation factor of states in eigenvalues
  
          Returns
          -------