State Generator

class perceval.utils.stategenerator.StateGenerator(encoding, polarization_base=(|{P:H}>, |{P:V}>))

StateGenerator class for conveniently generating common complex StateVectors

Parameters:
  • encoding – for specifying the output format of the StateVector supported are Encoding.RAW, Encoding.DUAL_RAIL, Encoding.POLARIZATION

  • polarization_base – (optional) you can provide your own polarization basis as a tuple of BasicStates default=(BasicState(”|{P:H}>”), BasicState(”|{P:V}>”)

bell_state(state)

Generate a StateVector representing a Bell state

Parameters:

state (str) – name of the bell state you want to generate: "phi+" = (|0,0>+|1,1>)/sqrt(2) "phi-" = (|0,0>-|1,1>)/sqrt(2) "psi+" = (|0,1>+|1,0>)/sqrt(2) "psi-" = (|0,1>-|1,0>)/sqrt(2)

Returns:

StateVector for a bell state

ghz_state(n)

Generate a StateVector representing a (generalized) Greenberger–Horne–Zeilinger state

Parameters:

n (int) – order of the GHZ state

Returns:

StateVector representing the GHZ state

graph_state(graph)

Generate a StateVector representing a graph state.

Parameters:

graph (Graph) – networkx.Graph object. Edge weights are ignored.

Returns:

StateVector representing the graph state

logical_state(state)

Generate a StateVector from a list of logical state

Parameters:

state (List[int]) – list of bits

Returns:

StateVector representing the logical state