docs: def spin_z(particles, index):
      """Generates the spin_z projection operator for a system of
          N=particles and for the selected spin index name. where index=0..N-1"""
      mat = np.zeros((2**particles, 2**particles))
  
      for i in range(2**particles):
          ispin = btest(i, index)
          if ispin == 1:
              mat[i, i] = 1
          else:
              mat[i, i] = -1
      return 1/2.*mat