createInitState

Graph3P.createInitState(initState)

Generate the initial state of the quantum walk.

Parameters:initState (array) – an \(n\times 4\) array, containing the initial state of the quantum walker in the format [[x1,y1,z1,amp1],[x2,y2,z2,amp2],...].
Returns:: this creates a PETSc vector containing the initial state, accessed via the attribute Graph3P.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 \otimes\left|5\right\rangle - \frac{i}{\sqrt{2}} \left|1\right\rangle\otimes\left|0\right\rangle \otimes\left|2\right\rangle\), the initial state would be created like so:

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

Fortran interface

This function calls the Fortran function p3_init().