quimb.gen.states

Functions for generating quantum states.

Attributes

Functions

basis_vec(i, dim[, ownership])

Constructs a unit vector ket:

up(**kwargs)

Returns up-state, aka. |0>, +Z eigenstate:

down(**kwargs)

Returns down-state, aka. |1>, -Z eigenstate:

plus(**kwargs)

Returns plus-state, aka. |+>, +X eigenstate:

minus(**kwargs)

Returns minus-state, aka. |->, -X eigenstate:

yplus(**kwargs)

Returns yplus-state, aka. |y+>, +Y eigenstate:

yminus(**kwargs)

Returns yplus-state, aka. |y->, -Y eigenstate:

bloch_state(ax, ay, az[, purified])

Construct qubit density operator from bloch vector:

bell_state(s, **kwargs)

One of the four bell-states.

singlet(**kwargs)

Alias for the 'psi-' bell-state.

thermal_state(ham, beta[, precomp_func])

Generate a thermal state of a Hamiltonian.

computational_state(binary, **kwargs)

Generate the qubit computational state with binary.

neel_state(n[, down_first])

Construct Neel state for n spins, i.e. alternating up/down.

singlet_pairs(n, **kwargs)

Construct fully dimerised spin chain.

werner_state(p, **kwargs)

Construct Werner State, i.e. fractional mix of identity with singlet.

ghz_state(n, **kwargs)

Construct GHZ state of n spins, i.e. equal superposition of all up

w_state(n, **kwargs)

Construct W-state: equal superposition of all single spin up states.

levi_civita(perm)

Compute the generalised levi-civita coefficient for a permutation.

perm_state(ps)

Construct the anti-symmetric state which is the +- sum of all

graph_state_1d(n[, cyclic, sparse])

Graph State on a line.

Module Contents

quimb.gen.states.basis_vec(i, dim, ownership=None, **kwargs)[source]

Constructs a unit vector ket:

\[\begin{split}|i\rangle = \begin{pmatrix} 0 \\ \vdots \\ 1 \\ \vdots \\ 0 \end{pmatrix}\end{split}\]
Parameters:
  • i (int) – Which index should the single non-zero, unit entry.

  • dim (int) – Total size of hilbert space.

  • sparse (bool, optional) – Return vector as sparse matrix.

  • kwargs – Supplied to qu.

Returns:

The basis vector.

Return type:

vector

quimb.gen.states.up(**kwargs)[source]

Returns up-state, aka. |0>, +Z eigenstate:

\[\begin{split}|0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}\end{split}\]
quimb.gen.states.zplus[source]
quimb.gen.states.down(**kwargs)[source]

Returns down-state, aka. |1>, -Z eigenstate:

\[\begin{split}|1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}\end{split}\]
quimb.gen.states.zminus[source]
quimb.gen.states.plus(**kwargs)[source]

Returns plus-state, aka. |+>, +X eigenstate:

\[\begin{split}|+\rangle = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ 1 \end{pmatrix}\end{split}\]
quimb.gen.states.xplus[source]
quimb.gen.states.minus(**kwargs)[source]

Returns minus-state, aka. |->, -X eigenstate:

\[\begin{split}|-\rangle = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ -1 \end{pmatrix}\end{split}\]
quimb.gen.states.xminus[source]
quimb.gen.states.yplus(**kwargs)[source]

Returns yplus-state, aka. |y+>, +Y eigenstate:

\[\begin{split}|y+\rangle = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ i \end{pmatrix}\end{split}\]
quimb.gen.states.yminus(**kwargs)[source]

Returns yplus-state, aka. |y->, -Y eigenstate:

\[\begin{split}|y-\rangle = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ -i \end{pmatrix}\end{split}\]
quimb.gen.states.bloch_state(ax, ay, az, purified=False, **kwargs)[source]

Construct qubit density operator from bloch vector:

\[\rho = \frac{1}{2} \left( I + a_x X + a_y Y + a_z Z \right)\]
Parameters:
  • ax (float) – X component of bloch vector.

  • ay (float) – Y component of bloch vector.

  • az (float) – Z component of bloch vector.

  • purified – Whether to map vector to surface of bloch sphere.

Returns:

Density operator of qubit ‘pointing’ in (ax, ay, az) direction.

Return type:

Matrix

