# createInitState¶

Graph.createInitState(initState)

Generate the initial state of the quantum walk.

Parameters: initState (array) – an $$n\times 2$$ array, containing the initial state of the quantum walker in the format [[j1,amp1],[j2,amp2],...]. : this creates a PETSc vector containing the initial state, accessed via the attribute Graph.ps0. petsc4py.PETSc.Vec()

Example

For a CTQW initially located in a superposition of nodes 1 and 2, e.g. $$\left|\psi(0)\right\rangle = \frac{1}{\sqrt{2}}\left|1\right\rangle - \frac{1}{\sqrt{2}} \left|2\right\rangle$$, the initial state would be created like so:

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