createInitState

Graph2P.createInitState(initState)

Generate the initial state of the quantum walk.

Parameters:initState (array) – an \(n\times 3\) array, containing the initial state of the quantum walker in the format [[x1,y1,amp1],[x2,y2,amp2],...].
Returns:: this creates a PETSc vector containing the initial state, accessed via the attribute Graph2P.ps0.
Return type:petsc4py.PETSc.Vec()

Example

For a CTQW initially located in state \(\left|\psi(0)\right\rangle = \frac{1}{\sqrt{2}}\left|0\right\rangle\otimes\left|1\right\rangle - \frac{1}{\sqrt{2}} \left|1\right\rangle\otimes\left|0\right\rangle\), the initial state would be created like so:

>>> import numpy as np
>>> init_state = [[0,1,1./np.sqrt(2.)], [1,0,-1./np.sqrt(2.)]]
>>> walk.createInitState(init_state)

Fortran interface

This function calls the Fortran function p2_init().