quimb.gen.states ================ .. py:module:: quimb.gen.states .. autoapi-nested-parse:: Functions for generating quantum states. Attributes ---------- .. autoapisummary:: quimb.gen.states.zplus quimb.gen.states.zminus quimb.gen.states.xplus quimb.gen.states.xminus Functions --------- .. autoapisummary:: quimb.gen.states.basis_vec quimb.gen.states.up quimb.gen.states.down quimb.gen.states.plus quimb.gen.states.minus quimb.gen.states.yplus quimb.gen.states.yminus quimb.gen.states.bloch_state quimb.gen.states.bell_state quimb.gen.states.singlet quimb.gen.states.thermal_state quimb.gen.states.computational_state quimb.gen.states.neel_state quimb.gen.states.singlet_pairs quimb.gen.states.werner_state quimb.gen.states.ghz_state quimb.gen.states.w_state quimb.gen.states.levi_civita quimb.gen.states.perm_state quimb.gen.states.graph_state_1d Module Contents --------------- .. py:function:: basis_vec(i, dim, ownership=None, **kwargs) Constructs a unit vector ket: .. math:: |i\rangle = \begin{pmatrix} 0 \\ \vdots \\ 1 \\ \vdots \\ 0 \end{pmatrix} :param i: Which index should the single non-zero, unit entry. :type i: int :param dim: Total size of hilbert space. :type dim: int :param sparse: Return vector as sparse matrix. :type sparse: bool, optional :param kwargs: Supplied to ``qu``. :returns: The basis vector. :rtype: vector .. py:function:: up(**kwargs) Returns up-state, aka. ``|0>``, +Z eigenstate: .. math:: |0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix} .. py:data:: zplus .. py:function:: down(**kwargs) Returns down-state, aka. ``|1>``, -Z eigenstate: .. math:: |1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix} .. py:data:: zminus .. py:function:: plus(**kwargs) Returns plus-state, aka. ``|+>``, +X eigenstate: .. math:: |+\rangle = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ 1 \end{pmatrix} .. py:data:: xplus .. py:function:: minus(**kwargs) Returns minus-state, aka. ``|->``, -X eigenstate: .. math:: |-\rangle = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ -1 \end{pmatrix} .. py:data:: xminus .. py:function:: yplus(**kwargs) Returns yplus-state, aka. ``|y+>``, +Y eigenstate: .. math:: |y+\rangle = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ i \end{pmatrix} .. py:function:: yminus(**kwargs) Returns yplus-state, aka. ``|y->``, -Y eigenstate: .. math:: |y-\rangle = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ -i \end{pmatrix} .. py:function:: bloch_state(ax, ay, az, purified=False, **kwargs) Construct qubit density operator from bloch vector: .. math:: \rho = \frac{1}{2} \left( I + a_x X + a_y Y + a_z Z \right) :param ax: X component of bloch vector. :type ax: float :param ay: Y component of bloch vector. :type ay: float :param az: Z component of bloch vector. :type az: float :param purified: Whether to map vector to surface of bloch sphere. :returns: Density operator of qubit 'pointing' in (ax, ay, az) direction. :rtype: Matrix .. py:function:: bell_state(s, **kwargs) One of the four bell-states. If n = 2**-0.5, they are: 0. ``'psi-'`` : ``n * ( |01> - |10> )`` 1. ``'psi+'`` : ``n * ( |01> + |10> )`` 2. ``'phi-'`` : ``n * ( |00> - |11> )`` 3. ``'phi+'`` : ``n * ( |00> + |11> )`` They can be enumerated in this order. :param s: String of number of state corresponding to above. :type s: str or int :param kwargs: Supplied to ``qu`` called on state. :returns: **p** -- The bell-state ``s``. :rtype: immutable vector .. py:function:: singlet(**kwargs) Alias for the 'psi-' bell-state. .. py:function:: thermal_state(ham, beta, precomp_func=False) Generate a thermal state of a Hamiltonian. :param ham: Hamiltonian, either full or tuple of (evals, evecs). :type ham: operator or (1d-array, 2d-array) :param beta: Inverse temperature of state. :type beta: float :param precomp_func: If True, return a function that takes ``beta`` only and is closed over the solved hamiltonian. :type precomp_func: bool, optional :returns: Density operator of thermal state, or function to generate such given a temperature. :rtype: operator or callable .. py:function:: computational_state(binary, **kwargs) Generate the qubit computational state with ``binary``. :param binary: The binary of the computation state. :type binary: sequence of 0s and 1s .. rubric:: 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]]) .. seealso:: :obj:`MPS_computational_state`, :obj:`basic_vec` .. py:function:: neel_state(n, down_first=False, **kwargs) Construct Neel state for n spins, i.e. alternating up/down. :param n: Number of spins. :type n: int :param down_first: Whether to start with '1' or '0' first. :type down_first: bool, optional :param kwargs: Supplied to ``qu`` called on state. .. seealso:: :obj:`computational_state`, :obj:`MPS_neel_state` .. py:function:: singlet_pairs(n, **kwargs) Construct fully dimerised spin chain. I.e. ``bell_state('psi-') & bell_state('psi-') & ...`` :param n: Number of spins. :type n: int :param kwargs: Supplied to ``qu`` called on state. :rtype: vector .. py:function:: werner_state(p, **kwargs) Construct Werner State, i.e. fractional mix of identity with singlet. :param p: Singlet Fraction. :type p: float :param kwargs: Supplied to :func:`~quimb.qu` called on state. :rtype: qarray .. py:function:: ghz_state(n, **kwargs) Construct GHZ state of `n` spins, i.e. equal superposition of all up and down. :param n: Number of spins. :type n: int :param kwargs: Supplied to ``qu`` called on state. :rtype: vector .. py:function:: w_state(n, **kwargs) Construct W-state: equal superposition of all single spin up states. :param n: Number of spins. :type n: int :param kwargs: Supplied to ``qu`` called on state. :rtype: vector .. py:function:: levi_civita(perm) Compute the generalised levi-civita coefficient for a permutation. :param perm: The permutation, a re-arrangement of ``range(n)``. :type perm: sequence of int :returns: Either -1, 0 or 1. :rtype: int .. py:function:: perm_state(ps) Construct the anti-symmetric state which is the +- sum of all tensored permutations of states ``ps``. :param ps: The states to combine. :type ps: sequence of states :returns: The permutation state, dimension same as ``kron(*ps)``. :rtype: vector or operator .. rubric:: Examples A singlet is the ``perm_state`` of up and down. >>> states = [up(), down()] >>> pstate = perm_state(states) >>> expec(pstate, singlet()) 1.0 .. py:function:: graph_state_1d(n, cyclic=False, sparse=False) Graph State on a line. :param n: The number of spins. :type n: int :param cyclic: Whether to use cyclic boundary conditions for the graph. :type cyclic: bool, optional :param sparse: Whether to return a sparse state. :type sparse: bool, optional :returns: The 1d-graph state. :rtype: vector