BasicMathGate
Extends:
Direct Subclass:
Base class for all math gates.
It allows efficient emulation by providing a mathematical representation which is given by the concrete gate which derives from this base class. The AddConstant gate, for example, registers a function of the form
Example:
function add(x)
return (x+a,)
upon initialization. More generally, the function takes integers as
parameters and returns a tuple / list of outputs, each entry corresponding
to the function input. As an example, consider out-of-place
multiplication, which takes two input registers and adds the result into a
third, i.e., (a,b,c) -> (a,b,c+a*b). The corresponding function then is
    
function multiply(a,b,c)
return (a,b,c+a*b)
    Constructor Summary
| Public Constructor | ||
| public | 
       constructor(mathFunc: function)  | 
    |
Member Summary
| Public Members | ||
| public | 
       mathFunc: *  | 
    |
Method Summary
| Public Methods | ||
| public | 
       getMathFunction(qubits: Array<Qureg>): function Return the math function which corresponds to the action of this math gate, given the input to the gate (a tuple of quantum registers).  | 
    |
| public | 
      
       | 
    |
Inherited Summary
| From class BasicGate | ||
| public static | 
      
       Convert quantum input of "gate | quantum input" to internal formatting.  | 
    |
| public | 
      
       | 
    |
| public | 
      
       | 
    |
| public | 
      
       | 
    |
| public | 
       generateCommand(qubits: *): Command Helper function to generate a command consisting of the gate and the qubits being acted upon.  | 
    |
| public | 
      
       | 
    |
| public | 
      
       | 
    |
| public | 
      
       | 
    |
| public | 
       or(qubits: *) Operator| overload which enables the syntax Gate | qubits.  | 
    |
| public | 
       toString()  | 
    |
Public Constructors
public constructor(mathFunc: function) source
Override:
BasicGate#constructorParams:
| Name | Type | Attribute | Description | 
| mathFunc | function | Function which takes as many int values as input, as the gate takes registers. For each of these values, it then returns the output (i.e., it returns a list/tuple of output values).  | 
    
Example:
function add(a,b)
return (a,a+b)
BasicMathGate.__init__(self, add)
If the gate acts on, e.g., fixed point numbers, the number of bits per
register is also required in order to describe the action of such a
mathematical gate. For this reason, there is
    
BasicMathGate.get_math_function(qubits)
which can be overwritten by the gate deriving from BasicMathGate.
    
function get_math_function(self, qubits)
n = len(qubits[0])
scal = 2.**n
function math_fun(a)
return (int(scal * (math.sin(math.pi * a / scal))),)
return math_fun
    Public Members
public mathFunc: * source
Public Methods
public getMathFunction(qubits: Array<Qureg>): function source
Return the math function which corresponds to the action of this math gate, given the input to the gate (a tuple of quantum registers).
Return:
| function | javascript function describing the action of this gate. (See BasicMathGate.constructor for an example).  |