QNLP  v1.0
PyQNLPSimulator.GateOps Class Reference
Collaboration diagram for PyQNLPSimulator.GateOps:
Collaboration graph

Public Member Functions

def __init__ (self, simulator)
 
def createU (self, list vals)
 
def RX (self, theta)
 
def RY (self, theta)
 
def RZ (self, theta)
 
def RZPh (self, theta)
 
def RU (self, theta, U)
 

Data Fields

 gates
 
 X
 
 Y
 
 Z
 
 H
 
 I
 
 Xnp
 
 Ynp
 
 Znp
 
 Hnp
 
 Inp
 

Detailed Description

This class is primarily for experimenting with gate operations during algorithm development.
This wraps the underlying gate types from the given simulator, and also gives a numpy version.

THIS IS NOT TO BE USED FOR PERFORMANT/PRODUCTION CODE AND IS STRICTLY FOR DEV/TEST.

Definition at line 15 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

def PyQNLPSimulator.GateOps.__init__ (   self,
  simulator 
)

Definition at line 22 of file __init__.py.

22  def __init__(self, simulator):
23  self.gates= {
24  "X" : simulator.getGateX(),
25  "Y" : simulator.getGateX(),
26  "Z" : simulator.getGateX(),
27  "H" : simulator.getGateX(),
28  "I" : simulator.getGateX(),
29  "Xnp" : simulator.getGateX(),
30  "Xnp" : simulator.getGateX(),
31  "Xnp" : simulator.getGateX(),
32  "Xnp" : simulator.getGateX(),
33  }
34  self.X = simulator.getGateX()
35  self.Y = simulator.getGateY()
36  self.Z = simulator.getGateZ()
37  self.H = simulator.getGateH()
38  self.I = simulator.getGateI()
39 
40  self.Xnp = np.matrix(self.X.as_numpy())
41  self.Ynp = np.matrix(self.Y.as_numpy())
42  self.Znp = np.matrix(self.Z.as_numpy())
43  self.Hnp = np.matrix(self.H.as_numpy())
44  self.Inp = np.matrix(self.I.as_numpy())
45 

Member Function Documentation

◆ createU()

def PyQNLPSimulator.GateOps.createU (   self,
list  vals 
)

Definition at line 46 of file __init__.py.

46  def createU(self, vals : list):
47  return DCMatrix(vals)
48 

Referenced by PyQNLPSimulator.GateOps.RU().

Here is the caller graph for this function:

◆ RU()

def PyQNLPSimulator.GateOps.RU (   self,
  theta,
  U 
)

Definition at line 63 of file __init__.py.

63  def RU(self, theta, U):
64  res = None
65  if isinstance(U, list):
66  res = self.createU(U)
67  elif isinstance(U, DCMatrix):
68  res = U.as_numpy()
69  else:
70  raise TypeError("U is not an accepted type: should be list or DCMatrix")
71 
72  return np.matrix(expm(-0.5*1j*theta*res))
73 

References PyQNLPSimulator.GateOps.createU().

Here is the call graph for this function:

◆ RX()

def PyQNLPSimulator.GateOps.RX (   self,
  theta 
)

Definition at line 49 of file __init__.py.

49  def RX(self, theta):
50  return np.matrix(expm(-0.5*1j*theta*self.Xnp))
51 

References PyQNLPSimulator.GateOps.Xnp.

◆ RY()

def PyQNLPSimulator.GateOps.RY (   self,
  theta 
)

Definition at line 52 of file __init__.py.

52  def RY(self, theta):
53  return np.matrix(expm(-0.5*1j*theta*self.Ynp))
54 

References PyQNLPSimulator.GateOps.Ynp.

◆ RZ()

def PyQNLPSimulator.GateOps.RZ (   self,
  theta 
)

Definition at line 55 of file __init__.py.

55  def RZ(self, theta):
56  return np.matrix(expm(-0.5*1j*theta*self.Znp))
57 

References PyQNLPSimulator.GateOps.Znp.

◆ RZPh()

def PyQNLPSimulator.GateOps.RZPh (   self,
  theta 
)

Definition at line 58 of file __init__.py.

58  def RZPh(self, theta):
59  "RZ excluding global phase of exp(iTheta/2)"
60  #np.matrix(np.exp(0.5*1j*theta)*expm(-0.5*1j*theta*self.Znp)))
61  return np.matrix([[1.0,0.0], [0., np.exp(1j*theta)] ])
62 

Field Documentation

◆ gates

PyQNLPSimulator.GateOps.gates

Definition at line 23 of file __init__.py.

◆ H

PyQNLPSimulator.GateOps.H

Definition at line 37 of file __init__.py.

◆ Hnp

PyQNLPSimulator.GateOps.Hnp

Definition at line 43 of file __init__.py.

◆ I

PyQNLPSimulator.GateOps.I

Definition at line 38 of file __init__.py.

◆ Inp

PyQNLPSimulator.GateOps.Inp

Definition at line 44 of file __init__.py.

◆ X

PyQNLPSimulator.GateOps.X

Definition at line 34 of file __init__.py.

◆ Xnp

PyQNLPSimulator.GateOps.Xnp

Definition at line 40 of file __init__.py.

Referenced by PyQNLPSimulator.GateOps.RX().

◆ Y

PyQNLPSimulator.GateOps.Y

Definition at line 35 of file __init__.py.

◆ Ynp

PyQNLPSimulator.GateOps.Ynp

Definition at line 41 of file __init__.py.

Referenced by PyQNLPSimulator.GateOps.RY().

◆ Z

PyQNLPSimulator.GateOps.Z

Definition at line 36 of file __init__.py.

◆ Znp

PyQNLPSimulator.GateOps.Znp

Definition at line 42 of file __init__.py.

Referenced by PyQNLPSimulator.GateOps.RZ().


The documentation for this class was generated from the following file: