Ejemplo n.º 1
0
 def __init__(self, operation, *, part=None, styles=None):
     '''
     Create a quantum circuit gate performing the given operation.
     '''
     if part is None:
         operands = NamedExprs(("operation", operation))
     else:
         operands = NamedExprs(("operation", operation), ("part", part))
     QcircuitElement.__init__(self,
                              Gate._operator_,
                              operands,
                              styles=styles)
Ejemplo n.º 2
0
 def __init__(self, basis, *, part=None, styles=None):
     '''
     Create an OUTPUT operation with the given input state.
     '''
     if part is None:
         operands = NamedExprs(("basis", basis))
     else:
         operands = NamedExprs(("basis", basis), ("part", part))
     QcircuitElement.__init__(self,
                              Measure._operator_,
                              operands,
                              styles=styles)
Ejemplo n.º 3
0
 def __init__(self, state, *, part=None, styles=None):
     '''
     Create an OUTPUT operation with the given input state.
     '''
     if part is None:
         operands = NamedExprs(("state", state))
     else:
         operands = NamedExprs(("state", state), ("part", part))
     QcircuitElement.__init__(self,
                              Output._operator_,
                              operands,
                              styles=styles)
Ejemplo n.º 4
0
 def __init__(self, state, *, part=None, styles=None):
     '''
     Create an INPUT operation (for entering the left-hand side
     of a circuit) with the given input state.
     '''
     if part is None:
         operands = NamedExprs(("state", state))
     else:
         operands = NamedExprs(("state", state), ("part", part))
     QcircuitElement.__init__(self,
                              Input._operator_,
                              operands,
                              styles=styles)
 def __init__(self, lambda_fn, operand):
     Operation.__init__(
         self, LambdaApplication._operator_,
         NamedExprs([('lambda_fn', lambda_fn), ('operand', operand)]))
     # The Lambda function operand
     self.lambda_fn = self.operands['lambda_fn']
     # The operand of the Lambda function
     self.lambda_operand = self.operands['operand']
Ejemplo n.º 6
0
 def __init__(self, lambda_fn, operand, *, styles=None):
     Operation.__init__(self,
                        LambdaApplication._operator_,
                        NamedExprs(('lambda_fn', lambda_fn),
                                   ('operand', operand)),
                        styles=styles)
     # The operand of the Lambda function
     self.lambda_operand = self.operands['operand']
Ejemplo n.º 7
0
 def __init__(self, field, rows, columns, *, styles=None):
     '''
     Create F^{m x n} as the MatrixSpace for field F with
     
     '''
     Operation.__init__(self, MatrixSpace._operator_,
                        NamedExprs(('field', field), 
                                   ('rows', rows),
                                   ('columns', columns)), 
                        styles=styles)
Ejemplo n.º 8
0
 def __init__(self, element, targets, *, styles=None):
     '''
     Create a quantum circuit gate for the given "element" acting
     on the given "targets".
     '''
     QcircuitElement.__init__(self,
                              MultiQubitElem._operator_,
                              NamedExprs(("element", element),
                                         ("targets", targets)),
                              styles=styles)