code: def expand(matrix, power):
      
      if isspmatrix(matrix):
          return matrix ** power
  
      return np.linalg.matrix_power(matrix, power)
docs: Apply cluster expansion to the given matrix by raising
      the matrix to the given power.
      
      :param matrix: The matrix to be expanded
      :param power: Cluster expansion parameter
      :returns: The expanded matrix