Thursday, December 24, 2009

Logically manipulating qubits in Cove

In Cove a collection of qubits is represented by an instance of IQuantumRegister. The logical manipulation of qubits in a register is largely inspired by Python's list manipulating, or slicing as it is called. There are a variety of ways these qubits can be logically manipulated, the following illustration demonstrates a few:


In the above the numbers represent the index is represented by numbers, just like you would with an array. The letters A - D represent specific qubits. So you can see the SliceTo(2) operation obtains indexes 0 to 2, resulting in qubits A, B, C. The SliceSubset() operation slices the current indexes to an arbitrary set. In this case the qubit at index 2 (C) will become the first one and the qubit at index 1 (A) will become the second qubit in the new slice.

It is important to point out that each of the slicing operation returns a new instance of IQuantumRegister. This means that the slices can be independently manipulated. That being said, they all share the same qubits: so the manipulation of one slice may impact another. As an example if we perform a Not operation on qubit A, it will be Not'ed in every slice.

This allows for easy applications of operations. Take a CNot (controlled not) operation for example, this is an operation on two qubits. So if we take the original register of 4 qubits and want to perform the operation on qubits A and D we can just do something like this:

MyRegister.SliceSubset(new int[] {0, 3}).OperationCNot();

The OperationCNot() will also return the slice after the operation is performed. So this example shows how operations can be chained together to manipulate the register, then discarded if needed- leaving MyRegister as the original 4 qubits after the above line of code is executed.

No comments:

Post a Comment