edu.buffalo.fs7.mathlib
Class Gate

java.lang.Object
  |
  +--edu.buffalo.fs7.mathlib.MathObject
        |
        +--edu.buffalo.fs7.mathlib.Argument
              |
              +--edu.buffalo.fs7.mathlib.Gate
All Implemented Interfaces:
java.lang.Cloneable

public class Gate
extends Argument

Class representing a quantum gate. Since it is not feasable to save gates as unitary matrices and usually a gate only affects a small number of qubits, it is useful to introduce a more abstract description of a model. The syntax is the following:

{-:-:1:NOT:-} - this would represent a controlled NOT gate operating on the 4th of 5 qubits and beeing controlled by the 3rd. The NOT entry can be replaced by any other unitary (2x2) matrix.

The object specifying the matrix can be a variable, a MathMap producing a matrix or a matrix definition.

For higher dimensional gates the notation is as follows:

{1:-:U:U} this represents a controlled U gate operating on the 3rd and 4th qubit of 4 qubits, it is controlled by the first qubit.

See Also:
BinaryOp, Braket

Field Summary
protected  boolean conjugate
           
 java.lang.String gate_descr
          holds the description of the gate in string form
 int matrixDimension
          holds the matrix dimension
 java.lang.String matrixName
          holds the matrix name
 int n
          holds the number of qubits
protected  boolean negative
           
protected  boolean transpose
           
 
Fields inherited from class edu.buffalo.fs7.mathlib.MathObject
mathlib
 
Constructor Summary
Gate(int n)
          here n is the number of qubits ==> the dimension of the corresponding matrix is 2^n.
Gate(int n, int matrixPos, java.lang.String matrixName)
          creates a gate for n qubits having a 2x2 matrix matrixName operating at position matrixPos
Gate(MathObject o)
          clone constructor
Gate(java.lang.String gate_descr, java.lang.String matrixName)
          creates a gate for a given gate_descr string and matrix name
 
Method Summary
 java.lang.Object clone()
          clone method
 void conjugate()
          complex conjugates the gate
 boolean equals(MathObject m1)
          equality predicate
 Matrix getMatrix()
          returns the matrix applied to the subspace
 void negative()
          negates the gate
static Gate parseGate(java.lang.String str)
          parses a gate from a given string.
 java.lang.String toString()
          return string representation of the gate
 void transpose()
          transposes the gate
 
Methods inherited from class edu.buffalo.fs7.mathlib.MathObject
toParseableString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

gate_descr

public java.lang.String gate_descr
holds the description of the gate in string form

matrixDimension

public int matrixDimension
holds the matrix dimension

matrixName

public java.lang.String matrixName
holds the matrix name

transpose

protected boolean transpose

conjugate

protected boolean conjugate

negative

protected boolean negative

n

public int n
holds the number of qubits
Constructor Detail

Gate

public Gate(int n)
here n is the number of qubits ==> the dimension of the corresponding matrix is 2^n. This constructor simply generates a gate with is unity.

Gate

public Gate(MathObject o)
clone constructor

Gate

public Gate(java.lang.String gate_descr,
            java.lang.String matrixName)
creates a gate for a given gate_descr string and matrix name

Gate

public Gate(int n,
            int matrixPos,
            java.lang.String matrixName)
creates a gate for n qubits having a 2x2 matrix matrixName operating at position matrixPos
Method Detail

clone

public java.lang.Object clone()
clone method
Overrides:
clone in class MathObject

parseGate

public static Gate parseGate(java.lang.String str)
                      throws java.lang.IllegalArgumentException
parses a gate from a given string. Throws an IllegalArgumentException when the operation fails.

transpose

public void transpose()
transposes the gate

conjugate

public void conjugate()
complex conjugates the gate

negative

public void negative()
negates the gate

getMatrix

public Matrix getMatrix()
returns the matrix applied to the subspace

equals

public boolean equals(MathObject m1)
equality predicate
Overrides:
equals in class Argument

toString

public java.lang.String toString()
return string representation of the gate
Overrides:
toString in class MathObject
Following copied from class: edu.buffalo.fs7.mathlib.MathObject
See Also:
MathObject.toParseableString()