quimb.gen.states.bell_state(s, **kwargs)[source]

One of the four bell-states.

If n = 2**-0.5, they are:

  1. 'psi-' : n * ( |01> - |10> )

  2. 'psi+' : n * ( |01> + |10> )

  3. 'phi-' : n * ( |00> - |11> )

  4. 'phi+' : n * ( |00> + |11> )

They can be enumerated in this order.

Parameters:
  • s (str or int) – String of number of state corresponding to above.

  • kwargs – Supplied to qu called on state.

Returns:

p – The bell-state s.

Return type:

immutable vector

quimb.gen.states.singlet(**kwargs)[source]

Alias for the ‘psi-’ bell-state.

quimb.gen.states.thermal_state(ham, beta, precomp_func=False)[source]

Generate a thermal state of a Hamiltonian.

Parameters:
  • ham (operator or (1d-array, 2d-array)) – Hamiltonian, either full or tuple of (evals, evecs).

  • beta (float) – Inverse temperature of state.

  • precomp_func (bool, optional) – If True, return a function that takes beta only and is closed over the solved hamiltonian.

Returns:

Density operator of thermal state, or function to generate such given a temperature.

Return type:

operator or callable

quimb.gen.states.computational_state(binary, **kwargs)[source]

Generate the qubit computational state with binary.

Parameters:

binary (sequence of 0s and 1s) – The binary of the computation state.

Examples

>>> computational_state('101'):
qarray([[0.+0.j],
        [0.+0.j],
        [0.+0.j],
        [0.+0.j],
        [0.+0.j],
        [1.+0.j],
        [0.+0.j],
        [0.+0.j]])
>>> qu.computational_state([0, 1], qtype='dop')
qarray([[0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
        [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j],
        [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
        [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]])

See also

MPS_computational_state, basic_vec

quimb.gen.states.neel_state(n, down_first=False, **kwargs)[source]

Construct Neel state for n spins, i.e. alternating up/down.

Parameters:
  • n (int) – Number of spins.

  • down_first (bool, optional) – Whether to start with ‘1’ or ‘0’ first.

  • kwargs – Supplied to qu called on state.

See also

computational_state, MPS_neel_state

quimb.gen.states.singlet_pairs(n, **kwargs)[source]

Construct fully dimerised spin chain.

I.e. bell_state('psi-') & bell_state('psi-') & ...

Parameters:
  • n (int) – Number of spins.

  • kwargs – Supplied to qu called on state.

Return type:

vector

quimb.gen.states.werner_state(p, **kwargs)[source]

Construct Werner State, i.e. fractional mix of identity with singlet.

Parameters:
  • p (float) – Singlet Fraction.

  • kwargs – Supplied to qu() called on state.

Return type:

qarray

quimb.gen.states.ghz_state(n, **kwargs)[source]

Construct GHZ state of n spins, i.e. equal superposition of all up and down.

Parameters:
  • n (int) – Number of spins.

  • kwargs – Supplied to qu called on state.

Return type:

vector

quimb.gen.states.w_state(n, **kwargs)[source]

Construct W-state: equal superposition of all single spin up states.

Parameters:
  • n (int) – Number of spins.

  • kwargs – Supplied to qu called on state.

Return type:

vector

quimb.gen.states.levi_civita(perm)[source]

Compute the generalised levi-civita coefficient for a permutation.

Parameters:

perm (sequence of int) – The permutation, a re-arrangement of range(n).

Returns:

Either -1, 0 or 1.

Return type:

int

quimb.gen.states.perm_state(ps)[source]

Construct the anti-symmetric state which is the +- sum of all tensored permutations of states ps.

Parameters:

ps (sequence of states) – The states to combine.

Returns:

The permutation state, dimension same as kron(*ps).

Return type:

vector or operator

Examples

A singlet is the perm_state of up and down.

>>> states = [up(), down()]
>>> pstate = perm_state(states)
>>> expec(pstate, singlet())
1.0
quimb.gen.states.graph_state_1d(n, cyclic=False, sparse=False)[source]

Graph State on a line.

Parameters:
  • n (int) – The number of spins.

  • cyclic (bool, optional) – Whether to use cyclic boundary conditions for the graph.

  • sparse (bool, optional) – Whether to return a sparse state.

Returns:

The 1d-graph state.

Return type:

vector