createInitState

Line.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],...].
Returns:: this creates a PETSc vector containing the initial state, accessed via the attribute Line.psi0.
Return type:petsc4py.PETSc.Vec()

Example

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

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

Fortran interface

This function calls the Fortran function p1_init().